diff --git a/.gitea/workflows/build-plugin.yml b/.gitea/workflows/build-plugin.yml index b35b691..d8cfbd5 100644 --- a/.gitea/workflows/build-plugin.yml +++ b/.gitea/workflows/build-plugin.yml @@ -13,18 +13,20 @@ concurrency: cancel-in-progress: false jobs: - prepare-release: + build-and-release: runs-on: docker-builder - outputs: - version: ${{ steps.version.outputs.version }} - tag: ${{ steps.version.outputs.tag }} - release_id: ${{ steps.release.outputs.release_id }} steps: - name: Checkout repository and tags uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Set up Java 25 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '25' + - name: Calculate next version id: version shell: bash @@ -44,134 +46,36 @@ jobs: echo "version=$version" >> "$GITHUB_OUTPUT" echo "tag=v$version" >> "$GITHUB_OUTPUT" - - name: Create Gitea release - id: release + - name: Build plugin and run crypto test + shell: bash + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + set -euo pipefail + chmod +x ./gradlew + ./gradlew --no-daemon clean build -PbuildVersion="$VERSION" + + - name: Create Gitea release and upload plugin + shell: bash env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_SERVER_URL: ${{ gitea.server_url }} GITEA_REPOSITORY: ${{ gitea.repository }} VERSION: ${{ steps.version.outputs.version }} TAG: ${{ steps.version.outputs.tag }} - shell: bash run: | set -euo pipefail if [[ -z "$GITEA_TOKEN" ]]; then echo "Add a repository write token as the GITEA_TOKEN secret." exit 1 fi + jar="build/libs/AsminVoiceChat-${VERSION}.jar" api="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY" release="$(curl --fail-with-body -sS -X POST "$api/releases" \ -H "Authorization: token $GITEA_TOKEN" \ -H 'Content-Type: application/json' \ - -d "{\"tag_name\":\"$TAG\",\"name\":\"AsminVoiceChat $VERSION\",\"body\":\"Dual-protocol Simple Voice Chat server release.\",\"draft\":false,\"prerelease\":false}")" + -d "{\"tag_name\":\"$TAG\",\"name\":\"AsminVoiceChat $VERSION\",\"body\":\"AsminVoiceChat $VERSION\",\"draft\":false,\"prerelease\":false}")" release_id="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])' <<< "$release")" - echo "release_id=$release_id" >> "$GITHUB_OUTPUT" - - build-and-test: - needs: prepare-release - runs-on: docker-builder - strategy: - fail-fast: false - matrix: - java: - - '16' - - '17' - - '18' - - '19' - - '20' - - '21' - - '22' - - '23' - - '24' - - '25' - - '26' - - '27-ea' - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Java ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: ${{ matrix.java }} - - - name: Download 2.6.25 base and compile dependencies - shell: bash - run: | - set -euo pipefail - mkdir -p build/deps build/classes build/test-classes - hangar="https://hangarcdn.papermc.io/plugins/henkelmax/SimpleVoiceChat/versions/bukkit-2.6.25/PAPER/voicechat-bukkit-2.6.25.jar" - curl --fail --location --silent --show-error "$hangar" -o build/deps/voicechat-bukkit-2.6.25.jar - - repo="https://repo.papermc.io/repository/maven-public" - curl --fail --location --silent --show-error "$repo/io/papermc/paper/paper-api/1.17.1-R0.1-SNAPSHOT/paper-api-1.17.1-R0.1-20220414.034903-311.jar" -o build/deps/paper-api.jar - curl --fail --location --silent --show-error "$repo/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4.jar" -o build/deps/bungeecord-chat.jar - curl --fail --location --silent --show-error "$repo/net/kyori/adventure-api/4.9.3/adventure-api-4.9.3.jar" -o build/deps/adventure-api.jar - curl --fail --location --silent --show-error "$repo/net/kyori/adventure-key/4.9.3/adventure-key-4.9.3.jar" -o build/deps/adventure-key.jar - curl --fail --location --silent --show-error "$repo/net/kyori/examination-api/1.3.0/examination-api-1.3.0.jar" -o build/deps/examination-api.jar - curl --fail --location --silent --show-error "$repo/net/kyori/examination-string/1.3.0/examination-string-1.3.0.jar" -o build/deps/examination-string.jar - curl --fail --location --silent --show-error "$repo/org/jetbrains/annotations/22.0.0/annotations-22.0.0.jar" -o build/deps/annotations.jar - curl --fail --location --silent --show-error "$repo/io/netty/netty-buffer/4.1.63.Final/netty-buffer-4.1.63.Final.jar" -o build/deps/netty-buffer.jar - curl --fail --location --silent --show-error "$repo/io/netty/netty-common/4.1.63.Final/netty-common-4.1.63.Final.jar" -o build/deps/netty-common.jar - - - name: Compile Java 8-compatible patch classes - env: - VERSION: ${{ needs.prepare-release.outputs.version }} - shell: bash - run: | - set -euo pipefail - cp="build/deps/voicechat-bukkit-2.6.25.jar:$(printf '%s:' build/deps/*.jar)" - javac --release 8 -cp "$cp" -d build/classes \ - source/patch/de/maxhenkel/voicechat/voice/common/Secret.java \ - source/patch/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java - - sed "s/^version:.*/version: '$VERSION'/" plugin.yml > build/plugin.yml - python3 - <<'PY' - from pathlib import Path - from zipfile import ZIP_DEFLATED, ZipFile - - base = Path("build/deps/voicechat-bukkit-2.6.25.jar") - target = Path("build/AsminVoiceChat-${{ needs.prepare-release.outputs.version }}.jar") - replacements = { - "de/maxhenkel/voicechat/voice/common/Secret.class": Path("build/classes/de/maxhenkel/voicechat/voice/common/Secret.class"), - "de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.class": Path("build/classes/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.class"), - "plugin.yml": Path("build/plugin.yml"), - } - with ZipFile(base) as source, ZipFile(target, "w", ZIP_DEFLATED) as output: - for item in source.infolist(): - replacement = replacements.get(item.filename) - output.writestr(item, replacement.read_bytes() if replacement else source.read(item.filename)) - print(f"Built {target}") - PY - - - name: Run CBC/GCM interoperability test - shell: bash - run: | - set -euo pipefail - cp="build/AsminVoiceChat-${{ needs.prepare-release.outputs.version }}.jar:build/deps/netty-buffer.jar:build/deps/netty-common.jar" - javac --release 8 -cp "$cp" -d build/test-classes tests/ProtocolCryptoSelfTest.java - java -cp "build/test-classes:$cp" ProtocolCryptoSelfTest - - - name: Upload JVM-specific build to release - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - GITEA_SERVER_URL: ${{ gitea.server_url }} - GITEA_REPOSITORY: ${{ gitea.repository }} - RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }} - VERSION: ${{ needs.prepare-release.outputs.version }} - JAVA_VERSION: ${{ matrix.java }} - shell: bash - run: | - set -euo pipefail - api="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY" - file="build/AsminVoiceChat-${VERSION}.jar" - asset="AsminVoiceChat-${VERSION}-Java${JAVA_VERSION}.jar" - curl --fail-with-body -sS -X POST "$api/releases/$RELEASE_ID/assets?name=$asset" \ + curl --fail-with-body -sS -X POST "$api/releases/$release_id/assets?name=AsminVoiceChat-${VERSION}.jar" \ -H "Authorization: token $GITEA_TOKEN" \ - -F "attachment=@$file;filename=$asset" - if [[ "$JAVA_VERSION" == "21" ]]; then - curl --fail-with-body -sS -X POST "$api/releases/$RELEASE_ID/assets?name=AsminVoiceChat-${VERSION}.jar" \ - -H "Authorization: token $GITEA_TOKEN" \ - -F "attachment=@$file;filename=AsminVoiceChat-${VERSION}.jar" - fi + -F "attachment=@$jar;filename=AsminVoiceChat-${VERSION}.jar" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..394a356 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.gradle/ +build/ +*.class +*.log diff --git a/AsminVoiceChat-1.0.0.jar b/AsminVoiceChat-1.0.0.jar index 50ad356..a3971f9 100644 Binary files a/AsminVoiceChat-1.0.0.jar and b/AsminVoiceChat-1.0.0.jar differ diff --git a/LICENSE-upstream.txt b/LICENSE-upstream.txt new file mode 100644 index 0000000..302654d --- /dev/null +++ b/LICENSE-upstream.txt @@ -0,0 +1 @@ +Copyright (c) Max Henkel - All Rights Reserved diff --git a/README.md b/README.md index e2292e7..b1397f6 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Simple Voice Chat server fork based on 2.6.25. It accepts protocol compatibility 18 (2.5.x clients) and 20 (2.6.x clients) at the same time. Clients remain unmodified; each player still needs a mod release for their Minecraft version. +The plugin is compiled to Java 8 bytecode and runs on newer JVMs. ## Architecture @@ -12,8 +13,9 @@ uses AES-CBC for 2.5 clients and AES-GCM for 2.6 clients. Shared packet layouts are passed through the existing 2.6 voice routing. The fork changes only the per-client cipher selection and compatibility-version acceptance. -The full source is in `source/decompiled/`. The two changed classes are also -available separately in `source/patch/`. +The Bukkit plugin source and API source are in `source/bukkit/` and +`source/api/`. The cipher and compatibility changes are in the regular source +files for those modules. ## Goxy diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..c4162a4 --- /dev/null +++ b/build.gradle @@ -0,0 +1,160 @@ +import groovy.json.JsonSlurper + +plugins { + id 'java' + id 'com.gradleup.shadow' version '9.6.0' +} + +group = 'de.maxhenkel.voicechat' +version = findProperty('buildVersion') ?: '1.0.0' + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +repositories { + mavenCentral() + maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' } + maven { url = 'https://libraries.minecraft.net/' } + maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' } + maven { url = 'https://maven.maxhenkel.de/repository/public' } + maven { url = 'https://repo.viaversion.com/' } +} + +configurations { + shadow +} + +dependencies { + compileOnly 'org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT' + compileOnly 'com.google.code.findbugs:jsr305:3.0.2' + compileOnly 'me.clip:placeholderapi:2.12.2' + compileOnly 'com.viaversion:viaversion-bukkit:5.7.2' + compileOnly 'com.viaversion:viaversion-common:5.7.2' + + implementation 'io.netty:netty-all:4.1.132.Final' + + implementation 'org.json:json:20251224' + shadow 'org.json:json:20251224' + implementation 'me.lucko:commodore:2.2' + shadow 'me.lucko:commodore:2.2' + implementation 'org.concentus:Concentus:1.0.1' + shadow 'org.concentus:Concentus:1.0.1' + implementation 'de.maxhenkel.configbuilder:configbuilder:2.1.0' + shadow 'de.maxhenkel.configbuilder:configbuilder:2.1.0' +} + +sourceSets { + main { + java { + srcDirs = [ + 'source/api/src/main/java', + 'source/bukkit/src/main/java', + layout.buildDirectory.dir('generated/sources/java').get().asFile + ] + } + resources { + srcDirs = ['source/bukkit/src/main/resources'] + exclude 'plugin.yml' + } + } + test { + java { + srcDirs = ['tests'] + } + } +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' + options.release = 8 +} + +tasks.register('generateBuildConstants', Copy) { + from 'source/bukkit/src/template/java' + into layout.buildDirectory.dir('generated/sources/java') + expand compatibility_version: '20', + mod_compatible_version: '2.6.x', + target_bukkit_version: '1.8.8-R0.1-SNAPSHOT', + plugin_name: 'Simple Voice Chat' +} +compileJava.dependsOn tasks.named('generateBuildConstants') + +tasks.register('generateFallbackTranslations') { + def inputFile = file('source/common/src/main/resources/assets/voicechat/lang/en_us.json') + def outputFile = layout.buildDirectory.file('generated/sources/java/de/maxhenkel/voicechat/FallbackTranslations.java') + inputs.file inputFile + outputs.file outputFile + + doLast { + def translations = new JsonSlurper().parse(inputFile) + def output = new StringBuilder('''package de.maxhenkel.voicechat; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class FallbackTranslations { + public static final Map FALLBACK_TRANSLATIONS; + static { + Map translations = new HashMap<>(); +''') + translations.each { key, value -> + def k = key.toString().replace('\\', '\\\\').replace('\n', '\\n').replace('"', '\\"') + def v = value.toString().replace('\\', '\\\\').replace('\n', '\\n').replace('"', '\\"') + output.append(" translations.put(\"${k}\", \"${v}\");\n") + } + output.append(''' FALLBACK_TRANSLATIONS = Collections.unmodifiableMap(translations); + } +} +''') + outputFile.get().asFile.parentFile.mkdirs() + outputFile.get().asFile.text = output.toString() + } +} +compileJava.dependsOn tasks.named('generateFallbackTranslations') + +processResources { + from('plugin.yml') { + filter { String line -> + line.startsWith('version:') ? "version: '${project.version}'" : line + } + } +} + +tasks.named('jar') { + archiveClassifier = 'dev' +} + +shadowJar { + configurations = [project.configurations.shadow] + archiveClassifier = '' + archiveFileName = "AsminVoiceChat-${project.version}.jar" + from('LICENSE-upstream.txt') { + rename { 'LICENSE_SimpleVoiceChat' } + } + relocate 'org.json', 'de.maxhenkel.voicechat.org.json' + relocate 'me.lucko.commodore', 'de.maxhenkel.voicechat.commodore' + relocate 'org.concentus', 'de.maxhenkel.voicechat.concentus' + relocate 'de.maxhenkel.configbuilder', 'de.maxhenkel.voicechat.configbuilder' + dependencies { + exclude(dependency('com.mojang:brigadier:.*')) + exclude(dependency('com.google.code.findbugs:jsr305:.*')) + } +} + +tasks.named('build') { + dependsOn 'shadowJar' + dependsOn 'cryptoTest' +} + +tasks.register('cryptoTest', JavaExec) { + dependsOn tasks.named('testClasses') + classpath = sourceSets.test.runtimeClasspath + files(shadowJar.archiveFile) + mainClass = 'ProtocolCryptoSelfTest' +} + +tasks.withType(Test).configureEach { + failOnNoDiscoveredTests = false +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..07a952b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +org.gradle.jvmargs=-Xmx2G +org.gradle.daemon=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..b1b8ef5 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..df6a6ad --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,9 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip +networkTimeout=10000 +retries=0 +retryBackOffMs=500 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..b9bb139 --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..24c62d5 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,82 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +"%COMSPEC%" /c exit 1 + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel + +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..0beebd9 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,8 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { url = 'https://repo.papermc.io/repository/maven-public/' } + } +} + +rootProject.name = 'AsminVoicechat' diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/BukkitVoicechatService.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/BukkitVoicechatService.java new file mode 100644 index 0000000..9667d1f --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/BukkitVoicechatService.java @@ -0,0 +1,12 @@ +package de.maxhenkel.voicechat.api; + +public interface BukkitVoicechatService { + + /** + * Registers the voice chat plugin on bukkit based servers. + * + * @param plugin the voicechat plugin + */ + void registerPlugin(VoicechatPlugin plugin); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/ClientVoicechatSocket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/ClientVoicechatSocket.java new file mode 100644 index 0000000..7192210 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/ClientVoicechatSocket.java @@ -0,0 +1,21 @@ +package de.maxhenkel.voicechat.api; + +import java.net.SocketAddress; + +/** + * A socket used for client side voice chat traffic. + * Can be set using {@link de.maxhenkel.voicechat.api.events.ClientVoicechatInitializationEvent#setSocketImplementation(ClientVoicechatSocket)}. + */ +public interface ClientVoicechatSocket { + + void open() throws Exception; + + RawUdpPacket read() throws Exception; + + void send(byte[] data, SocketAddress address) throws Exception; + + void close(); + + boolean isClosed(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/Entity.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/Entity.java new file mode 100644 index 0000000..669cf42 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/Entity.java @@ -0,0 +1,22 @@ +package de.maxhenkel.voicechat.api; + +import java.util.UUID; + +public interface Entity { + + /** + * @return the UUID of the entity + */ + UUID getUuid(); + + /** + * @return the actual entity object + */ + Object getEntity(); + + /** + * @return the current position of the entity + */ + Position getPosition(); + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/api/ForgeVoicechatPlugin.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/ForgeVoicechatPlugin.java similarity index 67% rename from source/decompiled/de/maxhenkel/voicechat/api/ForgeVoicechatPlugin.java rename to source/api/src/main/java/de/maxhenkel/voicechat/api/ForgeVoicechatPlugin.java index 3c66d36..4ada9f6 100644 --- a/source/decompiled/de/maxhenkel/voicechat/api/ForgeVoicechatPlugin.java +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/ForgeVoicechatPlugin.java @@ -1,12 +1,8 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.api; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -@Retention(value=RetentionPolicy.RUNTIME) +@Retention(RetentionPolicy.RUNTIME) public @interface ForgeVoicechatPlugin { } - diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/Group.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/Group.java new file mode 100644 index 0000000..105e966 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/Group.java @@ -0,0 +1,115 @@ +package de.maxhenkel.voicechat.api; + +import javax.annotation.Nullable; +import java.util.UUID; + +/** + * Groups can be created using {@link VoicechatServerApi#groupBuilder()}. + */ +public interface Group { + + /** + * @return the visual name of the group + */ + String getName(); + + /** + * @return if the group has a password + */ + boolean hasPassword(); + + /** + * @return the ID of the group + */ + UUID getId(); + + /** + * @return if the group is persistent + */ + boolean isPersistent(); + + /** + * @return if the group is hidden in the group list UI + */ + boolean isHidden(); + + /** + * @return the group type + */ + Type getType(); + + public interface Type { + + /** + * Players in a group can hear nearby players that are not in a group + */ + public static final Type NORMAL = new Type() { + }; + + /** + * Players in a group can hear nearby players and nearby players can hear players in the group + */ + public static final Type OPEN = new Type() { + }; + + /** + * Players in a group can only hear other players in the group + */ + public static final Type ISOLATED = new Type() { + }; + } + + public interface Builder { + + /** + * Sets the ID of the group. + * If this is not set, the ID will be randomly generated. + *
+ * NOTE: If there is already a group with the same ID, the group will be overwritten. + * + * @param id the group ID or null if the ID should be randomly generated + * @return the builder + */ + Builder setId(@Nullable UUID id); + + /** + * NOTE: The name might be stripped of special characters and whitespace. + * + * @param name the name of the group + * @return the builder + */ + Builder setName(String name); + + /** + * @param password the group password + * @return the builder + */ + Builder setPassword(@Nullable String password); + + /** + * @param persistent if the group should be persistent + * @return the builder + */ + Builder setPersistent(boolean persistent); + + /** + * @param hidden if the group should be hidden in the group list UI + * @return the builder + */ + Builder setHidden(boolean hidden); + + /** + * @param type the group type + * @return the builder + */ + Builder setType(Type type); + + /** + * @return the built group + * @throws IllegalStateException if the name is not set or invalid + */ + Group build(); + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/Player.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/Player.java new file mode 100644 index 0000000..686fe2c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/Player.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api; + +public interface Player extends Entity { + + /** + * @return the actual player object + */ + Object getPlayer(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/Position.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/Position.java new file mode 100644 index 0000000..b59d6ea --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/Position.java @@ -0,0 +1,20 @@ +package de.maxhenkel.voicechat.api; + +public interface Position { + + /** + * @return the X position + */ + double getX(); + + /** + * @return the Y position + */ + double getY(); + + /** + * @return the Z position + */ + double getZ(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/RawUdpPacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/RawUdpPacket.java new file mode 100644 index 0000000..4866639 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/RawUdpPacket.java @@ -0,0 +1,13 @@ +package de.maxhenkel.voicechat.api; + +import java.net.SocketAddress; + +public interface RawUdpPacket { + + byte[] getData(); + + long getTimestamp(); + + SocketAddress getSocketAddress(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/ServerLevel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/ServerLevel.java new file mode 100644 index 0000000..6cf21f3 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/ServerLevel.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api; + +public interface ServerLevel { + + /** + * @return the actual level object + */ + Object getServerLevel(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/ServerPlayer.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/ServerPlayer.java new file mode 100644 index 0000000..d0ef08b --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/ServerPlayer.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api; + +public interface ServerPlayer extends Player { + + /** + * @return the level of the player + */ + ServerLevel getServerLevel(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatApi.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatApi.java new file mode 100644 index 0000000..9c17758 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatApi.java @@ -0,0 +1,116 @@ +package de.maxhenkel.voicechat.api; + +import de.maxhenkel.voicechat.api.audio.AudioConverter; +import de.maxhenkel.voicechat.api.mp3.Mp3Decoder; +import de.maxhenkel.voicechat.api.mp3.Mp3Encoder; +import de.maxhenkel.voicechat.api.opus.OpusDecoder; +import de.maxhenkel.voicechat.api.opus.OpusEncoder; +import de.maxhenkel.voicechat.api.opus.OpusEncoderMode; + +import javax.annotation.Nullable; +import javax.sound.sampled.AudioFormat; +import java.io.InputStream; +import java.io.OutputStream; + +public interface VoicechatApi { + + /** + * Creates a new opus encoder. + * Note that the encoder needs to be closed after you are finished using it. + */ + OpusEncoder createEncoder(); + + /** + * Creates a new opus encoder. + * Note that the encoder needs to be closed after you are finished using it. + * + * @param mode the opus encoder mode + * @return the opus encoder + */ + OpusEncoder createEncoder(OpusEncoderMode mode); + + /** + * Creates a new opus decoder. + * Note that the decoder needs to be closed after you are finished using it. + * + * @return the opus decoder + */ + OpusDecoder createDecoder(); + + /** + * NOTE: This is not available for Bukkit! It will always return null. + * + * @param audioFormat the audio format + * @param bitrate the bitrate in kbps + * @param quality the quality from 0 (highest) to 9 (lowest) + * @param outputStream the output stream to write the mp3 to + * @return the mp3 encoder or null if the encoder could not be initialized or is not available + */ + @Nullable + Mp3Encoder createMp3Encoder(AudioFormat audioFormat, int bitrate, int quality, OutputStream outputStream); + + /** + * NOTE: This is not available for Bukkit! It will always return null. + * + * @param inputStream the input stream to read the mp3 from + * @return the mp3 decoder or null if the decoder could not be initialized or is not available + */ + @Nullable + Mp3Decoder createMp3Decoder(InputStream inputStream); + + /** + * @return the audio converter + */ + AudioConverter getAudioConverter(); + + /** + * Creates an entity object from an actual entity. + * + * @param entity the entity implementation of your mod/plugin loader + * @return the entity object + */ + Entity fromEntity(Object entity); + + /** + * Creates a level object from an actual level. + * + * @param serverLevel the level implementation of your mod/plugin loader + * @return the level + */ + ServerLevel fromServerLevel(Object serverLevel); + + /** + * Creates a player object from an actual player. + * + * @param serverPlayer the player implementation of your mod/plugin loader + * @return the player + */ + ServerPlayer fromServerPlayer(Object serverPlayer); + + /** + * Creates a new position object. + * + * @param x the X position + * @param y the Y position + * @param z the Z position + * @return the position with the provided coordinates + */ + Position createPosition(double x, double y, double z); + + /** + * Don't forget to register your category with {@link VoicechatServerApi#registerVolumeCategory(VolumeCategory)} or {@link VoicechatClientApi#registerClientVolumeCategory(VolumeCategory)} + * + * @return a builder to build a category + */ + VolumeCategory.Builder volumeCategoryBuilder(); + + /** + * NOTE: Voice chat plugins can change this. + * This is only the default value. + * This value might not be correct if you are not connected to a server. + * + * @return the default distance, audio from voice chat is heard from + */ + double getVoiceChatDistance(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatClientApi.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatClientApi.java new file mode 100644 index 0000000..ba9f48a --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatClientApi.java @@ -0,0 +1,166 @@ +package de.maxhenkel.voicechat.api; + +import de.maxhenkel.voicechat.api.audiochannel.ClientEntityAudioChannel; +import de.maxhenkel.voicechat.api.audiochannel.ClientLocationalAudioChannel; +import de.maxhenkel.voicechat.api.audiochannel.ClientStaticAudioChannel; +import de.maxhenkel.voicechat.api.config.ConfigAccessor; +import de.maxhenkel.voicechat.api.config.VolumeConfigAccessor; + +import javax.annotation.Nullable; +import java.util.UUID; + +public interface VoicechatClientApi extends VoicechatApi { + + /** + * @return if the local voice chat is muted + */ + boolean isMuted(); + + /** + * Does the same as {@link #isDisabled(UUID)} with null as the player UUID. + * + * @return if the local voice chat is disabled + */ + default boolean isDisabled() { + return isDisabled(null); + } + + /** + * @param playerId the UUID of the player or null for the local player + * @return if the player with the provided UUID has the voice chat disabled + */ + boolean isDisabled(@Nullable UUID playerId); + + /** + * Does the same as {@link #isDisconnected(UUID)} with null as the player UUID. + * + * @return if the voice chat is disconnected from the server + */ + default boolean isDisconnected() { + return isDisconnected(null); + } + + /** + * @param playerId the UUID of the player or null for the local player + * @return if the player with the provided UUID is disconnected from voice chat + */ + boolean isDisconnected(@Nullable UUID playerId); + + /** + * Does the same as {@link #isTalking(UUID)} with null as the player UUID. + * + * @return if the local player is talking + */ + default boolean isTalking() { + return isTalking(null); + } + + /** + * @param playerId the UUID of the player or null for the local player + * @return if the player with the provided UUID is currently talking + */ + boolean isTalking(@Nullable UUID playerId); + + /** + * Does the same as {@link #isWhispering(UUID)} with null as the player UUID. + * + * @return if the local player is whispering + */ + default boolean isWhispering() { + return isWhispering(null); + } + + /** + * @param playerId the UUID of the player or null for the local player + * @return if the player with the provided UUID is currently whispering + */ + boolean isWhispering(@Nullable UUID playerId); + + /** + * This method returns if the push to talk key is pressed, even when using voice activation. + * + * @return if the push to talk key is pressed + */ + boolean isPushToTalkKeyPressed(); + + /** + * @return if the whisper key is pressed + */ + boolean isWhisperKeyPressed(); + + @Nullable + Group getGroup(); + + /** + * Creates a client side entity audio channel. + * + * @param uuid the UUID of the entity + * @return the audio channel + * @deprecated use {@link #createEntityAudioChannel(UUID, Entity)} + */ + @Deprecated + ClientEntityAudioChannel createEntityAudioChannel(UUID uuid); + + /** + * Creates a client side entity audio channel. + * + * @param uuid the ID of the channel + * @param entity the entity to attach the channel to + * @return the audio channel + */ + ClientEntityAudioChannel createEntityAudioChannel(UUID uuid, Entity entity); + + /** + * Creates a client side locational audio channel. + * + * @param uuid the ID of the channel + * @return the audio channel + */ + ClientLocationalAudioChannel createLocationalAudioChannel(UUID uuid, Position position); + + /** + * Creates a client side static audio channel. + * + * @param uuid the ID of the channel + * @return the audio channel + */ + ClientStaticAudioChannel createStaticAudioChannel(UUID uuid); + + /** + * Registers a volume category just for this client. + * A category can be created with {@link VoicechatApi#volumeCategoryBuilder()}. + * The category can be unregistered with {@link #unregisterClientVolumeCategory}. + * + * @param category the category to register + */ + void registerClientVolumeCategory(VolumeCategory category); + + /** + * Unregisters a category on this client. + * This will release the texture ID for the icon if one exists. + * + * @param category the category to remove + */ + default void unregisterClientVolumeCategory(VolumeCategory category) { + unregisterClientVolumeCategory(category.getId()); + } + + /** + * Unregisters a category on this client. + * This will release the texture ID for the icon if one exists. + * + * @param categoryId the category ID to remove + */ + void unregisterClientVolumeCategory(String categoryId); + + /** + * @return a read-only config accessor for the mods client config + */ + ConfigAccessor getClientConfig(); + + /** + * @return a read-only accessor for player and category volumes + */ + VolumeConfigAccessor getVolumeConfig(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatConnection.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatConnection.java new file mode 100644 index 0000000..241aa7c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatConnection.java @@ -0,0 +1,80 @@ +package de.maxhenkel.voicechat.api; + +import javax.annotation.Nullable; + +/** + * Note: It is not guaranteed that the state of this connection object is up to date. + * Please re-fetch the connection object to get the latest state. + */ +public interface VoicechatConnection { + + /** + * Note: This only returns the group the player was in when fetching this connection object. + * Calling {@link #setGroup(Group)} won't update the return value of this method. + * + * @return the group of the player - null if the player is not in a group + */ + @Nullable + Group getGroup(); + + /** + * Note: This only returns if the player was in a group when fetching this connection object. + * Calling {@link #setGroup(Group)} won't update the return value of this method. + * + * @return if the player is in a group + */ + boolean isInGroup(); + + /** + * Joins this player to the provided group. + * + * @param group the group to join or null to leave the current group + */ + void setGroup(@Nullable Group group); + + /** + * This might not represent the actual state of the voice chat connection, since other voice chat plugins can fake having a player connected. + *
+ * Note: This only returns if the player was connected fetching this connection object. + * Calling {@link #setConnected(boolean)} won't update the return value of this method. + * + * @return if the player is connected to voice chat + */ + boolean isConnected(); + + /** + * The players disconnected state will reset if its actual disconnected state changes or if the player reconnects. + *
+ * NOTE: This method will only work for players that don't have the mod installed. See {@link #isInstalled()}. + * + * @param connected if the player should be shown as connected to voice chat + */ + void setConnected(boolean connected); + + /** + * Note: This only returns if the player has the voice chat disabled when fetching this connection object. + * Calling {@link #setDisabled(boolean)} won't update the return value of this method. + * + * @return If the player muted the sound + */ + boolean isDisabled(); + + /** + * Sets the players disabled state. + * NOTE: This method will only work for players that don't have the mod installed. See {@link #isInstalled()}. + * + * @param disabled if the player should have the voice chat disabled icon + */ + void setDisabled(boolean disabled); + + /** + * @return if the player has a version of voice chat installed that is compatible with the server + */ + boolean isInstalled(); + + /** + * @return the player + */ + ServerPlayer getPlayer(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatPlugin.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatPlugin.java new file mode 100644 index 0000000..9dc77a8 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatPlugin.java @@ -0,0 +1,26 @@ +package de.maxhenkel.voicechat.api; + +import de.maxhenkel.voicechat.api.events.EventRegistration; + +public interface VoicechatPlugin { + + /** + * @return the ID of this plugin - Has to be unique + */ + String getPluginId(); + + /** + * Called after loading the plugin. + */ + default void initialize(VoicechatApi api) { + } + + /** + * Register your events here - Only here! + * + * @param registration the event registration object, used to register events + */ + default void registerEvents(EventRegistration registration) { + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatServerApi.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatServerApi.java new file mode 100644 index 0000000..02ddac4 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatServerApi.java @@ -0,0 +1,343 @@ +package de.maxhenkel.voicechat.api; + +import de.maxhenkel.voicechat.api.audiochannel.*; +import de.maxhenkel.voicechat.api.audiolistener.AudioListener; +import de.maxhenkel.voicechat.api.audiolistener.PlayerAudioListener; +import de.maxhenkel.voicechat.api.audiosender.AudioSender; +import de.maxhenkel.voicechat.api.config.ConfigAccessor; +import de.maxhenkel.voicechat.api.opus.OpusEncoder; +import de.maxhenkel.voicechat.api.packets.ConvertablePacket; +import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; +import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; +import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; + +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.UUID; +import java.util.function.Predicate; +import java.util.function.Supplier; + +public interface VoicechatServerApi extends VoicechatApi { + + /** + * Sends the sound packet to the provided connection. + * + * @param connection the connection to send the packet to + * @param packet the packet to send + */ + void sendEntitySoundPacketTo(VoicechatConnection connection, EntitySoundPacket packet); + + /** + * Sends the sound packet to the provided connection. + * + * @param connection the connection to send the packet to + * @param packet the packet to send + */ + void sendLocationalSoundPacketTo(VoicechatConnection connection, LocationalSoundPacket packet); + + /** + * Sends the sound packet to the provided connection. + * + * @param connection the connection to send the packet to + * @param packet the packet to send + */ + void sendStaticSoundPacketTo(VoicechatConnection connection, StaticSoundPacket packet); + + /** + * Creates a sound packet that can be converted to any type. + * NOTE: When creating a packet using this method, the sequence number must be set manually using {@link de.maxhenkel.voicechat.api.packets.SoundPacket.Builder#sequenceNumber(long)}. + * + * @return a convertable packet without any data + */ + ConvertablePacket createPacket(); + + /** + * Creates a sound channel for the specified entity. + * + * @param channelId the ID of the channel - Has to be unique + * @param entity the entity to attach the channel to + * @return the channel + */ + @Nullable + EntityAudioChannel createEntityAudioChannel(UUID channelId, Entity entity); + + /** + * Creates a sound channel at the provided location. + * + * @param channelId the ID of the channel - Has to be unique + * @param level the world + * @param initialPosition the position where the sound should be played + * @return the channel + */ + @Nullable + LocationalAudioChannel createLocationalAudioChannel(UUID channelId, ServerLevel level, Position initialPosition); + + /** + * Creates a static audio channel. + * + * @param channelId the ID of the channel - Has to be unique + * @param level the level + * @param connection the connection that should hear the audio + * @return the channel + * @deprecated use {@link #createStaticAudioChannel(UUID)} and add a target using {@link StaticAudioChannel#addTarget(VoicechatConnection)} + */ + @Deprecated + @Nullable + StaticAudioChannel createStaticAudioChannel(UUID channelId, ServerLevel level, VoicechatConnection connection); + + /** + * Creates a static audio channel. + * + * @param channelId the ID of the channel - Has to be unique + * @return the channel + */ + @Nullable + StaticAudioChannel createStaticAudioChannel(UUID channelId); + + /** + * Creates a new audio player. + *
+ *
+ * NOTE: Never use more than one audio player for every audio channel. + * + * @param audioChannel the channel where the audio player should send the audio to + * @param encoder the opus encoder used to encode the audio data + * @param audioSupplier this gets called whenever a new audio frame needs to be sent. The size of the array always needs to be 960. To end the playback, return null + * @return the audio player + */ + AudioPlayer createAudioPlayer(AudioChannel audioChannel, OpusEncoder encoder, Supplier audioSupplier); + + /** + * Creates a new audio player. + *
+ *
+ * NOTE: Never use more than one audio player for every audio channel. + * + * @param audioChannel the channel where the audio player should send the audio to + * @param encoder the opus encoder used to encode the audio data + * @param audio the audio data + * @return the audio player + */ + AudioPlayer createAudioPlayer(AudioChannel audioChannel, OpusEncoder encoder, short[] audio); + + /** + * Creates a new audio sender. + *
+ * This can be used to simulate a player sending microphone packets. + * This needs to be registered using {@link #registerAudioSender(AudioSender)} and unregistered using {@link #unregisterAudioSender(AudioSender)}. + * + * @param connection the connection of the player + * @return the audio sender + */ + AudioSender createAudioSender(VoicechatConnection connection); + + /** + * NOTE: Only one instance of this can exist per player. This will return false if an audio sender for this player already exists. + *
+ * NOTE: The audio sender will only work for players that are connected to the server and don't have the mod installed. Otherwise, it will return false. + * + * @param sender the sender to register + * @return if the sender was registered + */ + boolean registerAudioSender(AudioSender sender); + + /** + * Unregisters an audio sender. + * + * @param sender the sender to unregister + * @return false if the audio sender was not registered. + */ + boolean unregisterAudioSender(AudioSender sender); + + /** + * @return a {@link PlayerAudioListener} builder + */ + PlayerAudioListener.Builder playerAudioListenerBuilder(); + + /** + * Registers a new {@link AudioListener}. + *
+ * Returns false if the listener is already registered. + * + * @param listener the listener to register + * @return if the listener was registered + */ + boolean registerAudioListener(AudioListener listener); + + /** + * Unregisters an {@link AudioListener}. + *
+ * Returns false if the listener is already unregistered. + * + * @param listener the listener to unregister + * @return if the listener was unregistered + */ + boolean unregisterAudioListener(AudioListener listener); + + /** + * Unregisters an {@link AudioListener}. + *
+ * Returns false if the listener is already unregistered. + * + * @param listenerId the {@link AudioListener#getListenerId()} of the listener to unregister + * @return if the listener was unregistered + */ + boolean unregisterAudioListener(UUID listenerId); + + /** + * Gets the connection of the player with this UUID. + * + * @param playerUuid the players UUID + * @return the connection or null if the player is not connected + */ + @Nullable + VoicechatConnection getConnectionOf(UUID playerUuid); + + /** + * Gets the connection of the player. + * + * @param player the player + * @return the connection or null if the player is not connected + */ + @Nullable + default VoicechatConnection getConnectionOf(ServerPlayer player) { + return getConnectionOf(player.getUuid()); + } + + /** + * Creates a new group. + * + * @param name the name of the group + * @param password the password of the group - null for no password + * @return the group + * @deprecated use {@link #groupBuilder()} instead + */ + @Deprecated + Group createGroup(String name, @Nullable String password); + + /** + * Creates a new group. + * + * @param name the name of the group + * @param password the password of the group - null for no password + * @param persistent if the group should be persistent + * @return the group + * @deprecated use {@link #groupBuilder()} instead + */ + @Deprecated + Group createGroup(String name, @Nullable String password, boolean persistent); + + /** + * @return a new group builder + */ + Group.Builder groupBuilder(); + + /** + * Removes a persistent group. + * + * NOTE: You can't remove a group that is not persistent or has players in it. + * + * @param groupId the ID of the group + * @return if the group was removed + */ + boolean removeGroup(UUID groupId); + + /** + * Gets a group by its ID. + * + * @param groupId the ID of the group + * @return the group or null if the group doesn't exist + */ + @Nullable + Group getGroup(UUID groupId); + + /** + * @return all groups + */ + Collection getGroups(); + + /** + * Gets the secret for the user with this userId. + * Calling this function with a players UUID, that is already connected, this will return the secret of that player. + * Calling it with a new random UUID this will return a new secret. + * Use this with caution - Keep this secret confidential, as this allows connecting to the voice chat as this person. + * Note that if this userId is a players UUID and this player disconnects, the secret will get removed and thus is no longer valid to connect with. + * + * @param userId the user ID + * @return the secret or null if no server is running + * @deprecated this will just return null + */ + @Nullable + @Deprecated + UUID getSecret(UUID userId); + + /** + * A convenience method to get all players in the range of a specific location. + * + * @param level the world + * @param pos the location + * @param range the range + * @param filter the filter to exclude specific players + * @return all players in the provided location + */ + Collection getPlayersInRange(ServerLevel level, Position pos, double range, Predicate filter); + + /** + * The distance at which audio packets are broadcast. + * NOTE: This is not the distance it can be heard. + * + * @return the maximum distance, voice chat audio packets can be received + */ + double getBroadcastRange(); + + /** + * A convenience method to get all players in the range of a specific location. + * + * @param level the world + * @param pos the location + * @param range the range + * @return all players in the provided location + */ + default Collection getPlayersInRange(ServerLevel level, Position pos, double range) { + return getPlayersInRange(level, pos, range, null); + } + + /** + * Registers a volume category. + * This will get synchronized to all connected clients and all future clients that will connect. + * A category can be created with {@link VoicechatApi#volumeCategoryBuilder()}. + * The category can be unregistered with {@link #unregisterVolumeCategory}. + * + * @param category the category to register + */ + void registerVolumeCategory(VolumeCategory category); + + /** + * Unregisters a category for all connected players. + * This will release the texture ID for the icon if one exists on all clients. + * + * @param category the category to remove + */ + default void unregisterVolumeCategory(VolumeCategory category) { + unregisterVolumeCategory(category.getId()); + } + + /** + * Unregisters a category for all connected players. + * This will release the texture ID for the icon if one exists on all clients. + * + * @param categoryId the category ID to remove + */ + void unregisterVolumeCategory(String categoryId); + + /** + * @return all registered volume categories + */ + Collection getVolumeCategories(); + + /** + * @return a read-only config accessor for the mods server config + */ + ConfigAccessor getServerConfig(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatSocket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatSocket.java new file mode 100644 index 0000000..e14a003 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VoicechatSocket.java @@ -0,0 +1,23 @@ +package de.maxhenkel.voicechat.api; + +import java.net.SocketAddress; + +/** + * A socket used for server side voice chat traffic. + * Can be set using {@link de.maxhenkel.voicechat.api.events.VoicechatServerStartingEvent#setSocketImplementation(VoicechatSocket)}. + */ +public interface VoicechatSocket { + + void open(int port, String bindAddress) throws Exception; + + RawUdpPacket read() throws Exception; + + void send(byte[] data, SocketAddress address) throws Exception; + + int getLocalPort(); + + void close(); + + boolean isClosed(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/VolumeCategory.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/VolumeCategory.java new file mode 100644 index 0000000..9950149 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/VolumeCategory.java @@ -0,0 +1,97 @@ +package de.maxhenkel.voicechat.api; + +import javax.annotation.Nullable; + +/** + * A custom volume category for the "adjust volumes screen". + * Create it with {@link VoicechatApi#volumeCategoryBuilder()}. + * Register it with {@link VoicechatServerApi#registerVolumeCategory(VolumeCategory)} or {@link VoicechatClientApi#registerClientVolumeCategory(VolumeCategory)}. + * Unregister it with {@link VoicechatServerApi#unregisterVolumeCategory} or {@link VoicechatClientApi#unregisterClientVolumeCategory}. + */ +public interface VolumeCategory { + + /** + * @return the unique ID of the category + */ + String getId(); + + /** + * @return the full name of the category, that is displayed for the end user + */ + String getName(); + + /** + * @return the translation key for the full name of the category + */ + @Nullable + String getNameTranslationKey(); + + /** + * @return the hover tooltip that is shown for this category + */ + @Nullable + String getDescription(); + + /** + * @return the translation key for the hover tooltip of the category + */ + @Nullable + String getDescriptionTranslationKey(); + + /** + * @return the icon that is shown for this category + */ + @Nullable + int[][] getIcon(); + + public interface Builder { + + /** + * This ID has to be between 1 and 16 characters and can only contain lowercase a-z and _. + * + * @param id the unique ID of the category + * @return the builder + */ + Builder setId(String id); + + /** + * @param name the full name of the category, that is displayed for the end user if no translation is present + * @return the builder + */ + Builder setName(String name); + + /** + * @param translationKey the translation key for the full name of the category + * @return the builder + */ + Builder setNameTranslationKey(@Nullable String translationKey); + + /** + * @param description the hover tooltip that is shown for this category if no translation is present + * @return the builder + */ + Builder setDescription(@Nullable String description); + + /** + * @param translationKey the translation key for the hover tooltip + * @return the builder + */ + Builder setDescriptionTranslationKey(@Nullable String translationKey); + + /** + * The array has to be 16x16. + * Each integer represents a pixel in the RGBA format. + * + * @param icon the icon that is shown for this category + * @return the builder + */ + Builder setIcon(@Nullable int[][] icon); + + /** + * @return the built category + */ + VolumeCategory build(); + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audio/AudioConverter.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audio/AudioConverter.java new file mode 100644 index 0000000..df19afb --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audio/AudioConverter.java @@ -0,0 +1,27 @@ +package de.maxhenkel.voicechat.api.audio; + +import de.maxhenkel.voicechat.api.VoicechatApi; + +/** + * A utility class to convert audio between different representations. + *
+ * Can be obtained by calling {@link VoicechatApi#getAudioConverter()}. + *
+ *
+ * NOTE: Everything is assumed to be 16 bit PCM audio. + */ +public interface AudioConverter { + + short[] bytesToShorts(byte[] bytes); + + byte[] shortsToBytes(short[] shorts); + + short[] floatsToShorts(float[] floats); + + float[] shortsToFloats(short[] shorts); + + byte[] floatsToBytes(float[] floats); + + float[] bytesToFloats(byte[] bytes); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audio/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audio/package-info.java new file mode 100644 index 0000000..8379386 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audio/package-info.java @@ -0,0 +1,4 @@ +/** + * Everything related to audio conversion and manipulation. + */ +package de.maxhenkel.voicechat.api.audio; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/AudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/AudioChannel.java new file mode 100644 index 0000000..eaff8e0 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/AudioChannel.java @@ -0,0 +1,65 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import de.maxhenkel.voicechat.api.ServerPlayer; +import de.maxhenkel.voicechat.api.VolumeCategory; +import de.maxhenkel.voicechat.api.packets.MicrophonePacket; + +import javax.annotation.Nullable; +import java.util.UUID; +import java.util.function.Predicate; + +public interface AudioChannel { + + /** + * Sends the audio data to this audio channel. + * + * @param opusData Opus encoded audio data + */ + void send(byte[] opusData); + + /** + * Forwards the provided microphone packet to this audio channel. + * + * @param packet the microphone packet containing the audio data + */ + void send(MicrophonePacket packet); + + /** + * Applies a filter to the audio channel. + * + * @param filter only sends the data to players where the filter applies + */ + void setFilter(Predicate filter); + + /** + * Call this if you are finished sending data. + * You can still use this audio channel after calling this function, + * just don't call it after every packet, only after you are finished sending data. + */ + void flush(); + + /** + * @return if the audio channel is closed + */ + boolean isClosed(); + + /** + * @return the ID of the audio channel + */ + UUID getId(); + + /** + * @return the category ID of the audio channel + */ + @Nullable + String getCategory(); + + /** + * Make sure you registered your category before using it. + * See {@link de.maxhenkel.voicechat.api.VoicechatServerApi#registerVolumeCategory(VolumeCategory)}. + * + * @param category the category ID of the audio channel + */ + void setCategory(@Nullable String category); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/AudioPlayer.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/AudioPlayer.java new file mode 100644 index 0000000..bddaba0 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/AudioPlayer.java @@ -0,0 +1,39 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +/** + * Streams audio data from the server to clients. + * A player instance can be obtained by calling {@link de.maxhenkel.voicechat.api.VoicechatServerApi#createAudioPlayer}. + */ +public interface AudioPlayer { + + /** + * Starts playing/streaming the audio. + */ + void startPlaying(); + + /** + * Stops playing/streaming the audio. + */ + void stopPlaying(); + + /** + * @return if the player has been started + */ + boolean isStarted(); + + /** + * @return if the audio is still playing + */ + boolean isPlaying(); + + /** + * @return if the player stopped playing + */ + boolean isStopped(); + + /** + * @param onStopped a runnable that's called when the player is finished playing + */ + void setOnStopped(Runnable onStopped); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientAudioChannel.java new file mode 100644 index 0000000..bc2ca16 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientAudioChannel.java @@ -0,0 +1,38 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import de.maxhenkel.voicechat.api.VolumeCategory; + +import javax.annotation.Nullable; +import java.util.UUID; + +public interface ClientAudioChannel { + + /** + * @return the ID of the channel + */ + UUID getId(); + + /** + * Plays this audio data on this audio channel. + *
+ * Providing audio that's not 960 samples will be ignored. + * + * @param rawAudio the raw 16 bit PCM audio frame + */ + void play(short[] rawAudio); + + /** + * @return the category ID of the audio channel + */ + @Nullable + String getCategory(); + + /** + * Make sure you registered your category before using it. + * See {@link de.maxhenkel.voicechat.api.VoicechatServerApi#registerVolumeCategory(VolumeCategory)}. + * + * @param category the category of the audio channel + */ + void setCategory(@Nullable String category); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientEntityAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientEntityAudioChannel.java new file mode 100644 index 0000000..91b8878 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientEntityAudioChannel.java @@ -0,0 +1,32 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import java.util.UUID; + +public interface ClientEntityAudioChannel extends ClientAudioChannel { + + /** + * @return the UUID of the entity + */ + UUID getEntityId(); + + /** + * @param whispering if the entity should whisper + */ + void setWhispering(boolean whispering); + + /** + * @return if the entity is whispering + */ + boolean isWhispering(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + + /** + * @param distance the distance, the audio can be heard + */ + void setDistance(float distance); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientLocationalAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientLocationalAudioChannel.java new file mode 100644 index 0000000..f99ff20 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientLocationalAudioChannel.java @@ -0,0 +1,29 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import de.maxhenkel.voicechat.api.Position; + +public interface ClientLocationalAudioChannel extends ClientAudioChannel { + + /** + * @return the current location of the audio channel + */ + Position getLocation(); + + /** + * Updates the location of the audio channel. + * + * @param position the location of the audio channel + */ + void setLocation(Position position); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + + /** + * @param distance the distance, the audio can be heard + */ + void setDistance(float distance); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientStaticAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientStaticAudioChannel.java new file mode 100644 index 0000000..fffab3a --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/ClientStaticAudioChannel.java @@ -0,0 +1,5 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +public interface ClientStaticAudioChannel extends ClientAudioChannel { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/EntityAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/EntityAudioChannel.java new file mode 100644 index 0000000..bcf1014 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/EntityAudioChannel.java @@ -0,0 +1,43 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import de.maxhenkel.voicechat.api.Entity; + +/** + * An audio channel that is bound to an entity. + * NOTE: If you are using this for a player, you need to use {@link #updateEntity(Entity)} to update the player after it died. + */ +public interface EntityAudioChannel extends AudioChannel { + + /** + * @return if the entity is whispering + */ + boolean isWhispering(); + + /** + * @param whispering if the entity should whisper + */ + void setWhispering(boolean whispering); + + /** + * Sets a new entity where this channel is attached to. + * + * @param entity the entity to attach the channel to + */ + void updateEntity(Entity entity); + + /** + * @return the entity where the channel is attached to + */ + Entity getEntity(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + + /** + * @param distance the distance, the audio can be heard + */ + void setDistance(float distance); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/LocationalAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/LocationalAudioChannel.java new file mode 100644 index 0000000..686bb8c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/LocationalAudioChannel.java @@ -0,0 +1,29 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import de.maxhenkel.voicechat.api.Position; + +public interface LocationalAudioChannel extends AudioChannel { + + /** + * Updates the location of the audio. + * + * @param position the audio location + */ + void updateLocation(Position position); + + /** + * @return the current location of this channel + */ + Position getLocation(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + + /** + * @param distance the distance, the audio can be heard + */ + void setDistance(float distance); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/StaticAudioChannel.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/StaticAudioChannel.java new file mode 100644 index 0000000..eabb086 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/StaticAudioChannel.java @@ -0,0 +1,38 @@ +package de.maxhenkel.voicechat.api.audiochannel; + +import de.maxhenkel.voicechat.api.VoicechatConnection; + +public interface StaticAudioChannel extends AudioChannel { + + /** + * Sets whether this audio channel should be received by targets in isolated groups. + * + * @param bypassGroupIsolation if group isolation should be bypassed + */ + void setBypassGroupIsolation(boolean bypassGroupIsolation); + + /** + * @return if this audio channel is received by targets in isolated groups + */ + boolean bypassesGroupIsolation(); + + /** + * Adds a target to the audio channel. + * + * @param target the target to add + */ + void addTarget(VoicechatConnection target); + + /** + * Removes a target from the audio channel. + * + * @param target the target to remove + */ + void removeTarget(VoicechatConnection target); + + /** + * Removes all targets from the audio channel. + */ + void clearTargets(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/package-info.java new file mode 100644 index 0000000..7987a0b --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiochannel/package-info.java @@ -0,0 +1,4 @@ +/** + * Everything related to audio channels and serverside audio. + */ +package de.maxhenkel.voicechat.api.audiochannel; \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiolistener/AudioListener.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/AudioListener.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/api/audiolistener/AudioListener.java rename to source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/AudioListener.java index d50e83a..7747e2d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiolistener/AudioListener.java +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/AudioListener.java @@ -1,11 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.api.audiolistener; import java.util.UUID; public interface AudioListener { - public UUID getListenerId(); -} + /** + * @return the ID of the listener + */ + UUID getListenerId(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/PlayerAudioListener.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/PlayerAudioListener.java new file mode 100644 index 0000000..1adb317 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/PlayerAudioListener.java @@ -0,0 +1,47 @@ +package de.maxhenkel.voicechat.api.audiolistener; + +import de.maxhenkel.voicechat.api.ServerPlayer; +import de.maxhenkel.voicechat.api.packets.SoundPacket; + +import java.util.UUID; +import java.util.function.Consumer; + +public interface PlayerAudioListener extends AudioListener { + + /** + * @return the {@link UUID} of the player that is listened to + */ + UUID getPlayerUuid(); + + public interface Builder { + + /** + * Note: It is required to either set a player with this method or with {@link #setPlayer(UUID)} + * + * @param player the player that should be listened to + */ + Builder setPlayer(ServerPlayer player); + + /** + * Note: It is required to either set a player with this method or with {@link #setPlayer(ServerPlayer)} + * + * @param playerUuid the player UUID that should be listened to + */ + Builder setPlayer(UUID playerUuid); + + /** + * Note: It is required to set a listener + * + * @param listener the listener + */ + Builder setPacketListener(Consumer listener); + + /** + * @return the built listener + * @throws IllegalStateException if the player or the listener is not set + */ + PlayerAudioListener build(); + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/package-info.java new file mode 100644 index 0000000..4e09114 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiolistener/package-info.java @@ -0,0 +1,6 @@ +/** + * Utilities for listening to all audio a player would theoretically receive. + *

+ * Can be obtained by calling {@link de.maxhenkel.voicechat.api.VoicechatServerApi#playerAudioListenerBuilder()}. + */ +package de.maxhenkel.voicechat.api.audiolistener; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiosender/AudioSender.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiosender/AudioSender.java new file mode 100644 index 0000000..95728fc --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiosender/AudioSender.java @@ -0,0 +1,52 @@ +package de.maxhenkel.voicechat.api.audiosender; + +public interface AudioSender { + + /** + * @param whispering if the player should whisper + * @return the audio sender itself + */ + AudioSender whispering(boolean whispering); + + /** + * @return if the player is whispering + */ + boolean isWhispering(); + + /** + * Sets the sequence number of the packet. + *
+ * Setting this will override the automatic sequence numbering. + *
+ * If you set this value, consequent calls to {@link AudioSender#send(byte[])} will increase this number by 1. + * If you don't intend this, you need to set the sequence number every time before calling {@link AudioSender#send(byte[])}. + *
+ * Calling {@link AudioSender#reset()} will also reset the sequence number to start with 0 again. + * + * @param sequenceNumber the sequence number (Must be >= 0) + * @return the audio sender itself + */ + AudioSender sequenceNumber(long sequenceNumber); + + /** + * @return if a microphone packet can be sent. This will return false if the player has the mod installed or the {@link AudioSender} is not registered. + */ + boolean canSend(); + + /** + * Acts as if the player has sent a microphone packet. + * + * @param opusEncodedAudioData the opus encoded audio data + * @return true if the packet was sent, false if the sender does have the mod installed or the {@link AudioSender} is not registered + */ + boolean send(byte[] opusEncodedAudioData); + + /** + * Resets the sequence number and indicates to clients that the current audio stream is paused/stopped. + *
+ * This method should be called when the sending of audio is paused or stopped. + * You can still send audio after this method is called. + */ + boolean reset(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/audiosender/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiosender/package-info.java new file mode 100644 index 0000000..ec73628 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/audiosender/package-info.java @@ -0,0 +1,6 @@ +/** + * Utilities for simulating players sending audio without the mod. + *

+ * Can be obtained by calling {@link de.maxhenkel.voicechat.api.VoicechatServerApi#createAudioSender(de.maxhenkel.voicechat.api.VoicechatConnection)}. + */ +package de.maxhenkel.voicechat.api.audiosender; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/config/ConfigAccessor.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/config/ConfigAccessor.java new file mode 100644 index 0000000..81dc9d3 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/config/ConfigAccessor.java @@ -0,0 +1,100 @@ +package de.maxhenkel.voicechat.api.config; + +import de.maxhenkel.voicechat.api.VoicechatClientApi; +import de.maxhenkel.voicechat.api.VoicechatServerApi; + +import javax.annotation.Nullable; + +/** + * An interface to access a config. + * This is kept very generic, so it can be used for any config type. + *
+ * This contains a few default methods to get primitive values from the config. + *
+ * NOTE: You need to implement more complex values yourself (e.g. enums). + *
+ * Can be obtained by calling {@link VoicechatServerApi#getServerConfig()} or {@link VoicechatClientApi#getClientConfig()}. + */ +public interface ConfigAccessor { + + /** + * Checks if the config has the given key. + * + * @param key the key + * @return true if the config has the key, false otherwise + */ + boolean hasKey(String key); + + /** + * Gets the raw value of the given key. + * NOTE: This gets the raw value from the config, so it will be a {@link String} even if the value is a number, a boolean or an enum. + * + * @param key the key + * @return the value or null if the key doesn't exist + */ + @Nullable + String getValue(String key); + + /** + * Gets the string value of the given key. + * + * @param key the key + * @param def the default value + * @return the value or the default value if the key doesn't exist + */ + default String getString(String key, String def) { + String value = getValue(key); + if (value == null) { + return def; + } + return value; + } + + /** + * Gets the boolean value of the given key. + * + * @param key the key + * @param def the default value + * @return the boolean value, false if the value is not "true" or the default value if the key doesn't exist + */ + default boolean getBoolean(String key, boolean def) { + String value = getValue(key); + if (value == null) { + return def; + } + return Boolean.parseBoolean(value); + } + + /** + * Gets the integer value of the given key. + * + * @param key the key + * @param def the default value + * @return the value or the default value if the key doesn't exist + * @throws NumberFormatException if the value is not an integer + */ + default int getInt(String key, int def) { + String value = getValue(key); + if (value == null) { + return def; + } + return Integer.parseInt(value); + } + + /** + * Gets the double value of the given key. + * + * @param key the key + * @param def the default value + * @return the value or the default value if the key doesn't exist + * @throws NumberFormatException if the value is not a double + */ + default double getDouble(String key, double def) { + String value = getValue(key); + if (value == null) { + return def; + } + return Double.parseDouble(value); + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/config/VolumeConfigAccessor.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/config/VolumeConfigAccessor.java new file mode 100644 index 0000000..2842330 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/config/VolumeConfigAccessor.java @@ -0,0 +1,51 @@ +package de.maxhenkel.voicechat.api.config; + +import de.maxhenkel.voicechat.api.VoicechatClientApi; + +import java.util.UUID; + +/** + * An interface to access client side adjusted volumes. + *
+ * Can be obtained by calling {@link VoicechatClientApi#getVolumeConfig()}. + */ +public interface VolumeConfigAccessor { + + /** + * Gets the volume of a player by its UUID. + *
+ *
+ * This will always return a value, even if the player is not in the volume config. + *
+ * By default, the volume will be 1.0. + * A volume of 0.0 means this player is muted. + * Can be larger than 1.0. + * Also works for players that are not online. + *
+ *
+ * If you want the Other volume (All volumes that are not covered by categories or players), use the UUID 00000000-0000-0000-0000-000000000000. + * + * @param uuid the UUID of the player + * @return the volume of the player + * @throws NullPointerException if the UUID is null + */ + double getVolume(UUID uuid); + + /** + * Gets the volume of a category by its UUID. + *
+ *
+ * This will always return a value, even if the category doesn't exist. + *
+ * By default, the volume will be 1.0. + * A volume of 0.0 means this category is muted. + * Can be larger than 1.0. + * Also works for categories that are currently not registered. + * + * @param category the category + * @return the volume of the category + * @throws NullPointerException if the category is null + */ + double getCategoryVolume(String category); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/config/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/config/package-info.java new file mode 100644 index 0000000..1a56bd4 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/config/package-info.java @@ -0,0 +1,4 @@ +/** + * Everything configuration related. + */ +package de.maxhenkel.voicechat.api.config; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientEvent.java new file mode 100644 index 0000000..f92a6d3 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientEvent.java @@ -0,0 +1,12 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatClientApi; + +public interface ClientEvent extends Event { + + /** + * @return the voice chat client API + */ + VoicechatClientApi getVoicechat(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientReceiveSoundEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientReceiveSoundEvent.java new file mode 100644 index 0000000..0f33b9f --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientReceiveSoundEvent.java @@ -0,0 +1,73 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Position; + +import javax.annotation.Nullable; +import java.util.UUID; + +/** + * This event is emitted before the sound is played on the client. + */ +public interface ClientReceiveSoundEvent extends ClientEvent { + + /** + * @return the ID of the channel + */ + UUID getId(); + + /** + * The unencoded audio data. + *
+ * Returns an empty array in case of the end of transmission + * + * @return the raw 16 bit PCM audio frame + */ + short[] getRawAudio(); + + /** + * Overrides the actual audio data that is played. + *

+ * This is ignored, if the {@link #getRawAudio} array is empty + *
+ * Providing audio that's not 960 samples will be ignored. + * An empty array skips this frame, which adds latency. To mute the audio, use an array filled with zeros instead. + * + * @param rawAudio the raw 16 bit PCM audio frame + */ + void setRawAudio(@Nullable short[] rawAudio); + + public static interface EntitySound extends ClientReceiveSoundEvent { + + /** + * @return the UUID of the entity + */ + UUID getEntityId(); + + /** + * @return if the player is whispering + */ + boolean isWhispering(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + } + + public static interface LocationalSound extends ClientReceiveSoundEvent { + /** + * @return the position of the sound + */ + Position getPosition(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + } + + public static interface StaticSound extends ClientReceiveSoundEvent { + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientSoundEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientSoundEvent.java new file mode 100644 index 0000000..115eb2d --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientSoundEvent.java @@ -0,0 +1,29 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted before the client encodes the audio and sends it to the server. + */ +public interface ClientSoundEvent extends ClientEvent { + + /** + * The unencoded audio data. + *
+ * Returns an empty array in case of the end of transmission + * + * @return the raw 16 bit PCM audio frame + */ + short[] getRawAudio(); + + /** + * Overrides the actual audio data that's sent to the server. + * + * @param rawAudio the raw 16 bit PCM audio frame + */ + void setRawAudio(short[] rawAudio); + + /** + * @return if the player is whispering + */ + boolean isWhispering(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientVoicechatConnectionEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientVoicechatConnectionEvent.java new file mode 100644 index 0000000..c266c28 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientVoicechatConnectionEvent.java @@ -0,0 +1,13 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted on the client when the voice chat connects/disconnects. + */ +public interface ClientVoicechatConnectionEvent extends ClientEvent { + + /** + * @return if the voice chat is connected to the server + */ + boolean isConnected(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientVoicechatInitializationEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientVoicechatInitializationEvent.java new file mode 100644 index 0000000..6c99766 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ClientVoicechatInitializationEvent.java @@ -0,0 +1,22 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.ClientVoicechatSocket; + +import javax.annotation.Nullable; + +public interface ClientVoicechatInitializationEvent extends ClientEvent { + + /** + * Sets a custom implementation of the socket used for client side voice chat traffic. + * + * @param socket the custom socket implementation + */ + void setSocketImplementation(ClientVoicechatSocket socket); + + /** + * @return the custom socket implementation or null to use voice chats default one + */ + @Nullable + ClientVoicechatSocket getSocketImplementation(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/CreateGroupEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/CreateGroupEvent.java new file mode 100644 index 0000000..2c3ab73 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/CreateGroupEvent.java @@ -0,0 +1,21 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Group; +import de.maxhenkel.voicechat.api.VoicechatConnection; + +import javax.annotation.Nullable; + +public interface CreateGroupEvent extends GroupEvent { + + /** + * @return the group that was created + */ + Group getGroup(); + + /** + * @return the connection of the player that created the group or null if the group was not created by a player + */ + @Nullable + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/CreateOpenALContextEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/CreateOpenALContextEvent.java new file mode 100644 index 0000000..ff71878 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/CreateOpenALContextEvent.java @@ -0,0 +1,18 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted when the voice chats OpenAL context is created. + */ +public interface CreateOpenALContextEvent extends ClientEvent { + + /** + * @return the OpenAL context + */ + long getContext(); + + /** + * @return the OpenAL device + */ + long getDevice(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/DestroyOpenALContextEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/DestroyOpenALContextEvent.java new file mode 100644 index 0000000..076dbe0 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/DestroyOpenALContextEvent.java @@ -0,0 +1,18 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted when the voice chats OpenAL context is destroyed. + */ +public interface DestroyOpenALContextEvent extends ClientEvent { + + /** + * @return the OpenAL context - Might be 0L in some cases + */ + long getContext(); + + /** + * @return the OpenAL device - Might be 0L in some cases + */ + long getDevice(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/EntitySoundPacketEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/EntitySoundPacketEvent.java new file mode 100644 index 0000000..8d1748c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/EntitySoundPacketEvent.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; + +/** + * This event is emitted when an entity sound packet is about to get sent to a client. + */ +public interface EntitySoundPacketEvent extends SoundPacketEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/Event.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/Event.java new file mode 100644 index 0000000..9cfeef5 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/Event.java @@ -0,0 +1,23 @@ +package de.maxhenkel.voicechat.api.events; + +public interface Event { + + /** + * @return if this event can be cancelled + */ + boolean isCancellable(); + + /** + * Cancels this event. + * Does nothing if the event isn't cancellable. + * + * @return if the event was actually cancelled + */ + boolean cancel(); + + /** + * @return if the event was cancelled + */ + boolean isCancelled(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/EventRegistration.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/EventRegistration.java new file mode 100644 index 0000000..ec00a2c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/EventRegistration.java @@ -0,0 +1,28 @@ +package de.maxhenkel.voicechat.api.events; + +import java.util.function.Consumer; + +public interface EventRegistration { + + /** + * Registers an event. + * + * @param eventClass the class of the event you want to receive + * @param onPacket the consumer that is called when the event was dispatched + * @param priority the event priority - Higher values mean a higher priority + * @param the event type + */ + void registerEvent(Class eventClass, Consumer onPacket, int priority); + + /** + * Registers an event. + * + * @param eventClass the class of the event you want to receive + * @param onPacket the consumer that is called when the event was dispatched + * @param the event type + */ + default void registerEvent(Class eventClass, Consumer onPacket) { + registerEvent(eventClass, onPacket, 0); + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/GroupEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/GroupEvent.java new file mode 100644 index 0000000..5cda398 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/GroupEvent.java @@ -0,0 +1,22 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Group; +import de.maxhenkel.voicechat.api.VoicechatConnection; + +import javax.annotation.Nullable; + +public interface GroupEvent extends ServerEvent { + + /** + * @return the group - null if there is no group + */ + @Nullable + Group getGroup(); + + /** + * @return the connection of the player + */ + @Nullable + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/JoinGroupEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/JoinGroupEvent.java new file mode 100644 index 0000000..f89608a --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/JoinGroupEvent.java @@ -0,0 +1,18 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Group; +import de.maxhenkel.voicechat.api.VoicechatConnection; + +public interface JoinGroupEvent extends GroupEvent { + + /** + * @return the group that was joined + */ + Group getGroup(); + + /** + * @return the connection of the player + */ + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/LeaveGroupEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/LeaveGroupEvent.java new file mode 100644 index 0000000..c116665 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/LeaveGroupEvent.java @@ -0,0 +1,21 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Group; +import de.maxhenkel.voicechat.api.VoicechatConnection; + +import javax.annotation.Nullable; + +public interface LeaveGroupEvent extends GroupEvent { + + /** + * @return the group that was left or null if the player was not in a group + */ + @Nullable + Group getGroup(); + + /** + * @return the connection of the player + */ + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/LocationalSoundPacketEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/LocationalSoundPacketEvent.java new file mode 100644 index 0000000..4d1549e --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/LocationalSoundPacketEvent.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; + +/** + * This event is emitted when a locational sound packet is about to get sent to a client. + */ +public interface LocationalSoundPacketEvent extends SoundPacketEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MergeClientSoundEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MergeClientSoundEvent.java new file mode 100644 index 0000000..cd47395 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MergeClientSoundEvent.java @@ -0,0 +1,22 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted before the {@link ClientSoundEvent} is getting called. + * It allows you to merge audio into the audio that is captured from the microphone. + *
+ * This is called even when the player is muted or not talking. + *
+ * When the voice chat it disabled, this event is not called. + */ +public interface MergeClientSoundEvent extends ClientEvent { + + /** + * Merges the audio into the audio that is captured from the microphone. + *
+ * Calling this multiple times will merge the audio multiple times into the same audio frame. + * + * @param audio the audio that should get merged + */ + void mergeAudio(short[] audio); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MicrophoneMuteEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MicrophoneMuteEvent.java new file mode 100644 index 0000000..87d46c8 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MicrophoneMuteEvent.java @@ -0,0 +1,13 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted on the client when the state of the microphone changes. + */ +public interface MicrophoneMuteEvent extends ClientEvent { + + /** + * @return if the microphone is muted + */ + boolean isDisabled(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MicrophonePacketEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MicrophonePacketEvent.java new file mode 100644 index 0000000..c1d0e97 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/MicrophonePacketEvent.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.packets.MicrophonePacket; + +/** + * This event is emitted when a microphone packet arrives at the server. + */ +public interface MicrophonePacketEvent extends PacketEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/NameTagIconRenderEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/NameTagIconRenderEvent.java new file mode 100644 index 0000000..7e493eb --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/NameTagIconRenderEvent.java @@ -0,0 +1,30 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatClientApi; + +import java.util.UUID; + +/** + * This event is emitted when an icon is getting rendered. + *
+ * This event should not be used to do any actual rendering. + * Just use this event to cancel the rendering of the icon. + *
+ * Warning: Don't do heavy operations in this event, as it will block the render thread! + *
+ *
+ * Note: Don't keep references to this event. It will be reused for every icon render to avoid allocations. + *
+ *
+ * Use {@link VoicechatClientApi#isTalking(UUID)}, {@link VoicechatClientApi#isWhispering(UUID)}, + * {@link VoicechatClientApi#isDisabled(UUID)} and {@link VoicechatClientApi#isDisconnected(UUID)} + * to get the status of the player and render it using your mod loaders render event system. + */ +public interface NameTagIconRenderEvent extends ClientEvent { + + /** + * @return the UUID of the entity the icon is being rendered for + */ + UUID getEntityId(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/OpenALSoundEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/OpenALSoundEvent.java new file mode 100644 index 0000000..e77dca6 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/OpenALSoundEvent.java @@ -0,0 +1,59 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Position; + +import javax.annotation.Nullable; +import java.util.UUID; + +/** + * This event is emitted for every audio chunk for every audio channel. + * These events are meant to be used to modify OpenAL effects. + *
+ * This specific event is emitted after the position of the sound is set, but before the any other OpenAL calls. + * Use {@link Pre} or {@link Post} get earlier or later events respectively. + */ +public interface OpenALSoundEvent extends ClientEvent { + + /** + * Returns the position of the sound. + * This returns null for static sounds. + * + * @return the position of the sound + */ + @Nullable + Position getPosition(); + + /** + * This returns null for non audio channel sounds, like microphone testing. + * + * @return the unique ID of the audio channel + */ + @Nullable + UUID getChannelId(); + + /** + * @return the OpenAL source + */ + int getSource(); + + /** + * @return the category of the sound + */ + @Nullable + String getCategory(); + + /** + * This event is emitted before any OpenAL calls were made by the voice chat. + */ + public interface Pre extends OpenALSoundEvent { + + } + + /** + * This event is emitted after all OpenAL calls by the voice chat and the audio is added to the buffer queue. + */ + public interface Post extends OpenALSoundEvent { + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PacketEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PacketEvent.java new file mode 100644 index 0000000..f53d9be --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PacketEvent.java @@ -0,0 +1,27 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatConnection; +import de.maxhenkel.voicechat.api.packets.Packet; + +import javax.annotation.Nullable; + +public interface PacketEvent extends ServerEvent { + + /** + * @return the packet + */ + T getPacket(); + + /** + * @return the connection of the player that should receive this packet + */ + @Nullable + VoicechatConnection getReceiverConnection(); + + /** + * @return the connection of the player that sent this packet or null if it wasn't sent by a player + */ + @Nullable + VoicechatConnection getSenderConnection(); + +} \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerConnectedEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerConnectedEvent.java new file mode 100644 index 0000000..247aed5 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerConnectedEvent.java @@ -0,0 +1,12 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatConnection; + +public interface PlayerConnectedEvent extends ServerEvent { + + /** + * @return the connection of the player + */ + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerDisconnectedEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerDisconnectedEvent.java new file mode 100644 index 0000000..7c02278 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerDisconnectedEvent.java @@ -0,0 +1,12 @@ +package de.maxhenkel.voicechat.api.events; + +import java.util.UUID; + +public interface PlayerDisconnectedEvent extends ServerEvent { + + /** + * @return the UUID of the player + */ + UUID getPlayerUuid(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerStateChangedEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerStateChangedEvent.java new file mode 100644 index 0000000..6bd3833 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/PlayerStateChangedEvent.java @@ -0,0 +1,35 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatConnection; + +import javax.annotation.Nullable; +import java.util.UUID; + +/** + * Called when a player changes its state. + * For example if voice chat connects/disconnects, the player joins/leaves a group or disables voice chat. + */ +public interface PlayerStateChangedEvent extends ServerEvent { + + /** + * @return if the player disabled voice chat + */ + boolean isDisabled(); + + /** + * @return if the player is disconnected from voice chat + */ + boolean isDisconnected(); + + /** + * @return the uuid of the player + */ + UUID getPlayerUuid(); + + /** + * @return the connection of the player + */ + @Nullable + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/RegisterVolumeCategoryEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/RegisterVolumeCategoryEvent.java new file mode 100644 index 0000000..f1f0a45 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/RegisterVolumeCategoryEvent.java @@ -0,0 +1,5 @@ +package de.maxhenkel.voicechat.api.events; + +public interface RegisterVolumeCategoryEvent extends VolumeCategoryEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/RemoveGroupEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/RemoveGroupEvent.java new file mode 100644 index 0000000..4ea6166 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/RemoveGroupEvent.java @@ -0,0 +1,25 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.Group; +import de.maxhenkel.voicechat.api.VoicechatConnection; + +import javax.annotation.Nullable; + +/** + * This event is only cancellable if the group is persistent + */ +public interface RemoveGroupEvent extends GroupEvent { + + /** + * @return the group that was removed + */ + Group getGroup(); + + /** + * @return null + */ + @Nullable + @Deprecated + VoicechatConnection getConnection(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ServerEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ServerEvent.java new file mode 100644 index 0000000..c95e318 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/ServerEvent.java @@ -0,0 +1,12 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatServerApi; + +public interface ServerEvent extends Event { + + /** + * @return the voice chat server API + */ + VoicechatServerApi getVoicechat(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/SoundPacketEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/SoundPacketEvent.java new file mode 100644 index 0000000..f857cf2 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/SoundPacketEvent.java @@ -0,0 +1,23 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.packets.Packet; + +public interface SoundPacketEvent extends PacketEvent { + + String SOURCE_GROUP = "group"; + String SOURCE_PROXIMITY = "proximity"; + String SOURCE_SPECTATOR = "spectator"; + String SOURCE_PLUGIN = "plugin"; + + /** + * Where the packet originated from. + * It can be either {@value SOURCE_GROUP} for group chats, + * {@value SOURCE_PROXIMITY} for proximity sound, + * {@value SOURCE_SPECTATOR} for spectator sound + * or {@value SOURCE_PLUGIN} if the packet was sent from a plugin. + * + * @return the source of the packet + */ + String getSource(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/StaticSoundPacketEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/StaticSoundPacketEvent.java new file mode 100644 index 0000000..6e5306b --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/StaticSoundPacketEvent.java @@ -0,0 +1,10 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; + +/** + * This event is emitted when a static sound packet is about to get sent to a client. + */ +public interface StaticSoundPacketEvent extends SoundPacketEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/UnregisterVolumeCategoryEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/UnregisterVolumeCategoryEvent.java new file mode 100644 index 0000000..8c7bb3c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/UnregisterVolumeCategoryEvent.java @@ -0,0 +1,5 @@ +package de.maxhenkel.voicechat.api.events; + +public interface UnregisterVolumeCategoryEvent extends VolumeCategoryEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoiceDistanceEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoiceDistanceEvent.java new file mode 100644 index 0000000..fdaf86c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoiceDistanceEvent.java @@ -0,0 +1,39 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatConnection; +import de.maxhenkel.voicechat.api.packets.MicrophonePacket; + +/** + * This event is emitted after a microphone packet arrives at the server and the distance is processed. + * This can be used to modify the distance at which other players can hear this packet. + */ +public interface VoiceDistanceEvent extends ServerEvent { + + /** + * @return the microphone packet + */ + MicrophonePacket getPacket(); + + /** + * @return the connection of the player + */ + VoicechatConnection getSenderConnection(); + + /** + * This returns either the default distance that's set on the server or the modified distance if another subscriber changed it already. + * In case a player is whispering, this will return the whisper distance. + * The whisper state can be obtained by calling {@link #getPacket()} and getting {@link MicrophonePacket#isWhispering()}. + * + * @return the distance in blocks + */ + float getDistance(); + + /** + * Sets the distance this player sends audio at. + * Note that this also includes the whisper distance, if the player is whispering. + * + * @param distance the distance in blocks + */ + void setDistance(float distance); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoiceHostEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoiceHostEvent.java new file mode 100644 index 0000000..39ffb73 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoiceHostEvent.java @@ -0,0 +1,24 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.ServerPlayer; + +public interface VoiceHostEvent extends ServerEvent { + + /** + * @return the voice host string + */ + String getVoiceHost(); + + /** + * Overwrites voice chats voice host - This is sent to the client and used by it to connect to the server. + * + * @param voiceHost the voice host string + */ + void setVoiceHost(String voiceHost); + + /** + * @return the player that is connecting + */ + ServerPlayer getPlayer(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatDisableEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatDisableEvent.java new file mode 100644 index 0000000..df9f62b --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatDisableEvent.java @@ -0,0 +1,13 @@ +package de.maxhenkel.voicechat.api.events; + +/** + * This event is emitted on the client when the voice chat is getting enabled/disabled. + */ +public interface VoicechatDisableEvent extends ClientEvent { + + /** + * @return if the voice chat is disabled + */ + boolean isDisabled(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStartedEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStartedEvent.java new file mode 100644 index 0000000..492d2f8 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStartedEvent.java @@ -0,0 +1,5 @@ +package de.maxhenkel.voicechat.api.events; + +public interface VoicechatServerStartedEvent extends ServerEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStartingEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStartingEvent.java new file mode 100644 index 0000000..3dc4caa --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStartingEvent.java @@ -0,0 +1,22 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VoicechatSocket; + +import javax.annotation.Nullable; + +public interface VoicechatServerStartingEvent extends ServerEvent { + + /** + * Sets a custom implementation of the socket used for voice chat traffic. + * + * @param socket the custom socket implementation + */ + void setSocketImplementation(VoicechatSocket socket); + + /** + * @return the custom socket implementation or null to use voice chats default one + */ + @Nullable + VoicechatSocket getSocketImplementation(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStoppedEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStoppedEvent.java new file mode 100644 index 0000000..8988fbe --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VoicechatServerStoppedEvent.java @@ -0,0 +1,5 @@ +package de.maxhenkel.voicechat.api.events; + +public interface VoicechatServerStoppedEvent extends ServerEvent { + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VolumeCategoryEvent.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VolumeCategoryEvent.java new file mode 100644 index 0000000..f30e58f --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/VolumeCategoryEvent.java @@ -0,0 +1,12 @@ +package de.maxhenkel.voicechat.api.events; + +import de.maxhenkel.voicechat.api.VolumeCategory; + +public interface VolumeCategoryEvent extends ServerEvent { + + /** + * @return the volume category + */ + VolumeCategory getVolumeCategory(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/events/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/package-info.java new file mode 100644 index 0000000..01260d4 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/events/package-info.java @@ -0,0 +1,6 @@ +/** + * All registerable events. + *

+ * Events can be registered by calling {@link de.maxhenkel.voicechat.api.events.EventRegistration#registerEvent}. + */ +package de.maxhenkel.voicechat.api.events; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/Mp3Decoder.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/Mp3Decoder.java new file mode 100644 index 0000000..a49f6fe --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/Mp3Decoder.java @@ -0,0 +1,37 @@ +package de.maxhenkel.voicechat.api.mp3; + +import de.maxhenkel.voicechat.api.VoicechatApi; + +import javax.sound.sampled.AudioFormat; +import java.io.IOException; + +/** + * You can obtain an instance of this class by calling {@link VoicechatApi#createMp3Decoder}. + */ +public interface Mp3Decoder { + + /** + * Decodes the MP3 file and returns the decoded audio data as PCM samples. + * + * @return the decoded audio data as PCM samples + * @throws IOException if an I/O error occurs + */ + short[] decode() throws IOException; + + /** + * Decodes the MP3 file if {@link #decode()} has not been called before. + * + * @return the audio format of the decoded audio data + * @throws IOException if an I/O error occurs + */ + AudioFormat getAudioFormat() throws IOException; + + /** + * Decodes the MP3 file if {@link #decode()} has not been called before. + * + * @return the bitrate of the mp3 file + * @throws IOException if an I/O error occurs + */ + int getBitrate() throws IOException; + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/Mp3Encoder.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/Mp3Encoder.java new file mode 100644 index 0000000..550c386 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/Mp3Encoder.java @@ -0,0 +1,30 @@ +package de.maxhenkel.voicechat.api.mp3; + +import de.maxhenkel.voicechat.api.VoicechatApi; + +import java.io.IOException; + +/** + * You can obtain an instance of this class by calling {@link VoicechatApi#createMp3Encoder}. + */ +public interface Mp3Encoder { + + /** + * Encodes the given PCM samples and writes it to the provided output stream. + * + * @param samples the PCM samples to encode + * @throws IOException if an I/O error occurs + */ + void encode(short[] samples) throws IOException; + + /** + * Closes the encoder and flushes the output stream. + * Also writes leftover mp3 data to the output stream. + * + * NOTE: Not closing encoders will cause a memory leak in voice chat versions <2.6.3! + * + * @throws IOException if an I/O error occurs + */ + void close() throws IOException; + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/package-info.java new file mode 100644 index 0000000..d0db587 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/mp3/package-info.java @@ -0,0 +1,4 @@ +/** + * Wrappers for mp3 encoding and decoding. + */ +package de.maxhenkel.voicechat.api.mp3; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusDecoder.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusDecoder.java new file mode 100644 index 0000000..2a3068c --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusDecoder.java @@ -0,0 +1,45 @@ +package de.maxhenkel.voicechat.api.opus; + +import de.maxhenkel.voicechat.api.VoicechatApi; + +import javax.annotation.Nullable; + +/** + * Instances can be obtained by calling {@link VoicechatApi#createDecoder()}. + */ +public interface OpusDecoder { + + /** + * Decodes opus encoded audio data to 16 bit PCM audio. + * + * @param data the opus encoded data or null to do PLC + * @return the 16 bit PCM audio data + */ + short[] decode(@Nullable byte[] data); + + /** + * Decodes the provided packet and recovers previous lost frames using FEC. + * + * @param input the input packet + * @param frames the number of frames to return (min 1 for just the current frame) + * @return an array containing the decoded frames - the length of the array is equal to {@param frames} + */ + short[][] decode(byte[] input, int frames); + + /** + * Resets the decoders state. + */ + void resetState(); + + /** + * @return if the decoder is closed + */ + boolean isClosed(); + + /** + * Closes the decoder. + * NOTE: Not closing encoders will cause a memory leak in voice chat versions <2.6.3! + */ + void close(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusEncoder.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusEncoder.java new file mode 100644 index 0000000..70bdaff --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusEncoder.java @@ -0,0 +1,34 @@ +package de.maxhenkel.voicechat.api.opus; + +import de.maxhenkel.voicechat.api.VoicechatApi; + +/** + * Instances can be obtained by calling {@link VoicechatApi#createEncoder()}. + */ +public interface OpusEncoder { + + /** + * Encodes 16 bit PCM audio with opus. + * + * @param rawAudio the raw 16 bit PCM audio + * @return the opus encoded data + */ + byte[] encode(short[] rawAudio); + + /** + * Resets the encoders state. + */ + void resetState(); + + /** + * @return if the encoder is closed + */ + boolean isClosed(); + + /** + * Closes the encoder. + * NOTE: Not closing encoders will cause a memory leak in voice chat versions <2.6.3! + */ + void close(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusEncoderMode.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusEncoderMode.java new file mode 100644 index 0000000..3351104 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/OpusEncoderMode.java @@ -0,0 +1,8 @@ +package de.maxhenkel.voicechat.api.opus; + +/** + * The different Opus encoder modes + */ +public enum OpusEncoderMode { + VOIP, AUDIO, RESTRICTED_LOWDELAY; +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/package-info.java new file mode 100644 index 0000000..2be6d37 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/opus/package-info.java @@ -0,0 +1,4 @@ +/** + * Wrappers for the Opus codec. + */ +package de.maxhenkel.voicechat.api.opus; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/package-info.java new file mode 100644 index 0000000..4554d9f --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/package-info.java @@ -0,0 +1,4 @@ +/** + * The main Simple Voice Chat API package. + */ +package de.maxhenkel.voicechat.api; \ No newline at end of file diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/ConvertablePacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/ConvertablePacket.java new file mode 100644 index 0000000..2434d3f --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/ConvertablePacket.java @@ -0,0 +1,64 @@ +package de.maxhenkel.voicechat.api.packets; + +import de.maxhenkel.voicechat.api.Position; +import de.maxhenkel.voicechat.api.VoicechatServerApi; + +import java.util.UUID; + +public interface ConvertablePacket { + + /** + * NOTE: Make sure to set {@link SoundPacket.Builder#channelId(UUID)} to avoid conflicts with other channels. + * + * @return a builder to build an entity sound packet based on this packet + */ + EntitySoundPacket.Builder entitySoundPacketBuilder(); + + /** + * NOTE: Make sure to set {@link SoundPacket.Builder#channelId(UUID)} to avoid conflicts with other channels. + * + * @return a builder to build a locational sound packet based on this packet + */ + LocationalSoundPacket.Builder locationalSoundPacketBuilder(); + + /** + * NOTE: Make sure to set {@link SoundPacket.Builder#channelId(UUID)} to avoid conflicts with other channels. + * + * @return a builder to build a static sound packet based on this packet + */ + StaticSoundPacket.Builder staticSoundPacketBuilder(); + + /** + * Converts this packet to an entity sound packet. + * + * @param entityUuid the UUID of the entity + * @param whispering if the entity is whispering + * @return the entity sound packet + * @throws UnsupportedOperationException if this is called on a packet created by {@link VoicechatServerApi#createPacket()} + * @deprecated use {@link #entitySoundPacketBuilder()} + */ + @Deprecated + EntitySoundPacket toEntitySoundPacket(UUID entityUuid, boolean whispering); + + /** + * Converts this packet to a locational sound packet. + * + * @param position the position of the audio + * @return the locational sound packet + * @throws UnsupportedOperationException if this is called on a packet created by {@link VoicechatServerApi#createPacket()} + * @deprecated use {@link #locationalSoundPacketBuilder()} + */ + @Deprecated + LocationalSoundPacket toLocationalSoundPacket(Position position); + + /** + * Converts this packet to a static sound packet. + * + * @return the static sound packet + * @throws UnsupportedOperationException if this is called on a packet created by {@link VoicechatServerApi#createPacket()} + * @deprecated use {@link #staticSoundPacketBuilder()} + */ + @Deprecated + StaticSoundPacket toStaticSoundPacket(); + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/EntitySoundPacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/EntitySoundPacket.java new file mode 100644 index 0000000..8d264f6 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/EntitySoundPacket.java @@ -0,0 +1,60 @@ +package de.maxhenkel.voicechat.api.packets; + +import java.util.UUID; + +/** + * The receiver of this event will hear the sound from the specified entity. + * This can be done for all entities, but only players will show the speaker icon. + * If the entity is further away than the maximum voice distance, the receiving player won't actually hear the sound. + */ +public interface EntitySoundPacket extends SoundPacket { + + /** + * @return the UUID of the entity + */ + UUID getEntityUuid(); + + /** + * @return if the entity is whispering + */ + boolean isWhispering(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + + /** + * A builder to build an entity sound packet. + * + * NOTE: Some values are required to be set. + * + * @param the builder itself + */ + public interface Builder> extends SoundPacket.Builder { + + /** + * This is required to be set! + *
+ * The entity UUID is also used as the sender of the packet. + * + * @param entityUuid the UUID of the entity + * @return the builder + */ + T entityUuid(UUID entityUuid); + + /** + * @param whispering if the entity should be whispering + * @return the builder + */ + T whispering(boolean whispering); + + /** + * @param distance the distance, this packet can be heard + * @return the builder + */ + T distance(float distance); + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/LocationalSoundPacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/LocationalSoundPacket.java new file mode 100644 index 0000000..da029ff --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/LocationalSoundPacket.java @@ -0,0 +1,46 @@ +package de.maxhenkel.voicechat.api.packets; + +import de.maxhenkel.voicechat.api.Position; + +/** + * The receiver of this event will hear the sound from the specified location. + * If the location is further away than the maximum voice distance, the receiving player won't actually hear the sound. + */ +public interface LocationalSoundPacket extends SoundPacket { + + /** + * @return the audio location + */ + Position getPosition(); + + /** + * @return the distance, the audio can be heard + */ + float getDistance(); + + /** + * A builder to build a locational sound packet. + * + * NOTE: Some values are required to be set. + * + * @param the builder itself + */ + public interface Builder> extends SoundPacket.Builder { + + /** + * This is required to be set! + * + * @param position the position of the sound + * @return the builder + */ + T position(Position position); + + /** + * @param distance the distance, this packet can be heard + * @return the builder + */ + T distance(float distance); + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/MicrophonePacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/MicrophonePacket.java new file mode 100644 index 0000000..4f9daf4 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/MicrophonePacket.java @@ -0,0 +1,22 @@ +package de.maxhenkel.voicechat.api.packets; + +public interface MicrophonePacket extends Packet, ConvertablePacket { + + /** + * @return if the player is whispering + */ + boolean isWhispering(); + + /** + * @return the opus encoded audio data from the player + */ + byte[] getOpusEncodedData(); + + /** + * Allows you to modify or replace the opus encoded audio data. + * + * @param data the opus encoded audio data to replace + */ + void setOpusEncodedData(byte[] data); + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/Packet.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/Packet.java similarity index 65% rename from source/decompiled/de/maxhenkel/voicechat/api/packets/Packet.java rename to source/api/src/main/java/de/maxhenkel/voicechat/api/packets/Packet.java index 3c586be..6185e0f 100644 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/Packet.java +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/Packet.java @@ -1,8 +1,4 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.api.packets; public interface Packet { } - diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/SoundPacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/SoundPacket.java new file mode 100644 index 0000000..4956916 --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/SoundPacket.java @@ -0,0 +1,100 @@ +package de.maxhenkel.voicechat.api.packets; + +import de.maxhenkel.voicechat.api.VoicechatServerApi; +import de.maxhenkel.voicechat.api.VolumeCategory; + +import javax.annotation.Nullable; +import java.util.UUID; + +public interface SoundPacket extends Packet, ConvertablePacket { + + /** + * @return the channel ID of the sound packet + */ + UUID getChannelId(); + + /** + * @return the sender of this packet - doesn't necessarily need to be a player's UUID + */ + UUID getSender(); + + /** + * @return the opus encoded audio data + */ + byte[] getOpusEncodedData(); + + /** + * @return the sequence number of the packet + */ + long getSequenceNumber(); + + /** + * @return the category ID of the sound packet + */ + @Nullable + String getCategory(); + + /** + * A builder to build a sound packet. + * + * @param the builder itself + * @param

the packet, the builder builds + */ + public interface Builder, P extends SoundPacket> { + + /** + * NOTE: Make sure to set this to a unique value to avoid conflicts with other channels. + * This value needs to be the same when sending multiple packets of the same channel. + * + * @param channelId the channel ID of the sound packet + * @return the builder + */ + T channelId(UUID channelId); + + /** + * Sets the sender of the sound packet. + * This must be set if this is created using {@link VoicechatServerApi#createPacket()}. + * + * @param sender the sender of the sound packet + * @return the builder + */ + T sender(UUID sender); + + /** + * @param data the opus encoded audio data + * @return the builder + */ + T opusEncodedData(byte[] data); + + /** + * Sets the sequence number of the sound packet. + * The sequence number is set automatically for everything except when using {@link VoicechatServerApi#createPacket()}. + *
+ *
+ * NOTE: You should only change this when using {@link VoicechatServerApi#createPacket()}. + * + * @param sequenceNumber the sequence number of the sound packet + * @return the builder + */ + T sequenceNumber(long sequenceNumber); + + /** + * Make sure you registered your category before using it. + * See {@link de.maxhenkel.voicechat.api.VoicechatServerApi#registerVolumeCategory(VolumeCategory)}. + * + * @param category the category ID of the sound packet + * @return the builder + */ + T category(@Nullable String category); + + /** + * Builds the packet. + * NOTE: If you are missing required values, this will throw an {@link IllegalStateException}. + * + * @return the packet + */ + P build(); + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/StaticSoundPacket.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/StaticSoundPacket.java new file mode 100644 index 0000000..3f1698d --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/StaticSoundPacket.java @@ -0,0 +1,18 @@ +package de.maxhenkel.voicechat.api.packets; + +/** + * The receiver of this event will hear the sound non-directional. + * This is what is basically used for group chats. + */ +public interface StaticSoundPacket extends SoundPacket { + + /** + * A builder to build a static sound packet. + * + * @param the builder itself + */ + public interface Builder> extends SoundPacket.Builder { + + } + +} diff --git a/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/package-info.java b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/package-info.java new file mode 100644 index 0000000..f28d51a --- /dev/null +++ b/source/api/src/main/java/de/maxhenkel/voicechat/api/packets/package-info.java @@ -0,0 +1,4 @@ +/** + * All voice chat UDP packets. + */ +package de.maxhenkel.voicechat.api.packets; \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/BukkitVersion.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/BukkitVersion.java similarity index 71% rename from source/decompiled/de/maxhenkel/voicechat/BukkitVersion.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/BukkitVersion.java index db4e732..13ad954 100644 --- a/source/decompiled/de/maxhenkel/voicechat/BukkitVersion.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/BukkitVersion.java @@ -1,19 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat; -import de.maxhenkel.voicechat.Version; +import javax.annotation.Nullable; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nullable; -public class BukkitVersion -extends Version { +public class BukkitVersion extends Version { + public static final Pattern BUKKIT_VERSION_REGEX = Pattern.compile("^(?\\d+)\\.(?\\d+)(?:\\.(?\\d+))?-R(?[\\d.-]+)(?:-SNAPSHOT)?$"); + protected final String revision; public BukkitVersion(int major, int minor, int patch, String revision) { @@ -35,15 +29,17 @@ extends Version { @Nullable public static BukkitVersion parseBukkitVersion(String bukkitVersion) { Matcher targetMatcher = BUKKIT_VERSION_REGEX.matcher(bukkitVersion); + if (!targetMatcher.matches()) { return null; } + return BukkitVersion.fromRegex(targetMatcher); } @Nullable public static BukkitVersion getTargetVersion() { - return BukkitVersion.parseBukkitVersion("1.8.8-R0.1-SNAPSHOT"); + return parseBukkitVersion(BuildConstants.TARGET_BUKKIT_VERSION); } @Override @@ -54,24 +50,26 @@ extends Version { if (!(o instanceof BukkitVersion)) { return false; } - BukkitVersion that = (BukkitVersion)o; - if (this.major != that.major) { + + BukkitVersion that = (BukkitVersion) o; + + if (major != that.major) { return false; } - if (this.minor != that.minor) { + if (minor != that.minor) { return false; } - if (this.patch != that.patch) { + if (patch != that.patch) { return false; } - return this.revision.equals(that.revision); + return revision.equals(that.revision); } + @Override public String toString() { - if (this.patch <= 0) { - return this.major + "." + this.minor + "-R" + this.revision; + if (patch <= 0) { + return major + "." + minor + "-R" + revision; } - return this.major + "." + this.minor + "." + this.patch + "-R" + this.revision; + return major + "." + minor + "." + patch + "-R" + revision; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/PaperVersion.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/PaperVersion.java similarity index 77% rename from source/decompiled/de/maxhenkel/voicechat/PaperVersion.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/PaperVersion.java index 4896e6d..ae6303c 100644 --- a/source/decompiled/de/maxhenkel/voicechat/PaperVersion.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/PaperVersion.java @@ -1,20 +1,15 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat; -import de.maxhenkel.voicechat.Version; import de.maxhenkel.voicechat.compatibility.ReflectionUtils; + +import javax.annotation.Nullable; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nullable; -public class PaperVersion -extends Version { +public class PaperVersion extends Version { + public static final Pattern PAPER_VERSION_REGEX = Pattern.compile("^(?\\d+)\\.(?\\d+)(?:\\.(?\\d+))?\\.(?.*)$"); + private final String build; public PaperVersion(int major, int minor, int patch, String build) { @@ -39,21 +34,24 @@ extends Version { @Nullable public static PaperVersion parsePaperVersion(String version) { - if (!PaperVersion.isPaper()) { + if (!isPaper()) { return null; } + Matcher targetMatcher = PAPER_VERSION_REGEX.matcher(version); + if (!targetMatcher.matches()) { return null; } + return PaperVersion.fromRegex(targetMatcher); } + @Override public String toString() { - if (this.patch <= 0) { - return this.major + "." + this.minor + "." + this.build; + if (patch <= 0) { + return major + "." + minor + "." + build; } - return this.major + "." + this.minor + "." + this.patch + "." + this.build; + return major + "." + minor + "." + patch + "." + build; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/Version.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/Version.java similarity index 59% rename from source/decompiled/de/maxhenkel/voicechat/Version.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/Version.java index 6c517e4..37bdda0 100644 --- a/source/decompiled/de/maxhenkel/voicechat/Version.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/Version.java @@ -1,18 +1,11 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - */ package de.maxhenkel.voicechat; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.PaperVersion; -import javax.annotation.Nullable; import org.bukkit.Bukkit; +import javax.annotation.Nullable; + public class Version { + protected final int major; protected final int minor; protected final int patch; @@ -34,43 +27,46 @@ public class Version { @Nullable public static Version getVersion() { - return Version.parse(Bukkit.getBukkitVersion()); + return parse(Bukkit.getBukkitVersion()); } public int getMajor() { - return this.major; + return major; } public int getMinor() { - return this.minor; + return minor; } public int getPatch() { - return this.patch; + return patch; } + @Override public boolean equals(Object o) { if (this == o) { return true; } - if (o == null || this.getClass() != o.getClass()) { + if (o == null || getClass() != o.getClass()) { return false; } - Version that = (Version)o; - if (this.major != that.major) { + + Version that = (Version) o; + + if (major != that.major) { return false; } - if (this.minor != that.minor) { + if (minor != that.minor) { return false; } - return this.patch == that.patch; + return patch == that.patch; } + @Override public int hashCode() { - int result = this.major; - result = 31 * result + this.minor; - result = 31 * result + this.patch; + int result = major; + result = 31 * result + minor; + result = 31 * result + patch; return result; } } - diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/Voicechat.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/Voicechat.java new file mode 100644 index 0000000..cb5588c --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/Voicechat.java @@ -0,0 +1,157 @@ +package de.maxhenkel.voicechat; + +import de.maxhenkel.configbuilder.ConfigBuilder; +import de.maxhenkel.voicechat.api.BukkitVoicechatService; +import de.maxhenkel.voicechat.command.VoiceChatCommands; +import de.maxhenkel.voicechat.compatibility.BukkitCompatibilityManager; +import de.maxhenkel.voicechat.compatibility.Compatibility; +import de.maxhenkel.voicechat.config.ServerConfig; +import de.maxhenkel.voicechat.config.Translations; +import de.maxhenkel.voicechat.integration.commodore.CommodoreCommands; +import de.maxhenkel.voicechat.integration.commodore.MissingArgumentTypeException; +import de.maxhenkel.voicechat.integration.placeholderapi.VoicechatExpansion; +import de.maxhenkel.voicechat.integration.viaversion.ViaVersionCompatibility; +import de.maxhenkel.voicechat.logging.JavaLoggingLogger; +import de.maxhenkel.voicechat.logging.VoicechatLogger; +import de.maxhenkel.voicechat.net.NetManager; +import de.maxhenkel.voicechat.plugins.PluginManager; +import de.maxhenkel.voicechat.plugins.impl.BukkitVoicechatServiceImpl; +import de.maxhenkel.voicechat.voice.server.ServerVoiceEvents; +import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; +import me.lucko.commodore.Commodore; +import me.lucko.commodore.CommodoreProvider; +import org.bukkit.Bukkit; +import org.bukkit.command.PluginCommand; +import org.bukkit.plugin.ServicePriority; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.regex.Pattern; + +public final class Voicechat extends JavaPlugin { + + public static Voicechat INSTANCE; + + public static final String MODID = "voicechat"; + public static VoicechatLogger LOGGER; + + public static int COMPATIBILITY_VERSION = BuildConstants.COMPATIBILITY_VERSION; + + public static ServerConfig SERVER_CONFIG; + public static Translations TRANSLATIONS; + public static ServerVoiceEvents SERVER; + + public static BukkitVoicechatServiceImpl apiService; + public static NetManager netManager; + public static Compatibility compatibility; + + public static final int MAX_GROUP_NAME_LENGTH = 24; + public static final Pattern GROUP_REGEX = Pattern.compile("^[^\\p{C}\\s][^\\p{C}]{0,23}$"); + + @Override + public void onEnable() { + INSTANCE = this; + LOGGER = new JavaLoggingLogger(getLogger()); + + if (debugMode()) { + LOGGER.warn("Running in debug mode - Don't leave this enabled in production!"); + } + + try { + compatibility = BukkitCompatibilityManager.loadCompatibility(); + if (compatibility == null) { + disablePlugin(); + return; + } + } catch (Throwable t) { + LOGGER.fatal("An unexpected error occurred while loading compatibility", t); + disablePlugin(); + return; + } + + LOGGER.info("Compatibility version {}", COMPATIBILITY_VERSION); + + SERVER_CONFIG = ConfigBuilder.builder(ServerConfig::new).path(getDataFolder().toPath().resolve("voicechat-server.properties")).build(); + TRANSLATIONS = ConfigBuilder.builder(Translations::new).path(getDataFolder().toPath().resolve("translations.properties")).build(); + + netManager = new NetManager(); + netManager.onEnable(); + + apiService = new BukkitVoicechatServiceImpl(); + getServer().getServicesManager().register(BukkitVoicechatService.class, apiService, this, ServicePriority.Normal); + + PluginCommand voicechatCommand = getCommand(VoiceChatCommands.VOICECHAT_COMMAND); + if (voicechatCommand != null) { + VoiceChatCommands voiceChatCommands = new VoiceChatCommands(); + voicechatCommand.setExecutor(voiceChatCommands); + voicechatCommand.setTabCompleter(voiceChatCommands); + try { + if (CommodoreProvider.isSupported()) { + Commodore commodore = CommodoreProvider.getCommodore(this); + CommodoreCommands.registerCompletions(commodore); + LOGGER.info("Successfully initialized commodore command completion"); + } else { + LOGGER.warn("Commodore command completion is not supported"); + } + } catch (MissingArgumentTypeException t) { + LOGGER.warn("Failed to initialize commodore command completion: {}", t.getMessage()); + } catch (Throwable t) { + LOGGER.warn("Failed to initialize commodore command completion", t); + } + } else { + LOGGER.error("Failed to register commands"); + } + + try { + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { + new VoicechatExpansion().register(); + LOGGER.info("Successfully registered PlaceholderAPI expansion"); + } + } catch (Throwable t) { + LOGGER.error("Failed to register PlaceholderAPI expansion", t); + } + + try { + if (Bukkit.getPluginManager().getPlugin("ViaVersion") != null) { + ViaVersionCompatibility.register(); + LOGGER.info("Successfully added ViaVersion mappings"); + } + } catch (Throwable t) { + LOGGER.error("Failed to add ViaVersion mappings", t); + } + + if (System.getProperty("VOICECHAT_RELOADED") != null) { + LOGGER.error("{} does not support reloads! Expect that things will break!", BuildConstants.PLUGIN_NAME); + } + System.setProperty("VOICECHAT_RELOADED", "true"); + + compatibility.runTask(() -> { + SERVER = new ServerVoiceEvents(); + PluginManager.instance().init(); + SERVER.init(); + + Bukkit.getPluginManager().registerEvents(SERVER, this); + ServerPlayerManager.init(this); + }); + } + + private void disablePlugin() { + LOGGER.fatal("Disabling {}", BuildConstants.PLUGIN_NAME); + Bukkit.getPluginManager().disablePlugin(this); + } + + @Override + public void onDisable() { + if (netManager != null) { + netManager.onDisable(); + } + getServer().getServicesManager().unregister(apiService); + if (SERVER != null) { + SERVER.getServer().close(); + } + } + + public static boolean debugMode() { + return System.getProperty("voicechat.debug") != null; + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/command/VoiceChatCommands.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/command/VoiceChatCommands.java similarity index 70% rename from source/decompiled/de/maxhenkel/voicechat/command/VoiceChatCommands.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/command/VoiceChatCommands.java index 6d74d14..086a3d3 100644 --- a/source/decompiled/de/maxhenkel/voicechat/command/VoiceChatCommands.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/command/VoiceChatCommands.java @@ -1,16 +1,6 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.command.Command - * org.bukkit.command.CommandExecutor - * org.bukkit.command.CommandSender - * org.bukkit.command.TabCompleter - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.command; +import de.maxhenkel.voicechat.BuildConstants; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.net.NetManager; import de.maxhenkel.voicechat.permission.PermissionManager; @@ -19,72 +9,76 @@ import de.maxhenkel.voicechat.voice.server.ClientConnection; import de.maxhenkel.voicechat.voice.server.Group; import de.maxhenkel.voicechat.voice.server.PingManager; import de.maxhenkel.voicechat.voice.server.Server; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; -import javax.annotation.Nullable; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; import org.bukkit.entity.Player; -public class VoiceChatCommands -implements CommandExecutor, -TabCompleter { +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +public class VoiceChatCommands implements CommandExecutor, TabCompleter { + public static final String VOICECHAT_COMMAND = "voicechat"; + @Override public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) { - if (VoiceChatCommands.checkNoVoicechat(commandSender)) { + if (checkNoVoicechat(commandSender)) { return true; } if (!(commandSender instanceof Player)) { return true; } - Player sender = (Player)commandSender; + Player sender = (Player) commandSender; + if (args.length >= 1) { if (args[0].equalsIgnoreCase("help")) { - return this.helpCommand(sender, command, label, args); - } - if (args[0].equalsIgnoreCase("test")) { + return helpCommand(sender, command, label, args); + } else if (args[0].equalsIgnoreCase("test")) { if (commandSender.hasPermission(PermissionManager.ADMIN_PERMISSION)) { - return this.testCommand(sender, command, label, args); + return testCommand(sender, command, label, args); + } else { + return true; } - return true; - } - if (args[0].equalsIgnoreCase("invite")) { - return this.inviteCommand(sender, command, label, args); - } - if (args[0].equalsIgnoreCase("join")) { - return this.joinCommand(sender, command, label, args); - } - if (args[0].equalsIgnoreCase("leave")) { - return this.leaveCommand(sender, command, label, args); + } else if (args[0].equalsIgnoreCase("invite")) { + return inviteCommand(sender, command, label, args); + } else if (args[0].equalsIgnoreCase("join")) { + return joinCommand(sender, command, label, args); + } else if (args[0].equalsIgnoreCase("leave")) { + return leaveCommand(sender, command, label, args); } } - return this.helpCommand(sender, command, label, args); + return helpCommand(sender, command, label, args); } @Nullable + @Override public List onTabComplete(CommandSender commandSender, Command command, String label, String[] args) { - String arg; if (args.length == 1) { - return this.tabCompleteList(args[0], Arrays.asList("help", "test", "invite", "join", "leave")); + return tabCompleteList(args[0], Arrays.asList("help", "test", "invite", "join", "leave")); } + if (args.length == 2) { - arg = args[0]; + String arg = args[0]; if (arg.equals("test") || arg.equals("invite")) { return null; + } else if (arg.startsWith("join")) { + return Collections.emptyList(); } + } + + if (args.length == 3) { + String arg = args[0]; if (arg.startsWith("join")) { return Collections.emptyList(); } } - if (args.length == 3 && (arg = args[0]).startsWith("join")) { - return Collections.emptyList(); - } + return Collections.emptyList(); } @@ -101,31 +95,33 @@ TabCompleter { return true; } - private boolean testCommand(final Player commandSender, Command command, String label, String[] args) { + private boolean testCommand(Player commandSender, Command command, String label, String[] args) { if (args.length < 2) { return false; } - Player player = VoiceChatCommands.parsePlayer((CommandSender)commandSender, args[1]); + + Player player = parsePlayer(commandSender, args[1]); + if (player == null) { - NetManager.sendMessage(commandSender, "argument.entity.notfound.player", new String[0]); + NetManager.sendMessage(commandSender, "argument.entity.notfound.player"); return true; } + if (!Voicechat.SERVER.isCompatible(player)) { - NetManager.sendMessage(commandSender, "message.voicechat.player_no_voicechat", player.getDisplayName(), "Simple Voice Chat"); + NetManager.sendMessage(commandSender, "message.voicechat.player_no_voicechat", player.getDisplayName(), BuildConstants.PLUGIN_NAME); return true; } + ClientConnection clientConnection = Voicechat.SERVER.getServer().getConnections().get(player.getUniqueId()); + if (clientConnection == null) { - NetManager.sendMessage(commandSender, "message.voicechat.client_not_connected", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.client_not_connected"); return true; } + try { - NetManager.sendMessage(commandSender, "message.voicechat.sending_ping", new String[0]); - Voicechat.SERVER.getServer().getPingManager().sendPing(clientConnection, 500L, 10, new PingManager.PingListener(){ - final /* synthetic */ VoiceChatCommands this$0; - { - this.this$0 = this$0; - } + NetManager.sendMessage(commandSender, "message.voicechat.sending_ping"); + Voicechat.SERVER.getServer().getPingManager().sendPing(clientConnection, 500, 10, new PingManager.PingListener() { @Override public void onPong(int attempts, long pingMilliseconds) { @@ -138,7 +134,7 @@ TabCompleter { @Override public void onFailedAttempt(int attempts) { - NetManager.sendMessage(commandSender, "message.voicechat.ping_retry", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.ping_retry"); } @Override @@ -146,9 +142,8 @@ TabCompleter { NetManager.sendMessage(commandSender, "message.voicechat.ping_timed_out", String.valueOf(attempts)); } }); - NetManager.sendMessage(commandSender, "message.voicechat.ping_sent_waiting", new String[0]); - } - catch (Exception e) { + NetManager.sendMessage(commandSender, "message.voicechat.ping_sent_waiting"); + } catch (Exception e) { NetManager.sendMessage(commandSender, "message.voicechat.failed_to_send_ping", e.getMessage()); Voicechat.LOGGER.warn("Failed to send ping", e); } @@ -159,128 +154,156 @@ TabCompleter { if (args.length < 2) { return false; } - Player player = VoiceChatCommands.parsePlayer((CommandSender)commandSender, args[1]); + + Player player = parsePlayer(commandSender, args[1]); + if (player == null || !Voicechat.compatibility.canSee(commandSender, player)) { - NetManager.sendMessage(commandSender, "argument.entity.notfound.player", new String[0]); + NetManager.sendMessage(commandSender, "argument.entity.notfound.player"); return true; } + PlayerState state = Voicechat.SERVER.getServer().getPlayerStateManager().getState(commandSender.getUniqueId()); + if (state == null || !state.hasGroup()) { - NetManager.sendMessage(commandSender, "message.voicechat.not_in_group", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.not_in_group"); return true; } + Group group = Voicechat.SERVER.getServer().getGroupManager().getGroup(state.getGroup()); if (group == null) { return true; } + if (!Voicechat.SERVER.isCompatible(player)) { - NetManager.sendMessage(commandSender, "message.voicechat.player_no_voicechat", player.getDisplayName(), "Simple Voice Chat"); + NetManager.sendMessage(commandSender, "message.voicechat.player_no_voicechat", player.getDisplayName(), BuildConstants.PLUGIN_NAME); return true; } + String passwordSuffix = group.getPassword() == null ? "" : " \"" + group.getPassword() + "\""; String cmd = "/voicechat join " + group.getId().toString() + passwordSuffix; Voicechat.compatibility.sendInviteMessage(player, commandSender, group.getName(), cmd); + NetManager.sendMessage(commandSender, "message.voicechat.invite_successful", player.getName()); + return true; } private boolean joinCommand(Player commandSender, Command command, String label, String[] args) { - UUID groupUUID; - int argIndex; if (args.length < 2) { return false; } + + int argIndex = 1; + UUID groupUUID; try { groupUUID = UUID.fromString(args[argIndex]); - } - catch (Exception e) { + } catch (Exception e) { String groupName; if (args[argIndex].startsWith("\"")) { - String[] split; StringBuilder sb = new StringBuilder(); - for (argIndex = 1; argIndex < args.length; ++argIndex) { + for (; argIndex < args.length; argIndex++) { sb.append(args[argIndex]).append(" "); - if (args[argIndex].endsWith("\"") && !args[argIndex].endsWith("\\\"")) break; + if (args[argIndex].endsWith("\"") && !args[argIndex].endsWith("\\\"")) { + break; + } } - if ((split = (groupName = sb.toString().trim()).split("\"")).length > 1) { + groupName = sb.toString().trim(); + String[] split = groupName.split("\""); + if (split.length > 1) { groupName = split[1]; } } else { groupName = args[argIndex]; } - groupUUID = this.getGroupUUID(commandSender, Voicechat.SERVER.getServer(), groupName); + groupUUID = getGroupUUID(commandSender, Voicechat.SERVER.getServer(), groupName); } + if (groupUUID == null) { return true; } + + argIndex++; + String password = null; - if (args.length >= ++argIndex + 1) { - String[] split; + if (args.length >= argIndex + 1) { StringBuilder sb = new StringBuilder(); - while (argIndex < args.length) { + for (; argIndex < args.length; argIndex++) { sb.append(args[argIndex]).append(" "); - ++argIndex; } password = sb.toString().trim(); - if (password.startsWith("\"") && (split = password.split("\"")).length > 1) { - password = split[1]; + if (password.startsWith("\"")) { + String[] split = password.split("\""); + if (split.length > 1) { + password = split[1]; + } } } - VoiceChatCommands.joinGroup(commandSender, groupUUID, password); + + joinGroup(commandSender, groupUUID, password); return true; } private UUID getGroupUUID(Player commandSender, Server server, String groupName) { - List groups = server.getGroupManager().getGroups().values().stream().filter(group -> group.getName().equals(groupName)).collect(Collectors.toList()); + List groups = server.getGroupManager().getGroups().values().stream().filter(group -> group.getName().equals(groupName)).collect(Collectors.toList()); + if (groups.isEmpty()) { - NetManager.sendMessage(commandSender, "message.voicechat.group_does_not_exist", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.group_does_not_exist"); return null; } + if (groups.size() > 1) { - NetManager.sendMessage(commandSender, "message.voicechat.group_name_not_unique", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.group_name_not_unique"); return null; } - return ((Group)groups.get(0)).getId(); + + return groups.get(0).getId(); } private static void joinGroup(Player commandSender, UUID groupID, @Nullable String password) { - if (!Voicechat.SERVER_CONFIG.groupsEnabled.get().booleanValue()) { - NetManager.sendMessage(commandSender, "message.voicechat.groups_disabled", new String[0]); + if (!Voicechat.SERVER_CONFIG.groupsEnabled.get()) { + NetManager.sendMessage(commandSender, "message.voicechat.groups_disabled"); return; } + Server server = Voicechat.SERVER.getServer(); + if (!commandSender.hasPermission(PermissionManager.GROUPS_PERMISSION)) { - NetManager.sendMessage(commandSender, "message.voicechat.no_group_permission", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.no_group_permission"); return; } + Group group = server.getGroupManager().getGroup(groupID); + if (group == null) { - NetManager.sendMessage(commandSender, "message.voicechat.group_does_not_exist", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.group_does_not_exist"); return; } + server.getGroupManager().joinGroup(group, commandSender, password); - NetManager.sendMessage(commandSender, "message.voicechat.join_successful", group.getName()); + NetManager.sendMessage(commandSender, "message.voicechat.join_successful", group.getName()); //TODO Make group name green } private boolean leaveCommand(Player commandSender, Command command, String label, String[] args) { - if (!Voicechat.SERVER_CONFIG.groupsEnabled.get().booleanValue()) { - NetManager.sendMessage(commandSender, "message.voicechat.groups_disabled", new String[0]); + if (!Voicechat.SERVER_CONFIG.groupsEnabled.get()) { + NetManager.sendMessage(commandSender, "message.voicechat.groups_disabled"); return true; } + Server server = Voicechat.SERVER.getServer(); PlayerState state = server.getPlayerStateManager().getState(commandSender.getUniqueId()); if (state == null || !state.hasGroup()) { - NetManager.sendMessage(commandSender, "message.voicechat.not_in_group", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.not_in_group"); return true; } + server.getGroupManager().leaveGroup(commandSender); - NetManager.sendMessage(commandSender, "message.voicechat.leave_successful", new String[0]); + NetManager.sendMessage(commandSender, "message.voicechat.leave_successful"); return true; } private static boolean checkNoVoicechat(CommandSender commandSender) { if (commandSender instanceof Player) { - if (Voicechat.SERVER.isCompatible((Player)commandSender)) { + if (Voicechat.SERVER.isCompatible((Player) commandSender)) { return false; } commandSender.sendMessage(String.format(Voicechat.TRANSLATIONS.voicechatNeededForCommandMessage.get(), "Simple Voice Chat")); @@ -299,10 +322,8 @@ TabCompleter { try { UUID uuid = UUID.fromString(playerArg); return commandSender.getServer().getPlayer(uuid); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { return null; } } -} - +} \ No newline at end of file diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/BaseCompatibility.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/BaseCompatibility.java new file mode 100644 index 0000000..056f2d4 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/BaseCompatibility.java @@ -0,0 +1,217 @@ +package de.maxhenkel.voicechat.compatibility; + +import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.util.Key; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.plugin.Plugin; + +import javax.annotation.Nullable; +import java.lang.reflect.Method; +import java.util.function.Consumer; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public abstract class BaseCompatibility implements Compatibility { + + private String baseBukkitPackage; + private String baseServerPackage; + + private Method addChannel; + private Method removeChannel; + @Nullable + private Class playerHideEntityEvent; + @Nullable + private Method playerHideEntityEventGetEntity; + @Nullable + private Class playerShowEntityEvent; + @Nullable + private Method playerShowEntityEventGetEntity; + private Consumer runTask; + private TaskScheduler taskScheduler; + + @Override + public void init() throws Exception { + Compatibility.super.init(); + + baseBukkitPackage = Bukkit.getServer().getClass().getPackage().getName(); + baseServerPackage = callMethod(Bukkit.getServer(), "getServer").getClass().getPackage().getName(); + + Class craftPlayer = getBukkitClass("entity.CraftPlayer"); + addChannel = getMethod(craftPlayer, new String[]{"addChannel"}, new Class[]{String.class}); + removeChannel = getMethod(craftPlayer, new String[]{"removeChannel"}, new Class[]{String.class}); + + try { + if (doesClassExist("org.bukkit.event.player.PlayerHideEntityEvent") && doesClassExist("org.bukkit.event.player.PlayerShowEntityEvent")) { + Class hide = ReflectionUtils.getClazz("org.bukkit.event.player.PlayerHideEntityEvent"); + if (!PlayerEvent.class.isAssignableFrom(hide)) { + throw new CompatibilityReflectionException("PlayerHideEntityEvent is not a subclass of PlayerEvent"); + } + + Class show = ReflectionUtils.getClazz("org.bukkit.event.player.PlayerShowEntityEvent"); + if (!PlayerEvent.class.isAssignableFrom(show)) { + throw new CompatibilityReflectionException("PlayerShowEntityEvent is not a subclass of PlayerEvent"); + } + playerShowEntityEventGetEntity = getMethod(show, "getEntity"); + playerHideEntityEventGetEntity = getMethod(hide, "getEntity"); + playerShowEntityEvent = (Class) show; + playerHideEntityEvent = (Class) hide; + } else { + Voicechat.LOGGER.warn("Vanish plugin integration is not supported"); + } + } catch (CompatibilityReflectionException e) { + Voicechat.LOGGER.warn("Vanish plugin integration is disabled"); + Voicechat.LOGGER.warn("Failed to load vanish compatibility", e); + playerHideEntityEvent = null; + playerShowEntityEvent = null; + } + + runTask = runnable -> Bukkit.getScheduler().runTask(Voicechat.INSTANCE, runnable); + taskScheduler = new TaskScheduler() { + @Override + public void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period) { + Bukkit.getScheduler().scheduleSyncRepeatingTask(Voicechat.INSTANCE, runnable, delay, period); + } + + @Override + public void runTaskLater(Runnable runnable, long delay) { + Bukkit.getScheduler().runTaskLater(Voicechat.INSTANCE, runnable, delay); + } + }; + if (doesMethodExist(Bukkit.class, "getGlobalRegionScheduler")) { + Object globalRegionScheduler = callMethod(Bukkit.class, "getGlobalRegionScheduler"); + + Method run = getMethod(globalRegionScheduler.getClass(), new String[]{"run"}, new Class[]{Plugin.class, Consumer.class}); + runTask = runnable -> call(run, globalRegionScheduler, Voicechat.INSTANCE, (Consumer) (task) -> runnable.run()); + + if ( + doesMethodExist(globalRegionScheduler.getClass(), "runAtFixedRate", Plugin.class, Consumer.class, long.class, long.class) + && doesMethodExist(globalRegionScheduler.getClass(), "runDelayed", Plugin.class, Consumer.class, long.class) + ) { + Method runAtFixedRate = getMethod(globalRegionScheduler.getClass(), new String[]{"runAtFixedRate"}, new Class[]{Plugin.class, Consumer.class, long.class, long.class}); + Method runDelayed = getMethod(globalRegionScheduler.getClass(), new String[]{"runDelayed"}, new Class[]{Plugin.class, Consumer.class, long.class}); + taskScheduler = new TaskScheduler() { + @Override + public void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period) { + call(runAtFixedRate, globalRegionScheduler, Voicechat.INSTANCE, (Consumer) (task) -> runnable.run(), delay <= 0 ? 1 : delay, period); + } + + @Override + public void runTaskLater(Runnable runnable, long delay) { + call(runDelayed, globalRegionScheduler, Voicechat.INSTANCE, (Consumer) (task) -> runnable.run(), delay <= 0 ? 1 : delay); + } + }; + } + } + } + + @Override + public void addChannel(Player player, String channel) { + call(addChannel, player, channel); + } + + @Override + public void removeChannel(Player player, String channel) { + call(removeChannel, player, channel); + } + + @Override + public Key createNamespacedKey(String key) { + return Key.of(key); + } + + @Override + public void runTask(Runnable runnable) { + runTask.accept(runnable); + } + + @Override + public void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period) { + taskScheduler.scheduleSyncRepeatingTask(runnable, delay, period); + } + + @Override + public void runTaskLater(Runnable runnable, long delay) { + taskScheduler.runTaskLater(runnable, delay); + } + + @Override + public boolean canSee(Player player, Player other) { + if (playerHideEntityEvent == null || playerShowEntityEvent == null) { + // Don't use canSee if hide and show events are missing + // This avoids state desyncs on older versions that have canSee but not the events + return true; + } + return player.canSee(other); + } + + @Override + public void registerPlayerHideEvent(Consumer event) { + if (playerHideEntityEvent == null) { + return; + } + Bukkit.getPluginManager().registerEvent( + playerHideEntityEvent, + new Listener() { + }, + EventPriority.NORMAL, + (listener, evt) -> { + if (!evt.getClass().isAssignableFrom(playerHideEntityEvent)) { + return; + } + PlayerEvent playerEvent = (PlayerEvent) evt; + Object entityObj = call(playerHideEntityEventGetEntity, playerEvent); + if (!(entityObj instanceof Player)) { + return; + } + event.accept(new PlayerHideEvent((Player) entityObj, playerEvent.getPlayer())); + }, + Voicechat.INSTANCE + ); + } + + @Override + public void registerPlayerShowEvent(Consumer event) { + if (playerShowEntityEvent == null) { + return; + } + Bukkit.getPluginManager().registerEvent( + playerShowEntityEvent, + new Listener() { + }, + EventPriority.NORMAL, + (listener, evt) -> { + if (!evt.getClass().isAssignableFrom(playerShowEntityEvent)) { + return; + } + PlayerEvent playerEvent = (PlayerEvent) evt; + Object entityObj = call(playerShowEntityEventGetEntity, playerEvent); + if (!(entityObj instanceof Player)) { + return; + } + event.accept(new PlayerShowEvent((Player) entityObj, playerEvent.getPlayer())); + }, + Voicechat.INSTANCE + ); + } + + @Override + public String getBaseBukkitPackage() { + return baseBukkitPackage; + } + + @Override + public String getBaseServerPackage() { + return baseServerPackage; + } + + private interface TaskScheduler { + void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period); + + void runTaskLater(Runnable runnable, long delay); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/BukkitCompatibilityManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/BukkitCompatibilityManager.java similarity index 78% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/BukkitCompatibilityManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/BukkitCompatibilityManager.java index 33b7e90..7fec88d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/BukkitCompatibilityManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/BukkitCompatibilityManager.java @@ -1,123 +1,16 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - */ package de.maxhenkel.voicechat.compatibility; import de.maxhenkel.voicechat.Version; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.compatibility.Compatibility; -import de.maxhenkel.voicechat.compatibility.Compatibility1_12; -import de.maxhenkel.voicechat.compatibility.Compatibility1_16; -import de.maxhenkel.voicechat.compatibility.Compatibility1_17; -import de.maxhenkel.voicechat.compatibility.Compatibility1_18; -import de.maxhenkel.voicechat.compatibility.Compatibility1_19; -import de.maxhenkel.voicechat.compatibility.Compatibility1_19_1; -import de.maxhenkel.voicechat.compatibility.Compatibility1_20; -import de.maxhenkel.voicechat.compatibility.Compatibility1_20_2; -import de.maxhenkel.voicechat.compatibility.Compatibility1_20_3; -import de.maxhenkel.voicechat.compatibility.Compatibility1_21_5; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.CompatibilityReflectionException; -import de.maxhenkel.voicechat.compatibility.FallbackCompatibility; -import de.maxhenkel.voicechat.compatibility.SpigotCompatibility; -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Nullable; import org.bukkit.Bukkit; +import javax.annotation.Nullable; +import java.util.HashMap; +import java.util.Map; + public class BukkitCompatibilityManager { - private static final Map COMPATIBILITIES = new HashMap(); - @Nullable - public static Compatibility loadCompatibility() { - Version forcedVersion = BukkitCompatibilityManager.getForcedVersion(); - Version version = forcedVersion != null ? forcedVersion : Version.getVersion(); - if (version == null) { - Voicechat.LOGGER.info("Failed to parse version {}, trying to fall back to Spigot API compatibility mode", Bukkit.getBukkitVersion()); - return BukkitCompatibilityManager.tryLoadSpigot(); - } - Voicechat.LOGGER.info("Initializing compatibility for version {}", version); - if (version.getMajor() == 1 && version.getMinor() <= 7) { - Voicechat.LOGGER.fatal("You are running a server that's too old to be able to join with any voice chat client", new Object[0]); - return null; - } - Compatibility compatibility = COMPATIBILITIES.get(version); - if (compatibility != null) { - try { - compatibility.init(); - } - catch (Throwable t) { - compatibility = null; - Voicechat.LOGGER.warn("Failed to load compatibility for version {}", version, t); - } - } - if (compatibility == null) { - Voicechat.LOGGER.warn("Incompatible version {}, trying to fall back to Spigot API compatibility mode", version); - compatibility = BukkitCompatibilityManager.tryLoadSpigot(); - } - if (compatibility == null) { - compatibility = FallbackCompatibility.INSTANCE; - try { - compatibility.init(); - Voicechat.LOGGER.warn("Falling back to Bukkit compatibility mode, expect issues and lack of features", new Object[0]); - Voicechat.LOGGER.warn("Chat messages won't be translatable", new Object[0]); - } - catch (CompatibilityReflectionException e) { - compatibility = null; - Voicechat.LOGGER.warn("Failed to load Bukkit compatibility mode: {}", e.getMessage()); - } - catch (Throwable t) { - compatibility = null; - Voicechat.LOGGER.warn("Failed to load Bukkit compatibility mode", t); - } - } - if (compatibility == null) { - Voicechat.LOGGER.fatal("Could not load any compatibility for {}", version); - } - return compatibility; - } - - @Nullable - private static Compatibility tryLoadSpigot() { - if (!SpigotCompatibility.isSpigotCompatible()) { - Voicechat.LOGGER.warn("Spigot API not found", new Object[0]); - return null; - } - SpigotCompatibility compatibility = SpigotCompatibility.INSTANCE; - try { - compatibility.init(); - Voicechat.LOGGER.warn("Falling back to Spigot API compatibility mode, expect issues and lack of features", new Object[0]); - } - catch (CompatibilityReflectionException e) { - compatibility = null; - Voicechat.LOGGER.warn("Failed to load Spigot API compatibility mode: {}", e.getMessage()); - } - catch (Throwable t) { - compatibility = null; - Voicechat.LOGGER.warn("Failed to load Spigot API compatibility mode", t); - } - return compatibility; - } - - @Nullable - public static Version getForcedVersion() { - String property = System.getProperty("voicechat.compatibility"); - if (property == null) { - return null; - } - Version forcedVersion = Version.parse(property); - if (forcedVersion == null) { - Voicechat.LOGGER.warn("Failed to parse forced compatibility version: {}", property); - return null; - } - Voicechat.LOGGER.info("Forcing compatibility for {}", forcedVersion); - Voicechat.LOGGER.warn("Forcing version compatibility could lead to issues - use with caution!", new Object[0]); - return forcedVersion; - } + private static final Map COMPATIBILITIES = new HashMap<>(); static { COMPATIBILITIES.put(Compatibility1_21_5.VERSION_PAPER_26_3, Compatibility1_21_5.INSTANCE); @@ -169,5 +62,102 @@ public class BukkitCompatibilityManager { COMPATIBILITIES.put(Compatibility1_12.VERSION_1_12, Compatibility1_12.INSTANCE); COMPATIBILITIES.put(Compatibility1_8.VERSION_1_8_8, Compatibility1_8.INSTANCE); } -} + @Nullable + public static Compatibility loadCompatibility() { + Version version; + + Version forcedVersion = getForcedVersion(); + if (forcedVersion != null) { + version = forcedVersion; + } else { + version = Version.getVersion(); + } + + if (version == null) { + Voicechat.LOGGER.info("Failed to parse version {}, trying to fall back to Spigot API compatibility mode", Bukkit.getBukkitVersion()); + return tryLoadSpigot(); + } + + Voicechat.LOGGER.info("Initializing compatibility for version {}", version); + + if (version.getMajor() == 1 && version.getMinor() <= 7) { + Voicechat.LOGGER.fatal("You are running a server that's too old to be able to join with any voice chat client"); + return null; + } + + Compatibility compatibility = COMPATIBILITIES.get(version); + if (compatibility != null) { + try { + compatibility.init(); + } catch (Throwable t) { + compatibility = null; + Voicechat.LOGGER.warn("Failed to load compatibility for version {}", version, t); + } + } + if (compatibility == null) { + Voicechat.LOGGER.warn("Incompatible version {}, trying to fall back to Spigot API compatibility mode", version); + compatibility = tryLoadSpigot(); + } + + if (compatibility == null) { + compatibility = FallbackCompatibility.INSTANCE; + try { + compatibility.init(); + Voicechat.LOGGER.warn("Falling back to Bukkit compatibility mode, expect issues and lack of features"); + Voicechat.LOGGER.warn("Chat messages won't be translatable"); + } catch (CompatibilityReflectionException e) { + compatibility = null; + // Only log the message in case reflection fails + Voicechat.LOGGER.warn("Failed to load Bukkit compatibility mode: {}", e.getMessage()); + } catch (Throwable t) { + compatibility = null; + Voicechat.LOGGER.warn("Failed to load Bukkit compatibility mode", t); + } + } + + if (compatibility == null) { + Voicechat.LOGGER.fatal("Could not load any compatibility for {}", version); + } + + return compatibility; + } + + @Nullable + private static Compatibility tryLoadSpigot() { + if (!SpigotCompatibility.isSpigotCompatible()) { + Voicechat.LOGGER.warn("Spigot API not found"); + return null; + } + Compatibility compatibility = SpigotCompatibility.INSTANCE; + try { + compatibility.init(); + Voicechat.LOGGER.warn("Falling back to Spigot API compatibility mode, expect issues and lack of features"); + } catch (CompatibilityReflectionException e) { + compatibility = null; + // Only log the message in case reflection fails + Voicechat.LOGGER.warn("Failed to load Spigot API compatibility mode: {}", e.getMessage()); + } catch (Throwable t) { + compatibility = null; + Voicechat.LOGGER.warn("Failed to load Spigot API compatibility mode", t); + } + return compatibility; + } + + @Nullable + public static Version getForcedVersion() { + String property = System.getProperty("voicechat.compatibility"); + if (property == null) { + return null; + } + Version forcedVersion = Version.parse(property); + if (forcedVersion == null) { + Voicechat.LOGGER.warn("Failed to parse forced compatibility version: {}", property); + return null; + } + Voicechat.LOGGER.info("Forcing compatibility for {}", forcedVersion); + Voicechat.LOGGER.warn("Forcing version compatibility could lead to issues - use with caution!"); + return forcedVersion; + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility.java new file mode 100644 index 0000000..df2993d --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility.java @@ -0,0 +1,76 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.util.Key; +import org.bukkit.entity.Player; + +import javax.annotation.Nullable; +import java.util.function.Consumer; + +public interface Compatibility { + + default void init() throws Exception { + + } + + void addChannel(Player player, String channel); + + void removeChannel(Player player, String channel); + + Key createNamespacedKey(String key); + + void sendTranslationMessage(Player player, String key, String... args); + + void sendStatusMessage(Player player, String key, String... args); + + void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand); + + void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName); + + void runTask(Runnable runnable); + + void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period); + + void runTaskLater(Runnable runnable, long delay); + + boolean canSee(Player player, Player other); + + void registerPlayerHideEvent(Consumer event); + + void registerPlayerShowEvent(Consumer event); + + @Nullable + ArgumentType playerArgument(); + + @Nullable + ArgumentType uuidArgument(); + + String getBaseBukkitPackage(); + + String getBaseServerPackage(); + + /** + * @param classNames the class names including the package name, starting after the bukkit the base package e.g. org.bukkit.craftbukkit.v1_20_R3.CraftServer would be CraftServer + * @return the class + */ + default Class getBukkitClass(String... classNames) { + for (String className : classNames) { + try { + return Class.forName(String.format("%s.%s", getBaseBukkitPackage(), className)); + } catch (Throwable ignored) { + } + } + throw new CompatibilityReflectionException(String.format("Could not find any of the following classes: %s", String.join(", ", classNames))); + } + + default Class getServerClass(String... classNames) { + for (String className : classNames) { + try { + return Class.forName(String.format("%s.%s", getBaseServerPackage(), className)); + } catch (Throwable ignored) { + } + } + throw new CompatibilityReflectionException(String.format("Could not find any of the following classes: %s", String.join(", ", classNames))); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_12.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_12.java new file mode 100644 index 0000000..95a2ace --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_12.java @@ -0,0 +1,82 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import de.maxhenkel.voicechat.util.Key; +import org.bukkit.entity.Player; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_12 extends JsonMessageBaseCompatibility { + + public static final String CHANNEL = "vc"; + + public static final BukkitVersion VERSION_1_12_2 = BukkitVersion.parseBukkitVersion("1.12.2-R0.1"); + public static final BukkitVersion VERSION_1_12_1 = BukkitVersion.parseBukkitVersion("1.12.1-R0.1"); + public static final BukkitVersion VERSION_1_12 = BukkitVersion.parseBukkitVersion("1.12-R0.1"); + + public static final Compatibility1_12 INSTANCE = new Compatibility1_12(); + + @Override + public Key createNamespacedKey(String key) { + return Key.of(CHANNEL, key); + } + + @Override + public void sendJsonMessage(Player player, String json) { + Class chatMessageTypeClass = getServerClass("ChatMessageType"); + Object b = getField(chatMessageTypeClass, "CHAT"); + send(player, json, b); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + Class chatMessageTypeClass = getServerClass("ChatMessageType"); + Object b = getField(chatMessageTypeClass, "GAME_INFO"); + send(player, json, b); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + return null; + } + + @Override + public ArgumentType uuidArgument() { + return null; + } + + private void send(Player player, String json, Object chatMessageType) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "playerConnection"); + Class packet = getServerClass("Packet"); + Class chatSerializer = getServerClass("IChatBaseComponent$ChatSerializer"); + + Class iChatBaseComponentClass = getServerClass("IChatBaseComponent"); + Object iChatBaseComponent = callMethod(chatSerializer, "a", new Class[]{String.class}, json); + + Class packetPlayOutChatClass = getServerClass("PacketPlayOutChat"); + + Class chatMessageTypeClass = getServerClass("ChatMessageType"); + + Object clientboundSystemChatPacket = callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass}, iChatBaseComponent, chatMessageType); + + callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_16.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_16.java new file mode 100644 index 0000000..cdb4e86 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_16.java @@ -0,0 +1,84 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import java.util.UUID; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_16 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_16_5 = BukkitVersion.parseBukkitVersion("1.16.5-R0.1"); + public static final BukkitVersion VERSION_1_16_4 = BukkitVersion.parseBukkitVersion("1.16.4-R0.1"); + public static final BukkitVersion VERSION_1_16_3 = BukkitVersion.parseBukkitVersion("1.16.3-R0.1"); + public static final BukkitVersion VERSION_1_16_2 = BukkitVersion.parseBukkitVersion("1.16.2-R0.1"); + public static final BukkitVersion VERSION_1_16_1 = BukkitVersion.parseBukkitVersion("1.16.1-R0.1"); + public static final BukkitVersion VERSION_1_16 = BukkitVersion.parseBukkitVersion("1.16-R0.1"); + + public static final Compatibility1_16 INSTANCE = new Compatibility1_16(); + + @Override + public void sendJsonMessage(Player player, String json) { + Class chatMessageTypeClass = getServerClass("ChatMessageType"); + Object b = getField(chatMessageTypeClass, "CHAT"); + send(player, json, b); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + Class chatMessageTypeClass = getServerClass("ChatMessageType"); + Object b = getField(chatMessageTypeClass, "GAME_INFO"); + send(player, json, b); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + Class argumentEntity = getServerClass("ArgumentEntity"); + return callMethod(argumentEntity, "c"); + } + + @Override + public ArgumentType uuidArgument() { + Class argumentEntity = getServerClass("ArgumentUUID"); + return callMethod(argumentEntity, "a"); + } + + private static final UUID NUL_UUID = new UUID(0L, 0L); + + private void send(Player player, String json, Object chatMessageType) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "playerConnection"); + Class packet = getServerClass("Packet"); + Class chatSerializer = getServerClass("IChatBaseComponent$ChatSerializer"); + + Class iChatBaseComponentClass = getServerClass("IChatBaseComponent"); + + Object iChatBaseComponent = callMethod(chatSerializer, "a", new Class[]{String.class}, json); + + Class packetPlayOutChatClass = getServerClass("PacketPlayOutChat"); + + Class chatMessageTypeClass = getServerClass("ChatMessageType"); + + Object clientboundSystemChatPacket = callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID); + + callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_17.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_17.java new file mode 100644 index 0000000..a14acfa --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_17.java @@ -0,0 +1,77 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import java.util.UUID; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_17 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_17_1 = BukkitVersion.parseBukkitVersion("1.17.1-R0.1"); + public static final BukkitVersion VERSION_1_17 = BukkitVersion.parseBukkitVersion("1.17-R0.1"); + + public static final Compatibility1_17 INSTANCE = new Compatibility1_17(); + + @Override + public void sendJsonMessage(Player player, String json) { + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + Object b = getField(chatMessageTypeClass, "b"); + send(player, json, b); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + Object b = getField(chatMessageTypeClass, "c"); + send(player, json, b); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + return Compatibility1_19.INSTANCE.playerArgument(); + } + + @Override + public ArgumentType uuidArgument() { + return Compatibility1_19.INSTANCE.uuidArgument(); + } + + private static final UUID NUL_UUID = new UUID(0L, 0L); + + private void send(Player player, String json, Object chatMessageType) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "b"); + Class packet = getClazz("net.minecraft.network.protocol.Packet"); + Class craftChatMessage = getBukkitClass("util.CraftChatMessage"); + + Class iChatBaseComponentClass = getClazz("net.minecraft.network.chat.IChatBaseComponent"); + Object iChatBaseComponent = callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); + + Class packetPlayOutChatClass = getClazz("net.minecraft.network.protocol.game.PacketPlayOutChat"); + + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + + Object clientboundSystemChatPacket = callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID); + + callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java new file mode 100644 index 0000000..d3dcf0c --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java @@ -0,0 +1,78 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import java.util.UUID; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_18 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_18_2 = BukkitVersion.parseBukkitVersion("1.18.2-R0.1"); + public static final BukkitVersion VERSION_1_18_1 = BukkitVersion.parseBukkitVersion("1.18.1-R0.1"); + public static final BukkitVersion VERSION_1_18 = BukkitVersion.parseBukkitVersion("1.18-R0.1"); + + public static final Compatibility1_18 INSTANCE = new Compatibility1_18(); + + @Override + public void sendJsonMessage(Player player, String json) { + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + Object b = getField(chatMessageTypeClass, "b"); + send(player, json, b); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + Object b = getField(chatMessageTypeClass, "c"); + send(player, json, b); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + return Compatibility1_19.INSTANCE.playerArgument(); + } + + @Override + public ArgumentType uuidArgument() { + return Compatibility1_19.INSTANCE.uuidArgument(); + } + + private static final UUID NUL_UUID = new UUID(0L, 0L); + + private void send(Player player, String json, Object chatMessageType) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "b"); + Class packet = getClazz("net.minecraft.network.protocol.Packet"); + Class craftChatMessage = getBukkitClass("util.CraftChatMessage"); + + Class iChatBaseComponentClass = getClazz("net.minecraft.network.chat.IChatBaseComponent"); + Object iChatBaseComponent = callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); + + Class packetPlayOutChatClass = getClazz("net.minecraft.network.protocol.game.PacketPlayOutChat"); + + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + + Object clientboundSystemChatPacket = callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID); + + callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_19.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_19.java new file mode 100644 index 0000000..82f603a --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_19.java @@ -0,0 +1,91 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_19 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_19 = BukkitVersion.parseBukkitVersion("1.19-R0.1"); + + public static final Compatibility1_19 INSTANCE = new Compatibility1_19(); + + @Override + public void sendJsonMessage(Player player, String json) { + send(player, json, false); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + send(player, json, true); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + return Compatibility1_19_1.INSTANCE.playerArgument(); + } + + @Override + public ArgumentType uuidArgument() { + return Compatibility1_19_1.INSTANCE.uuidArgument(); + } + + private void send(Player player, String json, boolean status) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "b"); + Class packet = getClazz("net.minecraft.network.protocol.Packet"); + Class craftChatMessage = getBukkitClass("util.CraftChatMessage"); + + Class iChatBaseComponentClass = getClazz("net.minecraft.network.chat.IChatBaseComponent"); + Object iChatBaseComponent = callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); + + Class clientboundSystemChatPacketClass = getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); + + Object clientboundSystemChatPacket = callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, int.class}, iChatBaseComponent, getId(player, status)); + + callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); + } + + private int getId(Player player, boolean status) { + Object world = callMethod(player.getWorld(), "getHandle"); + Class iRegistryCustomClass = getClazz("net.minecraft.core.IRegistryCustom"); + Object iRegistryCustom = callMethod(world, "s"); + + Class resourceKeyClass = getClazz("net.minecraft.resources.ResourceKey"); + + Class iRegistry = getClazz("net.minecraft.core.IRegistry"); + Object resourceKey = getField(iRegistry, "bI"); + + Object registry = callMethod(iRegistryCustomClass, iRegistryCustom, "d", new Class[]{resourceKeyClass}, resourceKey); + + Class chatMessageTypeClass = getClazz("net.minecraft.network.chat.ChatMessageType"); + Object chatMessageType; + if (status) { + chatMessageType = getField(chatMessageTypeClass, "d"); + } else { + chatMessageType = getField(chatMessageTypeClass, "c"); + } + + Object messageType = callMethod(registry, "a", new Class[]{resourceKeyClass}, chatMessageType); + + return callMethod(registry, "a", new Class[]{Object.class}, messageType); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_19_1.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_19_1.java new file mode 100644 index 0000000..6ea4be7 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_19_1.java @@ -0,0 +1,71 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_19_1 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_19_4 = BukkitVersion.parseBukkitVersion("1.19.4-R0.1"); + public static final BukkitVersion VERSION_1_19_3 = BukkitVersion.parseBukkitVersion("1.19.3-R0.1"); + public static final BukkitVersion VERSION_1_19_2 = BukkitVersion.parseBukkitVersion("1.19.2-R0.1"); + public static final BukkitVersion VERSION_1_19_1 = BukkitVersion.parseBukkitVersion("1.19.1-R0.1"); + + public static final Compatibility1_19_1 INSTANCE = new Compatibility1_19_1(); + + @Override + public void sendJsonMessage(Player player, String json) { + send(player, json, false); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + send(player, json, true); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + Class argumentEntity = getClazz("net.minecraft.commands.arguments.ArgumentEntity"); + return callMethod(argumentEntity, "c"); + } + + @Override + public ArgumentType uuidArgument() { + Class argumentEntity = getClazz("net.minecraft.commands.arguments.ArgumentUUID"); + return callMethod(argumentEntity, "a"); + } + + private void send(Player player, String json, boolean status) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "b"); + Class packet = getClazz("net.minecraft.network.protocol.Packet"); + Class craftChatMessage = getBukkitClass("util.CraftChatMessage"); + + Class iChatBaseComponentClass = getClazz("net.minecraft.network.chat.IChatBaseComponent"); + Object iChatBaseComponent = callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); + + Class clientboundSystemChatPacketClass = getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); + + Object clientboundSystemChatPacket = callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, boolean.class}, iChatBaseComponent, status); + + callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20.java new file mode 100644 index 0000000..0a74585 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20.java @@ -0,0 +1,69 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_20 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_20 = BukkitVersion.parseBukkitVersion("1.20-R0.1"); + public static final BukkitVersion VERSION_1_20_1 = BukkitVersion.parseBukkitVersion("1.20.1-R0.1"); + + public static final Compatibility1_20 INSTANCE = new Compatibility1_20(); + + @Override + public void sendJsonMessage(Player player, String json) { + send(player, json, false); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + send(player, json, true); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + Class argumentEntity = getClazz("net.minecraft.commands.arguments.ArgumentEntity"); + return callMethod(argumentEntity, "c"); + } + + @Override + public ArgumentType uuidArgument() { + Class argumentEntity = getClazz("net.minecraft.commands.arguments.ArgumentUUID"); + return callMethod(argumentEntity, "a"); + } + + private void send(Player player, String json, boolean status) { + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "c"); + Class packet = getClazz("net.minecraft.network.protocol.Packet"); + Class craftChatMessage = getBukkitClass("util.CraftChatMessage"); + + Class iChatBaseComponentClass = getClazz("net.minecraft.network.chat.IChatBaseComponent"); + Object iChatBaseComponent = callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); + + Class clientboundSystemChatPacketClass = getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); + + Object clientboundSystemChatPacket = callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, boolean.class}, iChatBaseComponent, status); + + callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20_2.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20_2.java new file mode 100644 index 0000000..ce11b0b --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20_2.java @@ -0,0 +1,60 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_20_2 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_20_2 = BukkitVersion.parseBukkitVersion("1.20.2-R0.1"); + + public static final Compatibility1_20_2 INSTANCE = new Compatibility1_20_2(); + + @Override + public void sendJsonMessage(Player player, String json) { + send(player, json, false); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + send(player, json, true); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + Class argumentEntity = getClazz("net.minecraft.commands.arguments.ArgumentEntity"); + return callMethod(argumentEntity, "c"); + } + + @Override + public ArgumentType uuidArgument() { + Class argumentEntity = getClazz("net.minecraft.commands.arguments.ArgumentUUID"); + return callMethod(argumentEntity, "a"); + } + + private void send(Player player, String json, boolean status) { + Object entityPlayer = callMethod(player, "getHandle"); + Class iChatBaseComponentClass = getClazz("net.minecraft.network.chat.IChatBaseComponent"); + Class craftChatMessage = getBukkitClass("util.CraftChatMessage"); + Object iChatBaseComponent = callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); + callMethod(entityPlayer, "a", new Class[]{iChatBaseComponentClass, boolean.class}, iChatBaseComponent, status); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20_3.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20_3.java new file mode 100644 index 0000000..f5b7106 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_20_3.java @@ -0,0 +1,97 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import de.maxhenkel.voicechat.BukkitVersion; +import org.bukkit.entity.Player; + +import java.lang.reflect.Method; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_20_3 extends JsonMessageBaseCompatibility { + + public static final BukkitVersion VERSION_1_20_3 = BukkitVersion.parseBukkitVersion("1.20.3-R0.1"); + public static final BukkitVersion VERSION_1_20_4 = BukkitVersion.parseBukkitVersion("1.20.4-R0.1"); + public static final BukkitVersion VERSION_1_20_5 = BukkitVersion.parseBukkitVersion("1.20.5-R0.1"); + public static final BukkitVersion VERSION_1_20_6 = BukkitVersion.parseBukkitVersion("1.20.6-R0.1"); + public static final BukkitVersion VERSION_1_21 = BukkitVersion.parseBukkitVersion("1.21-R0.1"); + public static final BukkitVersion VERSION_1_21_1 = BukkitVersion.parseBukkitVersion("1.21.1-R0.1"); + public static final BukkitVersion VERSION_1_21_2 = BukkitVersion.parseBukkitVersion("1.21.2-R0.1"); + public static final BukkitVersion VERSION_1_21_3 = BukkitVersion.parseBukkitVersion("1.21.3-R0.1"); + public static final BukkitVersion VERSION_1_21_4 = BukkitVersion.parseBukkitVersion("1.21.4-R0.1"); + + public static final Compatibility1_20_3 INSTANCE = new Compatibility1_20_3(); + + private Method playerArgument; + private Method uuidArgument; + private Method fromJson; + private Method getHandle; + private Method sendSystemMessage; + + public void init() throws Exception { + super.init(); + + Class argumentEntityClass = getClazz( + "net.minecraft.commands.arguments.ArgumentEntity", + "net.minecraft.commands.arguments.EntityArgument" + ); + playerArgument = getMethod(argumentEntityClass, "c", "entity"); + + Class argumentUuidClass = getClazz( + "net.minecraft.commands.arguments.ArgumentUUID", + "net.minecraft.commands.arguments.UuidArgument" + ); + uuidArgument = getMethod(argumentUuidClass, "a", "uuid"); + + Class craftPlayer = getBukkitClass("entity.CraftPlayer"); + getHandle = getMethod(craftPlayer, "getHandle"); + Class componentClass = getClazz( + "net.minecraft.network.chat.IChatBaseComponent", + "net.minecraft.network.chat.Component" + ); + Class craftChatMessageClass = getBukkitClass("util.CraftChatMessage"); + fromJson = getMethod(craftChatMessageClass, new String[]{"fromJSON"}, new Class[]{String.class}); + Class player = getClazz("net.minecraft.server.level.EntityPlayer", "net.minecraft.server.level.ServerPlayer"); + sendSystemMessage = getMethod(player, new String[]{"a", "sendSystemMessage"}, new Class[]{componentClass, boolean.class}); + } + + @Override + public void sendJsonMessage(Player player, String json) { + send(player, json, false); + } + + @Override + public void sendJsonStatusMessage(Player player, String json) { + send(player, json, true); + } + + @Override + public String createTranslationMessage(String key, String... args) { + return Compatibility1_8.constructTranslationMessage(key, args); + } + + @Override + public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { + sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + } + + @Override + public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { + sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + } + + @Override + public ArgumentType playerArgument() { + return call(playerArgument, null); + } + + @Override + public ArgumentType uuidArgument() { + return call(uuidArgument, null); + } + + protected void send(Player player, String json, boolean status) { + call(sendSystemMessage, call(getHandle, player), call(fromJson, null, json), status); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_21_5.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_21_5.java similarity index 88% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_21_5.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_21_5.java index 76588af..ec2a68e 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_21_5.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_21_5.java @@ -1,20 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.compatibility; import de.maxhenkel.voicechat.BukkitVersion; import de.maxhenkel.voicechat.PaperVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_20_3; -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONObject; import org.bukkit.entity.Player; +import org.json.JSONArray; +import org.json.JSONObject; + +public class Compatibility1_21_5 extends Compatibility1_20_3 { -public class Compatibility1_21_5 -extends Compatibility1_20_3 { public static final BukkitVersion VERSION_1_21_5 = BukkitVersion.parseBukkitVersion("1.21.5-R0.1"); public static final BukkitVersion VERSION_1_21_6 = BukkitVersion.parseBukkitVersion("1.21.6-R0.1"); public static final BukkitVersion VERSION_1_21_7 = BukkitVersion.parseBukkitVersion("1.21.7-R0.1"); @@ -31,43 +24,55 @@ extends Compatibility1_20_3 { public static final PaperVersion VERSION_PAPER_26_2 = PaperVersion.parsePaperVersion("26.2.build.0"); public static final BukkitVersion VERSION_26_3 = BukkitVersion.parseBukkitVersion("26.3-R0.1"); public static final PaperVersion VERSION_PAPER_26_3 = PaperVersion.parsePaperVersion("26.3.build.0"); + public static final Compatibility1_21_5 INSTANCE = new Compatibility1_21_5(); @Override public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_21_5.constructInviteMessage(commandSender, groupName, joinCommand)); + sendJsonMessage(player, constructInviteMessage(commandSender, groupName, joinCommand)); } public static String constructInviteMessage(Player commandSender, String groupName, String joinCommand) { JSONObject msg = new JSONObject(); msg.put("translate", "message.voicechat.invite"); + JSONArray args = new JSONArray(); + args.put(commandSender.getName()); + JSONObject groupNameObj = new JSONObject(); groupNameObj.put("color", "gray"); groupNameObj.put("text", groupName); args.put(groupNameObj); + JSONObject acceptInBrackets = new JSONObject(); acceptInBrackets.put("translate", "chat.square_brackets"); acceptInBrackets.put("color", "green"); JSONArray withBrackets = new JSONArray(); + JSONObject accept = new JSONObject(); accept.put("translate", "message.voicechat.accept_invite"); + JSONObject clickEvent = new JSONObject(); clickEvent.put("action", "run_command"); clickEvent.put("command", joinCommand); accept.put("click_event", clickEvent); + JSONObject hoverEvent = new JSONObject(); hoverEvent.put("action", "show_text"); JSONObject contents = new JSONObject(); contents.put("translate", "message.voicechat.accept_invite.hover"); hoverEvent.put("value", contents); accept.put("hover_event", hoverEvent); + withBrackets.put(accept); + acceptInBrackets.put("with", withBrackets); args.put(acceptInBrackets); + msg.put("with", args); + return msg.toString(); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_8.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_8.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_8.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_8.java index afecbcc..0240a7d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_8.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/Compatibility1_8.java @@ -1,47 +1,41 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.compatibility; import com.mojang.brigadier.arguments.ArgumentType; import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONObject; import de.maxhenkel.voicechat.util.Key; import org.bukkit.entity.Player; +import org.json.JSONArray; +import org.json.JSONObject; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class Compatibility1_8 extends JsonMessageBaseCompatibility { -public class Compatibility1_8 -extends JsonMessageBaseCompatibility { public static final BukkitVersion VERSION_1_8_8 = BukkitVersion.parseBukkitVersion("1.8.8-R0.1"); + public static final Compatibility1_8 INSTANCE = new Compatibility1_8(); @Override public Key createNamespacedKey(String key) { - return Key.of("vc", key); + return Key.of(Compatibility1_12.CHANNEL, key); } @Override public void sendJsonMessage(Player player, String json) { - this.send(player, json, (byte)0); + send(player, json, (byte) 0); } @Override public void sendJsonStatusMessage(Player player, String json) { - this.send(player, json, (byte)2); + send(player, json, (byte) 2); } @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); + public String createTranslationMessage(String key, String... args) { + return constructTranslationMessage(key, args); } - public static String constructTranslationMessage(String key, String ... args) { + public static String constructTranslationMessage(String key, String... args) { JSONObject msg = new JSONObject(); msg.put("translate", key); msg.put("with", args); @@ -50,45 +44,56 @@ extends JsonMessageBaseCompatibility { @Override public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); + sendJsonMessage(player, constructInviteMessage(commandSender, groupName, joinCommand)); } @Override public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); + sendJsonMessage(player, constructIncompatibleMessage(pluginVersion, pluginName)); } public static String constructInviteMessage(Player commandSender, String groupName, String joinCommand) { JSONObject msg = new JSONObject(); msg.put("translate", "message.voicechat.invite"); + JSONArray args = new JSONArray(); + args.put(commandSender.getName()); + JSONObject groupNameObj = new JSONObject(); groupNameObj.put("color", "gray"); groupNameObj.put("text", groupName); args.put(groupNameObj); + JSONObject acceptInBrackets = new JSONObject(); acceptInBrackets.put("text", "["); acceptInBrackets.put("color", "green"); JSONArray extra = new JSONArray(); + JSONObject accept = new JSONObject(); accept.put("translate", "message.voicechat.accept_invite"); accept.put("color", "green"); + JSONObject clickEvent = new JSONObject(); clickEvent.put("action", "run_command"); clickEvent.put("value", joinCommand); accept.put("clickEvent", clickEvent); + JSONObject hoverEvent = new JSONObject(); hoverEvent.put("action", "show_text"); JSONObject contents = new JSONObject(); contents.put("translate", "message.voicechat.accept_invite.hover"); hoverEvent.put("contents", contents); accept.put("hoverEvent", hoverEvent); + extra.put(accept); extra.put("]"); + acceptInBrackets.put("extra", extra); args.put(acceptInBrackets); + msg.put("with", args); + return msg.toString(); } @@ -96,14 +101,17 @@ extends JsonMessageBaseCompatibility { JSONObject msg = new JSONObject(); msg.put("translate", "message.voicechat.incompatible_version"); JSONArray with = new JSONArray(); + JSONObject version = new JSONObject(); version.put("text", pluginVersion); version.put("bold", true); with.put(version); + JSONObject name = new JSONObject(); name.put("text", pluginName); name.put("bold", true); with.put(name); + msg.put("with", with); return msg.toString(); } @@ -119,15 +127,19 @@ extends JsonMessageBaseCompatibility { } private void send(Player player, String json, byte chatMessageType) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "playerConnection"); - Class packet = this.getServerClass("Packet"); - Class chatSerializer = this.getServerClass("IChatBaseComponent$ChatSerializer"); - Class iChatBaseComponentClass = this.getServerClass("IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(chatSerializer, "a", new Class[]{String.class}, json); - Class packetPlayOutChatClass = this.getServerClass("PacketPlayOutChat"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, Byte.TYPE}, iChatBaseComponent, chatMessageType); - ReflectionUtils.callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); - } -} + Object entityPlayer = callMethod(player, "getHandle"); + Object playerConnection = getField(entityPlayer, "playerConnection"); + Class packet = getServerClass("Packet"); + Class chatSerializer = getServerClass("IChatBaseComponent$ChatSerializer"); + Class iChatBaseComponentClass = getServerClass("IChatBaseComponent"); + Object iChatBaseComponent = callMethod(chatSerializer, "a", new Class[]{String.class}, json); + + Class packetPlayOutChatClass = getServerClass("PacketPlayOutChat"); + + Object clientboundSystemChatPacket = callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, byte.class}, iChatBaseComponent, chatMessageType); + + callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/CompatibilityReflectionException.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/CompatibilityReflectionException.java similarity index 70% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/CompatibilityReflectionException.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/CompatibilityReflectionException.java index 2b8465f..c225a90 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/CompatibilityReflectionException.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/CompatibilityReflectionException.java @@ -1,10 +1,7 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.compatibility; -public class CompatibilityReflectionException -extends RuntimeException { +public class CompatibilityReflectionException extends RuntimeException { + public CompatibilityReflectionException(String message) { super(message); } @@ -12,5 +9,5 @@ extends RuntimeException { public CompatibilityReflectionException(String message, Throwable cause) { super(message, cause); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/FallbackCompatibility.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/FallbackCompatibility.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/FallbackCompatibility.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/FallbackCompatibility.java index b310e63..e8962fd 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/FallbackCompatibility.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/FallbackCompatibility.java @@ -1,43 +1,35 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.compatibility; import com.mojang.brigadier.arguments.ArgumentType; import de.maxhenkel.voicechat.FallbackTranslations; import de.maxhenkel.voicechat.Version; -import de.maxhenkel.voicechat.compatibility.BaseCompatibility; import de.maxhenkel.voicechat.util.Key; -import javax.annotation.Nullable; import org.bukkit.entity.Player; -public class FallbackCompatibility -extends BaseCompatibility { +import javax.annotation.Nullable; + +public class FallbackCompatibility extends BaseCompatibility { + public static final FallbackCompatibility INSTANCE = new FallbackCompatibility(); @Override - public void sendTranslationMessage(Player player, String key, String ... args) { - player.sendMessage(FallbackCompatibility.fallbackTranslation(key, args)); + public void sendTranslationMessage(Player player, String key, String... args) { + player.sendMessage(fallbackTranslation(key, args)); } @Override - public void sendStatusMessage(Player player, String key, String ... args) { - this.sendTranslationMessage(player, key, args); + public void sendStatusMessage(Player player, String key, String... args) { + sendTranslationMessage(player, key, args); } @Override public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendTranslationMessage(player, "message.voicechat.invite", commandSender.getName(), groupName, ""); + sendTranslationMessage(player, "message.voicechat.invite", commandSender.getName(), groupName, ""); } @Override public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendTranslationMessage(player, "message.voicechat.incompatible_version", pluginVersion, pluginName); + sendTranslationMessage(player, "message.voicechat.incompatible_version", pluginVersion, pluginName); } @Override @@ -52,7 +44,8 @@ extends BaseCompatibility { if (version.getMinor() > 12) { return super.createNamespacedKey(key); } - return Key.of("vc", key); + // Use old channels for versions older than 1.13 + return Key.of(Compatibility1_12.CHANNEL, key); } @Override @@ -67,12 +60,13 @@ extends BaseCompatibility { return null; } - public static String fallbackTranslation(String key, String ... args) { + public static String fallbackTranslation(String key, String... args) { String rawTranslation = FallbackTranslations.FALLBACK_TRANSLATIONS.get(key); if (rawTranslation == null) { return key; } - return String.format(rawTranslation, args); - } -} + return String.format(rawTranslation, (Object[]) args); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/JsonMessageBaseCompatibility.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/JsonMessageBaseCompatibility.java new file mode 100644 index 0000000..388e1d7 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/JsonMessageBaseCompatibility.java @@ -0,0 +1,23 @@ +package de.maxhenkel.voicechat.compatibility; + +import org.bukkit.entity.Player; + +public abstract class JsonMessageBaseCompatibility extends BaseCompatibility { + + @Override + public void sendTranslationMessage(Player player, String key, String... args) { + sendJsonMessage(player, createTranslationMessage(key, args)); + } + + @Override + public void sendStatusMessage(Player player, String key, String... args) { + sendJsonStatusMessage(player, createTranslationMessage(key, args)); + } + + public abstract void sendJsonMessage(Player player, String json); + + public abstract void sendJsonStatusMessage(Player player, String json); + + public abstract String createTranslationMessage(String key, String... args); + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/PlayerHideEvent.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/PlayerHideEvent.java similarity index 70% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/PlayerHideEvent.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/PlayerHideEvent.java index 26f061f..fbdc3b4 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/PlayerHideEvent.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/PlayerHideEvent.java @@ -1,14 +1,9 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.compatibility; import org.bukkit.entity.Player; public class PlayerHideEvent { + private final Player hiddenPlayer; private final Player observer; @@ -18,11 +13,11 @@ public class PlayerHideEvent { } public Player getHiddenPlayer() { - return this.hiddenPlayer; + return hiddenPlayer; } public Player getObserver() { - return this.observer; + return observer; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/PlayerShowEvent.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/PlayerShowEvent.java similarity index 70% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/PlayerShowEvent.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/PlayerShowEvent.java index 4996235..46c0918 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/PlayerShowEvent.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/PlayerShowEvent.java @@ -1,14 +1,9 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.compatibility; import org.bukkit.entity.Player; public class PlayerShowEvent { + private final Player shownPlayer; private final Player observer; @@ -18,11 +13,11 @@ public class PlayerShowEvent { } public Player getShownPlayer() { - return this.shownPlayer; + return shownPlayer; } public Player getObserver() { - return this.observer; + return observer; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/ReflectionUtils.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/ReflectionUtils.java similarity index 56% rename from source/decompiled/de/maxhenkel/voicechat/compatibility/ReflectionUtils.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/ReflectionUtils.java index 39da3db..3b5b4fd 100644 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/ReflectionUtils.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/ReflectionUtils.java @@ -1,72 +1,64 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.compatibility; -import de.maxhenkel.voicechat.compatibility.CompatibilityReflectionException; +import javax.annotation.Nullable; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import javax.annotation.Nullable; public class ReflectionUtils { - public static T callMethod(Object object, String ... methodNames) { - return ReflectionUtils.callMethod(object, methodNames, new Class[0], new Object[0]); + + public static T callMethod(Object object, String... methodNames) { + return callMethod(object, methodNames, new Class[]{}); } - public static T callMethod(Object object, String[] methodNames, Class[] parameterTypes, Object ... args) { - return ReflectionUtils.callMethod(object.getClass(), object, methodNames, parameterTypes, args); + public static T callMethod(Object object, String[] methodNames, Class[] parameterTypes, Object... args) { + return callMethod(object.getClass(), object, methodNames, parameterTypes, args); } - public static T callMethod(Object object, String methodName, Class[] parameterTypes, Object ... args) { - return ReflectionUtils.callMethod(object.getClass(), object, new String[]{methodName}, parameterTypes, args); + public static T callMethod(Object object, String methodName, Class[] parameterTypes, Object... args) { + return callMethod(object.getClass(), object, new String[]{methodName}, parameterTypes, args); } - public static T callMethod(Class clazz, Object object, String ... methodNames) { - return ReflectionUtils.callMethod(clazz, object, methodNames, new Class[0], new Object[0]); + public static T callMethod(Class clazz, Object object, String... methodNames) { + return callMethod(clazz, object, methodNames, new Class[]{}); } - public static T callMethod(Class clazz, Object object, String methodName, Class[] parameterTypes, Object ... args) { - return ReflectionUtils.callMethod(clazz, object, new String[]{methodName}, parameterTypes, args); + public static T callMethod(Class clazz, Object object, String methodName, Class[] parameterTypes, Object... args) { + return callMethod(clazz, object, new String[]{methodName}, parameterTypes, args); } - public static T callMethod(Class clazz, Object object, String[] methodNames, Class[] parameterTypes, Object ... args) { + public static T callMethod(Class clazz, Object object, String[] methodNames, Class[] parameterTypes, Object... args) { for (String name : methodNames) { try { Method method = clazz.getDeclaredMethod(name, parameterTypes); method.setAccessible(true); - return (T)method.invoke(object, args); - } - catch (Throwable ignored) { + return (T) method.invoke(object, args); + } catch (Throwable ignored) { try { Method method = clazz.getMethod(name, parameterTypes); method.setAccessible(true); - return (T)method.invoke(object, args); - } - catch (Throwable throwable) { + return (T) method.invoke(object, args); + } catch (Throwable ignored2) { } } } - throw new CompatibilityReflectionException(String.format("Could not find any of the following methods in the class %s: %s", clazz.getSimpleName(), String.join((CharSequence)", ", methodNames))); + throw new CompatibilityReflectionException(String.format("Could not find any of the following methods in the class %s: %s", clazz.getSimpleName(), String.join(", ", methodNames))); } - public static T callMethod(Class object, String ... methodNames) { - return ReflectionUtils.callMethod(object, methodNames, new Class[0], new Object[0]); + public static T callMethod(Class object, String... methodNames) { + return callMethod(object, methodNames, new Class[]{}); } - public static T callMethod(Class object, String[] methodNames, Class[] parameterTypes, Object ... args) { - return ReflectionUtils.callMethod(object, null, methodNames, parameterTypes, args); + public static T callMethod(Class object, String[] methodNames, Class[] parameterTypes, Object... args) { + return callMethod(object, null, methodNames, parameterTypes, args); } - public static T callMethod(Class object, String methodName, Class[] parameterTypes, Object ... args) { - return ReflectionUtils.callMethod(object, null, new String[]{methodName}, parameterTypes, args); + public static T callMethod(Class object, String methodName, Class[] parameterTypes, Object... args) { + return callMethod(object, null, new String[]{methodName}, parameterTypes, args); } - public static Method getMethod(Class clazz, String ... methodNames) { - return ReflectionUtils.getMethod(clazz, methodNames, new Class[0]); + public static Method getMethod(Class clazz, String... methodNames) { + return getMethod(clazz, methodNames, new Class[]{}); } public static Method getMethod(Class clazz, String[] methodNames, Class[] parameterTypes) { @@ -75,141 +67,131 @@ public class ReflectionUtils { Method method = clazz.getDeclaredMethod(name, parameterTypes); method.setAccessible(true); return method; - } - catch (Throwable ignored) { + } catch (Throwable ignored) { try { Method method = clazz.getMethod(name, parameterTypes); method.setAccessible(true); return method; - } - catch (Throwable throwable) { + } catch (Throwable ignored2) { } } } - throw new CompatibilityReflectionException(String.format("Could not find any of the following methods in the class %s: %s", clazz.getSimpleName(), String.join((CharSequence)", ", methodNames))); + throw new CompatibilityReflectionException(String.format("Could not find any of the following methods in the class %s: %s", clazz.getSimpleName(), String.join(", ", methodNames))); } - public static T call(Method method, @Nullable Object instance, Object ... args) { + public static T call(Method method, @Nullable Object instance, Object... args) { try { - return (T)method.invoke(instance, args); - } - catch (Throwable t) { + return (T) method.invoke(instance, args); + } catch (Throwable t) { throw new CompatibilityReflectionException(String.format("Failed to invoke method %s", method.getName()), t); } } public static T callConstructor(Class object) { - return ReflectionUtils.callConstructor(object, new Class[0], new Object[0]); + return callConstructor(object, new Class[]{}); } - public static T callConstructor(Class object, Class[] parameterTypes, Object ... args) { + public static T callConstructor(Class object, Class[] parameterTypes, Object... args) { try { Constructor constructor = object.getDeclaredConstructor(parameterTypes); constructor.setAccessible(true); - return (T)constructor.newInstance(args); - } - catch (Throwable t) { + return (T) constructor.newInstance(args); + } catch (Throwable t) { throw new CompatibilityReflectionException(String.format("Failed to invoke constructor of %s", object.getName()), t); } } - public static Constructor getConstructor(Class object, Class ... parameterTypes) { + public static Constructor getConstructor(Class object, Class... parameterTypes) { try { Constructor constructor = object.getDeclaredConstructor(parameterTypes); constructor.setAccessible(true); return constructor; - } - catch (Throwable t) { + } catch (Throwable t) { throw new CompatibilityReflectionException(String.format("Failed to get constructor of %s", object.getName()), t); } } - public static T newInstance(Constructor constructor, Object ... args) { + public static T newInstance(Constructor constructor, Object... args) { try { return constructor.newInstance(args); - } - catch (Throwable t) { + } catch (Throwable t) { throw new CompatibilityReflectionException(String.format("Failed to invoke constructor of %s", constructor.getDeclaringClass().getName()), t); } } - public static T getField(Object object, String ... fieldNames) { + public static T getField(Object object, String... fieldNames) { for (String fieldName : fieldNames) { try { Field field = object.getClass().getDeclaredField(fieldName); field.setAccessible(true); - return (T)field.get(object); - } - catch (Throwable ignored) { + return (T) field.get(object); + } catch (Throwable ignored) { try { Field field = object.getClass().getField(fieldName); field.setAccessible(true); - return (T)field.get(object); - } - catch (Throwable throwable) { + return (T) field.get(object); + } catch (Throwable ignored2) { } } } - throw new CompatibilityReflectionException(String.format("Could not find any of the following fields in the class %s: %s", object.getClass().getSimpleName(), String.join((CharSequence)", ", fieldNames))); + throw new CompatibilityReflectionException(String.format("Could not find any of the following fields in the class %s: %s", object.getClass().getSimpleName(), String.join(", ", fieldNames))); } - public static T getField(Class clazz, String ... fieldNames) { + public static T getField(Class clazz, String... fieldNames) { for (String fieldName : fieldNames) { try { Field field = clazz.getDeclaredField(fieldName); field.setAccessible(true); - return (T)field.get(null); - } - catch (Throwable ignored) { + return (T) field.get(null); + } catch (Throwable ignored) { try { Field field = clazz.getField(fieldName); field.setAccessible(true); - return (T)field.get(null); - } - catch (Throwable throwable) { + return (T) field.get(null); + } catch (Throwable ignored2) { } } } - throw new CompatibilityReflectionException(String.format("Could not find any of the following fields in the class %s: %s", clazz.getSimpleName(), String.join((CharSequence)", ", fieldNames))); + throw new CompatibilityReflectionException(String.format("Could not find any of the following fields in the class %s: %s", clazz.getSimpleName(), String.join(", ", fieldNames))); } - public static Class getClazz(String ... classNames) { + /** + * @param classNames the class names including the package name + * @return the class + */ + public static Class getClazz(String... classNames) { for (String className : classNames) { try { return Class.forName(className); - } - catch (Throwable throwable) { + } catch (Throwable ignored) { } } - throw new CompatibilityReflectionException(String.format("Could not find any of the following classes: %s", String.join((CharSequence)", ", classNames))); + throw new CompatibilityReflectionException(String.format("Could not find any of the following classes: %s", String.join(", ", classNames))); } - public static boolean doesClassExist(String ... classNames) { + public static boolean doesClassExist(String... classNames) { for (String className : classNames) { try { Class.forName(className); return true; - } - catch (Throwable throwable) { + } catch (Throwable ignored) { } } return false; } - public static boolean doesMethodExist(Class clazz, String methodName, Class ... parameterTypes) { + public static boolean doesMethodExist(Class clazz, String methodName, Class... parameterTypes) { try { clazz.getDeclaredMethod(methodName, parameterTypes); return true; - } - catch (Throwable ignored) { + } catch (Throwable ignored) { try { clazz.getMethod(methodName, parameterTypes); return true; - } - catch (Throwable throwable) { - return false; + } catch (Throwable ignored2) { } } + return false; } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/SpigotCompatibility.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/SpigotCompatibility.java new file mode 100644 index 0000000..5bc0052 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/compatibility/SpigotCompatibility.java @@ -0,0 +1,72 @@ +package de.maxhenkel.voicechat.compatibility; + +import com.mojang.brigadier.arguments.ArgumentType; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import javax.annotation.Nullable; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +import static de.maxhenkel.voicechat.compatibility.ReflectionUtils.*; + +public class SpigotCompatibility extends FallbackCompatibility { + + public static final SpigotCompatibility INSTANCE = new SpigotCompatibility(); + + private MessageSender messageSender; + + @Override + public void init() throws Exception { + super.init(); + + Class playerSpigotClass = getClazz("org.bukkit.entity.Player$Spigot"); + Class baseComponentClass = getClazz("net.md_5.bungee.api.chat.BaseComponent"); + + Class chatMessageTypeClass = getClazz("net.md_5.bungee.api.ChatMessageType"); + Object systemType = getField(chatMessageTypeClass, "SYSTEM"); + Object actionBarType = getField(chatMessageTypeClass, "ACTION_BAR"); + + Method playerSpigot = getMethod(Player.class, "spigot"); + Method sendMessage = getMethod(playerSpigotClass, new String[]{"sendMessage"}, new Class[]{chatMessageTypeClass, baseComponentClass}); + + Class translatableComponentClass = getClazz("net.md_5.bungee.api.chat.TranslatableComponent"); + Constructor translatableComponentConstructor = getConstructor(translatableComponentClass, String.class, Object[].class); + + messageSender = ((player, actionBar, key, args) -> { + Object messageType = actionBar ? actionBarType : systemType; + call(sendMessage, call(playerSpigot, player), messageType, newInstance(translatableComponentConstructor, key, args)); + }); + } + + public static boolean isSpigotCompatible() { + return doesMethodExist(Bukkit.class, "spigot"); + } + + @Override + public void sendTranslationMessage(Player player, String key, String... args) { + messageSender.send(player, false, key, args); + } + + @Override + public void sendStatusMessage(Player player, String key, String... args) { + messageSender.send(player, true, key, args); + } + + @Override + @Nullable + public ArgumentType playerArgument() { + return null; + } + + @Override + @Nullable + public ArgumentType uuidArgument() { + return null; + } + + private interface MessageSender { + void send(Player player, boolean actionBar, String key, String... args); + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/config/ServerConfig.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/config/ServerConfig.java new file mode 100644 index 0000000..a0c97b7 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/config/ServerConfig.java @@ -0,0 +1,129 @@ +package de.maxhenkel.voicechat.config; + +import de.maxhenkel.configbuilder.ConfigBuilder; +import de.maxhenkel.configbuilder.entry.ConfigEntry; +import de.maxhenkel.voicechat.BuildConstants; +import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.voice.common.AudioUtils; + +public class ServerConfig { + + public final ConfigEntry voiceChatPort; + public final ConfigEntry voiceChatBindAddress; + public final ConfigEntry voiceChatDistance; + public ConfigEntry whisperDistance; + public final ConfigEntry voiceChatCodec; + public final ConfigEntry voiceChatMtuSize; + public final ConfigEntry tcpRateLimit; + public final ConfigEntry keepAlive; + public final ConfigEntry groupsEnabled; + public final ConfigEntry voiceHost; + public final ConfigEntry allowRecording; + public final ConfigEntry spectatorInteraction; + public ConfigEntry spectatorPlayerPossession; + public ConfigEntry forceVoiceChat; + public ConfigEntry loginTimeout; + public ConfigEntry broadcastRange; + public ConfigEntry allowPings; + public ConfigEntry threadedServerSupport; + + public ServerConfig(ConfigBuilder builder) { + builder.header(String.format("%s server config v%s", BuildConstants.PLUGIN_NAME, Voicechat.INSTANCE.getDescription().getVersion())); + + voiceChatPort = builder + .integerEntry("port", 24454, -1, 65535, + "The port number to use for the voice chat communication.", + "Audio packets are always transmitted via the UDP protocol on the port number", + "specified here, independently of other networking used for the game server.", + "Set this to '-1' to use the same port number that is used by the Minecraft server.", + "However, it is strongly recommended NOT to use the same port number because UDP on", + "it is also used by default for the server query. Doing so may crash the server!" + ); + voiceChatBindAddress = builder + .stringEntry("bind_address", "", + "The server IP address to bind the voice chat to", + "Leave blank to use the 'server-ip' property from the 'server.properties' config file", + "To bind to the wildcard IP address, use '*'" + ); + voiceChatDistance = builder + .doubleEntry("max_voice_distance", 48D, 1D, 1_000_000D, + "The distance to which the voice can be heard" + ); + whisperDistance = builder + .doubleEntry("whisper_distance", 24D, 1D, 1_000_000D, + "The distance to which the voice can be heard when whispering" + ); + voiceChatCodec = builder + .enumEntry("codec", Codec.VOIP, + "The Opus codec", + "Valid values are 'VOIP', 'AUDIO', and 'RESTRICTED_LOWDELAY'" + ); + voiceChatMtuSize = builder + .integerEntry("mtu_size", AudioUtils.MAX_OPUS_PAYLOAD_SIZE, 512, 2048, + "The maximum size that audio packets are allowed to have (in bytes)", + "Setting this to lower values might cause issues" + ); + tcpRateLimit = builder + .integerEntry("tcp_rate_limit", 16, -1, 1024, + "The maximum number of packets a player can send per second", + "Set this to -1 to disable the rate limit - This must be greater than 0 in all other cases", + "This only applies to voice chat packets that are sent through Minecrafts networking", + "This affects actions like opening/joining/leaving voice chat groups or general state changes like disabling/enabling the voice chat" + ); + keepAlive = builder + .integerEntry("keep_alive", 1000, 1000, Integer.MAX_VALUE, + "The frequency at which keep-alive packets are sent (in milliseconds)", + "Setting this to a higher value may result in timeouts" + ); + groupsEnabled = builder + .booleanEntry("enable_groups", true, + "If group chats are allowed" + ); + voiceHost = builder + .stringEntry("voice_host", "", + "The hostname that clients should use to connect to the voice chat", + "This may also include a port, e.g. 'example.com:24454'", + "Do NOT change this value if you don't know what you're doing" + ); + allowRecording = builder + .booleanEntry("allow_recording", true, + "If players are allowed to record the voice chat audio" + ); + spectatorInteraction = builder + .booleanEntry("spectator_interaction", false, + "If spectators are allowed to talk to other players" + ); + spectatorPlayerPossession = builder + .booleanEntry("spectator_player_possession", false, + "If spectators can talk to players they are spectating" + ); + forceVoiceChat = builder + .booleanEntry("force_voice_chat", false, + "If players without the voice chat mod should be kicked from the server" + ); + loginTimeout = builder + .integerEntry("login_timeout", 10_000, 100, Integer.MAX_VALUE, + "The amount of time the server should wait to check if a player has the mod installed (in milliseconds)", + "Only relevant when 'force_voice_chat' is set to 'true'" + ); + broadcastRange = builder + .doubleEntry("broadcast_range", -1D, -1D, Double.MAX_VALUE, + "The range in which the voice chat should broadcast audio", + "A value less than 0 means 'max_voice_distance'" + ); + allowPings = builder + .booleanEntry("allow_pings", true, + "If the voice chat server should reply to external pings" + ); + threadedServerSupport = builder + .booleanEntry("threaded_server_support", true, + "If the voice chat should support servers that run multiple threads, like Folia", + "Disabling this may slightly improve performance, but can cause issues on servers that don't run everything on a single thread" + ); + } + + public enum Codec { + VOIP, AUDIO, RESTRICTED_LOWDELAY; + } + +} \ No newline at end of file diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/config/Translations.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/config/Translations.java new file mode 100644 index 0000000..104570c --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/config/Translations.java @@ -0,0 +1,68 @@ +package de.maxhenkel.voicechat.config; + +import de.maxhenkel.configbuilder.ConfigBuilder; +import de.maxhenkel.configbuilder.entry.ConfigEntry; + +public class Translations { + + public final ConfigEntry forceVoicechatKickMessage; + public final ConfigEntry rateLimitKickMessage; + public final ConfigEntry voicechatNotCompatibleMessage; + public final ConfigEntry voicechatNeededForCommandMessage; + public final ConfigEntry playerCommandMessage; + public final ConfigEntry placeholderVoicechatInstalled; + public final ConfigEntry placeholderVoicechatNotInstalled; + public final ConfigEntry placeholderVoicechatDisabled; + + public Translations(ConfigBuilder builder) { + builder.header( + "Simple Voice Chat translations", + "This file contains all server-side translations for the Simple Voice Chat plugin" + ); + + forceVoicechatKickMessage = builder.stringEntry( + "force_voicechat_kick_message", + "You need %s %s to play on this server", + "The message a player gets when kicked for not having voice chat installed and the server has force_voicechat enabled", + "The first parameter is the mod/plugin name and the second parameter is the mod/plugin version" + ); + rateLimitKickMessage = builder.stringEntry( + "rate_limit_kick_message", + "Kicked for exceeding packet rate limit", + "The message a player gets when kicked for sending too many voice chat packets" + ); + voicechatNotCompatibleMessage = builder.stringEntry( + "voicechat_not_compatible_message", + "Your voice chat client version is not compatible with the server-side version.\\nPlease install version %s of %s.", + "The message a player gets when joining a server with an incompatible voice chat version", + "The first parameter is the mod/plugin version and the second parameter is the mod/plugin name" + ); + voicechatNeededForCommandMessage = builder.stringEntry( + "voicechat_needed_for_command_message", + "You need to have %s installed on your client to use this command", + "The message a player gets when trying to execute a command that requires the voice chat mod installed on the client side.", + "The first parameter is the mod/plugin name" + ); + playerCommandMessage = builder.stringEntry( + "player_command_message", + "This command can only be executed as a player", + "The message a player gets when trying to execute a command that can only be executed as a player" + ); + placeholderVoicechatInstalled = builder.stringEntry( + "placeholder_api_voicechat_installed", + "", + "The Placeholder API string for '%voicechat_installed%'" + ); + placeholderVoicechatNotInstalled = builder.stringEntry( + "placeholder_api_voicechat_not_installed", + "", + "The Placeholder API string for '%voicechat_not_installed%'" + ); + placeholderVoicechatDisabled = builder.stringEntry( + "placeholder_api_voicechat_disabled", + "", + "The Placeholder API string for '%voicechat_disabled%'" + ); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/debug/CooldownTimer.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/CooldownTimer.java similarity index 71% rename from source/decompiled/de/maxhenkel/voicechat/debug/CooldownTimer.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/CooldownTimer.java index 6fb3052..da1ec77 100644 --- a/source/decompiled/de/maxhenkel/voicechat/debug/CooldownTimer.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/CooldownTimer.java @@ -1,12 +1,14 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.debug; import java.util.concurrent.ConcurrentHashMap; public class CooldownTimer { - private static ConcurrentHashMap cooldowns = new ConcurrentHashMap(); + + private static ConcurrentHashMap cooldowns; + + static { + cooldowns = new ConcurrentHashMap<>(); + } public static void run(String id, long time, Runnable runnable) { if (System.currentTimeMillis() - cooldowns.getOrDefault(id, 0L) > time) { @@ -16,7 +18,7 @@ public class CooldownTimer { } public static void run(String id, Runnable runnable) { - CooldownTimer.run(id, 10000L, runnable); + run(id, 10_000L, runnable); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/debug/PingHandler.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/PingHandler.java similarity index 80% rename from source/decompiled/de/maxhenkel/voicechat/debug/PingHandler.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/PingHandler.java index 6ca7263..6159803 100644 --- a/source/decompiled/de/maxhenkel/voicechat/debug/PingHandler.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/PingHandler.java @@ -1,46 +1,44 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * io.netty.buffer.Unpooled - */ package de.maxhenkel.voicechat.debug; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.voice.server.Server; import io.netty.buffer.Unpooled; + import java.net.SocketAddress; import java.util.UUID; public class PingHandler { + public static final UUID PING_V1 = UUID.fromString("58bc9ae9-c7a8-45e4-a11c-efbb67199425"); private static final int PAYLOAD_SIZE = 24; public static boolean onPacket(Server server, SocketAddress socketAddress, UUID playerID, FriendlyByteBuf buf) { - if (!Voicechat.SERVER_CONFIG.allowPings.get().booleanValue()) { + if (!Voicechat.SERVER_CONFIG.allowPings.get()) { return false; } if (!PING_V1.equals(playerID)) { return false; } try { - byte[] payload = buf.readByteArray(24); - FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer((byte[])payload)); + byte[] payload = buf.readByteArray(PAYLOAD_SIZE); + FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer(payload)); UUID id = buffer.readUUID(); long timestamp = buffer.readLong(); Voicechat.LOGGER.debug("Received ping {} from {}", id, socketAddress); - FriendlyByteBuf responseBuffer = new FriendlyByteBuf(Unpooled.buffer((int)24)); + + FriendlyByteBuf responseBuffer = new FriendlyByteBuf(Unpooled.buffer(PAYLOAD_SIZE)); + responseBuffer.writeUUID(id); responseBuffer.writeLong(timestamp); + byte[] response = new byte[responseBuffer.readableBytes()]; responseBuffer.readBytes(response); + server.getSocket().send(response, socketAddress); - } - catch (Exception e) { + } catch (Exception e) { Voicechat.LOGGER.debug("Failed to send ping to {}: {}", socketAddress, e.getMessage()); } return true; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/debug/VoicechatUncaughtExceptionHandler.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/VoicechatUncaughtExceptionHandler.java similarity index 65% rename from source/decompiled/de/maxhenkel/voicechat/debug/VoicechatUncaughtExceptionHandler.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/VoicechatUncaughtExceptionHandler.java index 398af6f..e4bc91c 100644 --- a/source/decompiled/de/maxhenkel/voicechat/debug/VoicechatUncaughtExceptionHandler.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/debug/VoicechatUncaughtExceptionHandler.java @@ -1,15 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.debug; import de.maxhenkel.voicechat.Voicechat; -public class VoicechatUncaughtExceptionHandler -implements Thread.UncaughtExceptionHandler { +public class VoicechatUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { + @Override public void uncaughtException(Thread t, Throwable e) { Voicechat.LOGGER.error("Uncaught exception in thread {}", t.getName(), e); } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/CommodoreCommands.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/CommodoreCommands.java new file mode 100644 index 0000000..d8b60cb --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/CommodoreCommands.java @@ -0,0 +1,40 @@ +package de.maxhenkel.voicechat.integration.commodore; + +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.builder.RequiredArgumentBuilder; +import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.command.VoiceChatCommands; +import me.lucko.commodore.Commodore; + +public class CommodoreCommands { + + public static void registerCompletions(Commodore commodore) throws MissingArgumentTypeException { + ArgumentType playerArgument = playerArgument(); + ArgumentType uuidArgument = uuidArgument(); + if (playerArgument == null || uuidArgument == null) { + throw new MissingArgumentTypeException("Could not acquire argument types"); + } + LiteralArgumentBuilder literalBuilder = LiteralArgumentBuilder.literal(VoiceChatCommands.VOICECHAT_COMMAND) + .then(LiteralArgumentBuilder.literal("help")) + .then(LiteralArgumentBuilder.literal("test").then(RequiredArgumentBuilder.argument("target", playerArgument))) + .then(LiteralArgumentBuilder.literal("invite").then(RequiredArgumentBuilder.argument("target", playerArgument))) + .then(LiteralArgumentBuilder.literal("join").then(RequiredArgumentBuilder.argument("group_id", uuidArgument))) + .then(LiteralArgumentBuilder.literal("join").then(RequiredArgumentBuilder.argument("group_id", uuidArgument).then(RequiredArgumentBuilder.argument("password", StringArgumentType.string())))) + .then(LiteralArgumentBuilder.literal("join").then(RequiredArgumentBuilder.argument("group_name", StringArgumentType.string()).suggests(GroupNameSuggestionProvider.INSTANCE))) + .then(LiteralArgumentBuilder.literal("join").then(RequiredArgumentBuilder.argument("group_name", StringArgumentType.string()).suggests(GroupNameSuggestionProvider.INSTANCE).then(RequiredArgumentBuilder.argument("password", StringArgumentType.string())))) + .then(LiteralArgumentBuilder.literal("leave")); + + commodore.register(literalBuilder); + } + + private static ArgumentType playerArgument() { + return Voicechat.compatibility.playerArgument(); + } + + private static ArgumentType uuidArgument() { + return Voicechat.compatibility.uuidArgument(); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/integration/commodore/GroupNameSuggestionProvider.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/GroupNameSuggestionProvider.java similarity index 71% rename from source/decompiled/de/maxhenkel/voicechat/integration/commodore/GroupNameSuggestionProvider.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/GroupNameSuggestionProvider.java index b7c6f07..88a75ca 100644 --- a/source/decompiled/de/maxhenkel/voicechat/integration/commodore/GroupNameSuggestionProvider.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/GroupNameSuggestionProvider.java @@ -1,12 +1,3 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.context.CommandContext - * com.mojang.brigadier.suggestion.SuggestionProvider - * com.mojang.brigadier.suggestion.Suggestions - * com.mojang.brigadier.suggestion.SuggestionsBuilder - */ package de.maxhenkel.voicechat.integration.commodore; import com.mojang.brigadier.context.CommandContext; @@ -16,12 +7,14 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.voice.server.Group; import de.maxhenkel.voicechat.voice.server.Server; + import java.util.concurrent.CompletableFuture; -public class GroupNameSuggestionProvider -implements SuggestionProvider { +public class GroupNameSuggestionProvider implements SuggestionProvider { + public static final GroupNameSuggestionProvider INSTANCE = new GroupNameSuggestionProvider(); + @Override public CompletableFuture getSuggestions(CommandContext context, SuggestionsBuilder builder) { Server server = Voicechat.SERVER.getServer(); if (server == null) { @@ -32,8 +25,7 @@ implements SuggestionProvider { return String.format("\"%s\"", s); } return s; - }).forEach(arg_0 -> ((SuggestionsBuilder)builder).suggest(arg_0)); + }).forEach(builder::suggest); return builder.buildFuture(); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/integration/commodore/MissingArgumentTypeException.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/MissingArgumentTypeException.java similarity index 59% rename from source/decompiled/de/maxhenkel/voicechat/integration/commodore/MissingArgumentTypeException.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/MissingArgumentTypeException.java index fda7735..7a66e29 100644 --- a/source/decompiled/de/maxhenkel/voicechat/integration/commodore/MissingArgumentTypeException.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/commodore/MissingArgumentTypeException.java @@ -1,12 +1,9 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.integration.commodore; -public class MissingArgumentTypeException -extends Exception { +public class MissingArgumentTypeException extends Exception { + public MissingArgumentTypeException(String message) { super(message); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/integration/placeholderapi/VoicechatExpansion.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/placeholderapi/VoicechatExpansion.java similarity index 71% rename from source/decompiled/de/maxhenkel/voicechat/integration/placeholderapi/VoicechatExpansion.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/placeholderapi/VoicechatExpansion.java index 6f7e6b5..97dd903 100644 --- a/source/decompiled/de/maxhenkel/voicechat/integration/placeholderapi/VoicechatExpansion.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/placeholderapi/VoicechatExpansion.java @@ -1,50 +1,46 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * me.clip.placeholderapi.expansion.PlaceholderExpansion - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.integration.placeholderapi; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.voice.common.PlayerState; import de.maxhenkel.voicechat.voice.server.Server; -import javax.annotation.Nullable; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; -public class VoicechatExpansion -extends PlaceholderExpansion { +import javax.annotation.Nullable; + +public class VoicechatExpansion extends PlaceholderExpansion { + + @Override public String getIdentifier() { - return "voicechat"; + return Voicechat.MODID; } + @Override public String getAuthor() { - return String.join((CharSequence)", ", Voicechat.INSTANCE.getDescription().getAuthors()); + return String.join(", ", Voicechat.INSTANCE.getDescription().getAuthors()); } + @Override public String getVersion() { return Voicechat.INSTANCE.getDescription().getVersion(); } + @Override public boolean persist() { return true; } - @Nullable - public String onPlaceholderRequest(Player player, String params) { + @Override + public @Nullable String onPlaceholderRequest(Player player, String params) { if (player == null) { return super.onPlaceholderRequest(player, params); } + if (params.equalsIgnoreCase("installed")) { return Voicechat.SERVER.isCompatible(player) ? Voicechat.TRANSLATIONS.placeholderVoicechatInstalled.get() : ""; - } - if (params.equalsIgnoreCase("not_installed")) { + } else if (params.equalsIgnoreCase("not_installed")) { return !Voicechat.SERVER.isCompatible(player) ? Voicechat.TRANSLATIONS.placeholderVoicechatNotInstalled.get() : ""; - } - if (params.equalsIgnoreCase("disabled")) { + } else if (params.equalsIgnoreCase("disabled")) { Server server = Voicechat.SERVER.getServer(); if (server == null) { return ""; @@ -58,7 +54,7 @@ extends PlaceholderExpansion { } return Voicechat.TRANSLATIONS.placeholderVoicechatDisabled.get(); } + return super.onPlaceholderRequest(player, params); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/integration/viaversion/ViaVersionCompatibility.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/viaversion/ViaVersionCompatibility.java similarity index 56% rename from source/decompiled/de/maxhenkel/voicechat/integration/viaversion/ViaVersionCompatibility.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/viaversion/ViaVersionCompatibility.java index 24aaef4..3d3de7d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/integration/viaversion/ViaVersionCompatibility.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/integration/viaversion/ViaVersionCompatibility.java @@ -1,27 +1,26 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.integration.viaversion; import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.compatibility.Compatibility1_12; import de.maxhenkel.voicechat.util.Key; + +import javax.annotation.Nullable; import java.lang.reflect.Field; import java.lang.reflect.Method; -import javax.annotation.Nullable; public class ViaVersionCompatibility { + public static void register() throws Exception { - Class protocol113to1122 = ViaVersionCompatibility.getClass("com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2"); + // ViaVersion 4.x.x + Class protocol113to1122 = getClass("com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2"); if (protocol113to1122 != null) { - ViaVersionCompatibility.registerPackets(protocol113to1122); + registerPackets(protocol113to1122); return; } - Class protocol1122to113 = ViaVersionCompatibility.getClass("com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13"); + //ViaVersion 5.x.x + Class protocol1122to113 = getClass("com.viaversion.viaversion.protocols.v1_12_2to1_13.Protocol1_12_2To1_13"); if (protocol1122to113 != null) { - ViaVersionCompatibility.registerPackets(protocol1122to113); + registerPackets(protocol1122to113); return; } } @@ -29,12 +28,12 @@ public class ViaVersionCompatibility { private static void registerPackets(Class protocolClass) throws Exception { Field mappingsField = protocolClass.getDeclaredField("MAPPINGS"); Object mappings = mappingsField.get(null); - Method getChannelMappings = mappings.getClass().getDeclaredMethod("getChannelMappings", new Class[0]); - Object mappingMap = getChannelMappings.invoke(mappings, new Object[0]); + Method getChannelMappings = mappings.getClass().getDeclaredMethod("getChannelMappings"); + Object mappingMap = getChannelMappings.invoke(mappings); Method put = mappingMap.getClass().getDeclaredMethod("put", Object.class, Object.class); for (String id : Voicechat.netManager.getPackets()) { Key key = Key.parse(id); - put.invoke(mappingMap, String.format("%s:%s", "vc", key.getValue()), String.format("%s:%s", "voicechat", key.getValue())); + put.invoke(mappingMap, String.format("%s:%s", Compatibility1_12.CHANNEL, key.getValue()), String.format("%s:%s", Voicechat.MODID, key.getValue())); } } @@ -42,10 +41,9 @@ public class ViaVersionCompatibility { private static Class getClass(String name) { try { return Class.forName(name); - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { return null; } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/logging/JavaLoggingLogger.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/JavaLoggingLogger.java similarity index 52% rename from source/decompiled/de/maxhenkel/voicechat/logging/JavaLoggingLogger.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/JavaLoggingLogger.java index 21a31ff..d8e9f81 100644 --- a/source/decompiled/de/maxhenkel/voicechat/logging/JavaLoggingLogger.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/JavaLoggingLogger.java @@ -1,19 +1,14 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.logging; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.logging.LogLevel; -import de.maxhenkel.voicechat.logging.VoicechatLogger; + import java.util.logging.Level; import java.util.logging.Logger; -public class JavaLoggingLogger -implements VoicechatLogger { +public class JavaLoggingLogger implements VoicechatLogger { + private final boolean debugMode; private final Logger logger; - private static final String PLACEHOLDER = "{}"; public JavaLoggingLogger(Logger logger) { this.logger = logger; @@ -21,74 +16,77 @@ implements VoicechatLogger { } @Override - public void log(LogLevel level, String message, Object ... args) { - if (!this.isEnabled(level)) { + public void log(LogLevel level, String message, Object... args) { + if (!isEnabled(level)) { return; } Throwable throwable = null; - if (args.length > 0 && args[args.length - 1] instanceof Throwable) { - throwable = (Throwable)args[args.length - 1]; - Object[] newArgs = new Object[args.length - 1]; - System.arraycopy(args, 0, newArgs, 0, newArgs.length); - args = newArgs; + if (args.length > 0) { + if (args[args.length - 1] instanceof Throwable) { + throwable = (Throwable) args[args.length - 1]; + Object[] newArgs = new Object[args.length - 1]; + System.arraycopy(args, 0, newArgs, 0, newArgs.length); + args = newArgs; + } } - this.logger.log(this.fromLogLevel(level), this.replacePlaceholders(message, args), throwable); + logger.log(fromLogLevel(level), replacePlaceholders(message, args), throwable); } - private String replacePlaceholders(String message, Object ... args) { + private static final String PLACEHOLDER = "{}"; + + private String replacePlaceholders(String message, Object... args) { StringBuilder formattedMessage = new StringBuilder(); + int argIndex = 0; int placeholderStart = message.indexOf(PLACEHOLDER); - for (int argIndex = 0; placeholderStart >= 0 && argIndex < args.length; ++argIndex) { + + while (placeholderStart >= 0 && argIndex < args.length) { formattedMessage.append(message, 0, placeholderStart); formattedMessage.append(args[argIndex]); message = message.substring(placeholderStart + PLACEHOLDER.length()); + argIndex++; placeholderStart = message.indexOf(PLACEHOLDER); } + formattedMessage.append(message); return formattedMessage.toString(); } @Override public boolean isEnabled(LogLevel level) { - return this.logger.isLoggable(this.fromLogLevel(level)); + return logger.isLoggable(fromLogLevel(level)); } private Level fromLogLevel(LogLevel level) { - if (this.debugMode) { + if (debugMode) { switch (level) { - case TRACE: { + case TRACE: return Level.ALL; - } - case WARN: { + case WARN: return Level.WARNING; - } - case ERROR: - case FATAL: { + case ERROR: + case FATAL: return Level.SEVERE; - } + default: + return Level.INFO; } - return Level.INFO; } switch (level) { - case TRACE: { + case TRACE: return Level.ALL; - } - case DEBUG: { + case DEBUG: return Level.CONFIG; - } - case WARN: { + case WARN: return Level.WARNING; - } - case ERROR: - case FATAL: { + case ERROR: + case FATAL: return Level.SEVERE; - } + default: + return Level.INFO; } - return Level.INFO; } public Logger getLogger() { - return this.logger; + return logger; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/logging/LogLevel.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/LogLevel.java similarity index 71% rename from source/decompiled/de/maxhenkel/voicechat/logging/LogLevel.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/LogLevel.java index c671af6..267255f 100644 --- a/source/decompiled/de/maxhenkel/voicechat/logging/LogLevel.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/LogLevel.java @@ -1,15 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.logging; public enum LogLevel { + TRACE, DEBUG, INFO, WARN, ERROR, - FATAL; + FATAL } - diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/VoicechatLogger.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/VoicechatLogger.java new file mode 100644 index 0000000..e85191b --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/logging/VoicechatLogger.java @@ -0,0 +1,33 @@ +package de.maxhenkel.voicechat.logging; + +public interface VoicechatLogger { + + void log(LogLevel level, String message, Object... args); + + boolean isEnabled(LogLevel level); + + default void trace(String message, Object... args){ + log(LogLevel.TRACE, message, args); + } + + default void debug(String message, Object... args){ + log(LogLevel.DEBUG, message, args); + } + + default void info(String message, Object... args){ + log(LogLevel.INFO, message, args); + } + + default void warn(String message, Object... args){ + log(LogLevel.WARN, message, args); + } + + default void error(String message, Object... args){ + log(LogLevel.ERROR, message, args); + } + + default void fatal(String message, Object... args){ + log(LogLevel.FATAL, message, args); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/AddCategoryPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/AddCategoryPacket.java similarity index 75% rename from source/decompiled/de/maxhenkel/voicechat/net/AddCategoryPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/AddCategoryPacket.java index 08f6954..ed6e775 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/AddCategoryPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/AddCategoryPacket.java @@ -1,20 +1,18 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; -public class AddCategoryPacket -implements Packet { +public class AddCategoryPacket implements Packet { + public static final Key ADD_CATEGORY = Voicechat.compatibility.createNamespacedKey("add_category"); + private VolumeCategoryImpl category; public AddCategoryPacket() { + } public AddCategoryPacket(VolumeCategoryImpl category) { @@ -22,7 +20,7 @@ implements Packet { } public VolumeCategoryImpl getCategory() { - return this.category; + return category; } @Override @@ -32,13 +30,13 @@ implements Packet { @Override public AddCategoryPacket fromBytes(FriendlyByteBuf buf) { - this.category = VolumeCategoryImpl.fromBytes(buf); + category = VolumeCategoryImpl.fromBytes(buf); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - this.category.toBytes(buf); + category.toBytes(buf); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/AddGroupPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/AddGroupPacket.java similarity index 75% rename from source/decompiled/de/maxhenkel/voicechat/net/AddGroupPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/AddGroupPacket.java index 7980f57..ef37d22 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/AddGroupPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/AddGroupPacket.java @@ -1,20 +1,18 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import de.maxhenkel.voicechat.voice.common.ClientGroup; -public class AddGroupPacket -implements Packet { +public class AddGroupPacket implements Packet { + public static final Key ADD_ADD_GROUP = Voicechat.compatibility.createNamespacedKey("add_group"); + private ClientGroup group; public AddGroupPacket() { + } public AddGroupPacket(ClientGroup group) { @@ -22,7 +20,7 @@ implements Packet { } public ClientGroup getGroup() { - return this.group; + return group; } @Override @@ -32,13 +30,13 @@ implements Packet { @Override public AddGroupPacket fromBytes(FriendlyByteBuf buf) { - this.group = ClientGroup.fromBytes(buf); + group = ClientGroup.fromBytes(buf); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - this.group.toBytes(buf); + group.toBytes(buf); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/CreateGroupPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/CreateGroupPacket.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/net/CreateGroupPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/CreateGroupPacket.java index 392e20b..e7d17b7 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/CreateGroupPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/CreateGroupPacket.java @@ -1,30 +1,25 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.plugins.impl.GroupImpl; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; -import javax.annotation.Nullable; import org.bukkit.entity.Player; -public class CreateGroupPacket -implements Packet { +import javax.annotation.Nullable; + +public class CreateGroupPacket implements Packet { + public static final Key CREATE_GROUP = Voicechat.compatibility.createNamespacedKey("create_group"); + private String name; @Nullable private String password; private Group.Type type; public CreateGroupPacket() { + } public CreateGroupPacket(String name, @Nullable String password, Group.Type type) { @@ -34,16 +29,16 @@ implements Packet { } public String getName() { - return this.name; + return name; } @Nullable public String getPassword() { - return this.password; + return password; } public Group.Type getType() { - return this.type; + return type; } @Override @@ -58,23 +53,23 @@ implements Packet { @Override public CreateGroupPacket fromBytes(FriendlyByteBuf buf) { - this.name = buf.readUtf(24); - this.password = null; + name = buf.readUtf(Voicechat.MAX_GROUP_NAME_LENGTH); + password = null; if (buf.readBoolean()) { - this.password = buf.readUtf(24); + password = buf.readUtf(Voicechat.MAX_GROUP_NAME_LENGTH); } - this.type = GroupImpl.TypeImpl.fromInt(buf.readShort()); + type = GroupImpl.TypeImpl.fromInt(buf.readShort()); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUtf(this.name, 24); - buf.writeBoolean(this.password != null); - if (this.password != null) { - buf.writeUtf(this.password, 24); + buf.writeUtf(name, Voicechat.MAX_GROUP_NAME_LENGTH); + buf.writeBoolean(password != null); + if (password != null) { + buf.writeUtf(password, Voicechat.MAX_GROUP_NAME_LENGTH); } - buf.writeShort(GroupImpl.TypeImpl.toInt(this.type)); + buf.writeShort(GroupImpl.TypeImpl.toInt(type)); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/JoinGroupPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/JoinGroupPacket.java similarity index 67% rename from source/decompiled/de/maxhenkel/voicechat/net/JoinGroupPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/JoinGroupPacket.java index 53df9b9..dea102c 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/JoinGroupPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/JoinGroupPacket.java @@ -1,28 +1,23 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; -import java.util.UUID; -import javax.annotation.Nullable; import org.bukkit.entity.Player; -public class JoinGroupPacket -implements Packet { +import javax.annotation.Nullable; +import java.util.UUID; + +public class JoinGroupPacket implements Packet { + public static final Key SET_GROUP = Voicechat.compatibility.createNamespacedKey("set_group"); + private UUID group; @Nullable private String password; public JoinGroupPacket() { + } public JoinGroupPacket(UUID group, @Nullable String password) { @@ -31,12 +26,12 @@ implements Packet { } public UUID getGroup() { - return this.group; + return group; } @Nullable public String getPassword() { - return this.password; + return password; } @Override @@ -51,20 +46,20 @@ implements Packet { @Override public JoinGroupPacket fromBytes(FriendlyByteBuf buf) { - this.group = buf.readUUID(); + group = buf.readUUID(); if (buf.readBoolean()) { - this.password = buf.readUtf(512); + password = buf.readUtf(512); } return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.group); - buf.writeBoolean(this.password != null); - if (this.password != null) { - buf.writeUtf(this.password, 512); + buf.writeUUID(group); + buf.writeBoolean(password != null); + if (password != null) { + buf.writeUtf(password, 512); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/JoinedGroupPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/JoinedGroupPacket.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/net/JoinedGroupPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/JoinedGroupPacket.java index aa4ebda..1d6b81c 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/JoinedGroupPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/JoinedGroupPacket.java @@ -1,26 +1,22 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; -import java.util.UUID; -import javax.annotation.Nullable; -public class JoinedGroupPacket -implements Packet { +import javax.annotation.Nullable; +import java.util.UUID; + +public class JoinedGroupPacket implements Packet { + public static final Key JOINED_GROUP = Voicechat.compatibility.createNamespacedKey("joined_group"); + @Nullable private UUID group; private boolean wrongPassword; public JoinedGroupPacket() { + } public JoinedGroupPacket(@Nullable UUID group, boolean wrongPassword) { @@ -30,11 +26,11 @@ implements Packet { @Nullable public UUID getGroup() { - return this.group; + return group; } public boolean isWrongPassword() { - return this.wrongPassword; + return wrongPassword; } @Override @@ -45,19 +41,19 @@ implements Packet { @Override public JoinedGroupPacket fromBytes(FriendlyByteBuf buf) { if (buf.readBoolean()) { - this.group = buf.readUUID(); + group = buf.readUUID(); } - this.wrongPassword = buf.readBoolean(); + wrongPassword = buf.readBoolean(); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeBoolean(this.group != null); - if (this.group != null) { - buf.writeUUID(this.group); + buf.writeBoolean(group != null); + if (group != null) { + buf.writeUUID(group); } - buf.writeBoolean(this.wrongPassword); + buf.writeBoolean(wrongPassword); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/LeaveGroupPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/LeaveGroupPacket.java similarity index 76% rename from source/decompiled/de/maxhenkel/voicechat/net/LeaveGroupPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/LeaveGroupPacket.java index f7f8fdb..95d39fa 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/LeaveGroupPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/LeaveGroupPacket.java @@ -1,21 +1,18 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import org.bukkit.entity.Player; -public class LeaveGroupPacket -implements Packet { +public class LeaveGroupPacket implements Packet { + public static final Key LEAVE_GROUP = Voicechat.compatibility.createNamespacedKey("leave_group"); + public LeaveGroupPacket() { + + } + @Override public Key getID() { return LEAVE_GROUP; @@ -33,6 +30,7 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { - } -} + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/NetManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/NetManager.java new file mode 100644 index 0000000..da80ef5 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/NetManager.java @@ -0,0 +1,132 @@ +package de.maxhenkel.voicechat.net; + +import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.util.FriendlyByteBuf; +import io.netty.buffer.Unpooled; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.Set; + +public class NetManager implements Listener { + + private final Set packets = new HashSet<>(); + + public void onEnable() { + packets.clear(); + Bukkit.getPluginManager().registerEvents(this, Voicechat.INSTANCE); + try { + registerIncomingPacket(UpdateStatePacket.class); + registerIncomingPacket(RequestSecretPacket.class); + registerIncomingPacket(CreateGroupPacket.class); + registerIncomingPacket(JoinGroupPacket.class); + registerIncomingPacket(LeaveGroupPacket.class); + + registerOutgoingPacket(SecretPacket.class); + registerOutgoingPacket(PlayerStatesPacket.class); + registerOutgoingPacket(PlayerStatePacket.class); + registerOutgoingPacket(RemovePlayerStatePacket.class); + registerOutgoingPacket(AddGroupPacket.class); + registerOutgoingPacket(RemoveGroupPacket.class); + registerOutgoingPacket(JoinedGroupPacket.class); + registerOutgoingPacket(AddCategoryPacket.class); + registerOutgoingPacket(RemoveCategoryPacket.class); + } catch (Exception e) { + throw new IllegalStateException("Failed to register voice chat packets", e); + } + } + + public void onDisable() { + Set incomingChannels = Bukkit.getMessenger().getIncomingChannels(Voicechat.INSTANCE); + Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels(Voicechat.INSTANCE); + for (String channel : incomingChannels) { + Bukkit.getMessenger().unregisterIncomingPluginChannel(Voicechat.INSTANCE, channel); + } + for (String channel : outgoingChannels) { + Bukkit.getMessenger().unregisterOutgoingPluginChannel(Voicechat.INSTANCE, channel); + } + packets.clear(); + } + + public Set getPackets() { + return packets; + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels(Voicechat.INSTANCE); + for (String channel : outgoingChannels) { + Voicechat.compatibility.addChannel(event.getPlayer(), channel); + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels(Voicechat.INSTANCE); + for (String channel : outgoingChannels) { + Voicechat.compatibility.removeChannel(event.getPlayer(), channel); + } + } + + private > void registerIncomingPacket(Class packetClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { + Constructor c = packetClass.getDeclaredConstructor(); + String id = c.newInstance().getID().toString(); + packets.add(id); + Bukkit.getMessenger().registerIncomingPluginChannel(Voicechat.INSTANCE, id, (s, player, bytes) -> { + if (!Voicechat.SERVER.getRateLimiter().allow(player.getUniqueId())) { + Voicechat.LOGGER.warn("Player {} exceeded packet rate limit", player.getDisplayName()); + player.kickPlayer(Voicechat.TRANSLATIONS.rateLimitKickMessage.get()); + return; + } + T packet; + try { + packet = c.newInstance(); + } catch (Exception e) { + Voicechat.LOGGER.error("Failed to create new packet instance of {}", packetClass.getSimpleName(), e); + return; + } + FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes)); + packet.fromBytes(buffer); + packet.onPacket(player); + }); + } + + private > void registerOutgoingPacket(Class packetClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { + String id = packetClass.getDeclaredConstructor().newInstance().getID().toString(); + packets.add(id); + Bukkit.getMessenger().registerOutgoingPluginChannel(Voicechat.INSTANCE, id); + } + + public static void sendToClient(Player player, Packet p) { + Voicechat.compatibility.runTask(() -> { + if (!Voicechat.SERVER.isCompatible(player)) { + return; + } + try { + FriendlyByteBuf buf = new FriendlyByteBuf(); + p.toBytes(buf); + byte[] bytes = new byte[buf.readableBytes()]; + buf.readBytes(bytes); + player.sendPluginMessage(Voicechat.INSTANCE, p.getID().toString(), bytes); + } catch (Exception e) { + Voicechat.LOGGER.error("Failed to send packet to '{}'", player.getName(), e); + } + }); + } + + public static void sendMessage(Player player, String key, String... args) { + Voicechat.compatibility.sendTranslationMessage(player, key, args); + } + + public static void sendStatusMessage(Player player, String key, String... args) { + Voicechat.compatibility.sendStatusMessage(player, key, args); + } + +} \ No newline at end of file diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/Packet.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/Packet.java new file mode 100644 index 0000000..0100c4b --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/Packet.java @@ -0,0 +1,19 @@ +package de.maxhenkel.voicechat.net; + +import de.maxhenkel.voicechat.util.FriendlyByteBuf; +import de.maxhenkel.voicechat.util.Key; +import org.bukkit.entity.Player; + +public interface Packet { + + Key getID(); + + T fromBytes(FriendlyByteBuf buf); + + void toBytes(FriendlyByteBuf buf); + + default void onPacket(Player player) { + + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/PacketRateLimiter.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PacketRateLimiter.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/net/PacketRateLimiter.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PacketRateLimiter.java index eed6ec2..84f009b 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/PacketRateLimiter.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PacketRateLimiter.java @@ -1,17 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; +import org.bukkit.entity.Player; + import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.entity.Player; public class PacketRateLimiter { - private final ConcurrentHashMap rateLimiters = new ConcurrentHashMap(); + + private final ConcurrentHashMap rateLimiters = new ConcurrentHashMap<>(); private final int maxPacketsPerSecond; private final int timeWindowSeconds = 5; @@ -20,15 +16,15 @@ public class PacketRateLimiter { } public boolean allow(UUID player) { - if (this.maxPacketsPerSecond <= 0) { + if (maxPacketsPerSecond <= 0) { return true; } - RateLimiter limiter = this.rateLimiters.computeIfAbsent(player, id -> new RateLimiter(this.maxPacketsPerSecond * 5, 5000L)); + RateLimiter limiter = rateLimiters.computeIfAbsent(player, id -> new RateLimiter(maxPacketsPerSecond * timeWindowSeconds, 1000 * timeWindowSeconds)); return limiter.tryAcquire(); } public void onPlayerLoggedOut(Player player) { - this.rateLimiters.remove(player.getUniqueId()); + rateLimiters.remove(player.getUniqueId()); } private static class RateLimiter { @@ -39,28 +35,31 @@ public class PacketRateLimiter { public RateLimiter(int threshold, long windowMillis) { this.threshold = threshold; - this.timePerTokenNanos = windowMillis * 1000000L / (long)threshold; + this.timePerTokenNanos = (windowMillis * 1_000_000L) / threshold; this.lastLeakNanos = System.nanoTime(); this.amount = 0L; } public boolean tryAcquire() { long currentTime = System.nanoTime(); - long elapsed = currentTime - this.lastLeakNanos; - long leakedTokens = elapsed / this.timePerTokenNanos; - if (leakedTokens > 0L) { - this.amount -= leakedTokens; - if (this.amount < 0L) { - this.amount = 0L; + long elapsed = currentTime - lastLeakNanos; + long leakedTokens = elapsed / timePerTokenNanos; + + if (leakedTokens > 0) { + amount -= leakedTokens; + if (amount < 0) { + amount = 0; } - this.lastLeakNanos += leakedTokens * this.timePerTokenNanos; + lastLeakNanos += leakedTokens * timePerTokenNanos; } - if (this.amount >= (long)this.threshold) { + + if (amount >= threshold) { return false; } - ++this.amount; + + amount++; return true; } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/PlayerStatePacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PlayerStatePacket.java similarity index 74% rename from source/decompiled/de/maxhenkel/voicechat/net/PlayerStatePacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PlayerStatePacket.java index fb93cbc..434bf93 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/PlayerStatePacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PlayerStatePacket.java @@ -1,20 +1,18 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import de.maxhenkel.voicechat.voice.common.PlayerState; -public class PlayerStatePacket -implements Packet { +public class PlayerStatePacket implements Packet { + public static final Key PLAYER_STATE = Voicechat.compatibility.createNamespacedKey("state"); + private PlayerState playerState; public PlayerStatePacket() { + } public PlayerStatePacket(PlayerState playerState) { @@ -22,7 +20,7 @@ implements Packet { } public PlayerState getPlayerState() { - return this.playerState; + return playerState; } @Override @@ -32,13 +30,13 @@ implements Packet { @Override public PlayerStatePacket fromBytes(FriendlyByteBuf buf) { - this.playerState = PlayerState.fromBytes(buf); + playerState = PlayerState.fromBytes(buf); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - this.playerState.toBytes(buf); + playerState.toBytes(buf); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/PlayerStatesPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PlayerStatesPacket.java similarity index 66% rename from source/decompiled/de/maxhenkel/voicechat/net/PlayerStatesPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PlayerStatesPacket.java index 5a4b730..d436e47 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/PlayerStatesPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/PlayerStatesPacket.java @@ -1,22 +1,20 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import de.maxhenkel.voicechat.voice.common.PlayerState; -import java.util.ArrayList; -import java.util.Collection; -public class PlayerStatesPacket -implements Packet { +import java.util.*; + +public class PlayerStatesPacket implements Packet { + public static final Key PLAYER_STATES = Voicechat.compatibility.createNamespacedKey("states"); + private Collection playerStates; public PlayerStatesPacket() { + } public PlayerStatesPacket(Collection playerStates) { @@ -24,7 +22,7 @@ implements Packet { } public Collection getPlayerStates() { - return this.playerStates; + return playerStates; } @Override @@ -35,20 +33,21 @@ implements Packet { @Override public PlayerStatesPacket fromBytes(FriendlyByteBuf buf) { int count = buf.readInt(); - this.playerStates = new ArrayList(count); - for (int i = 0; i < count; ++i) { + playerStates = new ArrayList<>(count); + for (int i = 0; i < count; i++) { PlayerState playerState = PlayerState.fromBytes(buf); - this.playerStates.add(playerState); + playerStates.add(playerState); } + return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeInt(this.playerStates.size()); - for (PlayerState state : this.playerStates) { + buf.writeInt(playerStates.size()); + for (PlayerState state : playerStates) { state.toBytes(buf); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/RemoveCategoryPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemoveCategoryPacket.java similarity index 73% rename from source/decompiled/de/maxhenkel/voicechat/net/RemoveCategoryPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemoveCategoryPacket.java index e4e7c6d..3358189 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/RemoveCategoryPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemoveCategoryPacket.java @@ -1,19 +1,17 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; -public class RemoveCategoryPacket -implements Packet { +public class RemoveCategoryPacket implements Packet { + public static final Key REMOVE_CATEGORY = Voicechat.compatibility.createNamespacedKey("remove_category"); + private String categoryId; public RemoveCategoryPacket() { + } public RemoveCategoryPacket(String categoryId) { @@ -21,7 +19,7 @@ implements Packet { } public String getCategoryId() { - return this.categoryId; + return categoryId; } @Override @@ -31,13 +29,13 @@ implements Packet { @Override public RemoveCategoryPacket fromBytes(FriendlyByteBuf buf) { - this.categoryId = buf.readUtf(16); + categoryId = buf.readUtf(16); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUtf(this.categoryId, 16); + buf.writeUtf(categoryId, 16); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/RemoveGroupPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemoveGroupPacket.java similarity index 74% rename from source/decompiled/de/maxhenkel/voicechat/net/RemoveGroupPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemoveGroupPacket.java index cdbd61d..26e8829 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/RemoveGroupPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemoveGroupPacket.java @@ -1,20 +1,19 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; + import java.util.UUID; -public class RemoveGroupPacket -implements Packet { +public class RemoveGroupPacket implements Packet { + public static final Key REMOVE_GROUP = Voicechat.compatibility.createNamespacedKey("remove_group"); + private UUID groupId; public RemoveGroupPacket() { + } public RemoveGroupPacket(UUID groupId) { @@ -22,7 +21,7 @@ implements Packet { } public UUID getGroupId() { - return this.groupId; + return groupId; } @Override @@ -32,13 +31,13 @@ implements Packet { @Override public RemoveGroupPacket fromBytes(FriendlyByteBuf buf) { - this.groupId = buf.readUUID(); + groupId = buf.readUUID(); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.groupId); + buf.writeUUID(groupId); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/RemovePlayerStatePacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemovePlayerStatePacket.java similarity index 74% rename from source/decompiled/de/maxhenkel/voicechat/net/RemovePlayerStatePacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemovePlayerStatePacket.java index 4a5d4b0..351962c 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/RemovePlayerStatePacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RemovePlayerStatePacket.java @@ -1,20 +1,19 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; + import java.util.UUID; -public class RemovePlayerStatePacket -implements Packet { +public class RemovePlayerStatePacket implements Packet { + public static final Key REMOVE_PLAYER_STATE = Voicechat.compatibility.createNamespacedKey("remove_state"); + private UUID id; public RemovePlayerStatePacket() { + } public RemovePlayerStatePacket(UUID id) { @@ -22,7 +21,7 @@ implements Packet { } public UUID getId() { - return this.id; + return id; } @Override @@ -32,13 +31,13 @@ implements Packet { @Override public RemovePlayerStatePacket fromBytes(FriendlyByteBuf buf) { - this.id = buf.readUUID(); + id = buf.readUUID(); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.id); + buf.writeUUID(id); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/RequestSecretPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RequestSecretPacket.java similarity index 71% rename from source/decompiled/de/maxhenkel/voicechat/net/RequestSecretPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RequestSecretPacket.java index d59f0e0..66247d3 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/RequestSecretPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/RequestSecretPacket.java @@ -1,23 +1,18 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import org.bukkit.entity.Player; -public class RequestSecretPacket -implements Packet { +public class RequestSecretPacket implements Packet { + public static final Key REQUEST_SECRET = Voicechat.compatibility.createNamespacedKey("request_secret"); + private int compatibilityVersion; public RequestSecretPacket() { + } public RequestSecretPacket(int compatibilityVersion) { @@ -25,7 +20,7 @@ implements Packet { } public int getCompatibilityVersion() { - return this.compatibilityVersion; + return compatibilityVersion; } @Override @@ -40,13 +35,13 @@ implements Packet { @Override public RequestSecretPacket fromBytes(FriendlyByteBuf buf) { - this.compatibilityVersion = buf.readInt(); + compatibilityVersion = buf.readInt(); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeInt(this.compatibilityVersion); + buf.writeInt(compatibilityVersion); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/SecretPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/SecretPacket.java similarity index 59% rename from source/decompiled/de/maxhenkel/voicechat/net/SecretPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/SecretPacket.java index 93f0071..0670c37 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/SecretPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/SecretPacket.java @@ -1,23 +1,18 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.config.ServerConfig; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import de.maxhenkel.voicechat.voice.common.Secret; -import java.util.UUID; import org.bukkit.entity.Player; -public class SecretPacket -implements Packet { +import java.util.UUID; + +public class SecretPacket implements Packet { + public static final Key SECRET = Voicechat.compatibility.createNamespacedKey("secret"); + private Secret secret; private int serverPort; private UUID playerUUID; @@ -30,6 +25,7 @@ implements Packet { private boolean allowRecording; public SecretPacket() { + } public SecretPacket(Player player, Secret secret, int port, ServerConfig serverConfig, String voiceHost) { @@ -46,39 +42,39 @@ implements Packet { } public Secret getSecret() { - return this.secret; + return secret; } public int getServerPort() { - return this.serverPort; + return serverPort; } public UUID getPlayerUUID() { - return this.playerUUID; + return playerUUID; } public ServerConfig.Codec getCodec() { - return this.codec; + return codec; } public int getMtuSize() { - return this.mtuSize; + return mtuSize; } public double getVoiceChatDistance() { - return this.voiceChatDistance; + return voiceChatDistance; } public int getKeepAlive() { - return this.keepAlive; + return keepAlive; } public boolean groupsEnabled() { - return this.groupsEnabled; + return groupsEnabled; } public String getVoiceHost() { - return this.voiceHost; + return voiceHost; } @Override @@ -87,36 +83,36 @@ implements Packet { } public boolean allowRecording() { - return this.allowRecording; + return allowRecording; } @Override public SecretPacket fromBytes(FriendlyByteBuf buf) { - this.secret = Secret.fromBytes(buf); - this.serverPort = buf.readInt(); - this.playerUUID = buf.readUUID(); - this.codec = ServerConfig.Codec.values()[buf.readByte()]; - this.mtuSize = buf.readInt(); - this.voiceChatDistance = buf.readDouble(); - this.keepAlive = buf.readInt(); - this.groupsEnabled = buf.readBoolean(); - this.voiceHost = buf.readUtf(); - this.allowRecording = buf.readBoolean(); + secret = Secret.fromBytes(buf); + serverPort = buf.readInt(); + playerUUID = buf.readUUID(); + codec = ServerConfig.Codec.values()[buf.readByte()]; + mtuSize = buf.readInt(); + voiceChatDistance = buf.readDouble(); + keepAlive = buf.readInt(); + groupsEnabled = buf.readBoolean(); + voiceHost = buf.readUtf(); + allowRecording = buf.readBoolean(); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - this.secret.toBytes(buf); - buf.writeInt(this.serverPort); - buf.writeUUID(this.playerUUID); - buf.writeByte(this.codec.ordinal()); - buf.writeInt(this.mtuSize); - buf.writeDouble(this.voiceChatDistance); - buf.writeInt(this.keepAlive); - buf.writeBoolean(this.groupsEnabled); - buf.writeUtf(this.voiceHost); - buf.writeBoolean(this.allowRecording); + secret.toBytes(buf); + buf.writeInt(serverPort); + buf.writeUUID(playerUUID); + buf.writeByte(codec.ordinal()); + buf.writeInt(mtuSize); + buf.writeDouble(voiceChatDistance); + buf.writeInt(keepAlive); + buf.writeBoolean(groupsEnabled); + buf.writeUtf(voiceHost); + buf.writeBoolean(allowRecording); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/net/UpdateStatePacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/UpdateStatePacket.java similarity index 73% rename from source/decompiled/de/maxhenkel/voicechat/net/UpdateStatePacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/net/UpdateStatePacket.java index 0f467c6..45fdcad 100644 --- a/source/decompiled/de/maxhenkel/voicechat/net/UpdateStatePacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/net/UpdateStatePacket.java @@ -1,23 +1,18 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.net; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.Packet; import de.maxhenkel.voicechat.util.FriendlyByteBuf; import de.maxhenkel.voicechat.util.Key; import org.bukkit.entity.Player; -public class UpdateStatePacket -implements Packet { +public class UpdateStatePacket implements Packet { + public static final Key PLAYER_STATE = Voicechat.compatibility.createNamespacedKey("update_state"); + private boolean disabled; public UpdateStatePacket() { + } public UpdateStatePacket(boolean disabled) { @@ -25,7 +20,7 @@ implements Packet { } public boolean isDisabled() { - return this.disabled; + return disabled; } @Override @@ -40,13 +35,13 @@ implements Packet { @Override public UpdateStatePacket fromBytes(FriendlyByteBuf buf) { - this.disabled = buf.readBoolean(); + disabled = buf.readBoolean(); return this; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeBoolean(this.disabled); + buf.writeBoolean(disabled); } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/permission/PermissionManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/permission/PermissionManager.java new file mode 100644 index 0000000..8e28e69 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/permission/PermissionManager.java @@ -0,0 +1,14 @@ +package de.maxhenkel.voicechat.permission; + +import de.maxhenkel.voicechat.Voicechat; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; + +public class PermissionManager { + + public static Permission LISTEN_PERMISSION = new Permission(Voicechat.MODID + ".listen", PermissionDefault.TRUE); + public static Permission SPEAK_PERMISSION = new Permission(Voicechat.MODID + ".speak", PermissionDefault.TRUE); + public static Permission GROUPS_PERMISSION = new Permission(Voicechat.MODID + ".groups", PermissionDefault.TRUE); + public static Permission ADMIN_PERMISSION = new Permission(Voicechat.MODID + ".admin", PermissionDefault.OP); + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/CategoryManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/CategoryManager.java similarity index 56% rename from source/decompiled/de/maxhenkel/voicechat/plugins/CategoryManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/CategoryManager.java index 11a1939..b22eef1 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/CategoryManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/CategoryManager.java @@ -1,31 +1,30 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins; import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl; + +import javax.annotation.Nullable; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nullable; public class CategoryManager { - protected final Map categories = new ConcurrentHashMap(); + + protected final Map categories; + + public CategoryManager() { + categories = new ConcurrentHashMap<>(); + } public void addCategory(VolumeCategoryImpl category) { - this.categories.put(category.getId(), category); + categories.put(category.getId(), category); } @Nullable public VolumeCategoryImpl removeCategory(String categoryId) { - return this.categories.remove(categoryId); + return categories.remove(categoryId); } public Collection getCategories() { - return this.categories.values(); + return categories.values(); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/EventBuilder.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/EventBuilder.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/plugins/EventBuilder.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/EventBuilder.java index bfaf2a4..766a00e 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/EventBuilder.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/EventBuilder.java @@ -1,9 +1,7 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins; import de.maxhenkel.voicechat.api.events.Event; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -12,22 +10,24 @@ import java.util.function.Consumer; import java.util.stream.Collectors; public class EventBuilder { - private final Map, List>>> events = new HashMap, List>>>(); + + private final Map, List>>> events; private EventBuilder() { + events = new HashMap<>(); } public EventBuilder addEvent(Class eventClass, Consumer event, int priority) { - List eventList = this.events.getOrDefault(eventClass, new ArrayList()); - eventList.add(new Tuple>(priority, event)); + List>> eventList = this.events.getOrDefault(eventClass, new ArrayList<>()); + eventList.add(new Tuple<>(priority, event)); this.events.put(eventClass, eventList); return this; } public Map, List>> build() { - HashMap, List>> result = new HashMap, List>>(); - for (Map.Entry, List>>> entry : this.events.entrySet()) { - result.put(entry.getKey(), entry.getValue().stream().sorted((o1, o2) -> Integer.compare((Integer)o2.getA(), (Integer)o1.getA())).map(Tuple::getB).collect(Collectors.toList())); + Map, List>> result = new HashMap<>(); + for (Map.Entry, List>>> entry : events.entrySet()) { + result.put(entry.getKey(), entry.getValue().stream().sorted((o1, o2) -> Integer.compare(o2.getA(), o1.getA())).map(Tuple::getB).collect(Collectors.toList())); } return result; } @@ -46,12 +46,12 @@ public class EventBuilder { } public A getA() { - return this.a; + return a; } public B getB() { - return this.b; + return b; } } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/PluginManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/PluginManager.java new file mode 100644 index 0000000..d769775 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/PluginManager.java @@ -0,0 +1,300 @@ +package de.maxhenkel.voicechat.plugins; + +import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.api.VoicechatConnection; +import de.maxhenkel.voicechat.api.VoicechatPlugin; +import de.maxhenkel.voicechat.api.VoicechatSocket; +import de.maxhenkel.voicechat.api.VolumeCategory; +import de.maxhenkel.voicechat.api.audiolistener.AudioListener; +import de.maxhenkel.voicechat.api.audiolistener.PlayerAudioListener; +import de.maxhenkel.voicechat.api.events.*; +import de.maxhenkel.voicechat.plugins.impl.GroupImpl; +import de.maxhenkel.voicechat.plugins.impl.VoicechatConnectionImpl; +import de.maxhenkel.voicechat.plugins.impl.VoicechatServerApiImpl; +import de.maxhenkel.voicechat.plugins.impl.VoicechatSocketImpl; +import de.maxhenkel.voicechat.plugins.impl.audiolistener.PlayerAudioListenerImpl; +import de.maxhenkel.voicechat.plugins.impl.events.*; +import de.maxhenkel.voicechat.plugins.impl.packets.*; +import de.maxhenkel.voicechat.voice.common.*; +import de.maxhenkel.voicechat.voice.server.Group; +import de.maxhenkel.voicechat.voice.server.Server; +import org.bukkit.entity.Player; + +import javax.annotation.Nullable; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Consumer; + +public class PluginManager { + + private List plugins; + private Map, List>> events; + private final Map> playerAudioListeners = new ConcurrentHashMap<>(); + + public void init() { + Voicechat.LOGGER.info("Loading plugins"); + plugins = Voicechat.apiService.getPlugins(); + Voicechat.LOGGER.info("Loaded {} plugin(s)", plugins.size()); + Voicechat.LOGGER.info("Initializing plugins"); + for (VoicechatPlugin plugin : plugins) { + try { + plugin.initialize(VoicechatServerApiImpl.instance()); + } catch (Exception e) { + Voicechat.LOGGER.error("Failed to initialize plugin '{}'", plugin.getPluginId(), e); + } + } + Voicechat.LOGGER.info("Initialized {} plugin(s)", plugins.size()); + gatherEvents(); + } + + private void gatherEvents() { + EventBuilder eventBuilder = EventBuilder.create(); + EventRegistration registration = eventBuilder::addEvent; + for (VoicechatPlugin plugin : plugins) { + Voicechat.LOGGER.info("Registering events for '{}'", plugin.getPluginId()); + try { + plugin.registerEvents(registration); + } catch (Throwable t) { + Voicechat.LOGGER.error("Failed to register events for '{}'", plugin.getPluginId(), t); + } + } + events = eventBuilder.build(); + } + + public synchronized boolean registerAudioListener(AudioListener l) { + if (!(l instanceof PlayerAudioListener)) { + return false; + } + PlayerAudioListener listener = (PlayerAudioListener) l; + boolean exists = playerAudioListeners + .values() + .stream() + .anyMatch(listeners -> + listeners + .stream() + .anyMatch(playerAudioListener -> playerAudioListener.getListenerId().equals(listener.getListenerId())) + ); + + if (exists) { + return false; + } + + playerAudioListeners.computeIfAbsent(listener.getPlayerUuid(), k -> new CopyOnWriteArrayList<>()).add(listener); + return true; + } + + public synchronized boolean unregisterAudioListener(UUID listenerId) { + boolean removed = playerAudioListeners + .values() + .stream() + .anyMatch(listeners -> + listeners.removeIf(listener -> listener.getListenerId().equals(listenerId)) + ); + if (!removed) { + return false; + } + playerAudioListeners.values().removeIf(List::isEmpty); + return true; + } + + public List getPlayerAudioListeners(UUID playerUuid) { + return playerAudioListeners.getOrDefault(playerUuid, Collections.emptyList()); + } + + public void onListenerAudio(UUID playerUuid, SoundPacket packet) { + if (playerUuid.equals(packet.getSender())) { + return; + } + List listeners = getPlayerAudioListeners(playerUuid); + if (listeners.isEmpty()) { + return; + } + + SoundPacketImpl soundPacket; + if (packet instanceof GroupSoundPacket) { + soundPacket = new StaticSoundPacketImpl((GroupSoundPacket) packet); + } else if (packet instanceof PlayerSoundPacket) { + soundPacket = new EntitySoundPacketImpl((PlayerSoundPacket) packet); + } else if (packet instanceof LocationSoundPacket) { + soundPacket = new LocationalSoundPacketImpl((LocationSoundPacket) packet); + } else { + soundPacket = new SoundPacketImpl(packet); + } + + for (PlayerAudioListener l : listeners) { + if (l instanceof PlayerAudioListenerImpl) { + try { + ((PlayerAudioListenerImpl) l).getListener().accept(soundPacket); + } catch (Throwable t) { + Voicechat.LOGGER.error("Failed to process audio listener", t); + } + } + } + } + + public boolean dispatchEvent(Class eventClass, T event) { + List> events = this.events.get(eventClass); + if (events == null) { + return false; + } + for (Consumer evt : events) { + try { + Consumer e = (Consumer) evt; + e.accept(event); + if (event.isCancelled()) { + break; + } + } catch (Throwable t) { + Voicechat.LOGGER.error("Failed to dispatch event '{}'", eventClass.getSimpleName(), t); + } + } + return event.isCancelled(); + } + + public VoicechatSocket getSocketImplementation() { + VoicechatServerStartingEventImpl event = new VoicechatServerStartingEventImpl(); + dispatchEvent(VoicechatServerStartingEvent.class, event); + VoicechatSocket socket = event.getSocketImplementation(); + if (socket == null) { + socket = new VoicechatSocketImpl(); + Voicechat.LOGGER.debug("Using default voicechat socket implementation"); + } else { + Voicechat.LOGGER.info("Using custom voicechat socket implementation: {}", socket.getClass().getName()); + } + return socket; + } + + public String getVoiceHost(Player player, String voiceHost) { + VoiceHostEventImpl event = new VoiceHostEventImpl(player, voiceHost); + dispatchEvent(VoiceHostEvent.class, event); + return event.getVoiceHost(); + } + + public void onRegisterVolumeCategory(VolumeCategory category) { + dispatchEvent(RegisterVolumeCategoryEvent.class, new RegisterVolumeCategoryEventImpl(category)); + } + + public void onUnregisterVolumeCategory(VolumeCategory category) { + dispatchEvent(UnregisterVolumeCategoryEvent.class, new UnregisterVolumeCategoryEventImpl(category)); + } + + public void onServerStarted() { + dispatchEvent(VoicechatServerStartedEvent.class, new VoicechatServerStartedEventImpl()); + } + + public void onServerStopped() { + dispatchEvent(VoicechatServerStoppedEvent.class, new VoicechatServerStoppedEventImpl()); + } + + public void onPlayerConnected(@Nullable Player player) { + if (player == null) { + return; + } + dispatchEvent(PlayerConnectedEvent.class, new PlayerConnectedEventImpl(VoicechatConnectionImpl.fromPlayer(player))); + } + + public void onPlayerDisconnected(UUID player) { + dispatchEvent(PlayerDisconnectedEvent.class, new PlayerDisconnectedEventImpl(player)); + } + + public void onPlayerStateChanged(PlayerState state) { + dispatchEvent(PlayerStateChangedEvent.class, new PlayerStateChangedEventImpl(state)); + } + + public boolean onJoinGroup(Player player, @Nullable Group group) { + if (group == null) { + return onLeaveGroup(player); + } + return dispatchEvent(JoinGroupEvent.class, new JoinGroupEventImpl(new GroupImpl(group), VoicechatConnectionImpl.fromPlayer(player))); + } + + public boolean onCreateGroup(@Nullable Player player, @Nullable Group group) { + if (group == null) { + if (player == null) { + return false; + } + return onLeaveGroup(player); + } + return dispatchEvent(CreateGroupEvent.class, new CreateGroupEventImpl(new GroupImpl(group), VoicechatConnectionImpl.fromPlayer(player))); + } + + public boolean onLeaveGroup(Player player) { + Server server = Voicechat.SERVER.getServer(); + if (server == null) { + return false; + } + @Nullable GroupImpl group = null; + PlayerState state = server.getPlayerStateManager().getState(player.getUniqueId()); + if (state != null) { + UUID groupUUID = state.getGroup(); + if (groupUUID != null) { + Group g = server.getGroupManager().getGroup(groupUUID); + if (g != null) { + group = new GroupImpl(g); + } + } + } + + return dispatchEvent(LeaveGroupEvent.class, new LeaveGroupEventImpl(group, VoicechatConnectionImpl.fromPlayer(player))); + } + + public boolean onRemoveGroup(Group group) { + return dispatchEvent(RemoveGroupEvent.class, new RemoveGroupEventImpl(new GroupImpl(group))); + } + + public boolean onMicPacket(Player sender, PlayerState senderState, MicPacket packet) { + return dispatchEvent(MicrophonePacketEvent.class, new MicrophonePacketEventImpl( + new MicrophonePacketImpl(packet, sender.getUniqueId()), + new VoicechatConnectionImpl(sender, senderState) + )); + } + + public float getDistance(Player sender, PlayerState senderState, MicPacket packet, float originalDistance) { + VoiceDistanceEventImpl event = new VoiceDistanceEventImpl(new MicrophonePacketImpl(packet, sender.getUniqueId()), new VoicechatConnectionImpl(sender, senderState), originalDistance); + dispatchEvent(VoiceDistanceEvent.class, event); + return event.getDistance(); + } + + public boolean onSoundPacket(@Nullable Player sender, @Nullable PlayerState senderState, Player receiver, PlayerState receiverState, SoundPacket p, String source) { + VoicechatConnection senderConnection = null; + if (sender != null && senderState != null) { + senderConnection = new VoicechatConnectionImpl(sender, senderState); + } + + VoicechatConnection receiverConnection = new VoicechatConnectionImpl(receiver, receiverState); + if (p instanceof LocationSoundPacket) { + return dispatchEvent(LocationalSoundPacketEvent.class, new LocationalSoundPacketEventImpl( + new LocationalSoundPacketImpl((LocationSoundPacket) p), + senderConnection, + receiverConnection, + source + )); + } else if (p instanceof PlayerSoundPacket) { + return dispatchEvent(EntitySoundPacketEvent.class, new EntitySoundPacketEventImpl( + new EntitySoundPacketImpl((PlayerSoundPacket) p), + senderConnection, + receiverConnection, + source + )); + } else if (p instanceof GroupSoundPacket) { + return dispatchEvent(StaticSoundPacketEvent.class, new StaticSoundPacketEventImpl( + new StaticSoundPacketImpl((GroupSoundPacket) p), + senderConnection, + receiverConnection, + source + )); + } + return false; + } + + private static PluginManager instance; + + public static synchronized PluginManager instance() { + if (instance == null) { + instance = new PluginManager(); + } + return instance; + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/BukkitVoicechatServiceImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/BukkitVoicechatServiceImpl.java similarity index 56% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/BukkitVoicechatServiceImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/BukkitVoicechatServiceImpl.java index 69e22ba..30439de 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/BukkitVoicechatServiceImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/BukkitVoicechatServiceImpl.java @@ -1,24 +1,25 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.api.BukkitVoicechatService; import de.maxhenkel.voicechat.api.VoicechatPlugin; + import java.util.ArrayList; import java.util.List; -public class BukkitVoicechatServiceImpl -implements BukkitVoicechatService { - private final List plugins = new ArrayList(); +public class BukkitVoicechatServiceImpl implements BukkitVoicechatService { + + private final List plugins; + + public BukkitVoicechatServiceImpl() { + plugins = new ArrayList<>(); + } @Override public void registerPlugin(VoicechatPlugin plugin) { - this.plugins.add(plugin); + plugins.add(plugin); } public List getPlugins() { - return this.plugins; + return plugins; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/EntityImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/EntityImpl.java similarity index 54% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/EntityImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/EntityImpl.java index 371815c..cdb3463 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/EntityImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/EntityImpl.java @@ -1,19 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Entity - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.api.Entity; import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.plugins.impl.PositionImpl; + import java.util.Objects; import java.util.UUID; -public class EntityImpl -implements Entity { +public class EntityImpl implements Entity { + protected org.bukkit.entity.Entity entity; public EntityImpl(org.bukkit.entity.Entity entity) { @@ -22,36 +16,38 @@ implements Entity { @Override public UUID getUuid() { - return this.entity.getUniqueId(); + return entity.getUniqueId(); } @Override public Object getEntity() { - return this.entity; + return entity; } @Override public Position getPosition() { - return new PositionImpl(this.entity.getLocation()); + return new PositionImpl(entity.getLocation()); } public org.bukkit.entity.Entity getRealEntity() { - return this.entity; + return entity; } + @Override public boolean equals(Object object) { if (this == object) { return true; } - if (object == null || this.getClass() != object.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - EntityImpl entity1 = (EntityImpl)object; - return Objects.equals(this.entity, entity1.entity); + EntityImpl entity1 = (EntityImpl) object; + return Objects.equals(entity, entity1.entity); } + @Override public int hashCode() { - return this.entity != null ? this.entity.hashCode() : 0; + return entity != null ? entity.hashCode() : 0; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/GroupImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/GroupImpl.java similarity index 58% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/GroupImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/GroupImpl.java index 27f02da..9617ca6 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/GroupImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/GroupImpl.java @@ -1,113 +1,88 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.voice.common.PlayerState; -import de.maxhenkel.voicechat.voice.server.Group; import de.maxhenkel.voicechat.voice.server.Server; + +import javax.annotation.Nullable; import java.util.Objects; import java.util.UUID; -import javax.annotation.Nullable; -public class GroupImpl -implements de.maxhenkel.voicechat.api.Group { - private final Group group; +public class GroupImpl implements Group { - public GroupImpl(Group group) { + private final de.maxhenkel.voicechat.voice.server.Group group; + + public GroupImpl(de.maxhenkel.voicechat.voice.server.Group group) { this.group = group; } @Override public String getName() { - return this.group.getName(); + return group.getName(); } @Override public boolean hasPassword() { - return this.group.getPassword() != null; + return group.getPassword() != null; } @Override public UUID getId() { - return this.group.getId(); + return group.getId(); } @Override public boolean isPersistent() { - return this.group.isPersistent(); + return group.isPersistent(); } @Override public boolean isHidden() { - return this.group.isHidden(); + return group.isHidden(); } @Override - public Group.Type getType() { - return this.group.getType(); + public Type getType() { + return group.getType(); } - public Group getGroup() { - return this.group; + public de.maxhenkel.voicechat.voice.server.Group getGroup() { + return group; } @Nullable public static GroupImpl create(PlayerState state) { - Group g; UUID groupId = state.getGroup(); Server server = Voicechat.SERVER.getServer(); - if (server != null && groupId != null && (g = server.getGroupManager().getGroup(groupId)) != null) { - return new GroupImpl(g); + if (server != null && groupId != null) { + de.maxhenkel.voicechat.voice.server.Group g = server.getGroupManager().getGroup(groupId); + if (g != null) { + return new GroupImpl(g); + } } return null; } + @Override public boolean equals(Object object) { if (this == object) { return true; } - if (object == null || this.getClass() != object.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - GroupImpl group1 = (GroupImpl)object; - return Objects.equals(this.group.getId(), group1.group.getId()); + GroupImpl group1 = (GroupImpl) object; + return Objects.equals(group.getId(), group1.group.getId()); } + @Override public int hashCode() { - return this.group != null ? this.group.getId().hashCode() : 0; + return group != null ? group.getId().hashCode() : 0; } - public static class TypeImpl - implements Group.Type { - public static short toInt(Group.Type type) { - if (type == OPEN) { - return 1; - } - if (type == ISOLATED) { - return 2; - } - return 0; - } + public static class BuilderImpl implements Group.Builder { - public static Group.Type fromInt(short i) { - if (i == 1) { - return OPEN; - } - if (i == 2) { - return ISOLATED; - } - return NORMAL; - } - } - - public static class BuilderImpl - implements Group.Builder { @Nullable private UUID id; private String name; @@ -115,10 +90,14 @@ implements de.maxhenkel.voicechat.api.Group { private String password; private boolean persistent; private boolean hidden; - private Group.Type type = Group.Type.NORMAL; + private Type type; + + public BuilderImpl() { + type = Type.NORMAL; + } @Override - public Group.Builder setId(@Nullable UUID id) { + public Builder setId(@Nullable UUID id) { this.id = id; return this; } @@ -126,12 +105,13 @@ implements de.maxhenkel.voicechat.api.Group { @Override public Group.Builder setName(String name) { this.name = name; - this.name = BuilderImpl.convertGroupName(name); + this.name = convertGroupName(name); return this; } private static String convertGroupName(String name) { - if ((name = name.replaceAll("[\\n\\r\\t]", "")).matches("^\\s.*")) { + name = name.replaceAll("[\\n\\r\\t]", ""); + if (name.matches("^\\s.*")) { name = name.replaceFirst("^\\s+", ""); } if (name.length() > 16) { @@ -153,32 +133,55 @@ implements de.maxhenkel.voicechat.api.Group { } @Override - public Group.Builder setHidden(boolean hidden) { + public Builder setHidden(boolean hidden) { this.hidden = hidden; return this; } @Override - public Group.Builder setType(Group.Type type) { + public Group.Builder setType(Type type) { this.type = type; return this; } @Override - public de.maxhenkel.voicechat.api.Group build() { - if (this.name == null) { + public Group build() { + if (name == null) { throw new IllegalStateException("Group is missing a name"); } - if (!Voicechat.GROUP_REGEX.matcher(this.name).matches()) { - throw new IllegalStateException(String.format("Invalid group name: %s", this.name)); + if (!Voicechat.GROUP_REGEX.matcher(name).matches()) { + throw new IllegalStateException(String.format("Invalid group name: %s", name)); } - GroupImpl group = new GroupImpl(new Group(this.id == null ? UUID.randomUUID() : this.id, this.name, this.password, this.persistent, this.hidden, this.type)); + GroupImpl group = new GroupImpl(new de.maxhenkel.voicechat.voice.server.Group(id == null ? UUID.randomUUID() : id, name, password, persistent, hidden, type)); Server server = Voicechat.SERVER.getServer(); - if (server != null && this.persistent) { + if (server != null && persistent) { server.getGroupManager().addGroup(group.getGroup(), null); } return group; } } -} + public static class TypeImpl implements Group.Type { + + public static short toInt(Group.Type type) { + if (type == OPEN) { + return 1; + } else if (type == ISOLATED) { + return 2; + } else { + return 0; + } + } + + public static Group.Type fromInt(short i) { + if (i == 1) { + return OPEN; + } else if (i == 2) { + return ISOLATED; + } else { + return NORMAL; + } + } + } + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/PlayerImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/PlayerImpl.java new file mode 100644 index 0000000..7fbbf77 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/PlayerImpl.java @@ -0,0 +1,20 @@ +package de.maxhenkel.voicechat.plugins.impl; + +import de.maxhenkel.voicechat.api.Player; + +public class PlayerImpl extends EntityImpl implements Player { + + public PlayerImpl(org.bukkit.entity.Player entity) { + super(entity); + } + + @Override + public Object getPlayer() { + return entity; + } + + public org.bukkit.entity.Player getRealPlayer() { + return (org.bukkit.entity.Player) entity; + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/PositionImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/PositionImpl.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/PositionImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/PositionImpl.java index 2dc6695..3a5d403 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/PositionImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/PositionImpl.java @@ -1,17 +1,12 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.Location - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.api.Position; -import java.util.Objects; import org.bukkit.Location; -public class PositionImpl -implements Position { +import java.util.Objects; + +public class PositionImpl implements Position { + private final Location position; public PositionImpl(Location position) { @@ -24,36 +19,37 @@ implements Position { @Override public double getX() { - return this.position.getX(); + return position.getX(); } @Override public double getY() { - return this.position.getY(); + return position.getY(); } @Override public double getZ() { - return this.position.getZ(); + return position.getZ(); } public Location getPosition() { - return this.position; + return position; } + @Override public boolean equals(Object object) { if (this == object) { return true; } - if (object == null || this.getClass() != object.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - PositionImpl position1 = (PositionImpl)object; - return Objects.equals(this.position, position1.position); + PositionImpl position1 = (PositionImpl) object; + return Objects.equals(position, position1.position); } + @Override public int hashCode() { - return this.position != null ? this.position.hashCode() : 0; + return position != null ? position.hashCode() : 0; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/RawUdpPacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/RawUdpPacketImpl.java similarity index 78% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/RawUdpPacketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/RawUdpPacketImpl.java index 7454bfe..2e4ad42 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/RawUdpPacketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/RawUdpPacketImpl.java @@ -1,14 +1,13 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.api.RawUdpPacket; + import java.net.SocketAddress; -public class RawUdpPacketImpl -implements RawUdpPacket { +public class RawUdpPacketImpl implements RawUdpPacket { + private static final byte[] BUFFER = new byte[4096]; + private final byte[] data; private final SocketAddress socketAddress; private final long timestamp; @@ -21,17 +20,16 @@ implements RawUdpPacket { @Override public byte[] getData() { - return this.data; + return data; } @Override public long getTimestamp() { - return this.timestamp; + return timestamp; } @Override public SocketAddress getSocketAddress() { - return this.socketAddress; + return socketAddress; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/ServerLevelImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/ServerLevelImpl.java similarity index 53% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/ServerLevelImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/ServerLevelImpl.java index 8300659..4b8fc73 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/ServerLevelImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/ServerLevelImpl.java @@ -1,17 +1,12 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.World - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.api.ServerLevel; -import java.util.Objects; import org.bukkit.World; -public class ServerLevelImpl -implements ServerLevel { +import java.util.Objects; + +public class ServerLevelImpl implements ServerLevel { + private final World serverLevel; public ServerLevelImpl(World serverLevel) { @@ -20,22 +15,23 @@ implements ServerLevel { @Override public Object getServerLevel() { - return this.serverLevel; + return serverLevel; } + @Override public boolean equals(Object object) { if (this == object) { return true; } - if (object == null || this.getClass() != object.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - ServerLevelImpl that = (ServerLevelImpl)object; - return Objects.equals(this.serverLevel, that.serverLevel); + ServerLevelImpl that = (ServerLevelImpl) object; + return Objects.equals(serverLevel, that.serverLevel); } + @Override public int hashCode() { - return this.serverLevel != null ? this.serverLevel.hashCode() : 0; + return serverLevel != null ? serverLevel.hashCode() : 0; } } - diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/ServerPlayerImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/ServerPlayerImpl.java new file mode 100644 index 0000000..9672924 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/ServerPlayerImpl.java @@ -0,0 +1,21 @@ +package de.maxhenkel.voicechat.plugins.impl; + +import de.maxhenkel.voicechat.api.ServerLevel; +import de.maxhenkel.voicechat.api.ServerPlayer; +import org.bukkit.entity.Player; + +public class ServerPlayerImpl extends PlayerImpl implements ServerPlayer { + + public ServerPlayerImpl(Player entity) { + super(entity); + } + + public Player getRealServerPlayer() { + return (Player) entity; + } + + @Override + public ServerLevel getServerLevel() { + return new ServerLevelImpl(entity.getWorld()); + } +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatApiImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatApiImpl.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatApiImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatApiImpl.java index 392892e..cac8199 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatApiImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatApiImpl.java @@ -1,43 +1,24 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.World - * org.bukkit.entity.Entity - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl; -import de.maxhenkel.voicechat.api.Entity; -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.ServerLevel; -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.VoicechatApi; -import de.maxhenkel.voicechat.api.VolumeCategory; +import de.maxhenkel.voicechat.api.*; import de.maxhenkel.voicechat.api.audio.AudioConverter; import de.maxhenkel.voicechat.api.mp3.Mp3Decoder; import de.maxhenkel.voicechat.api.mp3.Mp3Encoder; import de.maxhenkel.voicechat.api.opus.OpusDecoder; import de.maxhenkel.voicechat.api.opus.OpusEncoder; import de.maxhenkel.voicechat.api.opus.OpusEncoderMode; -import de.maxhenkel.voicechat.plugins.impl.EntityImpl; -import de.maxhenkel.voicechat.plugins.impl.PositionImpl; -import de.maxhenkel.voicechat.plugins.impl.ServerLevelImpl; -import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl; import de.maxhenkel.voicechat.plugins.impl.audio.AudioConverterImpl; import de.maxhenkel.voicechat.plugins.impl.opus.OpusManager; import de.maxhenkel.voicechat.voice.common.Utils; -import java.io.InputStream; -import java.io.OutputStream; +import org.bukkit.World; + import javax.annotation.Nullable; import javax.sound.sampled.AudioFormat; -import org.bukkit.World; -import org.bukkit.entity.Player; +import java.io.InputStream; +import java.io.OutputStream; + +public abstract class VoicechatApiImpl implements VoicechatApi { -public abstract class VoicechatApiImpl -implements VoicechatApi { private static final AudioConverter AUDIO_CONVERTER = new AudioConverterImpl(); @Override @@ -50,14 +31,14 @@ implements VoicechatApi { return OpusManager.createEncoder(mode); } - @Override @Nullable + @Override public Mp3Encoder createMp3Encoder(AudioFormat audioFormat, int bitrate, int quality, OutputStream outputStream) { return null; } - @Override @Nullable + @Override public Mp3Decoder createMp3Decoder(InputStream inputStream) { return null; } @@ -67,7 +48,6 @@ implements VoicechatApi { return OpusManager.createDecoder(); } - @Override public AudioConverter getAudioConverter() { return AUDIO_CONVERTER; } @@ -75,25 +55,28 @@ implements VoicechatApi { @Override public Entity fromEntity(Object entity) { if (entity instanceof org.bukkit.entity.Entity) { - return new EntityImpl((org.bukkit.entity.Entity)entity); + return new EntityImpl((org.bukkit.entity.Entity) entity); + } else { + throw new IllegalArgumentException("entity is not an instance of Entity"); } - throw new IllegalArgumentException("entity is not an instance of Entity"); } @Override public ServerLevel fromServerLevel(Object serverLevel) { if (serverLevel instanceof World) { - return new ServerLevelImpl((World)serverLevel); + return new ServerLevelImpl((World) serverLevel); + } else { + throw new IllegalArgumentException("serverLevel is not an instance of World"); } - throw new IllegalArgumentException("serverLevel is not an instance of World"); } @Override public ServerPlayer fromServerPlayer(Object serverPlayer) { - if (serverPlayer instanceof Player) { - return new ServerPlayerImpl((Player)serverPlayer); + if (serverPlayer instanceof org.bukkit.entity.Player) { + return new ServerPlayerImpl((org.bukkit.entity.Player) serverPlayer); + } else { + throw new IllegalArgumentException("serverPlayer is not an instance of Player"); } - throw new IllegalArgumentException("serverPlayer is not an instance of Player"); } @Override @@ -110,5 +93,5 @@ implements VoicechatApi { public double getVoiceChatDistance() { return Utils.getDefaultDistance(); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatConnectionImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatConnectionImpl.java similarity index 69% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatConnectionImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatConnectionImpl.java index a564bcd..2b727ca 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatConnectionImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatConnectionImpl.java @@ -1,31 +1,23 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.ServerPlayer; import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.plugins.impl.GroupImpl; -import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; import de.maxhenkel.voicechat.voice.common.PlayerState; -import de.maxhenkel.voicechat.voice.server.Group; import de.maxhenkel.voicechat.voice.server.PlayerStateManager; import de.maxhenkel.voicechat.voice.server.Server; -import javax.annotation.Nullable; import org.bukkit.entity.Player; -public class VoicechatConnectionImpl -implements VoicechatConnection { +import javax.annotation.Nullable; + +public class VoicechatConnectionImpl implements VoicechatConnection { + private final ServerPlayer player; private final Player serverPlayer; private final PlayerState state; @Nullable - private final de.maxhenkel.voicechat.api.Group group; + private final Group group; public VoicechatConnectionImpl(Player player, PlayerState state) { this.serverPlayer = player; @@ -50,46 +42,46 @@ implements VoicechatConnection { return new VoicechatConnectionImpl(player, state); } - @Override @Nullable - public de.maxhenkel.voicechat.api.Group getGroup() { - return this.group; + @Override + public Group getGroup() { + return group; } @Override public boolean isInGroup() { - return this.group != null; + return group != null; } @Override - public void setGroup(@Nullable de.maxhenkel.voicechat.api.Group group) { + public void setGroup(@Nullable Group group) { Server server = Voicechat.SERVER.getServer(); if (server == null) { return; } if (group == null) { - server.getGroupManager().leaveGroup((Player)this.player.getPlayer()); + server.getGroupManager().leaveGroup((Player) player.getPlayer()); return; } if (group instanceof GroupImpl) { - GroupImpl g = (GroupImpl)group; - Group actualGroup = server.getGroupManager().getGroup(g.getGroup().getId()); + GroupImpl g = (GroupImpl) group; + de.maxhenkel.voicechat.voice.server.Group actualGroup = server.getGroupManager().getGroup(g.getGroup().getId()); if (actualGroup == null) { - server.getGroupManager().addGroup(g.getGroup(), this.serverPlayer); + server.getGroupManager().addGroup(g.getGroup(), serverPlayer); actualGroup = g.getGroup(); } - server.getGroupManager().joinGroup(actualGroup, this.serverPlayer, g.getGroup().getPassword()); + server.getGroupManager().joinGroup(actualGroup, serverPlayer, g.getGroup().getPassword()); } } @Override public boolean isConnected() { - return !this.state.isDisconnected(); + return !state.isDisconnected(); } @Override public void setConnected(boolean connected) { - if (this.isInstalled()) { + if (isInstalled()) { return; } Server server = Voicechat.SERVER.getServer(); @@ -97,7 +89,7 @@ implements VoicechatConnection { return; } PlayerStateManager manager = server.getPlayerStateManager(); - PlayerState actualState = manager.getState(this.state.getUuid()); + PlayerState actualState = manager.getState(state.getUuid()); if (actualState == null) { return; } @@ -110,12 +102,12 @@ implements VoicechatConnection { @Override public boolean isDisabled() { - return this.state.isDisabled(); + return state.isDisabled(); } @Override public void setDisabled(boolean disabled) { - if (this.isInstalled()) { + if (isInstalled()) { return; } Server server = Voicechat.SERVER.getServer(); @@ -123,7 +115,7 @@ implements VoicechatConnection { return; } PlayerStateManager manager = server.getPlayerStateManager(); - PlayerState actualState = manager.getState(this.state.getUuid()); + PlayerState actualState = manager.getState(state.getUuid()); if (actualState == null) { return; } @@ -136,12 +128,12 @@ implements VoicechatConnection { @Override public boolean isInstalled() { - return Voicechat.SERVER.isCompatible(this.serverPlayer); + return Voicechat.SERVER.isCompatible(serverPlayer); } @Override public ServerPlayer getPlayer() { - return this.player; + return player; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatServerApiImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatServerApiImpl.java similarity index 72% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatServerApiImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatServerApiImpl.java index 871551c..cf06911 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatServerApiImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatServerApiImpl.java @@ -1,49 +1,20 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - * org.bukkit.World - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.api.Entity; -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.ServerLevel; -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.VoicechatServerApi; -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.AudioPlayer; -import de.maxhenkel.voicechat.api.audiochannel.EntityAudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.LocationalAudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.StaticAudioChannel; +import de.maxhenkel.voicechat.api.*; +import de.maxhenkel.voicechat.api.audiochannel.*; import de.maxhenkel.voicechat.api.audiolistener.AudioListener; import de.maxhenkel.voicechat.api.audiolistener.PlayerAudioListener; import de.maxhenkel.voicechat.api.audiosender.AudioSender; import de.maxhenkel.voicechat.api.config.ConfigAccessor; +import de.maxhenkel.voicechat.api.events.SoundPacketEvent; import de.maxhenkel.voicechat.api.opus.OpusEncoder; import de.maxhenkel.voicechat.api.packets.ConvertablePacket; import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; import de.maxhenkel.voicechat.plugins.PluginManager; -import de.maxhenkel.voicechat.plugins.impl.GroupImpl; -import de.maxhenkel.voicechat.plugins.impl.PositionImpl; -import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.VoicechatApiImpl; -import de.maxhenkel.voicechat.plugins.impl.VoicechatConnectionImpl; -import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioSupplier; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.EntityAudioChannelImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.LocationalAudioChannelImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.StaticAudioChannelImpl; +import de.maxhenkel.voicechat.plugins.impl.audiochannel.*; import de.maxhenkel.voicechat.plugins.impl.audiolistener.PlayerAudioListenerImpl; import de.maxhenkel.voicechat.plugins.impl.audiosender.AudioSenderImpl; import de.maxhenkel.voicechat.plugins.impl.config.ConfigAccessorImpl; @@ -54,50 +25,50 @@ import de.maxhenkel.voicechat.plugins.impl.packets.StaticSoundPacketImpl; import de.maxhenkel.voicechat.voice.common.PlayerState; import de.maxhenkel.voicechat.voice.common.SoundPacket; import de.maxhenkel.voicechat.voice.server.ClientConnection; -import de.maxhenkel.voicechat.voice.server.Group; import de.maxhenkel.voicechat.voice.server.Server; import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; +import org.bukkit.Bukkit; +import org.bukkit.World; + +import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; import java.util.UUID; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; -public class VoicechatServerApiImpl -extends VoicechatApiImpl -implements VoicechatServerApi { +public class VoicechatServerApiImpl extends VoicechatApiImpl implements VoicechatServerApi { + private static final VoicechatServerApiImpl INSTANCE = new VoicechatServerApiImpl(); private VoicechatServerApiImpl() { + } public static VoicechatServerApiImpl instance() { return INSTANCE; } + @Override public void sendEntitySoundPacketTo(VoicechatConnection connection, EntitySoundPacket p) { if (p instanceof EntitySoundPacketImpl) { - VoicechatServerApiImpl.sendPacket(connection, ((EntitySoundPacketImpl)p).getPacket()); + sendPacket(connection, ((EntitySoundPacketImpl) p).getPacket()); } } @Override public void sendLocationalSoundPacketTo(VoicechatConnection connection, LocationalSoundPacket p) { if (p instanceof LocationalSoundPacketImpl) { - VoicechatServerApiImpl.sendPacket(connection, ((LocationalSoundPacketImpl)p).getPacket()); + sendPacket(connection, ((LocationalSoundPacketImpl) p).getPacket()); } } @Override public void sendStaticSoundPacketTo(VoicechatConnection connection, StaticSoundPacket p) { if (p instanceof StaticSoundPacketImpl) { - VoicechatServerApiImpl.sendPacket(connection, ((StaticSoundPacketImpl)p).getPacket()); + sendPacket(connection, ((StaticSoundPacketImpl) p).getPacket()); } } @@ -106,8 +77,8 @@ implements VoicechatServerApi { return new ConvertablePacketImpl(); } - @Override @Nullable + @Override public EntityAudioChannel createEntityAudioChannel(UUID channelId, Entity entity) { Server server = Voicechat.SERVER.getServer(); if (server == null) { @@ -116,21 +87,22 @@ implements VoicechatServerApi { return new EntityAudioChannelImpl(channelId, server, entity); } - @Override @Nullable + @Override public LocationalAudioChannel createLocationalAudioChannel(UUID channelId, ServerLevel level, Position initialPosition) { Server server = Voicechat.SERVER.getServer(); if (server == null) { return null; } if (initialPosition instanceof PositionImpl) { - return new LocationalAudioChannelImpl(channelId, server, level, (PositionImpl)initialPosition); + return new LocationalAudioChannelImpl(channelId, server, level, (PositionImpl) initialPosition); + } else { + throw new IllegalArgumentException("initialPosition is not an instance of PositionImpl"); } - throw new IllegalArgumentException("initialPosition is not an instance of PositionImpl"); } - @Override @Nullable + @Override public StaticAudioChannel createStaticAudioChannel(UUID channelId, ServerLevel level, VoicechatConnection connection) { Server server = Voicechat.SERVER.getServer(); if (server == null) { @@ -141,8 +113,8 @@ implements VoicechatServerApi { return staticAudioChannel; } - @Override @Nullable + @Override public StaticAudioChannel createStaticAudioChannel(UUID channelId) { Server server = Voicechat.SERVER.getServer(); if (server == null) { @@ -171,7 +143,7 @@ implements VoicechatServerApi { if (!(sender instanceof AudioSenderImpl)) { return false; } - return AudioSenderImpl.registerAudioSender((AudioSenderImpl)sender); + return AudioSenderImpl.registerAudioSender((AudioSenderImpl) sender); } @Override @@ -179,7 +151,7 @@ implements VoicechatServerApi { if (!(sender instanceof AudioSenderImpl)) { return false; } - return AudioSenderImpl.unregisterAudioSender((AudioSenderImpl)sender); + return AudioSenderImpl.unregisterAudioSender((AudioSenderImpl) sender); } @Override @@ -194,7 +166,7 @@ implements VoicechatServerApi { @Override public boolean unregisterAudioListener(AudioListener listener) { - return this.unregisterAudioListener(listener.getListenerId()); + return unregisterAudioListener(listener.getListenerId()); } @Override @@ -206,10 +178,10 @@ implements VoicechatServerApi { if (!(receiver.getPlayer() instanceof ServerPlayerImpl)) { throw new IllegalArgumentException("ServerPlayer is not an instance of ServerPlayerImpl"); } - VoicechatServerApiImpl.sendPacket(((ServerPlayerImpl)receiver.getPlayer()).getRealServerPlayer(), soundPacket); + sendPacket(((ServerPlayerImpl) receiver.getPlayer()).getRealServerPlayer(), soundPacket); } - public static void sendPacket(Player receiver, SoundPacket soundPacket) { + public static void sendPacket(org.bukkit.entity.Player receiver, SoundPacket soundPacket) { Server server = Voicechat.SERVER.getServer(); if (server == null) { return; @@ -218,14 +190,14 @@ implements VoicechatServerApi { if (state == null) { return; } - ClientConnection c = server.getConnections().get(receiver.getUniqueId()); - server.sendSoundPacket(null, null, receiver, state, c, soundPacket, "plugin"); + @Nullable ClientConnection c = server.getConnections().get(receiver.getUniqueId()); + server.sendSoundPacket(null, null, receiver, state, c, soundPacket, SoundPacketEvent.SOURCE_PLUGIN); } - @Override @Nullable + @Override public VoicechatConnection getConnectionOf(UUID playerUuid) { - Player player = Bukkit.getPlayer((UUID)playerUuid); + org.bukkit.entity.Player player = Bukkit.getPlayer(playerUuid); if (player == null) { return null; } @@ -233,13 +205,13 @@ implements VoicechatServerApi { } @Override - public de.maxhenkel.voicechat.api.Group createGroup(String name, @Nullable String password) { - return this.createGroup(name, password, false); + public Group createGroup(String name, @Nullable String password) { + return createGroup(name, password, false); } @Override - public de.maxhenkel.voicechat.api.Group createGroup(String name, @Nullable String password, boolean persistent) { - return this.groupBuilder().setName(name).setPassword(password).setPersistent(persistent).build(); + public Group createGroup(String name, @Nullable String password, boolean persistent) { + return groupBuilder().setName(name).setPassword(password).setPersistent(persistent).build(); } @Override @@ -256,9 +228,9 @@ implements VoicechatServerApi { return server.getGroupManager().removeGroup(groupId); } - @Override @Nullable - public de.maxhenkel.voicechat.api.Group getGroup(UUID groupId) { + @Override + public Group getGroup(UUID groupId) { Server server = Voicechat.SERVER.getServer(); if (server == null) { return null; @@ -267,16 +239,16 @@ implements VoicechatServerApi { } @Override - public Collection getGroups() { + public Collection getGroups() { Server server = Voicechat.SERVER.getServer(); if (server == null) { return Collections.emptyList(); } - return server.getGroupManager().getGroups().values().stream().map(group -> new GroupImpl((Group)group)).collect(Collectors.toList()); + return server.getGroupManager().getGroups().values().stream().map(group -> (Group) new GroupImpl(group)).collect(Collectors.toList()); } - @Override @Nullable + @Override public UUID getSecret(UUID userId) { return null; } @@ -284,9 +256,10 @@ implements VoicechatServerApi { @Override public Collection getPlayersInRange(ServerLevel level, Position pos, double range, @Nullable Predicate filter) { if (pos instanceof PositionImpl) { - return ServerPlayerManager.getPlayersInRange((World)level.getServerLevel(), ((PositionImpl)pos).getPosition(), range, filter == null ? null : player -> filter.test(new ServerPlayerImpl((Player)player))).stream().map(ServerPlayerImpl::new).collect(Collectors.toList()); + return ServerPlayerManager.getPlayersInRange((World) level.getServerLevel(), ((PositionImpl) pos).getPosition(), range, filter == null ? null : player -> filter.test(new ServerPlayerImpl(player))).stream().map(ServerPlayerImpl::new).collect(Collectors.toList()); + } else { + throw new IllegalArgumentException("Position is not an instance of PositionImpl"); } - throw new IllegalArgumentException("Position is not an instance of PositionImpl"); } @Override @@ -303,7 +276,7 @@ implements VoicechatServerApi { if (server == null) { return; } - server.getCategoryManager().addCategory((VolumeCategoryImpl)category); + server.getCategoryManager().addCategory((VolumeCategoryImpl) category); PluginManager.instance().onRegisterVolumeCategory(category); } @@ -332,5 +305,5 @@ implements VoicechatServerApi { public ConfigAccessor getServerConfig() { return new ConfigAccessorImpl(Voicechat.SERVER_CONFIG.voiceChatDistance.getConfig()); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketBase.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketBase.java similarity index 68% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketBase.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketBase.java index f19dd3a..5a2e21d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketBase.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketBase.java @@ -1,29 +1,30 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.debug.CooldownTimer; -import de.maxhenkel.voicechat.plugins.impl.RawUdpPacketImpl; + import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; public class VoicechatSocketBase { + private final byte[] BUFFER = new byte[4096]; public RawUdpPacketImpl read(DatagramSocket socket) throws IOException { - DatagramPacket packet = new DatagramPacket(this.BUFFER, this.BUFFER.length); + DatagramPacket packet = new DatagramPacket(BUFFER, BUFFER.length); socket.receive(packet); - if (packet.getLength() >= this.BUFFER.length) { - CooldownTimer.run("udp_packet_too_large", () -> Voicechat.LOGGER.warn("Packet from {} is too large", packet.getSocketAddress())); + if (packet.getLength() >= BUFFER.length) { + CooldownTimer.run("udp_packet_too_large", () -> { + Voicechat.LOGGER.warn("Packet from {} is too large", packet.getSocketAddress()); + }); throw new IOException(String.format("Packet from %s is too large", packet.getSocketAddress())); } + // Setting the timestamp after receiving the packet long timestamp = System.currentTimeMillis(); byte[] data = new byte[packet.getLength()]; System.arraycopy(packet.getData(), packet.getOffset(), data, 0, packet.getLength()); return new RawUdpPacketImpl(data, packet.getSocketAddress(), timestamp); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketImpl.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketImpl.java index 9ba0b85..8e09034 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VoicechatSocketImpl.java @@ -1,65 +1,49 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.Bukkit - * org.bukkit.plugin.Plugin - */ package de.maxhenkel.voicechat.plugins.impl; +import de.maxhenkel.voicechat.BuildConstants; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.api.RawUdpPacket; import de.maxhenkel.voicechat.api.VoicechatSocket; -import de.maxhenkel.voicechat.plugins.impl.VoicechatSocketBase; -import java.net.BindException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.SocketAddress; -import java.net.URI; -import java.net.URISyntaxException; import org.bukkit.Bukkit; -import org.bukkit.plugin.Plugin; -public class VoicechatSocketImpl -extends VoicechatSocketBase -implements VoicechatSocket { +import java.net.*; + +public class VoicechatSocketImpl extends VoicechatSocketBase implements VoicechatSocket { + private DatagramSocket socket; @Override public void open(int port, String bindAddress) throws Exception { - if (this.socket != null) { + if (socket != null) { throw new IllegalStateException("Socket already opened"); } - this.checkCorrectHost(); + checkCorrectHost(); InetAddress address = null; try { if (!bindAddress.isEmpty()) { address = InetAddress.getByName(bindAddress); } - } - catch (Exception e) { + } catch (Exception e) { bindAddress = ""; Voicechat.LOGGER.error("Failed to parse bind IP address '{}'", bindAddress, e); } + try { try { - this.socket = new DatagramSocket(port, address); - } - catch (BindException e) { + socket = new DatagramSocket(port, address); + } catch (BindException e) { if (address == null || bindAddress.equals("0.0.0.0")) { throw e; } Voicechat.LOGGER.error("Failed to bind to address '{}', binding to wildcard IP instead", bindAddress); - this.socket = new DatagramSocket(port); + socket = new DatagramSocket(port); } - this.socket.setTrafficClass(4); - } - catch (BindException e) { + socket.setTrafficClass(0x04); // IPTOS_RELIABILITY + } catch (BindException e) { Voicechat.LOGGER.fatal("Failed to run voice chat at UDP port {}, make sure no other application is running at that port", port); - Bukkit.getScheduler().runTask((Plugin)Voicechat.INSTANCE, () -> { - Voicechat.LOGGER.fatal("Disabling {}", "Simple Voice Chat"); - Bukkit.getPluginManager().disablePlugin((Plugin)Voicechat.INSTANCE); + Bukkit.getScheduler().runTask(Voicechat.INSTANCE, () -> { + Voicechat.LOGGER.fatal("Disabling {}", BuildConstants.PLUGIN_NAME); + Bukkit.getPluginManager().disablePlugin(Voicechat.INSTANCE); }); throw e; } @@ -77,13 +61,11 @@ implements VoicechatSocket { } else { Voicechat.LOGGER.info("Voice host port is {}", port); } - } - catch (NumberFormatException ignored) { + } catch (NumberFormatException ignored) { try { new URI("voicechat://" + host); Voicechat.LOGGER.info("Voice host is '{}'", host); - } - catch (URISyntaxException e) { + } catch (URISyntaxException e) { Voicechat.LOGGER.warn("Failed to parse voice host", e); Bukkit.shutdown(); throw e; @@ -93,46 +75,44 @@ implements VoicechatSocket { @Override public RawUdpPacket read() throws Exception { - if (this.socket == null) { + if (socket == null) { throw new IllegalStateException("Socket not opened yet"); } - return this.read(this.socket); + return read(socket); } @Override public void send(byte[] data, SocketAddress address) throws Exception { - if (this.socket == null || this.socket.isClosed()) { - return; + if (socket == null || socket.isClosed()) { + return; // Ignoring packet sending when socket isn't open yet or already closed } - this.socket.send(new DatagramPacket(data, data.length, address)); + socket.send(new DatagramPacket(data, data.length, address)); } @Override public int getLocalPort() { - if (this.socket == null) { + if (socket == null) { return -1; } - return this.socket.getLocalPort(); + return socket.getLocalPort(); } @Override public void close() { - if (this.socket != null) { + if (socket != null) { try { - this.socket.close(); - } - catch (Throwable throwable) { - // empty catch block + socket.close(); + } catch (Throwable ignored) { + // Apparently some JDKs throw an "Error" when closing a datagram socket } } } @Override public boolean isClosed() { - if (this.socket == null) { + if (socket == null) { return true; } - return this.socket.isClosed(); + return socket.isClosed(); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VolumeCategoryImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VolumeCategoryImpl.java similarity index 61% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/VolumeCategoryImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VolumeCategoryImpl.java index 5d3ab99..bd49b5e 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/VolumeCategoryImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/VolumeCategoryImpl.java @@ -1,19 +1,15 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl; import de.maxhenkel.voicechat.api.VolumeCategory; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import java.util.regex.Pattern; -import javax.annotation.Nullable; -public class VolumeCategoryImpl -implements VolumeCategory { +import javax.annotation.Nullable; +import java.util.regex.Pattern; + +public class VolumeCategoryImpl implements VolumeCategory { + public static final Pattern ID_REGEX = Pattern.compile("^[a-z_]{1,16}$"); + private final String id; private final String name; @Nullable @@ -39,49 +35,49 @@ implements VolumeCategory { @Override public String getId() { - return this.id; + return id; } @Override public String getName() { - return this.name; + return name; } @Override @Nullable public String getNameTranslationKey() { - return this.nameTranslationKey; + return nameTranslationKey; } - @Override @Nullable + @Override public String getDescription() { - return this.description; + return description; } @Override @Nullable public String getDescriptionTranslationKey() { - return this.descriptionTranslationKey; + return descriptionTranslationKey; } - @Override @Nullable + @Override public int[][] getIcon() { - return this.icon; + return icon; } public static VolumeCategoryImpl fromBytes(FriendlyByteBuf buf) { String id = buf.readUtf(16); String name = buf.readUtf(16); - String nameTranslationKey = VolumeCategoryImpl.readOptionalString(buf); - String description = VolumeCategoryImpl.readOptionalString(buf); - String descriptionTranslationKey = VolumeCategoryImpl.readOptionalString(buf); + String nameTranslationKey = readOptionalString(buf); + String description = readOptionalString(buf); + String descriptionTranslationKey = readOptionalString(buf); int[][] icon = null; if (buf.readBoolean()) { icon = new int[16][16]; - for (int x = 0; x < icon.length; ++x) { - for (int y = 0; y < icon.length; ++y) { + for (int x = 0; x < icon.length; x++) { + for (int y = 0; y < icon.length; y++) { icon[x][y] = buf.readInt(); } } @@ -92,28 +88,28 @@ implements VolumeCategory { @Nullable private static String readOptionalString(FriendlyByteBuf buf) { if (buf.readBoolean()) { - return buf.readUtf(Short.MAX_VALUE); + return buf.readUtf(32767); } return null; } public void toBytes(FriendlyByteBuf buf) { - buf.writeUtf(this.id, 16); - buf.writeUtf(this.name, 16); - VolumeCategoryImpl.writeOptionalString(buf, this.nameTranslationKey); - VolumeCategoryImpl.writeOptionalString(buf, this.description); - VolumeCategoryImpl.writeOptionalString(buf, this.descriptionTranslationKey); - buf.writeBoolean(this.icon != null); - if (this.icon != null) { - if (this.icon.length != 16) { + buf.writeUtf(id, 16); + buf.writeUtf(name, 16); + writeOptionalString(buf, nameTranslationKey); + writeOptionalString(buf, description); + writeOptionalString(buf, descriptionTranslationKey); + buf.writeBoolean(icon != null); + if (icon != null) { + if (icon.length != 16) { throw new IllegalStateException("Icon is not 16x16"); } - for (int x = 0; x < this.icon.length; ++x) { - if (this.icon[x].length != 16) { + for (int x = 0; x < icon.length; x++) { + if (icon[x].length != 16) { throw new IllegalStateException("Icon is not 16x16"); } - for (int y = 0; y < this.icon.length; ++y) { - buf.writeInt(this.icon[x][y]); + for (int y = 0; y < icon.length; y++) { + buf.writeInt(icon[x][y]); } } } @@ -122,27 +118,29 @@ implements VolumeCategory { private static void writeOptionalString(FriendlyByteBuf buf, @Nullable String string) { buf.writeBoolean(string != null); if (string != null) { - buf.writeUtf(string, Short.MAX_VALUE); + buf.writeUtf(string, 32767); } } + @Override public boolean equals(Object object) { if (this == object) { return true; } - if (object == null || this.getClass() != object.getClass()) { + if (object == null || getClass() != object.getClass()) { return false; } - VolumeCategoryImpl that = (VolumeCategoryImpl)object; - return this.id.equals(that.id); + VolumeCategoryImpl that = (VolumeCategoryImpl) object; + return id.equals(that.id); } + @Override public int hashCode() { - return this.id.hashCode(); + return id.hashCode(); } - public static class BuilderImpl - implements VolumeCategory.Builder { + public static class BuilderImpl implements VolumeCategory.Builder { + private String id; private String name; @Nullable @@ -155,51 +153,51 @@ implements VolumeCategory { private int[][] icon; @Override - public VolumeCategory.Builder setId(String id) { + public Builder setId(String id) { this.id = id; return this; } @Override - public VolumeCategory.Builder setName(String name) { + public Builder setName(String name) { this.name = name; return this; } @Override - public VolumeCategory.Builder setNameTranslationKey(@Nullable String translationKey) { + public Builder setNameTranslationKey(@Nullable String translationKey) { this.nameTranslationKey = translationKey; return this; } @Override - public VolumeCategory.Builder setDescription(@Nullable String description) { + public Builder setDescription(@Nullable String description) { this.description = description; return this; } @Override - public VolumeCategory.Builder setDescriptionTranslationKey(@Nullable String translationKey) { + public Builder setDescriptionTranslationKey(@Nullable String translationKey) { this.descriptionTranslationKey = translationKey; return this; } @Override - public VolumeCategory.Builder setIcon(@Nullable int[][] icon) { + public Builder setIcon(@Nullable int[][] icon) { this.icon = icon; return this; } @Override public VolumeCategory build() { - if (this.id == null) { + if (id == null) { throw new IllegalStateException("id missing"); } - if (this.name == null) { + if (name == null) { throw new IllegalStateException("name missing"); } - return new VolumeCategoryImpl(this.id, this.name, this.nameTranslationKey, this.description, this.descriptionTranslationKey, this.icon); + return new VolumeCategoryImpl(id, name, nameTranslationKey, description, descriptionTranslationKey, icon); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audio/AudioConverterImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audio/AudioConverterImpl.java similarity index 90% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audio/AudioConverterImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audio/AudioConverterImpl.java index 3cfdd10..f56eb7b 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audio/AudioConverterImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audio/AudioConverterImpl.java @@ -1,13 +1,10 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.audio; import de.maxhenkel.voicechat.api.audio.AudioConverter; import de.maxhenkel.voicechat.voice.common.AudioUtils; -public class AudioConverterImpl -implements AudioConverter { +public class AudioConverterImpl implements AudioConverter { + @Override public short[] bytesToShorts(byte[] bytes) { return AudioUtils.bytesToShorts(bytes); @@ -38,4 +35,3 @@ implements AudioConverter { return AudioUtils.bytesToFloats(bytes); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioChannelImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioChannelImpl.java similarity index 80% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioChannelImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioChannelImpl.java index 3a32f19..459e46b 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioChannelImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioChannelImpl.java @@ -1,21 +1,16 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.audiochannel; import de.maxhenkel.voicechat.api.ServerPlayer; import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; import de.maxhenkel.voicechat.voice.server.Server; + +import javax.annotation.Nullable; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Predicate; -import javax.annotation.Nullable; -public abstract class AudioChannelImpl -implements AudioChannel { +public abstract class AudioChannelImpl implements AudioChannel { + protected UUID channelId; protected Server server; protected AtomicLong sequenceNumber; @@ -37,18 +32,18 @@ implements AudioChannel { @Override public UUID getId() { - return this.channelId; + return channelId; } @Override public boolean isClosed() { - return this.server.isClosed(); + return server.isClosed(); } - @Override @Nullable + @Override public String getCategory() { - return this.category; + return category; } @Override @@ -56,4 +51,3 @@ implements AudioChannel { this.category = category; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioPlayerImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioPlayerImpl.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioPlayerImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioPlayerImpl.java index a43fa9a..946754f 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioPlayerImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioPlayerImpl.java @@ -1,10 +1,3 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.audiochannel; import de.maxhenkel.voicechat.Voicechat; @@ -12,15 +5,16 @@ import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; import de.maxhenkel.voicechat.api.audiochannel.AudioPlayer; import de.maxhenkel.voicechat.api.opus.OpusEncoder; import de.maxhenkel.voicechat.debug.VoicechatUncaughtExceptionHandler; -import java.util.function.Supplier; + import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.util.function.Supplier; -public class AudioPlayerImpl -extends Thread -implements AudioPlayer { - private static final long FRAME_SIZE_NS = 20000000L; +public class AudioPlayerImpl extends Thread implements AudioPlayer { + + private static final long FRAME_SIZE_NS = 20_000_000; public static final int FRAME_SIZE = 960; + private final AudioChannel audioChannel; private final OpusEncoder encoder; private final Supplier audioSupplier; @@ -32,38 +26,38 @@ implements AudioPlayer { this.audioChannel = audioChannel; this.encoder = encoder; this.audioSupplier = audioSupplier; - this.setDaemon(true); - this.setName(String.format("AudioPlayer-%s", audioChannel.getId())); - this.setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler()); + setDaemon(true); + setName(String.format("AudioPlayer-%s", audioChannel.getId())); + setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler()); } @Override public void startPlaying() { - if (this.started) { + if (started) { return; } - this.start(); - this.started = true; + start(); + started = true; } @Override public void stopPlaying() { - this.interrupt(); + interrupt(); } @Override public boolean isStarted() { - return this.started; + return started; } @Override public boolean isPlaying() { - return this.isAlive(); + return isAlive(); } @Override public boolean isStopped() { - return this.started && !this.isAlive(); + return started && !isAlive(); } @Override @@ -73,30 +67,38 @@ implements AudioPlayer { @Override public void run() { - short[] frame; int framePosition = 0; + long startTime = System.nanoTime(); - while ((frame = this.audioSupplier.get()) != null) { - if (frame.length != 960) { - Voicechat.LOGGER.error("Got invalid audio frame size {}!={}", frame.length, 960); + + short[] frame; + + while ((frame = audioSupplier.get()) != null) { + if (frame.length != FRAME_SIZE) { + Voicechat.LOGGER.error("Got invalid audio frame size {}!={}", frame.length, FRAME_SIZE); break; } - this.audioChannel.send(this.encoder.encode(frame)); - long waitTimestamp = startTime + (long)(++framePosition) * 20000000L; + audioChannel.send(encoder.encode(frame)); + framePosition++; + long waitTimestamp = startTime + framePosition * FRAME_SIZE_NS; + long waitNanos = waitTimestamp - System.nanoTime(); + try { - if (waitNanos <= 0L) continue; - Thread.sleep(waitNanos / 1000000L, (int)(waitNanos % 1000000L)); - } - catch (InterruptedException e) { + if (waitNanos > 0L) { + Thread.sleep(waitNanos / 1_000_000L, (int) (waitNanos % 1_000_000)); + } + } catch (InterruptedException e) { break; } } - this.encoder.close(); - this.audioChannel.flush(); - if (this.onStopped != null) { - this.onStopped.run(); + + encoder.close(); + audioChannel.flush(); + + if (onStopped != null) { + onStopped.run(); } } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioSupplier.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioSupplier.java new file mode 100644 index 0000000..97b5df1 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioSupplier.java @@ -0,0 +1,28 @@ +package de.maxhenkel.voicechat.plugins.impl.audiochannel; + +import java.util.Arrays; +import java.util.function.Supplier; + +public class AudioSupplier implements Supplier { + + private final short[] audioData; + private final short[] frame; + private int framePosition; + + public AudioSupplier(short[] audioData) { + this.audioData = audioData; + this.frame = new short[AudioPlayerImpl.FRAME_SIZE]; + } + + @Override + public short[] get() { + if (framePosition >= audioData.length) { + return null; + } + + Arrays.fill(frame, (short) 0); + System.arraycopy(audioData, framePosition, frame, 0, Math.min(frame.length, audioData.length - framePosition)); + framePosition += frame.length; + return frame; + } +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/EntityAudioChannelImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/EntityAudioChannelImpl.java similarity index 54% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/EntityAudioChannelImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/EntityAudioChannelImpl.java index 7354d1f..8147bef 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/EntityAudioChannelImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/EntityAudioChannelImpl.java @@ -1,27 +1,19 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Entity - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl.audiochannel; import de.maxhenkel.voicechat.api.Entity; import de.maxhenkel.voicechat.api.audiochannel.EntityAudioChannel; +import de.maxhenkel.voicechat.api.events.SoundPacketEvent; import de.maxhenkel.voicechat.api.packets.MicrophonePacket; import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioChannelImpl; import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; import de.maxhenkel.voicechat.voice.server.Server; import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; -import java.util.UUID; -import org.bukkit.entity.Player; -public class EntityAudioChannelImpl -extends AudioChannelImpl -implements EntityAudioChannel { +import java.util.UUID; + +public class EntityAudioChannelImpl extends AudioChannelImpl implements EntityAudioChannel { + protected Entity entity; protected boolean whispering; protected float distance; @@ -40,7 +32,7 @@ implements EntityAudioChannel { @Override public boolean isWhispering() { - return this.whispering; + return whispering; } @Override @@ -50,12 +42,12 @@ implements EntityAudioChannel { @Override public Entity getEntity() { - return this.entity; + return entity; } @Override public float getDistance() { - return this.distance; + return distance; } @Override @@ -65,24 +57,24 @@ implements EntityAudioChannel { @Override public void send(byte[] opusData) { - this.broadcast(new PlayerSoundPacket(this.channelId, this.entity.getUuid(), opusData, this.sequenceNumber.getAndIncrement(), this.whispering, this.distance, this.category)); + broadcast(new PlayerSoundPacket(channelId, entity.getUuid(), opusData, sequenceNumber.getAndIncrement(), whispering, distance, category)); } @Override public void send(MicrophonePacket microphonePacket) { - this.broadcast(new PlayerSoundPacket(this.channelId, this.entity.getUuid(), microphonePacket.getOpusEncodedData(), this.sequenceNumber.getAndIncrement(), this.whispering, this.distance, this.category)); + broadcast(new PlayerSoundPacket(channelId, entity.getUuid(), microphonePacket.getOpusEncodedData(), sequenceNumber.getAndIncrement(), whispering, distance, category)); } @Override public void flush() { - this.broadcast(new PlayerSoundPacket(this.channelId, this.entity.getUuid(), new byte[0], this.sequenceNumber.getAndIncrement(), this.whispering, this.distance, this.category)); + broadcast(new PlayerSoundPacket(channelId, entity.getUuid(), new byte[0], sequenceNumber.getAndIncrement(), whispering, distance, category)); } private void broadcast(PlayerSoundPacket packet) { - if (this.entity.getEntity() instanceof org.bukkit.entity.Entity) { - org.bukkit.entity.Entity entity = (org.bukkit.entity.Entity)this.entity.getEntity(); - this.server.broadcast(ServerPlayerManager.getPlayersInRange(entity.getWorld(), entity.getLocation(), this.server.getBroadcastRange(this.distance), this.filter == null ? null : player -> this.filter.test(new ServerPlayerImpl((Player)player))), packet, null, null, null, "plugin"); + if (entity.getEntity() instanceof org.bukkit.entity.Entity) { + org.bukkit.entity.Entity entity = (org.bukkit.entity.Entity) this.entity.getEntity(); + server.broadcast(ServerPlayerManager.getPlayersInRange(entity.getWorld(), entity.getLocation(), server.getBroadcastRange(distance), filter == null ? null : player -> filter.test(new ServerPlayerImpl(player))), packet, null, null, null, SoundPacketEvent.SOURCE_PLUGIN); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/LocationalAudioChannelImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/LocationalAudioChannelImpl.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/LocationalAudioChannelImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/LocationalAudioChannelImpl.java index fb8cc3e..66d9097 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/LocationalAudioChannelImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/LocationalAudioChannelImpl.java @@ -1,30 +1,22 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.World - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl.audiochannel; import de.maxhenkel.voicechat.api.Position; import de.maxhenkel.voicechat.api.ServerLevel; import de.maxhenkel.voicechat.api.audiochannel.LocationalAudioChannel; +import de.maxhenkel.voicechat.api.events.SoundPacketEvent; import de.maxhenkel.voicechat.api.packets.MicrophonePacket; import de.maxhenkel.voicechat.plugins.impl.PositionImpl; import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioChannelImpl; import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; import de.maxhenkel.voicechat.voice.server.Server; import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; -import java.util.UUID; import org.bukkit.World; -import org.bukkit.entity.Player; -public class LocationalAudioChannelImpl -extends AudioChannelImpl -implements LocationalAudioChannel { +import java.util.UUID; + +public class LocationalAudioChannelImpl extends AudioChannelImpl implements LocationalAudioChannel { + protected ServerLevel level; protected PositionImpl position; protected float distance; @@ -38,20 +30,21 @@ implements LocationalAudioChannel { @Override public void updateLocation(Position position) { - if (!(position instanceof PositionImpl)) { + if (position instanceof PositionImpl) { + this.position = (PositionImpl) position; + } else { throw new IllegalArgumentException("position is not an instance of PositionImpl"); } - this.position = (PositionImpl)position; } @Override public Position getLocation() { - return this.position; + return position; } @Override public float getDistance() { - return this.distance; + return distance; } @Override @@ -61,21 +54,21 @@ implements LocationalAudioChannel { @Override public void send(byte[] opusData) { - this.broadcast(new LocationSoundPacket(this.channelId, this.channelId, this.position.getPosition(), opusData, this.sequenceNumber.getAndIncrement(), this.distance, this.category)); + broadcast(new LocationSoundPacket(channelId, channelId, position.getPosition(), opusData, sequenceNumber.getAndIncrement(), distance, category)); } @Override public void send(MicrophonePacket packet) { - this.send(packet.getOpusEncodedData()); + send(packet.getOpusEncodedData()); } @Override public void flush() { - this.broadcast(new LocationSoundPacket(this.channelId, this.channelId, this.position.getPosition(), new byte[0], this.sequenceNumber.getAndIncrement(), this.distance, this.category)); + broadcast(new LocationSoundPacket(channelId, channelId, position.getPosition(), new byte[0], sequenceNumber.getAndIncrement(), distance, category)); } private void broadcast(LocationSoundPacket packet) { - this.server.broadcast(ServerPlayerManager.getPlayersInRange((World)this.level.getServerLevel(), this.position.getPosition(), this.server.getBroadcastRange(this.distance), this.filter == null ? null : player -> this.filter.test(new ServerPlayerImpl((Player)player))), packet, null, null, null, "plugin"); + server.broadcast(ServerPlayerManager.getPlayersInRange((World) level.getServerLevel(), position.getPosition(), server.getBroadcastRange(distance), filter == null ? null : player -> filter.test(new ServerPlayerImpl(player))), packet, null, null, null, SoundPacketEvent.SOURCE_PLUGIN); } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/StaticAudioChannelImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/StaticAudioChannelImpl.java new file mode 100644 index 0000000..a4535a9 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiochannel/StaticAudioChannelImpl.java @@ -0,0 +1,102 @@ +package de.maxhenkel.voicechat.plugins.impl.audiochannel; + +import de.maxhenkel.voicechat.api.VoicechatConnection; +import de.maxhenkel.voicechat.api.audiochannel.StaticAudioChannel; +import de.maxhenkel.voicechat.api.packets.MicrophonePacket; +import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; +import de.maxhenkel.voicechat.plugins.impl.VoicechatServerApiImpl; +import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; +import de.maxhenkel.voicechat.voice.server.ClientConnection; +import de.maxhenkel.voicechat.voice.server.Group; +import de.maxhenkel.voicechat.voice.server.Server; +import de.maxhenkel.voicechat.voice.server.ServerGroupManager; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.*; + +public class StaticAudioChannelImpl extends AudioChannelImpl implements StaticAudioChannel { + + protected boolean bypassGroupIsolation; + protected final Set targets; + + public StaticAudioChannelImpl(UUID channelId, Server server) { + super(channelId, server); + this.targets = new HashSet<>(); + } + + @Override + public void send(byte[] opusData) { + broadcast(new GroupSoundPacket(channelId, channelId, opusData, sequenceNumber.getAndIncrement(), category)); + } + + @Override + public void send(MicrophonePacket packet) { + send(packet.getOpusEncodedData()); + } + + @Override + public void flush() { + GroupSoundPacket packet = new GroupSoundPacket(channelId, channelId, new byte[0], sequenceNumber.getAndIncrement(), category); + broadcast(packet); + } + + private void broadcast(GroupSoundPacket packet) { + synchronized (targets) { + ServerGroupManager groupManager = server.getGroupManager(); + for (UUID target : targets) { + ClientConnection connection = server.getConnection(target); + if (connection == null) { + continue; + } + Player player = Bukkit.getPlayer(target); + if (player == null) { + continue; + } + if (!bypassGroupIsolation) { + Group playerGroup = groupManager.getPlayerGroup(player); + if (playerGroup != null && playerGroup.isIsolated()) { + continue; + } + } + if (filter != null) { + if (!filter.test(new ServerPlayerImpl(player))) { + continue; + } + } + VoicechatServerApiImpl.sendPacket(player, packet); + } + } + } + + @Override + public void setBypassGroupIsolation(boolean bypassGroupIsolation) { + this.bypassGroupIsolation = bypassGroupIsolation; + } + + @Override + public boolean bypassesGroupIsolation() { + return bypassGroupIsolation; + } + + @Override + public void addTarget(VoicechatConnection target) { + synchronized (targets) { + targets.add(target.getPlayer().getUuid()); + } + } + + @Override + public void removeTarget(VoicechatConnection target) { + synchronized (targets) { + targets.remove(target.getPlayer().getUuid()); + } + } + + @Override + public void clearTargets() { + synchronized (targets) { + targets.clear(); + } + } +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiolistener/PlayerAudioListenerImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiolistener/PlayerAudioListenerImpl.java similarity index 66% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiolistener/PlayerAudioListenerImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiolistener/PlayerAudioListenerImpl.java index 7c65b76..59dc352 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiolistener/PlayerAudioListenerImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiolistener/PlayerAudioListenerImpl.java @@ -1,20 +1,15 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.audiolistener; import de.maxhenkel.voicechat.api.ServerPlayer; import de.maxhenkel.voicechat.api.audiolistener.PlayerAudioListener; import de.maxhenkel.voicechat.api.packets.SoundPacket; + +import javax.annotation.Nullable; import java.util.UUID; import java.util.function.Consumer; -import javax.annotation.Nullable; -public class PlayerAudioListenerImpl -implements PlayerAudioListener { +public class PlayerAudioListenerImpl implements PlayerAudioListener { + private final UUID playerUuid; private final Consumer listener; private final UUID listenerId; @@ -27,53 +22,57 @@ implements PlayerAudioListener { @Override public UUID getListenerId() { - return this.listenerId; + return listenerId; } @Override public UUID getPlayerUuid() { - return this.playerUuid; + return playerUuid; } public Consumer getListener() { - return this.listener; + return listener; } - public static class BuilderImpl - implements PlayerAudioListener.Builder { + public static class BuilderImpl implements Builder { + @Nullable private UUID playerUuid; @Nullable private Consumer listener; + public BuilderImpl() { + + } + @Override - public PlayerAudioListener.Builder setPlayer(ServerPlayer player) { + public Builder setPlayer(ServerPlayer player) { this.playerUuid = player.getUuid(); return this; } @Override - public PlayerAudioListener.Builder setPlayer(UUID playerUuid) { + public Builder setPlayer(UUID playerUuid) { this.playerUuid = playerUuid; return this; } @Override - public PlayerAudioListener.Builder setPacketListener(Consumer listener) { + public Builder setPacketListener(Consumer listener) { this.listener = listener; return this; } @Override public PlayerAudioListener build() { - if (this.playerUuid == null) { + if (playerUuid == null) { throw new IllegalStateException("No player provided"); } - if (this.listener == null) { + if (listener == null) { throw new IllegalStateException("No listener provided"); } - return new PlayerAudioListenerImpl(this.playerUuid, this.listener); + return new PlayerAudioListenerImpl(playerUuid, listener); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiosender/AudioSenderImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiosender/AudioSenderImpl.java similarity index 79% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiosender/AudioSenderImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiosender/AudioSenderImpl.java index 5c6734c..85d2c44 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiosender/AudioSenderImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/audiosender/AudioSenderImpl.java @@ -1,19 +1,18 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.audiosender; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.api.audiosender.AudioSender; import de.maxhenkel.voicechat.voice.common.MicPacket; import de.maxhenkel.voicechat.voice.server.Server; + import java.util.HashMap; import java.util.Map; import java.util.UUID; -public class AudioSenderImpl -implements AudioSender { - private static final Map AUDIO_SENDERS = new HashMap(); +public class AudioSenderImpl implements AudioSender { + + private static final Map AUDIO_SENDERS = new HashMap<>(); + private final UUID uuid; private boolean whispering; private long nextSequenceNumber; @@ -45,7 +44,7 @@ implements AudioSender { @Override public boolean isWhispering() { - return this.whispering; + return whispering; } @Override @@ -59,24 +58,24 @@ implements AudioSender { @Override public boolean canSend() { - return !Voicechat.SERVER.isCompatible(this.uuid) && AUDIO_SENDERS.get(this.uuid) == this; + return !Voicechat.SERVER.isCompatible(uuid) && AUDIO_SENDERS.get(uuid) == this; } @Override public boolean send(byte[] opusEncodedAudioData) { - return this.sendMicrophonePacket(opusEncodedAudioData); + return sendMicrophonePacket(opusEncodedAudioData); } @Override public boolean reset() { - return this.sendMicrophonePacket(new byte[0]); + return sendMicrophonePacket(new byte[0]); } public boolean sendMicrophonePacket(byte[] data) { if (data == null) { throw new IllegalStateException("opusEncodedData is not set"); } - if (!this.canSend()) { + if (!canSend()) { return false; } Server server = Voicechat.SERVER.getServer(); @@ -84,16 +83,15 @@ implements AudioSender { return true; } try { - MicPacket packet = new MicPacket(data, data.length > 0 && this.whispering, this.nextSequenceNumber++); + MicPacket packet = new MicPacket(data, data.length > 0 && whispering, nextSequenceNumber++); if (data.length <= 0) { - this.nextSequenceNumber = 0L; + nextSequenceNumber = 0L; } - server.onMicPacket(this.uuid, packet); - } - catch (Exception e) { + server.onMicPacket(uuid, packet); + } catch (Exception e) { Voicechat.LOGGER.error("Failed to send audio", e); } return true; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/config/ConfigAccessorImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/config/ConfigAccessorImpl.java similarity index 54% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/config/ConfigAccessorImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/config/ConfigAccessorImpl.java index 8c1bda8..9ba928b 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/config/ConfigAccessorImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/config/ConfigAccessorImpl.java @@ -1,17 +1,12 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.config; +import de.maxhenkel.configbuilder.Config; import de.maxhenkel.voicechat.api.config.ConfigAccessor; -import de.maxhenkel.voicechat.configbuilder.Config; + import javax.annotation.Nullable; -public class ConfigAccessorImpl -implements ConfigAccessor { +public class ConfigAccessorImpl implements ConfigAccessor { + private Config config; public ConfigAccessorImpl(Config config) { @@ -20,13 +15,13 @@ implements ConfigAccessor { @Override public boolean hasKey(String key) { - return this.config.getEntries().containsKey(key); + return config.getEntries().containsKey(key); } - @Override @Nullable + @Override public String getValue(String key) { - return this.config.getEntries().get(key); + return config.getEntries().get(key); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/CreateGroupEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/CreateGroupEventImpl.java similarity index 58% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/CreateGroupEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/CreateGroupEventImpl.java index cf84f0e..a9db267 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/CreateGroupEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/CreateGroupEventImpl.java @@ -1,22 +1,14 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.CreateGroupEvent; -import de.maxhenkel.voicechat.plugins.impl.events.GroupEventImpl; + import javax.annotation.Nullable; -public class CreateGroupEventImpl -extends GroupEventImpl -implements CreateGroupEvent { +public class CreateGroupEventImpl extends GroupEventImpl implements CreateGroupEvent { + public CreateGroupEventImpl(Group group, @Nullable VoicechatConnection connection) { super(group, connection); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/EntitySoundPacketEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/EntitySoundPacketEventImpl.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/EntitySoundPacketEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/EntitySoundPacketEventImpl.java index 099623a..088d46a 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/EntitySoundPacketEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/EntitySoundPacketEventImpl.java @@ -1,22 +1,14 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.EntitySoundPacketEvent; import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; -import de.maxhenkel.voicechat.plugins.impl.events.SoundPacketEventImpl; + import javax.annotation.Nullable; -public class EntitySoundPacketEventImpl -extends SoundPacketEventImpl -implements EntitySoundPacketEvent { +public class EntitySoundPacketEventImpl extends SoundPacketEventImpl implements EntitySoundPacketEvent { + public EntitySoundPacketEventImpl(EntitySoundPacket packet, @Nullable VoicechatConnection senderConnection, VoicechatConnection receiverConnection, String source) { super(packet, senderConnection, receiverConnection, source); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/EventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/EventImpl.java similarity index 68% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/EventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/EventImpl.java index d91a360..31141c5 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/EventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/EventImpl.java @@ -1,12 +1,9 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.events.Event; -public class EventImpl -implements Event { +public class EventImpl implements Event { + private boolean cancelled; @Override @@ -16,16 +13,15 @@ implements Event { @Override public boolean cancel() { - if (!this.isCancellable()) { + if (!isCancellable()) { return false; } - this.cancelled = true; + cancelled = true; return true; } @Override public boolean isCancelled() { - return this.cancelled; + return cancelled; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/GroupEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/GroupEventImpl.java similarity index 66% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/GroupEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/GroupEventImpl.java index 482a10f..154baa0 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/GroupEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/GroupEventImpl.java @@ -1,20 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.GroupEvent; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; + import javax.annotation.Nullable; -public class GroupEventImpl -extends ServerEventImpl -implements GroupEvent { +public class GroupEventImpl extends ServerEventImpl implements GroupEvent { + @Nullable protected Group group; protected VoicechatConnection connection; @@ -24,15 +17,14 @@ implements GroupEvent { this.connection = connection; } - @Override @Nullable + @Override public Group getGroup() { - return this.group; + return group; } @Override public VoicechatConnection getConnection() { - return this.connection; + return connection; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/JoinGroupEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/JoinGroupEventImpl.java similarity index 63% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/JoinGroupEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/JoinGroupEventImpl.java index 0bd560f..fa1a997 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/JoinGroupEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/JoinGroupEventImpl.java @@ -1,18 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.JoinGroupEvent; -import de.maxhenkel.voicechat.plugins.impl.events.GroupEventImpl; -public class JoinGroupEventImpl -extends GroupEventImpl -implements JoinGroupEvent { +public class JoinGroupEventImpl extends GroupEventImpl implements JoinGroupEvent { + public JoinGroupEventImpl(Group group, VoicechatConnection connection) { super(group, connection); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/LeaveGroupEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/LeaveGroupEventImpl.java similarity index 58% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/LeaveGroupEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/LeaveGroupEventImpl.java index 9edf8e4..0b10b19 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/LeaveGroupEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/LeaveGroupEventImpl.java @@ -1,22 +1,14 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.LeaveGroupEvent; -import de.maxhenkel.voicechat.plugins.impl.events.GroupEventImpl; + import javax.annotation.Nullable; -public class LeaveGroupEventImpl -extends GroupEventImpl -implements LeaveGroupEvent { +public class LeaveGroupEventImpl extends GroupEventImpl implements LeaveGroupEvent { + public LeaveGroupEventImpl(@Nullable Group group, VoicechatConnection connection) { super(group, connection); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/LocationalSoundPacketEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/LocationalSoundPacketEventImpl.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/LocationalSoundPacketEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/LocationalSoundPacketEventImpl.java index 5d8f86c..8544915 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/LocationalSoundPacketEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/LocationalSoundPacketEventImpl.java @@ -1,22 +1,14 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.LocationalSoundPacketEvent; import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; -import de.maxhenkel.voicechat.plugins.impl.events.SoundPacketEventImpl; + import javax.annotation.Nullable; -public class LocationalSoundPacketEventImpl -extends SoundPacketEventImpl -implements LocationalSoundPacketEvent { +public class LocationalSoundPacketEventImpl extends SoundPacketEventImpl implements LocationalSoundPacketEvent { + public LocationalSoundPacketEventImpl(LocationalSoundPacket packet, @Nullable VoicechatConnection senderConnection, VoicechatConnection receiverConnection, String source) { super(packet, senderConnection, receiverConnection, source); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/MicrophonePacketEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/MicrophonePacketEventImpl.java similarity index 63% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/MicrophonePacketEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/MicrophonePacketEventImpl.java index 7513910..b130ff9 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/MicrophonePacketEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/MicrophonePacketEventImpl.java @@ -1,18 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.MicrophonePacketEvent; import de.maxhenkel.voicechat.api.packets.MicrophonePacket; -import de.maxhenkel.voicechat.plugins.impl.events.PacketEventImpl; -public class MicrophonePacketEventImpl -extends PacketEventImpl -implements MicrophonePacketEvent { +public class MicrophonePacketEventImpl extends PacketEventImpl implements MicrophonePacketEvent { + public MicrophonePacketEventImpl(MicrophonePacket packet, VoicechatConnection connection) { super(packet, connection, null); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PacketEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PacketEventImpl.java similarity index 70% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PacketEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PacketEventImpl.java index 8de98f1..4c44e1d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PacketEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PacketEventImpl.java @@ -1,20 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.PacketEvent; import de.maxhenkel.voicechat.api.packets.Packet; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; + import javax.annotation.Nullable; -public class PacketEventImpl -extends ServerEventImpl -implements PacketEvent { +public class PacketEventImpl extends ServerEventImpl implements PacketEvent { + private final T packet; @Nullable private final VoicechatConnection receiverConnection; @@ -29,19 +22,18 @@ implements PacketEvent { @Override public T getPacket() { - return this.packet; + return packet; } - @Override @Nullable + @Override public VoicechatConnection getReceiverConnection() { - return this.receiverConnection; + return receiverConnection; } - @Override @Nullable + @Override public VoicechatConnection getSenderConnection() { - return this.senderConnection; + return senderConnection; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerConnectedEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerConnectedEventImpl.java similarity index 67% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerConnectedEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerConnectedEventImpl.java index 7125f6c..84da473 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerConnectedEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerConnectedEventImpl.java @@ -1,16 +1,11 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.PlayerConnectedEvent; import de.maxhenkel.voicechat.plugins.impl.VoicechatConnectionImpl; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; -public class PlayerConnectedEventImpl -extends ServerEventImpl -implements PlayerConnectedEvent { +public class PlayerConnectedEventImpl extends ServerEventImpl implements PlayerConnectedEvent { + protected VoicechatConnectionImpl connection; public PlayerConnectedEventImpl(VoicechatConnectionImpl connection) { @@ -19,7 +14,6 @@ implements PlayerConnectedEvent { @Override public VoicechatConnection getConnection() { - return this.connection; + return connection; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerDisconnectedEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerDisconnectedEventImpl.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerDisconnectedEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerDisconnectedEventImpl.java index 5626075..0d17bdb 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerDisconnectedEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerDisconnectedEventImpl.java @@ -1,15 +1,11 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.events.PlayerDisconnectedEvent; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; + import java.util.UUID; -public class PlayerDisconnectedEventImpl -extends ServerEventImpl -implements PlayerDisconnectedEvent { +public class PlayerDisconnectedEventImpl extends ServerEventImpl implements PlayerDisconnectedEvent { + protected UUID player; public PlayerDisconnectedEventImpl(UUID player) { @@ -18,7 +14,6 @@ implements PlayerDisconnectedEvent { @Override public UUID getPlayerUuid() { - return this.player; + return player; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerStateChangedEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerStateChangedEventImpl.java similarity index 63% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerStateChangedEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerStateChangedEventImpl.java index 7e57322..7bd3d00 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/PlayerStateChangedEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/PlayerStateChangedEventImpl.java @@ -1,25 +1,17 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.PlayerStateChangedEvent; import de.maxhenkel.voicechat.plugins.impl.VoicechatConnectionImpl; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; import de.maxhenkel.voicechat.voice.common.PlayerState; -import java.util.UUID; -import javax.annotation.Nullable; import org.bukkit.entity.Player; -public class PlayerStateChangedEventImpl -extends ServerEventImpl -implements PlayerStateChangedEvent { +import javax.annotation.Nullable; +import java.util.UUID; + +public class PlayerStateChangedEventImpl extends ServerEventImpl implements PlayerStateChangedEvent { + protected final PlayerState state; @Nullable protected VoicechatConnectionImpl connection; @@ -30,30 +22,29 @@ implements PlayerStateChangedEvent { @Override public boolean isDisabled() { - return this.state.isDisabled(); + return state.isDisabled(); } @Override public boolean isDisconnected() { - return this.state.isDisconnected(); + return state.isDisconnected(); } @Override public UUID getPlayerUuid() { - return this.state.getUuid(); + return state.getUuid(); } @Override @Nullable public VoicechatConnection getConnection() { - if (this.connection == null) { - Player player = Voicechat.INSTANCE.getServer().getPlayer(this.state.getUuid()); + if (connection == null) { + Player player = Voicechat.INSTANCE.getServer().getPlayer(state.getUuid()); if (player == null) { return null; } - this.connection = VoicechatConnectionImpl.fromPlayer(player); + connection = VoicechatConnectionImpl.fromPlayer(player); } - return this.connection; + return connection; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/RegisterVolumeCategoryEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/RegisterVolumeCategoryEventImpl.java similarity index 54% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/RegisterVolumeCategoryEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/RegisterVolumeCategoryEventImpl.java index 436d0f1..c7709cd 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/RegisterVolumeCategoryEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/RegisterVolumeCategoryEventImpl.java @@ -1,17 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VolumeCategory; import de.maxhenkel.voicechat.api.events.RegisterVolumeCategoryEvent; -import de.maxhenkel.voicechat.plugins.impl.events.VolumeCategoryEventImpl; -public class RegisterVolumeCategoryEventImpl -extends VolumeCategoryEventImpl -implements RegisterVolumeCategoryEvent { +public class RegisterVolumeCategoryEventImpl extends VolumeCategoryEventImpl implements RegisterVolumeCategoryEvent { + public RegisterVolumeCategoryEventImpl(VolumeCategory category) { super(category); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/RemoveGroupEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/RemoveGroupEventImpl.java similarity index 53% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/RemoveGroupEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/RemoveGroupEventImpl.java index 994dcf6..c97e1b1 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/RemoveGroupEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/RemoveGroupEventImpl.java @@ -1,22 +1,16 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.events.RemoveGroupEvent; -import de.maxhenkel.voicechat.plugins.impl.events.GroupEventImpl; -public class RemoveGroupEventImpl -extends GroupEventImpl -implements RemoveGroupEvent { +public class RemoveGroupEventImpl extends GroupEventImpl implements RemoveGroupEvent { + public RemoveGroupEventImpl(Group group) { super(group, null); } @Override public boolean isCancellable() { - return super.isCancellable() && this.group.isPersistent(); + return super.isCancellable() && group.isPersistent(); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/ServerEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/ServerEventImpl.java similarity index 67% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/ServerEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/ServerEventImpl.java index c412f9d..ebd9289 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/ServerEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/ServerEventImpl.java @@ -1,19 +1,14 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatServerApi; import de.maxhenkel.voicechat.api.events.ServerEvent; import de.maxhenkel.voicechat.plugins.impl.VoicechatServerApiImpl; -import de.maxhenkel.voicechat.plugins.impl.events.EventImpl; -public class ServerEventImpl -extends EventImpl -implements ServerEvent { +public class ServerEventImpl extends EventImpl implements ServerEvent { + @Override public VoicechatServerApi getVoicechat() { return VoicechatServerApiImpl.instance(); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/SoundPacketEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/SoundPacketEventImpl.java similarity index 65% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/SoundPacketEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/SoundPacketEventImpl.java index 9ea9745..1871270 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/SoundPacketEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/SoundPacketEventImpl.java @@ -1,20 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.SoundPacketEvent; import de.maxhenkel.voicechat.api.packets.Packet; -import de.maxhenkel.voicechat.plugins.impl.events.PacketEventImpl; + import javax.annotation.Nullable; -public class SoundPacketEventImpl -extends PacketEventImpl -implements SoundPacketEvent { +public class SoundPacketEventImpl extends PacketEventImpl implements SoundPacketEvent { + private final String source; public SoundPacketEventImpl(T packet, @Nullable VoicechatConnection senderConnection, @Nullable VoicechatConnection receiverConnection, String source) { @@ -24,7 +17,7 @@ implements SoundPacketEvent { @Override public String getSource() { - return this.source; + return source; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/StaticSoundPacketEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/StaticSoundPacketEventImpl.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/StaticSoundPacketEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/StaticSoundPacketEventImpl.java index 107734c..415b0d5 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/StaticSoundPacketEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/StaticSoundPacketEventImpl.java @@ -1,22 +1,14 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.StaticSoundPacketEvent; import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; -import de.maxhenkel.voicechat.plugins.impl.events.SoundPacketEventImpl; + import javax.annotation.Nullable; -public class StaticSoundPacketEventImpl -extends SoundPacketEventImpl -implements StaticSoundPacketEvent { +public class StaticSoundPacketEventImpl extends SoundPacketEventImpl implements StaticSoundPacketEvent { + public StaticSoundPacketEventImpl(StaticSoundPacket packet, @Nullable VoicechatConnection senderConnection, VoicechatConnection receiverConnection, String source) { super(packet, senderConnection, receiverConnection, source); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/UnregisterVolumeCategoryEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/UnregisterVolumeCategoryEventImpl.java similarity index 54% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/UnregisterVolumeCategoryEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/UnregisterVolumeCategoryEventImpl.java index 1d0228a..911978f 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/UnregisterVolumeCategoryEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/UnregisterVolumeCategoryEventImpl.java @@ -1,17 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VolumeCategory; import de.maxhenkel.voicechat.api.events.UnregisterVolumeCategoryEvent; -import de.maxhenkel.voicechat.plugins.impl.events.VolumeCategoryEventImpl; -public class UnregisterVolumeCategoryEventImpl -extends VolumeCategoryEventImpl -implements UnregisterVolumeCategoryEvent { +public class UnregisterVolumeCategoryEventImpl extends VolumeCategoryEventImpl implements UnregisterVolumeCategoryEvent { + public UnregisterVolumeCategoryEventImpl(VolumeCategory category) { super(category); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoiceDistanceEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoiceDistanceEventImpl.java similarity index 73% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoiceDistanceEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoiceDistanceEventImpl.java index fd14989..e08f16c 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoiceDistanceEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoiceDistanceEventImpl.java @@ -1,20 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatConnection; import de.maxhenkel.voicechat.api.events.VoiceDistanceEvent; import de.maxhenkel.voicechat.api.packets.MicrophonePacket; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; + import javax.annotation.Nullable; -public class VoiceDistanceEventImpl -extends ServerEventImpl -implements VoiceDistanceEvent { +public class VoiceDistanceEventImpl extends ServerEventImpl implements VoiceDistanceEvent { + private final MicrophonePacket packet; private final VoicechatConnection senderConnection; private float distance; @@ -32,18 +25,18 @@ implements VoiceDistanceEvent { @Override public MicrophonePacket getPacket() { - return this.packet; + return packet; } - @Override @Nullable + @Override public VoicechatConnection getSenderConnection() { - return this.senderConnection; + return senderConnection; } @Override public float getDistance() { - return this.distance; + return distance; } @Override @@ -51,4 +44,3 @@ implements VoiceDistanceEvent { this.distance = distance; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoiceHostEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoiceHostEventImpl.java similarity index 68% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoiceHostEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoiceHostEventImpl.java index cb62b56..11181b4 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoiceHostEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoiceHostEventImpl.java @@ -1,20 +1,12 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.ServerPlayer; import de.maxhenkel.voicechat.api.events.VoiceHostEvent; import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; import org.bukkit.entity.Player; -public class VoiceHostEventImpl -extends ServerEventImpl -implements VoiceHostEvent { +public class VoiceHostEventImpl extends ServerEventImpl implements VoiceHostEvent { + private final ServerPlayerImpl player; private String voiceHost; @@ -25,7 +17,7 @@ implements VoiceHostEvent { @Override public String getVoiceHost() { - return this.voiceHost; + return voiceHost; } @Override @@ -35,7 +27,7 @@ implements VoiceHostEvent { @Override public ServerPlayer getPlayer() { - return this.player; + return player; } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartedEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartedEventImpl.java new file mode 100644 index 0000000..b7664d7 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartedEventImpl.java @@ -0,0 +1,11 @@ +package de.maxhenkel.voicechat.plugins.impl.events; + +import de.maxhenkel.voicechat.api.events.VoicechatServerStartedEvent; + +public class VoicechatServerStartedEventImpl extends ServerEventImpl implements VoicechatServerStartedEvent { + + @Override + public boolean isCancellable() { + return false; + } +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartingEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartingEventImpl.java similarity index 63% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartingEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartingEventImpl.java index a91c6fd..a829392 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartingEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartingEventImpl.java @@ -1,19 +1,12 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VoicechatSocket; import de.maxhenkel.voicechat.api.events.VoicechatServerStartingEvent; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; + import javax.annotation.Nullable; -public class VoicechatServerStartingEventImpl -extends ServerEventImpl -implements VoicechatServerStartingEvent { +public class VoicechatServerStartingEventImpl extends ServerEventImpl implements VoicechatServerStartingEvent { + @Nullable private VoicechatSocket socketImplementation; @@ -22,10 +15,10 @@ implements VoicechatServerStartingEvent { this.socketImplementation = socket; } - @Override @Nullable + @Override public VoicechatSocket getSocketImplementation() { - return this.socketImplementation; + return socketImplementation; } @Override @@ -33,4 +26,3 @@ implements VoicechatServerStartingEvent { return false; } } - diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStoppedEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStoppedEventImpl.java new file mode 100644 index 0000000..5886407 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStoppedEventImpl.java @@ -0,0 +1,11 @@ +package de.maxhenkel.voicechat.plugins.impl.events; + +import de.maxhenkel.voicechat.api.events.VoicechatServerStoppedEvent; + +public class VoicechatServerStoppedEventImpl extends ServerEventImpl implements VoicechatServerStoppedEvent { + + @Override + public boolean isCancellable() { + return false; + } +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VolumeCategoryEventImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VolumeCategoryEventImpl.java similarity index 67% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VolumeCategoryEventImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VolumeCategoryEventImpl.java index 2487233..fff0643 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VolumeCategoryEventImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/events/VolumeCategoryEventImpl.java @@ -1,15 +1,10 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.events; import de.maxhenkel.voicechat.api.VolumeCategory; import de.maxhenkel.voicechat.api.events.VolumeCategoryEvent; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; -public class VolumeCategoryEventImpl -extends ServerEventImpl -implements VolumeCategoryEvent { +public class VolumeCategoryEventImpl extends ServerEventImpl implements VolumeCategoryEvent { + private final VolumeCategory category; public VolumeCategoryEventImpl(VolumeCategory category) { @@ -18,7 +13,7 @@ implements VolumeCategoryEvent { @Override public VolumeCategory getVolumeCategory() { - return this.category; + return category; } @Override @@ -26,4 +21,3 @@ implements VolumeCategoryEvent { return false; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusDecoderImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusDecoderImpl.java similarity index 54% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusDecoderImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusDecoderImpl.java index 8854eb2..8a85f8d 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusDecoderImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusDecoderImpl.java @@ -1,61 +1,60 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.opus; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.api.opus.OpusDecoder; -import de.maxhenkel.voicechat.concentus.OpusException; +import org.concentus.OpusDecoder; +import org.concentus.OpusException; + import javax.annotation.Nullable; -public class JavaOpusDecoderImpl -implements OpusDecoder { - protected de.maxhenkel.voicechat.concentus.OpusDecoder opusDecoder; +public class JavaOpusDecoderImpl implements de.maxhenkel.voicechat.api.opus.OpusDecoder { + + protected OpusDecoder opusDecoder; protected short[] buffer; protected int sampleRate; public JavaOpusDecoderImpl(int sampleRate, int frameSize) { this.sampleRate = sampleRate; this.buffer = new short[frameSize]; - this.open(); + open(); } private void open() { - if (this.opusDecoder != null) { + if (opusDecoder != null) { return; } try { - this.opusDecoder = new de.maxhenkel.voicechat.concentus.OpusDecoder(this.sampleRate, 1); - } - catch (OpusException e) { + opusDecoder = new OpusDecoder(sampleRate, 1); + } catch (OpusException e) { throw new IllegalStateException("Failed to create Opus decoder", e); } - Voicechat.LOGGER.debug("Initializing Java Opus decoder with sample rate {} Hz, frame size {} bytes", this.sampleRate, this.buffer.length); + Voicechat.LOGGER.debug("Initializing Java Opus decoder with sample rate {} Hz, frame size {} bytes", sampleRate, buffer.length); } @Override public short[] decode(@Nullable byte[] data) { - int result; - if (this.isClosed()) { + if (isClosed()) { throw new IllegalStateException("Decoder is closed"); } + int result; + try { - result = data == null || data.length == 0 ? this.opusDecoder.decode(null, 0, 0, this.buffer, 0, this.buffer.length, true) : this.opusDecoder.decode(data, 0, data.length, this.buffer, 0, this.buffer.length, false); - } - catch (Exception e) { + if (data == null || data.length == 0) { + result = opusDecoder.decode(null, 0, 0, buffer, 0, buffer.length, true); + } else { + result = opusDecoder.decode(data, 0, data.length, buffer, 0, buffer.length, false); + } + } catch (Exception e) { throw new RuntimeException("Failed to decode audio", e); } + short[] audio = new short[result]; - System.arraycopy(this.buffer, 0, audio, 0, result); + System.arraycopy(buffer, 0, audio, 0, result); return audio; } @Override public short[][] decode(byte[] data, int frames) { - if (this.isClosed()) { + if (isClosed()) { throw new IllegalStateException("Decoder is closed"); } if (frames <= 0) { @@ -64,53 +63,55 @@ implements OpusDecoder { if (data == null || data.length == 0) { throw new IllegalArgumentException("Data must not be null or empty"); } + short[][] recovered = new short[frames][]; try { int result; if (frames > 2) { - for (int i = 0; i < frames - 2; ++i) { - result = this.opusDecoder.decode(null, 0, 0, this.buffer, 0, this.buffer.length, true); + for (int i = 0; i < frames - 2; i++) { + result = opusDecoder.decode(null, 0, 0, buffer, 0, buffer.length, true); short[] audio = new short[result]; - System.arraycopy(this.buffer, 0, audio, 0, result); + System.arraycopy(buffer, 0, audio, 0, result); recovered[i] = audio; } } if (frames > 1) { - result = this.opusDecoder.decode(data, 0, data.length, this.buffer, 0, this.buffer.length, true); + result = opusDecoder.decode(data, 0, data.length, buffer, 0, buffer.length, true); short[] audio = new short[result]; - System.arraycopy(this.buffer, 0, audio, 0, result); + System.arraycopy(buffer, 0, audio, 0, result); recovered[frames - 2] = audio; } - result = this.opusDecoder.decode(data, 0, data.length, this.buffer, 0, this.buffer.length, false); + + result = opusDecoder.decode(data, 0, data.length, buffer, 0, buffer.length, false); short[] audio = new short[result]; - System.arraycopy(this.buffer, 0, audio, 0, result); + System.arraycopy(buffer, 0, audio, 0, result); recovered[frames - 1] = audio; - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException("Failed to decode audio", e); } + return recovered; } @Override public boolean isClosed() { - return this.opusDecoder == null; + return opusDecoder == null; } @Override public void close() { - if (this.isClosed()) { + if (isClosed()) { return; } - this.opusDecoder = null; + opusDecoder = null; } @Override public void resetState() { - if (this.isClosed()) { + if (isClosed()) { throw new IllegalStateException("Decoder is closed"); } - this.opusDecoder.resetState(); + opusDecoder.resetState(); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusEncoderImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusEncoderImpl.java similarity index 60% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusEncoderImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusEncoderImpl.java index 39b2ac8..ca7d824 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusEncoderImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/JavaOpusEncoderImpl.java @@ -1,13 +1,10 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.opus; -import de.maxhenkel.voicechat.concentus.OpusApplication; -import de.maxhenkel.voicechat.concentus.OpusEncoder; +import org.concentus.OpusApplication; +import org.concentus.OpusEncoder; + +public class JavaOpusEncoderImpl implements de.maxhenkel.voicechat.api.opus.OpusEncoder { -public class JavaOpusEncoderImpl -implements de.maxhenkel.voicechat.api.opus.OpusEncoder { protected OpusEncoder opusEncoder; protected byte[] buffer; protected int sampleRate; @@ -21,62 +18,62 @@ implements de.maxhenkel.voicechat.api.opus.OpusEncoder { this.maxPayloadSize = maxPayloadSize; this.application = application; this.buffer = new byte[maxPayloadSize]; - this.open(); + open(); } private void open() { - if (this.opusEncoder != null) { + if (opusEncoder != null) { return; } try { - this.opusEncoder = new OpusEncoder(this.sampleRate, 1, this.application); - this.opusEncoder.setUseInbandFEC(true); - this.opusEncoder.setPacketLossPercent(5); - } - catch (Exception e) { + opusEncoder = new OpusEncoder(sampleRate, 1, application); + opusEncoder.setUseInbandFEC(true); + opusEncoder.setPacketLossPercent(5); + } catch (Exception e) { throw new IllegalStateException("Opus encoder error " + e.getMessage()); } } @Override public byte[] encode(short[] rawAudio) { - int result; - if (this.isClosed()) { + if (isClosed()) { throw new IllegalStateException("Encoder is closed"); } + + int result; try { - result = this.opusEncoder.encode(rawAudio, 0, this.frameSize, this.buffer, 0, this.buffer.length); - } - catch (Exception e) { + result = opusEncoder.encode(rawAudio, 0, frameSize, buffer, 0, buffer.length); + } catch (Exception e) { throw new RuntimeException("Failed to encode audio data: " + e.getMessage()); } + if (result < 0) { throw new RuntimeException("Failed to encode audio data"); } + byte[] audio = new byte[result]; - System.arraycopy(this.buffer, 0, audio, 0, result); + System.arraycopy(buffer, 0, audio, 0, result); return audio; } @Override public void resetState() { - if (this.isClosed()) { + if (isClosed()) { throw new IllegalStateException("Encoder is closed"); } - this.opusEncoder.resetState(); + opusEncoder.resetState(); } @Override public boolean isClosed() { - return this.opusEncoder == null; + return opusEncoder == null; } @Override public void close() { - if (this.isClosed()) { + if (isClosed()) { return; } - this.opusEncoder = null; + opusEncoder = null; } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/OpusManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/OpusManager.java similarity index 69% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/OpusManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/OpusManager.java index 2f509b4..7b60ba2 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/opus/OpusManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/opus/OpusManager.java @@ -1,18 +1,14 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.plugins.impl.opus; import de.maxhenkel.voicechat.api.opus.OpusDecoder; import de.maxhenkel.voicechat.api.opus.OpusEncoder; import de.maxhenkel.voicechat.api.opus.OpusEncoderMode; -import de.maxhenkel.voicechat.concentus.OpusApplication; -import de.maxhenkel.voicechat.plugins.impl.opus.JavaOpusDecoderImpl; -import de.maxhenkel.voicechat.plugins.impl.opus.JavaOpusEncoderImpl; +import org.concentus.OpusApplication; public class OpusManager { + public static final int SAMPLE_RATE = 48000; - public static final int FRAME_SIZE = 960; + public static final int FRAME_SIZE = (SAMPLE_RATE / 1000) * 20; public static OpusEncoder createEncoder(int sampleRate, int frameSize, int maxPayloadSize, OpusApplication application) { return new JavaOpusEncoderImpl(sampleRate, frameSize, maxPayloadSize, application); @@ -22,17 +18,18 @@ public class OpusManager { OpusApplication application = OpusApplication.OPUS_APPLICATION_VOIP; if (mode != null) { switch (mode) { - case AUDIO: { + case AUDIO: application = OpusApplication.OPUS_APPLICATION_AUDIO; break; - } - case RESTRICTED_LOWDELAY: { + case RESTRICTED_LOWDELAY: application = OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY; break; - } + default: + break; } + } - return OpusManager.createEncoder(48000, 960, 1024, application); + return createEncoder(SAMPLE_RATE, FRAME_SIZE, 1024, application); } public static OpusDecoder createDecoder(int sampleRate, int frameSize) { @@ -40,7 +37,7 @@ public class OpusManager { } public static OpusDecoder createDecoder() { - return OpusManager.createDecoder(48000, 960); + return createDecoder(SAMPLE_RATE, FRAME_SIZE); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/ConvertablePacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/ConvertablePacketImpl.java similarity index 59% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/ConvertablePacketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/ConvertablePacketImpl.java index b86b9fe..3d22d45 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/ConvertablePacketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/ConvertablePacketImpl.java @@ -1,30 +1,17 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.packets; import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.packets.ConvertablePacket; -import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; -import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; -import de.maxhenkel.voicechat.api.packets.SoundPacket; -import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; +import de.maxhenkel.voicechat.api.packets.*; import de.maxhenkel.voicechat.plugins.impl.PositionImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.EntitySoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.LocationalSoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.StaticSoundPacketImpl; import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; -import java.util.UUID; -import javax.annotation.Nullable; -public class ConvertablePacketImpl -implements ConvertablePacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class ConvertablePacketImpl implements ConvertablePacket { @Override public EntitySoundPacket.Builder entitySoundPacketBuilder() { return new GenericEntitySoundPacketBuilder(); @@ -55,13 +42,76 @@ implements ConvertablePacket { throw new UnsupportedOperationException(); } - public static class GenericEntitySoundPacketBuilder - extends GenericSoundPacketBuilder - implements EntitySoundPacket.Builder { + public abstract static class GenericSoundPacketBuilder, P extends SoundPacket> implements SoundPacket.Builder { + + @Nullable + protected UUID channelId; + @Nullable + protected UUID sender; + @Nullable + protected byte[] opusEncodedData; + @Nullable + protected Long sequenceNumber; + @Nullable + protected String category; + + public GenericSoundPacketBuilder() { + + } + + @Override + public T channelId(UUID channelId) { + this.channelId = channelId; + return (T) this; + } + + @Override + public T sender(UUID sender) { + this.sender = sender; + return (T) this; + } + + @Override + public T opusEncodedData(byte[] data) { + this.opusEncodedData = data; + return (T) this; + } + + @Override + public T sequenceNumber(long sequenceNumber) { + this.sequenceNumber = sequenceNumber; + return (T) this; + } + + @Override + public T category(@Nullable String category) { + this.category = category; + return (T) this; + } + + public void checkRequiredFields() { + if (channelId == null) { + throw new IllegalStateException("Channel id must be set"); + } + if (sequenceNumber == null) { + throw new IllegalStateException("Sequence number must be set"); + } + if (opusEncodedData == null) { + throw new IllegalStateException("Opus encoded data must be set"); + } + } + } + + public static class GenericEntitySoundPacketBuilder extends GenericSoundPacketBuilder implements EntitySoundPacket.Builder { + protected UUID entityUuid; protected boolean whispering; protected Float distance; + public GenericEntitySoundPacketBuilder() { + + } + @Override public GenericEntitySoundPacketBuilder entityUuid(UUID entityUuid) { this.entityUuid = entityUuid; @@ -76,117 +126,58 @@ implements ConvertablePacket { @Override public GenericEntitySoundPacketBuilder distance(float distance) { - this.distance = Float.valueOf(distance); + this.distance = distance; return this; } @Override public EntitySoundPacket build() { - this.checkRequiredFields(); - if (this.entityUuid == null) { + checkRequiredFields(); + if (entityUuid == null) { throw new IllegalStateException("Entity UUID must be set"); } - if (this.distance == null) { - this.distance = Float.valueOf(Utils.getDefaultDistance()); + if (distance == null) { + distance = Utils.getDefaultDistance(); } - return new EntitySoundPacketImpl(new PlayerSoundPacket(this.channelId, this.entityUuid, this.opusEncodedData, this.sequenceNumber, this.whispering, this.distance.floatValue(), this.category)); + return new EntitySoundPacketImpl(new PlayerSoundPacket(channelId, entityUuid, opusEncodedData, sequenceNumber, whispering, distance, category)); } } - public static class GenericLocationalSoundPacketBuilder - extends GenericSoundPacketBuilder - implements LocationalSoundPacket.Builder { + public static class GenericLocationalSoundPacketBuilder extends GenericSoundPacketBuilder implements LocationalSoundPacket.Builder { + protected PositionImpl position; protected Float distance; @Override public GenericLocationalSoundPacketBuilder position(Position position) { - this.position = (PositionImpl)position; + this.position = (PositionImpl) position; return this; } @Override public GenericLocationalSoundPacketBuilder distance(float distance) { - this.distance = Float.valueOf(distance); + this.distance = distance; return this; } @Override public LocationalSoundPacket build() { - this.checkRequiredFields(); - if (this.position == null) { + checkRequiredFields(); + if (position == null) { throw new IllegalStateException("Position must be set"); } - if (this.distance == null) { - this.distance = Float.valueOf(Utils.getDefaultDistance()); + if (distance == null) { + distance = Utils.getDefaultDistance(); } - return new LocationalSoundPacketImpl(new LocationSoundPacket(this.channelId, this.sender, this.position.getPosition(), this.opusEncodedData, this.sequenceNumber, this.distance.floatValue(), this.category)); + return new LocationalSoundPacketImpl(new LocationSoundPacket(channelId, sender, position.getPosition(), opusEncodedData, sequenceNumber, distance, category)); } } - public static class GenericStaticSoundPacketBuilder - extends GenericSoundPacketBuilder - implements StaticSoundPacket.Builder { + public static class GenericStaticSoundPacketBuilder extends GenericSoundPacketBuilder implements StaticSoundPacket.Builder { @Override public StaticSoundPacket build() { - return new StaticSoundPacketImpl(new GroupSoundPacket(this.channelId, this.sender, this.opusEncodedData, this.sequenceNumber, this.category)); + return new StaticSoundPacketImpl(new GroupSoundPacket(channelId, sender, opusEncodedData, sequenceNumber, category)); } } - public static abstract class GenericSoundPacketBuilder, P extends SoundPacket> - implements SoundPacket.Builder { - @Nullable - protected UUID channelId; - @Nullable - protected UUID sender; - @Nullable - protected byte[] opusEncodedData; - @Nullable - protected Long sequenceNumber; - @Nullable - protected String category; - - @Override - public T channelId(UUID channelId) { - this.channelId = channelId; - return (T)this; - } - - @Override - public T sender(UUID sender) { - this.sender = sender; - return (T)this; - } - - @Override - public T opusEncodedData(byte[] data) { - this.opusEncodedData = data; - return (T)this; - } - - @Override - public T sequenceNumber(long sequenceNumber) { - this.sequenceNumber = sequenceNumber; - return (T)this; - } - - @Override - public T category(@Nullable String category) { - this.category = category; - return (T)this; - } - - public void checkRequiredFields() { - if (this.channelId == null) { - throw new IllegalStateException("Channel id must be set"); - } - if (this.sequenceNumber == null) { - throw new IllegalStateException("Sequence number must be set"); - } - if (this.opusEncodedData == null) { - throw new IllegalStateException("Opus encoded data must be set"); - } - } - } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/EntitySoundPacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/EntitySoundPacketImpl.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/EntitySoundPacketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/EntitySoundPacketImpl.java index e368059..5016eab 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/EntitySoundPacketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/EntitySoundPacketImpl.java @@ -1,22 +1,14 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.packets; import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; -import de.maxhenkel.voicechat.plugins.impl.packets.LocationalSoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.SoundPacketImpl; import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; -import java.util.UUID; -import javax.annotation.Nullable; -public class EntitySoundPacketImpl -extends SoundPacketImpl -implements EntitySoundPacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class EntitySoundPacketImpl extends SoundPacketImpl implements EntitySoundPacket { + private final PlayerSoundPacket packet; public EntitySoundPacketImpl(PlayerSoundPacket packet) { @@ -26,31 +18,31 @@ implements EntitySoundPacket { @Override public UUID getEntityUuid() { - return this.packet.getSender(); + return packet.getSender(); } @Override public boolean isWhispering() { - return this.packet.isWhispering(); + return packet.isWhispering(); } @Override public float getDistance() { - return this.packet.getDistance(); + return packet.getDistance(); } + @Override public PlayerSoundPacket getPacket() { - return this.packet; + return packet; } @Override public UUID getChannelId() { - return this.packet.getChannelId(); + return packet.getChannelId(); } - public static class BuilderImpl - extends SoundPacketImpl.BuilderImpl - implements EntitySoundPacket.Builder { + public static class BuilderImpl extends SoundPacketImpl.BuilderImpl implements EntitySoundPacket.Builder { + protected UUID entityUuid; protected boolean whispering; protected float distance; @@ -58,12 +50,14 @@ implements EntitySoundPacket { public BuilderImpl(SoundPacketImpl soundPacket) { super(soundPacket); if (soundPacket instanceof EntitySoundPacketImpl) { - EntitySoundPacketImpl p = (EntitySoundPacketImpl)soundPacket; - this.entityUuid = p.getEntityUuid(); - this.whispering = p.isWhispering(); - this.distance = p.getDistance(); + EntitySoundPacketImpl p = (EntitySoundPacketImpl) soundPacket; + entityUuid = p.getEntityUuid(); + whispering = p.isWhispering(); + distance = p.getDistance(); + } else if (soundPacket instanceof LocationalSoundPacketImpl) { + distance = ((LocationalSoundPacketImpl) soundPacket).getDistance(); } else { - this.distance = soundPacket instanceof LocationalSoundPacketImpl ? ((LocationalSoundPacketImpl)soundPacket).getDistance() : Utils.getDefaultDistance(); + distance = Utils.getDefaultDistance(); } } @@ -92,11 +86,11 @@ implements EntitySoundPacket { @Override public EntitySoundPacket build() { - if (this.entityUuid == null) { + if (entityUuid == null) { throw new IllegalStateException("entityUuid missing"); } - return new EntitySoundPacketImpl(new PlayerSoundPacket(this.channelId, this.entityUuid, this.opusEncodedData, this.sequenceNumber, this.whispering, this.distance, this.category)); + return new EntitySoundPacketImpl(new PlayerSoundPacket(channelId, entityUuid, opusEncodedData, sequenceNumber, whispering, distance, category)); } + } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/LocationalSoundPacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/LocationalSoundPacketImpl.java similarity index 59% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/LocationalSoundPacketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/LocationalSoundPacketImpl.java index c668b93..ecb5c11 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/LocationalSoundPacketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/LocationalSoundPacketImpl.java @@ -1,24 +1,16 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.packets; import de.maxhenkel.voicechat.api.Position; import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; import de.maxhenkel.voicechat.plugins.impl.PositionImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.EntitySoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.SoundPacketImpl; import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; -import java.util.UUID; -import javax.annotation.Nullable; -public class LocationalSoundPacketImpl -extends SoundPacketImpl -implements LocationalSoundPacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class LocationalSoundPacketImpl extends SoundPacketImpl implements LocationalSoundPacket { + private final LocationSoundPacket packet; private final PositionImpl position; @@ -28,61 +20,65 @@ implements LocationalSoundPacket { this.position = new PositionImpl(packet.getLocation()); } - @Override public Position getPosition() { - return this.position; + return position; } @Override public float getDistance() { - return this.packet.getDistance(); + return packet.getDistance(); } + @Override public LocationSoundPacket getPacket() { - return this.packet; + return packet; } - public static class BuilderImpl - extends SoundPacketImpl.BuilderImpl - implements LocationalSoundPacket.Builder { + + public static class BuilderImpl extends SoundPacketImpl.BuilderImpl implements LocationalSoundPacket.Builder { + protected PositionImpl position; protected float distance; public BuilderImpl(SoundPacketImpl soundPacket) { super(soundPacket); if (soundPacket instanceof LocationalSoundPacketImpl) { - LocationalSoundPacketImpl p = (LocationalSoundPacketImpl)soundPacket; - this.position = p.position; - this.distance = p.getDistance(); + LocationalSoundPacketImpl p = (LocationalSoundPacketImpl) soundPacket; + position = p.position; + distance = p.getDistance(); + } else if (soundPacket instanceof EntitySoundPacketImpl) { + distance = ((EntitySoundPacketImpl) soundPacket).getDistance(); } else { - this.distance = soundPacket instanceof EntitySoundPacketImpl ? ((EntitySoundPacketImpl)soundPacket).getDistance() : Utils.getDefaultDistance(); + distance = Utils.getDefaultDistance(); } } public BuilderImpl(UUID channelId, UUID sender, byte[] opusEncodedData, long sequenceNumber, @Nullable String category) { super(channelId, sender, opusEncodedData, sequenceNumber, category); - this.distance = Utils.getDefaultDistance(); + distance = Utils.getDefaultDistance(); } @Override public BuilderImpl position(Position position) { - this.position = (PositionImpl)position; + this.position = (PositionImpl) position; return this; } @Override - public BuilderImpl distance(float distance) { + public LocationalSoundPacketImpl.BuilderImpl distance(float distance) { this.distance = distance; return this; } @Override public LocationalSoundPacket build() { - if (this.position == null) { + if (position == null) { throw new IllegalStateException("position missing"); } - return new LocationalSoundPacketImpl(new LocationSoundPacket(this.channelId, this.sender, this.position.getPosition(), this.opusEncodedData, this.sequenceNumber, this.distance, this.category)); + return new LocationalSoundPacketImpl(new LocationSoundPacket(channelId, sender, position.getPosition(), opusEncodedData, sequenceNumber, distance, category)); } - } -} + } + + +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/MicrophonePacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/MicrophonePacketImpl.java new file mode 100644 index 0000000..07a5c61 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/MicrophonePacketImpl.java @@ -0,0 +1,77 @@ +package de.maxhenkel.voicechat.plugins.impl.packets; + +import de.maxhenkel.voicechat.api.Position; +import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; +import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; +import de.maxhenkel.voicechat.api.packets.MicrophonePacket; +import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; +import de.maxhenkel.voicechat.plugins.impl.PositionImpl; +import de.maxhenkel.voicechat.voice.common.*; + +import java.util.Objects; +import java.util.UUID; + +public class MicrophonePacketImpl implements MicrophonePacket { + + private final MicPacket packet; + private final UUID sender; + + public MicrophonePacketImpl(MicPacket packet, UUID sender) { + this.packet = packet; + this.sender = sender; + } + + @Override + public boolean isWhispering() { + return packet.isWhispering(); + } + + @Override + public byte[] getOpusEncodedData() { + return packet.getData(); + } + + @Override + public void setOpusEncodedData(byte[] data) { + packet.setData(Objects.requireNonNull(data)); + } + + @Override + public EntitySoundPacket.Builder entitySoundPacketBuilder() { + return new EntitySoundPacketImpl.BuilderImpl(sender, sender, packet.getData(), packet.getSequenceNumber(), null); + } + + @Override + public LocationalSoundPacket.Builder locationalSoundPacketBuilder() { + return new LocationalSoundPacketImpl.BuilderImpl(sender, sender, packet.getData(), packet.getSequenceNumber(), null); + } + + @Override + public StaticSoundPacket.Builder staticSoundPacketBuilder() { + return new StaticSoundPacketImpl.BuilderImpl(sender, sender, packet.getData(), packet.getSequenceNumber(), null); + } + + @Override + @Deprecated + public EntitySoundPacket toEntitySoundPacket(UUID entityUuid, boolean whispering) { + return new EntitySoundPacketImpl(new PlayerSoundPacket(sender, entityUuid, packet.getData(), packet.getSequenceNumber(), whispering, Utils.getDefaultDistance(), null)); + } + + + @Override + @Deprecated + public LocationalSoundPacket toLocationalSoundPacket(Position position) { + if (position instanceof PositionImpl) { + return new LocationalSoundPacketImpl(new LocationSoundPacket(sender, sender, ((PositionImpl) position).getPosition(), packet.getData(), packet.getSequenceNumber(), Utils.getDefaultDistance(), null)); + } else { + throw new IllegalArgumentException("position is not an instance of PositionImpl"); + } + } + + @Override + @Deprecated + public StaticSoundPacket toStaticSoundPacket() { + return new StaticSoundPacketImpl(new GroupSoundPacket(sender, sender, packet.getData(), packet.getSequenceNumber(), null)); + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/SoundPacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/SoundPacketImpl.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/SoundPacketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/SoundPacketImpl.java index f9df157..b2fb157 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/SoundPacketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/SoundPacketImpl.java @@ -1,9 +1,3 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.packets; import de.maxhenkel.voicechat.api.Position; @@ -12,53 +6,50 @@ import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; import de.maxhenkel.voicechat.api.packets.SoundPacket; import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; import de.maxhenkel.voicechat.plugins.impl.PositionImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.EntitySoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.LocationalSoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.StaticSoundPacketImpl; import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; -import de.maxhenkel.voicechat.voice.common.SoundPacket; import de.maxhenkel.voicechat.voice.common.Utils; -import java.util.UUID; + import javax.annotation.Nullable; +import java.util.UUID; -public class SoundPacketImpl -implements de.maxhenkel.voicechat.api.packets.SoundPacket { - private final SoundPacket packet; +public class SoundPacketImpl implements SoundPacket { - public SoundPacketImpl(SoundPacket packet) { + private final de.maxhenkel.voicechat.voice.common.SoundPacket packet; + + public SoundPacketImpl(de.maxhenkel.voicechat.voice.common.SoundPacket packet) { this.packet = packet; } @Override public UUID getChannelId() { - return this.packet.getChannelId(); + return packet.getChannelId(); } @Override public UUID getSender() { - return this.packet.getSender(); + return packet.getSender(); } @Override public byte[] getOpusEncodedData() { - return this.packet.getData(); + return packet.getData(); } @Override public long getSequenceNumber() { - return this.packet.getSequenceNumber(); + return packet.getSequenceNumber(); } - @Override @Nullable + @Override public String getCategory() { - return this.packet.getCategory(); + return packet.getCategory(); } - public SoundPacket getPacket() { - return this.packet; + public de.maxhenkel.voicechat.voice.common.SoundPacket getPacket() { + return packet; } @Override @@ -78,34 +69,34 @@ implements de.maxhenkel.voicechat.api.packets.SoundPacket { @Override public EntitySoundPacket toEntitySoundPacket(UUID entityUuid, boolean whispering) { - return new EntitySoundPacketImpl(new PlayerSoundPacket(this.packet.getChannelId(), entityUuid, this.packet.getData(), this.packet.getSequenceNumber(), whispering, this.getDistance(), null)); + return new EntitySoundPacketImpl(new PlayerSoundPacket(packet.getChannelId(), entityUuid, packet.getData(), packet.getSequenceNumber(), whispering, getDistance(), null)); } @Override public LocationalSoundPacket toLocationalSoundPacket(Position position) { if (position instanceof PositionImpl) { - return new LocationalSoundPacketImpl(new LocationSoundPacket(this.packet.getChannelId(), this.packet.getSender(), ((PositionImpl)position).getPosition(), this.packet.getData(), this.packet.getSequenceNumber(), this.getDistance(), null)); + return new LocationalSoundPacketImpl(new LocationSoundPacket(packet.getChannelId(), packet.getSender(), ((PositionImpl) position).getPosition(), packet.getData(), packet.getSequenceNumber(), getDistance(), null)); + } else { + throw new IllegalArgumentException("position is not an instance of PositionImpl"); } - throw new IllegalArgumentException("position is not an instance of PositionImpl"); } private float getDistance() { if (this instanceof EntitySoundPacket) { - return ((EntitySoundPacket)((Object)this)).getDistance(); - } - if (this instanceof LocationalSoundPacket) { - return ((LocationalSoundPacket)((Object)this)).getDistance(); + return ((EntitySoundPacket) this).getDistance(); + } else if (this instanceof LocationalSoundPacket) { + return ((LocationalSoundPacket) this).getDistance(); } return Utils.getDefaultDistance(); } @Override public StaticSoundPacket toStaticSoundPacket() { - return new StaticSoundPacketImpl(new GroupSoundPacket(this.packet.getChannelId(), this.packet.getSender(), this.packet.getData(), this.packet.getSequenceNumber(), null)); + return new StaticSoundPacketImpl(new GroupSoundPacket(packet.getChannelId(), packet.getSender(), packet.getData(), packet.getSequenceNumber(), null)); } - public static abstract class BuilderImpl, P extends de.maxhenkel.voicechat.api.packets.SoundPacket> - implements SoundPacket.Builder { + public abstract static class BuilderImpl, P extends SoundPacket> implements Builder { + protected UUID channelId; protected UUID sender; protected byte[] opusEncodedData; @@ -135,32 +126,32 @@ implements de.maxhenkel.voicechat.api.packets.SoundPacket { throw new IllegalArgumentException("channelId can't be null"); } this.channelId = channelId; - return (T)this; + return (T) this; } @Override public T sender(UUID sender) { this.sender = sender; - return (T)this; + return (T) this; } @Override public T opusEncodedData(byte[] data) { this.opusEncodedData = data; - return (T)this; + return (T) this; } @Override public T sequenceNumber(long sequenceNumber) { this.sequenceNumber = sequenceNumber; - return (T)this; + return (T) this; } @Override public T category(@Nullable String category) { this.category = category; - return (T)this; + return (T) this; } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/StaticSoundPacketImpl.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/StaticSoundPacketImpl.java similarity index 60% rename from source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/StaticSoundPacketImpl.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/StaticSoundPacketImpl.java index efa1541..c901529 100644 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/StaticSoundPacketImpl.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/plugins/impl/packets/StaticSoundPacketImpl.java @@ -1,27 +1,19 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.plugins.impl.packets; import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; -import de.maxhenkel.voicechat.plugins.impl.packets.SoundPacketImpl; import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; -import java.util.UUID; -import javax.annotation.Nullable; -public class StaticSoundPacketImpl -extends SoundPacketImpl -implements StaticSoundPacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class StaticSoundPacketImpl extends SoundPacketImpl implements StaticSoundPacket { + public StaticSoundPacketImpl(GroupSoundPacket packet) { super(packet); } - public static class BuilderImpl - extends SoundPacketImpl.BuilderImpl - implements StaticSoundPacket.Builder { + public static class BuilderImpl extends SoundPacketImpl.BuilderImpl implements StaticSoundPacket.Builder { + public BuilderImpl(SoundPacketImpl soundPacket) { super(soundPacket); } @@ -32,8 +24,9 @@ implements StaticSoundPacket { @Override public StaticSoundPacket build() { - return new StaticSoundPacketImpl(new GroupSoundPacket(this.channelId, this.sender, this.opusEncodedData, this.sequenceNumber, this.category)); + return new StaticSoundPacketImpl(new GroupSoundPacket(channelId, sender, opusEncodedData, sequenceNumber, category)); } - } -} + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/util/FriendlyByteBuf.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/util/FriendlyByteBuf.java similarity index 52% rename from source/decompiled/de/maxhenkel/voicechat/util/FriendlyByteBuf.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/util/FriendlyByteBuf.java index e44d97b..841fb20 100644 --- a/source/decompiled/de/maxhenkel/voicechat/util/FriendlyByteBuf.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/util/FriendlyByteBuf.java @@ -1,22 +1,10 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * io.netty.buffer.ByteBuf - * io.netty.buffer.ByteBufAllocator - * io.netty.buffer.Unpooled - * io.netty.handler.codec.DecoderException - * io.netty.handler.codec.EncoderException - * io.netty.util.ByteProcessor - */ package de.maxhenkel.voicechat.util; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufAllocator; -import io.netty.buffer.Unpooled; +import io.netty.buffer.*; import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.EncoderException; import io.netty.util.ByteProcessor; + import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -29,12 +17,12 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.UUID; -public class FriendlyByteBuf -extends ByteBuf { +public class FriendlyByteBuf extends ByteBuf { + private final ByteBuf buf; public FriendlyByteBuf(ByteBuf byteBuf) { - this.buf = byteBuf; + buf = byteBuf; } public FriendlyByteBuf() { @@ -42,825 +30,1014 @@ extends ByteBuf { } public ByteBuf getUnderlyingByteBuf() { - return this.buf; + return buf; } public FriendlyByteBuf writeByteArray(byte[] bs) { - this.writeVarInt(bs.length); - this.writeBytes(bs); + writeVarInt(bs.length); + writeBytes(bs); return this; } public byte[] readByteArray() { - return this.readByteArray(this.readableBytes()); + return readByteArray(readableBytes()); } public byte[] readByteArray(int i) { - int j = this.readVarInt(); + int j = readVarInt(); if (j > i) { throw new DecoderException("ByteArray with size " + j + " is bigger than allowed " + i); + } else { + byte[] bs = new byte[j]; + readBytes(bs); + return bs; } - byte[] bs = new byte[j]; - this.readBytes(bs); - return bs; } public int readVarInt() { - byte b; int i = 0; int j = 0; + + byte b; do { - b = this.readByte(); - i |= (b & 0x7F) << j++ * 7; - if (j <= 5) continue; - throw new RuntimeException("VarInt too big"); - } while ((b & 0x80) == 128); + b = readByte(); + i |= (b & 127) << j++ * 7; + if (j > 5) { + throw new RuntimeException("VarInt too big"); + } + } while ((b & 128) == 128); + return i; } public FriendlyByteBuf writeUUID(UUID uUID) { - this.writeLong(uUID.getMostSignificantBits()); - this.writeLong(uUID.getLeastSignificantBits()); + writeLong(uUID.getMostSignificantBits()); + writeLong(uUID.getLeastSignificantBits()); return this; } public UUID readUUID() { - return new UUID(this.readLong(), this.readLong()); + return new UUID(readLong(), readLong()); } public FriendlyByteBuf writeVarInt(int i) { - while ((i & 0xFFFFFF80) != 0) { - this.writeByte(i & 0x7F | 0x80); + while ((i & -128) != 0) { + writeByte(i & 127 | 128); i >>>= 7; } - this.writeByte(i); + + writeByte(i); return this; } public String readUtf(int i) { - int j = this.readVarInt(); + int j = readVarInt(); if (j > i * 4) { throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + j + " > " + i * 4 + ')'); - } - if (j < 0) { + } else if (j < 0) { throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); + } else { + String string = toString(readerIndex(), j, StandardCharsets.UTF_8); + readerIndex(readerIndex() + j); + if (string.length() > i) { + throw new DecoderException("The received string length is longer than maximum allowed (" + j + " > " + i + ')'); + } else { + return string; + } } - String string = this.toString(this.readerIndex(), j, StandardCharsets.UTF_8); - this.readerIndex(this.readerIndex() + j); - if (string.length() > i) { - throw new DecoderException("The received string length is longer than maximum allowed (" + j + " > " + i + ')'); - } - return string; } public FriendlyByteBuf writeUtf(String string, int i) { byte[] bs = string.getBytes(StandardCharsets.UTF_8); if (bs.length > i) { throw new EncoderException("String too big (was " + bs.length + " bytes encoded, max " + i + ')'); + } else { + writeVarInt(bs.length); + writeBytes(bs); + return this; } - this.writeVarInt(bs.length); - this.writeBytes(bs); - return this; } public String readUtf() { - return this.readUtf(Short.MAX_VALUE); + return readUtf(32767); } public FriendlyByteBuf writeUtf(String string) { - return this.writeUtf(string, Short.MAX_VALUE); + return writeUtf(string, 32767); } + @Override public int capacity() { - return this.buf.capacity(); + return buf.capacity(); } + @Override public ByteBuf capacity(int i) { - return this.buf.capacity(i); + return buf.capacity(i); } + @Override public int maxCapacity() { - return this.buf.maxCapacity(); + return buf.maxCapacity(); } + @Override public ByteBufAllocator alloc() { - return this.buf.alloc(); + return buf.alloc(); } + @Override public ByteOrder order() { - return this.buf.order(); + return buf.order(); } + @Override public ByteBuf order(ByteOrder byteOrder) { - return this.buf.order(byteOrder); + return buf.order(byteOrder); } + @Override public ByteBuf unwrap() { - return this.buf.unwrap(); + return buf.unwrap(); } + @Override public boolean isDirect() { - return this.buf.isDirect(); + return buf.isDirect(); } + @Override public boolean isReadOnly() { - return this.buf.isReadOnly(); + return buf.isReadOnly(); } + @Override public ByteBuf asReadOnly() { - return this.buf.asReadOnly(); + return buf.asReadOnly(); } + @Override public int readerIndex() { - return this.buf.readerIndex(); + return buf.readerIndex(); } + @Override public ByteBuf readerIndex(int i) { - return this.buf.readerIndex(i); + return buf.readerIndex(i); } + @Override public int writerIndex() { - return this.buf.writerIndex(); + return buf.writerIndex(); } + @Override public ByteBuf writerIndex(int i) { - return this.buf.writerIndex(i); + return buf.writerIndex(i); } + @Override public ByteBuf setIndex(int i, int j) { - return this.buf.setIndex(i, j); + return buf.setIndex(i, j); } + @Override public int readableBytes() { - return this.buf.readableBytes(); + return buf.readableBytes(); } + @Override public int writableBytes() { - return this.buf.writableBytes(); + return buf.writableBytes(); } + @Override public int maxWritableBytes() { - return this.buf.maxWritableBytes(); + return buf.maxWritableBytes(); } + @Override public boolean isReadable() { - return this.buf.isReadable(); + return buf.isReadable(); } + @Override public boolean isReadable(int i) { - return this.buf.isReadable(i); + return buf.isReadable(i); } + @Override public boolean isWritable() { - return this.buf.isWritable(); + return buf.isWritable(); } + @Override public boolean isWritable(int i) { - return this.buf.isWritable(i); + return buf.isWritable(i); } + @Override public ByteBuf clear() { - return this.buf.clear(); + return buf.clear(); } + @Override public ByteBuf markReaderIndex() { - return this.buf.markReaderIndex(); + return buf.markReaderIndex(); } + @Override public ByteBuf resetReaderIndex() { - return this.buf.resetReaderIndex(); + return buf.resetReaderIndex(); } + @Override public ByteBuf markWriterIndex() { - return this.buf.markWriterIndex(); + return buf.markWriterIndex(); } + @Override public ByteBuf resetWriterIndex() { - return this.buf.resetWriterIndex(); + return buf.resetWriterIndex(); } + @Override public ByteBuf discardReadBytes() { - return this.buf.discardReadBytes(); + return buf.discardReadBytes(); } + @Override public ByteBuf discardSomeReadBytes() { - return this.buf.discardSomeReadBytes(); + return buf.discardSomeReadBytes(); } + @Override public ByteBuf ensureWritable(int i) { - return this.buf.ensureWritable(i); + return buf.ensureWritable(i); } + @Override public int ensureWritable(int i, boolean bl) { - return this.buf.ensureWritable(i, bl); + return buf.ensureWritable(i, bl); } + @Override public boolean getBoolean(int i) { - return this.buf.getBoolean(i); + return buf.getBoolean(i); } + @Override public byte getByte(int i) { - return this.buf.getByte(i); + return buf.getByte(i); } + @Override public short getUnsignedByte(int i) { - return this.buf.getUnsignedByte(i); + return buf.getUnsignedByte(i); } + @Override public short getShort(int i) { - return this.buf.getShort(i); + return buf.getShort(i); } + @Override public short getShortLE(int i) { - return this.buf.getShortLE(i); + return buf.getShortLE(i); } + @Override public int getUnsignedShort(int i) { - return this.buf.getUnsignedShort(i); + return buf.getUnsignedShort(i); } + @Override public int getUnsignedShortLE(int i) { - return this.buf.getUnsignedShortLE(i); + return buf.getUnsignedShortLE(i); } + @Override public int getMedium(int i) { - return this.buf.getMedium(i); + return buf.getMedium(i); } + @Override public int getMediumLE(int i) { - return this.buf.getMediumLE(i); + return buf.getMediumLE(i); } + @Override public int getUnsignedMedium(int i) { - return this.buf.getUnsignedMedium(i); + return buf.getUnsignedMedium(i); } + @Override public int getUnsignedMediumLE(int i) { - return this.buf.getUnsignedMediumLE(i); + return buf.getUnsignedMediumLE(i); } + @Override public int getInt(int i) { - return this.buf.getInt(i); + return buf.getInt(i); } + @Override public int getIntLE(int i) { - return this.buf.getIntLE(i); + return buf.getIntLE(i); } + @Override public long getUnsignedInt(int i) { - return this.buf.getUnsignedInt(i); + return buf.getUnsignedInt(i); } + @Override public long getUnsignedIntLE(int i) { - return this.buf.getUnsignedIntLE(i); + return buf.getUnsignedIntLE(i); } + @Override public long getLong(int i) { - return this.buf.getLong(i); + return buf.getLong(i); } + @Override public long getLongLE(int i) { - return this.buf.getLongLE(i); + return buf.getLongLE(i); } + @Override public char getChar(int i) { - return this.buf.getChar(i); + return buf.getChar(i); } + @Override public float getFloat(int i) { - return this.buf.getFloat(i); + return buf.getFloat(i); } + @Override public double getDouble(int i) { - return this.buf.getDouble(i); + return buf.getDouble(i); } + @Override public ByteBuf getBytes(int i, ByteBuf byteBuf) { - return this.buf.getBytes(i, byteBuf); + return buf.getBytes(i, byteBuf); } + @Override public ByteBuf getBytes(int i, ByteBuf byteBuf, int j) { - return this.buf.getBytes(i, byteBuf, j); + return buf.getBytes(i, byteBuf, j); } + @Override public ByteBuf getBytes(int i, ByteBuf byteBuf, int j, int k) { - return this.buf.getBytes(i, byteBuf, j, k); + return buf.getBytes(i, byteBuf, j, k); } + @Override public ByteBuf getBytes(int i, byte[] bs) { - return this.buf.getBytes(i, bs); + return buf.getBytes(i, bs); } + @Override public ByteBuf getBytes(int i, byte[] bs, int j, int k) { - return this.buf.getBytes(i, bs, j, k); + return buf.getBytes(i, bs, j, k); } + @Override public ByteBuf getBytes(int i, ByteBuffer byteBuffer) { - return this.buf.getBytes(i, byteBuffer); + return buf.getBytes(i, byteBuffer); } + @Override public ByteBuf getBytes(int i, OutputStream outputStream, int j) throws IOException { - return this.buf.getBytes(i, outputStream, j); + return buf.getBytes(i, outputStream, j); } + @Override public int getBytes(int i, GatheringByteChannel gatheringByteChannel, int j) throws IOException { - return this.buf.getBytes(i, gatheringByteChannel, j); + return buf.getBytes(i, gatheringByteChannel, j); } + @Override public int getBytes(int i, FileChannel fileChannel, long l, int j) throws IOException { - return this.buf.getBytes(i, fileChannel, l, j); + return buf.getBytes(i, fileChannel, l, j); } + @Override public CharSequence getCharSequence(int i, int j, Charset charset) { - return this.buf.getCharSequence(i, j, charset); + return buf.getCharSequence(i, j, charset); } + @Override public ByteBuf setBoolean(int i, boolean bl) { - return this.buf.setBoolean(i, bl); + return buf.setBoolean(i, bl); } + @Override public ByteBuf setByte(int i, int j) { - return this.buf.setByte(i, j); + return buf.setByte(i, j); } + @Override public ByteBuf setShort(int i, int j) { - return this.buf.setShort(i, j); + return buf.setShort(i, j); } + @Override public ByteBuf setShortLE(int i, int j) { - return this.buf.setShortLE(i, j); + return buf.setShortLE(i, j); } + @Override public ByteBuf setMedium(int i, int j) { - return this.buf.setMedium(i, j); + return buf.setMedium(i, j); } + @Override public ByteBuf setMediumLE(int i, int j) { - return this.buf.setMediumLE(i, j); + return buf.setMediumLE(i, j); } + @Override public ByteBuf setInt(int i, int j) { - return this.buf.setInt(i, j); + return buf.setInt(i, j); } + @Override public ByteBuf setIntLE(int i, int j) { - return this.buf.setIntLE(i, j); + return buf.setIntLE(i, j); } + @Override public ByteBuf setLong(int i, long l) { - return this.buf.setLong(i, l); + return buf.setLong(i, l); } + @Override public ByteBuf setLongLE(int i, long l) { - return this.buf.setLongLE(i, l); + return buf.setLongLE(i, l); } + @Override public ByteBuf setChar(int i, int j) { - return this.buf.setChar(i, j); + return buf.setChar(i, j); } + @Override public ByteBuf setFloat(int i, float f) { - return this.buf.setFloat(i, f); + return buf.setFloat(i, f); } + @Override public ByteBuf setDouble(int i, double d) { - return this.buf.setDouble(i, d); + return buf.setDouble(i, d); } + @Override public ByteBuf setBytes(int i, ByteBuf byteBuf) { - return this.buf.setBytes(i, byteBuf); + return buf.setBytes(i, byteBuf); } + @Override public ByteBuf setBytes(int i, ByteBuf byteBuf, int j) { - return this.buf.setBytes(i, byteBuf, j); + return buf.setBytes(i, byteBuf, j); } + @Override public ByteBuf setBytes(int i, ByteBuf byteBuf, int j, int k) { - return this.buf.setBytes(i, byteBuf, j, k); + return buf.setBytes(i, byteBuf, j, k); } + @Override public ByteBuf setBytes(int i, byte[] bs) { - return this.buf.setBytes(i, bs); + return buf.setBytes(i, bs); } + @Override public ByteBuf setBytes(int i, byte[] bs, int j, int k) { - return this.buf.setBytes(i, bs, j, k); + return buf.setBytes(i, bs, j, k); } + @Override public ByteBuf setBytes(int i, ByteBuffer byteBuffer) { - return this.buf.setBytes(i, byteBuffer); + return buf.setBytes(i, byteBuffer); } + @Override public int setBytes(int i, InputStream inputStream, int j) throws IOException { - return this.buf.setBytes(i, inputStream, j); + return buf.setBytes(i, inputStream, j); } + @Override public int setBytes(int i, ScatteringByteChannel scatteringByteChannel, int j) throws IOException { - return this.buf.setBytes(i, scatteringByteChannel, j); + return buf.setBytes(i, scatteringByteChannel, j); } + @Override public int setBytes(int i, FileChannel fileChannel, long l, int j) throws IOException { - return this.buf.setBytes(i, fileChannel, l, j); + return buf.setBytes(i, fileChannel, l, j); } + @Override public ByteBuf setZero(int i, int j) { - return this.buf.setZero(i, j); + return buf.setZero(i, j); } + @Override public int setCharSequence(int i, CharSequence charSequence, Charset charset) { - return this.buf.setCharSequence(i, charSequence, charset); + return buf.setCharSequence(i, charSequence, charset); } + @Override public boolean readBoolean() { - return this.buf.readBoolean(); + return buf.readBoolean(); } + @Override public byte readByte() { - return this.buf.readByte(); + return buf.readByte(); } + @Override public short readUnsignedByte() { - return this.buf.readUnsignedByte(); + return buf.readUnsignedByte(); } + @Override public short readShort() { - return this.buf.readShort(); + return buf.readShort(); } + @Override public short readShortLE() { - return this.buf.readShortLE(); + return buf.readShortLE(); } + @Override public int readUnsignedShort() { - return this.buf.readUnsignedShort(); + return buf.readUnsignedShort(); } + @Override public int readUnsignedShortLE() { - return this.buf.readUnsignedShortLE(); + return buf.readUnsignedShortLE(); } + @Override public int readMedium() { - return this.buf.readMedium(); + return buf.readMedium(); } + @Override public int readMediumLE() { - return this.buf.readMediumLE(); + return buf.readMediumLE(); } + @Override public int readUnsignedMedium() { - return this.buf.readUnsignedMedium(); + return buf.readUnsignedMedium(); } + @Override public int readUnsignedMediumLE() { - return this.buf.readUnsignedMediumLE(); + return buf.readUnsignedMediumLE(); } + @Override public int readInt() { - return this.buf.readInt(); + return buf.readInt(); } + @Override public int readIntLE() { - return this.buf.readIntLE(); + return buf.readIntLE(); } + @Override public long readUnsignedInt() { - return this.buf.readUnsignedInt(); + return buf.readUnsignedInt(); } + @Override public long readUnsignedIntLE() { - return this.buf.readUnsignedIntLE(); + return buf.readUnsignedIntLE(); } + @Override public long readLong() { - return this.buf.readLong(); + return buf.readLong(); } + @Override public long readLongLE() { - return this.buf.readLongLE(); + return buf.readLongLE(); } + @Override public char readChar() { - return this.buf.readChar(); + return buf.readChar(); } + @Override public float readFloat() { - return this.buf.readFloat(); + return buf.readFloat(); } + @Override public double readDouble() { - return this.buf.readDouble(); + return buf.readDouble(); } + @Override public ByteBuf readBytes(int i) { - return this.buf.readBytes(i); + return buf.readBytes(i); } + @Override public ByteBuf readSlice(int i) { - return this.buf.readSlice(i); + return buf.readSlice(i); } + @Override public ByteBuf readRetainedSlice(int i) { - return this.buf.readRetainedSlice(i); + return buf.readRetainedSlice(i); } + @Override public ByteBuf readBytes(ByteBuf byteBuf) { - return this.buf.readBytes(byteBuf); + return buf.readBytes(byteBuf); } + @Override public ByteBuf readBytes(ByteBuf byteBuf, int i) { - return this.buf.readBytes(byteBuf, i); + return buf.readBytes(byteBuf, i); } + @Override public ByteBuf readBytes(ByteBuf byteBuf, int i, int j) { - return this.buf.readBytes(byteBuf, i, j); + return buf.readBytes(byteBuf, i, j); } + @Override public ByteBuf readBytes(byte[] bs) { - return this.buf.readBytes(bs); + return buf.readBytes(bs); } + @Override public ByteBuf readBytes(byte[] bs, int i, int j) { - return this.buf.readBytes(bs, i, j); + return buf.readBytes(bs, i, j); } + @Override public ByteBuf readBytes(ByteBuffer byteBuffer) { - return this.buf.readBytes(byteBuffer); + return buf.readBytes(byteBuffer); } + @Override public ByteBuf readBytes(OutputStream outputStream, int i) throws IOException { - return this.buf.readBytes(outputStream, i); + return buf.readBytes(outputStream, i); } + @Override public int readBytes(GatheringByteChannel gatheringByteChannel, int i) throws IOException { - return this.buf.readBytes(gatheringByteChannel, i); + return buf.readBytes(gatheringByteChannel, i); } + @Override public CharSequence readCharSequence(int i, Charset charset) { - return this.buf.readCharSequence(i, charset); + return buf.readCharSequence(i, charset); } + @Override public int readBytes(FileChannel fileChannel, long l, int i) throws IOException { - return this.buf.readBytes(fileChannel, l, i); + return buf.readBytes(fileChannel, l, i); } + @Override public ByteBuf skipBytes(int i) { - return this.buf.skipBytes(i); + return buf.skipBytes(i); } + @Override public ByteBuf writeBoolean(boolean bl) { - return this.buf.writeBoolean(bl); + return buf.writeBoolean(bl); } + @Override public ByteBuf writeByte(int i) { - return this.buf.writeByte(i); + return buf.writeByte(i); } + @Override public ByteBuf writeShort(int i) { - return this.buf.writeShort(i); + return buf.writeShort(i); } + @Override public ByteBuf writeShortLE(int i) { - return this.buf.writeShortLE(i); + return buf.writeShortLE(i); } + @Override public ByteBuf writeMedium(int i) { - return this.buf.writeMedium(i); + return buf.writeMedium(i); } + @Override public ByteBuf writeMediumLE(int i) { - return this.buf.writeMediumLE(i); + return buf.writeMediumLE(i); } + @Override public ByteBuf writeInt(int i) { - return this.buf.writeInt(i); + return buf.writeInt(i); } + @Override public ByteBuf writeIntLE(int i) { - return this.buf.writeIntLE(i); + return buf.writeIntLE(i); } + @Override public ByteBuf writeLong(long l) { - return this.buf.writeLong(l); + return buf.writeLong(l); } + @Override public ByteBuf writeLongLE(long l) { - return this.buf.writeLongLE(l); + return buf.writeLongLE(l); } + @Override public ByteBuf writeChar(int i) { - return this.buf.writeChar(i); + return buf.writeChar(i); } + @Override public ByteBuf writeFloat(float f) { - return this.buf.writeFloat(f); + return buf.writeFloat(f); } + @Override public ByteBuf writeDouble(double d) { - return this.buf.writeDouble(d); + return buf.writeDouble(d); } + @Override public ByteBuf writeBytes(ByteBuf byteBuf) { - return this.buf.writeBytes(byteBuf); + return buf.writeBytes(byteBuf); } + @Override public ByteBuf writeBytes(ByteBuf byteBuf, int i) { - return this.buf.writeBytes(byteBuf, i); + return buf.writeBytes(byteBuf, i); } + @Override public ByteBuf writeBytes(ByteBuf byteBuf, int i, int j) { - return this.buf.writeBytes(byteBuf, i, j); + return buf.writeBytes(byteBuf, i, j); } + @Override public ByteBuf writeBytes(byte[] bs) { - return this.buf.writeBytes(bs); + return buf.writeBytes(bs); } + @Override public ByteBuf writeBytes(byte[] bs, int i, int j) { - return this.buf.writeBytes(bs, i, j); + return buf.writeBytes(bs, i, j); } + @Override public ByteBuf writeBytes(ByteBuffer byteBuffer) { - return this.buf.writeBytes(byteBuffer); + return buf.writeBytes(byteBuffer); } + @Override public int writeBytes(InputStream inputStream, int i) throws IOException { - return this.buf.writeBytes(inputStream, i); + return buf.writeBytes(inputStream, i); } + @Override public int writeBytes(ScatteringByteChannel scatteringByteChannel, int i) throws IOException { - return this.buf.writeBytes(scatteringByteChannel, i); + return buf.writeBytes(scatteringByteChannel, i); } + @Override public int writeBytes(FileChannel fileChannel, long l, int i) throws IOException { - return this.buf.writeBytes(fileChannel, l, i); + return buf.writeBytes(fileChannel, l, i); } + @Override public ByteBuf writeZero(int i) { - return this.buf.writeZero(i); + return buf.writeZero(i); } + @Override public int writeCharSequence(CharSequence charSequence, Charset charset) { - return this.buf.writeCharSequence(charSequence, charset); + return buf.writeCharSequence(charSequence, charset); } + @Override public int indexOf(int i, int j, byte b) { - return this.buf.indexOf(i, j, b); + return buf.indexOf(i, j, b); } + @Override public int bytesBefore(byte b) { - return this.buf.bytesBefore(b); + return buf.bytesBefore(b); } + @Override public int bytesBefore(int i, byte b) { - return this.buf.bytesBefore(i, b); + return buf.bytesBefore(i, b); } + @Override public int bytesBefore(int i, int j, byte b) { - return this.buf.bytesBefore(i, j, b); + return buf.bytesBefore(i, j, b); } + @Override public int forEachByte(ByteProcessor byteProcessor) { - return this.buf.forEachByte(byteProcessor); + return buf.forEachByte(byteProcessor); } + @Override public int forEachByte(int i, int j, ByteProcessor byteProcessor) { - return this.buf.forEachByte(i, j, byteProcessor); + return buf.forEachByte(i, j, byteProcessor); } + @Override public int forEachByteDesc(ByteProcessor byteProcessor) { - return this.buf.forEachByteDesc(byteProcessor); + return buf.forEachByteDesc(byteProcessor); } + @Override public int forEachByteDesc(int i, int j, ByteProcessor byteProcessor) { - return this.buf.forEachByteDesc(i, j, byteProcessor); + return buf.forEachByteDesc(i, j, byteProcessor); } + @Override public ByteBuf copy() { - return this.buf.copy(); + return buf.copy(); } + @Override public ByteBuf copy(int i, int j) { - return this.buf.copy(i, j); + return buf.copy(i, j); } + @Override public ByteBuf slice() { - return this.buf.slice(); + return buf.slice(); } + @Override public ByteBuf retainedSlice() { - return this.buf.retainedSlice(); + return buf.retainedSlice(); } + @Override public ByteBuf slice(int i, int j) { - return this.buf.slice(i, j); + return buf.slice(i, j); } + @Override public ByteBuf retainedSlice(int i, int j) { - return this.buf.retainedSlice(i, j); + return buf.retainedSlice(i, j); } + @Override public ByteBuf duplicate() { - return this.buf.duplicate(); + return buf.duplicate(); } + @Override public ByteBuf retainedDuplicate() { - return this.buf.retainedDuplicate(); + return buf.retainedDuplicate(); } + @Override public int nioBufferCount() { - return this.buf.nioBufferCount(); + return buf.nioBufferCount(); } + @Override public ByteBuffer nioBuffer() { - return this.buf.nioBuffer(); + return buf.nioBuffer(); } + @Override public ByteBuffer nioBuffer(int i, int j) { - return this.buf.nioBuffer(i, j); + return buf.nioBuffer(i, j); } + @Override public ByteBuffer internalNioBuffer(int i, int j) { - return this.buf.internalNioBuffer(i, j); + return buf.internalNioBuffer(i, j); } + @Override public ByteBuffer[] nioBuffers() { - return this.buf.nioBuffers(); + return buf.nioBuffers(); } + @Override public ByteBuffer[] nioBuffers(int i, int j) { - return this.buf.nioBuffers(i, j); + return buf.nioBuffers(i, j); } + @Override public boolean hasArray() { - return this.buf.hasArray(); + return buf.hasArray(); } + @Override public byte[] array() { - return this.buf.array(); + return buf.array(); } + @Override public int arrayOffset() { - return this.buf.arrayOffset(); + return buf.arrayOffset(); } + @Override public boolean hasMemoryAddress() { - return this.buf.hasMemoryAddress(); + return buf.hasMemoryAddress(); } + @Override public long memoryAddress() { - return this.buf.memoryAddress(); + return buf.memoryAddress(); } + @Override public String toString(Charset charset) { - return this.buf.toString(charset); + return buf.toString(charset); } + @Override public String toString(int i, int j, Charset charset) { - return this.buf.toString(i, j, charset); + return buf.toString(i, j, charset); } + @Override public int hashCode() { - return this.buf.hashCode(); + return buf.hashCode(); } + @Override public boolean equals(Object object) { - return this.buf.equals(object); + return buf.equals(object); } + @Override public int compareTo(ByteBuf byteBuf) { - return this.buf.compareTo(byteBuf); + return buf.compareTo(byteBuf); } + @Override public String toString() { - return this.buf.toString(); + return buf.toString(); } + @Override public ByteBuf retain(int i) { - return this.buf.retain(i); + return buf.retain(i); } + @Override public ByteBuf retain() { - return this.buf.retain(); + return buf.retain(); } + @Override public ByteBuf touch() { - return this.buf.touch(); + return buf.touch(); } + @Override public ByteBuf touch(Object object) { - return this.buf.touch(object); + return buf.touch(object); } + @Override public int refCnt() { - return this.buf.refCnt(); + return buf.refCnt(); } + @Override public boolean release() { - return this.buf.release(); + return buf.release(); } + @Override public boolean release(int i) { - return this.buf.release(i); + return buf.release(i); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/util/Key.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/util/Key.java similarity index 76% rename from source/decompiled/de/maxhenkel/voicechat/util/Key.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/util/Key.java index d77a3e0..d9120f2 100644 --- a/source/decompiled/de/maxhenkel/voicechat/util/Key.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/util/Key.java @@ -1,12 +1,13 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.util; +import de.maxhenkel.voicechat.Voicechat; + public class Key { + private final String namespace; private final String value; + //TODO Validate allowed characters public Key(String namespace, String value) { this.namespace = namespace; this.value = value; @@ -17,7 +18,7 @@ public class Key { } public static Key of(String value) { - return new Key("voicechat", value); + return new Key(Voicechat.MODID, value); } public static Key parse(String value) { @@ -29,15 +30,16 @@ public class Key { } public String getNamespace() { - return this.namespace; + return namespace; } public String getValue() { - return this.value; + return value; } + @Override public String toString() { - return String.format("%s:%s", this.namespace, this.value); + return String.format("%s:%s", namespace, value); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/AudioUtils.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AudioUtils.java similarity index 65% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/AudioUtils.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AudioUtils.java index 6e6e3fe..e251a05 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/AudioUtils.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AudioUtils.java @@ -1,6 +1,3 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import java.nio.ByteBuffer; @@ -8,6 +5,7 @@ import java.nio.ByteOrder; import java.nio.ShortBuffer; public class AudioUtils { + public static final int MAX_OPUS_PAYLOAD_SIZE = 1275; public static short[] bytesToShorts(byte[] bytes) { @@ -30,36 +28,40 @@ public class AudioUtils { public static short[] floatsToShorts(float[] floats) { short[] shorts = new short[floats.length]; - for (int i = 0; i < floats.length; ++i) { - shorts[i] = Float.valueOf(floats[i]).shortValue(); + for (int i = 0; i < floats.length; i++) { + shorts[i] = ((Float) floats[i]).shortValue(); } return shorts; } public static float[] shortsToFloats(short[] shorts) { float[] floats = new float[shorts.length]; - for (int i = 0; i < shorts.length; ++i) { - floats[i] = Short.valueOf(shorts[i]).floatValue(); + for (int i = 0; i < shorts.length; i++) { + floats[i] = ((Short) shorts[i]).floatValue(); } return floats; } public static byte[] floatsToBytes(float[] floats) { byte[] bytes = new byte[floats.length * 2]; - for (int i = 0; i < floats.length; ++i) { - short x = Float.valueOf(floats[i]).shortValue(); - bytes[i * 2] = (byte)(x & 0xFF); - bytes[i * 2 + 1] = (byte)((x & 0xFF00) >> 8); + for (int i = 0; i < floats.length; i++) { + short x = ((Float) floats[i]).shortValue(); + bytes[i * 2] = (byte) (x & 0x00FF); + bytes[i * 2 + 1] = (byte) ((x & 0xFF00) >> 8); } return bytes; } public static float[] bytesToFloats(byte[] bytes) { float[] floats = new float[bytes.length / 2]; - for (int i = 0; i < bytes.length / 2; ++i) { - floats[i] = (bytes[i * 2 + 1] & 0x80) != 0 ? (float)(Short.MIN_VALUE + ((bytes[i * 2 + 1] & 0x7F) << 8) | bytes[i * 2] & 0xFF) : (float)(bytes[i * 2 + 1] << 8 & 0xFF00 | bytes[i * 2] & 0xFF); + for (int i = 0; i < bytes.length / 2; i++) { + if ((bytes[i * 2 + 1] & 0x80) != 0) { + floats[i] = Short.MIN_VALUE + ((bytes[i * 2 + 1] & 0x7F) << 8) | (bytes[i * 2] & 0xFF); + } else { + floats[i] = ((bytes[i * 2 + 1] << 8) & 0xFF00) | (bytes[i * 2] & 0xFF); + } } return floats; } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/AuthenticateAckPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AuthenticateAckPacket.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/AuthenticateAckPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AuthenticateAckPacket.java index 84130fb..567c4e2 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/AuthenticateAckPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AuthenticateAckPacket.java @@ -1,13 +1,13 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; -public class AuthenticateAckPacket -implements Packet { +public class AuthenticateAckPacket implements Packet { + + public AuthenticateAckPacket() { + + } + @Override public AuthenticateAckPacket fromBytes(FriendlyByteBuf buf) { return new AuthenticateAckPacket(); @@ -15,6 +15,6 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { + } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/AuthenticatePacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AuthenticatePacket.java similarity index 69% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/AuthenticatePacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AuthenticatePacket.java index aaa9d50..a050231 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/AuthenticatePacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/AuthenticatePacket.java @@ -1,15 +1,11 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; -import de.maxhenkel.voicechat.voice.common.Secret; + import java.util.UUID; -public class AuthenticatePacket -implements Packet { +public class AuthenticatePacket implements Packet { + private UUID playerUUID; private Secret secret; @@ -19,14 +15,15 @@ implements Packet { } public AuthenticatePacket() { + } public UUID getPlayerUUID() { - return this.playerUUID; + return playerUUID; } public Secret getSecret() { - return this.secret; + return secret; } @Override @@ -39,8 +36,7 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.playerUUID); - this.secret.toBytes(buf); + buf.writeUUID(playerUUID); + secret.toBytes(buf); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/ClientGroup.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ClientGroup.java similarity index 66% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/ClientGroup.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ClientGroup.java index 73fbb25..aa0ea62 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/ClientGroup.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ClientGroup.java @@ -1,23 +1,22 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.plugins.impl.GroupImpl; import de.maxhenkel.voicechat.util.FriendlyByteBuf; + import java.util.Objects; import java.util.UUID; public class ClientGroup { + private final UUID id; private final String name; private final boolean hasPassword; private final boolean persistent; private final boolean hidden; - private final Group.Type type; + private final de.maxhenkel.voicechat.api.Group.Type type; - public ClientGroup(UUID id, String name, boolean hasPassword, boolean persistent, boolean hidden, Group.Type type) { + public ClientGroup(UUID id, String name, boolean hasPassword, boolean persistent, boolean hidden, de.maxhenkel.voicechat.api.Group.Type type) { this.id = id; this.name = name; this.hasPassword = hasPassword; @@ -27,27 +26,27 @@ public class ClientGroup { } public UUID getId() { - return this.id; + return id; } public String getName() { - return this.name; + return name; } public boolean hasPassword() { - return this.hasPassword; + return hasPassword; } public boolean isPersistent() { - return this.persistent; + return persistent; } public boolean isHidden() { - return this.hidden; + return hidden; } public Group.Type getType() { - return this.type; + return type; } public static ClientGroup fromBytes(FriendlyByteBuf buf) { @@ -55,23 +54,25 @@ public class ClientGroup { } public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.id); - buf.writeUtf(this.name, 512); - buf.writeBoolean(this.hasPassword); - buf.writeBoolean(this.persistent); - buf.writeBoolean(this.hidden); - buf.writeShort(GroupImpl.TypeImpl.toInt(this.type)); + buf.writeUUID(id); + buf.writeUtf(name, 512); + buf.writeBoolean(hasPassword); + buf.writeBoolean(persistent); + buf.writeBoolean(hidden); + buf.writeShort(GroupImpl.TypeImpl.toInt(type)); } + @Override public boolean equals(Object o) { if (this == o) { return true; } - if (o == null || this.getClass() != o.getClass()) { + if (o == null || getClass() != o.getClass()) { return false; } - ClientGroup group = (ClientGroup)o; - return Objects.equals(this.id, group.id); - } -} + ClientGroup group = (ClientGroup) o; + + return Objects.equals(id, group.id); + } +} \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/ConnectionCheckAckPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ConnectionCheckAckPacket.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/ConnectionCheckAckPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ConnectionCheckAckPacket.java index ba645a7..4181a43 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/ConnectionCheckAckPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ConnectionCheckAckPacket.java @@ -1,13 +1,13 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; -public class ConnectionCheckAckPacket -implements Packet { +public class ConnectionCheckAckPacket implements Packet { + + public ConnectionCheckAckPacket() { + + } + @Override public ConnectionCheckAckPacket fromBytes(FriendlyByteBuf buf) { return new ConnectionCheckAckPacket(); @@ -15,6 +15,6 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { + } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/ConnectionCheckPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ConnectionCheckPacket.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/ConnectionCheckPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ConnectionCheckPacket.java index dc2aa61..46a3834 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/ConnectionCheckPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/ConnectionCheckPacket.java @@ -1,13 +1,13 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; -public class ConnectionCheckPacket -implements Packet { +public class ConnectionCheckPacket implements Packet { + + public ConnectionCheckPacket() { + + } + @Override public ConnectionCheckPacket fromBytes(FriendlyByteBuf buf) { return new ConnectionCheckPacket(); @@ -15,6 +15,6 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { + } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/GroupSoundPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/GroupSoundPacket.java similarity index 57% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/GroupSoundPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/GroupSoundPacket.java index 1aa2505..13f2ddc 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/GroupSoundPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/GroupSoundPacket.java @@ -1,23 +1,18 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.SoundPacket; -import java.util.UUID; -import javax.annotation.Nullable; -public class GroupSoundPacket -extends SoundPacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class GroupSoundPacket extends SoundPacket { + public GroupSoundPacket(UUID channelId, UUID sender, byte[] data, long sequenceNumber, @Nullable String category) { super(channelId, sender, data, sequenceNumber, category); } public GroupSoundPacket() { + } @Override @@ -25,10 +20,11 @@ extends SoundPacket { GroupSoundPacket soundPacket = new GroupSoundPacket(); soundPacket.channelId = buf.readUUID(); soundPacket.sender = buf.readUUID(); - soundPacket.data = buf.readByteArray(1275); + soundPacket.data = buf.readByteArray(AudioUtils.MAX_OPUS_PAYLOAD_SIZE); soundPacket.sequenceNumber = buf.readLong(); + byte data = buf.readByte(); - if (this.hasFlag(data, (byte)2)) { + if (hasFlag(data, HAS_CATEGORY_MASK)) { soundPacket.category = buf.readUtf(16); } return soundPacket; @@ -36,18 +32,19 @@ extends SoundPacket { @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.channelId); - buf.writeUUID(this.sender); - buf.writeByteArray(this.data); - buf.writeLong(this.sequenceNumber); - byte data = 0; - if (this.category != null) { - data = this.setFlag(data, (byte)2); + buf.writeUUID(channelId); + buf.writeUUID(sender); + buf.writeByteArray(data); + buf.writeLong(sequenceNumber); + + byte data = 0b0; + if (category != null) { + data = setFlag(data, HAS_CATEGORY_MASK); } buf.writeByte(data); - if (this.category != null) { - buf.writeUtf(this.category, 16); + if (category != null) { + buf.writeUtf(category, 16); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/KeepAlivePacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/KeepAlivePacket.java similarity index 65% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/KeepAlivePacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/KeepAlivePacket.java index 5cadbd2..fe7ec27 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/KeepAlivePacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/KeepAlivePacket.java @@ -1,13 +1,13 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; -public class KeepAlivePacket -implements Packet { +public class KeepAlivePacket implements Packet { + + public KeepAlivePacket() { + + } + @Override public KeepAlivePacket fromBytes(FriendlyByteBuf buf) { return new KeepAlivePacket(); @@ -15,6 +15,6 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { + } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/LocationSoundPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/LocationSoundPacket.java similarity index 59% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/LocationSoundPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/LocationSoundPacket.java index 8054941..02820fa 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/LocationSoundPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/LocationSoundPacket.java @@ -1,20 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Location - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.SoundPacket; -import java.util.UUID; -import javax.annotation.Nullable; import org.bukkit.Location; -public class LocationSoundPacket -extends SoundPacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class LocationSoundPacket extends SoundPacket { + protected Location location; protected float distance; @@ -25,14 +18,15 @@ extends SoundPacket { } public LocationSoundPacket() { + } public Location getLocation() { - return this.location; + return location; } public float getDistance() { - return this.distance; + return distance; } @Override @@ -41,34 +35,36 @@ extends SoundPacket { soundPacket.channelId = buf.readUUID(); soundPacket.sender = buf.readUUID(); soundPacket.location = new Location(null, buf.readDouble(), buf.readDouble(), buf.readDouble()); - soundPacket.data = buf.readByteArray(1275); + soundPacket.data = buf.readByteArray(AudioUtils.MAX_OPUS_PAYLOAD_SIZE); soundPacket.sequenceNumber = buf.readLong(); soundPacket.distance = buf.readFloat(); + byte data = buf.readByte(); - if (this.hasFlag(data, (byte)2)) { + if (hasFlag(data, HAS_CATEGORY_MASK)) { soundPacket.category = buf.readUtf(16); } + return soundPacket; } @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.channelId); - buf.writeUUID(this.sender); - buf.writeDouble(this.location.getX()); - buf.writeDouble(this.location.getY()); - buf.writeDouble(this.location.getZ()); - buf.writeByteArray(this.data); - buf.writeLong(this.sequenceNumber); - buf.writeFloat(this.distance); - byte data = 0; - if (this.category != null) { - data = this.setFlag(data, (byte)2); + buf.writeUUID(channelId); + buf.writeUUID(sender); + buf.writeDouble(location.getX()); + buf.writeDouble(location.getY()); + buf.writeDouble(location.getZ()); + buf.writeByteArray(data); + buf.writeLong(sequenceNumber); + buf.writeFloat(distance); + + byte data = 0b0; + if (category != null) { + data = setFlag(data, HAS_CATEGORY_MASK); } buf.writeByte(data); - if (this.category != null) { - buf.writeUtf(this.category, 16); + if (category != null) { + buf.writeUtf(category, 16); } } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/MicPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/MicPacket.java similarity index 70% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/MicPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/MicPacket.java index 43e4096..6d3bae6 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/MicPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/MicPacket.java @@ -1,13 +1,9 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; -public class MicPacket -implements Packet { +public class MicPacket implements Packet { + private byte[] data; private boolean whispering; private long sequenceNumber; @@ -19,6 +15,7 @@ implements Packet { } public MicPacket() { + } @Override @@ -27,7 +24,7 @@ implements Packet { } public byte[] getData() { - return this.data; + return data; } public void setData(byte[] data) { @@ -35,17 +32,17 @@ implements Packet { } public long getSequenceNumber() { - return this.sequenceNumber; + return sequenceNumber; } public boolean isWhispering() { - return this.whispering; + return whispering; } @Override public MicPacket fromBytes(FriendlyByteBuf buf) { MicPacket soundPacket = new MicPacket(); - soundPacket.data = buf.readByteArray(1275); + soundPacket.data = buf.readByteArray(AudioUtils.MAX_OPUS_PAYLOAD_SIZE); soundPacket.sequenceNumber = buf.readLong(); soundPacket.whispering = buf.readBoolean(); return soundPacket; @@ -53,9 +50,8 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeByteArray(this.data); - buf.writeLong(this.sequenceNumber); - buf.writeBoolean(this.whispering); + buf.writeByteArray(data); + buf.writeLong(sequenceNumber); + buf.writeBoolean(whispering); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/NetworkMessage.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/NetworkMessage.java similarity index 64% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/NetworkMessage.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/NetworkMessage.java index 78537a8..4f5c2a1 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/NetworkMessage.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/NetworkMessage.java @@ -1,34 +1,19 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * io.netty.buffer.Unpooled - * io.netty.handler.codec.DecoderException - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.api.RawUdpPacket; import de.maxhenkel.voicechat.debug.PingHandler; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.AuthenticateAckPacket; -import de.maxhenkel.voicechat.voice.common.AuthenticatePacket; -import de.maxhenkel.voicechat.voice.common.ConnectionCheckAckPacket; -import de.maxhenkel.voicechat.voice.common.ConnectionCheckPacket; -import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; -import de.maxhenkel.voicechat.voice.common.KeepAlivePacket; -import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; -import de.maxhenkel.voicechat.voice.common.MicPacket; -import de.maxhenkel.voicechat.voice.common.Packet; -import de.maxhenkel.voicechat.voice.common.PingPacket; -import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; -import de.maxhenkel.voicechat.voice.common.Secret; import de.maxhenkel.voicechat.voice.server.ClientConnection; import de.maxhenkel.voicechat.voice.server.Server; import io.netty.buffer.Unpooled; import io.netty.handler.codec.DecoderException; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; import java.lang.reflect.InvocationTargetException; import java.net.SocketAddress; import java.security.InvalidAlgorithmParameterException; @@ -37,18 +22,14 @@ import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.UUID; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; public class NetworkMessage { - public static final byte MAGIC_BYTE = -1; + + public static final byte MAGIC_BYTE = (byte) 0b11111111; + private final long timestamp; private Packet packet; private SocketAddress address; - private static final Map> packetRegistry = new HashMap>(); public NetworkMessage(long timestamp, Packet packet) { this(timestamp); @@ -66,27 +47,43 @@ public class NetworkMessage { @Nonnull public Packet getPacket() { - return this.packet; + return packet; } public long getTimestamp() { - return this.timestamp; + return timestamp; } public long getTTL() { - return this.packet.getTTL(); + return packet.getTTL(); } public SocketAddress getAddress() { - return this.address; + return address; + } + + private static final Map> packetRegistry; + + static { + packetRegistry = new HashMap<>(); + packetRegistry.put((byte) 0x1, MicPacket.class); + packetRegistry.put((byte) 0x2, PlayerSoundPacket.class); + packetRegistry.put((byte) 0x3, GroupSoundPacket.class); + packetRegistry.put((byte) 0x4, LocationSoundPacket.class); + packetRegistry.put((byte) 0x5, AuthenticatePacket.class); + packetRegistry.put((byte) 0x6, AuthenticateAckPacket.class); + packetRegistry.put((byte) 0x7, PingPacket.class); + packetRegistry.put((byte) 0x8, KeepAlivePacket.class); + packetRegistry.put((byte) 0x9, ConnectionCheckPacket.class); + packetRegistry.put((byte) 0xA, ConnectionCheckAckPacket.class); } @Nullable public static NetworkMessage readPacketServer(RawUdpPacket packet, Server server) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException { try { byte[] data = packet.getData(); - FriendlyByteBuf b = new FriendlyByteBuf(Unpooled.wrappedBuffer((byte[])data)); - if (b.readByte() != -1) { + FriendlyByteBuf b = new FriendlyByteBuf(Unpooled.wrappedBuffer(data)); + if (b.readByte() != MAGIC_BYTE) { Voicechat.LOGGER.debug("Received invalid packet from {}", packet.getSocketAddress()); return null; } @@ -95,12 +92,12 @@ public class NetworkMessage { if (PingHandler.onPacket(server, packet.getSocketAddress(), playerID, b)) { return null; } + // Ignore packets if they are not from a player that has a secret Voicechat.LOGGER.debug("Player {} does not have a secret", playerID); return null; } - return NetworkMessage.readFromBytes(packet.getSocketAddress(), server.getSecret(playerID), b.readByteArray(2048), packet.getTimestamp()); - } - catch (DecoderException | IndexOutOfBoundsException e) { + return readFromBytes(packet.getSocketAddress(), server.getSecret(playerID), b.readByteArray(Utils.MAX_VOICE_CHAT_PACKET_SIZE), packet.getTimestamp()); + } catch (DecoderException | IndexOutOfBoundsException e) { Voicechat.LOGGER.debug("Received invalid packet from {}", packet.getSocketAddress()); return null; } @@ -111,38 +108,42 @@ public class NetworkMessage { byte[] decrypt; try { decrypt = secret.decrypt(encryptedPayload); - } - catch (Exception e) { + } catch (Exception e) { + // Return null if the encryption fails due to a wrong secret Voicechat.LOGGER.debug("Failed to decrypt packet from {}", socketAddress); return null; } - FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer((byte[])decrypt)); + FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer(decrypt)); byte packetType = buffer.readByte(); Class packetClass = packetRegistry.get(packetType); if (packetClass == null) { Voicechat.LOGGER.debug("Got invalid packet ID {}", packetType); return null; } - Packet p = packetClass.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); + Packet> p = packetClass.getDeclaredConstructor().newInstance(); + NetworkMessage message = new NetworkMessage(timestamp); message.address = socketAddress; message.packet = p.fromBytes(buffer); + return message; } private static byte getPacketType(Packet packet) { for (Map.Entry> entry : packetRegistry.entrySet()) { - if (!packet.getClass().equals(entry.getValue())) continue; - return entry.getKey(); + if (packet.getClass().equals(entry.getValue())) { + return entry.getKey(); + } } return -1; } public byte[] writeServer(Server server, ClientConnection connection) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { - byte[] payload = this.write(server.getSecret(connection.getPlayerUUID())); - FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer((int)(1 + payload.length))); - buffer.writeByte(-1); + byte[] payload = write(server.getSecret(connection.getPlayerUUID())); + FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer(1 + payload.length)); + buffer.writeByte(MAGIC_BYTE); buffer.writeByteArray(payload); + byte[] bytes = new byte[buffer.readableBytes()]; buffer.readBytes(bytes); return bytes; @@ -150,26 +151,16 @@ public class NetworkMessage { public byte[] write(Secret secret) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer()); - byte type = NetworkMessage.getPacketType(this.packet); + + byte type = getPacketType(packet); if (type < 0) { throw new IllegalArgumentException("Packet type not found"); } + buffer.writeByte(type); - this.packet.toBytes(buffer); + packet.toBytes(buffer); + return secret.encrypt(buffer.array()); } - static { - packetRegistry.put((byte)1, MicPacket.class); - packetRegistry.put((byte)2, PlayerSoundPacket.class); - packetRegistry.put((byte)3, GroupSoundPacket.class); - packetRegistry.put((byte)4, LocationSoundPacket.class); - packetRegistry.put((byte)5, AuthenticatePacket.class); - packetRegistry.put((byte)6, AuthenticateAckPacket.class); - packetRegistry.put((byte)7, PingPacket.class); - packetRegistry.put((byte)8, KeepAlivePacket.class); - packetRegistry.put((byte)9, ConnectionCheckPacket.class); - packetRegistry.put((byte)10, ConnectionCheckAckPacket.class); - } } - diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Packet.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Packet.java new file mode 100644 index 0000000..2d88e9c --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Packet.java @@ -0,0 +1,15 @@ +package de.maxhenkel.voicechat.voice.common; + +import de.maxhenkel.voicechat.util.FriendlyByteBuf; + +public interface Packet { + + T fromBytes(FriendlyByteBuf buf); + + void toBytes(FriendlyByteBuf buf); + + default long getTTL() { + return 10_000L; + } + +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/PingPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PingPacket.java similarity index 72% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/PingPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PingPacket.java index 35912b8..eb92b8b 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/PingPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PingPacket.java @@ -1,14 +1,11 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.Packet; + import java.util.UUID; -public class PingPacket -implements Packet { +public class PingPacket implements Packet { + private UUID id; private long timestamp; @@ -18,14 +15,15 @@ implements Packet { } public PingPacket() { + } public long getTimestamp() { - return this.timestamp; + return timestamp; } public UUID getId() { - return this.id; + return id; } @Override @@ -38,8 +36,7 @@ implements Packet { @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.id); - buf.writeLong(this.timestamp); + buf.writeUUID(id); + buf.writeLong(timestamp); } } - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/PlayerSoundPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PlayerSoundPacket.java similarity index 56% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/PlayerSoundPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PlayerSoundPacket.java index 116c09e..06230e4 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/PlayerSoundPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PlayerSoundPacket.java @@ -1,18 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.voice.common.SoundPacket; -import java.util.UUID; -import javax.annotation.Nullable; -public class PlayerSoundPacket -extends SoundPacket { +import javax.annotation.Nullable; +import java.util.UUID; + +public class PlayerSoundPacket extends SoundPacket { + + // TODO Add a separate entity UUID instead of using the sender as the entity when breaking network compatibility protected boolean whispering; protected float distance; @@ -23,19 +18,19 @@ extends SoundPacket { } public PlayerSoundPacket() { + } - @Override public UUID getSender() { - return this.sender; + return sender; } public boolean isWhispering() { - return this.whispering; + return whispering; } public float getDistance() { - return this.distance; + return distance; } @Override @@ -43,12 +38,13 @@ extends SoundPacket { PlayerSoundPacket soundPacket = new PlayerSoundPacket(); soundPacket.channelId = buf.readUUID(); soundPacket.sender = buf.readUUID(); - soundPacket.data = buf.readByteArray(1275); + soundPacket.data = buf.readByteArray(AudioUtils.MAX_OPUS_PAYLOAD_SIZE); soundPacket.sequenceNumber = buf.readLong(); soundPacket.distance = buf.readFloat(); + byte data = buf.readByte(); - soundPacket.whispering = this.hasFlag(data, (byte)1); - if (this.hasFlag(data, (byte)2)) { + soundPacket.whispering = hasFlag(data, WHISPER_MASK); + if (hasFlag(data, HAS_CATEGORY_MASK)) { soundPacket.category = buf.readUtf(16); } return soundPacket; @@ -56,22 +52,23 @@ extends SoundPacket { @Override public void toBytes(FriendlyByteBuf buf) { - buf.writeUUID(this.channelId); - buf.writeUUID(this.sender); - buf.writeByteArray(this.data); - buf.writeLong(this.sequenceNumber); - buf.writeFloat(this.distance); - byte data = 0; - if (this.whispering) { - data = this.setFlag(data, (byte)1); + buf.writeUUID(channelId); + buf.writeUUID(sender); + buf.writeByteArray(data); + buf.writeLong(sequenceNumber); + buf.writeFloat(distance); + + byte data = 0b0; + if (whispering) { + data = setFlag(data, WHISPER_MASK); } - if (this.category != null) { - data = this.setFlag(data, (byte)2); + if (category != null) { + data = setFlag(data, HAS_CATEGORY_MASK); } buf.writeByte(data); - if (this.category != null) { - buf.writeUtf(this.category, 16); + if (category != null) { + buf.writeUtf(category, 16); } } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/PlayerState.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PlayerState.java similarity index 69% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/PlayerState.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PlayerState.java index 97ea9b9..21b9248 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/PlayerState.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/PlayerState.java @@ -1,16 +1,12 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import java.util.UUID; + import javax.annotation.Nullable; +import java.util.UUID; public class PlayerState { + private UUID uuid; private String name; private boolean disabled; @@ -26,7 +22,7 @@ public class PlayerState { } public UUID getUuid() { - return this.uuid; + return uuid; } public void setUuid(UUID uuid) { @@ -34,7 +30,7 @@ public class PlayerState { } public String getName() { - return this.name; + return name; } public void setName(String name) { @@ -42,7 +38,7 @@ public class PlayerState { } public boolean isDisabled() { - return this.disabled; + return disabled; } public void setDisabled(boolean disabled) { @@ -50,7 +46,7 @@ public class PlayerState { } public boolean isDisconnected() { - return this.disconnected; + return disconnected; } public void setDisconnected(boolean disconnected) { @@ -59,7 +55,7 @@ public class PlayerState { @Nullable public UUID getGroup() { - return this.group; + return group; } public void setGroup(@Nullable UUID group) { @@ -67,34 +63,44 @@ public class PlayerState { } public boolean hasGroup() { - return this.group != null; + return group != null; } + @Override public String toString() { - return "{disabled=" + this.disabled + ", disconnected=" + this.disconnected + ", uuid=" + this.uuid + ", name=" + this.name + ", group=" + this.group + '}'; + return "{" + + "disabled=" + disabled + + ", disconnected=" + disconnected + + ", uuid=" + uuid + + ", name=" + name + + ", group=" + group + + '}'; } public static PlayerState fromBytes(FriendlyByteBuf buf) { boolean disabled = buf.readBoolean(); boolean disconnected = buf.readBoolean(); UUID uuid = buf.readUUID(); - String name = buf.readUtf(Short.MAX_VALUE); + String name = buf.readUtf(32767); + PlayerState state = new PlayerState(uuid, name, disabled, disconnected); + if (buf.readBoolean()) { state.setGroup(buf.readUUID()); } + return state; } public void toBytes(FriendlyByteBuf buf) { - buf.writeBoolean(this.disabled); - buf.writeBoolean(this.disconnected); - buf.writeUUID(this.uuid); - buf.writeUtf(this.name); - buf.writeBoolean(this.hasGroup()); - if (this.hasGroup()) { - buf.writeUUID(this.group); + buf.writeBoolean(disabled); + buf.writeBoolean(disconnected); + buf.writeUUID(uuid); + buf.writeUtf(name); + buf.writeBoolean(hasGroup()); + if (hasGroup()) { + buf.writeUUID(group); } } -} +} diff --git a/source/patch/de/maxhenkel/voicechat/voice/common/Secret.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Secret.java similarity index 84% rename from source/patch/de/maxhenkel/voicechat/voice/common/Secret.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Secret.java index 9c3e451..f4de0ff 100644 --- a/source/patch/de/maxhenkel/voicechat/voice/common/Secret.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Secret.java @@ -1,12 +1,7 @@ package de.maxhenkel.voicechat.voice.common; import io.netty.buffer.ByteBuf; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.Arrays; + import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; @@ -14,13 +9,21 @@ import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.util.Arrays; public class Secret { public static final int SECRET_SIZE_BYTES = 16; public static final int IV_SIZE_BYTES = 12; public static final int TAG_LEN_BITS = 128; public static final String CIPHER = "AES/GCM/NoPadding"; + private static final SecureRandom RANDOM = new SecureRandom(); + private final byte[] secret; private final SecretKeySpec keySpec; private volatile boolean legacyProtocol; @@ -50,15 +53,15 @@ public class Secret { } public void toBytes(ByteBuf buf) { - buf.writeBytes(this.secret); + buf.writeBytes(secret); } public byte[] getSecret() { - return this.secret.clone(); + return secret.clone(); } public SecretKeySpec getKeySpec() { - return this.keySpec; + return keySpec; } public void setLegacyProtocol(boolean legacyProtocol) { @@ -66,7 +69,7 @@ public class Secret { } public boolean isLegacyProtocol() { - return this.legacyProtocol; + return legacyProtocol; } public static byte[] generateIV() { @@ -83,19 +86,20 @@ public class Secret { public byte[] encrypt(byte[] data) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - if (this.legacyProtocol) { - byte[] iv = Secret.generateLegacyIV(); + if (legacyProtocol) { + byte[] iv = generateLegacyIV(); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.ENCRYPT_MODE, (Key) this.keySpec, new IvParameterSpec(iv)); + cipher.init(Cipher.ENCRYPT_MODE, (Key) keySpec, new IvParameterSpec(iv)); byte[] encrypted = cipher.doFinal(data); byte[] payload = new byte[iv.length + encrypted.length]; System.arraycopy(iv, 0, payload, 0, iv.length); System.arraycopy(encrypted, 0, payload, iv.length, encrypted.length); return payload; } - byte[] iv = Secret.generateIV(); + + byte[] iv = generateIV(); Cipher cipher = Cipher.getInstance(CIPHER); - cipher.init(Cipher.ENCRYPT_MODE, (Key) this.keySpec, new GCMParameterSpec(TAG_LEN_BITS, iv)); + cipher.init(Cipher.ENCRYPT_MODE, (Key) keySpec, new GCMParameterSpec(TAG_LEN_BITS, iv)); byte[] encrypted = cipher.doFinal(data); byte[] payload = new byte[iv.length + encrypted.length]; System.arraycopy(iv, 0, payload, 0, iv.length); @@ -105,33 +109,34 @@ public class Secret { public byte[] decrypt(byte[] payload) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - if (this.legacyProtocol) { + if (legacyProtocol) { if (payload.length < 32 || (payload.length - 16) % 16 != 0) { throw new IllegalBlockSizeException("Invalid legacy AES-CBC packet size"); } byte[] iv = Arrays.copyOfRange(payload, 0, 16); byte[] encrypted = Arrays.copyOfRange(payload, 16, payload.length); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(Cipher.DECRYPT_MODE, (Key) this.keySpec, new IvParameterSpec(iv)); + cipher.init(Cipher.DECRYPT_MODE, (Key) keySpec, new IvParameterSpec(iv)); return cipher.doFinal(encrypted); } + if (payload.length < IV_SIZE_BYTES + 16) { throw new IllegalBlockSizeException("Invalid AES-GCM packet size"); } byte[] iv = Arrays.copyOfRange(payload, 0, IV_SIZE_BYTES); byte[] encrypted = Arrays.copyOfRange(payload, IV_SIZE_BYTES, payload.length); Cipher cipher = Cipher.getInstance(CIPHER); - cipher.init(Cipher.DECRYPT_MODE, (Key) this.keySpec, new GCMParameterSpec(TAG_LEN_BITS, iv)); + cipher.init(Cipher.DECRYPT_MODE, (Key) keySpec, new GCMParameterSpec(TAG_LEN_BITS, iv)); return cipher.doFinal(encrypted); } @Override public boolean equals(Object o) { - return o instanceof Secret && Arrays.equals(this.secret, ((Secret) o).secret); + return o instanceof Secret && Arrays.equals(secret, ((Secret) o).secret); } @Override public int hashCode() { - return Arrays.hashCode(this.secret); + return Arrays.hashCode(secret); } } diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/SoundPacket.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/SoundPacket.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/SoundPacket.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/SoundPacket.java index 0b2b432..8e9d360 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/SoundPacket.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/SoundPacket.java @@ -1,19 +1,13 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.voice.common; -import de.maxhenkel.voicechat.voice.common.Packet; -import java.util.UUID; import javax.annotation.Nullable; +import java.util.UUID; + +public abstract class SoundPacket implements Packet { + + public static final byte WHISPER_MASK = 0b1; + public static final byte HAS_CATEGORY_MASK = 0b10; -public abstract class SoundPacket -implements Packet { - public static final byte WHISPER_MASK = 1; - public static final byte HAS_CATEGORY_MASK = 2; protected UUID channelId; protected UUID sender; protected byte[] data; @@ -30,35 +24,36 @@ implements Packet { } public SoundPacket() { + } public UUID getChannelId() { - return this.channelId; + return channelId; } public UUID getSender() { - return this.sender; + return sender; } public byte[] getData() { - return this.data; + return data; } public long getSequenceNumber() { - return this.sequenceNumber; + return sequenceNumber; } @Nullable public String getCategory() { - return this.category; + return category; } protected boolean hasFlag(byte data, byte mask) { - return (data & mask) != 0; + return (data & mask) != 0b0; } protected byte setFlag(byte data, byte mask) { - return (byte)(data | mask); + return (byte) (data | mask); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/Utils.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Utils.java similarity index 72% rename from source/decompiled/de/maxhenkel/voicechat/voice/common/Utils.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Utils.java index 4bdd798..68760f1 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/Utils.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/common/Utils.java @@ -1,15 +1,18 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.common; import de.maxhenkel.voicechat.Voicechat; public class Utils { + public static final int MAX_VOICE_CHAT_PACKET_SIZE = 2048; + /** + * Gets the default voice chat distance + * + * @return the default voice chat distance + */ public static float getDefaultDistance() { return Voicechat.SERVER_CONFIG.voiceChatDistance.get().floatValue(); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/ClientConnection.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ClientConnection.java similarity index 81% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/ClientConnection.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ClientConnection.java index f5b70b8..b8aa19e 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/ClientConnection.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ClientConnection.java @@ -1,14 +1,12 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.server; import de.maxhenkel.voicechat.voice.common.NetworkMessage; -import de.maxhenkel.voicechat.voice.server.Server; + import java.net.SocketAddress; import java.util.UUID; public class ClientConnection { + private UUID playerUUID; private SocketAddress address; private long lastKeepAliveResponse; @@ -20,15 +18,15 @@ public class ClientConnection { } public UUID getPlayerUUID() { - return this.playerUUID; + return playerUUID; } public SocketAddress getAddress() { - return this.address; + return address; } public long getLastKeepAliveResponse() { - return this.lastKeepAliveResponse; + return lastKeepAliveResponse; } public void setLastKeepAliveResponse(long lastKeepAliveResponse) { @@ -36,7 +34,7 @@ public class ClientConnection { } public void send(Server server, NetworkMessage message) throws Exception { - server.getSocket().send(message.writeServer(server, this), this.address); + server.getSocket().send(message.writeServer(server, this), address); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/Group.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/Group.java similarity index 62% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/Group.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/Group.java index d0ea554..84e7a67 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/Group.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/Group.java @@ -1,26 +1,21 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ package de.maxhenkel.voicechat.voice.server; -import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.voice.common.ClientGroup; -import java.util.UUID; + import javax.annotation.Nullable; +import java.util.UUID; public class Group { + private UUID id; private String name; @Nullable private String password; private boolean persistent; private boolean hidden; - private Group.Type type; + private de.maxhenkel.voicechat.api.Group.Type type; - public Group(UUID id, String name, @Nullable String password, boolean persistent, boolean hidden, Group.Type type) { + public Group(UUID id, String name, @Nullable String password, boolean persistent, boolean hidden, de.maxhenkel.voicechat.api.Group.Type type) { this.id = id; this.name = name; this.password = password; @@ -30,7 +25,7 @@ public class Group { } public Group(UUID id, String name, @Nullable String password, boolean persistent) { - this(id, name, password, persistent, false, Group.Type.NORMAL); + this(id, name, password, persistent, false, de.maxhenkel.voicechat.api.Group.Type.NORMAL); } public Group(UUID id, String name, @Nullable String password) { @@ -42,47 +37,48 @@ public class Group { } public Group() { + } public UUID getId() { - return this.id; + return id; } public String getName() { - return this.name; + return name; } @Nullable public String getPassword() { - return this.password; + return password; } public boolean isPersistent() { - return this.persistent; + return persistent; } public boolean isHidden() { - return this.hidden; + return hidden; } - public Group.Type getType() { - return this.type; + public de.maxhenkel.voicechat.api.Group.Type getType() { + return type; } public boolean isOpen() { - return this.type == Group.Type.OPEN; + return type == de.maxhenkel.voicechat.api.Group.Type.OPEN; } public boolean isNormal() { - return this.type == Group.Type.NORMAL; + return type == de.maxhenkel.voicechat.api.Group.Type.NORMAL; } public boolean isIsolated() { - return this.type == Group.Type.ISOLATED; + return type == de.maxhenkel.voicechat.api.Group.Type.ISOLATED; } public ClientGroup toClientGroup() { - return new ClientGroup(this.id, this.name, this.password != null, this.persistent, this.hidden, this.type); + return new ClientGroup(id, name, password != null, persistent, hidden, type); } -} +} \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/PingManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/PingManager.java similarity index 53% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/PingManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/PingManager.java index ac0a70e..1265c55 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/PingManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/PingManager.java @@ -1,12 +1,8 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat.voice.server; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.voice.common.PingPacket; -import de.maxhenkel.voicechat.voice.server.ClientConnection; -import de.maxhenkel.voicechat.voice.server.Server; + import java.util.List; import java.util.Map; import java.util.UUID; @@ -14,17 +10,18 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; public class PingManager { + private final Map listeners; private final Server server; public PingManager(Server server) { this.server = server; - this.listeners = new ConcurrentHashMap(); + listeners = new ConcurrentHashMap<>(); } public void onPongPacket(PingPacket packet) { Voicechat.LOGGER.info("Received pong {}", packet.getId()); - Ping ping = this.listeners.remove(packet.getId()); + Ping ping = listeners.remove(packet.getId()); if (ping == null) { return; } @@ -32,36 +29,35 @@ public class PingManager { } public void checkTimeouts() { - if (this.listeners.isEmpty()) { + if (listeners.isEmpty()) { return; } - List timedOut = this.listeners.entrySet().stream().filter(uuidPingEntry -> ((Ping)uuidPingEntry.getValue()).isTimedOut()).collect(Collectors.toList()); - for (Map.Entry pingEntry : timedOut) { - Ping ping = (Ping)pingEntry.getValue(); + List> timedOut = listeners.entrySet().stream().filter(uuidPingEntry -> uuidPingEntry.getValue().isTimedOut()).collect(Collectors.toList()); + for (Map.Entry pingEntry : timedOut) { + Ping ping = pingEntry.getValue(); if (ping.attempt >= ping.maxAttempts) { - this.listeners.remove(pingEntry.getKey()); + listeners.remove(pingEntry.getKey()); ping.listener.onTimeout(ping.attempt); - continue; - } - ping.listener.onFailedAttempt(ping.attempt); - try { - ping.send(); - } - catch (Exception e) { - ping.listener.onTimeout(ping.attempt); - Voicechat.LOGGER.warn("Failed to send ping {} after attempt {}", ping.id, ping.attempt); + } else { + ping.listener.onFailedAttempt(ping.attempt); + try { + ping.send(); + } catch (Exception e) { + ping.listener.onTimeout(ping.attempt); + Voicechat.LOGGER.warn("Failed to send ping {} after attempt {}", ping.id, ping.attempt); + } } } } public void sendPing(ClientConnection connection, long timeout, int attempts, PingListener listener) throws Exception { Ping ping = new Ping(connection, listener, timeout, attempts); - this.listeners.put(ping.id, ping); + listeners.put(ping.id, ping); ping.send(); } private class Ping { - private final UUID id = UUID.randomUUID(); + private final UUID id; private final ClientConnection connection; private final PingListener listener; private long timestamp; @@ -70,6 +66,7 @@ public class PingManager { private int attempt; public Ping(ClientConnection connection, PingListener listener, long timeout, int maxAttempts) { + this.id = UUID.randomUUID(); this.connection = connection; this.listener = listener; this.timeout = timeout; @@ -78,23 +75,23 @@ public class PingManager { } public boolean isTimedOut() { - return System.currentTimeMillis() - this.timestamp >= this.timeout; + return (System.currentTimeMillis() - timestamp) >= timeout; } public void send() throws Exception { - this.timestamp = System.currentTimeMillis(); - ++this.attempt; - PingManager.this.server.sendPacketRaw(new PingPacket(this.id, this.timestamp), this.connection); - Voicechat.LOGGER.info("Sent ping {} attempt {}", this.id, this.attempt); + timestamp = System.currentTimeMillis(); + attempt++; + server.sendPacketRaw(new PingPacket(id, timestamp), connection); + Voicechat.LOGGER.info("Sent ping {} attempt {}", id, attempt); } } - public static interface PingListener { - public void onPong(int var1, long var2); + public interface PingListener { + void onPong(int attempts, long pingMilliseconds); - public void onFailedAttempt(int var1); + void onFailedAttempt(int attempts); - public void onTimeout(int var1); + void onTimeout(int attempts); } -} +} \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/PlayerStateManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/PlayerStateManager.java similarity index 63% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/PlayerStateManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/PlayerStateManager.java index e64af4d..2cc4d1f 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/PlayerStateManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/PlayerStateManager.java @@ -1,62 +1,57 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - * org.bukkit.entity.Player - * org.bukkit.event.Listener - * org.bukkit.event.player.PlayerJoinEvent - * org.bukkit.event.player.PlayerQuitEvent - */ package de.maxhenkel.voicechat.voice.server; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.compatibility.PlayerHideEvent; import de.maxhenkel.voicechat.compatibility.PlayerShowEvent; -import de.maxhenkel.voicechat.net.NetManager; -import de.maxhenkel.voicechat.net.PlayerStatePacket; -import de.maxhenkel.voicechat.net.PlayerStatesPacket; -import de.maxhenkel.voicechat.net.RemovePlayerStatePacket; -import de.maxhenkel.voicechat.net.UpdateStatePacket; +import de.maxhenkel.voicechat.net.*; import de.maxhenkel.voicechat.plugins.PluginManager; import de.maxhenkel.voicechat.voice.common.PlayerState; -import java.util.ArrayList; -import java.util.Collection; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import javax.annotation.Nullable; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -public class PlayerStateManager -implements Listener { - private final ConcurrentHashMap states = new ConcurrentHashMap(); +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +public class PlayerStateManager implements Listener { + + private final ConcurrentHashMap states; + + public PlayerStateManager() { + this.states = new ConcurrentHashMap<>(); + } public void onUpdateStatePacket(Player player, UpdateStatePacket packet) { - PlayerState state = this.states.get(player.getUniqueId()); + PlayerState state = states.get(player.getUniqueId()); + if (state == null) { - state = PlayerStateManager.defaultDisconnectedState(player); + state = defaultDisconnectedState(player); } + state.setDisabled(packet.isDisabled()); - this.states.put(player.getUniqueId(), state); - this.broadcastState(player, state); + + states.put(player.getUniqueId(), state); + + broadcastState(player, state); Voicechat.LOGGER.debug("Got state of {}: {}", player.getName(), state); } public void onPlayerQuit(PlayerQuitEvent event) { - this.states.remove(event.getPlayer().getUniqueId()); - this.broadcastRemoveState(event.getPlayer()); + states.remove(event.getPlayer().getUniqueId()); + broadcastRemoveState(event.getPlayer()); Voicechat.LOGGER.debug("Removing state of {}", event.getPlayer().getName()); } public void onPlayerJoin(PlayerJoinEvent event) { - PlayerState state = PlayerStateManager.defaultDisconnectedState(event.getPlayer()); - this.states.put(event.getPlayer().getUniqueId(), state); - this.broadcastState(event.getPlayer(), state); + PlayerState state = defaultDisconnectedState(event.getPlayer()); + states.put(event.getPlayer().getUniqueId(), state); + broadcastState(event.getPlayer(), state); Voicechat.LOGGER.debug("Setting default state of {}: {}", event.getPlayer().getName(), state); } @@ -67,9 +62,9 @@ implements Listener { } public void onPlayerShow(PlayerShowEvent event) { - PlayerState state = this.states.get(event.getShownPlayer().getUniqueId()); + PlayerState state = states.get(event.getShownPlayer().getUniqueId()); if (state == null) { - state = PlayerStateManager.defaultDisconnectedState(event.getShownPlayer()); + state = defaultDisconnectedState(event.getShownPlayer()); } PlayerStatePacket packet = new PlayerStatePacket(state); NetManager.sendToClient(event.getObserver(), packet); @@ -79,7 +74,9 @@ implements Listener { public void broadcastState(@Nullable Player stateOwner, PlayerState state) { PlayerStatePacket packet = new PlayerStatePacket(state); for (Player receiver : Voicechat.INSTANCE.getServer().getOnlinePlayers()) { - if (stateOwner != null && !Voicechat.compatibility.canSee(receiver, stateOwner)) continue; + if (stateOwner != null && !Voicechat.compatibility.canSee(receiver, stateOwner)) { + continue; + } NetManager.sendToClient(receiver, packet); } PluginManager.instance().onPlayerStateChanged(state); @@ -90,14 +87,20 @@ implements Listener { for (Player receiver : Voicechat.INSTANCE.getServer().getOnlinePlayers()) { NetManager.sendToClient(receiver, packet); } - PluginManager.instance().onPlayerStateChanged(PlayerStateManager.defaultDisconnectedState(stateOwner)); + // Send the default disconnected state to the API when disconnecting + PluginManager.instance().onPlayerStateChanged(defaultDisconnectedState(stateOwner)); } public void onPlayerCompatibilityCheckSucceeded(Player player) { - ArrayList stateList = new ArrayList(this.states.size()); - for (PlayerState state : this.states.values()) { + List stateList = new ArrayList<>(states.size()); + for (PlayerState state : states.values()) { Player otherPlayer = Voicechat.INSTANCE.getServer().getPlayer(state.getUuid()); - if (otherPlayer == null || !Voicechat.compatibility.canSee(player, otherPlayer)) continue; + if (otherPlayer == null) { + continue; + } + if (!Voicechat.compatibility.canSee(player, otherPlayer)) { + continue; + } stateList.add(state); } PlayerStatesPacket packet = new PlayerStatesPacket(stateList); @@ -106,30 +109,37 @@ implements Listener { } public void onPlayerVoicechatDisconnect(UUID uuid) { - PlayerState state = this.states.get(uuid); + PlayerState state = states.get(uuid); if (state == null) { return; } + state.setDisconnected(true); - Player player = Bukkit.getPlayer((UUID)uuid); - this.broadcastState(player, state); + + @Nullable Player player = Bukkit.getPlayer(uuid); + + broadcastState(player, state); Voicechat.LOGGER.debug("Set state of {} to disconnected: {}", uuid, state); } public void onPlayerVoicechatConnect(Player player) { - PlayerState state = this.states.get(player.getUniqueId()); + PlayerState state = states.get(player.getUniqueId()); + if (state == null) { - state = PlayerStateManager.defaultDisconnectedState(player); + state = defaultDisconnectedState(player); } + state.setDisconnected(false); - this.states.put(player.getUniqueId(), state); - this.broadcastState(player, state); + + states.put(player.getUniqueId(), state); + + broadcastState(player, state); Voicechat.LOGGER.debug("Set state of {} to connected: {}", player.getName(), state); } @Nullable public PlayerState getState(UUID playerUUID) { - return this.states.get(playerUUID); + return states.get(playerUUID); } public static PlayerState defaultDisconnectedState(Player player) { @@ -137,19 +147,19 @@ implements Listener { } public void setGroup(Player player, @Nullable UUID group) { - PlayerState state = this.states.get(player.getUniqueId()); + PlayerState state = states.get(player.getUniqueId()); if (state == null) { state = PlayerStateManager.defaultDisconnectedState(player); Voicechat.LOGGER.debug("Defaulting to default state for {}: {}", player.getName(), state); } state.setGroup(group); - this.states.put(player.getUniqueId(), state); - this.broadcastState(player, state); + states.put(player.getUniqueId(), state); + broadcastState(player, state); Voicechat.LOGGER.debug("Setting group of {}: {}", player.getName(), state); } public Collection getStates() { - return this.states.values(); + return states.values(); } -} +} diff --git a/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/Server.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/Server.java new file mode 100644 index 0000000..374a027 --- /dev/null +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/Server.java @@ -0,0 +1,559 @@ +package de.maxhenkel.voicechat.voice.server; + +import de.maxhenkel.voicechat.Voicechat; +import de.maxhenkel.voicechat.api.RawUdpPacket; +import de.maxhenkel.voicechat.api.VoicechatSocket; +import de.maxhenkel.voicechat.api.events.SoundPacketEvent; +import de.maxhenkel.voicechat.debug.CooldownTimer; +import de.maxhenkel.voicechat.debug.VoicechatUncaughtExceptionHandler; +import de.maxhenkel.voicechat.net.NetManager; +import de.maxhenkel.voicechat.permission.PermissionManager; +import de.maxhenkel.voicechat.plugins.PluginManager; +import de.maxhenkel.voicechat.voice.common.*; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import javax.annotation.Nullable; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.nio.channels.AsynchronousCloseException; +import java.security.InvalidKeyException; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + +public class Server extends Thread { + + private final Map connections; + private final Map unCheckedConnections; + private final Map secrets; + private final int port; + private final org.bukkit.Server server; + private final VoicechatSocket socket; + private final ProcessThread processThread; + private final BlockingQueue packetQueue; + private final PingManager pingManager; + private final PlayerStateManager playerStateManager; + private final ServerGroupManager groupManager; + private final ServerCategoryManager categoryManager; + + public Server() { + int configPort = Voicechat.SERVER_CONFIG.voiceChatPort.get(); + if (configPort < 0) { + Voicechat.LOGGER.info("Using the Minecraft servers port as voice chat port"); + port = Bukkit.getPort(); + } else { + port = configPort; + } + this.server = Bukkit.getServer(); + socket = PluginManager.instance().getSocketImplementation(); + connections = new ConcurrentHashMap<>(); + unCheckedConnections = new ConcurrentHashMap<>(); + secrets = new ConcurrentHashMap<>(); + packetQueue = new LinkedBlockingQueue<>(); + pingManager = new PingManager(this); + playerStateManager = new PlayerStateManager(); + groupManager = new ServerGroupManager(); + categoryManager = new ServerCategoryManager(); + setDaemon(true); + setName("VoiceChatServerThread"); + setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler()); + processThread = new ProcessThread(); + processThread.start(); + } + + @Override + public void run() { + try { + String bindAddress = getBindAddress(); + try { + InetAddress.getByName(bindAddress); + } catch (UnknownHostException e) { + Voicechat.LOGGER.error("Failed to parse bind IP address '{}'", bindAddress, e); + Voicechat.LOGGER.info("Binding to wildcard IP address"); + bindAddress = ""; + } + socket.open(port, bindAddress); + + if (bindAddress.isEmpty()) { + Voicechat.LOGGER.info("Voice chat server started at port {}", socket.getLocalPort()); + } else { + Voicechat.LOGGER.info("Voice chat server started at {}:{}", bindAddress, socket.getLocalPort()); + } + + while (!socket.isClosed()) { + try { + packetQueue.add(socket.read()); + } catch (Exception e) { + // Only log an error if the error isn't caused by the socket being closed + if (!(e instanceof SocketException && e.getCause() instanceof AsynchronousCloseException)) { + if (Voicechat.debugMode()) { + Voicechat.LOGGER.error("Failed to read from socket", e); + } + } + } + } + } catch (Exception e) { + Voicechat.LOGGER.error("Voice chat server error", e); + } + } + + private String getBindAddress() { + String bindAddress = Voicechat.SERVER_CONFIG.voiceChatBindAddress.get(); + + if (bindAddress.trim().equals("*")) { + bindAddress = ""; + } else if (bindAddress.trim().isEmpty()) { + try { + bindAddress = Bukkit.getIp(); + if (!bindAddress.trim().isEmpty()) { + try { + InetAddress address = InetAddress.getByName(bindAddress); + if (address.isLoopbackAddress()) { + bindAddress = ""; + } else { + Voicechat.LOGGER.info("Using server-ip as bind address: {}", bindAddress); + } + } catch (Exception e) { + Voicechat.LOGGER.warn("Invalid server-ip", e); + bindAddress = ""; + } + } + } catch (Throwable t) { + Voicechat.LOGGER.warn("Failed to get server-ip from server.properties - binding to wildcard address", t); + } + } + + return bindAddress; + } + + public Secret getSecret(UUID playerUUID) { + if (hasSecret(playerUUID)) { + return secrets.get(playerUUID); + } else { + Secret secret = Secret.generateNewRandomSecret(); + secrets.put(playerUUID, secret); + return secret; + } + } + + /** + * @param playerUUID the player uuid + * @return the new secret or null if the player already has a secret + */ + @Nullable + public Secret generateNewSecret(UUID playerUUID) { + if (hasSecret(playerUUID)) { + return null; + } + return getSecret(playerUUID); + } + + public boolean hasSecret(UUID playerUUID) { + return secrets.containsKey(playerUUID); + } + + public void disconnectClient(UUID playerUUID) { + connections.remove(playerUUID); + unCheckedConnections.remove(playerUUID); + secrets.remove(playerUUID); + PluginManager.instance().onPlayerDisconnected(playerUUID); + } + + public void close() { + socket.close(); + processThread.close(); + + PluginManager.instance().onServerStopped(); + } + + public boolean isClosed() { + return !processThread.running; + } + + private class ProcessThread extends Thread { + private boolean running; + private long lastKeepAlive; + + public ProcessThread() { + running = true; + lastKeepAlive = 0L; + setDaemon(true); + setName("VoiceChatPacketProcessingThread"); + setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler()); + } + + @Override + public void run() { + while (running) { + try { + pingManager.checkTimeouts(); + long keepAliveTime = System.currentTimeMillis(); + if (keepAliveTime - lastKeepAlive > Voicechat.SERVER_CONFIG.keepAlive.get()) { + sendKeepAlives(); + lastKeepAlive = keepAliveTime; + } + + RawUdpPacket rawPacket = packetQueue.poll(10, TimeUnit.MILLISECONDS); + if (rawPacket == null) { + continue; + } + + NetworkMessage message; + try { + message = NetworkMessage.readPacketServer(rawPacket, Server.this); + } catch (Exception e) { + CooldownTimer.run("failed_reading_packet", () -> { + Voicechat.LOGGER.warn("Failed to read packet from {}", rawPacket.getSocketAddress()); + }); + continue; + } + + if (message == null) { + continue; + } + + if (System.currentTimeMillis() - message.getTimestamp() > message.getTTL()) { + CooldownTimer.run("ttl", () -> { + Voicechat.LOGGER.error("Dropping voice chat packets! Your Server might be overloaded!"); + Voicechat.LOGGER.error("Packet queue has {} packets", packetQueue.size()); + }); + continue; + } + + if (message.getPacket() instanceof AuthenticatePacket) { + AuthenticatePacket packet = (AuthenticatePacket) message.getPacket(); + Secret secret = secrets.get(packet.getPlayerUUID()); + if (secret != null && secret.equals(packet.getSecret())) { + ClientConnection connection = unCheckedConnections.get(packet.getPlayerUUID()); + if (connection == null) { + connection = connections.get(packet.getPlayerUUID()); + } + if (connection == null) { + connection = new ClientConnection(packet.getPlayerUUID(), message.getAddress()); + unCheckedConnections.put(packet.getPlayerUUID(), connection); + Voicechat.LOGGER.info("Successfully authenticated player {}", packet.getPlayerUUID()); + } + sendPacket(new AuthenticateAckPacket(), connection); + } + } + + if (message.getPacket() instanceof ConnectionCheckPacket) { + ClientConnection connection = getUnconnectedSender(message); + if (connection == null) { + connection = getSender(message); + if (connection != null) { + sendPacket(new ConnectionCheckAckPacket(), connection); + } + continue; + } + // Refresh keepalive, so players who took longer than the timeout can still connect + connection.setLastKeepAliveResponse(System.currentTimeMillis()); + connections.put(connection.getPlayerUUID(), connection); + unCheckedConnections.remove(connection.getPlayerUUID()); + Voicechat.LOGGER.info("Successfully validated connection of player {}", connection.getPlayerUUID()); + Player player = server.getPlayer(connection.getPlayerUUID()); + if (player != null) { + playerStateManager.onPlayerVoicechatConnect(player); + PluginManager.instance().onPlayerConnected(player); + Voicechat.LOGGER.info("Player {} ({}) successfully connected to voice chat", player.getName(), connection.getPlayerUUID()); + } + sendPacket(new ConnectionCheckAckPacket(), connection); + continue; + } + + ClientConnection conn = getSender(message); + if (conn == null) { + continue; + } + + if (message.getPacket() instanceof MicPacket) { + onMicPacket(conn.getPlayerUUID(), (MicPacket) message.getPacket()); + } else if (message.getPacket() instanceof PingPacket) { + PingPacket packet = (PingPacket) message.getPacket(); + pingManager.onPongPacket(packet); + } else if (message.getPacket() instanceof KeepAlivePacket) { + conn.setLastKeepAliveResponse(System.currentTimeMillis()); + } + } catch (Exception e) { + Voicechat.LOGGER.error("Voice chat server error", e); + } + } + } + + public void close() { + running = false; + } + } + + public void onMicPacket(UUID playerUuid, MicPacket packet) { + Player player = server.getPlayer(playerUuid); + if (player == null) { + return; + } + if (!player.hasPermission(PermissionManager.SPEAK_PERMISSION)) { + CooldownTimer.run("no-speak-" + playerUuid, () -> { + NetManager.sendStatusMessage(player, "message.voicechat.no_speak_permission"); + }); + return; + } + PlayerState state = playerStateManager.getState(player.getUniqueId()); + if (state == null) { + return; + } + if (!PluginManager.instance().onMicPacket(player, state, packet)) { + processMicPacket(player, state, packet); + } + } + + private void processMicPacket(Player player, PlayerState state, MicPacket packet) { + if (state.hasGroup()) { + @Nullable Group group = groupManager.getGroup(state.getGroup()); + processGroupPacket(state, player, packet); + if (group == null || group.isOpen()) { + processProximityPacket(state, player, packet); + } + return; + } + processProximityPacket(state, player, packet); + } + + private void processGroupPacket(PlayerState senderState, Player sender, MicPacket packet) { + UUID groupId = senderState.getGroup(); + if (groupId == null) { + return; + } + GroupSoundPacket groupSoundPacket = new GroupSoundPacket(senderState.getUuid(), senderState.getUuid(), packet.getData(), packet.getSequenceNumber(), null); + for (PlayerState state : playerStateManager.getStates()) { + if (!groupId.equals(state.getGroup())) { + continue; + } + if (senderState.getUuid().equals(state.getUuid())) { + continue; + } + Player p = server.getPlayer(state.getUuid()); + if (p == null) { + continue; + } + @Nullable ClientConnection connection = getConnection(state.getUuid()); + sendSoundPacket(sender, senderState, p, state, connection, groupSoundPacket, SoundPacketEvent.SOURCE_GROUP); + } + } + + private void processProximityPacket(PlayerState senderState, Player sender, MicPacket packet) { + @Nullable UUID groupId = senderState.getGroup(); + float distance; + if (packet.isWhispering()) { + distance = Voicechat.SERVER_CONFIG.whisperDistance.get().floatValue(); + } else { + distance = Utils.getDefaultDistance(); + } + + distance = PluginManager.instance().getDistance(sender, senderState, packet, distance); + + SoundPacket soundPacket = null; + String source = null; + if (sender.getGameMode().equals(GameMode.SPECTATOR)) { + if (Voicechat.SERVER_CONFIG.spectatorPlayerPossession.get()) { + Entity camera = sender.getSpectatorTarget(); + if (camera instanceof Player) { + Player spectatingPlayer = (Player) camera; + if (spectatingPlayer != sender) { + PlayerState receiverState = playerStateManager.getState(spectatingPlayer.getUniqueId()); + if (receiverState == null) { + return; + } + GroupSoundPacket groupSoundPacket = new GroupSoundPacket(senderState.getUuid(), senderState.getUuid(), packet.getData(), packet.getSequenceNumber(), null); + @Nullable ClientConnection connection = getConnection(receiverState.getUuid()); + sendSoundPacket(sender, senderState, spectatingPlayer, receiverState, connection, groupSoundPacket, SoundPacketEvent.SOURCE_SPECTATOR); + return; + } + } + } + if (Voicechat.SERVER_CONFIG.spectatorInteraction.get()) { + soundPacket = new LocationSoundPacket(sender.getUniqueId(), sender.getUniqueId(), sender.getLocation(), packet.getData(), packet.getSequenceNumber(), distance, null); + source = SoundPacketEvent.SOURCE_SPECTATOR; + } + } + + if (soundPacket == null) { + soundPacket = new PlayerSoundPacket(sender.getUniqueId(), sender.getUniqueId(), packet.getData(), packet.getSequenceNumber(), packet.isWhispering(), distance, null); + source = SoundPacketEvent.SOURCE_PROXIMITY; + } + + broadcast(ServerPlayerManager.getPlayersInRange(sender.getWorld(), sender.getLocation(), getBroadcastRange(distance), p -> !p.getUniqueId().equals(sender.getUniqueId())), soundPacket, sender, senderState, groupId, source); + } + + public void sendSoundPacket(@Nullable Player sender, @Nullable PlayerState senderState, Player receiver, PlayerState receiverState, @Nullable ClientConnection connection, SoundPacket soundPacket, String source) { + PluginManager.instance().onListenerAudio(receiver.getUniqueId(), soundPacket); + + if (connection == null) { + return; + } + + if (receiverState.isDisabled() || receiverState.isDisconnected()) { + return; + } + + if (PluginManager.instance().onSoundPacket(sender, senderState, receiver, receiverState, soundPacket, source)) { + return; + } + + if (!receiver.hasPermission(PermissionManager.LISTEN_PERMISSION)) { + CooldownTimer.run(String.format("no-listen-%s", receiver.getUniqueId()), 30_000L, () -> { + NetManager.sendStatusMessage(receiver, "message.voicechat.no_listen_permission"); + }); + return; + } + sendPacket(soundPacket, connection); + } + + public double getBroadcastRange(float minRange) { + double broadcastRange = Voicechat.SERVER_CONFIG.broadcastRange.get(); + if (broadcastRange < 0D) { + broadcastRange = Voicechat.SERVER_CONFIG.voiceChatDistance.get() + 1D; + } + return Math.max(broadcastRange, minRange); + } + + public void broadcast(Collection players, SoundPacket packet, @Nullable Player sender, @Nullable PlayerState senderState, @Nullable UUID groupId, String source) { + for (Player player : players) { + PlayerState state = playerStateManager.getState(player.getUniqueId()); + if (state == null) { + continue; + } + if (state.hasGroup() && state.getGroup().equals(groupId)) { + continue; + } + @Nullable Group receiverGroup = null; + if (state.hasGroup()) { + receiverGroup = groupManager.getGroup(state.getGroup()); + } + if (receiverGroup != null && receiverGroup.isIsolated()) { + continue; + } + @Nullable ClientConnection connection = getConnection(state.getUuid()); + sendSoundPacket(sender, senderState, player, state, connection, packet, source); + } + } + + private void sendKeepAlives() { + long timestamp = System.currentTimeMillis(); + + connections.values().removeIf(connection -> { + if (timestamp - connection.getLastKeepAliveResponse() >= Voicechat.SERVER_CONFIG.keepAlive.get() * 10L) { + // Don't call disconnectClient here! + secrets.remove(connection.getPlayerUUID()); + Voicechat.LOGGER.info("Player {} timed out", connection.getPlayerUUID()); + Player player = server.getPlayer(connection.getPlayerUUID()); + if (player != null) { + Voicechat.LOGGER.info("Reconnecting player {}", player.getName()); + Voicechat.SERVER.initializePlayerConnection(player); + } else { + Voicechat.LOGGER.error("Reconnecting player {} failed (Could not find player)", connection.getPlayerUUID()); + } + playerStateManager.onPlayerVoicechatDisconnect(connection.getPlayerUUID()); + PluginManager.instance().onPlayerDisconnected(connection.getPlayerUUID()); + return true; + } + return false; + }); + + for (ClientConnection connection : connections.values()) { + sendPacket(new KeepAlivePacket(), connection); + } + + } + + @Nullable + public ClientConnection getSender(NetworkMessage message) { + return connections + .values() + .stream() + .filter(connection -> connection.getAddress().equals(message.getAddress())) + .findAny() + .orElse(null); + } + + @Nullable + public ClientConnection getUnconnectedSender(NetworkMessage message) { + return unCheckedConnections + .values() + .stream() + .filter(connection -> connection.getAddress().equals(message.getAddress())) + .findAny() + .orElse(null); + } + + public Map getConnections() { + return connections; + } + + @Nullable + public ClientConnection getConnection(UUID playerID) { + return connections.get(playerID); + } + + public VoicechatSocket getSocket() { + return socket; + } + + public int getPort() { + return socket.getLocalPort(); + } + + /** + * Sends the packet and handles potential errors. + * + * @param packet the packet to send + * @param connection the connection to send the packet to + * @return if the packet was sent successfully + */ + public boolean sendPacket(Packet packet, ClientConnection connection) { + try { + sendPacketRaw(packet, connection); + return true; + } catch (Exception e) { + Voicechat.LOGGER.error("Failed to send voice chat packet to {}", connection.getPlayerUUID()); + return false; + } + } + + /** + * Sends the packet. You must handle potential errors + * + * @param packet the packet to send + * @param connection the connection to send the packet to + * @throws Exception if an I/O error occurs + */ + public void sendPacketRaw(Packet packet, ClientConnection connection) throws Exception { + connection.send(this, new NetworkMessage(packet)); + } + + public PingManager getPingManager() { + return pingManager; + } + + public PlayerStateManager getPlayerStateManager() { + return playerStateManager; + } + + public ServerGroupManager getGroupManager() { + return groupManager; + } + + public ServerCategoryManager getCategoryManager() { + return categoryManager; + } + +} \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerCategoryManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerCategoryManager.java similarity index 80% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/ServerCategoryManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerCategoryManager.java index 3fb712a..04b2330 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerCategoryManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerCategoryManager.java @@ -1,10 +1,3 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ package de.maxhenkel.voicechat.voice.server; import de.maxhenkel.voicechat.Voicechat; @@ -13,14 +6,15 @@ import de.maxhenkel.voicechat.net.NetManager; import de.maxhenkel.voicechat.net.RemoveCategoryPacket; import de.maxhenkel.voicechat.plugins.CategoryManager; import de.maxhenkel.voicechat.plugins.impl.VolumeCategoryImpl; -import javax.annotation.Nullable; import org.bukkit.entity.Player; -public class ServerCategoryManager -extends CategoryManager { +import javax.annotation.Nullable; + +public class ServerCategoryManager extends CategoryManager { + public void onPlayerCompatibilityCheckSucceeded(Player player) { - Voicechat.LOGGER.debug("Synchronizing {} volume categories with {}", this.categories.size(), player.getName()); - for (VolumeCategoryImpl category : this.getCategories()) { + Voicechat.LOGGER.debug("Synchronizing {} volume categories with {}", categories.size(), player.getName()); + for (VolumeCategoryImpl category : getCategories()) { NetManager.sendToClient(player, new AddCategoryPacket(category)); } } @@ -29,7 +23,7 @@ extends CategoryManager { public void addCategory(VolumeCategoryImpl category) { super.addCategory(category); Voicechat.LOGGER.debug("Synchronizing volume category {} with all players", category.getId()); - this.broadcastAddCategory(category); + broadcastAddCategory(category); } @Override @@ -37,7 +31,7 @@ extends CategoryManager { public VolumeCategoryImpl removeCategory(String categoryId) { VolumeCategoryImpl volumeCategory = super.removeCategory(categoryId); Voicechat.LOGGER.debug("Removing volume category {} for all players", categoryId); - this.broadcastRemoveCategory(categoryId); + broadcastRemoveCategory(categoryId); return volumeCategory; } @@ -50,5 +44,5 @@ extends CategoryManager { RemoveCategoryPacket packet = new RemoveCategoryPacket(categoryId); Voicechat.INSTANCE.getServer().getOnlinePlayers().forEach(p -> NetManager.sendToClient(p, packet)); } -} +} diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerGroupManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerGroupManager.java similarity index 66% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/ServerGroupManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerGroupManager.java index 5f99ea4..b21aa66 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerGroupManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerGroupManager.java @@ -1,55 +1,45 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - * org.bukkit.event.player.PlayerQuitEvent - */ package de.maxhenkel.voicechat.voice.server; import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.AddGroupPacket; -import de.maxhenkel.voicechat.net.CreateGroupPacket; -import de.maxhenkel.voicechat.net.JoinGroupPacket; -import de.maxhenkel.voicechat.net.JoinedGroupPacket; -import de.maxhenkel.voicechat.net.LeaveGroupPacket; -import de.maxhenkel.voicechat.net.NetManager; -import de.maxhenkel.voicechat.net.RemoveGroupPacket; +import de.maxhenkel.voicechat.net.*; import de.maxhenkel.voicechat.permission.PermissionManager; import de.maxhenkel.voicechat.plugins.PluginManager; import de.maxhenkel.voicechat.voice.common.PlayerState; -import de.maxhenkel.voicechat.voice.server.Group; -import de.maxhenkel.voicechat.voice.server.PlayerStateManager; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerQuitEvent; + +import javax.annotation.Nullable; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import javax.annotation.Nullable; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerQuitEvent; public class ServerGroupManager { - private final Map groups = new ConcurrentHashMap(); + + private final Map groups; + + public ServerGroupManager() { + groups = new ConcurrentHashMap<>(); + } public void onJoinGroupPacket(Player player, JoinGroupPacket packet) { - if (!Voicechat.SERVER_CONFIG.groupsEnabled.get().booleanValue()) { + if (!Voicechat.SERVER_CONFIG.groupsEnabled.get()) { return; } if (!player.hasPermission(PermissionManager.GROUPS_PERMISSION)) { - NetManager.sendStatusMessage(player, "message.voicechat.no_group_permission", new String[0]); + NetManager.sendStatusMessage(player, "message.voicechat.no_group_permission"); return; } - this.joinGroup(this.groups.get(packet.getGroup()), player, packet.getPassword()); + joinGroup(groups.get(packet.getGroup()), player, packet.getPassword()); } public void onCreateGroupPacket(Player player, CreateGroupPacket packet) { - if (!Voicechat.SERVER_CONFIG.groupsEnabled.get().booleanValue()) { + if (!Voicechat.SERVER_CONFIG.groupsEnabled.get()) { return; } if (!player.hasPermission(PermissionManager.GROUPS_PERMISSION)) { - NetManager.sendStatusMessage(player, "message.voicechat.no_group_permission", new String[0]); + NetManager.sendStatusMessage(player, "message.voicechat.no_group_permission"); return; } if (!Voicechat.GROUP_REGEX.matcher(packet.getName()).matches()) { @@ -61,22 +51,22 @@ public class ServerGroupManager { return; } Group group = new Group(UUID.randomUUID(), packet.getName(), packet.getPassword(), false, false, packet.getType()); - this.addGroup(group, player); + addGroup(group, player); } public void onLeaveGroupPacket(Player player, LeaveGroupPacket packet) { - this.leaveGroup(player); + leaveGroup(player); } public void onPlayerCompatibilityCheckSucceeded(Player player) { - Voicechat.LOGGER.debug("Synchronizing {} groups with {}", this.groups.size(), player.getDisplayName()); - for (Group group : this.groups.values()) { + Voicechat.LOGGER.debug("Synchronizing {} groups with {}", groups.size(), player.getDisplayName()); + for (Group group : groups.values()) { NetManager.sendToClient(player, new AddGroupPacket(group.toClientGroup())); } } public void onPlayerQuit(PlayerQuitEvent event) { - this.cleanupGroups(); + cleanupGroups(); } private PlayerStateManager getStates() { @@ -87,13 +77,16 @@ public class ServerGroupManager { if (PluginManager.instance().onCreateGroup(player, group)) { return; } - this.groups.put(group.getId(), group); - this.broadcastAddGroup(group); + groups.put(group.getId(), group); + broadcastAddGroup(group); + if (player == null) { return; } - PlayerStateManager manager = this.getStates(); + + PlayerStateManager manager = getStates(); manager.setGroup(player, group.getId()); + NetManager.sendToClient(player, new JoinedGroupPacket(group.getId(), false)); } @@ -102,15 +95,19 @@ public class ServerGroupManager { NetManager.sendToClient(player, new JoinedGroupPacket(null, true)); return; } + if (PluginManager.instance().onJoinGroup(player, group)) { return; } + if (group == null) { NetManager.sendToClient(player, new JoinedGroupPacket(null, false)); return; } - PlayerStateManager manager = this.getStates(); + + PlayerStateManager manager = getStates(); manager.setGroup(player, group.getId()); + NetManager.sendToClient(player, new JoinedGroupPacket(group.getId(), false)); } @@ -118,41 +115,47 @@ public class ServerGroupManager { if (PluginManager.instance().onLeaveGroup(player)) { return; } - PlayerStateManager manager = this.getStates(); + + PlayerStateManager manager = getStates(); manager.setGroup(player, null); NetManager.sendToClient(player, new JoinedGroupPacket(null, false)); - this.cleanupGroups(); + + cleanupGroups(); } public void cleanupGroups() { - PlayerStateManager manager = this.getStates(); - List usedGroups = manager.getStates().stream().filter(PlayerState::hasGroup).map(PlayerState::getGroup).distinct().collect(Collectors.toList()); - List groupsToRemove = this.groups.entrySet().stream().filter(entry -> !((Group)entry.getValue()).isPersistent()).map(Map.Entry::getKey).filter(uuid -> !usedGroups.contains(uuid)).collect(Collectors.toList()); - for (UUID uuid2 : groupsToRemove) { - this.removeGroup(uuid2); + PlayerStateManager manager = getStates(); + List usedGroups = manager.getStates().stream().filter(PlayerState::hasGroup).map(PlayerState::getGroup).distinct().collect(Collectors.toList()); + List groupsToRemove = groups.entrySet().stream().filter(entry -> !entry.getValue().isPersistent()).map(Map.Entry::getKey).filter(uuid -> !usedGroups.contains(uuid)).collect(Collectors.toList()); + for (UUID uuid : groupsToRemove) { + removeGroup(uuid); } } public boolean removeGroup(UUID groupId) { - Group group = this.groups.get(groupId); + Group group = groups.get(groupId); if (group == null) { return false; } - PlayerStateManager manager = this.getStates(); + + PlayerStateManager manager = getStates(); if (manager.getStates().stream().anyMatch(state -> state.hasGroup() && state.getGroup().equals(groupId))) { return false; } + if (PluginManager.instance().onRemoveGroup(group)) { return false; } - this.groups.remove(groupId); - this.broadcastRemoveGroup(groupId); + + groups.remove(groupId); + broadcastRemoveGroup(groupId); + // TODO Handle kicking players from group instead of preventing it return true; } @Nullable public Group getGroup(UUID groupID) { - return this.groups.get(groupID); + return groups.get(groupID); } private void broadcastAddGroup(Group group) { @@ -167,7 +170,7 @@ public class ServerGroupManager { @Nullable public Group getPlayerGroup(Player player) { - PlayerState state = this.getStates().getState(player.getUniqueId()); + PlayerState state = getStates().getState(player.getUniqueId()); if (state == null) { return null; } @@ -175,11 +178,11 @@ public class ServerGroupManager { if (groupId == null) { return null; } - return this.getGroup(groupId); + return getGroup(groupId); } public Map getGroups() { - return this.groups; + return groups; } -} +} \ No newline at end of file diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerPlayerManager.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerPlayerManager.java similarity index 51% rename from source/decompiled/de/maxhenkel/voicechat/voice/server/ServerPlayerManager.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerPlayerManager.java index 446ebc4..0af0ca3 100644 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerPlayerManager.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerPlayerManager.java @@ -1,29 +1,6 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - * org.bukkit.Location - * org.bukkit.World - * org.bukkit.entity.Player - * org.bukkit.event.EventHandler - * org.bukkit.event.Listener - * org.bukkit.event.player.PlayerJoinEvent - * org.bukkit.event.player.PlayerQuitEvent - * org.bukkit.plugin.Plugin - */ package de.maxhenkel.voicechat.voice.server; import de.maxhenkel.voicechat.Voicechat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; -import javax.annotation.Nullable; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -34,39 +11,51 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; -public class ServerPlayerManager -implements Listener { - private static final long REFRESH_INTERVAL_TICKS = 600L; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + +public class ServerPlayerManager implements Listener { + + private static final long REFRESH_INTERVAL_TICKS = 20L * 30L; + public static final ServerPlayerManager INSTANCE = new ServerPlayerManager(); - private volatile Set players = Collections.emptySet(); public static void init(Plugin plugin) { - if (!Voicechat.SERVER_CONFIG.threadedServerSupport.get().booleanValue()) { + if (!Voicechat.SERVER_CONFIG.threadedServerSupport.get()) { return; } - Bukkit.getPluginManager().registerEvents((Listener)INSTANCE, plugin); - Voicechat.compatibility.scheduleSyncRepeatingTask(INSTANCE::refresh, 0L, 600L); + Bukkit.getPluginManager().registerEvents(ServerPlayerManager.INSTANCE, plugin); + Voicechat.compatibility.scheduleSyncRepeatingTask(INSTANCE::refresh, 0, REFRESH_INTERVAL_TICKS); } + private volatile Set players; + private ServerPlayerManager() { + players = Collections.emptySet(); } private synchronized void refresh() { - this.players = new HashSet(Bukkit.getOnlinePlayers()); + players = new HashSet<>(Bukkit.getOnlinePlayers()); } @EventHandler public synchronized void onPlayerJoin(PlayerJoinEvent event) { - HashSet newPlayers = new HashSet(this.players); + Set newPlayers = new HashSet<>(players); newPlayers.add(event.getPlayer()); - this.players = newPlayers; + players = newPlayers; } @EventHandler public synchronized void onPlayerQuit(PlayerQuitEvent event) { - HashSet newPlayers = new HashSet(this.players); + Set newPlayers = new HashSet<>(players); newPlayers.remove(event.getPlayer()); - this.players = newPlayers; + players = newPlayers; } public static Collection getPlayersInRange(World level, Location pos, double range, @Nullable Predicate filter) { @@ -74,34 +63,39 @@ implements Listener { } private Collection getPlayersInRangeInternal(World world, Location pos, double range, @Nullable Predicate filter) { - if (!Voicechat.SERVER_CONFIG.threadedServerSupport.get().booleanValue()) { - return ServerPlayerManager.getPlayersInRangeDirect(world, pos, range, filter); + if (!Voicechat.SERVER_CONFIG.threadedServerSupport.get()) { + return getPlayersInRangeDirect(world, pos, range, filter); } - ArrayList nearbyPlayers = new ArrayList(); - for (Player player : this.players) { - if (!world.equals((Object)player.getWorld()) || !ServerPlayerManager.isInRange(player.getLocation(), pos, range) || filter != null && !filter.test(player)) continue; - nearbyPlayers.add(player); + List nearbyPlayers = new ArrayList<>(); + for (Player player : players) { + if (!world.equals(player.getWorld())) { + continue; + } + if (isInRange(player.getLocation(), pos, range) && (filter == null || filter.test(player))) { + nearbyPlayers.add(player); + } } return nearbyPlayers; } private static Collection getPlayersInRangeDirect(World world, Location pos, double range, @Nullable Predicate filter) { - ArrayList nearbyPlayers = new ArrayList(); - List worldPlayers = world.getPlayers(); - for (int i = 0; i < worldPlayers.size(); ++i) { - Player player = (Player)worldPlayers.get(i); - if (!ServerPlayerManager.isInRange(player.getLocation(), pos, range) || filter != null && !filter.test(player)) continue; - nearbyPlayers.add(player); + List nearbyPlayers = new ArrayList<>(); + List worldPlayers = world.getPlayers(); + for (int i = 0; i < worldPlayers.size(); i++) { + Player player = worldPlayers.get(i); + if (isInRange(player.getLocation(), pos, range) && (filter == null || filter.test(player))) { + nearbyPlayers.add(player); + } } return nearbyPlayers; } public static boolean isInRange(Location pos1, Location pos2, double range) { - return ServerPlayerManager.square(pos1.getX() - pos2.getX()) + ServerPlayerManager.square(pos1.getY() - pos2.getY()) + ServerPlayerManager.square(pos1.getZ() - pos2.getZ()) <= ServerPlayerManager.square(range); + return (square(pos1.getX() - pos2.getX()) + square(pos1.getY() - pos2.getY()) + square(pos1.getZ() - pos2.getZ())) <= square(range); } private static double square(double value) { return value * value; } -} +} diff --git a/source/patch/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java similarity index 64% rename from source/patch/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java rename to source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java index 6c4fe38..44bd8da 100644 --- a/source/patch/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java +++ b/source/bukkit/src/main/java/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java @@ -1,5 +1,6 @@ package de.maxhenkel.voicechat.voice.server; +import de.maxhenkel.voicechat.BuildConstants; import de.maxhenkel.voicechat.Voicechat; import de.maxhenkel.voicechat.compatibility.PlayerHideEvent; import de.maxhenkel.voicechat.compatibility.PlayerShowEvent; @@ -9,9 +10,6 @@ import de.maxhenkel.voicechat.net.RequestSecretPacket; import de.maxhenkel.voicechat.net.SecretPacket; import de.maxhenkel.voicechat.plugins.PluginManager; import de.maxhenkel.voicechat.voice.common.Secret; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -19,36 +17,42 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + public class ServerVoiceEvents implements Listener { private static final int LEGACY_COMPATIBILITY_VERSION = 18; - private static final int CURRENT_COMPATIBILITY_VERSION = 20; private final Map clientCompatibilities = new ConcurrentHashMap<>(); private final PacketRateLimiter rateLimiter; private Server server; public ServerVoiceEvents() { - this.rateLimiter = new PacketRateLimiter(Voicechat.SERVER_CONFIG.tcpRateLimit.get()); + rateLimiter = new PacketRateLimiter(Voicechat.SERVER_CONFIG.tcpRateLimit.get()); } public void init() { - if (this.server != null) { + if (server != null) { return; } if (!Bukkit.getOnlineMode()) { - Voicechat.LOGGER.warn("Running in offline mode - Voice chat encryption is not secure!", new Object[0]); + Voicechat.LOGGER.warn("Running in offline mode - Voice chat encryption is not secure!"); } + Voicechat.compatibility.registerPlayerHideEvent(this::onPlayerHide); Voicechat.compatibility.registerPlayerShowEvent(this::onPlayerShow); - this.server = new Server(); - this.server.start(); + + server = new Server(); + server.start(); PluginManager.instance().onServerStarted(); } public void onRequestSecretPacket(Player player, RequestSecretPacket packet) { - UUID playerUUID; int clientVersion = packet.getCompatibilityVersion(); Voicechat.LOGGER.info("Received secret request of {} ({})", player.getName(), clientVersion); + + UUID playerUUID; try { playerUUID = player.getUniqueId(); } catch (UnsupportedOperationException e) { @@ -56,59 +60,64 @@ public class ServerVoiceEvents implements Listener { Voicechat.LOGGER.warn("{} tried to authenticate voice chat while still connecting", player.getName()); return; } - this.clientCompatibilities.put(playerUUID, clientVersion); - if (!ServerVoiceEvents.isSupportedCompatibilityVersion(clientVersion)) { + + clientCompatibilities.put(playerUUID, clientVersion); + if (!isSupportedCompatibilityVersion(clientVersion)) { Voicechat.LOGGER.warn("Connected client {} has incompatible voice chat version (server={}, client={})", player.getName(), Voicechat.COMPATIBILITY_VERSION, clientVersion); - ServerVoiceEvents.sendIncompatibleMessage(player, clientVersion); - return; + sendIncompatibleMessage(player, clientVersion); + } else { + initializePlayerConnection(player); } - this.initializePlayerConnection(player); } private static boolean isSupportedCompatibilityVersion(int version) { - return version == LEGACY_COMPATIBILITY_VERSION || version == CURRENT_COMPATIBILITY_VERSION; + return version == LEGACY_COMPATIBILITY_VERSION || version == BuildConstants.COMPATIBILITY_VERSION; } public boolean isCompatible(Player player) { - return this.isCompatible(player.getUniqueId()); + return isCompatible(player.getUniqueId()); } public boolean isCompatible(UUID playerUuid) { - return ServerVoiceEvents.isSupportedCompatibilityVersion(this.clientCompatibilities.getOrDefault(playerUuid, -1)); + return isSupportedCompatibilityVersion(clientCompatibilities.getOrDefault(playerUuid, -1)); } public static void sendIncompatibleMessage(Player player, int clientCompatibilityVersion) { if (clientCompatibilityVersion <= 6) { - player.sendMessage(String.format(Voicechat.TRANSLATIONS.voicechatNotCompatibleMessage.get(), "2.6.x", "Simple Voice Chat")); + player.sendMessage(String.format(Voicechat.TRANSLATIONS.voicechatNotCompatibleMessage.get(), + BuildConstants.MOD_COMPATIBLE_VERSION, BuildConstants.PLUGIN_NAME)); } else { - Voicechat.compatibility.sendIncompatibleMessage(player, "2.6.x", "Simple Voice Chat"); + Voicechat.compatibility.sendIncompatibleMessage(player, + BuildConstants.MOD_COMPATIBLE_VERSION, BuildConstants.PLUGIN_NAME); } } public void initializePlayerConnection(Player player) { - if (this.server == null) { + if (server == null) { return; } UUID playerUuid = player.getUniqueId(); - this.server.getPlayerStateManager().onPlayerCompatibilityCheckSucceeded(player); - this.server.getCategoryManager().onPlayerCompatibilityCheckSucceeded(player); - this.server.getGroupManager().onPlayerCompatibilityCheckSucceeded(player); - Secret secret = this.server.generateNewSecret(playerUuid); + server.getPlayerStateManager().onPlayerCompatibilityCheckSucceeded(player); + server.getCategoryManager().onPlayerCompatibilityCheckSucceeded(player); + server.getGroupManager().onPlayerCompatibilityCheckSucceeded(player); + + Secret secret = server.generateNewSecret(playerUuid); if (secret == null) { - Voicechat.LOGGER.warn("Player already requested secret - ignoring", new Object[0]); + Voicechat.LOGGER.warn("Player already requested secret - ignoring"); return; } - secret.setLegacyProtocol(this.clientCompatibilities.getOrDefault(playerUuid, -1) == LEGACY_COMPATIBILITY_VERSION); + secret.setLegacyProtocol(clientCompatibilities.getOrDefault(playerUuid, -1) == LEGACY_COMPATIBILITY_VERSION); + String voiceHost = PluginManager.instance().getVoiceHost(player, Voicechat.SERVER_CONFIG.voiceHost.get()); - NetManager.sendToClient(player, new SecretPacket(player, secret, this.server.getPort(), Voicechat.SERVER_CONFIG, voiceHost)); + NetManager.sendToClient(player, new SecretPacket(player, secret, server.getPort(), Voicechat.SERVER_CONFIG, voiceHost)); Voicechat.LOGGER.info("Sent secret to {}", player.getName()); } @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - this.server.getPlayerStateManager().onPlayerJoin(event); - if (!Voicechat.SERVER_CONFIG.forceVoiceChat.get().booleanValue()) { + server.getPlayerStateManager().onPlayerJoin(event); + if (!Voicechat.SERVER_CONFIG.forceVoiceChat.get()) { return; } Player player = event.getPlayer(); @@ -116,39 +125,42 @@ public class ServerVoiceEvents implements Listener { if (!player.isOnline()) { return; } - if (!this.isCompatible(player)) { - player.kickPlayer(String.format(Voicechat.TRANSLATIONS.forceVoicechatKickMessage.get(), "Simple Voice Chat", Voicechat.INSTANCE.getDescription().getVersion())); + if (!isCompatible(player)) { + player.kickPlayer(String.format(Voicechat.TRANSLATIONS.forceVoicechatKickMessage.get(), + BuildConstants.PLUGIN_NAME, Voicechat.INSTANCE.getDescription().getVersion())); } - }, (long) Voicechat.SERVER_CONFIG.loginTimeout.get().intValue() / 50L); + }, Voicechat.SERVER_CONFIG.loginTimeout.get() / 50L); } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - this.server.getPlayerStateManager().onPlayerQuit(event); - this.server.getGroupManager().onPlayerQuit(event); + server.getPlayerStateManager().onPlayerQuit(event); + server.getGroupManager().onPlayerQuit(event); + UUID playerUuid = event.getPlayer().getUniqueId(); - this.clientCompatibilities.remove(playerUuid); - this.rateLimiter.onPlayerLoggedOut(event.getPlayer()); - if (this.server == null) { + clientCompatibilities.remove(playerUuid); + rateLimiter.onPlayerLoggedOut(event.getPlayer()); + if (server == null) { return; } - this.server.disconnectClient(playerUuid); + + server.disconnectClient(playerUuid); Voicechat.LOGGER.info("Disconnecting client {}", event.getPlayer().getName()); } public void onPlayerHide(PlayerHideEvent event) { - this.server.getPlayerStateManager().onPlayerHide(event); + server.getPlayerStateManager().onPlayerHide(event); } public void onPlayerShow(PlayerShowEvent event) { - this.server.getPlayerStateManager().onPlayerShow(event); + server.getPlayerStateManager().onPlayerShow(event); } public PacketRateLimiter getRateLimiter() { - return this.rateLimiter; + return rateLimiter; } public Server getServer() { - return this.server; + return server; } } diff --git a/source/decompiled/de/maxhenkel/voicechat/BuildConstants.java b/source/bukkit/src/template/java/de/maxhenkel/voicechat/BuildConstants.java similarity index 51% rename from source/decompiled/de/maxhenkel/voicechat/BuildConstants.java rename to source/bukkit/src/template/java/de/maxhenkel/voicechat/BuildConstants.java index e44a2f3..0905f25 100644 --- a/source/decompiled/de/maxhenkel/voicechat/BuildConstants.java +++ b/source/bukkit/src/template/java/de/maxhenkel/voicechat/BuildConstants.java @@ -1,24 +1,21 @@ -/* - * Decompiled with CFR 0.152. - */ package de.maxhenkel.voicechat; public class BuildConstants { + public static final int COMPATIBILITY_VERSION; - public static final String PLUGIN_NAME = "Simple Voice Chat"; - public static final String TARGET_BUKKIT_VERSION = "1.8.8-R0.1-SNAPSHOT"; - public static final String MOD_COMPATIBLE_VERSION = "2.6.x"; + public static final String PLUGIN_NAME = "${plugin_name}"; + public static final String TARGET_BUKKIT_VERSION = "${target_bukkit_version}"; + public static final String MOD_COMPATIBLE_VERSION = "${mod_compatible_version}"; static { + String compatibilityVersionString = "${compatibility_version}"; int compatibilityVersion; - String compatibilityVersionString = "20"; try { compatibilityVersion = Integer.parseInt(compatibilityVersionString); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { compatibilityVersion = -1; } COMPATIBILITY_VERSION = compatibilityVersion; } -} +} diff --git a/source/common/src/main/resources/assets/voicechat/lang/en_us.json b/source/common/src/main/resources/assets/voicechat/lang/en_us.json new file mode 100644 index 0000000..a78fe67 --- /dev/null +++ b/source/common/src/main/resources/assets/voicechat/lang/en_us.json @@ -0,0 +1,230 @@ +{ + "key.category.voicechat.voicechat": "Voice Chat", + "key.push_to_talk": "Push to Talk", + "key.whisper": "Whisper", + "key.mute_microphone": "Mute Microphone", + "key.disable_voice_chat": "Disable Voice Chat", + "key.hide_icons": "Hide Voice Chat Icons", + "key.voice_chat_settings": "Voice Chat Settings", + "key.voice_chat": "Voice Chat Menu", + "key.voice_chat_group": "Group Management", + "key.voice_chat_toggle_recording": "Toggle Recording", + "key.voice_chat_adjust_volumes": "Adjust Volumes", + "gui.voicechat.voice_chat.title": "Voice Chat", + "gui.voicechat.voice_chat_settings.title": "Voice Chat Settings", + "gui.voicechat.adjust_volume.title": "Adjust Volumes", + "gui.voicechat.select_microphone.title": "Select Microphone", + "gui.voicechat.select_speaker.title": "Select Speaker", + "gui.voicechat.group.title": "Group Management", + "gui.voicechat.join_create_group.title": "Join or Create Group", + "gui.voicechat.create_group.title": "Create Group", + "gui.voicechat.enter_password.title": "Enter Group Password", + "message.voicechat.settings": "Settings", + "message.voicechat.group": "Group", + "message.voicechat.voice_chat_volume": "Voice Chat Volume: %s", + "message.voicechat.gain": "Gain: %s", + "message.voicechat.gain.auto": "Auto", + "message.voicechat.gain.manual": "Manual", + "message.voicechat.gain.manual.warning": "Please keep automatic microphone gain adjustment enabled to ensure consistent volume levels for everyone hearing you.", + "message.voicechat.microphone_gain": "Microphone Gain: %s dB", + "message.voicechat.microphone_gain.warning": "Exceeding %s dB amplification may produce audio distortion and other issues!", + "message.voicechat.mic_test_unavailable": "Microphone testing unavailable!", + "message.voicechat.mic_test.disabled": "Press to enable microphone testing.", + "message.voicechat.mic_test.enabled": "Press to disable microphone testing.", + "message.voicechat.voice_chat_unavailable": "Voice chat unavailable", + "message.voicechat.voice_chat_not_connected": "Voice chat not connected", + "message.voicechat.activation_type": "Activation Method: %s", + "message.voicechat.activation_type.ptt": "Push to Talk", + "message.voicechat.activation_type.voice": "Voice", + "message.voicechat.voice_activation_detection": "Voice Activation: %s", + "message.voicechat.voice_activation_detection.auto": "Auto", + "message.voicechat.voice_activation_detection.manual": "Manual", + "message.voicechat.voice_activation": "Voice Activation Threshold: %s dB", + "message.voicechat.voice_activation.disabled": "0 dB deactivates the microphone!", + "message.voicechat.adjust_volumes": "Adjust Volumes", + "message.voicechat.volume_amplification": "Amplification: %s", + "message.voicechat.muted": "Muted", + "message.voicechat.no_microphone": "No microphones available", + "message.voicechat.default_microphone": "System Default", + "message.voicechat.no_speaker": "No speakers available", + "message.voicechat.default_speaker": "System Default", + "message.voicechat.test_speaker": "Press to play a test sound.", + "message.voicechat.select_microphone": "Select Microphone", + "message.voicechat.select_speaker": "Select Speaker", + "message.voicechat.back": "Back", + "message.voicechat.client_not_connected": "Client not connected", + "message.voicechat.failed_to_send_ping": "Failed to send ping: %s", + "message.voicechat.sending_ping": "Sending ping...", + "message.voicechat.ping_sent_waiting": "Ping sent. Waiting for response...", + "message.voicechat.ping_received": "Got a response in %s ms", + "message.voicechat.ping_received_attempt": "Got a response in %s ms after %s attempts", + "message.voicechat.ping_retry": "No response. Retrying...", + "message.voicechat.ping_timed_out": "Request timed out after %s attempts", + "message.voicechat.icons_hidden": "Voice chat icons hidden", + "message.voicechat.icons_visible": "Voice chat icons visible", + "message.voicechat.incompatible_version": "Your voice chat client version is not compatible with the server-side version.\nPlease install version %s of %s.", + "message.voicechat.incompatible": "Your voice chat client version is not compatible with the server-side version.", + "message.voicechat.group_members": "Group members:", + "message.voicechat.no_group_members": "Empty group", + "message.voicechat.join_create_group": "Join or Create Group", + "message.voicechat.group_name": "Group Name", + "message.voicechat.leave_group": "Press to leave the group.", + "message.voicechat.not_in_group": "You are not in a group", + "message.voicechat.invite": "%s invited you to the group %s. %s", + "message.voicechat.accept_invite": "ACCEPT", + "message.voicechat.accept_invite.hover": "Click to accept the invitation", + "message.voicechat.join_successful": "Successfully joined the group %s", + "message.voicechat.leave_successful": "Successfully left the group", + "message.voicechat.groups_disabled": "Groups are disabled on this server", + "message.voicechat.recording_disabled": "Recording is disabled on this server", + "message.voicechat.invite_successful": "Successfully invited %s", + "message.voicechat.processing_recording_session": "Processing recording session...", + "message.voicechat.processing_progress": "Processing %s%%", + "message.voicechat.save_session": "Saved session to %s", + "message.voicechat.save_session_failed": "Failed to save recording session: %s", + "message.voicechat.recording_started": "Started Recording", + "message.voicechat.recording_stopped": "Stopped Recording", + "message.voicechat.open_folder": "Open folder", + "message.voicechat.storage_size": "Estimated disk space usage: %s.", + "message.voicechat.microphone_unavailable": "Microphone unavailable", + "message.voicechat.speaker_unavailable": "Speaker unavailable", + "message.voicechat.playback_unavailable": "Playback unavailable", + "message.voicechat.denoiser": "Noise Suppression: %s", + "message.voicechat.denoiser.on": "ON", + "message.voicechat.denoiser.off": "OFF", + "message.voicechat.group_type_title": "%s (%s)", + "message.voicechat.group_title": "%s", + "message.voicechat.group_does_not_exist": "Such a group does not exist", + "message.voicechat.group_name_not_unique": "Group name is ambiguous", + "message.voicechat.create": "Create", + "message.voicechat.create_group": "Create Group", + "message.voicechat.create_group_button": "Create Group", + "message.voicechat.optional_password": "Password (Optional)", + "message.voicechat.group_type": "Group Type", + "message.voicechat.group_type.normal": "Normal", + "message.voicechat.group_type.normal.description": "Players who are not in your group can't hear you, but you can hear them.", + "message.voicechat.group_type.open": "Open", + "message.voicechat.group_type.open.description": "Players who are not in your group can hear you, and you can hear them too.", + "message.voicechat.group_type.isolated": "Isolated", + "message.voicechat.group_type.isolated.description": "Players who are not in your group can't hear you, and you can't hear them either.", + "message.voicechat.join_group": "Join Group", + "message.voicechat.enter_group_password": "Enter Group Password", + "message.voicechat.password": "Password", + "message.voicechat.wrong_password": "Incorrect Password", + "message.voicechat.server_port": "Voice chat server hosted on port %s", + "message.voicechat.macos_no_mic_permission": "No permission to access your microphone. Please open System Settings > Privacy & Security and check the access options there", + "message.voicechat.macos_unsupported_launcher": "Your launcher does not support macOS microphone permissions", + "message.voicechat.player_no_voicechat": "%s does not have %s installed", + "message.voicechat.mute.enabled": "Press to unmute your microphone.", + "message.voicechat.mute.disabled": "Press to mute your microphone.", + "message.voicechat.mute.disabled_ptt": "You can't mute your microphone when using push to talk.", + "message.voicechat.disable.enabled": "Press to enable all voice chat sounds.", + "message.voicechat.disable.disabled": "Press to disable all voice chat sounds.", + "message.voicechat.disable.speaker_unavailable": "Speaker unavailable.", + "message.voicechat.hide_icons.enabled": "Press to show all voice chat icons.", + "message.voicechat.hide_icons.disabled": "Press to hide all voice chat icons.", + "message.voicechat.show_group_hud.enabled": "Press to hide the group chat HUD.", + "message.voicechat.show_group_hud.disabled": "Press to show the group chat HUD.", + "message.voicechat.recording.disabled": "Press to start recording.", + "message.voicechat.recording.enabled": "Press to stop recording.", + "message.voicechat.no_speak_permission": "You do not have permission to speak", + "message.voicechat.no_listen_permission": "You do not have permission to hear the voice chat", + "message.voicechat.no_group_permission": "You do not have permission to join groups", + "message.voicechat.search_hint": "Search...", + "message.voicechat.search_empty": "Couldn't find any players with that name", + "message.voicechat.other_volume": "Other", + "message.voicechat.other_volume.description": "The volume of any sound not listed below.", + "message.voicechat.more_members": "and %s more...", + "message.voicechat.no_groups": "No existing groups", + "message.voicechat.audio_type": "3D Audio: %s", + "message.voicechat.audio_type.normal": "Normal", + "message.voicechat.audio_type.reduced": "Reduced", + "message.voicechat.audio_type.off": "OFF", + "message.voicechat.invite_player": "Press to invite %s to your group.", + "message.voicechat.press_to_reassign_key": "Press to assign a key.", + "message.voicechat.native_error": "Some modules failed to load - Your Operating System might not be supported.", + "message.voicechat.set_up": "Press %s to set up", + "message.voicechat.onboarding.reset": "Onboarding status has been reset", + "message.voicechat.onboarding.next": "Next", + "message.voicechat.onboarding.confirm": "Confirm", + "message.voicechat.onboarding.back": "Back", + "message.voicechat.onboarding.cancel": "Cancel", + "message.voicechat.onboarding.introduction.title": "Set Up %s", + "message.voicechat.onboarding.introduction.description": "This setup guide will help you configure your voice chat.\n\nYou can skip it if you know what you are doing.", + "message.voicechat.onboarding.introduction.skip": "I Know What I Am Doing - Skip", + "message.voicechat.onboarding.skip.title": "Skip Setup", + "message.voicechat.onboarding.skip.description": "Are you sure you want to skip this setup guide?\n\nIf you skip it, you will have to adjust all the settings manually!", + "message.voicechat.onboarding.microphone": "Select Microphone", + "message.voicechat.onboarding.speaker": "Select Speaker", + "message.voicechat.onboarding.activation.title": "Select Activation Method", + "message.voicechat.onboarding.activation": "Please choose the method to activate your microphone.", + "message.voicechat.onboarding.activation.ptt": "When selecting %s, you need to press and hold a button to speak.", + "message.voicechat.onboarding.activation.ptt.name": "Push to Talk", + "message.voicechat.onboarding.activation.voice": "%s automatically activates your microphone when you speak.", + "message.voicechat.onboarding.activation.voice.name": "Voice Activation", + "message.voicechat.onboarding.ptt.title": "Choose Push to Talk Keybind", + "message.voicechat.onboarding.ptt.description": "Please choose the key that should be used to activate your microphone.", + "message.voicechat.onboarding.ptt.button_description": "Press to assign", + "message.voicechat.onboarding.voice.title": "Adjust Voice Activation", + "message.voicechat.onboarding.voice.description": "Enable microphone testing and make sure you can hear your voice when speaking. If this doesn't work, use manual voice activation and adjust the voice activation threshold.", + "message.voicechat.onboarding.final": "Finish Setup", + "message.voicechat.onboarding.final.description.success": "You have successfully configured your voice chat!\n\nOpen the voice chat menu with %s.", + "message.voicechat.onboarding.final.description.ptt": "Hold %s while speaking to use the voice chat.", + "message.voicechat.onboarding.final.description.voice": "You will be muted after exiting this screen. Press %s to unmute.", + "message.voicechat.onboarding.final.description.configuration": "You can always change all the settings in the voice chat menu.\nKeybinds, however, can be changed just like any other keybind in the game.", + "message.voicechat.onboarding.final.finish_setup": "Finish Setup", + "resourcepack.voicechat.classic_icons": "Classic Icons", + "resourcepack.voicechat.classic_icons.description": "Classic voice chat icons", + "resourcepack.voicechat.white_icons": "White Icons", + "resourcepack.voicechat.white_icons.description": "White voice chat icons", + "resourcepack.voicechat.black_icons": "Black Icons", + "resourcepack.voicechat.black_icons.description": "Black voice chat icons", + "cloth_config.voicechat.settings": "Voice Chat Settings", + "cloth_config.voicechat.category.general": "General", + "cloth_config.voicechat.category.audio": "Audio", + "cloth_config.voicechat.category.hud_icons": "HUD Icons", + "cloth_config.voicechat.category.group_chat_icons": "Group Chat Icons", + "cloth_config.voicechat.category.ingame_menu": "In-Game Menu", + "cloth_config.voicechat.config.recording_destination": "Recording destination", + "cloth_config.voicechat.config.recording_destination.description": "The location where recordings should be saved.\nLeave blank to use the default location.", + "cloth_config.voicechat.config.run_local_server": "Run in singleplayer or LAN worlds", + "cloth_config.voicechat.config.run_local_server.description": "If the voice chat should work in singleplayer or in worlds shared over LAN.", + "cloth_config.voicechat.config.offline_player_volume_adjustment": "Offline player volume adjustment", + "cloth_config.voicechat.config.offline_player_volume_adjustment.description": "If the volume adjustment interface should also display offline players.", + "cloth_config.voicechat.config.freecam_mode": "Freecam mode", + "cloth_config.voicechat.config.freecam_mode.description": "How listening to other players should work when using freecam mods.\nCAMERA: You will hear the voice chat around your camera. Whether you will still be able to hear the voice chat when the camera is far away from your character depends on the voice chat broadcast range of the server.\nPLAYER: You will hear the voice chat around your character no matter where your camera is.", + "cloth_config.voicechat.config.freecam_mode.camera": "Camera", + "cloth_config.voicechat.config.freecam_mode.player": "Player", + "cloth_config.voicechat.config.mute_on_join": "Mute on join", + "cloth_config.voicechat.config.mute_on_join.description": "If enabled, you will be automatically muted when joining a world.", + "cloth_config.voicechat.config.audio_packet_threshold": "Audio packet threshold", + "cloth_config.voicechat.config.audio_packet_threshold.description": "The maximum number of audio packets that should be held back if a packet arrives out of order or is dropped.\nThis prevents audio packets that are only slightly out of order from being discarded.\nSet this to 0 to disable.", + "cloth_config.voicechat.config.voice_deactivation_delay": "Microphone deactivation delay", + "cloth_config.voicechat.config.voice_deactivation_delay.description": "The time it takes for the microphone to deactivate when using voice activation.\nA value of 1 means 20 milliseconds, 2=40 ms, 3=60 ms, and so on.", + "cloth_config.voicechat.config.ptt_deactivation_delay": "Push to talk deactivation delay", + "cloth_config.voicechat.config.ptt_deactivation_delay.description": "The time it takes for the microphone to deactivate when using push to talk.\nA value of 1 means 20 milliseconds, 2=40 ms, 3=60 ms, and so on.", + "cloth_config.voicechat.config.output_buffer_size": "Output buffer size", + "cloth_config.voicechat.config.output_buffer_size.description": "The size of the audio output buffer (in packets).\nHigher values mean a higher latency but less crackling.\nIncrease this value if you have an unstable internet connection.", + "cloth_config.voicechat.config.show_nametag_icons": "Show voice chat name tag icons", + "cloth_config.voicechat.config.show_nametag_icons.description": "If the voice chat icons next to player names should be visible", + "cloth_config.voicechat.config.show_hud_icons": "Show voice chat HUD icons", + "cloth_config.voicechat.config.show_hud_icons.description": "If the voice chat icons on the HUD should be visible", + "cloth_config.voicechat.config.hud_icon_scale": "Voice chat HUD icon scale", + "cloth_config.voicechat.config.hud_icon_scale.description": "The scale of the icons in the voice chat HUD, such as microphone or connection status.", + "cloth_config.voicechat.config.hud_icon_pos_x": "Voice chat HUD icon X position", + "cloth_config.voicechat.config.hud_icon_pos_x.description": "The X position of the icons in the voice chat HUD.\nNegative values mean anchoring to the right instead.", + "cloth_config.voicechat.config.hud_icon_pos_y": "Voice chat HUD icon Y position", + "cloth_config.voicechat.config.hud_icon_pos_y.description": "The Y position of the icons in the voice chat HUD.\nNegative values mean anchoring to the bottom instead.", + "cloth_config.voicechat.config.group_player_icon_orientation": "Group chat HUD icon orientation", + "cloth_config.voicechat.config.group_player_icon_orientation.description": "The orientation of the player icons in the group chat HUD.", + "cloth_config.voicechat.config.group_player_icon_orientation.vertical": "Vertical", + "cloth_config.voicechat.config.group_player_icon_orientation.horizontal": "Horizontal", + "cloth_config.voicechat.config.group_hud_icon_scale": "Group chat HUD icon scale", + "cloth_config.voicechat.config.group_hud_icon_scale.description": "The scale of the player icons in the group chat HUD.", + "cloth_config.voicechat.config.group_player_icon_pos_x": "Group chat HUD icon X position", + "cloth_config.voicechat.config.group_player_icon_pos_x.description": "The X position of the player icons in the group chat HUD.\nNegative values mean anchoring to the right instead.", + "cloth_config.voicechat.config.group_player_icon_pos_y": "Group chat HUD icon Y position", + "cloth_config.voicechat.config.group_player_icon_pos_y.description": "The Y position of the player icons in the group chat HUD.\nNegative values mean anchoring to the bottom instead.", + "cloth_config.voicechat.config.show_own_group_icon": "Show yourself in the group chat HUD", + "cloth_config.voicechat.config.show_own_group_icon.description": "If your own player icon should be displayed in the group chat HUD when you are in a group." +} diff --git a/source/decompiled/de/maxhenkel/voicechat/FallbackTranslations.java b/source/decompiled/de/maxhenkel/voicechat/FallbackTranslations.java deleted file mode 100644 index b2e6438..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/FallbackTranslations.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -public class FallbackTranslations { - public static final Map FALLBACK_TRANSLATIONS; - - static { - HashMap translations = new HashMap(); - translations.put("key.category.voicechat.voicechat", "Voice Chat"); - translations.put("key.push_to_talk", "Push to Talk"); - translations.put("key.whisper", "Whisper"); - translations.put("key.mute_microphone", "Mute Microphone"); - translations.put("key.disable_voice_chat", "Disable Voice Chat"); - translations.put("key.hide_icons", "Hide Voice Chat Icons"); - translations.put("key.voice_chat_settings", "Voice Chat Settings"); - translations.put("key.voice_chat", "Voice Chat Menu"); - translations.put("key.voice_chat_group", "Group Management"); - translations.put("key.voice_chat_toggle_recording", "Toggle Recording"); - translations.put("key.voice_chat_adjust_volumes", "Adjust Volumes"); - translations.put("gui.voicechat.voice_chat.title", "Voice Chat"); - translations.put("gui.voicechat.voice_chat_settings.title", "Voice Chat Settings"); - translations.put("gui.voicechat.adjust_volume.title", "Adjust Volumes"); - translations.put("gui.voicechat.select_microphone.title", "Select Microphone"); - translations.put("gui.voicechat.select_speaker.title", "Select Speaker"); - translations.put("gui.voicechat.group.title", "Group Management"); - translations.put("gui.voicechat.join_create_group.title", "Join or Create Group"); - translations.put("gui.voicechat.create_group.title", "Create Group"); - translations.put("gui.voicechat.enter_password.title", "Enter Group Password"); - translations.put("message.voicechat.settings", "Settings"); - translations.put("message.voicechat.group", "Group"); - translations.put("message.voicechat.voice_chat_volume", "Voice Chat Volume: %s"); - translations.put("message.voicechat.gain", "Gain: %s"); - translations.put("message.voicechat.gain.auto", "Auto"); - translations.put("message.voicechat.gain.manual", "Manual"); - translations.put("message.voicechat.gain.manual.warning", "Please keep automatic microphone gain adjustment enabled to ensure consistent volume levels for everyone hearing you."); - translations.put("message.voicechat.microphone_gain", "Microphone Gain: %s dB"); - translations.put("message.voicechat.microphone_gain.warning", "Exceeding %s dB amplification may produce audio distortion and other issues!"); - translations.put("message.voicechat.mic_test_unavailable", "Microphone testing unavailable!"); - translations.put("message.voicechat.mic_test.disabled", "Press to enable microphone testing."); - translations.put("message.voicechat.mic_test.enabled", "Press to disable microphone testing."); - translations.put("message.voicechat.voice_chat_unavailable", "Voice chat unavailable"); - translations.put("message.voicechat.voice_chat_not_connected", "Voice chat not connected"); - translations.put("message.voicechat.activation_type", "Activation Method: %s"); - translations.put("message.voicechat.activation_type.ptt", "Push to Talk"); - translations.put("message.voicechat.activation_type.voice", "Voice"); - translations.put("message.voicechat.voice_activation_detection", "Voice Activation: %s"); - translations.put("message.voicechat.voice_activation_detection.auto", "Auto"); - translations.put("message.voicechat.voice_activation_detection.manual", "Manual"); - translations.put("message.voicechat.voice_activation", "Voice Activation Threshold: %s dB"); - translations.put("message.voicechat.voice_activation.disabled", "0 dB deactivates the microphone!"); - translations.put("message.voicechat.adjust_volumes", "Adjust Volumes"); - translations.put("message.voicechat.volume_amplification", "Amplification: %s"); - translations.put("message.voicechat.muted", "Muted"); - translations.put("message.voicechat.no_microphone", "No microphones available"); - translations.put("message.voicechat.default_microphone", "System Default"); - translations.put("message.voicechat.no_speaker", "No speakers available"); - translations.put("message.voicechat.default_speaker", "System Default"); - translations.put("message.voicechat.test_speaker", "Press to play a test sound."); - translations.put("message.voicechat.select_microphone", "Select Microphone"); - translations.put("message.voicechat.select_speaker", "Select Speaker"); - translations.put("message.voicechat.back", "Back"); - translations.put("message.voicechat.client_not_connected", "Client not connected"); - translations.put("message.voicechat.failed_to_send_ping", "Failed to send ping: %s"); - translations.put("message.voicechat.sending_ping", "Sending ping..."); - translations.put("message.voicechat.ping_sent_waiting", "Ping sent. Waiting for response..."); - translations.put("message.voicechat.ping_received", "Got a response in %s ms"); - translations.put("message.voicechat.ping_received_attempt", "Got a response in %s ms after %s attempts"); - translations.put("message.voicechat.ping_retry", "No response. Retrying..."); - translations.put("message.voicechat.ping_timed_out", "Request timed out after %s attempts"); - translations.put("message.voicechat.icons_hidden", "Voice chat icons hidden"); - translations.put("message.voicechat.icons_visible", "Voice chat icons visible"); - translations.put("message.voicechat.incompatible_version", "Your voice chat client version is not compatible with the server-side version.\nPlease install version %s of %s."); - translations.put("message.voicechat.incompatible", "Your voice chat client version is not compatible with the server-side version."); - translations.put("message.voicechat.group_members", "Group members:"); - translations.put("message.voicechat.no_group_members", "Empty group"); - translations.put("message.voicechat.join_create_group", "Join or Create Group"); - translations.put("message.voicechat.group_name", "Group Name"); - translations.put("message.voicechat.leave_group", "Press to leave the group."); - translations.put("message.voicechat.not_in_group", "You are not in a group"); - translations.put("message.voicechat.invite", "%s invited you to the group %s. %s"); - translations.put("message.voicechat.accept_invite", "ACCEPT"); - translations.put("message.voicechat.accept_invite.hover", "Click to accept the invitation"); - translations.put("message.voicechat.join_successful", "Successfully joined the group %s"); - translations.put("message.voicechat.leave_successful", "Successfully left the group"); - translations.put("message.voicechat.groups_disabled", "Groups are disabled on this server"); - translations.put("message.voicechat.recording_disabled", "Recording is disabled on this server"); - translations.put("message.voicechat.invite_successful", "Successfully invited %s"); - translations.put("message.voicechat.processing_recording_session", "Processing recording session..."); - translations.put("message.voicechat.processing_progress", "Processing %s%%"); - translations.put("message.voicechat.save_session", "Saved session to %s"); - translations.put("message.voicechat.save_session_failed", "Failed to save recording session: %s"); - translations.put("message.voicechat.recording_started", "Started Recording"); - translations.put("message.voicechat.recording_stopped", "Stopped Recording"); - translations.put("message.voicechat.open_folder", "Open folder"); - translations.put("message.voicechat.storage_size", "Estimated disk space usage: %s."); - translations.put("message.voicechat.microphone_unavailable", "Microphone unavailable"); - translations.put("message.voicechat.speaker_unavailable", "Speaker unavailable"); - translations.put("message.voicechat.playback_unavailable", "Playback unavailable"); - translations.put("message.voicechat.denoiser", "Noise Suppression: %s"); - translations.put("message.voicechat.denoiser.on", "ON"); - translations.put("message.voicechat.denoiser.off", "OFF"); - translations.put("message.voicechat.group_type_title", "%s (%s)"); - translations.put("message.voicechat.group_title", "%s"); - translations.put("message.voicechat.group_does_not_exist", "Such a group does not exist"); - translations.put("message.voicechat.group_name_not_unique", "Group name is ambiguous"); - translations.put("message.voicechat.create", "Create"); - translations.put("message.voicechat.create_group", "Create Group"); - translations.put("message.voicechat.create_group_button", "Create Group"); - translations.put("message.voicechat.optional_password", "Password (Optional)"); - translations.put("message.voicechat.group_type", "Group Type"); - translations.put("message.voicechat.group_type.normal", "Normal"); - translations.put("message.voicechat.group_type.normal.description", "Players who are not in your group can't hear you, but you can hear them."); - translations.put("message.voicechat.group_type.open", "Open"); - translations.put("message.voicechat.group_type.open.description", "Players who are not in your group can hear you, and you can hear them too."); - translations.put("message.voicechat.group_type.isolated", "Isolated"); - translations.put("message.voicechat.group_type.isolated.description", "Players who are not in your group can't hear you, and you can't hear them either."); - translations.put("message.voicechat.join_group", "Join Group"); - translations.put("message.voicechat.enter_group_password", "Enter Group Password"); - translations.put("message.voicechat.password", "Password"); - translations.put("message.voicechat.wrong_password", "Incorrect Password"); - translations.put("message.voicechat.server_port", "Voice chat server hosted on port %s"); - translations.put("message.voicechat.macos_no_mic_permission", "No permission to access your microphone. Please open System Settings > Privacy & Security and check the access options there"); - translations.put("message.voicechat.macos_unsupported_launcher", "Your launcher does not support macOS microphone permissions"); - translations.put("message.voicechat.player_no_voicechat", "%s does not have %s installed"); - translations.put("message.voicechat.mute.enabled", "Press to unmute your microphone."); - translations.put("message.voicechat.mute.disabled", "Press to mute your microphone."); - translations.put("message.voicechat.mute.disabled_ptt", "You can't mute your microphone when using push to talk."); - translations.put("message.voicechat.disable.enabled", "Press to enable all voice chat sounds."); - translations.put("message.voicechat.disable.disabled", "Press to disable all voice chat sounds."); - translations.put("message.voicechat.disable.speaker_unavailable", "Speaker unavailable."); - translations.put("message.voicechat.hide_icons.enabled", "Press to show all voice chat icons."); - translations.put("message.voicechat.hide_icons.disabled", "Press to hide all voice chat icons."); - translations.put("message.voicechat.show_group_hud.enabled", "Press to hide the group chat HUD."); - translations.put("message.voicechat.show_group_hud.disabled", "Press to show the group chat HUD."); - translations.put("message.voicechat.recording.disabled", "Press to start recording."); - translations.put("message.voicechat.recording.enabled", "Press to stop recording."); - translations.put("message.voicechat.no_speak_permission", "You do not have permission to speak"); - translations.put("message.voicechat.no_listen_permission", "You do not have permission to hear the voice chat"); - translations.put("message.voicechat.no_group_permission", "You do not have permission to join groups"); - translations.put("message.voicechat.search_hint", "Search..."); - translations.put("message.voicechat.search_empty", "Couldn't find any players with that name"); - translations.put("message.voicechat.other_volume", "Other"); - translations.put("message.voicechat.other_volume.description", "The volume of any sound not listed below."); - translations.put("message.voicechat.more_members", "and %s more..."); - translations.put("message.voicechat.no_groups", "No existing groups"); - translations.put("message.voicechat.audio_type", "3D Audio: %s"); - translations.put("message.voicechat.audio_type.normal", "Normal"); - translations.put("message.voicechat.audio_type.reduced", "Reduced"); - translations.put("message.voicechat.audio_type.off", "OFF"); - translations.put("message.voicechat.invite_player", "Press to invite %s to your group."); - translations.put("message.voicechat.press_to_reassign_key", "Press to assign a key."); - translations.put("message.voicechat.native_error", "Some modules failed to load - Your Operating System might not be supported."); - translations.put("message.voicechat.set_up", "Press %s to set up"); - translations.put("message.voicechat.onboarding.reset", "Onboarding status has been reset"); - translations.put("message.voicechat.onboarding.next", "Next"); - translations.put("message.voicechat.onboarding.confirm", "Confirm"); - translations.put("message.voicechat.onboarding.back", "Back"); - translations.put("message.voicechat.onboarding.cancel", "Cancel"); - translations.put("message.voicechat.onboarding.introduction.title", "Set Up %s"); - translations.put("message.voicechat.onboarding.introduction.description", "This setup guide will help you configure your voice chat.\n\nYou can skip it if you know what you are doing."); - translations.put("message.voicechat.onboarding.introduction.skip", "I Know What I Am Doing - Skip"); - translations.put("message.voicechat.onboarding.skip.title", "Skip Setup"); - translations.put("message.voicechat.onboarding.skip.description", "Are you sure you want to skip this setup guide?\n\nIf you skip it, you will have to adjust all the settings manually!"); - translations.put("message.voicechat.onboarding.microphone", "Select Microphone"); - translations.put("message.voicechat.onboarding.speaker", "Select Speaker"); - translations.put("message.voicechat.onboarding.activation.title", "Select Activation Method"); - translations.put("message.voicechat.onboarding.activation", "Please choose the method to activate your microphone."); - translations.put("message.voicechat.onboarding.activation.ptt", "When selecting %s, you need to press and hold a button to speak."); - translations.put("message.voicechat.onboarding.activation.ptt.name", "Push to Talk"); - translations.put("message.voicechat.onboarding.activation.voice", "%s automatically activates your microphone when you speak."); - translations.put("message.voicechat.onboarding.activation.voice.name", "Voice Activation"); - translations.put("message.voicechat.onboarding.ptt.title", "Choose Push to Talk Keybind"); - translations.put("message.voicechat.onboarding.ptt.description", "Please choose the key that should be used to activate your microphone."); - translations.put("message.voicechat.onboarding.ptt.button_description", "Press to assign"); - translations.put("message.voicechat.onboarding.voice.title", "Adjust Voice Activation"); - translations.put("message.voicechat.onboarding.voice.description", "Enable microphone testing and make sure you can hear your voice when speaking. If this doesn't work, use manual voice activation and adjust the voice activation threshold."); - translations.put("message.voicechat.onboarding.final", "Finish Setup"); - translations.put("message.voicechat.onboarding.final.description.success", "You have successfully configured your voice chat!\n\nOpen the voice chat menu with %s."); - translations.put("message.voicechat.onboarding.final.description.ptt", "Hold %s while speaking to use the voice chat."); - translations.put("message.voicechat.onboarding.final.description.voice", "You will be muted after exiting this screen. Press %s to unmute."); - translations.put("message.voicechat.onboarding.final.description.configuration", "You can always change all the settings in the voice chat menu.\nKeybinds, however, can be changed just like any other keybind in the game."); - translations.put("message.voicechat.onboarding.final.finish_setup", "Finish Setup"); - translations.put("resourcepack.voicechat.classic_icons", "Classic Icons"); - translations.put("resourcepack.voicechat.classic_icons.description", "Classic voice chat icons"); - translations.put("resourcepack.voicechat.white_icons", "White Icons"); - translations.put("resourcepack.voicechat.white_icons.description", "White voice chat icons"); - translations.put("resourcepack.voicechat.black_icons", "Black Icons"); - translations.put("resourcepack.voicechat.black_icons.description", "Black voice chat icons"); - translations.put("cloth_config.voicechat.settings", "Voice Chat Settings"); - translations.put("cloth_config.voicechat.category.general", "General"); - translations.put("cloth_config.voicechat.category.audio", "Audio"); - translations.put("cloth_config.voicechat.category.hud_icons", "HUD Icons"); - translations.put("cloth_config.voicechat.category.group_chat_icons", "Group Chat Icons"); - translations.put("cloth_config.voicechat.category.ingame_menu", "In-Game Menu"); - translations.put("cloth_config.voicechat.config.recording_destination", "Recording destination"); - translations.put("cloth_config.voicechat.config.recording_destination.description", "The location where recordings should be saved.\nLeave blank to use the default location."); - translations.put("cloth_config.voicechat.config.run_local_server", "Run in singleplayer or LAN worlds"); - translations.put("cloth_config.voicechat.config.run_local_server.description", "If the voice chat should work in singleplayer or in worlds shared over LAN."); - translations.put("cloth_config.voicechat.config.offline_player_volume_adjustment", "Offline player volume adjustment"); - translations.put("cloth_config.voicechat.config.offline_player_volume_adjustment.description", "If the volume adjustment interface should also display offline players."); - translations.put("cloth_config.voicechat.config.freecam_mode", "Freecam mode"); - translations.put("cloth_config.voicechat.config.freecam_mode.description", "How listening to other players should work when using freecam mods.\nCAMERA: You will hear the voice chat around your camera. Whether you will still be able to hear the voice chat when the camera is far away from your character depends on the voice chat broadcast range of the server.\nPLAYER: You will hear the voice chat around your character no matter where your camera is."); - translations.put("cloth_config.voicechat.config.freecam_mode.camera", "Camera"); - translations.put("cloth_config.voicechat.config.freecam_mode.player", "Player"); - translations.put("cloth_config.voicechat.config.mute_on_join", "Mute on join"); - translations.put("cloth_config.voicechat.config.mute_on_join.description", "If enabled, you will be automatically muted when joining a world."); - translations.put("cloth_config.voicechat.config.audio_packet_threshold", "Audio packet threshold"); - translations.put("cloth_config.voicechat.config.audio_packet_threshold.description", "The maximum number of audio packets that should be held back if a packet arrives out of order or is dropped.\nThis prevents audio packets that are only slightly out of order from being discarded.\nSet this to 0 to disable."); - translations.put("cloth_config.voicechat.config.voice_deactivation_delay", "Microphone deactivation delay"); - translations.put("cloth_config.voicechat.config.voice_deactivation_delay.description", "The time it takes for the microphone to deactivate when using voice activation.\nA value of 1 means 20 milliseconds, 2=40 ms, 3=60 ms, and so on."); - translations.put("cloth_config.voicechat.config.ptt_deactivation_delay", "Push to talk deactivation delay"); - translations.put("cloth_config.voicechat.config.ptt_deactivation_delay.description", "The time it takes for the microphone to deactivate when using push to talk.\nA value of 1 means 20 milliseconds, 2=40 ms, 3=60 ms, and so on."); - translations.put("cloth_config.voicechat.config.output_buffer_size", "Output buffer size"); - translations.put("cloth_config.voicechat.config.output_buffer_size.description", "The size of the audio output buffer (in packets).\nHigher values mean a higher latency but less crackling.\nIncrease this value if you have an unstable internet connection."); - translations.put("cloth_config.voicechat.config.show_nametag_icons", "Show voice chat name tag icons"); - translations.put("cloth_config.voicechat.config.show_nametag_icons.description", "If the voice chat icons next to player names should be visible"); - translations.put("cloth_config.voicechat.config.show_hud_icons", "Show voice chat HUD icons"); - translations.put("cloth_config.voicechat.config.show_hud_icons.description", "If the voice chat icons on the HUD should be visible"); - translations.put("cloth_config.voicechat.config.hud_icon_scale", "Voice chat HUD icon scale"); - translations.put("cloth_config.voicechat.config.hud_icon_scale.description", "The scale of the icons in the voice chat HUD, such as microphone or connection status."); - translations.put("cloth_config.voicechat.config.hud_icon_pos_x", "Voice chat HUD icon X position"); - translations.put("cloth_config.voicechat.config.hud_icon_pos_x.description", "The X position of the icons in the voice chat HUD.\nNegative values mean anchoring to the right instead."); - translations.put("cloth_config.voicechat.config.hud_icon_pos_y", "Voice chat HUD icon Y position"); - translations.put("cloth_config.voicechat.config.hud_icon_pos_y.description", "The Y position of the icons in the voice chat HUD.\nNegative values mean anchoring to the bottom instead."); - translations.put("cloth_config.voicechat.config.group_player_icon_orientation", "Group chat HUD icon orientation"); - translations.put("cloth_config.voicechat.config.group_player_icon_orientation.description", "The orientation of the player icons in the group chat HUD."); - translations.put("cloth_config.voicechat.config.group_player_icon_orientation.vertical", "Vertical"); - translations.put("cloth_config.voicechat.config.group_player_icon_orientation.horizontal", "Horizontal"); - translations.put("cloth_config.voicechat.config.group_hud_icon_scale", "Group chat HUD icon scale"); - translations.put("cloth_config.voicechat.config.group_hud_icon_scale.description", "The scale of the player icons in the group chat HUD."); - translations.put("cloth_config.voicechat.config.group_player_icon_pos_x", "Group chat HUD icon X position"); - translations.put("cloth_config.voicechat.config.group_player_icon_pos_x.description", "The X position of the player icons in the group chat HUD.\nNegative values mean anchoring to the right instead."); - translations.put("cloth_config.voicechat.config.group_player_icon_pos_y", "Group chat HUD icon Y position"); - translations.put("cloth_config.voicechat.config.group_player_icon_pos_y.description", "The Y position of the player icons in the group chat HUD.\nNegative values mean anchoring to the bottom instead."); - translations.put("cloth_config.voicechat.config.show_own_group_icon", "Show yourself in the group chat HUD"); - translations.put("cloth_config.voicechat.config.show_own_group_icon.description", "If your own player icon should be displayed in the group chat HUD when you are in a group."); - FALLBACK_TRANSLATIONS = Collections.unmodifiableMap(translations); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/Voicechat.java b/source/decompiled/de/maxhenkel/voicechat/Voicechat.java deleted file mode 100644 index 366a02a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/Voicechat.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.Bukkit - * org.bukkit.command.CommandExecutor - * org.bukkit.command.PluginCommand - * org.bukkit.command.TabCompleter - * org.bukkit.event.Listener - * org.bukkit.plugin.Plugin - * org.bukkit.plugin.ServicePriority - * org.bukkit.plugin.java.JavaPlugin - */ -package de.maxhenkel.voicechat; - -import de.maxhenkel.voicechat.BuildConstants; -import de.maxhenkel.voicechat.api.BukkitVoicechatService; -import de.maxhenkel.voicechat.command.VoiceChatCommands; -import de.maxhenkel.voicechat.commodore.Commodore; -import de.maxhenkel.voicechat.commodore.CommodoreProvider; -import de.maxhenkel.voicechat.compatibility.BukkitCompatibilityManager; -import de.maxhenkel.voicechat.compatibility.Compatibility; -import de.maxhenkel.voicechat.config.ServerConfig; -import de.maxhenkel.voicechat.config.Translations; -import de.maxhenkel.voicechat.configbuilder.ConfigBuilder; -import de.maxhenkel.voicechat.integration.commodore.CommodoreCommands; -import de.maxhenkel.voicechat.integration.commodore.MissingArgumentTypeException; -import de.maxhenkel.voicechat.integration.placeholderapi.VoicechatExpansion; -import de.maxhenkel.voicechat.integration.viaversion.ViaVersionCompatibility; -import de.maxhenkel.voicechat.logging.JavaLoggingLogger; -import de.maxhenkel.voicechat.logging.VoicechatLogger; -import de.maxhenkel.voicechat.net.NetManager; -import de.maxhenkel.voicechat.plugins.PluginManager; -import de.maxhenkel.voicechat.plugins.impl.BukkitVoicechatServiceImpl; -import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; -import de.maxhenkel.voicechat.voice.server.ServerVoiceEvents; -import java.util.regex.Pattern; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.PluginCommand; -import org.bukkit.command.TabCompleter; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.ServicePriority; -import org.bukkit.plugin.java.JavaPlugin; - -public final class Voicechat -extends JavaPlugin { - public static Voicechat INSTANCE; - public static final String MODID = "voicechat"; - public static VoicechatLogger LOGGER; - public static int COMPATIBILITY_VERSION; - public static ServerConfig SERVER_CONFIG; - public static Translations TRANSLATIONS; - public static ServerVoiceEvents SERVER; - public static BukkitVoicechatServiceImpl apiService; - public static NetManager netManager; - public static Compatibility compatibility; - public static final int MAX_GROUP_NAME_LENGTH = 24; - public static final Pattern GROUP_REGEX; - - public void onEnable() { - block17: { - INSTANCE = this; - LOGGER = new JavaLoggingLogger(this.getLogger()); - if (Voicechat.debugMode()) { - LOGGER.warn("Running in debug mode - Don't leave this enabled in production!", new Object[0]); - } - try { - compatibility = BukkitCompatibilityManager.loadCompatibility(); - if (compatibility == null) { - this.disablePlugin(); - return; - } - } - catch (Throwable t) { - LOGGER.fatal("An unexpected error occurred while loading compatibility", t); - this.disablePlugin(); - return; - } - LOGGER.info("Compatibility version {}", COMPATIBILITY_VERSION); - SERVER_CONFIG = ConfigBuilder.builder(ServerConfig::new).path(this.getDataFolder().toPath().resolve("voicechat-server.properties")).build(); - TRANSLATIONS = ConfigBuilder.builder(Translations::new).path(this.getDataFolder().toPath().resolve("translations.properties")).build(); - netManager = new NetManager(); - netManager.onEnable(); - apiService = new BukkitVoicechatServiceImpl(); - this.getServer().getServicesManager().register(BukkitVoicechatService.class, (Object)apiService, (Plugin)this, ServicePriority.Normal); - PluginCommand voicechatCommand = this.getCommand(MODID); - if (voicechatCommand != null) { - VoiceChatCommands voiceChatCommands = new VoiceChatCommands(); - voicechatCommand.setExecutor((CommandExecutor)voiceChatCommands); - voicechatCommand.setTabCompleter((TabCompleter)voiceChatCommands); - try { - if (CommodoreProvider.isSupported()) { - Commodore commodore = CommodoreProvider.getCommodore((Plugin)this); - CommodoreCommands.registerCompletions(commodore); - LOGGER.info("Successfully initialized commodore command completion", new Object[0]); - break block17; - } - LOGGER.warn("Commodore command completion is not supported", new Object[0]); - } - catch (MissingArgumentTypeException t) { - LOGGER.warn("Failed to initialize commodore command completion: {}", t.getMessage()); - } - catch (Throwable t) { - LOGGER.warn("Failed to initialize commodore command completion", t); - } - } else { - LOGGER.error("Failed to register commands", new Object[0]); - } - } - try { - if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { - new VoicechatExpansion().register(); - LOGGER.info("Successfully registered PlaceholderAPI expansion", new Object[0]); - } - } - catch (Throwable t) { - LOGGER.error("Failed to register PlaceholderAPI expansion", t); - } - try { - if (Bukkit.getPluginManager().getPlugin("ViaVersion") != null) { - ViaVersionCompatibility.register(); - LOGGER.info("Successfully added ViaVersion mappings", new Object[0]); - } - } - catch (Throwable t) { - LOGGER.error("Failed to add ViaVersion mappings", t); - } - if (System.getProperty("VOICECHAT_RELOADED") != null) { - LOGGER.error("{} does not support reloads! Expect that things will break!", "Simple Voice Chat"); - } - System.setProperty("VOICECHAT_RELOADED", "true"); - compatibility.runTask(() -> { - SERVER = new ServerVoiceEvents(); - PluginManager.instance().init(); - SERVER.init(); - Bukkit.getPluginManager().registerEvents((Listener)SERVER, (Plugin)this); - ServerPlayerManager.init((Plugin)this); - }); - } - - private void disablePlugin() { - LOGGER.fatal("Disabling {}", "Simple Voice Chat"); - Bukkit.getPluginManager().disablePlugin((Plugin)this); - } - - public void onDisable() { - if (netManager != null) { - netManager.onDisable(); - } - this.getServer().getServicesManager().unregister((Object)apiService); - if (SERVER != null) { - SERVER.getServer().close(); - } - } - - public static boolean debugMode() { - return System.getProperty("voicechat.debug") != null; - } - - static { - COMPATIBILITY_VERSION = BuildConstants.COMPATIBILITY_VERSION; - GROUP_REGEX = Pattern.compile("^[^\\p{C}\\s][^\\p{C}]{0,23}$"); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/BukkitVoicechatService.java b/source/decompiled/de/maxhenkel/voicechat/api/BukkitVoicechatService.java deleted file mode 100644 index 2a519a9..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/BukkitVoicechatService.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.VoicechatPlugin; - -public interface BukkitVoicechatService { - public void registerPlugin(VoicechatPlugin var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/ClientVoicechatSocket.java b/source/decompiled/de/maxhenkel/voicechat/api/ClientVoicechatSocket.java deleted file mode 100644 index b163f31..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/ClientVoicechatSocket.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.RawUdpPacket; -import java.net.SocketAddress; - -public interface ClientVoicechatSocket { - public void open() throws Exception; - - public RawUdpPacket read() throws Exception; - - public void send(byte[] var1, SocketAddress var2) throws Exception; - - public void close(); - - public boolean isClosed(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/Entity.java b/source/decompiled/de/maxhenkel/voicechat/api/Entity.java deleted file mode 100644 index 32c9adc..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/Entity.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Position; -import java.util.UUID; - -public interface Entity { - public UUID getUuid(); - - public Object getEntity(); - - public Position getPosition(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/Group.java b/source/decompiled/de/maxhenkel/voicechat/api/Group.java deleted file mode 100644 index b80c830..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/Group.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api; - -import java.util.UUID; -import javax.annotation.Nullable; - -public interface Group { - public String getName(); - - public boolean hasPassword(); - - public UUID getId(); - - public boolean isPersistent(); - - public boolean isHidden(); - - public Type getType(); - - public static interface Builder { - public Builder setId(@Nullable UUID var1); - - public Builder setName(String var1); - - public Builder setPassword(@Nullable String var1); - - public Builder setPersistent(boolean var1); - - public Builder setHidden(boolean var1); - - public Builder setType(Type var1); - - public Group build(); - } - - public static interface Type { - public static final Type NORMAL = new Type(){}; - public static final Type OPEN = new Type(){}; - public static final Type ISOLATED = new Type(){}; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/Player.java b/source/decompiled/de/maxhenkel/voicechat/api/Player.java deleted file mode 100644 index c268ecb..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/Player.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Entity; - -public interface Player -extends Entity { - public Object getPlayer(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/Position.java b/source/decompiled/de/maxhenkel/voicechat/api/Position.java deleted file mode 100644 index 1a9eff9..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/Position.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -public interface Position { - public double getX(); - - public double getY(); - - public double getZ(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/RawUdpPacket.java b/source/decompiled/de/maxhenkel/voicechat/api/RawUdpPacket.java deleted file mode 100644 index dedfd17..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/RawUdpPacket.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import java.net.SocketAddress; - -public interface RawUdpPacket { - public byte[] getData(); - - public long getTimestamp(); - - public SocketAddress getSocketAddress(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/ServerLevel.java b/source/decompiled/de/maxhenkel/voicechat/api/ServerLevel.java deleted file mode 100644 index ac3d59f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/ServerLevel.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -public interface ServerLevel { - public Object getServerLevel(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/ServerPlayer.java b/source/decompiled/de/maxhenkel/voicechat/api/ServerPlayer.java deleted file mode 100644 index 7a2b933..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/ServerPlayer.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Player; -import de.maxhenkel.voicechat.api.ServerLevel; - -public interface ServerPlayer -extends Player { - public ServerLevel getServerLevel(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatApi.java b/source/decompiled/de/maxhenkel/voicechat/api/VoicechatApi.java deleted file mode 100644 index 54cfc12..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatApi.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Entity; -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.ServerLevel; -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.audio.AudioConverter; -import de.maxhenkel.voicechat.api.mp3.Mp3Decoder; -import de.maxhenkel.voicechat.api.mp3.Mp3Encoder; -import de.maxhenkel.voicechat.api.opus.OpusDecoder; -import de.maxhenkel.voicechat.api.opus.OpusEncoder; -import de.maxhenkel.voicechat.api.opus.OpusEncoderMode; -import java.io.InputStream; -import java.io.OutputStream; -import javax.annotation.Nullable; -import javax.sound.sampled.AudioFormat; - -public interface VoicechatApi { - public OpusEncoder createEncoder(); - - public OpusEncoder createEncoder(OpusEncoderMode var1); - - public OpusDecoder createDecoder(); - - @Nullable - public Mp3Encoder createMp3Encoder(AudioFormat var1, int var2, int var3, OutputStream var4); - - @Nullable - public Mp3Decoder createMp3Decoder(InputStream var1); - - public AudioConverter getAudioConverter(); - - public Entity fromEntity(Object var1); - - public ServerLevel fromServerLevel(Object var1); - - public ServerPlayer fromServerPlayer(Object var1); - - public Position createPosition(double var1, double var3, double var5); - - public VolumeCategory.Builder volumeCategoryBuilder(); - - public double getVoiceChatDistance(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatClientApi.java b/source/decompiled/de/maxhenkel/voicechat/api/VoicechatClientApi.java deleted file mode 100644 index 9885918..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatClientApi.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Entity; -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.VoicechatApi; -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.audiochannel.ClientEntityAudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.ClientLocationalAudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.ClientStaticAudioChannel; -import de.maxhenkel.voicechat.api.config.ConfigAccessor; -import de.maxhenkel.voicechat.api.config.VolumeConfigAccessor; -import java.util.UUID; -import javax.annotation.Nullable; - -public interface VoicechatClientApi -extends VoicechatApi { - public boolean isMuted(); - - default public boolean isDisabled() { - return this.isDisabled(null); - } - - public boolean isDisabled(@Nullable UUID var1); - - default public boolean isDisconnected() { - return this.isDisconnected(null); - } - - public boolean isDisconnected(@Nullable UUID var1); - - default public boolean isTalking() { - return this.isTalking(null); - } - - public boolean isTalking(@Nullable UUID var1); - - default public boolean isWhispering() { - return this.isWhispering(null); - } - - public boolean isWhispering(@Nullable UUID var1); - - public boolean isPushToTalkKeyPressed(); - - public boolean isWhisperKeyPressed(); - - @Nullable - public Group getGroup(); - - @Deprecated - public ClientEntityAudioChannel createEntityAudioChannel(UUID var1); - - public ClientEntityAudioChannel createEntityAudioChannel(UUID var1, Entity var2); - - public ClientLocationalAudioChannel createLocationalAudioChannel(UUID var1, Position var2); - - public ClientStaticAudioChannel createStaticAudioChannel(UUID var1); - - public void registerClientVolumeCategory(VolumeCategory var1); - - default public void unregisterClientVolumeCategory(VolumeCategory category) { - this.unregisterClientVolumeCategory(category.getId()); - } - - public void unregisterClientVolumeCategory(String var1); - - public ConfigAccessor getClientConfig(); - - public VolumeConfigAccessor getVolumeConfig(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatConnection.java b/source/decompiled/de/maxhenkel/voicechat/api/VoicechatConnection.java deleted file mode 100644 index 8c01fcc..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatConnection.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.ServerPlayer; -import javax.annotation.Nullable; - -public interface VoicechatConnection { - @Nullable - public Group getGroup(); - - public boolean isInGroup(); - - public void setGroup(@Nullable Group var1); - - public boolean isConnected(); - - public void setConnected(boolean var1); - - public boolean isDisabled(); - - public void setDisabled(boolean var1); - - public boolean isInstalled(); - - public ServerPlayer getPlayer(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatPlugin.java b/source/decompiled/de/maxhenkel/voicechat/api/VoicechatPlugin.java deleted file mode 100644 index 994a104..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatPlugin.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.VoicechatApi; -import de.maxhenkel.voicechat.api.events.EventRegistration; - -public interface VoicechatPlugin { - public String getPluginId(); - - default public void initialize(VoicechatApi api) { - } - - default public void registerEvents(EventRegistration registration) { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatServerApi.java b/source/decompiled/de/maxhenkel/voicechat/api/VoicechatServerApi.java deleted file mode 100644 index 4006362..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatServerApi.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.Entity; -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.ServerLevel; -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.VoicechatApi; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.AudioPlayer; -import de.maxhenkel.voicechat.api.audiochannel.EntityAudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.LocationalAudioChannel; -import de.maxhenkel.voicechat.api.audiochannel.StaticAudioChannel; -import de.maxhenkel.voicechat.api.audiolistener.AudioListener; -import de.maxhenkel.voicechat.api.audiolistener.PlayerAudioListener; -import de.maxhenkel.voicechat.api.audiosender.AudioSender; -import de.maxhenkel.voicechat.api.config.ConfigAccessor; -import de.maxhenkel.voicechat.api.opus.OpusEncoder; -import de.maxhenkel.voicechat.api.packets.ConvertablePacket; -import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; -import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; -import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; -import java.util.Collection; -import java.util.UUID; -import java.util.function.Predicate; -import java.util.function.Supplier; -import javax.annotation.Nullable; - -public interface VoicechatServerApi -extends VoicechatApi { - public void sendEntitySoundPacketTo(VoicechatConnection var1, EntitySoundPacket var2); - - public void sendLocationalSoundPacketTo(VoicechatConnection var1, LocationalSoundPacket var2); - - public void sendStaticSoundPacketTo(VoicechatConnection var1, StaticSoundPacket var2); - - public ConvertablePacket createPacket(); - - @Nullable - public EntityAudioChannel createEntityAudioChannel(UUID var1, Entity var2); - - @Nullable - public LocationalAudioChannel createLocationalAudioChannel(UUID var1, ServerLevel var2, Position var3); - - @Deprecated - @Nullable - public StaticAudioChannel createStaticAudioChannel(UUID var1, ServerLevel var2, VoicechatConnection var3); - - @Nullable - public StaticAudioChannel createStaticAudioChannel(UUID var1); - - public AudioPlayer createAudioPlayer(AudioChannel var1, OpusEncoder var2, Supplier var3); - - public AudioPlayer createAudioPlayer(AudioChannel var1, OpusEncoder var2, short[] var3); - - public AudioSender createAudioSender(VoicechatConnection var1); - - public boolean registerAudioSender(AudioSender var1); - - public boolean unregisterAudioSender(AudioSender var1); - - public PlayerAudioListener.Builder playerAudioListenerBuilder(); - - public boolean registerAudioListener(AudioListener var1); - - public boolean unregisterAudioListener(AudioListener var1); - - public boolean unregisterAudioListener(UUID var1); - - @Nullable - public VoicechatConnection getConnectionOf(UUID var1); - - @Nullable - default public VoicechatConnection getConnectionOf(ServerPlayer player) { - return this.getConnectionOf(player.getUuid()); - } - - @Deprecated - public Group createGroup(String var1, @Nullable String var2); - - @Deprecated - public Group createGroup(String var1, @Nullable String var2, boolean var3); - - public Group.Builder groupBuilder(); - - public boolean removeGroup(UUID var1); - - @Nullable - public Group getGroup(UUID var1); - - public Collection getGroups(); - - @Nullable - @Deprecated - public UUID getSecret(UUID var1); - - public Collection getPlayersInRange(ServerLevel var1, Position var2, double var3, Predicate var5); - - public double getBroadcastRange(); - - default public Collection getPlayersInRange(ServerLevel level, Position pos, double range) { - return this.getPlayersInRange(level, pos, range, null); - } - - public void registerVolumeCategory(VolumeCategory var1); - - default public void unregisterVolumeCategory(VolumeCategory category) { - this.unregisterVolumeCategory(category.getId()); - } - - public void unregisterVolumeCategory(String var1); - - public Collection getVolumeCategories(); - - public ConfigAccessor getServerConfig(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatSocket.java b/source/decompiled/de/maxhenkel/voicechat/api/VoicechatSocket.java deleted file mode 100644 index e975a0e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VoicechatSocket.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api; - -import de.maxhenkel.voicechat.api.RawUdpPacket; -import java.net.SocketAddress; - -public interface VoicechatSocket { - public void open(int var1, String var2) throws Exception; - - public RawUdpPacket read() throws Exception; - - public void send(byte[] var1, SocketAddress var2) throws Exception; - - public int getLocalPort(); - - public void close(); - - public boolean isClosed(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/VolumeCategory.java b/source/decompiled/de/maxhenkel/voicechat/api/VolumeCategory.java deleted file mode 100644 index f5edbdf..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/VolumeCategory.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api; - -import javax.annotation.Nullable; - -public interface VolumeCategory { - public String getId(); - - public String getName(); - - @Nullable - public String getNameTranslationKey(); - - @Nullable - public String getDescription(); - - @Nullable - public String getDescriptionTranslationKey(); - - @Nullable - public int[][] getIcon(); - - public static interface Builder { - public Builder setId(String var1); - - public Builder setName(String var1); - - public Builder setNameTranslationKey(@Nullable String var1); - - public Builder setDescription(@Nullable String var1); - - public Builder setDescriptionTranslationKey(@Nullable String var1); - - public Builder setIcon(@Nullable int[][] var1); - - public VolumeCategory build(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audio/AudioConverter.java b/source/decompiled/de/maxhenkel/voicechat/api/audio/AudioConverter.java deleted file mode 100644 index 36ac212..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audio/AudioConverter.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audio; - -public interface AudioConverter { - public short[] bytesToShorts(byte[] var1); - - public byte[] shortsToBytes(short[] var1); - - public short[] floatsToShorts(float[] var1); - - public float[] shortsToFloats(short[] var1); - - public byte[] floatsToBytes(float[] var1); - - public float[] bytesToFloats(byte[] var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/AudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/AudioChannel.java deleted file mode 100644 index 8cf5367..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/AudioChannel.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.packets.MicrophonePacket; -import java.util.UUID; -import java.util.function.Predicate; -import javax.annotation.Nullable; - -public interface AudioChannel { - public void send(byte[] var1); - - public void send(MicrophonePacket var1); - - public void setFilter(Predicate var1); - - public void flush(); - - public boolean isClosed(); - - public UUID getId(); - - @Nullable - public String getCategory(); - - public void setCategory(@Nullable String var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/AudioPlayer.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/AudioPlayer.java deleted file mode 100644 index c330938..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/AudioPlayer.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -public interface AudioPlayer { - public void startPlaying(); - - public void stopPlaying(); - - public boolean isStarted(); - - public boolean isPlaying(); - - public boolean isStopped(); - - public void setOnStopped(Runnable var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientAudioChannel.java deleted file mode 100644 index a6e3bf3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientAudioChannel.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import java.util.UUID; -import javax.annotation.Nullable; - -public interface ClientAudioChannel { - public UUID getId(); - - public void play(short[] var1); - - @Nullable - public String getCategory(); - - public void setCategory(@Nullable String var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientEntityAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientEntityAudioChannel.java deleted file mode 100644 index d1d3d39..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientEntityAudioChannel.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.audiochannel.ClientAudioChannel; -import java.util.UUID; - -public interface ClientEntityAudioChannel -extends ClientAudioChannel { - public UUID getEntityId(); - - public void setWhispering(boolean var1); - - public boolean isWhispering(); - - public float getDistance(); - - public void setDistance(float var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientLocationalAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientLocationalAudioChannel.java deleted file mode 100644 index 33c4e9f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientLocationalAudioChannel.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.audiochannel.ClientAudioChannel; - -public interface ClientLocationalAudioChannel -extends ClientAudioChannel { - public Position getLocation(); - - public void setLocation(Position var1); - - public float getDistance(); - - public void setDistance(float var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientStaticAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientStaticAudioChannel.java deleted file mode 100644 index 11e7b86..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/ClientStaticAudioChannel.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.audiochannel.ClientAudioChannel; - -public interface ClientStaticAudioChannel -extends ClientAudioChannel { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/EntityAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/EntityAudioChannel.java deleted file mode 100644 index d9424b6..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/EntityAudioChannel.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.Entity; -import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; - -public interface EntityAudioChannel -extends AudioChannel { - public boolean isWhispering(); - - public void setWhispering(boolean var1); - - public void updateEntity(Entity var1); - - public Entity getEntity(); - - public float getDistance(); - - public void setDistance(float var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/LocationalAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/LocationalAudioChannel.java deleted file mode 100644 index 06e1d8b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/LocationalAudioChannel.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; - -public interface LocationalAudioChannel -extends AudioChannel { - public void updateLocation(Position var1); - - public Position getLocation(); - - public float getDistance(); - - public void setDistance(float var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/StaticAudioChannel.java b/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/StaticAudioChannel.java deleted file mode 100644 index b14ed16..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiochannel/StaticAudioChannel.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiochannel; - -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.audiochannel.AudioChannel; - -public interface StaticAudioChannel -extends AudioChannel { - public void setBypassGroupIsolation(boolean var1); - - public boolean bypassesGroupIsolation(); - - public void addTarget(VoicechatConnection var1); - - public void removeTarget(VoicechatConnection var1); - - public void clearTargets(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiolistener/PlayerAudioListener.java b/source/decompiled/de/maxhenkel/voicechat/api/audiolistener/PlayerAudioListener.java deleted file mode 100644 index 9755797..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiolistener/PlayerAudioListener.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiolistener; - -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.audiolistener.AudioListener; -import de.maxhenkel.voicechat.api.packets.SoundPacket; -import java.util.UUID; -import java.util.function.Consumer; - -public interface PlayerAudioListener -extends AudioListener { - public UUID getPlayerUuid(); - - public static interface Builder { - public Builder setPlayer(ServerPlayer var1); - - public Builder setPlayer(UUID var1); - - public Builder setPacketListener(Consumer var1); - - public PlayerAudioListener build(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/audiosender/AudioSender.java b/source/decompiled/de/maxhenkel/voicechat/api/audiosender/AudioSender.java deleted file mode 100644 index ed8d313..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/audiosender/AudioSender.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.audiosender; - -public interface AudioSender { - public AudioSender whispering(boolean var1); - - public boolean isWhispering(); - - public AudioSender sequenceNumber(long var1); - - public boolean canSend(); - - public boolean send(byte[] var1); - - public boolean reset(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/config/ConfigAccessor.java b/source/decompiled/de/maxhenkel/voicechat/api/config/ConfigAccessor.java deleted file mode 100644 index e8c488e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/config/ConfigAccessor.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.config; - -import javax.annotation.Nullable; - -public interface ConfigAccessor { - public boolean hasKey(String var1); - - @Nullable - public String getValue(String var1); - - default public String getString(String key, String def) { - String value = this.getValue(key); - if (value == null) { - return def; - } - return value; - } - - default public boolean getBoolean(String key, boolean def) { - String value = this.getValue(key); - if (value == null) { - return def; - } - return Boolean.parseBoolean(value); - } - - default public int getInt(String key, int def) { - String value = this.getValue(key); - if (value == null) { - return def; - } - return Integer.parseInt(value); - } - - default public double getDouble(String key, double def) { - String value = this.getValue(key); - if (value == null) { - return def; - } - return Double.parseDouble(value); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/config/VolumeConfigAccessor.java b/source/decompiled/de/maxhenkel/voicechat/api/config/VolumeConfigAccessor.java deleted file mode 100644 index 466ad3e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/config/VolumeConfigAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.config; - -import java.util.UUID; - -public interface VolumeConfigAccessor { - public double getVolume(UUID var1); - - public double getCategoryVolume(String var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/ClientEvent.java deleted file mode 100644 index 0e00374..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatClientApi; -import de.maxhenkel.voicechat.api.events.Event; - -public interface ClientEvent -extends Event { - public VoicechatClientApi getVoicechat(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientReceiveSoundEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/ClientReceiveSoundEvent.java deleted file mode 100644 index 4806bd9..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientReceiveSoundEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.events.ClientEvent; -import java.util.UUID; -import javax.annotation.Nullable; - -public interface ClientReceiveSoundEvent -extends ClientEvent { - public UUID getId(); - - public short[] getRawAudio(); - - public void setRawAudio(@Nullable short[] var1); - - public static interface StaticSound - extends ClientReceiveSoundEvent { - } - - public static interface LocationalSound - extends ClientReceiveSoundEvent { - public Position getPosition(); - - public float getDistance(); - } - - public static interface EntitySound - extends ClientReceiveSoundEvent { - public UUID getEntityId(); - - public boolean isWhispering(); - - public float getDistance(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientSoundEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/ClientSoundEvent.java deleted file mode 100644 index 494e7ff..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientSoundEvent.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface ClientSoundEvent -extends ClientEvent { - public short[] getRawAudio(); - - public void setRawAudio(short[] var1); - - public boolean isWhispering(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientVoicechatConnectionEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/ClientVoicechatConnectionEvent.java deleted file mode 100644 index 994b730..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientVoicechatConnectionEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface ClientVoicechatConnectionEvent -extends ClientEvent { - public boolean isConnected(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientVoicechatInitializationEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/ClientVoicechatInitializationEvent.java deleted file mode 100644 index 6134ce7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/ClientVoicechatInitializationEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.ClientVoicechatSocket; -import de.maxhenkel.voicechat.api.events.ClientEvent; -import javax.annotation.Nullable; - -public interface ClientVoicechatInitializationEvent -extends ClientEvent { - public void setSocketImplementation(ClientVoicechatSocket var1); - - @Nullable - public ClientVoicechatSocket getSocketImplementation(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/CreateGroupEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/CreateGroupEvent.java deleted file mode 100644 index f0cd60d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/CreateGroupEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.GroupEvent; -import javax.annotation.Nullable; - -public interface CreateGroupEvent -extends GroupEvent { - @Override - public Group getGroup(); - - @Override - @Nullable - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/CreateOpenALContextEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/CreateOpenALContextEvent.java deleted file mode 100644 index 15ea83e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/CreateOpenALContextEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface CreateOpenALContextEvent -extends ClientEvent { - public long getContext(); - - public long getDevice(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/DestroyOpenALContextEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/DestroyOpenALContextEvent.java deleted file mode 100644 index 5e8004a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/DestroyOpenALContextEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface DestroyOpenALContextEvent -extends ClientEvent { - public long getContext(); - - public long getDevice(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/EntitySoundPacketEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/EntitySoundPacketEvent.java deleted file mode 100644 index fb5c416..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/EntitySoundPacketEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.SoundPacketEvent; -import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; - -public interface EntitySoundPacketEvent -extends SoundPacketEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/Event.java b/source/decompiled/de/maxhenkel/voicechat/api/events/Event.java deleted file mode 100644 index 81d99fc..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/Event.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -public interface Event { - public boolean isCancellable(); - - public boolean cancel(); - - public boolean isCancelled(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/EventRegistration.java b/source/decompiled/de/maxhenkel/voicechat/api/events/EventRegistration.java deleted file mode 100644 index 784a374..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/EventRegistration.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.Event; -import java.util.function.Consumer; - -public interface EventRegistration { - public void registerEvent(Class var1, Consumer var2, int var3); - - default public void registerEvent(Class eventClass, Consumer onPacket) { - this.registerEvent(eventClass, onPacket, 0); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/GroupEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/GroupEvent.java deleted file mode 100644 index 4405f6d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/GroupEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.ServerEvent; -import javax.annotation.Nullable; - -public interface GroupEvent -extends ServerEvent { - @Nullable - public Group getGroup(); - - @Nullable - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/JoinGroupEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/JoinGroupEvent.java deleted file mode 100644 index 9912984..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/JoinGroupEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.GroupEvent; - -public interface JoinGroupEvent -extends GroupEvent { - @Override - public Group getGroup(); - - @Override - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/LeaveGroupEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/LeaveGroupEvent.java deleted file mode 100644 index 7c72c47..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/LeaveGroupEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.GroupEvent; -import javax.annotation.Nullable; - -public interface LeaveGroupEvent -extends GroupEvent { - @Override - @Nullable - public Group getGroup(); - - @Override - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/LocationalSoundPacketEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/LocationalSoundPacketEvent.java deleted file mode 100644 index d477f6d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/LocationalSoundPacketEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.SoundPacketEvent; -import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; - -public interface LocationalSoundPacketEvent -extends SoundPacketEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/MergeClientSoundEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/MergeClientSoundEvent.java deleted file mode 100644 index 7d97d4e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/MergeClientSoundEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface MergeClientSoundEvent -extends ClientEvent { - public void mergeAudio(short[] var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/MicrophoneMuteEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/MicrophoneMuteEvent.java deleted file mode 100644 index 1d802ed..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/MicrophoneMuteEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface MicrophoneMuteEvent -extends ClientEvent { - public boolean isDisabled(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/MicrophonePacketEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/MicrophonePacketEvent.java deleted file mode 100644 index 51f28ea..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/MicrophonePacketEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.PacketEvent; -import de.maxhenkel.voicechat.api.packets.MicrophonePacket; - -public interface MicrophonePacketEvent -extends PacketEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/NameTagIconRenderEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/NameTagIconRenderEvent.java deleted file mode 100644 index 1e783f7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/NameTagIconRenderEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; -import java.util.UUID; - -public interface NameTagIconRenderEvent -extends ClientEvent { - public UUID getEntityId(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/OpenALSoundEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/OpenALSoundEvent.java deleted file mode 100644 index a3aa9ab..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/OpenALSoundEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.events.ClientEvent; -import java.util.UUID; -import javax.annotation.Nullable; - -public interface OpenALSoundEvent -extends ClientEvent { - @Nullable - public Position getPosition(); - - @Nullable - public UUID getChannelId(); - - public int getSource(); - - @Nullable - public String getCategory(); - - public static interface Post - extends OpenALSoundEvent { - } - - public static interface Pre - extends OpenALSoundEvent { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/PacketEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/PacketEvent.java deleted file mode 100644 index 4b0fdfd..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/PacketEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.ServerEvent; -import de.maxhenkel.voicechat.api.packets.Packet; -import javax.annotation.Nullable; - -public interface PacketEvent -extends ServerEvent { - public T getPacket(); - - @Nullable - public VoicechatConnection getReceiverConnection(); - - @Nullable - public VoicechatConnection getSenderConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerConnectedEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerConnectedEvent.java deleted file mode 100644 index e76096f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerConnectedEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.ServerEvent; - -public interface PlayerConnectedEvent -extends ServerEvent { - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerDisconnectedEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerDisconnectedEvent.java deleted file mode 100644 index d23382f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerDisconnectedEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ServerEvent; -import java.util.UUID; - -public interface PlayerDisconnectedEvent -extends ServerEvent { - public UUID getPlayerUuid(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerStateChangedEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerStateChangedEvent.java deleted file mode 100644 index c29eef5..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/PlayerStateChangedEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.ServerEvent; -import java.util.UUID; -import javax.annotation.Nullable; - -public interface PlayerStateChangedEvent -extends ServerEvent { - public boolean isDisabled(); - - public boolean isDisconnected(); - - public UUID getPlayerUuid(); - - @Nullable - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/RegisterVolumeCategoryEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/RegisterVolumeCategoryEvent.java deleted file mode 100644 index 6562898..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/RegisterVolumeCategoryEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.VolumeCategoryEvent; - -public interface RegisterVolumeCategoryEvent -extends VolumeCategoryEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/RemoveGroupEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/RemoveGroupEvent.java deleted file mode 100644 index ffdce3d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/RemoveGroupEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.Group; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.GroupEvent; -import javax.annotation.Nullable; - -public interface RemoveGroupEvent -extends GroupEvent { - @Override - public Group getGroup(); - - @Override - @Nullable - @Deprecated - public VoicechatConnection getConnection(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/ServerEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/ServerEvent.java deleted file mode 100644 index addf083..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/ServerEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatServerApi; -import de.maxhenkel.voicechat.api.events.Event; - -public interface ServerEvent -extends Event { - public VoicechatServerApi getVoicechat(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/SoundPacketEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/SoundPacketEvent.java deleted file mode 100644 index 6e15ac6..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/SoundPacketEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.PacketEvent; -import de.maxhenkel.voicechat.api.packets.Packet; - -public interface SoundPacketEvent -extends PacketEvent { - public static final String SOURCE_GROUP = "group"; - public static final String SOURCE_PROXIMITY = "proximity"; - public static final String SOURCE_SPECTATOR = "spectator"; - public static final String SOURCE_PLUGIN = "plugin"; - - public String getSource(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/StaticSoundPacketEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/StaticSoundPacketEvent.java deleted file mode 100644 index af71625..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/StaticSoundPacketEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.SoundPacketEvent; -import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; - -public interface StaticSoundPacketEvent -extends SoundPacketEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/UnregisterVolumeCategoryEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/UnregisterVolumeCategoryEvent.java deleted file mode 100644 index a4eeefa..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/UnregisterVolumeCategoryEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.VolumeCategoryEvent; - -public interface UnregisterVolumeCategoryEvent -extends VolumeCategoryEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VoiceDistanceEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VoiceDistanceEvent.java deleted file mode 100644 index ecf20c6..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VoiceDistanceEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.events.ServerEvent; -import de.maxhenkel.voicechat.api.packets.MicrophonePacket; - -public interface VoiceDistanceEvent -extends ServerEvent { - public MicrophonePacket getPacket(); - - public VoicechatConnection getSenderConnection(); - - public float getDistance(); - - public void setDistance(float var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VoiceHostEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VoiceHostEvent.java deleted file mode 100644 index ad8053e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VoiceHostEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.api.events.ServerEvent; - -public interface VoiceHostEvent -extends ServerEvent { - public String getVoiceHost(); - - public void setVoiceHost(String var1); - - public ServerPlayer getPlayer(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatDisableEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatDisableEvent.java deleted file mode 100644 index cbd2981..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatDisableEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ClientEvent; - -public interface VoicechatDisableEvent -extends ClientEvent { - public boolean isDisabled(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStartedEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStartedEvent.java deleted file mode 100644 index 635fdc8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStartedEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ServerEvent; - -public interface VoicechatServerStartedEvent -extends ServerEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStartingEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStartingEvent.java deleted file mode 100644 index de62eb2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStartingEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VoicechatSocket; -import de.maxhenkel.voicechat.api.events.ServerEvent; -import javax.annotation.Nullable; - -public interface VoicechatServerStartingEvent -extends ServerEvent { - public void setSocketImplementation(VoicechatSocket var1); - - @Nullable - public VoicechatSocket getSocketImplementation(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStoppedEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStoppedEvent.java deleted file mode 100644 index 79185ad..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VoicechatServerStoppedEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.events.ServerEvent; - -public interface VoicechatServerStoppedEvent -extends ServerEvent { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/events/VolumeCategoryEvent.java b/source/decompiled/de/maxhenkel/voicechat/api/events/VolumeCategoryEvent.java deleted file mode 100644 index f56e44e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/events/VolumeCategoryEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.events; - -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.events.ServerEvent; - -public interface VolumeCategoryEvent -extends ServerEvent { - public VolumeCategory getVolumeCategory(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/mp3/Mp3Decoder.java b/source/decompiled/de/maxhenkel/voicechat/api/mp3/Mp3Decoder.java deleted file mode 100644 index 4252b9a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/mp3/Mp3Decoder.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.mp3; - -import java.io.IOException; -import javax.sound.sampled.AudioFormat; - -public interface Mp3Decoder { - public short[] decode() throws IOException; - - public AudioFormat getAudioFormat() throws IOException; - - public int getBitrate() throws IOException; -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/mp3/Mp3Encoder.java b/source/decompiled/de/maxhenkel/voicechat/api/mp3/Mp3Encoder.java deleted file mode 100644 index 73e4ff1..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/mp3/Mp3Encoder.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.mp3; - -import java.io.IOException; - -public interface Mp3Encoder { - public void encode(short[] var1) throws IOException; - - public void close() throws IOException; -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusDecoder.java b/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusDecoder.java deleted file mode 100644 index b549cab..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusDecoder.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.opus; - -import javax.annotation.Nullable; - -public interface OpusDecoder { - public short[] decode(@Nullable byte[] var1); - - public short[][] decode(byte[] var1, int var2); - - public void resetState(); - - public boolean isClosed(); - - public void close(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusEncoder.java b/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusEncoder.java deleted file mode 100644 index 41032d6..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusEncoder.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.opus; - -public interface OpusEncoder { - public byte[] encode(short[] var1); - - public void resetState(); - - public boolean isClosed(); - - public void close(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusEncoderMode.java b/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusEncoderMode.java deleted file mode 100644 index b324d2d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/opus/OpusEncoderMode.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.opus; - -public enum OpusEncoderMode { - VOIP, - AUDIO, - RESTRICTED_LOWDELAY; - -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/ConvertablePacket.java b/source/decompiled/de/maxhenkel/voicechat/api/packets/ConvertablePacket.java deleted file mode 100644 index b3a3c50..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/ConvertablePacket.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.packets; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; -import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; -import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; -import java.util.UUID; - -public interface ConvertablePacket { - public EntitySoundPacket.Builder entitySoundPacketBuilder(); - - public LocationalSoundPacket.Builder locationalSoundPacketBuilder(); - - public StaticSoundPacket.Builder staticSoundPacketBuilder(); - - @Deprecated - public EntitySoundPacket toEntitySoundPacket(UUID var1, boolean var2); - - @Deprecated - public LocationalSoundPacket toLocationalSoundPacket(Position var1); - - @Deprecated - public StaticSoundPacket toStaticSoundPacket(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/EntitySoundPacket.java b/source/decompiled/de/maxhenkel/voicechat/api/packets/EntitySoundPacket.java deleted file mode 100644 index 1aad5df..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/EntitySoundPacket.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.packets; - -import de.maxhenkel.voicechat.api.packets.SoundPacket; -import java.util.UUID; - -public interface EntitySoundPacket -extends SoundPacket { - public UUID getEntityUuid(); - - public boolean isWhispering(); - - public float getDistance(); - - public static interface Builder> - extends SoundPacket.Builder { - public T entityUuid(UUID var1); - - public T whispering(boolean var1); - - public T distance(float var1); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/LocationalSoundPacket.java b/source/decompiled/de/maxhenkel/voicechat/api/packets/LocationalSoundPacket.java deleted file mode 100644 index 6be8ef2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/LocationalSoundPacket.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.packets; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.packets.SoundPacket; - -public interface LocationalSoundPacket -extends SoundPacket { - public Position getPosition(); - - public float getDistance(); - - public static interface Builder> - extends SoundPacket.Builder { - public T position(Position var1); - - public T distance(float var1); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/MicrophonePacket.java b/source/decompiled/de/maxhenkel/voicechat/api/packets/MicrophonePacket.java deleted file mode 100644 index 9d5b236..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/MicrophonePacket.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.packets; - -import de.maxhenkel.voicechat.api.packets.ConvertablePacket; -import de.maxhenkel.voicechat.api.packets.Packet; - -public interface MicrophonePacket -extends Packet, -ConvertablePacket { - public boolean isWhispering(); - - public byte[] getOpusEncodedData(); - - public void setOpusEncodedData(byte[] var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/SoundPacket.java b/source/decompiled/de/maxhenkel/voicechat/api/packets/SoundPacket.java deleted file mode 100644 index 18f0771..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/SoundPacket.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.api.packets; - -import de.maxhenkel.voicechat.api.packets.ConvertablePacket; -import de.maxhenkel.voicechat.api.packets.Packet; -import java.util.UUID; -import javax.annotation.Nullable; - -public interface SoundPacket -extends Packet, -ConvertablePacket { - public UUID getChannelId(); - - public UUID getSender(); - - public byte[] getOpusEncodedData(); - - public long getSequenceNumber(); - - @Nullable - public String getCategory(); - - public static interface Builder, P extends SoundPacket> { - public T channelId(UUID var1); - - public T sender(UUID var1); - - public T opusEncodedData(byte[] var1); - - public T sequenceNumber(long var1); - - public T category(@Nullable String var1); - - public P build(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/api/packets/StaticSoundPacket.java b/source/decompiled/de/maxhenkel/voicechat/api/packets/StaticSoundPacket.java deleted file mode 100644 index 3637202..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/api/packets/StaticSoundPacket.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.api.packets; - -import de.maxhenkel.voicechat.api.packets.SoundPacket; - -public interface StaticSoundPacket -extends SoundPacket { - - public static interface Builder> - extends SoundPacket.Builder { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/AbstractCommodore.java b/source/decompiled/de/maxhenkel/voicechat/commodore/AbstractCommodore.java deleted file mode 100644 index af6f20c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/AbstractCommodore.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.Command - * com.mojang.brigadier.suggestion.SuggestionProvider - * com.mojang.brigadier.tree.ArgumentCommandNode - * com.mojang.brigadier.tree.CommandNode - * com.mojang.brigadier.tree.LiteralCommandNode - * com.mojang.brigadier.tree.RootCommandNode - * org.bukkit.command.Command - * org.bukkit.command.PluginCommand - */ -package de.maxhenkel.voicechat.commodore; - -import com.mojang.brigadier.Command; -import com.mojang.brigadier.suggestion.SuggestionProvider; -import com.mojang.brigadier.tree.ArgumentCommandNode; -import com.mojang.brigadier.tree.CommandNode; -import com.mojang.brigadier.tree.LiteralCommandNode; -import com.mojang.brigadier.tree.RootCommandNode; -import de.maxhenkel.voicechat.commodore.Commodore; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.bukkit.command.PluginCommand; - -abstract class AbstractCommodore -implements Commodore { - protected static final Field CUSTOM_SUGGESTIONS_FIELD; - protected static final Field COMMAND_EXECUTE_FUNCTION_FIELD; - protected static final Field CHILDREN_FIELD; - protected static final Field LITERALS_FIELD; - protected static final Field ARGUMENTS_FIELD; - protected static final Field[] CHILDREN_FIELDS; - protected static final Command DUMMY_COMMAND; - protected static final SuggestionProvider DUMMY_SUGGESTION_PROVIDER; - - AbstractCommodore() { - } - - protected static void removeChild(RootCommandNode root, String name) { - try { - for (Field field : CHILDREN_FIELDS) { - Map children = (Map)field.get(root); - children.remove(name); - } - } - catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } - } - - protected static void setRequiredHackyFieldsRecursively(CommandNode node, SuggestionProvider suggestionProvider) { - try { - COMMAND_EXECUTE_FUNCTION_FIELD.set(node, DUMMY_COMMAND); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - if (suggestionProvider != null && node instanceof ArgumentCommandNode) { - ArgumentCommandNode argumentNode = (ArgumentCommandNode)node; - try { - CUSTOM_SUGGESTIONS_FIELD.set(argumentNode, suggestionProvider); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - for (CommandNode child : node.getChildren()) { - AbstractCommodore.setRequiredHackyFieldsRecursively(child, suggestionProvider); - } - } - - protected static LiteralCommandNode renameLiteralNode(LiteralCommandNode node, String newLiteral) { - LiteralCommandNode clone = new LiteralCommandNode(newLiteral, node.getCommand(), node.getRequirement(), node.getRedirect(), node.getRedirectModifier(), node.isFork()); - for (CommandNode child : node.getChildren()) { - clone.addChild(child); - } - return clone; - } - - protected static Collection getAliases(org.bukkit.command.Command command) { - Objects.requireNonNull(command, "command"); - Stream aliasesStream = Stream.concat(Stream.of(command.getLabel()), command.getAliases().stream()); - if (command instanceof PluginCommand) { - String fallbackPrefix = ((PluginCommand)command).getPlugin().getName().toLowerCase().trim(); - aliasesStream = aliasesStream.flatMap(alias -> Stream.of(alias, fallbackPrefix + ":" + alias)); - } - return aliasesStream.distinct().collect(Collectors.toList()); - } - - static { - try { - CUSTOM_SUGGESTIONS_FIELD = ArgumentCommandNode.class.getDeclaredField("customSuggestions"); - CUSTOM_SUGGESTIONS_FIELD.setAccessible(true); - COMMAND_EXECUTE_FUNCTION_FIELD = CommandNode.class.getDeclaredField("command"); - COMMAND_EXECUTE_FUNCTION_FIELD.setAccessible(true); - CHILDREN_FIELD = CommandNode.class.getDeclaredField("children"); - LITERALS_FIELD = CommandNode.class.getDeclaredField("literals"); - ARGUMENTS_FIELD = CommandNode.class.getDeclaredField("arguments"); - for (Field field : CHILDREN_FIELDS = new Field[]{CHILDREN_FIELD, LITERALS_FIELD, ARGUMENTS_FIELD}) { - field.setAccessible(true); - } - DUMMY_COMMAND = ctx -> { - throw new UnsupportedOperationException(); - }; - DUMMY_SUGGESTION_PROVIDER = (context, builder) -> { - throw new UnsupportedOperationException(); - }; - } - catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/BrigadierUnsupportedException.java b/source/decompiled/de/maxhenkel/voicechat/commodore/BrigadierUnsupportedException.java deleted file mode 100644 index 5076fa7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/BrigadierUnsupportedException.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.commodore; - -public final class BrigadierUnsupportedException -extends UnsupportedOperationException { - BrigadierUnsupportedException(String message) { - super(message); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/Commodore.java b/source/decompiled/de/maxhenkel/voicechat/commodore/Commodore.java deleted file mode 100644 index 0ae4c27..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/Commodore.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.builder.LiteralArgumentBuilder - * com.mojang.brigadier.tree.LiteralCommandNode - * org.bukkit.command.Command - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.commodore; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.tree.LiteralCommandNode; -import java.util.Objects; -import java.util.function.Predicate; -import org.bukkit.command.Command; -import org.bukkit.entity.Player; - -public interface Commodore { - public void register(Command var1, LiteralCommandNode var2, Predicate var3); - - default public void register(Command command, LiteralArgumentBuilder argumentBuilder, Predicate permissionTest) { - Objects.requireNonNull(command, "command"); - Objects.requireNonNull(argumentBuilder, "argumentBuilder"); - Objects.requireNonNull(permissionTest, "permissionTest"); - this.register(command, argumentBuilder.build(), permissionTest); - } - - default public void register(Command command, LiteralCommandNode node) { - Objects.requireNonNull(command, "command"); - Objects.requireNonNull(node, "node"); - this.register(command, node, arg_0 -> ((Command)command).testPermissionSilent(arg_0)); - } - - default public void register(Command command, LiteralArgumentBuilder argumentBuilder) { - Objects.requireNonNull(command, "command"); - Objects.requireNonNull(argumentBuilder, "argumentBuilder"); - this.register(command, argumentBuilder.build()); - } - - public void register(LiteralCommandNode var1); - - default public void register(LiteralArgumentBuilder argumentBuilder) { - Objects.requireNonNull(argumentBuilder, "argumentBuilder"); - this.register(argumentBuilder.build()); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/CommodoreProvider.java b/source/decompiled/de/maxhenkel/voicechat/commodore/CommodoreProvider.java deleted file mode 100644 index 87d0f0e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/CommodoreProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.plugin.Plugin - */ -package de.maxhenkel.voicechat.commodore; - -import de.maxhenkel.voicechat.commodore.BrigadierUnsupportedException; -import de.maxhenkel.voicechat.commodore.Commodore; -import de.maxhenkel.voicechat.commodore.PaperCommodore; -import de.maxhenkel.voicechat.commodore.ReflectionCommodore; -import java.util.Objects; -import java.util.function.Function; -import org.bukkit.plugin.Plugin; - -public final class CommodoreProvider { - private static final Function PROVIDER = CommodoreProvider.checkSupported(); - - private CommodoreProvider() { - throw new AssertionError(); - } - - private static Function checkSupported() { - try { - Class.forName("com.mojang.brigadier.CommandDispatcher"); - } - catch (Throwable e) { - CommodoreProvider.printDebugInfo(e); - return null; - } - try { - PaperCommodore.ensureSetup(); - return PaperCommodore::new; - } - catch (Throwable e) { - CommodoreProvider.printDebugInfo(e); - try { - ReflectionCommodore.ensureSetup(); - return ReflectionCommodore::new; - } - catch (Throwable e2) { - CommodoreProvider.printDebugInfo(e2); - return null; - } - } - } - - private static void printDebugInfo(Throwable e) { - if (System.getProperty("commodore.debug") != null) { - System.err.println("Exception while initialising commodore:"); - e.printStackTrace(System.err); - } - } - - public static boolean isSupported() { - return PROVIDER != null; - } - - public static Commodore getCommodore(Plugin plugin) throws BrigadierUnsupportedException { - Objects.requireNonNull(plugin, "plugin"); - if (PROVIDER == null) { - throw new BrigadierUnsupportedException("Brigadier is not supported by the server. Set -Dcommodore.debug=true for debug info."); - } - return PROVIDER.apply(plugin); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/PaperCommodore.java b/source/decompiled/de/maxhenkel/voicechat/commodore/PaperCommodore.java deleted file mode 100644 index be7b331..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/PaperCommodore.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent - * com.mojang.brigadier.builder.LiteralArgumentBuilder - * com.mojang.brigadier.tree.LiteralCommandNode - * com.mojang.brigadier.tree.RootCommandNode - * org.bukkit.command.Command - * org.bukkit.entity.Player - * org.bukkit.event.EventHandler - * org.bukkit.event.Listener - * org.bukkit.plugin.Plugin - */ -package de.maxhenkel.voicechat.commodore; - -import com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.tree.LiteralCommandNode; -import com.mojang.brigadier.tree.RootCommandNode; -import de.maxhenkel.voicechat.commodore.AbstractCommodore; -import de.maxhenkel.voicechat.commodore.Commodore; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import java.util.function.Predicate; -import org.bukkit.command.Command; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; - -final class PaperCommodore -extends AbstractCommodore -implements Commodore, -Listener { - private final List commands = new ArrayList(); - - PaperCommodore(Plugin plugin) { - plugin.getServer().getPluginManager().registerEvents((Listener)this, plugin); - } - - @Override - public void register(LiteralCommandNode node) { - Objects.requireNonNull(node, "node"); - this.commands.add(new CommodoreCommand(node, null)); - } - - @Override - public void register(Command command, LiteralCommandNode node, Predicate permissionTest) { - Objects.requireNonNull(command, "command"); - Objects.requireNonNull(node, "node"); - Objects.requireNonNull(permissionTest, "permissionTest"); - try { - PaperCommodore.setRequiredHackyFieldsRecursively(node, DUMMY_SUGGESTION_PROVIDER); - } - catch (Throwable e) { - e.printStackTrace(); - } - Collection aliases = PaperCommodore.getAliases(command); - if (!aliases.contains(node.getLiteral())) { - node = PaperCommodore.renameLiteralNode(node, command.getName()); - } - for (String alias : aliases) { - if (node.getLiteral().equals(alias)) { - this.commands.add(new CommodoreCommand(node, permissionTest)); - continue; - } - LiteralCommandNode redirectNode = ((LiteralArgumentBuilder)LiteralArgumentBuilder.literal((String)alias).redirect(node)).build(); - this.commands.add(new CommodoreCommand(redirectNode, permissionTest)); - } - } - - @EventHandler - public void onPlayerSendCommandsEvent(AsyncPlayerSendCommandsEvent event) { - if (event.isAsynchronous() || !event.hasFiredAsync()) { - for (CommodoreCommand command : this.commands) { - command.apply(event.getPlayer(), event.getCommandNode()); - } - } - } - - static void ensureSetup() { - } - - static { - try { - Class.forName("com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent"); - } - catch (ClassNotFoundException e) { - throw new UnsupportedOperationException("Not running on modern Paper!", e); - } - } - - private static final class CommodoreCommand { - private final LiteralCommandNode node; - private final Predicate permissionTest; - - private CommodoreCommand(LiteralCommandNode node, Predicate permissionTest) { - this.node = node; - this.permissionTest = permissionTest; - } - - public void apply(Player player, RootCommandNode root) { - if (this.permissionTest != null && !this.permissionTest.test((Player)player)) { - return; - } - AbstractCommodore.removeChild(root, this.node.getName()); - root.addChild(this.node); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/ReflectionCommodore.java b/source/decompiled/de/maxhenkel/voicechat/commodore/ReflectionCommodore.java deleted file mode 100644 index 9d7bba5..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/ReflectionCommodore.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.CommandDispatcher - * com.mojang.brigadier.builder.LiteralArgumentBuilder - * com.mojang.brigadier.suggestion.SuggestionProvider - * com.mojang.brigadier.tree.CommandNode - * com.mojang.brigadier.tree.LiteralCommandNode - * com.mojang.brigadier.tree.RootCommandNode - * org.bukkit.Bukkit - * org.bukkit.command.Command - * org.bukkit.entity.Player - * org.bukkit.event.EventHandler - * org.bukkit.event.Listener - * org.bukkit.event.player.PlayerCommandSendEvent - * org.bukkit.event.server.ServerLoadEvent - * org.bukkit.plugin.Plugin - */ -package de.maxhenkel.voicechat.commodore; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.suggestion.SuggestionProvider; -import com.mojang.brigadier.tree.CommandNode; -import com.mojang.brigadier.tree.LiteralCommandNode; -import com.mojang.brigadier.tree.RootCommandNode; -import de.maxhenkel.voicechat.commodore.AbstractCommodore; -import de.maxhenkel.voicechat.commodore.Commodore; -import de.maxhenkel.voicechat.commodore.ReflectionUtil; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Collectors; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandSendEvent; -import org.bukkit.event.server.ServerLoadEvent; -import org.bukkit.plugin.Plugin; - -final class ReflectionCommodore -extends AbstractCommodore -implements Commodore { - private static final Field CONSOLE_FIELD; - private static final Method GET_COMMAND_DISPATCHER_METHOD; - private static final Method GET_BRIGADIER_DISPATCHER_METHOD; - private static final Constructor COMMAND_WRAPPER_CONSTRUCTOR; - private final Plugin plugin; - private final List> registeredNodes = new ArrayList(); - - ReflectionCommodore(Plugin plugin) { - this.plugin = plugin; - this.plugin.getServer().getPluginManager().registerEvents((Listener)new ServerReloadListener(this), this.plugin); - } - - private CommandDispatcher getDispatcher() { - try { - Object mcServerObject = CONSOLE_FIELD.get(Bukkit.getServer()); - Object commandDispatcherObject = GET_COMMAND_DISPATCHER_METHOD.invoke(mcServerObject, new Object[0]); - return (CommandDispatcher)GET_BRIGADIER_DISPATCHER_METHOD.invoke(commandDispatcherObject, new Object[0]); - } - catch (ReflectiveOperationException e) { - throw new RuntimeException(e); - } - } - - @Override - public void register(LiteralCommandNode node) { - Objects.requireNonNull(node, "node"); - CommandDispatcher dispatcher = this.getDispatcher(); - RootCommandNode root = dispatcher.getRoot(); - ReflectionCommodore.removeChild(root, node.getName()); - root.addChild(node); - this.registeredNodes.add(node); - } - - @Override - public void register(Command command, LiteralCommandNode node, Predicate permissionTest) { - Objects.requireNonNull(command, "command"); - Objects.requireNonNull(node, "node"); - Objects.requireNonNull(permissionTest, "permissionTest"); - try { - SuggestionProvider wrapper = (SuggestionProvider)COMMAND_WRAPPER_CONSTRUCTOR.newInstance(this.plugin.getServer(), command); - ReflectionCommodore.setRequiredHackyFieldsRecursively(node, wrapper); - } - catch (Throwable e) { - e.printStackTrace(); - } - Collection aliases = ReflectionCommodore.getAliases(command); - if (!aliases.contains(node.getLiteral())) { - node = ReflectionCommodore.renameLiteralNode(node, command.getName()); - } - for (String alias : aliases) { - if (node.getLiteral().equals(alias)) { - this.register(node); - continue; - } - this.register(((LiteralArgumentBuilder)LiteralArgumentBuilder.literal((String)alias).redirect(node)).build()); - } - this.plugin.getServer().getPluginManager().registerEvents((Listener)new CommandDataSendListener(command, permissionTest), this.plugin); - } - - static void ensureSetup() { - } - - static { - try { - Class commandDispatcher; - Class minecraftServer; - if (ReflectionUtil.minecraftVersion() >= 19) { - throw new UnsupportedOperationException("ReflectionCommodore is not supported on MC 1.19 or above. Switch to Paper :)"); - } - if (ReflectionUtil.minecraftVersion() > 16) { - minecraftServer = ReflectionUtil.mcClass("server.MinecraftServer"); - commandDispatcher = ReflectionUtil.mcClass("commands.CommandDispatcher"); - } else { - minecraftServer = ReflectionUtil.nmsClass("MinecraftServer"); - commandDispatcher = ReflectionUtil.nmsClass("CommandDispatcher"); - } - Class craftServer = ReflectionUtil.obcClass("CraftServer"); - CONSOLE_FIELD = craftServer.getDeclaredField("console"); - CONSOLE_FIELD.setAccessible(true); - GET_COMMAND_DISPATCHER_METHOD = Arrays.stream(minecraftServer.getDeclaredMethods()).filter(method -> method.getParameterCount() == 0).filter(method -> commandDispatcher.isAssignableFrom(method.getReturnType())).findFirst().orElseThrow(NoSuchMethodException::new); - GET_COMMAND_DISPATCHER_METHOD.setAccessible(true); - GET_BRIGADIER_DISPATCHER_METHOD = Arrays.stream(commandDispatcher.getDeclaredMethods()).filter(method -> method.getParameterCount() == 0).filter(method -> CommandDispatcher.class.isAssignableFrom(method.getReturnType())).findFirst().orElseThrow(NoSuchMethodException::new); - GET_BRIGADIER_DISPATCHER_METHOD.setAccessible(true); - Class commandWrapperClass = ReflectionUtil.obcClass("command.BukkitCommandWrapper"); - COMMAND_WRAPPER_CONSTRUCTOR = commandWrapperClass.getConstructor(craftServer, Command.class); - } - catch (ReflectiveOperationException e) { - throw new ExceptionInInitializerError(e); - } - } - - private static final class ServerReloadListener - implements Listener { - private final ReflectionCommodore commodore; - - private ServerReloadListener(ReflectionCommodore commodore) { - this.commodore = commodore; - } - - @EventHandler - public void onLoad(ServerLoadEvent e) { - CommandDispatcher dispatcher = this.commodore.getDispatcher(); - RootCommandNode root = dispatcher.getRoot(); - for (LiteralCommandNode node : this.commodore.registeredNodes) { - AbstractCommodore.removeChild(root, node.getName()); - root.addChild((CommandNode)node); - } - } - } - - private static final class CommandDataSendListener - implements Listener { - private final Set aliases; - private final Set minecraftPrefixedAliases; - private final Predicate permissionTest; - - CommandDataSendListener(Command pluginCommand, Predicate permissionTest) { - this.aliases = new HashSet(AbstractCommodore.getAliases(pluginCommand)); - this.minecraftPrefixedAliases = this.aliases.stream().map(alias -> "minecraft:" + alias).collect(Collectors.toSet()); - this.permissionTest = permissionTest; - } - - @EventHandler - public void onCommandSend(PlayerCommandSendEvent e) { - e.getCommands().removeAll(this.minecraftPrefixedAliases); - if (!this.permissionTest.test((Player)e.getPlayer())) { - e.getCommands().removeAll(this.aliases); - } - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/ReflectionUtil.java b/source/decompiled/de/maxhenkel/voicechat/commodore/ReflectionUtil.java deleted file mode 100644 index 21469ce..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/ReflectionUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.Bukkit - */ -package de.maxhenkel.voicechat.commodore; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.bukkit.Bukkit; - -final class ReflectionUtil { - private static final String SERVER_VERSION = ReflectionUtil.getServerVersion(); - - private static String getServerVersion() { - Class server = Bukkit.getServer().getClass(); - if (!server.getSimpleName().equals("CraftServer")) { - return "."; - } - if (server.getName().equals("org.bukkit.craftbukkit.CraftServer")) { - return "."; - } - String version = server.getName().substring("org.bukkit.craftbukkit".length()); - return version.substring(0, version.length() - "CraftServer".length()); - } - - public static String mc(String name) { - return "net.minecraft." + name; - } - - public static String nms(String className) { - return "net.minecraft.server" + SERVER_VERSION + className; - } - - public static Class mcClass(String className) throws ClassNotFoundException { - return Class.forName(ReflectionUtil.mc(className)); - } - - public static Class nmsClass(String className) throws ClassNotFoundException { - return Class.forName(ReflectionUtil.nms(className)); - } - - public static String obc(String className) { - return "org.bukkit.craftbukkit" + SERVER_VERSION + className; - } - - public static Class obcClass(String className) throws ClassNotFoundException { - return Class.forName(ReflectionUtil.obc(className)); - } - - public static int minecraftVersion() { - try { - Matcher matcher = Pattern.compile("\\(MC: (\\d)\\.(\\d+)\\.?(\\d+?)?( .*)?\\)").matcher(Bukkit.getVersion()); - if (matcher.find()) { - return Integer.parseInt(matcher.toMatchResult().group(2), 10); - } - throw new IllegalArgumentException(String.format("No match found in '%s'", Bukkit.getVersion())); - } - catch (IllegalArgumentException ex) { - throw new RuntimeException("Failed to determine Minecraft version", ex); - } - } - - private ReflectionUtil() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/AbstractIterator.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/AbstractIterator.java deleted file mode 100644 index 7143455..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/AbstractIterator.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.commodore.file; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -abstract class AbstractIterator -implements Iterator { - private State state = State.NOT_READY; - private T next; - - protected AbstractIterator() { - } - - protected abstract T computeNext() throws Exception; - - protected final T endOfData() { - this.state = State.DONE; - return null; - } - - @Override - public final boolean hasNext() { - if (this.state == State.FAILED) { - throw new IllegalStateException(); - } - switch (this.state) { - case DONE: { - return false; - } - case READY: { - return true; - } - } - return this.tryToComputeNext(); - } - - private boolean tryToComputeNext() { - this.state = State.FAILED; - try { - this.next = this.computeNext(); - } - catch (Exception e) { - throw new RuntimeException("Exception whilst computing next value", e); - } - if (this.state != State.DONE) { - this.state = State.READY; - return true; - } - return false; - } - - @Override - public final T next() { - if (!this.hasNext()) { - throw new NoSuchElementException(); - } - this.state = State.NOT_READY; - T result = this.next; - this.next = null; - return result; - } - - public final T peek() { - if (!this.hasNext()) { - throw new NoSuchElementException(); - } - return this.next; - } - - private static enum State { - READY, - NOT_READY, - DONE, - FAILED; - - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/ArgumentTypeParser.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/ArgumentTypeParser.java deleted file mode 100644 index 3a592f7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/ArgumentTypeParser.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - */ -package de.maxhenkel.voicechat.commodore.file; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.commodore.file.ParseException; -import de.maxhenkel.voicechat.commodore.file.TokenStream; - -public interface ArgumentTypeParser { - public boolean canParse(String var1, String var2); - - public ArgumentType parse(String var1, String var2, TokenStream var3) throws ParseException; -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/BrigadierArgumentTypeParser.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/BrigadierArgumentTypeParser.java deleted file mode 100644 index 558f72b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/BrigadierArgumentTypeParser.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * com.mojang.brigadier.arguments.BoolArgumentType - * com.mojang.brigadier.arguments.DoubleArgumentType - * com.mojang.brigadier.arguments.FloatArgumentType - * com.mojang.brigadier.arguments.IntegerArgumentType - * com.mojang.brigadier.arguments.LongArgumentType - * com.mojang.brigadier.arguments.StringArgumentType - */ -package de.maxhenkel.voicechat.commodore.file; - -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.arguments.DoubleArgumentType; -import com.mojang.brigadier.arguments.FloatArgumentType; -import com.mojang.brigadier.arguments.IntegerArgumentType; -import com.mojang.brigadier.arguments.LongArgumentType; -import com.mojang.brigadier.arguments.StringArgumentType; -import de.maxhenkel.voicechat.commodore.file.ArgumentTypeParser; -import de.maxhenkel.voicechat.commodore.file.ParseException; -import de.maxhenkel.voicechat.commodore.file.Token; -import de.maxhenkel.voicechat.commodore.file.TokenStream; - -public class BrigadierArgumentTypeParser -implements ArgumentTypeParser { - public static final BrigadierArgumentTypeParser INSTANCE = new BrigadierArgumentTypeParser(); - - private BrigadierArgumentTypeParser() { - } - - @Override - public boolean canParse(String namespace, String name) { - if (!namespace.equals("brigadier")) { - return false; - } - switch (name) { - case "bool": - case "string": - case "integer": - case "long": - case "float": - case "double": { - return true; - } - } - return false; - } - - @Override - public ArgumentType parse(String namespace, String name, TokenStream tokens) throws ParseException { - switch (name) { - case "bool": { - return BoolArgumentType.bool(); - } - case "string": { - return BrigadierArgumentTypeParser.parseStringArgumentType(tokens); - } - case "integer": { - return BrigadierArgumentTypeParser.parseIntegerArgumentType(tokens); - } - case "long": { - return BrigadierArgumentTypeParser.parseLongArgumentType(tokens); - } - case "float": { - return BrigadierArgumentTypeParser.parseFloatArgumentType(tokens); - } - case "double": { - return BrigadierArgumentTypeParser.parseDoubleArgumentType(tokens); - } - } - throw new AssertionError(); - } - - private static StringArgumentType parseStringArgumentType(TokenStream tokens) throws ParseException { - String stringType; - Token token = tokens.next(); - if (!(token instanceof Token.StringToken)) { - throw tokens.createException("Expected string token for string type but got " + token); - } - switch (stringType = ((Token.StringToken)token).getString()) { - case "single_word": { - return StringArgumentType.word(); - } - case "quotable_phrase": { - return StringArgumentType.string(); - } - case "greedy_phrase": { - return StringArgumentType.greedyString(); - } - } - throw tokens.createException("Unknown string type: " + stringType); - } - - private static IntegerArgumentType parseIntegerArgumentType(TokenStream tokens) throws ParseException { - if (tokens.peek() instanceof Token.StringToken) { - int min = BrigadierArgumentTypeParser.parseInt(tokens); - if (tokens.peek() instanceof Token.StringToken) { - int max = BrigadierArgumentTypeParser.parseInt(tokens); - return IntegerArgumentType.integer((int)min, (int)max); - } - return IntegerArgumentType.integer((int)min); - } - return IntegerArgumentType.integer(); - } - - private static LongArgumentType parseLongArgumentType(TokenStream tokens) throws ParseException { - if (tokens.peek() instanceof Token.StringToken) { - long min = BrigadierArgumentTypeParser.parseLong(tokens); - if (tokens.peek() instanceof Token.StringToken) { - long max = BrigadierArgumentTypeParser.parseLong(tokens); - return LongArgumentType.longArg((long)min, (long)max); - } - return LongArgumentType.longArg((long)min); - } - return LongArgumentType.longArg(); - } - - private static FloatArgumentType parseFloatArgumentType(TokenStream tokens) throws ParseException { - if (tokens.peek() instanceof Token.StringToken) { - float min = BrigadierArgumentTypeParser.parseFloat(tokens); - if (tokens.peek() instanceof Token.StringToken) { - float max = BrigadierArgumentTypeParser.parseFloat(tokens); - return FloatArgumentType.floatArg((float)min, (float)max); - } - return FloatArgumentType.floatArg((float)min); - } - return FloatArgumentType.floatArg(); - } - - private static DoubleArgumentType parseDoubleArgumentType(TokenStream tokens) throws ParseException { - if (tokens.peek() instanceof Token.StringToken) { - double min = BrigadierArgumentTypeParser.parseDouble(tokens); - if (tokens.peek() instanceof Token.StringToken) { - double max = BrigadierArgumentTypeParser.parseDouble(tokens); - return DoubleArgumentType.doubleArg((double)min, (double)max); - } - return DoubleArgumentType.doubleArg((double)min); - } - return DoubleArgumentType.doubleArg(); - } - - private static int parseInt(TokenStream tokens) throws ParseException { - Token token = tokens.next(); - if (!(token instanceof Token.StringToken)) { - throw tokens.createException("Expected string token for integer but got " + token); - } - String value = ((Token.StringToken)token).getString(); - if (value.equals("min")) { - return Integer.MIN_VALUE; - } - if (value.equals("max")) { - return Integer.MAX_VALUE; - } - try { - return Integer.parseInt(value); - } - catch (NumberFormatException e) { - throw tokens.createException("Expected int but got " + value, e); - } - } - - private static long parseLong(TokenStream tokens) throws ParseException { - Token token = tokens.next(); - if (!(token instanceof Token.StringToken)) { - throw tokens.createException("Expected string token for long but got " + token); - } - String value = ((Token.StringToken)token).getString(); - if (value.equals("min")) { - return Long.MIN_VALUE; - } - if (value.equals("max")) { - return Long.MAX_VALUE; - } - try { - return Long.parseLong(value); - } - catch (NumberFormatException e) { - throw tokens.createException("Expected long but got " + value, e); - } - } - - private static float parseFloat(TokenStream tokens) throws ParseException { - Token token = tokens.next(); - if (!(token instanceof Token.StringToken)) { - throw tokens.createException("Expected string token for float but got " + token); - } - String value = ((Token.StringToken)token).getString(); - if (value.equals("min")) { - return Float.MIN_VALUE; - } - if (value.equals("max")) { - return Float.MAX_VALUE; - } - try { - return Float.parseFloat(value); - } - catch (NumberFormatException e) { - throw tokens.createException("Expected float but got " + value, e); - } - } - - private static double parseDouble(TokenStream tokens) throws ParseException { - Token token = tokens.next(); - if (!(token instanceof Token.StringToken)) { - throw tokens.createException("Expected string token for double but got " + token); - } - String value = ((Token.StringToken)token).getString(); - if (value.equals("min")) { - return Double.MIN_VALUE; - } - if (value.equals("max")) { - return Double.MAX_VALUE; - } - try { - return Double.parseDouble(value); - } - catch (NumberFormatException e) { - throw tokens.createException("Expected double but got " + value); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/CommodoreFileReader.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/CommodoreFileReader.java deleted file mode 100644 index 8ded418..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/CommodoreFileReader.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.tree.LiteralCommandNode - */ -package de.maxhenkel.voicechat.commodore.file; - -import com.mojang.brigadier.tree.LiteralCommandNode; -import de.maxhenkel.voicechat.commodore.file.ArgumentTypeParser; -import de.maxhenkel.voicechat.commodore.file.BrigadierArgumentTypeParser; -import de.maxhenkel.voicechat.commodore.file.Lexer; -import de.maxhenkel.voicechat.commodore.file.ParseException; -import de.maxhenkel.voicechat.commodore.file.Parser; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -public class CommodoreFileReader { - public static final CommodoreFileReader INSTANCE = CommodoreFileReader.builder().withArgumentTypeParser(BrigadierArgumentTypeParser.INSTANCE).build(); - private final List argumentTypeParsers; - - public static Builder builder() { - return new Builder(); - } - - CommodoreFileReader(List argumentTypeParsers) { - this.argumentTypeParsers = Collections.unmodifiableList(argumentTypeParsers); - } - - public LiteralCommandNode parse(Reader reader) throws IOException { - try { - return new Parser(new Lexer(reader), this.argumentTypeParsers).parse(); - } - catch (ParseException e) { - if (e.getCause() instanceof IOException) { - throw (IOException)e.getCause(); - } - throw new IOException(e); - } - } - - public LiteralCommandNode parse(InputStream inputStream) throws IOException { - try (InputStreamReader reader = new InputStreamReader(inputStream);){ - LiteralCommandNode literalCommandNode = this.parse(reader); - return literalCommandNode; - } - } - - public LiteralCommandNode parse(Path path) throws IOException { - try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);){ - LiteralCommandNode literalCommandNode = this.parse(reader); - return literalCommandNode; - } - } - - public LiteralCommandNode parse(File file) throws IOException { - return this.parse(file.toPath()); - } - - public static final class Builder { - private final List argumentTypeParsers = new ArrayList(); - - Builder() { - } - - public Builder withArgumentTypeParser(ArgumentTypeParser argumentTypeParser) { - Objects.requireNonNull(argumentTypeParser, "argumentTypeParser"); - this.argumentTypeParsers.add(argumentTypeParser); - return this; - } - - public CommodoreFileReader build() { - return new CommodoreFileReader(new ArrayList(this.argumentTypeParsers)); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/Lexer.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/Lexer.java deleted file mode 100644 index fbce218..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/Lexer.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.commodore.file; - -import de.maxhenkel.voicechat.commodore.file.AbstractIterator; -import de.maxhenkel.voicechat.commodore.file.ParseException; -import de.maxhenkel.voicechat.commodore.file.Token; -import de.maxhenkel.voicechat.commodore.file.TokenStream; -import java.io.IOException; -import java.io.Reader; -import java.io.StreamTokenizer; - -class Lexer -extends AbstractIterator -implements TokenStream { - private final StreamTokenizer tokenizer; - private boolean end = false; - - Lexer(Reader reader) { - this.tokenizer = new StreamTokenizer(reader); - this.tokenizer.resetSyntax(); - this.tokenizer.wordChars(33, 126); - this.tokenizer.quoteChar(34); - this.tokenizer.whitespaceChars(0, 32); - "{};".chars().forEach(this.tokenizer::ordinaryChar); - this.tokenizer.slashSlashComments(true); - this.tokenizer.slashStarComments(true); - } - - @Override - protected Token computeNext() throws ParseException { - if (this.end) { - return (Token)this.endOfData(); - } - try { - int token = this.tokenizer.nextToken(); - switch (token) { - case -1: { - this.end = true; - return Token.ConstantToken.EOF; - } - case -3: { - return new Token.StringToken(this.tokenizer.sval); - } - case 123: { - return Token.ConstantToken.OPEN_BRACKET; - } - case 125: { - return Token.ConstantToken.CLOSE_BRACKET; - } - case 59: { - return Token.ConstantToken.SEMICOLON; - } - } - throw this.createException("Unknown token: " + (char)token + "(" + token + ")"); - } - catch (IOException e) { - throw this.createException(e); - } - } - - @Override - public ParseException createException(String message) { - return new ParseException(message, this.tokenizer.lineno()); - } - - @Override - public ParseException createException(Throwable cause) { - return new ParseException(cause, this.tokenizer.lineno()); - } - - @Override - public ParseException createException(String message, Throwable cause) { - return new ParseException(message, cause, this.tokenizer.lineno()); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/ParseException.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/ParseException.java deleted file mode 100644 index d8fa1c4..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/ParseException.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.commodore.file; - -public final class ParseException -extends Exception { - ParseException(String message, int currentLine) { - super(message + " (at line " + currentLine + ")"); - } - - ParseException(Throwable cause, int currentLine) { - super("At line " + currentLine, cause); - } - - ParseException(String message, Throwable cause, int currentLine) { - super(message + " (at line " + currentLine + ")", cause); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/Parser.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/Parser.java deleted file mode 100644 index 099efeb..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/Parser.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * com.mojang.brigadier.builder.LiteralArgumentBuilder - * com.mojang.brigadier.builder.RequiredArgumentBuilder - * com.mojang.brigadier.tree.CommandNode - * com.mojang.brigadier.tree.LiteralCommandNode - */ -package de.maxhenkel.voicechat.commodore.file; - -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.builder.RequiredArgumentBuilder; -import com.mojang.brigadier.tree.CommandNode; -import com.mojang.brigadier.tree.LiteralCommandNode; -import de.maxhenkel.voicechat.commodore.file.ArgumentTypeParser; -import de.maxhenkel.voicechat.commodore.file.Lexer; -import de.maxhenkel.voicechat.commodore.file.ParseException; -import de.maxhenkel.voicechat.commodore.file.Token; -import java.util.Arrays; -import java.util.Collection; - -class Parser { - private final Lexer lexer; - private final Collection argumentTypeParsers; - - Parser(Lexer lexer, Collection argumentTypeParsers) { - this.lexer = lexer; - this.argumentTypeParsers = argumentTypeParsers; - } - - LiteralCommandNode parse() throws ParseException { - CommandNode node = this.parseNode(); - if (!(node instanceof LiteralCommandNode)) { - throw this.lexer.createException("Root command node is not a literal command node"); - } - if (this.lexer.peek() != Token.ConstantToken.EOF) { - throw this.lexer.createException("Expected end of file but got " + this.lexer.peek()); - } - return (LiteralCommandNode)node; - } - - private CommandNode parseNode() throws ParseException { - Token token = (Token)this.lexer.next(); - if (!(token instanceof Token.StringToken)) { - throw this.lexer.createException("Expected string token for node name but got " + token); - } - String name = ((Token.StringToken)token).getString(); - Object node = this.lexer.peek() instanceof Token.StringToken ? RequiredArgumentBuilder.argument((String)name, this.parseArgumentType()) : LiteralArgumentBuilder.literal((String)name); - if (this.lexer.peek() == Token.ConstantToken.OPEN_BRACKET) { - this.lexer.next(); - while (this.lexer.peek() != Token.ConstantToken.CLOSE_BRACKET) { - CommandNode child = this.parseNode(); - node.then(child); - } - this.lexer.next(); - } else { - if (this.lexer.peek() != Token.ConstantToken.SEMICOLON) { - throw this.lexer.createException("Node definition not ended with semicolon, got " + this.lexer.peek()); - } - this.lexer.next(); - } - return node.build(); - } - - private ArgumentType parseArgumentType() throws ParseException { - Token token = (Token)this.lexer.next(); - if (!(token instanceof Token.StringToken)) { - throw this.lexer.createException("Expected string token for argument type but got " + token); - } - String argumentType = ((Token.StringToken)token).getString(); - Object[] key = argumentType.split(":"); - if (key.length != 2) { - throw this.lexer.createException("Invalid key for argument type: " + Arrays.toString(key)); - } - for (ArgumentTypeParser parser : this.argumentTypeParsers) { - if (!parser.canParse((String)key[0], (String)key[1])) continue; - return parser.parse((String)key[0], (String)key[1], this.lexer); - } - throw this.lexer.createException("Unable to parse argument type: " + argumentType); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/Token.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/Token.java deleted file mode 100644 index 089158f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/Token.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.commodore.file; - -public interface Token { - - public static final class StringToken - implements Token { - private final String string; - - StringToken(String string) { - this.string = string; - } - - public String getString() { - return this.string; - } - } - - public static enum ConstantToken implements Token - { - OPEN_BRACKET, - CLOSE_BRACKET, - SEMICOLON, - EOF; - - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/commodore/file/TokenStream.java b/source/decompiled/de/maxhenkel/voicechat/commodore/file/TokenStream.java deleted file mode 100644 index 73b0c38..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/commodore/file/TokenStream.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.commodore.file; - -import de.maxhenkel.voicechat.commodore.file.ParseException; -import de.maxhenkel.voicechat.commodore.file.Token; - -public interface TokenStream { - public boolean hasNext(); - - public Token next(); - - public Token peek(); - - public ParseException createException(String var1); - - public ParseException createException(Throwable var1); - - public ParseException createException(String var1, Throwable var2); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/BaseCompatibility.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/BaseCompatibility.java deleted file mode 100644 index bcf683a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/BaseCompatibility.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - * org.bukkit.entity.Player - * org.bukkit.event.EventPriority - * org.bukkit.event.Listener - * org.bukkit.event.player.PlayerEvent - * org.bukkit.plugin.Plugin - */ -package de.maxhenkel.voicechat.compatibility; - -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.compatibility.Compatibility; -import de.maxhenkel.voicechat.compatibility.CompatibilityReflectionException; -import de.maxhenkel.voicechat.compatibility.PlayerHideEvent; -import de.maxhenkel.voicechat.compatibility.PlayerShowEvent; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import de.maxhenkel.voicechat.util.Key; -import java.lang.reflect.Method; -import java.util.function.Consumer; -import javax.annotation.Nullable; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.plugin.Plugin; - -public abstract class BaseCompatibility -implements Compatibility { - private String baseBukkitPackage; - private String baseServerPackage; - private Method addChannel; - private Method removeChannel; - @Nullable - private Class playerHideEntityEvent; - @Nullable - private Method playerHideEntityEventGetEntity; - @Nullable - private Class playerShowEntityEvent; - @Nullable - private Method playerShowEntityEventGetEntity; - private Consumer runTask; - private TaskScheduler taskScheduler; - - @Override - public void init() throws Exception { - Compatibility.super.init(); - this.baseBukkitPackage = Bukkit.getServer().getClass().getPackage().getName(); - this.baseServerPackage = ReflectionUtils.callMethod((Object)Bukkit.getServer(), "getServer").getClass().getPackage().getName(); - Class craftPlayer = this.getBukkitClass("entity.CraftPlayer"); - this.addChannel = ReflectionUtils.getMethod(craftPlayer, new String[]{"addChannel"}, new Class[]{String.class}); - this.removeChannel = ReflectionUtils.getMethod(craftPlayer, new String[]{"removeChannel"}, new Class[]{String.class}); - try { - if (ReflectionUtils.doesClassExist("org.bukkit.event.player.PlayerHideEntityEvent") && ReflectionUtils.doesClassExist("org.bukkit.event.player.PlayerShowEntityEvent")) { - Class hide = ReflectionUtils.getClazz("org.bukkit.event.player.PlayerHideEntityEvent"); - if (!PlayerEvent.class.isAssignableFrom(hide)) { - throw new CompatibilityReflectionException("PlayerHideEntityEvent is not a subclass of PlayerEvent"); - } - Class show = ReflectionUtils.getClazz("org.bukkit.event.player.PlayerShowEntityEvent"); - if (!PlayerEvent.class.isAssignableFrom(show)) { - throw new CompatibilityReflectionException("PlayerShowEntityEvent is not a subclass of PlayerEvent"); - } - this.playerShowEntityEventGetEntity = ReflectionUtils.getMethod(show, "getEntity"); - this.playerHideEntityEventGetEntity = ReflectionUtils.getMethod(hide, "getEntity"); - this.playerShowEntityEvent = show; - this.playerHideEntityEvent = hide; - } else { - Voicechat.LOGGER.warn("Vanish plugin integration is not supported", new Object[0]); - } - } - catch (CompatibilityReflectionException e) { - Voicechat.LOGGER.warn("Vanish plugin integration is disabled", new Object[0]); - Voicechat.LOGGER.warn("Failed to load vanish compatibility", e); - this.playerHideEntityEvent = null; - this.playerShowEntityEvent = null; - } - this.runTask = runnable -> Bukkit.getScheduler().runTask((Plugin)Voicechat.INSTANCE, runnable); - this.taskScheduler = new TaskScheduler(){ - - @Override - public void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period) { - Bukkit.getScheduler().scheduleSyncRepeatingTask((Plugin)Voicechat.INSTANCE, runnable, delay, period); - } - - @Override - public void runTaskLater(Runnable runnable, long delay) { - Bukkit.getScheduler().runTaskLater((Plugin)Voicechat.INSTANCE, runnable, delay); - } - }; - if (ReflectionUtils.doesMethodExist(Bukkit.class, "getGlobalRegionScheduler", new Class[0])) { - final Object globalRegionScheduler = ReflectionUtils.callMethod(Bukkit.class, "getGlobalRegionScheduler"); - Method run = ReflectionUtils.getMethod(globalRegionScheduler.getClass(), new String[]{"run"}, new Class[]{Plugin.class, Consumer.class}); - this.runTask = runnable -> ReflectionUtils.call(run, globalRegionScheduler, new Object[]{Voicechat.INSTANCE, task -> runnable.run()}); - if (ReflectionUtils.doesMethodExist(globalRegionScheduler.getClass(), "runAtFixedRate", Plugin.class, Consumer.class, Long.TYPE, Long.TYPE) && ReflectionUtils.doesMethodExist(globalRegionScheduler.getClass(), "runDelayed", Plugin.class, Consumer.class, Long.TYPE)) { - final Method runAtFixedRate = ReflectionUtils.getMethod(globalRegionScheduler.getClass(), new String[]{"runAtFixedRate"}, new Class[]{Plugin.class, Consumer.class, Long.TYPE, Long.TYPE}); - final Method runDelayed = ReflectionUtils.getMethod(globalRegionScheduler.getClass(), new String[]{"runDelayed"}, new Class[]{Plugin.class, Consumer.class, Long.TYPE}); - this.taskScheduler = new TaskScheduler(){ - final /* synthetic */ BaseCompatibility this$0; - { - this.this$0 = this$0; - } - - @Override - public void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period) { - ReflectionUtils.call(runAtFixedRate, globalRegionScheduler, new Object[]{Voicechat.INSTANCE, task -> runnable.run(), delay <= 0L ? 1L : delay, period}); - } - - @Override - public void runTaskLater(Runnable runnable, long delay) { - ReflectionUtils.call(runDelayed, globalRegionScheduler, new Object[]{Voicechat.INSTANCE, task -> runnable.run(), delay <= 0L ? 1L : delay}); - } - }; - } - } - } - - @Override - public void addChannel(Player player, String channel) { - ReflectionUtils.call(this.addChannel, player, channel); - } - - @Override - public void removeChannel(Player player, String channel) { - ReflectionUtils.call(this.removeChannel, player, channel); - } - - @Override - public Key createNamespacedKey(String key) { - return Key.of(key); - } - - @Override - public void runTask(Runnable runnable) { - this.runTask.accept(runnable); - } - - @Override - public void scheduleSyncRepeatingTask(Runnable runnable, long delay, long period) { - this.taskScheduler.scheduleSyncRepeatingTask(runnable, delay, period); - } - - @Override - public void runTaskLater(Runnable runnable, long delay) { - this.taskScheduler.runTaskLater(runnable, delay); - } - - @Override - public boolean canSee(Player player, Player other) { - if (this.playerHideEntityEvent == null || this.playerShowEntityEvent == null) { - return true; - } - return player.canSee(other); - } - - @Override - public void registerPlayerHideEvent(Consumer event) { - if (this.playerHideEntityEvent == null) { - return; - } - Bukkit.getPluginManager().registerEvent(this.playerHideEntityEvent, new Listener(){}, EventPriority.NORMAL, (listener, evt) -> { - if (!evt.getClass().isAssignableFrom(this.playerHideEntityEvent)) { - return; - } - PlayerEvent playerEvent = (PlayerEvent)evt; - Object entityObj = ReflectionUtils.call(this.playerHideEntityEventGetEntity, playerEvent, new Object[0]); - if (!(entityObj instanceof Player)) { - return; - } - event.accept(new PlayerHideEvent((Player)entityObj, playerEvent.getPlayer())); - }, (Plugin)Voicechat.INSTANCE); - } - - @Override - public void registerPlayerShowEvent(Consumer event) { - if (this.playerShowEntityEvent == null) { - return; - } - Bukkit.getPluginManager().registerEvent(this.playerShowEntityEvent, new Listener(){}, EventPriority.NORMAL, (listener, evt) -> { - if (!evt.getClass().isAssignableFrom(this.playerShowEntityEvent)) { - return; - } - PlayerEvent playerEvent = (PlayerEvent)evt; - Object entityObj = ReflectionUtils.call(this.playerShowEntityEventGetEntity, playerEvent, new Object[0]); - if (!(entityObj instanceof Player)) { - return; - } - event.accept(new PlayerShowEvent((Player)entityObj, playerEvent.getPlayer())); - }, (Plugin)Voicechat.INSTANCE); - } - - @Override - public String getBaseBukkitPackage() { - return this.baseBukkitPackage; - } - - @Override - public String getBaseServerPackage() { - return this.baseServerPackage; - } - - private static interface TaskScheduler { - public void scheduleSyncRepeatingTask(Runnable var1, long var2, long var4); - - public void runTaskLater(Runnable var1, long var2); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility.java deleted file mode 100644 index 9fb6528..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.compatibility.CompatibilityReflectionException; -import de.maxhenkel.voicechat.compatibility.PlayerHideEvent; -import de.maxhenkel.voicechat.compatibility.PlayerShowEvent; -import de.maxhenkel.voicechat.util.Key; -import java.util.function.Consumer; -import javax.annotation.Nullable; -import org.bukkit.entity.Player; - -public interface Compatibility { - default public void init() throws Exception { - } - - public void addChannel(Player var1, String var2); - - public void removeChannel(Player var1, String var2); - - public Key createNamespacedKey(String var1); - - public void sendTranslationMessage(Player var1, String var2, String ... var3); - - public void sendStatusMessage(Player var1, String var2, String ... var3); - - public void sendInviteMessage(Player var1, Player var2, String var3, String var4); - - public void sendIncompatibleMessage(Player var1, String var2, String var3); - - public void runTask(Runnable var1); - - public void scheduleSyncRepeatingTask(Runnable var1, long var2, long var4); - - public void runTaskLater(Runnable var1, long var2); - - public boolean canSee(Player var1, Player var2); - - public void registerPlayerHideEvent(Consumer var1); - - public void registerPlayerShowEvent(Consumer var1); - - @Nullable - public ArgumentType playerArgument(); - - @Nullable - public ArgumentType uuidArgument(); - - public String getBaseBukkitPackage(); - - public String getBaseServerPackage(); - - default public Class getBukkitClass(String ... classNames) { - for (String className : classNames) { - try { - return Class.forName(String.format("%s.%s", this.getBaseBukkitPackage(), className)); - } - catch (Throwable throwable) { - } - } - throw new CompatibilityReflectionException(String.format("Could not find any of the following classes: %s", String.join((CharSequence)", ", classNames))); - } - - default public Class getServerClass(String ... classNames) { - for (String className : classNames) { - try { - return Class.forName(String.format("%s.%s", this.getBaseServerPackage(), className)); - } - catch (Throwable throwable) { - } - } - throw new CompatibilityReflectionException(String.format("Could not find any of the following classes: %s", String.join((CharSequence)", ", classNames))); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_12.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_12.java deleted file mode 100644 index 466446b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_12.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import de.maxhenkel.voicechat.util.Key; -import org.bukkit.entity.Player; - -public class Compatibility1_12 -extends JsonMessageBaseCompatibility { - public static final String CHANNEL = "vc"; - public static final BukkitVersion VERSION_1_12_2 = BukkitVersion.parseBukkitVersion("1.12.2-R0.1"); - public static final BukkitVersion VERSION_1_12_1 = BukkitVersion.parseBukkitVersion("1.12.1-R0.1"); - public static final BukkitVersion VERSION_1_12 = BukkitVersion.parseBukkitVersion("1.12-R0.1"); - public static final Compatibility1_12 INSTANCE = new Compatibility1_12(); - - @Override - public Key createNamespacedKey(String key) { - return Key.of(CHANNEL, key); - } - - @Override - public void sendJsonMessage(Player player, String json) { - Class chatMessageTypeClass = this.getServerClass("ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "CHAT"); - this.send(player, json, b); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - Class chatMessageTypeClass = this.getServerClass("ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "GAME_INFO"); - this.send(player, json, b); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - return null; - } - - @Override - public ArgumentType uuidArgument() { - return null; - } - - private void send(Player player, String json, Object chatMessageType) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "playerConnection"); - Class packet = this.getServerClass("Packet"); - Class chatSerializer = this.getServerClass("IChatBaseComponent$ChatSerializer"); - Class iChatBaseComponentClass = this.getServerClass("IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(chatSerializer, "a", new Class[]{String.class}, json); - Class packetPlayOutChatClass = this.getServerClass("PacketPlayOutChat"); - Class chatMessageTypeClass = this.getServerClass("ChatMessageType"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass}, iChatBaseComponent, chatMessageType); - ReflectionUtils.callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_16.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_16.java deleted file mode 100644 index 8f7ee8c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_16.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import java.util.UUID; -import org.bukkit.entity.Player; - -public class Compatibility1_16 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_16_5 = BukkitVersion.parseBukkitVersion("1.16.5-R0.1"); - public static final BukkitVersion VERSION_1_16_4 = BukkitVersion.parseBukkitVersion("1.16.4-R0.1"); - public static final BukkitVersion VERSION_1_16_3 = BukkitVersion.parseBukkitVersion("1.16.3-R0.1"); - public static final BukkitVersion VERSION_1_16_2 = BukkitVersion.parseBukkitVersion("1.16.2-R0.1"); - public static final BukkitVersion VERSION_1_16_1 = BukkitVersion.parseBukkitVersion("1.16.1-R0.1"); - public static final BukkitVersion VERSION_1_16 = BukkitVersion.parseBukkitVersion("1.16-R0.1"); - public static final Compatibility1_16 INSTANCE = new Compatibility1_16(); - private static final UUID NUL_UUID = new UUID(0L, 0L); - - @Override - public void sendJsonMessage(Player player, String json) { - Class chatMessageTypeClass = this.getServerClass("ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "CHAT"); - this.send(player, json, b); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - Class chatMessageTypeClass = this.getServerClass("ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "GAME_INFO"); - this.send(player, json, b); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - Class argumentEntity = this.getServerClass("ArgumentEntity"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "c"); - } - - @Override - public ArgumentType uuidArgument() { - Class argumentEntity = this.getServerClass("ArgumentUUID"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "a"); - } - - private void send(Player player, String json, Object chatMessageType) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "playerConnection"); - Class packet = this.getServerClass("Packet"); - Class chatSerializer = this.getServerClass("IChatBaseComponent$ChatSerializer"); - Class iChatBaseComponentClass = this.getServerClass("IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(chatSerializer, "a", new Class[]{String.class}, json); - Class packetPlayOutChatClass = this.getServerClass("PacketPlayOutChat"); - Class chatMessageTypeClass = this.getServerClass("ChatMessageType"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID); - ReflectionUtils.callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_17.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_17.java deleted file mode 100644 index c543a09..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_17.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_19; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import java.util.UUID; -import org.bukkit.entity.Player; - -public class Compatibility1_17 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_17_1 = BukkitVersion.parseBukkitVersion("1.17.1-R0.1"); - public static final BukkitVersion VERSION_1_17 = BukkitVersion.parseBukkitVersion("1.17-R0.1"); - public static final Compatibility1_17 INSTANCE = new Compatibility1_17(); - private static final UUID NUL_UUID = new UUID(0L, 0L); - - @Override - public void sendJsonMessage(Player player, String json) { - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "b"); - this.send(player, json, b); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "c"); - this.send(player, json, b); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - return Compatibility1_19.INSTANCE.playerArgument(); - } - - @Override - public ArgumentType uuidArgument() { - return Compatibility1_19.INSTANCE.uuidArgument(); - } - - private void send(Player player, String json, Object chatMessageType) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "b"); - Class packet = ReflectionUtils.getClazz("net.minecraft.network.protocol.Packet"); - Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); - Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); - Class packetPlayOutChatClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.PacketPlayOutChat"); - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID); - ReflectionUtils.callMethod(playerConnection, "sendPacket", new Class[]{packet}, clientboundSystemChatPacket); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java deleted file mode 100644 index 306d5bc..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_18.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_19; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import java.util.UUID; -import org.bukkit.entity.Player; - -public class Compatibility1_18 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_18_2 = BukkitVersion.parseBukkitVersion("1.18.2-R0.1"); - public static final BukkitVersion VERSION_1_18_1 = BukkitVersion.parseBukkitVersion("1.18.1-R0.1"); - public static final BukkitVersion VERSION_1_18 = BukkitVersion.parseBukkitVersion("1.18-R0.1"); - public static final Compatibility1_18 INSTANCE = new Compatibility1_18(); - private static final UUID NUL_UUID = new UUID(0L, 0L); - - @Override - public void sendJsonMessage(Player player, String json) { - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "b"); - this.send(player, json, b); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object b = ReflectionUtils.getField(chatMessageTypeClass, "c"); - this.send(player, json, b); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - return Compatibility1_19.INSTANCE.playerArgument(); - } - - @Override - public ArgumentType uuidArgument() { - return Compatibility1_19.INSTANCE.uuidArgument(); - } - - private void send(Player player, String json, Object chatMessageType) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "b"); - Class packet = ReflectionUtils.getClazz("net.minecraft.network.protocol.Packet"); - Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); - Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); - Class packetPlayOutChatClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.PacketPlayOutChat"); - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(packetPlayOutChatClass, new Class[]{iChatBaseComponentClass, chatMessageTypeClass, UUID.class}, iChatBaseComponent, chatMessageType, NUL_UUID); - ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_19.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_19.java deleted file mode 100644 index beee97f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_19.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_19_1; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import org.bukkit.entity.Player; - -public class Compatibility1_19 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_19 = BukkitVersion.parseBukkitVersion("1.19-R0.1"); - public static final Compatibility1_19 INSTANCE = new Compatibility1_19(); - - @Override - public void sendJsonMessage(Player player, String json) { - this.send(player, json, false); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - this.send(player, json, true); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - return Compatibility1_19_1.INSTANCE.playerArgument(); - } - - @Override - public ArgumentType uuidArgument() { - return Compatibility1_19_1.INSTANCE.uuidArgument(); - } - - private void send(Player player, String json, boolean status) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "b"); - Class packet = ReflectionUtils.getClazz("net.minecraft.network.protocol.Packet"); - Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); - Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); - Class clientboundSystemChatPacketClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, Integer.TYPE}, iChatBaseComponent, this.getId(player, status)); - ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); - } - - private int getId(Player player, boolean status) { - Object world = ReflectionUtils.callMethod((Object)player.getWorld(), "getHandle"); - Class iRegistryCustomClass = ReflectionUtils.getClazz("net.minecraft.core.IRegistryCustom"); - Object iRegistryCustom = ReflectionUtils.callMethod(world, "s"); - Class resourceKeyClass = ReflectionUtils.getClazz("net.minecraft.resources.ResourceKey"); - Class iRegistry = ReflectionUtils.getClazz("net.minecraft.core.IRegistry"); - Object resourceKey = ReflectionUtils.getField(iRegistry, "bI"); - Object registry = ReflectionUtils.callMethod(iRegistryCustomClass, iRegistryCustom, "d", new Class[]{resourceKeyClass}, resourceKey); - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.minecraft.network.chat.ChatMessageType"); - Object chatMessageType = status ? ReflectionUtils.getField(chatMessageTypeClass, "d") : ReflectionUtils.getField(chatMessageTypeClass, "c"); - Object messageType = ReflectionUtils.callMethod(registry, "a", new Class[]{resourceKeyClass}, chatMessageType); - return (Integer)ReflectionUtils.callMethod(registry, "a", new Class[]{Object.class}, messageType); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_19_1.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_19_1.java deleted file mode 100644 index 042c0e9..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_19_1.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import org.bukkit.entity.Player; - -public class Compatibility1_19_1 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_19_4 = BukkitVersion.parseBukkitVersion("1.19.4-R0.1"); - public static final BukkitVersion VERSION_1_19_3 = BukkitVersion.parseBukkitVersion("1.19.3-R0.1"); - public static final BukkitVersion VERSION_1_19_2 = BukkitVersion.parseBukkitVersion("1.19.2-R0.1"); - public static final BukkitVersion VERSION_1_19_1 = BukkitVersion.parseBukkitVersion("1.19.1-R0.1"); - public static final Compatibility1_19_1 INSTANCE = new Compatibility1_19_1(); - - @Override - public void sendJsonMessage(Player player, String json) { - this.send(player, json, false); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - this.send(player, json, true); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - Class argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentEntity"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "c"); - } - - @Override - public ArgumentType uuidArgument() { - Class argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentUUID"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "a"); - } - - private void send(Player player, String json, boolean status) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "b"); - Class packet = ReflectionUtils.getClazz("net.minecraft.network.protocol.Packet"); - Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); - Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); - Class clientboundSystemChatPacketClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, Boolean.TYPE}, iChatBaseComponent, status); - ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20.java deleted file mode 100644 index 984330c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import org.bukkit.entity.Player; - -public class Compatibility1_20 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_20 = BukkitVersion.parseBukkitVersion("1.20-R0.1"); - public static final BukkitVersion VERSION_1_20_1 = BukkitVersion.parseBukkitVersion("1.20.1-R0.1"); - public static final Compatibility1_20 INSTANCE = new Compatibility1_20(); - - @Override - public void sendJsonMessage(Player player, String json) { - this.send(player, json, false); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - this.send(player, json, true); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - Class argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentEntity"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "c"); - } - - @Override - public ArgumentType uuidArgument() { - Class argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentUUID"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "a"); - } - - private void send(Player player, String json, boolean status) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Object playerConnection = ReflectionUtils.getField(entityPlayer, "c"); - Class packet = ReflectionUtils.getClazz("net.minecraft.network.protocol.Packet"); - Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); - Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); - Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); - Class clientboundSystemChatPacketClass = ReflectionUtils.getClazz("net.minecraft.network.protocol.game.ClientboundSystemChatPacket"); - Object clientboundSystemChatPacket = ReflectionUtils.callConstructor(clientboundSystemChatPacketClass, new Class[]{iChatBaseComponentClass, Boolean.TYPE}, iChatBaseComponent, status); - ReflectionUtils.callMethod(playerConnection, "a", new Class[]{packet}, clientboundSystemChatPacket); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20_2.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20_2.java deleted file mode 100644 index faa0598..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20_2.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import org.bukkit.entity.Player; - -public class Compatibility1_20_2 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_20_2 = BukkitVersion.parseBukkitVersion("1.20.2-R0.1"); - public static final Compatibility1_20_2 INSTANCE = new Compatibility1_20_2(); - - @Override - public void sendJsonMessage(Player player, String json) { - this.send(player, json, false); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - this.send(player, json, true); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - Class argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentEntity"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "c"); - } - - @Override - public ArgumentType uuidArgument() { - Class argumentEntity = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentUUID"); - return (ArgumentType)ReflectionUtils.callMethod(argumentEntity, "a"); - } - - private void send(Player player, String json, boolean status) { - Object entityPlayer = ReflectionUtils.callMethod((Object)player, "getHandle"); - Class iChatBaseComponentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent"); - Class craftChatMessage = this.getBukkitClass("util.CraftChatMessage"); - Object iChatBaseComponent = ReflectionUtils.callMethod(craftChatMessage, "fromJSON", new Class[]{String.class}, json); - ReflectionUtils.callMethod(entityPlayer, "a", new Class[]{iChatBaseComponentClass, Boolean.TYPE}, iChatBaseComponent, status); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20_3.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20_3.java deleted file mode 100644 index e2a968a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/Compatibility1_20_3.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.BukkitVersion; -import de.maxhenkel.voicechat.compatibility.Compatibility1_8; -import de.maxhenkel.voicechat.compatibility.JsonMessageBaseCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import java.lang.reflect.Method; -import org.bukkit.entity.Player; - -public class Compatibility1_20_3 -extends JsonMessageBaseCompatibility { - public static final BukkitVersion VERSION_1_20_3 = BukkitVersion.parseBukkitVersion("1.20.3-R0.1"); - public static final BukkitVersion VERSION_1_20_4 = BukkitVersion.parseBukkitVersion("1.20.4-R0.1"); - public static final BukkitVersion VERSION_1_20_5 = BukkitVersion.parseBukkitVersion("1.20.5-R0.1"); - public static final BukkitVersion VERSION_1_20_6 = BukkitVersion.parseBukkitVersion("1.20.6-R0.1"); - public static final BukkitVersion VERSION_1_21 = BukkitVersion.parseBukkitVersion("1.21-R0.1"); - public static final BukkitVersion VERSION_1_21_1 = BukkitVersion.parseBukkitVersion("1.21.1-R0.1"); - public static final BukkitVersion VERSION_1_21_2 = BukkitVersion.parseBukkitVersion("1.21.2-R0.1"); - public static final BukkitVersion VERSION_1_21_3 = BukkitVersion.parseBukkitVersion("1.21.3-R0.1"); - public static final BukkitVersion VERSION_1_21_4 = BukkitVersion.parseBukkitVersion("1.21.4-R0.1"); - public static final Compatibility1_20_3 INSTANCE = new Compatibility1_20_3(); - private Method playerArgument; - private Method uuidArgument; - private Method fromJson; - private Method getHandle; - private Method sendSystemMessage; - - @Override - public void init() throws Exception { - super.init(); - Class argumentEntityClass = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentEntity", "net.minecraft.commands.arguments.EntityArgument"); - this.playerArgument = ReflectionUtils.getMethod(argumentEntityClass, "c", "entity"); - Class argumentUuidClass = ReflectionUtils.getClazz("net.minecraft.commands.arguments.ArgumentUUID", "net.minecraft.commands.arguments.UuidArgument"); - this.uuidArgument = ReflectionUtils.getMethod(argumentUuidClass, "a", "uuid"); - Class craftPlayer = this.getBukkitClass("entity.CraftPlayer"); - this.getHandle = ReflectionUtils.getMethod(craftPlayer, "getHandle"); - Class componentClass = ReflectionUtils.getClazz("net.minecraft.network.chat.IChatBaseComponent", "net.minecraft.network.chat.Component"); - Class craftChatMessageClass = this.getBukkitClass("util.CraftChatMessage"); - this.fromJson = ReflectionUtils.getMethod(craftChatMessageClass, new String[]{"fromJSON"}, new Class[]{String.class}); - Class player = ReflectionUtils.getClazz("net.minecraft.server.level.EntityPlayer", "net.minecraft.server.level.ServerPlayer"); - this.sendSystemMessage = ReflectionUtils.getMethod(player, new String[]{"a", "sendSystemMessage"}, new Class[]{componentClass, Boolean.TYPE}); - } - - @Override - public void sendJsonMessage(Player player, String json) { - this.send(player, json, false); - } - - @Override - public void sendJsonStatusMessage(Player player, String json) { - this.send(player, json, true); - } - - @Override - public String createTranslationMessage(String key, String ... args) { - return Compatibility1_8.constructTranslationMessage(key, args); - } - - @Override - public void sendInviteMessage(Player player, Player commandSender, String groupName, String joinCommand) { - this.sendJsonMessage(player, Compatibility1_8.constructInviteMessage(commandSender, groupName, joinCommand)); - } - - @Override - public void sendIncompatibleMessage(Player player, String pluginVersion, String pluginName) { - this.sendJsonMessage(player, Compatibility1_8.constructIncompatibleMessage(pluginVersion, pluginName)); - } - - @Override - public ArgumentType playerArgument() { - return (ArgumentType)ReflectionUtils.call(this.playerArgument, null, new Object[0]); - } - - @Override - public ArgumentType uuidArgument() { - return (ArgumentType)ReflectionUtils.call(this.uuidArgument, null, new Object[0]); - } - - protected void send(Player player, String json, boolean status) { - ReflectionUtils.call(this.sendSystemMessage, ReflectionUtils.call(this.getHandle, player, new Object[0]), ReflectionUtils.call(this.fromJson, null, json), status); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/JsonMessageBaseCompatibility.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/JsonMessageBaseCompatibility.java deleted file mode 100644 index a893428..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/JsonMessageBaseCompatibility.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import de.maxhenkel.voicechat.compatibility.BaseCompatibility; -import org.bukkit.entity.Player; - -public abstract class JsonMessageBaseCompatibility -extends BaseCompatibility { - @Override - public void sendTranslationMessage(Player player, String key, String ... args) { - this.sendJsonMessage(player, this.createTranslationMessage(key, args)); - } - - @Override - public void sendStatusMessage(Player player, String key, String ... args) { - this.sendJsonStatusMessage(player, this.createTranslationMessage(key, args)); - } - - public abstract void sendJsonMessage(Player var1, String var2); - - public abstract void sendJsonStatusMessage(Player var1, String var2); - - public abstract String createTranslationMessage(String var1, String ... var2); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/compatibility/SpigotCompatibility.java b/source/decompiled/de/maxhenkel/voicechat/compatibility/SpigotCompatibility.java deleted file mode 100644 index 110b2fe..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/compatibility/SpigotCompatibility.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * javax.annotation.Nullable - * org.bukkit.Bukkit - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.compatibility; - -import com.mojang.brigadier.arguments.ArgumentType; -import de.maxhenkel.voicechat.compatibility.FallbackCompatibility; -import de.maxhenkel.voicechat.compatibility.ReflectionUtils; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import javax.annotation.Nullable; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class SpigotCompatibility -extends FallbackCompatibility { - public static final SpigotCompatibility INSTANCE = new SpigotCompatibility(); - private MessageSender messageSender; - - @Override - public void init() throws Exception { - super.init(); - Class playerSpigotClass = ReflectionUtils.getClazz("org.bukkit.entity.Player$Spigot"); - Class baseComponentClass = ReflectionUtils.getClazz("net.md_5.bungee.api.chat.BaseComponent"); - Class chatMessageTypeClass = ReflectionUtils.getClazz("net.md_5.bungee.api.ChatMessageType"); - Object systemType = ReflectionUtils.getField(chatMessageTypeClass, "SYSTEM"); - Object actionBarType = ReflectionUtils.getField(chatMessageTypeClass, "ACTION_BAR"); - Method playerSpigot = ReflectionUtils.getMethod(Player.class, "spigot"); - Method sendMessage = ReflectionUtils.getMethod(playerSpigotClass, new String[]{"sendMessage"}, new Class[]{chatMessageTypeClass, baseComponentClass}); - Class translatableComponentClass = ReflectionUtils.getClazz("net.md_5.bungee.api.chat.TranslatableComponent"); - Constructor translatableComponentConstructor = ReflectionUtils.getConstructor(translatableComponentClass, String.class, Object[].class); - this.messageSender = (player, actionBar, key, args) -> { - Object messageType = actionBar ? actionBarType : systemType; - ReflectionUtils.call(sendMessage, ReflectionUtils.call(playerSpigot, player, new Object[0]), messageType, ReflectionUtils.newInstance(translatableComponentConstructor, key, args)); - }; - } - - public static boolean isSpigotCompatible() { - return ReflectionUtils.doesMethodExist(Bukkit.class, "spigot", new Class[0]); - } - - @Override - public void sendTranslationMessage(Player player, String key, String ... args) { - this.messageSender.send(player, false, key, args); - } - - @Override - public void sendStatusMessage(Player player, String key, String ... args) { - this.messageSender.send(player, true, key, args); - } - - @Override - @Nullable - public ArgumentType playerArgument() { - return null; - } - - @Override - @Nullable - public ArgumentType uuidArgument() { - return null; - } - - private static interface MessageSender { - public void send(Player var1, boolean var2, String var3, String ... var4); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Analysis.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Analysis.java deleted file mode 100644 index 0c253a3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Analysis.java +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.AnalysisInfo; -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.Downmix; -import de.maxhenkel.voicechat.concentus.FFTState; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.KissFFT; -import de.maxhenkel.voicechat.concentus.MultiLayerPerceptron; -import de.maxhenkel.voicechat.concentus.OpusTables; -import de.maxhenkel.voicechat.concentus.TonalityAnalysisState; - -class Analysis { - private static final double M_PI = 3.141592653; - private static final float cA = 0.43157974f; - private static final float cB = 0.678484f; - private static final float cC = 0.08595542f; - private static final float cE = 1.5707964f; - private static final int NB_TONAL_SKIP_BANDS = 9; - - Analysis() { - } - - static float fast_atan2f(float y, float x) { - float y2; - float x2; - if (Inlines.ABS16(x) + Inlines.ABS16(y) < 1.0E-9f) { - x *= 1.0E12f; - y *= 1.0E12f; - } - if ((x2 = x * x) < (y2 = y * y)) { - float den = (y2 + 0.678484f * x2) * (y2 + 0.08595542f * x2); - if (den != 0.0f) { - return -x * y * (y2 + 0.43157974f * x2) / den + (y < 0.0f ? -1.5707964f : 1.5707964f); - } - return y < 0.0f ? -1.5707964f : 1.5707964f; - } - float den = (x2 + 0.678484f * y2) * (x2 + 0.08595542f * y2); - if (den != 0.0f) { - return x * y * (x2 + 0.43157974f * y2) / den + (y < 0.0f ? -1.5707964f : 1.5707964f) - (x * y < 0.0f ? -1.5707964f : 1.5707964f); - } - return (y < 0.0f ? -1.5707964f : 1.5707964f) - (x * y < 0.0f ? -1.5707964f : 1.5707964f); - } - - static void tonality_analysis_init(TonalityAnalysisState tonal) { - tonal.Reset(); - } - - static void tonality_get_info(TonalityAnalysisState tonal, AnalysisInfo info_out, int len) { - int i; - int pos = tonal.read_pos; - int curr_lookahead = tonal.write_pos - tonal.read_pos; - if (curr_lookahead < 0) { - curr_lookahead += 200; - } - if (len > 480 && pos != tonal.write_pos && ++pos == 200) { - pos = 0; - } - if (pos == tonal.write_pos) { - --pos; - } - if (pos < 0) { - pos = 199; - } - info_out.Assign(tonal.info[pos]); - tonal.read_subframe += len / 120; - while (tonal.read_subframe >= 4) { - tonal.read_subframe -= 4; - ++tonal.read_pos; - } - if (tonal.read_pos >= 200) { - tonal.read_pos -= 200; - } - curr_lookahead = Inlines.IMAX(curr_lookahead - 10, 0); - float psum = 0.0f; - for (i = 0; i < 200 - curr_lookahead; ++i) { - psum += tonal.pmusic[i]; - } - while (i < 200) { - psum += tonal.pspeech[i]; - ++i; - } - info_out.music_prob = psum = psum * tonal.music_confidence + (1.0f - psum) * tonal.speech_confidence; - } - - static void tonality_analysis(TonalityAnalysisState tonal, CeltMode celt_mode, short[] x, int x_ptr, int len, int offset, int c1, int c2, int C, int lsb_depth) { - float E; - int b; - int i; - int N = 480; - int N2 = 240; - float[] A = tonal.angle; - float[] dA = tonal.d_angle; - float[] d2A = tonal.d2_angle; - float[] band_tonality = new float[18]; - float[] logE = new float[18]; - float[] BFCC = new float[8]; - float[] features = new float[25]; - float pi4 = 97.40909f; - float slope = 0.0f; - float[] frame_probs = new float[2]; - int bandwidth = 0; - float maxE = 0.0f; - ++tonal.last_transition; - float alpha = 1.0f / (float)Inlines.IMIN(20, 1 + tonal.count); - float alphaE = 1.0f / (float)Inlines.IMIN(50, 1 + tonal.count); - float alphaE2 = 1.0f / (float)Inlines.IMIN(1000, 1 + tonal.count); - if (tonal.count < 4) { - tonal.music_prob = 0.5f; - } - FFTState kfft = celt_mode.mdct.kfft[0]; - if (tonal.count == 0) { - tonal.mem_fill = 240; - } - Downmix.downmix_int(x, x_ptr, tonal.inmem, tonal.mem_fill, Inlines.IMIN(len, 720 - tonal.mem_fill), offset, c1, c2, C); - if (tonal.mem_fill + len < 720) { - tonal.mem_fill += len; - return; - } - AnalysisInfo info = tonal.info[tonal.write_pos++]; - if (tonal.write_pos >= 200) { - tonal.write_pos -= 200; - } - int[] input = new int[960]; - int[] output = new int[960]; - float[] tonality = new float[240]; - float[] noisiness = new float[240]; - for (i = 0; i < N2; ++i) { - float w = OpusTables.analysis_window[i]; - input[2 * i] = (int)(w * (float)tonal.inmem[i]); - input[2 * i + 1] = (int)(w * (float)tonal.inmem[N2 + i]); - input[2 * (N - i - 1)] = (int)(w * (float)tonal.inmem[N - i - 1]); - input[2 * (N - i - 1) + 1] = (int)(w * (float)tonal.inmem[N + N2 - i - 1]); - } - Arrays.MemMove(tonal.inmem, 480, 0, 240); - int remaining = len - (720 - tonal.mem_fill); - Downmix.downmix_int(x, x_ptr, tonal.inmem, 240, remaining, offset + 720 - tonal.mem_fill, c1, c2, C); - tonal.mem_fill = 240 + remaining; - KissFFT.opus_fft(kfft, input, output); - for (i = 1; i < N2; ++i) { - float X1r = (float)output[2 * i] + (float)output[2 * (N - i)]; - float X1i = (float)output[2 * i + 1] - (float)output[2 * (N - i) + 1]; - float X2r = (float)output[2 * i + 1] + (float)output[2 * (N - i) + 1]; - float X2i = (float)output[2 * (N - i)] - (float)output[2 * i]; - float angle = 0.15915494f * Analysis.fast_atan2f(X1i, X1r); - float d_angle = angle - A[i]; - float d2_angle = d_angle - dA[i]; - float angle2 = 0.15915494f * Analysis.fast_atan2f(X2i, X2r); - float d_angle2 = angle2 - angle; - float d2_angle2 = d_angle2 - d_angle; - float mod1 = d2_angle - (float)Math.floor(0.5f + d2_angle); - noisiness[i] = Inlines.ABS16(mod1); - mod1 *= mod1; - mod1 *= mod1; - float mod2 = d2_angle2 - (float)Math.floor(0.5f + d2_angle2); - int n = i; - noisiness[n] = noisiness[n] + Inlines.ABS16(mod2); - mod2 *= mod2; - mod2 *= mod2; - float avg_mod = 0.25f * (d2A[i] + 2.0f * mod1 + mod2); - tonality[i] = 1.0f / (1.0f + 640.0f * pi4 * avg_mod) - 0.015f; - A[i] = angle2; - dA[i] = d_angle2; - d2A[i] = mod2; - } - float frame_tonality = 0.0f; - float max_frame_tonality = 0.0f; - info.activity = 0.0f; - float frame_noisiness = 0.0f; - float frame_stationarity = 0.0f; - if (tonal.count == 0) { - for (b = 0; b < 18; ++b) { - tonal.lowE[b] = 1.0E10f; - tonal.highE[b] = -1.0E10f; - } - } - float relativeE = 0.0f; - float frame_loudness = 0.0f; - for (b = 0; b < 18; ++b) { - E = 0.0f; - float tE = 0.0f; - float nE = 0.0f; - for (i = OpusTables.tbands[b]; i < OpusTables.tbands[b + 1]; ++i) { - float binE = (float)output[2 * i] * (float)output[2 * i] + (float)output[2 * (N - i)] * (float)output[2 * (N - i)] + (float)output[2 * i + 1] * (float)output[2 * i + 1] + (float)output[2 * (N - i) + 1] * (float)output[2 * (N - i) + 1]; - E += (binE *= 5.55E-17f); - tE += binE * tonality[i]; - nE += binE * 2.0f * (0.5f - noisiness[i]); - } - tonal.E[tonal.E_count][b] = E; - frame_noisiness += nE / (1.0E-15f + E); - frame_loudness += (float)Math.sqrt(E + 1.0E-10f); - logE[b] = (float)Math.log(E + 1.0E-10f); - tonal.lowE[b] = Inlines.MIN32(logE[b], tonal.lowE[b] + 0.01f); - tonal.highE[b] = Inlines.MAX32(logE[b], tonal.highE[b] - 0.1f); - if (tonal.highE[b] < tonal.lowE[b] + 1.0f) { - int n = b; - tonal.highE[n] = tonal.highE[n] + 0.5f; - int n2 = b; - tonal.lowE[n2] = tonal.lowE[n2] - 0.5f; - } - relativeE += (logE[b] - tonal.lowE[b]) / (1.0E-15f + tonal.highE[b] - tonal.lowE[b]); - float L2 = 0.0f; - float L1 = 0.0f; - for (i = 0; i < 8; ++i) { - L1 += (float)Math.sqrt(tonal.E[i][b]); - L2 += tonal.E[i][b]; - } - float stationarity = Inlines.MIN16(0.99f, L1 / (float)Math.sqrt(1.0E-15 + (double)(8.0f * L2))); - stationarity *= stationarity; - stationarity *= stationarity; - frame_stationarity += stationarity; - band_tonality[b] = Inlines.MAX16(tE / (1.0E-15f + E), stationarity * tonal.prev_band_tonality[b]); - frame_tonality += band_tonality[b]; - if (b >= 9) { - frame_tonality -= band_tonality[b - 18 + 9]; - } - max_frame_tonality = Inlines.MAX16(max_frame_tonality, (1.0f + 0.03f * (float)(b - 18)) * frame_tonality); - slope += band_tonality[b] * (float)(b - 8); - tonal.prev_band_tonality[b] = band_tonality[b]; - } - float bandwidth_mask = 0.0f; - bandwidth = 0; - maxE = 0.0f; - float noise_floor = 5.7E-4f / (float)(1 << Inlines.IMAX(0, lsb_depth - 8)); - noise_floor *= 1.3421773E8f; - noise_floor *= noise_floor; - for (b = 0; b < 21; ++b) { - E = 0.0f; - int band_start = OpusTables.extra_bands[b]; - int band_end = OpusTables.extra_bands[b + 1]; - for (i = band_start; i < band_end; ++i) { - float binE = (float)output[2 * i] * (float)output[2 * i] + (float)output[2 * (N - i)] * (float)output[2 * (N - i)] + (float)output[2 * i + 1] * (float)output[2 * i + 1] + (float)output[2 * (N - i) + 1] * (float)output[2 * (N - i) + 1]; - E += binE; - } - maxE = Inlines.MAX32(maxE, E); - tonal.meanE[b] = Inlines.MAX32((1.0f - alphaE2) * tonal.meanE[b], E); - if (!((double)(E = Inlines.MAX32(E, tonal.meanE[b])) > 0.1 * (double)(bandwidth_mask = Inlines.MAX32(0.05f * bandwidth_mask, E))) || !(E * 1.0E9f > maxE) || !(E > noise_floor * (float)(band_end - band_start))) continue; - bandwidth = b; - } - if (tonal.count <= 2) { - bandwidth = 20; - } - frame_loudness = 20.0f * (float)Math.log10(frame_loudness); - tonal.Etracker = Inlines.MAX32(tonal.Etracker - 0.03f, frame_loudness); - tonal.lowECount *= 1.0f - alphaE; - if (frame_loudness < tonal.Etracker - 30.0f) { - tonal.lowECount += alphaE; - } - for (i = 0; i < 8; ++i) { - float sum = 0.0f; - for (b = 0; b < 16; ++b) { - sum += OpusTables.dct_table[i * 16 + b] * logE[b]; - } - BFCC[i] = sum; - } - frame_stationarity /= 18.0f; - relativeE /= 18.0f; - if (tonal.count < 10) { - relativeE = 0.5f; - } - info.activity = (frame_noisiness /= 18.0f) + (1.0f - frame_noisiness) * relativeE; - frame_tonality = max_frame_tonality / 9.0f; - tonal.prev_tonality = frame_tonality = Inlines.MAX16(frame_tonality, tonal.prev_tonality * 0.8f); - info.tonality_slope = slope /= 64.0f; - tonal.E_count = (tonal.E_count + 1) % 8; - ++tonal.count; - info.tonality = frame_tonality; - for (i = 0; i < 4; ++i) { - features[i] = -0.12299f * (BFCC[i] + tonal.mem[i + 24]) + 0.49195f * (tonal.mem[i] + tonal.mem[i + 16]) + 0.69693f * tonal.mem[i + 8] - 1.4349f * tonal.cmean[i]; - } - for (i = 0; i < 4; ++i) { - tonal.cmean[i] = (1.0f - alpha) * tonal.cmean[i] + alpha * BFCC[i]; - } - for (i = 0; i < 4; ++i) { - features[4 + i] = 0.63246f * (BFCC[i] - tonal.mem[i + 24]) + 0.31623f * (tonal.mem[i] - tonal.mem[i + 16]); - } - for (i = 0; i < 3; ++i) { - features[8 + i] = 0.53452f * (BFCC[i] + tonal.mem[i + 24]) - 0.26726f * (tonal.mem[i] + tonal.mem[i + 16]) - 0.53452f * tonal.mem[i + 8]; - } - if (tonal.count > 5) { - for (i = 0; i < 9; ++i) { - tonal.std[i] = (1.0f - alpha) * tonal.std[i] + alpha * features[i] * features[i]; - } - } - for (i = 0; i < 8; ++i) { - tonal.mem[i + 24] = tonal.mem[i + 16]; - tonal.mem[i + 16] = tonal.mem[i + 8]; - tonal.mem[i + 8] = tonal.mem[i]; - tonal.mem[i] = BFCC[i]; - } - for (i = 0; i < 9; ++i) { - features[11 + i] = (float)Math.sqrt(tonal.std[i]); - } - features[20] = info.tonality; - features[21] = info.activity; - features[22] = frame_stationarity; - features[23] = info.tonality_slope; - features[24] = tonal.lowECount; - if (info.enabled) { - MultiLayerPerceptron.mlp_process(OpusTables.net, features, frame_probs); - frame_probs[0] = 0.5f * (frame_probs[0] + 1.0f); - frame_probs[0] = 0.01f + 1.21f * frame_probs[0] * frame_probs[0] - 0.23f * (float)Math.pow(frame_probs[0], 10.0); - frame_probs[1] = 0.5f * frame_probs[1] + 0.5f; - frame_probs[0] = frame_probs[1] * frame_probs[0] + (1.0f - frame_probs[1]) * 0.5f; - float tau = 5.0E-5f * frame_probs[1]; - float beta = 0.05f; - float p = Inlines.MAX16(0.05f, Inlines.MIN16(0.95f, frame_probs[0])); - float q = Inlines.MAX16(0.05f, Inlines.MIN16(0.95f, tonal.music_prob)); - beta = 0.01f + 0.05f * Inlines.ABS16(p - q) / (p * (1.0f - q) + q * (1.0f - p)); - float p0 = (1.0f - tonal.music_prob) * (1.0f - tau) + tonal.music_prob * tau; - float p1 = tonal.music_prob * (1.0f - tau) + (1.0f - tonal.music_prob) * tau; - info.music_prob = tonal.music_prob = (p1 *= (float)Math.pow(frame_probs[0], beta)) / ((p0 *= (float)Math.pow(1.0f - frame_probs[0], beta)) + p1); - float psum = 1.0E-20f; - float speech0 = (float)Math.pow(1.0f - frame_probs[0], beta); - float music0 = (float)Math.pow(frame_probs[0], beta); - if (tonal.count == 1) { - tonal.pspeech[0] = 0.5f; - tonal.pmusic[0] = 0.5f; - } - float s0 = tonal.pspeech[0] + tonal.pspeech[1]; - float m0 = tonal.pmusic[0] + tonal.pmusic[1]; - tonal.pspeech[0] = s0 * (1.0f - tau) * speech0; - tonal.pmusic[0] = m0 * (1.0f - tau) * music0; - for (i = 1; i < 199; ++i) { - tonal.pspeech[i] = tonal.pspeech[i + 1] * speech0; - tonal.pmusic[i] = tonal.pmusic[i + 1] * music0; - } - tonal.pspeech[199] = m0 * tau * speech0; - tonal.pmusic[199] = s0 * tau * music0; - for (i = 0; i < 200; ++i) { - psum += tonal.pspeech[i] + tonal.pmusic[i]; - } - psum = 1.0f / psum; - i = 0; - while (i < 200) { - int n = i; - tonal.pspeech[n] = tonal.pspeech[n] * psum; - int n3 = i++; - tonal.pmusic[n3] = tonal.pmusic[n3] * psum; - } - psum = tonal.pmusic[0]; - for (i = 1; i < 200; ++i) { - psum += tonal.pspeech[i]; - } - if ((double)frame_probs[1] > 0.75) { - float adapt; - if ((double)tonal.music_prob > 0.9) { - adapt = 1.0f / (float)(++tonal.music_confidence_count); - tonal.music_confidence_count = Inlines.IMIN(tonal.music_confidence_count, 500); - tonal.music_confidence += adapt * Inlines.MAX16(-0.2f, frame_probs[0] - tonal.music_confidence); - } - if ((double)tonal.music_prob < 0.1) { - adapt = 1.0f / (float)(++tonal.speech_confidence_count); - tonal.speech_confidence_count = Inlines.IMIN(tonal.speech_confidence_count, 500); - tonal.speech_confidence += adapt * Inlines.MIN16(0.2f, frame_probs[0] - tonal.speech_confidence); - } - } else { - if (tonal.music_confidence_count == 0) { - tonal.music_confidence = 0.9f; - } - if (tonal.speech_confidence_count == 0) { - tonal.speech_confidence = 0.1f; - } - } - if (tonal.last_music != (tonal.music_prob > 0.5f ? 1 : 0)) { - tonal.last_transition = 0; - } - tonal.last_music = tonal.music_prob > 0.5f ? 1 : 0; - } else { - info.music_prob = 0.0f; - } - info.bandwidth = bandwidth; - info.noisiness = frame_noisiness; - info.valid = 1; - } - - static void run_analysis(TonalityAnalysisState analysis, CeltMode celt_mode, short[] analysis_pcm, int analysis_pcm_ptr, int analysis_frame_size, int frame_size, int c1, int c2, int C, int Fs, int lsb_depth, AnalysisInfo analysis_info) { - if (analysis_pcm != null) { - analysis_frame_size = Inlines.IMIN(195 * Fs / 100, analysis_frame_size); - int pcm_len = analysis_frame_size - analysis.analysis_offset; - int offset = analysis.analysis_offset; - do { - Analysis.tonality_analysis(analysis, celt_mode, analysis_pcm, analysis_pcm_ptr, Inlines.IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth); - offset += 480; - } while ((pcm_len -= 480) > 0); - analysis.analysis_offset = analysis_frame_size; - analysis.analysis_offset -= frame_size; - } - analysis_info.valid = 0; - Analysis.tonality_get_info(analysis, analysis_info, frame_size); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/AnalysisInfo.java b/source/decompiled/de/maxhenkel/voicechat/concentus/AnalysisInfo.java deleted file mode 100644 index 68fb9be..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/AnalysisInfo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class AnalysisInfo { - boolean enabled = false; - int valid = 0; - float tonality = 0.0f; - float tonality_slope = 0.0f; - float noisiness = 0.0f; - float activity = 0.0f; - float music_prob = 0.0f; - int bandwidth = 0; - - AnalysisInfo() { - } - - void Assign(AnalysisInfo other) { - this.valid = other.valid; - this.tonality = other.tonality; - this.tonality_slope = other.tonality_slope; - this.noisiness = other.noisiness; - this.activity = other.activity; - this.music_prob = other.music_prob; - this.bandwidth = other.bandwidth; - } - - void Reset() { - this.valid = 0; - this.tonality = 0.0f; - this.tonality_slope = 0.0f; - this.noisiness = 0.0f; - this.activity = 0.0f; - this.music_prob = 0.0f; - this.bandwidth = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/ApplySineWindow.java b/source/decompiled/de/maxhenkel/voicechat/concentus/ApplySineWindow.java deleted file mode 100644 index 3768608..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/ApplySineWindow.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class ApplySineWindow { - private static final short[] freq_table_Q16 = new short[]{12111, 9804, 8235, 7100, 6239, 5565, 5022, 4575, 4202, 3885, 3612, 3375, 3167, 2984, 2820, 2674, 2542, 2422, 2313, 2214, 2123, 2038, 1961, 1889, 1822, 1760, 1702}; - - ApplySineWindow() { - } - - static void silk_apply_sine_window(short[] px_win, int px_win_ptr, short[] px, int px_ptr, int win_type, int length) { - int S1_Q16; - int S0_Q16; - Inlines.OpusAssert(win_type == 1 || win_type == 2); - Inlines.OpusAssert(length >= 16 && length <= 120); - Inlines.OpusAssert((length & 3) == 0); - int k = (length >> 2) - 4; - Inlines.OpusAssert(k >= 0 && k <= 26); - short f_Q16 = freq_table_Q16[k]; - int c_Q16 = Inlines.silk_SMULWB(f_Q16, -f_Q16); - Inlines.OpusAssert(c_Q16 >= Short.MIN_VALUE); - if (win_type == 1) { - S0_Q16 = 0; - S1_Q16 = f_Q16 + Inlines.silk_RSHIFT(length, 3); - } else { - S0_Q16 = 65536; - S1_Q16 = 65536 + Inlines.silk_RSHIFT(c_Q16, 1) + Inlines.silk_RSHIFT(length, 4); - } - for (k = 0; k < length; k += 4) { - int pxwk = px_win_ptr + k; - int pxk = px_ptr + k; - px_win[pxwk] = (short)Inlines.silk_SMULWB(Inlines.silk_RSHIFT(S0_Q16 + S1_Q16, 1), px[pxk]); - px_win[pxwk + 1] = (short)Inlines.silk_SMULWB(S1_Q16, px[pxk + 1]); - S0_Q16 = Inlines.silk_SMULWB(S1_Q16, c_Q16) + Inlines.silk_LSHIFT(S1_Q16, 1) - S0_Q16 + 1; - S0_Q16 = Inlines.silk_min(S0_Q16, 65536); - px_win[pxwk + 2] = (short)Inlines.silk_SMULWB(Inlines.silk_RSHIFT(S0_Q16 + S1_Q16, 1), px[pxk + 2]); - px_win[pxwk + 3] = (short)Inlines.silk_SMULWB(S0_Q16, px[pxk + 3]); - S1_Q16 = Inlines.silk_SMULWB(S0_Q16, c_Q16) + Inlines.silk_LSHIFT(S0_Q16, 1) - S1_Q16; - S1_Q16 = Inlines.silk_min(S1_Q16, 65536); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Arrays.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Arrays.java deleted file mode 100644 index 5310f34..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Arrays.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class Arrays { - Arrays() { - } - - static int[][] InitTwoDimensionalArrayInt(int x, int y) { - return new int[x][y]; - } - - static float[][] InitTwoDimensionalArrayFloat(int x, int y) { - return new float[x][y]; - } - - static short[][] InitTwoDimensionalArrayShort(int x, int y) { - return new short[x][y]; - } - - static byte[][] InitTwoDimensionalArrayByte(int x, int y) { - return new byte[x][y]; - } - - static byte[][][] InitThreeDimensionalArrayByte(int x, int y, int z) { - return new byte[x][y][z]; - } - - static void MemSet(byte[] array, byte value) { - java.util.Arrays.fill(array, value); - } - - static void MemSet(short[] array, short value) { - java.util.Arrays.fill(array, value); - } - - static void MemSet(int[] array, int value) { - java.util.Arrays.fill(array, value); - } - - static void MemSet(float[] array, float value) { - java.util.Arrays.fill(array, value); - } - - static void MemSet(byte[] array, byte value, int length) { - java.util.Arrays.fill(array, 0, length, value); - } - - static void MemSet(short[] array, short value, int length) { - java.util.Arrays.fill(array, 0, length, value); - } - - static void MemSet(int[] array, int value, int length) { - java.util.Arrays.fill(array, 0, length, value); - } - - static void MemSet(float[] array, float value, int length) { - java.util.Arrays.fill(array, 0, length, value); - } - - static void MemSetWithOffset(byte[] array, byte value, int offset, int length) { - java.util.Arrays.fill(array, offset, offset + length, value); - } - - static void MemSetWithOffset(short[] array, short value, int offset, int length) { - java.util.Arrays.fill(array, offset, offset + length, value); - } - - static void MemSetWithOffset(int[] array, int value, int offset, int length) { - java.util.Arrays.fill(array, offset, offset + length, value); - } - - static void MemMove(byte[] array, int src_idx, int dst_idx, int length) { - System.arraycopy(array, src_idx, array, dst_idx, length); - } - - static void MemMove(short[] array, int src_idx, int dst_idx, int length) { - System.arraycopy(array, src_idx, array, dst_idx, length); - } - - static void MemMove(int[] array, int src_idx, int dst_idx, int length) { - System.arraycopy(array, src_idx, array, dst_idx, length); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Autocorrelation.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Autocorrelation.java deleted file mode 100644 index 42ba397..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Autocorrelation.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltPitchXCorr; -import de.maxhenkel.voicechat.concentus.Inlines; - -class Autocorrelation { - private static final int QC = 10; - private static final int QS = 14; - - Autocorrelation() { - } - - static void silk_autocorr(int[] results, BoxedValueInt scale, short[] inputData, int inputDataSize, int correlationCount) { - int corrCount = Inlines.silk_min_int(inputDataSize, correlationCount); - scale.Val = Autocorrelation._celt_autocorr(inputData, results, corrCount - 1, inputDataSize); - } - - static int _celt_autocorr(short[] x, int[] ac, int lag, int n) { - int shift2; - int i; - int fastN = n - lag; - short[] xx = new short[n]; - Inlines.OpusAssert(n > 0); - short[] xptr = x; - int shift = 0; - int ac0 = 1 + (n << 7); - if ((n & 1) != 0) { - ac0 += Inlines.SHR32(Inlines.MULT16_16(xptr[0], xptr[0]), 9); - } - for (i = n & 1; i < n; i += 2) { - ac0 += Inlines.SHR32(Inlines.MULT16_16(xptr[i], xptr[i]), 9); - ac0 += Inlines.SHR32(Inlines.MULT16_16(xptr[i + 1], xptr[i + 1]), 9); - } - shift = Inlines.celt_ilog2(ac0) - 30 + 10; - if ((shift /= 2) > 0) { - for (i = 0; i < n; ++i) { - xx[i] = (short)Inlines.PSHR32(xptr[i], shift); - } - xptr = xx; - } else { - shift = 0; - } - CeltPitchXCorr.pitch_xcorr(xptr, xptr, ac, fastN, lag + 1); - int k = 0; - while (k <= lag) { - int d = 0; - for (i = k + fastN; i < n; ++i) { - d = Inlines.MAC16_16(d, xptr[i], xptr[i - k]); - } - int n2 = k++; - ac[n2] = ac[n2] + d; - } - if ((shift = 2 * shift) <= 0) { - ac[0] = ac[0] + Inlines.SHL32(1, -shift); - } - if (ac[0] < 0x10000000) { - shift2 = 29 - Inlines.EC_ILOG(ac[0]); - for (i = 0; i <= lag; ++i) { - ac[i] = Inlines.SHL32(ac[i], shift2); - } - shift -= shift2; - } else if (ac[0] >= 0x20000000) { - shift2 = 1; - if (ac[0] >= 0x40000000) { - ++shift2; - } - for (i = 0; i <= lag; ++i) { - ac[i] = Inlines.SHR32(ac[i], shift2); - } - shift += shift2; - } - return shift; - } - - static int _celt_autocorr(int[] x, int[] ac, int[] window, int overlap, int lag, int n) { - int i; - int[] xptr; - int fastN = n - lag; - int[] xx = new int[n]; - Inlines.OpusAssert(n > 0); - Inlines.OpusAssert(overlap >= 0); - if (overlap == 0) { - xptr = x; - } else { - for (i = 0; i < n; ++i) { - xx[i] = x[i]; - } - for (i = 0; i < overlap; ++i) { - xx[i] = Inlines.MULT16_16_Q15(x[i], window[i]); - xx[n - i - 1] = Inlines.MULT16_16_Q15(x[n - i - 1], window[i]); - } - xptr = xx; - } - int shift = 0; - int ac0 = 1 + (n << 7); - if ((n & 1) != 0) { - ac0 += Inlines.SHR32(Inlines.MULT16_16(xptr[0], xptr[0]), 9); - } - for (i = n & 1; i < n; i += 2) { - ac0 += Inlines.SHR32(Inlines.MULT16_16(xptr[i], xptr[i]), 9); - ac0 += Inlines.SHR32(Inlines.MULT16_16(xptr[i + 1], xptr[i + 1]), 9); - } - shift = Inlines.celt_ilog2(ac0) - 30 + 10; - if ((shift /= 2) > 0) { - for (i = 0; i < n; ++i) { - xx[i] = Inlines.PSHR32(xptr[i], shift); - } - xptr = xx; - } else { - shift = 0; - } - CeltPitchXCorr.pitch_xcorr(xptr, xptr, ac, fastN, lag + 1); - int k = 0; - while (k <= lag) { - int d = 0; - for (i = k + fastN; i < n; ++i) { - d = Inlines.MAC16_16(d, xptr[i], xptr[i - k]); - } - int n2 = k++; - ac[n2] = ac[n2] + d; - } - if ((shift = 2 * shift) <= 0) { - ac[0] = ac[0] + Inlines.SHL32(1, -shift); - } - if (ac[0] < 0x10000000) { - int shift2 = 29 - Inlines.EC_ILOG(ac[0]); - for (i = 0; i <= lag; ++i) { - ac[i] = Inlines.SHL32(ac[i], shift2); - } - shift -= shift2; - } else if (ac[0] >= 0x20000000) { - int shift2 = 1; - if (ac[0] >= 0x40000000) { - ++shift2; - } - for (i = 0; i <= lag; ++i) { - ac[i] = Inlines.SHR32(ac[i], shift2); - } - shift += shift2; - } - return shift; - } - - static void silk_warped_autocorrelation(int[] corr, BoxedValueInt scale, short[] input, int warping_Q16, int length, int order) { - int i; - int[] state_QS = new int[17]; - long[] corr_QC = new long[17]; - Inlines.OpusAssert((order & 1) == 0); - Inlines.OpusAssert(true); - for (int n = 0; n < length; ++n) { - int tmp1_QS = Inlines.silk_LSHIFT32(input[n], 14); - for (i = 0; i < order; i += 2) { - int tmp2_QS = Inlines.silk_SMLAWB(state_QS[i], state_QS[i + 1] - tmp1_QS, warping_Q16); - state_QS[i] = tmp1_QS; - int n2 = i; - corr_QC[n2] = corr_QC[n2] + Inlines.silk_RSHIFT64(Inlines.silk_SMULL(tmp1_QS, state_QS[0]), 18); - tmp1_QS = Inlines.silk_SMLAWB(state_QS[i + 1], state_QS[i + 2] - tmp2_QS, warping_Q16); - state_QS[i + 1] = tmp2_QS; - int n3 = i + 1; - corr_QC[n3] = corr_QC[n3] + Inlines.silk_RSHIFT64(Inlines.silk_SMULL(tmp2_QS, state_QS[0]), 18); - } - state_QS[order] = tmp1_QS; - int n4 = order; - corr_QC[n4] = corr_QC[n4] + Inlines.silk_RSHIFT64(Inlines.silk_SMULL(tmp1_QS, state_QS[0]), 18); - } - int lsh = Inlines.silk_CLZ64(corr_QC[0]) - 35; - lsh = Inlines.silk_LIMIT(lsh, -22, 20); - scale.Val = -(10 + lsh); - Inlines.OpusAssert(scale.Val >= -30 && scale.Val <= 12); - if (lsh >= 0) { - for (i = 0; i < order + 1; ++i) { - corr[i] = (int)Inlines.silk_LSHIFT64(corr_QC[i], lsh); - } - } else { - for (i = 0; i < order + 1; ++i) { - corr[i] = (int)Inlines.silk_RSHIFT64(corr_QC[i], -lsh); - } - } - Inlines.OpusAssert(corr_QC[0] >= 0L); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/BWExpander.java b/source/decompiled/de/maxhenkel/voicechat/concentus/BWExpander.java deleted file mode 100644 index a0a4036..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/BWExpander.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class BWExpander { - BWExpander() { - } - - static void silk_bwexpander_32(int[] ar, int d, int chirp_Q16) { - int chirp_minus_one_Q16 = chirp_Q16 - 65536; - for (int i = 0; i < d - 1; ++i) { - ar[i] = Inlines.silk_SMULWW(chirp_Q16, ar[i]); - chirp_Q16 += Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, chirp_minus_one_Q16), 16); - } - ar[d - 1] = Inlines.silk_SMULWW(chirp_Q16, ar[d - 1]); - } - - static void silk_bwexpander(short[] ar, int d, int chirp_Q16) { - int chirp_minus_one_Q16 = chirp_Q16 - 65536; - for (int i = 0; i < d - 1; ++i) { - ar[i] = (short)Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, ar[i]), 16); - chirp_Q16 += Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, chirp_minus_one_Q16), 16); - } - ar[d - 1] = (short)Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, ar[d - 1]), 16); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Bands.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Bands.java deleted file mode 100644 index 7b7c49d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Bands.java +++ /dev/null @@ -1,986 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; -import de.maxhenkel.voicechat.concentus.Rate; -import de.maxhenkel.voicechat.concentus.VQ; - -class Bands { - private static final byte[] bit_interleave_table = new byte[]{0, 1, 1, 1, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3}; - private static final short[] bit_deinterleave_table = new short[]{0, 3, 12, 15, 48, 51, 60, 63, 192, 195, 204, 207, 240, 243, 252, 255}; - - Bands() { - } - - static int hysteresis_decision(int val, int[] thresholds, int[] hysteresis, int N, int prev) { - int i; - for (i = 0; i < N && val >= thresholds[i]; ++i) { - } - if (i > prev && val < thresholds[prev] + hysteresis[prev]) { - i = prev; - } - if (i < prev && val > thresholds[prev - 1] - hysteresis[prev - 1]) { - i = prev; - } - return i; - } - - static int celt_lcg_rand(int seed) { - return 1664525 * seed + 1013904223; - } - - static int bitexact_cos(int x) { - int tmp = 4096 + x * x >> 13; - Inlines.OpusAssert(tmp <= Short.MAX_VALUE); - int x2 = tmp; - x2 = Short.MAX_VALUE - x2 + Inlines.FRAC_MUL16(x2, -7651 + Inlines.FRAC_MUL16(x2, 8277 + Inlines.FRAC_MUL16(-626, x2))); - Inlines.OpusAssert(x2 <= 32766); - return 1 + x2; - } - - static int bitexact_log2tan(int isin, int icos) { - int lc = Inlines.EC_ILOG(icos); - int ls = Inlines.EC_ILOG(isin); - return (ls - lc) * 2048 + Inlines.FRAC_MUL16(isin <<= 15 - ls, Inlines.FRAC_MUL16(isin, -2597) + 7932) - Inlines.FRAC_MUL16(icos <<= 15 - lc, Inlines.FRAC_MUL16(icos, -2597) + 7932); - } - - static void compute_band_energies(CeltMode m, int[][] X, int[][] bandE, int end, int C, int LM) { - short[] eBands = m.eBands; - int N = m.shortMdctSize << LM; - int c = 0; - do { - for (int i = 0; i < end; ++i) { - int maxval = 0; - int sum = 0; - maxval = Inlines.celt_maxabs32(X[c], eBands[i] << LM, eBands[i + 1] - eBands[i] << LM); - if (maxval > 0) { - int shift = Inlines.celt_ilog2(maxval) - 14 + ((m.logN[i] >> 3) + LM + 1 >> 1); - int j = eBands[i] << LM; - if (shift > 0) { - do { - sum = Inlines.MAC16_16(sum, Inlines.EXTRACT16(Inlines.SHR32(X[c][j], shift)), Inlines.EXTRACT16(Inlines.SHR32(X[c][j], shift))); - } while (++j < eBands[i + 1] << LM); - } else { - do { - sum = Inlines.MAC16_16(sum, Inlines.EXTRACT16(Inlines.SHL32(X[c][j], -shift)), Inlines.EXTRACT16(Inlines.SHL32(X[c][j], -shift))); - } while (++j < eBands[i + 1] << LM); - } - bandE[c][i] = 1 + Inlines.VSHR32(Inlines.celt_sqrt(sum), -shift); - continue; - } - bandE[c][i] = 1; - } - } while (++c < C); - } - - static void normalise_bands(CeltMode m, int[][] freq, int[][] X, int[][] bandE, int end, int C, int M) { - short[] eBands = m.eBands; - int c = 0; - do { - int i = 0; - do { - int shift = Inlines.celt_zlog2(bandE[c][i]) - 13; - int E = Inlines.VSHR32(bandE[c][i], shift); - short g = Inlines.EXTRACT16(Inlines.celt_rcp(Inlines.SHL32(E, 3))); - int j = M * eBands[i]; - do { - X[c][j] = Inlines.MULT16_16_Q15(Inlines.VSHR32(freq[c][j], shift - 1), (int)g); - } while (++j < M * eBands[i + 1]); - } while (++i < end); - } while (++c < C); - } - - static void denormalise_bands(CeltMode m, int[] X, int[] freq, int freq_ptr, int[] bandLogE, int bandLogE_ptr, int start, int end, int M, int downsample, int silence) { - int i; - short[] eBands = m.eBands; - int N = M * m.shortMdctSize; - int bound = M * eBands[end]; - if (downsample != 1) { - bound = Inlines.IMIN(bound, N / downsample); - } - if (silence != 0) { - bound = 0; - end = 0; - start = 0; - } - int f = freq_ptr; - int x = M * eBands[start]; - for (i = 0; i < M * eBands[start]; ++i) { - freq[f++] = 0; - } - for (i = start; i < end; ++i) { - int g; - int j = M * eBands[i]; - int band_end = M * eBands[i + 1]; - int lg = Inlines.ADD16(bandLogE[bandLogE_ptr + i], (int)Inlines.SHL16(CeltTables.eMeans[i], 6)); - int shift = 16 - (lg >> 10); - if (shift > 31) { - shift = 0; - g = 0; - } else { - g = Inlines.celt_exp2_frac(lg & 0x3FF); - } - if (shift < 0) { - if (shift < -2) { - g = Short.MAX_VALUE; - shift = -2; - } - do { - freq[f] = Inlines.SHR32(Inlines.MULT16_16(X[x], g), -shift); - } while (++j < band_end); - continue; - } - do { - freq[f++] = Inlines.SHR32(Inlines.MULT16_16(X[x++], g), shift); - } while (++j < band_end); - } - Inlines.OpusAssert(start <= end); - Arrays.MemSetWithOffset(freq, 0, freq_ptr + bound, N - bound); - } - - static void anti_collapse(CeltMode m, int[][] X_, short[] collapse_masks, int LM, int C, int size, int start, int end, int[] logE, int[] prev1logE, int[] prev2logE, int[] pulses, int seed) { - for (int i = start; i < end; ++i) { - int N0 = m.eBands[i + 1] - m.eBands[i]; - Inlines.OpusAssert(pulses[i] >= 0); - int depth = Inlines.celt_udiv(1 + pulses[i], m.eBands[i + 1] - m.eBands[i]) >> LM; - int thresh32 = Inlines.SHR32(Inlines.celt_exp2(0 - Inlines.SHL16(depth, 7)), 1); - int thresh = Inlines.MULT16_32_Q15((short)16384, Inlines.MIN32(Short.MAX_VALUE, thresh32)); - int t = N0 << LM; - int shift = Inlines.celt_ilog2(t) >> 1; - t = Inlines.SHL32(t, 7 - shift << 1); - int sqrt_1 = Inlines.celt_rsqrt_norm(t); - int c = 0; - do { - int r; - boolean renormalize = false; - int prev1 = prev1logE[c * m.nbEBands + i]; - int prev2 = prev2logE[c * m.nbEBands + i]; - if (C == 1) { - prev1 = Inlines.MAX16(prev1, prev1logE[m.nbEBands + i]); - prev2 = Inlines.MAX16(prev2, prev2logE[m.nbEBands + i]); - } - int Ediff = Inlines.EXTEND32(logE[c * m.nbEBands + i]) - Inlines.EXTEND32(Inlines.MIN16(prev1, prev2)); - if ((Ediff = Inlines.MAX32(0, Ediff)) < 16384) { - int r32 = Inlines.SHR32(Inlines.celt_exp2((short)(0 - Inlines.EXTRACT16(Ediff))), 1); - r = 2 * Inlines.MIN16(16383, r32); - } else { - r = 0; - } - if (LM == 3) { - r = Inlines.MULT16_16_Q14(23170, Inlines.MIN32(23169, r)); - } - r = Inlines.SHR16(Inlines.MIN16(thresh, r), 1); - r = Inlines.SHR32(Inlines.MULT16_16_Q15(sqrt_1, r), shift); - int X = m.eBands[i] << LM; - for (int k = 0; k < 1 << LM; ++k) { - if ((collapse_masks[i * C + c] & 1 << k) != 0) continue; - int Xk = X + k; - for (int j = 0; j < N0; ++j) { - seed = Bands.celt_lcg_rand(seed); - X_[c][Xk + (j << LM)] = (seed & 0x8000) != 0 ? r : 0 - r; - } - renormalize = true; - } - if (!renormalize) continue; - VQ.renormalise_vector(X_[c], X, N0 << LM, Short.MAX_VALUE); - } while (++c < C); - } - } - - static void intensity_stereo(CeltMode m, int[] X, int X_ptr, int[] Y, int Y_ptr, int[][] bandE, int bandID, int N) { - int i = bandID; - int shift = Inlines.celt_zlog2(Inlines.MAX32(bandE[0][i], bandE[1][i])) - 13; - int left = Inlines.VSHR32(bandE[0][i], shift); - int right = Inlines.VSHR32(bandE[1][i], shift); - int norm = 1 + Inlines.celt_sqrt(1 + Inlines.MULT16_16(left, left) + Inlines.MULT16_16(right, right)); - int a1 = Inlines.DIV32_16(Inlines.SHL32(left, 14), norm); - int a2 = Inlines.DIV32_16(Inlines.SHL32(right, 14), norm); - for (int j = 0; j < N; ++j) { - int l = X[X_ptr + j]; - int r = Y[Y_ptr + j]; - X[X_ptr + j] = Inlines.EXTRACT16(Inlines.SHR32(Inlines.MAC16_16(Inlines.MULT16_16(a1, l), a2, r), 14)); - } - } - - static void stereo_split(int[] X, int X_ptr, int[] Y, int Y_ptr, int N) { - for (int j = 0; j < N; ++j) { - int l = Inlines.MULT16_16(23170, X[X_ptr + j]); - int r = Inlines.MULT16_16(23170, Y[Y_ptr + j]); - X[X_ptr + j] = Inlines.EXTRACT16(Inlines.SHR32(Inlines.ADD32(l, r), 15)); - Y[Y_ptr + j] = Inlines.EXTRACT16(Inlines.SHR32(Inlines.SUB32(r, l), 15)); - } - } - - static void stereo_merge(int[] X, int X_ptr, int[] Y, int Y_ptr, int mid, int N) { - BoxedValueInt xp = new BoxedValueInt(0); - BoxedValueInt side = new BoxedValueInt(0); - Kernels.dual_inner_prod(Y, Y_ptr, X, X_ptr, Y, Y_ptr, N, xp, side); - xp.Val = Inlines.MULT16_32_Q15(mid, xp.Val); - int mid2 = Inlines.SHR16(mid, 1); - int El = Inlines.MULT16_16(mid2, mid2) + side.Val - 2 * xp.Val; - int Er = Inlines.MULT16_16(mid2, mid2) + side.Val + 2 * xp.Val; - if (Er < 161061 || El < 161061) { - System.arraycopy(X, X_ptr, Y, Y_ptr, N); - return; - } - int kl = Inlines.celt_ilog2(El) >> 1; - int kr = Inlines.celt_ilog2(Er) >> 1; - int t = Inlines.VSHR32(El, kl - 7 << 1); - int lgain = Inlines.celt_rsqrt_norm(t); - t = Inlines.VSHR32(Er, kr - 7 << 1); - int rgain = Inlines.celt_rsqrt_norm(t); - if (kl < 7) { - kl = 7; - } - if (kr < 7) { - kr = 7; - } - for (int j = 0; j < N; ++j) { - int l = Inlines.MULT16_16_P15(mid, X[X_ptr + j]); - int r = Y[Y_ptr + j]; - X[X_ptr + j] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MULT16_16(lgain, Inlines.SUB16(l, r)), kl + 1)); - Y[Y_ptr + j] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MULT16_16(rgain, Inlines.ADD16(l, r)), kr + 1)); - } - } - - static int spreading_decision(CeltMode m, int[][] X, BoxedValueInt average, int last_decision, BoxedValueInt hf_average, BoxedValueInt tapset_decision, int update_hf, int end, int C, int M) { - int sum = 0; - int nbBands = 0; - short[] eBands = m.eBands; - int hf_sum = 0; - Inlines.OpusAssert(end > 0); - if (M * (eBands[end] - eBands[end - 1]) <= 8) { - return 0; - } - int c = 0; - do { - for (int i = 0; i < end; ++i) { - int tmp = 0; - int[] tcount = new int[]{0, 0, 0}; - int[] x = X[c]; - int x_ptr = M * eBands[i]; - int N = M * (eBands[i + 1] - eBands[i]); - if (N <= 8) continue; - for (int j = x_ptr; j < N + x_ptr; ++j) { - int x2N = Inlines.MULT16_16(Inlines.MULT16_16_Q15(x[j], x[j]), N); - if (x2N < 2048) { - tcount[0] = tcount[0] + 1; - } - if (x2N < 512) { - tcount[1] = tcount[1] + 1; - } - if (x2N >= 128) continue; - tcount[2] = tcount[2] + 1; - } - if (i > m.nbEBands - 4) { - hf_sum += Inlines.celt_udiv(32 * (tcount[1] + tcount[0]), N); - } - tmp = (2 * tcount[2] >= N ? 1 : 0) + (2 * tcount[1] >= N ? 1 : 0) + (2 * tcount[0] >= N ? 1 : 0); - sum += tmp * 256; - ++nbBands; - } - } while (++c < C); - if (update_hf != 0) { - if (hf_sum != 0) { - hf_sum = Inlines.celt_udiv(hf_sum, C * (4 - m.nbEBands + end)); - } - hf_sum = hf_average.Val = hf_average.Val + hf_sum >> 1; - if (tapset_decision.Val == 2) { - hf_sum += 4; - } else if (tapset_decision.Val == 0) { - hf_sum -= 4; - } - tapset_decision.Val = hf_sum > 22 ? 2 : (hf_sum > 18 ? 1 : 0); - } - Inlines.OpusAssert(nbBands > 0); - Inlines.OpusAssert(sum >= 0); - sum = Inlines.celt_udiv(sum, nbBands); - average.Val = sum = sum + average.Val >> 1; - sum = 3 * sum + ((3 - last_decision << 7) + 64) + 2 >> 2; - int decision = sum < 80 ? 3 : (sum < 256 ? 2 : (sum < 384 ? 1 : 0)); - return decision; - } - - static void deinterleave_hadamard(int[] X, int X_ptr, int N0, int stride, int hadamard) { - int N = N0 * stride; - int[] tmp = new int[N]; - Inlines.OpusAssert(stride > 0); - if (hadamard != 0) { - int ordery = stride - 2; - for (int i = 0; i < stride; ++i) { - for (int j = 0; j < N0; ++j) { - tmp[CeltTables.ordery_table[ordery + i] * N0 + j] = X[j * stride + i + X_ptr]; - } - } - } else { - for (int i = 0; i < stride; ++i) { - for (int j = 0; j < N0; ++j) { - tmp[i * N0 + j] = X[j * stride + i + X_ptr]; - } - } - } - System.arraycopy(tmp, 0, X, X_ptr, N); - } - - static void interleave_hadamard(int[] X, int X_ptr, int N0, int stride, int hadamard) { - int N = N0 * stride; - int[] tmp = new int[N]; - if (hadamard != 0) { - int ordery = stride - 2; - for (int i = 0; i < stride; ++i) { - for (int j = 0; j < N0; ++j) { - tmp[j * stride + i] = X[CeltTables.ordery_table[ordery + i] * N0 + j + X_ptr]; - } - } - } else { - for (int i = 0; i < stride; ++i) { - for (int j = 0; j < N0; ++j) { - tmp[j * stride + i] = X[i * N0 + j + X_ptr]; - } - } - } - System.arraycopy(tmp, 0, X, X_ptr, N); - } - - static void haar1(int[] X, int X_ptr, int N0, int stride) { - N0 >>= 1; - for (int i = 0; i < stride; ++i) { - for (int j = 0; j < N0; ++j) { - int tmpidx = X_ptr + i + stride * 2 * j; - int tmp1 = Inlines.MULT16_16(23170, X[tmpidx]); - int tmp2 = Inlines.MULT16_16(23170, X[tmpidx + stride]); - X[tmpidx] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.ADD32(tmp1, tmp2), 15)); - X[tmpidx + stride] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.SUB32(tmp1, tmp2), 15)); - } - } - } - - static void haar1ZeroOffset(int[] X, int N0, int stride) { - N0 >>= 1; - for (int i = 0; i < stride; ++i) { - for (int j = 0; j < N0; ++j) { - int tmpidx = i + stride * 2 * j; - int tmp1 = Inlines.MULT16_16(23170, X[tmpidx]); - int tmp2 = Inlines.MULT16_16(23170, X[tmpidx + stride]); - X[tmpidx] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.ADD32(tmp1, tmp2), 15)); - X[tmpidx + stride] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.SUB32(tmp1, tmp2), 15)); - } - } - } - - static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo) { - int qn; - short[] exp2_table8 = new short[]{16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048}; - int N2 = 2 * N - 1; - if (stereo != 0 && N == 2) { - --N2; - } - int qb = Inlines.celt_sudiv(b + N2 * offset, N2); - qb = Inlines.IMIN(b - pulse_cap - 32, qb); - if ((qb = Inlines.IMIN(64, qb)) < 4) { - qn = 1; - } else { - qn = exp2_table8[qb & 7] >> 14 - (qb >> 3); - qn = qn + 1 >> 1 << 1; - } - Inlines.OpusAssert(qn <= 256); - return qn; - } - - static void compute_theta(band_ctx ctx, split_ctx sctx, int[] X, int X_ptr, int[] Y, int Y_ptr, int N, BoxedValueInt b, int B, int B0, int LM, int stereo, BoxedValueInt fill) { - int delta; - int iside; - int imid; - int itheta = 0; - int inv = 0; - int encode = ctx.encode; - CeltMode m = ctx.m; - int i = ctx.i; - int intensity = ctx.intensity; - EntropyCoder ec = ctx.ec; - int[][] bandE = ctx.bandE; - int pulse_cap = m.logN[i] + LM * 8; - int offset = (pulse_cap >> 1) - (stereo != 0 && N == 2 ? 16 : 4); - int qn = Bands.compute_qn(N, b.Val, offset, pulse_cap, stereo); - if (stereo != 0 && i >= intensity) { - qn = 1; - } - if (encode != 0) { - itheta = VQ.stereo_itheta(X, X_ptr, Y, Y_ptr, stereo, N); - } - int tell = ec.tell_frac(); - if (qn != 1) { - if (encode != 0) { - itheta = itheta * qn + 8192 >> 14; - } - if (stereo != 0 && N > 2) { - int p0 = 3; - int x = itheta; - int x0 = qn / 2; - long ft = Inlines.CapToUInt32(p0 * (x0 + 1) + x0); - if (encode != 0) { - ec.encode(x <= x0 ? p0 * x : x - 1 - x0 + (x0 + 1) * p0, x <= x0 ? p0 * (x + 1) : x - x0 + (x0 + 1) * p0, ft); - } else { - int fs = (int)ec.decode(ft); - x = fs < (x0 + 1) * p0 ? fs / p0 : x0 + 1 + (fs - (x0 + 1) * p0); - ec.dec_update(x <= x0 ? p0 * x : x - 1 - x0 + (x0 + 1) * p0, x <= x0 ? p0 * (x + 1) : x - x0 + (x0 + 1) * p0, ft); - itheta = x; - } - } else if (B0 > 1 || stereo != 0) { - if (encode != 0) { - ec.enc_uint(itheta, qn + 1); - } else { - itheta = (int)ec.dec_uint(qn + 1); - } - } else { - int fs = 1; - int ft = ((qn >> 1) + 1) * ((qn >> 1) + 1); - if (encode != 0) { - fs = itheta <= qn >> 1 ? itheta + 1 : qn + 1 - itheta; - int fl = itheta <= qn >> 1 ? itheta * (itheta + 1) >> 1 : ft - ((qn + 1 - itheta) * (qn + 2 - itheta) >> 1); - ec.encode(fl, fl + fs, ft); - } else { - int fl = 0; - int fm = (int)ec.decode(ft); - if (fm < (qn >> 1) * ((qn >> 1) + 1) >> 1) { - itheta = Inlines.isqrt32(8 * fm + 1) - 1 >> 1; - fs = itheta + 1; - fl = itheta * (itheta + 1) >> 1; - } else { - itheta = 2 * (qn + 1) - Inlines.isqrt32(8 * (ft - fm - 1) + 1) >> 1; - fs = qn + 1 - itheta; - fl = ft - ((qn + 1 - itheta) * (qn + 2 - itheta) >> 1); - } - ec.dec_update(fl, fl + fs, ft); - } - } - Inlines.OpusAssert(itheta >= 0); - itheta = Inlines.celt_udiv(itheta * 16384, qn); - if (encode != 0 && stereo != 0) { - if (itheta == 0) { - Bands.intensity_stereo(m, X, X_ptr, Y, Y_ptr, bandE, i, N); - } else { - Bands.stereo_split(X, X_ptr, Y, Y_ptr, N); - } - } - } else if (stereo != 0) { - if (encode != 0) { - int n = inv = itheta > 8192 ? 1 : 0; - if (inv != 0) { - for (int j = 0; j < N; ++j) { - Y[Y_ptr + j] = 0 - Y[Y_ptr + j]; - } - } - Bands.intensity_stereo(m, X, X_ptr, Y, Y_ptr, bandE, i, N); - } - if (b.Val > 16 && ctx.remaining_bits > 16) { - if (encode != 0) { - ec.enc_bit_logp(inv, 2); - } else { - inv = ec.dec_bit_logp(2L); - } - } else { - inv = 0; - } - itheta = 0; - } - int qalloc = ec.tell_frac() - tell; - b.Val -= qalloc; - if (itheta == 0) { - imid = Short.MAX_VALUE; - iside = 0; - fill.Val &= (1 << B) - 1; - delta = -16384; - } else if (itheta == 16384) { - imid = 0; - iside = Short.MAX_VALUE; - fill.Val &= (1 << B) - 1 << B; - delta = 16384; - } else { - imid = Bands.bitexact_cos((short)itheta); - iside = Bands.bitexact_cos((short)(16384 - itheta)); - delta = Inlines.FRAC_MUL16(N - 1 << 7, Bands.bitexact_log2tan(iside, imid)); - } - sctx.inv = inv; - sctx.imid = imid; - sctx.iside = iside; - sctx.delta = delta; - sctx.itheta = itheta; - sctx.qalloc = qalloc; - } - - static int quant_band_n1(band_ctx ctx, int[] X, int X_ptr, int[] Y, int Y_ptr, int b, int[] lowband_out, int lowband_out_ptr) { - boolean resynth = ctx.encode == 0; - int[] x = X; - int x_ptr = X_ptr; - int encode = ctx.encode; - EntropyCoder ec = ctx.ec; - int stereo = Y != null ? 1 : 0; - int c = 0; - do { - int sign = 0; - if (ctx.remaining_bits >= 8) { - if (encode != 0) { - sign = x[x_ptr] < 0 ? 1 : 0; - ec.enc_bits(sign, 1); - } else { - sign = ec.dec_bits(1); - } - ctx.remaining_bits -= 8; - b -= 8; - } - if (resynth) { - x[x_ptr] = sign != 0 ? -16384 : 16384; - } - x = Y; - x_ptr = Y_ptr; - } while (++c < 1 + stereo); - if (lowband_out != null) { - lowband_out[lowband_out_ptr] = Inlines.SHR16(X[X_ptr], 4); - } - return 1; - } - - static int quant_partition(band_ctx ctx, int[] X, int X_ptr, int N, int b, int B, int[] lowband, int lowband_ptr, int LM, int gain, int fill) { - int imid = 0; - int iside = 0; - int B0 = B; - int mid = 0; - int side = 0; - int cm = 0; - boolean resynth = ctx.encode == 0; - int Y = 0; - int encode = ctx.encode; - CeltMode m = ctx.m; - int i = ctx.i; - int spread = ctx.spread; - EntropyCoder ec = ctx.ec; - short[] cache = m.cache.bits; - short cache_ptr = m.cache.index[(LM + 1) * m.nbEBands + i]; - if (LM != -1 && b > cache[cache_ptr + cache[cache_ptr]] + 12 && N > 2) { - split_ctx sctx = new split_ctx(); - int next_lowband2 = 0; - Y = X_ptr + (N >>= 1); - --LM; - if (B == 1) { - fill = fill & 1 | fill << 1; - } - B = B + 1 >> 1; - BoxedValueInt boxed_b = new BoxedValueInt(b); - BoxedValueInt boxed_fill = new BoxedValueInt(fill); - Bands.compute_theta(ctx, sctx, X, X_ptr, X, Y, N, boxed_b, B, B0, LM, 0, boxed_fill); - b = boxed_b.Val; - fill = boxed_fill.Val; - imid = sctx.imid; - iside = sctx.iside; - int delta = sctx.delta; - int itheta = sctx.itheta; - int qalloc = sctx.qalloc; - mid = imid; - side = iside; - if (B0 > 1 && (itheta & 0x3FFF) != 0) { - delta = itheta > 8192 ? (delta -= delta >> 4 - LM) : Inlines.IMIN(0, delta + (N << 3 >> 5 - LM)); - } - int mbits = Inlines.IMAX(0, Inlines.IMIN(b, (b - delta) / 2)); - int sbits = b - mbits; - ctx.remaining_bits -= qalloc; - if (lowband != null) { - next_lowband2 = lowband_ptr + N; - } - int rebalance = ctx.remaining_bits; - if (mbits >= sbits) { - cm = Bands.quant_partition(ctx, X, X_ptr, N, mbits, B, lowband, lowband_ptr, LM, Inlines.MULT16_16_P15(gain, mid), fill); - if ((rebalance = mbits - (rebalance - ctx.remaining_bits)) > 24 && itheta != 0) { - sbits += rebalance - 24; - } - cm |= Bands.quant_partition(ctx, X, Y, N, sbits, B, lowband, next_lowband2, LM, Inlines.MULT16_16_P15(gain, side), fill >> B) << (B0 >> 1); - } else { - cm = Bands.quant_partition(ctx, X, Y, N, sbits, B, lowband, next_lowband2, LM, Inlines.MULT16_16_P15(gain, side), fill >> B) << (B0 >> 1); - if ((rebalance = sbits - (rebalance - ctx.remaining_bits)) > 24 && itheta != 16384) { - mbits += rebalance - 24; - } - cm |= Bands.quant_partition(ctx, X, X_ptr, N, mbits, B, lowband, lowband_ptr, LM, Inlines.MULT16_16_P15(gain, mid), fill); - } - } else { - int q = Rate.bits2pulses(m, i, LM, b); - int curr_bits = Rate.pulses2bits(m, i, LM, q); - ctx.remaining_bits -= curr_bits; - while (ctx.remaining_bits < 0 && q > 0) { - ctx.remaining_bits += curr_bits; - curr_bits = Rate.pulses2bits(m, i, LM, --q); - ctx.remaining_bits -= curr_bits; - } - if (q != 0) { - int K = Rate.get_pulses(q); - cm = encode != 0 ? VQ.alg_quant(X, X_ptr, N, K, spread, B, ec) : VQ.alg_unquant(X, X_ptr, N, K, spread, B, ec, gain); - } else if (resynth) { - int cm_mask = (1 << B) - 1; - if ((fill &= cm_mask) == 0) { - Arrays.MemSetWithOffset(X, 0, X_ptr, N); - } else { - if (lowband == null) { - for (int j = 0; j < N; ++j) { - ctx.seed = Bands.celt_lcg_rand(ctx.seed); - X[X_ptr + j] = ctx.seed >> 20; - } - cm = cm_mask; - } else { - for (int j = 0; j < N; ++j) { - ctx.seed = Bands.celt_lcg_rand(ctx.seed); - int tmp = 4; - tmp = (ctx.seed & 0x8000) != 0 ? tmp : 0 - tmp; - X[X_ptr + j] = lowband[lowband_ptr + j] + tmp; - } - cm = fill; - } - VQ.renormalise_vector(X, X_ptr, N, gain); - } - } - } - return cm; - } - - static int quant_band(band_ctx ctx, int[] X, int X_ptr, int N, int b, int B, int[] lowband, int lowband_ptr, int LM, int[] lowband_out, int lowband_out_ptr, int gain, int[] lowband_scratch, int lowband_scratch_ptr, int fill) { - int k; - int N0 = N; - int N_B = N; - int B0 = B; - int time_divide = 0; - int recombine = 0; - int cm = 0; - boolean resynth = ctx.encode == 0; - int encode = ctx.encode; - int tf_change = ctx.tf_change; - int longBlocks = B0 == 1 ? 1 : 0; - N_B = Inlines.celt_udiv(N_B, B); - if (N == 1) { - return Bands.quant_band_n1(ctx, X, X_ptr, null, 0, b, lowband_out, lowband_out_ptr); - } - if (tf_change > 0) { - recombine = tf_change; - } - if (lowband_scratch != null && lowband != null && (recombine != 0 || (N_B & 1) == 0 && tf_change < 0 || B0 > 1)) { - System.arraycopy(lowband, lowband_ptr, lowband_scratch, lowband_scratch_ptr, N); - lowband = lowband_scratch; - lowband_ptr = lowband_scratch_ptr; - } - for (k = 0; k < recombine; ++k) { - if (encode != 0) { - Bands.haar1(X, X_ptr, N >> k, 1 << k); - } - if (lowband != null) { - Bands.haar1(lowband, lowband_ptr, N >> k, 1 << k); - } - int idx1 = fill & 0xF; - int idx2 = fill >> 4; - if (idx1 < 0) { - System.out.println("e"); - } - if (idx2 < 0) { - System.out.println("e"); - } - fill = bit_interleave_table[fill & 0xF] | bit_interleave_table[fill >> 4] << 2; - } - B >>= recombine; - N_B <<= recombine; - while ((N_B & 1) == 0 && tf_change < 0) { - if (encode != 0) { - Bands.haar1(X, X_ptr, N_B, B); - } - if (lowband != null) { - Bands.haar1(lowband, lowband_ptr, N_B, B); - } - fill |= fill << B; - B <<= 1; - N_B >>= 1; - ++time_divide; - ++tf_change; - } - B0 = B; - int N_B0 = N_B; - if (B0 > 1) { - if (encode != 0) { - Bands.deinterleave_hadamard(X, X_ptr, N_B >> recombine, B0 << recombine, longBlocks); - } - if (lowband != null) { - Bands.deinterleave_hadamard(lowband, lowband_ptr, N_B >> recombine, B0 << recombine, longBlocks); - } - } - cm = Bands.quant_partition(ctx, X, X_ptr, N, b, B, lowband, lowband_ptr, LM, gain, fill); - if (resynth) { - if (B0 > 1) { - Bands.interleave_hadamard(X, X_ptr, N_B >> recombine, B0 << recombine, longBlocks); - } - N_B = N_B0; - B = B0; - for (k = 0; k < time_divide; ++k) { - cm |= cm >> (B >>= 1); - Bands.haar1(X, X_ptr, N_B <<= 1, B); - } - for (k = 0; k < recombine; ++k) { - cm = bit_deinterleave_table[cm]; - Bands.haar1(X, X_ptr, N0 >> k, 1 << k); - } - B <<= recombine; - if (lowband_out != null) { - int n = Inlines.celt_sqrt(Inlines.SHL32(N0, 22)); - for (int j = 0; j < N0; ++j) { - lowband_out[lowband_out_ptr + j] = Inlines.MULT16_16_Q15(n, X[X_ptr + j]); - } - } - cm &= (1 << B) - 1; - } - return cm; - } - - static int quant_band_stereo(band_ctx ctx, int[] X, int X_ptr, int[] Y, int Y_ptr, int N, int b, int B, int[] lowband, int lowband_ptr, int LM, int[] lowband_out, int lowband_out_ptr, int[] lowband_scratch, int lowband_scratch_ptr, int fill) { - int sbits; - int mbits; - int imid = 0; - int iside = 0; - int inv = 0; - int mid = 0; - int side = 0; - int cm = 0; - boolean resynth = ctx.encode == 0; - split_ctx sctx = new split_ctx(); - int encode = ctx.encode; - EntropyCoder ec = ctx.ec; - if (N == 1) { - return Bands.quant_band_n1(ctx, X, X_ptr, Y, Y_ptr, b, lowband_out, lowband_out_ptr); - } - int orig_fill = fill; - BoxedValueInt boxed_b = new BoxedValueInt(b); - BoxedValueInt boxed_fill = new BoxedValueInt(fill); - Bands.compute_theta(ctx, sctx, X, X_ptr, Y, Y_ptr, N, boxed_b, B, B, LM, 1, boxed_fill); - b = boxed_b.Val; - fill = boxed_fill.Val; - inv = sctx.inv; - imid = sctx.imid; - iside = sctx.iside; - int delta = sctx.delta; - int itheta = sctx.itheta; - int qalloc = sctx.qalloc; - mid = imid; - side = iside; - if (N == 2) { - int y2_ptr; - int[] y2; - int x2_ptr; - int[] x2; - int sign = 0; - mbits = b; - sbits = 0; - if (itheta != 0 && itheta != 16384) { - sbits = 8; - } - mbits -= sbits; - boolean c = itheta > 8192; - ctx.remaining_bits -= qalloc + sbits; - if (c) { - x2 = Y; - x2_ptr = Y_ptr; - y2 = X; - y2_ptr = X_ptr; - } else { - x2 = X; - x2_ptr = X_ptr; - y2 = Y; - y2_ptr = Y_ptr; - } - if (sbits != 0) { - if (encode != 0) { - sign = x2[x2_ptr] * y2[Y_ptr + 1] - x2[x2_ptr + 1] * y2[Y_ptr] < 0 ? 1 : 0; - ec.enc_bits(sign, 1); - } else { - sign = ec.dec_bits(1); - } - } - sign = 1 - 2 * sign; - cm = Bands.quant_band(ctx, x2, x2_ptr, N, mbits, B, lowband, lowband_ptr, LM, lowband_out, lowband_out_ptr, Short.MAX_VALUE, lowband_scratch, lowband_scratch_ptr, orig_fill); - y2[Y_ptr] = (0 - sign) * x2[x2_ptr + 1]; - y2[Y_ptr + 1] = sign * x2[x2_ptr]; - if (resynth) { - X[X_ptr] = Inlines.MULT16_16_Q15(mid, X[X_ptr]); - X[X_ptr + 1] = Inlines.MULT16_16_Q15(mid, X[X_ptr + 1]); - Y[Y_ptr] = Inlines.MULT16_16_Q15(side, Y[Y_ptr]); - Y[Y_ptr + 1] = Inlines.MULT16_16_Q15(side, Y[Y_ptr + 1]); - int tmp = X[X_ptr]; - X[X_ptr] = Inlines.SUB16(tmp, Y[Y_ptr]); - Y[Y_ptr] = Inlines.ADD16(tmp, Y[Y_ptr]); - tmp = X[X_ptr + 1]; - X[X_ptr + 1] = Inlines.SUB16(tmp, Y[Y_ptr + 1]); - Y[Y_ptr + 1] = Inlines.ADD16(tmp, Y[Y_ptr + 1]); - } - } else { - mbits = Inlines.IMAX(0, Inlines.IMIN(b, (b - delta) / 2)); - sbits = b - mbits; - ctx.remaining_bits -= qalloc; - int rebalance = ctx.remaining_bits; - if (mbits >= sbits) { - cm = Bands.quant_band(ctx, X, X_ptr, N, mbits, B, lowband, lowband_ptr, LM, lowband_out, lowband_out_ptr, Short.MAX_VALUE, lowband_scratch, lowband_scratch_ptr, fill); - if ((rebalance = mbits - (rebalance - ctx.remaining_bits)) > 24 && itheta != 0) { - sbits += rebalance - 24; - } - cm |= Bands.quant_band(ctx, Y, Y_ptr, N, sbits, B, null, 0, LM, null, 0, side, null, 0, fill >> B); - } else { - cm = Bands.quant_band(ctx, Y, Y_ptr, N, sbits, B, null, 0, LM, null, 0, side, null, 0, fill >> B); - if ((rebalance = sbits - (rebalance - ctx.remaining_bits)) > 24 && itheta != 16384) { - mbits += rebalance - 24; - } - cm |= Bands.quant_band(ctx, X, X_ptr, N, mbits, B, lowband, lowband_ptr, LM, lowband_out, lowband_out_ptr, Short.MAX_VALUE, lowband_scratch, lowband_scratch_ptr, fill); - } - } - if (resynth) { - if (N != 2) { - Bands.stereo_merge(X, X_ptr, Y, Y_ptr, mid, N); - } - if (inv != 0) { - for (int j = Y_ptr; j < N + Y_ptr; ++j) { - Y[j] = (short)(0 - Y[j]); - } - } - } - return cm; - } - - static void quant_all_bands(int encode, CeltMode m, int start, int end, int[] X_, int[] Y_, short[] collapse_masks, int[][] bandE, int[] pulses, int shortBlocks, int spread, int dual_stereo, int intensity, int[] tf_res, int total_bits, int balance, EntropyCoder ec, int LM, int codedBands, BoxedValueInt seed) { - short[] eBands = m.eBands; - boolean update_lowband = true; - int C = Y_ != null ? 2 : 1; - boolean resynth = encode == 0; - band_ctx ctx = new band_ctx(); - int M = 1 << LM; - int B = shortBlocks != 0 ? M : 1; - int norm_offset = M * eBands[start]; - int[] norm = new int[C * (M * eBands[m.nbEBands - 1] - norm_offset)]; - int norm2 = M * eBands[m.nbEBands - 1] - norm_offset; - int[] lowband_scratch = X_; - int lowband_scratch_ptr = M * eBands[m.nbEBands - 1]; - int lowband_offset = 0; - ctx.bandE = bandE; - ctx.ec = ec; - ctx.encode = encode; - ctx.intensity = intensity; - ctx.m = m; - ctx.seed = seed.Val; - ctx.spread = spread; - for (int i = start; i < end; ++i) { - long x_cm; - long y_cm; - int b; - int remaining_bits; - int[] Y; - int effective_lowband = -1; - int Y_ptr = 0; - int tf_change = 0; - ctx.i = i; - boolean last = i == end - 1; - int[] X = X_; - int X_ptr = M * eBands[i]; - if (Y_ != null) { - Y = Y_; - Y_ptr = M * eBands[i]; - } else { - Y = null; - } - int N = M * eBands[i + 1] - M * eBands[i]; - int tell = ec.tell_frac(); - if (i != start) { - balance -= tell; - } - ctx.remaining_bits = remaining_bits = total_bits - tell - 1; - if (i <= codedBands - 1) { - int curr_balance = Inlines.celt_sudiv(balance, Inlines.IMIN(3, codedBands - i)); - b = Inlines.IMAX(0, Inlines.IMIN(16383, Inlines.IMIN(remaining_bits + 1, pulses[i] + curr_balance))); - } else { - b = 0; - } - if (resynth && M * eBands[i] - N >= M * eBands[start] && (update_lowband || lowband_offset == 0)) { - lowband_offset = i; - } - ctx.tf_change = tf_change = tf_res[i]; - if (i >= m.effEBands) { - X = norm; - X_ptr = 0; - if (Y_ != null) { - Y = norm; - Y_ptr = 0; - } - lowband_scratch = null; - } - if (i == end - 1) { - lowband_scratch = null; - } - if (lowband_offset != 0 && (spread != 3 || B > 1 || tf_change < 0)) { - effective_lowband = Inlines.IMAX(0, M * eBands[lowband_offset] - norm_offset - N); - int fold_start = lowband_offset; - while (M * eBands[--fold_start] > effective_lowband + norm_offset) { - } - int fold_end = lowband_offset - 1; - while (M * eBands[++fold_end] < effective_lowband + norm_offset + N) { - } - y_cm = 0L; - x_cm = 0L; - int fold_i = fold_start; - do { - x_cm |= (long)collapse_masks[fold_i * C + 0]; - y_cm |= (long)collapse_masks[fold_i * C + C - 1]; - } while (++fold_i < fold_end); - } else { - x_cm = y_cm = (long)((1 << B) - 1); - } - if (dual_stereo != 0 && i == intensity) { - dual_stereo = 0; - if (resynth) { - for (int j = 0; j < M * eBands[i] - norm_offset; ++j) { - norm[j] = Inlines.HALF32(norm[j] + norm[norm2 + j]); - } - } - } - if (dual_stereo != 0) { - x_cm = Bands.quant_band(ctx, X, X_ptr, N, b / 2, B, (int[])(effective_lowband != -1 ? norm : null), effective_lowband, LM, last ? null : norm, M * eBands[i] - norm_offset, Short.MAX_VALUE, lowband_scratch, lowband_scratch_ptr, (int)x_cm); - y_cm = Bands.quant_band(ctx, Y, Y_ptr, N, b / 2, B, (int[])(effective_lowband != -1 ? norm : null), norm2 + effective_lowband, LM, last ? null : norm, norm2 + (M * eBands[i] - norm_offset), Short.MAX_VALUE, lowband_scratch, lowband_scratch_ptr, (int)y_cm); - } else { - x_cm = Y != null ? (long)Bands.quant_band_stereo(ctx, X, X_ptr, Y, Y_ptr, N, b, B, (int[])(effective_lowband != -1 ? norm : null), effective_lowband, LM, last ? null : norm, M * eBands[i] - norm_offset, lowband_scratch, lowband_scratch_ptr, (int)(x_cm | y_cm)) : (long)Bands.quant_band(ctx, X, X_ptr, N, b, B, (int[])(effective_lowband != -1 ? norm : null), effective_lowband, LM, last ? null : norm, M * eBands[i] - norm_offset, Short.MAX_VALUE, lowband_scratch, lowband_scratch_ptr, (int)(x_cm | y_cm)); - y_cm = x_cm; - } - collapse_masks[i * C + 0] = (short)(x_cm & 0xFFL); - collapse_masks[i * C + C - 1] = (short)(y_cm & 0xFFL); - balance += pulses[i] + tell; - update_lowband = b > N << 3; - } - seed.Val = ctx.seed; - } - - public static class band_ctx { - public int encode; - public CeltMode m; - public int i; - public int intensity; - public int spread; - public int tf_change; - public EntropyCoder ec; - public int remaining_bits; - public int[][] bandE; - public int seed; - } - - public static class split_ctx { - public int inv; - public int imid; - public int iside; - public int delta; - public int itheta; - public int qalloc; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueByte.java b/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueByte.java deleted file mode 100644 index a799b4e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueByte.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class BoxedValueByte { - public byte Val; - - public BoxedValueByte(byte v) { - this.Val = v; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueInt.java b/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueInt.java deleted file mode 100644 index 64ae46c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueInt.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class BoxedValueInt { - public int Val; - - public BoxedValueInt(int v) { - this.Val = v; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueShort.java b/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueShort.java deleted file mode 100644 index 1881674..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/BoxedValueShort.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class BoxedValueShort { - public short Val; - - public BoxedValueShort(short v) { - this.Val = v; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/BurgModified.java b/source/decompiled/de/maxhenkel/voicechat/concentus/BurgModified.java deleted file mode 100644 index 59ee3ab..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/BurgModified.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltPitchXCorr; -import de.maxhenkel.voicechat.concentus.Inlines; - -class BurgModified { - private static final int MAX_FRAME_SIZE = 384; - private static final int QA = 25; - private static final int N_BITS_HEAD_ROOM = 2; - private static final int MIN_RSHIFTS = -16; - private static final int MAX_RSHIFTS = 7; - - BurgModified() { - } - - static void silk_burg_modified(BoxedValueInt res_nrg, BoxedValueInt res_nrg_Q, int[] A_Q16, short[] x, int x_ptr, int minInvGain_Q30, int subfr_length, int nb_subfr, int D) { - int nrg; - int Atmp1; - int k; - int tmp1; - int n; - int x_offset; - int s; - int[] C_first_row = new int[16]; - int[] C_last_row = new int[16]; - int[] Af_QA = new int[16]; - int[] CAf = new int[17]; - int[] CAb = new int[17]; - int[] xcorr = new int[16]; - Inlines.OpusAssert(subfr_length * nb_subfr <= 384); - long C0_64 = Inlines.silk_inner_prod16_aligned_64(x, x_ptr, x, x_ptr, subfr_length * nb_subfr); - int lz = Inlines.silk_CLZ64(C0_64); - int rshifts = 35 - lz; - if (rshifts > 7) { - rshifts = 7; - } - if (rshifts < -16) { - rshifts = -16; - } - int C0 = rshifts > 0 ? (int)Inlines.silk_RSHIFT64(C0_64, rshifts) : Inlines.silk_LSHIFT32((int)C0_64, -rshifts); - CAb[0] = CAf[0] = C0 + Inlines.silk_SMMUL(42950, C0) + 1; - Arrays.MemSet(C_first_row, 0, 16); - if (rshifts > 0) { - for (s = 0; s < nb_subfr; ++s) { - x_offset = x_ptr + s * subfr_length; - for (n = 1; n < D + 1; ++n) { - int n2 = n - 1; - C_first_row[n2] = C_first_row[n2] + (int)Inlines.silk_RSHIFT64(Inlines.silk_inner_prod16_aligned_64(x, x_offset, x, x_offset + n, subfr_length - n), rshifts); - } - } - } else { - for (s = 0; s < nb_subfr; ++s) { - x_offset = x_ptr + s * subfr_length; - CeltPitchXCorr.pitch_xcorr(x, x_offset, x, x_offset + 1, xcorr, subfr_length - D, D); - for (n = 1; n < D + 1; ++n) { - int d = 0; - for (int i = n + subfr_length - D; i < subfr_length; ++i) { - d = Inlines.MAC16_16(d, x[x_offset + i], x[x_offset + i - n]); - } - int n3 = n - 1; - xcorr[n3] = xcorr[n3] + d; - } - for (n = 1; n < D + 1; ++n) { - int n4 = n - 1; - C_first_row[n4] = C_first_row[n4] + Inlines.silk_LSHIFT32(xcorr[n - 1], -rshifts); - } - } - } - System.arraycopy(C_first_row, 0, C_last_row, 0, 16); - CAb[0] = CAf[0] = C0 + Inlines.silk_SMMUL(42950, C0) + 1; - int invGain_Q30 = 0x40000000; - boolean reached_max_gain = false; - for (n = 0; n < D; ++n) { - int Atmp_QA; - int tmp2; - int x2; - int x1; - if (rshifts > -2) { - for (s = 0; s < nb_subfr; ++s) { - x_offset = x_ptr + s * subfr_length; - x1 = -Inlines.silk_LSHIFT32(x[x_offset + n], 16 - rshifts); - x2 = -Inlines.silk_LSHIFT32(x[x_offset + subfr_length - n - 1], 16 - rshifts); - tmp1 = Inlines.silk_LSHIFT32(x[x_offset + n], 9); - tmp2 = Inlines.silk_LSHIFT32(x[x_offset + subfr_length - n - 1], 9); - for (k = 0; k < n; ++k) { - C_first_row[k] = Inlines.silk_SMLAWB(C_first_row[k], x1, x[x_offset + n - k - 1]); - C_last_row[k] = Inlines.silk_SMLAWB(C_last_row[k], x2, x[x_offset + subfr_length - n + k]); - Atmp_QA = Af_QA[k]; - tmp1 = Inlines.silk_SMLAWB(tmp1, Atmp_QA, x[x_offset + n - k - 1]); - tmp2 = Inlines.silk_SMLAWB(tmp2, Atmp_QA, x[x_offset + subfr_length - n + k]); - } - tmp1 = Inlines.silk_LSHIFT32(-tmp1, 7 - rshifts); - tmp2 = Inlines.silk_LSHIFT32(-tmp2, 7 - rshifts); - for (k = 0; k <= n; ++k) { - CAf[k] = Inlines.silk_SMLAWB(CAf[k], tmp1, x[x_offset + n - k]); - CAb[k] = Inlines.silk_SMLAWB(CAb[k], tmp2, x[x_offset + subfr_length - n + k - 1]); - } - } - } else { - for (s = 0; s < nb_subfr; ++s) { - x_offset = x_ptr + s * subfr_length; - x1 = -Inlines.silk_LSHIFT32(x[x_offset + n], -rshifts); - x2 = -Inlines.silk_LSHIFT32(x[x_offset + subfr_length - n - 1], -rshifts); - tmp1 = Inlines.silk_LSHIFT32(x[x_offset + n], 17); - tmp2 = Inlines.silk_LSHIFT32(x[x_offset + subfr_length - n - 1], 17); - for (k = 0; k < n; ++k) { - C_first_row[k] = Inlines.silk_MLA(C_first_row[k], x1, x[x_offset + n - k - 1]); - C_last_row[k] = Inlines.silk_MLA(C_last_row[k], x2, x[x_offset + subfr_length - n + k]); - Atmp1 = Inlines.silk_RSHIFT_ROUND(Af_QA[k], 8); - tmp1 = Inlines.silk_MLA(tmp1, x[x_offset + n - k - 1], Atmp1); - tmp2 = Inlines.silk_MLA(tmp2, x[x_offset + subfr_length - n + k], Atmp1); - } - tmp1 = -tmp1; - tmp2 = -tmp2; - for (k = 0; k <= n; ++k) { - CAf[k] = Inlines.silk_SMLAWW(CAf[k], tmp1, Inlines.silk_LSHIFT32(x[x_offset + n - k], -rshifts - 1)); - CAb[k] = Inlines.silk_SMLAWW(CAb[k], tmp2, Inlines.silk_LSHIFT32(x[x_offset + subfr_length - n + k - 1], -rshifts - 1)); - } - } - } - tmp1 = C_first_row[n]; - tmp2 = C_last_row[n]; - int num = 0; - nrg = Inlines.silk_ADD32(CAb[0], CAf[0]); - for (k = 0; k < n; ++k) { - Atmp_QA = Af_QA[k]; - lz = Inlines.silk_CLZ32(Inlines.silk_abs(Atmp_QA)) - 1; - lz = Inlines.silk_min(7, lz); - Atmp1 = Inlines.silk_LSHIFT32(Atmp_QA, lz); - tmp1 = Inlines.silk_ADD_LSHIFT32(tmp1, Inlines.silk_SMMUL(C_last_row[n - k - 1], Atmp1), 7 - lz); - tmp2 = Inlines.silk_ADD_LSHIFT32(tmp2, Inlines.silk_SMMUL(C_first_row[n - k - 1], Atmp1), 7 - lz); - num = Inlines.silk_ADD_LSHIFT32(num, Inlines.silk_SMMUL(CAb[n - k], Atmp1), 7 - lz); - nrg = Inlines.silk_ADD_LSHIFT32(nrg, Inlines.silk_SMMUL(Inlines.silk_ADD32(CAb[k + 1], CAf[k + 1]), Atmp1), 7 - lz); - } - CAf[n + 1] = tmp1; - CAb[n + 1] = tmp2; - num = Inlines.silk_ADD32(num, tmp2); - int rc_Q31 = Inlines.silk_abs(num = Inlines.silk_LSHIFT32(-num, 1)) < nrg ? Inlines.silk_DIV32_varQ(num, nrg, 31) : (num > 0 ? Integer.MAX_VALUE : Integer.MIN_VALUE); - tmp1 = 0x40000000 - Inlines.silk_SMMUL(rc_Q31, rc_Q31); - if ((tmp1 = Inlines.silk_LSHIFT(Inlines.silk_SMMUL(invGain_Q30, tmp1), 2)) <= minInvGain_Q30) { - tmp2 = 0x40000000 - Inlines.silk_DIV32_varQ(minInvGain_Q30, invGain_Q30, 30); - rc_Q31 = Inlines.silk_SQRT_APPROX(tmp2); - rc_Q31 = Inlines.silk_RSHIFT32(rc_Q31 + Inlines.silk_DIV32(tmp2, rc_Q31), 1); - rc_Q31 = Inlines.silk_LSHIFT32(rc_Q31, 16); - if (num < 0) { - rc_Q31 = -rc_Q31; - } - invGain_Q30 = minInvGain_Q30; - reached_max_gain = true; - } else { - invGain_Q30 = tmp1; - } - for (k = 0; k < n + 1 >> 1; ++k) { - tmp1 = Af_QA[k]; - tmp2 = Af_QA[n - k - 1]; - Af_QA[k] = Inlines.silk_ADD_LSHIFT32(tmp1, Inlines.silk_SMMUL(tmp2, rc_Q31), 1); - Af_QA[n - k - 1] = Inlines.silk_ADD_LSHIFT32(tmp2, Inlines.silk_SMMUL(tmp1, rc_Q31), 1); - } - Af_QA[n] = Inlines.silk_RSHIFT32(rc_Q31, 6); - if (reached_max_gain) { - for (k = n + 1; k < D; ++k) { - Af_QA[k] = 0; - } - break; - } - for (k = 0; k <= n + 1; ++k) { - tmp1 = CAf[k]; - tmp2 = CAb[n - k + 1]; - CAf[k] = Inlines.silk_ADD_LSHIFT32(tmp1, Inlines.silk_SMMUL(tmp2, rc_Q31), 1); - CAb[n - k + 1] = Inlines.silk_ADD_LSHIFT32(tmp2, Inlines.silk_SMMUL(tmp1, rc_Q31), 1); - } - } - if (reached_max_gain) { - for (k = 0; k < D; ++k) { - A_Q16[k] = -Inlines.silk_RSHIFT_ROUND(Af_QA[k], 9); - } - if (rshifts > 0) { - for (s = 0; s < nb_subfr; ++s) { - x_offset = x_ptr + s * subfr_length; - C0 -= (int)Inlines.silk_RSHIFT64(Inlines.silk_inner_prod16_aligned_64(x, x_offset, x, x_offset, D), rshifts); - } - } else { - for (s = 0; s < nb_subfr; ++s) { - x_offset = x_ptr + s * subfr_length; - C0 -= Inlines.silk_LSHIFT32(Inlines.silk_inner_prod_self(x, x_offset, D), -rshifts); - } - } - res_nrg.Val = Inlines.silk_LSHIFT(Inlines.silk_SMMUL(invGain_Q30, C0), 2); - res_nrg_Q.Val = 0 - rshifts; - } else { - nrg = CAf[0]; - tmp1 = 65536; - for (k = 0; k < D; ++k) { - Atmp1 = Inlines.silk_RSHIFT_ROUND(Af_QA[k], 9); - nrg = Inlines.silk_SMLAWW(nrg, CAf[k + 1], Atmp1); - tmp1 = Inlines.silk_SMLAWW(tmp1, Atmp1, Atmp1); - A_Q16[k] = -Atmp1; - } - res_nrg.Val = Inlines.silk_SMLAWW(nrg, Inlines.silk_SMMUL(42950, C0), -tmp1); - res_nrg_Q.Val = -rshifts; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CNG.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CNG.java deleted file mode 100644 index 80155ba..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CNG.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CNGState; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSF; -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.SilkDecoderControl; - -class CNG { - CNG() { - } - - static void silk_CNG_exc(int[] exc_Q10, int exc_Q10_ptr, int[] exc_buf_Q14, int Gain_Q16, int length, BoxedValueInt rand_seed) { - int exc_mask = 255; - while (exc_mask > length) { - exc_mask = Inlines.silk_RSHIFT(exc_mask, 1); - } - int seed = rand_seed.Val; - for (int i = exc_Q10_ptr; i < exc_Q10_ptr + length; ++i) { - int idx = Inlines.silk_RSHIFT(seed = Inlines.silk_RAND(seed), 24) & exc_mask; - Inlines.OpusAssert(idx >= 0); - Inlines.OpusAssert(idx <= 255); - exc_Q10[i] = (short)Inlines.silk_SAT16(Inlines.silk_SMULWW(exc_buf_Q14[idx], Gain_Q16 >> 4)); - } - rand_seed.Val = seed; - } - - static void silk_CNG_Reset(SilkChannelDecoder psDec) { - int NLSF_step_Q15 = Inlines.silk_DIV32_16(Short.MAX_VALUE, (short)(psDec.LPC_order + 1)); - int NLSF_acc_Q15 = 0; - for (int i = 0; i < psDec.LPC_order; ++i) { - psDec.sCNG.CNG_smth_NLSF_Q15[i] = (short)(NLSF_acc_Q15 += NLSF_step_Q15); - } - psDec.sCNG.CNG_smth_Gain_Q16 = 0; - psDec.sCNG.rand_seed = 3176576; - } - - static void silk_CNG(SilkChannelDecoder psDec, SilkDecoderControl psDecCtrl, short[] frame, int frame_ptr, int length) { - int i; - short[] A_Q12 = new short[psDec.LPC_order]; - CNGState psCNG = psDec.sCNG; - if (psDec.fs_kHz != psCNG.fs_kHz) { - CNG.silk_CNG_Reset(psDec); - psCNG.fs_kHz = psDec.fs_kHz; - } - if (psDec.lossCnt == 0 && psDec.prevSignalType == 0) { - for (i = 0; i < psDec.LPC_order; ++i) { - int n = i; - psCNG.CNG_smth_NLSF_Q15[n] = (short)(psCNG.CNG_smth_NLSF_Q15[n] + (short)Inlines.silk_SMULWB(psDec.prevNLSF_Q15[i] - psCNG.CNG_smth_NLSF_Q15[i], 16348)); - } - int max_Gain_Q16 = 0; - int subfr = 0; - for (i = 0; i < psDec.nb_subfr; ++i) { - if (psDecCtrl.Gains_Q16[i] <= max_Gain_Q16) continue; - max_Gain_Q16 = psDecCtrl.Gains_Q16[i]; - subfr = i; - } - Arrays.MemMove(psCNG.CNG_exc_buf_Q14, 0, psDec.subfr_length, (psDec.nb_subfr - 1) * psDec.subfr_length); - for (i = 0; i < psDec.nb_subfr; ++i) { - psCNG.CNG_smth_Gain_Q16 += Inlines.silk_SMULWB(psDecCtrl.Gains_Q16[i] - psCNG.CNG_smth_Gain_Q16, 4634); - } - } - if (psDec.lossCnt != 0) { - int[] CNG_sig_Q10 = new int[length + 16]; - int gain_Q16 = Inlines.silk_SMULWW(psDec.sPLC.randScale_Q14, psDec.sPLC.prevGain_Q16[1]); - if (gain_Q16 >= 0x200000 || psCNG.CNG_smth_Gain_Q16 > 0x800000) { - gain_Q16 = Inlines.silk_SMULTT(gain_Q16, gain_Q16); - gain_Q16 = Inlines.silk_SUB_LSHIFT32(Inlines.silk_SMULTT(psCNG.CNG_smth_Gain_Q16, psCNG.CNG_smth_Gain_Q16), gain_Q16, 5); - gain_Q16 = Inlines.silk_LSHIFT32(Inlines.silk_SQRT_APPROX(gain_Q16), 16); - } else { - gain_Q16 = Inlines.silk_SMULWW(gain_Q16, gain_Q16); - gain_Q16 = Inlines.silk_SUB_LSHIFT32(Inlines.silk_SMULWW(psCNG.CNG_smth_Gain_Q16, psCNG.CNG_smth_Gain_Q16), gain_Q16, 5); - gain_Q16 = Inlines.silk_LSHIFT32(Inlines.silk_SQRT_APPROX(gain_Q16), 8); - } - BoxedValueInt boxed_rand_seed = new BoxedValueInt(psCNG.rand_seed); - CNG.silk_CNG_exc(CNG_sig_Q10, 16, psCNG.CNG_exc_buf_Q14, gain_Q16, length, boxed_rand_seed); - psCNG.rand_seed = boxed_rand_seed.Val; - NLSF.silk_NLSF2A(A_Q12, psCNG.CNG_smth_NLSF_Q15, psDec.LPC_order); - System.arraycopy(psCNG.CNG_synth_state, 0, CNG_sig_Q10, 0, 16); - for (i = 0; i < length; ++i) { - int lpci = 16 + i; - Inlines.OpusAssert(psDec.LPC_order == 10 || psDec.LPC_order == 16); - int sum_Q6 = Inlines.silk_RSHIFT(psDec.LPC_order, 1); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 1], A_Q12[0]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 2], A_Q12[1]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 3], A_Q12[2]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 4], A_Q12[3]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 5], A_Q12[4]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 6], A_Q12[5]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 7], A_Q12[6]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 8], A_Q12[7]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 9], A_Q12[8]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 10], A_Q12[9]); - if (psDec.LPC_order == 16) { - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 11], A_Q12[10]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 12], A_Q12[11]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 13], A_Q12[12]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 14], A_Q12[13]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 15], A_Q12[14]); - sum_Q6 = Inlines.silk_SMLAWB(sum_Q6, CNG_sig_Q10[lpci - 16], A_Q12[15]); - } - CNG_sig_Q10[lpci] = Inlines.silk_ADD_LSHIFT(CNG_sig_Q10[lpci], sum_Q6, 4); - frame[frame_ptr + i] = Inlines.silk_ADD_SAT16(frame[frame_ptr + i], (short)Inlines.silk_RSHIFT_ROUND(CNG_sig_Q10[lpci], 10)); - } - System.arraycopy(CNG_sig_Q10, length, psCNG.CNG_synth_state, 0, 16); - } else { - Arrays.MemSet(psCNG.CNG_synth_state, 0, psDec.LPC_order); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CNGState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CNGState.java deleted file mode 100644 index 4013159..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CNGState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class CNGState { - final int[] CNG_exc_buf_Q14 = new int[320]; - final short[] CNG_smth_NLSF_Q15 = new short[16]; - final int[] CNG_synth_state = new int[16]; - int CNG_smth_Gain_Q16 = 0; - int rand_seed = 0; - int fs_kHz = 0; - - CNGState() { - } - - void Reset() { - Arrays.MemSet(this.CNG_exc_buf_Q14, 0, 320); - Arrays.MemSet(this.CNG_smth_NLSF_Q15, (short)0, 16); - Arrays.MemSet(this.CNG_synth_state, 0, 16); - this.CNG_smth_Gain_Q16 = 0; - this.rand_seed = 0; - this.fs_kHz = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CWRS.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CWRS.java deleted file mode 100644 index be2bc76..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CWRS.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; - -class CWRS { - static final int[] CELT_PVQ_U_ROW = new int[]{0, 176, 351, 525, 698, 870, 1041, 1131, 1178, 1207, 1226, 1240, 1248, 1254, 1257}; - - CWRS() { - } - - private static long CELT_PVQ_U(int _n, int _k) { - return CeltTables.CELT_PVQ_U_DATA[CELT_PVQ_U_ROW[Inlines.IMIN(_n, _k)] + Inlines.IMAX(_n, _k)]; - } - - private static long CELT_PVQ_V(int _n, int _k) { - return CWRS.CELT_PVQ_U(_n, _k) + CWRS.CELT_PVQ_U(_n, _k + 1); - } - - static long icwrs(int _n, int[] _y) { - Inlines.OpusAssert(_n >= 2); - int j = _n - 1; - long i = _y[j] < 0 ? 1L : 0L; - int k = Inlines.abs(_y[j]); - do { - i += CWRS.CELT_PVQ_U(_n - --j, k); - k += Inlines.abs(_y[j]); - if (_y[j] >= 0) continue; - i += CWRS.CELT_PVQ_U(_n - j, k + 1); - } while (j > 0); - return i; - } - - static void encode_pulses(int[] _y, int _n, int _k, EntropyCoder _enc) { - Inlines.OpusAssert(_k > 0); - _enc.enc_uint(CWRS.icwrs(_n, _y), CWRS.CELT_PVQ_V(_n, _k)); - } - - static int cwrsi(int _n, int _k, long _i, int[] _y) { - short val; - int k0; - int s; - long p; - int yy = 0; - int y_ptr = 0; - Inlines.OpusAssert(_k > 0); - Inlines.OpusAssert(_n > 1); - while (_n > 2) { - long q; - if (_k >= _n) { - int row = CELT_PVQ_U_ROW[_n]; - p = CeltTables.CELT_PVQ_U_DATA[row + _k + 1]; - s = 0 - (_i >= p ? 1 : 0); - k0 = _k; - q = CeltTables.CELT_PVQ_U_DATA[row + _n]; - if (q > (_i -= Inlines.CapToUInt32(p & (long)s))) { - Inlines.OpusAssert(p > q); - _k = _n; - while ((p = CeltTables.CELT_PVQ_U_DATA[CELT_PVQ_U_ROW[--_k] + _n]) > _i) { - } - } else { - p = CeltTables.CELT_PVQ_U_DATA[row + _k]; - while (p > _i) { - p = CeltTables.CELT_PVQ_U_DATA[row + --_k]; - } - } - _i -= p; - val = (short)(k0 - _k + s ^ s); - _y[y_ptr++] = val; - yy = Inlines.MAC16_16(yy, val, val); - } else { - p = CeltTables.CELT_PVQ_U_DATA[CELT_PVQ_U_ROW[_k] + _n]; - q = CeltTables.CELT_PVQ_U_DATA[CELT_PVQ_U_ROW[_k + 1] + _n]; - if (p <= _i && _i < q) { - _i -= p; - _y[y_ptr++] = 0; - } else { - s = 0 - (_i >= q ? 1 : 0); - _i -= Inlines.CapToUInt32(q & (long)s); - k0 = _k; - while ((p = CeltTables.CELT_PVQ_U_DATA[CELT_PVQ_U_ROW[--_k] + _n]) > _i) { - } - _i -= p; - val = (short)(k0 - _k + s ^ s); - _y[y_ptr++] = val; - yy = Inlines.MAC16_16(yy, val, val); - } - } - --_n; - } - p = 2L * (long)_k + 1L; - s = 0 - (_i >= p ? 1 : 0); - k0 = _k; - _k = (int)((_i -= Inlines.CapToUInt32(p & (long)s)) + 1L >> 1); - if (_k != 0) { - _i -= 2L * (long)_k - 1L; - } - val = (short)(k0 - _k + s ^ s); - _y[y_ptr++] = val; - yy = Inlines.MAC16_16(yy, val, val); - s = -((int)_i); - val = (short)(_k + s ^ s); - _y[y_ptr] = val; - yy = Inlines.MAC16_16(yy, val, val); - return yy; - } - - static int decode_pulses(int[] _y, int _n, int _k, EntropyCoder _dec) { - return CWRS.cwrsi(_n, _k, _dec.dec_uint(CWRS.CELT_PVQ_V(_n, _k)), _y); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltCommon.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltCommon.java deleted file mode 100644 index b4f80d3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltCommon.java +++ /dev/null @@ -1,843 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.AnalysisInfo; -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Bands; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; -import de.maxhenkel.voicechat.concentus.MDCT; -import de.maxhenkel.voicechat.concentus.OpusFramesize; -import de.maxhenkel.voicechat.concentus.Pitch; - -class CeltCommon { - private static final short[] inv_table = new short[]{255, 255, 156, 110, 86, 70, 59, 51, 45, 40, 37, 33, 31, 28, 26, 25, 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2}; - private static final short[][] gains = new short[][]{{10048, 7112, 4248}, {15200, 8784, 0}, {26208, 3280, 0}}; - private static final byte[][] tf_select_table = new byte[][]{{0, -1, 0, -1, 0, -1, 0, -1}, {0, -1, 0, -2, 1, 0, 1, -1}, {0, -2, 0, -3, 2, 0, 1, -1}, {0, -2, 0, -3, 3, 0, 1, -1}}; - - CeltCommon() { - } - - static int compute_vbr(CeltMode mode, AnalysisInfo analysis, int base_target, int LM, int bitrate, int lastCodedBands, int C, int intensity, int constrained_vbr, int stereo_saving, int tot_boost, int tf_estimate, int pitch_change, int maxDepth, OpusFramesize variable_duration, int lfe, int has_surround_mask, int surround_masking, int temporal_vbr) { - int nbEBands = mode.nbEBands; - short[] eBands = mode.eBands; - int coded_bands = lastCodedBands != 0 ? lastCodedBands : nbEBands; - int coded_bins = eBands[coded_bands] << LM; - if (C == 2) { - coded_bins += eBands[Inlines.IMIN(intensity, coded_bands)] << LM; - } - int target = base_target; - if (analysis.enabled && analysis.valid != 0 && (double)analysis.activity < 0.4) { - target -= (int)((float)(coded_bins << 3) * (0.4f - analysis.activity)); - } - if (C == 2) { - int coded_stereo_bands = Inlines.IMIN(intensity, coded_bands); - int coded_stereo_dof = (eBands[coded_stereo_bands] << LM) - coded_stereo_bands; - int max_frac = Inlines.DIV32_16(Inlines.MULT16_16(26214, coded_stereo_dof), coded_bins); - stereo_saving = Inlines.MIN16(stereo_saving, 256); - target -= Inlines.MIN32(Inlines.MULT16_32_Q15(max_frac, target), Inlines.SHR32(Inlines.MULT16_16(stereo_saving - 26, coded_stereo_dof << 3), 8)); - } - target += tot_boost - (16 << LM); - int tf_calibration = variable_duration == OpusFramesize.OPUS_FRAMESIZE_VARIABLE ? 328 : 655; - target += Inlines.SHL32(Inlines.MULT16_32_Q15(tf_estimate - tf_calibration, target), 1); - if (analysis.enabled && analysis.valid != 0 && lfe == 0) { - float tonal = Inlines.MAX16(0.0f, analysis.tonality - 0.15f) - 0.09f; - int tonal_target = target + (int)((float)(coded_bins << 3) * 1.2f * tonal); - if (pitch_change != 0) { - tonal_target += (int)((float)(coded_bins << 3) * 0.8f); - } - target = tonal_target; - } - if (has_surround_mask != 0 && lfe == 0) { - int surround_target = target + Inlines.SHR32(Inlines.MULT16_16(surround_masking, coded_bins << 3), 10); - target = Inlines.IMAX(target / 4, surround_target); - } - int bins = eBands[nbEBands - 2] << LM; - int floor_depth = Inlines.SHR32(Inlines.MULT16_16(C * bins << 3, maxDepth), 10); - floor_depth = Inlines.IMAX(floor_depth, target >> 2); - target = Inlines.IMIN(target, floor_depth); - if (!(has_surround_mask != 0 && lfe == 0 || constrained_vbr == 0 && bitrate >= 64000)) { - int rate_factor = Inlines.MAX16(0, bitrate - 32000); - if (constrained_vbr != 0) { - rate_factor = Inlines.MIN16(rate_factor, 21955); - } - target = base_target + Inlines.MULT16_32_Q15(rate_factor, target - base_target); - } - if (has_surround_mask == 0 && tf_estimate < 3277) { - int amount = Inlines.MULT16_16_Q15(3329, Inlines.IMAX(0, Inlines.IMIN(32000, 96000 - bitrate))); - int tvbr_factor = Inlines.SHR32(Inlines.MULT16_16(temporal_vbr, amount), 10); - target += Inlines.MULT16_32_Q15(tvbr_factor, target); - } - target = Inlines.IMIN(2 * base_target, target); - return target; - } - - static int transient_analysis(int[][] input, int len, int C, BoxedValueInt tf_estimate, BoxedValueInt tf_chan) { - int is_transient = 0; - int mask_metric = 0; - tf_chan.Val = 0; - int[] tmp = new int[len]; - int len2 = len / 2; - for (int c = 0; c < C; ++c) { - int i; - int unmask = 0; - int mem0 = 0; - int mem1 = 0; - for (i = 0; i < len; ++i) { - int x = Inlines.SHR32(input[c][i], 12); - int y = Inlines.ADD32(mem0, x); - mem0 = mem1 + y - Inlines.SHL32(x, 1); - mem1 = x - Inlines.SHR32(y, 1); - tmp[i] = Inlines.EXTRACT16(Inlines.SHR32(y, 2)); - } - Arrays.MemSet(tmp, 0, 12); - int shift = 0; - shift = 14 - Inlines.celt_ilog2(1 + Inlines.celt_maxabs32(tmp, 0, len)); - if (shift != 0) { - for (i = 0; i < len; ++i) { - tmp[i] = Inlines.SHL16(tmp[i], shift); - } - } - int mean = 0; - mem0 = 0; - for (i = 0; i < len2; ++i) { - int x2 = Inlines.PSHR32(Inlines.MULT16_16(tmp[2 * i], tmp[2 * i]) + Inlines.MULT16_16(tmp[2 * i + 1], tmp[2 * i + 1]), 16); - mean += x2; - tmp[i] = mem0 + Inlines.PSHR32(x2 - mem0, 4); - mem0 = tmp[i]; - } - mem0 = 0; - int maxE = 0; - for (i = len2 - 1; i >= 0; --i) { - tmp[i] = mem0 + Inlines.PSHR32(tmp[i] - mem0, 3); - mem0 = tmp[i]; - maxE = Inlines.MAX16(maxE, mem0); - } - mean = Inlines.MULT16_16(Inlines.celt_sqrt(mean), Inlines.celt_sqrt(Inlines.MULT16_16(maxE, len2 >> 1))); - int norm = Inlines.SHL32(len2, 20) / Inlines.ADD32(1, Inlines.SHR32(mean, 1)); - unmask = 0; - for (i = 12; i < len2 - 5; i += 4) { - int id = Inlines.MAX32(0, Inlines.MIN32(127, Inlines.MULT16_32_Q15(tmp[i] + 1, norm))); - unmask += inv_table[id]; - } - if ((unmask = 64 * unmask * 4 / (6 * (len2 - 17))) <= mask_metric) continue; - tf_chan.Val = c; - mask_metric = unmask; - } - is_transient = mask_metric > 200 ? 1 : 0; - int tf_max = Inlines.MAX16(0, Inlines.celt_sqrt(27 * mask_metric) - 42); - tf_estimate.Val = Inlines.celt_sqrt(Inlines.MAX32(0, Inlines.SHL32(Inlines.MULT16_16(113, Inlines.MIN16(163, tf_max)), 14) - 37312528)); - return is_transient; - } - - static int patch_transient_decision(int[][] newE, int[][] oldE, int nbEBands, int start, int end, int C) { - int i; - int mean_diff = 0; - int[] spread_old = new int[26]; - if (C == 1) { - spread_old[start] = oldE[0][start]; - for (i = start + 1; i < end; ++i) { - spread_old[i] = Inlines.MAX16(spread_old[i - 1] - 1024, oldE[0][i]); - } - } else { - spread_old[start] = Inlines.MAX16(oldE[0][start], oldE[1][start]); - for (i = start + 1; i < end; ++i) { - spread_old[i] = Inlines.MAX16(spread_old[i - 1] - 1024, Inlines.MAX16(oldE[0][i], oldE[1][i])); - } - } - for (i = end - 2; i >= start; --i) { - spread_old[i] = Inlines.MAX16(spread_old[i], spread_old[i + 1] - 1024); - } - int c = 0; - do { - for (i = Inlines.IMAX(2, start); i < end - 1; ++i) { - int x1 = Inlines.MAX16(0, newE[c][i]); - int x2 = Inlines.MAX16(0, spread_old[i]); - mean_diff = Inlines.ADD32(mean_diff, Inlines.MAX16(0, Inlines.SUB16(x1, x2))); - } - } while (++c < C); - return (mean_diff = Inlines.DIV32(mean_diff, C * (end - 1 - Inlines.IMAX(2, start)))) > 1024 ? 1 : 0; - } - - static void compute_mdcts(CeltMode mode, int shortBlocks, int[][] input, int[][] output, int C, int CC, int LM, int upsample) { - int i; - int shift; - int N; - int B; - int overlap = mode.overlap; - if (shortBlocks != 0) { - B = shortBlocks; - N = mode.shortMdctSize; - shift = mode.maxLM; - } else { - B = 1; - N = mode.shortMdctSize << LM; - shift = mode.maxLM - LM; - } - int c = 0; - do { - for (int b = 0; b < B; ++b) { - MDCT.clt_mdct_forward(mode.mdct, input[c], b * N, output[c], b, mode.window, overlap, shift, B); - } - } while (++c < CC); - if (CC == 2 && C == 1) { - for (i = 0; i < B * N; ++i) { - output[0][i] = Inlines.ADD32(Inlines.HALF32(output[0][i]), Inlines.HALF32(output[1][i])); - } - } - if (upsample != 1) { - c = 0; - do { - int bound = B * N / upsample; - i = 0; - while (i < bound) { - int[] nArray = output[c]; - int n = i++; - nArray[n] = nArray[n] * upsample; - } - Arrays.MemSetWithOffset(output[c], 0, bound, B * N - bound); - } while (++c < C); - } - } - - static void celt_preemphasis(short[] pcmp, int pcmp_ptr, int[] inp, int inp_ptr, int N, int CC, int upsample, int[] coef, BoxedValueInt mem, int clip) { - int i; - int coef0 = coef[0]; - int m = mem.Val; - if (coef[1] == 0 && upsample == 1 && clip == 0) { - for (int i2 = 0; i2 < N; ++i2) { - short x = pcmp[pcmp_ptr + CC * i2]; - inp[inp_ptr + i2] = Inlines.SHL32(x, 12) - m; - m = Inlines.SHR32(Inlines.MULT16_16(coef0, (int)x), 3); - } - mem.Val = m; - return; - } - int Nu = N / upsample; - if (upsample != 1) { - Arrays.MemSetWithOffset(inp, 0, inp_ptr, N); - } - for (i = 0; i < Nu; ++i) { - inp[inp_ptr + i * upsample] = pcmp[pcmp_ptr + CC * i]; - } - for (i = 0; i < N; ++i) { - int x = inp[inp_ptr + i]; - inp[inp_ptr + i] = Inlines.SHL32(x, 12) - m; - m = Inlines.SHR32(Inlines.MULT16_16(coef0, x), 3); - } - mem.Val = m; - } - - static void celt_preemphasis(short[] pcmp, int[] inp, int inp_ptr, int N, int CC, int upsample, int[] coef, BoxedValueInt mem, int clip) { - int i; - int coef0 = coef[0]; - int m = mem.Val; - if (coef[1] == 0 && upsample == 1 && clip == 0) { - for (int i2 = 0; i2 < N; ++i2) { - short x = pcmp[CC * i2]; - inp[inp_ptr + i2] = Inlines.SHL32(x, 12) - m; - m = Inlines.SHR32(Inlines.MULT16_16(coef0, (int)x), 3); - } - mem.Val = m; - return; - } - int Nu = N / upsample; - if (upsample != 1) { - Arrays.MemSetWithOffset(inp, 0, inp_ptr, N); - } - for (i = 0; i < Nu; ++i) { - inp[inp_ptr + i * upsample] = pcmp[CC * i]; - } - for (i = 0; i < N; ++i) { - int x = inp[inp_ptr + i]; - inp[inp_ptr + i] = Inlines.SHL32(x, 12) - m; - m = Inlines.SHR32(Inlines.MULT16_16(coef0, x), 3); - } - mem.Val = m; - } - - static int l1_metric(int[] tmp, int N, int LM, int bias) { - int L1 = 0; - for (int i = 0; i < N; ++i) { - L1 += Inlines.EXTEND32(Inlines.ABS32(tmp[i])); - } - L1 = Inlines.MAC16_32_Q15(L1, LM * bias, L1); - return L1; - } - - static int tf_analysis(CeltMode m, int len, int isTransient, int[] tf_res, int lambda, int[][] X, int N0, int LM, BoxedValueInt tf_sum, int tf_estimate, int tf_chan) { - int curr1; - int curr0; - int cost1; - int cost0; - int i; - int[] selcost = new int[2]; - int tf_select = 0; - int bias = Inlines.MULT16_16_Q14(1311, Inlines.MAX16(-4096, 8192 - tf_estimate)); - int[] metric = new int[len]; - int[] tmp = new int[m.eBands[len] - m.eBands[len - 1] << LM]; - int[] tmp_1 = new int[m.eBands[len] - m.eBands[len - 1] << LM]; - int[] path0 = new int[len]; - int[] path1 = new int[len]; - tf_sum.Val = 0; - for (i = 0; i < len; ++i) { - int L1; - int best_level = 0; - int N = m.eBands[i + 1] - m.eBands[i] << LM; - boolean narrow = m.eBands[i + 1] - m.eBands[i] == 1; - System.arraycopy(X[tf_chan], m.eBands[i] << LM, tmp, 0, N); - int best_L1 = L1 = CeltCommon.l1_metric(tmp, N, isTransient != 0 ? LM : 0, bias); - if (isTransient != 0 && !narrow) { - System.arraycopy(tmp, 0, tmp_1, 0, N); - Bands.haar1ZeroOffset(tmp_1, N >> LM, 1 << LM); - L1 = CeltCommon.l1_metric(tmp_1, N, LM + 1, bias); - if (L1 < best_L1) { - best_L1 = L1; - best_level = -1; - } - } - for (int k = 0; k < LM + (isTransient == 0 && !narrow ? 1 : 0); ++k) { - int B = isTransient != 0 ? LM - k - 1 : k + 1; - Bands.haar1ZeroOffset(tmp, N >> k, 1 << k); - L1 = CeltCommon.l1_metric(tmp, N, B, bias); - if (L1 >= best_L1) continue; - best_L1 = L1; - best_level = k + 1; - } - metric[i] = isTransient != 0 ? 2 * best_level : -2 * best_level; - tf_sum.Val = tf_sum.Val + ((isTransient != 0 ? LM : 0) - metric[i] / 2); - if (!narrow || metric[i] != 0 && metric[i] != -2 * LM) continue; - int n = i; - metric[n] = metric[n] - 1; - } - tf_select = 0; - for (int sel = 0; sel < 2; ++sel) { - cost0 = 0; - cost1 = isTransient != 0 ? 0 : lambda; - for (i = 1; i < len; ++i) { - curr0 = Inlines.IMIN(cost0, cost1 + lambda); - curr1 = Inlines.IMIN(cost0 + lambda, cost1); - cost0 = curr0 + Inlines.abs(metric[i] - 2 * CeltTables.tf_select_table[LM][4 * isTransient + 2 * sel + 0]); - cost1 = curr1 + Inlines.abs(metric[i] - 2 * CeltTables.tf_select_table[LM][4 * isTransient + 2 * sel + 1]); - } - selcost[sel] = cost0 = Inlines.IMIN(cost0, cost1); - } - if (selcost[1] < selcost[0] && isTransient != 0) { - tf_select = 1; - } - cost0 = 0; - cost1 = isTransient != 0 ? 0 : lambda; - for (i = 1; i < len; ++i) { - int from0 = cost0; - int from1 = cost1 + lambda; - if (from0 < from1) { - curr0 = from0; - path0[i] = 0; - } else { - curr0 = from1; - path0[i] = 1; - } - from0 = cost0 + lambda; - from1 = cost1; - if (from0 < from1) { - curr1 = from0; - path1[i] = 0; - } else { - curr1 = from1; - path1[i] = 1; - } - cost0 = curr0 + Inlines.abs(metric[i] - 2 * CeltTables.tf_select_table[LM][4 * isTransient + 2 * tf_select + 0]); - cost1 = curr1 + Inlines.abs(metric[i] - 2 * CeltTables.tf_select_table[LM][4 * isTransient + 2 * tf_select + 1]); - } - tf_res[len - 1] = cost0 < cost1 ? 0 : 1; - for (i = len - 2; i >= 0; --i) { - tf_res[i] = tf_res[i + 1] == 1 ? path1[i + 1] : path0[i + 1]; - } - return tf_select; - } - - static void tf_encode(int start, int end, int isTransient, int[] tf_res, int LM, int tf_select, EntropyCoder enc) { - int i; - int budget = enc.storage * 8; - int tell = enc.tell(); - int logp = isTransient != 0 ? 2 : 4; - int tf_select_rsv = LM > 0 && tell + logp + 1 <= budget ? 1 : 0; - budget -= tf_select_rsv; - int tf_changed = 0; - int curr = 0; - for (i = start; i < end; ++i) { - if (tell + logp <= budget) { - enc.enc_bit_logp(tf_res[i] ^ curr, logp); - tell = enc.tell(); - curr = tf_res[i]; - tf_changed |= curr; - } else { - tf_res[i] = curr; - } - logp = isTransient != 0 ? 4 : 5; - } - if (tf_select_rsv != 0 && CeltTables.tf_select_table[LM][4 * isTransient + 0 + tf_changed] != CeltTables.tf_select_table[LM][4 * isTransient + 2 + tf_changed]) { - enc.enc_bit_logp(tf_select, 1); - } else { - tf_select = 0; - } - for (i = start; i < end; ++i) { - tf_res[i] = CeltTables.tf_select_table[LM][4 * isTransient + 2 * tf_select + tf_res[i]]; - } - } - - static int alloc_trim_analysis(CeltMode m, int[][] X, int[][] bandLogE, int end, int LM, int C, AnalysisInfo analysis, BoxedValueInt stereo_saving, int tf_estimate, int intensity, int surround_trim) { - int i; - int diff = 0; - int trim = 1280; - if (C == 2) { - int partial; - int sum = 0; - for (i = 0; i < 8; ++i) { - partial = Kernels.celt_inner_prod(X[0], m.eBands[i] << LM, X[1], m.eBands[i] << LM, m.eBands[i + 1] - m.eBands[i] << LM); - sum = Inlines.ADD16(sum, (int)Inlines.EXTRACT16(Inlines.SHR32(partial, 18))); - } - sum = Inlines.MULT16_16_Q15(4096, sum); - int minXC = sum = Inlines.MIN16(1024, Inlines.ABS32(sum)); - for (i = 8; i < intensity; ++i) { - partial = Kernels.celt_inner_prod(X[0], m.eBands[i] << LM, X[1], m.eBands[i] << LM, m.eBands[i + 1] - m.eBands[i] << LM); - minXC = Inlines.MIN16(minXC, (int)Inlines.ABS16(Inlines.EXTRACT16(Inlines.SHR32(partial, 18)))); - } - minXC = Inlines.MIN16(1024, Inlines.ABS32(minXC)); - int logXC = Inlines.celt_log2(1049625 - Inlines.MULT16_16(sum, sum)); - int logXC2 = Inlines.MAX16(Inlines.HALF16(logXC), Inlines.celt_log2(1049625 - Inlines.MULT16_16(minXC, minXC))); - logXC = Inlines.PSHR32(logXC - 6144, 2); - logXC2 = Inlines.PSHR32(logXC2 - 6144, 2); - trim += Inlines.MAX16(-1024, Inlines.MULT16_16_Q15(24576, logXC)); - stereo_saving.Val = Inlines.MIN16(stereo_saving.Val + 64, 0 - Inlines.HALF16(logXC2)); - } - int c = 0; - do { - for (i = 0; i < end - 1; ++i) { - diff += bandLogE[c][i] * (2 + 2 * i - end); - } - } while (++c < C); - trim -= Inlines.MAX16((int)Inlines.NEG16((short)512), Inlines.MIN16(512, Inlines.SHR16((diff /= C * (end - 1)) + 1024, 2) / 6)); - trim -= Inlines.SHR16(surround_trim, 2); - trim -= 2 * Inlines.SHR16(tf_estimate, 6); - if (analysis.enabled && analysis.valid != 0) { - trim -= Inlines.MAX16(-512, Inlines.MIN16(512, (int)(512.0f * (analysis.tonality_slope + 0.05f)))); - } - int trim_index = Inlines.PSHR32(trim, 8); - trim_index = Inlines.IMAX(0, Inlines.IMIN(10, trim_index)); - return trim_index; - } - - static int stereo_analysis(CeltMode m, int[][] X, int LM) { - int sumLR = 1; - int sumMS = 1; - for (int i = 0; i < 13; ++i) { - for (int j = m.eBands[i] << LM; j < m.eBands[i + 1] << LM; ++j) { - int L = Inlines.EXTEND32(X[0][j]); - int R = Inlines.EXTEND32(X[1][j]); - int M = Inlines.ADD32(L, R); - int S = Inlines.SUB32(L, R); - sumLR = Inlines.ADD32(sumLR, Inlines.ADD32(Inlines.ABS32(L), Inlines.ABS32(R))); - sumMS = Inlines.ADD32(sumMS, Inlines.ADD32(Inlines.ABS32(M), Inlines.ABS32(S))); - } - } - sumMS = Inlines.MULT16_32_Q15((short)23170, sumMS); - int thetas = 13; - if (LM <= 1) { - thetas -= 8; - } - return Inlines.MULT16_32_Q15((m.eBands[13] << LM + 1) + thetas, sumMS) > Inlines.MULT16_32_Q15(m.eBands[13] << LM + 1, sumLR) ? 1 : 0; - } - - static int median_of_5(int[] x, int x_ptr) { - int t4; - int t3; - int t1; - int t0; - int t2 = x[x_ptr + 2]; - if (x[x_ptr] > x[x_ptr + 1]) { - t0 = x[x_ptr + 1]; - t1 = x[x_ptr]; - } else { - t0 = x[x_ptr]; - t1 = x[x_ptr + 1]; - } - if (x[x_ptr + 3] > x[x_ptr + 4]) { - t3 = x[x_ptr + 4]; - t4 = x[x_ptr + 3]; - } else { - t3 = x[x_ptr + 3]; - t4 = x[x_ptr + 4]; - } - if (t0 > t3) { - int tmp = t3; - t3 = t0; - t0 = tmp; - tmp = t4; - t4 = t1; - t1 = tmp; - } - if (t2 > t1) { - if (t1 < t3) { - return Inlines.MIN16(t2, t3); - } - return Inlines.MIN16(t4, t1); - } - if (t2 < t3) { - return Inlines.MIN16(t1, t3); - } - return Inlines.MIN16(t2, t4); - } - - static int median_of_3(int[] x, int x_ptr) { - int t1; - int t0; - if (x[x_ptr] > x[x_ptr + 1]) { - t0 = x[x_ptr + 1]; - t1 = x[x_ptr]; - } else { - t0 = x[x_ptr]; - t1 = x[x_ptr + 1]; - } - int t2 = x[x_ptr + 2]; - if (t1 < t2) { - return t1; - } - if (t0 < t2) { - return t2; - } - return t0; - } - - static int dynalloc_analysis(int[][] bandLogE, int[][] bandLogE2, int nbEBands, int start, int end, int C, int[] offsets, int lsb_depth, short[] logN, int isTransient, int vbr, int constrained_vbr, short[] eBands, int LM, int effectiveBytes, BoxedValueInt tot_boost_, int lfe, int[] surround_dynalloc) { - int i; - int tot_boost = 0; - int[][] follower = Arrays.InitTwoDimensionalArrayInt(2, nbEBands); - int[] noise_floor = new int[C * nbEBands]; - Arrays.MemSet(offsets, 0, nbEBands); - int maxDepth = -32666; - for (i = 0; i < end; ++i) { - noise_floor[i] = Inlines.MULT16_16((short)64, logN[i]) + 512 + Inlines.SHL16(9 - lsb_depth, 10) - Inlines.SHL16(CeltTables.eMeans[i], 6) + Inlines.MULT16_16(6, (i + 5) * (i + 5)); - } - int c = 0; - do { - for (i = 0; i < end; ++i) { - maxDepth = Inlines.MAX16(maxDepth, bandLogE[c][i] - noise_floor[i]); - } - } while (++c < C); - if (effectiveBytes > 50 && LM >= 1 && lfe == 0) { - int last = 0; - c = 0; - do { - int[] f = follower[c]; - f[0] = bandLogE2[c][0]; - for (i = 1; i < end; ++i) { - if (bandLogE2[c][i] > bandLogE2[c][i - 1] + 512) { - last = i; - } - f[i] = Inlines.MIN16(f[i - 1] + 1536, bandLogE2[c][i]); - } - for (i = last - 1; i >= 0; --i) { - f[i] = Inlines.MIN16(f[i], Inlines.MIN16(f[i + 1] + 2048, bandLogE2[c][i])); - } - int offset = 1024; - for (i = 2; i < end - 2; ++i) { - f[i] = Inlines.MAX16(f[i], CeltCommon.median_of_5(bandLogE2[c], i - 2) - offset); - } - int tmp = CeltCommon.median_of_3(bandLogE2[c], 0) - offset; - f[0] = Inlines.MAX16(f[0], tmp); - f[1] = Inlines.MAX16(f[1], tmp); - tmp = CeltCommon.median_of_3(bandLogE2[c], end - 3) - offset; - f[end - 2] = Inlines.MAX16(f[end - 2], tmp); - f[end - 1] = Inlines.MAX16(f[end - 1], tmp); - for (i = 0; i < end; ++i) { - f[i] = Inlines.MAX16(f[i], noise_floor[i]); - } - } while (++c < C); - if (C == 2) { - for (i = start; i < end; ++i) { - follower[1][i] = Inlines.MAX16(follower[1][i], follower[0][i] - 4096); - follower[0][i] = Inlines.MAX16(follower[0][i], follower[1][i] - 4096); - follower[0][i] = Inlines.HALF16(Inlines.MAX16(0, bandLogE[0][i] - follower[0][i]) + Inlines.MAX16(0, bandLogE[1][i] - follower[1][i])); - } - } else { - for (i = start; i < end; ++i) { - follower[0][i] = Inlines.MAX16(0, bandLogE[0][i] - follower[0][i]); - } - } - for (i = start; i < end; ++i) { - follower[0][i] = Inlines.MAX16(follower[0][i], surround_dynalloc[i]); - } - if ((vbr == 0 || constrained_vbr != 0) && isTransient == 0) { - for (i = start; i < end; ++i) { - follower[0][i] = Inlines.HALF16(follower[0][i]); - } - } - for (i = start; i < end; ++i) { - int boost_bits; - int boost; - if (i < 8) { - int[] nArray = follower[0]; - int n = i; - nArray[n] = nArray[n] * 2; - } - if (i >= 12) { - follower[0][i] = Inlines.HALF16(follower[0][i]); - } - follower[0][i] = Inlines.MIN16(follower[0][i], 4096); - int width = C * (eBands[i + 1] - eBands[i]) << LM; - if (width < 6) { - boost = Inlines.SHR32(follower[0][i], 10); - boost_bits = boost * width << 3; - } else if (width > 48) { - boost = Inlines.SHR32(follower[0][i] * 8, 10); - boost_bits = (boost * width << 3) / 8; - } else { - boost = Inlines.SHR32(follower[0][i] * width / 6, 10); - boost_bits = boost * 6 << 3; - } - if ((vbr == 0 || constrained_vbr != 0 && isTransient == 0) && tot_boost + boost_bits >> 3 >> 3 > effectiveBytes / 4) { - int cap = effectiveBytes / 4 << 3 << 3; - offsets[i] = cap - tot_boost; - tot_boost = cap; - break; - } - offsets[i] = boost; - tot_boost += boost_bits; - } - } - tot_boost_.Val = tot_boost; - return maxDepth; - } - - static void deemphasis(int[][] input, int[] input_ptrs, short[] pcm, int pcm_ptr, int N, int C, int downsample, int[] coef, int[] mem, int accum) { - boolean apply_downsampling = false; - int[] scratch = new int[N]; - int coef0 = coef[0]; - int Nd = N / downsample; - int c = 0; - do { - int tmp; - int j; - int m = mem[c]; - int[] x = input[c]; - int x_ptr = input_ptrs[c]; - int y = pcm_ptr + c; - if (downsample > 1) { - for (j = 0; j < N; ++j) { - tmp = x[x_ptr + j] + m + 0; - m = Inlines.MULT16_32_Q15(coef0, tmp); - scratch[j] = tmp; - } - apply_downsampling = true; - } else if (accum != 0) { - for (j = 0; j < N; ++j) { - tmp = x[x_ptr + j] + m + 0; - m = Inlines.MULT16_32_Q15(coef0, tmp); - pcm[y + j * C] = Inlines.SAT16(Inlines.ADD32(pcm[y + j * C], Inlines.SIG2WORD16(tmp))); - } - } else { - for (j = 0; j < N; ++j) { - tmp = x[x_ptr + j] + m + 0; - if (x[x_ptr + j] > 0 && m > 0 && tmp < 0) { - tmp = Integer.MAX_VALUE; - m = Integer.MAX_VALUE; - } else { - m = Inlines.MULT16_32_Q15(coef0, tmp); - } - pcm[y + j * C] = Inlines.SIG2WORD16(tmp); - } - } - mem[c] = m; - if (!apply_downsampling) continue; - for (j = 0; j < Nd; ++j) { - pcm[y + j * C] = Inlines.SIG2WORD16(scratch[j * downsample]); - } - } while (++c < C); - } - - static void celt_synthesis(CeltMode mode, int[][] X, int[][] out_syn, int[] out_syn_ptrs, int[] oldBandE, int start, int effEnd, int C, int CC, int isTransient, int LM, int downsample, int silence) { - int shift; - int NB; - int B; - int overlap = mode.overlap; - int nbEBands = mode.nbEBands; - int N = mode.shortMdctSize << LM; - int[] freq = new int[N]; - int M = 1 << LM; - if (isTransient != 0) { - B = M; - NB = mode.shortMdctSize; - shift = mode.maxLM; - } else { - B = 1; - NB = mode.shortMdctSize << LM; - shift = mode.maxLM - LM; - } - if (CC == 2 && C == 1) { - int b; - Bands.denormalise_bands(mode, X[0], freq, 0, oldBandE, 0, start, effEnd, M, downsample, silence); - int freq2 = out_syn_ptrs[1] + overlap / 2; - System.arraycopy(freq, 0, out_syn[1], freq2, N); - for (b = 0; b < B; ++b) { - MDCT.clt_mdct_backward(mode.mdct, out_syn[1], freq2 + b, out_syn[0], out_syn_ptrs[0] + NB * b, mode.window, overlap, shift, B); - } - for (b = 0; b < B; ++b) { - MDCT.clt_mdct_backward(mode.mdct, freq, b, out_syn[1], out_syn_ptrs[1] + NB * b, mode.window, overlap, shift, B); - } - } else if (CC == 1 && C == 2) { - int freq2 = out_syn_ptrs[0] + overlap / 2; - Bands.denormalise_bands(mode, X[0], freq, 0, oldBandE, 0, start, effEnd, M, downsample, silence); - Bands.denormalise_bands(mode, X[1], out_syn[0], freq2, oldBandE, nbEBands, start, effEnd, M, downsample, silence); - for (int i = 0; i < N; ++i) { - freq[i] = Inlines.HALF32(Inlines.ADD32(freq[i], out_syn[0][freq2 + i])); - } - for (int b = 0; b < B; ++b) { - MDCT.clt_mdct_backward(mode.mdct, freq, b, out_syn[0], out_syn_ptrs[0] + NB * b, mode.window, overlap, shift, B); - } - } else { - int c = 0; - do { - Bands.denormalise_bands(mode, X[c], freq, 0, oldBandE, c * nbEBands, start, effEnd, M, downsample, silence); - for (int b = 0; b < B; ++b) { - MDCT.clt_mdct_backward(mode.mdct, freq, b, out_syn[c], out_syn_ptrs[c] + NB * b, mode.window, overlap, shift, B); - } - } while (++c < CC); - } - } - - static void tf_decode(int start, int end, int isTransient, int[] tf_res, int LM, EntropyCoder dec) { - int i; - int budget = dec.storage * 8; - int tell = dec.tell(); - int logp = isTransient != 0 ? 2 : 4; - int tf_select_rsv = LM > 0 && tell + logp + 1 <= budget ? 1 : 0; - budget -= tf_select_rsv; - int curr = 0; - int tf_changed = 0; - for (i = start; i < end; ++i) { - if (tell + logp <= budget) { - tell = dec.tell(); - tf_changed |= (curr ^= dec.dec_bit_logp(logp)); - } - tf_res[i] = curr; - logp = isTransient != 0 ? 4 : 5; - } - int tf_select = 0; - if (tf_select_rsv != 0 && CeltTables.tf_select_table[LM][4 * isTransient + 0 + tf_changed] != CeltTables.tf_select_table[LM][4 * isTransient + 2 + tf_changed]) { - tf_select = dec.dec_bit_logp(1L); - } - for (i = start; i < end; ++i) { - tf_res[i] = CeltTables.tf_select_table[LM][4 * isTransient + 2 * tf_select + tf_res[i]]; - } - } - - static int celt_plc_pitch_search(int[][] decode_mem, int C) { - BoxedValueInt pitch_index = new BoxedValueInt(0); - int[] lp_pitch_buf = new int[1024]; - Pitch.pitch_downsample(decode_mem, lp_pitch_buf, 2048, C); - Pitch.pitch_search(lp_pitch_buf, 360, lp_pitch_buf, 1328, 620, pitch_index); - pitch_index.Val = 720 - pitch_index.Val; - return pitch_index.Val; - } - - static int resampling_factor(int rate) { - int ret; - switch (rate) { - case 48000: { - ret = 1; - break; - } - case 24000: { - ret = 2; - break; - } - case 16000: { - ret = 3; - break; - } - case 12000: { - ret = 4; - break; - } - case 8000: { - ret = 6; - break; - } - default: { - Inlines.OpusAssert(false); - ret = 0; - } - } - return ret; - } - - static void comb_filter_const(int[] y, int y_ptr, int[] x, int x_ptr, int T, int N, int g10, int g11, int g12) { - int xpt = x_ptr - T; - int x4 = x[xpt - 2]; - int x3 = x[xpt - 1]; - int x2 = x[xpt]; - int x1 = x[xpt + 1]; - for (int i = 0; i < N; ++i) { - int x0 = x[xpt + i + 2]; - y[y_ptr + i] = x[x_ptr + i] + Inlines.MULT16_32_Q15(g10, x2) + Inlines.MULT16_32_Q15(g11, Inlines.ADD32(x1, x3)) + Inlines.MULT16_32_Q15(g12, Inlines.ADD32(x0, x4)); - x4 = x3; - x3 = x2; - x2 = x1; - x1 = x0; - } - } - - static void comb_filter(int[] y, int y_ptr, int[] x, int x_ptr, int T0, int T1, int N, int g0, int g1, int tapset0, int tapset1, int[] window, int overlap) { - int i; - if (g0 == 0 && g1 == 0) { - if (x_ptr != y_ptr) { - // empty if block - } - return; - } - int g00 = Inlines.MULT16_16_P15(g0, (int)gains[tapset0][0]); - int g01 = Inlines.MULT16_16_P15(g0, (int)gains[tapset0][1]); - int g02 = Inlines.MULT16_16_P15(g0, (int)gains[tapset0][2]); - int g10 = Inlines.MULT16_16_P15(g1, (int)gains[tapset1][0]); - int g11 = Inlines.MULT16_16_P15(g1, (int)gains[tapset1][1]); - int g12 = Inlines.MULT16_16_P15(g1, (int)gains[tapset1][2]); - int x1 = x[x_ptr - T1 + 1]; - int x2 = x[x_ptr - T1]; - int x3 = x[x_ptr - T1 - 1]; - int x4 = x[x_ptr - T1 - 2]; - if (g0 == g1 && T0 == T1 && tapset0 == tapset1) { - overlap = 0; - } - for (i = 0; i < overlap; ++i) { - int x0 = x[x_ptr + i - T1 + 2]; - int f = Inlines.MULT16_16_Q15(window[i], window[i]); - y[y_ptr + i] = x[x_ptr + i] + Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15((int)((short)(Short.MAX_VALUE - f)), g00), x[x_ptr + i - T0]) + Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15((int)((short)(Short.MAX_VALUE - f)), g01), Inlines.ADD32(x[x_ptr + i - T0 + 1], x[x_ptr + i - T0 - 1])) + Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15((int)((short)(Short.MAX_VALUE - f)), g02), Inlines.ADD32(x[x_ptr + i - T0 + 2], x[x_ptr + i - T0 - 2])) + Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15(f, g10), x2) + Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15(f, g11), Inlines.ADD32(x1, x3)) + Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15(f, g12), Inlines.ADD32(x0, x4)); - x4 = x3; - x3 = x2; - x2 = x1; - x1 = x0; - } - if (g1 == 0) { - if (x_ptr != y_ptr) { - // empty if block - } - return; - } - CeltCommon.comb_filter_const(y, y_ptr + i, x, x_ptr + i, T1, N - i, g10, g11, g12); - } - - static void init_caps(CeltMode m, int[] cap, int LM, int C) { - for (int i = 0; i < m.nbEBands; ++i) { - int N = m.eBands[i + 1] - m.eBands[i] << LM; - cap[i] = (m.cache.caps[m.nbEBands * (2 * LM + C - 1) + i] + 64) * C * N >> 2; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltConstants.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltConstants.java deleted file mode 100644 index 49a9630..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltConstants.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class CeltConstants { - public static final int Q15ONE = Short.MAX_VALUE; - public static final float CELT_SIG_SCALE = 32768.0f; - public static final int SIG_SHIFT = 12; - public static final int NORM_SCALING = 16384; - public static final int DB_SHIFT = 10; - public static final int EPSILON = 1; - public static final int VERY_SMALL = 0; - public static final short VERY_LARGE16 = Short.MAX_VALUE; - public static final short Q15_ONE = Short.MAX_VALUE; - public static final int COMBFILTER_MAXPERIOD = 1024; - public static final int COMBFILTER_MINPERIOD = 15; - public static final int DECODE_BUFFER_SIZE = 2048; - public static final int BITALLOC_SIZE = 11; - public static final int MAX_PERIOD = 1024; - public static final int TOTAL_MODES = 1; - public static final int MAX_PSEUDO = 40; - public static final int LOG_MAX_PSEUDO = 6; - public static final int CELT_MAX_PULSES = 128; - public static final int MAX_FINE_BITS = 8; - public static final int FINE_OFFSET = 21; - public static final int QTHETA_OFFSET = 4; - public static final int QTHETA_OFFSET_TWOPHASE = 16; - public static final int PLC_PITCH_LAG_MAX = 720; - public static final int PLC_PITCH_LAG_MIN = 100; - public static final int LPC_ORDER = 24; - - CeltConstants() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltDecoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltDecoder.java deleted file mode 100644 index 3ef5085..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltDecoder.java +++ /dev/null @@ -1,534 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Autocorrelation; -import de.maxhenkel.voicechat.concentus.Bands; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltCommon; -import de.maxhenkel.voicechat.concentus.CeltLPC; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.QuantizeBands; -import de.maxhenkel.voicechat.concentus.Rate; -import de.maxhenkel.voicechat.concentus.VQ; - -class CeltDecoder { - CeltMode mode = null; - int overlap = 0; - int channels = 0; - int stream_channels = 0; - int downsample = 0; - int start = 0; - int end = 0; - int signalling = 0; - int rng = 0; - int error = 0; - int last_pitch_index = 0; - int loss_count = 0; - int postfilter_period = 0; - int postfilter_period_old = 0; - int postfilter_gain = 0; - int postfilter_gain_old = 0; - int postfilter_tapset = 0; - int postfilter_tapset_old = 0; - final int[] preemph_memD = new int[2]; - int[][] decode_mem = null; - int[][] lpc = null; - int[] oldEBands = null; - int[] oldLogE = null; - int[] oldLogE2 = null; - int[] backgroundLogE = null; - - CeltDecoder() { - } - - private void Reset() { - this.mode = null; - this.overlap = 0; - this.channels = 0; - this.stream_channels = 0; - this.downsample = 0; - this.start = 0; - this.end = 0; - this.signalling = 0; - this.PartialReset(); - } - - private void PartialReset() { - this.rng = 0; - this.error = 0; - this.last_pitch_index = 0; - this.loss_count = 0; - this.postfilter_period = 0; - this.postfilter_period_old = 0; - this.postfilter_gain = 0; - this.postfilter_gain_old = 0; - this.postfilter_tapset = 0; - this.postfilter_tapset_old = 0; - Arrays.MemSet(this.preemph_memD, 0, 2); - this.decode_mem = null; - this.lpc = null; - this.oldEBands = null; - this.oldLogE = null; - this.oldLogE2 = null; - this.backgroundLogE = null; - } - - void ResetState() { - this.PartialReset(); - this.decode_mem = new int[this.channels][]; - this.lpc = new int[this.channels][]; - for (int c = 0; c < this.channels; ++c) { - this.decode_mem[c] = new int[2048 + this.mode.overlap]; - this.lpc[c] = new int[24]; - } - this.oldEBands = new int[2 * this.mode.nbEBands]; - this.oldLogE = new int[2 * this.mode.nbEBands]; - this.oldLogE2 = new int[2 * this.mode.nbEBands]; - this.backgroundLogE = new int[2 * this.mode.nbEBands]; - for (int i = 0; i < 2 * this.mode.nbEBands; ++i) { - this.oldLogE2[i] = -28672; - this.oldLogE[i] = -28672; - } - } - - int celt_decoder_init(int sampling_rate, int channels) { - int ret = this.opus_custom_decoder_init(CeltMode.mode48000_960_120, channels); - if (ret != OpusError.OPUS_OK) { - return ret; - } - this.downsample = CeltCommon.resampling_factor(sampling_rate); - if (this.downsample == 0) { - return OpusError.OPUS_BAD_ARG; - } - return OpusError.OPUS_OK; - } - - private int opus_custom_decoder_init(CeltMode mode, int channels) { - if (channels < 0 || channels > 2) { - return OpusError.OPUS_BAD_ARG; - } - if (this == null) { - return OpusError.OPUS_ALLOC_FAIL; - } - this.Reset(); - this.mode = mode; - this.overlap = mode.overlap; - this.stream_channels = this.channels = channels; - this.downsample = 1; - this.start = 0; - this.end = this.mode.effEBands; - this.signalling = 1; - this.loss_count = 0; - this.ResetState(); - return OpusError.OPUS_OK; - } - - void celt_decode_lost(int N, int LM) { - boolean noise_based; - int C = this.channels; - int[][] out_syn = new int[2][]; - int[] out_syn_ptrs = new int[2]; - CeltMode mode = this.mode; - int nbEBands = mode.nbEBands; - int overlap = mode.overlap; - short[] eBands = mode.eBands; - int c = 0; - do { - out_syn[c] = this.decode_mem[c]; - out_syn_ptrs[c] = 2048 - N; - } while (++c < C); - boolean bl = noise_based = this.loss_count >= 5 || this.start != 0; - if (noise_based) { - int i; - int end = this.end; - int effEnd = Inlines.IMAX(this.start, Inlines.IMIN(end, mode.effEBands)); - int[][] X = Arrays.InitTwoDimensionalArrayInt(C, N); - int decay = this.loss_count == 0 ? 1536 : 512; - c = 0; - do { - for (i = this.start; i < end; ++i) { - this.oldEBands[c * nbEBands + i] = Inlines.MAX16(this.backgroundLogE[c * nbEBands + i], this.oldEBands[c * nbEBands + i] - decay); - } - } while (++c < C); - int seed = this.rng; - for (c = 0; c < C; ++c) { - for (i = this.start; i < effEnd; ++i) { - int boffs = eBands[i] << LM; - int blen = eBands[i + 1] - eBands[i] << LM; - for (int j = 0; j < blen; ++j) { - seed = Bands.celt_lcg_rand(seed); - X[c][boffs + j] = seed >> 20; - } - VQ.renormalise_vector(X[c], 0, blen, Short.MAX_VALUE); - } - } - this.rng = seed; - c = 0; - do { - Arrays.MemMove(this.decode_mem[c], N, 0, 2048 - N + (overlap >> 1)); - } while (++c < C); - CeltCommon.celt_synthesis(mode, X, out_syn, out_syn_ptrs, this.oldEBands, this.start, effEnd, C, C, 0, LM, this.downsample, 0); - } else { - int pitch_index; - int fade = Short.MAX_VALUE; - if (this.loss_count == 0) { - this.last_pitch_index = pitch_index = CeltCommon.celt_plc_pitch_search(this.decode_mem, C); - } else { - pitch_index = this.last_pitch_index; - fade = 26214; - } - int[] etmp = new int[overlap]; - int[] exc = new int[1024]; - int[] window = mode.window; - c = 0; - do { - int i; - int S1 = 0; - int[] buf = this.decode_mem[c]; - for (i = 0; i < 1024; ++i) { - exc[i] = Inlines.ROUND16(buf[1024 + i], 12); - } - if (this.loss_count == 0) { - int[] ac = new int[25]; - Autocorrelation._celt_autocorr(exc, ac, window, overlap, 24, 1024); - ac[0] = ac[0] + Inlines.SHR32(ac[0], 13); - for (i = 1; i <= 24; ++i) { - int n = i; - ac[n] = ac[n] - Inlines.MULT16_32_Q15(2 * i * i, ac[i]); - } - CeltLPC.celt_lpc(this.lpc[c], ac, 24); - } - int exc_length = Inlines.IMIN(2 * pitch_index, 1024); - int[] lpc_mem = new int[24]; - for (i = 0; i < 24; ++i) { - lpc_mem[i] = Inlines.ROUND16(buf[2048 - exc_length - 1 - i], 12); - } - Kernels.celt_fir(exc, 1024 - exc_length, this.lpc[c], 0, exc, 1024 - exc_length, exc_length, 24, lpc_mem); - int E1 = 1; - int E2 = 1; - int shift = Inlines.IMAX(0, 2 * Inlines.celt_zlog2(Inlines.celt_maxabs16(exc, 1024 - exc_length, exc_length)) - 20); - int decay_length = exc_length >> 1; - for (i = 0; i < decay_length; ++i) { - int e = exc[1024 - decay_length + i]; - E1 += Inlines.SHR32(Inlines.MULT16_16(e, e), shift); - e = exc[1024 - 2 * decay_length + i]; - E2 += Inlines.SHR32(Inlines.MULT16_16(e, e), shift); - } - E1 = Inlines.MIN32(E1, E2); - int decay = Inlines.celt_sqrt(Inlines.frac_div32(Inlines.SHR32(E1, 1), E2)); - Arrays.MemMove(buf, N, 0, 2048 - N); - int extrapolation_offset = 1024 - pitch_index; - int extrapolation_len = N + overlap; - int attenuation = Inlines.MULT16_16_Q15(fade, decay); - int j = 0; - i = 0; - while (i < extrapolation_len) { - if (j >= pitch_index) { - j -= pitch_index; - attenuation = Inlines.MULT16_16_Q15(attenuation, decay); - } - buf[2048 - N + i] = Inlines.SHL32(Inlines.MULT16_16_Q15(attenuation, exc[extrapolation_offset + j]), 12); - int tmp = Inlines.ROUND16(buf[1024 - N + extrapolation_offset + j], 12); - S1 += Inlines.SHR32(Inlines.MULT16_16(tmp, tmp), 8); - ++i; - ++j; - } - lpc_mem = new int[24]; - for (i = 0; i < 24; ++i) { - lpc_mem[i] = Inlines.ROUND16(buf[2048 - N - 1 - i], 12); - } - CeltLPC.celt_iir(buf, 2048 - N, this.lpc[c], buf, 2048 - N, extrapolation_len, 24, lpc_mem); - int S2 = 0; - for (i = 0; i < extrapolation_len; ++i) { - int tmp = Inlines.ROUND16(buf[2048 - N + i], 12); - S2 += Inlines.SHR32(Inlines.MULT16_16(tmp, tmp), 8); - } - if (S1 <= Inlines.SHR32(S2, 2)) { - for (i = 0; i < extrapolation_len; ++i) { - buf[2048 - N + i] = 0; - } - } else if (S1 < S2) { - int ratio = Inlines.celt_sqrt(Inlines.frac_div32(Inlines.SHR32(S1, 1) + 1, S2 + 1)); - for (i = 0; i < overlap; ++i) { - int tmp_g = Short.MAX_VALUE - Inlines.MULT16_16_Q15(window[i], Short.MAX_VALUE - ratio); - buf[2048 - N + i] = Inlines.MULT16_32_Q15(tmp_g, buf[2048 - N + i]); - } - for (i = overlap; i < extrapolation_len; ++i) { - buf[2048 - N + i] = Inlines.MULT16_32_Q15(ratio, buf[2048 - N + i]); - } - } - CeltCommon.comb_filter(etmp, 0, buf, 2048, this.postfilter_period, this.postfilter_period, overlap, -this.postfilter_gain, -this.postfilter_gain, this.postfilter_tapset, this.postfilter_tapset, null, 0); - for (i = 0; i < overlap / 2; ++i) { - buf[2048 + i] = Inlines.MULT16_32_Q15(window[i], etmp[overlap - 1 - i]) + Inlines.MULT16_32_Q15(window[overlap - i - 1], etmp[i]); - } - } while (++c < C); - } - ++this.loss_count; - } - - int celt_decode_with_ec(byte[] data, int data_ptr, int len, short[] pcm, int pcm_ptr, int frame_size, EntropyCoder dec, int accum) { - int isTransient; - int i; - int LM; - int[][] out_syn = new int[2][]; - int[] out_syn_ptrs = new int[2]; - int CC = this.channels; - int intensity = 0; - int dual_stereo = 0; - int anti_collapse_on = 0; - int C = this.stream_channels; - CeltMode mode = this.mode; - int nbEBands = mode.nbEBands; - int overlap = mode.overlap; - short[] eBands = mode.eBands; - int start = this.start; - int end = this.end; - frame_size *= this.downsample; - int[] oldBandE = this.oldEBands; - int[] oldLogE = this.oldLogE; - int[] oldLogE2 = this.oldLogE2; - int[] backgroundLogE = this.backgroundLogE; - for (LM = 0; LM <= mode.maxLM && mode.shortMdctSize << LM != frame_size; ++LM) { - } - if (LM > mode.maxLM) { - return OpusError.OPUS_BAD_ARG; - } - int M = 1 << LM; - if (len < 0 || len > 1275 || pcm == null) { - return OpusError.OPUS_BAD_ARG; - } - int N = M * mode.shortMdctSize; - int c = 0; - do { - out_syn[c] = this.decode_mem[c]; - out_syn_ptrs[c] = 2048 - N; - } while (++c < CC); - int effEnd = end; - if (effEnd > mode.effEBands) { - effEnd = mode.effEBands; - } - if (data == null || len <= 1) { - this.celt_decode_lost(N, LM); - CeltCommon.deemphasis(out_syn, out_syn_ptrs, pcm, pcm_ptr, N, CC, this.downsample, mode.preemph, this.preemph_memD, accum); - return frame_size / this.downsample; - } - if (dec == null) { - dec = new EntropyCoder(); - dec.dec_init(data, data_ptr, len); - } - if (C == 1) { - for (i = 0; i < nbEBands; ++i) { - oldBandE[i] = Inlines.MAX16(oldBandE[i], oldBandE[nbEBands + i]); - } - } - int total_bits = len * 8; - int tell = dec.tell(); - int silence = tell >= total_bits ? 1 : (tell == 1 ? dec.dec_bit_logp(15L) : 0); - if (silence != 0) { - tell = len * 8; - dec.nbits_total += tell - dec.tell(); - } - int postfilter_gain = 0; - int postfilter_pitch = 0; - int postfilter_tapset = 0; - if (start == 0 && tell + 16 <= total_bits) { - if (dec.dec_bit_logp(1L) != 0) { - int octave = (int)dec.dec_uint(6L); - postfilter_pitch = (16 << octave) + dec.dec_bits(4 + octave) - 1; - int qg = dec.dec_bits(3); - if (dec.tell() + 2 <= total_bits) { - postfilter_tapset = dec.dec_icdf(CeltTables.tapset_icdf, 2); - } - postfilter_gain = 3072 * (qg + 1); - } - tell = dec.tell(); - } - if (LM > 0 && tell + 3 <= total_bits) { - isTransient = dec.dec_bit_logp(3L); - tell = dec.tell(); - } else { - isTransient = 0; - } - int shortBlocks = isTransient != 0 ? M : 0; - int intra_ener = tell + 3 <= total_bits ? dec.dec_bit_logp(3L) : 0; - QuantizeBands.unquant_coarse_energy(mode, start, end, oldBandE, intra_ener, dec, C, LM); - int[] tf_res = new int[nbEBands]; - CeltCommon.tf_decode(start, end, isTransient, tf_res, LM, dec); - tell = dec.tell(); - int spread_decision = 2; - if (tell + 4 <= total_bits) { - spread_decision = dec.dec_icdf(CeltTables.spread_icdf, 5); - } - int[] cap = new int[nbEBands]; - CeltCommon.init_caps(mode, cap, LM, C); - int[] offsets = new int[nbEBands]; - int dynalloc_logp = 6; - total_bits <<= 3; - tell = dec.tell_frac(); - for (i = start; i < end; ++i) { - int boost; - int width = C * (eBands[i + 1] - eBands[i]) << LM; - int quanta = Inlines.IMIN(width << 3, Inlines.IMAX(48, width)); - int dynalloc_loop_logp = dynalloc_logp; - for (boost = 0; tell + (dynalloc_loop_logp << 3) < total_bits && boost < cap[i]; boost += quanta, total_bits -= quanta) { - int flag = dec.dec_bit_logp(dynalloc_loop_logp); - tell = dec.tell_frac(); - if (flag == 0) break; - dynalloc_loop_logp = 1; - } - offsets[i] = boost; - if (boost <= 0) continue; - dynalloc_logp = Inlines.IMAX(2, dynalloc_logp - 1); - } - int[] fine_quant = new int[nbEBands]; - int alloc_trim = tell + 48 <= total_bits ? dec.dec_icdf(CeltTables.trim_icdf, 7) : 5; - int bits = (len * 8 << 3) - dec.tell_frac() - 1; - int anti_collapse_rsv = isTransient != 0 && LM >= 2 && bits >= LM + 2 << 3 ? 8 : 0; - bits -= anti_collapse_rsv; - int[] pulses = new int[nbEBands]; - int[] fine_priority = new int[nbEBands]; - BoxedValueInt boxed_intensity = new BoxedValueInt(intensity); - BoxedValueInt boxed_dual_stereo = new BoxedValueInt(dual_stereo); - BoxedValueInt boxed_balance = new BoxedValueInt(0); - int codedBands = Rate.compute_allocation(mode, start, end, offsets, cap, alloc_trim, boxed_intensity, boxed_dual_stereo, bits, boxed_balance, pulses, fine_quant, fine_priority, C, LM, dec, 0, 0, 0); - intensity = boxed_intensity.Val; - dual_stereo = boxed_dual_stereo.Val; - int balance = boxed_balance.Val; - QuantizeBands.unquant_fine_energy(mode, start, end, oldBandE, fine_quant, dec, C); - c = 0; - do { - Arrays.MemMove(this.decode_mem[c], N, 0, 2048 - N + overlap / 2); - } while (++c < CC); - short[] collapse_masks = new short[C * nbEBands]; - int[][] X = Arrays.InitTwoDimensionalArrayInt(C, N); - BoxedValueInt boxed_rng = new BoxedValueInt(this.rng); - Bands.quant_all_bands(0, mode, start, end, X[0], C == 2 ? X[1] : null, collapse_masks, null, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, len * 64 - anti_collapse_rsv, balance, dec, LM, codedBands, boxed_rng); - this.rng = boxed_rng.Val; - if (anti_collapse_rsv > 0) { - anti_collapse_on = dec.dec_bits(1); - } - QuantizeBands.unquant_energy_finalise(mode, start, end, oldBandE, fine_quant, fine_priority, len * 8 - dec.tell(), dec, C); - if (anti_collapse_on != 0) { - Bands.anti_collapse(mode, X, collapse_masks, LM, C, N, start, end, oldBandE, oldLogE, oldLogE2, pulses, this.rng); - } - if (silence != 0) { - for (i = 0; i < C * nbEBands; ++i) { - oldBandE[i] = -28672; - } - } - CeltCommon.celt_synthesis(mode, X, out_syn, out_syn_ptrs, oldBandE, start, effEnd, C, CC, isTransient, LM, this.downsample, silence); - c = 0; - do { - this.postfilter_period = Inlines.IMAX(this.postfilter_period, 15); - this.postfilter_period_old = Inlines.IMAX(this.postfilter_period_old, 15); - CeltCommon.comb_filter(out_syn[c], out_syn_ptrs[c], out_syn[c], out_syn_ptrs[c], this.postfilter_period_old, this.postfilter_period, mode.shortMdctSize, this.postfilter_gain_old, this.postfilter_gain, this.postfilter_tapset_old, this.postfilter_tapset, mode.window, overlap); - if (LM == 0) continue; - CeltCommon.comb_filter(out_syn[c], out_syn_ptrs[c] + mode.shortMdctSize, out_syn[c], out_syn_ptrs[c] + mode.shortMdctSize, this.postfilter_period, postfilter_pitch, N - mode.shortMdctSize, this.postfilter_gain, postfilter_gain, this.postfilter_tapset, postfilter_tapset, mode.window, overlap); - } while (++c < CC); - this.postfilter_period_old = this.postfilter_period; - this.postfilter_gain_old = this.postfilter_gain; - this.postfilter_tapset_old = this.postfilter_tapset; - this.postfilter_period = postfilter_pitch; - this.postfilter_gain = postfilter_gain; - this.postfilter_tapset = postfilter_tapset; - if (LM != 0) { - this.postfilter_period_old = this.postfilter_period; - this.postfilter_gain_old = this.postfilter_gain; - this.postfilter_tapset_old = this.postfilter_tapset; - } - if (C == 1) { - System.arraycopy(oldBandE, 0, oldBandE, nbEBands, nbEBands); - } - if (isTransient == 0) { - System.arraycopy(oldLogE, 0, oldLogE2, 0, 2 * nbEBands); - System.arraycopy(oldBandE, 0, oldLogE, 0, 2 * nbEBands); - int max_background_increase = this.loss_count < 10 ? M * 1 : 1024; - for (i = 0; i < 2 * nbEBands; ++i) { - backgroundLogE[i] = Inlines.MIN16(backgroundLogE[i] + max_background_increase, oldBandE[i]); - } - } else { - for (i = 0; i < 2 * nbEBands; ++i) { - oldLogE[i] = Inlines.MIN16(oldLogE[i], oldBandE[i]); - } - } - c = 0; - do { - for (i = 0; i < start; ++i) { - oldBandE[c * nbEBands + i] = 0; - oldLogE2[c * nbEBands + i] = -28672; - oldLogE[c * nbEBands + i] = -28672; - } - for (i = end; i < nbEBands; ++i) { - oldBandE[c * nbEBands + i] = 0; - oldLogE2[c * nbEBands + i] = -28672; - oldLogE[c * nbEBands + i] = -28672; - } - } while (++c < 2); - this.rng = (int)dec.rng; - CeltCommon.deemphasis(out_syn, out_syn_ptrs, pcm, pcm_ptr, N, CC, this.downsample, mode.preemph, this.preemph_memD, accum); - this.loss_count = 0; - if (dec.tell() > 8 * len) { - return OpusError.OPUS_INTERNAL_ERROR; - } - if (dec.get_error() != 0) { - this.error = 1; - } - return frame_size / this.downsample; - } - - void SetStartBand(int value) { - if (value < 0 || value >= this.mode.nbEBands) { - throw new IllegalArgumentException("Start band above max number of ebands (or negative)"); - } - this.start = value; - } - - void SetEndBand(int value) { - if (value < 1 || value > this.mode.nbEBands) { - throw new IllegalArgumentException("End band above max number of ebands (or less than 1)"); - } - this.end = value; - } - - void SetChannels(int value) { - if (value < 1 || value > 2) { - throw new IllegalArgumentException("Channel count must be 1 or 2"); - } - this.stream_channels = value; - } - - int GetAndClearError() { - int returnVal = this.error; - this.error = 0; - return returnVal; - } - - public int GetLookahead() { - return this.overlap / this.downsample; - } - - public int GetPitch() { - return this.postfilter_period; - } - - public CeltMode GetMode() { - return this.mode; - } - - public void SetSignalling(int value) { - this.signalling = value; - } - - public int GetFinalRange() { - return this.rng; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltEncoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltEncoder.java deleted file mode 100644 index d91ddde..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltEncoder.java +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.AnalysisInfo; -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Bands; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltCommon; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusFramesize; -import de.maxhenkel.voicechat.concentus.Pitch; -import de.maxhenkel.voicechat.concentus.QuantizeBands; -import de.maxhenkel.voicechat.concentus.Rate; - -class CeltEncoder { - CeltMode mode = null; - int channels = 0; - int stream_channels = 0; - int force_intra = 0; - int clip = 0; - int disable_pf = 0; - int complexity = 0; - int upsample = 0; - int start = 0; - int end = 0; - int bitrate = 0; - int vbr = 0; - int signalling = 0; - int constrained_vbr = 0; - int loss_rate = 0; - int lsb_depth = 0; - OpusFramesize variable_duration = OpusFramesize.OPUS_FRAMESIZE_UNKNOWN; - int lfe = 0; - int rng = 0; - int spread_decision = 0; - int delayedIntra = 0; - int tonal_average = 0; - int lastCodedBands = 0; - int hf_average = 0; - int tapset_decision = 0; - int prefilter_period = 0; - int prefilter_gain = 0; - int prefilter_tapset = 0; - int consec_transient = 0; - AnalysisInfo analysis = new AnalysisInfo(); - final int[] preemph_memE = new int[2]; - final int[] preemph_memD = new int[2]; - int vbr_reservoir = 0; - int vbr_drift = 0; - int vbr_offset = 0; - int vbr_count = 0; - int overlap_max = 0; - int stereo_saving = 0; - int intensity = 0; - int[] energy_mask = null; - int spec_avg = 0; - int[][] in_mem = null; - int[][] prefilter_mem = null; - int[][] oldBandE = null; - int[][] oldLogE = null; - int[][] oldLogE2 = null; - - CeltEncoder() { - } - - private void Reset() { - this.mode = null; - this.channels = 0; - this.stream_channels = 0; - this.force_intra = 0; - this.clip = 0; - this.disable_pf = 0; - this.complexity = 0; - this.upsample = 0; - this.start = 0; - this.end = 0; - this.bitrate = 0; - this.vbr = 0; - this.signalling = 0; - this.constrained_vbr = 0; - this.loss_rate = 0; - this.lsb_depth = 0; - this.variable_duration = OpusFramesize.OPUS_FRAMESIZE_UNKNOWN; - this.lfe = 0; - this.PartialReset(); - } - - private void PartialReset() { - this.rng = 0; - this.spread_decision = 0; - this.delayedIntra = 0; - this.tonal_average = 0; - this.lastCodedBands = 0; - this.hf_average = 0; - this.tapset_decision = 0; - this.prefilter_period = 0; - this.prefilter_gain = 0; - this.prefilter_tapset = 0; - this.consec_transient = 0; - this.analysis.Reset(); - this.preemph_memE[0] = 0; - this.preemph_memE[1] = 0; - this.preemph_memD[0] = 0; - this.preemph_memD[1] = 0; - this.vbr_reservoir = 0; - this.vbr_drift = 0; - this.vbr_offset = 0; - this.vbr_count = 0; - this.overlap_max = 0; - this.stereo_saving = 0; - this.intensity = 0; - this.energy_mask = null; - this.spec_avg = 0; - this.in_mem = null; - this.prefilter_mem = null; - this.oldBandE = null; - this.oldLogE = null; - this.oldLogE2 = null; - } - - void ResetState() { - int i; - this.PartialReset(); - this.in_mem = Arrays.InitTwoDimensionalArrayInt(this.channels, this.mode.overlap); - this.prefilter_mem = Arrays.InitTwoDimensionalArrayInt(this.channels, 1024); - this.oldBandE = Arrays.InitTwoDimensionalArrayInt(this.channels, this.mode.nbEBands); - this.oldLogE = Arrays.InitTwoDimensionalArrayInt(this.channels, this.mode.nbEBands); - this.oldLogE2 = Arrays.InitTwoDimensionalArrayInt(this.channels, this.mode.nbEBands); - for (i = 0; i < this.mode.nbEBands; ++i) { - this.oldLogE2[0][i] = -28672; - this.oldLogE[0][i] = -28672; - } - if (this.channels == 2) { - for (i = 0; i < this.mode.nbEBands; ++i) { - this.oldLogE2[1][i] = -28672; - this.oldLogE[1][i] = -28672; - } - } - this.vbr_offset = 0; - this.delayedIntra = 1; - this.spread_decision = 2; - this.tonal_average = 256; - this.hf_average = 0; - this.tapset_decision = 0; - } - - int opus_custom_encoder_init_arch(CeltMode mode, int channels) { - if (channels < 0 || channels > 2) { - return OpusError.OPUS_BAD_ARG; - } - if (this == null || mode == null) { - return OpusError.OPUS_ALLOC_FAIL; - } - this.Reset(); - this.mode = mode; - this.stream_channels = this.channels = channels; - this.upsample = 1; - this.start = 0; - this.end = this.mode.effEBands; - this.signalling = 1; - this.constrained_vbr = 1; - this.clip = 1; - this.bitrate = -1; - this.vbr = 0; - this.force_intra = 0; - this.complexity = 5; - this.lsb_depth = 24; - this.ResetState(); - return OpusError.OPUS_OK; - } - - int celt_encoder_init(int sampling_rate, int channels) { - int ret = this.opus_custom_encoder_init_arch(CeltMode.mode48000_960_120, channels); - if (ret != OpusError.OPUS_OK) { - return ret; - } - this.upsample = CeltCommon.resampling_factor(sampling_rate); - return OpusError.OPUS_OK; - } - - int run_prefilter(int[][] input, int[][] prefilter_mem, int CC, int N, int prefilter_tapset, BoxedValueInt pitch, BoxedValueInt gain, BoxedValueInt qgain, int enabled, int nbAvailableBytes) { - int qg; - int pf_on; - int gain1; - int[][] pre = new int[CC][]; - BoxedValueInt pitch_index = new BoxedValueInt(0); - CeltMode mode = this.mode; - int overlap = mode.overlap; - for (int z = 0; z < CC; ++z) { - pre[z] = new int[N + 1024]; - } - int c = 0; - do { - System.arraycopy(prefilter_mem[c], 0, pre[c], 0, 1024); - System.arraycopy(input[c], overlap, pre[c], 1024, N); - } while (++c < CC); - if (enabled != 0) { - int[] pitch_buf = new int[1024 + N >> 1]; - Pitch.pitch_downsample(pre, pitch_buf, 1024 + N, CC); - Pitch.pitch_search(pitch_buf, 512, pitch_buf, N, 979, pitch_index); - pitch_index.Val = 1024 - pitch_index.Val; - gain1 = Pitch.remove_doubling(pitch_buf, 1024, 15, N, pitch_index, this.prefilter_period, this.prefilter_gain); - if (pitch_index.Val > 1022) { - pitch_index.Val = 1022; - } - gain1 = Inlines.MULT16_16_Q15(22938, gain1); - if (this.loss_rate > 2) { - gain1 = Inlines.HALF32(gain1); - } - if (this.loss_rate > 4) { - gain1 = Inlines.HALF32(gain1); - } - if (this.loss_rate > 8) { - gain1 = 0; - } - } else { - gain1 = 0; - pitch_index.Val = 15; - } - int pf_threshold = 6554; - if (Inlines.abs(pitch_index.Val - this.prefilter_period) * 10 > pitch_index.Val) { - pf_threshold += 6554; - } - if (nbAvailableBytes < 25) { - pf_threshold += 3277; - } - if (nbAvailableBytes < 35) { - pf_threshold += 3277; - } - if (this.prefilter_gain > 13107) { - pf_threshold -= 3277; - } - if (this.prefilter_gain > 18022) { - pf_threshold -= 3277; - } - if (gain1 < (pf_threshold = Inlines.MAX16(pf_threshold, 6554))) { - gain1 = 0; - pf_on = 0; - qg = 0; - } else { - if (Inlines.ABS32(gain1 - this.prefilter_gain) < 3277) { - gain1 = this.prefilter_gain; - } - qg = (gain1 + 1536 >> 10) / 3 - 1; - qg = Inlines.IMAX(0, Inlines.IMIN(7, qg)); - gain1 = 3072 * (qg + 1); - pf_on = 1; - } - c = 0; - do { - int offset = mode.shortMdctSize - overlap; - this.prefilter_period = Inlines.IMAX(this.prefilter_period, 15); - System.arraycopy(this.in_mem[c], 0, input[c], 0, overlap); - if (offset != 0) { - CeltCommon.comb_filter(input[c], overlap, pre[c], 1024, this.prefilter_period, this.prefilter_period, offset, -this.prefilter_gain, -this.prefilter_gain, this.prefilter_tapset, this.prefilter_tapset, null, 0); - } - CeltCommon.comb_filter(input[c], overlap + offset, pre[c], 1024 + offset, this.prefilter_period, pitch_index.Val, N - offset, -this.prefilter_gain, -gain1, this.prefilter_tapset, prefilter_tapset, mode.window, overlap); - System.arraycopy(input[c], N, this.in_mem[c], 0, overlap); - if (N > 1024) { - System.arraycopy(pre[c], N, prefilter_mem[c], 0, 1024); - continue; - } - Arrays.MemMove(prefilter_mem[c], N, 0, 1024 - N); - System.arraycopy(pre[c], 1024, prefilter_mem[c], 1024 - N, N); - } while (++c < CC); - gain.Val = gain1; - pitch.Val = pitch_index.Val; - qgain.Val = qg; - return pf_on; - } - - int celt_encode_with_ec(short[] pcm, int pcm_ptr, int frame_size, byte[] compressed, int compressed_ptr, int nbCompressedBytes, EntropyCoder enc) { - int tf_sum; - int tf_select; - int i; - int vbr_bound; - int max_allowed; - int effectiveBytes; - int vbr_rate; - int nbFilledBytes; - int tell; - int LM; - int shortBlocks = 0; - int isTransient = 0; - int CC = this.channels; - int C = this.stream_channels; - int pitch_index = 15; - int gain1 = 0; - int dual_stereo = 0; - int prefilter_tapset = 0; - int anti_collapse_on = 0; - int silence = 0; - int tf_chan = 0; - int pitch_change = 0; - boolean transient_got_disabled = false; - int surround_masking = 0; - int temporal_vbr = 0; - int surround_trim = 0; - int equiv_rate = 510000; - CeltMode mode = this.mode; - int nbEBands = mode.nbEBands; - int overlap = mode.overlap; - short[] eBands = mode.eBands; - int start = this.start; - int end = this.end; - int tf_estimate = 0; - if (nbCompressedBytes < 2 || pcm == null) { - return OpusError.OPUS_BAD_ARG; - } - frame_size *= this.upsample; - for (LM = 0; LM <= mode.maxLM && mode.shortMdctSize << LM != frame_size; ++LM) { - } - if (LM > mode.maxLM) { - return OpusError.OPUS_BAD_ARG; - } - int M = 1 << LM; - int N = M * mode.shortMdctSize; - if (enc == null) { - tell = 1; - nbFilledBytes = 0; - } else { - tell = enc.tell(); - nbFilledBytes = tell + 4 >> 3; - } - Inlines.OpusAssert(this.signalling == 0); - nbCompressedBytes = Inlines.IMIN(nbCompressedBytes, 1275); - int nbAvailableBytes = nbCompressedBytes - nbFilledBytes; - if (this.vbr != 0 && this.bitrate != -1) { - int den = mode.Fs >> 3; - vbr_rate = (this.bitrate * frame_size + (den >> 1)) / den; - effectiveBytes = vbr_rate >> 6; - } else { - vbr_rate = 0; - int tmp = this.bitrate * frame_size; - if (tell > 1) { - tmp += tell; - } - if (this.bitrate != -1) { - nbCompressedBytes = Inlines.IMAX(2, Inlines.IMIN(nbCompressedBytes, (tmp + 4 * mode.Fs) / (8 * mode.Fs) - (this.signalling != 0 ? 1 : 0))); - } - effectiveBytes = nbCompressedBytes; - } - if (this.bitrate != -1) { - equiv_rate = this.bitrate - (40 * C + 20) * ((400 >> LM) - 50); - } - if (enc == null) { - enc = new EntropyCoder(); - enc.enc_init(compressed, compressed_ptr, nbCompressedBytes); - } - if (vbr_rate > 0 && this.constrained_vbr != 0 && (max_allowed = Inlines.IMIN(Inlines.IMAX(tell == 1 ? 2 : 0, vbr_rate + (vbr_bound = vbr_rate) - this.vbr_reservoir >> 6), nbAvailableBytes)) < nbAvailableBytes) { - nbCompressedBytes = nbFilledBytes + max_allowed; - nbAvailableBytes = max_allowed; - enc.enc_shrink(nbCompressedBytes); - } - int total_bits = nbCompressedBytes * 8; - int effEnd = end; - if (effEnd > mode.effEBands) { - effEnd = mode.effEBands; - } - int[][] input = Arrays.InitTwoDimensionalArrayInt(CC, N + overlap); - int sample_max = Inlines.MAX32(this.overlap_max, Inlines.celt_maxabs32(pcm, pcm_ptr, C * (N - overlap) / this.upsample)); - this.overlap_max = Inlines.celt_maxabs32(pcm, pcm_ptr + C * (N - overlap) / this.upsample, C * overlap / this.upsample); - int n = silence = (sample_max = Inlines.MAX32(sample_max, this.overlap_max)) == 0 ? 1 : 0; - if (tell == 1) { - enc.enc_bit_logp(silence, 15); - } else { - silence = 0; - } - if (silence != 0) { - if (vbr_rate > 0) { - effectiveBytes = nbCompressedBytes = Inlines.IMIN(nbCompressedBytes, nbFilledBytes + 2); - total_bits = nbCompressedBytes * 8; - nbAvailableBytes = 2; - enc.enc_shrink(nbCompressedBytes); - } - tell = nbCompressedBytes * 8; - enc.nbits_total += tell - enc.tell(); - } - int c = 0; - BoxedValueInt boxed_memE = new BoxedValueInt(0); - do { - int need_clip = 0; - boxed_memE.Val = this.preemph_memE[c]; - CeltCommon.celt_preemphasis(pcm, pcm_ptr + c, input[c], overlap, N, CC, this.upsample, mode.preemph, boxed_memE, need_clip); - this.preemph_memE[c] = boxed_memE.Val; - } while (++c < CC); - int enabled = (this.lfe != 0 && nbAvailableBytes > 3 || nbAvailableBytes > 12 * C) && start == 0 && silence == 0 && this.disable_pf == 0 && this.complexity >= 5 && (this.consec_transient == 0 || LM == 3 || this.variable_duration != OpusFramesize.OPUS_FRAMESIZE_VARIABLE) ? 1 : 0; - prefilter_tapset = this.tapset_decision; - BoxedValueInt boxed_pitch_index = new BoxedValueInt(0); - BoxedValueInt boxed_gain1 = new BoxedValueInt(0); - BoxedValueInt boxed_qg = new BoxedValueInt(0); - int pf_on = this.run_prefilter(input, this.prefilter_mem, CC, N, prefilter_tapset, boxed_pitch_index, boxed_gain1, boxed_qg, enabled, nbAvailableBytes); - pitch_index = boxed_pitch_index.Val; - gain1 = boxed_gain1.Val; - int qg = boxed_qg.Val; - if (!(gain1 <= 13107 && this.prefilter_gain <= 13107 || this.analysis.valid != 0 && !((double)this.analysis.tonality > 0.3) || !((double)pitch_index > 1.26 * (double)this.prefilter_period) && !((double)pitch_index < 0.79 * (double)this.prefilter_period))) { - pitch_change = 1; - } - if (pf_on == 0) { - if (start == 0 && tell + 16 <= total_bits) { - enc.enc_bit_logp(0, 1); - } - } else { - enc.enc_bit_logp(1, 1); - int octave = Inlines.EC_ILOG(++pitch_index) - 5; - enc.enc_uint(octave, 6L); - enc.enc_bits(pitch_index - (16 << octave), 4 + octave); - --pitch_index; - enc.enc_bits(qg, 3); - enc.enc_icdf(prefilter_tapset, CeltTables.tapset_icdf, 2); - } - isTransient = 0; - shortBlocks = 0; - if (this.complexity >= 1 && this.lfe == 0) { - BoxedValueInt boxed_tf_estimate = new BoxedValueInt(0); - BoxedValueInt boxed_tf_chan = new BoxedValueInt(0); - isTransient = CeltCommon.transient_analysis(input, N + overlap, CC, boxed_tf_estimate, boxed_tf_chan); - tf_estimate = boxed_tf_estimate.Val; - tf_chan = boxed_tf_chan.Val; - } - if (LM > 0 && enc.tell() + 3 <= total_bits) { - if (isTransient != 0) { - shortBlocks = M; - } - } else { - isTransient = 0; - transient_got_disabled = true; - } - int[][] freq = Arrays.InitTwoDimensionalArrayInt(CC, N); - int[][] bandE = Arrays.InitTwoDimensionalArrayInt(CC, nbEBands); - int[][] bandLogE = Arrays.InitTwoDimensionalArrayInt(CC, nbEBands); - boolean secondMdct = shortBlocks != 0 && this.complexity >= 8; - int[][] bandLogE2 = Arrays.InitTwoDimensionalArrayInt(CC, nbEBands); - if (secondMdct) { - CeltCommon.compute_mdcts(mode, 0, input, freq, C, CC, LM, this.upsample); - Bands.compute_band_energies(mode, freq, bandE, effEnd, C, LM); - QuantizeBands.amp2Log2(mode, effEnd, end, bandE, bandLogE2, C); - i = 0; - while (i < nbEBands) { - int[] nArray = bandLogE2[0]; - int n2 = i++; - nArray[n2] = nArray[n2] + Inlines.HALF16(Inlines.SHL16(LM, 10)); - } - if (C == 2) { - i = 0; - while (i < nbEBands) { - int[] nArray = bandLogE2[1]; - int n3 = i++; - nArray[n3] = nArray[n3] + Inlines.HALF16(Inlines.SHL16(LM, 10)); - } - } - } - CeltCommon.compute_mdcts(mode, shortBlocks, input, freq, C, CC, LM, this.upsample); - if (CC == 2 && C == 1) { - tf_chan = 0; - } - Bands.compute_band_energies(mode, freq, bandE, effEnd, C, LM); - if (this.lfe != 0) { - for (i = 2; i < end; ++i) { - bandE[0][i] = Inlines.IMIN(bandE[0][i], Inlines.MULT16_32_Q15((short)3, bandE[0][0])); - bandE[0][i] = Inlines.MAX32(bandE[0][i], 1); - } - } - QuantizeBands.amp2Log2(mode, effEnd, end, bandE, bandLogE, C); - int[] surround_dynalloc = new int[C * nbEBands]; - if (start == 0 && this.energy_mask != null && this.lfe == 0) { - int mask_avg = 0; - int diff = 0; - int count = 0; - int mask_end = Inlines.IMAX(2, this.lastCodedBands); - for (c = 0; c < C; ++c) { - for (i = 0; i < mask_end; ++i) { - int mask = Inlines.MAX16(Inlines.MIN16(this.energy_mask[nbEBands * c + i], 256), -2048); - if (mask > 0) { - mask = Inlines.HALF16(mask); - } - mask_avg += Inlines.MULT16_16(mask, eBands[i + 1] - eBands[i]); - count += eBands[i + 1] - eBands[i]; - diff += Inlines.MULT16_16(mask, 1 + 2 * i - mask_end); - } - } - Inlines.OpusAssert(count > 0); - mask_avg = Inlines.DIV32_16(mask_avg, count); - mask_avg += 205; - diff = diff * 6 / (C * (mask_end - 1) * (mask_end + 1) * mask_end); - diff = Inlines.HALF32(diff); - diff = Inlines.MAX32(Inlines.MIN32(diff, 32), -32); - int midband = 0; - while (eBands[midband + 1] < eBands[mask_end] / 2) { - ++midband; - } - int count_dynalloc = 0; - for (i = 0; i < mask_end; ++i) { - int lin = mask_avg + diff * (i - midband); - int unmask = C == 2 ? Inlines.MAX16(this.energy_mask[i], this.energy_mask[nbEBands + i]) : this.energy_mask[i]; - unmask = Inlines.MIN16(unmask, 0); - if ((unmask -= lin) <= 256) continue; - surround_dynalloc[i] = unmask - 256; - ++count_dynalloc; - } - if (count_dynalloc >= 3) { - if ((mask_avg += 256) > 0) { - mask_avg = 0; - diff = 0; - Arrays.MemSet(surround_dynalloc, 0, mask_end); - } else { - for (i = 0; i < mask_end; ++i) { - surround_dynalloc[i] = Inlines.MAX16(0, surround_dynalloc[i] - 256); - } - } - } - surround_trim = 64 * diff; - surround_masking = mask_avg += 205; - } - if (this.lfe == 0) { - int follow = -10240; - int frame_avg = 0; - int offset = shortBlocks != 0 ? Inlines.HALF16(Inlines.SHL16(LM, 10)) : 0; - for (i = start; i < end; ++i) { - follow = Inlines.MAX16(follow - 1024, bandLogE[0][i] - offset); - if (C == 2) { - follow = Inlines.MAX16(follow, bandLogE[1][i] - offset); - } - frame_avg += follow; - } - temporal_vbr = Inlines.SUB16(frame_avg /= end - start, this.spec_avg); - temporal_vbr = Inlines.MIN16(3072, Inlines.MAX16(-1536, temporal_vbr)); - this.spec_avg += (short)Inlines.MULT16_16_Q15(655, temporal_vbr); - } - if (!secondMdct) { - System.arraycopy(bandLogE[0], 0, bandLogE2[0], 0, nbEBands); - if (C == 2) { - System.arraycopy(bandLogE[1], 0, bandLogE2[1], 0, nbEBands); - } - } - if (LM > 0 && enc.tell() + 3 <= total_bits && isTransient == 0 && this.complexity >= 5 && this.lfe == 0 && CeltCommon.patch_transient_decision(bandLogE, this.oldBandE, nbEBands, start, end, C) != 0) { - isTransient = 1; - shortBlocks = M; - CeltCommon.compute_mdcts(mode, shortBlocks, input, freq, C, CC, LM, this.upsample); - Bands.compute_band_energies(mode, freq, bandE, effEnd, C, LM); - QuantizeBands.amp2Log2(mode, effEnd, end, bandE, bandLogE, C); - i = 0; - while (i < nbEBands) { - int[] nArray = bandLogE2[0]; - int n4 = i++; - nArray[n4] = nArray[n4] + Inlines.HALF16(Inlines.SHL16(LM, 10)); - } - if (C == 2) { - i = 0; - while (i < nbEBands) { - int[] nArray = bandLogE2[1]; - int n5 = i++; - nArray[n5] = nArray[n5] + Inlines.HALF16(Inlines.SHL16(LM, 10)); - } - } - tf_estimate = 3277; - } - if (LM > 0 && enc.tell() + 3 <= total_bits) { - enc.enc_bit_logp(isTransient, 3); - } - int[][] X = Arrays.InitTwoDimensionalArrayInt(C, N); - Bands.normalise_bands(mode, freq, X, bandE, effEnd, C, M); - int[] tf_res = new int[nbEBands]; - if (effectiveBytes >= 15 * C && start == 0 && this.complexity >= 2 && this.lfe == 0) { - int lambda = effectiveBytes < 40 ? 12 : (effectiveBytes < 60 ? 6 : (effectiveBytes < 100 ? 4 : 3)); - BoxedValueInt boxed_tf_sum = new BoxedValueInt(0); - tf_select = CeltCommon.tf_analysis(mode, effEnd, isTransient, tf_res, lambda *= 2, X, N, LM, boxed_tf_sum, tf_estimate, tf_chan); - tf_sum = boxed_tf_sum.Val; - for (i = effEnd; i < end; ++i) { - tf_res[i] = tf_res[effEnd - 1]; - } - } else { - tf_sum = 0; - for (i = 0; i < end; ++i) { - tf_res[i] = isTransient; - } - tf_select = 0; - } - int[][] error = Arrays.InitTwoDimensionalArrayInt(C, nbEBands); - BoxedValueInt boxed_delayedintra = new BoxedValueInt(this.delayedIntra); - QuantizeBands.quant_coarse_energy(mode, start, end, effEnd, bandLogE, this.oldBandE, total_bits, error, enc, C, LM, nbAvailableBytes, this.force_intra, boxed_delayedintra, this.complexity >= 4 ? 1 : 0, this.loss_rate, this.lfe); - this.delayedIntra = boxed_delayedintra.Val; - CeltCommon.tf_encode(start, end, isTransient, tf_res, LM, tf_select, enc); - if (enc.tell() + 4 <= total_bits) { - if (this.lfe != 0) { - this.tapset_decision = 0; - this.spread_decision = 2; - } else if (shortBlocks != 0 || this.complexity < 3 || nbAvailableBytes < 10 * C || start != 0) { - this.spread_decision = this.complexity == 0 ? 0 : 2; - } else { - BoxedValueInt boxed_tonal_average = new BoxedValueInt(this.tonal_average); - BoxedValueInt boxed_tapset_decision = new BoxedValueInt(this.tapset_decision); - BoxedValueInt boxed_hf_average = new BoxedValueInt(this.hf_average); - this.spread_decision = Bands.spreading_decision(mode, X, boxed_tonal_average, this.spread_decision, boxed_hf_average, boxed_tapset_decision, pf_on != 0 && shortBlocks == 0 ? 1 : 0, effEnd, C, M); - this.tonal_average = boxed_tonal_average.Val; - this.tapset_decision = boxed_tapset_decision.Val; - this.hf_average = boxed_hf_average.Val; - } - enc.enc_icdf(this.spread_decision, CeltTables.spread_icdf, 5); - } - int[] offsets = new int[nbEBands]; - BoxedValueInt boxed_tot_boost = new BoxedValueInt(0); - int maxDepth = CeltCommon.dynalloc_analysis(bandLogE, bandLogE2, nbEBands, start, end, C, offsets, this.lsb_depth, mode.logN, isTransient, this.vbr, this.constrained_vbr, eBands, LM, effectiveBytes, boxed_tot_boost, this.lfe, surround_dynalloc); - int tot_boost = boxed_tot_boost.Val; - if (this.lfe != 0) { - offsets[0] = Inlines.IMIN(8, effectiveBytes / 3); - } - int[] cap = new int[nbEBands]; - CeltCommon.init_caps(mode, cap, LM, C); - int dynalloc_logp = 6; - total_bits <<= 3; - int total_boost = 0; - tell = enc.tell_frac(); - for (i = start; i < end; ++i) { - int width = C * (eBands[i + 1] - eBands[i]) << LM; - int quanta = Inlines.IMIN(width << 3, Inlines.IMAX(48, width)); - int dynalloc_loop_logp = dynalloc_logp; - int boost = 0; - int j = 0; - while (tell + (dynalloc_loop_logp << 3) < total_bits - total_boost && boost < cap[i]) { - int flag = j < offsets[i] ? 1 : 0; - enc.enc_bit_logp(flag, dynalloc_loop_logp); - tell = enc.tell_frac(); - if (flag == 0) break; - boost += quanta; - total_boost += quanta; - dynalloc_loop_logp = 1; - ++j; - } - if (j != 0) { - dynalloc_logp = Inlines.IMAX(2, dynalloc_logp - 1); - } - offsets[i] = boost; - } - if (C == 2) { - if (LM != 0) { - dual_stereo = CeltCommon.stereo_analysis(mode, X, LM); - } - this.intensity = Bands.hysteresis_decision(equiv_rate / 1000, CeltTables.intensity_thresholds, CeltTables.intensity_histeresis, 21, this.intensity); - this.intensity = Inlines.IMIN(end, Inlines.IMAX(start, this.intensity)); - } - int alloc_trim = 5; - if (tell + 48 <= total_bits - total_boost) { - if (this.lfe != 0) { - alloc_trim = 5; - } else { - BoxedValueInt boxed_stereo_saving = new BoxedValueInt(this.stereo_saving); - alloc_trim = CeltCommon.alloc_trim_analysis(mode, X, bandLogE, end, LM, C, this.analysis, boxed_stereo_saving, tf_estimate, this.intensity, surround_trim); - this.stereo_saving = boxed_stereo_saving.Val; - } - enc.enc_icdf(alloc_trim, CeltTables.trim_icdf, 7); - tell = enc.tell_frac(); - } - if (vbr_rate > 0) { - int alpha; - int lm_diff = mode.maxLM - LM; - nbCompressedBytes = Inlines.IMIN(nbCompressedBytes, 1275 >> 3 - LM); - int base_target = vbr_rate - (40 * C + 20 << 3); - if (this.constrained_vbr != 0) { - base_target += this.vbr_offset >> lm_diff; - } - int target = CeltCommon.compute_vbr(mode, this.analysis, base_target, LM, equiv_rate, this.lastCodedBands, C, this.intensity, this.constrained_vbr, this.stereo_saving, tot_boost, tf_estimate, pitch_change, maxDepth, this.variable_duration, this.lfe, this.energy_mask != null ? 1 : 0, surround_masking, temporal_vbr); - int min_allowed = (tell + total_boost + 64 - 1 >> 6) + 2 - nbFilledBytes; - nbAvailableBytes = (target += tell) + 32 >> 6; - nbAvailableBytes = Inlines.IMAX(min_allowed, nbAvailableBytes); - nbAvailableBytes = Inlines.IMIN(nbCompressedBytes, nbAvailableBytes + nbFilledBytes) - nbFilledBytes; - int delta = target - vbr_rate; - target = nbAvailableBytes << 6; - if (silence != 0) { - nbAvailableBytes = 2; - target = 128; - delta = 0; - } - if (this.vbr_count < 970) { - ++this.vbr_count; - alpha = Inlines.celt_rcp(Inlines.SHL32(this.vbr_count + 20, 16)); - } else { - alpha = 33; - } - if (this.constrained_vbr != 0) { - this.vbr_reservoir += target - vbr_rate; - } - if (this.constrained_vbr != 0) { - this.vbr_drift += Inlines.MULT16_32_Q15(alpha, delta * (1 << lm_diff) - this.vbr_offset - this.vbr_drift); - this.vbr_offset = -this.vbr_drift; - } - if (this.constrained_vbr != 0 && this.vbr_reservoir < 0) { - int adjust = -this.vbr_reservoir / 64; - nbAvailableBytes += silence != 0 ? 0 : adjust; - this.vbr_reservoir = 0; - } - nbCompressedBytes = Inlines.IMIN(nbCompressedBytes, nbAvailableBytes + nbFilledBytes); - enc.enc_shrink(nbCompressedBytes); - } - int[] fine_quant = new int[nbEBands]; - int[] pulses = new int[nbEBands]; - int[] fine_priority = new int[nbEBands]; - int bits = (nbCompressedBytes * 8 << 3) - enc.tell_frac() - 1; - int anti_collapse_rsv = isTransient != 0 && LM >= 2 && bits >= LM + 2 << 3 ? 8 : 0; - bits -= anti_collapse_rsv; - int signalBandwidth = end - 1; - if (this.analysis.enabled && this.analysis.valid != 0) { - int min_bandwidth = equiv_rate < 32000 * C ? 13 : (equiv_rate < 48000 * C ? 16 : (equiv_rate < 60000 * C ? 18 : (equiv_rate < 80000 * C ? 19 : 20))); - signalBandwidth = Inlines.IMAX(this.analysis.bandwidth, min_bandwidth); - } - if (this.lfe != 0) { - signalBandwidth = 1; - } - BoxedValueInt boxed_intensity = new BoxedValueInt(this.intensity); - BoxedValueInt boxed_balance = new BoxedValueInt(0); - BoxedValueInt boxed_dual_stereo = new BoxedValueInt(dual_stereo); - int codedBands = Rate.compute_allocation(mode, start, end, offsets, cap, alloc_trim, boxed_intensity, boxed_dual_stereo, bits, boxed_balance, pulses, fine_quant, fine_priority, C, LM, enc, 1, this.lastCodedBands, signalBandwidth); - this.intensity = boxed_intensity.Val; - int balance = boxed_balance.Val; - dual_stereo = boxed_dual_stereo.Val; - this.lastCodedBands = this.lastCodedBands != 0 ? Inlines.IMIN(this.lastCodedBands + 1, Inlines.IMAX(this.lastCodedBands - 1, codedBands)) : codedBands; - QuantizeBands.quant_fine_energy(mode, start, end, this.oldBandE, error, fine_quant, enc, C); - short[] collapse_masks = new short[C * nbEBands]; - BoxedValueInt boxed_rng = new BoxedValueInt(this.rng); - Bands.quant_all_bands(1, mode, start, end, X[0], C == 2 ? X[1] : null, collapse_masks, bandE, pulses, shortBlocks, this.spread_decision, dual_stereo, this.intensity, tf_res, nbCompressedBytes * 64 - anti_collapse_rsv, balance, enc, LM, codedBands, boxed_rng); - this.rng = boxed_rng.Val; - if (anti_collapse_rsv > 0) { - anti_collapse_on = this.consec_transient < 2 ? 1 : 0; - enc.enc_bits(anti_collapse_on, 1); - } - QuantizeBands.quant_energy_finalise(mode, start, end, this.oldBandE, error, fine_quant, fine_priority, nbCompressedBytes * 8 - enc.tell(), enc, C); - if (silence != 0) { - for (i = 0; i < nbEBands; ++i) { - this.oldBandE[0][i] = -28672; - } - if (C == 2) { - for (i = 0; i < nbEBands; ++i) { - this.oldBandE[1][i] = -28672; - } - } - } - this.prefilter_period = pitch_index; - this.prefilter_gain = gain1; - this.prefilter_tapset = prefilter_tapset; - if (CC == 2 && C == 1) { - System.arraycopy(this.oldBandE[0], 0, this.oldBandE[1], 0, nbEBands); - } - if (isTransient == 0) { - System.arraycopy(this.oldLogE[0], 0, this.oldLogE2[0], 0, nbEBands); - System.arraycopy(this.oldBandE[0], 0, this.oldLogE[0], 0, nbEBands); - if (CC == 2) { - System.arraycopy(this.oldLogE[1], 0, this.oldLogE2[1], 0, nbEBands); - System.arraycopy(this.oldBandE[1], 0, this.oldLogE[1], 0, nbEBands); - } - } else { - for (i = 0; i < nbEBands; ++i) { - this.oldLogE[0][i] = Inlines.MIN16(this.oldLogE[0][i], this.oldBandE[0][i]); - } - if (CC == 2) { - for (i = 0; i < nbEBands; ++i) { - this.oldLogE[1][i] = Inlines.MIN16(this.oldLogE[1][i], this.oldBandE[1][i]); - } - } - } - c = 0; - do { - for (i = 0; i < start; ++i) { - this.oldBandE[c][i] = 0; - this.oldLogE2[c][i] = -28672; - this.oldLogE[c][i] = -28672; - } - for (i = end; i < nbEBands; ++i) { - this.oldBandE[c][i] = 0; - this.oldLogE2[c][i] = -28672; - this.oldLogE[c][i] = -28672; - } - } while (++c < CC); - this.consec_transient = isTransient != 0 || transient_got_disabled ? ++this.consec_transient : 0; - this.rng = (int)enc.rng; - enc.enc_done(); - if (enc.get_error() != 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - return nbCompressedBytes; - } - - void SetComplexity(int value) { - if (value < 0 || value > 10) { - throw new IllegalArgumentException("Complexity must be between 0 and 10 inclusive"); - } - this.complexity = value; - } - - void SetStartBand(int value) { - if (value < 0 || value >= this.mode.nbEBands) { - throw new IllegalArgumentException("Start band above max number of ebands (or negative)"); - } - this.start = value; - } - - void SetEndBand(int value) { - if (value < 1 || value > this.mode.nbEBands) { - throw new IllegalArgumentException("End band above max number of ebands (or less than 1)"); - } - this.end = value; - } - - void SetPacketLossPercent(int value) { - if (value < 0 || value > 100) { - throw new IllegalArgumentException("Packet loss must be between 0 and 100"); - } - this.loss_rate = value; - } - - void SetPrediction(int value) { - if (value < 0 || value > 2) { - throw new IllegalArgumentException("CELT prediction mode must be 0, 1, or 2"); - } - this.disable_pf = value <= 1 ? 1 : 0; - this.force_intra = value == 0 ? 1 : 0; - } - - void SetVBRConstraint(boolean value) { - this.constrained_vbr = value ? 1 : 0; - } - - void SetVBR(boolean value) { - this.vbr = value ? 1 : 0; - } - - void SetBitrate(int value) { - if (value <= 500 && value != -1) { - throw new IllegalArgumentException("Bitrate out of range"); - } - this.bitrate = value = Inlines.IMIN(value, 260000 * this.channels); - } - - void SetChannels(int value) { - if (value < 1 || value > 2) { - throw new IllegalArgumentException("Channel count must be 1 or 2"); - } - this.stream_channels = value; - } - - void SetLSBDepth(int value) { - if (value < 8 || value > 24) { - throw new IllegalArgumentException("Bit depth must be between 8 and 24"); - } - this.lsb_depth = value; - } - - int GetLSBDepth() { - return this.lsb_depth; - } - - void SetExpertFrameDuration(OpusFramesize value) { - this.variable_duration = value; - } - - void SetSignalling(int value) { - this.signalling = value; - } - - void SetAnalysis(AnalysisInfo value) { - if (value == null) { - throw new IllegalArgumentException("AnalysisInfo"); - } - this.analysis.Assign(value); - } - - CeltMode GetMode() { - return this.mode; - } - - int GetFinalRange() { - return this.rng; - } - - void SetLFE(int value) { - this.lfe = value; - } - - void SetEnergyMask(int[] value) { - this.energy_mask = value; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltLPC.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltLPC.java deleted file mode 100644 index fbd180e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltLPC.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; - -class CeltLPC { - CeltLPC() { - } - - static void celt_lpc(int[] _lpc, int[] ac, int p) { - int i; - int error = ac[0]; - int[] lpc = new int[p]; - if (ac[0] != 0) { - for (i = 0; i < p; ++i) { - int j; - int rr = 0; - for (j = 0; j < i; ++j) { - rr += Inlines.MULT32_32_Q31(lpc[j], ac[i - j]); - } - int r = 0 - Inlines.frac_div32(Inlines.SHL32(rr += Inlines.SHR32(ac[i + 1], 3), 3), error); - lpc[i] = Inlines.SHR32(r, 3); - for (j = 0; j < i + 1 >> 1; ++j) { - int tmp1 = lpc[j]; - int tmp2 = lpc[i - 1 - j]; - lpc[j] = tmp1 + Inlines.MULT32_32_Q31(r, tmp2); - lpc[i - 1 - j] = tmp2 + Inlines.MULT32_32_Q31(r, tmp1); - } - if ((error -= Inlines.MULT32_32_Q31(Inlines.MULT32_32_Q31(r, r), error)) < Inlines.SHR32(ac[0], 10)) break; - } - } - for (i = 0; i < p; ++i) { - _lpc[i] = Inlines.ROUND16(lpc[i], 16); - } - } - - static void celt_iir(int[] _x, int _x_ptr, int[] den, int[] _y, int _y_ptr, int N, int ord, int[] mem) { - int i; - int[] rden = new int[ord]; - int[] y = new int[N + ord]; - Inlines.OpusAssert((ord & 3) == 0); - BoxedValueInt _sum0 = new BoxedValueInt(0); - BoxedValueInt _sum1 = new BoxedValueInt(0); - BoxedValueInt _sum2 = new BoxedValueInt(0); - BoxedValueInt _sum3 = new BoxedValueInt(0); - for (i = 0; i < ord; ++i) { - rden[i] = den[ord - i - 1]; - } - for (i = 0; i < ord; ++i) { - y[i] = 0 - mem[ord - i - 1]; - } - while (i < N + ord) { - y[i] = 0; - ++i; - } - for (i = 0; i < N - 3; i += 4) { - _sum0.Val = _x[_x_ptr + i]; - _sum1.Val = _x[_x_ptr + i + 1]; - _sum2.Val = _x[_x_ptr + i + 2]; - _sum3.Val = _x[_x_ptr + i + 3]; - Kernels.xcorr_kernel(rden, y, i, _sum0, _sum1, _sum2, _sum3, ord); - int sum0 = _sum0.Val; - int sum1 = _sum1.Val; - int sum2 = _sum2.Val; - int sum3 = _sum3.Val; - y[i + ord] = 0 - Inlines.ROUND16(sum0, 12); - _y[_y_ptr + i] = sum0; - sum1 = Inlines.MAC16_16(sum1, y[i + ord], den[0]); - y[i + ord + 1] = 0 - Inlines.ROUND16(sum1, 12); - _y[_y_ptr + i + 1] = sum1; - sum2 = Inlines.MAC16_16(sum2, y[i + ord + 1], den[0]); - sum2 = Inlines.MAC16_16(sum2, y[i + ord], den[1]); - y[i + ord + 2] = 0 - Inlines.ROUND16(sum2, 12); - _y[_y_ptr + i + 2] = sum2; - sum3 = Inlines.MAC16_16(sum3, y[i + ord + 2], den[0]); - sum3 = Inlines.MAC16_16(sum3, y[i + ord + 1], den[1]); - sum3 = Inlines.MAC16_16(sum3, y[i + ord], den[2]); - y[i + ord + 3] = 0 - Inlines.ROUND16(sum3, 12); - _y[_y_ptr + i + 3] = sum3; - } - while (i < N) { - int sum = _x[_x_ptr + i]; - for (int j = 0; j < ord; ++j) { - sum -= Inlines.MULT16_16(rden[j], y[i + j]); - } - y[i + ord] = Inlines.ROUND16(sum, 12); - _y[_y_ptr + i] = sum; - ++i; - } - for (i = 0; i < ord; ++i) { - mem[i] = _y[_y_ptr + N - i - 1]; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltMode.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltMode.java deleted file mode 100644 index fdc5261..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltMode.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.FFTState; -import de.maxhenkel.voicechat.concentus.MDCTLookup; -import de.maxhenkel.voicechat.concentus.PulseCache; - -class CeltMode { - int Fs = 0; - int overlap = 0; - int nbEBands = 0; - int effEBands = 0; - int[] preemph = new int[]{0, 0, 0, 0}; - short[] eBands = null; - int maxLM = 0; - int nbShortMdcts = 0; - int shortMdctSize = 0; - int nbAllocVectors = 0; - short[] allocVectors = null; - short[] logN = null; - int[] window = null; - MDCTLookup mdct = new MDCTLookup(); - PulseCache cache = new PulseCache(); - static final CeltMode mode48000_960_120 = new CeltMode(); - - private CeltMode() { - } - - static { - CeltMode.mode48000_960_120.Fs = 48000; - CeltMode.mode48000_960_120.overlap = 120; - CeltMode.mode48000_960_120.nbEBands = 21; - CeltMode.mode48000_960_120.effEBands = 21; - CeltMode.mode48000_960_120.preemph = new int[]{27853, 0, 4096, 8192}; - CeltMode.mode48000_960_120.eBands = CeltTables.eband5ms; - CeltMode.mode48000_960_120.maxLM = 3; - CeltMode.mode48000_960_120.nbShortMdcts = 8; - CeltMode.mode48000_960_120.shortMdctSize = 120; - CeltMode.mode48000_960_120.nbAllocVectors = 11; - CeltMode.mode48000_960_120.allocVectors = CeltTables.band_allocation; - CeltMode.mode48000_960_120.logN = CeltTables.logN400; - CeltMode.mode48000_960_120.window = CeltTables.window120; - CeltMode.mode48000_960_120.mdct = new MDCTLookup(); - CeltMode.mode48000_960_120.mdct.n = 1920; - CeltMode.mode48000_960_120.mdct.maxshift = 3; - CeltMode.mode48000_960_120.mdct.kfft = new FFTState[]{CeltTables.fft_state48000_960_0, CeltTables.fft_state48000_960_1, CeltTables.fft_state48000_960_2, CeltTables.fft_state48000_960_3}; - CeltMode.mode48000_960_120.mdct.trig = CeltTables.mdct_twiddles960; - CeltMode.mode48000_960_120.cache = new PulseCache(); - CeltMode.mode48000_960_120.cache.size = 392; - CeltMode.mode48000_960_120.cache.index = CeltTables.cache_index50; - CeltMode.mode48000_960_120.cache.bits = CeltTables.cache_bits50; - CeltMode.mode48000_960_120.cache.caps = CeltTables.cache_caps50; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltPitchXCorr.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltPitchXCorr.java deleted file mode 100644 index e32c8ee..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltPitchXCorr.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; - -class CeltPitchXCorr { - CeltPitchXCorr() { - } - - static int pitch_xcorr(int[] _x, int[] _y, int[] xcorr, int len, int max_pitch) { - int i; - int maxcorr = 1; - Inlines.OpusAssert(max_pitch > 0); - BoxedValueInt sum0 = new BoxedValueInt(0); - BoxedValueInt sum1 = new BoxedValueInt(0); - BoxedValueInt sum2 = new BoxedValueInt(0); - BoxedValueInt sum3 = new BoxedValueInt(0); - for (i = 0; i < max_pitch - 3; i += 4) { - sum0.Val = 0; - sum1.Val = 0; - sum2.Val = 0; - sum3.Val = 0; - Kernels.xcorr_kernel(_x, _y, i, sum0, sum1, sum2, sum3, len); - xcorr[i] = sum0.Val; - xcorr[i + 1] = sum1.Val; - xcorr[i + 2] = sum2.Val; - xcorr[i + 3] = sum3.Val; - sum0.Val = Inlines.MAX32(sum0.Val, sum1.Val); - sum2.Val = Inlines.MAX32(sum2.Val, sum3.Val); - sum0.Val = Inlines.MAX32(sum0.Val, sum2.Val); - maxcorr = Inlines.MAX32(maxcorr, sum0.Val); - } - while (i < max_pitch) { - int inner_sum; - xcorr[i] = inner_sum = Kernels.celt_inner_prod(_x, 0, _y, i, len); - maxcorr = Inlines.MAX32(maxcorr, inner_sum); - ++i; - } - return maxcorr; - } - - static int pitch_xcorr(short[] _x, int _x_ptr, short[] _y, int _y_ptr, int[] xcorr, int len, int max_pitch) { - int i; - int maxcorr = 1; - Inlines.OpusAssert(max_pitch > 0); - BoxedValueInt sum0 = new BoxedValueInt(0); - BoxedValueInt sum1 = new BoxedValueInt(0); - BoxedValueInt sum2 = new BoxedValueInt(0); - BoxedValueInt sum3 = new BoxedValueInt(0); - for (i = 0; i < max_pitch - 3; i += 4) { - sum0.Val = 0; - sum1.Val = 0; - sum2.Val = 0; - sum3.Val = 0; - Kernels.xcorr_kernel(_x, _x_ptr, _y, _y_ptr + i, sum0, sum1, sum2, sum3, len); - xcorr[i] = sum0.Val; - xcorr[i + 1] = sum1.Val; - xcorr[i + 2] = sum2.Val; - xcorr[i + 3] = sum3.Val; - sum0.Val = Inlines.MAX32(sum0.Val, sum1.Val); - sum2.Val = Inlines.MAX32(sum2.Val, sum3.Val); - sum0.Val = Inlines.MAX32(sum0.Val, sum2.Val); - maxcorr = Inlines.MAX32(maxcorr, sum0.Val); - } - while (i < max_pitch) { - int inner_sum; - xcorr[i] = inner_sum = Kernels.celt_inner_prod(_x, _x_ptr, _y, _y_ptr + i, len); - maxcorr = Inlines.MAX32(maxcorr, inner_sum); - ++i; - } - return maxcorr; - } - - static int pitch_xcorr(short[] _x, short[] _y, int[] xcorr, int len, int max_pitch) { - int i; - int maxcorr = 1; - Inlines.OpusAssert(max_pitch > 0); - BoxedValueInt sum0 = new BoxedValueInt(0); - BoxedValueInt sum1 = new BoxedValueInt(0); - BoxedValueInt sum2 = new BoxedValueInt(0); - BoxedValueInt sum3 = new BoxedValueInt(0); - for (i = 0; i < max_pitch - 3; i += 4) { - sum0.Val = 0; - sum1.Val = 0; - sum2.Val = 0; - sum3.Val = 0; - Kernels.xcorr_kernel(_x, 0, _y, i, sum0, sum1, sum2, sum3, len); - xcorr[i] = sum0.Val; - xcorr[i + 1] = sum1.Val; - xcorr[i + 2] = sum2.Val; - xcorr[i + 3] = sum3.Val; - sum0.Val = Inlines.MAX32(sum0.Val, sum1.Val); - sum2.Val = Inlines.MAX32(sum2.Val, sum3.Val); - sum0.Val = Inlines.MAX32(sum0.Val, sum2.Val); - maxcorr = Inlines.MAX32(maxcorr, sum0.Val); - } - while (i < max_pitch) { - int inner_sum; - xcorr[i] = inner_sum = Kernels.celt_inner_prod(_x, _y, i, len); - maxcorr = Inlines.MAX32(maxcorr, inner_sum); - ++i; - } - return maxcorr; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltTables.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CeltTables.java deleted file mode 100644 index bfa9a09..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CeltTables.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.FFTState; - -class CeltTables { - static final byte[] eMeans = new byte[]{103, 100, 92, 85, 81, 77, 72, 70, 78, 75, 73, 71, 78, 74, 69, 72, 70, 74, 76, 71, 60, 60, 60, 60, 60}; - static final int[] ordery_table = new int[]{1, 0, 3, 0, 2, 1, 7, 0, 4, 3, 6, 1, 5, 2, 15, 0, 8, 7, 12, 3, 11, 4, 14, 1, 9, 6, 13, 2, 10, 5}; - static final short[] eband5ms = new short[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100}; - static final short[][][] e_prob_model = new short[][][]{new short[][]{{72, 127, 65, 129, 66, 128, 65, 128, 64, 128, 62, 128, 64, 128, 64, 128, 92, 78, 92, 79, 92, 78, 90, 79, 116, 41, 115, 40, 114, 40, 132, 26, 132, 26, 145, 17, 161, 12, 176, 10, 177, 11}, {24, 179, 48, 138, 54, 135, 54, 132, 53, 134, 56, 133, 55, 132, 55, 132, 61, 114, 70, 96, 74, 88, 75, 88, 87, 74, 89, 66, 91, 67, 100, 59, 108, 50, 120, 40, 122, 37, 97, 43, 78, 50}}, new short[][]{{83, 78, 84, 81, 88, 75, 86, 74, 87, 71, 90, 73, 93, 74, 93, 74, 109, 40, 114, 36, 117, 34, 117, 34, 143, 17, 145, 18, 146, 19, 162, 12, 165, 10, 178, 7, 189, 6, 190, 8, 177, 9}, {23, 178, 54, 115, 63, 102, 66, 98, 69, 99, 74, 89, 71, 91, 73, 91, 78, 89, 86, 80, 92, 66, 93, 64, 102, 59, 103, 60, 104, 60, 117, 52, 123, 44, 138, 35, 133, 31, 97, 38, 77, 45}}, new short[][]{{61, 90, 93, 60, 105, 42, 107, 41, 110, 45, 116, 38, 113, 38, 112, 38, 124, 26, 132, 27, 136, 19, 140, 20, 155, 14, 159, 16, 158, 18, 170, 13, 177, 10, 187, 8, 192, 6, 175, 9, 159, 10}, {21, 178, 59, 110, 71, 86, 75, 85, 84, 83, 91, 66, 88, 73, 87, 72, 92, 75, 98, 72, 105, 58, 107, 54, 115, 52, 114, 55, 112, 56, 129, 51, 132, 40, 150, 33, 140, 29, 98, 35, 77, 42}}, new short[][]{{42, 121, 96, 66, 108, 43, 111, 40, 117, 44, 123, 32, 120, 36, 119, 33, 127, 33, 134, 34, 139, 21, 147, 23, 152, 20, 158, 25, 154, 26, 166, 21, 173, 16, 184, 13, 184, 10, 150, 13, 139, 15}, {22, 178, 63, 114, 74, 82, 84, 83, 92, 82, 103, 62, 96, 72, 96, 67, 101, 73, 107, 72, 113, 55, 118, 52, 125, 52, 118, 52, 117, 55, 135, 49, 137, 39, 157, 32, 145, 29, 97, 33, 77, 40}}}; - static final byte[][] tf_select_table = new byte[][]{{0, -1, 0, -1, 0, -1, 0, -1}, {0, -1, 0, -2, 1, 0, 1, -1}, {0, -2, 0, -3, 2, 0, 1, -1}, {0, -2, 0, -3, 3, 0, 1, -1}}; - static final short[] trim_icdf = new short[]{126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0}; - static final short[] spread_icdf = new short[]{25, 23, 2, 0}; - static final short[] tapset_icdf = new short[]{2, 1, 0}; - static final short[] band_allocation = new short[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 80, 75, 69, 63, 56, 49, 40, 34, 29, 20, 18, 10, 0, 0, 0, 0, 0, 0, 0, 0, 110, 100, 90, 84, 78, 71, 65, 58, 51, 45, 39, 32, 26, 20, 12, 0, 0, 0, 0, 0, 0, 118, 110, 103, 93, 86, 80, 75, 70, 65, 59, 53, 47, 40, 31, 23, 15, 4, 0, 0, 0, 0, 126, 119, 112, 104, 95, 89, 83, 78, 72, 66, 60, 54, 47, 39, 32, 25, 17, 12, 1, 0, 0, 134, 127, 120, 114, 103, 97, 91, 85, 78, 72, 66, 60, 54, 47, 41, 35, 29, 23, 16, 10, 1, 144, 137, 130, 124, 113, 107, 101, 95, 88, 82, 76, 70, 64, 57, 51, 45, 39, 33, 26, 15, 1, 152, 145, 138, 132, 123, 117, 111, 105, 98, 92, 86, 80, 74, 67, 61, 55, 49, 43, 36, 20, 1, 162, 155, 148, 142, 133, 127, 121, 115, 108, 102, 96, 90, 84, 77, 71, 65, 59, 53, 46, 30, 1, 172, 165, 158, 152, 143, 137, 131, 125, 118, 112, 106, 100, 94, 87, 81, 75, 69, 63, 56, 45, 20, 200, 200, 200, 200, 200, 200, 200, 200, 198, 193, 188, 183, 178, 173, 168, 163, 158, 153, 148, 129, 104}; - static final long[] CELT_PVQ_U_DATA = new long[]{1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 5L, 7L, 9L, 11L, 13L, 15L, 17L, 19L, 21L, 23L, 25L, 27L, 29L, 31L, 33L, 35L, 37L, 39L, 41L, 43L, 45L, 47L, 49L, 51L, 53L, 55L, 57L, 59L, 61L, 63L, 65L, 67L, 69L, 71L, 73L, 75L, 77L, 79L, 81L, 83L, 85L, 87L, 89L, 91L, 93L, 95L, 97L, 99L, 101L, 103L, 105L, 107L, 109L, 111L, 113L, 115L, 117L, 119L, 121L, 123L, 125L, 127L, 129L, 131L, 133L, 135L, 137L, 139L, 141L, 143L, 145L, 147L, 149L, 151L, 153L, 155L, 157L, 159L, 161L, 163L, 165L, 167L, 169L, 171L, 173L, 175L, 177L, 179L, 181L, 183L, 185L, 187L, 189L, 191L, 193L, 195L, 197L, 199L, 201L, 203L, 205L, 207L, 209L, 211L, 213L, 215L, 217L, 219L, 221L, 223L, 225L, 227L, 229L, 231L, 233L, 235L, 237L, 239L, 241L, 243L, 245L, 247L, 249L, 251L, 253L, 255L, 257L, 259L, 261L, 263L, 265L, 267L, 269L, 271L, 273L, 275L, 277L, 279L, 281L, 283L, 285L, 287L, 289L, 291L, 293L, 295L, 297L, 299L, 301L, 303L, 305L, 307L, 309L, 311L, 313L, 315L, 317L, 319L, 321L, 323L, 325L, 327L, 329L, 331L, 333L, 335L, 337L, 339L, 341L, 343L, 345L, 347L, 349L, 351L, 13L, 25L, 41L, 61L, 85L, 113L, 145L, 181L, 221L, 265L, 313L, 365L, 421L, 481L, 545L, 613L, 685L, 761L, 841L, 925L, 1013L, 1105L, 1201L, 1301L, 1405L, 1513L, 1625L, 1741L, 1861L, 1985L, 2113L, 2245L, 2381L, 2521L, 2665L, 2813L, 2965L, 3121L, 3281L, 3445L, 3613L, 3785L, 3961L, 4141L, 4325L, 4513L, 4705L, 4901L, 5101L, 5305L, 5513L, 5725L, 5941L, 6161L, 6385L, 6613L, 6845L, 7081L, 7321L, 7565L, 7813L, 8065L, 8321L, 8581L, 8845L, 9113L, 9385L, 9661L, 9941L, 10225L, 10513L, 10805L, 11101L, 11401L, 11705L, 12013L, 12325L, 12641L, 12961L, 13285L, 13613L, 13945L, 14281L, 14621L, 14965L, 15313L, 15665L, 16021L, 16381L, 16745L, 17113L, 17485L, 17861L, 18241L, 18625L, 19013L, 19405L, 19801L, 20201L, 20605L, 21013L, 21425L, 21841L, 22261L, 22685L, 23113L, 23545L, 23981L, 24421L, 24865L, 25313L, 25765L, 26221L, 26681L, 27145L, 27613L, 28085L, 28561L, 29041L, 29525L, 30013L, 30505L, 31001L, 31501L, 32005L, 32513L, 33025L, 33541L, 34061L, 34585L, 35113L, 35645L, 36181L, 36721L, 37265L, 37813L, 38365L, 38921L, 39481L, 40045L, 40613L, 41185L, 41761L, 42341L, 42925L, 43513L, 44105L, 44701L, 45301L, 45905L, 46513L, 47125L, 47741L, 48361L, 48985L, 49613L, 50245L, 50881L, 51521L, 52165L, 52813L, 53465L, 54121L, 54781L, 55445L, 56113L, 56785L, 57461L, 58141L, 58825L, 59513L, 60205L, 60901L, 61601L, 63L, 129L, 231L, 377L, 575L, 833L, 1159L, 1561L, 2047L, 2625L, 3303L, 4089L, 4991L, 6017L, 7175L, 8473L, 9919L, 11521L, 13287L, 15225L, 17343L, 19649L, 22151L, 24857L, 27775L, 30913L, 34279L, 37881L, 41727L, 45825L, 50183L, 54809L, 59711L, 64897L, 70375L, 76153L, 82239L, 88641L, 95367L, 102425L, 109823L, 117569L, 125671L, 134137L, 142975L, 152193L, 161799L, 171801L, 182207L, 193025L, 204263L, 215929L, 228031L, 240577L, 253575L, 267033L, 280959L, 295361L, 310247L, 325625L, 341503L, 357889L, 374791L, 392217L, 410175L, 428673L, 447719L, 467321L, 487487L, 508225L, 529543L, 551449L, 573951L, 597057L, 620775L, 645113L, 670079L, 695681L, 721927L, 748825L, 776383L, 804609L, 833511L, 863097L, 893375L, 924353L, 956039L, 988441L, 1021567L, 1055425L, 1090023L, 1125369L, 1161471L, 1198337L, 1235975L, 1274393L, 1313599L, 1353601L, 1394407L, 1436025L, 1478463L, 1521729L, 1565831L, 1610777L, 1656575L, 1703233L, 1750759L, 1799161L, 1848447L, 1898625L, 1949703L, 2001689L, 2054591L, 2108417L, 2163175L, 2218873L, 2275519L, 2333121L, 2391687L, 2451225L, 2511743L, 2573249L, 2635751L, 0x292FF9L, 2763775L, 2829313L, 2895879L, 2963481L, 3032127L, 3101825L, 3172583L, 3244409L, 3317311L, 3391297L, 3466375L, 3542553L, 3619839L, 3698241L, 3777767L, 3858425L, 3940223L, 4023169L, 4107271L, 4192537L, 4278975L, 4366593L, 4455399L, 4545401L, 4636607L, 4729025L, 4822663L, 4917529L, 5013631L, 5110977L, 5209575L, 5309433L, 5410559L, 5512961L, 5616647L, 5721625L, 5827903L, 5935489L, 6044391L, 6154617L, 6266175L, 6379073L, 6493319L, 6608921L, 6725887L, 6844225L, 6963943L, 7085049L, 7207551L, 321L, 681L, 1289L, 2241L, 3649L, 5641L, 8361L, 11969L, 16641L, 22569L, 29961L, 39041L, 50049L, 63241L, 78889L, 97281L, 118721L, 143529L, 172041L, 204609L, 241601L, 283401L, 330409L, 383041L, 441729L, 506921L, 579081L, 658689L, 746241L, 842249L, 947241L, 1061761L, 1186369L, 1321641L, 1468169L, 1626561L, 1797441L, 1981449L, 2179241L, 2391489L, 2618881L, 2862121L, 3121929L, 3399041L, 3694209L, 4008201L, 4341801L, 4695809L, 5071041L, 5468329L, 5888521L, 6332481L, 6801089L, 7295241L, 7815849L, 8363841L, 8940161L, 9545769L, 10181641L, 10848769L, 11548161L, 12280841L, 13047849L, 13850241L, 14689089L, 15565481L, 16480521L, 17435329L, 18431041L, 19468809L, 20549801L, 21675201L, 22846209L, 24064041L, 25329929L, 26645121L, 28010881L, 29428489L, 30899241L, 32424449L, 34005441L, 35643561L, 37340169L, 39096641L, 40914369L, 42794761L, 0x2AAAAA9L, 46749249L, 48826241L, 50971689L, 53187081L, 55473921L, 57833729L, 60268041L, 62778409L, 65366401L, 68033601L, 70781609L, 73612041L, 76526529L, 79526721L, 82614281L, 85790889L, 89058241L, 92418049L, 95872041L, 99421961L, 103069569L, 106816641L, 110664969L, 114616361L, 118672641L, 122835649L, 127107241L, 131489289L, 135983681L, 140592321L, 145317129L, 150160041L, 155123009L, 160208001L, 165417001L, 170752009L, 176215041L, 181808129L, 187533321L, 193392681L, 199388289L, 205522241L, 211796649L, 218213641L, 224775361L, 231483969L, 238341641L, 245350569L, 252512961L, 259831041L, 267307049L, 274943241L, 282741889L, 290705281L, 298835721L, 307135529L, 315607041L, 324252609L, 333074601L, 342075401L, 351257409L, 360623041L, 370174729L, 379914921L, 389846081L, 399970689L, 410291241L, 420810249L, 431530241L, 442453761L, 453583369L, 464921641L, 476471169L, 488234561L, 500214441L, 512413449L, 524834241L, 537479489L, 550351881L, 563454121L, 576788929L, 590359041L, 604167209L, 618216201L, 632508801L, 1683L, 3653L, 7183L, 13073L, 22363L, 36365L, 56695L, 85305L, 124515L, 177045L, 246047L, 335137L, 448427L, 590557L, 766727L, 982729L, 1244979L, 1560549L, 1937199L, 2383409L, 2908411L, 3522221L, 4235671L, 5060441L, 6009091L, 7095093L, 8332863L, 9737793L, 11326283L, 13115773L, 15124775L, 17372905L, 19880915L, 22670725L, 25765455L, 29189457L, 32968347L, 37129037L, 41699767L, 46710137L, 52191139L, 58175189L, 64696159L, 71789409L, 79491819L, 87841821L, 96879431L, 106646281L, 117185651L, 128542501L, 140763503L, 153897073L, 167993403L, 183104493L, 199284183L, 216588185L, 235074115L, 254801525L, 275831935L, 298228865L, 322057867L, 347386557L, 374284647L, 402823977L, 433078547L, 465124549L, 499040399L, 534906769L, 572806619L, 612825229L, 655050231L, 699571641L, 746481891L, 795875861L, 847850911L, 902506913L, 959946283L, 1020274013L, 1083597703L, 1150027593L, 1219676595L, 1292660325L, 1369097135L, 1449108145L, 1532817275L, 1620351277L, 1711839767L, 1807415257L, 1907213187L, 2011371957L, 2120032959L, 8989L, 19825L, 40081L, 75517L, 134245L, 227305L, 369305L, 579125L, 880685L, 1303777L, 1884961L, 2668525L, 3707509L, 5064793L, 6814249L, 9041957L, 11847485L, 15345233L, 19665841L, 24957661L, 31388293L, 39146185L, 48442297L, 59511829L, 72616013L, 88043969L, 106114625L, 127178701L, 151620757L, 179861305L, 212358985L, 249612805L, 292164445L, 340600625L, 395555537L, 457713341L, 527810725L, 606639529L, 695049433L, 793950709L, 904317037L, 1027188385L, 1163673953L, 1314955181L, 1482288821L, 1667010073L, 1870535785L, 2094367717L, 48639L, 108545L, 224143L, 433905L, 795455L, 1392065L, 2340495L, 3800305L, 5984767L, 9173505L, 13726991L, 20103025L, 28875327L, 40754369L, 56610575L, 77500017L, 104692735L, 139703809L, 184327311L, 240673265L, 311207743L, 398796225L, 506750351L, 638878193L, 799538175L, 993696769L, 1226990095L, 1505789553L, 1837271615L, 2229491905L, 265729L, 598417L, 1256465L, 2485825L, 4673345L, 8405905L, 14546705L, 24331777L, 39490049L, 62390545L, 96220561L, 145198913L, 214828609L, 312193553L, 446304145L, 628496897L, 872893441L, 1196924561L, 1621925137L, 2173806145L, 1462563L, 3317445L, 7059735L, 14218905L, 27298155L, 50250765L, 89129247L, 152951073L, 254831667L, 413442773L, 654862247L, 1014889769L, 1541911931L, 2300409629L, 3375210671L, 8097453L, 18474633L, 39753273L, 81270333L, 158819253L, 298199265L, 540279585L, 948062325L, 1616336765L, 45046719L, 103274625L, 224298231L, 464387817L, 921406335L, 1759885185L, 3248227095L, 251595969L, 579168825L, 1267854873L, 2653649025L, 1409933619L}; - static final int[] window120 = new int[]{2, 20, 55, 108, 178, 266, 372, 494, 635, 792, 966, 1157, 1365, 1590, 1831, 2089, 2362, 2651, 2956, 3276, 3611, 3961, 4325, 4703, 5094, 5499, 5916, 6346, 6788, 7241, 7705, 8179, 8663, 9156, 9657, 10167, 10684, 11207, 11736, 12271, 12810, 13353, 13899, 14447, 14997, 15547, 16098, 16648, 17197, 17744, 18287, 18827, 19363, 19893, 20418, 20936, 21447, 21950, 22445, 22931, 23407, 23874, 24330, 24774, 25208, 25629, 26039, 26435, 26819, 27190, 27548, 27893, 28224, 28541, 28845, 29135, 29411, 29674, 29924, 30160, 30384, 30594, 30792, 30977, 31151, 31313, 31463, 31602, 31731, 31849, 31958, 32057, 32148, 32229, 32303, 32370, 32429, 32481, 32528, 32568, 32604, 32634, 32661, 32683, 32701, 32717, 32729, 32740, 32748, 32754, 32758, 32762, 32764, 32766, Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE}; - static final short[] logN400 = new short[]{0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36}; - static final short[] cache_index50 = new short[]{-1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, 318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387}; - static final short[] cache_bits50 = new short[]{40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, 94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, 97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, 153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, 166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, 74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, 228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, 106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, 182, 234}; - static final short[] cache_caps50 = new short[]{224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, 178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, 240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, 160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, 138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, 204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, 185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, 207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, 188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, 204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, 140, 66, 40}; - static final short[] fft_twiddles48000_960 = new short[]{Short.MAX_VALUE, 0, 32766, -429, 32757, -858, 32743, -1287, 32724, -1715, 32698, -2143, 32667, -2570, 32631, -2998, 32588, -3425, 32541, -3851, 32488, -4277, 32429, -4701, 32364, -5125, 32295, -5548, 32219, -5971, 32138, -6393, 32051, -6813, 31960, -7231, 31863, -7650, 31760, -8067, 31652, -8481, 31539, -8895, 31419, -9306, 31294, -9716, 31165, -10126, 31030, -10532, 30889, -10937, 30743, -11340, 30592, -11741, 30436, -12141, 30274, -12540, 30107, -12935, 29936, -13328, 29758, -13718, 29577, -14107, 29390, -14493, 29197, -14875, 29000, -15257, 28797, -15635, 28590, -16010, 28379, -16384, 28162, -16753, 27940, -17119, 27714, -17484, 27482, -17845, 27246, -18205, 27006, -18560, 26760, -18911, 26510, -19260, 26257, -19606, 25997, -19947, 25734, -20286, 25466, -20621, 25194, -20952, 24918, -21281, 24637, -21605, 24353, -21926, 24063, -22242, 23770, -22555, 23473, -22865, 23171, -23171, 22866, -23472, 22557, -23769, 22244, -24063, 21927, -24352, 21606, -24636, 21282, -24917, 20954, -25194, 20622, -25465, 20288, -25733, 19949, -25997, 19607, -26255, 19261, -26509, 18914, -26760, 18561, -27004, 18205, -27246, 17846, -27481, 17485, -27713, 17122, -27940, 16755, -28162, 16385, -28378, 16012, -28590, 15636, -28797, 15258, -28999, 14878, -29197, 14494, -29389, 14108, -29576, 13720, -29757, 13329, -29934, 12937, -30107, 12540, -30274, 12142, -30435, 11744, -30592, 11342, -30743, 10939, -30889, 10534, -31030, 10127, -31164, 9718, -31294, 9307, -31418, 8895, -31537, 8482, -31652, 8067, -31759, 7650, -31862, 7233, -31960, 6815, -32051, 6393, -32138, 5973, -32219, 5549, -32294, 5127, -32364, 4703, -32429, 4278, -32487, 3852, -32541, 3426, -32588, 2999, -32630, 2572, -32667, 2144, -32698, 1716, -32724, 1287, -32742, 860, -32757, 430, -32766, 0, -32767, -429, -32766, -858, -32757, -1287, -32743, -1715, -32724, -2143, -32698, -2570, -32667, -2998, -32631, -3425, -32588, -3851, -32541, -4277, -32488, -4701, -32429, -5125, -32364, -5548, -32295, -5971, -32219, -6393, -32138, -6813, -32051, -7231, -31960, -7650, -31863, -8067, -31760, -8481, -31652, -8895, -31539, -9306, -31419, -9716, -31294, -10126, -31165, -10532, -31030, -10937, -30889, -11340, -30743, -11741, -30592, -12141, -30436, -12540, -30274, -12935, -30107, -13328, -29936, -13718, -29758, -14107, -29577, -14493, -29390, -14875, -29197, -15257, -29000, -15635, -28797, -16010, -28590, -16384, -28379, -16753, -28162, -17119, -27940, -17484, -27714, -17845, -27482, -18205, -27246, -18560, -27006, -18911, -26760, -19260, -26510, -19606, -26257, -19947, -25997, -20286, -25734, -20621, -25466, -20952, -25194, -21281, -24918, -21605, -24637, -21926, -24353, -22242, -24063, -22555, -23770, -22865, -23473, -23171, -23171, -23472, -22866, -23769, -22557, -24063, -22244, -24352, -21927, -24636, -21606, -24917, -21282, -25194, -20954, -25465, -20622, -25733, -20288, -25997, -19949, -26255, -19607, -26509, -19261, -26760, -18914, -27004, -18561, -27246, -18205, -27481, -17846, -27713, -17485, -27940, -17122, -28162, -16755, -28378, -16385, -28590, -16012, -28797, -15636, -28999, -15258, -29197, -14878, -29389, -14494, -29576, -14108, -29757, -13720, -29934, -13329, -30107, -12937, -30274, -12540, -30435, -12142, -30592, -11744, -30743, -11342, -30889, -10939, -31030, -10534, -31164, -10127, -31294, -9718, -31418, -9307, -31537, -8895, -31652, -8482, -31759, -8067, -31862, -7650, -31960, -7233, -32051, -6815, -32138, -6393, -32219, -5973, -32294, -5549, -32364, -5127, -32429, -4703, -32487, -4278, -32541, -3852, -32588, -3426, -32630, -2999, -32667, -2572, -32698, -2144, -32724, -1716, -32742, -1287, -32757, -860, -32766, -430, -32767, 0, -32766, 429, -32757, 858, -32743, 1287, -32724, 1715, -32698, 2143, -32667, 2570, -32631, 2998, -32588, 3425, -32541, 3851, -32488, 4277, -32429, 4701, -32364, 5125, -32295, 5548, -32219, 5971, -32138, 6393, -32051, 6813, -31960, 7231, -31863, 7650, -31760, 8067, -31652, 8481, -31539, 8895, -31419, 9306, -31294, 9716, -31165, 10126, -31030, 10532, -30889, 10937, -30743, 11340, -30592, 11741, -30436, 12141, -30274, 12540, -30107, 12935, -29936, 13328, -29758, 13718, -29577, 14107, -29390, 14493, -29197, 14875, -29000, 15257, -28797, 15635, -28590, 16010, -28379, 16384, -28162, 16753, -27940, 17119, -27714, 17484, -27482, 17845, -27246, 18205, -27006, 18560, -26760, 18911, -26510, 19260, -26257, 19606, -25997, 19947, -25734, 20286, -25466, 20621, -25194, 20952, -24918, 21281, -24637, 21605, -24353, 21926, -24063, 22242, -23770, 22555, -23473, 22865, -23171, 23171, -22866, 23472, -22557, 23769, -22244, 24063, -21927, 24352, -21606, 24636, -21282, 24917, -20954, 25194, -20622, 25465, -20288, 25733, -19949, 25997, -19607, 26255, -19261, 26509, -18914, 26760, -18561, 27004, -18205, 27246, -17846, 27481, -17485, 27713, -17122, 27940, -16755, 28162, -16385, 28378, -16012, 28590, -15636, 28797, -15258, 28999, -14878, 29197, -14494, 29389, -14108, 29576, -13720, 29757, -13329, 29934, -12937, 30107, -12540, 30274, -12142, 30435, -11744, 30592, -11342, 30743, -10939, 30889, -10534, 31030, -10127, 31164, -9718, 31294, -9307, 31418, -8895, 31537, -8482, 31652, -8067, 31759, -7650, 31862, -7233, 31960, -6815, 32051, -6393, 32138, -5973, 32219, -5549, 32294, -5127, 32364, -4703, 32429, -4278, 32487, -3852, 32541, -3426, 32588, -2999, 32630, -2572, 32667, -2144, 32698, -1716, 32724, -1287, 32742, -860, 32757, -430, 32766, 0, Short.MAX_VALUE, 429, 32766, 858, 32757, 1287, 32743, 1715, 32724, 2143, 32698, 2570, 32667, 2998, 32631, 3425, 32588, 3851, 32541, 4277, 32488, 4701, 32429, 5125, 32364, 5548, 32295, 5971, 32219, 6393, 32138, 6813, 32051, 7231, 31960, 7650, 31863, 8067, 31760, 8481, 31652, 8895, 31539, 9306, 31419, 9716, 31294, 10126, 31165, 10532, 31030, 10937, 30889, 11340, 30743, 11741, 30592, 12141, 30436, 12540, 30274, 12935, 30107, 13328, 29936, 13718, 29758, 14107, 29577, 14493, 29390, 14875, 29197, 15257, 29000, 15635, 28797, 16010, 28590, 16384, 28379, 16753, 28162, 17119, 27940, 17484, 27714, 17845, 27482, 18205, 27246, 18560, 27006, 18911, 26760, 19260, 26510, 19606, 26257, 19947, 25997, 20286, 25734, 20621, 25466, 20952, 25194, 21281, 24918, 21605, 24637, 21926, 24353, 22242, 24063, 22555, 23770, 22865, 23473, 23171, 23171, 23472, 22866, 23769, 22557, 24063, 22244, 24352, 21927, 24636, 21606, 24917, 21282, 25194, 20954, 25465, 20622, 25733, 20288, 25997, 19949, 26255, 19607, 26509, 19261, 26760, 18914, 27004, 18561, 27246, 18205, 27481, 17846, 27713, 17485, 27940, 17122, 28162, 16755, 28378, 16385, 28590, 16012, 28797, 15636, 28999, 15258, 29197, 14878, 29389, 14494, 29576, 14108, 29757, 13720, 29934, 13329, 30107, 12937, 30274, 12540, 30435, 12142, 30592, 11744, 30743, 11342, 30889, 10939, 31030, 10534, 31164, 10127, 31294, 9718, 31418, 9307, 31537, 8895, 31652, 8482, 31759, 8067, 31862, 7650, 31960, 7233, 32051, 6815, 32138, 6393, 32219, 5973, 32294, 5549, 32364, 5127, 32429, 4703, 32487, 4278, 32541, 3852, 32588, 3426, 32630, 2999, 32667, 2572, 32698, 2144, 32724, 1716, 32742, 1287, 32757, 860, 32766, 430}; - static final short[] fft_bitrev480 = new short[]{0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, 24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, 4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, 12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, 20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, 28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, 1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, 9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, 17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, 25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, 5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, 13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, 21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, 29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, 2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, 10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, 18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, 26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, 6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, 14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, 22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, 30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, 3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, 11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, 19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, 27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, 7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, 15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, 23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, 31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479}; - static final short[] fft_bitrev240 = new short[]{0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, 12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, 1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, 5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, 9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, 13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, 2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, 6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, 10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, 14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, 3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, 7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, 11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, 15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239}; - static final short[] fft_bitrev120 = new short[]{0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, 5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, 2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, 6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, 3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, 7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119}; - static final short[] fft_bitrev60 = new short[]{0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, 1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, 2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, 3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59}; - static final FFTState fft_state48000_960_0 = new FFTState(); - static final FFTState fft_state48000_960_1; - static final FFTState fft_state48000_960_2; - static final FFTState fft_state48000_960_3; - static final short[] mdct_twiddles960; - static final int[] intensity_thresholds; - static final int[] intensity_histeresis; - - CeltTables() { - } - - /* - * Opcode count of 26407 triggered aggressive code reduction. Override with --aggressivesizethreshold. - */ - static { - CeltTables.fft_state48000_960_0.nfft = 480; - CeltTables.fft_state48000_960_0.scale = (short)17476; - CeltTables.fft_state48000_960_0.scale_shift = 8; - CeltTables.fft_state48000_960_0.shift = -1; - CeltTables.fft_state48000_960_0.factors = new short[]{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0}; - CeltTables.fft_state48000_960_0.bitrev = fft_bitrev480; - CeltTables.fft_state48000_960_0.twiddles = fft_twiddles48000_960; - fft_state48000_960_1 = new FFTState(); - CeltTables.fft_state48000_960_1.nfft = 240; - CeltTables.fft_state48000_960_1.scale = (short)17476; - CeltTables.fft_state48000_960_1.scale_shift = 7; - CeltTables.fft_state48000_960_1.shift = 1; - CeltTables.fft_state48000_960_1.factors = new short[]{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0}; - CeltTables.fft_state48000_960_1.bitrev = fft_bitrev240; - CeltTables.fft_state48000_960_1.twiddles = fft_twiddles48000_960; - fft_state48000_960_2 = new FFTState(); - CeltTables.fft_state48000_960_2.nfft = 120; - CeltTables.fft_state48000_960_2.scale = (short)17476; - CeltTables.fft_state48000_960_2.scale_shift = 6; - CeltTables.fft_state48000_960_2.shift = 2; - CeltTables.fft_state48000_960_2.factors = new short[]{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0}; - CeltTables.fft_state48000_960_2.bitrev = fft_bitrev120; - CeltTables.fft_state48000_960_2.twiddles = fft_twiddles48000_960; - fft_state48000_960_3 = new FFTState(); - CeltTables.fft_state48000_960_3.nfft = 60; - CeltTables.fft_state48000_960_3.scale = (short)17476; - CeltTables.fft_state48000_960_3.scale_shift = 5; - CeltTables.fft_state48000_960_3.shift = 3; - CeltTables.fft_state48000_960_3.factors = new short[]{5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - CeltTables.fft_state48000_960_3.bitrev = fft_bitrev60; - CeltTables.fft_state48000_960_3.twiddles = fft_twiddles48000_960; - mdct_twiddles960 = new short[]{Short.MAX_VALUE, Short.MAX_VALUE, Short.MAX_VALUE, 32766, 32765, 32763, 32761, 32759, 32756, 32753, 32750, 32746, 32742, 32738, 32733, 32728, 32722, 32717, 32710, 32704, 32697, 32690, 32682, 32674, 32666, 32657, 32648, 32639, 32629, 32619, 32609, 32598, 32587, 32576, 32564, 32552, 32539, 32526, 32513, 32500, 32486, 32472, 32457, 32442, 32427, 32411, 32395, 32379, 32362, 32345, 32328, 32310, 32292, 32274, 32255, 32236, 32217, 32197, 32177, 32157, 32136, 32115, 32093, 32071, 32049, 32027, 32004, 31981, 31957, 31933, 31909, 31884, 31859, 31834, 31809, 31783, 31756, 31730, 31703, 31676, 31648, 31620, 31592, 31563, 31534, 31505, 31475, 31445, 31415, 31384, 31353, 31322, 31290, 31258, 31226, 31193, 31160, 31127, 31093, 31059, 31025, 30990, 30955, 30920, 30884, 30848, 30812, 30775, 30738, 30701, 30663, 30625, 30587, 30548, 30509, 30470, 30430, 30390, 30350, 30309, 30269, 30227, 30186, 30144, 30102, 30059, 30016, 29973, 29930, 29886, 29842, 29797, 29752, 29707, 29662, 29616, 29570, 29524, 29477, 29430, 29383, 29335, 29287, 29239, 29190, 29142, 29092, 29043, 28993, 28943, 28892, 28842, 28791, 28739, 28688, 28636, 28583, 28531, 28478, 28425, 28371, 28317, 28263, 28209, 28154, 28099, 28044, 27988, 27932, 27876, 27820, 27763, 27706, 27648, 27591, 27533, 27474, 27416, 27357, 27298, 27238, 27178, 27118, 27058, 26997, 26936, 26875, 26814, 26752, 26690, 26628, 26565, 26502, 26439, 26375, 26312, 26247, 26183, 26119, 26054, 25988, 25923, 25857, 25791, 25725, 25658, 25592, 25524, 25457, 25389, 25322, 25253, 25185, 25116, 25047, 24978, 24908, 24838, 24768, 24698, 24627, 24557, 24485, 24414, 24342, 24270, 24198, 24126, 24053, 23980, 23907, 23834, 23760, 23686, 23612, 23537, 23462, 23387, 23312, 23237, 23161, 23085, 23009, 22932, 22856, 22779, 22701, 22624, 22546, 22468, 22390, 22312, 22233, 22154, 22075, 21996, 21916, 21836, 21756, 21676, 21595, 21515, 21434, 21352, 21271, 21189, 21107, 21025, 20943, 20860, 20777, 20694, 20611, 20528, 20444, 20360, 20276, 20192, 20107, 20022, 19937, 19852, 19767, 19681, 19595, 19509, 19423, 19336, 19250, 19163, 19076, 18988, 18901, 18813, 18725, 18637, 18549, 18460, 18372, 18283, 18194, 18104, 18015, 17925, 17835, 17745, 17655, 17565, 17474, 17383, 17292, 17201, 17110, 17018, 16927, 16835, 16743, 16650, 16558, 16465, 16372, 16279, 16186, 16093, 15999, 15906, 15812, 15718, 15624, 15529, 15435, 15340, 15245, 15150, 15055, 14960, 14864, 14769, 14673, 14577, 14481, 14385, 14288, 14192, 14095, 13998, 13901, 13804, 13706, 13609, 13511, 13414, 13316, 13218, 13119, 13021, 12923, 12824, 12725, 12626, 12527, 12428, 12329, 12230, 12130, 12030, 11930, 11831, 11730, 11630, 11530, 11430, 11329, 11228, 11128, 11027, 10926, 10824, 10723, 10622, 10520, 10419, 10317, 10215, 10113, 10011, 9909, 9807, 9704, 9602, 9499, 9397, 9294, 9191, 9088, 8985, 8882, 8778, 8675, 8572, 8468, 8364, 8261, 8157, 8053, 7949, 7845, 7741, 7637, 7532, 7428, 7323, 7219, 7114, 7009, 6905, 6800, 6695, 6590, 6485, 6380, 6274, 6169, 6064, 5958, 5853, 5747, 5642, 5536, 5430, 5325, 5219, 5113, 5007, 4901, 4795, 4689, 4583, 4476, 4370, 4264, 4157, 4051, 3945, 3838, 3732, 3625, 3518, 3412, 3305, 3198, 3092, 2985, 2878, 2771, 2664, 2558, 2451, 2344, 2237, 2130, 2023, 1916, 1809, 1702, 1594, 1487, 1380, 1273, 1166, 1059, 952, 844, 737, 630, 523, 416, 308, 201, 94, -13, -121, -228, -335, -442, -550, -657, -764, -871, -978, -1086, -1193, -1300, -1407, -1514, -1621, -1728, -1835, -1942, -2049, -2157, -2263, -2370, -2477, -2584, -2691, -2798, -2905, -3012, -3118, -3225, -3332, -3439, -3545, -3652, -3758, -3865, -3971, -4078, -4184, -4290, -4397, -4503, -4609, -4715, -4821, -4927, -5033, -5139, -5245, -5351, -5457, -5562, -5668, -5774, -5879, -5985, -6090, -6195, -6301, -6406, -6511, -6616, -6721, -6826, -6931, -7036, -7140, -7245, -7349, -7454, -7558, -7663, -7767, -7871, -7975, -8079, -8183, -8287, -8390, -8494, -8597, -8701, -8804, -8907, -9011, -9114, -9217, -9319, -9422, -9525, -9627, -9730, -9832, -9934, -10037, -10139, -10241, -10342, -10444, -10546, -10647, -10748, -10850, -10951, -11052, -11153, -11253, -11354, -11455, -11555, -11655, -11756, -11856, -11955, -12055, -12155, -12254, -12354, -12453, -12552, -12651, -12750, -12849, -12947, -13046, -13144, -13242, -13340, -13438, -13536, -13633, -13731, -13828, -13925, -14022, -14119, -14216, -14312, -14409, -14505, -14601, -14697, -14793, -14888, -14984, -15079, -15174, -15269, -15364, -15459, -15553, -15647, -15741, -15835, -15929, -16023, -16116, -16210, -16303, -16396, -16488, -16581, -16673, -16766, -16858, -16949, -17041, -17133, -17224, -17315, -17406, -17497, -17587, -17678, -17768, -17858, -17948, -18037, -18127, -18216, -18305, -18394, -18483, -18571, -18659, -18747, -18835, -18923, -19010, -19098, -19185, -19271, -19358, -19444, -19531, -19617, -19702, -19788, -19873, -19959, -20043, -20128, -20213, -20297, -20381, -20465, -20549, -20632, -20715, -20798, -20881, -20963, -21046, -21128, -21210, -21291, -21373, -21454, -21535, -21616, -21696, -21776, -21856, -21936, -22016, -22095, -22174, -22253, -22331, -22410, -22488, -22566, -22643, -22721, -22798, -22875, -22951, -23028, -23104, -23180, -23256, -23331, -23406, -23481, -23556, -23630, -23704, -23778, -23852, -23925, -23998, -24071, -24144, -24216, -24288, -24360, -24432, -24503, -24574, -24645, -24716, -24786, -24856, -24926, -24995, -25064, -25133, -25202, -25270, -25339, -25406, -25474, -25541, -25608, -25675, -25742, -25808, -25874, -25939, -26005, -26070, -26135, -26199, -26264, -26327, -26391, -26455, -26518, -26581, -26643, -26705, -26767, -26829, -26891, -26952, -27013, -27073, -27133, -27193, -27253, -27312, -27372, -27430, -27489, -27547, -27605, -27663, -27720, -27777, -27834, -27890, -27946, -28002, -28058, -28113, -28168, -28223, -28277, -28331, -28385, -28438, -28491, -28544, -28596, -28649, -28701, -28752, -28803, -28854, -28905, -28955, -29006, -29055, -29105, -29154, -29203, -29251, -29299, -29347, -29395, -29442, -29489, -29535, -29582, -29628, -29673, -29719, -29764, -29808, -29853, -29897, -29941, -29984, -30027, -30070, -30112, -30154, -30196, -30238, -30279, -30320, -30360, -30400, -30440, -30480, -30519, -30558, -30596, -30635, -30672, -30710, -30747, -30784, -30821, -30857, -30893, -30929, -30964, -30999, -31033, -31068, -31102, -31135, -31168, -31201, -31234, -31266, -31298, -31330, -31361, -31392, -31422, -31453, -31483, -31512, -31541, -31570, -31599, -31627, -31655, -31682, -31710, -31737, -31763, -31789, -31815, -31841, -31866, -31891, -31915, -31939, -31963, -31986, -32010, -32032, -32055, -32077, -32099, -32120, -32141, -32162, -32182, -32202, -32222, -32241, -32260, -32279, -32297, -32315, -32333, -32350, -32367, -32383, -32399, -32415, -32431, -32446, -32461, -32475, -32489, -32503, -32517, -32530, -32542, -32555, -32567, -32579, -32590, -32601, -32612, -32622, -32632, -32641, -32651, -32659, -32668, -32676, -32684, -32692, -32699, -32706, -32712, -32718, -32724, -32729, -32734, -32739, -32743, -32747, -32751, -32754, -32757, -32760, -32762, -32764, -32765, -32767, -32767, -32767, Short.MAX_VALUE, Short.MAX_VALUE, 32765, 32761, 32756, 32750, 32742, 32732, 32722, 32710, 32696, 32681, 32665, 32647, 32628, 32608, 32586, 32562, 32538, 32512, 32484, 32455, 32425, 32393, 32360, 32326, 32290, 32253, 32214, 32174, 32133, 32090, 32046, 32001, 31954, 31906, 31856, 31805, 31753, 31700, 31645, 31588, 31530, 31471, 31411, 31349, 31286, 31222, 31156, 31089, 31020, 30951, 30880, 30807, 30733, 30658, 30582, 30504, 30425, 30345, 30263, 30181, 30096, 30011, 29924, 29836, 29747, 29656, 29564, 29471, 29377, 29281, 29184, 29086, 28987, 28886, 28784, 28681, 28577, 28471, 28365, 28257, 28147, 28037, 27925, 27812, 27698, 27583, 27467, 27349, 27231, 27111, 26990, 26868, 26744, 26620, 26494, 26367, 26239, 26110, 25980, 25849, 25717, 25583, 25449, 25313, 25176, 25038, 24900, 24760, 24619, 24477, 24333, 24189, 24044, 23898, 23751, 23602, 23453, 23303, 23152, 22999, 22846, 22692, 22537, 22380, 22223, 22065, 21906, 21746, 21585, 21423, 21261, 21097, 20933, 20767, 20601, 20434, 20265, 20096, 19927, 19756, 19584, 19412, 19239, 19065, 18890, 18714, 18538, 18361, 18183, 18004, 17824, 17644, 17463, 17281, 17098, 16915, 16731, 16546, 16361, 16175, 15988, 15800, 15612, 15423, 15234, 15043, 14852, 14661, 14469, 14276, 14083, 13889, 13694, 13499, 13303, 13107, 12910, 12713, 12515, 12317, 12118, 11918, 11718, 11517, 11316, 11115, 10913, 10710, 10508, 10304, 10100, 9896, 9691, 9486, 9281, 9075, 8869, 8662, 8455, 8248, 8040, 7832, 7623, 7415, 7206, 6996, 6787, 6577, 6366, 6156, 5945, 5734, 5523, 5311, 5100, 4888, 4675, 4463, 4251, 4038, 3825, 3612, 3399, 3185, 2972, 2758, 2544, 2330, 2116, 1902, 1688, 1474, 1260, 1045, 831, 617, 402, 188, -27, -241, -456, -670, -885, -1099, -1313, -1528, -1742, -1956, -2170, -2384, -2598, -2811, -3025, -3239, -3452, -3665, -3878, -4091, -4304, -4516, -4728, -4941, -5153, -5364, -5576, -5787, -5998, -6209, -6419, -6629, -6839, -7049, -7258, -7467, -7676, -7884, -8092, -8300, -8507, -8714, -8920, -9127, -9332, -9538, -9743, -9947, -10151, -10355, -10558, -10761, -10963, -11165, -11367, -11568, -11768, -11968, -12167, -12366, -12565, -12762, -12960, -13156, -13352, -13548, -13743, -13937, -14131, -14324, -14517, -14709, -14900, -15091, -15281, -15470, -15659, -15847, -16035, -16221, -16407, -16593, -16777, -16961, -17144, -17326, -17508, -17689, -17869, -18049, -18227, -18405, -18582, -18758, -18934, -19108, -19282, -19455, -19627, -19799, -19969, -20139, -20308, -20475, -20642, -20809, -20974, -21138, -21301, -21464, -21626, -21786, -21946, -22105, -22263, -22420, -22575, -22730, -22884, -23037, -23189, -23340, -23490, -23640, -23788, -23935, -24080, -24225, -24369, -24512, -24654, -24795, -24934, -25073, -25211, -25347, -25482, -25617, -25750, -25882, -26013, -26143, -26272, -26399, -26526, -26651, -26775, -26898, -27020, -27141, -27260, -27379, -27496, -27612, -27727, -27841, -27953, -28065, -28175, -28284, -28391, -28498, -28603, -28707, -28810, -28911, -29012, -29111, -29209, -29305, -29401, -29495, -29587, -29679, -29769, -29858, -29946, -30032, -30118, -30201, -30284, -30365, -30445, -30524, -30601, -30677, -30752, -30825, -30897, -30968, -31038, -31106, -31172, -31238, -31302, -31365, -31426, -31486, -31545, -31602, -31658, -31713, -31766, -31818, -31869, -31918, -31966, -32012, -32058, -32101, -32144, -32185, -32224, -32262, -32299, -32335, -32369, -32401, -32433, -32463, -32491, -32518, -32544, -32568, -32591, -32613, -32633, -32652, -32669, -32685, -32700, -32713, -32724, -32735, -32744, -32751, -32757, -32762, -32766, -32767, Short.MAX_VALUE, 32764, 32755, 32741, 32720, 32694, 32663, 32626, 32583, 32535, 32481, 32421, 32356, 32286, 32209, 32128, 32041, 31948, 31850, 31747, 31638, 31523, 31403, 31278, 31148, 31012, 30871, 30724, 30572, 30415, 30253, 30086, 29913, 29736, 29553, 29365, 29172, 28974, 28771, 28564, 28351, 28134, 27911, 27684, 27452, 27216, 26975, 26729, 26478, 26223, 25964, 25700, 25432, 25159, 24882, 24601, 24315, 24026, 23732, 23434, 23133, 22827, 22517, 22204, 21886, 21565, 21240, 20912, 20580, 20244, 19905, 19563, 19217, 18868, 18516, 18160, 17802, 17440, 17075, 16708, 16338, 15964, 15588, 15210, 14829, 14445, 14059, 13670, 13279, 12886, 12490, 12093, 11693, 11291, 10888, 10482, 10075, 9666, 9255, 8843, 8429, 8014, 7597, 7180, 6760, 6340, 5919, 5496, 5073, 4649, 4224, 3798, 3372, 2945, 2517, 2090, 1661, 1233, 804, 375, -54, -483, -911, -1340, -1768, -2197, -2624, -3052, -3479, -3905, -4330, -4755, -5179, -5602, -6024, -6445, -6865, -7284, -7702, -8118, -8533, -8946, -9358, -9768, -10177, -10584, -10989, -11392, -11793, -12192, -12589, -12984, -13377, -13767, -14155, -14541, -14924, -15305, -15683, -16058, -16430, -16800, -17167, -17531, -17892, -18249, -18604, -18956, -19304, -19649, -19990, -20329, -20663, -20994, -21322, -21646, -21966, -22282, -22595, -22904, -23208, -23509, -23806, -24099, -24387, -24672, -24952, -25228, -25499, -25766, -26029, -26288, -26541, -26791, -27035, -27275, -27511, -27741, -27967, -28188, -28405, -28616, -28823, -29024, -29221, -29412, -29599, -29780, -29957, -30128, -30294, -30455, -30611, -30761, -30906, -31046, -31181, -31310, -31434, -31552, -31665, -31773, -31875, -31972, -32063, -32149, -32229, -32304, -32373, -32437, -32495, -32547, -32594, -32635, -32671, -32701, -32726, -32745, -32758, -32766, Short.MAX_VALUE, 32754, 32717, 32658, 32577, 32473, 32348, 32200, 32029, 31837, 31624, 31388, 31131, 30853, 30553, 30232, 29891, 29530, 29148, 28746, 28324, 27883, 27423, 26944, 26447, 25931, 25398, 24847, 24279, 23695, 23095, 22478, 21846, 21199, 20538, 19863, 19174, 18472, 17757, 17030, 16291, 15541, 14781, 14010, 13230, 12441, 11643, 10837, 10024, 9204, 8377, 7545, 6708, 5866, 5020, 4171, 3319, 2464, 1608, 751, -107, -965, -1822, -2678, -3532, -4383, -5232, -6077, -6918, -7754, -8585, -9409, -10228, -11039, -11843, -12639, -13426, -14204, -14972, -15730, -16477, -17213, -17937, -18648, -19347, -20033, -20705, -21363, -22006, -22634, -23246, -23843, -24423, -24986, -25533, -26062, -26573, -27066, -27540, -27995, -28431, -28848, -29245, -29622, -29979, -30315, -30630, -30924, -31197, -31449, -31679, -31887, -32074, -32239, -32381, -32501, -32600, -32675, -32729, -32759}; - intensity_thresholds = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 16, 24, 36, 44, 50, 56, 62, 67, 72, 79, 88, 106, 134}; - intensity_histeresis = new int[]{1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 5, 6, 8, 8}; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/ChannelLayout.java b/source/decompiled/de/maxhenkel/voicechat/concentus/ChannelLayout.java deleted file mode 100644 index fe17c8a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/ChannelLayout.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class ChannelLayout { - int nb_channels; - int nb_streams; - int nb_coupled_streams; - final short[] mapping = new short[256]; - - ChannelLayout() { - } - - void Reset() { - this.nb_channels = 0; - this.nb_streams = 0; - this.nb_coupled_streams = 0; - Arrays.MemSet(this.mapping, (short)0); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CodeSigns.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CodeSigns.java deleted file mode 100644 index a358b9f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CodeSigns.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class CodeSigns { - CodeSigns() { - } - - private static int silk_enc_map(int a) { - return Inlines.silk_RSHIFT(a, 15) + 1; - } - - private static int silk_dec_map(int a) { - return Inlines.silk_LSHIFT(a, 1) - 1; - } - - static void silk_encode_signs(EntropyCoder psRangeEnc, byte[] pulses, int length, int signalType, int quantOffsetType, int[] sum_pulses) { - int i; - short[] icdf = new short[2]; - short[] sign_icdf = SilkTables.silk_sign_iCDF; - icdf[1] = 0; - int q_ptr = 0; - int icdf_ptr = i = Inlines.silk_SMULBB(7, Inlines.silk_ADD_LSHIFT(quantOffsetType, signalType, 1)); - length = Inlines.silk_RSHIFT(length + 8, 4); - for (i = 0; i < length; ++i) { - int p = sum_pulses[i]; - if (p > 0) { - icdf[0] = sign_icdf[icdf_ptr + Inlines.silk_min(p & 0x1F, 6)]; - for (int j = q_ptr; j < q_ptr + 16; ++j) { - if (pulses[j] == 0) continue; - psRangeEnc.enc_icdf(CodeSigns.silk_enc_map(pulses[j]), icdf, 8); - } - } - q_ptr += 16; - } - } - - static void silk_decode_signs(EntropyCoder psRangeDec, short[] pulses, int length, int signalType, int quantOffsetType, int[] sum_pulses) { - int i; - short[] icdf = new short[2]; - short[] icdf_table = SilkTables.silk_sign_iCDF; - icdf[1] = 0; - int q_ptr = 0; - int icdf_ptr = i = Inlines.silk_SMULBB(7, Inlines.silk_ADD_LSHIFT(quantOffsetType, signalType, 1)); - length = Inlines.silk_RSHIFT(length + 8, 4); - for (i = 0; i < length; ++i) { - int p = sum_pulses[i]; - if (p > 0) { - icdf[0] = icdf_table[icdf_ptr + Inlines.silk_min(p & 0x1F, 6)]; - for (int j = 0; j < 16; ++j) { - if (pulses[q_ptr + j] <= 0) continue; - int n = q_ptr + j; - pulses[n] = (short)(pulses[n] * (short)CodeSigns.silk_dec_map(psRangeDec.dec_icdf(icdf, 8))); - } - } - q_ptr += 16; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CodecHelpers.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CodecHelpers.java deleted file mode 100644 index 511d358..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CodecHelpers.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Downmix; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusBandwidth; -import de.maxhenkel.voicechat.concentus.OpusBandwidthHelpers; -import de.maxhenkel.voicechat.concentus.OpusFramesize; -import de.maxhenkel.voicechat.concentus.OpusFramesizeHelpers; -import de.maxhenkel.voicechat.concentus.OpusMode; -import de.maxhenkel.voicechat.concentus.StereoWidthState; - -public class CodecHelpers { - private static final int MAX_DYNAMIC_FRAMESIZE = 24; - - static byte gen_toc(OpusMode mode, int framerate, OpusBandwidth bandwidth, int channels) { - int toc; - int period = 0; - while (framerate < 400) { - framerate <<= 1; - ++period; - } - if (mode == OpusMode.MODE_SILK_ONLY) { - toc = (short)(OpusBandwidthHelpers.GetOrdinal(bandwidth) - OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND) << 5); - toc = (short)(toc | (short)(period - 2 << 3)); - } else if (mode == OpusMode.MODE_CELT_ONLY) { - int tmp = OpusBandwidthHelpers.GetOrdinal(bandwidth) - OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND); - if (tmp < 0) { - tmp = 0; - } - toc = 128; - toc = (short)(toc | (short)(tmp << 5)); - toc = (short)(toc | (short)(period << 3)); - } else { - toc = 96; - toc = (short)(toc | (short)(OpusBandwidthHelpers.GetOrdinal(bandwidth) - OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND) << 4)); - toc = (short)(toc | (short)(period - 2 << 3)); - } - toc = (short)(toc | (short)((channels == 2 ? 1 : 0) << 2)); - return (byte)(0xFF & toc); - } - - static void hp_cutoff(short[] input, int input_ptr, int cutoff_Hz, short[] output, int output_ptr, int[] hp_mem, int len, int channels, int Fs) { - int r_Q28; - int[] B_Q28 = new int[3]; - int[] A_Q28 = new int[2]; - Inlines.OpusAssert(cutoff_Hz <= 869074); - int Fc_Q19 = Inlines.silk_DIV32_16(Inlines.silk_SMULBB(2471, cutoff_Hz), Fs / 1000); - Inlines.OpusAssert(Fc_Q19 > 0 && Fc_Q19 < 32768); - B_Q28[0] = r_Q28 = 0x10000000 - Inlines.silk_MUL(471, Fc_Q19); - B_Q28[1] = Inlines.silk_LSHIFT(-r_Q28, 1); - B_Q28[2] = r_Q28; - int r_Q22 = Inlines.silk_RSHIFT(r_Q28, 6); - A_Q28[0] = Inlines.silk_SMULWW(r_Q22, Inlines.silk_SMULWW(Fc_Q19, Fc_Q19) - 0x800000); - A_Q28[1] = Inlines.silk_SMULWW(r_Q22, r_Q22); - Filters.silk_biquad_alt(input, input_ptr, B_Q28, A_Q28, hp_mem, 0, output, output_ptr, len, channels); - if (channels == 2) { - Filters.silk_biquad_alt(input, input_ptr + 1, B_Q28, A_Q28, hp_mem, 2, output, output_ptr + 1, len, channels); - } - } - - static void dc_reject(short[] input, int input_ptr, int cutoff_Hz, short[] output, int output_ptr, int[] hp_mem, int len, int channels, int Fs) { - int shift = Inlines.celt_ilog2(Fs / (cutoff_Hz * 3)); - for (int c = 0; c < channels; ++c) { - for (int i = 0; i < len; ++i) { - int x = Inlines.SHL32(Inlines.EXTEND32(input[channels * i + c + input_ptr]), 15); - int tmp = x - hp_mem[2 * c]; - hp_mem[2 * c] = hp_mem[2 * c] + Inlines.PSHR32(x - hp_mem[2 * c], shift); - int y = tmp - hp_mem[2 * c + 1]; - hp_mem[2 * c + 1] = hp_mem[2 * c + 1] + Inlines.PSHR32(tmp - hp_mem[2 * c + 1], shift); - output[channels * i + c + output_ptr] = Inlines.EXTRACT16(Inlines.SATURATE(Inlines.PSHR32(y, 15), Short.MAX_VALUE)); - } - } - } - - static void stereo_fade(short[] pcm_buf, int g1, int g2, int overlap48, int frame_size, int channels, int[] window, int Fs) { - int diff; - int i; - int inc = 48000 / Fs; - int overlap = overlap48 / inc; - g1 = Short.MAX_VALUE - g1; - g2 = Short.MAX_VALUE - g2; - for (i = 0; i < overlap; ++i) { - int w = Inlines.MULT16_16_Q15(window[i * inc], window[i * inc]); - int g = Inlines.SHR32(Inlines.MAC16_16(Inlines.MULT16_16(w, g2), Short.MAX_VALUE - w, g1), 15); - diff = Inlines.EXTRACT16(Inlines.HALF32(pcm_buf[i * channels] - pcm_buf[i * channels + 1])); - diff = Inlines.MULT16_16_Q15(g, diff); - pcm_buf[i * channels] = (short)(pcm_buf[i * channels] - diff); - pcm_buf[i * channels + 1] = (short)(pcm_buf[i * channels + 1] + diff); - } - while (i < frame_size) { - diff = Inlines.EXTRACT16(Inlines.HALF32(pcm_buf[i * channels] - pcm_buf[i * channels + 1])); - diff = Inlines.MULT16_16_Q15(g2, diff); - pcm_buf[i * channels] = (short)(pcm_buf[i * channels] - diff); - pcm_buf[i * channels + 1] = (short)(pcm_buf[i * channels + 1] + diff); - ++i; - } - } - - static void gain_fade(short[] buffer, int buf_ptr, int g1, int g2, int overlap48, int frame_size, int channels, int[] window, int Fs) { - int g; - int w; - int i; - int inc = 48000 / Fs; - int overlap = overlap48 / inc; - if (channels == 1) { - for (i = 0; i < overlap; ++i) { - w = Inlines.MULT16_16_Q15(window[i * inc], window[i * inc]); - g = Inlines.SHR32(Inlines.MAC16_16(Inlines.MULT16_16(w, g2), Short.MAX_VALUE - w, g1), 15); - buffer[buf_ptr + i] = (short)Inlines.MULT16_16_Q15(g, (int)buffer[buf_ptr + i]); - } - } else { - for (i = 0; i < overlap; ++i) { - w = Inlines.MULT16_16_Q15(window[i * inc], window[i * inc]); - g = Inlines.SHR32(Inlines.MAC16_16(Inlines.MULT16_16(w, g2), Short.MAX_VALUE - w, g1), 15); - buffer[buf_ptr + i * 2] = (short)Inlines.MULT16_16_Q15(g, (int)buffer[buf_ptr + i * 2]); - buffer[buf_ptr + i * 2 + 1] = (short)Inlines.MULT16_16_Q15(g, (int)buffer[buf_ptr + i * 2 + 1]); - } - } - int c = 0; - do { - for (i = overlap; i < frame_size; ++i) { - buffer[buf_ptr + i * channels + c] = (short)Inlines.MULT16_16_Q15(g2, (int)buffer[buf_ptr + i * channels + c]); - } - } while (++c < channels); - } - - static float transient_boost(float[] E, int E_ptr, float[] E_1, int LM, int maxM) { - float sumE = 0.0f; - float sumE_1 = 0.0f; - int M = Inlines.IMIN(maxM, (1 << LM) + 1); - for (int i = E_ptr; i < M + E_ptr; ++i) { - sumE += E[i]; - sumE_1 += E_1[i]; - } - float metric = sumE * sumE_1 / (float)(M * M); - return Inlines.MIN16(1.0f, (float)Math.sqrt(Inlines.MAX16(0.0f, 0.05f * (metric - 2.0f)))); - } - - static int transient_viterbi(float[] E, float[] E_1, int N, int frame_cost, int rate) { - int i; - float[][] cost = Arrays.InitTwoDimensionalArrayFloat(24, 16); - int[][] states = Arrays.InitTwoDimensionalArrayInt(24, 16); - float factor = rate < 80 ? 0.0f : (rate > 160 ? 1.0f : ((float)rate - 80.0f) / 80.0f); - for (i = 0; i < 16; ++i) { - states[0][i] = -1; - cost[0][i] = 1.0E10f; - } - for (i = 0; i < 4; ++i) { - cost[0][1 << i] = (float)(frame_cost + rate * (1 << i)) * (1.0f + factor * CodecHelpers.transient_boost(E, 0, E_1, i, N + 1)); - states[0][1 << i] = i; - } - for (i = 1; i < N; ++i) { - int j; - for (j = 2; j < 16; ++j) { - cost[i][j] = cost[i - 1][j - 1]; - states[i][j] = j - 1; - } - for (j = 0; j < 4; ++j) { - states[i][1 << j] = 1; - float min_cost = cost[i - 1][1]; - for (int k = 1; k < 4; ++k) { - float tmp = cost[i - 1][(1 << k + 1) - 1]; - if (!(tmp < min_cost)) continue; - states[i][1 << j] = (1 << k + 1) - 1; - min_cost = tmp; - } - float curr_cost = (float)(frame_cost + rate * (1 << j)) * (1.0f + factor * CodecHelpers.transient_boost(E, i, E_1, j, N - i + 1)); - cost[i][1 << j] = min_cost; - if (N - i < 1 << j) { - float[] fArray = cost[i]; - int n = 1 << j; - fArray[n] = fArray[n] + curr_cost * (float)(N - i) / (float)(1 << j); - continue; - } - float[] fArray = cost[i]; - int n = 1 << j; - fArray[n] = fArray[n] + curr_cost; - } - } - int best_state = 1; - float best_cost = cost[N - 1][1]; - for (i = 2; i < 16; ++i) { - if (!(cost[N - 1][i] < best_cost)) continue; - best_cost = cost[N - 1][i]; - best_state = i; - } - for (i = N - 1; i >= 0; --i) { - best_state = states[i][best_state]; - } - return best_state; - } - - static int optimize_framesize(short[] x, int x_ptr, int len, int C, int Fs, int bitrate, int tonality, float[] mem, int buffering) { - int i; - int pos; - int offset; - float[] e = new float[28]; - float[] e_1 = new float[27]; - int bestLM = 0; - int subframe = Fs / 400; - int[] sub = new int[subframe]; - e[0] = mem[0]; - e_1[0] = 1.0f / (1.0f + mem[0]); - if (buffering != 0) { - offset = 2 * subframe - buffering; - Inlines.OpusAssert(offset >= 0 && offset <= subframe); - len -= offset; - e[1] = mem[1]; - e_1[1] = 1.0f / (1.0f + mem[1]); - e[2] = mem[2]; - e_1[2] = 1.0f / (1.0f + mem[2]); - pos = 3; - } else { - pos = 1; - offset = 0; - } - int N = Inlines.IMIN(len / subframe, 24); - int memx = 0; - for (i = 0; i < N; ++i) { - float tmp = 1.0f; - Downmix.downmix_int(x, x_ptr, sub, 0, subframe, i * subframe + offset, 0, -2, C); - if (i == 0) { - memx = sub[0]; - } - for (int j = 0; j < subframe; ++j) { - int tmpx = sub[j]; - tmp += (float)(tmpx - memx) * (float)(tmpx - memx); - memx = tmpx; - } - e[i + pos] = tmp; - e_1[i + pos] = 1.0f / tmp; - } - e[i + pos] = e[i + pos - 1]; - if (buffering != 0) { - N = Inlines.IMIN(24, N + 2); - } - bestLM = CodecHelpers.transient_viterbi(e, e_1, N, (int)((1.0f + 0.5f * (float)tonality) * (float)(60 * C + 40)), bitrate / 400); - mem[0] = e[1 << bestLM]; - if (buffering != 0) { - mem[1] = e[(1 << bestLM) + 1]; - mem[2] = e[(1 << bestLM) + 2]; - } - return bestLM; - } - - static int frame_size_select(int frame_size, OpusFramesize variable_duration, int Fs) { - int new_size; - if (frame_size < Fs / 400) { - return -1; - } - if (variable_duration == OpusFramesize.OPUS_FRAMESIZE_ARG) { - new_size = frame_size; - } else if (variable_duration == OpusFramesize.OPUS_FRAMESIZE_VARIABLE) { - new_size = Fs / 50; - } else if (OpusFramesizeHelpers.GetOrdinal(variable_duration) >= OpusFramesizeHelpers.GetOrdinal(OpusFramesize.OPUS_FRAMESIZE_2_5_MS) && OpusFramesizeHelpers.GetOrdinal(variable_duration) <= OpusFramesizeHelpers.GetOrdinal(OpusFramesize.OPUS_FRAMESIZE_60_MS)) { - new_size = Inlines.IMIN(3 * Fs / 50, Fs / 400 << OpusFramesizeHelpers.GetOrdinal(variable_duration) - OpusFramesizeHelpers.GetOrdinal(OpusFramesize.OPUS_FRAMESIZE_2_5_MS)); - } else { - return -1; - } - if (new_size > frame_size) { - return -1; - } - if (400 * new_size != Fs && 200 * new_size != Fs && 100 * new_size != Fs && 50 * new_size != Fs && 25 * new_size != Fs && 50 * new_size != 3 * Fs) { - return -1; - } - return new_size; - } - - static int compute_frame_size(short[] analysis_pcm, int analysis_pcm_ptr, int frame_size, OpusFramesize variable_duration, int C, int Fs, int bitrate_bps, int delay_compensation, float[] subframe_mem, boolean analysis_enabled) { - if (analysis_enabled && variable_duration == OpusFramesize.OPUS_FRAMESIZE_VARIABLE && frame_size >= Fs / 200) { - int LM = 3; - LM = CodecHelpers.optimize_framesize(analysis_pcm, analysis_pcm_ptr, frame_size, C, Fs, bitrate_bps, 0, subframe_mem, delay_compensation); - while (Fs / 400 << LM > frame_size) { - --LM; - } - frame_size = Fs / 400 << LM; - } else { - frame_size = CodecHelpers.frame_size_select(frame_size, variable_duration, Fs); - } - if (frame_size < 0) { - return -1; - } - return frame_size; - } - - static int compute_stereo_width(short[] pcm, int pcm_ptr, int frame_size, int Fs, StereoWidthState mem) { - int frame_rate = Fs / frame_size; - int short_alpha = Short.MAX_VALUE - 819175 / Inlines.IMAX(50, frame_rate); - int yy = 0; - int xy = 0; - int xx = 0; - for (int i = 0; i < frame_size - 3; i += 4) { - int pxx = 0; - int pxy = 0; - int pyy = 0; - int p2i = pcm_ptr + 2 * i; - short x = pcm[p2i]; - short y = pcm[p2i + 1]; - pxx = Inlines.SHR32(Inlines.MULT16_16((int)x, (int)x), 2); - pxy = Inlines.SHR32(Inlines.MULT16_16((int)x, (int)y), 2); - pyy = Inlines.SHR32(Inlines.MULT16_16((int)y, (int)y), 2); - x = pcm[p2i + 2]; - y = pcm[p2i + 3]; - pxx += Inlines.SHR32(Inlines.MULT16_16((int)x, (int)x), 2); - pxy += Inlines.SHR32(Inlines.MULT16_16((int)x, (int)y), 2); - pyy += Inlines.SHR32(Inlines.MULT16_16((int)y, (int)y), 2); - x = pcm[p2i + 4]; - y = pcm[p2i + 5]; - pxx += Inlines.SHR32(Inlines.MULT16_16((int)x, (int)x), 2); - pxy += Inlines.SHR32(Inlines.MULT16_16((int)x, (int)y), 2); - pyy += Inlines.SHR32(Inlines.MULT16_16((int)y, (int)y), 2); - x = pcm[p2i + 6]; - y = pcm[p2i + 7]; - xx += Inlines.SHR32(pxx += Inlines.SHR32(Inlines.MULT16_16((int)x, (int)x), 2), 10); - xy += Inlines.SHR32(pxy += Inlines.SHR32(Inlines.MULT16_16((int)x, (int)y), 2), 10); - yy += Inlines.SHR32(pyy += Inlines.SHR32(Inlines.MULT16_16((int)y, (int)y), 2), 10); - } - mem.XX += Inlines.MULT16_32_Q15(short_alpha, xx - mem.XX); - mem.XY += Inlines.MULT16_32_Q15(short_alpha, xy - mem.XY); - mem.YY += Inlines.MULT16_32_Q15(short_alpha, yy - mem.YY); - mem.XX = Inlines.MAX32(0, mem.XX); - mem.XY = Inlines.MAX32(0, mem.XY); - mem.YY = Inlines.MAX32(0, mem.YY); - if (Inlines.MAX32(mem.XX, mem.YY) > 210) { - int sqrt_xx = Inlines.celt_sqrt(mem.XX); - int sqrt_yy = Inlines.celt_sqrt(mem.YY); - int qrrt_xx = Inlines.celt_sqrt(sqrt_xx); - int qrrt_yy = Inlines.celt_sqrt(sqrt_yy); - mem.XY = Inlines.MIN32(mem.XY, sqrt_xx * sqrt_yy); - int corr = Inlines.SHR32(Inlines.frac_div32(mem.XY, 1 + Inlines.MULT16_16(sqrt_xx, sqrt_yy)), 16); - int ldiff = Short.MAX_VALUE * Inlines.ABS16(qrrt_xx - qrrt_yy) / (1 + qrrt_xx + qrrt_yy); - int width = Inlines.MULT16_16_Q15(Inlines.celt_sqrt(0x40000000 - Inlines.MULT16_16(corr, corr)), ldiff); - mem.smoothed_width += (width - mem.smoothed_width) / frame_rate; - mem.max_follower = Inlines.MAX16(mem.max_follower - 655 / frame_rate, mem.smoothed_width); - } else { - boolean width = false; - int corr = Short.MAX_VALUE; - boolean ldiff = false; - } - return Inlines.EXTRACT16(Inlines.MIN32(Short.MAX_VALUE, 20 * mem.max_follower)); - } - - static void smooth_fade(short[] in1, int in1_ptr, short[] in2, int in2_ptr, short[] output, int output_ptr, int overlap, int channels, int[] window, int Fs) { - int inc = 48000 / Fs; - for (int c = 0; c < channels; ++c) { - for (int i = 0; i < overlap; ++i) { - int w = Inlines.MULT16_16_Q15(window[i * inc], window[i * inc]); - output[output_ptr + i * channels + c] = (short)Inlines.SHR32(Inlines.MAC16_16(Inlines.MULT16_16(w, (int)in2[in2_ptr + i * channels + c]), Short.MAX_VALUE - w, (int)in1[in1_ptr + i * channels + c]), 15); - } - } - } - - public static String opus_strerror(int error) { - String[] error_strings = new String[]{"success", "invalid argument", "buffer too small", "error", "corrupted stream", "request not implemented", "invalid state", "memory allocation failed"}; - if (error > 0 || error < -7) { - return "unknown error"; - } - return error_strings[-error]; - } - - public static String GetVersionString() { - return "concentus 1.0a-java-fixed"; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/CorrelateMatrix.java b/source/decompiled/de/maxhenkel/voicechat/concentus/CorrelateMatrix.java deleted file mode 100644 index ba1197f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/CorrelateMatrix.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class CorrelateMatrix { - CorrelateMatrix() { - } - - static void silk_corrVector(short[] x, int x_ptr, short[] t, int t_ptr, int L, int order, int[] Xt, int rshifts) { - int ptr1 = x_ptr + order - 1; - int ptr2 = t_ptr; - if (rshifts > 0) { - for (int lag = 0; lag < order; ++lag) { - int inner_prod = 0; - for (int i = 0; i < L; ++i) { - inner_prod += Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[ptr1 + i], t[ptr2 + i]), rshifts); - } - Xt[lag] = inner_prod; - --ptr1; - } - } else { - Inlines.OpusAssert(rshifts == 0); - for (int lag = 0; lag < order; ++lag) { - Xt[lag] = Inlines.silk_inner_prod(x, ptr1, t, ptr2, L); - --ptr1; - } - } - } - - static void silk_corrMatrix(short[] x, int x_ptr, int L, int order, int head_room, int[] XX, int XX_ptr, BoxedValueInt rshifts) { - int j; - int i; - BoxedValueInt boxed_energy = new BoxedValueInt(0); - BoxedValueInt boxed_rshifts_local = new BoxedValueInt(0); - SumSqrShift.silk_sum_sqr_shift(boxed_energy, boxed_rshifts_local, x, x_ptr, L + order - 1); - int energy = boxed_energy.Val; - int rshifts_local = boxed_rshifts_local.Val; - int head_room_rshifts = Inlines.silk_max(head_room - Inlines.silk_CLZ32(energy), 0); - energy = Inlines.silk_RSHIFT32(energy, head_room_rshifts); - rshifts_local += head_room_rshifts; - for (i = x_ptr; i < x_ptr + order - 1; ++i) { - energy -= Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[i], x[i]), rshifts_local); - } - if (rshifts_local < rshifts.Val) { - energy = Inlines.silk_RSHIFT32(energy, rshifts.Val - rshifts_local); - rshifts_local = rshifts.Val; - } - Inlines.MatrixSet(XX, XX_ptr, 0, 0, order, energy); - int ptr1 = x_ptr + order - 1; - for (j = 1; j < order; ++j) { - energy = Inlines.silk_SUB32(energy, Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[ptr1 + L - j], x[ptr1 + L - j]), rshifts_local)); - energy = Inlines.silk_ADD32(energy, Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[ptr1 - j], x[ptr1 - j]), rshifts_local)); - Inlines.MatrixSet(XX, XX_ptr, j, j, order, energy); - } - int ptr2 = x_ptr + order - 2; - if (rshifts_local > 0) { - for (int lag = 1; lag < order; ++lag) { - energy = 0; - for (i = 0; i < L; ++i) { - energy += Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[ptr1 + i], x[ptr2 + i]), rshifts_local); - } - Inlines.MatrixSet(XX, XX_ptr, lag, 0, order, energy); - Inlines.MatrixSet(XX, XX_ptr, 0, lag, order, energy); - for (j = 1; j < order - lag; ++j) { - energy = Inlines.silk_SUB32(energy, Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[ptr1 + L - j], x[ptr2 + L - j]), rshifts_local)); - energy = Inlines.silk_ADD32(energy, Inlines.silk_RSHIFT32(Inlines.silk_SMULBB(x[ptr1 - j], x[ptr2 - j]), rshifts_local)); - Inlines.MatrixSet(XX, XX_ptr, lag + j, j, order, energy); - Inlines.MatrixSet(XX, XX_ptr, j, lag + j, order, energy); - } - --ptr2; - } - } else { - for (int lag = 1; lag < order; ++lag) { - energy = Inlines.silk_inner_prod(x, ptr1, x, ptr2, L); - Inlines.MatrixSet(XX, XX_ptr, lag, 0, order, energy); - Inlines.MatrixSet(XX, XX_ptr, 0, lag, order, energy); - for (j = 1; j < order - lag; ++j) { - energy = Inlines.silk_SUB32(energy, Inlines.silk_SMULBB(x[ptr1 + L - j], x[ptr2 + L - j])); - energy = Inlines.silk_SMLABB(energy, x[ptr1 - j], x[ptr2 - j]); - Inlines.MatrixSet(XX, XX_ptr, lag + j, j, order, energy); - Inlines.MatrixSet(XX, XX_ptr, j, lag + j, order, energy); - } - --ptr2; - } - } - rshifts.Val = rshifts_local; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecControlState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecControlState.java deleted file mode 100644 index 048b1bc..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecControlState.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class DecControlState { - int nChannelsAPI = 0; - int nChannelsInternal = 0; - int API_sampleRate = 0; - int internalSampleRate = 0; - int payloadSize_ms = 0; - int prevPitchLag = 0; - - DecControlState() { - } - - void Reset() { - this.nChannelsAPI = 0; - this.nChannelsInternal = 0; - this.API_sampleRate = 0; - this.internalSampleRate = 0; - this.payloadSize_ms = 0; - this.prevPitchLag = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeAPI.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeAPI.java deleted file mode 100644 index ba9205d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeAPI.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.DecControlState; -import de.maxhenkel.voicechat.concentus.DecodeIndices; -import de.maxhenkel.voicechat.concentus.DecodePulses; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Resampler; -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.SilkDecoder; -import de.maxhenkel.voicechat.concentus.SilkError; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.Stereo; - -class DecodeAPI { - DecodeAPI() { - } - - static int silk_InitDecoder(SilkDecoder decState) { - decState.Reset(); - int ret = SilkError.SILK_NO_ERROR; - SilkChannelDecoder[] channel_states = decState.channel_state; - for (int n = 0; n < 2; ++n) { - ret = channel_states[n].silk_init_decoder(); - } - decState.sStereo.Reset(); - decState.prev_decode_only_middle = 0; - return ret; - } - - static int silk_Decode(SilkDecoder psDec, DecControlState decControl, int lostFlag, int newPacketFlag, EntropyCoder psRangeDec, short[] samplesOut, int samplesOut_ptr, BoxedValueInt nSamplesOut) { - int resample_out_ptr; - short[] resample_out; - short[] samplesOut_tmp; - boolean delay_stack_alloc; - int condCoding; - int i; - boolean stereo_to_mono; - int n; - int decode_only_middle = 0; - int ret = SilkError.SILK_NO_ERROR; - BoxedValueInt nSamplesOutDec = new BoxedValueInt(0); - int[] samplesOut_tmp_ptrs = new int[2]; - int[] MS_pred_Q13 = new int[]{0, 0}; - SilkChannelDecoder[] channel_state = psDec.channel_state; - nSamplesOut.Val = 0; - Inlines.OpusAssert(decControl.nChannelsInternal == 1 || decControl.nChannelsInternal == 2); - if (newPacketFlag != 0) { - for (n = 0; n < decControl.nChannelsInternal; ++n) { - channel_state[n].nFramesDecoded = 0; - } - } - if (decControl.nChannelsInternal > psDec.nChannelsInternal) { - ret += channel_state[1].silk_init_decoder(); - } - boolean bl = stereo_to_mono = decControl.nChannelsInternal == 1 && psDec.nChannelsInternal == 2 && decControl.internalSampleRate == 1000 * channel_state[0].fs_kHz; - if (channel_state[0].nFramesDecoded == 0) { - for (n = 0; n < decControl.nChannelsInternal; ++n) { - if (decControl.payloadSize_ms == 0) { - channel_state[n].nFramesPerPacket = 1; - channel_state[n].nb_subfr = 2; - } else if (decControl.payloadSize_ms == 10) { - channel_state[n].nFramesPerPacket = 1; - channel_state[n].nb_subfr = 2; - } else if (decControl.payloadSize_ms == 20) { - channel_state[n].nFramesPerPacket = 1; - channel_state[n].nb_subfr = 4; - } else if (decControl.payloadSize_ms == 40) { - channel_state[n].nFramesPerPacket = 2; - channel_state[n].nb_subfr = 4; - } else if (decControl.payloadSize_ms == 60) { - channel_state[n].nFramesPerPacket = 3; - channel_state[n].nb_subfr = 4; - } else { - Inlines.OpusAssert(false); - return SilkError.SILK_DEC_INVALID_FRAME_SIZE; - } - int fs_kHz_dec = (decControl.internalSampleRate >> 10) + 1; - if (fs_kHz_dec != 8 && fs_kHz_dec != 12 && fs_kHz_dec != 16) { - Inlines.OpusAssert(false); - return SilkError.SILK_DEC_INVALID_SAMPLING_FREQUENCY; - } - ret += channel_state[n].silk_decoder_set_fs(fs_kHz_dec, decControl.API_sampleRate); - } - } - if (decControl.nChannelsAPI == 2 && decControl.nChannelsInternal == 2 && (psDec.nChannelsAPI == 1 || psDec.nChannelsInternal == 1)) { - Arrays.MemSet(psDec.sStereo.pred_prev_Q13, (short)0, 2); - Arrays.MemSet(psDec.sStereo.sSide, (short)0, 2); - channel_state[1].resampler_state.Assign(channel_state[0].resampler_state); - } - psDec.nChannelsAPI = decControl.nChannelsAPI; - psDec.nChannelsInternal = decControl.nChannelsInternal; - if (decControl.API_sampleRate > 48000 || decControl.API_sampleRate < 8000) { - ret = SilkError.SILK_DEC_INVALID_SAMPLING_FREQUENCY; - return ret; - } - if (lostFlag != 1 && channel_state[0].nFramesDecoded == 0) { - for (n = 0; n < decControl.nChannelsInternal; ++n) { - for (i = 0; i < channel_state[n].nFramesPerPacket; ++i) { - channel_state[n].VAD_flags[i] = psRangeDec.dec_bit_logp(1L); - } - channel_state[n].LBRR_flag = psRangeDec.dec_bit_logp(1L); - } - for (n = 0; n < decControl.nChannelsInternal; ++n) { - Arrays.MemSet(channel_state[n].LBRR_flags, 0, 3); - if (channel_state[n].LBRR_flag == 0) continue; - if (channel_state[n].nFramesPerPacket == 1) { - channel_state[n].LBRR_flags[0] = 1; - continue; - } - int LBRR_symbol = psRangeDec.dec_icdf(SilkTables.silk_LBRR_flags_iCDF_ptr[channel_state[n].nFramesPerPacket - 2], 8) + 1; - for (i = 0; i < channel_state[n].nFramesPerPacket; ++i) { - channel_state[n].LBRR_flags[i] = Inlines.silk_RSHIFT(LBRR_symbol, i) & 1; - } - } - if (lostFlag == 0) { - for (i = 0; i < channel_state[0].nFramesPerPacket; ++i) { - for (n = 0; n < decControl.nChannelsInternal; ++n) { - if (channel_state[n].LBRR_flags[i] == 0) continue; - short[] pulses = new short[320]; - if (decControl.nChannelsInternal == 2 && n == 0) { - Stereo.silk_stereo_decode_pred(psRangeDec, MS_pred_Q13); - if (channel_state[1].LBRR_flags[i] == 0) { - BoxedValueInt decodeOnlyMiddleBoxed = new BoxedValueInt(decode_only_middle); - Stereo.silk_stereo_decode_mid_only(psRangeDec, decodeOnlyMiddleBoxed); - decode_only_middle = decodeOnlyMiddleBoxed.Val; - } - } - condCoding = i > 0 && channel_state[n].LBRR_flags[i - 1] != 0 ? 2 : 0; - DecodeIndices.silk_decode_indices(channel_state[n], psRangeDec, i, 1, condCoding); - DecodePulses.silk_decode_pulses(psRangeDec, pulses, channel_state[n].indices.signalType, channel_state[n].indices.quantOffsetType, channel_state[n].frame_length); - } - } - } - } - if (decControl.nChannelsInternal == 2) { - if (lostFlag == 0 || lostFlag == 2 && channel_state[0].LBRR_flags[channel_state[0].nFramesDecoded] == 1) { - Stereo.silk_stereo_decode_pred(psRangeDec, MS_pred_Q13); - if (lostFlag == 0 && channel_state[1].VAD_flags[channel_state[0].nFramesDecoded] == 0 || lostFlag == 2 && channel_state[1].LBRR_flags[channel_state[0].nFramesDecoded] == 0) { - BoxedValueInt decodeOnlyMiddleBoxed = new BoxedValueInt(decode_only_middle); - Stereo.silk_stereo_decode_mid_only(psRangeDec, decodeOnlyMiddleBoxed); - decode_only_middle = decodeOnlyMiddleBoxed.Val; - } else { - decode_only_middle = 0; - } - } else { - for (n = 0; n < 2; ++n) { - MS_pred_Q13[n] = psDec.sStereo.pred_prev_Q13[n]; - } - } - } - if (decControl.nChannelsInternal == 2 && decode_only_middle == 0 && psDec.prev_decode_only_middle == 1) { - Arrays.MemSet(psDec.channel_state[1].outBuf, (short)0, 480); - Arrays.MemSet(psDec.channel_state[1].sLPC_Q14_buf, 0, 16); - psDec.channel_state[1].lagPrev = 100; - psDec.channel_state[1].LastGainIndex = (byte)10; - psDec.channel_state[1].prevSignalType = 0; - psDec.channel_state[1].first_frame_after_reset = 1; - } - boolean bl2 = delay_stack_alloc = decControl.internalSampleRate * decControl.nChannelsInternal < decControl.API_sampleRate * decControl.nChannelsAPI; - if (delay_stack_alloc) { - samplesOut_tmp = samplesOut; - samplesOut_tmp_ptrs[0] = samplesOut_ptr; - samplesOut_tmp_ptrs[1] = samplesOut_ptr + channel_state[0].frame_length + 2; - } else { - short[] samplesOut1_tmp_storage1 = new short[decControl.nChannelsInternal * (channel_state[0].frame_length + 2)]; - samplesOut_tmp = samplesOut1_tmp_storage1; - samplesOut_tmp_ptrs[0] = 0; - samplesOut_tmp_ptrs[1] = channel_state[0].frame_length + 2; - } - boolean has_side = lostFlag == 0 ? decode_only_middle == 0 : psDec.prev_decode_only_middle == 0 || decControl.nChannelsInternal == 2 && lostFlag == 2 && channel_state[1].LBRR_flags[channel_state[1].nFramesDecoded] == 1; - for (n = 0; n < decControl.nChannelsInternal; ++n) { - if (n == 0 || has_side) { - int FrameIndex = channel_state[0].nFramesDecoded - n; - condCoding = FrameIndex <= 0 ? 0 : (lostFlag == 2 ? (channel_state[n].LBRR_flags[FrameIndex - 1] != 0 ? 2 : 0) : (n > 0 && psDec.prev_decode_only_middle != 0 ? 1 : 2)); - ret += channel_state[n].silk_decode_frame(psRangeDec, samplesOut_tmp, samplesOut_tmp_ptrs[n] + 2, nSamplesOutDec, lostFlag, condCoding); - } else { - Arrays.MemSetWithOffset(samplesOut_tmp, (short)0, samplesOut_tmp_ptrs[n] + 2, nSamplesOutDec.Val); - } - ++channel_state[n].nFramesDecoded; - } - if (decControl.nChannelsAPI == 2 && decControl.nChannelsInternal == 2) { - Stereo.silk_stereo_MS_to_LR(psDec.sStereo, samplesOut_tmp, samplesOut_tmp_ptrs[0], samplesOut_tmp, samplesOut_tmp_ptrs[1], MS_pred_Q13, channel_state[0].fs_kHz, nSamplesOutDec.Val); - } else { - System.arraycopy(psDec.sStereo.sMid, 0, samplesOut_tmp, samplesOut_tmp_ptrs[0], 2); - System.arraycopy(samplesOut_tmp, samplesOut_tmp_ptrs[0] + nSamplesOutDec.Val, psDec.sStereo.sMid, 0, 2); - } - nSamplesOut.Val = Inlines.silk_DIV32(nSamplesOutDec.Val * decControl.API_sampleRate, Inlines.silk_SMULBB(channel_state[0].fs_kHz, 1000)); - if (decControl.nChannelsAPI == 2) { - short[] samplesOut2_tmp = new short[nSamplesOut.Val]; - resample_out = samplesOut2_tmp; - resample_out_ptr = 0; - } else { - resample_out = samplesOut; - resample_out_ptr = samplesOut_ptr; - } - if (delay_stack_alloc) { - short[] samplesOut1_tmp_storage2 = new short[decControl.nChannelsInternal * (channel_state[0].frame_length + 2)]; - System.arraycopy(samplesOut, samplesOut_ptr, samplesOut1_tmp_storage2, 0, decControl.nChannelsInternal * (channel_state[0].frame_length + 2)); - samplesOut_tmp = samplesOut1_tmp_storage2; - samplesOut_tmp_ptrs[0] = 0; - samplesOut_tmp_ptrs[1] = channel_state[0].frame_length + 2; - } - for (n = 0; n < Inlines.silk_min(decControl.nChannelsAPI, decControl.nChannelsInternal); ++n) { - ret += Resampler.silk_resampler(channel_state[n].resampler_state, resample_out, resample_out_ptr, samplesOut_tmp, samplesOut_tmp_ptrs[n] + 1, nSamplesOutDec.Val); - if (decControl.nChannelsAPI != 2) continue; - int nptr = samplesOut_ptr + n; - for (i = 0; i < nSamplesOut.Val; ++i) { - samplesOut[nptr + 2 * i] = resample_out[resample_out_ptr + i]; - } - } - if (decControl.nChannelsAPI == 2 && decControl.nChannelsInternal == 1) { - if (stereo_to_mono) { - ret += Resampler.silk_resampler(channel_state[1].resampler_state, resample_out, resample_out_ptr, samplesOut_tmp, samplesOut_tmp_ptrs[0] + 1, nSamplesOutDec.Val); - for (i = 0; i < nSamplesOut.Val; ++i) { - samplesOut[samplesOut_ptr + 1 + 2 * i] = resample_out[resample_out_ptr + i]; - } - } else { - for (i = 0; i < nSamplesOut.Val; ++i) { - samplesOut[samplesOut_ptr + 1 + 2 * i] = samplesOut[samplesOut_ptr + 2 * i]; - } - } - } - if (channel_state[0].prevSignalType == 2) { - int[] mult_tab = new int[]{6, 4, 3}; - decControl.prevPitchLag = channel_state[0].lagPrev * mult_tab[channel_state[0].fs_kHz - 8 >> 2]; - } else { - decControl.prevPitchLag = 0; - } - if (lostFlag == 1) { - for (i = 0; i < psDec.nChannelsInternal; ++i) { - psDec.channel_state[i].LastGainIndex = (byte)10; - } - } else { - psDec.prev_decode_only_middle = decode_only_middle; - } - return ret; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeCore.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeCore.java deleted file mode 100644 index e038e59..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeCore.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.SilkDecoderControl; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class DecodeCore { - DecodeCore() { - } - - static void silk_decode_core(SilkChannelDecoder psDec, SilkDecoderControl psDecCtrl, short[] xq, int xq_ptr, short[] pulses) { - int i; - int lag = 0; - short[] B_Q14 = psDecCtrl.LTPCoef_Q14; - Inlines.OpusAssert(psDec.prev_gain_Q16 != 0); - short[] sLTP = new short[psDec.ltp_mem_length]; - int[] sLTP_Q15 = new int[psDec.ltp_mem_length + psDec.frame_length]; - int[] res_Q14 = new int[psDec.subfr_length]; - int[] sLPC_Q14 = new int[psDec.subfr_length + 16]; - short offset_Q10 = SilkTables.silk_Quantization_Offsets_Q10[psDec.indices.signalType >> 1][psDec.indices.quantOffsetType]; - boolean NLSF_interpolation_flag = psDec.indices.NLSFInterpCoef_Q2 < 4; - int rand_seed = psDec.indices.Seed; - for (i = 0; i < psDec.frame_length; ++i) { - rand_seed = Inlines.silk_RAND(rand_seed); - psDec.exc_Q14[i] = Inlines.silk_LSHIFT(pulses[i], 14); - if (psDec.exc_Q14[i] > 0) { - int n = i; - psDec.exc_Q14[n] = psDec.exc_Q14[n] - 1280; - } else if (psDec.exc_Q14[i] < 0) { - int n = i; - psDec.exc_Q14[n] = psDec.exc_Q14[n] + 1280; - } - int n = i; - psDec.exc_Q14[n] = psDec.exc_Q14[n] + (offset_Q10 << 4); - if (rand_seed < 0) { - psDec.exc_Q14[i] = -psDec.exc_Q14[i]; - } - rand_seed = Inlines.silk_ADD32_ovflw(rand_seed, pulses[i]); - } - System.arraycopy(psDec.sLPC_Q14_buf, 0, sLPC_Q14, 0, 16); - int pexc_Q14 = 0; - int pxq = xq_ptr; - int sLTP_buf_idx = psDec.ltp_mem_length; - for (int k = 0; k < psDec.nb_subfr; ++k) { - int gain_adj_Q16; - int[] pres_Q14 = res_Q14; - int pres_Q14_ptr = 0; - short[] A_Q12 = psDecCtrl.PredCoef_Q12[k >> 1]; - int B_Q14_ptr = k * 5; - int signalType = psDec.indices.signalType; - int Gain_Q10 = Inlines.silk_RSHIFT(psDecCtrl.Gains_Q16[k], 6); - int inv_gain_Q31 = Inlines.silk_INVERSE32_varQ(psDecCtrl.Gains_Q16[k], 47); - if (psDecCtrl.Gains_Q16[k] != psDec.prev_gain_Q16) { - gain_adj_Q16 = Inlines.silk_DIV32_varQ(psDec.prev_gain_Q16, psDecCtrl.Gains_Q16[k], 16); - for (i = 0; i < 16; ++i) { - sLPC_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, sLPC_Q14[i]); - } - } else { - gain_adj_Q16 = 65536; - } - Inlines.OpusAssert(inv_gain_Q31 != 0); - psDec.prev_gain_Q16 = psDecCtrl.Gains_Q16[k]; - if (psDec.lossCnt != 0 && psDec.prevSignalType == 2 && psDec.indices.signalType != 2 && k < 2) { - Arrays.MemSetWithOffset(B_Q14, (short)0, B_Q14_ptr, 5); - B_Q14[B_Q14_ptr + 2] = 4096; - signalType = 2; - psDecCtrl.pitchL[k] = psDec.lagPrev; - } - if (signalType == 2) { - lag = psDecCtrl.pitchL[k]; - if (k == 0 || k == 2 && NLSF_interpolation_flag) { - int start_idx = psDec.ltp_mem_length - lag - psDec.LPC_order - 2; - Inlines.OpusAssert(start_idx > 0); - if (k == 2) { - System.arraycopy(xq, xq_ptr, psDec.outBuf, psDec.ltp_mem_length, 2 * psDec.subfr_length); - } - Filters.silk_LPC_analysis_filter(sLTP, start_idx, psDec.outBuf, start_idx + k * psDec.subfr_length, A_Q12, 0, psDec.ltp_mem_length - start_idx, psDec.LPC_order); - if (k == 0) { - inv_gain_Q31 = Inlines.silk_LSHIFT(Inlines.silk_SMULWB(inv_gain_Q31, psDecCtrl.LTP_scale_Q14), 2); - } - for (i = 0; i < lag + 2; ++i) { - sLTP_Q15[sLTP_buf_idx - i - 1] = Inlines.silk_SMULWB(inv_gain_Q31, sLTP[psDec.ltp_mem_length - i - 1]); - } - } else if (gain_adj_Q16 != 65536) { - for (i = 0; i < lag + 2; ++i) { - sLTP_Q15[sLTP_buf_idx - i - 1] = Inlines.silk_SMULWW(gain_adj_Q16, sLTP_Q15[sLTP_buf_idx - i - 1]); - } - } - } - if (signalType == 2) { - int pred_lag_ptr = sLTP_buf_idx - lag + 2; - for (i = 0; i < psDec.subfr_length; ++i) { - int LTP_pred_Q13 = 2; - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr], B_Q14[B_Q14_ptr]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 1], B_Q14[B_Q14_ptr + 1]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 2], B_Q14[B_Q14_ptr + 2]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 3], B_Q14[B_Q14_ptr + 3]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 4], B_Q14[B_Q14_ptr + 4]); - ++pred_lag_ptr; - pres_Q14[pres_Q14_ptr + i] = Inlines.silk_ADD_LSHIFT32(psDec.exc_Q14[pexc_Q14 + i], LTP_pred_Q13, 1); - sLTP_Q15[sLTP_buf_idx] = Inlines.silk_LSHIFT(pres_Q14[pres_Q14_ptr + i], 1); - ++sLTP_buf_idx; - } - } else { - pres_Q14 = psDec.exc_Q14; - pres_Q14_ptr = pexc_Q14; - } - for (i = 0; i < psDec.subfr_length; ++i) { - Inlines.OpusAssert(psDec.LPC_order == 10 || psDec.LPC_order == 16); - int LPC_pred_Q10 = Inlines.silk_RSHIFT(psDec.LPC_order, 1); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 1], A_Q12[0]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 2], A_Q12[1]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 3], A_Q12[2]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 4], A_Q12[3]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 5], A_Q12[4]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 6], A_Q12[5]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 7], A_Q12[6]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 8], A_Q12[7]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 9], A_Q12[8]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 10], A_Q12[9]); - if (psDec.LPC_order == 16) { - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 11], A_Q12[10]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 12], A_Q12[11]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 13], A_Q12[12]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 14], A_Q12[13]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 15], A_Q12[14]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLPC_Q14[16 + i - 16], A_Q12[15]); - } - sLPC_Q14[16 + i] = Inlines.silk_ADD_LSHIFT32(pres_Q14[pres_Q14_ptr + i], LPC_pred_Q10, 4); - xq[pxq + i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWW(sLPC_Q14[16 + i], Gain_Q10), 8)); - } - System.arraycopy(sLPC_Q14, psDec.subfr_length, sLPC_Q14, 0, 16); - pexc_Q14 += psDec.subfr_length; - pxq += psDec.subfr_length; - } - System.arraycopy(sLPC_Q14, 0, psDec.sLPC_Q14_buf, 0, 16); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeIndices.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeIndices.java deleted file mode 100644 index d15da8f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeIndices.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSF; -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class DecodeIndices { - DecodeIndices() { - } - - static void silk_decode_indices(SilkChannelDecoder psDec, EntropyCoder psRangeDec, int FrameIndex, int decode_LBRR, int condCoding) { - int i; - short[] ec_ix = new short[psDec.LPC_order]; - short[] pred_Q8 = new short[psDec.LPC_order]; - int Ix = decode_LBRR != 0 || psDec.VAD_flags[FrameIndex] != 0 ? psRangeDec.dec_icdf(SilkTables.silk_type_offset_VAD_iCDF, 8) + 2 : psRangeDec.dec_icdf(SilkTables.silk_type_offset_no_VAD_iCDF, 8); - psDec.indices.signalType = (byte)Inlines.silk_RSHIFT(Ix, 1); - psDec.indices.quantOffsetType = (byte)(Ix & 1); - if (condCoding == 2) { - psDec.indices.GainsIndices[0] = (byte)psRangeDec.dec_icdf(SilkTables.silk_delta_gain_iCDF, 8); - } else { - psDec.indices.GainsIndices[0] = (byte)Inlines.silk_LSHIFT(psRangeDec.dec_icdf(SilkTables.silk_gain_iCDF[psDec.indices.signalType], 8), 3); - psDec.indices.GainsIndices[0] = (byte)(psDec.indices.GainsIndices[0] + (byte)psRangeDec.dec_icdf(SilkTables.silk_uniform8_iCDF, 8)); - } - for (i = 1; i < psDec.nb_subfr; ++i) { - psDec.indices.GainsIndices[i] = (byte)psRangeDec.dec_icdf(SilkTables.silk_delta_gain_iCDF, 8); - } - psDec.indices.NLSFIndices[0] = (byte)psRangeDec.dec_icdf(psDec.psNLSF_CB.CB1_iCDF, (psDec.indices.signalType >> 1) * psDec.psNLSF_CB.nVectors, 8); - NLSF.silk_NLSF_unpack(ec_ix, pred_Q8, psDec.psNLSF_CB, psDec.indices.NLSFIndices[0]); - Inlines.OpusAssert(psDec.psNLSF_CB.order == psDec.LPC_order); - for (i = 0; i < psDec.psNLSF_CB.order; ++i) { - Ix = psRangeDec.dec_icdf(psDec.psNLSF_CB.ec_iCDF, ec_ix[i], 8); - if (Ix == 0) { - Ix -= psRangeDec.dec_icdf(SilkTables.silk_NLSF_EXT_iCDF, 8); - } else if (Ix == 8) { - Ix += psRangeDec.dec_icdf(SilkTables.silk_NLSF_EXT_iCDF, 8); - } - psDec.indices.NLSFIndices[i + 1] = (byte)(Ix - 4); - } - psDec.indices.NLSFInterpCoef_Q2 = psDec.nb_subfr == 4 ? (byte)psRangeDec.dec_icdf(SilkTables.silk_NLSF_interpolation_factor_iCDF, 8) : (byte)4; - if (psDec.indices.signalType == 2) { - int delta_lagIndex; - boolean decode_absolute_lagIndex = true; - if (condCoding == 2 && psDec.ec_prevSignalType == 2 && (delta_lagIndex = (int)psRangeDec.dec_icdf(SilkTables.silk_pitch_delta_iCDF, 8)) > 0) { - psDec.indices.lagIndex = (short)(psDec.ec_prevLagIndex + (delta_lagIndex -= 9)); - decode_absolute_lagIndex = false; - } - if (decode_absolute_lagIndex) { - psDec.indices.lagIndex = (short)(psRangeDec.dec_icdf(SilkTables.silk_pitch_lag_iCDF, 8) * Inlines.silk_RSHIFT(psDec.fs_kHz, 1)); - psDec.indices.lagIndex = (short)(psDec.indices.lagIndex + (short)psRangeDec.dec_icdf(psDec.pitch_lag_low_bits_iCDF, 8)); - } - psDec.ec_prevLagIndex = psDec.indices.lagIndex; - psDec.indices.contourIndex = (byte)psRangeDec.dec_icdf(psDec.pitch_contour_iCDF, 8); - psDec.indices.PERIndex = (byte)psRangeDec.dec_icdf(SilkTables.silk_LTP_per_index_iCDF, 8); - for (int k = 0; k < psDec.nb_subfr; ++k) { - psDec.indices.LTPIndex[k] = (byte)psRangeDec.dec_icdf(SilkTables.silk_LTP_gain_iCDF_ptrs[psDec.indices.PERIndex], 8); - } - psDec.indices.LTP_scaleIndex = condCoding == 0 ? (byte)psRangeDec.dec_icdf(SilkTables.silk_LTPscale_iCDF, 8) : (byte)0; - } - psDec.ec_prevSignalType = psDec.indices.signalType; - psDec.indices.Seed = (byte)psRangeDec.dec_icdf(SilkTables.silk_uniform4_iCDF, 8); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeParameters.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeParameters.java deleted file mode 100644 index 3f5b6cd..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodeParameters.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BWExpander; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.DecodePitch; -import de.maxhenkel.voicechat.concentus.GainQuantization; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSF; -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.SilkDecoderControl; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class DecodeParameters { - DecodeParameters() { - } - - static void silk_decode_parameters(SilkChannelDecoder psDec, SilkDecoderControl psDecCtrl, int condCoding) { - int i; - short[] pNLSF_Q15 = new short[psDec.LPC_order]; - short[] pNLSF0_Q15 = new short[psDec.LPC_order]; - BoxedValueByte boxedLastGainIndex = new BoxedValueByte(psDec.LastGainIndex); - GainQuantization.silk_gains_dequant(psDecCtrl.Gains_Q16, psDec.indices.GainsIndices, boxedLastGainIndex, condCoding == 2 ? 1 : 0, psDec.nb_subfr); - psDec.LastGainIndex = boxedLastGainIndex.Val; - NLSF.silk_NLSF_decode(pNLSF_Q15, psDec.indices.NLSFIndices, psDec.psNLSF_CB); - NLSF.silk_NLSF2A(psDecCtrl.PredCoef_Q12[1], pNLSF_Q15, psDec.LPC_order); - if (psDec.first_frame_after_reset == 1) { - psDec.indices.NLSFInterpCoef_Q2 = (byte)4; - } - if (psDec.indices.NLSFInterpCoef_Q2 < 4) { - for (i = 0; i < psDec.LPC_order; ++i) { - pNLSF0_Q15[i] = (short)(psDec.prevNLSF_Q15[i] + Inlines.silk_RSHIFT(Inlines.silk_MUL(psDec.indices.NLSFInterpCoef_Q2, pNLSF_Q15[i] - psDec.prevNLSF_Q15[i]), 2)); - } - NLSF.silk_NLSF2A(psDecCtrl.PredCoef_Q12[0], pNLSF0_Q15, psDec.LPC_order); - } else { - System.arraycopy(psDecCtrl.PredCoef_Q12[1], 0, psDecCtrl.PredCoef_Q12[0], 0, psDec.LPC_order); - } - System.arraycopy(pNLSF_Q15, 0, psDec.prevNLSF_Q15, 0, psDec.LPC_order); - if (psDec.lossCnt != 0) { - BWExpander.silk_bwexpander(psDecCtrl.PredCoef_Q12[0], psDec.LPC_order, 63570); - BWExpander.silk_bwexpander(psDecCtrl.PredCoef_Q12[1], psDec.LPC_order, 63570); - } - if (psDec.indices.signalType == 2) { - byte Ix; - DecodePitch.silk_decode_pitch(psDec.indices.lagIndex, psDec.indices.contourIndex, psDecCtrl.pitchL, psDec.fs_kHz, psDec.nb_subfr); - byte[][] cbk_ptr_Q7 = SilkTables.silk_LTP_vq_ptrs_Q7[psDec.indices.PERIndex]; - for (int k = 0; k < psDec.nb_subfr; ++k) { - Ix = psDec.indices.LTPIndex[k]; - for (i = 0; i < 5; ++i) { - psDecCtrl.LTPCoef_Q14[k * 5 + i] = (short)Inlines.silk_LSHIFT(cbk_ptr_Q7[Ix][i], 7); - } - } - Ix = psDec.indices.LTP_scaleIndex; - psDecCtrl.LTP_scale_Q14 = SilkTables.silk_LTPScales_table_Q14[Ix]; - } else { - Arrays.MemSet(psDecCtrl.pitchL, 0, psDec.nb_subfr); - Arrays.MemSet(psDecCtrl.LTPCoef_Q14, (short)0, 5 * psDec.nb_subfr); - psDec.indices.PERIndex = 0; - psDecCtrl.LTP_scale_Q14 = 0; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodePitch.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecodePitch.java deleted file mode 100644 index 555f395..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodePitch.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class DecodePitch { - DecodePitch() { - } - - static void silk_decode_pitch(short lagIndex, byte contourIndex, int[] pitch_lags, int Fs_kHz, int nb_subfr) { - byte[][] Lag_CB_ptr; - if (Fs_kHz == 8) { - if (nb_subfr == 4) { - Lag_CB_ptr = SilkTables.silk_CB_lags_stage2; - } else { - Inlines.OpusAssert(nb_subfr == 2); - Lag_CB_ptr = SilkTables.silk_CB_lags_stage2_10_ms; - } - } else if (nb_subfr == 4) { - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3; - } else { - Inlines.OpusAssert(nb_subfr == 2); - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3_10_ms; - } - int min_lag = Inlines.silk_SMULBB(2, Fs_kHz); - int max_lag = Inlines.silk_SMULBB(18, Fs_kHz); - int lag = min_lag + lagIndex; - for (int k = 0; k < nb_subfr; ++k) { - pitch_lags[k] = lag + Lag_CB_ptr[k][contourIndex]; - pitch_lags[k] = Inlines.silk_LIMIT(pitch_lags[k], min_lag, max_lag); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodePulses.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecodePulses.java deleted file mode 100644 index c9daee8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecodePulses.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.CodeSigns; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.ShellCoder; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class DecodePulses { - DecodePulses() { - } - - static void silk_decode_pulses(EntropyCoder psRangeDec, short[] pulses, int signalType, int quantOffsetType, int frame_length) { - int i; - int[] sum_pulses = new int[20]; - int[] nLshifts = new int[20]; - int RateLevelIndex = psRangeDec.dec_icdf(SilkTables.silk_rate_levels_iCDF[signalType >> 1], 8); - Inlines.OpusAssert(true); - int iter = Inlines.silk_RSHIFT(frame_length, 4); - if (iter * 16 < frame_length) { - Inlines.OpusAssert(frame_length == 120); - ++iter; - } - for (i = 0; i < iter; ++i) { - nLshifts[i] = 0; - sum_pulses[i] = psRangeDec.dec_icdf(SilkTables.silk_pulses_per_block_iCDF[RateLevelIndex], 8); - while (sum_pulses[i] == 17) { - int n = i; - nLshifts[n] = nLshifts[n] + 1; - sum_pulses[i] = psRangeDec.dec_icdf(SilkTables.silk_pulses_per_block_iCDF[9], nLshifts[i] == 10 ? 1 : 0, 8); - } - } - for (i = 0; i < iter; ++i) { - if (sum_pulses[i] > 0) { - ShellCoder.silk_shell_decoder(pulses, Inlines.silk_SMULBB(i, 16), psRangeDec, sum_pulses[i]); - continue; - } - Arrays.MemSetWithOffset(pulses, (short)0, Inlines.silk_SMULBB(i, 16), 16); - } - for (i = 0; i < iter; ++i) { - if (nLshifts[i] <= 0) continue; - int nLS = nLshifts[i]; - int pulses_ptr = Inlines.silk_SMULBB(i, 16); - for (int k = 0; k < 16; ++k) { - int abs_q = pulses[pulses_ptr + k]; - for (int j = 0; j < nLS; ++j) { - abs_q = Inlines.silk_LSHIFT(abs_q, 1); - abs_q += psRangeDec.dec_icdf(SilkTables.silk_lsb_iCDF, 8); - } - pulses[pulses_ptr + k] = (short)abs_q; - } - int n = i; - sum_pulses[n] = sum_pulses[n] | nLS << 5; - } - CodeSigns.silk_decode_signs(psRangeDec, pulses, frame_length, signalType, quantOffsetType, sum_pulses); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/DecoderAPIFlag.java b/source/decompiled/de/maxhenkel/voicechat/concentus/DecoderAPIFlag.java deleted file mode 100644 index 80363a7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/DecoderAPIFlag.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class DecoderAPIFlag { - public static final int FLAG_DECODE_NORMAL = 0; - public static final int FLAG_PACKET_LOST = 1; - public static final int FLAG_DECODE_LBRR = 2; - - DecoderAPIFlag() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Downmix.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Downmix.java deleted file mode 100644 index 33f05c3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Downmix.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class Downmix { - Downmix() { - } - - static void downmix_int(short[] x, int x_ptr, int[] sub, int sub_ptr, int subframe, int offset, int c1, int c2, int C) { - int j; - for (j = 0; j < subframe; ++j) { - sub[j + sub_ptr] = x[(j + offset) * C + c1]; - } - if (c2 > -1) { - for (j = 0; j < subframe; ++j) { - int n = j + sub_ptr; - sub[n] = sub[n] + x[(j + offset) * C + c2]; - } - } else if (c2 == -2) { - for (int c = 1; c < C; ++c) { - for (j = 0; j < subframe; ++j) { - int n = j + sub_ptr; - sub[n] = sub[n] + x[(j + offset) * C + c]; - } - } - } - int scale = 4096; - scale = C == -2 ? (scale /= C) : (scale /= 2); - for (j = 0; j < subframe; ++j) { - int n = j + sub_ptr; - sub[n] = sub[n] * scale; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/EncControlState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/EncControlState.java deleted file mode 100644 index 06db12e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/EncControlState.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkError; - -class EncControlState { - int nChannelsAPI = 0; - int nChannelsInternal = 0; - int API_sampleRate = 0; - int maxInternalSampleRate = 0; - int minInternalSampleRate = 0; - int desiredInternalSampleRate = 0; - int payloadSize_ms = 0; - int bitRate = 0; - int packetLossPercentage = 0; - int complexity = 0; - int useInBandFEC = 0; - int useDTX = 0; - int useCBR = 0; - int maxBits = 0; - int toMono = 0; - int opusCanSwitch = 0; - int reducedDependency = 0; - int internalSampleRate = 0; - int allowBandwidthSwitch = 0; - int inWBmodeWithoutVariableLP = 0; - int stereoWidth_Q14 = 0; - int switchReady = 0; - - EncControlState() { - } - - void Reset() { - this.nChannelsAPI = 0; - this.nChannelsInternal = 0; - this.API_sampleRate = 0; - this.maxInternalSampleRate = 0; - this.minInternalSampleRate = 0; - this.desiredInternalSampleRate = 0; - this.payloadSize_ms = 0; - this.bitRate = 0; - this.packetLossPercentage = 0; - this.complexity = 0; - this.useInBandFEC = 0; - this.useDTX = 0; - this.useCBR = 0; - this.maxBits = 0; - this.toMono = 0; - this.opusCanSwitch = 0; - this.reducedDependency = 0; - this.internalSampleRate = 0; - this.allowBandwidthSwitch = 0; - this.inWBmodeWithoutVariableLP = 0; - this.stereoWidth_Q14 = 0; - this.switchReady = 0; - } - - int check_control_input() { - if (this.API_sampleRate != 8000 && this.API_sampleRate != 12000 && this.API_sampleRate != 16000 && this.API_sampleRate != 24000 && this.API_sampleRate != 32000 && this.API_sampleRate != 44100 && this.API_sampleRate != 48000 || this.desiredInternalSampleRate != 8000 && this.desiredInternalSampleRate != 12000 && this.desiredInternalSampleRate != 16000 || this.maxInternalSampleRate != 8000 && this.maxInternalSampleRate != 12000 && this.maxInternalSampleRate != 16000 || this.minInternalSampleRate != 8000 && this.minInternalSampleRate != 12000 && this.minInternalSampleRate != 16000 || this.minInternalSampleRate > this.desiredInternalSampleRate || this.maxInternalSampleRate < this.desiredInternalSampleRate || this.minInternalSampleRate > this.maxInternalSampleRate) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_FS_NOT_SUPPORTED; - } - if (this.payloadSize_ms != 10 && this.payloadSize_ms != 20 && this.payloadSize_ms != 40 && this.payloadSize_ms != 60) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; - } - if (this.packetLossPercentage < 0 || this.packetLossPercentage > 100) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_LOSS_RATE; - } - if (this.useDTX < 0 || this.useDTX > 1) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_DTX_SETTING; - } - if (this.useCBR < 0 || this.useCBR > 1) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_CBR_SETTING; - } - if (this.useInBandFEC < 0 || this.useInBandFEC > 1) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_INBAND_FEC_SETTING; - } - if (this.nChannelsAPI < 1 || this.nChannelsAPI > 2) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; - } - if (this.nChannelsInternal < 1 || this.nChannelsInternal > 2) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; - } - if (this.nChannelsInternal > this.nChannelsAPI) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; - } - if (this.complexity < 0 || this.complexity > 10) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INVALID_COMPLEXITY_SETTING; - } - return SilkError.SILK_NO_ERROR; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/EncodeAPI.java b/source/decompiled/de/maxhenkel/voicechat/concentus/EncodeAPI.java deleted file mode 100644 index a804aa0..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/EncodeAPI.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.EncControlState; -import de.maxhenkel.voicechat.concentus.EncodeIndices; -import de.maxhenkel.voicechat.concentus.EncodePulses; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.HPVariableCutoff; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Resampler; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoder; -import de.maxhenkel.voicechat.concentus.SilkError; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.Stereo; - -class EncodeAPI { - EncodeAPI() { - } - - static int silk_InitEncoder(SilkEncoder encState, EncControlState encStatus) { - int ret = SilkError.SILK_NO_ERROR; - encState.Reset(); - for (int n = 0; n < 2; ++n) { - Inlines.OpusAssert((ret += SilkEncoder.silk_init_encoder(encState.state_Fxx[n])) == SilkError.SILK_NO_ERROR); - } - encState.nChannelsAPI = 1; - encState.nChannelsInternal = 1; - Inlines.OpusAssert((ret += EncodeAPI.silk_QueryEncoder(encState, encStatus)) == SilkError.SILK_NO_ERROR); - return ret; - } - - static int silk_QueryEncoder(SilkEncoder encState, EncControlState encStatus) { - int ret = SilkError.SILK_NO_ERROR; - SilkChannelEncoder state_Fxx = encState.state_Fxx[0]; - encStatus.Reset(); - encStatus.nChannelsAPI = encState.nChannelsAPI; - encStatus.nChannelsInternal = encState.nChannelsInternal; - encStatus.API_sampleRate = state_Fxx.API_fs_Hz; - encStatus.maxInternalSampleRate = state_Fxx.maxInternal_fs_Hz; - encStatus.minInternalSampleRate = state_Fxx.minInternal_fs_Hz; - encStatus.desiredInternalSampleRate = state_Fxx.desiredInternal_fs_Hz; - encStatus.payloadSize_ms = state_Fxx.PacketSize_ms; - encStatus.bitRate = state_Fxx.TargetRate_bps; - encStatus.packetLossPercentage = state_Fxx.PacketLoss_perc; - encStatus.complexity = state_Fxx.Complexity; - encStatus.useInBandFEC = state_Fxx.useInBandFEC; - encStatus.useDTX = state_Fxx.useDTX; - encStatus.useCBR = state_Fxx.useCBR; - encStatus.internalSampleRate = Inlines.silk_SMULBB(state_Fxx.fs_kHz, 1000); - encStatus.allowBandwidthSwitch = state_Fxx.allow_bandwidth_switch; - encStatus.inWBmodeWithoutVariableLP = state_Fxx.fs_kHz == 16 && state_Fxx.sLP.mode == 0 ? 1 : 0; - return ret; - } - - static int silk_Encode(SilkEncoder psEnc, EncControlState encControl, short[] samplesIn, int nSamplesIn, EntropyCoder psRangeEnc, BoxedValueInt nBytesOut, int prefillFlag) { - int i; - int n; - int ret = SilkError.SILK_NO_ERROR; - int tmp_payloadSize_ms = 0; - int tmp_complexity = 0; - int nSamplesFromInput = 0; - int[] MStargetRates_bps = new int[2]; - nBytesOut.Val = 0; - if (encControl.reducedDependency != 0) { - psEnc.state_Fxx[0].first_frame_after_reset = 1; - psEnc.state_Fxx[1].first_frame_after_reset = 1; - } - psEnc.state_Fxx[1].nFramesEncoded = 0; - psEnc.state_Fxx[0].nFramesEncoded = 0; - if ((ret += encControl.check_control_input()) != SilkError.SILK_NO_ERROR) { - Inlines.OpusAssert(false); - return ret; - } - encControl.switchReady = 0; - if (encControl.nChannelsInternal > psEnc.nChannelsInternal) { - ret += SilkEncoder.silk_init_encoder(psEnc.state_Fxx[1]); - Arrays.MemSet(psEnc.sStereo.pred_prev_Q13, (short)0, 2); - Arrays.MemSet(psEnc.sStereo.sSide, (short)0, 2); - psEnc.sStereo.mid_side_amp_Q0[0] = 0; - psEnc.sStereo.mid_side_amp_Q0[1] = 1; - psEnc.sStereo.mid_side_amp_Q0[2] = 0; - psEnc.sStereo.mid_side_amp_Q0[3] = 1; - psEnc.sStereo.width_prev_Q14 = 0; - psEnc.sStereo.smth_width_Q14 = (short)16384; - if (psEnc.nChannelsAPI == 2) { - psEnc.state_Fxx[1].resampler_state.Assign(psEnc.state_Fxx[0].resampler_state); - System.arraycopy(psEnc.state_Fxx[0].In_HP_State, 0, psEnc.state_Fxx[1].In_HP_State, 0, 2); - } - } - boolean transition = encControl.payloadSize_ms != psEnc.state_Fxx[0].PacketSize_ms || psEnc.nChannelsInternal != encControl.nChannelsInternal; - psEnc.nChannelsAPI = encControl.nChannelsAPI; - psEnc.nChannelsInternal = encControl.nChannelsInternal; - int nBlocksOf10ms = Inlines.silk_DIV32(100 * nSamplesIn, encControl.API_sampleRate); - int tot_blocks = nBlocksOf10ms > 1 ? nBlocksOf10ms >> 1 : 1; - int curr_block = 0; - if (prefillFlag != 0) { - if (nBlocksOf10ms != 1) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - } - for (n = 0; n < encControl.nChannelsInternal; ++n) { - Inlines.OpusAssert((ret += SilkEncoder.silk_init_encoder(psEnc.state_Fxx[n])) == SilkError.SILK_NO_ERROR); - } - tmp_payloadSize_ms = encControl.payloadSize_ms; - encControl.payloadSize_ms = 10; - tmp_complexity = encControl.complexity; - encControl.complexity = 0; - for (n = 0; n < encControl.nChannelsInternal; ++n) { - psEnc.state_Fxx[n].controlled_since_last_payload = 0; - psEnc.state_Fxx[n].prefillFlag = 1; - } - } else { - if (nBlocksOf10ms * encControl.API_sampleRate != 100 * nSamplesIn || nSamplesIn < 0) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - } - if (1000 * nSamplesIn > encControl.payloadSize_ms * encControl.API_sampleRate) { - Inlines.OpusAssert(false); - return SilkError.SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; - } - } - int TargetRate_bps = Inlines.silk_RSHIFT32(encControl.bitRate, encControl.nChannelsInternal - 1); - for (n = 0; n < encControl.nChannelsInternal; ++n) { - int force_fs_kHz; - int n2 = force_fs_kHz = n == 1 ? psEnc.state_Fxx[0].fs_kHz : 0; - if ((ret += psEnc.state_Fxx[n].silk_control_encoder(encControl, TargetRate_bps, psEnc.allowBandwidthSwitch, n, force_fs_kHz)) != SilkError.SILK_NO_ERROR) { - Inlines.OpusAssert(false); - return ret; - } - if (psEnc.state_Fxx[n].first_frame_after_reset != 0 || transition) { - for (i = 0; i < psEnc.state_Fxx[0].nFramesPerPacket; ++i) { - psEnc.state_Fxx[n].LBRR_flags[i] = 0; - } - } - psEnc.state_Fxx[n].inDTX = psEnc.state_Fxx[n].useDTX; - } - Inlines.OpusAssert(encControl.nChannelsInternal == 1 || psEnc.state_Fxx[0].fs_kHz == psEnc.state_Fxx[1].fs_kHz); - int nSamplesToBufferMax = 10 * nBlocksOf10ms * psEnc.state_Fxx[0].fs_kHz; - int nSamplesFromInputMax = Inlines.silk_DIV32_16(nSamplesToBufferMax * psEnc.state_Fxx[0].API_fs_Hz, (short)(psEnc.state_Fxx[0].fs_kHz * 1000)); - short[] buf = new short[nSamplesFromInputMax]; - int samplesIn_ptr = 0; - while (true) { - int nSamplesToBuffer = psEnc.state_Fxx[0].frame_length - psEnc.state_Fxx[0].inputBufIx; - nSamplesToBuffer = Inlines.silk_min(nSamplesToBuffer, nSamplesToBufferMax); - nSamplesFromInput = Inlines.silk_DIV32_16(nSamplesToBuffer * psEnc.state_Fxx[0].API_fs_Hz, psEnc.state_Fxx[0].fs_kHz * 1000); - if (encControl.nChannelsAPI == 2 && encControl.nChannelsInternal == 2) { - int id = psEnc.state_Fxx[0].nFramesEncoded; - for (n = 0; n < nSamplesFromInput; ++n) { - buf[n] = samplesIn[samplesIn_ptr + 2 * n]; - } - if (psEnc.nPrevChannelsInternal == 1 && id == 0) { - psEnc.state_Fxx[1].resampler_state.Assign(psEnc.state_Fxx[0].resampler_state); - } - ret += Resampler.silk_resampler(psEnc.state_Fxx[0].resampler_state, psEnc.state_Fxx[0].inputBuf, psEnc.state_Fxx[0].inputBufIx + 2, buf, 0, nSamplesFromInput); - psEnc.state_Fxx[0].inputBufIx += nSamplesToBuffer; - nSamplesToBuffer = psEnc.state_Fxx[1].frame_length - psEnc.state_Fxx[1].inputBufIx; - nSamplesToBuffer = Inlines.silk_min(nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc.state_Fxx[1].fs_kHz); - for (n = 0; n < nSamplesFromInput; ++n) { - buf[n] = samplesIn[samplesIn_ptr + 2 * n + 1]; - } - ret += Resampler.silk_resampler(psEnc.state_Fxx[1].resampler_state, psEnc.state_Fxx[1].inputBuf, psEnc.state_Fxx[1].inputBufIx + 2, buf, 0, nSamplesFromInput); - psEnc.state_Fxx[1].inputBufIx += nSamplesToBuffer; - } else if (encControl.nChannelsAPI == 2 && encControl.nChannelsInternal == 1) { - for (n = 0; n < nSamplesFromInput; ++n) { - int sum = samplesIn[samplesIn_ptr + 2 * n] + samplesIn[samplesIn_ptr + 2 * n + 1]; - buf[n] = (short)Inlines.silk_RSHIFT_ROUND(sum, 1); - } - ret += Resampler.silk_resampler(psEnc.state_Fxx[0].resampler_state, psEnc.state_Fxx[0].inputBuf, psEnc.state_Fxx[0].inputBufIx + 2, buf, 0, nSamplesFromInput); - if (psEnc.nPrevChannelsInternal == 2 && psEnc.state_Fxx[0].nFramesEncoded == 0) { - ret += Resampler.silk_resampler(psEnc.state_Fxx[1].resampler_state, psEnc.state_Fxx[1].inputBuf, psEnc.state_Fxx[1].inputBufIx + 2, buf, 0, nSamplesFromInput); - for (n = 0; n < psEnc.state_Fxx[0].frame_length; ++n) { - psEnc.state_Fxx[0].inputBuf[psEnc.state_Fxx[0].inputBufIx + n + 2] = (short)Inlines.silk_RSHIFT(psEnc.state_Fxx[0].inputBuf[psEnc.state_Fxx[0].inputBufIx + n + 2] + psEnc.state_Fxx[1].inputBuf[psEnc.state_Fxx[1].inputBufIx + n + 2], 1); - } - } - psEnc.state_Fxx[0].inputBufIx += nSamplesToBuffer; - } else { - Inlines.OpusAssert(encControl.nChannelsAPI == 1 && encControl.nChannelsInternal == 1); - System.arraycopy(samplesIn, samplesIn_ptr, buf, 0, nSamplesFromInput); - ret += Resampler.silk_resampler(psEnc.state_Fxx[0].resampler_state, psEnc.state_Fxx[0].inputBuf, psEnc.state_Fxx[0].inputBufIx + 2, buf, 0, nSamplesFromInput); - psEnc.state_Fxx[0].inputBufIx += nSamplesToBuffer; - } - samplesIn_ptr += nSamplesFromInput * encControl.nChannelsAPI; - nSamplesIn -= nSamplesFromInput; - psEnc.allowBandwidthSwitch = 0; - if (psEnc.state_Fxx[0].inputBufIx < psEnc.state_Fxx[0].frame_length) break; - Inlines.OpusAssert(psEnc.state_Fxx[0].inputBufIx == psEnc.state_Fxx[0].frame_length); - Inlines.OpusAssert(encControl.nChannelsInternal == 1 || psEnc.state_Fxx[1].inputBufIx == psEnc.state_Fxx[1].frame_length); - if (psEnc.state_Fxx[0].nFramesEncoded == 0 && prefillFlag == 0) { - short[] iCDF = new short[]{0, 0}; - iCDF[0] = (short)(256 - Inlines.silk_RSHIFT(256, (psEnc.state_Fxx[0].nFramesPerPacket + 1) * encControl.nChannelsInternal)); - psRangeEnc.enc_icdf(0, iCDF, 8); - for (n = 0; n < encControl.nChannelsInternal; ++n) { - int LBRR_symbol = 0; - for (i = 0; i < psEnc.state_Fxx[n].nFramesPerPacket; ++i) { - LBRR_symbol |= Inlines.silk_LSHIFT(psEnc.state_Fxx[n].LBRR_flags[i], i); - } - psEnc.state_Fxx[n].LBRR_flag = (byte)(LBRR_symbol > 0 ? 1 : 0); - if (LBRR_symbol == 0 || psEnc.state_Fxx[n].nFramesPerPacket <= 1) continue; - psRangeEnc.enc_icdf(LBRR_symbol - 1, SilkTables.silk_LBRR_flags_iCDF_ptr[psEnc.state_Fxx[n].nFramesPerPacket - 2], 8); - } - for (i = 0; i < psEnc.state_Fxx[0].nFramesPerPacket; ++i) { - for (n = 0; n < encControl.nChannelsInternal; ++n) { - if (psEnc.state_Fxx[n].LBRR_flags[i] == 0) continue; - if (encControl.nChannelsInternal == 2 && n == 0) { - Stereo.silk_stereo_encode_pred(psRangeEnc, psEnc.sStereo.predIx[i]); - if (psEnc.state_Fxx[1].LBRR_flags[i] == 0) { - Stereo.silk_stereo_encode_mid_only(psRangeEnc, psEnc.sStereo.mid_only_flags[i]); - } - } - int condCoding = i > 0 && psEnc.state_Fxx[n].LBRR_flags[i - 1] != 0 ? 2 : 0; - EncodeIndices.silk_encode_indices(psEnc.state_Fxx[n], psRangeEnc, i, 1, condCoding); - EncodePulses.silk_encode_pulses(psRangeEnc, psEnc.state_Fxx[n].indices_LBRR[i].signalType, psEnc.state_Fxx[n].indices_LBRR[i].quantOffsetType, psEnc.state_Fxx[n].pulses_LBRR[i], psEnc.state_Fxx[n].frame_length); - } - } - for (n = 0; n < encControl.nChannelsInternal; ++n) { - Arrays.MemSet(psEnc.state_Fxx[n].LBRR_flags, 0, 3); - } - psEnc.nBitsUsedLBRR = psRangeEnc.tell(); - } - HPVariableCutoff.silk_HP_variable_cutoff(psEnc.state_Fxx); - int nBits = Inlines.silk_DIV32_16(Inlines.silk_MUL(encControl.bitRate, encControl.payloadSize_ms), 1000); - if (prefillFlag == 0) { - nBits -= psEnc.nBitsUsedLBRR; - } - nBits = Inlines.silk_DIV32_16(nBits, psEnc.state_Fxx[0].nFramesPerPacket); - TargetRate_bps = encControl.payloadSize_ms == 10 ? Inlines.silk_SMULBB(nBits, 100) : Inlines.silk_SMULBB(nBits, 50); - TargetRate_bps -= Inlines.silk_DIV32_16(Inlines.silk_MUL(psEnc.nBitsExceeded, 1000), 500); - if (prefillFlag == 0 && psEnc.state_Fxx[0].nFramesEncoded > 0) { - int bitsBalance = psRangeEnc.tell() - psEnc.nBitsUsedLBRR - nBits * psEnc.state_Fxx[0].nFramesEncoded; - TargetRate_bps -= Inlines.silk_DIV32_16(Inlines.silk_MUL(bitsBalance, 1000), 500); - } - TargetRate_bps = Inlines.silk_LIMIT(TargetRate_bps, encControl.bitRate, 5000); - if (encControl.nChannelsInternal == 2) { - BoxedValueByte midOnlyFlagBoxed = new BoxedValueByte(psEnc.sStereo.mid_only_flags[psEnc.state_Fxx[0].nFramesEncoded]); - Stereo.silk_stereo_LR_to_MS(psEnc.sStereo, psEnc.state_Fxx[0].inputBuf, 2, psEnc.state_Fxx[1].inputBuf, 2, psEnc.sStereo.predIx[psEnc.state_Fxx[0].nFramesEncoded], midOnlyFlagBoxed, MStargetRates_bps, TargetRate_bps, psEnc.state_Fxx[0].speech_activity_Q8, encControl.toMono, psEnc.state_Fxx[0].fs_kHz, psEnc.state_Fxx[0].frame_length); - psEnc.sStereo.mid_only_flags[psEnc.state_Fxx[0].nFramesEncoded] = midOnlyFlagBoxed.Val; - if (midOnlyFlagBoxed.Val == 0) { - if (psEnc.prev_decode_only_middle == 1) { - psEnc.state_Fxx[1].sShape.Reset(); - psEnc.state_Fxx[1].sPrefilt.Reset(); - psEnc.state_Fxx[1].sNSQ.Reset(); - Arrays.MemSet(psEnc.state_Fxx[1].prev_NLSFq_Q15, (short)0, 16); - Arrays.MemSet(psEnc.state_Fxx[1].sLP.In_LP_State, 0, 2); - psEnc.state_Fxx[1].prevLag = 100; - psEnc.state_Fxx[1].sNSQ.lagPrev = 100; - psEnc.state_Fxx[1].sShape.LastGainIndex = (byte)10; - psEnc.state_Fxx[1].prevSignalType = 0; - psEnc.state_Fxx[1].sNSQ.prev_gain_Q16 = 65536; - psEnc.state_Fxx[1].first_frame_after_reset = 1; - } - psEnc.state_Fxx[1].silk_encode_do_VAD(); - } else { - psEnc.state_Fxx[1].VAD_flags[psEnc.state_Fxx[0].nFramesEncoded] = 0; - } - if (prefillFlag == 0) { - Stereo.silk_stereo_encode_pred(psRangeEnc, psEnc.sStereo.predIx[psEnc.state_Fxx[0].nFramesEncoded]); - if (psEnc.state_Fxx[1].VAD_flags[psEnc.state_Fxx[0].nFramesEncoded] == 0) { - Stereo.silk_stereo_encode_mid_only(psRangeEnc, psEnc.sStereo.mid_only_flags[psEnc.state_Fxx[0].nFramesEncoded]); - } - } - } else { - System.arraycopy(psEnc.sStereo.sMid, 0, psEnc.state_Fxx[0].inputBuf, 0, 2); - System.arraycopy(psEnc.state_Fxx[0].inputBuf, psEnc.state_Fxx[0].frame_length, psEnc.sStereo.sMid, 0, 2); - } - psEnc.state_Fxx[0].silk_encode_do_VAD(); - for (n = 0; n < encControl.nChannelsInternal; ++n) { - int channelRate_bps; - int useCBR; - int maxBits = encControl.maxBits; - if (tot_blocks == 2 && curr_block == 0) { - maxBits = maxBits * 3 / 5; - } else if (tot_blocks == 3) { - if (curr_block == 0) { - maxBits = maxBits * 2 / 5; - } else if (curr_block == 1) { - maxBits = maxBits * 3 / 4; - } - } - int n3 = useCBR = encControl.useCBR != 0 && curr_block == tot_blocks - 1 ? 1 : 0; - if (encControl.nChannelsInternal == 1) { - channelRate_bps = TargetRate_bps; - } else { - channelRate_bps = MStargetRates_bps[n]; - if (n == 0 && MStargetRates_bps[1] > 0) { - useCBR = 0; - maxBits -= encControl.maxBits / (tot_blocks * 2); - } - } - if (channelRate_bps > 0) { - psEnc.state_Fxx[n].silk_control_SNR(channelRate_bps); - int condCoding = psEnc.state_Fxx[0].nFramesEncoded - n <= 0 ? 0 : (n > 0 && psEnc.prev_decode_only_middle != 0 ? 1 : 2); - Inlines.OpusAssert((ret += psEnc.state_Fxx[n].silk_encode_frame(nBytesOut, psRangeEnc, condCoding, maxBits, useCBR)) == SilkError.SILK_NO_ERROR); - } - psEnc.state_Fxx[n].controlled_since_last_payload = 0; - psEnc.state_Fxx[n].inputBufIx = 0; - ++psEnc.state_Fxx[n].nFramesEncoded; - } - psEnc.prev_decode_only_middle = psEnc.sStereo.mid_only_flags[psEnc.state_Fxx[0].nFramesEncoded - 1]; - if (nBytesOut.Val > 0 && psEnc.state_Fxx[0].nFramesEncoded == psEnc.state_Fxx[0].nFramesPerPacket) { - int flags = 0; - for (n = 0; n < encControl.nChannelsInternal; ++n) { - for (i = 0; i < psEnc.state_Fxx[n].nFramesPerPacket; ++i) { - flags = Inlines.silk_LSHIFT(flags, 1); - flags |= psEnc.state_Fxx[n].VAD_flags[i]; - } - flags = Inlines.silk_LSHIFT(flags, 1); - flags |= psEnc.state_Fxx[n].LBRR_flag; - } - if (prefillFlag == 0) { - psRangeEnc.enc_patch_initial_bits(flags, (psEnc.state_Fxx[0].nFramesPerPacket + 1) * encControl.nChannelsInternal); - } - if (psEnc.state_Fxx[0].inDTX != 0 && (encControl.nChannelsInternal == 1 || psEnc.state_Fxx[1].inDTX != 0)) { - nBytesOut.Val = 0; - } - psEnc.nBitsExceeded += nBytesOut.Val * 8; - psEnc.nBitsExceeded -= Inlines.silk_DIV32_16(Inlines.silk_MUL(encControl.bitRate, encControl.payloadSize_ms), 1000); - psEnc.nBitsExceeded = Inlines.silk_LIMIT(psEnc.nBitsExceeded, 0, 10000); - int speech_act_thr_for_switch_Q8 = Inlines.silk_SMLAWB(13, 3188, psEnc.timeSinceSwitchAllowed_ms); - if (psEnc.state_Fxx[0].speech_activity_Q8 < speech_act_thr_for_switch_Q8) { - psEnc.allowBandwidthSwitch = 1; - psEnc.timeSinceSwitchAllowed_ms = 0; - } else { - psEnc.allowBandwidthSwitch = 0; - psEnc.timeSinceSwitchAllowed_ms += encControl.payloadSize_ms; - } - } - if (nSamplesIn == 0) break; - ++curr_block; - } - psEnc.nPrevChannelsInternal = encControl.nChannelsInternal; - encControl.allowBandwidthSwitch = psEnc.allowBandwidthSwitch; - encControl.inWBmodeWithoutVariableLP = psEnc.state_Fxx[0].fs_kHz == 16 && psEnc.state_Fxx[0].sLP.mode == 0 ? 1 : 0; - encControl.internalSampleRate = Inlines.silk_SMULBB(psEnc.state_Fxx[0].fs_kHz, 1000); - int n4 = encControl.stereoWidth_Q14 = encControl.toMono != 0 ? 0 : (int)psEnc.sStereo.smth_width_Q14; - if (prefillFlag != 0) { - encControl.payloadSize_ms = tmp_payloadSize_ms; - encControl.complexity = tmp_complexity; - for (n = 0; n < encControl.nChannelsInternal; ++n) { - psEnc.state_Fxx[n].controlled_since_last_payload = 0; - psEnc.state_Fxx[n].prefillFlag = 0; - } - } - return ret; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/EncodeIndices.java b/source/decompiled/de/maxhenkel/voicechat/concentus/EncodeIndices.java deleted file mode 100644 index bed616b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/EncodeIndices.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSF; -import de.maxhenkel.voicechat.concentus.SideInfoIndices; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class EncodeIndices { - EncodeIndices() { - } - - static void silk_encode_indices(SilkChannelEncoder psEncC, EntropyCoder psRangeEnc, int FrameIndex, int encode_LBRR, int condCoding) { - int i; - short[] ec_ix = new short[16]; - short[] pred_Q8 = new short[16]; - SideInfoIndices psIndices = encode_LBRR != 0 ? psEncC.indices_LBRR[FrameIndex] : psEncC.indices; - int typeOffset = 2 * psIndices.signalType + psIndices.quantOffsetType; - Inlines.OpusAssert(typeOffset >= 0 && typeOffset < 6); - Inlines.OpusAssert(encode_LBRR == 0 || typeOffset >= 2); - if (encode_LBRR != 0 || typeOffset >= 2) { - psRangeEnc.enc_icdf(typeOffset - 2, SilkTables.silk_type_offset_VAD_iCDF, 8); - } else { - psRangeEnc.enc_icdf(typeOffset, SilkTables.silk_type_offset_no_VAD_iCDF, 8); - } - if (condCoding == 2) { - Inlines.OpusAssert(psIndices.GainsIndices[0] >= 0 && psIndices.GainsIndices[0] < 41); - psRangeEnc.enc_icdf(psIndices.GainsIndices[0], SilkTables.silk_delta_gain_iCDF, 8); - } else { - Inlines.OpusAssert(psIndices.GainsIndices[0] >= 0 && psIndices.GainsIndices[0] < 64); - psRangeEnc.enc_icdf(Inlines.silk_RSHIFT(psIndices.GainsIndices[0], 3), SilkTables.silk_gain_iCDF[psIndices.signalType], 8); - psRangeEnc.enc_icdf(psIndices.GainsIndices[0] & 7, SilkTables.silk_uniform8_iCDF, 8); - } - for (i = 1; i < psEncC.nb_subfr; ++i) { - Inlines.OpusAssert(psIndices.GainsIndices[i] >= 0 && psIndices.GainsIndices[i] < 41); - psRangeEnc.enc_icdf(psIndices.GainsIndices[i], SilkTables.silk_delta_gain_iCDF, 8); - } - psRangeEnc.enc_icdf(psIndices.NLSFIndices[0], psEncC.psNLSF_CB.CB1_iCDF, (psIndices.signalType >> 1) * psEncC.psNLSF_CB.nVectors, 8); - NLSF.silk_NLSF_unpack(ec_ix, pred_Q8, psEncC.psNLSF_CB, psIndices.NLSFIndices[0]); - Inlines.OpusAssert(psEncC.psNLSF_CB.order == psEncC.predictLPCOrder); - for (i = 0; i < psEncC.psNLSF_CB.order; ++i) { - if (psIndices.NLSFIndices[i + 1] >= 4) { - psRangeEnc.enc_icdf(8, psEncC.psNLSF_CB.ec_iCDF, ec_ix[i], 8); - psRangeEnc.enc_icdf(psIndices.NLSFIndices[i + 1] - 4, SilkTables.silk_NLSF_EXT_iCDF, 8); - continue; - } - if (psIndices.NLSFIndices[i + 1] <= -4) { - psRangeEnc.enc_icdf(0, psEncC.psNLSF_CB.ec_iCDF, ec_ix[i], 8); - psRangeEnc.enc_icdf(-psIndices.NLSFIndices[i + 1] - 4, SilkTables.silk_NLSF_EXT_iCDF, 8); - continue; - } - psRangeEnc.enc_icdf(psIndices.NLSFIndices[i + 1] + 4, psEncC.psNLSF_CB.ec_iCDF, ec_ix[i], 8); - } - if (psEncC.nb_subfr == 4) { - Inlines.OpusAssert(psIndices.NLSFInterpCoef_Q2 >= 0 && psIndices.NLSFInterpCoef_Q2 < 5); - psRangeEnc.enc_icdf(psIndices.NLSFInterpCoef_Q2, SilkTables.silk_NLSF_interpolation_factor_iCDF, 8); - } - if (psIndices.signalType == 2) { - boolean encode_absolute_lagIndex = true; - if (condCoding == 2 && psEncC.ec_prevSignalType == 2) { - int delta_lagIndex = psIndices.lagIndex - psEncC.ec_prevLagIndex; - if (delta_lagIndex < -8 || delta_lagIndex > 11) { - delta_lagIndex = 0; - } else { - delta_lagIndex += 9; - encode_absolute_lagIndex = false; - } - Inlines.OpusAssert(delta_lagIndex >= 0 && delta_lagIndex < 21); - psRangeEnc.enc_icdf(delta_lagIndex, SilkTables.silk_pitch_delta_iCDF, 8); - } - if (encode_absolute_lagIndex) { - int pitch_high_bits = Inlines.silk_DIV32_16(psIndices.lagIndex, Inlines.silk_RSHIFT(psEncC.fs_kHz, 1)); - int pitch_low_bits = psIndices.lagIndex - Inlines.silk_SMULBB(pitch_high_bits, Inlines.silk_RSHIFT(psEncC.fs_kHz, 1)); - Inlines.OpusAssert(pitch_low_bits < psEncC.fs_kHz / 2); - Inlines.OpusAssert(pitch_high_bits < 32); - psRangeEnc.enc_icdf(pitch_high_bits, SilkTables.silk_pitch_lag_iCDF, 8); - psRangeEnc.enc_icdf(pitch_low_bits, psEncC.pitch_lag_low_bits_iCDF, 8); - } - psEncC.ec_prevLagIndex = psIndices.lagIndex; - Inlines.OpusAssert(psIndices.contourIndex >= 0); - Inlines.OpusAssert(psIndices.contourIndex < 34 && psEncC.fs_kHz > 8 && psEncC.nb_subfr == 4 || psIndices.contourIndex < 11 && psEncC.fs_kHz == 8 && psEncC.nb_subfr == 4 || psIndices.contourIndex < 12 && psEncC.fs_kHz > 8 && psEncC.nb_subfr == 2 || psIndices.contourIndex < 3 && psEncC.fs_kHz == 8 && psEncC.nb_subfr == 2); - psRangeEnc.enc_icdf(psIndices.contourIndex, psEncC.pitch_contour_iCDF, 8); - Inlines.OpusAssert(psIndices.PERIndex >= 0 && psIndices.PERIndex < 3); - psRangeEnc.enc_icdf(psIndices.PERIndex, SilkTables.silk_LTP_per_index_iCDF, 8); - for (int k = 0; k < psEncC.nb_subfr; ++k) { - Inlines.OpusAssert(psIndices.LTPIndex[k] >= 0 && psIndices.LTPIndex[k] < 8 << psIndices.PERIndex); - psRangeEnc.enc_icdf(psIndices.LTPIndex[k], SilkTables.silk_LTP_gain_iCDF_ptrs[psIndices.PERIndex], 8); - } - if (condCoding == 0) { - Inlines.OpusAssert(psIndices.LTP_scaleIndex >= 0 && psIndices.LTP_scaleIndex < 3); - psRangeEnc.enc_icdf(psIndices.LTP_scaleIndex, SilkTables.silk_LTPscale_iCDF, 8); - } - Inlines.OpusAssert(condCoding == 0 || psIndices.LTP_scaleIndex == 0); - } - psEncC.ec_prevSignalType = psIndices.signalType; - Inlines.OpusAssert(psIndices.Seed >= 0 && psIndices.Seed < 4); - psRangeEnc.enc_icdf(psIndices.Seed, SilkTables.silk_uniform4_iCDF, 8); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/EncodePulses.java b/source/decompiled/de/maxhenkel/voicechat/concentus/EncodePulses.java deleted file mode 100644 index 66d6c61..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/EncodePulses.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.CodeSigns; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.ShellCoder; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class EncodePulses { - EncodePulses() { - } - - static int combine_and_check(int[] pulses_comb, int pulses_comb_ptr, int[] pulses_in, int pulses_in_ptr, int max_pulses, int len) { - for (int k = 0; k < len; ++k) { - int k2p = 2 * k + pulses_in_ptr; - int sum = pulses_in[k2p] + pulses_in[k2p + 1]; - if (sum > max_pulses) { - return 1; - } - pulses_comb[pulses_comb_ptr + k] = sum; - } - return 0; - } - - static int combine_and_check(int[] pulses_comb, int[] pulses_in, int max_pulses, int len) { - for (int k = 0; k < len; ++k) { - int sum = pulses_in[2 * k] + pulses_in[2 * k + 1]; - if (sum > max_pulses) { - return 1; - } - pulses_comb[k] = sum; - } - return 0; - } - - static void silk_encode_pulses(EntropyCoder psRangeEnc, int signalType, int quantOffsetType, byte[] pulses, int frame_length) { - int k; - int i; - int RateLevelIndex = 0; - int[] pulses_comb = new int[8]; - Arrays.MemSet(pulses_comb, 0, 8); - Inlines.OpusAssert(true); - int iter = Inlines.silk_RSHIFT(frame_length, 4); - if (iter * 16 < frame_length) { - Inlines.OpusAssert(frame_length == 120); - ++iter; - Arrays.MemSetWithOffset(pulses, (byte)0, frame_length, 16); - } - int[] abs_pulses = new int[iter * 16]; - Inlines.OpusAssert(true); - for (i = 0; i < iter * 16; i += 4) { - abs_pulses[i + 0] = Inlines.silk_abs(pulses[i + 0]); - abs_pulses[i + 1] = Inlines.silk_abs(pulses[i + 1]); - abs_pulses[i + 2] = Inlines.silk_abs(pulses[i + 2]); - abs_pulses[i + 3] = Inlines.silk_abs(pulses[i + 3]); - } - int[] sum_pulses = new int[iter]; - int[] nRshifts = new int[iter]; - int abs_pulses_ptr = 0; - for (i = 0; i < iter; ++i) { - nRshifts[i] = 0; - block2: while (true) { - int scale_down = EncodePulses.combine_and_check(pulses_comb, 0, abs_pulses, abs_pulses_ptr, SilkTables.silk_max_pulses_table[0], 8); - scale_down += EncodePulses.combine_and_check(pulses_comb, pulses_comb, SilkTables.silk_max_pulses_table[1], 4); - scale_down += EncodePulses.combine_and_check(pulses_comb, pulses_comb, SilkTables.silk_max_pulses_table[2], 2); - if ((scale_down += EncodePulses.combine_and_check(sum_pulses, i, pulses_comb, 0, SilkTables.silk_max_pulses_table[3], 1)) == 0) break; - int n = i; - nRshifts[n] = nRshifts[n] + 1; - k = abs_pulses_ptr; - while (true) { - if (k >= abs_pulses_ptr + 16) continue block2; - abs_pulses[k] = Inlines.silk_RSHIFT(abs_pulses[k], 1); - ++k; - } - break; - } - abs_pulses_ptr += 16; - } - int minSumBits_Q5 = Integer.MAX_VALUE; - for (k = 0; k < 9; ++k) { - short[] nBits_ptr = SilkTables.silk_pulses_per_block_BITS_Q5[k]; - int sumBits_Q5 = SilkTables.silk_rate_levels_BITS_Q5[signalType >> 1][k]; - for (i = 0; i < iter; ++i) { - if (nRshifts[i] > 0) { - sumBits_Q5 += nBits_ptr[17]; - continue; - } - sumBits_Q5 += nBits_ptr[sum_pulses[i]]; - } - if (sumBits_Q5 >= minSumBits_Q5) continue; - minSumBits_Q5 = sumBits_Q5; - RateLevelIndex = k; - } - psRangeEnc.enc_icdf(RateLevelIndex, SilkTables.silk_rate_levels_iCDF[signalType >> 1], 8); - for (i = 0; i < iter; ++i) { - if (nRshifts[i] == 0) { - psRangeEnc.enc_icdf(sum_pulses[i], SilkTables.silk_pulses_per_block_iCDF[RateLevelIndex], 8); - continue; - } - psRangeEnc.enc_icdf(17, SilkTables.silk_pulses_per_block_iCDF[RateLevelIndex], 8); - for (k = 0; k < nRshifts[i] - 1; ++k) { - psRangeEnc.enc_icdf(17, SilkTables.silk_pulses_per_block_iCDF[9], 8); - } - psRangeEnc.enc_icdf(sum_pulses[i], SilkTables.silk_pulses_per_block_iCDF[9], 8); - } - for (i = 0; i < iter; ++i) { - if (sum_pulses[i] <= 0) continue; - ShellCoder.silk_shell_encoder(psRangeEnc, abs_pulses, i * 16); - } - for (i = 0; i < iter; ++i) { - if (nRshifts[i] <= 0) continue; - int pulses_ptr = i * 16; - int nLS = nRshifts[i] - 1; - for (k = 0; k < 16; ++k) { - int bit; - byte abs_q = (byte)Inlines.silk_abs(pulses[pulses_ptr + k]); - for (int j = nLS; j > 0; --j) { - bit = Inlines.silk_RSHIFT(abs_q, j) & 1; - psRangeEnc.enc_icdf(bit, SilkTables.silk_lsb_iCDF, 8); - } - bit = abs_q & 1; - psRangeEnc.enc_icdf(bit, SilkTables.silk_lsb_iCDF, 8); - } - } - CodeSigns.silk_encode_signs(psRangeEnc, pulses, frame_length, signalType, quantOffsetType, sum_pulses); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/EntropyCoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/EntropyCoder.java deleted file mode 100644 index ae07e66..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/EntropyCoder.java +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Inlines; - -class EntropyCoder { - private final int EC_WINDOW_SIZE = 32; - private final int EC_UINT_BITS = 8; - static final int BITRES = 3; - private final int EC_SYM_BITS = 8; - private final int EC_CODE_BITS = 32; - private final long EC_SYM_MAX = 255L; - private final int EC_CODE_SHIFT = 23; - private final long EC_CODE_TOP = 0x80000000L; - private final long EC_CODE_BOT = 0x800000L; - private final int EC_CODE_EXTRA = 7; - private byte[] buf; - private int buf_ptr; - int storage; - int end_offs; - long end_window; - int nend_bits; - int nbits_total; - int offs; - long rng; - long val; - long ext; - int rem; - int error; - private static final int[] correction = new int[]{35733, 38967, 42495, 46340, 50535, 55109, 60097, 65535}; - - EntropyCoder() { - this.Reset(); - } - - void Reset() { - this.buf = null; - this.buf_ptr = 0; - this.storage = 0; - this.end_offs = 0; - this.end_window = 0L; - this.nend_bits = 0; - this.offs = 0; - this.rng = 0L; - this.val = 0L; - this.ext = 0L; - this.rem = 0; - this.error = 0; - } - - void Assign(EntropyCoder other) { - this.buf = other.buf; - this.buf_ptr = other.buf_ptr; - this.storage = other.storage; - this.end_offs = other.end_offs; - this.end_window = other.end_window; - this.nend_bits = other.nend_bits; - this.nbits_total = other.nbits_total; - this.offs = other.offs; - this.rng = other.rng; - this.val = other.val; - this.ext = other.ext; - this.rem = other.rem; - this.error = other.error; - } - - byte[] get_buffer() { - byte[] convertedBuf = new byte[this.storage]; - System.arraycopy(this.buf, this.buf_ptr, convertedBuf, 0, this.storage); - return convertedBuf; - } - - void write_buffer(byte[] data, int data_ptr, int target_offset, int size) { - System.arraycopy(data, data_ptr, this.buf, this.buf_ptr + target_offset, size); - } - - int read_byte() { - return this.offs < this.storage ? Inlines.SignedByteToUnsignedInt(this.buf[this.buf_ptr + this.offs++]) : 0; - } - - int read_byte_from_end() { - return this.end_offs < this.storage ? Inlines.SignedByteToUnsignedInt(this.buf[this.buf_ptr + (this.storage - ++this.end_offs)]) : 0; - } - - int write_byte(long _value) { - if (this.offs + this.end_offs >= this.storage) { - return -1; - } - this.buf[this.buf_ptr + this.offs++] = (byte)(_value & 0xFFL); - return 0; - } - - int write_byte_at_end(long _value) { - if (this.offs + this.end_offs >= this.storage) { - return -1; - } - this.buf[this.buf_ptr + (this.storage - ++this.end_offs)] = (byte)(_value & 0xFFL); - return 0; - } - - void dec_normalize() { - while (this.rng <= 0x800000L) { - this.nbits_total += 8; - this.rng = Inlines.CapToUInt32(this.rng << 8); - int sym = this.rem; - this.rem = this.read_byte(); - sym = (sym << 8 | this.rem) >> 1; - this.val = Inlines.CapToUInt32((this.val << 8) + (0xFFL & (long)(~sym)) & Integer.MAX_VALUE); - } - } - - void dec_init(byte[] _buf, int _buf_ptr, int _storage) { - this.buf = _buf; - this.buf_ptr = _buf_ptr; - this.storage = _storage; - this.end_offs = 0; - this.end_window = 0L; - this.nend_bits = 0; - this.nbits_total = 9; - this.offs = 0; - this.rng = 128L; - this.rem = this.read_byte(); - this.val = Inlines.CapToUInt32(this.rng - 1L - (long)(this.rem >> 1)); - this.error = 0; - this.dec_normalize(); - } - - long decode(long _ft) { - _ft = Inlines.CapToUInt32(_ft); - this.ext = Inlines.CapToUInt32(this.rng / _ft); - long s = Inlines.CapToUInt32(this.val / this.ext); - return Inlines.CapToUInt32(_ft - Inlines.EC_MINI(Inlines.CapToUInt32(s + 1L), _ft)); - } - - long decode_bin(int _bits) { - this.ext = this.rng >> _bits; - long s = Inlines.CapToUInt32(this.val / this.ext); - return Inlines.CapToUInt32(Inlines.CapToUInt32(1L << _bits) - Inlines.EC_MINI(Inlines.CapToUInt32(s + 1L), 1L << _bits)); - } - - void dec_update(long _fl, long _fh, long _ft) { - _fl = Inlines.CapToUInt32(_fl); - _fh = Inlines.CapToUInt32(_fh); - _ft = Inlines.CapToUInt32(_ft); - long s = Inlines.CapToUInt32(this.ext * (_ft - _fh)); - this.val -= s; - this.rng = _fl > 0L ? Inlines.CapToUInt32(this.ext * (_fh - _fl)) : this.rng - s; - this.dec_normalize(); - } - - int dec_bit_logp(long _logp) { - int ret; - long d = this.val; - long r = this.rng; - long s = r >> (int)_logp; - int n = ret = d < s ? 1 : 0; - if (ret == 0) { - this.val = Inlines.CapToUInt32(d - s); - } - this.rng = ret != 0 ? s : r - s; - this.dec_normalize(); - return ret; - } - - int dec_icdf(short[] _icdf, int _ftb) { - long t; - long s = this.rng; - long d = this.val; - long r = s >> _ftb; - int ret = -1; - do { - t = s; - } while (d < (s = Inlines.CapToUInt32(r * (long)_icdf[++ret]))); - this.val = Inlines.CapToUInt32(d - s); - this.rng = Inlines.CapToUInt32(t - s); - this.dec_normalize(); - return ret; - } - - int dec_icdf(short[] _icdf, int _icdf_offset, int _ftb) { - long t; - long s = this.rng; - long d = this.val; - long r = s >> _ftb; - int ret = _icdf_offset - 1; - do { - t = s; - } while (d < (s = Inlines.CapToUInt32(r * (long)_icdf[++ret]))); - this.val = Inlines.CapToUInt32(d - s); - this.rng = Inlines.CapToUInt32(t - s); - this.dec_normalize(); - return ret - _icdf_offset; - } - - long dec_uint(long _ft) { - Inlines.OpusAssert((_ft = Inlines.CapToUInt32(_ft)) > 1L); - int ftb = Inlines.EC_ILOG(--_ft); - if (ftb > 8) { - long ft = Inlines.CapToUInt32((_ft >> (ftb -= 8)) + 1L); - long s = Inlines.CapToUInt32(this.decode(ft)); - this.dec_update(s, s + 1L, ft); - long t = Inlines.CapToUInt32(s << ftb | (long)this.dec_bits(ftb)); - if (t <= _ft) { - return t; - } - this.error = 1; - return _ft; - } - long s = Inlines.CapToUInt32(this.decode(++_ft)); - this.dec_update(s, s + 1L, _ft); - return s; - } - - int dec_bits(int _bits) { - long window = this.end_window; - int available = this.nend_bits; - if (available < _bits) { - do { - window = Inlines.CapToUInt32(window | (long)(this.read_byte_from_end() << available)); - } while ((available += 8) <= 24); - } - int ret = (int)(0xFFFFFFFFFFFFFFFFL & (window & (long)((1 << _bits) - 1))); - this.end_window = Inlines.CapToUInt32(window >>= _bits); - this.nend_bits = available -= _bits; - this.nbits_total += _bits; - return ret; - } - - void enc_carry_out(int _c) { - if ((long)_c != 255L) { - int carry = _c >> 8; - if (this.rem >= 0) { - this.error |= this.write_byte(Inlines.CapToUInt32(this.rem + carry)); - } - if (this.ext > 0L) { - long sym = 255L + (long)carry & 0xFFL; - do { - this.error |= this.write_byte(sym); - } while (--this.ext > 0L); - } - this.rem = (int)((long)_c & 0xFFL); - } else { - ++this.ext; - } - } - - void enc_normalize() { - while (this.rng <= 0x800000L) { - this.enc_carry_out((int)(this.val >> 23)); - this.val = Inlines.CapToUInt32(this.val << 8 & Integer.MAX_VALUE); - this.rng = Inlines.CapToUInt32(this.rng << 8); - this.nbits_total += 8; - } - } - - void enc_init(byte[] _buf, int buf_ptr, int _size) { - this.buf = _buf; - this.buf_ptr = buf_ptr; - this.end_offs = 0; - this.end_window = 0L; - this.nend_bits = 0; - this.nbits_total = 33; - this.offs = 0; - this.rng = Inlines.CapToUInt32(0x80000000L); - this.rem = -1; - this.val = 0L; - this.ext = 0L; - this.storage = _size; - this.error = 0; - } - - void encode(long _fl, long _fh, long _ft) { - _fl = Inlines.CapToUInt32(_fl); - _fh = Inlines.CapToUInt32(_fh); - _ft = Inlines.CapToUInt32(_ft); - long r = Inlines.CapToUInt32(this.rng / _ft); - if (_fl > 0L) { - this.val += Inlines.CapToUInt32(this.rng - r * (_ft - _fl)); - this.rng = Inlines.CapToUInt32(r * (_fh - _fl)); - } else { - this.rng = Inlines.CapToUInt32(this.rng - r * (_ft - _fh)); - } - this.enc_normalize(); - } - - void encode_bin(long _fl, long _fh, int _bits) { - _fl = Inlines.CapToUInt32(_fl); - _fh = Inlines.CapToUInt32(_fh); - long r = Inlines.CapToUInt32(this.rng >> _bits); - if (_fl > 0L) { - this.val = Inlines.CapToUInt32(this.val + Inlines.CapToUInt32(this.rng - r * ((long)(1 << _bits) - _fl))); - this.rng = Inlines.CapToUInt32(r * (_fh - _fl)); - } else { - this.rng = Inlines.CapToUInt32(this.rng - r * ((long)(1 << _bits) - _fh)); - } - this.enc_normalize(); - } - - void enc_bit_logp(int _val, int _logp) { - long r = this.rng; - long l = this.val; - long s = r >> _logp; - r -= s; - if (_val != 0) { - this.val = Inlines.CapToUInt32(l + r); - } - this.rng = _val != 0 ? s : r; - this.enc_normalize(); - } - - void enc_icdf(int _s, short[] _icdf, int _ftb) { - long r = Inlines.CapToUInt32(this.rng >> _ftb); - if (_s > 0) { - this.val += Inlines.CapToUInt32(this.rng - Inlines.CapToUInt32(r * (long)_icdf[_s - 1])); - this.rng = r * Inlines.CapToUInt32(_icdf[_s - 1] - _icdf[_s]); - } else { - this.rng = Inlines.CapToUInt32(this.rng - r * (long)_icdf[_s]); - } - this.enc_normalize(); - } - - void enc_icdf(int _s, short[] _icdf, int icdf_ptr, int _ftb) { - long r = Inlines.CapToUInt32(this.rng >> _ftb); - if (_s > 0) { - this.val += Inlines.CapToUInt32(this.rng - Inlines.CapToUInt32(r * (long)_icdf[icdf_ptr + _s - 1])); - this.rng = Inlines.CapToUInt32(r * Inlines.CapToUInt32(_icdf[icdf_ptr + _s - 1] - _icdf[icdf_ptr + _s])); - } else { - this.rng = Inlines.CapToUInt32(this.rng - r * (long)_icdf[icdf_ptr + _s]); - } - this.enc_normalize(); - } - - void enc_uint(long _fl, long _ft) { - _fl = Inlines.CapToUInt32(_fl); - Inlines.OpusAssert((_ft = Inlines.CapToUInt32(_ft)) > 1L); - int ftb = Inlines.EC_ILOG(--_ft); - if (ftb > 8) { - long ft = Inlines.CapToUInt32((_ft >> (ftb -= 8)) + 1L); - long fl = Inlines.CapToUInt32(_fl >> ftb); - this.encode(fl, fl + 1L, ft); - this.enc_bits(_fl & Inlines.CapToUInt32((1 << ftb) - 1), ftb); - } else { - this.encode(_fl, _fl + 1L, _ft + 1L); - } - } - - void enc_bits(long _fl, int _bits) { - _fl = Inlines.CapToUInt32(_fl); - long window = this.end_window; - int used = this.nend_bits; - Inlines.OpusAssert(_bits > 0); - if (used + _bits > 32) { - do { - this.error |= this.write_byte_at_end(window & 0xFFL); - window >>= 8; - } while ((used -= 8) >= 8); - } - window |= Inlines.CapToUInt32(_fl << used); - this.end_window = window; - this.nend_bits = used += _bits; - this.nbits_total += _bits; - } - - void enc_patch_initial_bits(long _val, int _nbits) { - Inlines.OpusAssert(_nbits <= 8); - int shift = 8 - _nbits; - long mask = (1 << _nbits) - 1 << shift; - if (this.offs > 0) { - this.buf[this.buf_ptr] = (byte)((long)this.buf[this.buf_ptr] & (mask ^ 0xFFFFFFFFFFFFFFFFL) | Inlines.CapToUInt32(_val << shift)); - } else if (this.rem >= 0) { - this.rem = (int)Inlines.CapToUInt32(Inlines.CapToUInt32((long)this.rem & (mask ^ 0xFFFFFFFFFFFFFFFFL) | _val) << shift); - } else if (this.rng <= 0x80000000L >> _nbits) { - this.val = Inlines.CapToUInt32(this.val & (mask << 23 ^ 0xFFFFFFFFFFFFFFFFL) | Inlines.CapToUInt32(Inlines.CapToUInt32(_val) << 23 + shift)); - } else { - this.error = -1; - } - } - - void enc_shrink(int _size) { - Inlines.OpusAssert(this.offs + this.end_offs <= _size); - Arrays.MemMove(this.buf, this.buf_ptr + _size - this.end_offs, this.buf_ptr + this.storage - this.end_offs, this.end_offs); - this.storage = _size; - } - - int range_bytes() { - return this.offs; - } - - int get_error() { - return this.error; - } - - int tell() { - int returnVal = this.nbits_total - Inlines.EC_ILOG(this.rng); - return returnVal; - } - - int tell_frac() { - long b; - int nbits = this.nbits_total << 3; - int l = Inlines.EC_ILOG(this.rng); - int r = (int)(this.rng >> l - 16); - b = Inlines.CapToUInt32(b + (long)(r > correction[(int)(b = Inlines.CapToUInt32((r >> 12) - 8))] ? 1 : 0)); - l = (int)((long)(l << 3) + b); - return nbits - l; - } - - void enc_done() { - int used; - int l = 32 - Inlines.EC_ILOG(this.rng); - long msk = Inlines.CapToUInt32(Integer.MAX_VALUE >>> l); - long end = Inlines.CapToUInt32(Inlines.CapToUInt32(this.val + msk) & (msk ^ 0xFFFFFFFFFFFFFFFFL)); - if ((end | msk) >= this.val + this.rng) { - ++l; - end = Inlines.CapToUInt32(Inlines.CapToUInt32(this.val + (msk >>= 1)) & (msk ^ 0xFFFFFFFFFFFFFFFFL)); - } - while (l > 0) { - this.enc_carry_out((int)(end >> 23)); - end = Inlines.CapToUInt32(end << 8 & Integer.MAX_VALUE); - l -= 8; - } - if (this.rem >= 0 || this.ext > 0L) { - this.enc_carry_out(0); - } - long window = this.end_window; - for (used = this.nend_bits; used >= 8; used -= 8) { - this.error |= this.write_byte_at_end(window & 0xFFL); - window >>= 8; - } - if (this.error == 0) { - Arrays.MemSetWithOffset(this.buf, (byte)0, this.buf_ptr + this.offs, this.storage - this.offs - this.end_offs); - if (used > 0) { - if (this.end_offs >= this.storage) { - this.error = -1; - } else { - l = -l; - if (this.offs + this.end_offs >= this.storage && l < used) { - window = Inlines.CapToUInt32(window & (long)((1 << l) - 1)); - this.error = -1; - } - int z = this.buf_ptr + this.storage - this.end_offs - 1; - this.buf[z] = (byte)(this.buf[z] | (byte)(window & 0xFFL)); - } - } - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/FFTState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/FFTState.java deleted file mode 100644 index f9f6330..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/FFTState.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class FFTState { - int nfft = 0; - short scale = 0; - int scale_shift = 0; - int shift = 0; - short[] factors = new short[16]; - short[] bitrev = null; - short[] twiddles = null; - - FFTState() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Filters.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Filters.java deleted file mode 100644 index 6742f15..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Filters.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; -import de.maxhenkel.voicechat.concentus.SilkPrefilterState; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class Filters { - private static final short A_fb1_20 = 10788; - private static final short A_fb1_21 = -24290; - private static final int QA = 24; - private static final int A_LIMIT = 0xFFEF9E; - - Filters() { - } - - static void silk_warped_LPC_analysis_filter(int[] state, int[] res_Q2, short[] coef_Q13, int coef_Q13_ptr, short[] input, int input_ptr, short lambda_Q16, int length, int order) { - Inlines.OpusAssert((order & 1) == 0); - for (int n = 0; n < length; ++n) { - int tmp2 = Inlines.silk_SMLAWB(state[0], state[1], lambda_Q16); - state[0] = Inlines.silk_LSHIFT(input[input_ptr + n], 14); - int tmp1 = Inlines.silk_SMLAWB(state[1], state[2] - tmp2, lambda_Q16); - state[1] = tmp2; - int acc_Q11 = Inlines.silk_RSHIFT(order, 1); - acc_Q11 = Inlines.silk_SMLAWB(acc_Q11, tmp2, coef_Q13[coef_Q13_ptr]); - for (int i = 2; i < order; i += 2) { - tmp2 = Inlines.silk_SMLAWB(state[i], state[i + 1] - tmp1, lambda_Q16); - state[i] = tmp1; - acc_Q11 = Inlines.silk_SMLAWB(acc_Q11, tmp1, coef_Q13[coef_Q13_ptr + i - 1]); - tmp1 = Inlines.silk_SMLAWB(state[i + 1], state[i + 2] - tmp2, lambda_Q16); - state[i + 1] = tmp2; - acc_Q11 = Inlines.silk_SMLAWB(acc_Q11, tmp2, coef_Q13[coef_Q13_ptr + i]); - } - state[order] = tmp1; - acc_Q11 = Inlines.silk_SMLAWB(acc_Q11, tmp1, coef_Q13[coef_Q13_ptr + order - 1]); - res_Q2[n] = Inlines.silk_LSHIFT(input[input_ptr + n], 2) - Inlines.silk_RSHIFT_ROUND(acc_Q11, 9); - } - } - - static void silk_prefilter(SilkChannelEncoder psEnc, SilkEncoderControl psEncCtrl, int[] xw_Q3, short[] x, int x_ptr) { - SilkPrefilterState P = psEnc.sPrefilt; - short[] B_Q10 = new short[2]; - int px = x_ptr; - int pxw_Q3 = 0; - int lag = P.lagPrev; - int[] x_filt_Q12 = new int[psEnc.subfr_length]; - int[] st_res_Q2 = new int[psEnc.subfr_length]; - for (int k = 0; k < psEnc.nb_subfr; ++k) { - int HarmShapeGain_Q12; - if (psEnc.indices.signalType == 2) { - lag = psEncCtrl.pitchL[k]; - } - Inlines.OpusAssert((HarmShapeGain_Q12 = Inlines.silk_SMULWB(psEncCtrl.HarmShapeGain_Q14[k], 16384 - psEncCtrl.HarmBoost_Q14[k])) >= 0); - int HarmShapeFIRPacked_Q12 = Inlines.silk_RSHIFT(HarmShapeGain_Q12, 2); - HarmShapeFIRPacked_Q12 |= Inlines.silk_LSHIFT(Inlines.silk_RSHIFT(HarmShapeGain_Q12, 1), 16); - int Tilt_Q14 = psEncCtrl.Tilt_Q14[k]; - int LF_shp_Q14 = psEncCtrl.LF_shp_Q14[k]; - int AR1_shp_Q13 = k * 16; - Filters.silk_warped_LPC_analysis_filter(P.sAR_shp, st_res_Q2, psEncCtrl.AR1_Q13, AR1_shp_Q13, x, px, (short)psEnc.warping_Q16, psEnc.subfr_length, psEnc.shapingLPCOrder); - B_Q10[0] = (short)Inlines.silk_RSHIFT_ROUND(psEncCtrl.GainsPre_Q14[k], 4); - int tmp_32 = Inlines.silk_SMLABB(0x333333, psEncCtrl.HarmBoost_Q14[k], HarmShapeGain_Q12); - tmp_32 = Inlines.silk_SMLABB(tmp_32, psEncCtrl.coding_quality_Q14, 410); - tmp_32 = Inlines.silk_SMULWB(tmp_32, -psEncCtrl.GainsPre_Q14[k]); - tmp_32 = Inlines.silk_RSHIFT_ROUND(tmp_32, 14); - B_Q10[1] = (short)Inlines.silk_SAT16(tmp_32); - x_filt_Q12[0] = Inlines.silk_MLA(Inlines.silk_MUL(st_res_Q2[0], B_Q10[0]), P.sHarmHP_Q2, B_Q10[1]); - for (int j = 1; j < psEnc.subfr_length; ++j) { - x_filt_Q12[j] = Inlines.silk_MLA(Inlines.silk_MUL(st_res_Q2[j], B_Q10[0]), st_res_Q2[j - 1], B_Q10[1]); - } - P.sHarmHP_Q2 = st_res_Q2[psEnc.subfr_length - 1]; - Filters.silk_prefilt(P, x_filt_Q12, xw_Q3, pxw_Q3, HarmShapeFIRPacked_Q12, Tilt_Q14, LF_shp_Q14, lag, psEnc.subfr_length); - px += psEnc.subfr_length; - pxw_Q3 += psEnc.subfr_length; - } - P.lagPrev = psEncCtrl.pitchL[psEnc.nb_subfr - 1]; - } - - static void silk_prefilt(SilkPrefilterState P, int[] st_res_Q12, int[] xw_Q3, int xw_Q3_ptr, int HarmShapeFIRPacked_Q12, int Tilt_Q14, int LF_shp_Q14, int lag, int length) { - short[] LTP_shp_buf = P.sLTP_shp; - int LTP_shp_buf_idx = P.sLTP_shp_buf_idx; - int sLF_AR_shp_Q12 = P.sLF_AR_shp_Q12; - int sLF_MA_shp_Q12 = P.sLF_MA_shp_Q12; - for (int i = 0; i < length; ++i) { - int n_LTP_Q12; - if (lag > 0) { - Inlines.OpusAssert(true); - int idx = lag + LTP_shp_buf_idx; - n_LTP_Q12 = Inlines.silk_SMULBB(LTP_shp_buf[idx - 1 - 1 & 0x1FF], HarmShapeFIRPacked_Q12); - n_LTP_Q12 = Inlines.silk_SMLABT(n_LTP_Q12, LTP_shp_buf[idx - 1 & 0x1FF], HarmShapeFIRPacked_Q12); - n_LTP_Q12 = Inlines.silk_SMLABB(n_LTP_Q12, LTP_shp_buf[idx - 1 + 1 & 0x1FF], HarmShapeFIRPacked_Q12); - } else { - n_LTP_Q12 = 0; - } - int n_Tilt_Q10 = Inlines.silk_SMULWB(sLF_AR_shp_Q12, Tilt_Q14); - int n_LF_Q10 = Inlines.silk_SMLAWB(Inlines.silk_SMULWT(sLF_AR_shp_Q12, LF_shp_Q14), sLF_MA_shp_Q12, LF_shp_Q14); - sLF_AR_shp_Q12 = Inlines.silk_SUB32(st_res_Q12[i], Inlines.silk_LSHIFT(n_Tilt_Q10, 2)); - sLF_MA_shp_Q12 = Inlines.silk_SUB32(sLF_AR_shp_Q12, Inlines.silk_LSHIFT(n_LF_Q10, 2)); - LTP_shp_buf_idx = LTP_shp_buf_idx - 1 & 0x1FF; - LTP_shp_buf[LTP_shp_buf_idx] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(sLF_MA_shp_Q12, 12)); - xw_Q3[xw_Q3_ptr + i] = Inlines.silk_RSHIFT_ROUND(Inlines.silk_SUB32(sLF_MA_shp_Q12, n_LTP_Q12), 9); - } - P.sLF_AR_shp_Q12 = sLF_AR_shp_Q12; - P.sLF_MA_shp_Q12 = sLF_MA_shp_Q12; - P.sLTP_shp_buf_idx = LTP_shp_buf_idx; - } - - static void silk_biquad_alt(short[] input, int input_ptr, int[] B_Q28, int[] A_Q28, int[] S, short[] output, int output_ptr, int len, int stride) { - int A0_L_Q28 = -A_Q28[0] & 0x3FFF; - int A0_U_Q28 = Inlines.silk_RSHIFT(-A_Q28[0], 14); - int A1_L_Q28 = -A_Q28[1] & 0x3FFF; - int A1_U_Q28 = Inlines.silk_RSHIFT(-A_Q28[1], 14); - for (int k = 0; k < len; ++k) { - short inval = input[input_ptr + k * stride]; - int out32_Q14 = Inlines.silk_LSHIFT(Inlines.silk_SMLAWB(S[0], B_Q28[0], inval), 2); - S[0] = S[1] + Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWB(out32_Q14, A0_L_Q28), 14); - S[0] = Inlines.silk_SMLAWB(S[0], out32_Q14, A0_U_Q28); - S[0] = Inlines.silk_SMLAWB(S[0], B_Q28[1], inval); - S[1] = Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWB(out32_Q14, A1_L_Q28), 14); - S[1] = Inlines.silk_SMLAWB(S[1], out32_Q14, A1_U_Q28); - S[1] = Inlines.silk_SMLAWB(S[1], B_Q28[2], inval); - output[output_ptr + k * stride] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT(out32_Q14 + 16384 - 1, 14)); - } - } - - static void silk_biquad_alt(short[] input, int input_ptr, int[] B_Q28, int[] A_Q28, int[] S, int S_ptr, short[] output, int output_ptr, int len, int stride) { - int A0_L_Q28 = -A_Q28[0] & 0x3FFF; - int A0_U_Q28 = Inlines.silk_RSHIFT(-A_Q28[0], 14); - int A1_L_Q28 = -A_Q28[1] & 0x3FFF; - int A1_U_Q28 = Inlines.silk_RSHIFT(-A_Q28[1], 14); - for (int k = 0; k < len; ++k) { - int s1 = S_ptr + 1; - short inval = input[input_ptr + k * stride]; - int out32_Q14 = Inlines.silk_LSHIFT(Inlines.silk_SMLAWB(S[S_ptr], B_Q28[0], inval), 2); - S[S_ptr] = S[s1] + Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWB(out32_Q14, A0_L_Q28), 14); - S[S_ptr] = Inlines.silk_SMLAWB(S[S_ptr], out32_Q14, A0_U_Q28); - S[S_ptr] = Inlines.silk_SMLAWB(S[S_ptr], B_Q28[1], inval); - S[s1] = Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWB(out32_Q14, A1_L_Q28), 14); - S[s1] = Inlines.silk_SMLAWB(S[s1], out32_Q14, A1_U_Q28); - S[s1] = Inlines.silk_SMLAWB(S[s1], B_Q28[2], inval); - output[output_ptr + k * stride] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT(out32_Q14 + 16384 - 1, 14)); - } - } - - static void silk_ana_filt_bank_1(short[] input, int input_ptr, int[] S, short[] outL, short[] outH, int outH_ptr, int N) { - int N2 = Inlines.silk_RSHIFT(N, 1); - for (int k = 0; k < N2; ++k) { - int in32 = Inlines.silk_LSHIFT(input[input_ptr + 2 * k], 10); - int Y = Inlines.silk_SUB32(in32, S[0]); - int X = Inlines.silk_SMLAWB(Y, Y, -24290); - int out_1 = Inlines.silk_ADD32(S[0], X); - S[0] = Inlines.silk_ADD32(in32, X); - in32 = Inlines.silk_LSHIFT(input[input_ptr + 2 * k + 1], 10); - Y = Inlines.silk_SUB32(in32, S[1]); - X = Inlines.silk_SMULWB(Y, 10788); - int out_2 = Inlines.silk_ADD32(S[1], X); - S[1] = Inlines.silk_ADD32(in32, X); - outL[k] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_ADD32(out_2, out_1), 11)); - outH[outH_ptr + k] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SUB32(out_2, out_1), 11)); - } - } - - static void silk_bwexpander_32(int[] ar, int d, int chirp_Q16) { - int chirp_minus_one_Q16 = chirp_Q16 - 65536; - for (int i = 0; i < d - 1; ++i) { - ar[i] = Inlines.silk_SMULWW(chirp_Q16, ar[i]); - chirp_Q16 += Inlines.silk_RSHIFT_ROUND(Inlines.silk_MUL(chirp_Q16, chirp_minus_one_Q16), 16); - } - ar[d - 1] = Inlines.silk_SMULWW(chirp_Q16, ar[d - 1]); - } - - static void silk_LP_interpolate_filter_taps(int[] B_Q28, int[] A_Q28, int ind, int fac_Q16) { - if (ind < 4) { - if (fac_Q16 > 0) { - if (fac_Q16 < 32768) { - for (int nb = 0; nb < 3; ++nb) { - B_Q28[nb] = Inlines.silk_SMLAWB(SilkTables.silk_Transition_LP_B_Q28[ind][nb], SilkTables.silk_Transition_LP_B_Q28[ind + 1][nb] - SilkTables.silk_Transition_LP_B_Q28[ind][nb], fac_Q16); - } - for (int na = 0; na < 2; ++na) { - A_Q28[na] = Inlines.silk_SMLAWB(SilkTables.silk_Transition_LP_A_Q28[ind][na], SilkTables.silk_Transition_LP_A_Q28[ind + 1][na] - SilkTables.silk_Transition_LP_A_Q28[ind][na], fac_Q16); - } - } else { - Inlines.OpusAssert(fac_Q16 - 65536 == Inlines.silk_SAT16(fac_Q16 - 65536)); - for (int nb = 0; nb < 3; ++nb) { - B_Q28[nb] = Inlines.silk_SMLAWB(SilkTables.silk_Transition_LP_B_Q28[ind + 1][nb], SilkTables.silk_Transition_LP_B_Q28[ind + 1][nb] - SilkTables.silk_Transition_LP_B_Q28[ind][nb], fac_Q16 - 65536); - } - for (int na = 0; na < 2; ++na) { - A_Q28[na] = Inlines.silk_SMLAWB(SilkTables.silk_Transition_LP_A_Q28[ind + 1][na], SilkTables.silk_Transition_LP_A_Q28[ind + 1][na] - SilkTables.silk_Transition_LP_A_Q28[ind][na], fac_Q16 - 65536); - } - } - } else { - System.arraycopy(SilkTables.silk_Transition_LP_B_Q28[ind], 0, B_Q28, 0, 3); - System.arraycopy(SilkTables.silk_Transition_LP_A_Q28[ind], 0, A_Q28, 0, 2); - } - } else { - System.arraycopy(SilkTables.silk_Transition_LP_B_Q28[4], 0, B_Q28, 0, 3); - System.arraycopy(SilkTables.silk_Transition_LP_A_Q28[4], 0, A_Q28, 0, 2); - } - } - - static void silk_LPC_analysis_filter(short[] output, int output_ptr, short[] input, int input_ptr, short[] B, int B_ptr, int len, int d) { - int j; - short[] mem = new short[16]; - short[] num = new short[16]; - Inlines.OpusAssert(d >= 6); - Inlines.OpusAssert((d & 1) == 0); - Inlines.OpusAssert(d <= len); - Inlines.OpusAssert(d <= 16); - for (j = 0; j < d; ++j) { - num[j] = (short)(0 - B[B_ptr + j]); - } - for (j = 0; j < d; ++j) { - mem[j] = input[input_ptr + d - j - 1]; - } - Kernels.celt_fir(input, input_ptr + d, num, output, output_ptr + d, len - d, d, mem); - for (j = output_ptr; j < output_ptr + d; ++j) { - output[j] = 0; - } - } - - static int LPC_inverse_pred_gain_QA(int[][] A_QA, int order) { - int rc_mult1_Q30; - int rc_Q31; - int[] Anew_QA = A_QA[order & 1]; - int invGain_Q30 = 0x40000000; - for (int k = order - 1; k > 0; --k) { - if (Anew_QA[k] > 0xFFEF9E || Anew_QA[k] < -16773022) { - return 0; - } - rc_Q31 = 0 - Inlines.silk_LSHIFT(Anew_QA[k], 7); - rc_mult1_Q30 = 0x40000000 - Inlines.silk_SMMUL(rc_Q31, rc_Q31); - Inlines.OpusAssert(rc_mult1_Q30 > 32768); - Inlines.OpusAssert(rc_mult1_Q30 <= 0x40000000); - int mult2Q = 32 - Inlines.silk_CLZ32(Inlines.silk_abs(rc_mult1_Q30)); - int rc_mult2 = Inlines.silk_INVERSE32_varQ(rc_mult1_Q30, mult2Q + 30); - invGain_Q30 = Inlines.silk_LSHIFT(Inlines.silk_SMMUL(invGain_Q30, rc_mult1_Q30), 2); - Inlines.OpusAssert(invGain_Q30 >= 0); - Inlines.OpusAssert(invGain_Q30 <= 0x40000000); - int[] Aold_QA = Anew_QA; - Anew_QA = A_QA[k & 1]; - for (int n = 0; n < k; ++n) { - int tmp_QA = Aold_QA[n] - Inlines.MUL32_FRAC_Q(Aold_QA[k - n - 1], rc_Q31, 31); - Anew_QA[n] = Inlines.MUL32_FRAC_Q(tmp_QA, rc_mult2, mult2Q); - } - } - if (Anew_QA[0] > 0xFFEF9E || Anew_QA[0] < -16773022) { - return 0; - } - rc_Q31 = 0 - Inlines.silk_LSHIFT(Anew_QA[0], 7); - rc_mult1_Q30 = 0x40000000 - Inlines.silk_SMMUL(rc_Q31, rc_Q31); - Inlines.OpusAssert((invGain_Q30 = Inlines.silk_LSHIFT(Inlines.silk_SMMUL(invGain_Q30, rc_mult1_Q30), 2)) >= 0); - Inlines.OpusAssert(invGain_Q30 <= 0x40000000); - return invGain_Q30; - } - - static int silk_LPC_inverse_pred_gain(short[] A_Q12, int order) { - int[][] Atmp_QA = new int[][]{new int[order], new int[order]}; - int DC_resp = 0; - int[] Anew_QA = Atmp_QA[order & 1]; - for (int k = 0; k < order; ++k) { - DC_resp += A_Q12[k]; - Anew_QA[k] = Inlines.silk_LSHIFT32(A_Q12[k], 12); - } - if (DC_resp >= 4096) { - return 0; - } - return Filters.LPC_inverse_pred_gain_QA(Atmp_QA, order); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/FindLPC.java b/source/decompiled/de/maxhenkel/voicechat/concentus/FindLPC.java deleted file mode 100644 index 9b33036..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/FindLPC.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.BurgModified; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSF; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class FindLPC { - FindLPC() { - } - - static void silk_find_LPC(SilkChannelEncoder psEncC, short[] NLSF_Q15, short[] x, int minInvGain_Q30) { - int[] a_Q16 = new int[16]; - BoxedValueInt res_nrg0 = new BoxedValueInt(0); - BoxedValueInt res_nrg1 = new BoxedValueInt(0); - BoxedValueInt rshift0 = new BoxedValueInt(0); - BoxedValueInt rshift1 = new BoxedValueInt(0); - BoxedValueInt scratch_box1 = new BoxedValueInt(0); - BoxedValueInt scratch_box2 = new BoxedValueInt(0); - int[] a_tmp_Q16 = new int[16]; - short[] a_tmp_Q12 = new short[16]; - short[] NLSF0_Q15 = new short[16]; - int subfr_length = psEncC.subfr_length + psEncC.predictLPCOrder; - psEncC.indices.NLSFInterpCoef_Q2 = (byte)4; - BurgModified.silk_burg_modified(scratch_box1, scratch_box2, a_Q16, x, 0, minInvGain_Q30, subfr_length, psEncC.nb_subfr, psEncC.predictLPCOrder); - int res_nrg = scratch_box1.Val; - int res_nrg_Q = scratch_box2.Val; - if (psEncC.useInterpolatedNLSFs != 0 && psEncC.first_frame_after_reset == 0 && psEncC.nb_subfr == 4) { - BurgModified.silk_burg_modified(scratch_box1, scratch_box2, a_tmp_Q16, x, 2 * subfr_length, minInvGain_Q30, subfr_length, 2, psEncC.predictLPCOrder); - int res_tmp_nrg = scratch_box1.Val; - int res_tmp_nrg_Q = scratch_box2.Val; - int shift = res_tmp_nrg_Q - res_nrg_Q; - if (shift >= 0) { - if (shift < 32) { - res_nrg -= Inlines.silk_RSHIFT(res_tmp_nrg, shift); - } - } else { - Inlines.OpusAssert(shift > -32); - res_nrg = Inlines.silk_RSHIFT(res_nrg, -shift) - res_tmp_nrg; - res_nrg_Q = res_tmp_nrg_Q; - } - NLSF.silk_A2NLSF(NLSF_Q15, a_tmp_Q16, psEncC.predictLPCOrder); - short[] LPC_res = new short[2 * subfr_length]; - for (int k = 3; k >= 0; --k) { - int res_nrg_interp_Q; - Inlines.silk_interpolate(NLSF0_Q15, psEncC.prev_NLSFq_Q15, NLSF_Q15, k, psEncC.predictLPCOrder); - NLSF.silk_NLSF2A(a_tmp_Q12, NLSF0_Q15, psEncC.predictLPCOrder); - Filters.silk_LPC_analysis_filter(LPC_res, 0, x, 0, a_tmp_Q12, 0, 2 * subfr_length, psEncC.predictLPCOrder); - SumSqrShift.silk_sum_sqr_shift(res_nrg0, rshift0, LPC_res, psEncC.predictLPCOrder, subfr_length - psEncC.predictLPCOrder); - SumSqrShift.silk_sum_sqr_shift(res_nrg1, rshift1, LPC_res, psEncC.predictLPCOrder + subfr_length, subfr_length - psEncC.predictLPCOrder); - shift = rshift0.Val - rshift1.Val; - if (shift >= 0) { - res_nrg1.Val = Inlines.silk_RSHIFT(res_nrg1.Val, shift); - res_nrg_interp_Q = 0 - rshift0.Val; - } else { - res_nrg0.Val = Inlines.silk_RSHIFT(res_nrg0.Val, 0 - shift); - res_nrg_interp_Q = 0 - rshift1.Val; - } - int res_nrg_interp = Inlines.silk_ADD32(res_nrg0.Val, res_nrg1.Val); - shift = res_nrg_interp_Q - res_nrg_Q; - boolean isInterpLower = shift >= 0 ? Inlines.silk_RSHIFT(res_nrg_interp, shift) < res_nrg : (-shift < 32 ? res_nrg_interp < Inlines.silk_RSHIFT(res_nrg, -shift) : false); - if (!isInterpLower) continue; - res_nrg = res_nrg_interp; - res_nrg_Q = res_nrg_interp_Q; - psEncC.indices.NLSFInterpCoef_Q2 = (byte)k; - } - } - if (psEncC.indices.NLSFInterpCoef_Q2 == 4) { - NLSF.silk_A2NLSF(NLSF_Q15, a_Q16, psEncC.predictLPCOrder); - } - Inlines.OpusAssert(psEncC.indices.NLSFInterpCoef_Q2 == 4 || psEncC.useInterpolatedNLSFs != 0 && psEncC.first_frame_after_reset == 0 && psEncC.nb_subfr == 4); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/FindLTP.java b/source/decompiled/de/maxhenkel/voicechat/concentus/FindLTP.java deleted file mode 100644 index fc1f234..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/FindLTP.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CorrelateMatrix; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.LinearAlgebra; -import de.maxhenkel.voicechat.concentus.RegularizeCorrelations; -import de.maxhenkel.voicechat.concentus.ResidualEnergy; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class FindLTP { - private static final int LTP_CORRS_HEAD_ROOM = 2; - - FindLTP() { - } - - static void silk_find_LTP(short[] b_Q14, int[] WLTP, BoxedValueInt LTPredCodGain_Q7, short[] r_lpc, int[] lag, int[] Wght_Q15, int subfr_length, int nb_subfr, int mem_offset, int[] corr_rshifts) { - int i; - int temp32; - int extra_shifts; - int k; - int[] b_Q16 = new int[5]; - int[] delta_b_Q14 = new int[5]; - int[] d_Q14 = new int[4]; - int[] nrg = new int[4]; - int[] w = new int[4]; - int[] Rr = new int[5]; - int[] rr = new int[4]; - int b_Q14_ptr = 0; - int WLTP_ptr = 0; - int r_ptr = mem_offset; - for (k = 0; k < nb_subfr; ++k) { - int lag_ptr = r_ptr - (lag[k] + 2); - BoxedValueInt boxed_rr = new BoxedValueInt(0); - BoxedValueInt boxed_rr_shift = new BoxedValueInt(0); - SumSqrShift.silk_sum_sqr_shift(boxed_rr, boxed_rr_shift, r_lpc, r_ptr, subfr_length); - rr[k] = boxed_rr.Val; - int rr_shifts = boxed_rr_shift.Val; - int LZs = Inlines.silk_CLZ32(rr[k]); - if (LZs < 2) { - rr[k] = Inlines.silk_RSHIFT_ROUND(rr[k], 2 - LZs); - rr_shifts += 2 - LZs; - } - corr_rshifts[k] = rr_shifts; - BoxedValueInt boxed_shifts = new BoxedValueInt(corr_rshifts[k]); - CorrelateMatrix.silk_corrMatrix(r_lpc, lag_ptr, subfr_length, 5, 2, WLTP, WLTP_ptr, boxed_shifts); - corr_rshifts[k] = boxed_shifts.Val; - CorrelateMatrix.silk_corrVector(r_lpc, lag_ptr, r_lpc, r_ptr, subfr_length, 5, Rr, corr_rshifts[k]); - if (corr_rshifts[k] > rr_shifts) { - rr[k] = Inlines.silk_RSHIFT(rr[k], corr_rshifts[k] - rr_shifts); - } - Inlines.OpusAssert(rr[k] >= 0); - int regu = 1; - regu = Inlines.silk_SMLAWB(regu, rr[k], 1092); - regu = Inlines.silk_SMLAWB(regu, Inlines.MatrixGet(WLTP, WLTP_ptr, 0, 0, 5), 1092); - regu = Inlines.silk_SMLAWB(regu, Inlines.MatrixGet(WLTP, WLTP_ptr, 4, 4, 5), 1092); - RegularizeCorrelations.silk_regularize_correlations(WLTP, WLTP_ptr, rr, k, regu, 5); - LinearAlgebra.silk_solve_LDL(WLTP, WLTP_ptr, 5, Rr, b_Q16); - FindLTP.silk_fit_LTP(b_Q16, b_Q14, b_Q14_ptr); - nrg[k] = ResidualEnergy.silk_residual_energy16_covar(b_Q14, b_Q14_ptr, WLTP, WLTP_ptr, Rr, rr[k], 5, 14); - extra_shifts = Inlines.silk_min_int(corr_rshifts[k], 2); - int denom32 = Inlines.silk_LSHIFT_SAT32(Inlines.silk_SMULWB(nrg[k], Wght_Q15[k]), 1 + extra_shifts) + Inlines.silk_RSHIFT(Inlines.silk_SMULWB(subfr_length, 655), corr_rshifts[k] - extra_shifts); - denom32 = Inlines.silk_max(denom32, 1); - Inlines.OpusAssert((long)Wght_Q15[k] << 16 < Integer.MAX_VALUE); - temp32 = Inlines.silk_DIV32(Inlines.silk_LSHIFT(Wght_Q15[k], 16), denom32); - temp32 = Inlines.silk_RSHIFT(temp32, 31 + corr_rshifts[k] - extra_shifts - 26); - int WLTP_max = 0; - for (i = WLTP_ptr; i < WLTP_ptr + 25; ++i) { - WLTP_max = Inlines.silk_max(WLTP[i], WLTP_max); - } - int lshift = Inlines.silk_CLZ32(WLTP_max) - 1 - 3; - Inlines.OpusAssert(8 + lshift >= 0); - if (8 + lshift < 31) { - temp32 = Inlines.silk_min_32(temp32, Inlines.silk_LSHIFT(1, 8 + lshift)); - } - Inlines.silk_scale_vector32_Q26_lshift_18(WLTP, WLTP_ptr, temp32, 25); - w[k] = Inlines.MatrixGet(WLTP, WLTP_ptr, 2, 2, 5); - Inlines.OpusAssert(w[k] >= 0); - r_ptr += subfr_length; - b_Q14_ptr += 5; - WLTP_ptr += 25; - } - int maxRshifts = 0; - for (k = 0; k < nb_subfr; ++k) { - maxRshifts = Inlines.silk_max_int(corr_rshifts[k], maxRshifts); - } - if (LTPredCodGain_Q7 != null) { - int LPC_LTP_res_nrg = 0; - int LPC_res_nrg = 0; - Inlines.OpusAssert(true); - for (k = 0; k < nb_subfr; ++k) { - LPC_res_nrg = Inlines.silk_ADD32(LPC_res_nrg, Inlines.silk_RSHIFT(Inlines.silk_ADD32(Inlines.silk_SMULWB(rr[k], Wght_Q15[k]), 1), 1 + (maxRshifts - corr_rshifts[k]))); - LPC_LTP_res_nrg = Inlines.silk_ADD32(LPC_LTP_res_nrg, Inlines.silk_RSHIFT(Inlines.silk_ADD32(Inlines.silk_SMULWB(nrg[k], Wght_Q15[k]), 1), 1 + (maxRshifts - corr_rshifts[k]))); - } - LPC_LTP_res_nrg = Inlines.silk_max(LPC_LTP_res_nrg, 1); - int div_Q16 = Inlines.silk_DIV32_varQ(LPC_res_nrg, LPC_LTP_res_nrg, 16); - LTPredCodGain_Q7.Val = Inlines.silk_SMULBB(3, Inlines.silk_lin2log(div_Q16) - 2048); - Inlines.OpusAssert(LTPredCodGain_Q7.Val == Inlines.silk_SAT16(Inlines.silk_MUL(3, Inlines.silk_lin2log(div_Q16) - 2048))); - } - b_Q14_ptr = 0; - for (k = 0; k < nb_subfr; ++k) { - d_Q14[k] = 0; - for (i = b_Q14_ptr; i < b_Q14_ptr + 5; ++i) { - int n = k; - d_Q14[n] = d_Q14[n] + b_Q14[i]; - } - b_Q14_ptr += 5; - } - int max_abs_d_Q14 = 0; - int max_w_bits = 0; - for (k = 0; k < nb_subfr; ++k) { - max_abs_d_Q14 = Inlines.silk_max_32(max_abs_d_Q14, Inlines.silk_abs(d_Q14[k])); - max_w_bits = Inlines.silk_max_32(max_w_bits, 32 - Inlines.silk_CLZ32(w[k]) + corr_rshifts[k] - maxRshifts); - } - Inlines.OpusAssert(max_abs_d_Q14 <= 163840); - extra_shifts = max_w_bits + 32 - Inlines.silk_CLZ32(max_abs_d_Q14) - 14; - extra_shifts -= 29 + maxRshifts; - extra_shifts = Inlines.silk_max_int(extra_shifts, 0); - int maxRshifts_wxtra = maxRshifts + extra_shifts; - temp32 = Inlines.silk_RSHIFT(262, maxRshifts + extra_shifts) + 1; - int wd = 0; - for (k = 0; k < nb_subfr; ++k) { - temp32 = Inlines.silk_ADD32(temp32, Inlines.silk_RSHIFT(w[k], maxRshifts_wxtra - corr_rshifts[k])); - wd = Inlines.silk_ADD32(wd, Inlines.silk_LSHIFT(Inlines.silk_SMULWW(Inlines.silk_RSHIFT(w[k], maxRshifts_wxtra - corr_rshifts[k]), d_Q14[k]), 2)); - } - int m_Q12 = Inlines.silk_DIV32_varQ(wd, temp32, 12); - b_Q14_ptr = 0; - for (k = 0; k < nb_subfr; ++k) { - temp32 = 2 - corr_rshifts[k] > 0 ? Inlines.silk_RSHIFT(w[k], 2 - corr_rshifts[k]) : Inlines.silk_LSHIFT_SAT32(w[k], corr_rshifts[k] - 2); - int g_Q26 = Inlines.silk_MUL(Inlines.silk_DIV32(0x666667, Inlines.silk_RSHIFT(0x666667, 10) + temp32), Inlines.silk_LSHIFT_SAT32(Inlines.silk_SUB_SAT32(m_Q12, Inlines.silk_RSHIFT(d_Q14[k], 2)), 4)); - temp32 = 0; - for (i = 0; i < 5; ++i) { - delta_b_Q14[i] = Inlines.silk_max_16(b_Q14[b_Q14_ptr + i], (short)1638); - temp32 += delta_b_Q14[i]; - } - temp32 = Inlines.silk_DIV32(g_Q26, temp32); - for (i = 0; i < 5; ++i) { - b_Q14[b_Q14_ptr + i] = (short)Inlines.silk_LIMIT_32(b_Q14[b_Q14_ptr + i] + Inlines.silk_SMULWB(Inlines.silk_LSHIFT_SAT32(temp32, 4), delta_b_Q14[i]), -16000, 28000); - } - b_Q14_ptr += 5; - } - } - - static void silk_fit_LTP(int[] LTP_coefs_Q16, short[] LTP_coefs_Q14, int LTP_coefs_Q14_ptr) { - for (int i = 0; i < 5; ++i) { - LTP_coefs_Q14[LTP_coefs_Q14_ptr + i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(LTP_coefs_Q16[i], 2)); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/FindPitchLags.java b/source/decompiled/de/maxhenkel/voicechat/concentus/FindPitchLags.java deleted file mode 100644 index 292a83b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/FindPitchLags.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.ApplySineWindow; -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Autocorrelation; -import de.maxhenkel.voicechat.concentus.BWExpander; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.BoxedValueShort; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.K2A; -import de.maxhenkel.voicechat.concentus.PitchAnalysisCore; -import de.maxhenkel.voicechat.concentus.Schur; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; - -class FindPitchLags { - FindPitchLags() { - } - - static void silk_find_pitch_lags(SilkChannelEncoder psEnc, SilkEncoderControl psEncCtrl, short[] res, short[] x, int x_ptr) { - int[] auto_corr = new int[17]; - short[] rc_Q15 = new short[16]; - int[] A_Q24 = new int[16]; - short[] A_Q12 = new short[16]; - int buf_len = psEnc.la_pitch + psEnc.frame_length + psEnc.ltp_mem_length; - Inlines.OpusAssert(buf_len >= psEnc.pitch_LPC_win_length); - int x_buf = x_ptr - psEnc.ltp_mem_length; - short[] Wsig = new short[psEnc.pitch_LPC_win_length]; - int x_buf_ptr = x_buf + buf_len - psEnc.pitch_LPC_win_length; - int Wsig_ptr = 0; - ApplySineWindow.silk_apply_sine_window(Wsig, Wsig_ptr, x, x_buf_ptr, 1, psEnc.la_pitch); - System.arraycopy(x, x_buf_ptr += psEnc.la_pitch, Wsig, Wsig_ptr += psEnc.la_pitch, psEnc.pitch_LPC_win_length - Inlines.silk_LSHIFT(psEnc.la_pitch, 1)); - ApplySineWindow.silk_apply_sine_window(Wsig, Wsig_ptr += psEnc.pitch_LPC_win_length - Inlines.silk_LSHIFT(psEnc.la_pitch, 1), x, x_buf_ptr += psEnc.pitch_LPC_win_length - Inlines.silk_LSHIFT(psEnc.la_pitch, 1), 2, psEnc.la_pitch); - BoxedValueInt boxed_scale = new BoxedValueInt(0); - Autocorrelation.silk_autocorr(auto_corr, boxed_scale, Wsig, psEnc.pitch_LPC_win_length, psEnc.pitchEstimationLPCOrder + 1); - int scale = boxed_scale.Val; - auto_corr[0] = Inlines.silk_SMLAWB(auto_corr[0], auto_corr[0], 66) + 1; - int res_nrg = Schur.silk_schur(rc_Q15, auto_corr, psEnc.pitchEstimationLPCOrder); - psEncCtrl.predGain_Q16 = Inlines.silk_DIV32_varQ(auto_corr[0], Inlines.silk_max_int(res_nrg, 1), 16); - K2A.silk_k2a(A_Q24, rc_Q15, psEnc.pitchEstimationLPCOrder); - for (int i = 0; i < psEnc.pitchEstimationLPCOrder; ++i) { - A_Q12[i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT(A_Q24[i], 12)); - } - BWExpander.silk_bwexpander(A_Q12, psEnc.pitchEstimationLPCOrder, 64881); - Filters.silk_LPC_analysis_filter(res, 0, x, x_buf, A_Q12, 0, buf_len, psEnc.pitchEstimationLPCOrder); - if (psEnc.indices.signalType != 0 && psEnc.first_frame_after_reset == 0) { - int thrhld_Q13 = 4915; - thrhld_Q13 = Inlines.silk_SMLABB(thrhld_Q13, -32, psEnc.pitchEstimationLPCOrder); - thrhld_Q13 = Inlines.silk_SMLAWB(thrhld_Q13, -209714, psEnc.speech_activity_Q8); - thrhld_Q13 = Inlines.silk_SMLABB(thrhld_Q13, -1228, Inlines.silk_RSHIFT(psEnc.prevSignalType, 1)); - thrhld_Q13 = Inlines.silk_SMLAWB(thrhld_Q13, -1637, psEnc.input_tilt_Q15); - BoxedValueShort boxed_lagIndex = new BoxedValueShort(psEnc.indices.lagIndex); - BoxedValueByte boxed_contourIndex = new BoxedValueByte(psEnc.indices.contourIndex); - BoxedValueInt boxed_LTPcorr = new BoxedValueInt(psEnc.LTPCorr_Q15); - psEnc.indices.signalType = PitchAnalysisCore.silk_pitch_analysis_core(res, psEncCtrl.pitchL, boxed_lagIndex, boxed_contourIndex, boxed_LTPcorr, psEnc.prevLag, psEnc.pitchEstimationThreshold_Q16, thrhld_Q13 = Inlines.silk_SAT16(thrhld_Q13), psEnc.fs_kHz, psEnc.pitchEstimationComplexity, psEnc.nb_subfr) == 0 ? (byte)2 : (byte)1; - psEnc.indices.lagIndex = boxed_lagIndex.Val; - psEnc.indices.contourIndex = boxed_contourIndex.Val; - psEnc.LTPCorr_Q15 = boxed_LTPcorr.Val; - } else { - Arrays.MemSet(psEncCtrl.pitchL, 0, 4); - psEnc.indices.lagIndex = 0; - psEnc.indices.contourIndex = 0; - psEnc.LTPCorr_Q15 = 0; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/FindPredCoefs.java b/source/decompiled/de/maxhenkel/voicechat/concentus/FindPredCoefs.java deleted file mode 100644 index 023e657..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/FindPredCoefs.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.FindLPC; -import de.maxhenkel.voicechat.concentus.FindLTP; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.LTPAnalysisFilter; -import de.maxhenkel.voicechat.concentus.LTPScaleControl; -import de.maxhenkel.voicechat.concentus.NLSF; -import de.maxhenkel.voicechat.concentus.QuantizeLTPGains; -import de.maxhenkel.voicechat.concentus.ResidualEnergy; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; - -class FindPredCoefs { - FindPredCoefs() { - } - - static void silk_find_pred_coefs(SilkChannelEncoder psEnc, SilkEncoderControl psEncCtrl, short[] res_pitch, short[] x, int x_ptr, int condCoding) { - int minInvGain_Q30; - int i; - int[] invGains_Q16 = new int[4]; - int[] local_gains = new int[4]; - int[] Wght_Q15 = new int[4]; - short[] NLSF_Q15 = new short[16]; - int[] LTP_corrs_rshift = new int[4]; - int min_gain_Q16 = 0x1FFFFFF; - for (i = 0; i < psEnc.nb_subfr; ++i) { - min_gain_Q16 = Inlines.silk_min(min_gain_Q16, psEncCtrl.Gains_Q16[i]); - } - for (i = 0; i < psEnc.nb_subfr; ++i) { - Inlines.OpusAssert(psEncCtrl.Gains_Q16[i] > 0); - invGains_Q16[i] = Inlines.silk_DIV32_varQ(min_gain_Q16, psEncCtrl.Gains_Q16[i], 14); - invGains_Q16[i] = Inlines.silk_max(invGains_Q16[i], 363); - Inlines.OpusAssert(invGains_Q16[i] == Inlines.silk_SAT16(invGains_Q16[i])); - int tmp = Inlines.silk_SMULWB(invGains_Q16[i], invGains_Q16[i]); - Wght_Q15[i] = Inlines.silk_RSHIFT(tmp, 1); - local_gains[i] = Inlines.silk_DIV32(65536, invGains_Q16[i]); - } - short[] LPC_in_pre = new short[psEnc.nb_subfr * psEnc.predictLPCOrder + psEnc.frame_length]; - if (psEnc.indices.signalType == 2) { - Inlines.OpusAssert(psEnc.ltp_mem_length - psEnc.predictLPCOrder >= psEncCtrl.pitchL[0] + 2); - int[] WLTP = new int[psEnc.nb_subfr * 5 * 5]; - BoxedValueInt boxed_codgain = new BoxedValueInt(psEncCtrl.LTPredCodGain_Q7); - FindLTP.silk_find_LTP(psEncCtrl.LTPCoef_Q14, WLTP, boxed_codgain, res_pitch, psEncCtrl.pitchL, Wght_Q15, psEnc.subfr_length, psEnc.nb_subfr, psEnc.ltp_mem_length, LTP_corrs_rshift); - psEncCtrl.LTPredCodGain_Q7 = boxed_codgain.Val; - BoxedValueByte boxed_periodicity = new BoxedValueByte(psEnc.indices.PERIndex); - BoxedValueInt boxed_gain = new BoxedValueInt(psEnc.sum_log_gain_Q7); - QuantizeLTPGains.silk_quant_LTP_gains(psEncCtrl.LTPCoef_Q14, psEnc.indices.LTPIndex, boxed_periodicity, boxed_gain, WLTP, psEnc.mu_LTP_Q9, psEnc.LTPQuantLowComplexity, psEnc.nb_subfr); - psEnc.indices.PERIndex = boxed_periodicity.Val; - psEnc.sum_log_gain_Q7 = boxed_gain.Val; - LTPScaleControl.silk_LTP_scale_ctrl(psEnc, psEncCtrl, condCoding); - LTPAnalysisFilter.silk_LTP_analysis_filter(LPC_in_pre, x, x_ptr - psEnc.predictLPCOrder, psEncCtrl.LTPCoef_Q14, psEncCtrl.pitchL, invGains_Q16, psEnc.subfr_length, psEnc.nb_subfr, psEnc.predictLPCOrder); - } else { - int x_ptr2 = x_ptr - psEnc.predictLPCOrder; - int x_pre_ptr = 0; - for (i = 0; i < psEnc.nb_subfr; ++i) { - Inlines.silk_scale_copy_vector16(LPC_in_pre, x_pre_ptr, x, x_ptr2, invGains_Q16[i], psEnc.subfr_length + psEnc.predictLPCOrder); - x_pre_ptr += psEnc.subfr_length + psEnc.predictLPCOrder; - x_ptr2 += psEnc.subfr_length; - } - Arrays.MemSet(psEncCtrl.LTPCoef_Q14, (short)0, psEnc.nb_subfr * 5); - psEncCtrl.LTPredCodGain_Q7 = 0; - psEnc.sum_log_gain_Q7 = 0; - } - if (psEnc.first_frame_after_reset != 0) { - minInvGain_Q30 = 10737418; - } else { - minInvGain_Q30 = Inlines.silk_log2lin(Inlines.silk_SMLAWB(2048, psEncCtrl.LTPredCodGain_Q7, 21845)); - minInvGain_Q30 = Inlines.silk_DIV32_varQ(minInvGain_Q30, Inlines.silk_SMULWW(10000, Inlines.silk_SMLAWB(65536, 196608, psEncCtrl.coding_quality_Q14)), 14); - } - FindLPC.silk_find_LPC(psEnc, NLSF_Q15, LPC_in_pre, minInvGain_Q30); - NLSF.silk_process_NLSFs(psEnc, psEncCtrl.PredCoef_Q12, NLSF_Q15, psEnc.prev_NLSFq_Q15); - ResidualEnergy.silk_residual_energy(psEncCtrl.ResNrg, psEncCtrl.ResNrgQ, LPC_in_pre, psEncCtrl.PredCoef_Q12, local_gains, psEnc.subfr_length, psEnc.nb_subfr, psEnc.predictLPCOrder); - System.arraycopy(NLSF_Q15, 0, psEnc.prev_NLSFq_Q15, 0, 16); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/GainQuantization.java b/source/decompiled/de/maxhenkel/voicechat/concentus/GainQuantization.java deleted file mode 100644 index ffd3562..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/GainQuantization.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.Inlines; - -class GainQuantization { - private static final int OFFSET = 2090; - private static final int SCALE_Q16 = 2251; - private static final int INV_SCALE_Q16 = 1907825; - - GainQuantization() { - } - - static void silk_gains_quant(byte[] ind, int[] gain_Q16, BoxedValueByte prev_ind, int conditional, int nb_subfr) { - for (int k = 0; k < nb_subfr; ++k) { - ind[k] = (byte)Inlines.silk_SMULWB(2251, Inlines.silk_lin2log(gain_Q16[k]) - 2090); - if (ind[k] < prev_ind.Val) { - int n = k; - ind[n] = (byte)(ind[n] + 1); - } - ind[k] = (byte)Inlines.silk_LIMIT_int(ind[k], 0, 63); - if (k == 0 && conditional == 0) { - ind[k] = (byte)Inlines.silk_LIMIT_int(ind[k], prev_ind.Val + -4, 63); - prev_ind.Val = ind[k]; - } else { - ind[k] = (byte)(ind[k] - prev_ind.Val); - int double_step_size_threshold = 8 + prev_ind.Val; - if (ind[k] > double_step_size_threshold) { - ind[k] = (byte)(double_step_size_threshold + Inlines.silk_RSHIFT(ind[k] - double_step_size_threshold + 1, 1)); - } - ind[k] = (byte)Inlines.silk_LIMIT_int(ind[k], -4, 36); - prev_ind.Val = ind[k] > double_step_size_threshold ? (byte)(prev_ind.Val + (byte)(Inlines.silk_LSHIFT(ind[k], 1) - double_step_size_threshold)) : (byte)(prev_ind.Val + ind[k]); - int n = k; - ind[n] = (byte)(ind[n] - -4); - } - gain_Q16[k] = Inlines.silk_log2lin(Inlines.silk_min_32(Inlines.silk_SMULWB(1907825, prev_ind.Val) + 2090, 3967)); - } - } - - static void silk_gains_dequant(int[] gain_Q16, byte[] ind, BoxedValueByte prev_ind, int conditional, int nb_subfr) { - for (int k = 0; k < nb_subfr; ++k) { - int double_step_size_threshold; - int ind_tmp; - prev_ind.Val = k == 0 && conditional == 0 ? (byte)Inlines.silk_max_int(ind[k], prev_ind.Val - 16) : ((ind_tmp = ind[k] + -4) > (double_step_size_threshold = 8 + prev_ind.Val) ? (byte)(prev_ind.Val + (byte)(Inlines.silk_LSHIFT(ind_tmp, 1) - double_step_size_threshold)) : (byte)(prev_ind.Val + (byte)ind_tmp)); - prev_ind.Val = (byte)Inlines.silk_LIMIT_int(prev_ind.Val, 0, 63); - gain_Q16[k] = Inlines.silk_log2lin(Inlines.silk_min_32(Inlines.silk_SMULWB(1907825, prev_ind.Val) + 2090, 3967)); - } - } - - static int silk_gains_ID(byte[] ind, int nb_subfr) { - int gainsID = 0; - for (int k = 0; k < nb_subfr; ++k) { - gainsID = Inlines.silk_ADD_LSHIFT32(ind[k], gainsID, 8); - } - return gainsID; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/HPVariableCutoff.java b/source/decompiled/de/maxhenkel/voicechat/concentus/HPVariableCutoff.java deleted file mode 100644 index 924b732..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/HPVariableCutoff.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; - -class HPVariableCutoff { - HPVariableCutoff() { - } - - static void silk_HP_variable_cutoff(SilkChannelEncoder[] state_Fxx) { - SilkChannelEncoder psEncC1 = state_Fxx[0]; - if (psEncC1.prevSignalType == 2) { - int pitch_freq_Hz_Q16 = Inlines.silk_DIV32_16(Inlines.silk_LSHIFT(Inlines.silk_MUL(psEncC1.fs_kHz, 1000), 16), psEncC1.prevLag); - int pitch_freq_log_Q7 = Inlines.silk_lin2log(pitch_freq_Hz_Q16) - 2048; - int quality_Q15 = psEncC1.input_quality_bands_Q15[0]; - int delta_freq_Q7 = (pitch_freq_log_Q7 = Inlines.silk_SMLAWB(pitch_freq_log_Q7, Inlines.silk_SMULWB(Inlines.silk_LSHIFT(-quality_Q15, 2), quality_Q15), pitch_freq_log_Q7 - (Inlines.silk_lin2log(0x3C0000) - 2048))) - Inlines.silk_RSHIFT(psEncC1.variable_HP_smth1_Q15, 8); - if (delta_freq_Q7 < 0) { - delta_freq_Q7 = Inlines.silk_MUL(delta_freq_Q7, 3); - } - delta_freq_Q7 = Inlines.silk_LIMIT_32(delta_freq_Q7, -51, 51); - psEncC1.variable_HP_smth1_Q15 = Inlines.silk_SMLAWB(psEncC1.variable_HP_smth1_Q15, Inlines.silk_SMULBB(psEncC1.speech_activity_Q8, delta_freq_Q7), 6554); - psEncC1.variable_HP_smth1_Q15 = Inlines.silk_LIMIT_32(psEncC1.variable_HP_smth1_Q15, Inlines.silk_LSHIFT(Inlines.silk_lin2log(60), 8), Inlines.silk_LSHIFT(Inlines.silk_lin2log(100), 8)); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Inlines.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Inlines.java deleted file mode 100644 index 7d17551..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Inlines.java +++ /dev/null @@ -1,1263 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.PitchAnalysisCore; - -class Inlines { - private static short[] sqrt_C = new short[]{23175, 11561, -3011, 1699, -664}; - private static short log2_C0 = (short)-6793; - - Inlines() { - } - - static void OpusAssert(boolean condition) { - if (!condition) { - throw new AssertionError(); - } - } - - static void OpusAssert(boolean condition, String message) { - if (!condition) { - throw new AssertionError((Object)message); - } - } - - static long CapToUInt32(long val) { - return 0xFFFFFFFFL & (long)((int)val); - } - - static long CapToUInt32(int val) { - return val; - } - - static int MULT16_16SU(int a, int b) { - return (short)a * (b & 0xFFFF); - } - - static int MULT16_32_Q16(short a, int b) { - return Inlines.ADD32(Inlines.MULT16_16((int)a, Inlines.SHR(b, 16)), Inlines.SHR(Inlines.MULT16_16SU(a, b & 0xFFFF), 16)); - } - - static int MULT16_32_Q16(int a, int b) { - return Inlines.ADD32(Inlines.MULT16_16(a, Inlines.SHR(b, 16)), Inlines.SHR(Inlines.MULT16_16SU(a, b & 0xFFFF), 16)); - } - - static int MULT16_32_P16(short a, int b) { - return Inlines.ADD32(Inlines.MULT16_16((int)a, Inlines.SHR(b, 16)), Inlines.PSHR(Inlines.MULT16_16SU(a, b & 0xFFFF), 16)); - } - - static int MULT16_32_P16(int a, int b) { - return Inlines.ADD32(Inlines.MULT16_16(a, Inlines.SHR(b, 16)), Inlines.PSHR(Inlines.MULT16_16SU(a, b & 0xFFFF), 16)); - } - - static int MULT16_32_Q15(short a, int b) { - return (a * (b >> 16) << 1) + (a * (b & 0xFFFF) >> 15); - } - - static int MULT16_32_Q15(int a, int b) { - return (a * (b >> 16) << 1) + (a * (b & 0xFFFF) >> 15); - } - - static int MULT32_32_Q31(int a, int b) { - return Inlines.ADD32(Inlines.ADD32(Inlines.SHL(Inlines.MULT16_16(Inlines.SHR(a, 16), Inlines.SHR(b, 16)), 1), Inlines.SHR(Inlines.MULT16_16SU(Inlines.SHR(a, 16), b & 0xFFFF), 15)), Inlines.SHR(Inlines.MULT16_16SU(Inlines.SHR(b, 16), a & 0xFFFF), 15)); - } - - static short QCONST16(float x, int bits) { - return (short)(0.5 + (double)(x * (float)(1 << bits))); - } - - static int QCONST32(float x, int bits) { - return (int)(0.5 + (double)(x * (float)(1 << bits))); - } - - static short NEG16(short x) { - return (short)(0 - x); - } - - static int NEG16(int x) { - return 0 - x; - } - - static int NEG32(int x) { - return 0 - x; - } - - static short EXTRACT16(int x) { - return (short)x; - } - - static int EXTEND32(short x) { - return x; - } - - static int EXTEND32(int x) { - return x; - } - - static short SHR16(short a, int shift) { - return (short)(a >> shift); - } - - static int SHR16(int a, int shift) { - return a >> shift; - } - - static short SHL16(short a, int shift) { - return (short)((a & 0xFFFF) << shift); - } - - static int SHL16(int a, int shift) { - return (int)(0xFFFFFFFFFFFFFFFFL & (long)a << shift); - } - - static int SHR32(int a, int shift) { - return a >> shift; - } - - static int SHL32(int a, int shift) { - return (int)(0xFFFFFFFFFFFFFFFFL & (long)a << shift); - } - - static int PSHR32(int a, int shift) { - return Inlines.SHR32(a + (Inlines.EXTEND32(1) << shift >> 1), shift); - } - - static short PSHR16(short a, int shift) { - return Inlines.SHR16((short)(a + (1 << shift >> 1)), shift); - } - - static int PSHR16(int a, int shift) { - return Inlines.SHR32(a + (1 << shift >> 1), shift); - } - - static int VSHR32(int a, int shift) { - return shift > 0 ? Inlines.SHR32(a, shift) : Inlines.SHL32(a, -shift); - } - - private static int SHR(int a, int shift) { - return a >> shift; - } - - private static int SHL(int a, int shift) { - return Inlines.SHL32(a, shift); - } - - private static int SHR(short a, int shift) { - return a >> shift; - } - - private static int SHL(short a, int shift) { - return Inlines.SHL32(a, shift); - } - - private static int PSHR(int a, int shift) { - return Inlines.SHR(a + (Inlines.EXTEND32(1) << shift >> 1), shift); - } - - static int SATURATE(int x, int a) { - return x > a ? a : (x < -a ? -a : x); - } - - static short SATURATE16(int x) { - return Inlines.EXTRACT16(x > Short.MAX_VALUE ? Short.MAX_VALUE : (x < Short.MIN_VALUE ? Short.MIN_VALUE : x)); - } - - static short ROUND16(short x, short a) { - return Inlines.EXTRACT16(Inlines.PSHR32(x, a)); - } - - static int ROUND16(int x, int a) { - return Inlines.PSHR32(x, a); - } - - static int PDIV32(int a, int b) { - return a / b; - } - - static short HALF16(short x) { - return Inlines.SHR16(x, 1); - } - - static int HALF16(int x) { - return Inlines.SHR32(x, 1); - } - - static int HALF32(int x) { - return Inlines.SHR32(x, 1); - } - - static short ADD16(short a, short b) { - return (short)(a + b); - } - - static int ADD16(int a, int b) { - return a + b; - } - - static short SUB16(short a, short b) { - return (short)(a - b); - } - - static int SUB16(int a, int b) { - return a - b; - } - - static int ADD32(int a, int b) { - return a + b; - } - - static int SUB32(int a, int b) { - return a - b; - } - - static short MULT16_16_16(short a, short b) { - return (short)(a * b); - } - - static int MULT16_16_16(int a, int b) { - return a * b; - } - - static int MULT16_16(int a, int b) { - return a * b; - } - - static int MULT16_16(short a, short b) { - return a * b; - } - - static int MAC16_16(short c, short a, short b) { - return c + a * b; - } - - static int MAC16_16(int c, short a, short b) { - return c + a * b; - } - - static int MAC16_16(int c, int a, int b) { - return c + a * b; - } - - static int MAC16_32_Q15(int c, short a, short b) { - return Inlines.ADD32(c, Inlines.ADD32(Inlines.MULT16_16((int)a, Inlines.SHR(b, 15)), Inlines.SHR(Inlines.MULT16_16((int)a, b & Short.MAX_VALUE), 15))); - } - - static int MAC16_32_Q15(int c, int a, int b) { - return Inlines.ADD32(c, Inlines.ADD32(Inlines.MULT16_16(a, Inlines.SHR(b, 15)), Inlines.SHR(Inlines.MULT16_16(a, b & Short.MAX_VALUE), 15))); - } - - static int MAC16_32_Q16(int c, short a, short b) { - return Inlines.ADD32(c, Inlines.ADD32(Inlines.MULT16_16((int)a, Inlines.SHR(b, 16)), Inlines.SHR(Inlines.MULT16_16SU(a, b & 0xFFFF), 16))); - } - - static int MAC16_32_Q16(int c, int a, int b) { - return Inlines.ADD32(c, Inlines.ADD32(Inlines.MULT16_16(a, Inlines.SHR(b, 16)), Inlines.SHR(Inlines.MULT16_16SU(a, b & 0xFFFF), 16))); - } - - static int MULT16_16_Q11_32(short a, short b) { - return Inlines.SHR(Inlines.MULT16_16(a, b), 11); - } - - static int MULT16_16_Q11_32(int a, int b) { - return Inlines.SHR(Inlines.MULT16_16(a, b), 11); - } - - static short MULT16_16_Q11(short a, short b) { - return (short)Inlines.SHR(Inlines.MULT16_16(a, b), 11); - } - - static int MULT16_16_Q11(int a, int b) { - return Inlines.SHR(Inlines.MULT16_16(a, b), 11); - } - - static short MULT16_16_Q13(short a, short b) { - return (short)Inlines.SHR(Inlines.MULT16_16(a, b), 13); - } - - static int MULT16_16_Q13(int a, int b) { - return Inlines.SHR(Inlines.MULT16_16(a, b), 13); - } - - static short MULT16_16_Q14(short a, short b) { - return (short)Inlines.SHR(Inlines.MULT16_16(a, b), 14); - } - - static int MULT16_16_Q14(int a, int b) { - return Inlines.SHR(Inlines.MULT16_16(a, b), 14); - } - - static short MULT16_16_Q15(short a, short b) { - return (short)Inlines.SHR(Inlines.MULT16_16(a, b), 15); - } - - static int MULT16_16_Q15(int a, int b) { - return Inlines.SHR(Inlines.MULT16_16(a, b), 15); - } - - static short MULT16_16_P13(short a, short b) { - return (short)Inlines.SHR(Inlines.ADD32(4096, Inlines.MULT16_16(a, b)), 13); - } - - static int MULT16_16_P13(int a, int b) { - return Inlines.SHR(Inlines.ADD32(4096, Inlines.MULT16_16(a, b)), 13); - } - - static short MULT16_16_P14(short a, short b) { - return (short)Inlines.SHR(Inlines.ADD32(8192, Inlines.MULT16_16(a, b)), 14); - } - - static int MULT16_16_P14(int a, int b) { - return Inlines.SHR(Inlines.ADD32(8192, Inlines.MULT16_16(a, b)), 14); - } - - static short MULT16_16_P15(short a, short b) { - return (short)Inlines.SHR(Inlines.ADD32(16384, Inlines.MULT16_16(a, b)), 15); - } - - static int MULT16_16_P15(int a, int b) { - return Inlines.SHR(Inlines.ADD32(16384, Inlines.MULT16_16(a, b)), 15); - } - - static short DIV32_16(int a, short b) { - return (short)(a / b); - } - - static int DIV32_16(int a, int b) { - return a / b; - } - - static int DIV32(int a, int b) { - return a / b; - } - - static short SAT16(int x) { - return (short)(x > Short.MAX_VALUE ? Short.MAX_VALUE : (short)(x < Short.MIN_VALUE ? Short.MIN_VALUE : (short)x)); - } - - static short SIG2WORD16(int x) { - x = Inlines.PSHR32(x, 12); - x = Inlines.MAX32(x, Short.MIN_VALUE); - x = Inlines.MIN32(x, Short.MAX_VALUE); - return Inlines.EXTRACT16(x); - } - - static short MIN(short a, short b) { - return a < b ? a : b; - } - - static short MAX(short a, short b) { - return a > b ? a : b; - } - - static short MIN16(short a, short b) { - return a < b ? a : b; - } - - static short MAX16(short a, short b) { - return a > b ? a : b; - } - - static int MIN16(int a, int b) { - return a < b ? a : b; - } - - static int MAX16(int a, int b) { - return a > b ? a : b; - } - - static float MIN16(float a, float b) { - return a < b ? a : b; - } - - static float MAX16(float a, float b) { - return a > b ? a : b; - } - - static int MIN(int a, int b) { - return a < b ? a : b; - } - - static int MAX(int a, int b) { - return a > b ? a : b; - } - - static int IMIN(int a, int b) { - return a < b ? a : b; - } - - static long IMIN(long a, long b) { - return a < b ? a : b; - } - - static int IMAX(int a, int b) { - return a > b ? a : b; - } - - static int MIN32(int a, int b) { - return a < b ? a : b; - } - - static int MAX32(int a, int b) { - return a > b ? a : b; - } - - static float MIN32(float a, float b) { - return a < b ? a : b; - } - - static float MAX32(float a, float b) { - return a > b ? a : b; - } - - static int ABS16(int x) { - return x < 0 ? -x : x; - } - - static float ABS16(float x) { - return x < 0.0f ? -x : x; - } - - static short ABS16(short x) { - return x < 0 ? -x : x; - } - - static int ABS32(int x) { - return x < 0 ? -x : x; - } - - static int celt_udiv(int n, int d) { - Inlines.OpusAssert(d > 0); - return n / d; - } - - static int celt_sudiv(int n, int d) { - Inlines.OpusAssert(d > 0); - return n / d; - } - - static int celt_div(int a, int b) { - return Inlines.MULT32_32_Q31(a, Inlines.celt_rcp(b)); - } - - static int celt_ilog2(int x) { - Inlines.OpusAssert(x > 0, "celt_ilog2() only defined for strictly positive numbers"); - return Inlines.EC_ILOG(x) - 1; - } - - static int celt_zlog2(int x) { - return x <= 0 ? 0 : Inlines.celt_ilog2(x); - } - - static int celt_maxabs16(int[] x, int x_ptr, int len) { - int maxval = 0; - int minval = 0; - for (int i = x_ptr; i < len + x_ptr; ++i) { - maxval = Inlines.MAX32(maxval, x[i]); - minval = Inlines.MIN32(minval, x[i]); - } - return Inlines.MAX32(Inlines.EXTEND32(maxval), -Inlines.EXTEND32(minval)); - } - - static int celt_maxabs32(int[] x, int x_ptr, int len) { - int maxval = 0; - int minval = 0; - for (int i = x_ptr; i < x_ptr + len; ++i) { - maxval = Inlines.MAX32(maxval, x[i]); - minval = Inlines.MIN32(minval, x[i]); - } - return Inlines.MAX32(maxval, 0 - minval); - } - - static short celt_maxabs32(short[] x, int x_ptr, int len) { - short maxval = 0; - short minval = 0; - for (int i = x_ptr; i < x_ptr + len; ++i) { - maxval = Inlines.MAX16(maxval, x[i]); - minval = Inlines.MIN16(minval, x[i]); - } - return Inlines.MAX(maxval, (short)(0 - minval)); - } - - static int FRAC_MUL16(int a, int b) { - return 16384 + (short)a * (short)b >> 15; - } - - static int isqrt32(long _val) { - int g = 0; - int bshift = Inlines.EC_ILOG(_val) - 1 >> 1; - int b = 1 << bshift; - do { - long t; - if ((t = (long)((g << 1) + b << bshift)) <= _val) { - g += b; - _val -= t; - } - b >>= 1; - } while (--bshift >= 0); - return g; - } - - static int celt_sqrt(int x) { - if (x == 0) { - return 0; - } - if (x >= 0x40000000) { - return Short.MAX_VALUE; - } - int k = (Inlines.celt_ilog2(x) >> 1) - 7; - x = Inlines.VSHR32(x, 2 * k); - short n = (short)(x - 32768); - int rt = Inlines.ADD16(sqrt_C[0], Inlines.MULT16_16_Q15(n, Inlines.ADD16(sqrt_C[1], Inlines.MULT16_16_Q15(n, Inlines.ADD16(sqrt_C[2], Inlines.MULT16_16_Q15(n, Inlines.ADD16(sqrt_C[3], Inlines.MULT16_16_Q15(n, sqrt_C[4])))))))); - rt = Inlines.VSHR32(rt, 7 - k); - return rt; - } - - static int celt_rcp(int x) { - Inlines.OpusAssert(x > 0, "celt_rcp() only defined for positive values"); - int i = Inlines.celt_ilog2(x); - int n = Inlines.VSHR32(x, i - 15) - 32768; - int r = Inlines.ADD16(30840, Inlines.MULT16_16_Q15(-15420, n)); - r = Inlines.SUB16(r, Inlines.MULT16_16_Q15(r, Inlines.ADD16(Inlines.MULT16_16_Q15(r, n), Inlines.ADD16(r, Short.MIN_VALUE)))); - r = Inlines.SUB16(r, Inlines.ADD16(1, Inlines.MULT16_16_Q15(r, Inlines.ADD16(Inlines.MULT16_16_Q15(r, n), Inlines.ADD16(r, Short.MIN_VALUE))))); - return Inlines.VSHR32(Inlines.EXTEND32(r), i - 16); - } - - static int celt_rsqrt_norm(int x) { - int n = x - 32768; - int r = Inlines.ADD16(23557, Inlines.MULT16_16_Q15(n, Inlines.ADD16(-13490, Inlines.MULT16_16_Q15(n, 6713)))); - int r2 = Inlines.MULT16_16_Q15(r, r); - int y = Inlines.SHL16(Inlines.SUB16(Inlines.ADD16(Inlines.MULT16_16_Q15(r2, n), r2), 16384), 1); - return Inlines.ADD16(r, Inlines.MULT16_16_Q15(r, Inlines.MULT16_16_Q15(y, Inlines.SUB16(Inlines.MULT16_16_Q15(y, 12288), 16384)))); - } - - static int frac_div32(int a, int b) { - int shift = Inlines.celt_ilog2(b) - 29; - a = Inlines.VSHR32(a, shift); - b = Inlines.VSHR32(b, shift); - int rcp = Inlines.ROUND16(Inlines.celt_rcp(Inlines.ROUND16(b, 16)), 3); - int result = Inlines.MULT16_32_Q15(rcp, a); - int rem = Inlines.PSHR32(a, 2) - Inlines.MULT32_32_Q31(result, b); - if ((result = Inlines.ADD32(result, Inlines.SHL32(Inlines.MULT16_32_Q15(rcp, rem), 2))) >= 0x20000000) { - return Integer.MAX_VALUE; - } - if (result <= -536870912) { - return -2147483647; - } - return Inlines.SHL32(result, 2); - } - - static int celt_log2(int x) { - if (x == 0) { - return -32767; - } - int i = Inlines.celt_ilog2(x); - int n = Inlines.VSHR32(x, i - 15) - 32768 - 16384; - int frac = Inlines.ADD16((int)log2_C0, Inlines.MULT16_16_Q15(n, Inlines.ADD16(15746, Inlines.MULT16_16_Q15(n, Inlines.ADD16(-5217, Inlines.MULT16_16_Q15(n, Inlines.ADD16(2545, Inlines.MULT16_16_Q15(n, -1401)))))))); - return Inlines.SHL16((short)(i - 13), 10) + Inlines.SHR16(frac, 4); - } - - static int celt_exp2_frac(int x) { - int frac = Inlines.SHL16(x, 4); - return Inlines.ADD16(16383, Inlines.MULT16_16_Q15(frac, Inlines.ADD16(22804, Inlines.MULT16_16_Q15(frac, Inlines.ADD16(14819, Inlines.MULT16_16_Q15(10204, frac)))))); - } - - static int celt_exp2(int x) { - int integer = Inlines.SHR16(x, 10); - if (integer > 14) { - return 0x7F000000; - } - if (integer < -15) { - return 0; - } - short frac = (short)Inlines.celt_exp2_frac((short)(x - Inlines.SHL16((short)integer, 10))); - return Inlines.VSHR32(Inlines.EXTEND32((int)frac), -integer - 2); - } - - static int celt_atan01(int x) { - return Inlines.MULT16_16_P15(x, Inlines.ADD32(Short.MAX_VALUE, Inlines.MULT16_16_P15(x, Inlines.ADD32(-21, Inlines.MULT16_16_P15(x, Inlines.ADD32(-11943, Inlines.MULT16_16_P15(4936, x))))))); - } - - static int celt_atan2p(int y, int x) { - if (y < x) { - int arg = Inlines.celt_div(Inlines.SHL32(Inlines.EXTEND32(y), 15), x); - if (arg >= Short.MAX_VALUE) { - arg = Short.MAX_VALUE; - } - return Inlines.SHR32(Inlines.celt_atan01(Inlines.EXTRACT16(arg)), 1); - } - int arg = Inlines.celt_div(Inlines.SHL32(Inlines.EXTEND32(x), 15), y); - if (arg >= Short.MAX_VALUE) { - arg = Short.MAX_VALUE; - } - return 25736 - Inlines.SHR16(Inlines.celt_atan01(Inlines.EXTRACT16(arg)), 1); - } - - static int celt_cos_norm(int x) { - if ((x &= 0x1FFFF) > Inlines.SHL32(Inlines.EXTEND32(1), 16)) { - x = Inlines.SUB32(Inlines.SHL32(Inlines.EXTEND32(1), 17), x); - } - if ((x & Short.MAX_VALUE) != 0) { - if (x < Inlines.SHL32(Inlines.EXTEND32(1), 15)) { - return Inlines._celt_cos_pi_2(Inlines.EXTRACT16(x)); - } - return Inlines.NEG32(Inlines._celt_cos_pi_2(Inlines.EXTRACT16(65536 - x))); - } - if ((x & 0xFFFF) != 0) { - return 0; - } - if ((x & 0x1FFFF) != 0) { - return -32767; - } - return Short.MAX_VALUE; - } - - static int _celt_cos_pi_2(int x) { - int x2 = Inlines.MULT16_16_P15(x, x); - return Inlines.ADD32(1, Inlines.MIN32(32766, Inlines.ADD32(Inlines.SUB16(Short.MAX_VALUE, x2), Inlines.MULT16_16_P15(x2, Inlines.ADD32(-7651, Inlines.MULT16_16_P15(x2, Inlines.ADD32(8277, Inlines.MULT16_16_P15(-626, x2)))))))); - } - - static short FLOAT2INT16(float x) { - if ((x *= 32768.0f) < -32768.0f) { - x = -32768.0f; - } - if (x > 32767.0f) { - x = 32767.0f; - } - return (short)x; - } - - static int silk_ROR32(int a32, int rot) { - int m = 0 - rot; - if (rot == 0) { - return a32; - } - if (rot < 0) { - return a32 << m | a32 >> 32 - m; - } - return a32 << 32 - rot | a32 >> rot; - } - - static int silk_MUL(int a32, int b32) { - int ret = a32 * b32; - return ret; - } - - static int silk_MLA(int a32, int b32, int c32) { - int ret = Inlines.silk_ADD32(a32, b32 * c32); - Inlines.OpusAssert((long)ret == (long)a32 + (long)b32 * (long)c32); - return ret; - } - - static int silk_SMULTT(int a32, int b32) { - return (a32 >> 16) * (b32 >> 16); - } - - static int silk_SMLATT(int a32, int b32, int c32) { - return Inlines.silk_ADD32(a32, (b32 >> 16) * (c32 >> 16)); - } - - static long silk_SMLALBB(long a64, short b16, short c16) { - return Inlines.silk_ADD64(a64, b16 * c16); - } - - static long silk_SMULL(int a32, int b32) { - return (long)a32 * (long)b32; - } - - static int silk_ADD32_ovflw(int a, int b) { - return (int)((long)a + (long)b); - } - - static int silk_ADD32_ovflw(long a, long b) { - return (int)(a + b); - } - - static int silk_SUB32_ovflw(int a, int b) { - return (int)((long)a - (long)b); - } - - static int silk_MLA_ovflw(int a32, int b32, int c32) { - return Inlines.silk_ADD32_ovflw((long)a32, (long)b32 * (long)c32); - } - - static int silk_SMLABB_ovflw(int a32, int b32, int c32) { - return Inlines.silk_ADD32_ovflw(a32, (short)b32 * (short)c32); - } - - static int silk_SMULBB(int a32, int b32) { - return (short)a32 * (short)b32; - } - - static int silk_SMULWB(int a32, int b32) { - return (int)((long)a32 * (long)((short)b32) >> 16); - } - - static int silk_SMLABB(int a32, int b32, int c32) { - return a32 + (short)b32 * (short)c32; - } - - static int silk_DIV32_16(int a32, int b32) { - return a32 / b32; - } - - static int silk_DIV32(int a32, int b32) { - return a32 / b32; - } - - static short silk_ADD16(short a, short b) { - short ret = (short)(a + b); - return ret; - } - - static int silk_ADD32(int a, int b) { - int ret = a + b; - return ret; - } - - static long silk_ADD64(long a, long b) { - long ret = a + b; - Inlines.OpusAssert(ret == Inlines.silk_ADD_SAT64(a, b)); - return ret; - } - - static short silk_SUB16(short a, short b) { - short ret = (short)(a - b); - Inlines.OpusAssert(ret == Inlines.silk_SUB_SAT16(a, b)); - return ret; - } - - static int silk_SUB32(int a, int b) { - int ret = a - b; - Inlines.OpusAssert(ret == Inlines.silk_SUB_SAT32(a, b)); - return ret; - } - - static long silk_SUB64(long a, long b) { - long ret = a - b; - Inlines.OpusAssert(ret == Inlines.silk_SUB_SAT64(a, b)); - return ret; - } - - static int silk_SAT8(int a) { - return a > 127 ? 127 : (a < -128 ? -128 : a); - } - - static int silk_SAT16(int a) { - return a > Short.MAX_VALUE ? Short.MAX_VALUE : (a < Short.MIN_VALUE ? Short.MIN_VALUE : a); - } - - static int silk_SAT32(long a) { - return a > Integer.MAX_VALUE ? Integer.MAX_VALUE : (a < Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)a); - } - - static short silk_ADD_SAT16(short a16, short b16) { - short res = (short)Inlines.silk_SAT16(Inlines.silk_ADD32(a16, b16)); - Inlines.OpusAssert(res == Inlines.silk_SAT16(a16 + b16)); - return res; - } - - static int silk_ADD_SAT32(int a32, int b32) { - int res = ((long)a32 + (long)b32 & Integer.MIN_VALUE) == 0L ? ((a32 & b32 & Integer.MIN_VALUE) != 0 ? Integer.MIN_VALUE : a32 + b32) : (((a32 | b32) & Integer.MIN_VALUE) == 0 ? Integer.MAX_VALUE : a32 + b32); - Inlines.OpusAssert(res == Inlines.silk_SAT32((long)a32 + (long)b32)); - return res; - } - - static long silk_ADD_SAT64(long a64, long b64) { - long res = (a64 + b64 & Long.MIN_VALUE) == 0L ? ((a64 & b64 & Long.MIN_VALUE) != 0L ? Long.MIN_VALUE : a64 + b64) : (((a64 | b64) & Long.MIN_VALUE) == 0L ? Long.MAX_VALUE : a64 + b64); - return res; - } - - static short silk_SUB_SAT16(short a16, short b16) { - short res = (short)Inlines.silk_SAT16(Inlines.silk_SUB32(a16, b16)); - Inlines.OpusAssert(res == Inlines.silk_SAT16(a16 - b16)); - return res; - } - - static int silk_SUB_SAT32(int a32, int b32) { - int res = ((long)a32 - (long)b32 & Integer.MIN_VALUE) == 0L ? ((a32 & (b32 ^ Integer.MIN_VALUE) & Integer.MIN_VALUE) != 0 ? Integer.MIN_VALUE : a32 - b32) : (((a32 ^ Integer.MIN_VALUE) & b32 & Integer.MIN_VALUE) != 0 ? Integer.MAX_VALUE : a32 - b32); - Inlines.OpusAssert(res == Inlines.silk_SAT32((long)a32 - (long)b32)); - return res; - } - - static long silk_SUB_SAT64(long a64, long b64) { - long res = (a64 - b64 & Long.MIN_VALUE) == 0L ? ((a64 & (b64 ^ Long.MIN_VALUE) & Long.MIN_VALUE) != 0L ? Long.MIN_VALUE : a64 - b64) : (((a64 ^ Long.MIN_VALUE) & b64 & Long.MIN_VALUE) != 0L ? Long.MAX_VALUE : a64 - b64); - return res; - } - - static byte silk_ADD_POS_SAT8(byte a, byte b) { - return (byte)((a + b & 0x80) != 0 ? 127 : a + b); - } - - static short silk_ADD_POS_SAT16(short a, short b) { - return (short)((a + b & 0x8000) != 0 ? Short.MAX_VALUE : a + b); - } - - static int silk_ADD_POS_SAT32(int a, int b) { - return (a + b & Integer.MIN_VALUE) != 0 ? Integer.MAX_VALUE : a + b; - } - - static long silk_ADD_POS_SAT64(long a, long b) { - return (a + b & Long.MIN_VALUE) != 0L ? Long.MAX_VALUE : a + b; - } - - static byte silk_LSHIFT8(byte a, int shift) { - byte ret = (byte)(a << shift); - return ret; - } - - static short silk_LSHIFT16(short a, int shift) { - short ret = (short)(a << shift); - return ret; - } - - static int silk_LSHIFT32(int a, int shift) { - int ret = a << shift; - return ret; - } - - static long silk_LSHIFT64(long a, int shift) { - long ret = a << shift; - return ret; - } - - static int silk_LSHIFT(int a, int shift) { - int ret = a << shift; - return ret; - } - - static int silk_LSHIFT_ovflw(int a, int shift) { - return a << shift; - } - - static int silk_LSHIFT_SAT32(int a, int shift) { - return Inlines.silk_LSHIFT32(Inlines.silk_LIMIT(a, Inlines.silk_RSHIFT32(Integer.MIN_VALUE, shift), Inlines.silk_RSHIFT32(Integer.MAX_VALUE, shift)), shift); - } - - static byte silk_RSHIFT8(byte a, int shift) { - return (byte)(a >> shift); - } - - static short silk_RSHIFT16(short a, int shift) { - return (short)(a >> shift); - } - - static int silk_RSHIFT32(int a, int shift) { - return a >> shift; - } - - static int silk_RSHIFT(int a, int shift) { - return a >> shift; - } - - static long silk_RSHIFT64(long a, int shift) { - return a >> shift; - } - - static long silk_RSHIFT_uint(long a, int shift) { - return Inlines.CapToUInt32(a) >> shift; - } - - static int silk_ADD_LSHIFT(int a, int b, int shift) { - int ret = a + (b << shift); - return ret; - } - - static int silk_ADD_LSHIFT32(int a, int b, int shift) { - int ret = a + (b << shift); - return ret; - } - - static int silk_ADD_RSHIFT(int a, int b, int shift) { - int ret = a + (b >> shift); - return ret; - } - - static int silk_ADD_RSHIFT32(int a, int b, int shift) { - int ret = a + (b >> shift); - return ret; - } - - static long silk_ADD_RSHIFT_uint(long a, long b, int shift) { - long ret = Inlines.CapToUInt32(a + (Inlines.CapToUInt32(b) >> shift)); - return ret; - } - - static int silk_SUB_LSHIFT32(int a, int b, int shift) { - int ret = a - (b << shift); - return ret; - } - - static int silk_SUB_RSHIFT32(int a, int b, int shift) { - int ret = a - (b >> shift); - return ret; - } - - static int silk_RSHIFT_ROUND(int a, int shift) { - int ret = shift == 1 ? (a >> 1) + (a & 1) : (a >> shift - 1) + 1 >> 1; - return ret; - } - - static long silk_RSHIFT_ROUND64(long a, int shift) { - long ret = shift == 1 ? (a >> 1) + (a & 1L) : (a >> shift - 1) + 1L >> 1; - return ret; - } - - static int silk_min(int a, int b) { - return a < b ? a : b; - } - - static int silk_max(int a, int b) { - return a > b ? a : b; - } - - static float silk_min(float a, float b) { - return a < b ? a : b; - } - - static float silk_max(float a, float b) { - return a > b ? a : b; - } - - static int SILK_CONST(float number, int scale) { - return (int)((double)(number * (float)(1L << scale)) + 0.5); - } - - static int silk_min_int(int a, int b) { - return a < b ? a : b; - } - - static short silk_min_16(short a, short b) { - return a < b ? a : b; - } - - static int silk_min_32(int a, int b) { - return a < b ? a : b; - } - - static long silk_min_64(long a, long b) { - return a < b ? a : b; - } - - static int silk_max_int(int a, int b) { - return a > b ? a : b; - } - - static short silk_max_16(short a, short b) { - return a > b ? a : b; - } - - static int silk_max_32(int a, int b) { - return a > b ? a : b; - } - - static long silk_max_64(long a, long b) { - return a > b ? a : b; - } - - static float silk_LIMIT(float a, float limit1, float limit2) { - return limit1 > limit2 ? (a > limit1 ? limit1 : (a < limit2 ? limit2 : a)) : (a > limit2 ? limit2 : (a < limit1 ? limit1 : a)); - } - - static int silk_LIMIT(int a, int limit1, int limit2) { - return Inlines.silk_LIMIT_32(a, limit1, limit2); - } - - static int silk_LIMIT_int(int a, int limit1, int limit2) { - return Inlines.silk_LIMIT_32(a, limit1, limit2); - } - - static short silk_LIMIT_16(short a, short limit1, short limit2) { - return limit1 > limit2 ? (a > limit1 ? limit1 : (a < limit2 ? limit2 : a)) : (a > limit2 ? limit2 : (a < limit1 ? limit1 : a)); - } - - static int silk_LIMIT_32(int a, int limit1, int limit2) { - return limit1 > limit2 ? (a > limit1 ? limit1 : (a < limit2 ? limit2 : a)) : (a > limit2 ? limit2 : (a < limit1 ? limit1 : a)); - } - - static int silk_abs(int a) { - return a > 0 ? a : -a; - } - - static int silk_abs_int16(int a) { - return (a ^ a >> 15) - (a >> 15); - } - - static int silk_abs_int32(int a) { - return (a ^ a >> 31) - (a >> 31); - } - - static long silk_abs_int64(long a) { - return a > 0L ? a : -a; - } - - static long silk_sign(int a) { - return a > 0 ? 1L : (long)(a < 0 ? -1 : 0); - } - - static int silk_RAND(int seed) { - return Inlines.silk_MLA_ovflw(907633515, seed, 196314165); - } - - static int silk_SMMUL(int a32, int b32) { - return (int)Inlines.silk_RSHIFT64(Inlines.silk_SMULL(a32, b32), 32); - } - - static int silk_SMLAWT(int a32, int b32, int c32) { - int ret = a32 + (b32 >> 16) * (c32 >> 16) + ((b32 & 0xFFFF) * (c32 >> 16) >> 16); - return ret; - } - - static int silk_DIV32_varQ(int a32, int b32, int Qres) { - Inlines.OpusAssert(b32 != 0); - Inlines.OpusAssert(Qres >= 0); - int a_headrm = Inlines.silk_CLZ32(Inlines.silk_abs(a32)) - 1; - int a32_nrm = Inlines.silk_LSHIFT(a32, a_headrm); - int b_headrm = Inlines.silk_CLZ32(Inlines.silk_abs(b32)) - 1; - int b32_nrm = Inlines.silk_LSHIFT(b32, b_headrm); - int b32_inv = Inlines.silk_DIV32_16(0x1FFFFFFF, Inlines.silk_RSHIFT(b32_nrm, 16)); - int result = Inlines.silk_SMULWB(a32_nrm, b32_inv); - a32_nrm = Inlines.silk_SUB32_ovflw(a32_nrm, Inlines.silk_LSHIFT_ovflw(Inlines.silk_SMMUL(b32_nrm, result), 3)); - result = Inlines.silk_SMLAWB(result, a32_nrm, b32_inv); - int lshift = 29 + a_headrm - b_headrm - Qres; - if (lshift < 0) { - return Inlines.silk_LSHIFT_SAT32(result, -lshift); - } - if (lshift < 32) { - return Inlines.silk_RSHIFT(result, lshift); - } - return 0; - } - - static int silk_INVERSE32_varQ(int b32, int Qres) { - Inlines.OpusAssert(b32 != 0); - Inlines.OpusAssert(Qres > 0); - int b_headrm = Inlines.silk_CLZ32(Inlines.silk_abs(b32)) - 1; - int b32_nrm = Inlines.silk_LSHIFT(b32, b_headrm); - int b32_inv = Inlines.silk_DIV32_16(0x1FFFFFFF, (short)Inlines.silk_RSHIFT(b32_nrm, 16)); - int result = Inlines.silk_LSHIFT(b32_inv, 16); - int err_Q32 = Inlines.silk_LSHIFT(0x20000000 - Inlines.silk_SMULWB(b32_nrm, b32_inv), 3); - result = Inlines.silk_SMLAWW(result, err_Q32, b32_inv); - int lshift = 61 - b_headrm - Qres; - if (lshift <= 0) { - return Inlines.silk_LSHIFT_SAT32(result, -lshift); - } - if (lshift < 32) { - return Inlines.silk_RSHIFT(result, lshift); - } - return 0; - } - - static int silk_SMLAWB(int a32, int b32, int c32) { - int ret = a32 + Inlines.silk_SMULWB(b32, c32); - return ret; - } - - static int silk_SMULWT(int a32, int b32) { - return (a32 >> 16) * (b32 >> 16) + ((a32 & 0xFFFF) * (b32 >> 16) >> 16); - } - - static int silk_SMULBT(int a32, int b32) { - return (short)a32 * (b32 >> 16); - } - - static int silk_SMLABT(int a32, int b32, int c32) { - return a32 + (short)b32 * (c32 >> 16); - } - - static long silk_SMLAL(long a64, int b32, int c32) { - return Inlines.silk_ADD64(a64, (long)b32 * (long)c32); - } - - static int MatrixGetPointer(int row, int column, int N) { - return row * N + column; - } - - static int MatrixGet(int[] Matrix_base_adr, int row, int column, int N) { - return Matrix_base_adr[row * N + column]; - } - - static short MatrixGet(short[] Matrix_base_adr, int row, int column, int N) { - return Matrix_base_adr[row * N + column]; - } - - static PitchAnalysisCore.silk_pe_stage3_vals MatrixGet(PitchAnalysisCore.silk_pe_stage3_vals[] Matrix_base_adr, int row, int column, int N) { - return Matrix_base_adr[row * N + column]; - } - - static int MatrixGet(int[] Matrix_base_adr, int matrix_ptr, int row, int column, int N) { - return Matrix_base_adr[matrix_ptr + row * N + column]; - } - - static short MatrixGet(short[] Matrix_base_adr, int matrix_ptr, int row, int column, int N) { - return Matrix_base_adr[matrix_ptr + row * N + column]; - } - - static void MatrixSet(int[] Matrix_base_adr, int matrix_ptr, int row, int column, int N, int value) { - Matrix_base_adr[matrix_ptr + row * N + column] = value; - } - - static void MatrixSet(short[] Matrix_base_adr, int matrix_ptr, int row, int column, int N, short value) { - Matrix_base_adr[matrix_ptr + row * N + column] = value; - } - - static void MatrixSet(int[] Matrix_base_adr, int row, int column, int N, int value) { - Matrix_base_adr[row * N + column] = value; - } - - static void MatrixSet(short[] Matrix_base_adr, int row, int column, int N, short value) { - Matrix_base_adr[row * N + column] = value; - } - - static int silk_SMULWW(int a32, int b32) { - return Inlines.silk_MLA(Inlines.silk_SMULWB(a32, b32), a32, Inlines.silk_RSHIFT_ROUND(b32, 16)); - } - - static int silk_SMLAWW(int a32, int b32, int c32) { - return Inlines.silk_MLA(Inlines.silk_SMLAWB(a32, b32, c32), b32, Inlines.silk_RSHIFT_ROUND(c32, 16)); - } - - static int silk_CLZ64(long input) { - int in_upper = (int)Inlines.silk_RSHIFT64(input, 32); - if (in_upper == 0) { - return 32 + Inlines.silk_CLZ32((int)input); - } - return Inlines.silk_CLZ32(in_upper); - } - - static int silk_CLZ32(int in32) { - return in32 == 0 ? 32 : 32 - Inlines.EC_ILOG(in32); - } - - static void silk_CLZ_FRAC(int input, BoxedValueInt lz, BoxedValueInt frac_Q7) { - int lzeros; - lz.Val = lzeros = Inlines.silk_CLZ32(input); - frac_Q7.Val = Inlines.silk_ROR32(input, 24 - lzeros) & 0x7F; - } - - static int silk_SQRT_APPROX(int x) { - if (x <= 0) { - return 0; - } - BoxedValueInt boxed_lz = new BoxedValueInt(0); - BoxedValueInt boxed_frac_Q7 = new BoxedValueInt(0); - Inlines.silk_CLZ_FRAC(x, boxed_lz, boxed_frac_Q7); - int lz = boxed_lz.Val; - int frac_Q7 = boxed_frac_Q7.Val; - int y = (lz & 1) != 0 ? 32768 : 46214; - y >>= Inlines.silk_RSHIFT(lz, 1); - y = Inlines.silk_SMLAWB(y, y, Inlines.silk_SMULBB(213, frac_Q7)); - return y; - } - - static int MUL32_FRAC_Q(int a32, int b32, int Q) { - return (int)Inlines.silk_RSHIFT_ROUND64(Inlines.silk_SMULL(a32, b32), Q); - } - - static int silk_lin2log(int inLin) { - BoxedValueInt lz = new BoxedValueInt(0); - BoxedValueInt frac_Q7 = new BoxedValueInt(0); - Inlines.silk_CLZ_FRAC(inLin, lz, frac_Q7); - return Inlines.silk_LSHIFT(31 - lz.Val, 7) + Inlines.silk_SMLAWB(frac_Q7.Val, Inlines.silk_MUL(frac_Q7.Val, 128 - frac_Q7.Val), 179); - } - - static int silk_log2lin(int inLog_Q7) { - if (inLog_Q7 < 0) { - return 0; - } - if (inLog_Q7 >= 3967) { - return Integer.MAX_VALUE; - } - int output = Inlines.silk_LSHIFT(1, Inlines.silk_RSHIFT(inLog_Q7, 7)); - int frac_Q7 = inLog_Q7 & 0x7F; - output = inLog_Q7 < 2048 ? Inlines.silk_ADD_RSHIFT32(output, Inlines.silk_MUL(output, Inlines.silk_SMLAWB(frac_Q7, Inlines.silk_SMULBB(frac_Q7, 128 - frac_Q7), -174)), 7) : Inlines.silk_MLA(output, Inlines.silk_RSHIFT(output, 7), Inlines.silk_SMLAWB(frac_Q7, Inlines.silk_SMULBB(frac_Q7, 128 - frac_Q7), -174)); - return output; - } - - static void silk_interpolate(short[] xi, short[] x0, short[] x1, int ifact_Q2, int d) { - Inlines.OpusAssert(ifact_Q2 >= 0); - Inlines.OpusAssert(ifact_Q2 <= 4); - for (int i = 0; i < d; ++i) { - xi[i] = (short)Inlines.silk_ADD_RSHIFT(x0[i], Inlines.silk_SMULBB(x1[i] - x0[i], ifact_Q2), 2); - } - } - - static int silk_inner_prod_aligned_scale(short[] inVec1, short[] inVec2, int scale, int len) { - int sum = 0; - for (int i = 0; i < len; ++i) { - sum = Inlines.silk_ADD_RSHIFT32(sum, Inlines.silk_SMULBB(inVec1[i], inVec2[i]), scale); - } - return sum; - } - - static void silk_scale_copy_vector16(short[] data_out, int data_out_ptr, short[] data_in, int data_in_ptr, int gain_Q16, int dataSize) { - for (int i = 0; i < dataSize; ++i) { - data_out[data_out_ptr + i] = (short)Inlines.silk_SMULWB(gain_Q16, data_in[data_in_ptr + i]); - } - } - - static void silk_scale_vector32_Q26_lshift_18(int[] data1, int data1_ptr, int gain_Q26, int dataSize) { - for (int i = data1_ptr; i < data1_ptr + dataSize; ++i) { - data1[i] = (int)Inlines.silk_RSHIFT64(Inlines.silk_SMULL(data1[i], gain_Q26), 8); - } - } - - static int silk_inner_prod(short[] inVec1, int inVec1_ptr, short[] inVec2, int inVec2_ptr, int len) { - int xy = 0; - for (int i = 0; i < len; ++i) { - xy = Inlines.MAC16_16(xy, inVec1[inVec1_ptr + i], inVec2[inVec2_ptr + i]); - } - return xy; - } - - static int silk_inner_prod_self(short[] inVec, int inVec_ptr, int len) { - int xy = 0; - for (int i = inVec_ptr; i < inVec_ptr + len; ++i) { - xy = Inlines.MAC16_16(xy, inVec[i], inVec[i]); - } - return xy; - } - - static long silk_inner_prod16_aligned_64(short[] inVec1, int inVec1_ptr, short[] inVec2, int inVec2_ptr, int len) { - long sum = 0L; - for (int i = 0; i < len; ++i) { - sum = Inlines.silk_SMLALBB(sum, inVec1[inVec1_ptr + i], inVec2[inVec2_ptr + i]); - } - return sum; - } - - static long EC_MINI(long a, long b) { - return a + (b - a & (long)(b < a ? -1 : 0)); - } - - static int EC_ILOG(long x) { - if (x == 0L) { - return 1; - } - x |= x >> 1; - x |= x >> 2; - x |= x >> 4; - x |= x >> 8; - x |= x >> 16; - long y = x - (x >> 1 & 0x55555555L); - y = (y >> 2 & 0x33333333L) + (y & 0x33333333L); - y = (y >> 4) + y & 0xF0F0F0FL; - y += y >> 8; - y += y >> 16; - return (int)(y &= 0x3FL); - } - - static int abs(int a) { - if (a < 0) { - return 0 - a; - } - return a; - } - - static int SignedByteToUnsignedInt(byte b) { - return b & 0xFF; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/K2A.java b/source/decompiled/de/maxhenkel/voicechat/concentus/K2A.java deleted file mode 100644 index 6908a7c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/K2A.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class K2A { - K2A() { - } - - static void silk_k2a(int[] A_Q24, short[] rc_Q15, int order) { - int[] Atmp = new int[16]; - for (int k = 0; k < order; ++k) { - int n; - for (n = 0; n < k; ++n) { - Atmp[n] = A_Q24[n]; - } - for (n = 0; n < k; ++n) { - A_Q24[n] = Inlines.silk_SMLAWB(A_Q24[n], Inlines.silk_LSHIFT(Atmp[k - n - 1], 1), rc_Q15[k]); - } - A_Q24[k] = 0 - Inlines.silk_LSHIFT(rc_Q15[k], 9); - } - } - - static void silk_k2a_Q16(int[] A_Q24, int[] rc_Q16, int order) { - int[] Atmp = new int[16]; - for (int k = 0; k < order; ++k) { - int n; - for (n = 0; n < k; ++n) { - Atmp[n] = A_Q24[n]; - } - for (n = 0; n < k; ++n) { - A_Q24[n] = Inlines.silk_SMLAWW(A_Q24[n], Atmp[k - n - 1], rc_Q16[k]); - } - A_Q24[k] = 0 - Inlines.silk_LSHIFT(rc_Q16[k], 8); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Kernels.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Kernels.java deleted file mode 100644 index 8e69f8a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Kernels.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; - -class Kernels { - Kernels() { - } - - static void celt_fir(short[] x, int x_ptr, short[] num, short[] y, int y_ptr, int N, int ord, short[] mem) { - int i; - short[] rnum = new short[ord]; - short[] local_x = new short[N + ord]; - for (i = 0; i < ord; ++i) { - rnum[i] = num[ord - i - 1]; - } - for (i = 0; i < ord; ++i) { - local_x[i] = mem[ord - i - 1]; - } - for (i = 0; i < N; ++i) { - local_x[i + ord] = x[x_ptr + i]; - } - for (i = 0; i < ord; ++i) { - mem[i] = x[x_ptr + N - i - 1]; - } - BoxedValueInt sum0 = new BoxedValueInt(0); - BoxedValueInt sum1 = new BoxedValueInt(0); - BoxedValueInt sum2 = new BoxedValueInt(0); - BoxedValueInt sum3 = new BoxedValueInt(0); - for (i = 0; i < N - 3; i += 4) { - sum0.Val = 0; - sum1.Val = 0; - sum2.Val = 0; - sum3.Val = 0; - Kernels.xcorr_kernel(rnum, 0, local_x, i, sum0, sum1, sum2, sum3, ord); - y[y_ptr + i] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i]), Inlines.PSHR32(sum0.Val, 12))); - y[y_ptr + i + 1] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i + 1]), Inlines.PSHR32(sum1.Val, 12))); - y[y_ptr + i + 2] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i + 2]), Inlines.PSHR32(sum2.Val, 12))); - y[y_ptr + i + 3] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i + 3]), Inlines.PSHR32(sum3.Val, 12))); - } - while (i < N) { - int sum = 0; - for (int j = 0; j < ord; ++j) { - sum = Inlines.MAC16_16(sum, rnum[j], local_x[i + j]); - } - y[y_ptr + i] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i]), Inlines.PSHR32(sum, 12))); - ++i; - } - } - - static void celt_fir(int[] x, int x_ptr, int[] num, int num_ptr, int[] y, int y_ptr, int N, int ord, int[] mem) { - int i; - int[] rnum = new int[ord]; - int[] local_x = new int[N + ord]; - for (i = 0; i < ord; ++i) { - rnum[i] = num[num_ptr + ord - i - 1]; - } - for (i = 0; i < ord; ++i) { - local_x[i] = mem[ord - i - 1]; - } - for (i = 0; i < N; ++i) { - local_x[i + ord] = x[x_ptr + i]; - } - for (i = 0; i < ord; ++i) { - mem[i] = x[x_ptr + N - i - 1]; - } - BoxedValueInt sum0 = new BoxedValueInt(0); - BoxedValueInt sum1 = new BoxedValueInt(0); - BoxedValueInt sum2 = new BoxedValueInt(0); - BoxedValueInt sum3 = new BoxedValueInt(0); - for (i = 0; i < N - 3; i += 4) { - sum0.Val = 0; - sum1.Val = 0; - sum2.Val = 0; - sum3.Val = 0; - Kernels.xcorr_kernel(rnum, local_x, i, sum0, sum1, sum2, sum3, ord); - y[y_ptr + i] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i]), Inlines.PSHR32(sum0.Val, 12))); - y[y_ptr + i + 1] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i + 1]), Inlines.PSHR32(sum1.Val, 12))); - y[y_ptr + i + 2] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i + 2]), Inlines.PSHR32(sum2.Val, 12))); - y[y_ptr + i + 3] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i + 3]), Inlines.PSHR32(sum3.Val, 12))); - } - while (i < N) { - int sum = 0; - for (int j = 0; j < ord; ++j) { - sum = Inlines.MAC16_16(sum, rnum[j], local_x[i + j]); - } - y[y_ptr + i] = Inlines.SATURATE16(Inlines.ADD32(Inlines.EXTEND32(x[x_ptr + i]), Inlines.PSHR32(sum, 12))); - ++i; - } - } - - static void xcorr_kernel(short[] x, int x_ptr, short[] y, int y_ptr, BoxedValueInt _sum0, BoxedValueInt _sum1, BoxedValueInt _sum2, BoxedValueInt _sum3, int len) { - short tmp; - int j; - int sum0 = _sum0.Val; - int sum1 = _sum1.Val; - int sum2 = _sum2.Val; - int sum3 = _sum3.Val; - Inlines.OpusAssert(len >= 3); - short y_3 = 0; - short y_0 = y[y_ptr++]; - short y_1 = y[y_ptr++]; - short y_2 = y[y_ptr++]; - for (j = 0; j < len - 3; j += 4) { - tmp = x[x_ptr++]; - y_3 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_0); - sum1 = Inlines.MAC16_16(sum1, tmp, y_1); - sum2 = Inlines.MAC16_16(sum2, tmp, y_2); - sum3 = Inlines.MAC16_16(sum3, tmp, y_3); - tmp = x[x_ptr++]; - y_0 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_1); - sum1 = Inlines.MAC16_16(sum1, tmp, y_2); - sum2 = Inlines.MAC16_16(sum2, tmp, y_3); - sum3 = Inlines.MAC16_16(sum3, tmp, y_0); - tmp = x[x_ptr++]; - y_1 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_2); - sum1 = Inlines.MAC16_16(sum1, tmp, y_3); - sum2 = Inlines.MAC16_16(sum2, tmp, y_0); - sum3 = Inlines.MAC16_16(sum3, tmp, y_1); - tmp = x[x_ptr++]; - y_2 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_3); - sum1 = Inlines.MAC16_16(sum1, tmp, y_0); - sum2 = Inlines.MAC16_16(sum2, tmp, y_1); - sum3 = Inlines.MAC16_16(sum3, tmp, y_2); - } - if (j++ < len) { - tmp = x[x_ptr++]; - y_3 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_0); - sum1 = Inlines.MAC16_16(sum1, tmp, y_1); - sum2 = Inlines.MAC16_16(sum2, tmp, y_2); - sum3 = Inlines.MAC16_16(sum3, tmp, y_3); - } - if (j++ < len) { - tmp = x[x_ptr++]; - y_0 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_1); - sum1 = Inlines.MAC16_16(sum1, tmp, y_2); - sum2 = Inlines.MAC16_16(sum2, tmp, y_3); - sum3 = Inlines.MAC16_16(sum3, tmp, y_0); - } - if (j < len) { - tmp = x[x_ptr++]; - y_1 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_2); - sum1 = Inlines.MAC16_16(sum1, tmp, y_3); - sum2 = Inlines.MAC16_16(sum2, tmp, y_0); - sum3 = Inlines.MAC16_16(sum3, tmp, y_1); - } - _sum0.Val = sum0; - _sum1.Val = sum1; - _sum2.Val = sum2; - _sum3.Val = sum3; - } - - static void xcorr_kernel(int[] x, int[] y, int y_ptr, BoxedValueInt _sum0, BoxedValueInt _sum1, BoxedValueInt _sum2, BoxedValueInt _sum3, int len) { - int tmp; - int j; - int sum0 = _sum0.Val; - int sum1 = _sum1.Val; - int sum2 = _sum2.Val; - int sum3 = _sum3.Val; - int x_ptr = 0; - Inlines.OpusAssert(len >= 3); - int y_3 = 0; - int y_0 = y[y_ptr++]; - int y_1 = y[y_ptr++]; - int y_2 = y[y_ptr++]; - for (j = 0; j < len - 3; j += 4) { - tmp = x[x_ptr++]; - y_3 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_0); - sum1 = Inlines.MAC16_16(sum1, tmp, y_1); - sum2 = Inlines.MAC16_16(sum2, tmp, y_2); - sum3 = Inlines.MAC16_16(sum3, tmp, y_3); - tmp = x[x_ptr++]; - y_0 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_1); - sum1 = Inlines.MAC16_16(sum1, tmp, y_2); - sum2 = Inlines.MAC16_16(sum2, tmp, y_3); - sum3 = Inlines.MAC16_16(sum3, tmp, y_0); - tmp = x[x_ptr++]; - y_1 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_2); - sum1 = Inlines.MAC16_16(sum1, tmp, y_3); - sum2 = Inlines.MAC16_16(sum2, tmp, y_0); - sum3 = Inlines.MAC16_16(sum3, tmp, y_1); - tmp = x[x_ptr++]; - y_2 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_3); - sum1 = Inlines.MAC16_16(sum1, tmp, y_0); - sum2 = Inlines.MAC16_16(sum2, tmp, y_1); - sum3 = Inlines.MAC16_16(sum3, tmp, y_2); - } - if (j++ < len) { - tmp = x[x_ptr++]; - y_3 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_0); - sum1 = Inlines.MAC16_16(sum1, tmp, y_1); - sum2 = Inlines.MAC16_16(sum2, tmp, y_2); - sum3 = Inlines.MAC16_16(sum3, tmp, y_3); - } - if (j++ < len) { - tmp = x[x_ptr++]; - y_0 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_1); - sum1 = Inlines.MAC16_16(sum1, tmp, y_2); - sum2 = Inlines.MAC16_16(sum2, tmp, y_3); - sum3 = Inlines.MAC16_16(sum3, tmp, y_0); - } - if (j < len) { - tmp = x[x_ptr++]; - y_1 = y[y_ptr++]; - sum0 = Inlines.MAC16_16(sum0, tmp, y_2); - sum1 = Inlines.MAC16_16(sum1, tmp, y_3); - sum2 = Inlines.MAC16_16(sum2, tmp, y_0); - sum3 = Inlines.MAC16_16(sum3, tmp, y_1); - } - _sum0.Val = sum0; - _sum1.Val = sum1; - _sum2.Val = sum2; - _sum3.Val = sum3; - } - - static int celt_inner_prod(short[] x, int x_ptr, short[] y, int y_ptr, int N) { - int xy = 0; - for (int i = 0; i < N; ++i) { - xy = Inlines.MAC16_16(xy, x[x_ptr + i], y[y_ptr + i]); - } - return xy; - } - - static int celt_inner_prod(short[] x, short[] y, int y_ptr, int N) { - int xy = 0; - for (int i = 0; i < N; ++i) { - xy = Inlines.MAC16_16(xy, x[i], y[y_ptr + i]); - } - return xy; - } - - static int celt_inner_prod(int[] x, int x_ptr, int[] y, int y_ptr, int N) { - int xy = 0; - for (int i = 0; i < N; ++i) { - xy = Inlines.MAC16_16(xy, x[x_ptr + i], y[y_ptr + i]); - } - return xy; - } - - static void dual_inner_prod(int[] x, int x_ptr, int[] y01, int y01_ptr, int[] y02, int y02_ptr, int N, BoxedValueInt xy1, BoxedValueInt xy2) { - int xy01 = 0; - int xy02 = 0; - for (int i = 0; i < N; ++i) { - xy01 = Inlines.MAC16_16(xy01, x[x_ptr + i], y01[y01_ptr + i]); - xy02 = Inlines.MAC16_16(xy02, x[x_ptr + i], y02[y02_ptr + i]); - } - xy1.Val = xy01; - xy2.Val = xy02; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/KissFFT.java b/source/decompiled/de/maxhenkel/voicechat/concentus/KissFFT.java deleted file mode 100644 index 43f4ea5..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/KissFFT.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.FFTState; -import de.maxhenkel.voicechat.concentus.Inlines; - -class KissFFT { - static final int MAXFACTORS = 8; - - KissFFT() { - } - - static int S_MUL(int a, int b) { - return Inlines.MULT16_32_Q15(b, a); - } - - static int S_MUL(int a, short b) { - return Inlines.MULT16_32_Q15(b, a); - } - - static int HALF_OF(int x) { - return x >> 1; - } - - static void kf_bfly2(int[] Fout, int fout_ptr, int m, int N) { - short tw = 23170; - Inlines.OpusAssert(m == 4); - for (int i = 0; i < N; ++i) { - int Fout2 = fout_ptr + 8; - int t_r = Fout[Fout2 + 0]; - int t_i = Fout[Fout2 + 1]; - Fout[Fout2 + 0] = Fout[fout_ptr + 0] - t_r; - Fout[Fout2 + 1] = Fout[fout_ptr + 1] - t_i; - int n = fout_ptr + 0; - Fout[n] = Fout[n] + t_r; - int n2 = fout_ptr + 1; - Fout[n2] = Fout[n2] + t_i; - t_r = KissFFT.S_MUL(Fout[Fout2 + 2] + Fout[Fout2 + 3], tw); - t_i = KissFFT.S_MUL(Fout[Fout2 + 3] - Fout[Fout2 + 2], tw); - Fout[Fout2 + 2] = Fout[fout_ptr + 2] - t_r; - Fout[Fout2 + 3] = Fout[fout_ptr + 3] - t_i; - int n3 = fout_ptr + 2; - Fout[n3] = Fout[n3] + t_r; - int n4 = fout_ptr + 3; - Fout[n4] = Fout[n4] + t_i; - t_r = Fout[Fout2 + 5]; - t_i = 0 - Fout[Fout2 + 4]; - Fout[Fout2 + 4] = Fout[fout_ptr + 4] - t_r; - Fout[Fout2 + 5] = Fout[fout_ptr + 5] - t_i; - int n5 = fout_ptr + 4; - Fout[n5] = Fout[n5] + t_r; - int n6 = fout_ptr + 5; - Fout[n6] = Fout[n6] + t_i; - t_r = KissFFT.S_MUL(Fout[Fout2 + 7] - Fout[Fout2 + 6], tw); - t_i = KissFFT.S_MUL(0 - Fout[Fout2 + 7] - Fout[Fout2 + 6], tw); - Fout[Fout2 + 6] = Fout[fout_ptr + 6] - t_r; - Fout[Fout2 + 7] = Fout[fout_ptr + 7] - t_i; - int n7 = fout_ptr + 6; - Fout[n7] = Fout[n7] + t_r; - int n8 = fout_ptr + 7; - Fout[n8] = Fout[n8] + t_i; - fout_ptr += 16; - } - } - - static void kf_bfly4(int[] Fout, int fout_ptr, int fstride, FFTState st, int m, int N, int mm) { - if (m == 1) { - for (int i = 0; i < N; ++i) { - int scratch0 = Fout[fout_ptr + 0] - Fout[fout_ptr + 4]; - int scratch1 = Fout[fout_ptr + 1] - Fout[fout_ptr + 5]; - int n = fout_ptr + 0; - Fout[n] = Fout[n] + Fout[fout_ptr + 4]; - int n2 = fout_ptr + 1; - Fout[n2] = Fout[n2] + Fout[fout_ptr + 5]; - int scratch2 = Fout[fout_ptr + 2] + Fout[fout_ptr + 6]; - int scratch3 = Fout[fout_ptr + 3] + Fout[fout_ptr + 7]; - Fout[fout_ptr + 4] = Fout[fout_ptr + 0] - scratch2; - Fout[fout_ptr + 5] = Fout[fout_ptr + 1] - scratch3; - int n3 = fout_ptr + 0; - Fout[n3] = Fout[n3] + scratch2; - int n4 = fout_ptr + 1; - Fout[n4] = Fout[n4] + scratch3; - scratch2 = Fout[fout_ptr + 2] - Fout[fout_ptr + 6]; - scratch3 = Fout[fout_ptr + 3] - Fout[fout_ptr + 7]; - Fout[fout_ptr + 2] = scratch0 + scratch3; - Fout[fout_ptr + 3] = scratch1 - scratch2; - Fout[fout_ptr + 6] = scratch0 - scratch3; - Fout[fout_ptr + 7] = scratch1 + scratch2; - fout_ptr += 8; - } - } else { - int Fout_beg = fout_ptr; - for (int i = 0; i < N; ++i) { - fout_ptr = Fout_beg + 2 * i * mm; - int m1 = fout_ptr + 2 * m; - int m2 = fout_ptr + 4 * m; - int m3 = fout_ptr + 6 * m; - int tw1 = 0; - int tw2 = 0; - int tw3 = 0; - for (int j = 0; j < m; ++j) { - int scratch0 = KissFFT.S_MUL(Fout[m1], st.twiddles[tw1]) - KissFFT.S_MUL(Fout[m1 + 1], st.twiddles[tw1 + 1]); - int scratch1 = KissFFT.S_MUL(Fout[m1], st.twiddles[tw1 + 1]) + KissFFT.S_MUL(Fout[m1 + 1], st.twiddles[tw1]); - int scratch2 = KissFFT.S_MUL(Fout[m2], st.twiddles[tw2]) - KissFFT.S_MUL(Fout[m2 + 1], st.twiddles[tw2 + 1]); - int scratch3 = KissFFT.S_MUL(Fout[m2], st.twiddles[tw2 + 1]) + KissFFT.S_MUL(Fout[m2 + 1], st.twiddles[tw2]); - int scratch4 = KissFFT.S_MUL(Fout[m3], st.twiddles[tw3]) - KissFFT.S_MUL(Fout[m3 + 1], st.twiddles[tw3 + 1]); - int scratch5 = KissFFT.S_MUL(Fout[m3], st.twiddles[tw3 + 1]) + KissFFT.S_MUL(Fout[m3 + 1], st.twiddles[tw3]); - int scratch10 = Fout[fout_ptr] - scratch2; - int scratch11 = Fout[fout_ptr + 1] - scratch3; - int n = fout_ptr; - Fout[n] = Fout[n] + scratch2; - int n5 = fout_ptr + 1; - Fout[n5] = Fout[n5] + scratch3; - int scratch6 = scratch0 + scratch4; - int scratch7 = scratch1 + scratch5; - int scratch8 = scratch0 - scratch4; - int scratch9 = scratch1 - scratch5; - Fout[m2] = Fout[fout_ptr] - scratch6; - Fout[m2 + 1] = Fout[fout_ptr + 1] - scratch7; - tw1 += fstride * 2; - tw2 += fstride * 4; - tw3 += fstride * 6; - int n6 = fout_ptr; - Fout[n6] = Fout[n6] + scratch6; - int n7 = fout_ptr + 1; - Fout[n7] = Fout[n7] + scratch7; - Fout[m1] = scratch10 + scratch9; - Fout[m1 + 1] = scratch11 - scratch8; - Fout[m3] = scratch10 - scratch9; - Fout[m3 + 1] = scratch11 + scratch8; - fout_ptr += 2; - m1 += 2; - m2 += 2; - m3 += 2; - } - } - } - } - - static void kf_bfly3(int[] Fout, int fout_ptr, int fstride, FFTState st, int m, int N, int mm) { - int m1 = 2 * m; - int m2 = 4 * m; - int Fout_beg = fout_ptr; - for (int i = 0; i < N; ++i) { - fout_ptr = Fout_beg + 2 * i * mm; - int tw2 = 0; - int tw1 = 0; - int k = m; - do { - int scratch2 = KissFFT.S_MUL(Fout[fout_ptr + m1], st.twiddles[tw1]) - KissFFT.S_MUL(Fout[fout_ptr + m1 + 1], st.twiddles[tw1 + 1]); - int scratch3 = KissFFT.S_MUL(Fout[fout_ptr + m1], st.twiddles[tw1 + 1]) + KissFFT.S_MUL(Fout[fout_ptr + m1 + 1], st.twiddles[tw1]); - int scratch4 = KissFFT.S_MUL(Fout[fout_ptr + m2], st.twiddles[tw2]) - KissFFT.S_MUL(Fout[fout_ptr + m2 + 1], st.twiddles[tw2 + 1]); - int scratch5 = KissFFT.S_MUL(Fout[fout_ptr + m2], st.twiddles[tw2 + 1]) + KissFFT.S_MUL(Fout[fout_ptr + m2 + 1], st.twiddles[tw2]); - int scratch6 = scratch2 + scratch4; - int scratch7 = scratch3 + scratch5; - int scratch0 = scratch2 - scratch4; - int scratch1 = scratch3 - scratch5; - tw1 += fstride * 2; - tw2 += fstride * 4; - Fout[fout_ptr + m1] = Fout[fout_ptr + 0] - KissFFT.HALF_OF(scratch6); - Fout[fout_ptr + m1 + 1] = Fout[fout_ptr + 1] - KissFFT.HALF_OF(scratch7); - scratch0 = KissFFT.S_MUL(scratch0, -28378); - scratch1 = KissFFT.S_MUL(scratch1, -28378); - int n = fout_ptr + 0; - Fout[n] = Fout[n] + scratch6; - int n2 = fout_ptr + 1; - Fout[n2] = Fout[n2] + scratch7; - Fout[fout_ptr + m2] = Fout[fout_ptr + m1] + scratch1; - Fout[fout_ptr + m2 + 1] = Fout[fout_ptr + m1 + 1] - scratch0; - int n3 = fout_ptr + m1; - Fout[n3] = Fout[n3] - scratch1; - int n4 = fout_ptr + m1 + 1; - Fout[n4] = Fout[n4] + scratch0; - fout_ptr += 2; - } while (--k != 0); - } - } - - static void kf_bfly5(int[] Fout, int fout_ptr, int fstride, FFTState st, int m, int N, int mm) { - int Fout_beg = fout_ptr; - short ya_r = 10126; - short ya_i = -31164; - short yb_r = -26510; - short yb_i = -19261; - for (int i = 0; i < N; ++i) { - int tw4 = 0; - int tw3 = 0; - int tw2 = 0; - int tw1 = 0; - int Fout0 = fout_ptr = Fout_beg + 2 * i * mm; - int Fout1 = fout_ptr + 2 * m; - int Fout2 = fout_ptr + 4 * m; - int Fout3 = fout_ptr + 6 * m; - int Fout4 = fout_ptr + 8 * m; - for (int u = 0; u < m; ++u) { - int scratch0 = Fout[Fout0 + 0]; - int scratch1 = Fout[Fout0 + 1]; - int scratch2 = KissFFT.S_MUL(Fout[Fout1 + 0], st.twiddles[tw1]) - KissFFT.S_MUL(Fout[Fout1 + 1], st.twiddles[tw1 + 1]); - int scratch3 = KissFFT.S_MUL(Fout[Fout1 + 0], st.twiddles[tw1 + 1]) + KissFFT.S_MUL(Fout[Fout1 + 1], st.twiddles[tw1]); - int scratch4 = KissFFT.S_MUL(Fout[Fout2 + 0], st.twiddles[tw2]) - KissFFT.S_MUL(Fout[Fout2 + 1], st.twiddles[tw2 + 1]); - int scratch5 = KissFFT.S_MUL(Fout[Fout2 + 0], st.twiddles[tw2 + 1]) + KissFFT.S_MUL(Fout[Fout2 + 1], st.twiddles[tw2]); - int scratch6 = KissFFT.S_MUL(Fout[Fout3 + 0], st.twiddles[tw3]) - KissFFT.S_MUL(Fout[Fout3 + 1], st.twiddles[tw3 + 1]); - int scratch7 = KissFFT.S_MUL(Fout[Fout3 + 0], st.twiddles[tw3 + 1]) + KissFFT.S_MUL(Fout[Fout3 + 1], st.twiddles[tw3]); - int scratch8 = KissFFT.S_MUL(Fout[Fout4 + 0], st.twiddles[tw4]) - KissFFT.S_MUL(Fout[Fout4 + 1], st.twiddles[tw4 + 1]); - int scratch9 = KissFFT.S_MUL(Fout[Fout4 + 0], st.twiddles[tw4 + 1]) + KissFFT.S_MUL(Fout[Fout4 + 1], st.twiddles[tw4]); - tw1 += 2 * fstride; - tw2 += 4 * fstride; - tw3 += 6 * fstride; - tw4 += 8 * fstride; - int scratch14 = scratch2 + scratch8; - int scratch15 = scratch3 + scratch9; - int scratch20 = scratch2 - scratch8; - int scratch21 = scratch3 - scratch9; - int scratch16 = scratch4 + scratch6; - int scratch17 = scratch5 + scratch7; - int scratch18 = scratch4 - scratch6; - int scratch19 = scratch5 - scratch7; - int n = Fout0 + 0; - Fout[n] = Fout[n] + (scratch14 + scratch16); - int n2 = Fout0 + 1; - Fout[n2] = Fout[n2] + (scratch15 + scratch17); - int scratch10 = scratch0 + KissFFT.S_MUL(scratch14, ya_r) + KissFFT.S_MUL(scratch16, yb_r); - int scratch11 = scratch1 + KissFFT.S_MUL(scratch15, ya_r) + KissFFT.S_MUL(scratch17, yb_r); - int scratch12 = KissFFT.S_MUL(scratch21, ya_i) + KissFFT.S_MUL(scratch19, yb_i); - int scratch13 = 0 - KissFFT.S_MUL(scratch20, ya_i) - KissFFT.S_MUL(scratch18, yb_i); - Fout[Fout1 + 0] = scratch10 - scratch12; - Fout[Fout1 + 1] = scratch11 - scratch13; - Fout[Fout4 + 0] = scratch10 + scratch12; - Fout[Fout4 + 1] = scratch11 + scratch13; - int scratch22 = scratch0 + KissFFT.S_MUL(scratch14, yb_r) + KissFFT.S_MUL(scratch16, ya_r); - int scratch23 = scratch1 + KissFFT.S_MUL(scratch15, yb_r) + KissFFT.S_MUL(scratch17, ya_r); - int scratch24 = 0 - KissFFT.S_MUL(scratch21, yb_i) + KissFFT.S_MUL(scratch19, ya_i); - int scratch25 = KissFFT.S_MUL(scratch20, yb_i) - KissFFT.S_MUL(scratch18, ya_i); - Fout[Fout2 + 0] = scratch22 + scratch24; - Fout[Fout2 + 1] = scratch23 + scratch25; - Fout[Fout3 + 0] = scratch22 - scratch24; - Fout[Fout3 + 1] = scratch23 - scratch25; - Fout0 += 2; - Fout1 += 2; - Fout2 += 2; - Fout3 += 2; - Fout4 += 2; - } - } - } - - static void opus_fft_impl(FFTState st, int[] fout, int fout_ptr) { - short m; - int[] fstride = new int[8]; - int shift = st.shift > 0 ? st.shift : 0; - fstride[0] = 1; - int L = 0; - do { - short p = st.factors[2 * L]; - m = st.factors[2 * L + 1]; - fstride[L + 1] = fstride[L] * p; - ++L; - } while (m != 1); - m = st.factors[2 * L - 1]; - for (int i = L - 1; i >= 0; --i) { - short m2 = i != 0 ? st.factors[2 * i - 1] : (short)1; - switch (st.factors[2 * i]) { - case 2: { - KissFFT.kf_bfly2(fout, fout_ptr, m, fstride[i]); - break; - } - case 4: { - KissFFT.kf_bfly4(fout, fout_ptr, fstride[i] << shift, st, m, fstride[i], m2); - break; - } - case 3: { - KissFFT.kf_bfly3(fout, fout_ptr, fstride[i] << shift, st, m, fstride[i], m2); - break; - } - case 5: { - KissFFT.kf_bfly5(fout, fout_ptr, fstride[i] << shift, st, m, fstride[i], m2); - } - } - m = m2; - } - } - - static void opus_fft(FFTState st, int[] fin, int[] fout) { - int scale_shift = st.scale_shift - 1; - short scale = st.scale; - Inlines.OpusAssert(fin != fout, "In-place FFT not supported"); - for (int i = 0; i < st.nfft; ++i) { - fout[2 * st.bitrev[i]] = Inlines.SHR32(Inlines.MULT16_32_Q16(scale, fin[2 * i]), scale_shift); - fout[2 * st.bitrev[i] + 1] = Inlines.SHR32(Inlines.MULT16_32_Q16(scale, fin[2 * i + 1]), scale_shift); - } - KissFFT.opus_fft_impl(st, fout, 0); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/LPCInversePredGain.java b/source/decompiled/de/maxhenkel/voicechat/concentus/LPCInversePredGain.java deleted file mode 100644 index d38e295..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/LPCInversePredGain.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Inlines; - -class LPCInversePredGain { - private static final int QA = 24; - private static final int A_LIMIT = 0xFFEF9E; - - LPCInversePredGain() { - } - - static int LPC_inverse_pred_gain_QA(int[][] A_QA, int order) { - int rc_mult1_Q30; - int rc_Q31; - int[] Anew_QA = A_QA[order & 1]; - int invGain_Q30 = 0x40000000; - for (int k = order - 1; k > 0; --k) { - if (Anew_QA[k] > 0xFFEF9E || Anew_QA[k] < -16773022) { - return 0; - } - rc_Q31 = 0 - Inlines.silk_LSHIFT(Anew_QA[k], 7); - rc_mult1_Q30 = 0x40000000 - Inlines.silk_SMMUL(rc_Q31, rc_Q31); - Inlines.OpusAssert(rc_mult1_Q30 > 32768); - Inlines.OpusAssert(rc_mult1_Q30 <= 0x40000000); - int mult2Q = 32 - Inlines.silk_CLZ32(Inlines.silk_abs(rc_mult1_Q30)); - int rc_mult2 = Inlines.silk_INVERSE32_varQ(rc_mult1_Q30, mult2Q + 30); - invGain_Q30 = Inlines.silk_LSHIFT(Inlines.silk_SMMUL(invGain_Q30, rc_mult1_Q30), 2); - Inlines.OpusAssert(invGain_Q30 >= 0); - Inlines.OpusAssert(invGain_Q30 <= 0x40000000); - int[] Aold_QA = Anew_QA; - Anew_QA = A_QA[k & 1]; - for (int n = 0; n < k; ++n) { - int tmp_QA = Aold_QA[n] - Inlines.MUL32_FRAC_Q(Aold_QA[k - n - 1], rc_Q31, 31); - Anew_QA[n] = Inlines.MUL32_FRAC_Q(tmp_QA, rc_mult2, mult2Q); - } - } - if (Anew_QA[0] > 0xFFEF9E || Anew_QA[0] < -16773022) { - return 0; - } - rc_Q31 = 0 - Inlines.silk_LSHIFT(Anew_QA[0], 7); - rc_mult1_Q30 = 0x40000000 - Inlines.silk_SMMUL(rc_Q31, rc_Q31); - Inlines.OpusAssert((invGain_Q30 = Inlines.silk_LSHIFT(Inlines.silk_SMMUL(invGain_Q30, rc_mult1_Q30), 2)) >= 0); - Inlines.OpusAssert(invGain_Q30 <= 0x40000000); - return invGain_Q30; - } - - static int silk_LPC_inverse_pred_gain(short[] A_Q12, int order) { - int[][] Atmp_QA = Arrays.InitTwoDimensionalArrayInt(2, 16); - int DC_resp = 0; - int[] Anew_QA = Atmp_QA[order & 1]; - for (int k = 0; k < order; ++k) { - DC_resp += A_Q12[k]; - Anew_QA[k] = Inlines.silk_LSHIFT32(A_Q12[k], 12); - } - if (DC_resp >= 4096) { - return 0; - } - return LPCInversePredGain.LPC_inverse_pred_gain_QA(Atmp_QA, order); - } - - static int silk_LPC_inverse_pred_gain_Q24(int[] A_Q24, int order) { - int[][] Atmp_QA = Arrays.InitTwoDimensionalArrayInt(2, 16); - int[] Anew_QA = Atmp_QA[order & 1]; - for (int k = 0; k < order; ++k) { - Anew_QA[k] = Inlines.silk_RSHIFT32(A_Q24[k], 0); - } - return LPCInversePredGain.LPC_inverse_pred_gain_QA(Atmp_QA, order); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/LTPAnalysisFilter.java b/source/decompiled/de/maxhenkel/voicechat/concentus/LTPAnalysisFilter.java deleted file mode 100644 index 3c5fcb5..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/LTPAnalysisFilter.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class LTPAnalysisFilter { - LTPAnalysisFilter() { - } - - static void silk_LTP_analysis_filter(short[] LTP_res, short[] x, int x_ptr, short[] LTPCoef_Q14, int[] pitchL, int[] invGains_Q16, int subfr_length, int nb_subfr, int pre_length) { - short[] Btmp_Q14 = new short[5]; - int x_ptr2 = x_ptr; - int LTP_res_ptr = 0; - for (int k = 0; k < nb_subfr; ++k) { - int x_lag_ptr = x_ptr2 - pitchL[k]; - Btmp_Q14[0] = LTPCoef_Q14[k * 5]; - Btmp_Q14[1] = LTPCoef_Q14[k * 5 + 1]; - Btmp_Q14[2] = LTPCoef_Q14[k * 5 + 2]; - Btmp_Q14[3] = LTPCoef_Q14[k * 5 + 3]; - Btmp_Q14[4] = LTPCoef_Q14[k * 5 + 4]; - for (int i = 0; i < subfr_length + pre_length; ++i) { - int LTP_res_ptri = LTP_res_ptr + i; - LTP_res[LTP_res_ptri] = x[x_ptr2 + i]; - int LTP_est = Inlines.silk_SMULBB(x[x_lag_ptr + 2], Btmp_Q14[0]); - LTP_est = Inlines.silk_SMLABB_ovflw(LTP_est, x[x_lag_ptr + 1], Btmp_Q14[1]); - LTP_est = Inlines.silk_SMLABB_ovflw(LTP_est, x[x_lag_ptr], Btmp_Q14[2]); - LTP_est = Inlines.silk_SMLABB_ovflw(LTP_est, x[x_lag_ptr - 1], Btmp_Q14[3]); - LTP_est = Inlines.silk_SMLABB_ovflw(LTP_est, x[x_lag_ptr - 2], Btmp_Q14[4]); - LTP_est = Inlines.silk_RSHIFT_ROUND(LTP_est, 14); - LTP_res[LTP_res_ptri] = (short)Inlines.silk_SAT16(x[x_ptr2 + i] - LTP_est); - LTP_res[LTP_res_ptri] = (short)Inlines.silk_SMULWB(invGains_Q16[k], LTP_res[LTP_res_ptri]); - ++x_lag_ptr; - } - LTP_res_ptr += subfr_length + pre_length; - x_ptr2 += subfr_length; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/LTPScaleControl.java b/source/decompiled/de/maxhenkel/voicechat/concentus/LTPScaleControl.java deleted file mode 100644 index 323130c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/LTPScaleControl.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class LTPScaleControl { - LTPScaleControl() { - } - - static void silk_LTP_scale_ctrl(SilkChannelEncoder psEnc, SilkEncoderControl psEncCtrl, int condCoding) { - if (condCoding == 0) { - int round_loss = psEnc.PacketLoss_perc + psEnc.nFramesPerPacket; - psEnc.indices.LTP_scaleIndex = (byte)Inlines.silk_LIMIT(Inlines.silk_SMULWB(Inlines.silk_SMULBB(round_loss, psEncCtrl.LTPredCodGain_Q7), 51), 0, 2); - } else { - psEnc.indices.LTP_scaleIndex = 0; - } - psEncCtrl.LTP_scale_Q14 = SilkTables.silk_LTPScales_table_Q14[psEnc.indices.LTP_scaleIndex]; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Laplace.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Laplace.java deleted file mode 100644 index 897592b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Laplace.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; - -class Laplace { - private static final int LAPLACE_LOG_MINP = 0; - private static final long LAPLACE_MINP = 1L; - private static final int LAPLACE_NMIN = 16; - - Laplace() { - } - - static long ec_laplace_get_freq1(long fs0, int decay) { - long ft = Inlines.CapToUInt32(32736L - fs0); - return Inlines.CapToUInt32(ft * (long)(16384 - decay)) >> 15; - } - - static void ec_laplace_encode(EntropyCoder enc, BoxedValueInt value, long fs, int decay) { - int val = value.Val; - long fl = 0L; - if (val != 0) { - int i; - int s = 0 - (val < 0 ? 1 : 0); - val = val + s ^ s; - fl = fs; - fs = Laplace.ec_laplace_get_freq1(fs, decay); - for (i = 1; fs > 0L && i < val; ++i) { - fl = Inlines.CapToUInt32(fl + (fs *= 2L) + 2L); - fs = Inlines.CapToUInt32(fs * (long)decay >> 15); - } - if (fs == 0L) { - int ndi_max = (int)(32768L - fl + 1L - 1L) >> 0; - ndi_max = ndi_max - s >> 1; - int di = Inlines.IMIN(val - i, ndi_max - 1); - fl = Inlines.CapToUInt32(fl + (long)(2 * di + 1 + s) * 1L); - fs = Inlines.IMIN(1L, 32768L - fl); - value.Val = i + di + s ^ s; - } else { - fl += Inlines.CapToUInt32(++fs & (long)(~s)); - } - Inlines.OpusAssert(fl + fs <= 32768L); - Inlines.OpusAssert(fs > 0L); - } - enc.encode_bin(fl, fl + fs, 15); - } - - static int ec_laplace_decode(EntropyCoder dec, long fs, int decay) { - int val = 0; - long fm = dec.decode_bin(15); - long fl = 0L; - if (fm >= fs) { - ++val; - fl = fs; - fs = Laplace.ec_laplace_get_freq1(fs, decay) + 1L; - while (fs > 1L && fm >= fl + 2L * fs) { - fl = Inlines.CapToUInt32(fl + (fs *= 2L)); - fs = Inlines.CapToUInt32((fs - 2L) * (long)decay >> 15); - ++fs; - ++val; - } - if (fs <= 1L) { - int di = (int)(fm - fl) >> 1; - val += di; - fl = Inlines.CapToUInt32(fl + Inlines.CapToUInt32((long)(2 * di) * 1L)); - } - if (fm < fl + fs) { - val = -val; - } else { - fl = Inlines.CapToUInt32(fl + fs); - } - } - Inlines.OpusAssert(fl < 32768L); - Inlines.OpusAssert(fs > 0L); - Inlines.OpusAssert(fl <= fm); - Inlines.OpusAssert(fm < Inlines.IMIN(fl + fs, 32768L)); - dec.dec_update(fl, Inlines.IMIN(fl + fs, 32768L), 32768L); - return val; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/LinearAlgebra.java b/source/decompiled/de/maxhenkel/voicechat/concentus/LinearAlgebra.java deleted file mode 100644 index a6d7042..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/LinearAlgebra.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class LinearAlgebra { - LinearAlgebra() { - } - - static void silk_solve_LDL(int[] A, int A_ptr, int M, int[] b, int[] x_Q16) { - Inlines.OpusAssert(M <= 16); - int[] L_Q16 = new int[M * M]; - int[] Y = new int[16]; - int[] inv_D = new int[32]; - LinearAlgebra.silk_LDL_factorize(A, A_ptr, M, L_Q16, inv_D); - LinearAlgebra.silk_LS_SolveFirst(L_Q16, M, b, Y); - LinearAlgebra.silk_LS_divide_Q16(Y, inv_D, M); - LinearAlgebra.silk_LS_SolveLast(L_Q16, M, Y, x_Q16); - } - - private static void silk_LDL_factorize(int[] A, int A_ptr, int M, int[] L_Q16, int[] inv_D) { - int[] v_Q0 = new int[M]; - int[] D_Q0 = new int[M]; - Inlines.OpusAssert(M <= 16); - boolean status = true; - int diag_min_value = Inlines.silk_max_32(Inlines.silk_SMMUL(Inlines.silk_ADD_SAT32(A[A_ptr], A[A_ptr + Inlines.silk_SMULBB(M, M) - 1]), 21475), 512); - block0: for (int loop_count = 0; loop_count < M && status; ++loop_count) { - status = false; - for (int j = 0; j < M; ++j) { - int i; - int[] scratch1 = L_Q16; - int scratch1_ptr = Inlines.MatrixGetPointer(j, 0, M); - int tmp_32 = 0; - for (i = 0; i < j; ++i) { - v_Q0[i] = Inlines.silk_SMULWW(D_Q0[i], scratch1[scratch1_ptr + i]); - tmp_32 = Inlines.silk_SMLAWW(tmp_32, v_Q0[i], scratch1[scratch1_ptr + i]); - } - tmp_32 = Inlines.silk_SUB32(Inlines.MatrixGet(A, A_ptr, j, j, M), tmp_32); - if (tmp_32 < diag_min_value) { - tmp_32 = Inlines.silk_SUB32(Inlines.silk_SMULBB(loop_count + 1, diag_min_value), tmp_32); - for (i = 0; i < M; ++i) { - Inlines.MatrixSet(A, A_ptr, i, i, M, Inlines.silk_ADD32(Inlines.MatrixGet(A, A_ptr, i, i, M), tmp_32)); - } - status = true; - continue block0; - } - D_Q0[j] = tmp_32; - int one_div_diag_Q36 = Inlines.silk_INVERSE32_varQ(tmp_32, 36); - int one_div_diag_Q40 = Inlines.silk_LSHIFT(one_div_diag_Q36, 4); - int err = Inlines.silk_SUB32(0x1000000, Inlines.silk_SMULWW(tmp_32, one_div_diag_Q40)); - int one_div_diag_Q48 = Inlines.silk_SMULWW(err, one_div_diag_Q40); - inv_D[j * 2 + 0] = one_div_diag_Q36; - inv_D[j * 2 + 1] = one_div_diag_Q48; - Inlines.MatrixSet(L_Q16, j, j, M, 65536); - scratch1 = A; - scratch1_ptr = Inlines.MatrixGetPointer(j, 0, M) + A_ptr; - int[] scratch2 = L_Q16; - int scratch2_ptr = Inlines.MatrixGetPointer(j + 1, 0, M); - for (i = j + 1; i < M; ++i) { - tmp_32 = 0; - for (int k = 0; k < j; ++k) { - tmp_32 = Inlines.silk_SMLAWW(tmp_32, v_Q0[k], scratch2[scratch2_ptr + k]); - } - tmp_32 = Inlines.silk_SUB32(scratch1[scratch1_ptr + i], tmp_32); - Inlines.MatrixSet(L_Q16, i, j, M, Inlines.silk_ADD32(Inlines.silk_SMMUL(tmp_32, one_div_diag_Q48), Inlines.silk_RSHIFT(Inlines.silk_SMULWW(tmp_32, one_div_diag_Q36), 4))); - scratch2_ptr += M; - } - } - } - Inlines.OpusAssert(!status); - } - - private static void silk_LS_divide_Q16(int[] T, int[] inv_D, int M) { - for (int i = 0; i < M; ++i) { - int one_div_diag_Q36 = inv_D[i * 2 + 0]; - int one_div_diag_Q48 = inv_D[i * 2 + 1]; - int tmp_32 = T[i]; - T[i] = Inlines.silk_ADD32(Inlines.silk_SMMUL(tmp_32, one_div_diag_Q48), Inlines.silk_RSHIFT(Inlines.silk_SMULWW(tmp_32, one_div_diag_Q36), 4)); - } - } - - private static void silk_LS_SolveFirst(int[] L_Q16, int M, int[] b, int[] x_Q16) { - for (int i = 0; i < M; ++i) { - int ptr32 = Inlines.MatrixGetPointer(i, 0, M); - int tmp_32 = 0; - for (int j = 0; j < i; ++j) { - tmp_32 = Inlines.silk_SMLAWW(tmp_32, L_Q16[ptr32 + j], x_Q16[j]); - } - x_Q16[i] = Inlines.silk_SUB32(b[i], tmp_32); - } - } - - private static void silk_LS_SolveLast(int[] L_Q16, int M, int[] b, int[] x_Q16) { - for (int i = M - 1; i >= 0; --i) { - int ptr32 = Inlines.MatrixGetPointer(0, i, M); - int tmp_32 = 0; - for (int j = M - 1; j > i; --j) { - tmp_32 = Inlines.silk_SMLAWW(tmp_32, L_Q16[ptr32 + Inlines.silk_SMULBB(j, M)], x_Q16[j]); - } - x_Q16[i] = Inlines.silk_SUB32(b[i], tmp_32); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/MDCT.java b/source/decompiled/de/maxhenkel/voicechat/concentus/MDCT.java deleted file mode 100644 index 2f2708e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/MDCT.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.FFTState; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.KissFFT; -import de.maxhenkel.voicechat.concentus.MDCTLookup; - -class MDCT { - MDCT() { - } - - static void clt_mdct_forward(MDCTLookup l, int[] input, int input_ptr, int[] output, int output_ptr, int[] window, int overlap, int shift, int stride) { - int i; - FFTState st = l.kfft[shift]; - int trig_ptr = 0; - int scale_shift = st.scale_shift - 1; - short scale = st.scale; - int N = l.n; - short[] trig = l.trig; - for (i = 0; i < shift; ++i) { - trig_ptr += (N >>= 1); - } - int N2 = N >> 1; - int N4 = N >> 2; - int[] f = new int[N2]; - int[] f2 = new int[N4 * 2]; - int xp1 = input_ptr + (overlap >> 1); - int xp2 = input_ptr + N2 - 1 + (overlap >> 1); - int yp = 0; - int wp1 = overlap >> 1; - int wp2 = (overlap >> 1) - 1; - for (i = 0; i < overlap + 3 >> 2; ++i) { - f[yp++] = Inlines.MULT16_32_Q15(window[wp2], input[xp1 + N2]) + Inlines.MULT16_32_Q15(window[wp1], input[xp2]); - f[yp++] = Inlines.MULT16_32_Q15(window[wp1], input[xp1]) - Inlines.MULT16_32_Q15(window[wp2], input[xp2 - N2]); - xp1 += 2; - xp2 -= 2; - wp1 += 2; - wp2 -= 2; - } - wp1 = 0; - wp2 = overlap - 1; - while (i < N4 - (overlap + 3 >> 2)) { - f[yp++] = input[xp2]; - f[yp++] = input[xp1]; - xp1 += 2; - xp2 -= 2; - ++i; - } - while (i < N4) { - f[yp++] = Inlines.MULT16_32_Q15(window[wp2], input[xp2]) - Inlines.MULT16_32_Q15(window[wp1], input[xp1 - N2]); - f[yp++] = Inlines.MULT16_32_Q15(window[wp2], input[xp1]) + Inlines.MULT16_32_Q15(window[wp1], input[xp2 + N2]); - xp1 += 2; - xp2 -= 2; - wp1 += 2; - wp2 -= 2; - ++i; - } - int yp2 = 0; - int t = trig_ptr; - for (i = 0; i < N4; ++i) { - short t0 = trig[t + i]; - short t1 = trig[t + N4 + i]; - int re = f[yp2++]; - int im = f[yp2++]; - int yr = KissFFT.S_MUL(re, t0) - KissFFT.S_MUL(im, t1); - int yi = KissFFT.S_MUL(im, t0) + KissFFT.S_MUL(re, t1); - f2[2 * st.bitrev[i]] = Inlines.PSHR32(Inlines.MULT16_32_Q16((int)scale, yr), scale_shift); - f2[2 * st.bitrev[i] + 1] = Inlines.PSHR32(Inlines.MULT16_32_Q16((int)scale, yi), scale_shift); - } - KissFFT.opus_fft_impl(st, f2, 0); - int fp = 0; - int yp1 = output_ptr; - int yp22 = output_ptr + stride * (N2 - 1); - int t2 = trig_ptr; - for (i = 0; i < N4; ++i) { - int yr = KissFFT.S_MUL(f2[fp + 1], trig[t2 + N4 + i]) - KissFFT.S_MUL(f2[fp], trig[t2 + i]); - int yi = KissFFT.S_MUL(f2[fp], trig[t2 + N4 + i]) + KissFFT.S_MUL(f2[fp + 1], trig[t2 + i]); - output[yp1] = yr; - output[yp22] = yi; - fp += 2; - yp1 += 2 * stride; - yp22 -= 2 * stride; - } - } - - static void clt_mdct_backward(MDCTLookup l, int[] input, int input_ptr, int[] output, int output_ptr, int[] window, int overlap, int shift, int stride) { - int i; - int trig = 0; - int N = l.n; - for (i = 0; i < shift; ++i) { - trig += (N >>= 1); - } - int N2 = N >> 1; - int N4 = N >> 2; - int xp2 = input_ptr + stride * (N2 - 1); - int yp = output_ptr + (overlap >> 1); - short[] bitrev = l.kfft[shift].bitrev; - int bitrav_ptr = 0; - for (i = 0; i < N4; ++i) { - short rev = bitrev[bitrav_ptr++]; - int ypr = yp + 2 * rev; - output[ypr + 1] = KissFFT.S_MUL(input[xp2], l.trig[trig + i]) + KissFFT.S_MUL(input[input_ptr], l.trig[trig + N4 + i]); - output[ypr] = KissFFT.S_MUL(input[input_ptr], l.trig[trig + i]) - KissFFT.S_MUL(input[xp2], l.trig[trig + N4 + i]); - input_ptr += 2 * stride; - xp2 -= 2 * stride; - } - KissFFT.opus_fft_impl(l.kfft[shift], output, output_ptr + (overlap >> 1)); - int yp0 = output_ptr + (overlap >> 1); - int yp1 = output_ptr + (overlap >> 1) + N2 - 2; - int t = trig; - int tN4m1 = t + N4 - 1; - int tN2m1 = t + N2 - 1; - for (i = 0; i < N4 + 1 >> 1; ++i) { - int re = output[yp0 + 1]; - int im = output[yp0]; - short t0 = l.trig[t + i]; - short t1 = l.trig[t + N4 + i]; - int yr = KissFFT.S_MUL(re, t0) + KissFFT.S_MUL(im, t1); - int yi = KissFFT.S_MUL(re, t1) - KissFFT.S_MUL(im, t0); - re = output[yp1 + 1]; - im = output[yp1]; - output[yp0] = yr; - output[yp1 + 1] = yi; - t0 = l.trig[tN4m1 - i]; - t1 = l.trig[tN2m1 - i]; - yr = KissFFT.S_MUL(re, t0) + KissFFT.S_MUL(im, t1); - yi = KissFFT.S_MUL(re, t1) - KissFFT.S_MUL(im, t0); - output[yp1] = yr; - output[yp0 + 1] = yi; - yp0 += 2; - yp1 -= 2; - } - int xp1 = output_ptr + overlap - 1; - yp1 = output_ptr; - int wp1 = 0; - int wp2 = overlap - 1; - for (i = 0; i < overlap / 2; ++i) { - int x1 = output[xp1]; - int x2 = output[yp1]; - output[yp1++] = Inlines.MULT16_32_Q15(window[wp2], x2) - Inlines.MULT16_32_Q15(window[wp1], x1); - output[xp1--] = Inlines.MULT16_32_Q15(window[wp1], x2) + Inlines.MULT16_32_Q15(window[wp2], x1); - ++wp1; - --wp2; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/MDCTLookup.java b/source/decompiled/de/maxhenkel/voicechat/concentus/MDCTLookup.java deleted file mode 100644 index 09b9865..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/MDCTLookup.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.FFTState; - -class MDCTLookup { - int n = 0; - int maxshift = 0; - FFTState[] kfft = new FFTState[4]; - short[] trig = null; - - MDCTLookup() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/MLPState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/MLPState.java deleted file mode 100644 index ba0c328..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/MLPState.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class MLPState { - int layers; - int[] topo; - float[] weights; - - MLPState() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/MultiLayerPerceptron.java b/source/decompiled/de/maxhenkel/voicechat/concentus/MultiLayerPerceptron.java deleted file mode 100644 index 9d49615..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/MultiLayerPerceptron.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.MLPState; -import de.maxhenkel.voicechat.concentus.OpusTables; - -class MultiLayerPerceptron { - private static final int MAX_NEURONS = 100; - - MultiLayerPerceptron() { - } - - static float tansig_approx(float x) { - float sign = 1.0f; - if (!(x < 8.0f)) { - return 1.0f; - } - if (!(x > -8.0f)) { - return -1.0f; - } - if (x < 0.0f) { - x = -x; - sign = -1.0f; - } - int i = (int)Math.floor(0.5f + 25.0f * x); - float y = OpusTables.tansig_table[i]; - float dy = 1.0f - y * y; - y += (x -= 0.04f * (float)i) * dy * (1.0f - y * x); - return sign * y; - } - - static void mlp_process(MLPState m, float[] input, float[] output) { - int k; - float sum; - int j; - float[] hidden = new float[100]; - float[] W = m.weights; - int W_ptr = 0; - for (j = 0; j < m.topo[1]; ++j) { - sum = W[W_ptr]; - ++W_ptr; - for (k = 0; k < m.topo[0]; ++k) { - sum += input[k] * W[W_ptr]; - ++W_ptr; - } - hidden[j] = MultiLayerPerceptron.tansig_approx(sum); - } - for (j = 0; j < m.topo[2]; ++j) { - sum = W[W_ptr]; - ++W_ptr; - for (k = 0; k < m.topo[1]; ++k) { - sum += hidden[k] * W[W_ptr]; - ++W_ptr; - } - output[j] = MultiLayerPerceptron.tansig_approx(sum); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/NLSF.java b/source/decompiled/de/maxhenkel/voicechat/concentus/NLSF.java deleted file mode 100644 index debf93b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/NLSF.java +++ /dev/null @@ -1,625 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSFCodebook; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.Sort; - -class NLSF { - private static final int MAX_STABILIZE_LOOPS = 20; - private static final int QA = 16; - private static final int BIN_DIV_STEPS_A2NLSF = 3; - private static final int MAX_ITERATIONS_A2NLSF = 30; - private static final byte[] ordering16 = new byte[]{0, 15, 8, 7, 4, 11, 12, 3, 2, 13, 10, 5, 6, 9, 14, 1}; - private static final byte[] ordering10 = new byte[]{0, 9, 6, 3, 4, 5, 8, 1, 2, 7}; - - NLSF() { - } - - static void silk_NLSF_VQ(int[] err_Q26, short[] in_Q15, short[] pCB_Q8, int K, int LPC_order) { - int pCB_idx = 0; - Inlines.OpusAssert(err_Q26 != null); - Inlines.OpusAssert(LPC_order <= 16); - Inlines.OpusAssert((LPC_order & 1) == 0); - for (int i = 0; i < K; ++i) { - int sum_error_Q26 = 0; - for (int m = 0; m < LPC_order; m += 2) { - int diff_Q15 = Inlines.silk_SUB_LSHIFT32(in_Q15[m], pCB_Q8[pCB_idx++], 7); - int sum_error_Q30 = Inlines.silk_SMULBB(diff_Q15, diff_Q15); - Inlines.OpusAssert((sum_error_Q26 = Inlines.silk_ADD_RSHIFT32(sum_error_Q26, sum_error_Q30 = Inlines.silk_SMLABB(sum_error_Q30, diff_Q15 = Inlines.silk_SUB_LSHIFT32(in_Q15[m + 1], pCB_Q8[pCB_idx++], 7), diff_Q15), 4)) >= 0); - Inlines.OpusAssert(sum_error_Q30 >= 0); - } - err_Q26[i] = sum_error_Q26; - } - } - - static void silk_NLSF_VQ_weights_laroia(short[] pNLSFW_Q_OUT, short[] pNLSF_Q15, int D) { - Inlines.OpusAssert(pNLSFW_Q_OUT != null); - Inlines.OpusAssert(D > 0); - Inlines.OpusAssert((D & 1) == 0); - int tmp1_int = Inlines.silk_max_int(pNLSF_Q15[0], 1); - tmp1_int = Inlines.silk_DIV32(131072, tmp1_int); - int tmp2_int = Inlines.silk_max_int(pNLSF_Q15[1] - pNLSF_Q15[0], 1); - tmp2_int = Inlines.silk_DIV32(131072, tmp2_int); - pNLSFW_Q_OUT[0] = (short)Inlines.silk_min_int(tmp1_int + tmp2_int, Short.MAX_VALUE); - Inlines.OpusAssert(pNLSFW_Q_OUT[0] > 0); - for (int k = 1; k < D - 1; k += 2) { - tmp1_int = Inlines.silk_max_int(pNLSF_Q15[k + 1] - pNLSF_Q15[k], 1); - tmp1_int = Inlines.silk_DIV32(131072, tmp1_int); - pNLSFW_Q_OUT[k] = (short)Inlines.silk_min_int(tmp1_int + tmp2_int, Short.MAX_VALUE); - Inlines.OpusAssert(pNLSFW_Q_OUT[k] > 0); - tmp2_int = Inlines.silk_max_int(pNLSF_Q15[k + 2] - pNLSF_Q15[k + 1], 1); - tmp2_int = Inlines.silk_DIV32(131072, tmp2_int); - pNLSFW_Q_OUT[k + 1] = (short)Inlines.silk_min_int(tmp1_int + tmp2_int, Short.MAX_VALUE); - Inlines.OpusAssert(pNLSFW_Q_OUT[k + 1] > 0); - } - tmp1_int = Inlines.silk_max_int(32768 - pNLSF_Q15[D - 1], 1); - tmp1_int = Inlines.silk_DIV32(131072, tmp1_int); - pNLSFW_Q_OUT[D - 1] = (short)Inlines.silk_min_int(tmp1_int + tmp2_int, Short.MAX_VALUE); - Inlines.OpusAssert(pNLSFW_Q_OUT[D - 1] > 0); - } - - static void silk_NLSF_residual_dequant(short[] x_Q10, byte[] indices, int indices_ptr, short[] pred_coef_Q8, int quant_step_size_Q16, short order) { - short out_Q10 = 0; - for (int i = order - 1; i >= 0; --i) { - int pred_Q10 = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(out_Q10, pred_coef_Q8[i]), 8); - out_Q10 = Inlines.silk_LSHIFT16(indices[indices_ptr + i], 10); - if (out_Q10 > 0) { - out_Q10 = Inlines.silk_SUB16(out_Q10, (short)102); - } else if (out_Q10 < 0) { - out_Q10 = Inlines.silk_ADD16(out_Q10, (short)102); - } - x_Q10[i] = out_Q10 = (short)Inlines.silk_SMLAWB(pred_Q10, out_Q10, quant_step_size_Q16); - } - } - - static void silk_NLSF_unpack(short[] ec_ix, short[] pred_Q8, NLSFCodebook psNLSF_CB, int CB1_index) { - short[] ec_sel = psNLSF_CB.ec_sel; - int ec_sel_ptr = CB1_index * psNLSF_CB.order / 2; - for (int i = 0; i < psNLSF_CB.order; i += 2) { - short entry = ec_sel[ec_sel_ptr]; - ++ec_sel_ptr; - ec_ix[i] = (short)Inlines.silk_SMULBB(Inlines.silk_RSHIFT(entry, 1) & 7, 9); - pred_Q8[i] = psNLSF_CB.pred_Q8[i + (entry & 1) * (psNLSF_CB.order - 1)]; - ec_ix[i + 1] = (short)Inlines.silk_SMULBB(Inlines.silk_RSHIFT(entry, 5) & 7, 9); - pred_Q8[i + 1] = psNLSF_CB.pred_Q8[i + (Inlines.silk_RSHIFT(entry, 4) & 1) * (psNLSF_CB.order - 1) + 1]; - } - } - - static void silk_NLSF_stabilize(short[] NLSF_Q15, short[] NDeltaMin_Q15, int L) { - int i; - int loops; - int I = 0; - Inlines.OpusAssert(NDeltaMin_Q15[L] >= 1); - for (loops = 0; loops < 20; ++loops) { - int k; - int diff_Q15; - int min_diff_Q15 = NLSF_Q15[0] - NDeltaMin_Q15[0]; - I = 0; - for (i = 1; i <= L - 1; ++i) { - diff_Q15 = NLSF_Q15[i] - (NLSF_Q15[i - 1] + NDeltaMin_Q15[i]); - if (diff_Q15 >= min_diff_Q15) continue; - min_diff_Q15 = diff_Q15; - I = i; - } - diff_Q15 = 32768 - (NLSF_Q15[L - 1] + NDeltaMin_Q15[L]); - if (diff_Q15 < min_diff_Q15) { - min_diff_Q15 = diff_Q15; - I = L; - } - if (min_diff_Q15 >= 0) { - return; - } - if (I == 0) { - NLSF_Q15[0] = NDeltaMin_Q15[0]; - continue; - } - if (I == L) { - NLSF_Q15[L - 1] = (short)(32768 - NDeltaMin_Q15[L]); - continue; - } - int min_center_Q15 = 0; - for (k = 0; k < I; ++k) { - min_center_Q15 += NDeltaMin_Q15[k]; - } - min_center_Q15 += Inlines.silk_RSHIFT(NDeltaMin_Q15[I], 1); - int max_center_Q15 = 32768; - for (k = L; k > I; --k) { - max_center_Q15 -= NDeltaMin_Q15[k]; - } - short center_freq_Q15 = (short)Inlines.silk_LIMIT_32(Inlines.silk_RSHIFT_ROUND(NLSF_Q15[I - 1] + NLSF_Q15[I], 1), min_center_Q15, max_center_Q15 -= Inlines.silk_RSHIFT(NDeltaMin_Q15[I], 1)); - NLSF_Q15[I - 1] = (short)(center_freq_Q15 - Inlines.silk_RSHIFT(NDeltaMin_Q15[I], 1)); - NLSF_Q15[I] = (short)(NLSF_Q15[I - 1] + NDeltaMin_Q15[I]); - } - if (loops == 20) { - Sort.silk_insertion_sort_increasing_all_values_int16(NLSF_Q15, L); - NLSF_Q15[0] = (short)Inlines.silk_max_int(NLSF_Q15[0], NDeltaMin_Q15[0]); - for (i = 1; i < L; ++i) { - NLSF_Q15[i] = (short)Inlines.silk_max_int(NLSF_Q15[i], NLSF_Q15[i - 1] + NDeltaMin_Q15[i]); - } - NLSF_Q15[L - 1] = (short)Inlines.silk_min_int(NLSF_Q15[L - 1], 32768 - NDeltaMin_Q15[L]); - for (i = L - 2; i >= 0; --i) { - NLSF_Q15[i] = (short)Inlines.silk_min_int(NLSF_Q15[i], NLSF_Q15[i + 1] - NDeltaMin_Q15[i + 1]); - } - } - } - - static void silk_NLSF_decode(short[] pNLSF_Q15, byte[] NLSFIndices, NLSFCodebook psNLSF_CB) { - int i; - short[] pred_Q8 = new short[psNLSF_CB.order]; - short[] ec_ix = new short[psNLSF_CB.order]; - short[] res_Q10 = new short[psNLSF_CB.order]; - short[] W_tmp_QW = new short[psNLSF_CB.order]; - short[] pCB = psNLSF_CB.CB1_NLSF_Q8; - int pCB_element = NLSFIndices[0] * psNLSF_CB.order; - for (i = 0; i < psNLSF_CB.order; ++i) { - pNLSF_Q15[i] = Inlines.silk_LSHIFT16(pCB[pCB_element + i], 7); - } - NLSF.silk_NLSF_unpack(ec_ix, pred_Q8, psNLSF_CB, NLSFIndices[0]); - NLSF.silk_NLSF_residual_dequant(res_Q10, NLSFIndices, 1, pred_Q8, psNLSF_CB.quantStepSize_Q16, psNLSF_CB.order); - NLSF.silk_NLSF_VQ_weights_laroia(W_tmp_QW, pNLSF_Q15, psNLSF_CB.order); - for (i = 0; i < psNLSF_CB.order; ++i) { - int W_tmp_Q9 = Inlines.silk_SQRT_APPROX(Inlines.silk_LSHIFT(W_tmp_QW[i], 16)); - int NLSF_Q15_tmp = Inlines.silk_ADD32(pNLSF_Q15[i], Inlines.silk_DIV32_16(Inlines.silk_LSHIFT(res_Q10[i], 14), (short)W_tmp_Q9)); - pNLSF_Q15[i] = (short)Inlines.silk_LIMIT(NLSF_Q15_tmp, 0, Short.MAX_VALUE); - } - NLSF.silk_NLSF_stabilize(pNLSF_Q15, psNLSF_CB.deltaMin_Q15, psNLSF_CB.order); - } - - static int silk_NLSF_del_dec_quant(byte[] indices, short[] x_Q10, short[] w_Q5, short[] pred_coef_Q8, short[] ec_ix, short[] ec_rates_Q5, int quant_step_size_Q16, short inv_quant_step_size_Q6, int mu_Q20, short order) { - int ind_tmp; - int j; - int out1_Q10; - int out0_Q10; - int i; - int[] ind_sort = new int[4]; - byte[][] ind = new byte[4][]; - for (i = 0; i < 4; ++i) { - ind[i] = new byte[16]; - } - short[] prev_out_Q10 = new short[8]; - int[] RD_Q25 = new int[8]; - int[] RD_min_Q25 = new int[4]; - int[] RD_max_Q25 = new int[4]; - int[] out0_Q10_table = new int[20]; - int[] out1_Q10_table = new int[20]; - for (i = -10; i <= 9; ++i) { - out0_Q10 = Inlines.silk_LSHIFT(i, 10); - out1_Q10 = Inlines.silk_ADD16((short)out0_Q10, (short)1024); - if (i > 0) { - out0_Q10 = Inlines.silk_SUB16((short)out0_Q10, (short)102); - out1_Q10 = Inlines.silk_SUB16((short)out1_Q10, (short)102); - } else if (i == 0) { - out1_Q10 = Inlines.silk_SUB16((short)out1_Q10, (short)102); - } else if (i == -1) { - out0_Q10 = Inlines.silk_ADD16((short)out0_Q10, (short)102); - } else { - out0_Q10 = Inlines.silk_ADD16((short)out0_Q10, (short)102); - out1_Q10 = Inlines.silk_ADD16((short)out1_Q10, (short)102); - } - out0_Q10_table[i + 10] = Inlines.silk_SMULWB(out0_Q10, quant_step_size_Q16); - out1_Q10_table[i + 10] = Inlines.silk_SMULWB(out1_Q10, quant_step_size_Q16); - } - Inlines.OpusAssert(true); - int nStates = 1; - RD_Q25[0] = 0; - prev_out_Q10[0] = 0; - i = order - 1; - while (true) { - int pred_coef_Q16 = Inlines.silk_LSHIFT(pred_coef_Q8[i], 8); - short in_Q10 = x_Q10[i]; - for (j = 0; j < nStates; ++j) { - int rate1_Q5; - int rate0_Q5; - int pred_Q10 = Inlines.silk_SMULWB(pred_coef_Q16, prev_out_Q10[j]); - short res_Q10 = Inlines.silk_SUB16(in_Q10, (short)pred_Q10); - ind_tmp = Inlines.silk_SMULWB(inv_quant_step_size_Q6, res_Q10); - ind_tmp = Inlines.silk_LIMIT(ind_tmp, -10, 9); - ind[j][i] = (byte)ind_tmp; - int rates_Q5 = ec_ix[i] + ind_tmp; - out0_Q10 = out0_Q10_table[ind_tmp + 10]; - out1_Q10 = out1_Q10_table[ind_tmp + 10]; - out0_Q10 = Inlines.silk_ADD16((short)out0_Q10, (short)pred_Q10); - out1_Q10 = Inlines.silk_ADD16((short)out1_Q10, (short)pred_Q10); - prev_out_Q10[j] = (short)out0_Q10; - prev_out_Q10[j + nStates] = (short)out1_Q10; - if (ind_tmp + 1 >= 4) { - if (ind_tmp + 1 == 4) { - rate0_Q5 = ec_rates_Q5[rates_Q5 + 4]; - rate1_Q5 = 280; - } else { - rate0_Q5 = Inlines.silk_SMLABB(108, 43, ind_tmp); - rate1_Q5 = Inlines.silk_ADD16((short)rate0_Q5, (short)43); - } - } else if (ind_tmp <= -4) { - if (ind_tmp == -4) { - rate0_Q5 = 280; - rate1_Q5 = ec_rates_Q5[rates_Q5 + 1 + 4]; - } else { - rate0_Q5 = Inlines.silk_SMLABB(108, -43, ind_tmp); - rate1_Q5 = Inlines.silk_SUB16((short)rate0_Q5, (short)43); - } - } else { - rate0_Q5 = ec_rates_Q5[rates_Q5 + 4]; - rate1_Q5 = ec_rates_Q5[rates_Q5 + 1 + 4]; - } - int RD_tmp_Q25 = RD_Q25[j]; - short diff_Q10 = Inlines.silk_SUB16(in_Q10, (short)out0_Q10); - RD_Q25[j] = Inlines.silk_SMLABB(Inlines.silk_MLA(RD_tmp_Q25, Inlines.silk_SMULBB(diff_Q10, diff_Q10), w_Q5[i]), mu_Q20, rate0_Q5); - diff_Q10 = Inlines.silk_SUB16(in_Q10, (short)out1_Q10); - RD_Q25[j + nStates] = Inlines.silk_SMLABB(Inlines.silk_MLA(RD_tmp_Q25, Inlines.silk_SMULBB(diff_Q10, diff_Q10), w_Q5[i]), mu_Q20, rate1_Q5); - } - if (nStates <= 2) { - for (j = 0; j < nStates; ++j) { - ind[j + nStates][i] = (byte)(ind[j][i] + 1); - } - for (j = nStates = Inlines.silk_LSHIFT(nStates, 1); j < 4; ++j) { - ind[j][i] = ind[j - nStates][i]; - } - } else { - if (i <= 0) break; - for (j = 0; j < 4; ++j) { - if (RD_Q25[j] > RD_Q25[j + 4]) { - RD_max_Q25[j] = RD_Q25[j]; - RD_min_Q25[j] = RD_Q25[j + 4]; - RD_Q25[j] = RD_min_Q25[j]; - RD_Q25[j + 4] = RD_max_Q25[j]; - out0_Q10 = prev_out_Q10[j]; - prev_out_Q10[j] = prev_out_Q10[j + 4]; - prev_out_Q10[j + 4] = (short)out0_Q10; - ind_sort[j] = j + 4; - continue; - } - RD_min_Q25[j] = RD_Q25[j]; - RD_max_Q25[j] = RD_Q25[j + 4]; - ind_sort[j] = j; - } - while (true) { - int min_max_Q25 = Integer.MAX_VALUE; - int max_min_Q25 = 0; - int ind_min_max = 0; - int ind_max_min = 0; - for (j = 0; j < 4; ++j) { - if (min_max_Q25 > RD_max_Q25[j]) { - min_max_Q25 = RD_max_Q25[j]; - ind_min_max = j; - } - if (max_min_Q25 >= RD_min_Q25[j]) continue; - max_min_Q25 = RD_min_Q25[j]; - ind_max_min = j; - } - if (min_max_Q25 >= max_min_Q25) break; - ind_sort[ind_max_min] = ind_sort[ind_min_max] ^ 4; - RD_Q25[ind_max_min] = RD_Q25[ind_min_max + 4]; - prev_out_Q10[ind_max_min] = prev_out_Q10[ind_min_max + 4]; - RD_min_Q25[ind_max_min] = 0; - RD_max_Q25[ind_min_max] = Integer.MAX_VALUE; - System.arraycopy(ind[ind_min_max], 0, ind[ind_max_min], 0, order); - } - for (j = 0; j < 4; ++j) { - byte x = (byte)Inlines.silk_RSHIFT(ind_sort[j], 2); - byte[] byArray = ind[j]; - int n = i; - byArray[n] = (byte)(byArray[n] + x); - } - } - --i; - } - ind_tmp = 0; - int min_Q25 = Integer.MAX_VALUE; - for (j = 0; j < 8; ++j) { - if (min_Q25 <= RD_Q25[j]) continue; - min_Q25 = RD_Q25[j]; - ind_tmp = j; - } - for (j = 0; j < order; ++j) { - indices[j] = ind[ind_tmp & 3][j]; - Inlines.OpusAssert(indices[j] >= -10); - Inlines.OpusAssert(indices[j] <= 10); - } - indices[0] = (byte)(indices[0] + Inlines.silk_RSHIFT(ind_tmp, 2)); - Inlines.OpusAssert(indices[0] <= 10); - Inlines.OpusAssert(min_Q25 >= 0); - return min_Q25; - } - - static int silk_NLSF_encode(byte[] NLSFIndices, short[] pNLSF_Q15, NLSFCodebook psNLSF_CB, short[] pW_QW, int NLSF_mu_Q20, int nSurvivors, int signalType) { - short[] res_Q15 = new short[psNLSF_CB.order]; - short[] res_Q10 = new short[psNLSF_CB.order]; - short[] NLSF_tmp_Q15 = new short[psNLSF_CB.order]; - short[] W_tmp_QW = new short[psNLSF_CB.order]; - short[] W_adj_Q5 = new short[psNLSF_CB.order]; - short[] pred_Q8 = new short[psNLSF_CB.order]; - short[] ec_ix = new short[psNLSF_CB.order]; - short[] pCB = psNLSF_CB.CB1_NLSF_Q8; - Inlines.OpusAssert(nSurvivors <= 32); - Inlines.OpusAssert(signalType >= 0 && signalType <= 2); - Inlines.OpusAssert(NLSF_mu_Q20 <= Short.MAX_VALUE && NLSF_mu_Q20 >= 0); - NLSF.silk_NLSF_stabilize(pNLSF_Q15, psNLSF_CB.deltaMin_Q15, psNLSF_CB.order); - int[] err_Q26 = new int[psNLSF_CB.nVectors]; - NLSF.silk_NLSF_VQ(err_Q26, pNLSF_Q15, psNLSF_CB.CB1_NLSF_Q8, psNLSF_CB.nVectors, psNLSF_CB.order); - int[] tempIndices1 = new int[nSurvivors]; - Sort.silk_insertion_sort_increasing(err_Q26, tempIndices1, psNLSF_CB.nVectors, nSurvivors); - int[] RD_Q25 = new int[nSurvivors]; - byte[][] tempIndices2 = Arrays.InitTwoDimensionalArrayByte(nSurvivors, 16); - for (int s = 0; s < nSurvivors; ++s) { - int i; - int ind1 = tempIndices1[s]; - int pCB_element = ind1 * psNLSF_CB.order; - for (i = 0; i < psNLSF_CB.order; ++i) { - NLSF_tmp_Q15[i] = Inlines.silk_LSHIFT16(pCB[pCB_element + i], 7); - res_Q15[i] = (short)(pNLSF_Q15[i] - NLSF_tmp_Q15[i]); - } - NLSF.silk_NLSF_VQ_weights_laroia(W_tmp_QW, NLSF_tmp_Q15, psNLSF_CB.order); - for (i = 0; i < psNLSF_CB.order; ++i) { - int W_tmp_Q9 = Inlines.silk_SQRT_APPROX(Inlines.silk_LSHIFT(W_tmp_QW[i], 16)); - res_Q10[i] = (short)Inlines.silk_RSHIFT(Inlines.silk_SMULBB(res_Q15[i], W_tmp_Q9), 14); - } - for (i = 0; i < psNLSF_CB.order; ++i) { - W_adj_Q5[i] = (short)Inlines.silk_DIV32_16(Inlines.silk_LSHIFT(pW_QW[i], 5), W_tmp_QW[i]); - } - NLSF.silk_NLSF_unpack(ec_ix, pred_Q8, psNLSF_CB, ind1); - RD_Q25[s] = NLSF.silk_NLSF_del_dec_quant(tempIndices2[s], res_Q10, W_adj_Q5, pred_Q8, ec_ix, psNLSF_CB.ec_Rates_Q5, psNLSF_CB.quantStepSize_Q16, psNLSF_CB.invQuantStepSize_Q6, NLSF_mu_Q20, psNLSF_CB.order); - int iCDF_ptr = (signalType >> 1) * psNLSF_CB.nVectors; - int prob_Q8 = ind1 == 0 ? 256 - psNLSF_CB.CB1_iCDF[iCDF_ptr + ind1] : psNLSF_CB.CB1_iCDF[iCDF_ptr + ind1 - 1] - psNLSF_CB.CB1_iCDF[iCDF_ptr + ind1]; - int bits_q7 = 1024 - Inlines.silk_lin2log(prob_Q8); - RD_Q25[s] = Inlines.silk_SMLABB(RD_Q25[s], bits_q7, Inlines.silk_RSHIFT(NLSF_mu_Q20, 2)); - } - int[] bestIndex = new int[1]; - Sort.silk_insertion_sort_increasing(RD_Q25, bestIndex, nSurvivors, 1); - NLSFIndices[0] = (byte)tempIndices1[bestIndex[0]]; - System.arraycopy(tempIndices2[bestIndex[0]], 0, NLSFIndices, 1, psNLSF_CB.order); - NLSF.silk_NLSF_decode(pNLSF_Q15, NLSFIndices, psNLSF_CB); - return RD_Q25[0]; - } - - static void silk_NLSF2A_find_poly(int[] o, int[] cLSF, int cLSF_ptr, int dd) { - o[0] = Inlines.silk_LSHIFT(1, 16); - o[1] = 0 - cLSF[cLSF_ptr]; - for (int k = 1; k < dd; ++k) { - int ftmp = cLSF[cLSF_ptr + 2 * k]; - o[k + 1] = Inlines.silk_LSHIFT(o[k - 1], 1) - (int)Inlines.silk_RSHIFT_ROUND64(Inlines.silk_SMULL(ftmp, o[k]), 16); - for (int n = k; n > 1; --n) { - int n2 = n; - o[n2] = o[n2] + (o[n - 2] - (int)Inlines.silk_RSHIFT_ROUND64(Inlines.silk_SMULL(ftmp, o[n - 1]), 16)); - } - o[1] = o[1] - ftmp; - } - } - - static void silk_NLSF2A(short[] a_Q12, short[] NLSF2, int d) { - int i; - int k; - int[] cos_LSF_QA = new int[d]; - int[] P = new int[d / 2 + 1]; - int[] Q = new int[d / 2 + 1]; - int[] a32_QA1 = new int[d]; - int idx = 0; - Inlines.OpusAssert(true); - Inlines.OpusAssert(d == 10 || d == 16); - byte[] ordering = d == 16 ? ordering16 : ordering10; - for (k = 0; k < d; ++k) { - Inlines.OpusAssert(NLSF2[k] >= 0); - int f_int = Inlines.silk_RSHIFT(NLSF2[k], 8); - int f_frac = NLSF2[k] - Inlines.silk_LSHIFT(f_int, 8); - Inlines.OpusAssert(f_int >= 0); - Inlines.OpusAssert(f_int < 128); - short cos_val = SilkTables.silk_LSFCosTab_Q12[f_int]; - int delta = SilkTables.silk_LSFCosTab_Q12[f_int + 1] - cos_val; - cos_LSF_QA[ordering[k]] = Inlines.silk_RSHIFT_ROUND(Inlines.silk_LSHIFT(cos_val, 8) + Inlines.silk_MUL(delta, f_frac), 4); - } - int dd = Inlines.silk_RSHIFT(d, 1); - NLSF.silk_NLSF2A_find_poly(P, cos_LSF_QA, 0, dd); - NLSF.silk_NLSF2A_find_poly(Q, cos_LSF_QA, 1, dd); - for (k = 0; k < dd; ++k) { - int Ptmp = P[k + 1] + P[k]; - int Qtmp = Q[k + 1] - Q[k]; - a32_QA1[k] = -Qtmp - Ptmp; - a32_QA1[d - k - 1] = Qtmp - Ptmp; - } - for (i = 0; i < 10; ++i) { - int maxabs = 0; - for (k = 0; k < d; ++k) { - int absval = Inlines.silk_abs(a32_QA1[k]); - if (absval <= maxabs) continue; - maxabs = absval; - idx = k; - } - if ((maxabs = Inlines.silk_RSHIFT_ROUND(maxabs, 5)) <= Short.MAX_VALUE) break; - maxabs = Inlines.silk_min(maxabs, 163838); - int sc_Q16 = 65470 - Inlines.silk_DIV32(Inlines.silk_LSHIFT(maxabs - Short.MAX_VALUE, 14), Inlines.silk_RSHIFT32(Inlines.silk_MUL(maxabs, idx + 1), 2)); - Filters.silk_bwexpander_32(a32_QA1, d, sc_Q16); - } - if (i == 10) { - for (k = 0; k < d; ++k) { - a_Q12[k] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(a32_QA1[k], 5)); - a32_QA1[k] = Inlines.silk_LSHIFT(a_Q12[k], 5); - } - } else { - for (k = 0; k < d; ++k) { - a_Q12[k] = (short)Inlines.silk_RSHIFT_ROUND(a32_QA1[k], 5); - } - } - for (i = 0; i < 16 && Filters.silk_LPC_inverse_pred_gain(a_Q12, d) < 107374; ++i) { - Filters.silk_bwexpander_32(a32_QA1, d, 65536 - Inlines.silk_LSHIFT(2, i)); - for (k = 0; k < d; ++k) { - a_Q12[k] = (short)Inlines.silk_RSHIFT_ROUND(a32_QA1[k], 5); - } - } - } - - static void silk_A2NLSF_trans_poly(int[] p, int dd) { - for (int k = 2; k <= dd; ++k) { - for (int n = dd; n > k; --n) { - int n2 = n - 2; - p[n2] = p[n2] - p[n]; - } - int n = k - 2; - p[n] = p[n] - Inlines.silk_LSHIFT(p[k], 1); - } - } - - static int silk_A2NLSF_eval_poly(int[] p, int x, int dd) { - int y32 = p[dd]; - int x_Q16 = Inlines.silk_LSHIFT(x, 4); - if (8 == dd) { - y32 = Inlines.silk_SMLAWW(p[7], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[6], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[5], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[4], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[3], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[2], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[1], y32, x_Q16); - y32 = Inlines.silk_SMLAWW(p[0], y32, x_Q16); - } else { - for (int n = dd - 1; n >= 0; --n) { - y32 = Inlines.silk_SMLAWW(p[n], y32, x_Q16); - } - } - return y32; - } - - static void silk_A2NLSF_init(int[] a_Q16, int[] P, int[] Q, int dd) { - int k; - P[dd] = Inlines.silk_LSHIFT(1, 16); - Q[dd] = Inlines.silk_LSHIFT(1, 16); - for (k = 0; k < dd; ++k) { - P[k] = -a_Q16[dd - k - 1] - a_Q16[dd + k]; - Q[k] = -a_Q16[dd - k - 1] + a_Q16[dd + k]; - } - for (k = dd; k > 0; --k) { - int n = k - 1; - P[n] = P[n] - P[k]; - int n2 = k - 1; - Q[n2] = Q[n2] + Q[k]; - } - NLSF.silk_A2NLSF_trans_poly(P, dd); - NLSF.silk_A2NLSF_trans_poly(Q, dd); - } - - static void silk_A2NLSF(short[] NLSF2, int[] a_Q16, int d) { - int root_ix; - int[] P = new int[9]; - int[] Q = new int[9]; - int[][] PQ = new int[][]{P, Q}; - int dd = Inlines.silk_RSHIFT(d, 1); - NLSF.silk_A2NLSF_init(a_Q16, P, Q, dd); - int[] p = P; - int xlo = SilkTables.silk_LSFCosTab_Q12[0]; - int ylo = NLSF.silk_A2NLSF_eval_poly(p, xlo, dd); - if (ylo < 0) { - NLSF2[0] = 0; - p = Q; - ylo = NLSF.silk_A2NLSF_eval_poly(p, xlo, dd); - root_ix = 1; - } else { - root_ix = 0; - } - int k = 1; - int i = 0; - int thr = 0; - while (true) { - int xhi = SilkTables.silk_LSFCosTab_Q12[k]; - int yhi = NLSF.silk_A2NLSF_eval_poly(p, xhi, dd); - if (ylo <= 0 && yhi >= thr || ylo >= 0 && yhi <= -thr) { - thr = yhi == 0 ? 1 : 0; - int ffrac = -256; - for (int m = 0; m < 3; ++m) { - int xmid = Inlines.silk_RSHIFT_ROUND(xlo + xhi, 1); - int ymid = NLSF.silk_A2NLSF_eval_poly(p, xmid, dd); - if (ylo <= 0 && ymid >= 0 || ylo >= 0 && ymid <= 0) { - xhi = xmid; - yhi = ymid; - continue; - } - xlo = xmid; - ylo = ymid; - ffrac = Inlines.silk_ADD_RSHIFT(ffrac, 128, m); - } - if (Inlines.silk_abs(ylo) < 65536) { - int den = ylo - yhi; - int nom = Inlines.silk_LSHIFT(ylo, 5) + Inlines.silk_RSHIFT(den, 1); - if (den != 0) { - ffrac += Inlines.silk_DIV32(nom, den); - } - } else { - ffrac += Inlines.silk_DIV32(ylo, Inlines.silk_RSHIFT(ylo - yhi, 5)); - } - NLSF2[root_ix] = (short)Inlines.silk_min_32(Inlines.silk_LSHIFT(k, 8) + ffrac, Short.MAX_VALUE); - Inlines.OpusAssert(NLSF2[root_ix] >= 0); - if (++root_ix >= d) break; - p = PQ[root_ix & 1]; - xlo = SilkTables.silk_LSFCosTab_Q12[k - 1]; - ylo = Inlines.silk_LSHIFT(1 - (root_ix & 2), 12); - continue; - } - xlo = xhi; - ylo = yhi; - thr = 0; - if (++k <= 128) continue; - if (++i > 30) { - NLSF2[0] = (short)Inlines.silk_DIV32_16(32768, (short)(d + 1)); - for (k = 1; k < d; ++k) { - NLSF2[k] = (short)Inlines.silk_SMULBB(k + 1, NLSF2[0]); - } - return; - } - Filters.silk_bwexpander_32(a_Q16, d, 65536 - Inlines.silk_SMULBB(10 + i, i)); - NLSF.silk_A2NLSF_init(a_Q16, P, Q, dd); - p = P; - xlo = SilkTables.silk_LSFCosTab_Q12[0]; - ylo = NLSF.silk_A2NLSF_eval_poly(p, xlo, dd); - if (ylo < 0) { - NLSF2[0] = 0; - p = Q; - ylo = NLSF.silk_A2NLSF_eval_poly(p, xlo, dd); - root_ix = 1; - } else { - root_ix = 0; - } - k = 1; - } - } - - static void silk_process_NLSFs(SilkChannelEncoder psEncC, short[][] PredCoef_Q12, short[] pNLSF_Q15, short[] prev_NLSFq_Q15) { - boolean doInterpolate; - short[] pNLSF0_temp_Q15 = new short[16]; - short[] pNLSFW_QW = new short[16]; - short[] pNLSFW0_temp_QW = new short[16]; - Inlines.OpusAssert(psEncC.speech_activity_Q8 >= 0); - Inlines.OpusAssert(psEncC.speech_activity_Q8 <= 256); - Inlines.OpusAssert(psEncC.useInterpolatedNLSFs == 1 || psEncC.indices.NLSFInterpCoef_Q2 == 4); - int NLSF_mu_Q20 = Inlines.silk_SMLAWB(3146, -268434, psEncC.speech_activity_Q8); - if (psEncC.nb_subfr == 2) { - NLSF_mu_Q20 = Inlines.silk_ADD_RSHIFT(NLSF_mu_Q20, NLSF_mu_Q20, 1); - } - Inlines.OpusAssert(NLSF_mu_Q20 > 0); - Inlines.OpusAssert(NLSF_mu_Q20 <= 5243); - NLSF.silk_NLSF_VQ_weights_laroia(pNLSFW_QW, pNLSF_Q15, psEncC.predictLPCOrder); - boolean bl = doInterpolate = psEncC.useInterpolatedNLSFs == 1 && psEncC.indices.NLSFInterpCoef_Q2 < 4; - if (doInterpolate) { - Inlines.silk_interpolate(pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, psEncC.indices.NLSFInterpCoef_Q2, psEncC.predictLPCOrder); - NLSF.silk_NLSF_VQ_weights_laroia(pNLSFW0_temp_QW, pNLSF0_temp_Q15, psEncC.predictLPCOrder); - int i_sqr_Q15 = Inlines.silk_LSHIFT(Inlines.silk_SMULBB(psEncC.indices.NLSFInterpCoef_Q2, psEncC.indices.NLSFInterpCoef_Q2), 11); - for (int i = 0; i < psEncC.predictLPCOrder; ++i) { - pNLSFW_QW[i] = (short)Inlines.silk_SMLAWB(Inlines.silk_RSHIFT(pNLSFW_QW[i], 1), pNLSFW0_temp_QW[i], i_sqr_Q15); - Inlines.OpusAssert(pNLSFW_QW[i] >= 1); - } - } - NLSF.silk_NLSF_encode(psEncC.indices.NLSFIndices, pNLSF_Q15, psEncC.psNLSF_CB, pNLSFW_QW, NLSF_mu_Q20, psEncC.NLSF_MSVQ_Survivors, psEncC.indices.signalType); - NLSF.silk_NLSF2A(PredCoef_Q12[1], pNLSF_Q15, psEncC.predictLPCOrder); - if (doInterpolate) { - Inlines.silk_interpolate(pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, psEncC.indices.NLSFInterpCoef_Q2, psEncC.predictLPCOrder); - NLSF.silk_NLSF2A(PredCoef_Q12[0], pNLSF0_temp_Q15, psEncC.predictLPCOrder); - } else { - System.arraycopy(PredCoef_Q12[1], 0, PredCoef_Q12[0], 0, psEncC.predictLPCOrder); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/NLSFCodebook.java b/source/decompiled/de/maxhenkel/voicechat/concentus/NLSFCodebook.java deleted file mode 100644 index b5505a2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/NLSFCodebook.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class NLSFCodebook { - short nVectors = 0; - short order = 0; - short quantStepSize_Q16 = 0; - short invQuantStepSize_Q6 = 0; - short[] CB1_NLSF_Q8 = null; - short[] CB1_iCDF = null; - short[] pred_Q8 = null; - short[] ec_sel = null; - short[] ec_iCDF = null; - short[] ec_Rates_Q5 = null; - short[] deltaMin_Q15 = null; - - NLSFCodebook() { - } - - void Reset() { - this.nVectors = 0; - this.order = 0; - this.quantStepSize_Q16 = 0; - this.invQuantStepSize_Q6 = 0; - this.CB1_NLSF_Q8 = null; - this.CB1_iCDF = null; - this.pred_Q8 = null; - this.ec_sel = null; - this.ec_iCDF = null; - this.ec_Rates_Q5 = null; - this.deltaMin_Q15 = null; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/NoiseShapeAnalysis.java b/source/decompiled/de/maxhenkel/voicechat/concentus/NoiseShapeAnalysis.java deleted file mode 100644 index f430c48..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/NoiseShapeAnalysis.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.ApplySineWindow; -import de.maxhenkel.voicechat.concentus.Autocorrelation; -import de.maxhenkel.voicechat.concentus.BWExpander; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.K2A; -import de.maxhenkel.voicechat.concentus.LPCInversePredGain; -import de.maxhenkel.voicechat.concentus.Schur; -import de.maxhenkel.voicechat.concentus.Sigmoid; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; -import de.maxhenkel.voicechat.concentus.SilkShapeState; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class NoiseShapeAnalysis { - NoiseShapeAnalysis() { - } - - static int warped_gain(int[] coefs_Q24, int lambda_Q16, int order) { - lambda_Q16 = -lambda_Q16; - int gain_Q24 = coefs_Q24[order - 1]; - for (int i = order - 2; i >= 0; --i) { - gain_Q24 = Inlines.silk_SMLAWB(coefs_Q24[i], gain_Q24, lambda_Q16); - } - gain_Q24 = Inlines.silk_SMLAWB(0x1000000, gain_Q24, -lambda_Q16); - return Inlines.silk_INVERSE32_varQ(gain_Q24, 40); - } - - static void limit_warped_coefs(int[] coefs_syn_Q24, int[] coefs_ana_Q24, int lambda_Q16, int limit_Q24, int order) { - int i; - int ind = 0; - lambda_Q16 = -lambda_Q16; - for (i = order - 1; i > 0; --i) { - coefs_syn_Q24[i - 1] = Inlines.silk_SMLAWB(coefs_syn_Q24[i - 1], coefs_syn_Q24[i], lambda_Q16); - coefs_ana_Q24[i - 1] = Inlines.silk_SMLAWB(coefs_ana_Q24[i - 1], coefs_ana_Q24[i], lambda_Q16); - } - lambda_Q16 = -lambda_Q16; - int nom_Q16 = Inlines.silk_SMLAWB(65536, -lambda_Q16, lambda_Q16); - int den_Q24 = Inlines.silk_SMLAWB(0x1000000, coefs_syn_Q24[0], lambda_Q16); - int gain_syn_Q16 = Inlines.silk_DIV32_varQ(nom_Q16, den_Q24, 24); - den_Q24 = Inlines.silk_SMLAWB(0x1000000, coefs_ana_Q24[0], lambda_Q16); - int gain_ana_Q16 = Inlines.silk_DIV32_varQ(nom_Q16, den_Q24, 24); - for (i = 0; i < order; ++i) { - coefs_syn_Q24[i] = Inlines.silk_SMULWW(gain_syn_Q16, coefs_syn_Q24[i]); - coefs_ana_Q24[i] = Inlines.silk_SMULWW(gain_ana_Q16, coefs_ana_Q24[i]); - } - for (int iter = 0; iter < 10; ++iter) { - int maxabs_Q24 = -1; - for (i = 0; i < order; ++i) { - int tmp = Inlines.silk_max(Inlines.silk_abs_int32(coefs_syn_Q24[i]), Inlines.silk_abs_int32(coefs_ana_Q24[i])); - if (tmp <= maxabs_Q24) continue; - maxabs_Q24 = tmp; - ind = i; - } - if (maxabs_Q24 <= limit_Q24) { - return; - } - for (i = 1; i < order; ++i) { - coefs_syn_Q24[i - 1] = Inlines.silk_SMLAWB(coefs_syn_Q24[i - 1], coefs_syn_Q24[i], lambda_Q16); - coefs_ana_Q24[i - 1] = Inlines.silk_SMLAWB(coefs_ana_Q24[i - 1], coefs_ana_Q24[i], lambda_Q16); - } - gain_syn_Q16 = Inlines.silk_INVERSE32_varQ(gain_syn_Q16, 32); - gain_ana_Q16 = Inlines.silk_INVERSE32_varQ(gain_ana_Q16, 32); - for (i = 0; i < order; ++i) { - coefs_syn_Q24[i] = Inlines.silk_SMULWW(gain_syn_Q16, coefs_syn_Q24[i]); - coefs_ana_Q24[i] = Inlines.silk_SMULWW(gain_ana_Q16, coefs_ana_Q24[i]); - } - int chirp_Q16 = 64881 - Inlines.silk_DIV32_varQ(Inlines.silk_SMULWB(maxabs_Q24 - limit_Q24, Inlines.silk_SMLABB(819, 102, iter)), Inlines.silk_MUL(maxabs_Q24, ind + 1), 22); - BWExpander.silk_bwexpander_32(coefs_syn_Q24, order, chirp_Q16); - BWExpander.silk_bwexpander_32(coefs_ana_Q24, order, chirp_Q16); - lambda_Q16 = -lambda_Q16; - for (i = order - 1; i > 0; --i) { - coefs_syn_Q24[i - 1] = Inlines.silk_SMLAWB(coefs_syn_Q24[i - 1], coefs_syn_Q24[i], lambda_Q16); - coefs_ana_Q24[i - 1] = Inlines.silk_SMLAWB(coefs_ana_Q24[i - 1], coefs_ana_Q24[i], lambda_Q16); - } - lambda_Q16 = -lambda_Q16; - nom_Q16 = Inlines.silk_SMLAWB(65536, -lambda_Q16, lambda_Q16); - den_Q24 = Inlines.silk_SMLAWB(0x1000000, coefs_syn_Q24[0], lambda_Q16); - gain_syn_Q16 = Inlines.silk_DIV32_varQ(nom_Q16, den_Q24, 24); - den_Q24 = Inlines.silk_SMLAWB(0x1000000, coefs_ana_Q24[0], lambda_Q16); - gain_ana_Q16 = Inlines.silk_DIV32_varQ(nom_Q16, den_Q24, 24); - for (i = 0; i < order; ++i) { - coefs_syn_Q24[i] = Inlines.silk_SMULWW(gain_syn_Q16, coefs_syn_Q24[i]); - coefs_ana_Q24[i] = Inlines.silk_SMULWW(gain_ana_Q16, coefs_ana_Q24[i]); - } - } - Inlines.OpusAssert(false); - } - - static void silk_noise_shape_analysis(SilkChannelEncoder psEnc, SilkEncoderControl psEncCtrl, short[] pitch_res, int pitch_res_ptr, short[] x, int x_ptr) { - int HarmShapeGain_Q16; - int Tilt_Q16; - int b_Q14; - int gain_mult_Q16; - int BWExp2_Q16; - int nrg; - int k; - SilkShapeState psShapeSt = psEnc.sShape; - int scale = 0; - int[] auto_corr = new int[17]; - int[] refl_coef_Q16 = new int[16]; - int[] AR1_Q24 = new int[16]; - int[] AR2_Q24 = new int[16]; - int x_ptr2 = x_ptr - psEnc.la_shape; - int SNR_adj_dB_Q7 = psEnc.SNR_dB_Q7; - psEncCtrl.input_quality_Q14 = Inlines.silk_RSHIFT(psEnc.input_quality_bands_Q15[0] + psEnc.input_quality_bands_Q15[1], 2); - psEncCtrl.coding_quality_Q14 = Inlines.silk_RSHIFT(Sigmoid.silk_sigm_Q15(Inlines.silk_RSHIFT_ROUND(SNR_adj_dB_Q7 - 2560, 4)), 1); - if (psEnc.useCBR == 0) { - int b_Q8 = 256 - psEnc.speech_activity_Q8; - b_Q8 = Inlines.silk_SMULWB(Inlines.silk_LSHIFT(b_Q8, 8), b_Q8); - SNR_adj_dB_Q7 = Inlines.silk_SMLAWB(SNR_adj_dB_Q7, Inlines.silk_SMULBB(-8, b_Q8), Inlines.silk_SMULWB(16384 + psEncCtrl.input_quality_Q14, psEncCtrl.coding_quality_Q14)); - } - SNR_adj_dB_Q7 = psEnc.indices.signalType == 2 ? Inlines.silk_SMLAWB(SNR_adj_dB_Q7, 512, psEnc.LTPCorr_Q15) : Inlines.silk_SMLAWB(SNR_adj_dB_Q7, Inlines.silk_SMLAWB(3072, -104858, psEnc.SNR_dB_Q7), 16384 - psEncCtrl.input_quality_Q14); - if (psEnc.indices.signalType == 2) { - psEnc.indices.quantOffsetType = 0; - psEncCtrl.sparseness_Q8 = 0; - } else { - int nSamples = Inlines.silk_LSHIFT(psEnc.fs_kHz, 1); - int energy_variation_Q7 = 0; - int log_energy_prev_Q7 = 0; - int pitch_res_ptr2 = pitch_res_ptr; - BoxedValueInt boxed_nrg = new BoxedValueInt(0); - BoxedValueInt boxed_scale = new BoxedValueInt(0); - for (k = 0; k < Inlines.silk_SMULBB(5, psEnc.nb_subfr) / 2; ++k) { - SumSqrShift.silk_sum_sqr_shift(boxed_nrg, boxed_scale, pitch_res, pitch_res_ptr2, nSamples); - nrg = boxed_nrg.Val; - scale = boxed_scale.Val; - int log_energy_Q7 = Inlines.silk_lin2log(nrg += Inlines.silk_RSHIFT(nSamples, scale)); - if (k > 0) { - energy_variation_Q7 += Inlines.silk_abs(log_energy_Q7 - log_energy_prev_Q7); - } - log_energy_prev_Q7 = log_energy_Q7; - pitch_res_ptr2 += nSamples; - } - psEncCtrl.sparseness_Q8 = Inlines.silk_RSHIFT(Sigmoid.silk_sigm_Q15(Inlines.silk_SMULWB(energy_variation_Q7 - 640, 6554)), 7); - psEnc.indices.quantOffsetType = psEncCtrl.sparseness_Q8 > 192 ? (byte)0 : 1; - SNR_adj_dB_Q7 = Inlines.silk_SMLAWB(SNR_adj_dB_Q7, 65536, psEncCtrl.sparseness_Q8 - 128); - } - int strength_Q16 = Inlines.silk_SMULWB(psEncCtrl.predGain_Q16, 66); - int BWExp1_Q16 = BWExp2_Q16 = Inlines.silk_DIV32_varQ(62259, Inlines.silk_SMLAWW(65536, strength_Q16, strength_Q16), 16); - int delta_Q16 = Inlines.silk_SMULWB(65536 - Inlines.silk_SMULBB(3, psEncCtrl.coding_quality_Q14), 655); - BWExp1_Q16 = Inlines.silk_SUB32(BWExp1_Q16, delta_Q16); - BWExp2_Q16 = Inlines.silk_ADD32(BWExp2_Q16, delta_Q16); - BWExp1_Q16 = Inlines.silk_DIV32_16(Inlines.silk_LSHIFT(BWExp1_Q16, 14), Inlines.silk_RSHIFT(BWExp2_Q16, 2)); - int warping_Q16 = psEnc.warping_Q16 > 0 ? Inlines.silk_SMLAWB(psEnc.warping_Q16, psEncCtrl.coding_quality_Q14, 2621) : 0; - short[] x_windowed = new short[psEnc.shapeWinLength]; - for (k = 0; k < psEnc.nb_subfr; ++k) { - int flat_part = psEnc.fs_kHz * 3; - int slope_part = Inlines.silk_RSHIFT(psEnc.shapeWinLength - flat_part, 1); - ApplySineWindow.silk_apply_sine_window(x_windowed, 0, x, x_ptr2, 1, slope_part); - int shift = slope_part; - System.arraycopy(x, x_ptr2 + shift, x_windowed, shift, flat_part); - ApplySineWindow.silk_apply_sine_window(x_windowed, shift += flat_part, x, x_ptr2 + shift, 2, slope_part); - x_ptr2 += psEnc.subfr_length; - BoxedValueInt scale_boxed = new BoxedValueInt(scale); - if (psEnc.warping_Q16 > 0) { - Autocorrelation.silk_warped_autocorrelation(auto_corr, scale_boxed, x_windowed, warping_Q16, psEnc.shapeWinLength, psEnc.shapingLPCOrder); - } else { - Autocorrelation.silk_autocorr(auto_corr, scale_boxed, x_windowed, psEnc.shapeWinLength, psEnc.shapingLPCOrder + 1); - } - scale = scale_boxed.Val; - auto_corr[0] = Inlines.silk_ADD32(auto_corr[0], Inlines.silk_max_32(Inlines.silk_SMULWB(Inlines.silk_RSHIFT(auto_corr[0], 4), 52), 1)); - nrg = Schur.silk_schur64(refl_coef_Q16, auto_corr, psEnc.shapingLPCOrder); - Inlines.OpusAssert(nrg >= 0); - K2A.silk_k2a_Q16(AR2_Q24, refl_coef_Q16, psEnc.shapingLPCOrder); - int Qnrg = -scale; - Inlines.OpusAssert(Qnrg >= -12); - Inlines.OpusAssert(Qnrg <= 30); - if ((Qnrg & 1) != 0) { - --Qnrg; - nrg >>= 1; - } - int tmp32 = Inlines.silk_SQRT_APPROX(nrg); - psEncCtrl.Gains_Q16[k] = Inlines.silk_LSHIFT_SAT32(tmp32, 16 - (Qnrg >>= 1)); - if (psEnc.warping_Q16 > 0) { - gain_mult_Q16 = NoiseShapeAnalysis.warped_gain(AR2_Q24, warping_Q16, psEnc.shapingLPCOrder); - Inlines.OpusAssert(psEncCtrl.Gains_Q16[k] >= 0); - psEncCtrl.Gains_Q16[k] = Inlines.silk_SMULWW(Inlines.silk_RSHIFT_ROUND(psEncCtrl.Gains_Q16[k], 1), gain_mult_Q16) >= 0x3FFFFFFF ? Integer.MAX_VALUE : Inlines.silk_SMULWW(psEncCtrl.Gains_Q16[k], gain_mult_Q16); - } - BWExpander.silk_bwexpander_32(AR2_Q24, psEnc.shapingLPCOrder, BWExp2_Q16); - System.arraycopy(AR2_Q24, 0, AR1_Q24, 0, psEnc.shapingLPCOrder); - Inlines.OpusAssert(BWExp1_Q16 <= 65536); - BWExpander.silk_bwexpander_32(AR1_Q24, psEnc.shapingLPCOrder, BWExp1_Q16); - int pre_nrg_Q30 = LPCInversePredGain.silk_LPC_inverse_pred_gain_Q24(AR2_Q24, psEnc.shapingLPCOrder); - nrg = LPCInversePredGain.silk_LPC_inverse_pred_gain_Q24(AR1_Q24, psEnc.shapingLPCOrder); - pre_nrg_Q30 = Inlines.silk_LSHIFT32(Inlines.silk_SMULWB(pre_nrg_Q30, 22938), 1); - psEncCtrl.GainsPre_Q14[k] = 4915 + Inlines.silk_DIV32_varQ(pre_nrg_Q30, nrg, 14); - NoiseShapeAnalysis.limit_warped_coefs(AR2_Q24, AR1_Q24, warping_Q16, 67092088, psEnc.shapingLPCOrder); - for (int i = 0; i < psEnc.shapingLPCOrder; ++i) { - psEncCtrl.AR1_Q13[k * 16 + i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(AR1_Q24[i], 11)); - psEncCtrl.AR2_Q13[k * 16 + i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(AR2_Q24[i], 11)); - } - } - gain_mult_Q16 = Inlines.silk_log2lin(-Inlines.silk_SMLAWB(-2048, SNR_adj_dB_Q7, 10486)); - int gain_add_Q16 = Inlines.silk_log2lin(Inlines.silk_SMLAWB(2048, 256, 10486)); - Inlines.OpusAssert(gain_mult_Q16 > 0); - for (k = 0; k < psEnc.nb_subfr; ++k) { - psEncCtrl.Gains_Q16[k] = Inlines.silk_SMULWW(psEncCtrl.Gains_Q16[k], gain_mult_Q16); - Inlines.OpusAssert(psEncCtrl.Gains_Q16[k] >= 0); - psEncCtrl.Gains_Q16[k] = Inlines.silk_ADD_POS_SAT32(psEncCtrl.Gains_Q16[k], gain_add_Q16); - } - gain_mult_Q16 = 65536 + Inlines.silk_RSHIFT_ROUND(Inlines.silk_MLA(0x333333, psEncCtrl.coding_quality_Q14, 410), 10); - for (k = 0; k < psEnc.nb_subfr; ++k) { - psEncCtrl.GainsPre_Q14[k] = Inlines.silk_SMULWB(gain_mult_Q16, psEncCtrl.GainsPre_Q14[k]); - } - strength_Q16 = Inlines.silk_MUL(64, Inlines.silk_SMLAWB(4096, 4096, psEnc.input_quality_bands_Q15[0] - 32768)); - strength_Q16 = Inlines.silk_RSHIFT(Inlines.silk_MUL(strength_Q16, psEnc.speech_activity_Q8), 8); - if (psEnc.indices.signalType == 2) { - int fs_kHz_inv = Inlines.silk_DIV32_16(3277, psEnc.fs_kHz); - k = 0; - while (k < psEnc.nb_subfr) { - b_Q14 = fs_kHz_inv + Inlines.silk_DIV32_16(49152, psEncCtrl.pitchL[k]); - psEncCtrl.LF_shp_Q14[k] = Inlines.silk_LSHIFT(16384 - b_Q14 - Inlines.silk_SMULWB(strength_Q16, b_Q14), 16); - int n = k++; - psEncCtrl.LF_shp_Q14[n] = psEncCtrl.LF_shp_Q14[n] | b_Q14 - 16384 & 0xFFFF; - } - Inlines.OpusAssert(true); - Tilt_Q16 = -16384 - Inlines.silk_SMULWB(49152, Inlines.silk_SMULWB(0x59999A, psEnc.speech_activity_Q8)); - } else { - b_Q14 = Inlines.silk_DIV32_16(21299, psEnc.fs_kHz); - psEncCtrl.LF_shp_Q14[0] = Inlines.silk_LSHIFT(16384 - b_Q14 - Inlines.silk_SMULWB(strength_Q16, Inlines.silk_SMULWB(39322, b_Q14)), 16); - psEncCtrl.LF_shp_Q14[0] = psEncCtrl.LF_shp_Q14[0] | b_Q14 - 16384 & 0xFFFF; - for (k = 1; k < psEnc.nb_subfr; ++k) { - psEncCtrl.LF_shp_Q14[k] = psEncCtrl.LF_shp_Q14[0]; - } - Tilt_Q16 = -16384; - } - int HarmBoost_Q16 = Inlines.silk_SMULWB(Inlines.silk_SMULWB(131072 - Inlines.silk_LSHIFT(psEncCtrl.coding_quality_Q14, 3), psEnc.LTPCorr_Q15), 6554); - HarmBoost_Q16 = Inlines.silk_SMLAWB(HarmBoost_Q16, 65536 - Inlines.silk_LSHIFT(psEncCtrl.input_quality_Q14, 2), 6554); - if (psEnc.indices.signalType == 2) { - HarmShapeGain_Q16 = Inlines.silk_SMLAWB(19661, 65536 - Inlines.silk_SMULWB(262144 - Inlines.silk_LSHIFT(psEncCtrl.coding_quality_Q14, 4), psEncCtrl.input_quality_Q14), 13107); - HarmShapeGain_Q16 = Inlines.silk_SMULWB(Inlines.silk_LSHIFT(HarmShapeGain_Q16, 1), Inlines.silk_SQRT_APPROX(Inlines.silk_LSHIFT(psEnc.LTPCorr_Q15, 15))); - } else { - HarmShapeGain_Q16 = 0; - } - for (k = 0; k < 4; ++k) { - psShapeSt.HarmBoost_smth_Q16 = Inlines.silk_SMLAWB(psShapeSt.HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt.HarmBoost_smth_Q16, 26214); - psShapeSt.HarmShapeGain_smth_Q16 = Inlines.silk_SMLAWB(psShapeSt.HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt.HarmShapeGain_smth_Q16, 26214); - psShapeSt.Tilt_smth_Q16 = Inlines.silk_SMLAWB(psShapeSt.Tilt_smth_Q16, Tilt_Q16 - psShapeSt.Tilt_smth_Q16, 26214); - psEncCtrl.HarmBoost_Q14[k] = Inlines.silk_RSHIFT_ROUND(psShapeSt.HarmBoost_smth_Q16, 2); - psEncCtrl.HarmShapeGain_Q14[k] = Inlines.silk_RSHIFT_ROUND(psShapeSt.HarmShapeGain_smth_Q16, 2); - psEncCtrl.Tilt_Q14[k] = Inlines.silk_RSHIFT_ROUND(psShapeSt.Tilt_smth_Q16, 2); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusApplication.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusApplication.java deleted file mode 100644 index 93f9029..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public enum OpusApplication { - OPUS_APPLICATION_UNIMPLEMENTED, - OPUS_APPLICATION_VOIP, - OPUS_APPLICATION_AUDIO, - OPUS_APPLICATION_RESTRICTED_LOWDELAY; - -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusBandwidth.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusBandwidth.java deleted file mode 100644 index 06e698a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusBandwidth.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public enum OpusBandwidth { - OPUS_BANDWIDTH_UNKNOWN, - OPUS_BANDWIDTH_AUTO, - OPUS_BANDWIDTH_NARROWBAND, - OPUS_BANDWIDTH_MEDIUMBAND, - OPUS_BANDWIDTH_WIDEBAND, - OPUS_BANDWIDTH_SUPERWIDEBAND, - OPUS_BANDWIDTH_FULLBAND; - -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusBandwidthHelpers.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusBandwidthHelpers.java deleted file mode 100644 index 97002f4..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusBandwidthHelpers.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.OpusBandwidth; - -class OpusBandwidthHelpers { - OpusBandwidthHelpers() { - } - - static int GetOrdinal(OpusBandwidth bw) { - switch (bw) { - case OPUS_BANDWIDTH_NARROWBAND: { - return 1; - } - case OPUS_BANDWIDTH_MEDIUMBAND: { - return 2; - } - case OPUS_BANDWIDTH_WIDEBAND: { - return 3; - } - case OPUS_BANDWIDTH_SUPERWIDEBAND: { - return 4; - } - case OPUS_BANDWIDTH_FULLBAND: { - return 5; - } - } - return -1; - } - - static OpusBandwidth GetBandwidth(int ordinal) { - switch (ordinal) { - case 1: { - return OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND; - } - case 2: { - return OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND; - } - case 3: { - return OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND; - } - case 4: { - return OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND; - } - case 5: { - return OpusBandwidth.OPUS_BANDWIDTH_FULLBAND; - } - } - return OpusBandwidth.OPUS_BANDWIDTH_AUTO; - } - - static OpusBandwidth MIN(OpusBandwidth a, OpusBandwidth b) { - if (OpusBandwidthHelpers.GetOrdinal(a) < OpusBandwidthHelpers.GetOrdinal(b)) { - return a; - } - return b; - } - - static OpusBandwidth MAX(OpusBandwidth a, OpusBandwidth b) { - if (OpusBandwidthHelpers.GetOrdinal(a) > OpusBandwidthHelpers.GetOrdinal(b)) { - return a; - } - return b; - } - - static OpusBandwidth SUBTRACT(OpusBandwidth a, int b) { - return OpusBandwidthHelpers.GetBandwidth(OpusBandwidthHelpers.GetOrdinal(a) - b); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusConstants.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusConstants.java deleted file mode 100644 index 42ee1b8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusConstants.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public class OpusConstants { - public static final int OPUS_AUTO = -1000; - public static final int OPUS_BITRATE_MAX = -1; - public static final int NB_FRAMES = 8; - public static final int NB_TBANDS = 18; - public static final int NB_TOT_BANDS = 21; - public static final int NB_TONAL_SKIP_BANDS = 9; - public static final int ANALYSIS_BUF_SIZE = 720; - public static final int DETECT_SIZE = 200; - public static final int MAX_ENCODER_BUFFER = 480; -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusDecoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusDecoder.java deleted file mode 100644 index 61c1960..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusDecoder.java +++ /dev/null @@ -1,499 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltDecoder; -import de.maxhenkel.voicechat.concentus.CodecHelpers; -import de.maxhenkel.voicechat.concentus.DecControlState; -import de.maxhenkel.voicechat.concentus.DecodeAPI; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusBandwidth; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusException; -import de.maxhenkel.voicechat.concentus.OpusMode; -import de.maxhenkel.voicechat.concentus.OpusPacketInfo; -import de.maxhenkel.voicechat.concentus.SilkDecoder; - -public class OpusDecoder { - int channels; - int Fs; - final DecControlState DecControl = new DecControlState(); - int decode_gain; - int stream_channels; - OpusBandwidth bandwidth; - OpusMode mode; - OpusMode prev_mode; - int frame_size; - int prev_redundancy; - int last_packet_duration; - int rangeFinal; - SilkDecoder SilkDecoder = new SilkDecoder(); - CeltDecoder Celt_Decoder = new CeltDecoder(); - private static final byte[] SILENCE = new byte[]{-1, -1}; - - OpusDecoder() { - } - - void reset() { - this.channels = 0; - this.Fs = 0; - this.DecControl.Reset(); - this.decode_gain = 0; - this.partialReset(); - } - - void partialReset() { - this.stream_channels = 0; - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN; - this.mode = OpusMode.MODE_UNKNOWN; - this.prev_mode = OpusMode.MODE_UNKNOWN; - this.frame_size = 0; - this.prev_redundancy = 0; - this.last_packet_duration = 0; - this.rangeFinal = 0; - } - - int opus_decoder_init(int Fs, int channels) { - if (Fs != 48000 && Fs != 24000 && Fs != 16000 && Fs != 12000 && Fs != 8000 || channels != 1 && channels != 2) { - return OpusError.OPUS_BAD_ARG; - } - this.reset(); - SilkDecoder silk_dec = this.SilkDecoder; - CeltDecoder celt_dec = this.Celt_Decoder; - this.stream_channels = this.channels = channels; - this.DecControl.API_sampleRate = this.Fs = Fs; - this.DecControl.nChannelsAPI = this.channels; - int ret = DecodeAPI.silk_InitDecoder(silk_dec); - if (ret != 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - ret = celt_dec.celt_decoder_init(Fs, channels); - if (ret != OpusError.OPUS_OK) { - return OpusError.OPUS_INTERNAL_ERROR; - } - celt_dec.SetSignalling(0); - this.prev_mode = OpusMode.MODE_UNKNOWN; - this.frame_size = Fs / 400; - return OpusError.OPUS_OK; - } - - public OpusDecoder(int Fs, int channels) throws OpusException { - if (Fs != 48000 && Fs != 24000 && Fs != 16000 && Fs != 12000 && Fs != 8000) { - throw new IllegalArgumentException("Sample rate is invalid (must be 8/12/16/24/48 Khz)"); - } - if (channels != 1 && channels != 2) { - throw new IllegalArgumentException("Number of channels must be 1 or 2"); - } - int ret = this.opus_decoder_init(Fs, channels); - if (ret != OpusError.OPUS_OK) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("OPUS_BAD_ARG when creating decoder"); - } - throw new OpusException("Error while initializing decoder", ret); - } - } - - int opus_decode_frame(byte[] data, int data_ptr, int len, short[] pcm, int pcm_ptr, int frame_size, int decode_fec) { - int i; - OpusMode mode; - int audiosize; - int silk_ret = 0; - int celt_ret = 0; - EntropyCoder dec = new EntropyCoder(); - short[] pcm_transition = null; - boolean transition = false; - int redundancy = 0; - int redundancy_bytes = 0; - int celt_to_silk = 0; - int redundant_rng = 0; - SilkDecoder silk_dec = this.SilkDecoder; - CeltDecoder celt_dec = this.Celt_Decoder; - int F20 = this.Fs / 50; - int F10 = F20 >> 1; - int F5 = F10 >> 1; - int F2_5 = F5 >> 1; - if (frame_size < F2_5) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - frame_size = Inlines.IMIN(frame_size, this.Fs / 25 * 3); - if (len <= 1) { - data = null; - frame_size = Inlines.IMIN(frame_size, this.frame_size); - } - if (data != null) { - audiosize = this.frame_size; - mode = this.mode; - dec.dec_init(data, data_ptr, len); - } else { - audiosize = frame_size; - mode = this.prev_mode; - if (mode == OpusMode.MODE_UNKNOWN) { - for (int i2 = pcm_ptr; i2 < pcm_ptr + audiosize * this.channels; ++i2) { - pcm[i2] = 0; - } - return audiosize; - } - if (audiosize > F20) { - int ret; - do { - if ((ret = this.opus_decode_frame(null, 0, 0, pcm, pcm_ptr, Inlines.IMIN(audiosize, F20), 0)) < 0) { - return ret; - } - pcm_ptr += ret * this.channels; - } while ((audiosize -= ret) > 0); - return frame_size; - } - if (audiosize < F20) { - if (audiosize > F10) { - audiosize = F10; - } else if (mode != OpusMode.MODE_SILK_ONLY && audiosize > F5 && audiosize < F10) { - audiosize = F5; - } - } - } - int celt_accum = mode != OpusMode.MODE_CELT_ONLY && frame_size >= F10 ? 1 : 0; - int pcm_transition_silk_size = 0; - int pcm_transition_celt_size = 0; - if (data != null && this.prev_mode != OpusMode.MODE_UNKNOWN && this.prev_mode != OpusMode.MODE_AUTO && (mode == OpusMode.MODE_CELT_ONLY && this.prev_mode != OpusMode.MODE_CELT_ONLY && this.prev_redundancy == 0 || mode != OpusMode.MODE_CELT_ONLY && this.prev_mode == OpusMode.MODE_CELT_ONLY)) { - transition = true; - if (mode == OpusMode.MODE_CELT_ONLY) { - pcm_transition_celt_size = F5 * this.channels; - } else { - pcm_transition_silk_size = F5 * this.channels; - } - } - short[] pcm_transition_celt = new short[pcm_transition_celt_size]; - if (transition && mode == OpusMode.MODE_CELT_ONLY) { - pcm_transition = pcm_transition_celt; - this.opus_decode_frame(null, 0, 0, pcm_transition, 0, Inlines.IMIN(F5, audiosize), 0); - } - if (audiosize > frame_size) { - return OpusError.OPUS_BAD_ARG; - } - frame_size = audiosize; - int pcm_silk_size = mode != OpusMode.MODE_CELT_ONLY && celt_accum == 0 ? Inlines.IMAX(F10, frame_size) * this.channels : 0; - short[] pcm_silk = new short[pcm_silk_size]; - if (mode != OpusMode.MODE_CELT_ONLY) { - int silk_frame_size; - short[] pcm_ptr2; - int pcm_ptr2_ptr = 0; - if (celt_accum != 0) { - pcm_ptr2 = pcm; - pcm_ptr2_ptr = pcm_ptr; - } else { - pcm_ptr2 = pcm_silk; - pcm_ptr2_ptr = 0; - } - if (this.prev_mode == OpusMode.MODE_CELT_ONLY) { - DecodeAPI.silk_InitDecoder(silk_dec); - } - this.DecControl.payloadSize_ms = Inlines.IMAX(10, 1000 * audiosize / this.Fs); - if (data != null) { - this.DecControl.nChannelsInternal = this.stream_channels; - if (mode == OpusMode.MODE_SILK_ONLY) { - if (this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND) { - this.DecControl.internalSampleRate = 8000; - } else if (this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND) { - this.DecControl.internalSampleRate = 12000; - } else if (this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND) { - this.DecControl.internalSampleRate = 16000; - } else { - this.DecControl.internalSampleRate = 16000; - Inlines.OpusAssert(false); - } - } else { - this.DecControl.internalSampleRate = 16000; - } - } - int lost_flag = data == null ? 1 : 2 * decode_fec; - int decoded_samples = 0; - do { - int first_frame = decoded_samples == 0 ? 1 : 0; - BoxedValueInt boxed_silk_frame_size = new BoxedValueInt(0); - silk_ret = DecodeAPI.silk_Decode(silk_dec, this.DecControl, lost_flag, first_frame, dec, pcm_ptr2, pcm_ptr2_ptr, boxed_silk_frame_size); - silk_frame_size = boxed_silk_frame_size.Val; - if (silk_ret != 0) { - if (lost_flag != 0) { - silk_frame_size = frame_size; - Arrays.MemSetWithOffset(pcm_ptr2, (short)0, pcm_ptr2_ptr, frame_size * this.channels); - } else { - return OpusError.OPUS_INTERNAL_ERROR; - } - } - pcm_ptr2_ptr += silk_frame_size * this.channels; - } while ((decoded_samples += silk_frame_size) < frame_size); - } - int start_band = 0; - if (decode_fec == 0 && mode != OpusMode.MODE_CELT_ONLY && data != null && dec.tell() + 17 + 20 * (this.mode == OpusMode.MODE_HYBRID ? 1 : 0) <= 8 * len && (redundancy = mode == OpusMode.MODE_HYBRID ? dec.dec_bit_logp(12L) : 1) != 0) { - celt_to_silk = dec.dec_bit_logp(1L); - int n = redundancy_bytes = mode == OpusMode.MODE_HYBRID ? (int)dec.dec_uint(256L) + 2 : len - (dec.tell() + 7 >> 3); - if ((len -= redundancy_bytes) * 8 < dec.tell()) { - len = 0; - redundancy_bytes = 0; - redundancy = 0; - } - dec.storage -= redundancy_bytes; - } - if (mode != OpusMode.MODE_CELT_ONLY) { - start_band = 17; - } - int endband = 21; - switch (this.bandwidth) { - case OPUS_BANDWIDTH_NARROWBAND: { - endband = 13; - break; - } - case OPUS_BANDWIDTH_MEDIUMBAND: - case OPUS_BANDWIDTH_WIDEBAND: { - endband = 17; - break; - } - case OPUS_BANDWIDTH_SUPERWIDEBAND: { - endband = 19; - break; - } - case OPUS_BANDWIDTH_FULLBAND: { - endband = 21; - } - } - celt_dec.SetEndBand(endband); - celt_dec.SetChannels(this.stream_channels); - if (redundancy != 0) { - transition = false; - pcm_transition_silk_size = 0; - } - short[] pcm_transition_silk = new short[pcm_transition_silk_size]; - if (transition && mode != OpusMode.MODE_CELT_ONLY) { - pcm_transition = pcm_transition_silk; - this.opus_decode_frame(null, 0, 0, pcm_transition, 0, Inlines.IMIN(F5, audiosize), 0); - } - int redundant_audio_size = redundancy != 0 ? F5 * this.channels : 0; - short[] redundant_audio = new short[redundant_audio_size]; - if (redundancy != 0 && celt_to_silk != 0) { - celt_dec.SetStartBand(0); - celt_dec.celt_decode_with_ec(data, data_ptr + len, redundancy_bytes, redundant_audio, 0, F5, null, 0); - redundant_rng = celt_dec.GetFinalRange(); - } - celt_dec.SetStartBand(start_band); - if (mode != OpusMode.MODE_SILK_ONLY) { - int celt_frame_size = Inlines.IMIN(F20, frame_size); - if (mode != this.prev_mode && this.prev_mode != OpusMode.MODE_AUTO && this.prev_mode != OpusMode.MODE_UNKNOWN && this.prev_redundancy == 0) { - celt_dec.ResetState(); - } - celt_ret = celt_dec.celt_decode_with_ec(decode_fec != 0 ? null : data, data_ptr, len, pcm, pcm_ptr, celt_frame_size, dec, celt_accum); - } else { - if (celt_accum == 0) { - for (i = pcm_ptr; i < frame_size * this.channels + pcm_ptr; ++i) { - pcm[i] = 0; - } - } - if (this.prev_mode == OpusMode.MODE_HYBRID && (redundancy == 0 || celt_to_silk == 0 || this.prev_redundancy == 0)) { - celt_dec.SetStartBand(0); - celt_dec.celt_decode_with_ec(SILENCE, 0, 2, pcm, pcm_ptr, F2_5, null, celt_accum); - } - } - if (mode != OpusMode.MODE_CELT_ONLY && celt_accum == 0) { - for (i = 0; i < frame_size * this.channels; ++i) { - pcm[pcm_ptr + i] = Inlines.SAT16(Inlines.ADD32(pcm[pcm_ptr + i], pcm_silk[i])); - } - } - int[] window = celt_dec.GetMode().window; - if (redundancy != 0 && celt_to_silk == 0) { - celt_dec.ResetState(); - celt_dec.SetStartBand(0); - celt_dec.celt_decode_with_ec(data, data_ptr + len, redundancy_bytes, redundant_audio, 0, F5, null, 0); - redundant_rng = celt_dec.GetFinalRange(); - CodecHelpers.smooth_fade(pcm, pcm_ptr + this.channels * (frame_size - F2_5), redundant_audio, this.channels * F2_5, pcm, pcm_ptr + this.channels * (frame_size - F2_5), F2_5, this.channels, window, this.Fs); - } - if (redundancy != 0 && celt_to_silk != 0) { - for (int c = 0; c < this.channels; ++c) { - for (i = 0; i < F2_5; ++i) { - pcm[this.channels * i + c + pcm_ptr] = redundant_audio[this.channels * i + c]; - } - } - CodecHelpers.smooth_fade(redundant_audio, this.channels * F2_5, pcm, pcm_ptr + this.channels * F2_5, pcm, pcm_ptr + this.channels * F2_5, F2_5, this.channels, window, this.Fs); - } - if (transition) { - if (audiosize >= F5) { - for (i = 0; i < this.channels * F2_5; ++i) { - pcm[i] = pcm_transition[i]; - } - CodecHelpers.smooth_fade(pcm_transition, this.channels * F2_5, pcm, pcm_ptr + this.channels * F2_5, pcm, pcm_ptr + this.channels * F2_5, F2_5, this.channels, window, this.Fs); - } else { - CodecHelpers.smooth_fade(pcm_transition, 0, pcm, pcm_ptr, pcm, pcm_ptr, F2_5, this.channels, window, this.Fs); - } - } - if (this.decode_gain != 0) { - int gain = Inlines.celt_exp2(Inlines.MULT16_16_P15(21771, this.decode_gain)); - for (i = pcm_ptr; i < pcm_ptr + frame_size * this.channels; ++i) { - int x = Inlines.MULT16_32_P16(pcm[i], gain); - pcm[i] = (short)Inlines.SATURATE(x, Short.MAX_VALUE); - } - } - this.rangeFinal = len <= 1 ? 0 : (int)dec.rng ^ redundant_rng; - this.prev_mode = mode; - this.prev_redundancy = redundancy != 0 && celt_to_silk == 0 ? 1 : 0; - return celt_ret < 0 ? celt_ret : audiosize; - } - - int opus_decode_native(byte[] data, int data_ptr, int len, short[] pcm_out, int pcm_out_ptr, int frame_size, int decode_fec, int self_delimited, BoxedValueInt packet_offset, int soft_clip) { - packet_offset.Val = 0; - short[] size = new short[48]; - if (decode_fec < 0 || decode_fec > 1) { - return OpusError.OPUS_BAD_ARG; - } - if ((decode_fec != 0 || len == 0 || data == null) && frame_size % (this.Fs / 400) != 0) { - return OpusError.OPUS_BAD_ARG; - } - if (len == 0 || data == null) { - int ret; - int pcm_count = 0; - do { - if ((ret = this.opus_decode_frame(null, 0, 0, pcm_out, pcm_out_ptr + pcm_count * this.channels, frame_size - pcm_count, 0)) >= 0) continue; - return ret; - } while ((pcm_count += ret) < frame_size); - Inlines.OpusAssert(pcm_count == frame_size); - this.last_packet_duration = pcm_count; - return pcm_count; - } - if (len < 0) { - return OpusError.OPUS_BAD_ARG; - } - OpusMode packet_mode = OpusPacketInfo.getEncoderMode(data, data_ptr); - OpusBandwidth packet_bandwidth = OpusPacketInfo.getBandwidth(data, data_ptr); - int packet_frame_size = OpusPacketInfo.getNumSamplesPerFrame(data, data_ptr, this.Fs); - int packet_stream_channels = OpusPacketInfo.getNumEncodedChannels(data, data_ptr); - BoxedValueByte boxed_toc = new BoxedValueByte(0); - BoxedValueInt boxed_offset = new BoxedValueInt(0); - int count = OpusPacketInfo.opus_packet_parse_impl(data, data_ptr, len, self_delimited, boxed_toc, null, 0, size, 0, boxed_offset, packet_offset); - int offset = boxed_offset.Val; - if (count < 0) { - return count; - } - data_ptr += offset; - if (decode_fec != 0) { - int ret; - BoxedValueInt dummy = new BoxedValueInt(0); - if (frame_size < packet_frame_size || packet_mode == OpusMode.MODE_CELT_ONLY || this.mode == OpusMode.MODE_CELT_ONLY) { - return this.opus_decode_native(null, 0, 0, pcm_out, pcm_out_ptr, frame_size, 0, 0, dummy, soft_clip); - } - int duration_copy = this.last_packet_duration; - if (frame_size - packet_frame_size != 0) { - ret = this.opus_decode_native(null, 0, 0, pcm_out, pcm_out_ptr, frame_size - packet_frame_size, 0, 0, dummy, soft_clip); - if (ret < 0) { - this.last_packet_duration = duration_copy; - return ret; - } - Inlines.OpusAssert(ret == frame_size - packet_frame_size); - } - this.mode = packet_mode; - this.bandwidth = packet_bandwidth; - this.frame_size = packet_frame_size; - this.stream_channels = packet_stream_channels; - ret = this.opus_decode_frame(data, data_ptr, size[0], pcm_out, pcm_out_ptr + this.channels * (frame_size - packet_frame_size), packet_frame_size, 1); - if (ret < 0) { - return ret; - } - this.last_packet_duration = frame_size; - return frame_size; - } - if (count * packet_frame_size > frame_size) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - this.mode = packet_mode; - this.bandwidth = packet_bandwidth; - this.frame_size = packet_frame_size; - this.stream_channels = packet_stream_channels; - int nb_samples = 0; - for (int i = 0; i < count; ++i) { - int ret = this.opus_decode_frame(data, data_ptr, size[i], pcm_out, pcm_out_ptr + nb_samples * this.channels, frame_size - nb_samples, 0); - if (ret < 0) { - return ret; - } - Inlines.OpusAssert(ret == packet_frame_size); - data_ptr += size[i]; - nb_samples += ret; - } - this.last_packet_duration = nb_samples; - return nb_samples; - } - - public int decode(byte[] in_data, int in_data_offset, int len, short[] out_pcm, int out_pcm_offset, int frame_size, boolean decode_fec) throws OpusException { - if (frame_size <= 0) { - throw new IllegalArgumentException("Frame size must be > 0"); - } - try { - BoxedValueInt dummy = new BoxedValueInt(0); - int ret = this.opus_decode_native(in_data, in_data_offset, len, out_pcm, out_pcm_offset, frame_size, decode_fec ? 1 : 0, 0, dummy, 0); - if (ret < 0) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("OPUS_BAD_ARG while decoding"); - } - throw new OpusException("An error occurred during decoding", ret); - } - return ret; - } - catch (ArithmeticException e) { - throw new OpusException("Internal error during decoding: " + e.getMessage()); - } - } - - public int decode(byte[] in_data, int in_data_offset, int len, byte[] out_pcm, int out_pcm_offset, int frame_size, boolean decode_fec) throws OpusException { - short[] spcm = new short[Math.min(frame_size, 5760) * this.channels]; - int decSamples = this.decode(in_data, in_data_offset, len, spcm, 0, frame_size, decode_fec); - int idx = out_pcm_offset; - for (int c = 0; c < spcm.length; ++c) { - out_pcm[idx++] = (byte)(spcm[c] & 0xFF); - out_pcm[idx++] = (byte)(spcm[c] >> 8 & 0xFF); - } - return decSamples; - } - - public OpusBandwidth getBandwidth() { - return this.bandwidth; - } - - public int getFinalRange() { - return this.rangeFinal; - } - - public int getSampleRate() { - return this.Fs; - } - - public int getPitch() { - if (this.prev_mode == OpusMode.MODE_CELT_ONLY) { - return this.Celt_Decoder.GetPitch(); - } - return this.DecControl.prevPitchLag; - } - - public int getGain() { - return this.decode_gain; - } - - public void setGain(int value) { - if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { - throw new IllegalArgumentException("Gain must be within the range of a signed int16"); - } - this.decode_gain = value; - } - - public int getLastPacketDuration() { - return this.last_packet_duration; - } - - public void resetState() { - this.partialReset(); - this.Celt_Decoder.ResetState(); - DecodeAPI.silk_InitDecoder(this.SilkDecoder); - this.stream_channels = this.channels; - this.frame_size = this.Fs / 400; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusEncoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusEncoder.java deleted file mode 100644 index 4f7edc8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusEncoder.java +++ /dev/null @@ -1,1062 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Analysis; -import de.maxhenkel.voicechat.concentus.AnalysisInfo; -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltEncoder; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.CodecHelpers; -import de.maxhenkel.voicechat.concentus.EncControlState; -import de.maxhenkel.voicechat.concentus.EncodeAPI; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusApplication; -import de.maxhenkel.voicechat.concentus.OpusBandwidth; -import de.maxhenkel.voicechat.concentus.OpusBandwidthHelpers; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusException; -import de.maxhenkel.voicechat.concentus.OpusFramesize; -import de.maxhenkel.voicechat.concentus.OpusMode; -import de.maxhenkel.voicechat.concentus.OpusRepacketizer; -import de.maxhenkel.voicechat.concentus.OpusSignal; -import de.maxhenkel.voicechat.concentus.OpusTables; -import de.maxhenkel.voicechat.concentus.SilkEncoder; -import de.maxhenkel.voicechat.concentus.StereoWidthState; -import de.maxhenkel.voicechat.concentus.TonalityAnalysisState; - -public class OpusEncoder { - final EncControlState silk_mode = new EncControlState(); - OpusApplication application; - int channels; - int delay_compensation; - int force_channels; - OpusSignal signal_type; - OpusBandwidth user_bandwidth; - OpusBandwidth max_bandwidth; - OpusMode user_forced_mode; - int voice_ratio; - int Fs; - int use_vbr; - int vbr_constraint; - OpusFramesize variable_duration; - int bitrate_bps; - int user_bitrate_bps; - int lsb_depth; - int encoder_buffer; - int lfe; - final TonalityAnalysisState analysis = new TonalityAnalysisState(); - int stream_channels; - short hybrid_stereo_width_Q14; - int variable_HP_smth2_Q15; - int prev_HB_gain; - final int[] hp_mem = new int[4]; - OpusMode mode; - OpusMode prev_mode; - int prev_channels; - int prev_framesize; - OpusBandwidth bandwidth; - int silk_bw_switch; - int first; - int[] energy_masking; - final StereoWidthState width_mem = new StereoWidthState(); - final short[] delay_buffer = new short[960]; - OpusBandwidth detected_bandwidth; - int rangeFinal; - final SilkEncoder SilkEncoder = new SilkEncoder(); - final CeltEncoder Celt_Encoder = new CeltEncoder(); - - OpusEncoder() { - } - - void reset() { - this.silk_mode.Reset(); - this.application = OpusApplication.OPUS_APPLICATION_UNIMPLEMENTED; - this.channels = 0; - this.delay_compensation = 0; - this.force_channels = 0; - this.signal_type = OpusSignal.OPUS_SIGNAL_UNKNOWN; - this.user_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN; - this.max_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN; - this.user_forced_mode = OpusMode.MODE_UNKNOWN; - this.voice_ratio = 0; - this.Fs = 0; - this.use_vbr = 0; - this.vbr_constraint = 0; - this.variable_duration = OpusFramesize.OPUS_FRAMESIZE_UNKNOWN; - this.bitrate_bps = 0; - this.user_bitrate_bps = 0; - this.lsb_depth = 0; - this.encoder_buffer = 0; - this.lfe = 0; - this.analysis.Reset(); - this.PartialReset(); - } - - void PartialReset() { - this.stream_channels = 0; - this.hybrid_stereo_width_Q14 = 0; - this.variable_HP_smth2_Q15 = 0; - this.prev_HB_gain = 0; - Arrays.MemSet(this.hp_mem, 0, 4); - this.mode = OpusMode.MODE_UNKNOWN; - this.prev_mode = OpusMode.MODE_UNKNOWN; - this.prev_channels = 0; - this.prev_framesize = 0; - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN; - this.silk_bw_switch = 0; - this.first = 0; - this.energy_masking = null; - this.width_mem.Reset(); - Arrays.MemSet(this.delay_buffer, (short)0, 960); - this.detected_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN; - this.rangeFinal = 0; - } - - public void resetState() { - EncControlState dummy = new EncControlState(); - this.analysis.Reset(); - this.PartialReset(); - this.Celt_Encoder.ResetState(); - EncodeAPI.silk_InitEncoder(this.SilkEncoder, dummy); - this.stream_channels = this.channels; - this.hybrid_stereo_width_Q14 = (short)16384; - this.prev_HB_gain = Short.MAX_VALUE; - this.first = 1; - this.mode = OpusMode.MODE_HYBRID; - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_FULLBAND; - this.variable_HP_smth2_Q15 = Inlines.silk_LSHIFT(Inlines.silk_lin2log(60), 8); - } - - public OpusEncoder(int Fs, int channels, OpusApplication application) throws OpusException { - if (Fs != 48000 && Fs != 24000 && Fs != 16000 && Fs != 12000 && Fs != 8000) { - throw new IllegalArgumentException("Sample rate is invalid (must be 8/12/16/24/48 Khz)"); - } - if (channels != 1 && channels != 2) { - throw new IllegalArgumentException("Number of channels must be 1 or 2"); - } - int ret = this.opus_init_encoder(Fs, channels, application); - if (ret != OpusError.OPUS_OK) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("OPUS_BAD_ARG when creating encoder"); - } - throw new OpusException("Error while initializing encoder", ret); - } - } - - int opus_init_encoder(int Fs, int channels, OpusApplication application) { - if (Fs != 48000 && Fs != 24000 && Fs != 16000 && Fs != 12000 && Fs != 8000 || channels != 1 && channels != 2 || application == OpusApplication.OPUS_APPLICATION_UNIMPLEMENTED) { - return OpusError.OPUS_BAD_ARG; - } - this.reset(); - SilkEncoder silk_enc = this.SilkEncoder; - CeltEncoder celt_enc = this.Celt_Encoder; - this.stream_channels = this.channels = channels; - this.Fs = Fs; - int ret = EncodeAPI.silk_InitEncoder(silk_enc, this.silk_mode); - if (ret != 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - this.silk_mode.nChannelsAPI = channels; - this.silk_mode.nChannelsInternal = channels; - this.silk_mode.API_sampleRate = this.Fs; - this.silk_mode.maxInternalSampleRate = 16000; - this.silk_mode.minInternalSampleRate = 8000; - this.silk_mode.desiredInternalSampleRate = 16000; - this.silk_mode.payloadSize_ms = 20; - this.silk_mode.bitRate = 25000; - this.silk_mode.packetLossPercentage = 0; - this.silk_mode.complexity = 9; - this.silk_mode.useInBandFEC = 0; - this.silk_mode.useDTX = 0; - this.silk_mode.useCBR = 0; - this.silk_mode.reducedDependency = 0; - int err = celt_enc.celt_encoder_init(Fs, channels); - if (err != OpusError.OPUS_OK) { - return OpusError.OPUS_INTERNAL_ERROR; - } - celt_enc.SetSignalling(0); - celt_enc.SetComplexity(this.silk_mode.complexity); - this.use_vbr = 1; - this.vbr_constraint = 1; - this.user_bitrate_bps = -1000; - this.bitrate_bps = 3000 + Fs * channels; - this.application = application; - this.signal_type = OpusSignal.OPUS_SIGNAL_AUTO; - this.user_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_AUTO; - this.max_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_FULLBAND; - this.force_channels = -1000; - this.user_forced_mode = OpusMode.MODE_AUTO; - this.voice_ratio = -1; - this.encoder_buffer = this.Fs / 100; - this.lsb_depth = 24; - this.variable_duration = OpusFramesize.OPUS_FRAMESIZE_ARG; - this.delay_compensation = this.Fs / 250; - this.hybrid_stereo_width_Q14 = (short)16384; - this.prev_HB_gain = Short.MAX_VALUE; - this.variable_HP_smth2_Q15 = Inlines.silk_LSHIFT(Inlines.silk_lin2log(60), 8); - this.first = 1; - this.mode = OpusMode.MODE_HYBRID; - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_FULLBAND; - Analysis.tonality_analysis_init(this.analysis); - return OpusError.OPUS_OK; - } - - int user_bitrate_to_bitrate(int frame_size, int max_data_bytes) { - if (frame_size == 0) { - frame_size = this.Fs / 400; - } - if (this.user_bitrate_bps == -1000) { - return 60 * this.Fs / frame_size + this.Fs * this.channels; - } - if (this.user_bitrate_bps == -1) { - return max_data_bytes * 8 * this.Fs / frame_size; - } - return this.user_bitrate_bps; - } - - int opus_encode_native(short[] pcm, int pcm_ptr, int frame_size, byte[] data, int data_ptr, int out_data_bytes, int lsb_depth, short[] analysis_pcm, int analysis_pcm_ptr, int analysis_size, int c1, int c2, int analysis_channels, int float_api) { - int nb_compr_bytes; - int i; - int voice_est; - int ret = 0; - EntropyCoder enc = new EntropyCoder(); - boolean prefill = false; - int start_band = 0; - int redundancy = 0; - int redundancy_bytes = 0; - int celt_to_silk = 0; - boolean to_celt = false; - int redundant_rng = 0; - AnalysisInfo analysis_info = new AnalysisInfo(); - int analysis_read_pos_bak = -1; - int analysis_read_subframe_bak = -1; - int max_data_bytes = Inlines.IMIN(1276, out_data_bytes); - this.rangeFinal = 0; - if (this.variable_duration == OpusFramesize.OPUS_FRAMESIZE_UNKNOWN && 400 * frame_size != this.Fs && 200 * frame_size != this.Fs && 100 * frame_size != this.Fs && 50 * frame_size != this.Fs && 25 * frame_size != this.Fs && 50 * frame_size != 3 * this.Fs || 400 * frame_size < this.Fs || max_data_bytes <= 0) { - return OpusError.OPUS_BAD_ARG; - } - SilkEncoder silk_enc = this.SilkEncoder; - CeltEncoder celt_enc = this.Celt_Encoder; - int delay_compensation = this.application == OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY ? 0 : this.delay_compensation; - lsb_depth = Inlines.IMIN(lsb_depth, this.lsb_depth); - CeltMode celt_mode = celt_enc.GetMode(); - this.voice_ratio = -1; - if (this.analysis.enabled) { - analysis_info.valid = 0; - if (this.silk_mode.complexity >= 7 && this.Fs == 48000) { - analysis_read_pos_bak = this.analysis.read_pos; - analysis_read_subframe_bak = this.analysis.read_subframe; - Analysis.run_analysis(this.analysis, celt_mode, (short[])(analysis_pcm != null ? analysis_pcm : null), analysis_pcm_ptr, analysis_size, frame_size, c1, c2, analysis_channels, this.Fs, lsb_depth, analysis_info); - } - this.detected_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN; - if (analysis_info.valid != 0) { - int analysis_bandwidth; - if (this.signal_type == OpusSignal.OPUS_SIGNAL_AUTO) { - this.voice_ratio = (int)Math.floor(0.5f + 100.0f * (1.0f - analysis_info.music_prob)); - } - this.detected_bandwidth = (analysis_bandwidth = analysis_info.bandwidth) <= 12 ? OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND : (analysis_bandwidth <= 14 ? OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND : (analysis_bandwidth <= 16 ? OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND : (analysis_bandwidth <= 18 ? OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND : OpusBandwidth.OPUS_BANDWIDTH_FULLBAND))); - } - } - int stereo_width = this.channels == 2 && this.force_channels != 1 ? CodecHelpers.compute_stereo_width(pcm, pcm_ptr, frame_size, this.Fs, this.width_mem) : 0; - int total_buffer = delay_compensation; - this.bitrate_bps = this.user_bitrate_to_bitrate(frame_size, max_data_bytes); - int frame_rate = this.Fs / frame_size; - if (this.use_vbr == 0) { - int frame_rate3 = 3 * this.Fs / frame_size; - int cbrBytes = Inlines.IMIN((3 * this.bitrate_bps / 8 + frame_rate3 / 2) / frame_rate3, max_data_bytes); - this.bitrate_bps = cbrBytes * frame_rate3 * 8 / 3; - max_data_bytes = cbrBytes; - } - if (max_data_bytes < 3 || this.bitrate_bps < 3 * frame_rate * 8 || frame_rate < 50 && (max_data_bytes * frame_rate < 300 || this.bitrate_bps < 2400)) { - OpusBandwidth bw; - OpusMode tocmode = this.mode; - OpusBandwidth opusBandwidth = bw = this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN ? OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND : this.bandwidth; - if (tocmode == OpusMode.MODE_UNKNOWN) { - tocmode = OpusMode.MODE_SILK_ONLY; - } - if (frame_rate > 100) { - tocmode = OpusMode.MODE_CELT_ONLY; - } - if (frame_rate < 50) { - tocmode = OpusMode.MODE_SILK_ONLY; - } - if (tocmode == OpusMode.MODE_SILK_ONLY && OpusBandwidthHelpers.GetOrdinal(bw) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND)) { - bw = OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND; - } else if (tocmode == OpusMode.MODE_CELT_ONLY && OpusBandwidthHelpers.GetOrdinal(bw) == OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND)) { - bw = OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND; - } else if (tocmode == OpusMode.MODE_HYBRID && OpusBandwidthHelpers.GetOrdinal(bw) <= OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND)) { - bw = OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND; - } - data[data_ptr] = CodecHelpers.gen_toc(tocmode, frame_rate, bw, this.stream_channels); - ret = 1; - if (this.use_vbr == 0 && (ret = OpusRepacketizer.padPacket(data, data_ptr, ret, max_data_bytes)) == OpusError.OPUS_OK) { - ret = max_data_bytes; - } - return ret; - } - int max_rate = frame_rate * max_data_bytes * 8; - int equiv_rate = this.bitrate_bps - (40 * this.channels + 20) * (this.Fs / frame_size - 50); - if (this.signal_type == OpusSignal.OPUS_SIGNAL_VOICE) { - voice_est = 127; - } else if (this.signal_type == OpusSignal.OPUS_SIGNAL_MUSIC) { - voice_est = 0; - } else if (this.voice_ratio >= 0) { - voice_est = this.voice_ratio * 327 >> 8; - if (this.application == OpusApplication.OPUS_APPLICATION_AUDIO) { - voice_est = Inlines.IMIN(voice_est, 115); - } - } else { - voice_est = this.application == OpusApplication.OPUS_APPLICATION_VOIP ? 115 : 48; - } - if (this.force_channels != -1000 && this.channels == 2) { - this.stream_channels = this.force_channels; - } else if (this.channels == 2) { - int stereo_threshold = 30000 + (voice_est * voice_est * 0 >> 14); - stereo_threshold = this.stream_channels == 2 ? (stereo_threshold -= 1000) : (stereo_threshold += 1000); - this.stream_channels = equiv_rate > stereo_threshold ? 2 : 1; - } else { - this.stream_channels = this.channels; - } - equiv_rate = this.bitrate_bps - (40 * this.stream_channels + 20) * (this.Fs / frame_size - 50); - if (this.application == OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY) { - this.mode = OpusMode.MODE_CELT_ONLY; - } else if (this.user_forced_mode == OpusMode.MODE_AUTO) { - int mode_voice = Inlines.MULT16_32_Q15(Short.MAX_VALUE - stereo_width, OpusTables.mode_thresholds[0][0]) + Inlines.MULT16_32_Q15(stereo_width, OpusTables.mode_thresholds[1][0]); - int mode_music = Inlines.MULT16_32_Q15(Short.MAX_VALUE - stereo_width, OpusTables.mode_thresholds[1][1]) + Inlines.MULT16_32_Q15(stereo_width, OpusTables.mode_thresholds[1][1]); - int threshold = mode_music + (voice_est * voice_est * (mode_voice - mode_music) >> 14); - if (this.application == OpusApplication.OPUS_APPLICATION_VOIP) { - threshold += 8000; - } - if (this.prev_mode == OpusMode.MODE_CELT_ONLY) { - threshold -= 4000; - } else if (this.prev_mode != OpusMode.MODE_AUTO && this.prev_mode != OpusMode.MODE_UNKNOWN) { - threshold += 4000; - } - OpusMode opusMode = this.mode = equiv_rate >= threshold ? OpusMode.MODE_CELT_ONLY : OpusMode.MODE_SILK_ONLY; - if (this.silk_mode.useInBandFEC != 0 && this.silk_mode.packetLossPercentage > 128 - voice_est >> 4) { - this.mode = OpusMode.MODE_SILK_ONLY; - } - if (this.silk_mode.useDTX != 0 && voice_est > 100) { - this.mode = OpusMode.MODE_SILK_ONLY; - } - } else { - this.mode = this.user_forced_mode; - } - if (this.mode != OpusMode.MODE_CELT_ONLY && frame_size < this.Fs / 100) { - this.mode = OpusMode.MODE_CELT_ONLY; - } - if (this.lfe != 0) { - this.mode = OpusMode.MODE_CELT_ONLY; - } - if (max_data_bytes < (frame_rate > 50 ? 12000 : 8000) * frame_size / (this.Fs * 8)) { - this.mode = OpusMode.MODE_CELT_ONLY; - } - if (this.stream_channels == 1 && this.prev_channels == 2 && this.silk_mode.toMono == 0 && this.mode != OpusMode.MODE_CELT_ONLY && this.prev_mode != OpusMode.MODE_CELT_ONLY) { - this.silk_mode.toMono = 1; - this.stream_channels = 2; - } else { - this.silk_mode.toMono = 0; - } - if (this.prev_mode != OpusMode.MODE_AUTO && this.prev_mode != OpusMode.MODE_UNKNOWN && (this.mode != OpusMode.MODE_CELT_ONLY && this.prev_mode == OpusMode.MODE_CELT_ONLY || this.mode == OpusMode.MODE_CELT_ONLY && this.prev_mode != OpusMode.MODE_CELT_ONLY)) { - redundancy = 1; - int n = celt_to_silk = this.mode != OpusMode.MODE_CELT_ONLY ? 1 : 0; - if (celt_to_silk == 0) { - if (frame_size >= this.Fs / 100) { - this.mode = this.prev_mode; - to_celt = true; - } else { - redundancy = 0; - } - } - } - if (this.silk_bw_switch != 0) { - redundancy = 1; - celt_to_silk = 1; - this.silk_bw_switch = 0; - prefill = true; - } - if (redundancy != 0) { - redundancy_bytes = Inlines.IMIN(257, max_data_bytes * (this.Fs / 200) / (frame_size + this.Fs / 200)); - if (this.use_vbr != 0) { - redundancy_bytes = Inlines.IMIN(redundancy_bytes, this.bitrate_bps / 1600); - } - } - if (this.mode != OpusMode.MODE_CELT_ONLY && this.prev_mode == OpusMode.MODE_CELT_ONLY) { - EncControlState dummy = new EncControlState(); - EncodeAPI.silk_InitEncoder(silk_enc, dummy); - prefill = true; - } - if (this.mode == OpusMode.MODE_CELT_ONLY || this.first != 0 || this.silk_mode.allowBandwidthSwitch != 0) { - int threshold; - int[] music_bandwidth_thresholds; - int[] voice_bandwidth_thresholds; - int[] bandwidth_thresholds = new int[8]; - OpusBandwidth bandwidth = OpusBandwidth.OPUS_BANDWIDTH_FULLBAND; - int equiv_rate2 = equiv_rate; - if (this.mode != OpusMode.MODE_CELT_ONLY) { - equiv_rate2 = equiv_rate2 * (45 + this.silk_mode.complexity) / 50; - if (this.use_vbr == 0) { - equiv_rate2 -= 1000; - } - } - if (this.channels == 2 && this.force_channels != 1) { - voice_bandwidth_thresholds = OpusTables.stereo_voice_bandwidth_thresholds; - music_bandwidth_thresholds = OpusTables.stereo_music_bandwidth_thresholds; - } else { - voice_bandwidth_thresholds = OpusTables.mono_voice_bandwidth_thresholds; - music_bandwidth_thresholds = OpusTables.mono_music_bandwidth_thresholds; - } - for (i = 0; i < 8; ++i) { - bandwidth_thresholds[i] = music_bandwidth_thresholds[i] + (voice_est * voice_est * (voice_bandwidth_thresholds[i] - music_bandwidth_thresholds[i]) >> 14); - } - do { - threshold = bandwidth_thresholds[2 * (OpusBandwidthHelpers.GetOrdinal(bandwidth) - OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND))]; - int hysteresis = bandwidth_thresholds[2 * (OpusBandwidthHelpers.GetOrdinal(bandwidth) - OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND)) + 1]; - if (this.first != 0) continue; - if (OpusBandwidthHelpers.GetOrdinal(this.bandwidth) >= OpusBandwidthHelpers.GetOrdinal(bandwidth)) { - threshold -= hysteresis; - continue; - } - threshold += hysteresis; - } while (equiv_rate2 < threshold && OpusBandwidthHelpers.GetOrdinal(bandwidth = OpusBandwidthHelpers.SUBTRACT(bandwidth, 1)) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND)); - this.bandwidth = bandwidth; - if (this.first == 0 && this.mode != OpusMode.MODE_CELT_ONLY && this.silk_mode.inWBmodeWithoutVariableLP == 0 && OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND)) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND; - } - } - if (OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(this.max_bandwidth)) { - this.bandwidth = this.max_bandwidth; - } - if (this.user_bandwidth != OpusBandwidth.OPUS_BANDWIDTH_AUTO) { - this.bandwidth = this.user_bandwidth; - } - if (this.mode != OpusMode.MODE_CELT_ONLY && max_rate < 15000) { - this.bandwidth = OpusBandwidthHelpers.MIN(this.bandwidth, OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND); - } - if (this.Fs <= 24000 && OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND)) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND; - } - if (this.Fs <= 16000 && OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND)) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND; - } - if (this.Fs <= 12000 && OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND)) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND; - } - if (this.Fs <= 8000 && OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND)) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND; - } - if (this.detected_bandwidth != OpusBandwidth.OPUS_BANDWIDTH_UNKNOWN && this.user_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_AUTO) { - OpusBandwidth min_detected_bandwidth = equiv_rate <= 18000 * this.stream_channels && this.mode == OpusMode.MODE_CELT_ONLY ? OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND : (equiv_rate <= 24000 * this.stream_channels && this.mode == OpusMode.MODE_CELT_ONLY ? OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND : (equiv_rate <= 30000 * this.stream_channels ? OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND : (equiv_rate <= 44000 * this.stream_channels ? OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND : OpusBandwidth.OPUS_BANDWIDTH_FULLBAND))); - this.detected_bandwidth = OpusBandwidthHelpers.MAX(this.detected_bandwidth, min_detected_bandwidth); - this.bandwidth = OpusBandwidthHelpers.MIN(this.bandwidth, this.detected_bandwidth); - } - celt_enc.SetLSBDepth(lsb_depth); - if (this.mode == OpusMode.MODE_CELT_ONLY && this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND; - } - if (this.lfe != 0) { - this.bandwidth = OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND; - } - if (frame_size > this.Fs / 50 && (this.mode == OpusMode.MODE_CELT_ONLY || OpusBandwidthHelpers.GetOrdinal(this.bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND))) { - if (this.analysis.enabled && analysis_read_pos_bak != -1) { - this.analysis.read_pos = analysis_read_pos_bak; - this.analysis.read_subframe = analysis_read_subframe_bak; - } - int nb_frames = frame_size > this.Fs / 25 ? 3 : 2; - int bytes_per_frame = Inlines.IMIN(1276, (out_data_bytes - 3) / nb_frames); - byte[] tmp_data = new byte[nb_frames * bytes_per_frame]; - OpusRepacketizer rp = new OpusRepacketizer(); - OpusMode bak_mode = this.user_forced_mode; - OpusBandwidth bak_bandwidth = this.user_bandwidth; - int bak_channels = this.force_channels; - this.user_forced_mode = this.mode; - this.user_bandwidth = this.bandwidth; - this.force_channels = this.stream_channels; - int bak_to_mono = this.silk_mode.toMono; - if (bak_to_mono != 0) { - this.force_channels = 1; - } else { - this.prev_channels = this.stream_channels; - } - for (i = 0; i < nb_frames; ++i) { - int tmp_len; - this.silk_mode.toMono = 0; - if (to_celt && i == nb_frames - 1) { - this.user_forced_mode = OpusMode.MODE_CELT_ONLY; - } - if ((tmp_len = this.opus_encode_native(pcm, pcm_ptr + i * (this.channels * this.Fs / 50), this.Fs / 50, tmp_data, i * bytes_per_frame, bytes_per_frame, lsb_depth, null, 0, 0, c1, c2, analysis_channels, float_api)) < 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - ret = rp.addPacket(tmp_data, i * bytes_per_frame, tmp_len); - if (ret >= 0) continue; - return OpusError.OPUS_INTERNAL_ERROR; - } - int repacketize_len = this.use_vbr != 0 ? out_data_bytes : Inlines.IMIN(3 * this.bitrate_bps / (1200 / nb_frames), out_data_bytes); - ret = rp.opus_repacketizer_out_range_impl(0, nb_frames, data, data_ptr, repacketize_len, 0, this.use_vbr == 0 ? 1 : 0); - if (ret < 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - this.user_forced_mode = bak_mode; - this.user_bandwidth = bak_bandwidth; - this.force_channels = bak_channels; - this.silk_mode.toMono = bak_to_mono; - return ret; - } - OpusBandwidth curr_bandwidth = this.bandwidth; - if (this.mode == OpusMode.MODE_SILK_ONLY && OpusBandwidthHelpers.GetOrdinal(curr_bandwidth) > OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND)) { - this.mode = OpusMode.MODE_HYBRID; - } - if (this.mode == OpusMode.MODE_HYBRID && OpusBandwidthHelpers.GetOrdinal(curr_bandwidth) <= OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND)) { - this.mode = OpusMode.MODE_SILK_ONLY; - } - int bytes_target = Inlines.IMIN(max_data_bytes - redundancy_bytes, this.bitrate_bps * frame_size / (this.Fs * 8)) - 1; - enc.enc_init(data, ++data_ptr, max_data_bytes - 1); - short[] pcm_buf = new short[(total_buffer + frame_size) * this.channels]; - System.arraycopy(this.delay_buffer, (this.encoder_buffer - total_buffer) * this.channels, pcm_buf, 0, total_buffer * this.channels); - int hp_freq_smth1 = this.mode == OpusMode.MODE_CELT_ONLY ? Inlines.silk_LSHIFT(Inlines.silk_lin2log(60), 8) : silk_enc.state_Fxx[0].variable_HP_smth1_Q15; - this.variable_HP_smth2_Q15 = Inlines.silk_SMLAWB(this.variable_HP_smth2_Q15, hp_freq_smth1 - this.variable_HP_smth2_Q15, 983); - int cutoff_Hz = Inlines.silk_log2lin(Inlines.silk_RSHIFT(this.variable_HP_smth2_Q15, 8)); - if (this.application == OpusApplication.OPUS_APPLICATION_VOIP) { - CodecHelpers.hp_cutoff(pcm, pcm_ptr, cutoff_Hz, pcm_buf, total_buffer * this.channels, this.hp_mem, frame_size, this.channels, this.Fs); - } else { - CodecHelpers.dc_reject(pcm, pcm_ptr, 3, pcm_buf, total_buffer * this.channels, this.hp_mem, frame_size, this.channels, this.Fs); - } - int HB_gain = Short.MAX_VALUE; - if (this.mode != OpusMode.MODE_CELT_ONLY) { - short[] pcm_silk = new short[this.channels * frame_size]; - int total_bitRate = 8 * bytes_target * frame_rate; - if (this.mode == OpusMode.MODE_HYBRID) { - this.silk_mode.bitRate = this.stream_channels * (5000 + (this.Fs == 100 * frame_size ? 1000 : 0)); - this.silk_mode.bitRate = curr_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND ? (this.silk_mode.bitRate += (total_bitRate - this.silk_mode.bitRate) * 2 / 3) : (this.silk_mode.bitRate += (total_bitRate - this.silk_mode.bitRate) * 3 / 5); - if (this.silk_mode.bitRate > total_bitRate * 4 / 5) { - this.silk_mode.bitRate = total_bitRate * 4 / 5; - } - if (this.energy_masking == null) { - int celt_rate = total_bitRate - this.silk_mode.bitRate; - int HB_gain_ref = curr_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND ? 3000 : 3600; - HB_gain = Inlines.SHL32(celt_rate, 9) / Inlines.SHR32(celt_rate + this.stream_channels * HB_gain_ref, 6); - HB_gain = HB_gain < 28086 ? HB_gain + 4681 : Short.MAX_VALUE; - } - } else { - this.silk_mode.bitRate = total_bitRate; - } - if (this.energy_masking != null && this.use_vbr != 0 && this.lfe == 0) { - int mask_sum = 0; - int end = 17; - int srate = 16000; - if (this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND) { - end = 13; - srate = 8000; - } else if (this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND) { - end = 15; - srate = 12000; - } - for (int c = 0; c < this.channels; ++c) { - for (i = 0; i < end; ++i) { - int mask = Inlines.MAX16(Inlines.MIN16(this.energy_masking[21 * c + i], 512), -2048); - if (mask > 0) { - mask = Inlines.HALF16(mask); - } - mask_sum += mask; - } - } - int masking_depth = mask_sum / end * this.channels; - int rate_offset = Inlines.PSHR32(Inlines.MULT16_16(srate, masking_depth += 205), 10); - rate_offset = Inlines.MAX32(rate_offset, -2 * this.silk_mode.bitRate / 3); - this.silk_mode.bitRate = this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND || this.bandwidth == OpusBandwidth.OPUS_BANDWIDTH_FULLBAND ? (this.silk_mode.bitRate += 3 * rate_offset / 5) : (this.silk_mode.bitRate += rate_offset); - bytes_target += rate_offset * frame_size / (8 * this.Fs); - } - this.silk_mode.payloadSize_ms = 1000 * frame_size / this.Fs; - this.silk_mode.nChannelsAPI = this.channels; - this.silk_mode.nChannelsInternal = this.stream_channels; - if (curr_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND) { - this.silk_mode.desiredInternalSampleRate = 8000; - } else if (curr_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND) { - this.silk_mode.desiredInternalSampleRate = 12000; - } else { - Inlines.OpusAssert(this.mode == OpusMode.MODE_HYBRID || curr_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND); - this.silk_mode.desiredInternalSampleRate = 16000; - } - this.silk_mode.minInternalSampleRate = this.mode == OpusMode.MODE_HYBRID ? 16000 : 8000; - if (this.mode == OpusMode.MODE_SILK_ONLY) { - int effective_max_rate = max_rate; - this.silk_mode.maxInternalSampleRate = 16000; - if (frame_rate > 50) { - effective_max_rate = effective_max_rate * 2 / 3; - } - if (effective_max_rate < 13000) { - this.silk_mode.maxInternalSampleRate = 12000; - this.silk_mode.desiredInternalSampleRate = Inlines.IMIN(12000, this.silk_mode.desiredInternalSampleRate); - } - if (effective_max_rate < 9600) { - this.silk_mode.maxInternalSampleRate = 8000; - this.silk_mode.desiredInternalSampleRate = Inlines.IMIN(8000, this.silk_mode.desiredInternalSampleRate); - } - } else { - this.silk_mode.maxInternalSampleRate = 16000; - } - this.silk_mode.useCBR = this.use_vbr == 0 ? 1 : 0; - int nBytes = Inlines.IMIN(1275, max_data_bytes - 1 - redundancy_bytes); - this.silk_mode.maxBits = nBytes * 8; - if (this.mode == OpusMode.MODE_HYBRID) { - this.silk_mode.maxBits = this.silk_mode.maxBits * 9 / 10; - } - if (this.silk_mode.useCBR != 0) { - this.silk_mode.maxBits = this.silk_mode.bitRate * frame_size / (this.Fs * 8) * 8; - this.silk_mode.bitRate = Inlines.IMAX(1, this.silk_mode.bitRate - 2000); - } - if (prefill) { - BoxedValueInt zero = new BoxedValueInt(0); - int prefill_offset = this.channels * (this.encoder_buffer - this.delay_compensation - this.Fs / 400); - CodecHelpers.gain_fade(this.delay_buffer, prefill_offset, 0, Short.MAX_VALUE, celt_mode.overlap, this.Fs / 400, this.channels, celt_mode.window, this.Fs); - Arrays.MemSet(this.delay_buffer, (short)0, prefill_offset); - System.arraycopy(this.delay_buffer, 0, pcm_silk, 0, this.encoder_buffer * this.channels); - EncodeAPI.silk_Encode(silk_enc, this.silk_mode, pcm_silk, this.encoder_buffer, null, zero, 1); - } - System.arraycopy(pcm_buf, total_buffer * this.channels, pcm_silk, 0, frame_size * this.channels); - BoxedValueInt boxed_silkBytes = new BoxedValueInt(nBytes); - ret = EncodeAPI.silk_Encode(silk_enc, this.silk_mode, pcm_silk, frame_size, enc, boxed_silkBytes, 0); - nBytes = boxed_silkBytes.Val; - if (ret != 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - if (nBytes == 0) { - this.rangeFinal = 0; - data[data_ptr - 1] = CodecHelpers.gen_toc(this.mode, this.Fs / frame_size, curr_bandwidth, this.stream_channels); - return 1; - } - if (this.mode == OpusMode.MODE_SILK_ONLY) { - if (this.silk_mode.internalSampleRate == 8000) { - curr_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND; - } else if (this.silk_mode.internalSampleRate == 12000) { - curr_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND; - } else if (this.silk_mode.internalSampleRate == 16000) { - curr_bandwidth = OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND; - } - } else { - Inlines.OpusAssert(this.silk_mode.internalSampleRate == 16000); - } - this.silk_mode.opusCanSwitch = this.silk_mode.switchReady; - if (this.silk_mode.opusCanSwitch != 0) { - redundancy = 1; - celt_to_silk = 0; - this.silk_bw_switch = 1; - } - } - int endband = 21; - switch (curr_bandwidth) { - case OPUS_BANDWIDTH_NARROWBAND: { - endband = 13; - break; - } - case OPUS_BANDWIDTH_MEDIUMBAND: - case OPUS_BANDWIDTH_WIDEBAND: { - endband = 17; - break; - } - case OPUS_BANDWIDTH_SUPERWIDEBAND: { - endband = 19; - break; - } - case OPUS_BANDWIDTH_FULLBAND: { - endband = 21; - } - } - celt_enc.SetEndBand(endband); - celt_enc.SetChannels(this.stream_channels); - celt_enc.SetBitrate(-1); - if (this.mode != OpusMode.MODE_SILK_ONLY) { - int celt_pred = 2; - celt_enc.SetVBR(false); - if (this.silk_mode.reducedDependency != 0) { - celt_pred = 0; - } - celt_enc.SetPrediction(celt_pred); - if (this.mode == OpusMode.MODE_HYBRID) { - int len = enc.tell() + 7 >> 3; - if (redundancy != 0) { - len += this.mode == OpusMode.MODE_HYBRID ? 3 : 1; - } - nb_compr_bytes = this.use_vbr != 0 ? len + bytes_target - this.silk_mode.bitRate * frame_size / (8 * this.Fs) : (len > bytes_target ? len : bytes_target); - } else if (this.use_vbr != 0) { - int bonus = 0; - if (this.analysis.enabled && this.variable_duration == OpusFramesize.OPUS_FRAMESIZE_VARIABLE && frame_size != this.Fs / 50) { - bonus = (60 * this.stream_channels + 40) * (this.Fs / frame_size - 50); - if (analysis_info.valid != 0) { - bonus = (int)((float)bonus * (1.0f + 0.5f * analysis_info.tonality)); - } - } - celt_enc.SetVBR(true); - celt_enc.SetVBRConstraint(this.vbr_constraint != 0); - celt_enc.SetBitrate(this.bitrate_bps + bonus); - nb_compr_bytes = max_data_bytes - 1 - redundancy_bytes; - } else { - nb_compr_bytes = bytes_target; - } - } else { - nb_compr_bytes = 0; - } - short[] tmp_prefill = new short[this.channels * this.Fs / 400]; - if (this.mode != OpusMode.MODE_SILK_ONLY && this.mode != this.prev_mode && this.prev_mode != OpusMode.MODE_AUTO && this.prev_mode != OpusMode.MODE_UNKNOWN) { - System.arraycopy(this.delay_buffer, (this.encoder_buffer - total_buffer - this.Fs / 400) * this.channels, tmp_prefill, 0, this.channels * this.Fs / 400); - } - if (this.channels * (this.encoder_buffer - (frame_size + total_buffer)) > 0) { - Arrays.MemMove(this.delay_buffer, this.channels * frame_size, 0, this.channels * (this.encoder_buffer - frame_size - total_buffer)); - System.arraycopy(pcm_buf, 0, this.delay_buffer, this.channels * (this.encoder_buffer - frame_size - total_buffer), (frame_size + total_buffer) * this.channels); - } else { - System.arraycopy(pcm_buf, (frame_size + total_buffer - this.encoder_buffer) * this.channels, this.delay_buffer, 0, this.encoder_buffer * this.channels); - } - if (this.prev_HB_gain < Short.MAX_VALUE || HB_gain < Short.MAX_VALUE) { - CodecHelpers.gain_fade(pcm_buf, 0, this.prev_HB_gain, HB_gain, celt_mode.overlap, frame_size, this.channels, celt_mode.window, this.Fs); - } - this.prev_HB_gain = HB_gain; - if (this.mode != OpusMode.MODE_HYBRID || this.stream_channels == 1) { - this.silk_mode.stereoWidth_Q14 = Inlines.IMIN(16384, 2 * Inlines.IMAX(0, equiv_rate - 30000)); - } - if (this.energy_masking == null && this.channels == 2 && (this.hybrid_stereo_width_Q14 < 16384 || this.silk_mode.stereoWidth_Q14 < 16384)) { - int g1 = this.hybrid_stereo_width_Q14; - int g2 = this.silk_mode.stereoWidth_Q14; - g1 = g1 == 16384 ? Short.MAX_VALUE : Inlines.SHL16(g1, 1); - g2 = g2 == 16384 ? Short.MAX_VALUE : Inlines.SHL16(g2, 1); - CodecHelpers.stereo_fade(pcm_buf, g1, g2, celt_mode.overlap, frame_size, this.channels, celt_mode.window, this.Fs); - this.hybrid_stereo_width_Q14 = (short)this.silk_mode.stereoWidth_Q14; - } - if (this.mode != OpusMode.MODE_CELT_ONLY && enc.tell() + 17 + 20 * (this.mode == OpusMode.MODE_HYBRID ? 1 : 0) <= 8 * (max_data_bytes - 1)) { - if (this.mode == OpusMode.MODE_HYBRID && (redundancy != 0 || enc.tell() + 37 <= 8 * nb_compr_bytes)) { - enc.enc_bit_logp(redundancy, 12); - } - if (redundancy != 0) { - enc.enc_bit_logp(celt_to_silk, 1); - int max_redundancy = this.mode == OpusMode.MODE_HYBRID ? max_data_bytes - 1 - nb_compr_bytes : max_data_bytes - 1 - (enc.tell() + 7 >> 3); - redundancy_bytes = Inlines.IMIN(max_redundancy, this.bitrate_bps / 1600); - redundancy_bytes = Inlines.IMIN(257, Inlines.IMAX(2, redundancy_bytes)); - if (this.mode == OpusMode.MODE_HYBRID) { - enc.enc_uint(redundancy_bytes - 2, 256L); - } - } - } else { - redundancy = 0; - } - if (redundancy == 0) { - this.silk_bw_switch = 0; - redundancy_bytes = 0; - } - if (this.mode != OpusMode.MODE_CELT_ONLY) { - start_band = 17; - } - if (this.mode == OpusMode.MODE_SILK_ONLY) { - ret = enc.tell() + 7 >> 3; - enc.enc_done(); - nb_compr_bytes = ret; - } else { - nb_compr_bytes = Inlines.IMIN(max_data_bytes - 1 - redundancy_bytes, nb_compr_bytes); - enc.enc_shrink(nb_compr_bytes); - } - if (this.analysis.enabled && redundancy != 0 || this.mode != OpusMode.MODE_SILK_ONLY) { - analysis_info.enabled = this.analysis.enabled; - celt_enc.SetAnalysis(analysis_info); - } - if (redundancy != 0 && celt_to_silk != 0) { - celt_enc.SetStartBand(0); - celt_enc.SetVBR(false); - int err = celt_enc.celt_encode_with_ec(pcm_buf, 0, this.Fs / 200, data, data_ptr + nb_compr_bytes, redundancy_bytes, null); - if (err < 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - redundant_rng = celt_enc.GetFinalRange(); - celt_enc.ResetState(); - } - celt_enc.SetStartBand(start_band); - if (this.mode != OpusMode.MODE_SILK_ONLY) { - if (this.mode != this.prev_mode && this.prev_mode != OpusMode.MODE_AUTO && this.prev_mode != OpusMode.MODE_UNKNOWN) { - byte[] dummy = new byte[2]; - celt_enc.ResetState(); - celt_enc.celt_encode_with_ec(tmp_prefill, 0, this.Fs / 400, dummy, 0, 2, null); - celt_enc.SetPrediction(0); - } - if (enc.tell() <= 8 * nb_compr_bytes && (ret = celt_enc.celt_encode_with_ec(pcm_buf, 0, frame_size, null, 0, nb_compr_bytes, enc)) < 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - } - if (redundancy != 0 && celt_to_silk == 0) { - byte[] dummy = new byte[2]; - int N2 = this.Fs / 200; - int N4 = this.Fs / 400; - celt_enc.ResetState(); - celt_enc.SetStartBand(0); - celt_enc.SetPrediction(0); - celt_enc.celt_encode_with_ec(pcm_buf, this.channels * (frame_size - N2 - N4), N4, dummy, 0, 2, null); - int err = celt_enc.celt_encode_with_ec(pcm_buf, this.channels * (frame_size - N2), N2, data, data_ptr + nb_compr_bytes, redundancy_bytes, null); - if (err < 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - redundant_rng = celt_enc.GetFinalRange(); - } - data[--data_ptr] = CodecHelpers.gen_toc(this.mode, this.Fs / frame_size, curr_bandwidth, this.stream_channels); - this.rangeFinal = (int)enc.rng ^ redundant_rng; - this.prev_mode = to_celt ? OpusMode.MODE_CELT_ONLY : this.mode; - this.prev_channels = this.stream_channels; - this.prev_framesize = frame_size; - this.first = 0; - if (enc.tell() > (max_data_bytes - 1) * 8) { - if (max_data_bytes < 2) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - data[data_ptr + 1] = 0; - ret = 1; - this.rangeFinal = 0; - } else if (this.mode == OpusMode.MODE_SILK_ONLY && redundancy == 0) { - while (ret > 2 && data[data_ptr + ret] == 0) { - --ret; - } - } - ret += 1 + redundancy_bytes; - if (this.use_vbr == 0) { - if (OpusRepacketizer.padPacket(data, data_ptr, ret, max_data_bytes) != OpusError.OPUS_OK) { - return OpusError.OPUS_INTERNAL_ERROR; - } - ret = max_data_bytes; - } - return ret; - } - - public int encode(short[] in_pcm, int pcm_offset, int frame_size, byte[] out_data, int out_data_offset, int max_data_bytes) throws OpusException { - if (out_data_offset + max_data_bytes > out_data.length) { - throw new IllegalArgumentException("Output buffer is too small: Stated size is " + max_data_bytes + " bytes, actual size is " + (out_data.length - out_data_offset) + " bytes"); - } - int delay_compensation = this.application == OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY ? 0 : this.delay_compensation; - int internal_frame_size = CodecHelpers.compute_frame_size(in_pcm, pcm_offset, frame_size, this.variable_duration, this.channels, this.Fs, this.bitrate_bps, delay_compensation, this.analysis.subframe_mem, this.analysis.enabled); - if (pcm_offset + internal_frame_size > in_pcm.length) { - throw new IllegalArgumentException("Not enough samples provided in input signal: Expected " + internal_frame_size + " samples, found " + (in_pcm.length - pcm_offset)); - } - try { - int ret = this.opus_encode_native(in_pcm, pcm_offset, internal_frame_size, out_data, out_data_offset, max_data_bytes, 16, in_pcm, pcm_offset, frame_size, 0, -2, this.channels, 0); - if (ret < 0) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("OPUS_BAD_ARG while encoding"); - } - throw new OpusException("An error occurred during encoding", ret); - } - return ret; - } - catch (ArithmeticException e) { - throw new OpusException("Internal error during encoding: " + e.getMessage()); - } - } - - public int encode(byte[] in_pcm, int pcm_offset, int frame_size, byte[] out_data, int out_data_offset, int max_data_bytes) throws OpusException { - short[] spcm = new short[frame_size * this.channels]; - int idx = pcm_offset; - for (int c = 0; c < spcm.length; ++c) { - spcm[c] = (short)((in_pcm[idx] & 0xFF | in_pcm[idx + 1] << 8) & 0xFFFF); - idx += 2; - } - return this.encode(spcm, 0, frame_size, out_data, out_data_offset, max_data_bytes); - } - - public OpusApplication getApplication() { - return this.application; - } - - public void setApplication(OpusApplication value) { - if (this.first == 0 && this.application != value) { - throw new IllegalArgumentException("Application cannot be changed after encoding has started"); - } - this.application = value; - } - - public int getBitrate() { - return this.user_bitrate_to_bitrate(this.prev_framesize, 1276); - } - - public void setBitrate(int value) { - if (value != -1000 && value != -1) { - if (value <= 0) { - throw new IllegalArgumentException("Bitrate must be positive"); - } - if (value <= 500) { - value = 500; - } else if (value > 300000 * this.channels) { - value = 300000 * this.channels; - } - } - this.user_bitrate_bps = value; - } - - public int getForceChannels() { - return this.force_channels; - } - - public void setForceChannels(int value) { - if ((value < 1 || value > this.channels) && value != -1000) { - throw new IllegalArgumentException("Force channels must be <= num. of channels"); - } - this.force_channels = value; - } - - public OpusBandwidth getMaxBandwidth() { - return this.max_bandwidth; - } - - public void setMaxBandwidth(OpusBandwidth value) { - this.max_bandwidth = value; - this.silk_mode.maxInternalSampleRate = this.max_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND ? 8000 : (this.max_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND ? 12000 : 16000); - } - - public OpusBandwidth getBandwidth() { - return this.bandwidth; - } - - public void setBandwidth(OpusBandwidth value) { - this.user_bandwidth = value; - this.silk_mode.maxInternalSampleRate = this.user_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND ? 8000 : (this.user_bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND ? 12000 : 16000); - } - - public boolean getUseDTX() { - return this.silk_mode.useDTX != 0; - } - - public void setUseDTX(boolean value) { - this.silk_mode.useDTX = value ? 1 : 0; - } - - public int getComplexity() { - return this.silk_mode.complexity; - } - - public void setComplexity(int value) { - if (value < 0 || value > 10) { - throw new IllegalArgumentException("Complexity must be between 0 and 10"); - } - this.silk_mode.complexity = value; - this.Celt_Encoder.SetComplexity(value); - } - - public boolean getUseInbandFEC() { - return this.silk_mode.useInBandFEC != 0; - } - - public void setUseInbandFEC(boolean value) { - this.silk_mode.useInBandFEC = value ? 1 : 0; - } - - public int getPacketLossPercent() { - return this.silk_mode.packetLossPercentage; - } - - public void setPacketLossPercent(int value) { - if (value < 0 || value > 100) { - throw new IllegalArgumentException("Packet loss must be between 0 and 100"); - } - this.silk_mode.packetLossPercentage = value; - this.Celt_Encoder.SetPacketLossPercent(value); - } - - public boolean getUseVBR() { - return this.use_vbr != 0; - } - - public void setUseVBR(boolean value) { - this.use_vbr = value ? 1 : 0; - this.silk_mode.useCBR = value ? 0 : 1; - } - - public boolean getUseConstrainedVBR() { - return this.vbr_constraint != 0; - } - - public void setUseConstrainedVBR(boolean value) { - this.vbr_constraint = value ? 1 : 0; - } - - public OpusSignal getSignalType() { - return this.signal_type; - } - - public void setSignalType(OpusSignal value) { - this.signal_type = value; - } - - public int getLookahead() { - int returnVal = this.Fs / 400; - if (this.application != OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY) { - returnVal += this.delay_compensation; - } - return returnVal; - } - - public int getSampleRate() { - return this.Fs; - } - - public int getFinalRange() { - return this.rangeFinal; - } - - public int getLSBDepth() { - return this.lsb_depth; - } - - public void setLSBDepth(int value) { - if (value < 8 || value > 24) { - throw new IllegalArgumentException("LSB depth must be between 8 and 24"); - } - this.lsb_depth = value; - } - - public OpusFramesize getExpertFrameDuration() { - return this.variable_duration; - } - - public void setExpertFrameDuration(OpusFramesize value) { - this.variable_duration = value; - this.Celt_Encoder.SetExpertFrameDuration(value); - } - - public OpusMode getForceMode() { - return this.user_forced_mode; - } - - public void setForceMode(OpusMode value) { - this.user_forced_mode = value; - } - - public boolean getIsLFE() { - return this.lfe != 0; - } - - public void setIsLFE(boolean value) { - this.lfe = value ? 1 : 0; - this.Celt_Encoder.SetLFE(value ? 1 : 0); - } - - public boolean getPredictionDisabled() { - return this.silk_mode.reducedDependency != 0; - } - - public void setPredictionDisabled(boolean value) { - this.silk_mode.reducedDependency = value ? 1 : 0; - } - - public boolean getEnableAnalysis() { - return this.analysis.enabled; - } - - public void setEnableAnalysis(boolean value) { - this.analysis.enabled = value; - } - - void SetEnergyMask(int[] value) { - this.energy_masking = value; - this.Celt_Encoder.SetEnergyMask(value); - } - - CeltMode GetCeltMode() { - return this.Celt_Encoder.GetMode(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusError.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusError.java deleted file mode 100644 index e32167e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusError.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public class OpusError { - public static int OPUS_OK = 0; - public static int OPUS_BAD_ARG = -1; - public static int OPUS_BUFFER_TOO_SMALL = -2; - public static int OPUS_INTERNAL_ERROR = -3; - public static int OPUS_INVALID_PACKET = -4; - public static int OPUS_UNIMPLEMENTED = -5; - public static int OPUS_INVALID_STATE = -6; - public static int OPUS_ALLOC_FAIL = -7; -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusException.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusException.java deleted file mode 100644 index 95a1c05..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.CodecHelpers; - -public class OpusException -extends Exception { - private String _message; - private int _opus_error_code; - - public OpusException() { - this("", 0); - } - - public OpusException(String message) { - this(message, 1); - } - - public OpusException(String message, int opus_error_code) { - this._message = message + ": " + CodecHelpers.opus_strerror(opus_error_code); - this._opus_error_code = opus_error_code; - } - - @Override - public String getMessage() { - return this._message; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusFramesize.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusFramesize.java deleted file mode 100644 index 86e7eb9..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusFramesize.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public enum OpusFramesize { - OPUS_FRAMESIZE_UNKNOWN, - OPUS_FRAMESIZE_ARG, - OPUS_FRAMESIZE_2_5_MS, - OPUS_FRAMESIZE_5_MS, - OPUS_FRAMESIZE_10_MS, - OPUS_FRAMESIZE_20_MS, - OPUS_FRAMESIZE_40_MS, - OPUS_FRAMESIZE_60_MS, - OPUS_FRAMESIZE_VARIABLE; - -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusFramesizeHelpers.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusFramesizeHelpers.java deleted file mode 100644 index f7d121c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusFramesizeHelpers.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.OpusFramesize; - -class OpusFramesizeHelpers { - OpusFramesizeHelpers() { - } - - static int GetOrdinal(OpusFramesize size) { - switch (size) { - case OPUS_FRAMESIZE_ARG: { - return 1; - } - case OPUS_FRAMESIZE_2_5_MS: { - return 2; - } - case OPUS_FRAMESIZE_5_MS: { - return 3; - } - case OPUS_FRAMESIZE_10_MS: { - return 4; - } - case OPUS_FRAMESIZE_20_MS: { - return 5; - } - case OPUS_FRAMESIZE_40_MS: { - return 6; - } - case OPUS_FRAMESIZE_60_MS: { - return 7; - } - case OPUS_FRAMESIZE_VARIABLE: { - return 8; - } - } - return -1; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMSDecoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMSDecoder.java deleted file mode 100644 index bd2d04b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMSDecoder.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.ChannelLayout; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusBandwidth; -import de.maxhenkel.voicechat.concentus.OpusDecoder; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusException; -import de.maxhenkel.voicechat.concentus.OpusMultistream; -import de.maxhenkel.voicechat.concentus.OpusPacketInfo; - -public class OpusMSDecoder { - ChannelLayout layout = new ChannelLayout(); - OpusDecoder[] decoders = null; - - private OpusMSDecoder(int nb_streams, int nb_coupled_streams) { - this.decoders = new OpusDecoder[nb_streams]; - for (int c = 0; c < nb_streams; ++c) { - this.decoders[c] = new OpusDecoder(); - } - } - - int opus_multistream_decoder_init(int Fs, int channels, int streams, int coupled_streams, short[] mapping) { - int ret; - int i; - int decoder_ptr = 0; - if (channels > 255 || channels < 1 || coupled_streams > streams || streams < 1 || coupled_streams < 0 || streams > 255 - coupled_streams) { - throw new IllegalArgumentException("Invalid channel or coupled stream count"); - } - this.layout.nb_channels = channels; - this.layout.nb_streams = streams; - this.layout.nb_coupled_streams = coupled_streams; - for (i = 0; i < this.layout.nb_channels; ++i) { - this.layout.mapping[i] = mapping[i]; - } - if (OpusMultistream.validate_layout(this.layout) == 0) { - throw new IllegalArgumentException("Invalid surround channel layout"); - } - for (i = 0; i < this.layout.nb_coupled_streams; ++i) { - ret = this.decoders[decoder_ptr].opus_decoder_init(Fs, 2); - if (ret != OpusError.OPUS_OK) { - return ret; - } - ++decoder_ptr; - } - while (i < this.layout.nb_streams) { - ret = this.decoders[decoder_ptr].opus_decoder_init(Fs, 1); - if (ret != OpusError.OPUS_OK) { - return ret; - } - ++decoder_ptr; - ++i; - } - return OpusError.OPUS_OK; - } - - public static OpusMSDecoder create(int Fs, int channels, int streams, int coupled_streams, short[] mapping) throws OpusException { - if (channels > 255 || channels < 1 || coupled_streams > streams || streams < 1 || coupled_streams < 0 || streams > 255 - coupled_streams) { - throw new IllegalArgumentException("Invalid channel / stream configuration"); - } - OpusMSDecoder st = new OpusMSDecoder(streams, coupled_streams); - int ret = st.opus_multistream_decoder_init(Fs, channels, streams, coupled_streams, mapping); - if (ret != OpusError.OPUS_OK) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("Bad argument while creating MS decoder"); - } - throw new OpusException("Could not create MS decoder", ret); - } - return st; - } - - static int opus_multistream_packet_validate(byte[] data, int data_ptr, int len, int nb_streams, int Fs) { - BoxedValueByte toc = new BoxedValueByte(0); - short[] size = new short[48]; - int samples = 0; - BoxedValueInt packet_offset = new BoxedValueInt(0); - BoxedValueInt dummy = new BoxedValueInt(0); - for (int s = 0; s < nb_streams; ++s) { - if (len <= 0) { - return OpusError.OPUS_INVALID_PACKET; - } - int count = OpusPacketInfo.opus_packet_parse_impl(data, data_ptr, len, s != nb_streams - 1 ? 1 : 0, toc, null, 0, size, 0, dummy, packet_offset); - if (count < 0) { - return count; - } - int tmp_samples = OpusPacketInfo.getNumSamples(data, data_ptr, packet_offset.Val, Fs); - if (s != 0 && samples != tmp_samples) { - return OpusError.OPUS_INVALID_PACKET; - } - samples = tmp_samples; - data_ptr += packet_offset.Val; - len -= packet_offset.Val; - } - return samples; - } - - int opus_multistream_decode_native(byte[] data, int data_ptr, int len, short[] pcm, int pcm_ptr, int frame_size, int decode_fec, int soft_clip) { - boolean do_plc = false; - int Fs = this.getSampleRate(); - frame_size = Inlines.IMIN(frame_size, Fs / 25 * 3); - short[] buf = new short[2 * frame_size]; - int decoder_ptr = 0; - if (len == 0) { - do_plc = true; - } - if (len < 0) { - return OpusError.OPUS_BAD_ARG; - } - if (!do_plc && len < 2 * this.layout.nb_streams - 1) { - return OpusError.OPUS_INVALID_PACKET; - } - if (!do_plc) { - int ret = OpusMSDecoder.opus_multistream_packet_validate(data, data_ptr, len, this.layout.nb_streams, Fs); - if (ret < 0) { - return ret; - } - if (ret > frame_size) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - } - for (int s = 0; s < this.layout.nb_streams; ++s) { - int chan; - int prev; - OpusDecoder dec = this.decoders[decoder_ptr++]; - if (!do_plc && len <= 0) { - return OpusError.OPUS_INTERNAL_ERROR; - } - BoxedValueInt packet_offset = new BoxedValueInt(0); - int ret = dec.opus_decode_native(data, data_ptr, len, buf, 0, frame_size, decode_fec, s != this.layout.nb_streams - 1 ? 1 : 0, packet_offset, soft_clip); - data_ptr += packet_offset.Val; - len -= packet_offset.Val; - if (ret <= 0) { - return ret; - } - frame_size = ret; - if (s < this.layout.nb_coupled_streams) { - prev = -1; - while ((chan = OpusMultistream.get_left_channel(this.layout, s, prev)) != -1) { - OpusMSDecoder.opus_copy_channel_out_short(pcm, pcm_ptr, this.layout.nb_channels, chan, buf, 0, 2, frame_size); - prev = chan; - } - prev = -1; - while ((chan = OpusMultistream.get_right_channel(this.layout, s, prev)) != -1) { - OpusMSDecoder.opus_copy_channel_out_short(pcm, pcm_ptr, this.layout.nb_channels, chan, buf, 1, 2, frame_size); - prev = chan; - } - continue; - } - prev = -1; - while ((chan = OpusMultistream.get_mono_channel(this.layout, s, prev)) != -1) { - OpusMSDecoder.opus_copy_channel_out_short(pcm, pcm_ptr, this.layout.nb_channels, chan, buf, 0, 1, frame_size); - prev = chan; - } - } - for (int c = 0; c < this.layout.nb_channels; ++c) { - if (this.layout.mapping[c] != 255) continue; - OpusMSDecoder.opus_copy_channel_out_short(pcm, pcm_ptr, this.layout.nb_channels, c, null, 0, 0, frame_size); - } - return frame_size; - } - - static void opus_copy_channel_out_short(short[] dst, int dst_ptr, int dst_stride, int dst_channel, short[] src, int src_ptr, int src_stride, int frame_size) { - if (src != null) { - for (int i = 0; i < frame_size; ++i) { - dst[i * dst_stride + dst_channel + dst_ptr] = src[i * src_stride + src_ptr]; - } - } else { - for (int i = 0; i < frame_size; ++i) { - dst[i * dst_stride + dst_channel + dst_ptr] = 0; - } - } - } - - public int decodeMultistream(byte[] data, int data_offset, int len, short[] out_pcm, int out_pcm_offset, int frame_size, int decode_fec) { - return this.opus_multistream_decode_native(data, data_offset, len, out_pcm, out_pcm_offset, frame_size, decode_fec, 0); - } - - public OpusBandwidth getBandwidth() { - if (this.decoders == null || this.decoders.length == 0) { - throw new IllegalStateException("Decoder not initialized"); - } - return this.decoders[0].getBandwidth(); - } - - public int getSampleRate() { - if (this.decoders == null || this.decoders.length == 0) { - throw new IllegalStateException("Decoder not initialized"); - } - return this.decoders[0].getSampleRate(); - } - - public int getGain() { - if (this.decoders == null || this.decoders.length == 0) { - throw new IllegalStateException("Decoder not initialized"); - } - return this.decoders[0].getGain(); - } - - public void setGain(int value) { - for (int s = 0; s < this.layout.nb_streams; ++s) { - this.decoders[s].setGain(value); - } - } - - public int getLastPacketDuration() { - if (this.decoders == null || this.decoders.length == 0) { - return OpusError.OPUS_INVALID_STATE; - } - return this.decoders[0].getLastPacketDuration(); - } - - public int getFinalRange() { - int value = 0; - for (int s = 0; s < this.layout.nb_streams; ++s) { - value ^= this.decoders[s].getFinalRange(); - } - return value; - } - - public void ResetState() { - for (int s = 0; s < this.layout.nb_streams; ++s) { - this.decoders[s].resetState(); - } - } - - public OpusDecoder GetMultistreamDecoderState(int streamId) { - return this.decoders[streamId]; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMSEncoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMSEncoder.java deleted file mode 100644 index 1877d9e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMSEncoder.java +++ /dev/null @@ -1,735 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Bands; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltCommon; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.ChannelLayout; -import de.maxhenkel.voicechat.concentus.CodecHelpers; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.MDCT; -import de.maxhenkel.voicechat.concentus.OpusApplication; -import de.maxhenkel.voicechat.concentus.OpusBandwidth; -import de.maxhenkel.voicechat.concentus.OpusEncoder; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusException; -import de.maxhenkel.voicechat.concentus.OpusFramesize; -import de.maxhenkel.voicechat.concentus.OpusMode; -import de.maxhenkel.voicechat.concentus.OpusMultistream; -import de.maxhenkel.voicechat.concentus.OpusRepacketizer; -import de.maxhenkel.voicechat.concentus.OpusSignal; -import de.maxhenkel.voicechat.concentus.QuantizeBands; -import de.maxhenkel.voicechat.concentus.VorbisLayout; - -public class OpusMSEncoder { - final ChannelLayout layout = new ChannelLayout(); - int lfe_stream = 0; - OpusApplication application = OpusApplication.OPUS_APPLICATION_AUDIO; - OpusFramesize variable_duration = OpusFramesize.OPUS_FRAMESIZE_UNKNOWN; - int surround = 0; - int bitrate_bps = 0; - final float[] subframe_mem = new float[3]; - OpusEncoder[] encoders = null; - int[] window_mem = null; - int[] preemph_mem = null; - private static final int[] diff_table = new int[]{512, 300, 165, 87, 45, 23, 11, 6, 3, 0, 0, 0, 0, 0, 0, 0, 0}; - private final int MS_FRAME_TMP = 3832; - - private OpusMSEncoder(int nb_streams, int nb_coupled_streams) { - if (nb_streams < 1 || nb_coupled_streams > nb_streams || nb_coupled_streams < 0) { - throw new IllegalArgumentException("Invalid channel count in MS encoder"); - } - this.encoders = new OpusEncoder[nb_streams]; - for (int c = 0; c < nb_streams; ++c) { - this.encoders[c] = new OpusEncoder(); - } - int nb_channels = nb_coupled_streams * 2 + (nb_streams - nb_coupled_streams); - this.window_mem = new int[nb_channels * 120]; - this.preemph_mem = new int[nb_channels]; - } - - public void resetState() { - this.subframe_mem[2] = 0.0f; - this.subframe_mem[1] = 0.0f; - this.subframe_mem[0] = 0.0f; - if (this.surround != 0) { - Arrays.MemSet(this.preemph_mem, 0, this.layout.nb_channels); - Arrays.MemSet(this.window_mem, 0, this.layout.nb_channels * 120); - } - int encoder_ptr = 0; - for (int s = 0; s < this.layout.nb_streams; ++s) { - OpusEncoder enc = this.encoders[encoder_ptr++]; - enc.resetState(); - } - } - - static int validate_encoder_layout(ChannelLayout layout) { - for (int s = 0; s < layout.nb_streams; ++s) { - if (s < layout.nb_coupled_streams) { - if (OpusMultistream.get_left_channel(layout, s, -1) == -1) { - return 0; - } - if (OpusMultistream.get_right_channel(layout, s, -1) != -1) continue; - return 0; - } - if (OpusMultistream.get_mono_channel(layout, s, -1) != -1) continue; - return 0; - } - return 1; - } - - static void channel_pos(int channels, int[] pos) { - if (channels == 4) { - pos[0] = 1; - pos[1] = 3; - pos[2] = 1; - pos[3] = 3; - } else if (channels == 3 || channels == 5 || channels == 6) { - pos[0] = 1; - pos[1] = 2; - pos[2] = 3; - pos[3] = 1; - pos[4] = 3; - pos[5] = 0; - } else if (channels == 7) { - pos[0] = 1; - pos[1] = 2; - pos[2] = 3; - pos[3] = 1; - pos[4] = 3; - pos[5] = 2; - pos[6] = 0; - } else if (channels == 8) { - pos[0] = 1; - pos[1] = 2; - pos[2] = 3; - pos[3] = 1; - pos[4] = 3; - pos[5] = 1; - pos[6] = 3; - pos[7] = 0; - } - } - - static int logSum(int a, int b) { - int diff; - int max; - if (a > b) { - max = a; - diff = Inlines.SUB32(Inlines.EXTEND32(a), Inlines.EXTEND32(b)); - } else { - max = b; - diff = Inlines.SUB32(Inlines.EXTEND32(b), Inlines.EXTEND32(a)); - } - if (diff >= 8192) { - return max; - } - int low = Inlines.SHR32(diff, 9); - int frac = Inlines.SHL16(diff - Inlines.SHL16(low, 9), 6); - return max + diff_table[low] + Inlines.MULT16_16_Q15(frac, Inlines.SUB16(diff_table[low + 1], diff_table[low])); - } - - static void surround_analysis(CeltMode celt_mode, short[] pcm, int pcm_ptr, int[] bandLogE, int[] mem, int[] preemph_mem, int len, int overlap, int channels, int rate) { - int i; - int c; - int LM; - int[] pos = new int[]{0, 0, 0, 0, 0, 0, 0, 0}; - int[][] bandE = Arrays.InitTwoDimensionalArrayInt(1, 21); - int[][] maskLogE = Arrays.InitTwoDimensionalArrayInt(3, 21); - int upsample = CeltCommon.resampling_factor(rate); - int frame_size = len * upsample; - for (LM = 0; LM < celt_mode.maxLM && celt_mode.shortMdctSize << LM != frame_size; ++LM) { - } - int[] input = new int[frame_size + overlap]; - short[] x = new short[len]; - int[][] freq = Arrays.InitTwoDimensionalArrayInt(1, frame_size); - OpusMSEncoder.channel_pos(channels, pos); - for (c = 0; c < 3; ++c) { - for (i = 0; i < 21; ++i) { - maskLogE[c][i] = -28672; - } - } - for (c = 0; c < channels; ++c) { - System.arraycopy(mem, c * overlap, input, 0, overlap); - OpusMSEncoder.opus_copy_channel_in_short(x, 0, 1, pcm, pcm_ptr, channels, c, len); - BoxedValueInt boxed_preemph = new BoxedValueInt(preemph_mem[c]); - CeltCommon.celt_preemphasis(x, input, overlap, frame_size, 1, upsample, celt_mode.preemph, boxed_preemph, 0); - preemph_mem[c] = boxed_preemph.Val; - MDCT.clt_mdct_forward(celt_mode.mdct, input, 0, freq[0], 0, celt_mode.window, overlap, celt_mode.maxLM - LM, 1); - if (upsample != 1) { - int bound = len; - i = 0; - while (i < bound) { - int[] nArray = freq[0]; - int n = i++; - nArray[n] = nArray[n] * upsample; - } - while (i < frame_size) { - freq[0][i] = 0; - ++i; - } - } - Bands.compute_band_energies(celt_mode, freq, bandE, 21, 1, LM); - QuantizeBands.amp2Log2(celt_mode, 21, 21, bandE[0], bandLogE, 21 * c, 1); - for (i = 1; i < 21; ++i) { - bandLogE[21 * c + i] = Inlines.MAX16(bandLogE[21 * c + i], bandLogE[21 * c + i - 1] - 1024); - } - for (i = 19; i >= 0; --i) { - bandLogE[21 * c + i] = Inlines.MAX16(bandLogE[21 * c + i], bandLogE[21 * c + i + 1] - 2048); - } - if (pos[c] == 1) { - for (i = 0; i < 21; ++i) { - maskLogE[0][i] = OpusMSEncoder.logSum(maskLogE[0][i], bandLogE[21 * c + i]); - } - } else if (pos[c] == 3) { - for (i = 0; i < 21; ++i) { - maskLogE[2][i] = OpusMSEncoder.logSum(maskLogE[2][i], bandLogE[21 * c + i]); - } - } else if (pos[c] == 2) { - for (i = 0; i < 21; ++i) { - maskLogE[0][i] = OpusMSEncoder.logSum(maskLogE[0][i], bandLogE[21 * c + i] - 512); - maskLogE[2][i] = OpusMSEncoder.logSum(maskLogE[2][i], bandLogE[21 * c + i] - 512); - } - } - System.arraycopy(input, frame_size, mem, c * overlap, overlap); - } - for (i = 0; i < 21; ++i) { - maskLogE[1][i] = Inlines.MIN32(maskLogE[0][i], maskLogE[2][i]); - } - int channel_offset = Inlines.HALF16(Inlines.celt_log2(32768 / (channels - 1))); - for (c = 0; c < 3; ++c) { - i = 0; - while (i < 21) { - int[] nArray = maskLogE[c]; - int n = i++; - nArray[n] = nArray[n] + channel_offset; - } - } - for (c = 0; c < channels; ++c) { - if (pos[c] != 0) { - int[] mask = maskLogE[pos[c] - 1]; - for (i = 0; i < 21; ++i) { - bandLogE[21 * c + i] = bandLogE[21 * c + i] - mask[i]; - } - continue; - } - for (i = 0; i < 21; ++i) { - bandLogE[21 * c + i] = 0; - } - } - } - - int opus_multistream_encoder_init(int Fs, int channels, int streams, int coupled_streams, short[] mapping, OpusApplication application, int surround) { - int ret; - int i; - if (channels > 255 || channels < 1 || coupled_streams > streams || streams < 1 || coupled_streams < 0 || streams > 255 - coupled_streams) { - return OpusError.OPUS_BAD_ARG; - } - this.layout.nb_channels = channels; - this.layout.nb_streams = streams; - this.layout.nb_coupled_streams = coupled_streams; - this.subframe_mem[2] = 0.0f; - this.subframe_mem[1] = 0.0f; - this.subframe_mem[0] = 0.0f; - if (surround == 0) { - this.lfe_stream = -1; - } - this.bitrate_bps = -1000; - this.application = application; - this.variable_duration = OpusFramesize.OPUS_FRAMESIZE_ARG; - for (i = 0; i < this.layout.nb_channels; ++i) { - this.layout.mapping[i] = mapping[i]; - } - if (OpusMultistream.validate_layout(this.layout) == 0 || OpusMSEncoder.validate_encoder_layout(this.layout) == 0) { - return OpusError.OPUS_BAD_ARG; - } - int encoder_ptr = 0; - for (i = 0; i < this.layout.nb_coupled_streams; ++i) { - ret = this.encoders[encoder_ptr].opus_init_encoder(Fs, 2, application); - if (ret != OpusError.OPUS_OK) { - return ret; - } - if (i == this.lfe_stream) { - this.encoders[encoder_ptr].setIsLFE(true); - } - ++encoder_ptr; - } - while (i < this.layout.nb_streams) { - ret = this.encoders[encoder_ptr].opus_init_encoder(Fs, 1, application); - if (i == this.lfe_stream) { - this.encoders[encoder_ptr].setIsLFE(true); - } - if (ret != OpusError.OPUS_OK) { - return ret; - } - ++encoder_ptr; - ++i; - } - if (surround != 0) { - Arrays.MemSet(this.preemph_mem, 0, channels); - Arrays.MemSet(this.window_mem, 0, channels * 120); - } - this.surround = surround; - return OpusError.OPUS_OK; - } - - /* - * Enabled force condition propagation - * Lifted jumps to return sites - */ - int opus_multistream_surround_encoder_init(int Fs, int channels, int mapping_family, BoxedValueInt streams, BoxedValueInt coupled_streams, short[] mapping, OpusApplication application) { - streams.Val = 0; - coupled_streams.Val = 0; - if (channels > 255 || channels < 1) { - return OpusError.OPUS_BAD_ARG; - } - this.lfe_stream = -1; - if (mapping_family == 0) { - if (channels == 1) { - streams.Val = 1; - coupled_streams.Val = 0; - mapping[0] = 0; - return this.opus_multistream_encoder_init(Fs, channels, streams.Val, coupled_streams.Val, mapping, application, channels > 2 && mapping_family == 1 ? 1 : 0); - } else { - if (channels != 2) return OpusError.OPUS_UNIMPLEMENTED; - streams.Val = 1; - coupled_streams.Val = 1; - mapping[0] = 0; - mapping[1] = 1; - } - return this.opus_multistream_encoder_init(Fs, channels, streams.Val, coupled_streams.Val, mapping, application, channels > 2 && mapping_family == 1 ? 1 : 0); - } else if (mapping_family == 1 && channels <= 8 && channels >= 1) { - streams.Val = VorbisLayout.vorbis_mappings[channels - 1].nb_streams; - coupled_streams.Val = VorbisLayout.vorbis_mappings[channels - 1].nb_coupled_streams; - for (int i = 0; i < channels; ++i) { - mapping[i] = VorbisLayout.vorbis_mappings[channels - 1].mapping[i]; - } - if (channels < 6) return this.opus_multistream_encoder_init(Fs, channels, streams.Val, coupled_streams.Val, mapping, application, channels > 2 && mapping_family == 1 ? 1 : 0); - this.lfe_stream = streams.Val - 1; - return this.opus_multistream_encoder_init(Fs, channels, streams.Val, coupled_streams.Val, mapping, application, channels > 2 && mapping_family == 1 ? 1 : 0); - } else { - if (mapping_family != 255) return OpusError.OPUS_UNIMPLEMENTED; - streams.Val = channels; - coupled_streams.Val = 0; - for (int i = 0; i < channels; i = (int)((byte)(i + 1))) { - mapping[i] = (short)i; - } - } - return this.opus_multistream_encoder_init(Fs, channels, streams.Val, coupled_streams.Val, mapping, application, channels > 2 && mapping_family == 1 ? 1 : 0); - } - - public static OpusMSEncoder Create(int Fs, int channels, int streams, int coupled_streams, short[] mapping, OpusApplication application) throws OpusException { - if (channels > 255 || channels < 1 || coupled_streams > streams || streams < 1 || coupled_streams < 0 || streams > 255 - coupled_streams) { - throw new IllegalArgumentException("Invalid channel / stream configuration"); - } - OpusMSEncoder st = new OpusMSEncoder(streams, coupled_streams); - int ret = st.opus_multistream_encoder_init(Fs, channels, streams, coupled_streams, mapping, application, 0); - if (ret != OpusError.OPUS_OK) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("OPUS_BAD_ARG when creating MS encoder"); - } - throw new OpusException("Could not create MS encoder", ret); - } - return st; - } - - /* - * Enabled force condition propagation - * Lifted jumps to return sites - */ - static void GetStreamCount(int channels, int mapping_family, BoxedValueInt nb_streams, BoxedValueInt nb_coupled_streams) { - if (mapping_family == 0) { - if (channels == 1) { - nb_streams.Val = 1; - nb_coupled_streams.Val = 0; - return; - } else { - if (channels != 2) throw new IllegalArgumentException("More than 2 channels requires custom mappings"); - nb_streams.Val = 1; - nb_coupled_streams.Val = 1; - } - return; - } else if (mapping_family == 1 && channels <= 8 && channels >= 1) { - nb_streams.Val = VorbisLayout.vorbis_mappings[channels - 1].nb_streams; - nb_coupled_streams.Val = VorbisLayout.vorbis_mappings[channels - 1].nb_coupled_streams; - return; - } else { - if (mapping_family != 255) throw new IllegalArgumentException("Invalid mapping family"); - nb_streams.Val = channels; - nb_coupled_streams.Val = 0; - } - } - - public static OpusMSEncoder CreateSurround(int Fs, int channels, int mapping_family, BoxedValueInt streams, BoxedValueInt coupled_streams, short[] mapping, OpusApplication application) throws OpusException { - if (channels > 255 || channels < 1 || application == OpusApplication.OPUS_APPLICATION_UNIMPLEMENTED) { - throw new IllegalArgumentException("Invalid channel count or application"); - } - BoxedValueInt nb_streams = new BoxedValueInt(0); - BoxedValueInt nb_coupled_streams = new BoxedValueInt(0); - OpusMSEncoder.GetStreamCount(channels, mapping_family, nb_streams, nb_coupled_streams); - OpusMSEncoder st = new OpusMSEncoder(nb_streams.Val, nb_coupled_streams.Val); - int ret = st.opus_multistream_surround_encoder_init(Fs, channels, mapping_family, streams, coupled_streams, mapping, application); - if (ret != OpusError.OPUS_OK) { - if (ret == OpusError.OPUS_BAD_ARG) { - throw new IllegalArgumentException("Bad argument passed to CreateSurround"); - } - throw new OpusException("Could not create multistream encoder", ret); - } - return st; - } - - int surround_rate_allocation(int[] out_rates, int frame_size) { - int channel_rate; - int rate_sum = 0; - OpusEncoder ptr = this.encoders[0]; - int Fs = ptr.getSampleRate(); - int stream_offset = this.bitrate_bps > this.layout.nb_channels * 40000 ? 20000 : this.bitrate_bps / this.layout.nb_channels / 2; - stream_offset += 60 * (Fs / frame_size - 50); - int lfe_offset = 3500 + 60 * (Fs / frame_size - 50); - int coupled_ratio = 512; - int lfe_ratio = 32; - if (this.bitrate_bps == -1000) { - channel_rate = Fs + 60 * Fs / frame_size; - } else if (this.bitrate_bps == -1) { - channel_rate = 300000; - } else { - int nb_lfe = this.lfe_stream != -1 ? 1 : 0; - int nb_coupled = this.layout.nb_coupled_streams; - int nb_uncoupled = this.layout.nb_streams - nb_coupled - nb_lfe; - int total = (nb_uncoupled << 8) + coupled_ratio * nb_coupled + nb_lfe * lfe_ratio; - channel_rate = 256 * (this.bitrate_bps - lfe_offset * nb_lfe - stream_offset * (nb_coupled + nb_uncoupled)) / total; - } - for (int i = 0; i < this.layout.nb_streams; ++i) { - out_rates[i] = i < this.layout.nb_coupled_streams ? stream_offset + (channel_rate * coupled_ratio >> 8) : (i != this.lfe_stream ? stream_offset + channel_rate : lfe_offset + (channel_rate * lfe_ratio >> 8)); - out_rates[i] = Inlines.IMAX(out_rates[i], 500); - rate_sum += out_rates[i]; - } - return rate_sum; - } - - int opus_multistream_encode_native(short[] pcm, int pcm_ptr, int analysis_frame_size, byte[] data, int data_ptr, int max_data_bytes, int lsb_depth, int float_api) { - int s; - byte[] tmp_data = new byte[3832]; - OpusRepacketizer rp = new OpusRepacketizer(); - int[] bitrates = new int[256]; - int[] bandLogE = new int[42]; - int[] mem = null; - int[] preemph_mem = null; - if (this.surround != 0) { - preemph_mem = this.preemph_mem; - mem = this.window_mem; - } - int encoder_ptr = 0; - int Fs = this.encoders[encoder_ptr].getSampleRate(); - boolean vbr = this.encoders[encoder_ptr].getUseVBR(); - CeltMode celt_mode = this.encoders[encoder_ptr].GetCeltMode(); - int channels = this.layout.nb_streams + this.layout.nb_coupled_streams; - int delay_compensation = this.encoders[encoder_ptr].getLookahead(); - int frame_size = CodecHelpers.compute_frame_size(pcm, pcm_ptr, analysis_frame_size, this.variable_duration, channels, Fs, this.bitrate_bps, delay_compensation -= Fs / 400, this.subframe_mem, this.encoders[encoder_ptr].analysis.enabled); - if (400 * frame_size < Fs) { - return OpusError.OPUS_BAD_ARG; - } - if (400 * frame_size != Fs && 200 * frame_size != Fs && 100 * frame_size != Fs && 50 * frame_size != Fs && 25 * frame_size != Fs && 50 * frame_size != 3 * Fs) { - return OpusError.OPUS_BAD_ARG; - } - int smallest_packet = this.layout.nb_streams * 2 - 1; - if (max_data_bytes < smallest_packet) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - short[] buf = new short[2 * frame_size]; - int[] bandSMR = new int[21 * this.layout.nb_channels]; - if (this.surround != 0) { - OpusMSEncoder.surround_analysis(celt_mode, pcm, pcm_ptr, bandSMR, mem, preemph_mem, frame_size, 120, this.layout.nb_channels, Fs); - } - int rate_sum = this.surround_rate_allocation(bitrates, frame_size); - if (!vbr) { - if (this.bitrate_bps == -1000) { - max_data_bytes = Inlines.IMIN(max_data_bytes, 3 * rate_sum / (24 * Fs / frame_size)); - } else if (this.bitrate_bps != -1) { - max_data_bytes = Inlines.IMIN(max_data_bytes, Inlines.IMAX(smallest_packet, 3 * this.bitrate_bps / (24 * Fs / frame_size))); - } - } - for (s = 0; s < this.layout.nb_streams; ++s) { - OpusEncoder enc = this.encoders[encoder_ptr]; - ++encoder_ptr; - enc.setBitrate(bitrates[s]); - if (this.surround == 0) continue; - int equiv_rate = this.bitrate_bps; - if (frame_size * 50 < Fs) { - equiv_rate -= 60 * (Fs / frame_size - 50) * this.layout.nb_channels; - } - if (equiv_rate > 10000 * this.layout.nb_channels) { - enc.setBandwidth(OpusBandwidth.OPUS_BANDWIDTH_FULLBAND); - } else if (equiv_rate > 7000 * this.layout.nb_channels) { - enc.setBandwidth(OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND); - } else if (equiv_rate > 5000 * this.layout.nb_channels) { - enc.setBandwidth(OpusBandwidth.OPUS_BANDWIDTH_WIDEBAND); - } else { - enc.setBandwidth(OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND); - } - if (s >= this.layout.nb_coupled_streams) continue; - enc.setForceMode(OpusMode.MODE_CELT_ONLY); - enc.setForceChannels(2); - } - encoder_ptr = 0; - int tot_size = 0; - for (s = 0; s < this.layout.nb_streams; ++s) { - int len; - int c2; - int c1; - int i; - rp.Reset(); - OpusEncoder enc = this.encoders[encoder_ptr]; - if (s < this.layout.nb_coupled_streams) { - int left = OpusMultistream.get_left_channel(this.layout, s, -1); - int right = OpusMultistream.get_right_channel(this.layout, s, -1); - OpusMSEncoder.opus_copy_channel_in_short(buf, 0, 2, pcm, pcm_ptr, this.layout.nb_channels, left, frame_size); - OpusMSEncoder.opus_copy_channel_in_short(buf, 1, 2, pcm, pcm_ptr, this.layout.nb_channels, right, frame_size); - ++encoder_ptr; - if (this.surround != 0) { - for (i = 0; i < 21; ++i) { - bandLogE[i] = bandSMR[21 * left + i]; - bandLogE[21 + i] = bandSMR[21 * right + i]; - } - } - c1 = left; - c2 = right; - } else { - int chan = OpusMultistream.get_mono_channel(this.layout, s, -1); - OpusMSEncoder.opus_copy_channel_in_short(buf, 0, 1, pcm, pcm_ptr, this.layout.nb_channels, chan, frame_size); - ++encoder_ptr; - if (this.surround != 0) { - for (i = 0; i < 21; ++i) { - bandLogE[i] = bandSMR[21 * chan + i]; - } - } - c1 = chan; - c2 = -1; - } - if (this.surround != 0) { - enc.SetEnergyMask(bandLogE); - } - int curr_max = max_data_bytes - tot_size; - curr_max -= Inlines.IMAX(0, 2 * (this.layout.nb_streams - s - 1) - 1); - curr_max = Inlines.IMIN(curr_max, 3832); - if (s != this.layout.nb_streams - 1) { - curr_max -= curr_max > 253 ? 2 : 1; - } - if (!vbr && s == this.layout.nb_streams - 1) { - enc.setBitrate(curr_max * (8 * Fs / frame_size)); - } - if ((len = enc.opus_encode_native(buf, 0, frame_size, tmp_data, 0, curr_max, lsb_depth, pcm, pcm_ptr, analysis_frame_size, c1, c2, this.layout.nb_channels, float_api)) < 0) { - return len; - } - rp.addPacket(tmp_data, 0, len); - len = rp.opus_repacketizer_out_range_impl(0, rp.getNumFrames(), data, data_ptr, max_data_bytes - tot_size, s != this.layout.nb_streams - 1 ? 1 : 0, !vbr && s == this.layout.nb_streams - 1 ? 1 : 0); - data_ptr += len; - tot_size += len; - } - return tot_size; - } - - static void opus_copy_channel_in_short(short[] dst, int dst_ptr, int dst_stride, short[] src, int src_ptr, int src_stride, int src_channel, int frame_size) { - for (int i = 0; i < frame_size; ++i) { - dst[dst_ptr + i * dst_stride] = src[i * src_stride + src_channel + src_ptr]; - } - } - - public int encodeMultistream(short[] pcm, int pcm_offset, int frame_size, byte[] outputBuffer, int outputBuffer_offset, int max_data_bytes) { - return this.opus_multistream_encode_native(pcm, pcm_offset, frame_size, outputBuffer, outputBuffer_offset, max_data_bytes, 16, 0); - } - - public int getBitrate() { - int value = 0; - int encoder_ptr = 0; - for (int s = 0; s < this.layout.nb_streams; ++s) { - OpusEncoder enc = this.encoders[encoder_ptr++]; - value += enc.getBitrate(); - } - return value; - } - - public void setBitrate(int value) { - if (value < 0 && value != -1000 && value != -1) { - throw new IllegalArgumentException("Invalid bitrate"); - } - this.bitrate_bps = value; - } - - public OpusApplication getApplication() { - return this.encoders[0].getApplication(); - } - - public void setApplication(OpusApplication value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setApplication(value); - } - } - - public int getForceChannels() { - return this.encoders[0].getForceChannels(); - } - - public void setForceChannels(int value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setForceChannels(value); - } - } - - public OpusBandwidth getMaxBandwidth() { - return this.encoders[0].getMaxBandwidth(); - } - - public void setMaxBandwidth(OpusBandwidth value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setMaxBandwidth(value); - } - } - - public OpusBandwidth getBandwidth() { - return this.encoders[0].getBandwidth(); - } - - public void setBandwidth(OpusBandwidth value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setBandwidth(value); - } - } - - public boolean getUseDTX() { - return this.encoders[0].getUseDTX(); - } - - public void setUseDTX(boolean value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setUseDTX(value); - } - } - - public int getComplexity() { - return this.encoders[0].getComplexity(); - } - - public void setComplexity(int value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setComplexity(value); - } - } - - public OpusMode getForceMode() { - return this.encoders[0].getForceMode(); - } - - public void setForceMode(OpusMode value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setForceMode(value); - } - } - - public boolean getUseInbandFEC() { - return this.encoders[0].getUseInbandFEC(); - } - - public void setUseInbandFEC(boolean value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setUseInbandFEC(value); - } - } - - public int getPacketLossPercent() { - return this.encoders[0].getPacketLossPercent(); - } - - public void setPacketLossPercent(int value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setPacketLossPercent(value); - } - } - - public boolean getUseVBR() { - return this.encoders[0].getUseVBR(); - } - - public void setUseVBR(boolean value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setUseVBR(value); - } - } - - public boolean getUseConstrainedVBR() { - return this.encoders[0].getUseConstrainedVBR(); - } - - public void setUseConstrainedVBR(boolean value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setUseConstrainedVBR(value); - } - } - - public OpusSignal getSignalType() { - return this.encoders[0].getSignalType(); - } - - public void setSignalType(OpusSignal value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setSignalType(value); - } - } - - public int getLookahead() { - return this.encoders[0].getLookahead(); - } - - public int getSampleRate() { - return this.encoders[0].getSampleRate(); - } - - public int getFinalRange() { - int value = 0; - int encoder_ptr = 0; - for (int s = 0; s < this.layout.nb_streams; ++s) { - value ^= this.encoders[encoder_ptr++].getFinalRange(); - } - return value; - } - - public int getLSBDepth() { - return this.encoders[0].getLSBDepth(); - } - - public void setLSBDepth(int value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setLSBDepth(value); - } - } - - public boolean getPredictionDisabled() { - return this.encoders[0].getPredictionDisabled(); - } - - public void setPredictionDisabled(boolean value) { - for (int encoder_ptr = 0; encoder_ptr < this.layout.nb_streams; ++encoder_ptr) { - this.encoders[encoder_ptr].setPredictionDisabled(value); - } - } - - public OpusFramesize getExpertFrameDuration() { - return this.variable_duration; - } - - public void setExpertFrameDuration(OpusFramesize value) { - this.variable_duration = value; - } - - public OpusEncoder getMultistreamEncoderState(int streamId) { - if (streamId >= this.layout.nb_streams) { - throw new IllegalArgumentException("Requested stream doesn't exist"); - } - return this.encoders[streamId]; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMode.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMode.java deleted file mode 100644 index 0dfb454..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMode.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public enum OpusMode { - MODE_UNKNOWN, - MODE_AUTO, - MODE_SILK_ONLY, - MODE_HYBRID, - MODE_CELT_ONLY; - -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMultistream.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMultistream.java deleted file mode 100644 index 993665f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusMultistream.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.ChannelLayout; - -class OpusMultistream { - OpusMultistream() { - } - - static int validate_layout(ChannelLayout layout) { - int max_channel = layout.nb_streams + layout.nb_coupled_streams; - if (max_channel > 255) { - return 0; - } - for (int i = 0; i < layout.nb_channels; ++i) { - if (layout.mapping[i] < max_channel || layout.mapping[i] == 255) continue; - return 0; - } - return 1; - } - - static int get_left_channel(ChannelLayout layout, int stream_id, int prev) { - int i; - int n = i = prev < 0 ? 0 : prev + 1; - while (i < layout.nb_channels) { - if (layout.mapping[i] == stream_id * 2) { - return i; - } - ++i; - } - return -1; - } - - static int get_right_channel(ChannelLayout layout, int stream_id, int prev) { - int i; - int n = i = prev < 0 ? 0 : prev + 1; - while (i < layout.nb_channels) { - if (layout.mapping[i] == stream_id * 2 + 1) { - return i; - } - ++i; - } - return -1; - } - - static int get_mono_channel(ChannelLayout layout, int stream_id, int prev) { - int i; - int n = i = prev < 0 ? 0 : prev + 1; - while (i < layout.nb_channels) { - if (layout.mapping[i] == stream_id + layout.nb_coupled_streams) { - return i; - } - ++i; - } - return -1; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusPacketInfo.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusPacketInfo.java deleted file mode 100644 index 6870920..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusPacketInfo.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.BoxedValueShort; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusBandwidth; -import de.maxhenkel.voicechat.concentus.OpusBandwidthHelpers; -import de.maxhenkel.voicechat.concentus.OpusDecoder; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusException; -import de.maxhenkel.voicechat.concentus.OpusMode; -import java.util.ArrayList; -import java.util.List; - -public class OpusPacketInfo { - public byte TOCByte; - public List Frames; - public int PayloadOffset; - - private OpusPacketInfo(byte toc, List frames, int payloadOffset) { - this.TOCByte = toc; - this.Frames = frames; - this.PayloadOffset = payloadOffset; - } - - public static OpusPacketInfo parseOpusPacket(byte[] packet, int packet_offset, int len) throws OpusException { - BoxedValueInt packetOffset; - BoxedValueInt payload_offset; - short[] size; - BoxedValueByte out_toc = new BoxedValueByte(0); - int numFrames = OpusPacketInfo.getNumFrames(packet, packet_offset, len); - byte[][] frames = new byte[numFrames][]; - int error = OpusPacketInfo.opus_packet_parse_impl(packet, packet_offset, len, 0, out_toc, frames, 0, size = new short[numFrames], 0, payload_offset = new BoxedValueInt(0), packetOffset = new BoxedValueInt(0)); - if (error < 0) { - throw new OpusException("An error occurred while parsing the packet", error); - } - ArrayList copiedFrames = new ArrayList(); - for (int c = 0; c < frames.length; ++c) { - Byte[] convertedFrame = new Byte[frames[c].length]; - for (int d = 0; d < convertedFrame.length; ++d) { - convertedFrame[d] = frames[c][d]; - } - copiedFrames.add(convertedFrame); - } - return new OpusPacketInfo(out_toc.Val, copiedFrames, payload_offset.Val); - } - - public static int getNumSamplesPerFrame(byte[] packet, int packet_offset, int Fs) { - int audiosize; - if ((packet[packet_offset] & 0x80) != 0) { - audiosize = packet[packet_offset] >> 3 & 3; - audiosize = (Fs << audiosize) / 400; - } else { - audiosize = (packet[packet_offset] & 0x60) == 96 ? ((packet[packet_offset] & 8) != 0 ? Fs / 50 : Fs / 100) : ((audiosize = packet[packet_offset] >> 3 & 3) == 3 ? Fs * 60 / 1000 : (Fs << audiosize) / 100); - } - return audiosize; - } - - public static OpusBandwidth getBandwidth(byte[] packet, int packet_offset) { - OpusBandwidth bandwidth; - if ((packet[packet_offset] & 0x80) != 0) { - bandwidth = OpusBandwidthHelpers.GetBandwidth(OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND) + (packet[packet_offset] >> 5 & 3)); - if (bandwidth == OpusBandwidth.OPUS_BANDWIDTH_MEDIUMBAND) { - bandwidth = OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND; - } - } else { - bandwidth = (packet[packet_offset] & 0x60) == 96 ? ((packet[packet_offset] & 0x10) != 0 ? OpusBandwidth.OPUS_BANDWIDTH_FULLBAND : OpusBandwidth.OPUS_BANDWIDTH_SUPERWIDEBAND) : OpusBandwidthHelpers.GetBandwidth(OpusBandwidthHelpers.GetOrdinal(OpusBandwidth.OPUS_BANDWIDTH_NARROWBAND) + (packet[packet_offset] >> 5 & 3)); - } - return bandwidth; - } - - public static int getNumEncodedChannels(byte[] packet, int packet_offset) { - return (packet[packet_offset] & 4) != 0 ? 2 : 1; - } - - public static int getNumFrames(byte[] packet, int packet_offset, int len) { - if (len < 1) { - return OpusError.OPUS_BAD_ARG; - } - int count = packet[packet_offset] & 3; - if (count == 0) { - return 1; - } - if (count != 3) { - return 2; - } - if (len < 2) { - return OpusError.OPUS_INVALID_PACKET; - } - return packet[packet_offset + 1] & 0x3F; - } - - public static int getNumSamples(byte[] packet, int packet_offset, int len, int Fs) { - int count = OpusPacketInfo.getNumFrames(packet, packet_offset, len); - if (count < 0) { - return count; - } - int samples = count * OpusPacketInfo.getNumSamplesPerFrame(packet, packet_offset, Fs); - if (samples * 25 > Fs * 3) { - return OpusError.OPUS_INVALID_PACKET; - } - return samples; - } - - public static int getNumSamples(OpusDecoder dec, byte[] packet, int packet_offset, int len) { - return OpusPacketInfo.getNumSamples(packet, packet_offset, len, dec.Fs); - } - - public static OpusMode getEncoderMode(byte[] packet, int packet_offset) { - OpusMode mode = (packet[packet_offset] & 0x80) != 0 ? OpusMode.MODE_CELT_ONLY : ((packet[packet_offset] & 0x60) == 96 ? OpusMode.MODE_HYBRID : OpusMode.MODE_SILK_ONLY); - return mode; - } - - static int encode_size(int size, byte[] data, int data_ptr) { - if (size < 252) { - data[data_ptr] = (byte)(size & 0xFF); - return 1; - } - int dp1 = 252 + (size & 3); - data[data_ptr] = (byte)(dp1 & 0xFF); - data[data_ptr + 1] = (byte)(size - dp1 >> 2); - return 2; - } - - static int parse_size(byte[] data, int data_ptr, int len, BoxedValueShort size) { - if (len < 1) { - size.Val = (short)-1; - return -1; - } - if (Inlines.SignedByteToUnsignedInt(data[data_ptr]) < 252) { - size.Val = (short)Inlines.SignedByteToUnsignedInt(data[data_ptr]); - return 1; - } - if (len < 2) { - size.Val = (short)-1; - return -1; - } - size.Val = (short)(4 * Inlines.SignedByteToUnsignedInt(data[data_ptr + 1]) + Inlines.SignedByteToUnsignedInt(data[data_ptr])); - return 2; - } - - static int opus_packet_parse_impl(byte[] data, int data_ptr, int len, int self_delimited, BoxedValueByte out_toc, byte[][] frames, int frames_ptr, short[] sizes, int sizes_ptr, BoxedValueInt payload_offset, BoxedValueInt packet_offset) { - int i; - int bytes; - BoxedValueShort boxed_size; - int count; - int pad = 0; - int data0 = data_ptr; - out_toc.Val = 0; - payload_offset.Val = 0; - packet_offset.Val = 0; - if (sizes == null || len < 0) { - return OpusError.OPUS_BAD_ARG; - } - if (len == 0) { - return OpusError.OPUS_INVALID_PACKET; - } - int framesize = OpusPacketInfo.getNumSamplesPerFrame(data, data_ptr, 48000); - boolean cbr = false; - byte toc = data[data_ptr++]; - int last_size = --len; - switch (toc & 3) { - case 0: { - count = 1; - break; - } - case 1: { - count = 2; - cbr = true; - if (self_delimited != 0) break; - if ((len & 1) != 0) { - return OpusError.OPUS_INVALID_PACKET; - } - last_size = len / 2; - sizes[sizes_ptr] = (short)last_size; - break; - } - case 2: { - count = 2; - boxed_size = new BoxedValueShort(sizes[sizes_ptr]); - bytes = OpusPacketInfo.parse_size(data, data_ptr, len, boxed_size); - sizes[sizes_ptr] = boxed_size.Val; - if (sizes[sizes_ptr] < 0 || sizes[sizes_ptr] > (len -= bytes)) { - return OpusError.OPUS_INVALID_PACKET; - } - data_ptr += bytes; - last_size = len - sizes[sizes_ptr]; - break; - } - default: { - int ch; - if (len < 1) { - return OpusError.OPUS_INVALID_PACKET; - } - if ((count = (ch = Inlines.SignedByteToUnsignedInt(data[data_ptr++])) & 0x3F) <= 0 || framesize * count > 5760) { - return OpusError.OPUS_INVALID_PACKET; - } - --len; - if ((ch & 0x40) != 0) { - int p; - do { - if (len <= 0) { - return OpusError.OPUS_INVALID_PACKET; - } - p = Inlines.SignedByteToUnsignedInt(data[data_ptr++]); - --len; - int tmp = p == 255 ? 254 : p; - len -= tmp; - pad += tmp; - } while (p == 255); - } - if (len < 0) { - return OpusError.OPUS_INVALID_PACKET; - } - boolean bl = cbr = (ch & 0x80) == 0; - if (!cbr) { - last_size = len; - for (i = 0; i < count - 1; ++i) { - boxed_size = new BoxedValueShort(sizes[sizes_ptr + i]); - bytes = OpusPacketInfo.parse_size(data, data_ptr, len, boxed_size); - sizes[sizes_ptr + i] = boxed_size.Val; - if (sizes[sizes_ptr + i] < 0 || sizes[sizes_ptr + i] > (len -= bytes)) { - return OpusError.OPUS_INVALID_PACKET; - } - data_ptr += bytes; - last_size -= bytes + sizes[sizes_ptr + i]; - } - if (last_size >= 0) break; - return OpusError.OPUS_INVALID_PACKET; - } - if (self_delimited != 0) break; - last_size = len / count; - if (last_size * count != len) { - return OpusError.OPUS_INVALID_PACKET; - } - for (i = 0; i < count - 1; ++i) { - sizes[sizes_ptr + i] = (short)last_size; - } - } - } - if (self_delimited != 0) { - boxed_size = new BoxedValueShort(sizes[sizes_ptr + count - 1]); - bytes = OpusPacketInfo.parse_size(data, data_ptr, len, boxed_size); - sizes[sizes_ptr + count - 1] = boxed_size.Val; - if (sizes[sizes_ptr + count - 1] < 0 || sizes[sizes_ptr + count - 1] > (len -= bytes)) { - return OpusError.OPUS_INVALID_PACKET; - } - data_ptr += bytes; - if (cbr) { - if (sizes[sizes_ptr + count - 1] * count > len) { - return OpusError.OPUS_INVALID_PACKET; - } - for (i = 0; i < count - 1; ++i) { - sizes[sizes_ptr + i] = sizes[sizes_ptr + count - 1]; - } - } else if (bytes + sizes[sizes_ptr + count - 1] > last_size) { - return OpusError.OPUS_INVALID_PACKET; - } - } else { - if (last_size > 1275) { - return OpusError.OPUS_INVALID_PACKET; - } - sizes[sizes_ptr + count - 1] = (short)last_size; - } - payload_offset.Val = data_ptr - data0; - for (i = 0; i < count; ++i) { - if (frames != null) { - frames[frames_ptr + i] = new byte[data.length - data_ptr]; - System.arraycopy(data, data_ptr, frames[frames_ptr + i], 0, data.length - data_ptr); - } - data_ptr += sizes[sizes_ptr + i]; - } - packet_offset.Val = pad + (data_ptr - data0); - out_toc.Val = toc; - return count; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusRepacketizer.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusRepacketizer.java deleted file mode 100644 index 90b91b8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusRepacketizer.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.OpusError; -import de.maxhenkel.voicechat.concentus.OpusPacketInfo; - -public class OpusRepacketizer { - byte toc = 0; - int nb_frames = 0; - final byte[][] frames = new byte[48][]; - final short[] len = new short[48]; - int framesize = 0; - - public void Reset() { - this.nb_frames = 0; - } - - public OpusRepacketizer() { - this.Reset(); - } - - int opus_repacketizer_cat_impl(byte[] data, int data_ptr, int len, int self_delimited) { - BoxedValueByte dummy_toc = new BoxedValueByte(0); - BoxedValueInt dummy_offset = new BoxedValueInt(0); - if (len < 1) { - return OpusError.OPUS_INVALID_PACKET; - } - if (this.nb_frames == 0) { - this.toc = data[data_ptr]; - this.framesize = OpusPacketInfo.getNumSamplesPerFrame(data, data_ptr, 8000); - } else if ((this.toc & 0xFC) != (data[data_ptr] & 0xFC)) { - return OpusError.OPUS_INVALID_PACKET; - } - int curr_nb_frames = OpusPacketInfo.getNumFrames(data, data_ptr, len); - if (curr_nb_frames < 1) { - return OpusError.OPUS_INVALID_PACKET; - } - if ((curr_nb_frames + this.nb_frames) * this.framesize > 960) { - return OpusError.OPUS_INVALID_PACKET; - } - int ret = OpusPacketInfo.opus_packet_parse_impl(data, data_ptr, len, self_delimited, dummy_toc, this.frames, this.nb_frames, this.len, this.nb_frames, dummy_offset, dummy_offset); - if (ret < 1) { - return ret; - } - this.nb_frames += curr_nb_frames; - return OpusError.OPUS_OK; - } - - public int addPacket(byte[] data, int data_offset, int len) { - return this.opus_repacketizer_cat_impl(data, data_offset, len, 0); - } - - public int getNumFrames() { - return this.nb_frames; - } - - int opus_repacketizer_out_range_impl(int begin, int end, byte[] data, int data_ptr, int maxlen, int self_delimited, int pad) { - int i; - if (begin < 0 || begin >= end || end > this.nb_frames) { - return OpusError.OPUS_BAD_ARG; - } - int count = end - begin; - int tot_size = self_delimited != 0 ? 1 + (this.len[count - 1] >= 252 ? 1 : 0) : 0; - int ptr = data_ptr; - if (count == 1) { - if ((tot_size += this.len[0] + 1) > maxlen) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - data[ptr++] = (byte)(this.toc & 0xFC); - } else if (count == 2) { - if (this.len[1] == this.len[0]) { - if ((tot_size += 2 * this.len[0] + 1) > maxlen) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - data[ptr++] = (byte)(this.toc & 0xFC | 1); - } else { - if ((tot_size += this.len[0] + this.len[1] + 2 + (this.len[0] >= 252 ? 1 : 0)) > maxlen) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - data[ptr++] = (byte)(this.toc & 0xFC | 2); - ptr += OpusPacketInfo.encode_size(this.len[0], data, ptr); - } - } - if (count > 2 || pad != 0 && tot_size < maxlen) { - int pad_amount = 0; - ptr = data_ptr; - tot_size = self_delimited != 0 ? 1 + (this.len[count - 1] >= 252 ? 1 : 0) : 0; - boolean vbr = false; - for (i = 1; i < count; ++i) { - if (this.len[i] == this.len[0]) continue; - vbr = true; - break; - } - if (vbr) { - tot_size += 2; - for (i = 0; i < count - 1; ++i) { - tot_size += 1 + (this.len[i] >= 252 ? 1 : 0) + this.len[i]; - } - if ((tot_size += this.len[count - 1]) > maxlen) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - data[ptr++] = (byte)(this.toc & 0xFC | 3); - data[ptr++] = (byte)(count | 0x80); - } else { - if ((tot_size += count * this.len[0] + 2) > maxlen) { - return OpusError.OPUS_BUFFER_TOO_SMALL; - } - data[ptr++] = (byte)(this.toc & 0xFC | 3); - data[ptr++] = (byte)count; - } - int n = pad_amount = pad != 0 ? maxlen - tot_size : 0; - if (pad_amount != 0) { - data[data_ptr + 1] = (byte)(data[data_ptr + 1] | 0x40); - int nb_255s = (pad_amount - 1) / 255; - for (i = 0; i < nb_255s; ++i) { - data[ptr++] = -1; - } - data[ptr++] = (byte)(pad_amount - 255 * nb_255s - 1); - tot_size += pad_amount; - } - if (vbr) { - for (i = 0; i < count - 1; ++i) { - ptr += OpusPacketInfo.encode_size(this.len[i], data, ptr); - } - } - } - if (self_delimited != 0) { - int sdlen = OpusPacketInfo.encode_size(this.len[count - 1], data, ptr); - ptr += sdlen; - } - for (i = begin; i < count + begin; ++i) { - if (data == this.frames[i]) { - Arrays.MemMove(data, 0, ptr, (int)this.len[i]); - } else { - System.arraycopy(this.frames[i], 0, data, ptr, this.len[i]); - } - ptr += this.len[i]; - } - if (pad != 0) { - Arrays.MemSetWithOffset(data, (byte)0, ptr, data_ptr + maxlen - ptr); - } - return tot_size; - } - - public int createPacket(int begin, int end, byte[] data, int data_offset, int maxlen) { - return this.opus_repacketizer_out_range_impl(begin, end, data, data_offset, maxlen, 0, 0); - } - - public int createPacket(byte[] data, int data_offset, int maxlen) { - return this.opus_repacketizer_out_range_impl(0, this.nb_frames, data, data_offset, maxlen, 0, 0); - } - - public static int padPacket(byte[] data, int data_offset, int len, int new_len) { - OpusRepacketizer rp = new OpusRepacketizer(); - if (len < 1) { - return OpusError.OPUS_BAD_ARG; - } - if (len == new_len) { - return OpusError.OPUS_OK; - } - if (len > new_len) { - return OpusError.OPUS_BAD_ARG; - } - rp.Reset(); - Arrays.MemMove(data, data_offset, data_offset + new_len - len, len); - rp.addPacket(data, data_offset + new_len - len, len); - int ret = rp.opus_repacketizer_out_range_impl(0, rp.nb_frames, data, data_offset, new_len, 0, 1); - if (ret > 0) { - return OpusError.OPUS_OK; - } - return ret; - } - - public static int unpadPacket(byte[] data, int data_offset, int len) { - if (len < 1) { - return OpusError.OPUS_BAD_ARG; - } - OpusRepacketizer rp = new OpusRepacketizer(); - rp.Reset(); - int ret = rp.addPacket(data, data_offset, len); - if (ret < 0) { - return ret; - } - ret = rp.opus_repacketizer_out_range_impl(0, rp.nb_frames, data, data_offset, len, 0, 0); - Inlines.OpusAssert(ret > 0 && ret <= len); - return ret; - } - - public static int padMultistreamPacket(byte[] data, int data_offset, int len, int new_len, int nb_streams) { - BoxedValueByte dummy_toc = new BoxedValueByte(0); - short[] size = new short[48]; - BoxedValueInt packet_offset = new BoxedValueInt(0); - BoxedValueInt dummy_offset = new BoxedValueInt(0); - if (len < 1) { - return OpusError.OPUS_BAD_ARG; - } - if (len == new_len) { - return OpusError.OPUS_OK; - } - if (len > new_len) { - return OpusError.OPUS_BAD_ARG; - } - int amount = new_len - len; - for (int s = 0; s < nb_streams - 1; ++s) { - if (len <= 0) { - return OpusError.OPUS_INVALID_PACKET; - } - int count = OpusPacketInfo.opus_packet_parse_impl(data, data_offset, len, 1, dummy_toc, null, 0, size, 0, dummy_offset, packet_offset); - if (count < 0) { - return count; - } - data_offset += packet_offset.Val; - len -= packet_offset.Val; - } - return OpusRepacketizer.padPacket(data, data_offset, len, len + amount); - } - - public static int unpadMultistreamPacket(byte[] data, int data_offset, int len, int nb_streams) { - BoxedValueByte dummy_toc = new BoxedValueByte(0); - short[] size = new short[48]; - BoxedValueInt packet_offset = new BoxedValueInt(0); - BoxedValueInt dummy_offset = new BoxedValueInt(0); - OpusRepacketizer rp = new OpusRepacketizer(); - if (len < 1) { - return OpusError.OPUS_BAD_ARG; - } - int dst = data_offset; - int dst_len = 0; - for (int s = 0; s < nb_streams; ++s) { - int self_delimited = (s != nb_streams ? 1 : 0) - 1; - if (len <= 0) { - return OpusError.OPUS_INVALID_PACKET; - } - rp.Reset(); - int ret = OpusPacketInfo.opus_packet_parse_impl(data, data_offset, len, self_delimited, dummy_toc, null, 0, size, 0, dummy_offset, packet_offset); - if (ret < 0) { - return ret; - } - ret = rp.opus_repacketizer_cat_impl(data, data_offset, packet_offset.Val, self_delimited); - if (ret < 0) { - return ret; - } - ret = rp.opus_repacketizer_out_range_impl(0, rp.nb_frames, data, dst, len, self_delimited, 0); - if (ret < 0) { - return ret; - } - dst_len += ret; - dst += ret; - data_offset += packet_offset.Val; - len -= packet_offset.Val; - } - return dst_len; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusSignal.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusSignal.java deleted file mode 100644 index 2c37415..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusSignal.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -public enum OpusSignal { - OPUS_SIGNAL_UNKNOWN, - OPUS_SIGNAL_AUTO, - OPUS_SIGNAL_VOICE, - OPUS_SIGNAL_MUSIC; - -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusTables.java b/source/decompiled/de/maxhenkel/voicechat/concentus/OpusTables.java deleted file mode 100644 index a4cd60a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/OpusTables.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.MLPState; - -class OpusTables { - static final float[] dct_table = new float[]{0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.351851f, 0.33833f, 0.311806f, 0.2733f, 0.224292f, 0.166664f, 0.102631f, 0.034654f, -0.034654f, -0.102631f, -0.166664f, -0.224292f, -0.2733f, -0.311806f, -0.33833f, -0.351851f, 0.34676f, 0.293969f, 0.196424f, 0.068975f, -0.068975f, -0.196424f, -0.293969f, -0.34676f, -0.34676f, -0.293969f, -0.196424f, -0.068975f, 0.068975f, 0.196424f, 0.293969f, 0.34676f, 0.33833f, 0.224292f, 0.034654f, -0.166664f, -0.311806f, -0.351851f, -0.2733f, -0.102631f, 0.102631f, 0.2733f, 0.351851f, 0.311806f, 0.166664f, -0.034654f, -0.224292f, -0.33833f, 0.326641f, 0.135299f, -0.135299f, -0.326641f, -0.326641f, -0.135299f, 0.135299f, 0.326641f, 0.326641f, 0.135299f, -0.135299f, -0.326641f, -0.326641f, -0.135299f, 0.135299f, 0.326641f, 0.311806f, 0.034654f, -0.2733f, -0.33833f, -0.102631f, 0.224292f, 0.351851f, 0.166664f, -0.166664f, -0.351851f, -0.224292f, 0.102631f, 0.33833f, 0.2733f, -0.034654f, -0.311806f, 0.293969f, -0.068975f, -0.34676f, -0.196424f, 0.196424f, 0.34676f, 0.068975f, -0.293969f, -0.293969f, 0.068975f, 0.34676f, 0.196424f, -0.196424f, -0.34676f, -0.068975f, 0.293969f, 0.2733f, -0.166664f, -0.33833f, 0.034654f, 0.351851f, 0.102631f, -0.311806f, -0.224292f, 0.224292f, 0.311806f, -0.102631f, -0.351851f, -0.034654f, 0.33833f, 0.166664f, -0.2733f}; - static final float[] analysis_window = new float[]{4.3E-5f, 1.71E-4f, 3.85E-4f, 6.85E-4f, 0.001071f, 0.001541f, 0.002098f, 0.002739f, 0.003466f, 0.004278f, 0.005174f, 0.006156f, 0.007222f, 0.008373f, 0.009607f, 0.010926f, 0.012329f, 0.013815f, 0.015385f, 0.017037f, 0.018772f, 0.02059f, 0.02249f, 0.024472f, 0.026535f, 0.028679f, 0.030904f, 0.03321f, 0.035595f, 0.03806f, 0.040604f, 0.043227f, 0.045928f, 0.048707f, 0.051564f, 0.054497f, 0.057506f, 0.060591f, 0.063752f, 0.066987f, 0.070297f, 0.07368f, 0.077136f, 0.080665f, 0.084265f, 0.087937f, 0.091679f, 0.095492f, 0.099373f, 0.103323f, 0.107342f, 0.111427f, 0.115579f, 0.119797f, 0.12408f, 0.128428f, 0.132839f, 0.137313f, 0.141849f, 0.146447f, 0.151105f, 0.155823f, 0.1606f, 0.165435f, 0.170327f, 0.175276f, 0.18028f, 0.18534f, 0.190453f, 0.195619f, 0.200838f, 0.206107f, 0.211427f, 0.216797f, 0.222215f, 0.22768f, 0.233193f, 0.238751f, 0.244353f, 0.25f, 0.255689f, 0.261421f, 0.267193f, 0.273005f, 0.278856f, 0.284744f, 0.29067f, 0.296632f, 0.302628f, 0.308658f, 0.314721f, 0.320816f, 0.326941f, 0.333097f, 0.33928f, 0.345492f, 0.351729f, 0.357992f, 0.36428f, 0.37059f, 0.376923f, 0.383277f, 0.389651f, 0.396044f, 0.402455f, 0.408882f, 0.415325f, 0.421783f, 0.428254f, 0.434737f, 0.441231f, 0.447736f, 0.454249f, 0.46077f, 0.467298f, 0.473832f, 0.48037f, 0.486912f, 0.493455f, 0.5f, 0.506545f, 0.513088f, 0.51963f, 0.526168f, 0.532702f, 0.53923f, 0.545751f, 0.552264f, 0.558769f, 0.565263f, 0.571746f, 0.578217f, 0.584675f, 0.591118f, 0.597545f, 0.603956f, 0.610349f, 0.616723f, 0.623077f, 0.62941f, 0.63572f, 0.642008f, 0.648271f, 0.654508f, 0.66072f, 0.666903f, 0.673059f, 0.679184f, 0.685279f, 0.691342f, 0.697372f, 0.703368f, 0.70933f, 0.715256f, 0.721144f, 0.726995f, 0.732807f, 0.738579f, 0.744311f, 0.75f, 0.755647f, 0.761249f, 0.766807f, 0.77232f, 0.777785f, 0.783203f, 0.788573f, 0.793893f, 0.799162f, 0.804381f, 0.809547f, 0.81466f, 0.81972f, 0.824724f, 0.829673f, 0.834565f, 0.8394f, 0.844177f, 0.848895f, 0.853553f, 0.858151f, 0.862687f, 0.867161f, 0.871572f, 0.87592f, 0.880203f, 0.884421f, 0.888573f, 0.892658f, 0.896677f, 0.900627f, 0.904508f, 0.908321f, 0.912063f, 0.915735f, 0.919335f, 0.922864f, 0.92632f, 0.929703f, 0.933013f, 0.936248f, 0.939409f, 0.942494f, 0.945503f, 0.948436f, 0.951293f, 0.954072f, 0.956773f, 0.959396f, 0.96194f, 0.964405f, 0.96679f, 0.969096f, 0.971321f, 0.973465f, 0.975528f, 0.97751f, 0.97941f, 0.981228f, 0.982963f, 0.984615f, 0.986185f, 0.987671f, 0.989074f, 0.990393f, 0.991627f, 0.992778f, 0.993844f, 0.994826f, 0.995722f, 0.996534f, 0.997261f, 0.997902f, 0.998459f, 0.998929f, 0.999315f, 0.999615f, 0.999829f, 0.999957f, 1.0f}; - static final int[] tbands = new int[]{2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 68, 80, 96, 120}; - static final int[] extra_bands = new int[]{1, 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 68, 80, 96, 120, 160, 200}; - static final float[] weights = new float[]{-0.0941125f, -0.302976f, -0.603555f, -0.19393f, -0.185983f, -0.601617f, -0.0465317f, -0.114563f, -0.103599f, -0.618938f, -0.317859f, -0.169949f, -0.0702885f, 0.148065f, 0.409524f, 0.548432f, 0.367649f, -0.494393f, 0.764306f, -1.83957f, 0.170849f, 12.786f, -1.08848f, -1.27284f, -16.2606f, 24.1773f, -5.57454f, -0.17276f, -0.163388f, -0.224421f, -0.0948944f, -0.0728695f, -0.26557f, -0.100283f, -0.0515459f, -0.146142f, -0.120674f, -0.180655f, 0.12857f, 0.442138f, -0.493735f, 0.167767f, 0.206699f, -0.197567f, 0.417999f, 1.50364f, -0.773341f, -10.0401f, 0.401872f, 2.97966f, 15.2165f, -1.88905f, -1.19254f, 0.0285397f, -0.00405139f, 0.0707565f, 0.00825699f, -0.0927269f, -0.010393f, -0.00428882f, -0.00489743f, -0.0709731f, -0.00255992f, 0.0395619f, 0.226424f, 0.0325231f, 0.162175f, -0.100118f, 0.485789f, 0.12697f, 0.285937f, 0.0155637f, 0.10546f, 3.05558f, 1.15059f, -1.00904f, -1.83088f, 3.31766f, -3.42516f, -0.119135f, -0.0405654f, 0.00690068f, 0.0179877f, -0.0382487f, 0.00597941f, -0.0183611f, 0.00190395f, -0.144322f, -0.0435671f, 9.90594E-4f, 0.221087f, 0.142405f, 0.484066f, 0.404395f, 0.511955f, -0.237255f, 0.241742f, 0.35045f, -0.699428f, 10.3993f, 2.6507f, -2.43459f, -4.18838f, 1.05928f, 1.71067f, 0.00667811f, -0.0721335f, -0.0397346f, 0.0362704f, -0.11496f, -0.0235776f, 0.0082161f, -0.0141741f, -0.0329699f, -0.0354253f, 0.00277404f, -0.290654f, -1.14767f, -0.319157f, -0.686544f, 0.36897f, 0.478899f, 0.182579f, -0.411069f, 0.881104f, -4.60683f, 1.4697f, 0.335845f, -1.81905f, -30.1699f, 5.55225f, 0.0019508f, -0.123576f, -0.0727332f, -0.0641597f, -0.0534458f, -0.108166f, -0.0937368f, -0.0697883f, -0.0275475f, -0.192309f, -0.110074f, 0.285375f, -0.405597f, 0.0926724f, -0.287881f, -0.851193f, -0.099493f, -0.233764f, -1.2852f, 1.13611f, 3.12168f, -0.0699f, -1.86216f, 2.65292f, -7.31036f, 2.44776f, -0.00111802f, -0.0632786f, -0.0376296f, -0.149851f, 0.142963f, 0.184368f, 0.123433f, 0.0756158f, 0.117312f, 0.0933395f, 0.0692163f, 0.0842592f, 0.0704683f, 0.0589963f, 0.0942205f, -0.448862f, 0.0262677f, 0.270352f, -0.262317f, 0.172586f, 2.00227f, -0.159216f, 0.038422f, 10.2073f, 4.15536f, -2.3407f, -0.0550265f, 0.00964792f, -0.141336f, 0.0274501f, 0.0343921f, -0.0487428f, 0.0950172f, -0.00775017f, -0.0372492f, -0.00548121f, -0.0663695f, 0.0960506f, -0.200008f, -0.0412827f, 0.58728f, 0.0515787f, 0.337254f, 0.855024f, 0.668371f, -0.114904f, -3.62962f, -0.467477f, -0.215472f, 2.61537f, 0.406117f, -1.36373f, 0.0425394f, 0.12208f, 0.0934502f, 0.123055f, 0.0340935f, -0.142466f, 0.035037f, -0.0490666f, 0.0733208f, 0.0576672f, 0.123984f, -0.0517194f, -0.253018f, 0.590565f, 0.145849f, 0.315185f, 0.221534f, -0.149081f, 0.216161f, -0.349575f, 24.5664f, -0.994196f, 0.614289f, -18.7905f, -2.83277f, -0.716801f, -0.347201f, 0.479515f, -0.246027f, 0.0758683f, 0.137293f, -0.17781f, 0.118751f, -0.00108329f, -0.237334f, 0.355732f, -0.12991f, -0.0547627f, -0.318576f, -0.325524f, 0.180494f, -0.0625604f, 0.141219f, 0.344064f, 0.37658f, -0.591772f, 5.8427f, -0.38075f, 0.221894f, -1.41934f, -1879430.0f, 1.34114f, 0.0283355f, -0.0447856f, -0.0211466f, -0.0256927f, 0.0139618f, 0.0207934f, -0.0107666f, 0.0110969f, 0.0586069f, -0.0253545f, -0.0328433f, 0.11872f, -0.216943f, 0.145748f, 0.119808f, -0.0915211f, -0.120647f, -0.0787719f, -0.143644f, -0.595116f, -1.152f, -1.25335f, -1.17092f, 4.34023f, -975268.0f, -1.37033f, -0.0401123f, 0.210602f, -0.136656f, 0.135962f, -0.0523293f, 0.0444604f, 0.0143928f, 0.00412666f, -0.0193003f, 0.218452f, -0.110204f, -2.02563f, 0.918238f, -2.45362f, 1.19542f, -0.061362f, -1.92243f, 0.308111f, 0.49764f, 0.912356f, 0.209272f, -2.34525f, 2.19326f, -6.47121f, 1.69771f, -0.725123f, 0.0118929f, 0.0377944f, 0.0554003f, 0.0226452f, -0.0704421f, -0.0300309f, 0.0122978f, -0.0041782f, -0.0686612f, 0.0313115f, 0.039111f, 0.364111f, -0.0945548f, 0.0229876f, -0.17414f, 0.329795f, 0.114714f, 0.30022f, 0.106997f, 0.132355f, 5.79932f, 0.908058f, -0.905324f, -3.3561f, 0.190647f, 0.184211f, -0.673648f, 0.231807f, -0.0586222f, 0.230752f, -0.438277f, 0.245857f, -0.17215f, 0.0876383f, -0.720512f, 0.162515f, 0.0170571f, 0.101781f, 0.388477f, 1.32931f, 1.08548f, -0.936301f, -2.36958f, -6.71988f, -3.44376f, 2.13818f, 14.2318f, 4.91459f, -3.09052f, -9.69191f, -0.768234f, 1.79604f, 0.0549653f, 0.163399f, 0.0797025f, 0.0343933f, -0.0555876f, -0.00505673f, 0.0187258f, 0.0326628f, 0.0231486f, 0.15573f, 0.0476223f, -0.254824f, 1.60155f, -0.801221f, 2.55496f, 0.737629f, -1.36249f, -0.695463f, -2.44301f, -1.73188f, 3.95279f, 1.89068f, 0.486087f, -11.3343f, 3941600.0f, -0.381439f, 0.12115f, -0.906927f, 2.93878f, 1.6388f, 0.882811f, 0.874344f, 1.21726f, -0.874545f, 0.321706f, 0.785055f, 0.946558f, -0.575066f, -3.46553f, 0.884905f, 0.0924047f, -9.90712f, 0.391338f, 0.160103f, -2.04954f, 4.1455f, 0.0684029f, -0.144761f, -0.285282f, 0.379244f, -1.1584f, -0.0277241f, -9.85f, -4.82386f, 3.71333f, 3.87308f, 3.52558f}; - static final int[] topo = new int[]{25, 15, 2}; - static final MLPState net = new MLPState(); - static final float[] tansig_table; - static final int[] mono_voice_bandwidth_thresholds; - static final int[] mono_music_bandwidth_thresholds; - static final int[] stereo_voice_bandwidth_thresholds; - static final int[] stereo_music_bandwidth_thresholds; - public static final int stereo_voice_threshold = 30000; - public static final int stereo_music_threshold = 30000; - static final int[][] mode_thresholds; - - OpusTables() { - } - - static { - OpusTables.net.layers = 3; - OpusTables.net.topo = topo; - OpusTables.net.weights = weights; - tansig_table = new float[]{0.0f, 0.039979f, 0.07983f, 0.119427f, 0.158649f, 0.197375f, 0.235496f, 0.272905f, 0.309507f, 0.345214f, 0.379949f, 0.413644f, 0.446244f, 0.4777f, 0.507977f, 0.53705f, 0.5649f, 0.591519f, 0.616909f, 0.641077f, 0.664037f, 0.685809f, 0.706419f, 0.725897f, 0.744277f, 0.761594f, 0.777888f, 0.793199f, 0.807569f, 0.82104f, 0.833655f, 0.845456f, 0.856485f, 0.866784f, 0.876393f, 0.885352f, 0.893698f, 0.901468f, 0.908698f, 0.91542f, 0.921669f, 0.927473f, 0.932862f, 0.937863f, 0.942503f, 0.946806f, 0.950795f, 0.954492f, 0.957917f, 0.96109f, 0.964028f, 0.966747f, 0.969265f, 0.971594f, 0.973749f, 0.975743f, 0.977587f, 0.979293f, 0.980869f, 0.982327f, 0.983675f, 0.984921f, 0.986072f, 0.987136f, 0.988119f, 0.989027f, 0.989867f, 0.990642f, 0.991359f, 0.99202f, 0.992631f, 0.993196f, 0.993718f, 0.994199f, 0.994644f, 0.995055f, 0.995434f, 0.995784f, 0.996108f, 0.996407f, 0.996682f, 0.996937f, 0.997172f, 0.997389f, 0.99759f, 0.997775f, 0.997946f, 0.998104f, 0.998249f, 0.998384f, 0.998508f, 0.998623f, 0.998728f, 0.998826f, 0.998916f, 0.999f, 0.999076f, 0.999147f, 0.999213f, 0.999273f, 0.999329f, 0.999381f, 0.999428f, 0.999472f, 0.999513f, 0.99955f, 0.999585f, 0.999617f, 0.999646f, 0.999673f, 0.999699f, 0.999722f, 0.999743f, 0.999763f, 0.999781f, 0.999798f, 0.999813f, 0.999828f, 0.999841f, 0.999853f, 0.999865f, 0.999875f, 0.999885f, 0.999893f, 0.999902f, 0.999909f, 0.999916f, 0.999923f, 0.999929f, 0.999934f, 0.999939f, 0.999944f, 0.999948f, 0.999952f, 0.999956f, 0.999959f, 0.999962f, 0.999965f, 0.999968f, 0.99997f, 0.999973f, 0.999975f, 0.999977f, 0.999978f, 0.99998f, 0.999982f, 0.999983f, 0.999984f, 0.999986f, 0.999987f, 0.999988f, 0.999989f, 0.99999f, 0.99999f, 0.999991f, 0.999992f, 0.999992f, 0.999993f, 0.999994f, 0.999994f, 0.999994f, 0.999995f, 0.999995f, 0.999996f, 0.999996f, 0.999996f, 0.999997f, 0.999997f, 0.999997f, 0.999997f, 0.999997f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; - mono_voice_bandwidth_thresholds = new int[]{11000, 1000, 14000, 1000, 17000, 1000, 21000, 2000}; - mono_music_bandwidth_thresholds = new int[]{12000, 1000, 15000, 1000, 18000, 2000, 22000, 2000}; - stereo_voice_bandwidth_thresholds = new int[]{11000, 1000, 14000, 1000, 21000, 2000, 28000, 2000}; - stereo_music_bandwidth_thresholds = new int[]{12000, 1000, 18000, 2000, 21000, 2000, 30000, 2000}; - mode_thresholds = new int[][]{{64000, 16000}, {36000, 16000}}; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/PLC.java b/source/decompiled/de/maxhenkel/voicechat/concentus/PLC.java deleted file mode 100644 index 9ff9d1b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/PLC.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BWExpander; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.LPCInversePredGain; -import de.maxhenkel.voicechat.concentus.PLCStruct; -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.SilkDecoderControl; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class PLC { - private static final int NB_ATT = 2; - private static final short[] HARM_ATT_Q15 = new short[]{32440, 31130}; - private static final short[] PLC_RAND_ATTENUATE_V_Q15 = new short[]{31130, 26214}; - private static final short[] PLC_RAND_ATTENUATE_UV_Q15 = new short[]{32440, 29491}; - - PLC() { - } - - static void silk_PLC_Reset(SilkChannelDecoder psDec) { - psDec.sPLC.pitchL_Q8 = Inlines.silk_LSHIFT(psDec.frame_length, 7); - psDec.sPLC.prevGain_Q16[0] = 65536; - psDec.sPLC.prevGain_Q16[1] = 65536; - psDec.sPLC.subfr_length = 20; - psDec.sPLC.nb_subfr = 2; - } - - static void silk_PLC(SilkChannelDecoder psDec, SilkDecoderControl psDecCtrl, short[] frame, int frame_ptr, int lost) { - if (psDec.fs_kHz != psDec.sPLC.fs_kHz) { - PLC.silk_PLC_Reset(psDec); - psDec.sPLC.fs_kHz = psDec.fs_kHz; - } - if (lost != 0) { - PLC.silk_PLC_conceal(psDec, psDecCtrl, frame, frame_ptr); - ++psDec.lossCnt; - } else { - PLC.silk_PLC_update(psDec, psDecCtrl); - } - } - - static void silk_PLC_update(SilkChannelDecoder psDec, SilkDecoderControl psDecCtrl) { - PLCStruct psPLC = psDec.sPLC; - psDec.prevSignalType = psDec.indices.signalType; - int LTP_Gain_Q14 = 0; - if (psDec.indices.signalType == 2) { - int i; - for (int j = 0; j * psDec.subfr_length < psDecCtrl.pitchL[psDec.nb_subfr - 1] && j != psDec.nb_subfr; ++j) { - int temp_LTP_Gain_Q14 = 0; - for (i = 0; i < 5; ++i) { - temp_LTP_Gain_Q14 += psDecCtrl.LTPCoef_Q14[(psDec.nb_subfr - 1 - j) * 5 + i]; - } - if (temp_LTP_Gain_Q14 <= LTP_Gain_Q14) continue; - LTP_Gain_Q14 = temp_LTP_Gain_Q14; - System.arraycopy(psDecCtrl.LTPCoef_Q14, Inlines.silk_SMULBB(psDec.nb_subfr - 1 - j, 5), psPLC.LTPCoef_Q14, 0, 5); - psPLC.pitchL_Q8 = Inlines.silk_LSHIFT(psDecCtrl.pitchL[psDec.nb_subfr - 1 - j], 8); - } - Arrays.MemSet(psPLC.LTPCoef_Q14, (short)0, 5); - psPLC.LTPCoef_Q14[2] = (short)LTP_Gain_Q14; - if (LTP_Gain_Q14 < 11469) { - int tmp = Inlines.silk_LSHIFT(11469, 10); - int scale_Q10 = Inlines.silk_DIV32(tmp, Inlines.silk_max(LTP_Gain_Q14, 1)); - for (i = 0; i < 5; ++i) { - psPLC.LTPCoef_Q14[i] = (short)Inlines.silk_RSHIFT(Inlines.silk_SMULBB(psPLC.LTPCoef_Q14[i], scale_Q10), 10); - } - } else if (LTP_Gain_Q14 > 15565) { - int tmp = Inlines.silk_LSHIFT(15565, 14); - int scale_Q14 = Inlines.silk_DIV32(tmp, Inlines.silk_max(LTP_Gain_Q14, 1)); - for (i = 0; i < 5; ++i) { - psPLC.LTPCoef_Q14[i] = (short)Inlines.silk_RSHIFT(Inlines.silk_SMULBB(psPLC.LTPCoef_Q14[i], scale_Q14), 14); - } - } - } else { - psPLC.pitchL_Q8 = Inlines.silk_LSHIFT(Inlines.silk_SMULBB(psDec.fs_kHz, 18), 8); - Arrays.MemSet(psPLC.LTPCoef_Q14, (short)0, 5); - } - System.arraycopy(psDecCtrl.PredCoef_Q12[1], 0, psPLC.prevLPC_Q12, 0, psDec.LPC_order); - psPLC.prevLTP_scale_Q14 = (short)psDecCtrl.LTP_scale_Q14; - System.arraycopy(psDecCtrl.Gains_Q16, psDec.nb_subfr - 2, psPLC.prevGain_Q16, 0, 2); - psPLC.subfr_length = psDec.subfr_length; - psPLC.nb_subfr = psDec.nb_subfr; - } - - static void silk_PLC_energy(BoxedValueInt energy1, BoxedValueInt shift1, BoxedValueInt energy2, BoxedValueInt shift2, int[] exc_Q14, int[] prevGain_Q10, int subfr_length, int nb_subfr) { - int exc_buf_ptr = 0; - short[] exc_buf = new short[2 * subfr_length]; - for (int k = 0; k < 2; ++k) { - for (int i = 0; i < subfr_length; ++i) { - exc_buf[exc_buf_ptr + i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT(Inlines.silk_SMULWW(exc_Q14[i + (k + nb_subfr - 2) * subfr_length], prevGain_Q10[k]), 8)); - } - exc_buf_ptr += subfr_length; - } - SumSqrShift.silk_sum_sqr_shift(energy1, shift1, exc_buf, subfr_length); - SumSqrShift.silk_sum_sqr_shift(energy2, shift2, exc_buf, subfr_length, subfr_length); - } - - static void silk_PLC_conceal(SilkChannelDecoder psDec, SilkDecoderControl psDecCtrl, short[] frame, int frame_ptr) { - int j; - int i; - BoxedValueInt energy1 = new BoxedValueInt(0); - BoxedValueInt energy2 = new BoxedValueInt(0); - BoxedValueInt shift1 = new BoxedValueInt(0); - BoxedValueInt shift2 = new BoxedValueInt(0); - short[] sLTP = new short[psDec.ltp_mem_length]; - int[] sLTP_Q14 = new int[psDec.ltp_mem_length + psDec.frame_length]; - PLCStruct psPLC = psDec.sPLC; - int[] prevGain_Q10 = new int[]{Inlines.silk_RSHIFT(psPLC.prevGain_Q16[0], 6), Inlines.silk_RSHIFT(psPLC.prevGain_Q16[1], 6)}; - if (psDec.first_frame_after_reset != 0) { - Arrays.MemSet(psPLC.prevLPC_Q12, (short)0, 16); - } - PLC.silk_PLC_energy(energy1, shift1, energy2, shift2, psDec.exc_Q14, prevGain_Q10, psDec.subfr_length, psDec.nb_subfr); - int rand_ptr = Inlines.silk_RSHIFT(energy1.Val, shift2.Val) < Inlines.silk_RSHIFT(energy2.Val, shift1.Val) ? Inlines.silk_max_int(0, (psPLC.nb_subfr - 1) * psPLC.subfr_length - 128) : Inlines.silk_max_int(0, psPLC.nb_subfr * psPLC.subfr_length - 128); - short[] B_Q14 = psPLC.LTPCoef_Q14; - short rand_scale_Q14 = psPLC.randScale_Q14; - short harm_Gain_Q15 = HARM_ATT_Q15[Inlines.silk_min_int(1, psDec.lossCnt)]; - int rand_Gain_Q15 = psDec.prevSignalType == 2 ? PLC_RAND_ATTENUATE_V_Q15[Inlines.silk_min_int(1, psDec.lossCnt)] : PLC_RAND_ATTENUATE_UV_Q15[Inlines.silk_min_int(1, psDec.lossCnt)]; - BWExpander.silk_bwexpander(psPLC.prevLPC_Q12, psDec.LPC_order, 64881); - if (psDec.lossCnt == 0) { - rand_scale_Q14 = 16384; - if (psDec.prevSignalType == 2) { - for (i = 0; i < 5; ++i) { - rand_scale_Q14 = (short)(rand_scale_Q14 - B_Q14[i]); - } - rand_scale_Q14 = Inlines.silk_max_16((short)3277, rand_scale_Q14); - rand_scale_Q14 = (short)Inlines.silk_RSHIFT(Inlines.silk_SMULBB(rand_scale_Q14, psPLC.prevLTP_scale_Q14), 14); - } else { - int invGain_Q30 = LPCInversePredGain.silk_LPC_inverse_pred_gain(psPLC.prevLPC_Q12, psDec.LPC_order); - int down_scale_Q30 = Inlines.silk_min_32(Inlines.silk_RSHIFT(0x40000000, 3), invGain_Q30); - down_scale_Q30 = Inlines.silk_max_32(Inlines.silk_RSHIFT(0x40000000, 8), down_scale_Q30); - down_scale_Q30 = Inlines.silk_LSHIFT(down_scale_Q30, 3); - rand_Gain_Q15 = Inlines.silk_RSHIFT(Inlines.silk_SMULWB(down_scale_Q30, rand_Gain_Q15), 14); - } - } - int rand_seed = psPLC.rand_seed; - int lag = Inlines.silk_RSHIFT_ROUND(psPLC.pitchL_Q8, 8); - int sLTP_buf_idx = psDec.ltp_mem_length; - int idx = psDec.ltp_mem_length - lag - psDec.LPC_order - 2; - Inlines.OpusAssert(idx > 0); - Filters.silk_LPC_analysis_filter(sLTP, idx, psDec.outBuf, idx, psPLC.prevLPC_Q12, 0, psDec.ltp_mem_length - idx, psDec.LPC_order); - int inv_gain_Q30 = Inlines.silk_INVERSE32_varQ(psPLC.prevGain_Q16[1], 46); - inv_gain_Q30 = Inlines.silk_min(inv_gain_Q30, 0x3FFFFFFF); - for (i = idx + psDec.LPC_order; i < psDec.ltp_mem_length; ++i) { - sLTP_Q14[i] = Inlines.silk_SMULWB(inv_gain_Q30, sLTP[i]); - } - for (int k = 0; k < psDec.nb_subfr; ++k) { - int pred_lag_ptr = sLTP_buf_idx - lag + 2; - for (i = 0; i < psDec.subfr_length; ++i) { - int LTP_pred_Q12 = 2; - LTP_pred_Q12 = Inlines.silk_SMLAWB(LTP_pred_Q12, sLTP_Q14[pred_lag_ptr], B_Q14[0]); - LTP_pred_Q12 = Inlines.silk_SMLAWB(LTP_pred_Q12, sLTP_Q14[pred_lag_ptr - 1], B_Q14[1]); - LTP_pred_Q12 = Inlines.silk_SMLAWB(LTP_pred_Q12, sLTP_Q14[pred_lag_ptr - 2], B_Q14[2]); - LTP_pred_Q12 = Inlines.silk_SMLAWB(LTP_pred_Q12, sLTP_Q14[pred_lag_ptr - 3], B_Q14[3]); - LTP_pred_Q12 = Inlines.silk_SMLAWB(LTP_pred_Q12, sLTP_Q14[pred_lag_ptr - 4], B_Q14[4]); - ++pred_lag_ptr; - rand_seed = Inlines.silk_RAND(rand_seed); - idx = Inlines.silk_RSHIFT(rand_seed, 25) & 0x7F; - sLTP_Q14[sLTP_buf_idx] = Inlines.silk_LSHIFT32(Inlines.silk_SMLAWB(LTP_pred_Q12, psDec.exc_Q14[rand_ptr + idx], rand_scale_Q14), 2); - ++sLTP_buf_idx; - } - for (j = 0; j < 5; ++j) { - B_Q14[j] = (short)Inlines.silk_RSHIFT(Inlines.silk_SMULBB(harm_Gain_Q15, B_Q14[j]), 15); - } - rand_scale_Q14 = (short)Inlines.silk_RSHIFT(Inlines.silk_SMULBB(rand_scale_Q14, rand_Gain_Q15), 15); - psPLC.pitchL_Q8 = Inlines.silk_SMLAWB(psPLC.pitchL_Q8, psPLC.pitchL_Q8, 655); - psPLC.pitchL_Q8 = Inlines.silk_min_32(psPLC.pitchL_Q8, Inlines.silk_LSHIFT(Inlines.silk_SMULBB(18, psDec.fs_kHz), 8)); - lag = Inlines.silk_RSHIFT_ROUND(psPLC.pitchL_Q8, 8); - } - int sLPC_Q14_ptr = psDec.ltp_mem_length - 16; - System.arraycopy(psDec.sLPC_Q14_buf, 0, sLTP_Q14, sLPC_Q14_ptr, 16); - Inlines.OpusAssert(psDec.LPC_order >= 10); - for (i = 0; i < psDec.frame_length; ++i) { - int sLPCmaxi = sLPC_Q14_ptr + 16 + i; - int LPC_pred_Q10 = Inlines.silk_RSHIFT(psDec.LPC_order, 1); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 1], psPLC.prevLPC_Q12[0]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 2], psPLC.prevLPC_Q12[1]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 3], psPLC.prevLPC_Q12[2]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 4], psPLC.prevLPC_Q12[3]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 5], psPLC.prevLPC_Q12[4]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 6], psPLC.prevLPC_Q12[5]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 7], psPLC.prevLPC_Q12[6]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 8], psPLC.prevLPC_Q12[7]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 9], psPLC.prevLPC_Q12[8]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - 10], psPLC.prevLPC_Q12[9]); - for (j = 10; j < psDec.LPC_order; ++j) { - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, sLTP_Q14[sLPCmaxi - j - 1], psPLC.prevLPC_Q12[j]); - } - sLTP_Q14[sLPCmaxi] = Inlines.silk_ADD_LSHIFT32(sLTP_Q14[sLPCmaxi], LPC_pred_Q10, 4); - frame[frame_ptr + i] = (short)Inlines.silk_SAT16(Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWW(sLTP_Q14[sLPCmaxi], prevGain_Q10[1]), 8))); - } - System.arraycopy(sLTP_Q14, sLPC_Q14_ptr + psDec.frame_length, psDec.sLPC_Q14_buf, 0, 16); - psPLC.rand_seed = rand_seed; - psPLC.randScale_Q14 = rand_scale_Q14; - for (i = 0; i < 4; ++i) { - psDecCtrl.pitchL[i] = lag; - } - } - - static void silk_PLC_glue_frames(SilkChannelDecoder psDec, short[] frame, int frame_ptr, int length) { - BoxedValueInt energy_shift = new BoxedValueInt(0); - BoxedValueInt energy = new BoxedValueInt(0); - PLCStruct psPLC = psDec.sPLC; - if (psDec.lossCnt != 0) { - BoxedValueInt boxed_conc_e = new BoxedValueInt(0); - BoxedValueInt boxed_conc_shift = new BoxedValueInt(0); - SumSqrShift.silk_sum_sqr_shift(boxed_conc_e, boxed_conc_shift, frame, frame_ptr, length); - psPLC.conc_energy = boxed_conc_e.Val; - psPLC.conc_energy_shift = boxed_conc_shift.Val; - psPLC.last_frame_lost = 1; - } else { - if (psDec.sPLC.last_frame_lost != 0) { - SumSqrShift.silk_sum_sqr_shift(energy, energy_shift, frame, frame_ptr, length); - if (energy_shift.Val > psPLC.conc_energy_shift) { - psPLC.conc_energy = Inlines.silk_RSHIFT(psPLC.conc_energy, energy_shift.Val - psPLC.conc_energy_shift); - } else if (energy_shift.Val < psPLC.conc_energy_shift) { - energy.Val = Inlines.silk_RSHIFT(energy.Val, psPLC.conc_energy_shift - energy_shift.Val); - } - if (energy.Val > psPLC.conc_energy) { - int LZ = Inlines.silk_CLZ32(psPLC.conc_energy); - psPLC.conc_energy = Inlines.silk_LSHIFT(psPLC.conc_energy, --LZ); - energy.Val = Inlines.silk_RSHIFT(energy.Val, Inlines.silk_max_32(24 - LZ, 0)); - int frac_Q24 = Inlines.silk_DIV32(psPLC.conc_energy, Inlines.silk_max(energy.Val, 1)); - int gain_Q16 = Inlines.silk_LSHIFT(Inlines.silk_SQRT_APPROX(frac_Q24), 4); - int slope_Q16 = Inlines.silk_DIV32_16(65536 - gain_Q16, length); - slope_Q16 = Inlines.silk_LSHIFT(slope_Q16, 2); - for (int i = frame_ptr; i < frame_ptr + length; ++i) { - frame[i] = (short)Inlines.silk_SMULWB(gain_Q16, frame[i]); - if ((gain_Q16 += slope_Q16) > 65536) break; - } - } - } - psPLC.last_frame_lost = 0; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/PLCStruct.java b/source/decompiled/de/maxhenkel/voicechat/concentus/PLCStruct.java deleted file mode 100644 index 91ec03b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/PLCStruct.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class PLCStruct { - int pitchL_Q8 = 0; - final short[] LTPCoef_Q14 = new short[5]; - final short[] prevLPC_Q12 = new short[16]; - int last_frame_lost = 0; - int rand_seed = 0; - short randScale_Q14 = 0; - int conc_energy = 0; - int conc_energy_shift = 0; - short prevLTP_scale_Q14 = 0; - final int[] prevGain_Q16 = new int[2]; - int fs_kHz = 0; - int nb_subfr = 0; - int subfr_length = 0; - - PLCStruct() { - } - - void Reset() { - this.pitchL_Q8 = 0; - Arrays.MemSet(this.LTPCoef_Q14, (short)0, 5); - Arrays.MemSet(this.prevLPC_Q12, (short)0, 16); - this.last_frame_lost = 0; - this.rand_seed = 0; - this.randScale_Q14 = 0; - this.conc_energy = 0; - this.conc_energy_shift = 0; - this.prevLTP_scale_Q14 = 0; - Arrays.MemSet(this.prevGain_Q16, 0, 2); - this.fs_kHz = 0; - this.nb_subfr = 0; - this.subfr_length = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Pitch.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Pitch.java deleted file mode 100644 index b578c0b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Pitch.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Autocorrelation; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltLPC; -import de.maxhenkel.voicechat.concentus.CeltPitchXCorr; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; - -class Pitch { - private static final int[] second_check = new int[]{0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}; - - Pitch() { - } - - static void find_best_pitch(int[] xcorr, int[] y, int len, int max_pitch, int[] best_pitch, int yshift, int maxcorr) { - int Syy = 1; - int xshift = Inlines.celt_ilog2(maxcorr) - 14; - int best_num_0 = -1; - int best_num_1 = -1; - int best_den_0 = 0; - int best_den_1 = 0; - best_pitch[0] = 0; - best_pitch[1] = 1; - for (int j = 0; j < len; ++j) { - Syy = Inlines.ADD32(Syy, Inlines.SHR32(Inlines.MULT16_16(y[j], y[j]), yshift)); - } - for (int i = 0; i < max_pitch; ++i) { - short xcorr16; - int num; - if (xcorr[i] > 0 && Inlines.MULT16_32_Q15(num = Inlines.MULT16_16_Q15((int)(xcorr16 = Inlines.EXTRACT16(Inlines.VSHR32(xcorr[i], xshift))), (int)xcorr16), best_den_1) > Inlines.MULT16_32_Q15(best_num_1, Syy)) { - if (Inlines.MULT16_32_Q15(num, best_den_0) > Inlines.MULT16_32_Q15(best_num_0, Syy)) { - best_num_1 = best_num_0; - best_den_1 = best_den_0; - best_pitch[1] = best_pitch[0]; - best_num_0 = num; - best_den_0 = Syy; - best_pitch[0] = i; - } else { - best_num_1 = num; - best_den_1 = Syy; - best_pitch[1] = i; - } - } - Syy += Inlines.SHR32(Inlines.MULT16_16(y[i + len], y[i + len]), yshift) - Inlines.SHR32(Inlines.MULT16_16(y[i], y[i]), yshift); - Syy = Inlines.MAX32(1, Syy); - } - } - - static void celt_fir5(int[] x, int[] num, int[] y, int N, int[] mem) { - int num0 = num[0]; - int num1 = num[1]; - int num2 = num[2]; - int num3 = num[3]; - int num4 = num[4]; - int mem0 = mem[0]; - int mem1 = mem[1]; - int mem2 = mem[2]; - int mem3 = mem[3]; - int mem4 = mem[4]; - for (int i = 0; i < N; ++i) { - int sum = Inlines.SHL32(Inlines.EXTEND32(x[i]), 12); - sum = Inlines.MAC16_16(sum, num0, mem0); - sum = Inlines.MAC16_16(sum, num1, mem1); - sum = Inlines.MAC16_16(sum, num2, mem2); - sum = Inlines.MAC16_16(sum, num3, mem3); - sum = Inlines.MAC16_16(sum, num4, mem4); - mem4 = mem3; - mem3 = mem2; - mem2 = mem1; - mem1 = mem0; - mem0 = x[i]; - y[i] = Inlines.ROUND16(sum, 12); - } - mem[0] = mem0; - mem[1] = mem1; - mem[2] = mem2; - mem[3] = mem3; - mem[4] = mem4; - } - - static void pitch_downsample(int[][] x, int[] x_lp, int len, int C) { - int i; - int shift; - int[] ac = new int[5]; - int tmp = Short.MAX_VALUE; - int[] lpc = new int[4]; - int[] mem = new int[]{0, 0, 0, 0, 0}; - int[] lpc2 = new int[5]; - int c1 = 26214; - int maxabs = Inlines.celt_maxabs32(x[0], 0, len); - if (C == 2) { - int maxabs_1 = Inlines.celt_maxabs32(x[1], 0, len); - maxabs = Inlines.MAX32(maxabs, maxabs_1); - } - if (maxabs < 1) { - maxabs = 1; - } - if ((shift = Inlines.celt_ilog2(maxabs) - 10) < 0) { - shift = 0; - } - if (C == 2) { - ++shift; - } - int halflen = len >> 1; - for (i = 1; i < halflen; ++i) { - x_lp[i] = Inlines.SHR32(Inlines.HALF32(Inlines.HALF32(x[0][2 * i - 1] + x[0][2 * i + 1]) + x[0][2 * i]), shift); - } - x_lp[0] = Inlines.SHR32(Inlines.HALF32(Inlines.HALF32(x[0][1]) + x[0][0]), shift); - if (C == 2) { - for (i = 1; i < halflen; ++i) { - int n = i; - x_lp[n] = x_lp[n] + Inlines.SHR32(Inlines.HALF32(Inlines.HALF32(x[1][2 * i - 1] + x[1][2 * i + 1]) + x[1][2 * i]), shift); - } - x_lp[0] = x_lp[0] + Inlines.SHR32(Inlines.HALF32(Inlines.HALF32(x[1][1]) + x[1][0]), shift); - } - Autocorrelation._celt_autocorr(x_lp, ac, null, 0, 4, halflen); - ac[0] = ac[0] + Inlines.SHR32(ac[0], 13); - for (i = 1; i <= 4; ++i) { - int n = i; - ac[n] = ac[n] - Inlines.MULT16_32_Q15(2 * i * i, ac[i]); - } - CeltLPC.celt_lpc(lpc, ac, 4); - for (i = 0; i < 4; ++i) { - tmp = Inlines.MULT16_16_Q15(29491, tmp); - lpc[i] = Inlines.MULT16_16_Q15(lpc[i], tmp); - } - lpc2[0] = lpc[0] + 3277; - lpc2[1] = lpc[1] + Inlines.MULT16_16_Q15(c1, lpc[0]); - lpc2[2] = lpc[2] + Inlines.MULT16_16_Q15(c1, lpc[1]); - lpc2[3] = lpc[3] + Inlines.MULT16_16_Q15(c1, lpc[2]); - lpc2[4] = Inlines.MULT16_16_Q15(c1, lpc[3]); - Pitch.celt_fir5(x_lp, lpc2, x_lp, halflen, mem); - } - - static void pitch_search(int[] x_lp, int x_lp_ptr, int[] y, int len, int max_pitch, BoxedValueInt pitch) { - int b; - int a; - int c; - int ymax; - int j; - int[] best_pitch = new int[]{0, 0}; - int shift = 0; - Inlines.OpusAssert(len > 0); - Inlines.OpusAssert(max_pitch > 0); - int lag = len + max_pitch; - int[] x_lp4 = new int[len >> 2]; - int[] y_lp4 = new int[lag >> 2]; - int[] xcorr = new int[max_pitch >> 1]; - for (j = 0; j < len >> 2; ++j) { - x_lp4[j] = x_lp[x_lp_ptr + 2 * j]; - } - for (j = 0; j < lag >> 2; ++j) { - y_lp4[j] = y[2 * j]; - } - int xmax = Inlines.celt_maxabs32(x_lp4, 0, len >> 2); - shift = Inlines.celt_ilog2(Inlines.MAX32(1, Inlines.MAX32(xmax, ymax = Inlines.celt_maxabs32(y_lp4, 0, lag >> 2)))) - 11; - if (shift > 0) { - for (j = 0; j < len >> 2; ++j) { - x_lp4[j] = Inlines.SHR16(x_lp4[j], shift); - } - for (j = 0; j < lag >> 2; ++j) { - y_lp4[j] = Inlines.SHR16(y_lp4[j], shift); - } - shift *= 2; - } else { - shift = 0; - } - int maxcorr = CeltPitchXCorr.pitch_xcorr(x_lp4, y_lp4, xcorr, len >> 2, max_pitch >> 2); - Pitch.find_best_pitch(xcorr, y_lp4, len >> 2, max_pitch >> 2, best_pitch, 0, maxcorr); - maxcorr = 1; - for (int i = 0; i < max_pitch >> 1; ++i) { - xcorr[i] = 0; - if (Inlines.abs(i - 2 * best_pitch[0]) > 2 && Inlines.abs(i - 2 * best_pitch[1]) > 2) continue; - int sum = 0; - for (j = 0; j < len >> 1; ++j) { - sum += Inlines.SHR32(Inlines.MULT16_16(x_lp[x_lp_ptr + j], y[i + j]), shift); - } - xcorr[i] = Inlines.MAX32(-1, sum); - maxcorr = Inlines.MAX32(maxcorr, sum); - } - Pitch.find_best_pitch(xcorr, y, len >> 1, max_pitch >> 1, best_pitch, shift + 1, maxcorr); - int offset = best_pitch[0] > 0 && best_pitch[0] < (max_pitch >> 1) - 1 ? ((c = xcorr[best_pitch[0] + 1]) - (a = xcorr[best_pitch[0] - 1]) > Inlines.MULT16_32_Q15((short)22938, (b = xcorr[best_pitch[0]]) - a) ? 1 : (a - c > Inlines.MULT16_32_Q15((short)22938, b - c) ? -1 : 0)) : 0; - pitch.Val = 2 * best_pitch[0] - offset; - } - - static int remove_doubling(int[] x, int maxperiod, int minperiod, int N, BoxedValueInt T0_, int prev_period, int prev_gain) { - int k; - int g; - int T0; - int[] xcorr = new int[3]; - int minperiod0 = minperiod; - minperiod /= 2; - T0_.Val /= 2; - prev_period /= 2; - N /= 2; - int x_ptr = maxperiod /= 2; - if (T0_.Val >= maxperiod) { - T0_.Val = maxperiod - 1; - } - int T = T0 = T0_.Val; - int[] yy_lookup = new int[maxperiod + 1]; - BoxedValueInt boxed_xx = new BoxedValueInt(0); - BoxedValueInt boxed_xy = new BoxedValueInt(0); - BoxedValueInt boxed_xy2 = new BoxedValueInt(0); - Kernels.dual_inner_prod(x, x_ptr, x, x_ptr, x, x_ptr - T0, N, boxed_xx, boxed_xy); - int xx = boxed_xx.Val; - int xy = boxed_xy.Val; - yy_lookup[0] = xx; - int yy = xx; - for (int i = 1; i <= maxperiod; ++i) { - int xi = x_ptr - i; - yy = yy + Inlines.MULT16_16(x[xi], x[xi]) - Inlines.MULT16_16(x[xi + N], x[xi + N]); - yy_lookup[i] = Inlines.MAX32(0, yy); - } - yy = yy_lookup[T0]; - int best_xy = xy; - int best_yy = yy; - int x2y2 = 1 + Inlines.HALF32(Inlines.MULT32_32_Q31(xx, yy)); - int sh = Inlines.celt_ilog2(x2y2) >> 1; - int t = Inlines.VSHR32(x2y2, 2 * (sh - 7)); - int g0 = g = Inlines.VSHR32(Inlines.MULT16_32_Q15(Inlines.celt_rsqrt_norm(t), xy), sh + 1); - for (k = 2; k <= 15; ++k) { - int cont = 0; - int T1 = Inlines.celt_udiv(2 * T0 + k, 2 * k); - if (T1 < minperiod) break; - int T1b = k == 2 ? (T1 + T0 > maxperiod ? T0 : T0 + T1) : Inlines.celt_udiv(2 * second_check[k] * T0 + k, 2 * k); - Kernels.dual_inner_prod(x, x_ptr, x, x_ptr - T1, x, x_ptr - T1b, N, boxed_xy, boxed_xy2); - xy = boxed_xy.Val; - int xy2 = boxed_xy2.Val; - yy = yy_lookup[T1] + yy_lookup[T1b]; - int x2y22 = 1 + Inlines.MULT32_32_Q31(xx, yy); - int sh2 = Inlines.celt_ilog2(x2y22) >> 1; - int t2 = Inlines.VSHR32(x2y22, 2 * (sh2 - 7)); - int g1 = Inlines.VSHR32(Inlines.MULT16_32_Q15(Inlines.celt_rsqrt_norm(t2), xy += xy2), sh2 + 1); - cont = Inlines.abs(T1 - prev_period) <= 1 ? prev_gain : (Inlines.abs(T1 - prev_period) <= 2 && 5 * k * k < T0 ? Inlines.HALF16(prev_gain) : 0); - int thresh = Inlines.MAX16(9830, Inlines.MULT16_16_Q15(22938, g0) - cont); - if (T1 < 3 * minperiod) { - thresh = Inlines.MAX16(13107, Inlines.MULT16_16_Q15(27853, g0) - cont); - } else if (T1 < 2 * minperiod) { - thresh = Inlines.MAX16(16384, Inlines.MULT16_16_Q15(29491, g0) - cont); - } - if (g1 <= thresh) continue; - best_xy = xy; - best_yy = yy; - T = T1; - g = g1; - } - int pg = best_yy <= (best_xy = Inlines.MAX32(0, best_xy)) ? Short.MAX_VALUE : Inlines.SHR32(Inlines.frac_div32(best_xy, best_yy + 1), 16); - for (k = 0; k < 3; ++k) { - xcorr[k] = Kernels.celt_inner_prod(x, x_ptr, x, x_ptr - (T + k - 1), N); - } - int offset = xcorr[2] - xcorr[0] > Inlines.MULT16_32_Q15((short)22938, xcorr[1] - xcorr[0]) ? 1 : (xcorr[0] - xcorr[2] > Inlines.MULT16_32_Q15((short)22938, xcorr[1] - xcorr[2]) ? -1 : 0); - if (pg > g) { - pg = g; - } - T0_.Val = 2 * T + offset; - if (T0_.Val < minperiod0) { - T0_.Val = minperiod0; - } - return pg; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/PitchAnalysisCore.java b/source/decompiled/de/maxhenkel/voicechat/concentus/PitchAnalysisCore.java deleted file mode 100644 index b8658bf..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/PitchAnalysisCore.java +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.BoxedValueShort; -import de.maxhenkel.voicechat.concentus.CeltPitchXCorr; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Resampler; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.Sort; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class PitchAnalysisCore { - private static final int SCRATCH_SIZE = 22; - private static final int SF_LENGTH_4KHZ = 20; - private static final int SF_LENGTH_8KHZ = 40; - private static final int MIN_LAG_4KHZ = 8; - private static final int MIN_LAG_8KHZ = 16; - private static final int MAX_LAG_4KHZ = 72; - private static final int MAX_LAG_8KHZ = 143; - private static final int CSTRIDE_4KHZ = 65; - private static final int CSTRIDE_8KHZ = 132; - private static final int D_COMP_MIN = 13; - private static final int D_COMP_MAX = 147; - private static final int D_COMP_STRIDE = 134; - - PitchAnalysisCore() { - } - - static int silk_pitch_analysis_core(short[] frame, int[] pitch_out, BoxedValueShort lagIndex, BoxedValueByte contourIndex, BoxedValueInt LTPCorr_Q15, int prevLag, int search_thres1_Q16, int search_thres2_Q13, int Fs_kHz, int complexity, int nb_subfr) { - int CCmax_new; - int nb_cbk_search; - byte[][] Lag_CB_ptr; - int prevLag_log2_Q7; - int j; - int energy_target; - int length_d_srch; - int sum; - int d; - int cross_corr; - int basis_ptr; - short[] basis; - int k; - int i; - int[] filt_state = new int[6]; - int[] d_srch = new int[24]; - int[] CC = new int[11]; - Inlines.OpusAssert(Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16); - Inlines.OpusAssert(complexity >= 0); - Inlines.OpusAssert(complexity <= 2); - Inlines.OpusAssert(search_thres1_Q16 >= 0 && search_thres1_Q16 <= 65536); - Inlines.OpusAssert(search_thres2_Q13 >= 0 && search_thres2_Q13 <= 8192); - int frame_length = (20 + nb_subfr * 5) * Fs_kHz; - int frame_length_4kHz = (20 + nb_subfr * 5) * 4; - int frame_length_8kHz = (20 + nb_subfr * 5) * 8; - int sf_length = 5 * Fs_kHz; - int min_lag = 2 * Fs_kHz; - int max_lag = 18 * Fs_kHz - 1; - short[] frame_8kHz = new short[frame_length_8kHz]; - if (Fs_kHz == 16) { - Arrays.MemSet(filt_state, 0, 2); - Resampler.silk_resampler_down2(filt_state, frame_8kHz, frame, frame_length); - } else if (Fs_kHz == 12) { - Arrays.MemSet(filt_state, 0, 6); - Resampler.silk_resampler_down2_3(filt_state, frame_8kHz, frame, frame_length); - } else { - Inlines.OpusAssert(Fs_kHz == 8); - System.arraycopy(frame, 0, frame_8kHz, 0, frame_length_8kHz); - } - Arrays.MemSet(filt_state, 0, 2); - short[] frame_4kHz = new short[frame_length_4kHz]; - Resampler.silk_resampler_down2(filt_state, frame_4kHz, frame_8kHz, frame_length_8kHz); - for (i = frame_length_4kHz - 1; i > 0; --i) { - frame_4kHz[i] = Inlines.silk_ADD_SAT16(frame_4kHz[i], frame_4kHz[i - 1]); - } - BoxedValueInt boxed_energy = new BoxedValueInt(0); - BoxedValueInt boxed_shift = new BoxedValueInt(0); - SumSqrShift.silk_sum_sqr_shift(boxed_energy, boxed_shift, frame_4kHz, frame_length_4kHz); - int energy = boxed_energy.Val; - int shift = boxed_shift.Val; - if (shift > 0) { - shift = Inlines.silk_RSHIFT(shift, 1); - for (i = 0; i < frame_length_4kHz; ++i) { - frame_4kHz[i] = Inlines.silk_RSHIFT16(frame_4kHz[i], shift); - } - } - short[] C = new short[nb_subfr * 132]; - int[] xcorr32 = new int[65]; - Arrays.MemSet(C, (short)0, (nb_subfr >> 1) * 65); - short[] target = frame_4kHz; - int target_ptr = Inlines.silk_LSHIFT(20, 2); - for (k = 0; k < nb_subfr >> 1; ++k) { - basis = target; - basis_ptr = target_ptr - 8; - CeltPitchXCorr.pitch_xcorr(target, target_ptr, target, target_ptr - 72, xcorr32, 40, 65); - cross_corr = xcorr32[64]; - int normalizer = Inlines.silk_inner_prod_self(target, target_ptr, 40); - normalizer = Inlines.silk_ADD32(normalizer, Inlines.silk_inner_prod_self(basis, basis_ptr, 40)); - normalizer = Inlines.silk_ADD32(normalizer, Inlines.silk_SMULBB(40, 4000)); - Inlines.MatrixSet(C, k, 0, 65, (short)Inlines.silk_DIV32_varQ(cross_corr, normalizer, 14)); - for (d = 9; d <= 72; ++d) { - cross_corr = xcorr32[72 - d]; - normalizer = Inlines.silk_ADD32(normalizer, Inlines.silk_SMULBB(basis[--basis_ptr], basis[basis_ptr]) - Inlines.silk_SMULBB(basis[basis_ptr + 40], basis[basis_ptr + 40])); - Inlines.MatrixSet(C, k, d - 8, 65, (short)Inlines.silk_DIV32_varQ(cross_corr, normalizer, 14)); - } - target_ptr += 40; - } - if (nb_subfr == 4) { - for (i = 72; i >= 8; --i) { - sum = Inlines.MatrixGet(C, 0, i - 8, 65) + Inlines.MatrixGet(C, 1, i - 8, 65); - sum = Inlines.silk_SMLAWB(sum, sum, Inlines.silk_LSHIFT(-i, 4)); - C[i - 8] = (short)sum; - } - } else { - for (i = 72; i >= 8; --i) { - sum = Inlines.silk_LSHIFT(C[i - 8], 1); - sum = Inlines.silk_SMLAWB(sum, sum, Inlines.silk_LSHIFT(-i, 4)); - C[i - 8] = (short)sum; - } - } - Inlines.OpusAssert(3 * (length_d_srch = Inlines.silk_ADD_LSHIFT32(4, complexity, 1)) <= 24); - Sort.silk_insertion_sort_decreasing_int16(C, d_srch, 65, length_d_srch); - short Cmax = C[0]; - if (Cmax < 3277) { - Arrays.MemSet(pitch_out, 0, nb_subfr); - LTPCorr_Q15.Val = 0; - lagIndex.Val = 0; - contourIndex.Val = 0; - return 1; - } - int threshold = Inlines.silk_SMULWB(search_thres1_Q16, Cmax); - for (i = 0; i < length_d_srch; ++i) { - if (C[i] <= threshold) { - length_d_srch = i; - break; - } - d_srch[i] = Inlines.silk_LSHIFT(d_srch[i] + 8, 1); - } - Inlines.OpusAssert(length_d_srch > 0); - short[] d_comp = new short[134]; - for (i = 13; i < 147; ++i) { - d_comp[i - 13] = 0; - } - for (i = 0; i < length_d_srch; ++i) { - d_comp[d_srch[i] - 13] = 1; - } - for (i = 146; i >= 16; --i) { - int n = i - 13; - d_comp[n] = (short)(d_comp[n] + (short)(d_comp[i - 1 - 13] + d_comp[i - 2 - 13])); - } - length_d_srch = 0; - for (i = 16; i < 144; ++i) { - if (d_comp[i + 1 - 13] <= 0) continue; - d_srch[length_d_srch] = i; - ++length_d_srch; - } - for (i = 146; i >= 16; --i) { - int n = i - 13; - d_comp[n] = (short)(d_comp[n] + (short)(d_comp[i - 1 - 13] + d_comp[i - 2 - 13] + d_comp[i - 3 - 13])); - } - int length_d_comp = 0; - for (i = 16; i < 147; ++i) { - if (d_comp[i - 13] <= 0) continue; - d_comp[length_d_comp] = (short)(i - 2); - ++length_d_comp; - } - boxed_energy.Val = 0; - boxed_shift.Val = 0; - SumSqrShift.silk_sum_sqr_shift(boxed_energy, boxed_shift, frame_8kHz, frame_length_8kHz); - energy = boxed_energy.Val; - shift = boxed_shift.Val; - if (shift > 0) { - shift = Inlines.silk_RSHIFT(shift, 1); - for (i = 0; i < frame_length_8kHz; ++i) { - frame_8kHz[i] = Inlines.silk_RSHIFT16(frame_8kHz[i], shift); - } - } - Arrays.MemSet(C, (short)0, nb_subfr * 132); - target = frame_8kHz; - target_ptr = 160; - for (k = 0; k < nb_subfr; ++k) { - energy_target = Inlines.silk_ADD32(Inlines.silk_inner_prod(target, target_ptr, target, target_ptr, 40), 1); - for (j = 0; j < length_d_comp; ++j) { - basis = target; - d = d_comp[j]; - basis_ptr = target_ptr - d; - cross_corr = Inlines.silk_inner_prod(target, target_ptr, basis, basis_ptr, 40); - if (cross_corr > 0) { - int energy_basis = Inlines.silk_inner_prod_self(basis, basis_ptr, 40); - Inlines.MatrixSet(C, k, d - 14, 132, (short)Inlines.silk_DIV32_varQ(cross_corr, Inlines.silk_ADD32(energy_target, energy_basis), 14)); - continue; - } - Inlines.MatrixSet(C, k, d - 14, 132, (short)0); - } - target_ptr += 40; - } - int CCmax = Integer.MIN_VALUE; - int CCmax_b = Integer.MIN_VALUE; - int CBimax = 0; - int lag = -1; - if (prevLag > 0) { - if (Fs_kHz == 12) { - prevLag = Inlines.silk_DIV32_16(Inlines.silk_LSHIFT(prevLag, 1), 3); - } else if (Fs_kHz == 16) { - prevLag = Inlines.silk_RSHIFT(prevLag, 1); - } - prevLag_log2_Q7 = Inlines.silk_lin2log(prevLag); - } else { - prevLag_log2_Q7 = 0; - } - Inlines.OpusAssert(search_thres2_Q13 == Inlines.silk_SAT16(search_thres2_Q13)); - if (nb_subfr == 4) { - Lag_CB_ptr = SilkTables.silk_CB_lags_stage2; - nb_cbk_search = Fs_kHz == 8 && complexity > 0 ? 11 : 3; - } else { - Lag_CB_ptr = SilkTables.silk_CB_lags_stage2_10_ms; - nb_cbk_search = 3; - } - for (k = 0; k < length_d_srch; ++k) { - d = d_srch[k]; - for (j = 0; j < nb_cbk_search; ++j) { - CC[j] = 0; - for (i = 0; i < nb_subfr; ++i) { - int d_subfr = d + Lag_CB_ptr[i][j]; - CC[j] = CC[j] + Inlines.MatrixGet(C, i, d_subfr - 14, 132); - } - } - CCmax_new = Integer.MIN_VALUE; - int CBimax_new = 0; - for (i = 0; i < nb_cbk_search; ++i) { - if (CC[i] <= CCmax_new) continue; - CCmax_new = CC[i]; - CBimax_new = i; - } - int lag_log2_Q7 = Inlines.silk_lin2log(d); - Inlines.OpusAssert(lag_log2_Q7 == Inlines.silk_SAT16(lag_log2_Q7)); - Inlines.OpusAssert(nb_subfr * 1638 == Inlines.silk_SAT16(nb_subfr * 1638)); - int CCmax_new_b = CCmax_new - Inlines.silk_RSHIFT(Inlines.silk_SMULBB(nb_subfr * 1638, lag_log2_Q7), 7); - Inlines.OpusAssert(nb_subfr * 1638 == Inlines.silk_SAT16(nb_subfr * 1638)); - if (prevLag > 0) { - int delta_lag_log2_sqr_Q7 = lag_log2_Q7 - prevLag_log2_Q7; - Inlines.OpusAssert(delta_lag_log2_sqr_Q7 == Inlines.silk_SAT16(delta_lag_log2_sqr_Q7)); - delta_lag_log2_sqr_Q7 = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(delta_lag_log2_sqr_Q7, delta_lag_log2_sqr_Q7), 7); - int prev_lag_bias_Q13 = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(nb_subfr * 1638, LTPCorr_Q15.Val), 15); - prev_lag_bias_Q13 = Inlines.silk_DIV32(Inlines.silk_MUL(prev_lag_bias_Q13, delta_lag_log2_sqr_Q7), delta_lag_log2_sqr_Q7 + 64); - CCmax_new_b -= prev_lag_bias_Q13; - } - if (CCmax_new_b <= CCmax_b || CCmax_new <= Inlines.silk_SMULBB(nb_subfr, search_thres2_Q13) || SilkTables.silk_CB_lags_stage2[0][CBimax_new] > 16) continue; - CCmax_b = CCmax_new_b; - CCmax = CCmax_new; - lag = d; - CBimax = CBimax_new; - } - if (lag == -1) { - Arrays.MemSet(pitch_out, 0, nb_subfr); - LTPCorr_Q15.Val = 0; - lagIndex.Val = 0; - contourIndex.Val = 0; - return 1; - } - LTPCorr_Q15.Val = Inlines.silk_LSHIFT(Inlines.silk_DIV32_16(CCmax, nb_subfr), 2); - Inlines.OpusAssert(LTPCorr_Q15.Val >= 0); - if (Fs_kHz > 8) { - short[] input_frame_ptr; - boxed_energy.Val = 0; - boxed_shift.Val = 0; - SumSqrShift.silk_sum_sqr_shift(boxed_energy, boxed_shift, frame, frame_length); - energy = boxed_energy.Val; - shift = boxed_shift.Val; - if (shift > 0) { - short[] scratch_mem = new short[frame_length]; - shift = Inlines.silk_RSHIFT(shift, 1); - for (i = 0; i < frame_length; ++i) { - scratch_mem[i] = Inlines.silk_RSHIFT16(frame[i], shift); - } - input_frame_ptr = scratch_mem; - } else { - input_frame_ptr = frame; - } - int CBimax_old = CBimax; - Inlines.OpusAssert(lag == Inlines.silk_SAT16(lag)); - lag = Fs_kHz == 12 ? Inlines.silk_RSHIFT(Inlines.silk_SMULBB(lag, 3), 1) : (Fs_kHz == 16 ? Inlines.silk_LSHIFT(lag, 1) : Inlines.silk_SMULBB(lag, 3)); - lag = Inlines.silk_LIMIT_int(lag, min_lag, max_lag); - int start_lag = Inlines.silk_max_int(lag - 2, min_lag); - int end_lag = Inlines.silk_min_int(lag + 2, max_lag); - int lag_new = lag; - CBimax = 0; - CCmax = Integer.MIN_VALUE; - for (k = 0; k < nb_subfr; ++k) { - pitch_out[k] = lag + 2 * SilkTables.silk_CB_lags_stage2[k][CBimax_old]; - } - if (nb_subfr == 4) { - nb_cbk_search = SilkTables.silk_nb_cbk_searchs_stage3[complexity]; - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3; - } else { - nb_cbk_search = 12; - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3_10_ms; - } - silk_pe_stage3_vals[] energies_st3 = new silk_pe_stage3_vals[nb_subfr * nb_cbk_search]; - silk_pe_stage3_vals[] cross_corr_st3 = new silk_pe_stage3_vals[nb_subfr * nb_cbk_search]; - for (int c = 0; c < nb_subfr * nb_cbk_search; ++c) { - energies_st3[c] = new silk_pe_stage3_vals(); - cross_corr_st3[c] = new silk_pe_stage3_vals(); - } - PitchAnalysisCore.silk_P_Ana_calc_corr_st3(cross_corr_st3, input_frame_ptr, start_lag, sf_length, nb_subfr, complexity); - PitchAnalysisCore.silk_P_Ana_calc_energy_st3(energies_st3, input_frame_ptr, start_lag, sf_length, nb_subfr, complexity); - int lag_counter = 0; - Inlines.OpusAssert(lag == Inlines.silk_SAT16(lag)); - int contour_bias_Q15 = Inlines.silk_DIV32_16(1638, lag); - target = input_frame_ptr; - target_ptr = 20 * Fs_kHz; - energy_target = Inlines.silk_ADD32(Inlines.silk_inner_prod_self(target, target_ptr, nb_subfr * sf_length), 1); - for (d = start_lag; d <= end_lag; ++d) { - for (j = 0; j < nb_cbk_search; ++j) { - cross_corr = 0; - energy = energy_target; - for (k = 0; k < nb_subfr; ++k) { - cross_corr = Inlines.silk_ADD32(cross_corr, Inlines.MatrixGet((silk_pe_stage3_vals[])cross_corr_st3, (int)k, (int)j, (int)nb_cbk_search).Values[lag_counter]); - Inlines.OpusAssert((energy = Inlines.silk_ADD32(energy, Inlines.MatrixGet((silk_pe_stage3_vals[])energies_st3, (int)k, (int)j, (int)nb_cbk_search).Values[lag_counter])) >= 0); - } - if (cross_corr > 0) { - CCmax_new = Inlines.silk_DIV32_varQ(cross_corr, energy, 14); - int diff = Short.MAX_VALUE - Inlines.silk_MUL(contour_bias_Q15, j); - Inlines.OpusAssert(diff == Inlines.silk_SAT16(diff)); - CCmax_new = Inlines.silk_SMULWB(CCmax_new, diff); - } else { - CCmax_new = 0; - } - if (CCmax_new <= CCmax || d + SilkTables.silk_CB_lags_stage3[0][j] > max_lag) continue; - CCmax = CCmax_new; - lag_new = d; - CBimax = j; - } - ++lag_counter; - } - for (k = 0; k < nb_subfr; ++k) { - pitch_out[k] = lag_new + Lag_CB_ptr[k][CBimax]; - pitch_out[k] = Inlines.silk_LIMIT(pitch_out[k], min_lag, 18 * Fs_kHz); - } - lagIndex.Val = (short)(lag_new - min_lag); - contourIndex.Val = (byte)CBimax; - } else { - for (k = 0; k < nb_subfr; ++k) { - pitch_out[k] = lag + Lag_CB_ptr[k][CBimax]; - pitch_out[k] = Inlines.silk_LIMIT(pitch_out[k], 16, 144); - } - lagIndex.Val = (short)(lag - 16); - contourIndex.Val = (byte)CBimax; - } - Inlines.OpusAssert(lagIndex.Val >= 0); - return 0; - } - - private static void silk_P_Ana_calc_corr_st3(silk_pe_stage3_vals[] cross_corr_st3, short[] frame, int start_lag, int sf_length, int nb_subfr, int complexity) { - int nb_cbk_search; - byte[][] Lag_CB_ptr; - byte[][] Lag_range_ptr; - Inlines.OpusAssert(complexity >= 0); - Inlines.OpusAssert(complexity <= 2); - if (nb_subfr == 4) { - Lag_range_ptr = SilkTables.silk_Lag_range_stage3[complexity]; - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3; - nb_cbk_search = SilkTables.silk_nb_cbk_searchs_stage3[complexity]; - } else { - Inlines.OpusAssert(nb_subfr == 2); - Lag_range_ptr = SilkTables.silk_Lag_range_stage3_10_ms; - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3_10_ms; - nb_cbk_search = 12; - } - int[] scratch_mem = new int[22]; - int[] xcorr32 = new int[22]; - int target_ptr = Inlines.silk_LSHIFT(sf_length, 2); - for (int k = 0; k < nb_subfr; ++k) { - int j; - int lag_counter = 0; - byte lag_high = Lag_range_ptr[k][1]; - int lag_low = Lag_range_ptr[k][0]; - Inlines.OpusAssert(lag_high - lag_low + 1 <= 22); - CeltPitchXCorr.pitch_xcorr(frame, target_ptr, frame, target_ptr - start_lag - lag_high, xcorr32, sf_length, lag_high - lag_low + 1); - for (j = lag_low; j <= lag_high; ++j) { - Inlines.OpusAssert(lag_counter < 22); - scratch_mem[lag_counter] = xcorr32[lag_high - j]; - ++lag_counter; - } - byte delta = Lag_range_ptr[k][0]; - for (int i = 0; i < nb_cbk_search; ++i) { - int idx = Lag_CB_ptr[k][i] - delta; - for (j = 0; j < 5; ++j) { - Inlines.OpusAssert(idx + j < 22); - Inlines.OpusAssert(idx + j < lag_counter); - Inlines.MatrixGet((silk_pe_stage3_vals[])cross_corr_st3, (int)k, (int)i, (int)nb_cbk_search).Values[j] = scratch_mem[idx + j]; - } - } - target_ptr += sf_length; - } - } - - static void silk_P_Ana_calc_energy_st3(silk_pe_stage3_vals[] energies_st3, short[] frame, int start_lag, int sf_length, int nb_subfr, int complexity) { - int nb_cbk_search; - byte[][] Lag_CB_ptr; - byte[][] Lag_range_ptr; - Inlines.OpusAssert(complexity >= 0); - Inlines.OpusAssert(complexity <= 2); - if (nb_subfr == 4) { - Lag_range_ptr = SilkTables.silk_Lag_range_stage3[complexity]; - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3; - nb_cbk_search = SilkTables.silk_nb_cbk_searchs_stage3[complexity]; - } else { - Inlines.OpusAssert(nb_subfr == 2); - Lag_range_ptr = SilkTables.silk_Lag_range_stage3_10_ms; - Lag_CB_ptr = SilkTables.silk_CB_lags_stage3_10_ms; - nb_cbk_search = 12; - } - int[] scratch_mem = new int[22]; - int target_ptr = Inlines.silk_LSHIFT(sf_length, 2); - for (int k = 0; k < nb_subfr; ++k) { - int i; - int lag_counter = 0; - int basis_ptr = target_ptr - (start_lag + Lag_range_ptr[k][0]); - int energy = Inlines.silk_inner_prod_self(frame, basis_ptr, sf_length); - Inlines.OpusAssert(energy >= 0); - scratch_mem[lag_counter] = energy; - ++lag_counter; - int lag_diff = Lag_range_ptr[k][1] - Lag_range_ptr[k][0] + 1; - for (i = 1; i < lag_diff; ++i) { - Inlines.OpusAssert((energy -= Inlines.silk_SMULBB(frame[basis_ptr + sf_length - i], frame[basis_ptr + sf_length - i])) >= 0); - energy = Inlines.silk_ADD_SAT32(energy, Inlines.silk_SMULBB(frame[basis_ptr - i], frame[basis_ptr - i])); - Inlines.OpusAssert(energy >= 0); - Inlines.OpusAssert(lag_counter < 22); - scratch_mem[lag_counter] = energy; - ++lag_counter; - } - byte delta = Lag_range_ptr[k][0]; - for (i = 0; i < nb_cbk_search; ++i) { - int idx = Lag_CB_ptr[k][i] - delta; - for (int j = 0; j < 5; ++j) { - Inlines.OpusAssert(idx + j < 22); - Inlines.OpusAssert(idx + j < lag_counter); - Inlines.MatrixGet((silk_pe_stage3_vals[])energies_st3, (int)k, (int)i, (int)nb_cbk_search).Values[j] = scratch_mem[idx + j]; - Inlines.OpusAssert(Inlines.MatrixGet((silk_pe_stage3_vals[])energies_st3, (int)k, (int)i, (int)nb_cbk_search).Values[j] >= 0); - } - } - target_ptr += sf_length; - } - } - - static class silk_pe_stage3_vals { - public final int[] Values = new int[5]; - - silk_pe_stage3_vals() { - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/ProcessGains.java b/source/decompiled/de/maxhenkel/voicechat/concentus/ProcessGains.java deleted file mode 100644 index 81f0500..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/ProcessGains.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.GainQuantization; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Sigmoid; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; -import de.maxhenkel.voicechat.concentus.SilkShapeState; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class ProcessGains { - ProcessGains() { - } - - static void silk_process_gains(SilkChannelEncoder psEnc, SilkEncoderControl psEncCtrl, int condCoding) { - int k; - SilkShapeState psShapeSt = psEnc.sShape; - if (psEnc.indices.signalType == 2) { - int s_Q16 = 0 - Sigmoid.silk_sigm_Q15(Inlines.silk_RSHIFT_ROUND(psEncCtrl.LTPredCodGain_Q7 - 1536, 4)); - for (k = 0; k < psEnc.nb_subfr; ++k) { - psEncCtrl.Gains_Q16[k] = Inlines.silk_SMLAWB(psEncCtrl.Gains_Q16[k], psEncCtrl.Gains_Q16[k], s_Q16); - } - } - int InvMaxSqrVal_Q16 = Inlines.silk_DIV32_16(Inlines.silk_log2lin(Inlines.silk_SMULWB(8894 - psEnc.SNR_dB_Q7, 21627)), psEnc.subfr_length); - for (k = 0; k < psEnc.nb_subfr; ++k) { - int gain; - int ResNrg = psEncCtrl.ResNrg[k]; - int ResNrgPart = Inlines.silk_SMULWW(ResNrg, InvMaxSqrVal_Q16); - ResNrgPart = psEncCtrl.ResNrgQ[k] > 0 ? Inlines.silk_RSHIFT_ROUND(ResNrgPart, psEncCtrl.ResNrgQ[k]) : (ResNrgPart >= Inlines.silk_RSHIFT(Integer.MAX_VALUE, -psEncCtrl.ResNrgQ[k]) ? Integer.MAX_VALUE : Inlines.silk_LSHIFT(ResNrgPart, -psEncCtrl.ResNrgQ[k])); - int gain_squared = Inlines.silk_ADD_SAT32(ResNrgPart, Inlines.silk_SMMUL(gain = psEncCtrl.Gains_Q16[k], gain)); - if (gain_squared < Short.MAX_VALUE) { - gain_squared = Inlines.silk_SMLAWW(Inlines.silk_LSHIFT(ResNrgPart, 16), gain, gain); - Inlines.OpusAssert(gain_squared > 0); - gain = Inlines.silk_SQRT_APPROX(gain_squared); - gain = Inlines.silk_min(gain, 0x7FFFFF); - psEncCtrl.Gains_Q16[k] = Inlines.silk_LSHIFT_SAT32(gain, 8); - continue; - } - gain = Inlines.silk_SQRT_APPROX(gain_squared); - gain = Inlines.silk_min(gain, Short.MAX_VALUE); - psEncCtrl.Gains_Q16[k] = Inlines.silk_LSHIFT_SAT32(gain, 16); - } - System.arraycopy(psEncCtrl.Gains_Q16, 0, psEncCtrl.GainsUnq_Q16, 0, psEnc.nb_subfr); - psEncCtrl.lastGainIndexPrev = psShapeSt.LastGainIndex; - BoxedValueByte boxed_lastGainIndex = new BoxedValueByte(psShapeSt.LastGainIndex); - GainQuantization.silk_gains_quant(psEnc.indices.GainsIndices, psEncCtrl.Gains_Q16, boxed_lastGainIndex, condCoding == 2 ? 1 : 0, psEnc.nb_subfr); - psShapeSt.LastGainIndex = boxed_lastGainIndex.Val; - if (psEnc.indices.signalType == 2) { - psEnc.indices.quantOffsetType = psEncCtrl.LTPredCodGain_Q7 + Inlines.silk_RSHIFT(psEnc.input_tilt_Q15, 8) > 128 ? (byte)0 : 1; - } - short quant_offset_Q10 = SilkTables.silk_Quantization_Offsets_Q10[psEnc.indices.signalType >> 1][psEnc.indices.quantOffsetType]; - psEncCtrl.Lambda_Q10 = 1229 + Inlines.silk_SMULBB(-50, psEnc.nStatesDelayedDecision) + Inlines.silk_SMULWB(-52428, psEnc.speech_activity_Q8) + Inlines.silk_SMULWB(-409, psEncCtrl.input_quality_Q14) + Inlines.silk_SMULWB(-818, psEncCtrl.coding_quality_Q14) + Inlines.silk_SMULWB(52429, quant_offset_Q10); - Inlines.OpusAssert(psEncCtrl.Lambda_Q10 > 0); - Inlines.OpusAssert(psEncCtrl.Lambda_Q10 < 2048); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/PulseCache.java b/source/decompiled/de/maxhenkel/voicechat/concentus/PulseCache.java deleted file mode 100644 index 52fff55..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/PulseCache.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class PulseCache { - int size = 0; - short[] index = null; - short[] bits = null; - short[] caps = null; - - PulseCache() { - } - - void Reset() { - this.size = 0; - this.index = null; - this.bits = null; - this.caps = null; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/QuantizeBands.java b/source/decompiled/de/maxhenkel/voicechat/concentus/QuantizeBands.java deleted file mode 100644 index d35030c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/QuantizeBands.java +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.CeltTables; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Laplace; - -class QuantizeBands { - private static final int[] pred_coef = new int[]{29440, 26112, 21248, 16384}; - private static final int[] beta_coef = new int[]{30147, 22282, 12124, 6554}; - private static final int beta_intra = 4915; - private static short[] small_energy_icdf = new short[]{2, 1, 0}; - - QuantizeBands() { - } - - static int loss_distortion(int[][] eBands, int[][] oldEBands, int start, int end, int len, int C) { - int dist = 0; - int c = 0; - do { - for (int i = start; i < end; ++i) { - int d = Inlines.SUB16(Inlines.SHR16(eBands[c][i], 3), Inlines.SHR16(oldEBands[c][i], 3)); - dist = Inlines.MAC16_16(dist, d, d); - } - } while (++c < C); - return Inlines.MIN32(200, Inlines.SHR32(dist, 14)); - } - - static int quant_coarse_energy_impl(CeltMode m, int start, int end, int[][] eBands, int[][] oldEBands, int budget, int tell, short[] prob_model, int[][] error, EntropyCoder enc, int C, int LM, int intra, int max_decay, int lfe) { - int beta; - int coef; - int badness = 0; - int[] prev = new int[]{0, 0}; - if (tell + 3 <= budget) { - enc.enc_bit_logp(intra, 3); - } - if (intra != 0) { - coef = 0; - beta = 4915; - } else { - beta = beta_coef[LM]; - coef = pred_coef[LM]; - } - for (int i = start; i < end; ++i) { - int c = 0; - do { - int x = eBands[c][i]; - int oldE = Inlines.MAX16(-9216, oldEBands[c][i]); - int f = Inlines.SHL32(Inlines.EXTEND32(x), 7) - Inlines.PSHR32(Inlines.MULT16_16(coef, oldE), 8) - prev[c]; - int qi = f + 65536 >> 17; - short decay_bound = Inlines.EXTRACT16(Inlines.MAX32(-28672, Inlines.SUB32(oldEBands[c][i], max_decay))); - if (qi < 0 && x < decay_bound && (qi += Inlines.SHR16(Inlines.SUB16((int)decay_bound, x), 10)) > 0) { - qi = 0; - } - int qi0 = qi; - tell = enc.tell(); - int bits_left = budget - tell - 3 * C * (end - i); - if (i != start && bits_left < 30) { - if (bits_left < 24) { - qi = Inlines.IMIN(1, qi); - } - if (bits_left < 16) { - qi = Inlines.IMAX(-1, qi); - } - } - if (lfe != 0 && i >= 2) { - qi = Inlines.IMIN(qi, 0); - } - if (budget - tell >= 15) { - int pi = 2 * Inlines.IMIN(i, 20); - BoxedValueInt boxed_qi = new BoxedValueInt(qi); - Laplace.ec_laplace_encode(enc, boxed_qi, prob_model[pi] << 7, prob_model[pi + 1] << 6); - qi = boxed_qi.Val; - } else if (budget - tell >= 2) { - enc.enc_icdf(2 * qi ^ 0 - ((qi = Inlines.IMAX(-1, Inlines.IMIN(qi, 1))) < 0 ? 1 : 0), small_energy_icdf, 2); - } else if (budget - tell >= 1) { - qi = Inlines.IMIN(0, qi); - enc.enc_bit_logp(-qi, 1); - } else { - qi = -1; - } - error[c][i] = Inlines.PSHR32(f, 7) - Inlines.SHL16(qi, 10); - badness += Inlines.abs(qi0 - qi); - int q = Inlines.SHL32(qi, 10); - int tmp = Inlines.PSHR32(Inlines.MULT16_16(coef, oldE), 8) + prev[c] + Inlines.SHL32(q, 7); - tmp = Inlines.MAX32(-3670016, tmp); - oldEBands[c][i] = Inlines.PSHR32(tmp, 7); - prev[c] = prev[c] + Inlines.SHL32(q, 7) - Inlines.MULT16_16(beta, Inlines.PSHR32(q, 8)); - } while (++c < C); - } - return lfe != 0 ? 0 : badness; - } - - static void quant_coarse_energy(CeltMode m, int start, int end, int effEnd, int[][] eBands, int[][] oldEBands, int budget, int[][] error, EntropyCoder enc, int C, int LM, int nbAvailableBytes, int force_intra, BoxedValueInt delayedIntra, int two_pass, int loss_rate, int lfe) { - EntropyCoder enc_start_state = new EntropyCoder(); - int badness1 = 0; - int intra = force_intra != 0 || two_pass == 0 && delayedIntra.Val > 2 * C * (end - start) && nbAvailableBytes > (end - start) * C ? 1 : 0; - int intra_bias = budget * delayedIntra.Val * loss_rate / (C * 512); - int new_distortion = QuantizeBands.loss_distortion(eBands, oldEBands, start, effEnd, m.nbEBands, C); - int tell = enc.tell(); - if (tell + 3 > budget) { - intra = 0; - two_pass = 0; - } - int max_decay = 16384; - if (end - start > 10) { - max_decay = Inlines.MIN32(max_decay, Inlines.SHL32(nbAvailableBytes, 7)); - } - if (lfe != 0) { - max_decay = 3072; - } - enc_start_state.Assign(enc); - int[][] oldEBands_intra = Arrays.InitTwoDimensionalArrayInt(C, m.nbEBands); - int[][] error_intra = Arrays.InitTwoDimensionalArrayInt(C, m.nbEBands); - System.arraycopy(oldEBands[0], 0, oldEBands_intra[0], 0, m.nbEBands); - if (C == 2) { - System.arraycopy(oldEBands[1], 0, oldEBands_intra[1], 0, m.nbEBands); - } - if (two_pass != 0 || intra != 0) { - badness1 = QuantizeBands.quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra, budget, tell, CeltTables.e_prob_model[LM][1], error_intra, enc, C, LM, 1, max_decay, lfe); - } - if (intra == 0) { - EntropyCoder enc_intra_state = new EntropyCoder(); - byte[] intra_bits = null; - int tell_intra = enc.tell_frac(); - enc_intra_state.Assign(enc); - int nstart_bytes = enc_start_state.range_bytes(); - int nintra_bytes = enc_intra_state.range_bytes(); - int intra_buf = nstart_bytes; - int save_bytes = nintra_bytes - nstart_bytes; - if (save_bytes != 0) { - intra_bits = new byte[save_bytes]; - System.arraycopy(enc_intra_state.get_buffer(), intra_buf, intra_bits, 0, save_bytes); - } - enc.Assign(enc_start_state); - int badness2 = QuantizeBands.quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget, tell, CeltTables.e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay, lfe); - if (two_pass != 0 && (badness1 < badness2 || badness1 == badness2 && enc.tell_frac() + intra_bias > tell_intra)) { - enc.Assign(enc_intra_state); - if (intra_bits != null) { - enc_intra_state.write_buffer(intra_bits, 0, intra_buf, nintra_bytes - nstart_bytes); - } - System.arraycopy(oldEBands_intra[0], 0, oldEBands[0], 0, m.nbEBands); - System.arraycopy(error_intra[0], 0, error[0], 0, m.nbEBands); - if (C == 2) { - System.arraycopy(oldEBands_intra[1], 0, oldEBands[1], 0, m.nbEBands); - System.arraycopy(error_intra[1], 0, error[1], 0, m.nbEBands); - } - intra = 1; - } - } else { - System.arraycopy(oldEBands_intra[0], 0, oldEBands[0], 0, m.nbEBands); - System.arraycopy(error_intra[0], 0, error[0], 0, m.nbEBands); - if (C == 2) { - System.arraycopy(oldEBands_intra[1], 0, oldEBands[1], 0, m.nbEBands); - System.arraycopy(error_intra[1], 0, error[1], 0, m.nbEBands); - } - } - delayedIntra.Val = intra != 0 ? new_distortion : Inlines.ADD32(Inlines.MULT16_32_Q15(Inlines.MULT16_16_Q15(pred_coef[LM], pred_coef[LM]), delayedIntra.Val), new_distortion); - } - - static void quant_fine_energy(CeltMode m, int start, int end, int[][] oldEBands, int[][] error, int[] fine_quant, EntropyCoder enc, int C) { - for (int i = start; i < end; ++i) { - int frac = 1 << fine_quant[i]; - if (fine_quant[i] <= 0) continue; - int c = 0; - do { - int q2; - if ((q2 = error[c][i] + 512 >> 10 - fine_quant[i]) > frac - 1) { - q2 = frac - 1; - } - if (q2 < 0) { - q2 = 0; - } - enc.enc_bits(q2, fine_quant[i]); - int offset = Inlines.SUB16(Inlines.SHR32(Inlines.SHL32(q2, 10) + 512, fine_quant[i]), 512); - int[] nArray = oldEBands[c]; - int n = i; - nArray[n] = nArray[n] + offset; - int[] nArray2 = error[c]; - int n2 = i; - nArray2[n2] = nArray2[n2] - offset; - } while (++c < C); - } - } - - static void quant_energy_finalise(CeltMode m, int start, int end, int[][] oldEBands, int[][] error, int[] fine_quant, int[] fine_priority, int bits_left, EntropyCoder enc, int C) { - for (int prio = 0; prio < 2; ++prio) { - for (int i = start; i < end && bits_left >= C; ++i) { - if (fine_quant[i] >= 8 || fine_priority[i] != prio) continue; - int c = 0; - do { - int q2 = error[c][i] < 0 ? 0 : 1; - enc.enc_bits(q2, 1); - int offset = Inlines.SHR16(Inlines.SHL16(q2, 10) - 512, fine_quant[i] + 1); - int[] nArray = oldEBands[c]; - int n = i; - nArray[n] = nArray[n] + offset; - --bits_left; - } while (++c < C); - } - } - } - - static void unquant_coarse_energy(CeltMode m, int start, int end, int[] oldEBands, int intra, EntropyCoder dec, int C, int LM) { - int beta; - int coef; - short[] prob_model = CeltTables.e_prob_model[LM][intra]; - int[] prev = new int[]{0, 0}; - if (intra != 0) { - coef = 0; - beta = 4915; - } else { - beta = beta_coef[LM]; - coef = pred_coef[LM]; - } - int budget = dec.storage * 8; - for (int i = start; i < end; ++i) { - int c = 0; - do { - int qi; - Inlines.OpusAssert(c < 2); - int tell = dec.tell(); - if (budget - tell >= 15) { - int pi = 2 * Inlines.IMIN(i, 20); - qi = Laplace.ec_laplace_decode(dec, prob_model[pi] << 7, prob_model[pi + 1] << 6); - } else if (budget - tell >= 2) { - qi = dec.dec_icdf(small_energy_icdf, 2); - qi = qi >> 1 ^ -(qi & 1); - } else { - qi = budget - tell >= 1 ? 0 - dec.dec_bit_logp(1L) : -1; - } - int q = Inlines.SHL32(qi, 10); - oldEBands[i + c * m.nbEBands] = Inlines.MAX16(-9216, oldEBands[i + c * m.nbEBands]); - int tmp = Inlines.PSHR32(Inlines.MULT16_16(coef, oldEBands[i + c * m.nbEBands]), 8) + prev[c] + Inlines.SHL32(q, 7); - tmp = Inlines.MAX32(-3670016, tmp); - oldEBands[i + c * m.nbEBands] = Inlines.PSHR32(tmp, 7); - prev[c] = prev[c] + Inlines.SHL32(q, 7) - Inlines.MULT16_16(beta, Inlines.PSHR32(q, 8)); - } while (++c < C); - } - } - - static void unquant_fine_energy(CeltMode m, int start, int end, int[] oldEBands, int[] fine_quant, EntropyCoder dec, int C) { - for (int i = start; i < end; ++i) { - if (fine_quant[i] <= 0) continue; - int c = 0; - do { - int q2 = dec.dec_bits(fine_quant[i]); - int offset = Inlines.SUB16(Inlines.SHR32(Inlines.SHL32(q2, 10) + 512, fine_quant[i]), 512); - int n = i + c * m.nbEBands; - oldEBands[n] = oldEBands[n] + offset; - } while (++c < C); - } - } - - static void unquant_energy_finalise(CeltMode m, int start, int end, int[] oldEBands, int[] fine_quant, int[] fine_priority, int bits_left, EntropyCoder dec, int C) { - for (int prio = 0; prio < 2; ++prio) { - for (int i = start; i < end && bits_left >= C; ++i) { - if (fine_quant[i] >= 8 || fine_priority[i] != prio) continue; - int c = 0; - do { - int q2 = dec.dec_bits(1); - int offset = Inlines.SHR16(Inlines.SHL16(q2, 10) - 512, fine_quant[i] + 1); - int n = i + c * m.nbEBands; - oldEBands[n] = oldEBands[n] + offset; - --bits_left; - } while (++c < C); - } - } - } - - static void amp2Log2(CeltMode m, int effEnd, int end, int[][] bandE, int[][] bandLogE, int C) { - int c = 0; - do { - int i; - for (i = 0; i < effEnd; ++i) { - bandLogE[c][i] = Inlines.celt_log2(Inlines.SHL32(bandE[c][i], 2)) - Inlines.SHL16((int)CeltTables.eMeans[i], 6); - } - for (i = effEnd; i < end; ++i) { - bandLogE[c][i] = -14336; - } - } while (++c < C); - } - - static void amp2Log2(CeltMode m, int effEnd, int end, int[] bandE, int[] bandLogE, int bandLogE_ptr, int C) { - int c = 0; - do { - int i; - for (i = 0; i < effEnd; ++i) { - bandLogE[bandLogE_ptr + c * m.nbEBands + i] = Inlines.celt_log2(Inlines.SHL32(bandE[i + c * m.nbEBands], 2)) - Inlines.SHL16((int)CeltTables.eMeans[i], 6); - } - for (i = effEnd; i < end; ++i) { - bandLogE[bandLogE_ptr + c * m.nbEBands + i] = -14336; - } - } while (++c < C); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/QuantizeLTPGains.java b/source/decompiled/de/maxhenkel/voicechat/concentus/QuantizeLTPGains.java deleted file mode 100644 index 0c76fd2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/QuantizeLTPGains.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.VQ_WMat_EC; - -class QuantizeLTPGains { - QuantizeLTPGains() { - } - - static void silk_quant_LTP_gains(short[] B_Q14, byte[] cbk_index, BoxedValueByte periodicity_index, BoxedValueInt sum_log_gain_Q7, int[] W_Q18, int mu_Q9, int lowComplexity, int nb_subfr) { - int j; - byte[][] cbk_ptr_Q7; - int k; - byte[] temp_idx = new byte[4]; - int min_rate_dist_Q14 = Integer.MAX_VALUE; - int best_sum_log_gain_Q7 = 0; - for (k = 0; k < 3; ++k) { - int gain_safety = 51; - short[] cl_ptr_Q5 = SilkTables.silk_LTP_gain_BITS_Q5_ptrs[k]; - cbk_ptr_Q7 = SilkTables.silk_LTP_vq_ptrs_Q7[k]; - short[] cbk_gain_ptr_Q7 = SilkTables.silk_LTP_vq_gain_ptrs_Q7[k]; - byte cbk_size = SilkTables.silk_LTP_vq_sizes[k]; - int W_Q18_ptr = 0; - int b_Q14_ptr = 0; - int rate_dist_Q14 = 0; - int sum_log_gain_tmp_Q7 = sum_log_gain_Q7.Val; - for (j = 0; j < nb_subfr; ++j) { - int max_gain_Q7 = Inlines.silk_log2lin(5333 - sum_log_gain_tmp_Q7 + 896) - gain_safety; - BoxedValueByte temp_idx_box = new BoxedValueByte(temp_idx[j]); - BoxedValueInt rate_dist_Q14_subfr_box = new BoxedValueInt(0); - BoxedValueInt gain_Q7_box = new BoxedValueInt(0); - VQ_WMat_EC.silk_VQ_WMat_EC(temp_idx_box, rate_dist_Q14_subfr_box, gain_Q7_box, B_Q14, b_Q14_ptr, W_Q18, W_Q18_ptr, cbk_ptr_Q7, cbk_gain_ptr_Q7, cl_ptr_Q5, mu_Q9, max_gain_Q7, cbk_size); - int rate_dist_Q14_subfr = rate_dist_Q14_subfr_box.Val; - int gain_Q7 = gain_Q7_box.Val; - temp_idx[j] = temp_idx_box.Val; - rate_dist_Q14 = Inlines.silk_ADD_POS_SAT32(rate_dist_Q14, rate_dist_Q14_subfr); - sum_log_gain_tmp_Q7 = Inlines.silk_max(0, sum_log_gain_tmp_Q7 + Inlines.silk_lin2log(gain_safety + gain_Q7) - 896); - b_Q14_ptr += 5; - W_Q18_ptr += 25; - } - if ((rate_dist_Q14 = Inlines.silk_min(0x7FFFFFFE, rate_dist_Q14)) < min_rate_dist_Q14) { - min_rate_dist_Q14 = rate_dist_Q14; - periodicity_index.Val = (byte)k; - System.arraycopy(temp_idx, 0, cbk_index, 0, nb_subfr); - best_sum_log_gain_Q7 = sum_log_gain_tmp_Q7; - } - if (lowComplexity != 0 && rate_dist_Q14 < 12304) break; - } - cbk_ptr_Q7 = SilkTables.silk_LTP_vq_ptrs_Q7[periodicity_index.Val]; - for (j = 0; j < nb_subfr; ++j) { - for (k = 0; k < 5; ++k) { - B_Q14[j * 5 + k] = (short)Inlines.silk_LSHIFT(cbk_ptr_Q7[cbk_index[j]][k], 7); - } - } - sum_log_gain_Q7.Val = best_sum_log_gain_Q7; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Rate.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Rate.java deleted file mode 100644 index ff2327d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Rate.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CeltMode; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; - -class Rate { - private static final byte[] LOG2_FRAC_TABLE = new byte[]{0, 8, 13, 16, 19, 21, 23, 24, 26, 27, 28, 29, 30, 31, 32, 32, 33, 34, 34, 35, 36, 36, 37, 37}; - private static final int ALLOC_STEPS = 6; - - Rate() { - } - - static int get_pulses(int i) { - return i < 8 ? i : 8 + (i & 7) << (i >> 3) - 1; - } - - static int bits2pulses(CeltMode m, int band, int LM, int bits) { - short[] cache = m.cache.bits; - short cache_ptr = m.cache.index[++LM * m.nbEBands + band]; - int lo = 0; - int hi = cache[cache_ptr]; - --bits; - for (int i = 0; i < 6; ++i) { - int mid = lo + hi + 1 >> 1; - if (cache[cache_ptr + mid] >= bits) { - hi = mid; - continue; - } - lo = mid; - } - if (bits - (lo == 0 ? -1 : cache[cache_ptr + lo]) <= cache[cache_ptr + hi] - bits) { - return lo; - } - return hi; - } - - static int pulses2bits(CeltMode m, int band, int LM, int pulses) { - return pulses == 0 ? 0 : m.cache.bits[m.cache.index[++LM * m.nbEBands + band] + pulses] + 1; - } - - static int interp_bits2pulses(CeltMode m, int start, int end, int skip_start, int[] bits1, int[] bits2, int[] thresh, int[] cap, int total, BoxedValueInt _balance, int skip_rsv, BoxedValueInt intensity, int intensity_rsv, BoxedValueInt dual_stereo, int dual_stereo_rsv, int[] bits, int[] ebits, int[] fine_priority, int C, int LM, EntropyCoder ec, int encode, int prev, int signalBandwidth) { - int percoeff; - int left; - int tmp; - int j; - boolean done; - int psum; - int codedBands = -1; - int alloc_floor = C << 3; - int stereo = C > 1 ? 1 : 0; - int logM = LM << 3; - int lo = 0; - int hi = 64; - for (int i = 0; i < 6; ++i) { - int mid = lo + hi >> 1; - psum = 0; - done = false; - j = end; - while (j-- > start) { - int tmp2 = bits1[j] + (mid * bits2[j] >> 6); - if (tmp2 >= thresh[j] || done) { - done = true; - psum += Inlines.IMIN(tmp2, cap[j]); - continue; - } - if (tmp2 < alloc_floor) continue; - psum += alloc_floor; - } - if (psum > total) { - hi = mid; - continue; - } - lo = mid; - } - psum = 0; - done = false; - j = end; - while (j-- > start) { - tmp = bits1[j] + (lo * bits2[j] >> 6); - if (tmp < thresh[j] && !done) { - tmp = tmp >= alloc_floor ? alloc_floor : 0; - } else { - done = true; - } - bits[j] = tmp = Inlines.IMIN(tmp, cap[j]); - psum += tmp; - } - codedBands = end; - while (true) { - int rem; - int band_width; - if ((j = codedBands - 1) <= skip_start) { - total += skip_rsv; - break; - } - left = total - psum; - percoeff = Inlines.celt_udiv(left, m.eBands[codedBands] - m.eBands[start]); - int band_bits = bits[j] + percoeff * (band_width = m.eBands[codedBands] - m.eBands[j]) + (rem = Inlines.IMAX((left -= (m.eBands[codedBands] - m.eBands[start]) * percoeff) - (m.eBands[j] - m.eBands[start]), 0)); - if (band_bits >= Inlines.IMAX(thresh[j], alloc_floor + 8)) { - if (encode != 0) { - if (codedBands <= start + 2 || band_bits > (j < prev ? 7 : 9) * band_width << LM << 3 >> 4 && j <= signalBandwidth) { - ec.enc_bit_logp(1, 1); - break; - } - ec.enc_bit_logp(0, 1); - } else if (ec.dec_bit_logp(1L) != 0) break; - psum += 8; - band_bits -= 8; - } - psum -= bits[j] + intensity_rsv; - if (intensity_rsv > 0) { - intensity_rsv = LOG2_FRAC_TABLE[j - start]; - } - psum += intensity_rsv; - if (band_bits >= alloc_floor) { - psum += alloc_floor; - bits[j] = alloc_floor; - } else { - bits[j] = 0; - } - --codedBands; - } - Inlines.OpusAssert(codedBands > start); - if (intensity_rsv > 0) { - if (encode != 0) { - intensity.Val = Inlines.IMIN(intensity.Val, codedBands); - ec.enc_uint(intensity.Val - start, codedBands + 1 - start); - } else { - intensity.Val = start + (int)ec.dec_uint(codedBands + 1 - start); - } - } else { - intensity.Val = 0; - } - if (intensity.Val <= start) { - total += dual_stereo_rsv; - dual_stereo_rsv = 0; - } - if (dual_stereo_rsv > 0) { - if (encode != 0) { - ec.enc_bit_logp(dual_stereo.Val, 1); - } else { - dual_stereo.Val = ec.dec_bit_logp(1L); - } - } else { - dual_stereo.Val = 0; - } - left = total - psum; - percoeff = Inlines.celt_udiv(left, m.eBands[codedBands] - m.eBands[start]); - left -= (m.eBands[codedBands] - m.eBands[start]) * percoeff; - for (j = start; j < codedBands; ++j) { - int n = j; - bits[n] = bits[n] + percoeff * (m.eBands[j + 1] - m.eBands[j]); - } - j = start; - while (j < codedBands) { - tmp = Inlines.IMIN(left, m.eBands[j + 1] - m.eBands[j]); - int n = j++; - bits[n] = bits[n] + tmp; - left -= tmp; - } - int balance = 0; - for (j = start; j < codedBands; ++j) { - int excess; - Inlines.OpusAssert(bits[j] >= 0); - int N0 = m.eBands[j + 1] - m.eBands[j]; - int N = N0 << LM; - int bit = bits[j] + balance; - if (N > 1) { - excess = Inlines.MAX32(bit - cap[j], 0); - bits[j] = bit - excess; - int den = C * N + (C == 2 && N > 2 && dual_stereo.Val == 0 && j < intensity.Val ? 1 : 0); - int NClogN = den * (m.logN[j] + logM); - int offset = (NClogN >> 1) - den * 21; - if (N == 2) { - offset += den << 3 >> 2; - } - if (bits[j] + offset < den * 2 << 3) { - offset += NClogN >> 2; - } else if (bits[j] + offset < den * 3 << 3) { - offset += NClogN >> 3; - } - ebits[j] = Inlines.IMAX(0, bits[j] + offset + (den << 2)); - ebits[j] = Inlines.celt_udiv(ebits[j], den) >> 3; - if (C * ebits[j] > bits[j] >> 3) { - ebits[j] = bits[j] >> stereo >> 3; - } - ebits[j] = Inlines.IMIN(ebits[j], 8); - fine_priority[j] = ebits[j] * (den << 3) >= bits[j] + offset ? 1 : 0; - int n = j; - bits[n] = bits[n] - (C * ebits[j] << 3); - } else { - excess = Inlines.MAX32(0, bit - (C << 3)); - bits[j] = bit - excess; - ebits[j] = 0; - fine_priority[j] = 1; - } - if (excess > 0) { - int extra_fine = Inlines.IMIN(excess >> stereo + 3, 8 - ebits[j]); - int n = j; - ebits[n] = ebits[n] + extra_fine; - int extra_bits = extra_fine * C << 3; - fine_priority[j] = extra_bits >= excess - balance ? 1 : 0; - excess -= extra_bits; - } - balance = excess; - Inlines.OpusAssert(bits[j] >= 0); - Inlines.OpusAssert(ebits[j] >= 0); - } - _balance.Val = balance; - while (j < end) { - ebits[j] = bits[j] >> stereo >> 3; - Inlines.OpusAssert(C * ebits[j] << 3 == bits[j]); - bits[j] = 0; - fine_priority[j] = ebits[j] < 1 ? 1 : 0; - ++j; - } - return codedBands; - } - - static int compute_allocation(CeltMode m, int start, int end, int[] offsets, int[] cap, int alloc_trim, BoxedValueInt intensity, BoxedValueInt dual_stereo, int total, BoxedValueInt balance, int[] pulses, int[] ebits, int[] fine_priority, int C, int LM, EntropyCoder ec, int encode, int prev, int signalBandwidth) { - int j; - total = Inlines.IMAX(total, 0); - int len = m.nbEBands; - int skip_start = start; - int skip_rsv = total >= 8 ? 8 : 0; - total -= skip_rsv; - int dual_stereo_rsv = 0; - int intensity_rsv = 0; - if (C == 2) { - intensity_rsv = LOG2_FRAC_TABLE[end - start]; - if (intensity_rsv > total) { - intensity_rsv = 0; - } else { - dual_stereo_rsv = (total -= intensity_rsv) >= 8 ? 8 : 0; - total -= dual_stereo_rsv; - } - } - int[] bits1 = new int[len]; - int[] bits2 = new int[len]; - int[] thresh = new int[len]; - int[] trim_offset = new int[len]; - for (j = start; j < end; ++j) { - thresh[j] = Inlines.IMAX(C << 3, 3 * (m.eBands[j + 1] - m.eBands[j]) << LM << 3 >> 4); - trim_offset[j] = C * (m.eBands[j + 1] - m.eBands[j]) * (alloc_trim - 5 - LM) * (end - j - 1) * (1 << LM + 3) >> 6; - if (m.eBands[j + 1] - m.eBands[j] << LM != 1) continue; - int n = j; - trim_offset[n] = trim_offset[n] - (C << 3); - } - int lo = 1; - int hi = m.nbAllocVectors - 1; - do { - boolean done = false; - int psum = 0; - int mid = lo + hi >> 1; - j = end; - while (j-- > start) { - int N = m.eBands[j + 1] - m.eBands[j]; - int bitsj = C * N * m.allocVectors[mid * len + j] << LM >> 2; - if (bitsj > 0) { - bitsj = Inlines.IMAX(0, bitsj + trim_offset[j]); - } - if ((bitsj += offsets[j]) >= thresh[j] || done) { - done = true; - psum += Inlines.IMIN(bitsj, cap[j]); - continue; - } - if (bitsj < C << 3) continue; - psum += C << 3; - } - if (psum > total) { - hi = mid - 1; - continue; - } - lo = mid + 1; - } while (lo <= hi); - hi = lo--; - for (j = start; j < end; ++j) { - int bits2j; - int N = m.eBands[j + 1] - m.eBands[j]; - int bits1j = C * N * m.allocVectors[lo * len + j] << LM >> 2; - int n = bits2j = hi >= m.nbAllocVectors ? cap[j] : C * N * m.allocVectors[hi * len + j] << LM >> 2; - if (bits1j > 0) { - bits1j = Inlines.IMAX(0, bits1j + trim_offset[j]); - } - if (bits2j > 0) { - bits2j = Inlines.IMAX(0, bits2j + trim_offset[j]); - } - if (lo > 0) { - bits1j += offsets[j]; - } - bits2j += offsets[j]; - if (offsets[j] > 0) { - skip_start = j; - } - bits2j = Inlines.IMAX(0, bits2j - bits1j); - bits1[j] = bits1j; - bits2[j] = bits2j; - } - int codedBands = Rate.interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thresh, cap, total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_stereo_rsv, pulses, ebits, fine_priority, C, LM, ec, encode, prev, signalBandwidth); - return codedBands; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/RegularizeCorrelations.java b/source/decompiled/de/maxhenkel/voicechat/concentus/RegularizeCorrelations.java deleted file mode 100644 index b67b303..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/RegularizeCorrelations.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class RegularizeCorrelations { - RegularizeCorrelations() { - } - - static void silk_regularize_correlations(int[] XX, int XX_ptr, int[] xx, int xx_ptr, int noise, int D) { - for (int i = 0; i < D; ++i) { - Inlines.MatrixSet(XX, XX_ptr, i, i, D, Inlines.silk_ADD32(Inlines.MatrixGet(XX, XX_ptr, i, i, D), noise)); - } - int n = xx_ptr; - xx[n] = xx[n] + noise; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Resampler.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Resampler.java deleted file mode 100644 index beb6dca..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Resampler.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkError; -import de.maxhenkel.voicechat.concentus.SilkResamplerState; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class Resampler { - private static final int USE_silk_resampler_copy = 0; - private static final int USE_silk_resampler_private_up2_HQ_wrapper = 1; - private static final int USE_silk_resampler_private_IIR_FIR = 2; - private static final int USE_silk_resampler_private_down_FIR = 3; - private static final int ORDER_FIR = 4; - - Resampler() { - } - - private static int rateID(int R) { - return ((R >> 12) - (R > 16000 ? 1 : 0) >> (R > 24000 ? 1 : 0)) - 1; - } - - /* - * Enabled aggressive block sorting - */ - static int silk_resampler_init(SilkResamplerState S, int Fs_Hz_in, int Fs_Hz_out, int forEnc) { - int up2x; - block13: { - block15: { - block18: { - block17: { - block16: { - block14: { - S.Reset(); - if (forEnc != 0) { - if (Fs_Hz_in != 8000 && Fs_Hz_in != 12000 && Fs_Hz_in != 16000 && Fs_Hz_in != 24000 && Fs_Hz_in != 48000 || Fs_Hz_out != 8000 && Fs_Hz_out != 12000 && Fs_Hz_out != 16000) { - Inlines.OpusAssert(false); - return -1; - } - S.inputDelay = SilkTables.delay_matrix_enc[Resampler.rateID(Fs_Hz_in)][Resampler.rateID(Fs_Hz_out)]; - } else { - if (Fs_Hz_in != 8000 && Fs_Hz_in != 12000 && Fs_Hz_in != 16000 || Fs_Hz_out != 8000 && Fs_Hz_out != 12000 && Fs_Hz_out != 16000 && Fs_Hz_out != 24000 && Fs_Hz_out != 48000) { - Inlines.OpusAssert(false); - return -1; - } - S.inputDelay = SilkTables.delay_matrix_dec[Resampler.rateID(Fs_Hz_in)][Resampler.rateID(Fs_Hz_out)]; - } - S.Fs_in_kHz = Inlines.silk_DIV32_16(Fs_Hz_in, 1000); - S.Fs_out_kHz = Inlines.silk_DIV32_16(Fs_Hz_out, 1000); - S.batchSize = S.Fs_in_kHz * 10; - up2x = 0; - if (Fs_Hz_out <= Fs_Hz_in) break block14; - if (Fs_Hz_out == Inlines.silk_MUL(Fs_Hz_in, 2)) { - S.resampler_function = 1; - break block13; - } else { - S.resampler_function = 2; - up2x = 1; - } - break block13; - } - if (Fs_Hz_out >= Fs_Hz_in) break block15; - S.resampler_function = 3; - if (Inlines.silk_MUL(Fs_Hz_out, 4) != Inlines.silk_MUL(Fs_Hz_in, 3)) break block16; - S.FIR_Fracs = 3; - S.FIR_Order = 18; - S.Coefs = SilkTables.silk_Resampler_3_4_COEFS; - break block13; - } - if (Inlines.silk_MUL(Fs_Hz_out, 3) != Inlines.silk_MUL(Fs_Hz_in, 2)) break block17; - S.FIR_Fracs = 2; - S.FIR_Order = 18; - S.Coefs = SilkTables.silk_Resampler_2_3_COEFS; - break block13; - } - if (Inlines.silk_MUL(Fs_Hz_out, 2) != Fs_Hz_in) break block18; - S.FIR_Fracs = 1; - S.FIR_Order = 24; - S.Coefs = SilkTables.silk_Resampler_1_2_COEFS; - break block13; - } - if (Inlines.silk_MUL(Fs_Hz_out, 3) == Fs_Hz_in) { - S.FIR_Fracs = 1; - S.FIR_Order = 36; - S.Coefs = SilkTables.silk_Resampler_1_3_COEFS; - break block13; - } else if (Inlines.silk_MUL(Fs_Hz_out, 4) == Fs_Hz_in) { - S.FIR_Fracs = 1; - S.FIR_Order = 36; - S.Coefs = SilkTables.silk_Resampler_1_4_COEFS; - break block13; - } else { - if (Inlines.silk_MUL(Fs_Hz_out, 6) != Fs_Hz_in) { - Inlines.OpusAssert(false); - return -1; - } - S.FIR_Fracs = 1; - S.FIR_Order = 36; - S.Coefs = SilkTables.silk_Resampler_1_6_COEFS; - } - break block13; - } - S.resampler_function = 0; - } - S.invRatio_Q16 = Inlines.silk_LSHIFT32(Inlines.silk_DIV32(Inlines.silk_LSHIFT32(Fs_Hz_in, 14 + up2x), Fs_Hz_out), 2); - while (Inlines.silk_SMULWW(S.invRatio_Q16, Fs_Hz_out) < Inlines.silk_LSHIFT32(Fs_Hz_in, up2x)) { - ++S.invRatio_Q16; - } - return 0; - } - - static int silk_resampler(SilkResamplerState S, short[] output, int output_ptr, short[] input, int input_ptr, int inLen) { - Inlines.OpusAssert(inLen >= S.Fs_in_kHz); - Inlines.OpusAssert(S.inputDelay <= S.Fs_in_kHz); - int nSamples = S.Fs_in_kHz - S.inputDelay; - short[] delayBufPtr = S.delayBuf; - System.arraycopy(input, input_ptr, delayBufPtr, S.inputDelay, nSamples); - switch (S.resampler_function) { - case 1: { - Resampler.silk_resampler_private_up2_HQ(S.sIIR, output, output_ptr, delayBufPtr, 0, S.Fs_in_kHz); - Resampler.silk_resampler_private_up2_HQ(S.sIIR, output, output_ptr + S.Fs_out_kHz, input, input_ptr + nSamples, inLen - S.Fs_in_kHz); - break; - } - case 2: { - Resampler.silk_resampler_private_IIR_FIR(S, output, output_ptr, delayBufPtr, 0, S.Fs_in_kHz); - Resampler.silk_resampler_private_IIR_FIR(S, output, output_ptr + S.Fs_out_kHz, input, input_ptr + nSamples, inLen - S.Fs_in_kHz); - break; - } - case 3: { - Resampler.silk_resampler_private_down_FIR(S, output, output_ptr, delayBufPtr, 0, S.Fs_in_kHz); - Resampler.silk_resampler_private_down_FIR(S, output, output_ptr + S.Fs_out_kHz, input, input_ptr + nSamples, inLen - S.Fs_in_kHz); - break; - } - default: { - System.arraycopy(delayBufPtr, 0, output, output_ptr, S.Fs_in_kHz); - System.arraycopy(input, input_ptr + nSamples, output, output_ptr + S.Fs_out_kHz, inLen - S.Fs_in_kHz); - } - } - System.arraycopy(input, input_ptr + inLen - S.inputDelay, delayBufPtr, 0, S.inputDelay); - return SilkError.SILK_NO_ERROR; - } - - static void silk_resampler_down2(int[] S, short[] output, short[] input, int inLen) { - int len2 = Inlines.silk_RSHIFT32(inLen, 1); - Inlines.OpusAssert(true); - Inlines.OpusAssert(true); - for (int k = 0; k < len2; ++k) { - int in32 = Inlines.silk_LSHIFT(input[2 * k], 10); - int Y = Inlines.silk_SUB32(in32, S[0]); - int X = Inlines.silk_SMLAWB(Y, Y, -25727); - int out32 = Inlines.silk_ADD32(S[0], X); - S[0] = Inlines.silk_ADD32(in32, X); - in32 = Inlines.silk_LSHIFT(input[2 * k + 1], 10); - Y = Inlines.silk_SUB32(in32, S[1]); - X = Inlines.silk_SMULWB(Y, 9872); - out32 = Inlines.silk_ADD32(out32, S[1]); - out32 = Inlines.silk_ADD32(out32, X); - S[1] = Inlines.silk_ADD32(in32, X); - output[k] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(out32, 11)); - } - } - - static void silk_resampler_down2_3(int[] S, short[] output, short[] input, int inLen) { - int nSamplesIn; - int[] buf = new int[484]; - int input_ptr = 0; - int output_ptr = 0; - System.arraycopy(S, 0, buf, 0, 4); - while (true) { - nSamplesIn = Inlines.silk_min(inLen, 480); - Resampler.silk_resampler_private_AR2(S, 4, buf, 4, input, input_ptr, SilkTables.silk_Resampler_2_3_COEFS_LQ, nSamplesIn); - int buf_ptr = 0; - for (int counter = nSamplesIn; counter > 2; counter -= 3) { - int res_Q6 = Inlines.silk_SMULWB(buf[buf_ptr], SilkTables.silk_Resampler_2_3_COEFS_LQ[2]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 1], SilkTables.silk_Resampler_2_3_COEFS_LQ[3]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 2], SilkTables.silk_Resampler_2_3_COEFS_LQ[5]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 3], SilkTables.silk_Resampler_2_3_COEFS_LQ[4]); - output[output_ptr++] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(res_Q6, 6)); - res_Q6 = Inlines.silk_SMULWB(buf[buf_ptr + 1], SilkTables.silk_Resampler_2_3_COEFS_LQ[4]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 2], SilkTables.silk_Resampler_2_3_COEFS_LQ[5]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 3], SilkTables.silk_Resampler_2_3_COEFS_LQ[3]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 4], SilkTables.silk_Resampler_2_3_COEFS_LQ[2]); - output[output_ptr++] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(res_Q6, 6)); - buf_ptr += 3; - } - input_ptr += nSamplesIn; - if ((inLen -= nSamplesIn) <= 0) break; - System.arraycopy(buf, nSamplesIn, buf, 0, 4); - } - System.arraycopy(buf, nSamplesIn, S, 0, 4); - } - - static void silk_resampler_private_AR2(int[] S, int S_ptr, int[] out_Q8, int out_Q8_ptr, short[] input, int input_ptr, short[] A_Q14, int len) { - for (int k = 0; k < len; ++k) { - int out32; - out_Q8[out_Q8_ptr + k] = out32 = Inlines.silk_ADD_LSHIFT32(S[S_ptr], input[input_ptr + k], 8); - out32 = Inlines.silk_LSHIFT(out32, 2); - S[S_ptr] = Inlines.silk_SMLAWB(S[S_ptr + 1], out32, A_Q14[0]); - S[S_ptr + 1] = Inlines.silk_SMULWB(out32, A_Q14[1]); - } - } - - static int silk_resampler_private_down_FIR_INTERPOL(short[] output, int output_ptr, int[] buf, short[] FIR_Coefs, int FIR_Coefs_ptr, int FIR_Order, int FIR_Fracs, int max_index_Q16, int index_increment_Q16) { - switch (FIR_Order) { - case 18: { - for (int index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16) { - int buf_ptr = Inlines.silk_RSHIFT(index_Q16, 16); - int interpol_ind = Inlines.silk_SMULWB(index_Q16 & 0xFFFF, FIR_Fracs); - int interpol_ptr = FIR_Coefs_ptr + 9 * interpol_ind; - int res_Q6 = Inlines.silk_SMULWB(buf[buf_ptr + 0], FIR_Coefs[interpol_ptr + 0]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 1], FIR_Coefs[interpol_ptr + 1]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 2], FIR_Coefs[interpol_ptr + 2]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 3], FIR_Coefs[interpol_ptr + 3]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 4], FIR_Coefs[interpol_ptr + 4]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 5], FIR_Coefs[interpol_ptr + 5]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 6], FIR_Coefs[interpol_ptr + 6]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 7], FIR_Coefs[interpol_ptr + 7]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 8], FIR_Coefs[interpol_ptr + 8]); - interpol_ptr = FIR_Coefs_ptr + 9 * (FIR_Fracs - 1 - interpol_ind); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 17], FIR_Coefs[interpol_ptr + 0]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 16], FIR_Coefs[interpol_ptr + 1]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 15], FIR_Coefs[interpol_ptr + 2]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 14], FIR_Coefs[interpol_ptr + 3]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 13], FIR_Coefs[interpol_ptr + 4]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 12], FIR_Coefs[interpol_ptr + 5]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 11], FIR_Coefs[interpol_ptr + 6]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 10], FIR_Coefs[interpol_ptr + 7]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, buf[buf_ptr + 9], FIR_Coefs[interpol_ptr + 8]); - output[output_ptr++] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(res_Q6, 6)); - } - break; - } - case 24: { - for (int index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16) { - int buf_ptr = Inlines.silk_RSHIFT(index_Q16, 16); - int res_Q6 = Inlines.silk_SMULWB(Inlines.silk_ADD32(buf[buf_ptr + 0], buf[buf_ptr + 23]), FIR_Coefs[FIR_Coefs_ptr + 0]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 1], buf[buf_ptr + 22]), FIR_Coefs[FIR_Coefs_ptr + 1]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 2], buf[buf_ptr + 21]), FIR_Coefs[FIR_Coefs_ptr + 2]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 3], buf[buf_ptr + 20]), FIR_Coefs[FIR_Coefs_ptr + 3]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 4], buf[buf_ptr + 19]), FIR_Coefs[FIR_Coefs_ptr + 4]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 5], buf[buf_ptr + 18]), FIR_Coefs[FIR_Coefs_ptr + 5]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 6], buf[buf_ptr + 17]), FIR_Coefs[FIR_Coefs_ptr + 6]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 7], buf[buf_ptr + 16]), FIR_Coefs[FIR_Coefs_ptr + 7]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 8], buf[buf_ptr + 15]), FIR_Coefs[FIR_Coefs_ptr + 8]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 9], buf[buf_ptr + 14]), FIR_Coefs[FIR_Coefs_ptr + 9]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 10], buf[buf_ptr + 13]), FIR_Coefs[FIR_Coefs_ptr + 10]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 11], buf[buf_ptr + 12]), FIR_Coefs[FIR_Coefs_ptr + 11]); - output[output_ptr++] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(res_Q6, 6)); - } - break; - } - case 36: { - for (int index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16) { - int buf_ptr = Inlines.silk_RSHIFT(index_Q16, 16); - int res_Q6 = Inlines.silk_SMULWB(Inlines.silk_ADD32(buf[buf_ptr + 0], buf[buf_ptr + 35]), FIR_Coefs[FIR_Coefs_ptr + 0]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 1], buf[buf_ptr + 34]), FIR_Coefs[FIR_Coefs_ptr + 1]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 2], buf[buf_ptr + 33]), FIR_Coefs[FIR_Coefs_ptr + 2]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 3], buf[buf_ptr + 32]), FIR_Coefs[FIR_Coefs_ptr + 3]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 4], buf[buf_ptr + 31]), FIR_Coefs[FIR_Coefs_ptr + 4]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 5], buf[buf_ptr + 30]), FIR_Coefs[FIR_Coefs_ptr + 5]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 6], buf[buf_ptr + 29]), FIR_Coefs[FIR_Coefs_ptr + 6]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 7], buf[buf_ptr + 28]), FIR_Coefs[FIR_Coefs_ptr + 7]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 8], buf[buf_ptr + 27]), FIR_Coefs[FIR_Coefs_ptr + 8]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 9], buf[buf_ptr + 26]), FIR_Coefs[FIR_Coefs_ptr + 9]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 10], buf[buf_ptr + 25]), FIR_Coefs[FIR_Coefs_ptr + 10]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 11], buf[buf_ptr + 24]), FIR_Coefs[FIR_Coefs_ptr + 11]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 12], buf[buf_ptr + 23]), FIR_Coefs[FIR_Coefs_ptr + 12]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 13], buf[buf_ptr + 22]), FIR_Coefs[FIR_Coefs_ptr + 13]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 14], buf[buf_ptr + 21]), FIR_Coefs[FIR_Coefs_ptr + 14]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 15], buf[buf_ptr + 20]), FIR_Coefs[FIR_Coefs_ptr + 15]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 16], buf[buf_ptr + 19]), FIR_Coefs[FIR_Coefs_ptr + 16]); - res_Q6 = Inlines.silk_SMLAWB(res_Q6, Inlines.silk_ADD32(buf[buf_ptr + 17], buf[buf_ptr + 18]), FIR_Coefs[FIR_Coefs_ptr + 17]); - output[output_ptr++] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(res_Q6, 6)); - } - break; - } - default: { - Inlines.OpusAssert(false); - } - } - return output_ptr; - } - - static void silk_resampler_private_down_FIR(SilkResamplerState S, short[] output, int output_ptr, short[] input, int input_ptr, int inLen) { - int nSamplesIn; - int[] buf = new int[S.batchSize + S.FIR_Order]; - System.arraycopy(S.sFIR_i32, 0, buf, 0, S.FIR_Order); - int index_increment_Q16 = S.invRatio_Q16; - while (true) { - nSamplesIn = Inlines.silk_min(inLen, S.batchSize); - Resampler.silk_resampler_private_AR2(S.sIIR, 0, buf, S.FIR_Order, input, input_ptr, S.Coefs, nSamplesIn); - int max_index_Q16 = Inlines.silk_LSHIFT32(nSamplesIn, 16); - output_ptr = Resampler.silk_resampler_private_down_FIR_INTERPOL(output, output_ptr, buf, S.Coefs, 2, S.FIR_Order, S.FIR_Fracs, max_index_Q16, index_increment_Q16); - input_ptr += nSamplesIn; - if ((inLen -= nSamplesIn) <= 1) break; - System.arraycopy(buf, nSamplesIn, buf, 0, S.FIR_Order); - } - System.arraycopy(buf, nSamplesIn, S.sFIR_i32, 0, S.FIR_Order); - } - - static int silk_resampler_private_IIR_FIR_INTERPOL(short[] output, int output_ptr, short[] buf, int max_index_Q16, int index_increment_Q16) { - for (int index_Q16 = 0; index_Q16 < max_index_Q16; index_Q16 += index_increment_Q16) { - int table_index = Inlines.silk_SMULWB(index_Q16 & 0xFFFF, 12); - int buf_ptr = index_Q16 >> 16; - int res_Q15 = Inlines.silk_SMULBB(buf[buf_ptr], SilkTables.silk_resampler_frac_FIR_12[table_index][0]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 1], SilkTables.silk_resampler_frac_FIR_12[table_index][1]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 2], SilkTables.silk_resampler_frac_FIR_12[table_index][2]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 3], SilkTables.silk_resampler_frac_FIR_12[table_index][3]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 4], SilkTables.silk_resampler_frac_FIR_12[11 - table_index][3]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 5], SilkTables.silk_resampler_frac_FIR_12[11 - table_index][2]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 6], SilkTables.silk_resampler_frac_FIR_12[11 - table_index][1]); - res_Q15 = Inlines.silk_SMLABB(res_Q15, buf[buf_ptr + 7], SilkTables.silk_resampler_frac_FIR_12[11 - table_index][0]); - output[output_ptr++] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(res_Q15, 15)); - } - return output_ptr; - } - - static void silk_resampler_private_IIR_FIR(SilkResamplerState S, short[] output, int output_ptr, short[] input, int input_ptr, int inLen) { - int nSamplesIn; - short[] buf = new short[2 * S.batchSize + 8]; - System.arraycopy(S.sFIR_i16, 0, buf, 0, 8); - int index_increment_Q16 = S.invRatio_Q16; - while (true) { - nSamplesIn = Inlines.silk_min(inLen, S.batchSize); - Resampler.silk_resampler_private_up2_HQ(S.sIIR, buf, 8, input, input_ptr, nSamplesIn); - int max_index_Q16 = Inlines.silk_LSHIFT32(nSamplesIn, 17); - output_ptr = Resampler.silk_resampler_private_IIR_FIR_INTERPOL(output, output_ptr, buf, max_index_Q16, index_increment_Q16); - input_ptr += nSamplesIn; - if ((inLen -= nSamplesIn) <= 0) break; - System.arraycopy(buf, nSamplesIn << 1, buf, 0, 8); - } - System.arraycopy(buf, nSamplesIn << 1, S.sFIR_i16, 0, 8); - } - - static void silk_resampler_private_up2_HQ(int[] S, short[] output, int output_ptr, short[] input, int input_ptr, int len) { - Inlines.OpusAssert(SilkTables.silk_resampler_up2_hq_0[0] > 0); - Inlines.OpusAssert(SilkTables.silk_resampler_up2_hq_0[1] > 0); - Inlines.OpusAssert(SilkTables.silk_resampler_up2_hq_0[2] < 0); - Inlines.OpusAssert(SilkTables.silk_resampler_up2_hq_1[0] > 0); - Inlines.OpusAssert(SilkTables.silk_resampler_up2_hq_1[1] > 0); - Inlines.OpusAssert(SilkTables.silk_resampler_up2_hq_1[2] < 0); - for (int k = 0; k < len; ++k) { - int in32 = Inlines.silk_LSHIFT(input[input_ptr + k], 10); - int Y = Inlines.silk_SUB32(in32, S[0]); - int X = Inlines.silk_SMULWB(Y, SilkTables.silk_resampler_up2_hq_0[0]); - int out32_1 = Inlines.silk_ADD32(S[0], X); - S[0] = Inlines.silk_ADD32(in32, X); - Y = Inlines.silk_SUB32(out32_1, S[1]); - X = Inlines.silk_SMULWB(Y, SilkTables.silk_resampler_up2_hq_0[1]); - int out32_2 = Inlines.silk_ADD32(S[1], X); - S[1] = Inlines.silk_ADD32(out32_1, X); - Y = Inlines.silk_SUB32(out32_2, S[2]); - X = Inlines.silk_SMLAWB(Y, Y, SilkTables.silk_resampler_up2_hq_0[2]); - out32_1 = Inlines.silk_ADD32(S[2], X); - S[2] = Inlines.silk_ADD32(out32_2, X); - output[output_ptr + 2 * k] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(out32_1, 10)); - Y = Inlines.silk_SUB32(in32, S[3]); - X = Inlines.silk_SMULWB(Y, SilkTables.silk_resampler_up2_hq_1[0]); - out32_1 = Inlines.silk_ADD32(S[3], X); - S[3] = Inlines.silk_ADD32(in32, X); - Y = Inlines.silk_SUB32(out32_1, S[4]); - X = Inlines.silk_SMULWB(Y, SilkTables.silk_resampler_up2_hq_1[1]); - out32_2 = Inlines.silk_ADD32(S[4], X); - S[4] = Inlines.silk_ADD32(out32_1, X); - Y = Inlines.silk_SUB32(out32_2, S[5]); - X = Inlines.silk_SMLAWB(Y, Y, SilkTables.silk_resampler_up2_hq_1[2]); - out32_1 = Inlines.silk_ADD32(S[5], X); - S[5] = Inlines.silk_ADD32(out32_2, X); - output[output_ptr + 2 * k + 1] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(out32_1, 10)); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/ResidualEnergy.java b/source/decompiled/de/maxhenkel/voicechat/concentus/ResidualEnergy.java deleted file mode 100644 index 459a5f2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/ResidualEnergy.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class ResidualEnergy { - ResidualEnergy() { - } - - static void silk_residual_energy(int[] nrgs, int[] nrgsQ, short[] x, short[][] a_Q12, int[] gains, int subfr_length, int nb_subfr, int LPC_order) { - int i; - BoxedValueInt rshift = new BoxedValueInt(0); - BoxedValueInt energy = new BoxedValueInt(0); - int x_ptr = 0; - int offset = LPC_order + subfr_length; - short[] LPC_res = new short[2 * offset]; - Inlines.OpusAssert((nb_subfr >> 1) * 2 == nb_subfr); - for (i = 0; i < nb_subfr >> 1; ++i) { - Filters.silk_LPC_analysis_filter(LPC_res, 0, x, x_ptr, a_Q12[i], 0, 2 * offset, LPC_order); - int LPC_res_ptr = LPC_order; - for (int j = 0; j < 2; ++j) { - SumSqrShift.silk_sum_sqr_shift(energy, rshift, LPC_res, LPC_res_ptr, subfr_length); - nrgs[i * 2 + j] = energy.Val; - nrgsQ[i * 2 + j] = 0 - rshift.Val; - LPC_res_ptr += offset; - } - x_ptr += 2 * offset; - } - i = 0; - while (i < nb_subfr) { - int lz1 = Inlines.silk_CLZ32(nrgs[i]) - 1; - int lz2 = Inlines.silk_CLZ32(gains[i]) - 1; - int tmp32 = Inlines.silk_LSHIFT32(gains[i], lz2); - tmp32 = Inlines.silk_SMMUL(tmp32, tmp32); - nrgs[i] = Inlines.silk_SMMUL(tmp32, Inlines.silk_LSHIFT32(nrgs[i], lz1)); - int n = i++; - nrgsQ[n] = nrgsQ[n] + (lz1 + 2 * lz2 - 32 - 32); - } - } - - static int silk_residual_energy16_covar(short[] c, int c_ptr, int[] wXX, int wXX_ptr, int[] wXx, int wxx, int D, int cQ) { - int i; - int lshifts; - int[] cn = new int[D]; - Inlines.OpusAssert(D >= 0); - Inlines.OpusAssert(D <= 16); - Inlines.OpusAssert(cQ > 0); - Inlines.OpusAssert(cQ < 16); - int Qxtra = lshifts = 16 - cQ; - int c_max = 0; - for (i = c_ptr; i < c_ptr + D; ++i) { - c_max = Inlines.silk_max_32(c_max, Inlines.silk_abs(c[i])); - } - Qxtra = Inlines.silk_min_int(Qxtra, Inlines.silk_CLZ32(c_max) - 17); - int w_max = Inlines.silk_max_32(wXX[wXX_ptr], wXX[wXX_ptr + D * D - 1]); - Qxtra = Inlines.silk_min_int(Qxtra, Inlines.silk_CLZ32(Inlines.silk_MUL(D, Inlines.silk_RSHIFT(Inlines.silk_SMULWB(w_max, c_max), 4))) - 5); - Qxtra = Inlines.silk_max_int(Qxtra, 0); - for (i = 0; i < D; ++i) { - cn[i] = Inlines.silk_LSHIFT(c[c_ptr + i], Qxtra); - Inlines.OpusAssert(Inlines.silk_abs(cn[i]) <= 32768); - } - lshifts -= Qxtra; - int tmp = 0; - for (i = 0; i < D; ++i) { - tmp = Inlines.silk_SMLAWB(tmp, wXx[i], cn[i]); - } - int nrg = Inlines.silk_RSHIFT(wxx, 1 + lshifts) - tmp; - int tmp2 = 0; - for (i = 0; i < D; ++i) { - tmp = 0; - int pRow = wXX_ptr + i * D; - for (int j = i + 1; j < D; ++j) { - tmp = Inlines.silk_SMLAWB(tmp, wXX[pRow + j], cn[j]); - } - tmp = Inlines.silk_SMLAWB(tmp, Inlines.silk_RSHIFT(wXX[pRow + i], 1), cn[i]); - tmp2 = Inlines.silk_SMLAWB(tmp2, tmp, cn[i]); - } - nrg = (nrg = Inlines.silk_ADD_LSHIFT32(nrg, tmp2, lshifts)) < 1 ? 1 : (nrg > Inlines.silk_RSHIFT(Integer.MAX_VALUE, lshifts + 2) ? 0x3FFFFFFF : Inlines.silk_LSHIFT(nrg, lshifts + 1)); - return nrg; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Schur.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Schur.java deleted file mode 100644 index a7135cd..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Schur.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.Inlines; - -class Schur { - Schur() { - } - - static int silk_schur(short[] rc_Q15, int[] c, int order) { - int k; - int[][] C = Arrays.InitTwoDimensionalArrayInt(17, 2); - Inlines.OpusAssert(order == 6 || order == 8 || order == 10 || order == 12 || order == 14 || order == 16); - int lz = Inlines.silk_CLZ32(c[0]); - if (lz < 2) { - for (k = 0; k < order + 1; ++k) { - int n = Inlines.silk_RSHIFT(c[k], 1); - C[k][1] = n; - C[k][0] = n; - } - } else if (lz > 2) { - lz -= 2; - for (k = 0; k < order + 1; ++k) { - int n = Inlines.silk_LSHIFT(c[k], lz); - C[k][1] = n; - C[k][0] = n; - } - } else { - for (k = 0; k < order + 1; ++k) { - int n = c[k]; - C[k][1] = n; - C[k][0] = n; - } - } - for (k = 0; k < order; ++k) { - if (Inlines.silk_abs_int32(C[k + 1][0]) >= C[0][1]) { - rc_Q15[k] = C[k + 1][0] > 0 ? -32440 : 32440; - ++k; - break; - } - int rc_tmp_Q15 = 0 - Inlines.silk_DIV32_16(C[k + 1][0], Inlines.silk_max_32(Inlines.silk_RSHIFT(C[0][1], 15), 1)); - rc_tmp_Q15 = Inlines.silk_SAT16(rc_tmp_Q15); - rc_Q15[k] = (short)rc_tmp_Q15; - for (int n = 0; n < order - k; ++n) { - int Ctmp1 = C[n + k + 1][0]; - int Ctmp2 = C[n][1]; - C[n + k + 1][0] = Inlines.silk_SMLAWB(Ctmp1, Inlines.silk_LSHIFT(Ctmp2, 1), rc_tmp_Q15); - C[n][1] = Inlines.silk_SMLAWB(Ctmp2, Inlines.silk_LSHIFT(Ctmp1, 1), rc_tmp_Q15); - } - } - while (k < order) { - rc_Q15[k] = 0; - ++k; - } - return Inlines.silk_max_32(1, C[0][1]); - } - - static int silk_schur64(int[] rc_Q16, int[] c, int order) { - int k; - int[][] C = Arrays.InitTwoDimensionalArrayInt(17, 2); - Inlines.OpusAssert(order == 6 || order == 8 || order == 10 || order == 12 || order == 14 || order == 16); - if (c[0] <= 0) { - Arrays.MemSet(rc_Q16, 0, order); - return 0; - } - for (k = 0; k < order + 1; ++k) { - int n = c[k]; - C[k][1] = n; - C[k][0] = n; - } - for (k = 0; k < order; ++k) { - if (Inlines.silk_abs_int32(C[k + 1][0]) >= C[0][1]) { - rc_Q16[k] = C[k + 1][0] > 0 ? -64881 : 64881; - ++k; - break; - } - int rc_tmp_Q31 = Inlines.silk_DIV32_varQ(-C[k + 1][0], C[0][1], 31); - rc_Q16[k] = Inlines.silk_RSHIFT_ROUND(rc_tmp_Q31, 15); - for (int n = 0; n < order - k; ++n) { - int Ctmp1_Q30 = C[n + k + 1][0]; - int Ctmp2_Q30 = C[n][1]; - C[n + k + 1][0] = Ctmp1_Q30 + Inlines.silk_SMMUL(Inlines.silk_LSHIFT(Ctmp2_Q30, 1), rc_tmp_Q31); - C[n][1] = Ctmp2_Q30 + Inlines.silk_SMMUL(Inlines.silk_LSHIFT(Ctmp1_Q30, 1), rc_tmp_Q31); - } - } - while (k < order) { - rc_Q16[k] = 0; - ++k; - } - return Inlines.silk_max_32(1, C[0][1]); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/ShellCoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/ShellCoder.java deleted file mode 100644 index 9c92bed..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/ShellCoder.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class ShellCoder { - ShellCoder() { - } - - static void combine_pulses(int[] output, int[] input, int input_ptr, int len) { - for (int k = 0; k < len; ++k) { - output[k] = input[input_ptr + 2 * k] + input[input_ptr + 2 * k + 1]; - } - } - - static void combine_pulses(int[] output, int[] input, int len) { - for (int k = 0; k < len; ++k) { - output[k] = input[2 * k] + input[2 * k + 1]; - } - } - - static void encode_split(EntropyCoder psRangeEnc, int p_child1, int p, short[] shell_table) { - if (p > 0) { - psRangeEnc.enc_icdf(p_child1, shell_table, SilkTables.silk_shell_code_table_offsets[p], 8); - } - } - - static void decode_split(short[] p_child1, int child1_ptr, short[] p_child2, int p_child2_ptr, EntropyCoder psRangeDec, int p, short[] shell_table) { - if (p > 0) { - p_child1[child1_ptr] = (short)psRangeDec.dec_icdf(shell_table, SilkTables.silk_shell_code_table_offsets[p], 8); - p_child2[p_child2_ptr] = (short)(p - p_child1[child1_ptr]); - } else { - p_child1[child1_ptr] = 0; - p_child2[p_child2_ptr] = 0; - } - } - - static void silk_shell_encoder(EntropyCoder psRangeEnc, int[] pulses0, int pulses0_ptr) { - int[] pulses1 = new int[8]; - int[] pulses2 = new int[4]; - int[] pulses3 = new int[2]; - int[] pulses4 = new int[1]; - Inlines.OpusAssert(true); - ShellCoder.combine_pulses(pulses1, pulses0, pulses0_ptr, 8); - ShellCoder.combine_pulses(pulses2, pulses1, 4); - ShellCoder.combine_pulses(pulses3, pulses2, 2); - ShellCoder.combine_pulses(pulses4, pulses3, 1); - ShellCoder.encode_split(psRangeEnc, pulses3[0], pulses4[0], SilkTables.silk_shell_code_table3); - ShellCoder.encode_split(psRangeEnc, pulses2[0], pulses3[0], SilkTables.silk_shell_code_table2); - ShellCoder.encode_split(psRangeEnc, pulses1[0], pulses2[0], SilkTables.silk_shell_code_table1); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr], pulses1[0], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 2], pulses1[1], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses1[2], pulses2[1], SilkTables.silk_shell_code_table1); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 4], pulses1[2], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 6], pulses1[3], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses2[2], pulses3[1], SilkTables.silk_shell_code_table2); - ShellCoder.encode_split(psRangeEnc, pulses1[4], pulses2[2], SilkTables.silk_shell_code_table1); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 8], pulses1[4], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 10], pulses1[5], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses1[6], pulses2[3], SilkTables.silk_shell_code_table1); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 12], pulses1[6], SilkTables.silk_shell_code_table0); - ShellCoder.encode_split(psRangeEnc, pulses0[pulses0_ptr + 14], pulses1[7], SilkTables.silk_shell_code_table0); - } - - static void silk_shell_decoder(short[] pulses0, int pulses0_ptr, EntropyCoder psRangeDec, int pulses4) { - short[] pulses1 = new short[8]; - short[] pulses2 = new short[4]; - short[] pulses3 = new short[2]; - Inlines.OpusAssert(true); - ShellCoder.decode_split(pulses3, 0, pulses3, 1, psRangeDec, pulses4, SilkTables.silk_shell_code_table3); - ShellCoder.decode_split(pulses2, 0, pulses2, 1, psRangeDec, pulses3[0], SilkTables.silk_shell_code_table2); - ShellCoder.decode_split(pulses1, 0, pulses1, 1, psRangeDec, pulses2[0], SilkTables.silk_shell_code_table1); - ShellCoder.decode_split(pulses0, pulses0_ptr, pulses0, pulses0_ptr + 1, psRangeDec, pulses1[0], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses0, pulses0_ptr + 2, pulses0, pulses0_ptr + 3, psRangeDec, pulses1[1], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses1, 2, pulses1, 3, psRangeDec, pulses2[1], SilkTables.silk_shell_code_table1); - ShellCoder.decode_split(pulses0, pulses0_ptr + 4, pulses0, pulses0_ptr + 5, psRangeDec, pulses1[2], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses0, pulses0_ptr + 6, pulses0, pulses0_ptr + 7, psRangeDec, pulses1[3], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses2, 2, pulses2, 3, psRangeDec, pulses3[1], SilkTables.silk_shell_code_table2); - ShellCoder.decode_split(pulses1, 4, pulses1, 5, psRangeDec, pulses2[2], SilkTables.silk_shell_code_table1); - ShellCoder.decode_split(pulses0, pulses0_ptr + 8, pulses0, pulses0_ptr + 9, psRangeDec, pulses1[4], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses0, pulses0_ptr + 10, pulses0, pulses0_ptr + 11, psRangeDec, pulses1[5], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses1, 6, pulses1, 7, psRangeDec, pulses2[3], SilkTables.silk_shell_code_table1); - ShellCoder.decode_split(pulses0, pulses0_ptr + 12, pulses0, pulses0_ptr + 13, psRangeDec, pulses1[6], SilkTables.silk_shell_code_table0); - ShellCoder.decode_split(pulses0, pulses0_ptr + 14, pulses0, pulses0_ptr + 15, psRangeDec, pulses1[7], SilkTables.silk_shell_code_table0); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SideInfoIndices.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SideInfoIndices.java deleted file mode 100644 index 0549f79..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SideInfoIndices.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class SideInfoIndices { - final byte[] GainsIndices = new byte[4]; - final byte[] LTPIndex = new byte[4]; - final byte[] NLSFIndices = new byte[17]; - short lagIndex = 0; - byte contourIndex = 0; - byte signalType = 0; - byte quantOffsetType = 0; - byte NLSFInterpCoef_Q2 = 0; - byte PERIndex = 0; - byte LTP_scaleIndex = 0; - byte Seed = 0; - - SideInfoIndices() { - } - - void Reset() { - Arrays.MemSet(this.GainsIndices, (byte)0, 4); - Arrays.MemSet(this.LTPIndex, (byte)0, 4); - Arrays.MemSet(this.NLSFIndices, (byte)0, 17); - this.lagIndex = 0; - this.contourIndex = 0; - this.signalType = 0; - this.quantOffsetType = 0; - this.NLSFInterpCoef_Q2 = 0; - this.PERIndex = 0; - this.LTP_scaleIndex = 0; - this.Seed = 0; - } - - void Assign(SideInfoIndices other) { - System.arraycopy(other.GainsIndices, 0, this.GainsIndices, 0, 4); - System.arraycopy(other.LTPIndex, 0, this.LTPIndex, 0, 4); - System.arraycopy(other.NLSFIndices, 0, this.NLSFIndices, 0, 17); - this.lagIndex = other.lagIndex; - this.contourIndex = other.contourIndex; - this.signalType = other.signalType; - this.quantOffsetType = other.quantOffsetType; - this.NLSFInterpCoef_Q2 = other.NLSFInterpCoef_Q2; - this.PERIndex = other.PERIndex; - this.LTP_scaleIndex = other.LTP_scaleIndex; - this.Seed = other.Seed; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Sigmoid.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Sigmoid.java deleted file mode 100644 index 3aa0ad2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Sigmoid.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class Sigmoid { - private static final int[] sigm_LUT_slope_Q10 = new int[]{237, 153, 73, 30, 12, 7}; - private static final int[] sigm_LUT_pos_Q15 = new int[]{16384, 23955, 28861, 31213, 32178, 32548}; - private static final int[] sigm_LUT_neg_Q15 = new int[]{16384, 8812, 3906, 1554, 589, 219}; - - Sigmoid() { - } - - static int silk_sigm_Q15(int in_Q5) { - if (in_Q5 < 0) { - if ((in_Q5 = -in_Q5) >= 192) { - return 0; - } - int ind = Inlines.silk_RSHIFT(in_Q5, 5); - return sigm_LUT_neg_Q15[ind] - Inlines.silk_SMULBB(sigm_LUT_slope_Q10[ind], in_Q5 & 0x1F); - } - if (in_Q5 >= 192) { - return Short.MAX_VALUE; - } - int ind = Inlines.silk_RSHIFT(in_Q5, 5); - return sigm_LUT_pos_Q15[ind] + Inlines.silk_SMULBB(sigm_LUT_slope_Q10[ind], in_Q5 & 0x1F); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkChannelDecoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkChannelDecoder.java deleted file mode 100644 index 05b0ce3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkChannelDecoder.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.CNG; -import de.maxhenkel.voicechat.concentus.CNGState; -import de.maxhenkel.voicechat.concentus.DecodeCore; -import de.maxhenkel.voicechat.concentus.DecodeIndices; -import de.maxhenkel.voicechat.concentus.DecodeParameters; -import de.maxhenkel.voicechat.concentus.DecodePulses; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSFCodebook; -import de.maxhenkel.voicechat.concentus.PLC; -import de.maxhenkel.voicechat.concentus.PLCStruct; -import de.maxhenkel.voicechat.concentus.Resampler; -import de.maxhenkel.voicechat.concentus.SideInfoIndices; -import de.maxhenkel.voicechat.concentus.SilkDecoderControl; -import de.maxhenkel.voicechat.concentus.SilkResamplerState; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class SilkChannelDecoder { - int prev_gain_Q16 = 0; - final int[] exc_Q14 = new int[320]; - final int[] sLPC_Q14_buf = new int[16]; - final short[] outBuf = new short[480]; - int lagPrev = 0; - byte LastGainIndex = 0; - int fs_kHz = 0; - int fs_API_hz = 0; - int nb_subfr = 0; - int frame_length = 0; - int subfr_length = 0; - int ltp_mem_length = 0; - int LPC_order = 0; - final short[] prevNLSF_Q15 = new short[16]; - int first_frame_after_reset = 0; - short[] pitch_lag_low_bits_iCDF; - short[] pitch_contour_iCDF; - int nFramesDecoded = 0; - int nFramesPerPacket = 0; - int ec_prevSignalType = 0; - short ec_prevLagIndex = 0; - final int[] VAD_flags = new int[3]; - int LBRR_flag = 0; - final int[] LBRR_flags = new int[3]; - final SilkResamplerState resampler_state = new SilkResamplerState(); - NLSFCodebook psNLSF_CB = null; - final SideInfoIndices indices = new SideInfoIndices(); - final CNGState sCNG = new CNGState(); - int lossCnt = 0; - int prevSignalType = 0; - final PLCStruct sPLC = new PLCStruct(); - - SilkChannelDecoder() { - } - - void Reset() { - this.prev_gain_Q16 = 0; - Arrays.MemSet(this.exc_Q14, 0, 320); - Arrays.MemSet(this.sLPC_Q14_buf, 0, 16); - Arrays.MemSet(this.outBuf, (short)0, 480); - this.lagPrev = 0; - this.LastGainIndex = 0; - this.fs_kHz = 0; - this.fs_API_hz = 0; - this.nb_subfr = 0; - this.frame_length = 0; - this.subfr_length = 0; - this.ltp_mem_length = 0; - this.LPC_order = 0; - Arrays.MemSet(this.prevNLSF_Q15, (short)0, 16); - this.first_frame_after_reset = 0; - this.pitch_lag_low_bits_iCDF = null; - this.pitch_contour_iCDF = null; - this.nFramesDecoded = 0; - this.nFramesPerPacket = 0; - this.ec_prevSignalType = 0; - this.ec_prevLagIndex = 0; - Arrays.MemSet(this.VAD_flags, 0, 3); - this.LBRR_flag = 0; - Arrays.MemSet(this.LBRR_flags, 0, 3); - this.resampler_state.Reset(); - this.psNLSF_CB = null; - this.indices.Reset(); - this.sCNG.Reset(); - this.lossCnt = 0; - this.prevSignalType = 0; - this.sPLC.Reset(); - } - - int silk_init_decoder() { - this.Reset(); - this.first_frame_after_reset = 1; - this.prev_gain_Q16 = 65536; - this.silk_CNG_Reset(); - this.silk_PLC_Reset(); - return 0; - } - - private void silk_CNG_Reset() { - int NLSF_step_Q15 = Inlines.silk_DIV32_16(Short.MAX_VALUE, this.LPC_order + 1); - int NLSF_acc_Q15 = 0; - for (int i = 0; i < this.LPC_order; ++i) { - this.sCNG.CNG_smth_NLSF_Q15[i] = (short)(NLSF_acc_Q15 += NLSF_step_Q15); - } - this.sCNG.CNG_smth_Gain_Q16 = 0; - this.sCNG.rand_seed = 3176576; - } - - private void silk_PLC_Reset() { - this.sPLC.pitchL_Q8 = Inlines.silk_LSHIFT(this.frame_length, 7); - this.sPLC.prevGain_Q16[0] = 65536; - this.sPLC.prevGain_Q16[1] = 65536; - this.sPLC.subfr_length = 20; - this.sPLC.nb_subfr = 2; - } - - int silk_decoder_set_fs(int fs_kHz, int fs_API_Hz) { - int ret = 0; - Inlines.OpusAssert(fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16); - Inlines.OpusAssert(this.nb_subfr == 4 || this.nb_subfr == 2); - this.subfr_length = Inlines.silk_SMULBB(5, fs_kHz); - int frame_length = Inlines.silk_SMULBB(this.nb_subfr, this.subfr_length); - if (this.fs_kHz != fs_kHz || this.fs_API_hz != fs_API_Hz) { - ret += Resampler.silk_resampler_init(this.resampler_state, Inlines.silk_SMULBB(fs_kHz, 1000), fs_API_Hz, 0); - this.fs_API_hz = fs_API_Hz; - } - if (this.fs_kHz != fs_kHz || frame_length != this.frame_length) { - this.pitch_contour_iCDF = fs_kHz == 8 ? (this.nb_subfr == 4 ? SilkTables.silk_pitch_contour_NB_iCDF : SilkTables.silk_pitch_contour_10_ms_NB_iCDF) : (this.nb_subfr == 4 ? SilkTables.silk_pitch_contour_iCDF : SilkTables.silk_pitch_contour_10_ms_iCDF); - if (this.fs_kHz != fs_kHz) { - this.ltp_mem_length = Inlines.silk_SMULBB(20, fs_kHz); - if (fs_kHz == 8 || fs_kHz == 12) { - this.LPC_order = 10; - this.psNLSF_CB = SilkTables.silk_NLSF_CB_NB_MB; - } else { - this.LPC_order = 16; - this.psNLSF_CB = SilkTables.silk_NLSF_CB_WB; - } - if (fs_kHz == 16) { - this.pitch_lag_low_bits_iCDF = SilkTables.silk_uniform8_iCDF; - } else if (fs_kHz == 12) { - this.pitch_lag_low_bits_iCDF = SilkTables.silk_uniform6_iCDF; - } else if (fs_kHz == 8) { - this.pitch_lag_low_bits_iCDF = SilkTables.silk_uniform4_iCDF; - } else { - Inlines.OpusAssert(false); - } - this.first_frame_after_reset = 1; - this.lagPrev = 100; - this.LastGainIndex = (byte)10; - this.prevSignalType = 0; - Arrays.MemSet(this.outBuf, (short)0, 480); - Arrays.MemSet(this.sLPC_Q14_buf, 0, 16); - } - this.fs_kHz = fs_kHz; - this.frame_length = frame_length; - } - Inlines.OpusAssert(this.frame_length > 0 && this.frame_length <= 320); - return ret; - } - - int silk_decode_frame(EntropyCoder psRangeDec, short[] pOut, int pOut_ptr, BoxedValueInt pN, int lostFlag, int condCoding) { - SilkDecoderControl thisCtrl = new SilkDecoderControl(); - int ret = 0; - int L = this.frame_length; - thisCtrl.LTP_scale_Q14 = 0; - Inlines.OpusAssert(L > 0 && L <= 320); - if (lostFlag == 0 || lostFlag == 2 && this.LBRR_flags[this.nFramesDecoded] == 1) { - short[] pulses = new short[L + 16 - 1 & 0xFFFFFFF0]; - DecodeIndices.silk_decode_indices(this, psRangeDec, this.nFramesDecoded, lostFlag, condCoding); - DecodePulses.silk_decode_pulses(psRangeDec, pulses, this.indices.signalType, this.indices.quantOffsetType, this.frame_length); - DecodeParameters.silk_decode_parameters(this, thisCtrl, condCoding); - DecodeCore.silk_decode_core(this, thisCtrl, pOut, pOut_ptr, pulses); - PLC.silk_PLC(this, thisCtrl, pOut, pOut_ptr, 0); - this.lossCnt = 0; - this.prevSignalType = this.indices.signalType; - Inlines.OpusAssert(this.prevSignalType >= 0 && this.prevSignalType <= 2); - this.first_frame_after_reset = 0; - } else { - PLC.silk_PLC(this, thisCtrl, pOut, pOut_ptr, 1); - } - Inlines.OpusAssert(this.ltp_mem_length >= this.frame_length); - int mv_len = this.ltp_mem_length - this.frame_length; - Arrays.MemMove(this.outBuf, this.frame_length, 0, mv_len); - System.arraycopy(pOut, pOut_ptr, this.outBuf, mv_len, this.frame_length); - CNG.silk_CNG(this, thisCtrl, pOut, pOut_ptr, L); - PLC.silk_PLC_glue_frames(this, pOut, pOut_ptr, L); - this.lagPrev = thisCtrl.pitchL[this.nb_subfr - 1]; - pN.Val = L; - return ret; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkChannelEncoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkChannelEncoder.java deleted file mode 100644 index 166084a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkChannelEncoder.java +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.EncControlState; -import de.maxhenkel.voicechat.concentus.EncodeIndices; -import de.maxhenkel.voicechat.concentus.EncodePulses; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.FindPitchLags; -import de.maxhenkel.voicechat.concentus.FindPredCoefs; -import de.maxhenkel.voicechat.concentus.GainQuantization; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.NLSFCodebook; -import de.maxhenkel.voicechat.concentus.NoiseShapeAnalysis; -import de.maxhenkel.voicechat.concentus.ProcessGains; -import de.maxhenkel.voicechat.concentus.Resampler; -import de.maxhenkel.voicechat.concentus.SideInfoIndices; -import de.maxhenkel.voicechat.concentus.SilkEncoderControl; -import de.maxhenkel.voicechat.concentus.SilkError; -import de.maxhenkel.voicechat.concentus.SilkLPState; -import de.maxhenkel.voicechat.concentus.SilkNSQState; -import de.maxhenkel.voicechat.concentus.SilkPrefilterState; -import de.maxhenkel.voicechat.concentus.SilkResamplerState; -import de.maxhenkel.voicechat.concentus.SilkShapeState; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.SilkVADState; -import de.maxhenkel.voicechat.concentus.VoiceActivityDetection; - -class SilkChannelEncoder { - final int[] In_HP_State = new int[2]; - int variable_HP_smth1_Q15 = 0; - int variable_HP_smth2_Q15 = 0; - final SilkLPState sLP = new SilkLPState(); - final SilkVADState sVAD = new SilkVADState(); - final SilkNSQState sNSQ = new SilkNSQState(); - final short[] prev_NLSFq_Q15 = new short[16]; - int speech_activity_Q8 = 0; - int allow_bandwidth_switch = 0; - byte LBRRprevLastGainIndex = 0; - byte prevSignalType = 0; - int prevLag = 0; - int pitch_LPC_win_length = 0; - int max_pitch_lag = 0; - int API_fs_Hz = 0; - int prev_API_fs_Hz = 0; - int maxInternal_fs_Hz = 0; - int minInternal_fs_Hz = 0; - int desiredInternal_fs_Hz = 0; - int fs_kHz = 0; - int nb_subfr = 0; - int frame_length = 0; - int subfr_length = 0; - int ltp_mem_length = 0; - int la_pitch = 0; - int la_shape = 0; - int shapeWinLength = 0; - int TargetRate_bps = 0; - int PacketSize_ms = 0; - int PacketLoss_perc = 0; - int frameCounter = 0; - int Complexity = 0; - int nStatesDelayedDecision = 0; - int useInterpolatedNLSFs = 0; - int shapingLPCOrder = 0; - int predictLPCOrder = 0; - int pitchEstimationComplexity = 0; - int pitchEstimationLPCOrder = 0; - int pitchEstimationThreshold_Q16 = 0; - int LTPQuantLowComplexity = 0; - int mu_LTP_Q9 = 0; - int sum_log_gain_Q7 = 0; - int NLSF_MSVQ_Survivors = 0; - int first_frame_after_reset = 0; - int controlled_since_last_payload = 0; - int warping_Q16 = 0; - int useCBR = 0; - int prefillFlag = 0; - short[] pitch_lag_low_bits_iCDF = null; - short[] pitch_contour_iCDF = null; - NLSFCodebook psNLSF_CB = null; - final int[] input_quality_bands_Q15 = new int[4]; - int input_tilt_Q15 = 0; - int SNR_dB_Q7 = 0; - final byte[] VAD_flags = new byte[3]; - byte LBRR_flag = 0; - final int[] LBRR_flags = new int[3]; - final SideInfoIndices indices = new SideInfoIndices(); - final byte[] pulses = new byte[320]; - final short[] inputBuf = new short[322]; - int inputBufIx = 0; - int nFramesPerPacket = 0; - int nFramesEncoded = 0; - int nChannelsAPI = 0; - int nChannelsInternal = 0; - int channelNb = 0; - int frames_since_onset = 0; - int ec_prevSignalType = 0; - short ec_prevLagIndex = 0; - final SilkResamplerState resampler_state = new SilkResamplerState(); - int useDTX = 0; - int inDTX = 0; - int noSpeechCounter = 0; - int useInBandFEC = 0; - int LBRR_enabled = 0; - int LBRR_GainIncreases = 0; - final SideInfoIndices[] indices_LBRR = new SideInfoIndices[3]; - final byte[][] pulses_LBRR = Arrays.InitTwoDimensionalArrayByte(3, 320); - final SilkShapeState sShape = new SilkShapeState(); - final SilkPrefilterState sPrefilt = new SilkPrefilterState(); - final short[] x_buf = new short[720]; - int LTPCorr_Q15 = 0; - - SilkChannelEncoder() { - for (int c = 0; c < 3; ++c) { - this.indices_LBRR[c] = new SideInfoIndices(); - } - } - - void Reset() { - Arrays.MemSet(this.In_HP_State, 0, 2); - this.variable_HP_smth1_Q15 = 0; - this.variable_HP_smth2_Q15 = 0; - this.sLP.Reset(); - this.sVAD.Reset(); - this.sNSQ.Reset(); - Arrays.MemSet(this.prev_NLSFq_Q15, (short)0, 16); - this.speech_activity_Q8 = 0; - this.allow_bandwidth_switch = 0; - this.LBRRprevLastGainIndex = 0; - this.prevSignalType = 0; - this.prevLag = 0; - this.pitch_LPC_win_length = 0; - this.max_pitch_lag = 0; - this.API_fs_Hz = 0; - this.prev_API_fs_Hz = 0; - this.maxInternal_fs_Hz = 0; - this.minInternal_fs_Hz = 0; - this.desiredInternal_fs_Hz = 0; - this.fs_kHz = 0; - this.nb_subfr = 0; - this.frame_length = 0; - this.subfr_length = 0; - this.ltp_mem_length = 0; - this.la_pitch = 0; - this.la_shape = 0; - this.shapeWinLength = 0; - this.TargetRate_bps = 0; - this.PacketSize_ms = 0; - this.PacketLoss_perc = 0; - this.frameCounter = 0; - this.Complexity = 0; - this.nStatesDelayedDecision = 0; - this.useInterpolatedNLSFs = 0; - this.shapingLPCOrder = 0; - this.predictLPCOrder = 0; - this.pitchEstimationComplexity = 0; - this.pitchEstimationLPCOrder = 0; - this.pitchEstimationThreshold_Q16 = 0; - this.LTPQuantLowComplexity = 0; - this.mu_LTP_Q9 = 0; - this.sum_log_gain_Q7 = 0; - this.NLSF_MSVQ_Survivors = 0; - this.first_frame_after_reset = 0; - this.controlled_since_last_payload = 0; - this.warping_Q16 = 0; - this.useCBR = 0; - this.prefillFlag = 0; - this.pitch_lag_low_bits_iCDF = null; - this.pitch_contour_iCDF = null; - this.psNLSF_CB = null; - Arrays.MemSet(this.input_quality_bands_Q15, 0, 4); - this.input_tilt_Q15 = 0; - this.SNR_dB_Q7 = 0; - Arrays.MemSet(this.VAD_flags, (byte)0, 3); - this.LBRR_flag = 0; - Arrays.MemSet(this.LBRR_flags, 0, 3); - this.indices.Reset(); - Arrays.MemSet(this.pulses, (byte)0, 320); - Arrays.MemSet(this.inputBuf, (short)0, 322); - this.inputBufIx = 0; - this.nFramesPerPacket = 0; - this.nFramesEncoded = 0; - this.nChannelsAPI = 0; - this.nChannelsInternal = 0; - this.channelNb = 0; - this.frames_since_onset = 0; - this.ec_prevSignalType = 0; - this.ec_prevLagIndex = 0; - this.resampler_state.Reset(); - this.useDTX = 0; - this.inDTX = 0; - this.noSpeechCounter = 0; - this.useInBandFEC = 0; - this.LBRR_enabled = 0; - this.LBRR_GainIncreases = 0; - for (int c = 0; c < 3; ++c) { - this.indices_LBRR[c].Reset(); - Arrays.MemSet(this.pulses_LBRR[c], (byte)0, 320); - } - this.sShape.Reset(); - this.sPrefilt.Reset(); - Arrays.MemSet(this.x_buf, (short)0, 720); - this.LTPCorr_Q15 = 0; - } - - int silk_control_encoder(EncControlState encControl, int TargetRate_bps, int allow_bw_switch, int channelNb, int force_fs_kHz) { - int ret = SilkError.SILK_NO_ERROR; - this.useDTX = encControl.useDTX; - this.useCBR = encControl.useCBR; - this.API_fs_Hz = encControl.API_sampleRate; - this.maxInternal_fs_Hz = encControl.maxInternalSampleRate; - this.minInternal_fs_Hz = encControl.minInternalSampleRate; - this.desiredInternal_fs_Hz = encControl.desiredInternalSampleRate; - this.useInBandFEC = encControl.useInBandFEC; - this.nChannelsAPI = encControl.nChannelsAPI; - this.nChannelsInternal = encControl.nChannelsInternal; - this.allow_bandwidth_switch = allow_bw_switch; - this.channelNb = channelNb; - if (this.controlled_since_last_payload != 0 && this.prefillFlag == 0) { - if (this.API_fs_Hz != this.prev_API_fs_Hz && this.fs_kHz > 0) { - ret = this.silk_setup_resamplers(this.fs_kHz); - } - return ret; - } - int fs_kHz = this.silk_control_audio_bandwidth(encControl); - if (force_fs_kHz != 0) { - fs_kHz = force_fs_kHz; - } - ret = this.silk_setup_resamplers(fs_kHz); - ret = this.silk_setup_fs(fs_kHz, encControl.payloadSize_ms); - ret = this.silk_setup_complexity(encControl.complexity); - this.PacketLoss_perc = encControl.packetLossPercentage; - ret = this.silk_setup_LBRR(TargetRate_bps); - this.controlled_since_last_payload = 1; - return ret; - } - - private int silk_setup_resamplers(int fs_kHz) { - int ret = 0; - if (this.fs_kHz != fs_kHz || this.prev_API_fs_Hz != this.API_fs_Hz) { - if (this.fs_kHz == 0) { - ret += Resampler.silk_resampler_init(this.resampler_state, this.API_fs_Hz, fs_kHz * 1000, 1); - } else { - SilkResamplerState temp_resampler_state = null; - int buf_length_ms = Inlines.silk_LSHIFT(this.nb_subfr * 5, 1) + 5; - int old_buf_samples = buf_length_ms * this.fs_kHz; - temp_resampler_state = new SilkResamplerState(); - ret += Resampler.silk_resampler_init(temp_resampler_state, Inlines.silk_SMULBB(this.fs_kHz, 1000), this.API_fs_Hz, 0); - int api_buf_samples = buf_length_ms * Inlines.silk_DIV32_16(this.API_fs_Hz, 1000); - short[] x_buf_API_fs_Hz = new short[api_buf_samples]; - ret += Resampler.silk_resampler(temp_resampler_state, x_buf_API_fs_Hz, 0, this.x_buf, 0, old_buf_samples); - ret += Resampler.silk_resampler_init(this.resampler_state, this.API_fs_Hz, Inlines.silk_SMULBB(fs_kHz, 1000), 1); - ret += Resampler.silk_resampler(this.resampler_state, this.x_buf, 0, x_buf_API_fs_Hz, 0, api_buf_samples); - } - } - this.prev_API_fs_Hz = this.API_fs_Hz; - return ret; - } - - private int silk_setup_fs(int fs_kHz, int PacketSize_ms) { - int ret = SilkError.SILK_NO_ERROR; - if (PacketSize_ms != this.PacketSize_ms) { - if (PacketSize_ms != 10 && PacketSize_ms != 20 && PacketSize_ms != 40 && PacketSize_ms != 60) { - ret = SilkError.SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; - } - if (PacketSize_ms <= 10) { - this.nFramesPerPacket = 1; - this.nb_subfr = PacketSize_ms == 10 ? 2 : 1; - this.frame_length = Inlines.silk_SMULBB(PacketSize_ms, fs_kHz); - this.pitch_LPC_win_length = Inlines.silk_SMULBB(14, fs_kHz); - this.pitch_contour_iCDF = this.fs_kHz == 8 ? SilkTables.silk_pitch_contour_10_ms_NB_iCDF : SilkTables.silk_pitch_contour_10_ms_iCDF; - } else { - this.nFramesPerPacket = Inlines.silk_DIV32_16(PacketSize_ms, 20); - this.nb_subfr = 4; - this.frame_length = Inlines.silk_SMULBB(20, fs_kHz); - this.pitch_LPC_win_length = Inlines.silk_SMULBB(24, fs_kHz); - this.pitch_contour_iCDF = this.fs_kHz == 8 ? SilkTables.silk_pitch_contour_NB_iCDF : SilkTables.silk_pitch_contour_iCDF; - } - this.PacketSize_ms = PacketSize_ms; - this.TargetRate_bps = 0; - } - Inlines.OpusAssert(fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16); - Inlines.OpusAssert(this.nb_subfr == 2 || this.nb_subfr == 4); - if (this.fs_kHz != fs_kHz) { - this.sShape.Reset(); - this.sPrefilt.Reset(); - this.sNSQ.Reset(); - Arrays.MemSet(this.prev_NLSFq_Q15, (short)0, 16); - Arrays.MemSet(this.sLP.In_LP_State, 0, 2); - this.inputBufIx = 0; - this.nFramesEncoded = 0; - this.TargetRate_bps = 0; - this.prevLag = 100; - this.first_frame_after_reset = 1; - this.sPrefilt.lagPrev = 100; - this.sShape.LastGainIndex = (byte)10; - this.sNSQ.lagPrev = 100; - this.sNSQ.prev_gain_Q16 = 65536; - this.prevSignalType = 0; - this.fs_kHz = fs_kHz; - this.pitch_contour_iCDF = this.fs_kHz == 8 ? (this.nb_subfr == 4 ? SilkTables.silk_pitch_contour_NB_iCDF : SilkTables.silk_pitch_contour_10_ms_NB_iCDF) : (this.nb_subfr == 4 ? SilkTables.silk_pitch_contour_iCDF : SilkTables.silk_pitch_contour_10_ms_iCDF); - if (this.fs_kHz == 8 || this.fs_kHz == 12) { - this.predictLPCOrder = 10; - this.psNLSF_CB = SilkTables.silk_NLSF_CB_NB_MB; - } else { - this.predictLPCOrder = 16; - this.psNLSF_CB = SilkTables.silk_NLSF_CB_WB; - } - this.subfr_length = 5 * fs_kHz; - this.frame_length = Inlines.silk_SMULBB(this.subfr_length, this.nb_subfr); - this.ltp_mem_length = Inlines.silk_SMULBB(20, fs_kHz); - this.la_pitch = Inlines.silk_SMULBB(2, fs_kHz); - this.max_pitch_lag = Inlines.silk_SMULBB(18, fs_kHz); - this.pitch_LPC_win_length = this.nb_subfr == 4 ? Inlines.silk_SMULBB(24, fs_kHz) : Inlines.silk_SMULBB(14, fs_kHz); - if (this.fs_kHz == 16) { - this.mu_LTP_Q9 = 10; - this.pitch_lag_low_bits_iCDF = SilkTables.silk_uniform8_iCDF; - } else if (this.fs_kHz == 12) { - this.mu_LTP_Q9 = 13; - this.pitch_lag_low_bits_iCDF = SilkTables.silk_uniform6_iCDF; - } else { - this.mu_LTP_Q9 = 15; - this.pitch_lag_low_bits_iCDF = SilkTables.silk_uniform4_iCDF; - } - } - Inlines.OpusAssert(this.subfr_length * this.nb_subfr == this.frame_length); - return ret; - } - - private int silk_setup_complexity(int Complexity) { - int ret = 0; - Inlines.OpusAssert(Complexity >= 0 && Complexity <= 10); - if (Complexity < 2) { - this.pitchEstimationComplexity = 0; - this.pitchEstimationThreshold_Q16 = 52429; - this.pitchEstimationLPCOrder = 6; - this.shapingLPCOrder = 8; - this.la_shape = 3 * this.fs_kHz; - this.nStatesDelayedDecision = 1; - this.useInterpolatedNLSFs = 0; - this.LTPQuantLowComplexity = 1; - this.NLSF_MSVQ_Survivors = 2; - this.warping_Q16 = 0; - } else if (Complexity < 4) { - this.pitchEstimationComplexity = 1; - this.pitchEstimationThreshold_Q16 = 49807; - this.pitchEstimationLPCOrder = 8; - this.shapingLPCOrder = 10; - this.la_shape = 5 * this.fs_kHz; - this.nStatesDelayedDecision = 1; - this.useInterpolatedNLSFs = 0; - this.LTPQuantLowComplexity = 0; - this.NLSF_MSVQ_Survivors = 4; - this.warping_Q16 = 0; - } else if (Complexity < 6) { - this.pitchEstimationComplexity = 1; - this.pitchEstimationThreshold_Q16 = 48497; - this.pitchEstimationLPCOrder = 10; - this.shapingLPCOrder = 12; - this.la_shape = 5 * this.fs_kHz; - this.nStatesDelayedDecision = 2; - this.useInterpolatedNLSFs = 1; - this.LTPQuantLowComplexity = 0; - this.NLSF_MSVQ_Survivors = 8; - this.warping_Q16 = this.fs_kHz * 983; - } else if (Complexity < 8) { - this.pitchEstimationComplexity = 1; - this.pitchEstimationThreshold_Q16 = 47186; - this.pitchEstimationLPCOrder = 12; - this.shapingLPCOrder = 14; - this.la_shape = 5 * this.fs_kHz; - this.nStatesDelayedDecision = 3; - this.useInterpolatedNLSFs = 1; - this.LTPQuantLowComplexity = 0; - this.NLSF_MSVQ_Survivors = 16; - this.warping_Q16 = this.fs_kHz * 983; - } else { - this.pitchEstimationComplexity = 2; - this.pitchEstimationThreshold_Q16 = 45875; - this.pitchEstimationLPCOrder = 16; - this.shapingLPCOrder = 16; - this.la_shape = 5 * this.fs_kHz; - this.nStatesDelayedDecision = 4; - this.useInterpolatedNLSFs = 1; - this.LTPQuantLowComplexity = 0; - this.NLSF_MSVQ_Survivors = 32; - this.warping_Q16 = this.fs_kHz * 983; - } - this.pitchEstimationLPCOrder = Inlines.silk_min_int(this.pitchEstimationLPCOrder, this.predictLPCOrder); - this.shapeWinLength = 5 * this.fs_kHz + 2 * this.la_shape; - this.Complexity = Complexity; - Inlines.OpusAssert(this.pitchEstimationLPCOrder <= 16); - Inlines.OpusAssert(this.shapingLPCOrder <= 16); - Inlines.OpusAssert(this.nStatesDelayedDecision <= 4); - Inlines.OpusAssert(this.warping_Q16 <= Short.MAX_VALUE); - Inlines.OpusAssert(this.la_shape <= 80); - Inlines.OpusAssert(this.shapeWinLength <= 240); - Inlines.OpusAssert(this.NLSF_MSVQ_Survivors <= 32); - return ret; - } - - private int silk_setup_LBRR(int TargetRate_bps) { - int ret = SilkError.SILK_NO_ERROR; - int LBRR_in_previous_packet = this.LBRR_enabled; - this.LBRR_enabled = 0; - if (this.useInBandFEC != 0 && this.PacketLoss_perc > 0) { - int LBRR_rate_thres_bps = this.fs_kHz == 8 ? 12000 : (this.fs_kHz == 12 ? 14000 : 16000); - if (TargetRate_bps > (LBRR_rate_thres_bps = Inlines.silk_SMULWB(Inlines.silk_MUL(LBRR_rate_thres_bps, 125 - Inlines.silk_min(this.PacketLoss_perc, 25)), 655))) { - this.LBRR_GainIncreases = LBRR_in_previous_packet == 0 ? 7 : Inlines.silk_max_int(7 - Inlines.silk_SMULWB(this.PacketLoss_perc, 26214), 2); - this.LBRR_enabled = 1; - } - } - return ret; - } - - int silk_control_audio_bandwidth(EncControlState encControl) { - int fs_kHz = this.fs_kHz; - int fs_Hz = Inlines.silk_SMULBB(fs_kHz, 1000); - if (fs_Hz == 0) { - fs_Hz = Inlines.silk_min(this.desiredInternal_fs_Hz, this.API_fs_Hz); - fs_kHz = Inlines.silk_DIV32_16(fs_Hz, 1000); - } else if (fs_Hz > this.API_fs_Hz || fs_Hz > this.maxInternal_fs_Hz || fs_Hz < this.minInternal_fs_Hz) { - fs_Hz = this.API_fs_Hz; - fs_Hz = Inlines.silk_min(fs_Hz, this.maxInternal_fs_Hz); - fs_Hz = Inlines.silk_max(fs_Hz, this.minInternal_fs_Hz); - fs_kHz = Inlines.silk_DIV32_16(fs_Hz, 1000); - } else { - if (this.sLP.transition_frame_no >= 256) { - this.sLP.mode = 0; - } - if (this.allow_bandwidth_switch != 0 || encControl.opusCanSwitch != 0) { - if (Inlines.silk_SMULBB(this.fs_kHz, 1000) > this.desiredInternal_fs_Hz) { - if (this.sLP.mode == 0) { - this.sLP.transition_frame_no = 256; - Arrays.MemSet(this.sLP.In_LP_State, 0, 2); - } - if (encControl.opusCanSwitch != 0) { - this.sLP.mode = 0; - fs_kHz = this.fs_kHz == 16 ? 12 : 8; - } else if (this.sLP.transition_frame_no <= 0) { - encControl.switchReady = 1; - encControl.maxBits -= encControl.maxBits * 5 / (encControl.payloadSize_ms + 5); - } else { - this.sLP.mode = -2; - } - } else if (Inlines.silk_SMULBB(this.fs_kHz, 1000) < this.desiredInternal_fs_Hz) { - if (encControl.opusCanSwitch != 0) { - fs_kHz = this.fs_kHz == 8 ? 12 : 16; - this.sLP.transition_frame_no = 0; - Arrays.MemSet(this.sLP.In_LP_State, 0, 2); - this.sLP.mode = 1; - } else if (this.sLP.mode == 0) { - encControl.switchReady = 1; - encControl.maxBits -= encControl.maxBits * 5 / (encControl.payloadSize_ms + 5); - } else { - this.sLP.mode = 1; - } - } else if (this.sLP.mode < 0) { - this.sLP.mode = 1; - } - } - } - return fs_kHz; - } - - int silk_control_SNR(int TargetRate_bps) { - int ret = SilkError.SILK_NO_ERROR; - if ((TargetRate_bps = Inlines.silk_LIMIT(TargetRate_bps, 5000, 80000)) != this.TargetRate_bps) { - this.TargetRate_bps = TargetRate_bps; - int[] rateTable = this.fs_kHz == 8 ? SilkTables.silk_TargetRate_table_NB : (this.fs_kHz == 12 ? SilkTables.silk_TargetRate_table_MB : SilkTables.silk_TargetRate_table_WB); - if (this.nb_subfr == 2) { - TargetRate_bps -= 2200; - } - for (int k = 1; k < 8; ++k) { - if (TargetRate_bps > rateTable[k]) continue; - int frac_Q6 = Inlines.silk_DIV32(Inlines.silk_LSHIFT(TargetRate_bps - rateTable[k - 1], 6), rateTable[k] - rateTable[k - 1]); - this.SNR_dB_Q7 = Inlines.silk_LSHIFT(SilkTables.silk_SNR_table_Q1[k - 1], 6) + Inlines.silk_MUL(frac_Q6, SilkTables.silk_SNR_table_Q1[k] - SilkTables.silk_SNR_table_Q1[k - 1]); - break; - } - } - return ret; - } - - void silk_encode_do_VAD() { - VoiceActivityDetection.silk_VAD_GetSA_Q8(this, this.inputBuf, 1); - if (this.speech_activity_Q8 < 13) { - this.indices.signalType = 0; - ++this.noSpeechCounter; - if (this.noSpeechCounter < 10) { - this.inDTX = 0; - } else if (this.noSpeechCounter > 30) { - this.noSpeechCounter = 10; - this.inDTX = 0; - } - this.VAD_flags[this.nFramesEncoded] = 0; - } else { - this.noSpeechCounter = 0; - this.inDTX = 0; - this.indices.signalType = 1; - this.VAD_flags[this.nFramesEncoded] = 1; - } - } - - int silk_encode_frame(BoxedValueInt pnBytesOut, EntropyCoder psRangeEnc, int condCoding, int maxBits, int useCBR) { - SilkEncoderControl sEncCtrl = new SilkEncoderControl(); - int ret = 0; - EntropyCoder sRangeEnc_copy = new EntropyCoder(); - EntropyCoder sRangeEnc_copy2 = new EntropyCoder(); - SilkNSQState sNSQ_copy = new SilkNSQState(); - SilkNSQState sNSQ_copy2 = new SilkNSQState(); - byte LastGainIndex_copy2 = 0; - int gainMult_upper = 0; - int gainMult_lower = 0; - int nBits_upper = 0; - int nBits_lower = 0; - this.indices.Seed = (byte)(this.frameCounter++ & 3); - int x_frame = this.ltp_mem_length; - this.sLP.silk_LP_variable_cutoff(this.inputBuf, 1, this.frame_length); - System.arraycopy(this.inputBuf, 1, this.x_buf, x_frame + 5 * this.fs_kHz, this.frame_length); - if (this.prefillFlag == 0) { - short[] res_pitch = new short[this.la_pitch + this.frame_length + this.ltp_mem_length]; - int res_pitch_frame = this.ltp_mem_length; - FindPitchLags.silk_find_pitch_lags(this, sEncCtrl, res_pitch, this.x_buf, x_frame); - NoiseShapeAnalysis.silk_noise_shape_analysis(this, sEncCtrl, res_pitch, res_pitch_frame, this.x_buf, x_frame); - FindPredCoefs.silk_find_pred_coefs(this, sEncCtrl, res_pitch, this.x_buf, x_frame, condCoding); - ProcessGains.silk_process_gains(this, sEncCtrl, condCoding); - int[] xfw_Q3 = new int[this.frame_length]; - Filters.silk_prefilter(this, sEncCtrl, xfw_Q3, this.x_buf, x_frame); - this.silk_LBRR_encode(sEncCtrl, xfw_Q3, condCoding); - int maxIter = 6; - int gainMult_Q8 = 256; - boolean found_lower = false; - boolean found_upper = false; - int gainsID = GainQuantization.silk_gains_ID(this.indices.GainsIndices, this.nb_subfr); - int gainsID_lower = -1; - int gainsID_upper = -1; - sRangeEnc_copy.Assign(psRangeEnc); - sNSQ_copy.Assign(this.sNSQ); - byte seed_copy = this.indices.Seed; - short ec_prevLagIndex_copy = this.ec_prevLagIndex; - int ec_prevSignalType_copy = this.ec_prevSignalType; - byte[] ec_buf_copy = new byte[1275]; - int iter = 0; - while (true) { - int nBits; - if (gainsID == gainsID_lower) { - nBits = nBits_lower; - } else if (gainsID == gainsID_upper) { - nBits = nBits_upper; - } else { - if (iter > 0) { - psRangeEnc.Assign(sRangeEnc_copy); - this.sNSQ.Assign(sNSQ_copy); - this.indices.Seed = seed_copy; - this.ec_prevLagIndex = ec_prevLagIndex_copy; - this.ec_prevSignalType = ec_prevSignalType_copy; - } - if (this.nStatesDelayedDecision > 1 || this.warping_Q16 > 0) { - this.sNSQ.silk_NSQ_del_dec(this, this.indices, xfw_Q3, this.pulses, sEncCtrl.PredCoef_Q12, sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14); - } else { - this.sNSQ.silk_NSQ(this, this.indices, xfw_Q3, this.pulses, sEncCtrl.PredCoef_Q12, sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14); - } - EncodeIndices.silk_encode_indices(this, psRangeEnc, this.nFramesEncoded, 0, condCoding); - EncodePulses.silk_encode_pulses(psRangeEnc, this.indices.signalType, this.indices.quantOffsetType, this.pulses, this.frame_length); - nBits = psRangeEnc.tell(); - if (useCBR == 0 && iter == 0 && nBits <= maxBits) break; - } - if (iter == maxIter) { - if (!found_lower || gainsID != gainsID_lower && nBits <= maxBits) break; - psRangeEnc.Assign(sRangeEnc_copy2); - Inlines.OpusAssert(sRangeEnc_copy2.offs <= 1275); - psRangeEnc.write_buffer(ec_buf_copy, 0, 0, sRangeEnc_copy2.offs); - this.sNSQ.Assign(sNSQ_copy2); - this.sShape.LastGainIndex = LastGainIndex_copy2; - break; - } - if (nBits > maxBits) { - if (!found_lower && iter >= 2) { - sEncCtrl.Lambda_Q10 = Inlines.silk_ADD_RSHIFT32(sEncCtrl.Lambda_Q10, sEncCtrl.Lambda_Q10, 1); - found_upper = false; - gainsID_upper = -1; - } else { - found_upper = true; - nBits_upper = nBits; - gainMult_upper = gainMult_Q8; - gainsID_upper = gainsID; - } - } else { - if (nBits >= maxBits - 5) break; - found_lower = true; - nBits_lower = nBits; - gainMult_lower = gainMult_Q8; - if (gainsID != gainsID_lower) { - gainsID_lower = gainsID; - sRangeEnc_copy2.Assign(psRangeEnc); - Inlines.OpusAssert(psRangeEnc.offs <= 1275); - System.arraycopy(psRangeEnc.get_buffer(), 0, ec_buf_copy, 0, psRangeEnc.offs); - sNSQ_copy2.Assign(this.sNSQ); - LastGainIndex_copy2 = this.sShape.LastGainIndex; - } - } - if (!(found_lower & found_upper)) { - int gain_factor_Q16 = Inlines.silk_log2lin(Inlines.silk_LSHIFT(nBits - maxBits, 7) / this.frame_length + 2048); - gain_factor_Q16 = Inlines.silk_min_32(gain_factor_Q16, 131072); - if (nBits > maxBits) { - gain_factor_Q16 = Inlines.silk_max_32(gain_factor_Q16, 85197); - } - gainMult_Q8 = (short)Inlines.silk_SMULWB(gain_factor_Q16, gainMult_Q8); - } else { - gainMult_Q8 = (short)(gainMult_lower + Inlines.silk_DIV32_16(Inlines.silk_MUL(gainMult_upper - gainMult_lower, maxBits - nBits_lower), nBits_upper - nBits_lower)); - if (gainMult_Q8 > Inlines.silk_ADD_RSHIFT32(gainMult_lower, gainMult_upper - gainMult_lower, 2)) { - gainMult_Q8 = (short)Inlines.silk_ADD_RSHIFT32(gainMult_lower, gainMult_upper - gainMult_lower, 2); - } else if (gainMult_Q8 < Inlines.silk_SUB_RSHIFT32(gainMult_upper, gainMult_upper - gainMult_lower, 2)) { - gainMult_Q8 = (short)Inlines.silk_SUB_RSHIFT32(gainMult_upper, gainMult_upper - gainMult_lower, 2); - } - } - for (int i = 0; i < this.nb_subfr; ++i) { - sEncCtrl.Gains_Q16[i] = Inlines.silk_LSHIFT_SAT32(Inlines.silk_SMULWB(sEncCtrl.GainsUnq_Q16[i], gainMult_Q8), 8); - } - this.sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; - BoxedValueByte boxed_gainIndex = new BoxedValueByte(this.sShape.LastGainIndex); - GainQuantization.silk_gains_quant(this.indices.GainsIndices, sEncCtrl.Gains_Q16, boxed_gainIndex, condCoding == 2 ? 1 : 0, this.nb_subfr); - this.sShape.LastGainIndex = boxed_gainIndex.Val; - gainsID = GainQuantization.silk_gains_ID(this.indices.GainsIndices, this.nb_subfr); - ++iter; - } - } - Arrays.MemMove(this.x_buf, this.frame_length, 0, this.ltp_mem_length + 5 * this.fs_kHz); - if (this.prefillFlag != 0) { - pnBytesOut.Val = 0; - return ret; - } - this.prevLag = sEncCtrl.pitchL[this.nb_subfr - 1]; - this.prevSignalType = this.indices.signalType; - this.first_frame_after_reset = 0; - pnBytesOut.Val = Inlines.silk_RSHIFT(psRangeEnc.tell() + 7, 3); - return ret; - } - - void silk_LBRR_encode(SilkEncoderControl thisCtrl, int[] xfw_Q3, int condCoding) { - int[] TempGains_Q16 = new int[this.nb_subfr]; - SideInfoIndices psIndices_LBRR = this.indices_LBRR[this.nFramesEncoded]; - SilkNSQState sNSQ_LBRR = new SilkNSQState(); - if (this.LBRR_enabled != 0 && this.speech_activity_Q8 > 77) { - this.LBRR_flags[this.nFramesEncoded] = 1; - sNSQ_LBRR.Assign(this.sNSQ); - psIndices_LBRR.Assign(this.indices); - System.arraycopy(thisCtrl.Gains_Q16, 0, TempGains_Q16, 0, this.nb_subfr); - if (this.nFramesEncoded == 0 || this.LBRR_flags[this.nFramesEncoded - 1] == 0) { - this.LBRRprevLastGainIndex = this.sShape.LastGainIndex; - psIndices_LBRR.GainsIndices[0] = (byte)(psIndices_LBRR.GainsIndices[0] + this.LBRR_GainIncreases); - psIndices_LBRR.GainsIndices[0] = (byte)Inlines.silk_min_int(psIndices_LBRR.GainsIndices[0], 63); - } - BoxedValueByte boxed_gainIndex = new BoxedValueByte(this.LBRRprevLastGainIndex); - GainQuantization.silk_gains_dequant(thisCtrl.Gains_Q16, psIndices_LBRR.GainsIndices, boxed_gainIndex, condCoding == 2 ? 1 : 0, this.nb_subfr); - this.LBRRprevLastGainIndex = boxed_gainIndex.Val; - if (this.nStatesDelayedDecision > 1 || this.warping_Q16 > 0) { - sNSQ_LBRR.silk_NSQ_del_dec(this, psIndices_LBRR, xfw_Q3, this.pulses_LBRR[this.nFramesEncoded], thisCtrl.PredCoef_Q12, thisCtrl.LTPCoef_Q14, thisCtrl.AR2_Q13, thisCtrl.HarmShapeGain_Q14, thisCtrl.Tilt_Q14, thisCtrl.LF_shp_Q14, thisCtrl.Gains_Q16, thisCtrl.pitchL, thisCtrl.Lambda_Q10, thisCtrl.LTP_scale_Q14); - } else { - sNSQ_LBRR.silk_NSQ(this, psIndices_LBRR, xfw_Q3, this.pulses_LBRR[this.nFramesEncoded], thisCtrl.PredCoef_Q12, thisCtrl.LTPCoef_Q14, thisCtrl.AR2_Q13, thisCtrl.HarmShapeGain_Q14, thisCtrl.Tilt_Q14, thisCtrl.LF_shp_Q14, thisCtrl.Gains_Q16, thisCtrl.pitchL, thisCtrl.Lambda_Q10, thisCtrl.LTP_scale_Q14); - } - System.arraycopy(TempGains_Q16, 0, thisCtrl.Gains_Q16, 0, this.nb_subfr); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkConstants.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkConstants.java deleted file mode 100644 index 0d28397..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkConstants.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class SilkConstants { - public static final int ENCODER_NUM_CHANNELS = 2; - public static final int DECODER_NUM_CHANNELS = 2; - public static final int MAX_FRAMES_PER_PACKET = 3; - public static final int MIN_TARGET_RATE_BPS = 5000; - public static final int MAX_TARGET_RATE_BPS = 80000; - public static final int TARGET_RATE_TAB_SZ = 8; - public static final int LBRR_NB_MIN_RATE_BPS = 12000; - public static final int LBRR_MB_MIN_RATE_BPS = 14000; - public static final int LBRR_WB_MIN_RATE_BPS = 16000; - public static final int NB_SPEECH_FRAMES_BEFORE_DTX = 10; - public static final int MAX_CONSECUTIVE_DTX = 20; - public static final int MAX_FS_KHZ = 16; - public static final int MAX_API_FS_KHZ = 48; - public static final int TYPE_NO_VOICE_ACTIVITY = 0; - public static final int TYPE_UNVOICED = 1; - public static final int TYPE_VOICED = 2; - public static final int CODE_INDEPENDENTLY = 0; - public static final int CODE_INDEPENDENTLY_NO_LTP_SCALING = 1; - public static final int CODE_CONDITIONALLY = 2; - public static final int STEREO_QUANT_TAB_SIZE = 16; - public static final int STEREO_QUANT_SUB_STEPS = 5; - public static final int STEREO_INTERP_LEN_MS = 8; - public static final float STEREO_RATIO_SMOOTH_COEF = 0.01f; - public static final int PITCH_EST_MIN_LAG_MS = 2; - public static final int PITCH_EST_MAX_LAG_MS = 18; - public static final int MAX_NB_SUBFR = 4; - public static final int LTP_MEM_LENGTH_MS = 20; - public static final int SUB_FRAME_LENGTH_MS = 5; - public static final int MAX_SUB_FRAME_LENGTH = 80; - public static final int MAX_FRAME_LENGTH_MS = 20; - public static final int MAX_FRAME_LENGTH = 320; - public static final int LA_PITCH_MS = 2; - public static final int LA_PITCH_MAX = 32; - public static final int MAX_FIND_PITCH_LPC_ORDER = 16; - public static final int FIND_PITCH_LPC_WIN_MS = 24; - public static final int FIND_PITCH_LPC_WIN_MS_2_SF = 14; - public static final int FIND_PITCH_LPC_WIN_MAX = 384; - public static final int LA_SHAPE_MS = 5; - public static final int LA_SHAPE_MAX = 80; - public static final int SHAPE_LPC_WIN_MAX = 240; - public static final int MIN_QGAIN_DB = 2; - public static final int MAX_QGAIN_DB = 88; - public static final int N_LEVELS_QGAIN = 64; - public static final int MAX_DELTA_GAIN_QUANT = 36; - public static final int MIN_DELTA_GAIN_QUANT = -4; - public static final short OFFSET_VL_Q10 = 32; - public static final short OFFSET_VH_Q10 = 100; - public static final short OFFSET_UVL_Q10 = 100; - public static final short OFFSET_UVH_Q10 = 240; - public static final int QUANT_LEVEL_ADJUST_Q10 = 80; - public static final int MAX_LPC_STABILIZE_ITERATIONS = 16; - public static final float MAX_PREDICTION_POWER_GAIN = 10000.0f; - public static final float MAX_PREDICTION_POWER_GAIN_AFTER_RESET = 100.0f; - public static final int SILK_MAX_ORDER_LPC = 16; - public static final int MAX_LPC_ORDER = 16; - public static final int MIN_LPC_ORDER = 10; - public static final int LTP_ORDER = 5; - public static final int NB_LTP_CBKS = 3; - public static final int USE_HARM_SHAPING = 1; - public static final int MAX_SHAPE_LPC_ORDER = 16; - public static final int HARM_SHAPE_FIR_TAPS = 3; - public static final int MAX_DEL_DEC_STATES = 4; - public static final int LTP_BUF_LENGTH = 512; - public static final int LTP_MASK = 511; - public static final int DECISION_DELAY = 32; - public static final int DECISION_DELAY_MASK = 31; - public static final int SHELL_CODEC_FRAME_LENGTH = 16; - public static final int LOG2_SHELL_CODEC_FRAME_LENGTH = 4; - public static final int MAX_NB_SHELL_BLOCKS = 20; - public static final int N_RATE_LEVELS = 10; - public static final int SILK_MAX_PULSES = 16; - public static final int MAX_MATRIX_SIZE = 16; - static final int NSQ_LPC_BUF_LENGTH = Math.max(16, 32); - public static final int VAD_N_BANDS = 4; - public static final int VAD_INTERNAL_SUBFRAMES_LOG2 = 2; - public static final int VAD_INTERNAL_SUBFRAMES = 4; - public static final int VAD_NOISE_LEVEL_SMOOTH_COEF_Q16 = 1024; - public static final int VAD_NOISE_LEVELS_BIAS = 50; - public static final int VAD_NEGATIVE_OFFSET_Q5 = 128; - public static final int VAD_SNR_FACTOR_Q16 = 45000; - public static final int VAD_SNR_SMOOTH_COEF_Q18 = 4096; - public static final int LSF_COS_TAB_SZ = 128; - public static final int NLSF_W_Q = 2; - public static final int NLSF_VQ_MAX_VECTORS = 32; - public static final int NLSF_VQ_MAX_SURVIVORS = 32; - public static final int NLSF_QUANT_MAX_AMPLITUDE = 4; - public static final int NLSF_QUANT_MAX_AMPLITUDE_EXT = 10; - public static final float NLSF_QUANT_LEVEL_ADJ = 0.1f; - public static final int NLSF_QUANT_DEL_DEC_STATES_LOG2 = 2; - public static final int NLSF_QUANT_DEL_DEC_STATES = 4; - public static final int TRANSITION_TIME_MS = 5120; - public static final int TRANSITION_NB = 3; - public static final int TRANSITION_NA = 2; - public static final int TRANSITION_INT_NUM = 5; - public static final int TRANSITION_FRAMES = 256; - public static final int TRANSITION_INT_STEPS = 64; - public static final int BWE_AFTER_LOSS_Q16 = 63570; - public static final int CNG_BUF_MASK_MAX = 255; - public static final int CNG_GAIN_SMTH_Q16 = 4634; - public static final int CNG_NLSF_SMTH_Q16 = 16348; - public static final int PE_MAX_FS_KHZ = 16; - public static final int PE_MAX_NB_SUBFR = 4; - public static final int PE_SUBFR_LENGTH_MS = 5; - public static final int PE_LTP_MEM_LENGTH_MS = 20; - public static final int PE_MAX_FRAME_LENGTH_MS = 40; - public static final int PE_MAX_FRAME_LENGTH = 640; - public static final int PE_MAX_FRAME_LENGTH_ST_1 = 160; - public static final int PE_MAX_FRAME_LENGTH_ST_2 = 320; - public static final int PE_MAX_LAG_MS = 18; - public static final int PE_MIN_LAG_MS = 2; - public static final int PE_MAX_LAG = 288; - public static final int PE_MIN_LAG = 32; - public static final int PE_D_SRCH_LENGTH = 24; - public static final int PE_NB_STAGE3_LAGS = 5; - public static final int PE_NB_CBKS_STAGE2 = 3; - public static final int PE_NB_CBKS_STAGE2_EXT = 11; - public static final int PE_NB_CBKS_STAGE3_MAX = 34; - public static final int PE_NB_CBKS_STAGE3_MID = 24; - public static final int PE_NB_CBKS_STAGE3_MIN = 16; - public static final int PE_NB_CBKS_STAGE3_10MS = 12; - public static final int PE_NB_CBKS_STAGE2_10MS = 3; - public static final float PE_SHORTLAG_BIAS = 0.2f; - public static final float PE_PREVLAG_BIAS = 0.2f; - public static final float PE_FLATCONTOUR_BIAS = 0.05f; - public static final int SILK_PE_MIN_COMPLEX = 0; - public static final int SILK_PE_MID_COMPLEX = 1; - public static final int SILK_PE_MAX_COMPLEX = 2; - public static final float BWE_COEF = 0.99f; - public static final int V_PITCH_GAIN_START_MIN_Q14 = 11469; - public static final int V_PITCH_GAIN_START_MAX_Q14 = 15565; - public static final int MAX_PITCH_LAG_MS = 18; - public static final int RAND_BUF_SIZE = 128; - public static final int RAND_BUF_MASK = 127; - public static final int LOG2_INV_LPC_GAIN_HIGH_THRES = 3; - public static final int LOG2_INV_LPC_GAIN_LOW_THRES = 8; - public static final int PITCH_DRIFT_FAC_Q16 = 655; - public static final int SILK_RESAMPLER_MAX_FIR_ORDER = 36; - public static final int SILK_RESAMPLER_MAX_IIR_ORDER = 6; - public static final int RESAMPLER_DOWN_ORDER_FIR0 = 18; - public static final int RESAMPLER_DOWN_ORDER_FIR1 = 24; - public static final int RESAMPLER_DOWN_ORDER_FIR2 = 36; - public static final int RESAMPLER_ORDER_FIR_12 = 8; - public static final int RESAMPLER_MAX_BATCH_SIZE_MS = 10; - public static final int RESAMPLER_MAX_FS_KHZ = 48; - public static final int RESAMPLER_MAX_BATCH_SIZE_IN = 480; - public static final int SILK_MAX_FRAMES_PER_PACKET = 3; - - SilkConstants() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkDecoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkDecoder.java deleted file mode 100644 index af6bbc4..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkDecoder.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.SilkChannelDecoder; -import de.maxhenkel.voicechat.concentus.StereoDecodeState; - -class SilkDecoder { - final SilkChannelDecoder[] channel_state = new SilkChannelDecoder[2]; - final StereoDecodeState sStereo = new StereoDecodeState(); - int nChannelsAPI = 0; - int nChannelsInternal = 0; - int prev_decode_only_middle = 0; - - SilkDecoder() { - for (int c = 0; c < 2; ++c) { - this.channel_state[c] = new SilkChannelDecoder(); - } - } - - void Reset() { - for (int c = 0; c < 2; ++c) { - this.channel_state[c].Reset(); - } - this.sStereo.Reset(); - this.nChannelsAPI = 0; - this.nChannelsInternal = 0; - this.prev_decode_only_middle = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkDecoderControl.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkDecoderControl.java deleted file mode 100644 index 1f0f1ff..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkDecoderControl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class SilkDecoderControl { - final int[] pitchL = new int[4]; - final int[] Gains_Q16 = new int[4]; - final short[][] PredCoef_Q12 = Arrays.InitTwoDimensionalArrayShort(2, 16); - final short[] LTPCoef_Q14 = new short[20]; - int LTP_scale_Q14 = 0; - - SilkDecoderControl() { - } - - void Reset() { - Arrays.MemSet(this.pitchL, 0, 4); - Arrays.MemSet(this.Gains_Q16, 0, 4); - Arrays.MemSet(this.PredCoef_Q12[0], (short)0, 16); - Arrays.MemSet(this.PredCoef_Q12[1], (short)0, 16); - Arrays.MemSet(this.LTPCoef_Q14, (short)0, 20); - this.LTP_scale_Q14 = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkEncoder.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkEncoder.java deleted file mode 100644 index 831490b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkEncoder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.StereoEncodeState; -import de.maxhenkel.voicechat.concentus.VoiceActivityDetection; - -class SilkEncoder { - final SilkChannelEncoder[] state_Fxx = new SilkChannelEncoder[2]; - final StereoEncodeState sStereo = new StereoEncodeState(); - int nBitsUsedLBRR = 0; - int nBitsExceeded = 0; - int nChannelsAPI = 0; - int nChannelsInternal = 0; - int nPrevChannelsInternal = 0; - int timeSinceSwitchAllowed_ms = 0; - int allowBandwidthSwitch = 0; - int prev_decode_only_middle = 0; - - SilkEncoder() { - for (int c = 0; c < 2; ++c) { - this.state_Fxx[c] = new SilkChannelEncoder(); - } - } - - void Reset() { - for (int c = 0; c < 2; ++c) { - this.state_Fxx[c].Reset(); - } - this.sStereo.Reset(); - this.nBitsUsedLBRR = 0; - this.nBitsExceeded = 0; - this.nChannelsAPI = 0; - this.nChannelsInternal = 0; - this.nPrevChannelsInternal = 0; - this.timeSinceSwitchAllowed_ms = 0; - this.allowBandwidthSwitch = 0; - this.prev_decode_only_middle = 0; - } - - static int silk_init_encoder(SilkChannelEncoder psEnc) { - int ret = 0; - psEnc.Reset(); - psEnc.variable_HP_smth2_Q15 = psEnc.variable_HP_smth1_Q15 = Inlines.silk_LSHIFT(Inlines.silk_lin2log(0x3C0000) - 2048, 8); - psEnc.first_frame_after_reset = 1; - return ret += VoiceActivityDetection.silk_VAD_Init(psEnc.sVAD); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkEncoderControl.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkEncoderControl.java deleted file mode 100644 index 8a61578..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkEncoderControl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class SilkEncoderControl { - final int[] Gains_Q16 = new int[4]; - final short[][] PredCoef_Q12 = Arrays.InitTwoDimensionalArrayShort(2, 16); - final short[] LTPCoef_Q14 = new short[20]; - int LTP_scale_Q14 = 0; - final int[] pitchL = new int[4]; - final short[] AR1_Q13 = new short[64]; - final short[] AR2_Q13 = new short[64]; - final int[] LF_shp_Q14 = new int[4]; - final int[] GainsPre_Q14 = new int[4]; - final int[] HarmBoost_Q14 = new int[4]; - final int[] Tilt_Q14 = new int[4]; - final int[] HarmShapeGain_Q14 = new int[4]; - int Lambda_Q10 = 0; - int input_quality_Q14 = 0; - int coding_quality_Q14 = 0; - int sparseness_Q8 = 0; - int predGain_Q16 = 0; - int LTPredCodGain_Q7 = 0; - final int[] ResNrg = new int[4]; - final int[] ResNrgQ = new int[4]; - final int[] GainsUnq_Q16 = new int[4]; - byte lastGainIndexPrev = 0; - - SilkEncoderControl() { - } - - void Reset() { - Arrays.MemSet(this.Gains_Q16, 0, 4); - Arrays.MemSet(this.PredCoef_Q12[0], (short)0, 16); - Arrays.MemSet(this.PredCoef_Q12[1], (short)0, 16); - Arrays.MemSet(this.LTPCoef_Q14, (short)0, 20); - this.LTP_scale_Q14 = 0; - Arrays.MemSet(this.pitchL, 0, 4); - Arrays.MemSet(this.AR1_Q13, (short)0, 64); - Arrays.MemSet(this.AR2_Q13, (short)0, 64); - Arrays.MemSet(this.LF_shp_Q14, 0, 4); - Arrays.MemSet(this.GainsPre_Q14, 0, 4); - Arrays.MemSet(this.HarmBoost_Q14, 0, 4); - Arrays.MemSet(this.Tilt_Q14, 0, 4); - Arrays.MemSet(this.HarmShapeGain_Q14, 0, 4); - this.Lambda_Q10 = 0; - this.input_quality_Q14 = 0; - this.coding_quality_Q14 = 0; - this.sparseness_Q8 = 0; - this.predGain_Q16 = 0; - this.LTPredCodGain_Q7 = 0; - Arrays.MemSet(this.ResNrg, 0, 4); - Arrays.MemSet(this.ResNrgQ, 0, 4); - Arrays.MemSet(this.GainsUnq_Q16, 0, 4); - this.lastGainIndexPrev = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkError.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkError.java deleted file mode 100644 index ae5bbc4..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkError.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class SilkError { - static int SILK_NO_ERROR = 0; - static int SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES = -101; - static int SILK_ENC_FS_NOT_SUPPORTED = -102; - static int SILK_ENC_PACKET_SIZE_NOT_SUPPORTED = -103; - static int SILK_ENC_PAYLOAD_BUF_TOO_SHORT = -104; - static int SILK_ENC_INVALID_LOSS_RATE = -105; - static int SILK_ENC_INVALID_COMPLEXITY_SETTING = -106; - static int SILK_ENC_INVALID_INBAND_FEC_SETTING = -107; - static int SILK_ENC_INVALID_DTX_SETTING = -108; - static int SILK_ENC_INVALID_CBR_SETTING = -109; - static int SILK_ENC_INTERNAL_ERROR = -110; - static int SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR = -111; - static int SILK_DEC_INVALID_SAMPLING_FREQUENCY = -200; - static int SILK_DEC_PAYLOAD_TOO_LARGE = -201; - static int SILK_DEC_PAYLOAD_ERROR = -202; - static int SILK_DEC_INVALID_FRAME_SIZE = -203; - - SilkError() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkLPState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkLPState.java deleted file mode 100644 index 3d60a80..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkLPState.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; - -class SilkLPState { - final int[] In_LP_State = new int[2]; - int transition_frame_no = 0; - int mode = 0; - - SilkLPState() { - } - - void Reset() { - this.In_LP_State[0] = 0; - this.In_LP_State[1] = 0; - this.transition_frame_no = 0; - this.mode = 0; - } - - void silk_LP_variable_cutoff(short[] frame, int frame_ptr, int frame_length) { - int[] B_Q28 = new int[3]; - int[] A_Q28 = new int[2]; - int fac_Q16 = 0; - int ind = 0; - Inlines.OpusAssert(this.transition_frame_no >= 0 && this.transition_frame_no <= 256); - if (this.mode != 0) { - fac_Q16 = Inlines.silk_LSHIFT(256 - this.transition_frame_no, 10); - ind = Inlines.silk_RSHIFT(fac_Q16, 16); - Inlines.OpusAssert(ind >= 0); - Inlines.OpusAssert(ind < 5); - Filters.silk_LP_interpolate_filter_taps(B_Q28, A_Q28, ind, fac_Q16 -= Inlines.silk_LSHIFT(ind, 16)); - this.transition_frame_no = Inlines.silk_LIMIT(this.transition_frame_no + this.mode, 0, 256); - Inlines.OpusAssert(true); - Filters.silk_biquad_alt(frame, frame_ptr, B_Q28, A_Q28, this.In_LP_State, frame, frame_ptr, frame_length, 1); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkNSQState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkNSQState.java deleted file mode 100644 index 8b9bb62..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkNSQState.java +++ /dev/null @@ -1,715 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SideInfoIndices; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkConstants; -import de.maxhenkel.voicechat.concentus.SilkTables; - -class SilkNSQState { - final short[] xq = new short[640]; - final int[] sLTP_shp_Q14 = new int[640]; - final int[] sLPC_Q14 = new int[80 + SilkConstants.NSQ_LPC_BUF_LENGTH]; - final int[] sAR2_Q14 = new int[16]; - int sLF_AR_shp_Q14 = 0; - int lagPrev = 0; - int sLTP_buf_idx = 0; - int sLTP_shp_buf_idx = 0; - int rand_seed = 0; - int prev_gain_Q16 = 0; - int rewhite_flag = 0; - - SilkNSQState() { - } - - void Reset() { - Arrays.MemSet(this.xq, (short)0, 640); - Arrays.MemSet(this.sLTP_shp_Q14, 0, 640); - Arrays.MemSet(this.sLPC_Q14, 0, 80 + SilkConstants.NSQ_LPC_BUF_LENGTH); - Arrays.MemSet(this.sAR2_Q14, 0, 16); - this.sLF_AR_shp_Q14 = 0; - this.lagPrev = 0; - this.sLTP_buf_idx = 0; - this.sLTP_shp_buf_idx = 0; - this.rand_seed = 0; - this.prev_gain_Q16 = 0; - this.rewhite_flag = 0; - } - - void Assign(SilkNSQState other) { - this.sLF_AR_shp_Q14 = other.sLF_AR_shp_Q14; - this.lagPrev = other.lagPrev; - this.sLTP_buf_idx = other.sLTP_buf_idx; - this.sLTP_shp_buf_idx = other.sLTP_shp_buf_idx; - this.rand_seed = other.rand_seed; - this.prev_gain_Q16 = other.prev_gain_Q16; - this.rewhite_flag = other.rewhite_flag; - System.arraycopy(other.xq, 0, this.xq, 0, 640); - System.arraycopy(other.sLTP_shp_Q14, 0, this.sLTP_shp_Q14, 0, 640); - System.arraycopy(other.sLPC_Q14, 0, this.sLPC_Q14, 0, 80 + SilkConstants.NSQ_LPC_BUF_LENGTH); - System.arraycopy(other.sAR2_Q14, 0, this.sAR2_Q14, 0, 16); - } - - void silk_NSQ(SilkChannelEncoder psEncC, SideInfoIndices psIndices, int[] x_Q3, byte[] pulses, short[][] PredCoef_Q12, short[] LTPCoef_Q14, short[] AR2_Q13, int[] HarmShapeGain_Q14, int[] Tilt_Q14, int[] LF_shp_Q14, int[] Gains_Q16, int[] pitchL, int Lambda_Q10, int LTP_scale_Q14) { - int pulses_ptr = 0; - int x_Q3_ptr = 0; - this.rand_seed = psIndices.Seed; - int lag = this.lagPrev; - Inlines.OpusAssert(this.prev_gain_Q16 != 0); - short offset_Q10 = SilkTables.silk_Quantization_Offsets_Q10[psIndices.signalType >> 1][psIndices.quantOffsetType]; - int LSF_interpolation_flag = psIndices.NLSFInterpCoef_Q2 == 4 ? 0 : 1; - int[] sLTP_Q15 = new int[psEncC.ltp_mem_length + psEncC.frame_length]; - short[] sLTP = new short[psEncC.ltp_mem_length + psEncC.frame_length]; - int[] x_sc_Q10 = new int[psEncC.subfr_length]; - this.sLTP_shp_buf_idx = psEncC.ltp_mem_length; - this.sLTP_buf_idx = psEncC.ltp_mem_length; - int pxq = psEncC.ltp_mem_length; - for (int k = 0; k < psEncC.nb_subfr; ++k) { - int A_Q12 = k >> 1 | 1 - LSF_interpolation_flag; - int B_Q14 = k * 5; - int AR_shp_Q13 = k * 16; - Inlines.OpusAssert(HarmShapeGain_Q14[k] >= 0); - int HarmShapeFIRPacked_Q14 = Inlines.silk_RSHIFT(HarmShapeGain_Q14[k], 2); - HarmShapeFIRPacked_Q14 |= Inlines.silk_LSHIFT(Inlines.silk_RSHIFT(HarmShapeGain_Q14[k], 1), 16); - this.rewhite_flag = 0; - if (psIndices.signalType == 2) { - lag = pitchL[k]; - if ((k & 3 - Inlines.silk_LSHIFT(LSF_interpolation_flag, 1)) == 0) { - int start_idx = psEncC.ltp_mem_length - lag - psEncC.predictLPCOrder - 2; - Inlines.OpusAssert(start_idx > 0); - Filters.silk_LPC_analysis_filter(sLTP, start_idx, this.xq, start_idx + k * psEncC.subfr_length, PredCoef_Q12[A_Q12], 0, psEncC.ltp_mem_length - start_idx, psEncC.predictLPCOrder); - this.rewhite_flag = 1; - this.sLTP_buf_idx = psEncC.ltp_mem_length; - } - } - this.silk_nsq_scale_states(psEncC, x_Q3, x_Q3_ptr, x_sc_Q10, sLTP, sLTP_Q15, k, LTP_scale_Q14, Gains_Q16, pitchL, psIndices.signalType); - this.silk_noise_shape_quantizer(psIndices.signalType, x_sc_Q10, pulses, pulses_ptr, this.xq, pxq, sLTP_Q15, PredCoef_Q12[A_Q12], LTPCoef_Q14, B_Q14, AR2_Q13, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[k], LF_shp_Q14[k], Gains_Q16[k], Lambda_Q10, offset_Q10, psEncC.subfr_length, psEncC.shapingLPCOrder, psEncC.predictLPCOrder); - x_Q3_ptr += psEncC.subfr_length; - pulses_ptr += psEncC.subfr_length; - pxq += psEncC.subfr_length; - } - this.lagPrev = pitchL[psEncC.nb_subfr - 1]; - Arrays.MemMove(this.xq, psEncC.frame_length, 0, psEncC.ltp_mem_length); - Arrays.MemMove(this.sLTP_shp_Q14, psEncC.frame_length, 0, psEncC.ltp_mem_length); - } - - private void silk_noise_shape_quantizer(int signalType, int[] x_sc_Q10, byte[] pulses, int pulses_ptr, short[] xq, int xq_ptr, int[] sLTP_Q15, short[] a_Q12, short[] b_Q14, int b_Q14_ptr, short[] AR_shp_Q13, int AR_shp_Q13_ptr, int lag, int HarmShapeFIRPacked_Q14, int Tilt_Q14, int LF_shp_Q14, int Gain_Q16, int Lambda_Q10, int offset_Q10, int length, int shapingLPCOrder, int predictLPCOrder) { - int shp_lag_ptr = this.sLTP_shp_buf_idx - lag + 1; - int pred_lag_ptr = this.sLTP_buf_idx - lag + 2; - int Gain_Q10 = Inlines.silk_RSHIFT(Gain_Q16, 6); - int psLPC_Q14 = SilkConstants.NSQ_LPC_BUF_LENGTH - 1; - for (int i = 0; i < length; ++i) { - int sLF_AR_shp_Q14; - int rd2_Q20; - int rd1_Q20; - int q2_Q10; - int q1_Q10; - int q1_Q0; - int LTP_pred_Q13; - this.rand_seed = Inlines.silk_RAND(this.rand_seed); - Inlines.OpusAssert(predictLPCOrder == 10 || predictLPCOrder == 16); - int LPC_pred_Q10 = Inlines.silk_RSHIFT(predictLPCOrder, 1); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 0], a_Q12[0]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 1], a_Q12[1]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 2], a_Q12[2]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 3], a_Q12[3]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 4], a_Q12[4]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 5], a_Q12[5]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 6], a_Q12[6]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 7], a_Q12[7]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 8], a_Q12[8]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 9], a_Q12[9]); - if (predictLPCOrder == 16) { - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 10], a_Q12[10]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 11], a_Q12[11]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 12], a_Q12[12]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 13], a_Q12[13]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 14], a_Q12[14]); - LPC_pred_Q10 = Inlines.silk_SMLAWB(LPC_pred_Q10, this.sLPC_Q14[psLPC_Q14 - 15], a_Q12[15]); - } - if (signalType == 2) { - LTP_pred_Q13 = 2; - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr], b_Q14[b_Q14_ptr]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 1], b_Q14[b_Q14_ptr + 1]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 2], b_Q14[b_Q14_ptr + 2]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 3], b_Q14[b_Q14_ptr + 3]); - LTP_pred_Q13 = Inlines.silk_SMLAWB(LTP_pred_Q13, sLTP_Q15[pred_lag_ptr - 4], b_Q14[b_Q14_ptr + 4]); - ++pred_lag_ptr; - } else { - LTP_pred_Q13 = 0; - } - Inlines.OpusAssert((shapingLPCOrder & 1) == 0); - int tmp2 = this.sLPC_Q14[psLPC_Q14]; - int tmp1 = this.sAR2_Q14[0]; - this.sAR2_Q14[0] = tmp2; - int n_AR_Q12 = Inlines.silk_RSHIFT(shapingLPCOrder, 1); - n_AR_Q12 = Inlines.silk_SMLAWB(n_AR_Q12, tmp2, AR_shp_Q13[AR_shp_Q13_ptr]); - for (int j = 2; j < shapingLPCOrder; j += 2) { - tmp2 = this.sAR2_Q14[j - 1]; - this.sAR2_Q14[j - 1] = tmp1; - n_AR_Q12 = Inlines.silk_SMLAWB(n_AR_Q12, tmp1, AR_shp_Q13[AR_shp_Q13_ptr + j - 1]); - tmp1 = this.sAR2_Q14[j + 0]; - this.sAR2_Q14[j + 0] = tmp2; - n_AR_Q12 = Inlines.silk_SMLAWB(n_AR_Q12, tmp2, AR_shp_Q13[AR_shp_Q13_ptr + j]); - } - this.sAR2_Q14[shapingLPCOrder - 1] = tmp1; - n_AR_Q12 = Inlines.silk_SMLAWB(n_AR_Q12, tmp1, AR_shp_Q13[AR_shp_Q13_ptr + shapingLPCOrder - 1]); - n_AR_Q12 = Inlines.silk_LSHIFT32(n_AR_Q12, 1); - n_AR_Q12 = Inlines.silk_SMLAWB(n_AR_Q12, this.sLF_AR_shp_Q14, Tilt_Q14); - int n_LF_Q12 = Inlines.silk_SMULWB(this.sLTP_shp_Q14[this.sLTP_shp_buf_idx - 1], LF_shp_Q14); - n_LF_Q12 = Inlines.silk_SMLAWT(n_LF_Q12, this.sLF_AR_shp_Q14, LF_shp_Q14); - Inlines.OpusAssert(lag > 0 || signalType != 2); - tmp1 = Inlines.silk_SUB32(Inlines.silk_LSHIFT32(LPC_pred_Q10, 2), n_AR_Q12); - tmp1 = Inlines.silk_SUB32(tmp1, n_LF_Q12); - if (lag > 0) { - int n_LTP_Q13 = Inlines.silk_SMULWB(Inlines.silk_ADD32(this.sLTP_shp_Q14[shp_lag_ptr], this.sLTP_shp_Q14[shp_lag_ptr - 2]), HarmShapeFIRPacked_Q14); - n_LTP_Q13 = Inlines.silk_SMLAWT(n_LTP_Q13, this.sLTP_shp_Q14[shp_lag_ptr - 1], HarmShapeFIRPacked_Q14); - n_LTP_Q13 = Inlines.silk_LSHIFT(n_LTP_Q13, 1); - ++shp_lag_ptr; - tmp2 = Inlines.silk_SUB32(LTP_pred_Q13, n_LTP_Q13); - tmp1 = Inlines.silk_ADD_LSHIFT32(tmp2, tmp1, 1); - tmp1 = Inlines.silk_RSHIFT_ROUND(tmp1, 3); - } else { - tmp1 = Inlines.silk_RSHIFT_ROUND(tmp1, 2); - } - int r_Q10 = Inlines.silk_SUB32(x_sc_Q10[i], tmp1); - if (this.rand_seed < 0) { - r_Q10 = -r_Q10; - } - if ((q1_Q0 = Inlines.silk_RSHIFT(q1_Q10 = Inlines.silk_SUB32(r_Q10 = Inlines.silk_LIMIT_32(r_Q10, -31744, 30720), offset_Q10), 10)) > 0) { - q1_Q10 = Inlines.silk_SUB32(Inlines.silk_LSHIFT(q1_Q0, 10), 80); - q1_Q10 = Inlines.silk_ADD32(q1_Q10, offset_Q10); - q2_Q10 = Inlines.silk_ADD32(q1_Q10, 1024); - rd1_Q20 = Inlines.silk_SMULBB(q1_Q10, Lambda_Q10); - rd2_Q20 = Inlines.silk_SMULBB(q2_Q10, Lambda_Q10); - } else if (q1_Q0 == 0) { - q1_Q10 = offset_Q10; - q2_Q10 = Inlines.silk_ADD32(q1_Q10, 944); - rd1_Q20 = Inlines.silk_SMULBB(q1_Q10, Lambda_Q10); - rd2_Q20 = Inlines.silk_SMULBB(q2_Q10, Lambda_Q10); - } else if (q1_Q0 == -1) { - q2_Q10 = offset_Q10; - q1_Q10 = Inlines.silk_SUB32(q2_Q10, 944); - rd1_Q20 = Inlines.silk_SMULBB(-q1_Q10, Lambda_Q10); - rd2_Q20 = Inlines.silk_SMULBB(q2_Q10, Lambda_Q10); - } else { - q1_Q10 = Inlines.silk_ADD32(Inlines.silk_LSHIFT(q1_Q0, 10), 80); - q1_Q10 = Inlines.silk_ADD32(q1_Q10, offset_Q10); - q2_Q10 = Inlines.silk_ADD32(q1_Q10, 1024); - rd1_Q20 = Inlines.silk_SMULBB(-q1_Q10, Lambda_Q10); - rd2_Q20 = Inlines.silk_SMULBB(-q2_Q10, Lambda_Q10); - } - int rr_Q10 = Inlines.silk_SUB32(r_Q10, q1_Q10); - rd1_Q20 = Inlines.silk_SMLABB(rd1_Q20, rr_Q10, rr_Q10); - rr_Q10 = Inlines.silk_SUB32(r_Q10, q2_Q10); - rd2_Q20 = Inlines.silk_SMLABB(rd2_Q20, rr_Q10, rr_Q10); - if (rd2_Q20 < rd1_Q20) { - q1_Q10 = q2_Q10; - } - pulses[pulses_ptr + i] = (byte)Inlines.silk_RSHIFT_ROUND(q1_Q10, 10); - int exc_Q14 = Inlines.silk_LSHIFT(q1_Q10, 4); - if (this.rand_seed < 0) { - exc_Q14 = -exc_Q14; - } - int LPC_exc_Q14 = Inlines.silk_ADD_LSHIFT32(exc_Q14, LTP_pred_Q13, 1); - int xq_Q14 = Inlines.silk_ADD_LSHIFT32(LPC_exc_Q14, LPC_pred_Q10, 4); - xq[xq_ptr + i] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWW(xq_Q14, Gain_Q10), 8)); - this.sLPC_Q14[++psLPC_Q14] = xq_Q14; - this.sLF_AR_shp_Q14 = sLF_AR_shp_Q14 = Inlines.silk_SUB_LSHIFT32(xq_Q14, n_AR_Q12, 2); - this.sLTP_shp_Q14[this.sLTP_shp_buf_idx] = Inlines.silk_SUB_LSHIFT32(sLF_AR_shp_Q14, n_LF_Q12, 2); - sLTP_Q15[this.sLTP_buf_idx] = Inlines.silk_LSHIFT(LPC_exc_Q14, 1); - ++this.sLTP_shp_buf_idx; - ++this.sLTP_buf_idx; - this.rand_seed = Inlines.silk_ADD32_ovflw(this.rand_seed, pulses[pulses_ptr + i]); - } - System.arraycopy(this.sLPC_Q14, length, this.sLPC_Q14, 0, SilkConstants.NSQ_LPC_BUF_LENGTH); - } - - private void silk_nsq_scale_states(SilkChannelEncoder psEncC, int[] x_Q3, int x_Q3_ptr, int[] x_sc_Q10, short[] sLTP, int[] sLTP_Q15, int subfr, int LTP_scale_Q14, int[] Gains_Q16, int[] pitchL, int signal_type) { - int i; - int lag = pitchL[subfr]; - int inv_gain_Q31 = Inlines.silk_INVERSE32_varQ(Inlines.silk_max(Gains_Q16[subfr], 1), 47); - Inlines.OpusAssert(inv_gain_Q31 != 0); - int gain_adj_Q16 = Gains_Q16[subfr] != this.prev_gain_Q16 ? Inlines.silk_DIV32_varQ(this.prev_gain_Q16, Gains_Q16[subfr], 16) : 65536; - int inv_gain_Q23 = Inlines.silk_RSHIFT_ROUND(inv_gain_Q31, 8); - for (i = 0; i < psEncC.subfr_length; ++i) { - x_sc_Q10[i] = Inlines.silk_SMULWW(x_Q3[x_Q3_ptr + i], inv_gain_Q23); - } - this.prev_gain_Q16 = Gains_Q16[subfr]; - if (this.rewhite_flag != 0) { - if (subfr == 0) { - inv_gain_Q31 = Inlines.silk_LSHIFT(Inlines.silk_SMULWB(inv_gain_Q31, LTP_scale_Q14), 2); - } - for (i = this.sLTP_buf_idx - lag - 2; i < this.sLTP_buf_idx; ++i) { - Inlines.OpusAssert(i < 320); - sLTP_Q15[i] = Inlines.silk_SMULWB(inv_gain_Q31, sLTP[i]); - } - } - if (gain_adj_Q16 != 65536) { - for (i = this.sLTP_shp_buf_idx - psEncC.ltp_mem_length; i < this.sLTP_shp_buf_idx; ++i) { - this.sLTP_shp_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, this.sLTP_shp_Q14[i]); - } - if (signal_type == 2 && this.rewhite_flag == 0) { - for (i = this.sLTP_buf_idx - lag - 2; i < this.sLTP_buf_idx; ++i) { - sLTP_Q15[i] = Inlines.silk_SMULWW(gain_adj_Q16, sLTP_Q15[i]); - } - } - this.sLF_AR_shp_Q14 = Inlines.silk_SMULWW(gain_adj_Q16, this.sLF_AR_shp_Q14); - for (i = 0; i < SilkConstants.NSQ_LPC_BUF_LENGTH; ++i) { - this.sLPC_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, this.sLPC_Q14[i]); - } - for (i = 0; i < 16; ++i) { - this.sAR2_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, this.sAR2_Q14[i]); - } - } - } - - void silk_NSQ_del_dec(SilkChannelEncoder psEncC, SideInfoIndices psIndices, int[] x_Q3, byte[] pulses, short[][] PredCoef_Q12, short[] LTPCoef_Q14, short[] AR2_Q13, int[] HarmShapeGain_Q14, int[] Tilt_Q14, int[] LF_shp_Q14, int[] Gains_Q16, int[] pitchL, int Lambda_Q10, int LTP_scale_Q14) { - int last_smple_idx; - int i; - int Winner_ind; - int RDmin_Q10; - NSQ_del_dec_struct psDD; - int k; - int pulses_ptr = 0; - int x_Q3_ptr = 0; - int lag = this.lagPrev; - Inlines.OpusAssert(this.prev_gain_Q16 != 0); - NSQ_del_dec_struct[] psDelDec = new NSQ_del_dec_struct[psEncC.nStatesDelayedDecision]; - for (int c = 0; c < psEncC.nStatesDelayedDecision; ++c) { - psDelDec[c] = new NSQ_del_dec_struct(psEncC.shapingLPCOrder); - } - for (k = 0; k < psEncC.nStatesDelayedDecision; ++k) { - psDD = psDelDec[k]; - psDD.SeedInit = psDD.Seed = k + psIndices.Seed & 3; - psDD.RD_Q10 = 0; - psDD.LF_AR_Q14 = this.sLF_AR_shp_Q14; - psDD.Shape_Q14[0] = this.sLTP_shp_Q14[psEncC.ltp_mem_length - 1]; - System.arraycopy(this.sLPC_Q14, 0, psDD.sLPC_Q14, 0, SilkConstants.NSQ_LPC_BUF_LENGTH); - System.arraycopy(this.sAR2_Q14, 0, psDD.sAR2_Q14, 0, psEncC.shapingLPCOrder); - } - short offset_Q10 = SilkTables.silk_Quantization_Offsets_Q10[psIndices.signalType >> 1][psIndices.quantOffsetType]; - int smpl_buf_idx = 0; - int decisionDelay = Inlines.silk_min_int(32, psEncC.subfr_length); - if (psIndices.signalType == 2) { - for (k = 0; k < psEncC.nb_subfr; ++k) { - decisionDelay = Inlines.silk_min_int(decisionDelay, pitchL[k] - 2 - 1); - } - } else if (lag > 0) { - decisionDelay = Inlines.silk_min_int(decisionDelay, lag - 2 - 1); - } - int LSF_interpolation_flag = psIndices.NLSFInterpCoef_Q2 == 4 ? 0 : 1; - int[] sLTP_Q15 = new int[psEncC.ltp_mem_length + psEncC.frame_length]; - short[] sLTP = new short[psEncC.ltp_mem_length + psEncC.frame_length]; - int[] x_sc_Q10 = new int[psEncC.subfr_length]; - int[] delayedGain_Q10 = new int[32]; - int pxq = psEncC.ltp_mem_length; - this.sLTP_shp_buf_idx = psEncC.ltp_mem_length; - this.sLTP_buf_idx = psEncC.ltp_mem_length; - int subfr = 0; - for (k = 0; k < psEncC.nb_subfr; ++k) { - int A_Q12 = k >> 1 | 1 - LSF_interpolation_flag; - Inlines.OpusAssert(HarmShapeGain_Q14[k] >= 0); - int HarmShapeFIRPacked_Q14 = Inlines.silk_RSHIFT(HarmShapeGain_Q14[k], 2); - HarmShapeFIRPacked_Q14 |= Inlines.silk_LSHIFT(Inlines.silk_RSHIFT(HarmShapeGain_Q14[k], 1), 16); - this.rewhite_flag = 0; - if (psIndices.signalType == 2) { - lag = pitchL[k]; - if ((k & 3 - Inlines.silk_LSHIFT(LSF_interpolation_flag, 1)) == 0) { - int start_idx; - if (k == 2) { - RDmin_Q10 = psDelDec[0].RD_Q10; - Winner_ind = 0; - for (i = 1; i < psEncC.nStatesDelayedDecision; ++i) { - if (psDelDec[i].RD_Q10 >= RDmin_Q10) continue; - RDmin_Q10 = psDelDec[i].RD_Q10; - Winner_ind = i; - } - for (i = 0; i < psEncC.nStatesDelayedDecision; ++i) { - if (i == Winner_ind) continue; - psDelDec[i].RD_Q10 += 0x7FFFFFF; - Inlines.OpusAssert(psDelDec[i].RD_Q10 >= 0); - } - psDD = psDelDec[Winner_ind]; - last_smple_idx = smpl_buf_idx + decisionDelay; - for (i = 0; i < decisionDelay; ++i) { - last_smple_idx = last_smple_idx - 1 & 0x1F; - pulses[pulses_ptr + i - decisionDelay] = (byte)Inlines.silk_RSHIFT_ROUND(psDD.Q_Q10[last_smple_idx], 10); - this.xq[pxq + i - decisionDelay] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWW(psDD.Xq_Q14[last_smple_idx], Gains_Q16[1]), 14)); - this.sLTP_shp_Q14[this.sLTP_shp_buf_idx - decisionDelay + i] = psDD.Shape_Q14[last_smple_idx]; - } - subfr = 0; - } - Inlines.OpusAssert((start_idx = psEncC.ltp_mem_length - lag - psEncC.predictLPCOrder - 2) > 0); - Filters.silk_LPC_analysis_filter(sLTP, start_idx, this.xq, start_idx + k * psEncC.subfr_length, PredCoef_Q12[A_Q12], 0, psEncC.ltp_mem_length - start_idx, psEncC.predictLPCOrder); - this.sLTP_buf_idx = psEncC.ltp_mem_length; - this.rewhite_flag = 1; - } - } - this.silk_nsq_del_dec_scale_states(psEncC, psDelDec, x_Q3, x_Q3_ptr, x_sc_Q10, sLTP, sLTP_Q15, k, psEncC.nStatesDelayedDecision, LTP_scale_Q14, Gains_Q16, pitchL, psIndices.signalType, decisionDelay); - BoxedValueInt smpl_buf_idx_boxed = new BoxedValueInt(smpl_buf_idx); - this.silk_noise_shape_quantizer_del_dec(psDelDec, psIndices.signalType, x_sc_Q10, pulses, pulses_ptr, this.xq, pxq, sLTP_Q15, delayedGain_Q10, PredCoef_Q12[A_Q12], LTPCoef_Q14, k * 5, AR2_Q13, k * 16, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[k], LF_shp_Q14[k], Gains_Q16[k], Lambda_Q10, offset_Q10, psEncC.subfr_length, subfr++, psEncC.shapingLPCOrder, psEncC.predictLPCOrder, psEncC.warping_Q16, psEncC.nStatesDelayedDecision, smpl_buf_idx_boxed, decisionDelay); - smpl_buf_idx = smpl_buf_idx_boxed.Val; - x_Q3_ptr += psEncC.subfr_length; - pulses_ptr += psEncC.subfr_length; - pxq += psEncC.subfr_length; - } - RDmin_Q10 = psDelDec[0].RD_Q10; - Winner_ind = 0; - for (k = 1; k < psEncC.nStatesDelayedDecision; ++k) { - if (psDelDec[k].RD_Q10 >= RDmin_Q10) continue; - RDmin_Q10 = psDelDec[k].RD_Q10; - Winner_ind = k; - } - psDD = psDelDec[Winner_ind]; - psIndices.Seed = (byte)psDD.SeedInit; - last_smple_idx = smpl_buf_idx + decisionDelay; - int Gain_Q10 = Inlines.silk_RSHIFT32(Gains_Q16[psEncC.nb_subfr - 1], 6); - for (i = 0; i < decisionDelay; ++i) { - last_smple_idx = last_smple_idx - 1 & 0x1F; - pulses[pulses_ptr + i - decisionDelay] = (byte)Inlines.silk_RSHIFT_ROUND(psDD.Q_Q10[last_smple_idx], 10); - this.xq[pxq + i - decisionDelay] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWW(psDD.Xq_Q14[last_smple_idx], Gain_Q10), 8)); - this.sLTP_shp_Q14[this.sLTP_shp_buf_idx - decisionDelay + i] = psDD.Shape_Q14[last_smple_idx]; - } - System.arraycopy(psDD.sLPC_Q14, psEncC.subfr_length, this.sLPC_Q14, 0, SilkConstants.NSQ_LPC_BUF_LENGTH); - System.arraycopy(psDD.sAR2_Q14, 0, this.sAR2_Q14, 0, psEncC.shapingLPCOrder); - this.sLF_AR_shp_Q14 = psDD.LF_AR_Q14; - this.lagPrev = pitchL[psEncC.nb_subfr - 1]; - Arrays.MemMove(this.xq, psEncC.frame_length, 0, psEncC.ltp_mem_length); - Arrays.MemMove(this.sLTP_shp_Q14, psEncC.frame_length, 0, psEncC.ltp_mem_length); - } - - private void silk_noise_shape_quantizer_del_dec(NSQ_del_dec_struct[] psDelDec, int signalType, int[] x_Q10, byte[] pulses, int pulses_ptr, short[] xq, int xq_ptr, int[] sLTP_Q15, int[] delayedGain_Q10, short[] a_Q12, short[] b_Q14, int b_Q14_ptr, short[] AR_shp_Q13, int AR_shp_Q13_ptr, int lag, int HarmShapeFIRPacked_Q14, int Tilt_Q14, int LF_shp_Q14, int Gain_Q16, int Lambda_Q10, int offset_Q10, int length, int subfr, int shapingLPCOrder, int predictLPCOrder, int warping_Q16, int nStatesDelayedDecision, BoxedValueInt smpl_buf_idx, int decisionDelay) { - NSQ_del_dec_struct psDD; - int k; - Inlines.OpusAssert(nStatesDelayedDecision > 0); - NSQ_sample_struct[] sampleStates = new NSQ_sample_struct[2 * nStatesDelayedDecision]; - for (int c = 0; c < 2 * nStatesDelayedDecision; ++c) { - sampleStates[c] = new NSQ_sample_struct(); - } - int shp_lag_ptr = this.sLTP_shp_buf_idx - lag + 1; - int pred_lag_ptr = this.sLTP_buf_idx - lag + 2; - int Gain_Q10 = Inlines.silk_RSHIFT(Gain_Q16, 6); - for (int i = 0; i < length; ++i) { - int k2; - int SS_left; - int n_LTP_Q14; - int LTP_pred_Q14; - if (signalType == 2) { - LTP_pred_Q14 = 2; - LTP_pred_Q14 = Inlines.silk_SMLAWB(LTP_pred_Q14, sLTP_Q15[pred_lag_ptr], b_Q14[b_Q14_ptr + 0]); - LTP_pred_Q14 = Inlines.silk_SMLAWB(LTP_pred_Q14, sLTP_Q15[pred_lag_ptr - 1], b_Q14[b_Q14_ptr + 1]); - LTP_pred_Q14 = Inlines.silk_SMLAWB(LTP_pred_Q14, sLTP_Q15[pred_lag_ptr - 2], b_Q14[b_Q14_ptr + 2]); - LTP_pred_Q14 = Inlines.silk_SMLAWB(LTP_pred_Q14, sLTP_Q15[pred_lag_ptr - 3], b_Q14[b_Q14_ptr + 3]); - LTP_pred_Q14 = Inlines.silk_SMLAWB(LTP_pred_Q14, sLTP_Q15[pred_lag_ptr - 4], b_Q14[b_Q14_ptr + 4]); - LTP_pred_Q14 = Inlines.silk_LSHIFT(LTP_pred_Q14, 1); - ++pred_lag_ptr; - } else { - LTP_pred_Q14 = 0; - } - if (lag > 0) { - n_LTP_Q14 = Inlines.silk_SMULWB(Inlines.silk_ADD32(this.sLTP_shp_Q14[shp_lag_ptr], this.sLTP_shp_Q14[shp_lag_ptr - 2]), HarmShapeFIRPacked_Q14); - n_LTP_Q14 = Inlines.silk_SMLAWT(n_LTP_Q14, this.sLTP_shp_Q14[shp_lag_ptr - 1], HarmShapeFIRPacked_Q14); - n_LTP_Q14 = Inlines.silk_SUB_LSHIFT32(LTP_pred_Q14, n_LTP_Q14, 2); - ++shp_lag_ptr; - } else { - n_LTP_Q14 = 0; - } - for (k = 0; k < nStatesDelayedDecision; ++k) { - int rd2_Q10; - int rd1_Q10; - int q2_Q10; - int q1_Q10; - int q1_Q0; - psDD = psDelDec[k]; - int[] psDD_sAR2 = psDD.sAR2_Q14; - SS_left = 2 * k; - int SS_right = SS_left + 1; - psDD.Seed = Inlines.silk_RAND(psDD.Seed); - int psLPC_Q14 = SilkConstants.NSQ_LPC_BUF_LENGTH - 1 + i; - Inlines.OpusAssert(predictLPCOrder == 10 || predictLPCOrder == 16); - int LPC_pred_Q14 = Inlines.silk_RSHIFT(predictLPCOrder, 1); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14], a_Q12[0]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 1], a_Q12[1]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 2], a_Q12[2]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 3], a_Q12[3]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 4], a_Q12[4]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 5], a_Q12[5]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 6], a_Q12[6]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 7], a_Q12[7]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 8], a_Q12[8]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 9], a_Q12[9]); - if (predictLPCOrder == 16) { - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 10], a_Q12[10]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 11], a_Q12[11]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 12], a_Q12[12]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 13], a_Q12[13]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 14], a_Q12[14]); - LPC_pred_Q14 = Inlines.silk_SMLAWB(LPC_pred_Q14, psDD.sLPC_Q14[psLPC_Q14 - 15], a_Q12[15]); - } - LPC_pred_Q14 = Inlines.silk_LSHIFT(LPC_pred_Q14, 4); - Inlines.OpusAssert((shapingLPCOrder & 1) == 0); - int tmp2 = Inlines.silk_SMLAWB(psDD.sLPC_Q14[psLPC_Q14], psDD_sAR2[0], warping_Q16); - int tmp1 = Inlines.silk_SMLAWB(psDD_sAR2[0], psDD_sAR2[1] - tmp2, warping_Q16); - psDD_sAR2[0] = tmp2; - int n_AR_Q14 = Inlines.silk_RSHIFT(shapingLPCOrder, 1); - n_AR_Q14 = Inlines.silk_SMLAWB(n_AR_Q14, tmp2, AR_shp_Q13[AR_shp_Q13_ptr]); - for (int j = 2; j < shapingLPCOrder; j += 2) { - tmp2 = Inlines.silk_SMLAWB(psDD_sAR2[j - 1], psDD_sAR2[j + 0] - tmp1, warping_Q16); - psDD_sAR2[j - 1] = tmp1; - n_AR_Q14 = Inlines.silk_SMLAWB(n_AR_Q14, tmp1, AR_shp_Q13[AR_shp_Q13_ptr + j - 1]); - tmp1 = Inlines.silk_SMLAWB(psDD_sAR2[j + 0], psDD_sAR2[j + 1] - tmp2, warping_Q16); - psDD_sAR2[j + 0] = tmp2; - n_AR_Q14 = Inlines.silk_SMLAWB(n_AR_Q14, tmp2, AR_shp_Q13[AR_shp_Q13_ptr + j]); - } - psDD_sAR2[shapingLPCOrder - 1] = tmp1; - n_AR_Q14 = Inlines.silk_SMLAWB(n_AR_Q14, tmp1, AR_shp_Q13[AR_shp_Q13_ptr + shapingLPCOrder - 1]); - n_AR_Q14 = Inlines.silk_LSHIFT(n_AR_Q14, 1); - n_AR_Q14 = Inlines.silk_SMLAWB(n_AR_Q14, psDD.LF_AR_Q14, Tilt_Q14); - n_AR_Q14 = Inlines.silk_LSHIFT(n_AR_Q14, 2); - int n_LF_Q14 = Inlines.silk_SMULWB(psDD.Shape_Q14[smpl_buf_idx.Val], LF_shp_Q14); - n_LF_Q14 = Inlines.silk_SMLAWT(n_LF_Q14, psDD.LF_AR_Q14, LF_shp_Q14); - n_LF_Q14 = Inlines.silk_LSHIFT(n_LF_Q14, 2); - tmp1 = Inlines.silk_ADD32(n_AR_Q14, n_LF_Q14); - tmp2 = Inlines.silk_ADD32(n_LTP_Q14, LPC_pred_Q14); - tmp1 = Inlines.silk_SUB32(tmp2, tmp1); - tmp1 = Inlines.silk_RSHIFT_ROUND(tmp1, 4); - int r_Q10 = Inlines.silk_SUB32(x_Q10[i], tmp1); - if (psDD.Seed < 0) { - r_Q10 = -r_Q10; - } - if ((q1_Q0 = Inlines.silk_RSHIFT(q1_Q10 = Inlines.silk_SUB32(r_Q10 = Inlines.silk_LIMIT_32(r_Q10, -31744, 30720), offset_Q10), 10)) > 0) { - q1_Q10 = Inlines.silk_SUB32(Inlines.silk_LSHIFT(q1_Q0, 10), 80); - q1_Q10 = Inlines.silk_ADD32(q1_Q10, offset_Q10); - q2_Q10 = Inlines.silk_ADD32(q1_Q10, 1024); - rd1_Q10 = Inlines.silk_SMULBB(q1_Q10, Lambda_Q10); - rd2_Q10 = Inlines.silk_SMULBB(q2_Q10, Lambda_Q10); - } else if (q1_Q0 == 0) { - q1_Q10 = offset_Q10; - q2_Q10 = Inlines.silk_ADD32(q1_Q10, 944); - rd1_Q10 = Inlines.silk_SMULBB(q1_Q10, Lambda_Q10); - rd2_Q10 = Inlines.silk_SMULBB(q2_Q10, Lambda_Q10); - } else if (q1_Q0 == -1) { - q2_Q10 = offset_Q10; - q1_Q10 = Inlines.silk_SUB32(q2_Q10, 944); - rd1_Q10 = Inlines.silk_SMULBB(-q1_Q10, Lambda_Q10); - rd2_Q10 = Inlines.silk_SMULBB(q2_Q10, Lambda_Q10); - } else { - q1_Q10 = Inlines.silk_ADD32(Inlines.silk_LSHIFT(q1_Q0, 10), 80); - q1_Q10 = Inlines.silk_ADD32(q1_Q10, offset_Q10); - q2_Q10 = Inlines.silk_ADD32(q1_Q10, 1024); - rd1_Q10 = Inlines.silk_SMULBB(-q1_Q10, Lambda_Q10); - rd2_Q10 = Inlines.silk_SMULBB(-q2_Q10, Lambda_Q10); - } - int rr_Q10 = Inlines.silk_SUB32(r_Q10, q1_Q10); - rd1_Q10 = Inlines.silk_RSHIFT(Inlines.silk_SMLABB(rd1_Q10, rr_Q10, rr_Q10), 10); - rr_Q10 = Inlines.silk_SUB32(r_Q10, q2_Q10); - rd2_Q10 = Inlines.silk_RSHIFT(Inlines.silk_SMLABB(rd2_Q10, rr_Q10, rr_Q10), 10); - if (rd1_Q10 < rd2_Q10) { - sampleStates[SS_left].RD_Q10 = Inlines.silk_ADD32(psDD.RD_Q10, rd1_Q10); - sampleStates[SS_right].RD_Q10 = Inlines.silk_ADD32(psDD.RD_Q10, rd2_Q10); - sampleStates[SS_left].Q_Q10 = q1_Q10; - sampleStates[SS_right].Q_Q10 = q2_Q10; - } else { - sampleStates[SS_left].RD_Q10 = Inlines.silk_ADD32(psDD.RD_Q10, rd2_Q10); - sampleStates[SS_right].RD_Q10 = Inlines.silk_ADD32(psDD.RD_Q10, rd1_Q10); - sampleStates[SS_left].Q_Q10 = q2_Q10; - sampleStates[SS_right].Q_Q10 = q1_Q10; - } - int exc_Q14 = Inlines.silk_LSHIFT32(sampleStates[SS_left].Q_Q10, 4); - if (psDD.Seed < 0) { - exc_Q14 = -exc_Q14; - } - int LPC_exc_Q14 = Inlines.silk_ADD32(exc_Q14, LTP_pred_Q14); - int xq_Q14 = Inlines.silk_ADD32(LPC_exc_Q14, LPC_pred_Q14); - int sLF_AR_shp_Q14 = Inlines.silk_SUB32(xq_Q14, n_AR_Q14); - sampleStates[SS_left].sLTP_shp_Q14 = Inlines.silk_SUB32(sLF_AR_shp_Q14, n_LF_Q14); - sampleStates[SS_left].LF_AR_Q14 = sLF_AR_shp_Q14; - sampleStates[SS_left].LPC_exc_Q14 = LPC_exc_Q14; - sampleStates[SS_left].xq_Q14 = xq_Q14; - exc_Q14 = Inlines.silk_LSHIFT32(sampleStates[SS_right].Q_Q10, 4); - if (psDD.Seed < 0) { - exc_Q14 = -exc_Q14; - } - LPC_exc_Q14 = Inlines.silk_ADD32(exc_Q14, LTP_pred_Q14); - xq_Q14 = Inlines.silk_ADD32(LPC_exc_Q14, LPC_pred_Q14); - sLF_AR_shp_Q14 = Inlines.silk_SUB32(xq_Q14, n_AR_Q14); - sampleStates[SS_right].sLTP_shp_Q14 = Inlines.silk_SUB32(sLF_AR_shp_Q14, n_LF_Q14); - sampleStates[SS_right].LF_AR_Q14 = sLF_AR_shp_Q14; - sampleStates[SS_right].LPC_exc_Q14 = LPC_exc_Q14; - sampleStates[SS_right].xq_Q14 = xq_Q14; - } - smpl_buf_idx.Val = smpl_buf_idx.Val - 1 & 0x1F; - int last_smple_idx = smpl_buf_idx.Val + decisionDelay & 0x1F; - int RDmin_Q10 = sampleStates[0].RD_Q10; - int Winner_ind = 0; - for (k = 1; k < nStatesDelayedDecision; ++k) { - if (sampleStates[k * 2].RD_Q10 >= RDmin_Q10) continue; - RDmin_Q10 = sampleStates[k * 2].RD_Q10; - Winner_ind = k; - } - int Winner_rand_state = psDelDec[Winner_ind].RandState[last_smple_idx]; - for (k = 0; k < nStatesDelayedDecision; ++k) { - if (psDelDec[k].RandState[last_smple_idx] == Winner_rand_state) continue; - k2 = k * 2; - sampleStates[k2].RD_Q10 = Inlines.silk_ADD32(sampleStates[k2].RD_Q10, 0x7FFFFFF); - sampleStates[k2 + 1].RD_Q10 = Inlines.silk_ADD32(sampleStates[k2 + 1].RD_Q10, 0x7FFFFFF); - Inlines.OpusAssert(sampleStates[k2].RD_Q10 >= 0); - } - int RDmax_Q10 = sampleStates[0].RD_Q10; - RDmin_Q10 = sampleStates[1].RD_Q10; - int RDmax_ind = 0; - int RDmin_ind = 0; - for (k = 1; k < nStatesDelayedDecision; ++k) { - k2 = k * 2; - if (sampleStates[k2].RD_Q10 > RDmax_Q10) { - RDmax_Q10 = sampleStates[k2].RD_Q10; - RDmax_ind = k; - } - if (sampleStates[k2 + 1].RD_Q10 >= RDmin_Q10) continue; - RDmin_Q10 = sampleStates[k2 + 1].RD_Q10; - RDmin_ind = k; - } - if (RDmin_Q10 < RDmax_Q10) { - psDelDec[RDmax_ind].PartialCopyFrom(psDelDec[RDmin_ind], i); - sampleStates[RDmax_ind * 2].Assign(sampleStates[RDmin_ind * 2 + 1]); - } - psDD = psDelDec[Winner_ind]; - if (subfr > 0 || i >= decisionDelay) { - pulses[pulses_ptr + i - decisionDelay] = (byte)Inlines.silk_RSHIFT_ROUND(psDD.Q_Q10[last_smple_idx], 10); - xq[xq_ptr + i - decisionDelay] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULWW(psDD.Xq_Q14[last_smple_idx], delayedGain_Q10[last_smple_idx]), 8)); - this.sLTP_shp_Q14[this.sLTP_shp_buf_idx - decisionDelay] = psDD.Shape_Q14[last_smple_idx]; - sLTP_Q15[this.sLTP_buf_idx - decisionDelay] = psDD.Pred_Q15[last_smple_idx]; - } - ++this.sLTP_shp_buf_idx; - ++this.sLTP_buf_idx; - for (k = 0; k < nStatesDelayedDecision; ++k) { - psDD = psDelDec[k]; - SS_left = k * 2; - psDD.LF_AR_Q14 = sampleStates[SS_left].LF_AR_Q14; - psDD.sLPC_Q14[SilkConstants.NSQ_LPC_BUF_LENGTH + i] = sampleStates[SS_left].xq_Q14; - psDD.Xq_Q14[smpl_buf_idx.Val] = sampleStates[SS_left].xq_Q14; - psDD.Q_Q10[smpl_buf_idx.Val] = sampleStates[SS_left].Q_Q10; - psDD.Pred_Q15[smpl_buf_idx.Val] = Inlines.silk_LSHIFT32(sampleStates[SS_left].LPC_exc_Q14, 1); - psDD.Shape_Q14[smpl_buf_idx.Val] = sampleStates[SS_left].sLTP_shp_Q14; - psDD.RandState[smpl_buf_idx.Val] = psDD.Seed = Inlines.silk_ADD32_ovflw(psDD.Seed, Inlines.silk_RSHIFT_ROUND(sampleStates[SS_left].Q_Q10, 10)); - psDD.RD_Q10 = sampleStates[SS_left].RD_Q10; - } - delayedGain_Q10[smpl_buf_idx.Val] = Gain_Q10; - } - for (k = 0; k < nStatesDelayedDecision; ++k) { - psDD = psDelDec[k]; - System.arraycopy(psDD.sLPC_Q14, length, psDD.sLPC_Q14, 0, SilkConstants.NSQ_LPC_BUF_LENGTH); - } - } - - private void silk_nsq_del_dec_scale_states(SilkChannelEncoder psEncC, NSQ_del_dec_struct[] psDelDec, int[] x_Q3, int x_Q3_ptr, int[] x_sc_Q10, short[] sLTP, int[] sLTP_Q15, int subfr, int nStatesDelayedDecision, int LTP_scale_Q14, int[] Gains_Q16, int[] pitchL, int signal_type, int decisionDelay) { - int i; - int lag = pitchL[subfr]; - int inv_gain_Q31 = Inlines.silk_INVERSE32_varQ(Inlines.silk_max(Gains_Q16[subfr], 1), 47); - Inlines.OpusAssert(inv_gain_Q31 != 0); - int gain_adj_Q16 = Gains_Q16[subfr] != this.prev_gain_Q16 ? Inlines.silk_DIV32_varQ(this.prev_gain_Q16, Gains_Q16[subfr], 16) : 65536; - int inv_gain_Q23 = Inlines.silk_RSHIFT_ROUND(inv_gain_Q31, 8); - for (i = 0; i < psEncC.subfr_length; ++i) { - x_sc_Q10[i] = Inlines.silk_SMULWW(x_Q3[x_Q3_ptr + i], inv_gain_Q23); - } - this.prev_gain_Q16 = Gains_Q16[subfr]; - if (this.rewhite_flag != 0) { - if (subfr == 0) { - inv_gain_Q31 = Inlines.silk_LSHIFT(Inlines.silk_SMULWB(inv_gain_Q31, LTP_scale_Q14), 2); - } - for (i = this.sLTP_buf_idx - lag - 2; i < this.sLTP_buf_idx; ++i) { - Inlines.OpusAssert(i < 320); - sLTP_Q15[i] = Inlines.silk_SMULWB(inv_gain_Q31, sLTP[i]); - } - } - if (gain_adj_Q16 != 65536) { - for (i = this.sLTP_shp_buf_idx - psEncC.ltp_mem_length; i < this.sLTP_shp_buf_idx; ++i) { - this.sLTP_shp_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, this.sLTP_shp_Q14[i]); - } - if (signal_type == 2 && this.rewhite_flag == 0) { - for (i = this.sLTP_buf_idx - lag - 2; i < this.sLTP_buf_idx - decisionDelay; ++i) { - sLTP_Q15[i] = Inlines.silk_SMULWW(gain_adj_Q16, sLTP_Q15[i]); - } - } - for (int k = 0; k < nStatesDelayedDecision; ++k) { - NSQ_del_dec_struct psDD = psDelDec[k]; - psDD.LF_AR_Q14 = Inlines.silk_SMULWW(gain_adj_Q16, psDD.LF_AR_Q14); - for (i = 0; i < SilkConstants.NSQ_LPC_BUF_LENGTH; ++i) { - psDD.sLPC_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, psDD.sLPC_Q14[i]); - } - for (i = 0; i < psEncC.shapingLPCOrder; ++i) { - psDD.sAR2_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, psDD.sAR2_Q14[i]); - } - for (i = 0; i < 32; ++i) { - psDD.Pred_Q15[i] = Inlines.silk_SMULWW(gain_adj_Q16, psDD.Pred_Q15[i]); - psDD.Shape_Q14[i] = Inlines.silk_SMULWW(gain_adj_Q16, psDD.Shape_Q14[i]); - } - } - } - } - - private class NSQ_del_dec_struct { - final int[] sLPC_Q14 = new int[80 + SilkConstants.NSQ_LPC_BUF_LENGTH]; - final int[] RandState = new int[32]; - final int[] Q_Q10 = new int[32]; - final int[] Xq_Q14 = new int[32]; - final int[] Pred_Q15 = new int[32]; - final int[] Shape_Q14 = new int[32]; - int[] sAR2_Q14; - int LF_AR_Q14 = 0; - int Seed = 0; - int SeedInit = 0; - int RD_Q10 = 0; - - NSQ_del_dec_struct(int shapingOrder) { - this.sAR2_Q14 = new int[shapingOrder]; - } - - void PartialCopyFrom(NSQ_del_dec_struct other, int q14Offset) { - System.arraycopy(other.sLPC_Q14, q14Offset, this.sLPC_Q14, q14Offset, 80 + SilkConstants.NSQ_LPC_BUF_LENGTH - q14Offset); - System.arraycopy(other.RandState, 0, this.RandState, 0, 32); - System.arraycopy(other.Q_Q10, 0, this.Q_Q10, 0, 32); - System.arraycopy(other.Xq_Q14, 0, this.Xq_Q14, 0, 32); - System.arraycopy(other.Pred_Q15, 0, this.Pred_Q15, 0, 32); - System.arraycopy(other.Shape_Q14, 0, this.Shape_Q14, 0, 32); - System.arraycopy(other.sAR2_Q14, 0, this.sAR2_Q14, 0, this.sAR2_Q14.length); - this.LF_AR_Q14 = other.LF_AR_Q14; - this.Seed = other.Seed; - this.SeedInit = other.SeedInit; - this.RD_Q10 = other.RD_Q10; - } - - void Assign(NSQ_del_dec_struct other) { - this.PartialCopyFrom(other, 0); - } - } - - private class NSQ_sample_struct { - int Q_Q10; - int RD_Q10; - int xq_Q14; - int LF_AR_Q14; - int sLTP_shp_Q14; - int LPC_exc_Q14; - - private NSQ_sample_struct() { - } - - void Assign(NSQ_sample_struct other) { - this.Q_Q10 = other.Q_Q10; - this.RD_Q10 = other.RD_Q10; - this.xq_Q14 = other.xq_Q14; - this.LF_AR_Q14 = other.LF_AR_Q14; - this.sLTP_shp_Q14 = other.sLTP_shp_Q14; - this.LPC_exc_Q14 = other.LPC_exc_Q14; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkPrefilterState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkPrefilterState.java deleted file mode 100644 index 917db81..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkPrefilterState.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class SilkPrefilterState { - final short[] sLTP_shp = new short[512]; - final int[] sAR_shp = new int[17]; - int sLTP_shp_buf_idx = 0; - int sLF_AR_shp_Q12 = 0; - int sLF_MA_shp_Q12 = 0; - int sHarmHP_Q2 = 0; - int rand_seed = 0; - int lagPrev = 0; - - SilkPrefilterState() { - } - - void Reset() { - Arrays.MemSet(this.sLTP_shp, (short)0, 512); - Arrays.MemSet(this.sAR_shp, 0, 17); - this.sLTP_shp_buf_idx = 0; - this.sLF_AR_shp_Q12 = 0; - this.sLF_MA_shp_Q12 = 0; - this.sHarmHP_Q2 = 0; - this.rand_seed = 0; - this.lagPrev = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkResamplerState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkResamplerState.java deleted file mode 100644 index e82a127..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkResamplerState.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class SilkResamplerState { - final int[] sIIR = new int[6]; - final int[] sFIR_i32 = new int[36]; - final short[] sFIR_i16 = new short[36]; - final short[] delayBuf = new short[48]; - int resampler_function = 0; - int batchSize = 0; - int invRatio_Q16 = 0; - int FIR_Order = 0; - int FIR_Fracs = 0; - int Fs_in_kHz = 0; - int Fs_out_kHz = 0; - int inputDelay = 0; - short[] Coefs = null; - - SilkResamplerState() { - } - - void Reset() { - Arrays.MemSet(this.sIIR, 0, 6); - Arrays.MemSet(this.sFIR_i32, 0, 36); - Arrays.MemSet(this.sFIR_i16, (short)0, 36); - Arrays.MemSet(this.delayBuf, (short)0, 48); - this.resampler_function = 0; - this.batchSize = 0; - this.invRatio_Q16 = 0; - this.FIR_Order = 0; - this.FIR_Fracs = 0; - this.Fs_in_kHz = 0; - this.Fs_out_kHz = 0; - this.inputDelay = 0; - this.Coefs = null; - } - - void Assign(SilkResamplerState other) { - this.resampler_function = other.resampler_function; - this.batchSize = other.batchSize; - this.invRatio_Q16 = other.invRatio_Q16; - this.FIR_Order = other.FIR_Order; - this.FIR_Fracs = other.FIR_Fracs; - this.Fs_in_kHz = other.Fs_in_kHz; - this.Fs_out_kHz = other.Fs_out_kHz; - this.inputDelay = other.inputDelay; - this.Coefs = other.Coefs; - System.arraycopy(other.sIIR, 0, this.sIIR, 0, 6); - System.arraycopy(other.sFIR_i32, 0, this.sFIR_i32, 0, 36); - System.arraycopy(other.sFIR_i16, 0, this.sFIR_i16, 0, 36); - System.arraycopy(other.delayBuf, 0, this.delayBuf, 0, 48); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkShapeState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkShapeState.java deleted file mode 100644 index 90bccab..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkShapeState.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class SilkShapeState { - byte LastGainIndex = 0; - int HarmBoost_smth_Q16 = 0; - int HarmShapeGain_smth_Q16 = 0; - int Tilt_smth_Q16 = 0; - - SilkShapeState() { - } - - void Reset() { - this.LastGainIndex = 0; - this.HarmBoost_smth_Q16 = 0; - this.HarmShapeGain_smth_Q16 = 0; - this.Tilt_smth_Q16 = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkTables.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkTables.java deleted file mode 100644 index 8a67825..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkTables.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.NLSFCodebook; - -class SilkTables { - static final short[] silk_LSFCosTab_Q12 = new short[]{8192, 8190, 8182, 8170, 8152, 8130, 8104, 8072, 8034, 7994, 7946, 7896, 7840, 7778, 7714, 7644, 7568, 7490, 7406, 7318, 7226, 7128, 7026, 6922, 6812, 6698, 6580, 6458, 6332, 6204, 6070, 5934, 5792, 5648, 5502, 5352, 5198, 5040, 4880, 4718, 4552, 4382, 4212, 4038, 3862, 3684, 3502, 3320, 3136, 2948, 2760, 2570, 2378, 2186, 1990, 1794, 1598, 1400, 1202, 1002, 802, 602, 402, 202, 0, -202, -402, -602, -802, -1002, -1202, -1400, -1598, -1794, -1990, -2186, -2378, -2570, -2760, -2948, -3136, -3320, -3502, -3684, -3862, -4038, -4212, -4382, -4552, -4718, -4880, -5040, -5198, -5352, -5502, -5648, -5792, -5934, -6070, -6204, -6332, -6458, -6580, -6698, -6812, -6922, -7026, -7128, -7226, -7318, -7406, -7490, -7568, -7644, -7714, -7778, -7840, -7896, -7946, -7994, -8034, -8072, -8104, -8130, -8152, -8170, -8182, -8190, -8192}; - static final short[][] silk_gain_iCDF = new short[][]{{224, 112, 44, 15, 3, 2, 1, 0}, {254, 237, 192, 132, 70, 23, 4, 0}, {255, 252, 226, 155, 61, 11, 2, 0}}; - static final short[] silk_delta_gain_iCDF = new short[]{250, 245, 234, 203, 71, 50, 42, 38, 35, 33, 31, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; - static final short[] silk_LTP_per_index_iCDF = new short[]{179, 99, 0}; - static final short[] silk_LTP_gain_iCDF_0 = new short[]{71, 56, 43, 30, 21, 12, 6, 0}; - static final short[] silk_LTP_gain_iCDF_1 = new short[]{199, 165, 144, 124, 109, 96, 84, 71, 61, 51, 42, 32, 23, 15, 8, 0}; - static final short[] silk_LTP_gain_iCDF_2 = new short[]{241, 225, 211, 199, 187, 175, 164, 153, 142, 132, 123, 114, 105, 96, 88, 80, 72, 64, 57, 50, 44, 38, 33, 29, 24, 20, 16, 12, 9, 5, 2, 0}; - static final short silk_LTP_gain_middle_avg_RD_Q14 = 12304; - static final short[] silk_LTP_gain_BITS_Q5_0 = new short[]{15, 131, 138, 138, 155, 155, 173, 173}; - static final short[] silk_LTP_gain_BITS_Q5_1 = new short[]{69, 93, 115, 118, 131, 138, 141, 138, 150, 150, 155, 150, 155, 160, 166, 160}; - static final short[] silk_LTP_gain_BITS_Q5_2 = new short[]{131, 128, 134, 141, 141, 141, 145, 145, 145, 150, 155, 155, 155, 155, 160, 160, 160, 160, 166, 166, 173, 173, 182, 192, 182, 192, 192, 192, 205, 192, 205, 224}; - static final short[][] silk_LTP_gain_iCDF_ptrs = new short[][]{silk_LTP_gain_iCDF_0, silk_LTP_gain_iCDF_1, silk_LTP_gain_iCDF_2}; - static final short[][] silk_LTP_gain_BITS_Q5_ptrs = new short[][]{silk_LTP_gain_BITS_Q5_0, silk_LTP_gain_BITS_Q5_1, silk_LTP_gain_BITS_Q5_2}; - static final byte[][] silk_LTP_gain_vq_0 = new byte[][]{{4, 6, 24, 7, 5}, {0, 0, 2, 0, 0}, {12, 28, 41, 13, -4}, {-9, 15, 42, 25, 14}, {1, -2, 62, 41, -9}, {-10, 37, 65, -4, 3}, {-6, 4, 66, 7, -8}, {16, 14, 38, -3, 33}}; - static final byte[][] silk_LTP_gain_vq_1 = new byte[][]{{13, 22, 39, 23, 12}, {-1, 36, 64, 27, -6}, {-7, 10, 55, 43, 17}, {1, 1, 8, 1, 1}, {6, -11, 74, 53, -9}, {-12, 55, 76, -12, 8}, {-3, 3, 93, 27, -4}, {26, 39, 59, 3, -8}, {2, 0, 77, 11, 9}, {-8, 22, 44, -6, 7}, {40, 9, 26, 3, 9}, {-7, 20, 101, -7, 4}, {3, -8, 42, 26, 0}, {-15, 33, 68, 2, 23}, {-2, 55, 46, -2, 15}, {3, -1, 21, 16, 41}}; - static final byte[][] silk_LTP_gain_vq_2 = new byte[][]{{-6, 27, 61, 39, 5}, {-11, 42, 88, 4, 1}, {-2, 60, 65, 6, -4}, {-1, -5, 73, 56, 1}, {-9, 19, 94, 29, -9}, {0, 12, 99, 6, 4}, {8, -19, 102, 46, -13}, {3, 2, 13, 3, 2}, {9, -21, 84, 72, -18}, {-11, 46, 104, -22, 8}, {18, 38, 48, 23, 0}, {-16, 70, 83, -21, 11}, {5, -11, 117, 22, -8}, {-6, 23, 117, -12, 3}, {3, -8, 95, 28, 4}, {-10, 15, 77, 60, -15}, {-1, 4, 124, 2, -4}, {3, 38, 84, 24, -25}, {2, 13, 42, 13, 31}, {21, -4, 56, 46, -1}, {-1, 35, 79, -13, 19}, {-7, 65, 88, -9, -14}, {20, 4, 81, 49, -29}, {20, 0, 75, 3, -17}, {5, -9, 44, 92, -8}, {1, -3, 22, 69, 31}, {-6, 95, 41, -12, 5}, {39, 67, 16, -4, 1}, {0, -6, 120, 55, -36}, {-13, 44, 122, 4, -24}, {81, 5, 11, 3, 7}, {2, 0, 9, 10, 88}}; - static final byte[][][] silk_LTP_vq_ptrs_Q7 = new byte[][][]{silk_LTP_gain_vq_0, silk_LTP_gain_vq_1, silk_LTP_gain_vq_2}; - static final short[] silk_LTP_gain_vq_0_gain = new short[]{46, 2, 90, 87, 93, 91, 82, 98}; - static final short[] silk_LTP_gain_vq_1_gain = new short[]{109, 120, 118, 12, 113, 115, 117, 119, 99, 59, 87, 111, 63, 111, 112, 80}; - static final short[] silk_LTP_gain_vq_2_gain = new short[]{126, 124, 125, 124, 129, 121, 126, 23, 132, 127, 127, 127, 126, 127, 122, 133, 130, 134, 101, 118, 119, 145, 126, 86, 124, 120, 123, 119, 170, 173, 107, 109}; - static final short[][] silk_LTP_vq_gain_ptrs_Q7 = new short[][]{silk_LTP_gain_vq_0_gain, silk_LTP_gain_vq_1_gain, silk_LTP_gain_vq_2_gain}; - static final byte[] silk_LTP_vq_sizes = new byte[]{8, 16, 32}; - static final short[] silk_NLSF_CB1_NB_MB_Q8 = new short[]{12, 35, 60, 83, 108, 132, 157, 180, 206, 228, 15, 32, 55, 77, 101, 125, 151, 175, 201, 225, 19, 42, 66, 89, 114, 137, 162, 184, 209, 230, 12, 25, 50, 72, 97, 120, 147, 172, 200, 223, 26, 44, 69, 90, 114, 135, 159, 180, 205, 225, 13, 22, 53, 80, 106, 130, 156, 180, 205, 228, 15, 25, 44, 64, 90, 115, 142, 168, 196, 222, 19, 24, 62, 82, 100, 120, 145, 168, 190, 214, 22, 31, 50, 79, 103, 120, 151, 170, 203, 227, 21, 29, 45, 65, 106, 124, 150, 171, 196, 224, 30, 49, 75, 97, 121, 142, 165, 186, 209, 229, 19, 25, 52, 70, 93, 116, 143, 166, 192, 219, 26, 34, 62, 75, 97, 118, 145, 167, 194, 217, 25, 33, 56, 70, 91, 113, 143, 165, 196, 223, 21, 34, 51, 72, 97, 117, 145, 171, 196, 222, 20, 29, 50, 67, 90, 117, 144, 168, 197, 221, 22, 31, 48, 66, 95, 117, 146, 168, 196, 222, 24, 33, 51, 77, 116, 134, 158, 180, 200, 224, 21, 28, 70, 87, 106, 124, 149, 170, 194, 217, 26, 33, 53, 64, 83, 117, 152, 173, 204, 225, 27, 34, 65, 95, 108, 129, 155, 174, 210, 225, 20, 26, 72, 99, 113, 131, 154, 176, 200, 219, 34, 43, 61, 78, 93, 114, 155, 177, 205, 229, 23, 29, 54, 97, 124, 138, 163, 179, 209, 229, 30, 38, 56, 89, 118, 129, 158, 178, 200, 231, 21, 29, 49, 63, 85, 111, 142, 163, 193, 222, 27, 48, 77, 103, 133, 158, 179, 196, 215, 232, 29, 47, 74, 99, 124, 151, 176, 198, 220, 237, 33, 42, 61, 76, 93, 121, 155, 174, 207, 225, 29, 53, 87, 112, 136, 154, 170, 188, 208, 227, 24, 30, 52, 84, 131, 150, 166, 186, 203, 229, 37, 48, 64, 84, 104, 118, 156, 177, 201, 230}; - static final short[] silk_NLSF_CB1_iCDF_NB_MB = new short[]{212, 178, 148, 129, 108, 96, 85, 82, 79, 77, 61, 59, 57, 56, 51, 49, 48, 45, 42, 41, 40, 38, 36, 34, 31, 30, 21, 12, 10, 3, 1, 0, 255, 245, 244, 236, 233, 225, 217, 203, 190, 176, 175, 161, 149, 136, 125, 114, 102, 91, 81, 71, 60, 52, 43, 35, 28, 20, 19, 18, 12, 11, 5, 0}; - static final short[] silk_NLSF_CB2_SELECT_NB_MB = new short[]{16, 0, 0, 0, 0, 99, 66, 36, 36, 34, 36, 34, 34, 34, 34, 83, 69, 36, 52, 34, 116, 102, 70, 68, 68, 176, 102, 68, 68, 34, 65, 85, 68, 84, 36, 116, 141, 152, 139, 170, 132, 187, 184, 216, 137, 132, 249, 168, 185, 139, 104, 102, 100, 68, 68, 178, 218, 185, 185, 170, 244, 216, 187, 187, 170, 244, 187, 187, 219, 138, 103, 155, 184, 185, 137, 116, 183, 155, 152, 136, 132, 217, 184, 184, 170, 164, 217, 171, 155, 139, 244, 169, 184, 185, 170, 164, 216, 223, 218, 138, 214, 143, 188, 218, 168, 244, 141, 136, 155, 170, 168, 138, 220, 219, 139, 164, 219, 202, 216, 137, 168, 186, 246, 185, 139, 116, 185, 219, 185, 138, 100, 100, 134, 100, 102, 34, 68, 68, 100, 68, 168, 203, 221, 218, 168, 167, 154, 136, 104, 70, 164, 246, 171, 137, 139, 137, 155, 218, 219, 139}; - static final short[] silk_NLSF_CB2_iCDF_NB_MB = new short[]{255, 254, 253, 238, 14, 3, 2, 1, 0, 255, 254, 252, 218, 35, 3, 2, 1, 0, 255, 254, 250, 208, 59, 4, 2, 1, 0, 255, 254, 246, 194, 71, 10, 2, 1, 0, 255, 252, 236, 183, 82, 8, 2, 1, 0, 255, 252, 235, 180, 90, 17, 2, 1, 0, 255, 248, 224, 171, 97, 30, 4, 1, 0, 255, 254, 236, 173, 95, 37, 7, 1, 0}; - static final short[] silk_NLSF_CB2_BITS_NB_MB_Q5 = new short[]{255, 255, 255, 131, 6, 145, 255, 255, 255, 255, 255, 236, 93, 15, 96, 255, 255, 255, 255, 255, 194, 83, 25, 71, 221, 255, 255, 255, 255, 162, 73, 34, 66, 162, 255, 255, 255, 210, 126, 73, 43, 57, 173, 255, 255, 255, 201, 125, 71, 48, 58, 130, 255, 255, 255, 166, 110, 73, 57, 62, 104, 210, 255, 255, 251, 123, 65, 55, 68, 100, 171, 255}; - static final short[] silk_NLSF_PRED_NB_MB_Q8 = new short[]{179, 138, 140, 148, 151, 149, 153, 151, 163, 116, 67, 82, 59, 92, 72, 100, 89, 92}; - static final short[] silk_NLSF_DELTA_MIN_NB_MB_Q15 = new short[]{250, 3, 6, 3, 3, 3, 4, 3, 3, 3, 461}; - static final NLSFCodebook silk_NLSF_CB_NB_MB = new NLSFCodebook(); - static final short[] silk_NLSF_CB1_WB_Q8; - static final short[] silk_NLSF_CB1_iCDF_WB; - static final short[] silk_NLSF_CB2_SELECT_WB; - static final short[] silk_NLSF_CB2_iCDF_WB; - static final short[] silk_NLSF_CB2_BITS_WB_Q5; - static final short[] silk_NLSF_PRED_WB_Q8; - static final short[] silk_NLSF_DELTA_MIN_WB_Q15; - static final NLSFCodebook silk_NLSF_CB_WB; - static final int[] silk_TargetRate_table_NB; - static final int[] silk_TargetRate_table_MB; - static final int[] silk_TargetRate_table_WB; - static final short[] silk_SNR_table_Q1; - static final short[] silk_stereo_pred_quant_Q13; - static final short[] silk_stereo_pred_joint_iCDF; - static final short[] silk_stereo_only_code_mid_iCDF; - static final short[] silk_LBRR_flags_2_iCDF; - static final short[] silk_LBRR_flags_3_iCDF; - static final short[][] silk_LBRR_flags_iCDF_ptr; - static final short[] silk_lsb_iCDF; - static final short[] silk_LTPscale_iCDF; - static final short[] silk_type_offset_VAD_iCDF; - static final short[] silk_type_offset_no_VAD_iCDF; - static final short[] silk_NLSF_interpolation_factor_iCDF; - static final short[][] silk_Quantization_Offsets_Q10; - static final short[] silk_LTPScales_table_Q14; - static final short[] silk_uniform3_iCDF; - static final short[] silk_uniform4_iCDF; - static final short[] silk_uniform5_iCDF; - static final short[] silk_uniform6_iCDF; - static final short[] silk_uniform8_iCDF; - static final short[] silk_NLSF_EXT_iCDF; - static final int[][] silk_Transition_LP_B_Q28; - static final int[][] silk_Transition_LP_A_Q28; - static final short[] silk_pitch_lag_iCDF; - static final short[] silk_pitch_delta_iCDF; - static final short[] silk_pitch_contour_iCDF; - static final short[] silk_pitch_contour_NB_iCDF; - static final short[] silk_pitch_contour_10_ms_iCDF; - static final short[] silk_pitch_contour_10_ms_NB_iCDF; - static final byte[] silk_max_pulses_table; - static final short[][] silk_pulses_per_block_iCDF; - static final short[][] silk_pulses_per_block_BITS_Q5; - static final short[][] silk_rate_levels_iCDF; - static final short[][] silk_rate_levels_BITS_Q5; - static final short[] silk_shell_code_table0; - static final short[] silk_shell_code_table1; - static final short[] silk_shell_code_table2; - static final short[] silk_shell_code_table3; - static final short[] silk_shell_code_table_offsets; - static final short[] silk_sign_iCDF; - static final byte[][] delay_matrix_enc; - static final byte[][] delay_matrix_dec; - static final short[] silk_Resampler_3_4_COEFS; - static final short[] silk_Resampler_2_3_COEFS; - static final short[] silk_Resampler_1_2_COEFS; - static final short[] silk_Resampler_1_3_COEFS; - static final short[] silk_Resampler_1_4_COEFS; - static final short[] silk_Resampler_1_6_COEFS; - static final short[] silk_Resampler_2_3_COEFS_LQ; - static final short[][] silk_resampler_frac_FIR_12; - public static final short silk_resampler_down2_0 = 9872; - public static final short silk_resampler_down2_1 = -25727; - static final short[] silk_resampler_up2_hq_0; - static final short[] silk_resampler_up2_hq_1; - static final byte[][] silk_CB_lags_stage2_10_ms; - static final byte[][] silk_CB_lags_stage3_10_ms; - static final byte[][] silk_CB_lags_stage2; - static final byte[][] silk_CB_lags_stage3; - static final byte[][] silk_Lag_range_stage3_10_ms; - static final byte[][][] silk_Lag_range_stage3; - static final byte[] silk_nb_cbk_searchs_stage3; - - SilkTables() { - } - - /* - * Opcode count of 17815 triggered aggressive code reduction. Override with --aggressivesizethreshold. - */ - static { - SilkTables.silk_NLSF_CB_NB_MB.nVectors = (short)32; - SilkTables.silk_NLSF_CB_NB_MB.order = (short)10; - SilkTables.silk_NLSF_CB_NB_MB.quantStepSize_Q16 = (short)11796; - SilkTables.silk_NLSF_CB_NB_MB.invQuantStepSize_Q6 = (short)356; - SilkTables.silk_NLSF_CB_NB_MB.CB1_NLSF_Q8 = silk_NLSF_CB1_NB_MB_Q8; - SilkTables.silk_NLSF_CB_NB_MB.CB1_iCDF = silk_NLSF_CB1_iCDF_NB_MB; - SilkTables.silk_NLSF_CB_NB_MB.pred_Q8 = silk_NLSF_PRED_NB_MB_Q8; - SilkTables.silk_NLSF_CB_NB_MB.ec_sel = silk_NLSF_CB2_SELECT_NB_MB; - SilkTables.silk_NLSF_CB_NB_MB.ec_iCDF = silk_NLSF_CB2_iCDF_NB_MB; - SilkTables.silk_NLSF_CB_NB_MB.ec_Rates_Q5 = silk_NLSF_CB2_BITS_NB_MB_Q5; - SilkTables.silk_NLSF_CB_NB_MB.deltaMin_Q15 = silk_NLSF_DELTA_MIN_NB_MB_Q15; - silk_NLSF_CB1_WB_Q8 = new short[]{7, 23, 38, 54, 69, 85, 100, 116, 131, 147, 162, 178, 193, 208, 223, 239, 13, 25, 41, 55, 69, 83, 98, 112, 127, 142, 157, 171, 187, 203, 220, 236, 15, 21, 34, 51, 61, 78, 92, 106, 126, 136, 152, 167, 185, 205, 225, 240, 10, 21, 36, 50, 63, 79, 95, 110, 126, 141, 157, 173, 189, 205, 221, 237, 17, 20, 37, 51, 59, 78, 89, 107, 123, 134, 150, 164, 184, 205, 224, 240, 10, 15, 32, 51, 67, 81, 96, 112, 129, 142, 158, 173, 189, 204, 220, 236, 8, 21, 37, 51, 65, 79, 98, 113, 126, 138, 155, 168, 179, 192, 209, 218, 12, 15, 34, 55, 63, 78, 87, 108, 118, 131, 148, 167, 185, 203, 219, 236, 16, 19, 32, 36, 56, 79, 91, 108, 118, 136, 154, 171, 186, 204, 220, 237, 11, 28, 43, 58, 74, 89, 105, 120, 135, 150, 165, 180, 196, 211, 226, 241, 6, 16, 33, 46, 60, 75, 92, 107, 123, 137, 156, 169, 185, 199, 214, 225, 11, 19, 30, 44, 57, 74, 89, 105, 121, 135, 152, 169, 186, 202, 218, 234, 12, 19, 29, 46, 57, 71, 88, 100, 120, 132, 148, 165, 182, 199, 216, 233, 17, 23, 35, 46, 56, 77, 92, 106, 123, 134, 152, 167, 185, 204, 222, 237, 14, 17, 45, 53, 63, 75, 89, 107, 115, 132, 151, 171, 188, 206, 221, 240, 9, 16, 29, 40, 56, 71, 88, 103, 119, 137, 154, 171, 189, 205, 222, 237, 16, 19, 36, 48, 57, 76, 87, 105, 118, 132, 150, 167, 185, 202, 218, 236, 12, 17, 29, 54, 71, 81, 94, 104, 126, 136, 149, 164, 182, 201, 221, 237, 15, 28, 47, 62, 79, 97, 115, 129, 142, 155, 168, 180, 194, 208, 223, 238, 8, 14, 30, 45, 62, 78, 94, 111, 127, 143, 159, 175, 192, 207, 223, 239, 17, 30, 49, 62, 79, 92, 107, 119, 132, 145, 160, 174, 190, 204, 220, 235, 14, 19, 36, 45, 61, 76, 91, 108, 121, 138, 154, 172, 189, 205, 222, 238, 12, 18, 31, 45, 60, 76, 91, 107, 123, 138, 154, 171, 187, 204, 221, 236, 13, 17, 31, 43, 53, 70, 83, 103, 114, 131, 149, 167, 185, 203, 220, 237, 17, 22, 35, 42, 58, 78, 93, 110, 125, 139, 155, 170, 188, 206, 224, 240, 8, 15, 34, 50, 67, 83, 99, 115, 131, 146, 162, 178, 193, 209, 224, 239, 13, 16, 41, 66, 73, 86, 95, 111, 128, 137, 150, 163, 183, 206, 225, 241, 17, 25, 37, 52, 63, 75, 92, 102, 119, 132, 144, 160, 175, 191, 212, 231, 19, 31, 49, 65, 83, 100, 117, 133, 147, 161, 174, 187, 200, 213, 227, 242, 18, 31, 52, 68, 88, 103, 117, 126, 138, 149, 163, 177, 192, 207, 223, 239, 16, 29, 47, 61, 76, 90, 106, 119, 133, 147, 161, 176, 193, 209, 224, 240, 15, 21, 35, 50, 61, 73, 86, 97, 110, 119, 129, 141, 175, 198, 218, 237}; - silk_NLSF_CB1_iCDF_WB = new short[]{225, 204, 201, 184, 183, 175, 158, 154, 153, 135, 119, 115, 113, 110, 109, 99, 98, 95, 79, 68, 52, 50, 48, 45, 43, 32, 31, 27, 18, 10, 3, 0, 255, 251, 235, 230, 212, 201, 196, 182, 167, 166, 163, 151, 138, 124, 110, 104, 90, 78, 76, 70, 69, 57, 45, 34, 24, 21, 11, 6, 5, 4, 3, 0}; - silk_NLSF_CB2_SELECT_WB = new short[]{0, 0, 0, 0, 0, 0, 0, 1, 100, 102, 102, 68, 68, 36, 34, 96, 164, 107, 158, 185, 180, 185, 139, 102, 64, 66, 36, 34, 34, 0, 1, 32, 208, 139, 141, 191, 152, 185, 155, 104, 96, 171, 104, 166, 102, 102, 102, 132, 1, 0, 0, 0, 0, 16, 16, 0, 80, 109, 78, 107, 185, 139, 103, 101, 208, 212, 141, 139, 173, 153, 123, 103, 36, 0, 0, 0, 0, 0, 0, 1, 48, 0, 0, 0, 0, 0, 0, 32, 68, 135, 123, 119, 119, 103, 69, 98, 68, 103, 120, 118, 118, 102, 71, 98, 134, 136, 157, 184, 182, 153, 139, 134, 208, 168, 248, 75, 189, 143, 121, 107, 32, 49, 34, 34, 34, 0, 17, 2, 210, 235, 139, 123, 185, 137, 105, 134, 98, 135, 104, 182, 100, 183, 171, 134, 100, 70, 68, 70, 66, 66, 34, 131, 64, 166, 102, 68, 36, 2, 1, 0, 134, 166, 102, 68, 34, 34, 66, 132, 212, 246, 158, 139, 107, 107, 87, 102, 100, 219, 125, 122, 137, 118, 103, 132, 114, 135, 137, 105, 171, 106, 50, 34, 164, 214, 141, 143, 185, 151, 121, 103, 192, 34, 0, 0, 0, 0, 0, 1, 208, 109, 74, 187, 134, 249, 159, 137, 102, 110, 154, 118, 87, 101, 119, 101, 0, 2, 0, 36, 36, 66, 68, 35, 96, 164, 102, 100, 36, 0, 2, 33, 167, 138, 174, 102, 100, 84, 2, 2, 100, 107, 120, 119, 36, 197, 24, 0}; - silk_NLSF_CB2_iCDF_WB = new short[]{255, 254, 253, 244, 12, 3, 2, 1, 0, 255, 254, 252, 224, 38, 3, 2, 1, 0, 255, 254, 251, 209, 57, 4, 2, 1, 0, 255, 254, 244, 195, 69, 4, 2, 1, 0, 255, 251, 232, 184, 84, 7, 2, 1, 0, 255, 254, 240, 186, 86, 14, 2, 1, 0, 255, 254, 239, 178, 91, 30, 5, 1, 0, 255, 248, 227, 177, 100, 19, 2, 1, 0}; - silk_NLSF_CB2_BITS_WB_Q5 = new short[]{255, 255, 255, 156, 4, 154, 255, 255, 255, 255, 255, 227, 102, 15, 92, 255, 255, 255, 255, 255, 213, 83, 24, 72, 236, 255, 255, 255, 255, 150, 76, 33, 63, 214, 255, 255, 255, 190, 121, 77, 43, 55, 185, 255, 255, 255, 245, 137, 71, 43, 59, 139, 255, 255, 255, 255, 131, 66, 50, 66, 107, 194, 255, 255, 166, 116, 76, 55, 53, 125, 255, 255}; - silk_NLSF_PRED_WB_Q8 = new short[]{175, 148, 160, 176, 178, 173, 174, 164, 177, 174, 196, 182, 198, 192, 182, 68, 62, 66, 60, 72, 117, 85, 90, 118, 136, 151, 142, 160, 142, 155}; - silk_NLSF_DELTA_MIN_WB_Q15 = new short[]{100, 3, 40, 3, 3, 3, 5, 14, 14, 10, 11, 3, 8, 9, 7, 3, 347}; - silk_NLSF_CB_WB = new NLSFCodebook(); - SilkTables.silk_NLSF_CB_WB.nVectors = (short)32; - SilkTables.silk_NLSF_CB_WB.order = (short)16; - SilkTables.silk_NLSF_CB_WB.quantStepSize_Q16 = (short)9830; - SilkTables.silk_NLSF_CB_WB.invQuantStepSize_Q6 = (short)427; - SilkTables.silk_NLSF_CB_WB.CB1_NLSF_Q8 = silk_NLSF_CB1_WB_Q8; - SilkTables.silk_NLSF_CB_WB.CB1_iCDF = silk_NLSF_CB1_iCDF_WB; - SilkTables.silk_NLSF_CB_WB.pred_Q8 = silk_NLSF_PRED_WB_Q8; - SilkTables.silk_NLSF_CB_WB.ec_sel = silk_NLSF_CB2_SELECT_WB; - SilkTables.silk_NLSF_CB_WB.ec_iCDF = silk_NLSF_CB2_iCDF_WB; - SilkTables.silk_NLSF_CB_WB.ec_Rates_Q5 = silk_NLSF_CB2_BITS_WB_Q5; - SilkTables.silk_NLSF_CB_WB.deltaMin_Q15 = silk_NLSF_DELTA_MIN_WB_Q15; - silk_TargetRate_table_NB = new int[]{0, 8000, 9400, 11500, 13500, 17500, 25000, 80000}; - silk_TargetRate_table_MB = new int[]{0, 9000, 12000, 14500, 18500, 24500, 35500, 80000}; - silk_TargetRate_table_WB = new int[]{0, 10500, 14000, 17000, 21500, 28500, 42000, 80000}; - silk_SNR_table_Q1 = new short[]{18, 29, 38, 40, 46, 52, 62, 84}; - silk_stereo_pred_quant_Q13 = new short[]{-13732, -10050, -8266, -7526, -6500, -5000, -2950, -820, 820, 2950, 5000, 6500, 7526, 8266, 10050, 13732}; - silk_stereo_pred_joint_iCDF = new short[]{249, 247, 246, 245, 244, 234, 210, 202, 201, 200, 197, 174, 82, 59, 56, 55, 54, 46, 22, 12, 11, 10, 9, 7, 0}; - silk_stereo_only_code_mid_iCDF = new short[]{64, 0}; - silk_LBRR_flags_2_iCDF = new short[]{203, 150, 0}; - silk_LBRR_flags_3_iCDF = new short[]{215, 195, 166, 125, 110, 82, 0}; - silk_LBRR_flags_iCDF_ptr = new short[][]{silk_LBRR_flags_2_iCDF, silk_LBRR_flags_3_iCDF}; - silk_lsb_iCDF = new short[]{120, 0}; - silk_LTPscale_iCDF = new short[]{128, 64, 0}; - silk_type_offset_VAD_iCDF = new short[]{232, 158, 10, 0}; - silk_type_offset_no_VAD_iCDF = new short[]{230, 0}; - silk_NLSF_interpolation_factor_iCDF = new short[]{243, 221, 192, 181, 0}; - silk_Quantization_Offsets_Q10 = new short[][]{{100, 240}, {32, 100}}; - silk_LTPScales_table_Q14 = new short[]{15565, 12288, 8192}; - silk_uniform3_iCDF = new short[]{171, 85, 0}; - silk_uniform4_iCDF = new short[]{192, 128, 64, 0}; - silk_uniform5_iCDF = new short[]{205, 154, 102, 51, 0}; - silk_uniform6_iCDF = new short[]{213, 171, 128, 85, 43, 0}; - silk_uniform8_iCDF = new short[]{224, 192, 160, 128, 96, 64, 32, 0}; - silk_NLSF_EXT_iCDF = new short[]{100, 40, 16, 7, 3, 1, 0}; - silk_Transition_LP_B_Q28 = new int[][]{{250767114, 501534038, 250767114}, {209867381, 419732057, 209867381}, {170987846, 341967853, 170987846}, {131531482, 263046905, 131531482}, {89306658, 178584282, 89306658}}; - silk_Transition_LP_A_Q28 = new int[][]{{506393414, 239854379}, {411067935, 169683996}, {306733530, 116694253}, {185807084, 77959395}, {35497197, 57401098}}; - silk_pitch_lag_iCDF = new short[]{253, 250, 244, 233, 212, 182, 150, 131, 120, 110, 98, 85, 72, 60, 49, 40, 32, 25, 19, 15, 13, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; - silk_pitch_delta_iCDF = new short[]{210, 208, 206, 203, 199, 193, 183, 168, 142, 104, 74, 52, 37, 27, 20, 14, 10, 6, 4, 2, 0}; - silk_pitch_contour_iCDF = new short[]{223, 201, 183, 167, 152, 138, 124, 111, 98, 88, 79, 70, 62, 56, 50, 44, 39, 35, 31, 27, 24, 21, 18, 16, 14, 12, 10, 8, 6, 4, 3, 2, 1, 0}; - silk_pitch_contour_NB_iCDF = new short[]{188, 176, 155, 138, 119, 97, 67, 43, 26, 10, 0}; - silk_pitch_contour_10_ms_iCDF = new short[]{165, 119, 80, 61, 47, 35, 27, 20, 14, 9, 4, 0}; - silk_pitch_contour_10_ms_NB_iCDF = new short[]{113, 63, 0}; - silk_max_pulses_table = new byte[]{8, 10, 12, 16}; - silk_pulses_per_block_iCDF = new short[][]{{125, 51, 26, 18, 15, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {198, 105, 45, 22, 15, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {213, 162, 116, 83, 59, 43, 32, 24, 18, 15, 12, 9, 7, 6, 5, 3, 2, 0}, {239, 187, 116, 59, 28, 16, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {250, 229, 188, 135, 86, 51, 30, 19, 13, 10, 8, 6, 5, 4, 3, 2, 1, 0}, {249, 235, 213, 185, 156, 128, 103, 83, 66, 53, 42, 33, 26, 21, 17, 13, 10, 0}, {254, 249, 235, 206, 164, 118, 77, 46, 27, 16, 10, 7, 5, 4, 3, 2, 1, 0}, {255, 253, 249, 239, 220, 191, 156, 119, 85, 57, 37, 23, 15, 10, 6, 4, 2, 0}, {255, 253, 251, 246, 237, 223, 203, 179, 152, 124, 98, 75, 55, 40, 29, 21, 15, 0}, {255, 254, 253, 247, 220, 162, 106, 67, 42, 28, 18, 12, 9, 6, 4, 3, 2, 0}}; - silk_pulses_per_block_BITS_Q5 = new short[][]{{31, 57, 107, 160, 205, 205, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, {69, 47, 67, 111, 166, 205, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, {82, 74, 79, 95, 109, 128, 145, 160, 173, 205, 205, 205, 224, 255, 255, 224, 255, 224}, {125, 74, 59, 69, 97, 141, 182, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}, {173, 115, 85, 73, 76, 92, 115, 145, 173, 205, 224, 224, 255, 255, 255, 255, 255, 255}, {166, 134, 113, 102, 101, 102, 107, 118, 125, 138, 145, 155, 166, 182, 192, 192, 205, 150}, {224, 182, 134, 101, 83, 79, 85, 97, 120, 145, 173, 205, 224, 255, 255, 255, 255, 255}, {255, 224, 192, 150, 120, 101, 92, 89, 93, 102, 118, 134, 160, 182, 192, 224, 224, 224}, {255, 224, 224, 182, 155, 134, 118, 109, 104, 102, 106, 111, 118, 131, 145, 160, 173, 131}}; - silk_rate_levels_iCDF = new short[][]{{241, 190, 178, 132, 87, 74, 41, 14, 0}, {223, 193, 157, 140, 106, 57, 39, 18, 0}}; - silk_rate_levels_BITS_Q5 = new short[][]{{131, 74, 141, 79, 80, 138, 95, 104, 134}, {95, 99, 91, 125, 93, 76, 123, 115, 123}}; - silk_shell_code_table0 = new short[]{128, 0, 214, 42, 0, 235, 128, 21, 0, 244, 184, 72, 11, 0, 248, 214, 128, 42, 7, 0, 248, 225, 170, 80, 25, 5, 0, 251, 236, 198, 126, 54, 18, 3, 0, 250, 238, 211, 159, 82, 35, 15, 5, 0, 250, 231, 203, 168, 128, 88, 53, 25, 6, 0, 252, 238, 216, 185, 148, 108, 71, 40, 18, 4, 0, 253, 243, 225, 199, 166, 128, 90, 57, 31, 13, 3, 0, 254, 246, 233, 212, 183, 147, 109, 73, 44, 23, 10, 2, 0, 255, 250, 240, 223, 198, 166, 128, 90, 58, 33, 16, 6, 1, 0, 255, 251, 244, 231, 210, 181, 146, 110, 75, 46, 25, 12, 5, 1, 0, 255, 253, 248, 238, 221, 196, 164, 128, 92, 60, 35, 18, 8, 3, 1, 0, 255, 253, 249, 242, 229, 208, 180, 146, 110, 76, 48, 27, 14, 7, 3, 1, 0}; - silk_shell_code_table1 = new short[]{129, 0, 207, 50, 0, 236, 129, 20, 0, 245, 185, 72, 10, 0, 249, 213, 129, 42, 6, 0, 250, 226, 169, 87, 27, 4, 0, 251, 233, 194, 130, 62, 20, 4, 0, 250, 236, 207, 160, 99, 47, 17, 3, 0, 255, 240, 217, 182, 131, 81, 41, 11, 1, 0, 255, 254, 233, 201, 159, 107, 61, 20, 2, 1, 0, 255, 249, 233, 206, 170, 128, 86, 50, 23, 7, 1, 0, 255, 250, 238, 217, 186, 148, 108, 70, 39, 18, 6, 1, 0, 255, 252, 243, 226, 200, 166, 128, 90, 56, 30, 13, 4, 1, 0, 255, 252, 245, 231, 209, 180, 146, 110, 76, 47, 25, 11, 4, 1, 0, 255, 253, 248, 237, 219, 194, 163, 128, 93, 62, 37, 19, 8, 3, 1, 0, 255, 254, 250, 241, 226, 205, 177, 145, 111, 79, 51, 30, 15, 6, 2, 1, 0}; - silk_shell_code_table2 = new short[]{129, 0, 203, 54, 0, 234, 129, 23, 0, 245, 184, 73, 10, 0, 250, 215, 129, 41, 5, 0, 252, 232, 173, 86, 24, 3, 0, 253, 240, 200, 129, 56, 15, 2, 0, 253, 244, 217, 164, 94, 38, 10, 1, 0, 253, 245, 226, 189, 132, 71, 27, 7, 1, 0, 253, 246, 231, 203, 159, 105, 56, 23, 6, 1, 0, 255, 248, 235, 213, 179, 133, 85, 47, 19, 5, 1, 0, 255, 254, 243, 221, 194, 159, 117, 70, 37, 12, 2, 1, 0, 255, 254, 248, 234, 208, 171, 128, 85, 48, 22, 8, 2, 1, 0, 255, 254, 250, 240, 220, 189, 149, 107, 67, 36, 16, 6, 2, 1, 0, 255, 254, 251, 243, 227, 201, 166, 128, 90, 55, 29, 13, 5, 2, 1, 0, 255, 254, 252, 246, 234, 213, 183, 147, 109, 73, 43, 22, 10, 4, 2, 1, 0}; - silk_shell_code_table3 = new short[]{130, 0, 200, 58, 0, 231, 130, 26, 0, 244, 184, 76, 12, 0, 249, 214, 130, 43, 6, 0, 252, 232, 173, 87, 24, 3, 0, 253, 241, 203, 131, 56, 14, 2, 0, 254, 246, 221, 167, 94, 35, 8, 1, 0, 254, 249, 232, 193, 130, 65, 23, 5, 1, 0, 255, 251, 239, 211, 162, 99, 45, 15, 4, 1, 0, 255, 251, 243, 223, 186, 131, 74, 33, 11, 3, 1, 0, 255, 252, 245, 230, 202, 158, 105, 57, 24, 8, 2, 1, 0, 255, 253, 247, 235, 214, 179, 132, 84, 44, 19, 7, 2, 1, 0, 255, 254, 250, 240, 223, 196, 159, 112, 69, 36, 15, 6, 2, 1, 0, 255, 254, 253, 245, 231, 209, 176, 136, 93, 55, 27, 11, 3, 2, 1, 0, 255, 254, 253, 252, 239, 221, 194, 158, 117, 76, 42, 18, 4, 3, 2, 1, 0}; - silk_shell_code_table_offsets = new short[]{0, 0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104, 119, 135}; - silk_sign_iCDF = new short[]{254, 49, 67, 77, 82, 93, 99, 198, 11, 18, 24, 31, 36, 45, 255, 46, 66, 78, 87, 94, 104, 208, 14, 21, 32, 42, 51, 66, 255, 94, 104, 109, 112, 115, 118, 248, 53, 69, 80, 88, 95, 102}; - delay_matrix_enc = new byte[][]{{6, 0, 3}, {0, 7, 3}, {0, 1, 10}, {0, 2, 6}, {18, 10, 12}}; - delay_matrix_dec = new byte[][]{{4, 0, 2, 0, 0}, {0, 9, 4, 7, 4}, {0, 3, 12, 7, 7}}; - silk_Resampler_3_4_COEFS = new short[]{-20694, -13867, -49, 64, 17, -157, 353, -496, 163, 11047, 22205, -39, 6, 91, -170, 186, 23, -896, 6336, 19928, -19, -36, 102, -89, -24, 328, -951, 2568, 15909}; - silk_Resampler_2_3_COEFS = new short[]{-14457, -14019, 64, 128, -122, 36, 310, -768, 584, 9267, 17733, 12, 128, 18, -142, 288, -117, -865, 4123, 14459}; - silk_Resampler_1_2_COEFS = new short[]{616, -14323, -10, 39, 58, -46, -84, 120, 184, -315, -541, 1284, 5380, 9024}; - silk_Resampler_1_3_COEFS = new short[]{16102, -15162, -13, 0, 20, 26, 5, -31, -43, -4, 65, 90, 7, -157, -248, -44, 593, 1583, 2612, 3271}; - silk_Resampler_1_4_COEFS = new short[]{22500, -15099, 3, -14, -20, -15, 2, 25, 37, 25, -16, -71, -107, -79, 50, 292, 623, 982, 1288, 1464}; - silk_Resampler_1_6_COEFS = new short[]{27540, -15257, 17, 12, 8, 1, -10, -22, -30, -32, -22, 3, 44, 100, 168, 243, 317, 381, 429, 455}; - silk_Resampler_2_3_COEFS_LQ = new short[]{-2797, -6507, 4697, 10739, 1567, 8276}; - silk_resampler_frac_FIR_12 = new short[][]{{189, -600, 617, 30567}, {117, -159, -1070, 29704}, {52, 221, -2392, 28276}, {-4, 529, -3350, 26341}, {-48, 758, -3956, 23973}, {-80, 905, -4235, 21254}, {-99, 972, -4222, 18278}, {-107, 967, -3957, 15143}, {-103, 896, -3487, 11950}, {-91, 773, -2865, 8798}, {-71, 611, -2143, 5784}, {-46, 425, -1375, 2996}}; - silk_resampler_up2_hq_0 = new short[]{1746, 14986, -26453}; - silk_resampler_up2_hq_1 = new short[]{6854, 25769, -9994}; - silk_CB_lags_stage2_10_ms = new byte[][]{{0, 1, 0}, {0, 0, 1}}; - silk_CB_lags_stage3_10_ms = new byte[][]{{0, 0, 1, -1, 1, -1, 2, -2, 2, -2, 3, -3}, {0, 1, 0, 1, -1, 2, -1, 2, -2, 3, -2, 3}}; - silk_CB_lags_stage2 = new byte[][]{{0, 2, -1, -1, -1, 0, 0, 1, 1, 0, 1}, {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0}, {0, -1, 2, 1, 0, 1, 1, 0, 0, -1, -1}}; - silk_CB_lags_stage3 = new byte[][]{{0, 0, 1, -1, 0, 1, -1, 0, -1, 1, -2, 2, -2, -2, 2, -3, 2, 3, -3, -4, 3, -4, 4, 4, -5, 5, -6, -5, 6, -7, 6, 5, 8, -9}, {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 1, -1, 0, 1, -1, -1, 1, -1, 2, 1, -1, 2, -2, -2, 2, -2, 2, 2, 3, -3}, {0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, -1, 1, 0, 0, 2, 1, -1, 2, -1, -1, 2, -1, 2, 2, -1, 3, -2, -2, -2, 3}, {0, 1, 0, 0, 1, 0, 1, -1, 2, -1, 2, -1, 2, 3, -2, 3, -2, -2, 4, 4, -3, 5, -3, -4, 6, -4, 6, 5, -5, 8, -6, -5, -7, 9}}; - silk_Lag_range_stage3_10_ms = new byte[][]{{-3, 7}, {-2, 7}}; - silk_Lag_range_stage3 = new byte[][][]{new byte[][]{{-5, 8}, {-1, 6}, {-1, 6}, {-4, 10}}, new byte[][]{{-6, 10}, {-2, 6}, {-1, 6}, {-5, 10}}, new byte[][]{{-9, 12}, {-3, 7}, {-2, 7}, {-7, 13}}}; - silk_nb_cbk_searchs_stage3 = new byte[]{16, 24, 34}; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkVADState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SilkVADState.java deleted file mode 100644 index fe6a773..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SilkVADState.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class SilkVADState { - final int[] AnaState = new int[2]; - final int[] AnaState1 = new int[2]; - final int[] AnaState2 = new int[2]; - final int[] XnrgSubfr = new int[4]; - final int[] NrgRatioSmth_Q8 = new int[4]; - short HPstate = 0; - final int[] NL = new int[4]; - final int[] inv_NL = new int[4]; - final int[] NoiseLevelBias = new int[4]; - int counter = 0; - - SilkVADState() { - } - - void Reset() { - Arrays.MemSet(this.AnaState, 0, 2); - Arrays.MemSet(this.AnaState1, 0, 2); - Arrays.MemSet(this.AnaState2, 0, 2); - Arrays.MemSet(this.XnrgSubfr, 0, 4); - Arrays.MemSet(this.NrgRatioSmth_Q8, 0, 4); - this.HPstate = 0; - Arrays.MemSet(this.NL, 0, 4); - Arrays.MemSet(this.inv_NL, 0, 4); - Arrays.MemSet(this.NoiseLevelBias, 0, 4); - this.counter = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Sort.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Sort.java deleted file mode 100644 index 6c0de8a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Sort.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Inlines; - -class Sort { - Sort() { - } - - static void silk_insertion_sort_increasing(int[] a, int[] idx, int L, int K) { - int j; - int value; - int i; - Inlines.OpusAssert(K > 0); - Inlines.OpusAssert(L > 0); - Inlines.OpusAssert(L >= K); - for (i = 0; i < K; ++i) { - idx[i] = i; - } - i = 1; - while (i < K) { - value = a[i]; - for (j = i - 1; j >= 0 && value < a[j]; --j) { - a[j + 1] = a[j]; - idx[j + 1] = idx[j]; - } - a[j + 1] = value; - idx[j + 1] = i++; - } - for (i = K; i < L; ++i) { - value = a[i]; - if (value >= a[K - 1]) continue; - for (j = K - 2; j >= 0 && value < a[j]; --j) { - a[j + 1] = a[j]; - idx[j + 1] = idx[j]; - } - a[j + 1] = value; - idx[j + 1] = i; - } - } - - static void silk_insertion_sort_increasing_all_values_int16(short[] a, int L) { - Inlines.OpusAssert(L > 0); - for (int i = 1; i < L; ++i) { - short value = a[i]; - for (int j = i - 1; j >= 0 && value < a[j]; --j) { - a[j + 1] = a[j]; - } - a[j + 1] = value; - } - } - - static void silk_insertion_sort_decreasing_int16(short[] a, int[] idx, int L, int K) { - int j; - short value; - int i; - Inlines.OpusAssert(K > 0); - Inlines.OpusAssert(L > 0); - Inlines.OpusAssert(L >= K); - for (i = 0; i < K; ++i) { - idx[i] = i; - } - i = 1; - while (i < K) { - value = a[i]; - for (j = i - 1; j >= 0 && value > a[j]; --j) { - a[j + 1] = a[j]; - idx[j + 1] = idx[j]; - } - a[j + 1] = value; - idx[j + 1] = i++; - } - for (i = K; i < L; ++i) { - value = a[i]; - if (value <= a[K - 1]) continue; - for (j = K - 2; j >= 0 && value > a[j]; --j) { - a[j + 1] = a[j]; - idx[j + 1] = idx[j]; - } - a[j + 1] = value; - idx[j + 1] = i; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Spread.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Spread.java deleted file mode 100644 index c1ea5e2..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Spread.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class Spread { - public static final int SPREAD_NONE = 0; - public static final int SPREAD_LIGHT = 1; - public static final int SPREAD_NORMAL = 2; - public static final int SPREAD_AGGRESSIVE = 3; - - Spread() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/Stereo.java b/source/decompiled/de/maxhenkel/voicechat/concentus/Stereo.java deleted file mode 100644 index 7dc0203..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/Stereo.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.SilkTables; -import de.maxhenkel.voicechat.concentus.StereoDecodeState; -import de.maxhenkel.voicechat.concentus.StereoEncodeState; -import de.maxhenkel.voicechat.concentus.SumSqrShift; - -class Stereo { - Stereo() { - } - - static void silk_stereo_decode_pred(EntropyCoder psRangeDec, int[] pred_Q13) { - int[][] ix = Arrays.InitTwoDimensionalArrayInt(2, 3); - int n = psRangeDec.dec_icdf(SilkTables.silk_stereo_pred_joint_iCDF, 8); - ix[0][2] = Inlines.silk_DIV32_16(n, 5); - ix[1][2] = n - 5 * ix[0][2]; - for (n = 0; n < 2; ++n) { - ix[n][0] = psRangeDec.dec_icdf(SilkTables.silk_uniform3_iCDF, 8); - ix[n][1] = psRangeDec.dec_icdf(SilkTables.silk_uniform5_iCDF, 8); - } - for (n = 0; n < 2; ++n) { - int[] nArray = ix[n]; - nArray[0] = nArray[0] + 3 * ix[n][2]; - short low_Q13 = SilkTables.silk_stereo_pred_quant_Q13[ix[n][0]]; - int step_Q13 = Inlines.silk_SMULWB(SilkTables.silk_stereo_pred_quant_Q13[ix[n][0] + 1] - low_Q13, 6554); - pred_Q13[n] = Inlines.silk_SMLABB(low_Q13, step_Q13, 2 * ix[n][1] + 1); - } - pred_Q13[0] = pred_Q13[0] - pred_Q13[1]; - } - - static void silk_stereo_decode_mid_only(EntropyCoder psRangeDec, BoxedValueInt decode_only_mid) { - decode_only_mid.Val = psRangeDec.dec_icdf(SilkTables.silk_stereo_only_code_mid_iCDF, 8); - } - - static void silk_stereo_encode_pred(EntropyCoder psRangeEnc, byte[][] ix) { - int n = 5 * ix[0][2] + ix[1][2]; - Inlines.OpusAssert(n < 25); - psRangeEnc.enc_icdf(n, SilkTables.silk_stereo_pred_joint_iCDF, 8); - for (n = 0; n < 2; ++n) { - Inlines.OpusAssert(ix[n][0] < 3); - Inlines.OpusAssert(ix[n][1] < 5); - psRangeEnc.enc_icdf(ix[n][0], SilkTables.silk_uniform3_iCDF, 8); - psRangeEnc.enc_icdf(ix[n][1], SilkTables.silk_uniform5_iCDF, 8); - } - } - - static void silk_stereo_encode_mid_only(EntropyCoder psRangeEnc, byte mid_only_flag) { - psRangeEnc.enc_icdf(mid_only_flag, SilkTables.silk_stereo_only_code_mid_iCDF, 8); - } - - static int silk_stereo_find_predictor(BoxedValueInt ratio_Q14, short[] x, short[] y, int[] mid_res_amp_Q0, int mid_res_amp_Q0_ptr, int length, int smooth_coef_Q16) { - BoxedValueInt nrgx = new BoxedValueInt(0); - BoxedValueInt nrgy = new BoxedValueInt(0); - BoxedValueInt scale1 = new BoxedValueInt(0); - BoxedValueInt scale2 = new BoxedValueInt(0); - SumSqrShift.silk_sum_sqr_shift(nrgx, scale1, x, length); - SumSqrShift.silk_sum_sqr_shift(nrgy, scale2, y, length); - int scale = Inlines.silk_max_int(scale1.Val, scale2.Val); - scale += scale & 1; - nrgy.Val = Inlines.silk_RSHIFT32(nrgy.Val, scale - scale2.Val); - nrgx.Val = Inlines.silk_RSHIFT32(nrgx.Val, scale - scale1.Val); - nrgx.Val = Inlines.silk_max_int(nrgx.Val, 1); - int corr = Inlines.silk_inner_prod_aligned_scale(x, y, scale, length); - int pred_Q13 = Inlines.silk_DIV32_varQ(corr, nrgx.Val, 13); - pred_Q13 = Inlines.silk_LIMIT(pred_Q13, -16384, 16384); - int pred2_Q10 = Inlines.silk_SMULWB(pred_Q13, pred_Q13); - smooth_coef_Q16 = Inlines.silk_max_int(smooth_coef_Q16, Inlines.silk_abs(pred2_Q10)); - Inlines.OpusAssert(smooth_coef_Q16 < 32768); - scale = Inlines.silk_RSHIFT(scale, 1); - mid_res_amp_Q0[mid_res_amp_Q0_ptr] = Inlines.silk_SMLAWB(mid_res_amp_Q0[mid_res_amp_Q0_ptr], Inlines.silk_LSHIFT(Inlines.silk_SQRT_APPROX(nrgx.Val), scale) - mid_res_amp_Q0[mid_res_amp_Q0_ptr], smooth_coef_Q16); - nrgy.Val = Inlines.silk_SUB_LSHIFT32(nrgy.Val, Inlines.silk_SMULWB(corr, pred_Q13), 4); - nrgy.Val = Inlines.silk_ADD_LSHIFT32(nrgy.Val, Inlines.silk_SMULWB(nrgx.Val, pred2_Q10), 6); - mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1] = Inlines.silk_SMLAWB(mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1], Inlines.silk_LSHIFT(Inlines.silk_SQRT_APPROX(nrgy.Val), scale) - mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1], smooth_coef_Q16); - ratio_Q14.Val = Inlines.silk_DIV32_varQ(mid_res_amp_Q0[mid_res_amp_Q0_ptr + 1], Inlines.silk_max(mid_res_amp_Q0[mid_res_amp_Q0_ptr], 1), 14); - ratio_Q14.Val = Inlines.silk_LIMIT(ratio_Q14.Val, 0, Short.MAX_VALUE); - return pred_Q13; - } - - static void silk_stereo_LR_to_MS(StereoEncodeState state, short[] x1, int x1_ptr, short[] x2, int x2_ptr, byte[][] ix, BoxedValueByte mid_only_flag, int[] mid_side_rates_bps, int total_rate_bps, int prev_speech_act_Q8, int toMono, int fs_kHz, int frame_length) { - int width_Q14; - int min_mid_rate_bps; - int sum; - int n; - int[] pred_Q13 = new int[2]; - BoxedValueInt LP_ratio_Q14 = new BoxedValueInt(0); - BoxedValueInt HP_ratio_Q14 = new BoxedValueInt(0); - int mid = x1_ptr - 2; - short[] side = new short[frame_length + 2]; - for (n = 0; n < frame_length + 2; ++n) { - sum = x1[x1_ptr + n - 2] + x2[x2_ptr + n - 2]; - int diff = x1[x1_ptr + n - 2] - x2[x2_ptr + n - 2]; - x1[mid + n] = (short)Inlines.silk_RSHIFT_ROUND(sum, 1); - side[n] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(diff, 1)); - } - System.arraycopy(state.sMid, 0, x1, mid, 2); - System.arraycopy(state.sSide, 0, side, 0, 2); - System.arraycopy(x1, mid + frame_length, state.sMid, 0, 2); - System.arraycopy(side, frame_length, state.sSide, 0, 2); - short[] LP_mid = new short[frame_length]; - short[] HP_mid = new short[frame_length]; - for (n = 0; n < frame_length; ++n) { - sum = Inlines.silk_RSHIFT_ROUND(Inlines.silk_ADD_LSHIFT32(x1[mid + n] + x1[mid + n + 2], x1[mid + n + 1], 1), 2); - LP_mid[n] = (short)sum; - HP_mid[n] = (short)(x1[mid + n + 1] - sum); - } - short[] LP_side = new short[frame_length]; - short[] HP_side = new short[frame_length]; - for (n = 0; n < frame_length; ++n) { - sum = Inlines.silk_RSHIFT_ROUND(Inlines.silk_ADD_LSHIFT32(side[n] + side[n + 2], side[n + 1], 1), 2); - LP_side[n] = (short)sum; - HP_side[n] = (short)(side[n + 1] - sum); - } - boolean is10msFrame = frame_length == 10 * fs_kHz; - int smooth_coef_Q16 = is10msFrame ? 328 : 655; - smooth_coef_Q16 = Inlines.silk_SMULWB(Inlines.silk_SMULBB(prev_speech_act_Q8, prev_speech_act_Q8), smooth_coef_Q16); - pred_Q13[0] = Stereo.silk_stereo_find_predictor(LP_ratio_Q14, LP_mid, LP_side, state.mid_side_amp_Q0, 0, frame_length, smooth_coef_Q16); - pred_Q13[1] = Stereo.silk_stereo_find_predictor(HP_ratio_Q14, HP_mid, HP_side, state.mid_side_amp_Q0, 2, frame_length, smooth_coef_Q16); - int frac_Q16 = Inlines.silk_SMLABB(HP_ratio_Q14.Val, LP_ratio_Q14.Val, 3); - frac_Q16 = Inlines.silk_min(frac_Q16, 65536); - if ((total_rate_bps -= is10msFrame ? 1200 : 600) < 1) { - total_rate_bps = 1; - } - Inlines.OpusAssert((min_mid_rate_bps = Inlines.silk_SMLABB(2000, fs_kHz, 900)) < Short.MAX_VALUE); - int frac_3_Q16 = Inlines.silk_MUL(3, frac_Q16); - mid_side_rates_bps[0] = Inlines.silk_DIV32_varQ(total_rate_bps, 851968 + frac_3_Q16, 19); - if (mid_side_rates_bps[0] < min_mid_rate_bps) { - mid_side_rates_bps[0] = min_mid_rate_bps; - mid_side_rates_bps[1] = total_rate_bps - mid_side_rates_bps[0]; - width_Q14 = Inlines.silk_DIV32_varQ(Inlines.silk_LSHIFT(mid_side_rates_bps[1], 1) - min_mid_rate_bps, Inlines.silk_SMULWB(65536 + frac_3_Q16, min_mid_rate_bps), 16); - width_Q14 = Inlines.silk_LIMIT(width_Q14, 0, 16384); - } else { - mid_side_rates_bps[1] = total_rate_bps - mid_side_rates_bps[0]; - width_Q14 = 16384; - } - state.smth_width_Q14 = (short)Inlines.silk_SMLAWB(state.smth_width_Q14, width_Q14 - state.smth_width_Q14, smooth_coef_Q16); - mid_only_flag.Val = 0; - if (toMono != 0) { - width_Q14 = 0; - pred_Q13[0] = 0; - pred_Q13[1] = 0; - Stereo.silk_stereo_quant_pred(pred_Q13, ix); - } else if (state.width_prev_Q14 == 0 && (8 * total_rate_bps < 13 * min_mid_rate_bps || Inlines.silk_SMULWB(frac_Q16, state.smth_width_Q14) < 819)) { - pred_Q13[0] = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(state.smth_width_Q14, pred_Q13[0]), 14); - pred_Q13[1] = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(state.smth_width_Q14, pred_Q13[1]), 14); - Stereo.silk_stereo_quant_pred(pred_Q13, ix); - width_Q14 = 0; - pred_Q13[0] = 0; - pred_Q13[1] = 0; - mid_side_rates_bps[0] = total_rate_bps; - mid_side_rates_bps[1] = 0; - mid_only_flag.Val = 1; - } else if (state.width_prev_Q14 != 0 && (8 * total_rate_bps < 11 * min_mid_rate_bps || Inlines.silk_SMULWB(frac_Q16, state.smth_width_Q14) < 328)) { - pred_Q13[0] = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(state.smth_width_Q14, pred_Q13[0]), 14); - pred_Q13[1] = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(state.smth_width_Q14, pred_Q13[1]), 14); - Stereo.silk_stereo_quant_pred(pred_Q13, ix); - width_Q14 = 0; - pred_Q13[0] = 0; - pred_Q13[1] = 0; - } else if (state.smth_width_Q14 > 15565) { - Stereo.silk_stereo_quant_pred(pred_Q13, ix); - width_Q14 = 16384; - } else { - pred_Q13[0] = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(state.smth_width_Q14, pred_Q13[0]), 14); - pred_Q13[1] = Inlines.silk_RSHIFT(Inlines.silk_SMULBB(state.smth_width_Q14, pred_Q13[1]), 14); - Stereo.silk_stereo_quant_pred(pred_Q13, ix); - width_Q14 = state.smth_width_Q14; - } - if (mid_only_flag.Val == 1) { - state.silent_side_len = (short)(state.silent_side_len + (short)(frame_length - 8 * fs_kHz)); - if (state.silent_side_len < 5 * fs_kHz) { - mid_only_flag.Val = 0; - } else { - state.silent_side_len = (short)10000; - } - } else { - state.silent_side_len = 0; - } - if (mid_only_flag.Val == 0 && mid_side_rates_bps[1] < 1) { - mid_side_rates_bps[1] = 1; - mid_side_rates_bps[0] = Inlines.silk_max_int(1, total_rate_bps - mid_side_rates_bps[1]); - } - int pred0_Q13 = -state.pred_prev_Q13[0]; - int pred1_Q13 = -state.pred_prev_Q13[1]; - int w_Q24 = Inlines.silk_LSHIFT(state.width_prev_Q14, 10); - int denom_Q16 = Inlines.silk_DIV32_16(65536, 8 * fs_kHz); - int delta0_Q13 = 0 - Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULBB(pred_Q13[0] - state.pred_prev_Q13[0], denom_Q16), 16); - int delta1_Q13 = 0 - Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULBB(pred_Q13[1] - state.pred_prev_Q13[1], denom_Q16), 16); - int deltaw_Q24 = Inlines.silk_LSHIFT(Inlines.silk_SMULWB(width_Q14 - state.width_prev_Q14, denom_Q16), 10); - for (n = 0; n < 8 * fs_kHz; ++n) { - sum = Inlines.silk_LSHIFT(Inlines.silk_ADD_LSHIFT(x1[mid + n] + x1[mid + n + 2], x1[mid + n + 1], 1), 9); - sum = Inlines.silk_SMLAWB(Inlines.silk_SMULWB(w_Q24 += deltaw_Q24, side[n + 1]), sum, pred0_Q13 += delta0_Q13); - sum = Inlines.silk_SMLAWB(sum, Inlines.silk_LSHIFT(x1[mid + n + 1], 11), pred1_Q13 += delta1_Q13); - x2[x2_ptr + n - 1] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(sum, 8)); - } - pred0_Q13 = 0 - pred_Q13[0]; - pred1_Q13 = 0 - pred_Q13[1]; - w_Q24 = Inlines.silk_LSHIFT(width_Q14, 10); - for (n = 8 * fs_kHz; n < frame_length; ++n) { - sum = Inlines.silk_LSHIFT(Inlines.silk_ADD_LSHIFT(x1[mid + n] + x1[mid + n + 2], x1[mid + n + 1], 1), 9); - sum = Inlines.silk_SMLAWB(Inlines.silk_SMULWB(w_Q24, side[n + 1]), sum, pred0_Q13); - sum = Inlines.silk_SMLAWB(sum, Inlines.silk_LSHIFT(x1[mid + n + 1], 11), pred1_Q13); - x2[x2_ptr + n - 1] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(sum, 8)); - } - state.pred_prev_Q13[0] = (short)pred_Q13[0]; - state.pred_prev_Q13[1] = (short)pred_Q13[1]; - state.width_prev_Q14 = (short)width_Q14; - } - - static void silk_stereo_MS_to_LR(StereoDecodeState state, short[] x1, int x1_ptr, short[] x2, int x2_ptr, int[] pred_Q13, int fs_kHz, int frame_length) { - int sum; - int n; - System.arraycopy(state.sMid, 0, x1, x1_ptr, 2); - System.arraycopy(state.sSide, 0, x2, x2_ptr, 2); - System.arraycopy(x1, x1_ptr + frame_length, state.sMid, 0, 2); - System.arraycopy(x2, x2_ptr + frame_length, state.sSide, 0, 2); - int pred0_Q13 = state.pred_prev_Q13[0]; - int pred1_Q13 = state.pred_prev_Q13[1]; - int denom_Q16 = Inlines.silk_DIV32_16(65536, 8 * fs_kHz); - int delta0_Q13 = Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULBB(pred_Q13[0] - state.pred_prev_Q13[0], denom_Q16), 16); - int delta1_Q13 = Inlines.silk_RSHIFT_ROUND(Inlines.silk_SMULBB(pred_Q13[1] - state.pred_prev_Q13[1], denom_Q16), 16); - for (n = 0; n < 8 * fs_kHz; ++n) { - sum = Inlines.silk_LSHIFT(Inlines.silk_ADD_LSHIFT(x1[x1_ptr + n] + x1[x1_ptr + n + 2], x1[x1_ptr + n + 1], 1), 9); - sum = Inlines.silk_SMLAWB(Inlines.silk_LSHIFT(x2[x2_ptr + n + 1], 8), sum, pred0_Q13 += delta0_Q13); - sum = Inlines.silk_SMLAWB(sum, Inlines.silk_LSHIFT(x1[x1_ptr + n + 1], 11), pred1_Q13 += delta1_Q13); - x2[x2_ptr + n + 1] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(sum, 8)); - } - pred0_Q13 = pred_Q13[0]; - pred1_Q13 = pred_Q13[1]; - for (n = 8 * fs_kHz; n < frame_length; ++n) { - sum = Inlines.silk_LSHIFT(Inlines.silk_ADD_LSHIFT(x1[x1_ptr + n] + x1[x1_ptr + n + 2], x1[x1_ptr + n + 1], 1), 9); - sum = Inlines.silk_SMLAWB(Inlines.silk_LSHIFT(x2[x2_ptr + n + 1], 8), sum, pred0_Q13); - sum = Inlines.silk_SMLAWB(sum, Inlines.silk_LSHIFT(x1[x1_ptr + n + 1], 11), pred1_Q13); - x2[x2_ptr + n + 1] = (short)Inlines.silk_SAT16(Inlines.silk_RSHIFT_ROUND(sum, 8)); - } - state.pred_prev_Q13[0] = (short)pred_Q13[0]; - state.pred_prev_Q13[1] = (short)pred_Q13[1]; - for (n = 0; n < frame_length; ++n) { - sum = x1[x1_ptr + n + 1] + x2[x2_ptr + n + 1]; - int diff = x1[x1_ptr + n + 1] - x2[x2_ptr + n + 1]; - x1[x1_ptr + n + 1] = (short)Inlines.silk_SAT16(sum); - x2[x2_ptr + n + 1] = (short)Inlines.silk_SAT16(diff); - } - } - - static void silk_stereo_quant_pred(int[] pred_Q13, byte[][] ix) { - int quant_pred_Q13 = 0; - Arrays.MemSet(ix[0], (byte)0, 3); - Arrays.MemSet(ix[1], (byte)0, 3); - for (int n = 0; n < 2; ++n) { - boolean done = false; - int err_min_Q13 = Integer.MAX_VALUE; - for (int i = 0; !done && i < 15; i = (int)((byte)(i + 1))) { - short low_Q13 = SilkTables.silk_stereo_pred_quant_Q13[i]; - int step_Q13 = Inlines.silk_SMULWB(SilkTables.silk_stereo_pred_quant_Q13[i + 1] - low_Q13, 6554); - for (int j = 0; !done && j < 5; j = (int)((byte)(j + 1))) { - int lvl_Q13 = Inlines.silk_SMLABB(low_Q13, step_Q13, 2 * j + 1); - int err_Q13 = Inlines.silk_abs(pred_Q13[n] - lvl_Q13); - if (err_Q13 < err_min_Q13) { - err_min_Q13 = err_Q13; - quant_pred_Q13 = lvl_Q13; - ix[n][0] = i; - ix[n][1] = j; - continue; - } - done = true; - } - } - ix[n][2] = (byte)Inlines.silk_DIV32_16(ix[n][0], 3); - ix[n][0] = (byte)(ix[n][0] - (byte)(ix[n][2] * 3)); - pred_Q13[n] = quant_pred_Q13; - } - pred_Q13[0] = pred_Q13[0] - pred_Q13[1]; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/StereoDecodeState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/StereoDecodeState.java deleted file mode 100644 index 2f9a1d3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/StereoDecodeState.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class StereoDecodeState { - final short[] pred_prev_Q13 = new short[2]; - final short[] sMid = new short[2]; - final short[] sSide = new short[2]; - - StereoDecodeState() { - } - - void Reset() { - Arrays.MemSet(this.pred_prev_Q13, (short)0, 2); - Arrays.MemSet(this.sMid, (short)0, 2); - Arrays.MemSet(this.sSide, (short)0, 2); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/StereoEncodeState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/StereoEncodeState.java deleted file mode 100644 index 8822ba0..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/StereoEncodeState.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class StereoEncodeState { - final short[] pred_prev_Q13 = new short[2]; - final short[] sMid = new short[2]; - final short[] sSide = new short[2]; - final int[] mid_side_amp_Q0 = new int[4]; - short smth_width_Q14 = 0; - short width_prev_Q14 = 0; - short silent_side_len = 0; - final byte[][][] predIx = Arrays.InitThreeDimensionalArrayByte(3, 2, 3); - final byte[] mid_only_flags = new byte[3]; - - StereoEncodeState() { - } - - void Reset() { - Arrays.MemSet(this.pred_prev_Q13, (short)0, 2); - Arrays.MemSet(this.sMid, (short)0, 2); - Arrays.MemSet(this.sSide, (short)0, 2); - Arrays.MemSet(this.mid_side_amp_Q0, 0, 4); - this.smth_width_Q14 = 0; - this.width_prev_Q14 = 0; - this.silent_side_len = 0; - for (int x = 0; x < 3; ++x) { - for (int y = 0; y < 2; ++y) { - Arrays.MemSet(this.predIx[x][y], (byte)0, 3); - } - } - Arrays.MemSet(this.mid_only_flags, (byte)0, 3); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/StereoWidthState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/StereoWidthState.java deleted file mode 100644 index f81c623..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/StereoWidthState.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class StereoWidthState { - int XX; - int XY; - int YY; - int smoothed_width; - int max_follower; - - StereoWidthState() { - } - - void Reset() { - this.XX = 0; - this.XY = 0; - this.YY = 0; - this.smoothed_width = 0; - this.max_follower = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/SumSqrShift.java b/source/decompiled/de/maxhenkel/voicechat/concentus/SumSqrShift.java deleted file mode 100644 index 72eeb6c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/SumSqrShift.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; - -class SumSqrShift { - SumSqrShift() { - } - - static void silk_sum_sqr_shift(BoxedValueInt energy, BoxedValueInt shift, short[] x, int x_ptr, int len) { - int nrg_tmp; - int i; - int nrg = 0; - int shft = 0; - --len; - for (i = 0; i < len; i += 2) { - nrg = Inlines.silk_SMLABB_ovflw(nrg, x[x_ptr + i], x[x_ptr + i]); - if ((nrg = Inlines.silk_SMLABB_ovflw(nrg, x[x_ptr + i + 1], x[x_ptr + i + 1])) >= 0) continue; - nrg = (int)Inlines.silk_RSHIFT_uint(nrg, 2); - shft = 2; - i += 2; - break; - } - while (i < len) { - nrg_tmp = Inlines.silk_SMULBB(x[x_ptr + i], x[x_ptr + i]); - if ((nrg = (int)Inlines.silk_ADD_RSHIFT_uint(nrg, nrg_tmp = Inlines.silk_SMLABB_ovflw(nrg_tmp, x[x_ptr + i + 1], x[x_ptr + i + 1]), shft)) < 0) { - nrg = (int)Inlines.silk_RSHIFT_uint(nrg, 2); - shft += 2; - } - i += 2; - } - if (i == len) { - nrg_tmp = Inlines.silk_SMULBB(x[x_ptr + i], x[x_ptr + i]); - nrg = (int)Inlines.silk_ADD_RSHIFT_uint(nrg, nrg_tmp, shft); - } - if ((nrg & 0xC0000000) != 0) { - nrg = (int)Inlines.silk_RSHIFT_uint(nrg, 2); - shft += 2; - } - shift.Val = shft; - energy.Val = nrg; - } - - static void silk_sum_sqr_shift(BoxedValueInt energy, BoxedValueInt shift, short[] x, int len) { - int nrg_tmp; - int i; - int nrg = 0; - int shft = 0; - --len; - for (i = 0; i < len; i += 2) { - nrg = Inlines.silk_SMLABB_ovflw(nrg, x[i], x[i]); - if ((nrg = Inlines.silk_SMLABB_ovflw(nrg, x[i + 1], x[i + 1])) >= 0) continue; - nrg = (int)Inlines.silk_RSHIFT_uint(nrg, 2); - shft = 2; - i += 2; - break; - } - while (i < len) { - nrg_tmp = Inlines.silk_SMULBB(x[i], x[i]); - if ((nrg = (int)Inlines.silk_ADD_RSHIFT_uint(nrg, nrg_tmp = Inlines.silk_SMLABB_ovflw(nrg_tmp, x[i + 1], x[i + 1]), shft)) < 0) { - nrg = (int)Inlines.silk_RSHIFT_uint(nrg, 2); - shft += 2; - } - i += 2; - } - if (i == len) { - nrg_tmp = Inlines.silk_SMULBB(x[i], x[i]); - nrg = (int)Inlines.silk_ADD_RSHIFT_uint(nrg, nrg_tmp, shft); - } - if ((nrg & 0xC0000000) != 0) { - nrg = (int)Inlines.silk_RSHIFT_uint(nrg, 2); - shft += 2; - } - shift.Val = shft; - energy.Val = nrg; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/TOCStruct.java b/source/decompiled/de/maxhenkel/voicechat/concentus/TOCStruct.java deleted file mode 100644 index bb301ff..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/TOCStruct.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Arrays; - -class TOCStruct { - int VADFlag = 0; - final int[] VADFlags = new int[3]; - int inbandFECFlag = 0; - - TOCStruct() { - } - - void Reset() { - this.VADFlag = 0; - Arrays.MemSet(this.VADFlags, 0, 3); - this.inbandFECFlag = 0; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/TonalityAnalysisState.java b/source/decompiled/de/maxhenkel/voicechat/concentus/TonalityAnalysisState.java deleted file mode 100644 index 27dd45c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/TonalityAnalysisState.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.AnalysisInfo; -import de.maxhenkel.voicechat.concentus.Arrays; - -class TonalityAnalysisState { - boolean enabled = false; - final float[] angle = new float[240]; - final float[] d_angle = new float[240]; - final float[] d2_angle = new float[240]; - final int[] inmem = new int[720]; - int mem_fill; - final float[] prev_band_tonality = new float[18]; - float prev_tonality; - final float[][] E = Arrays.InitTwoDimensionalArrayFloat(8, 18); - final float[] lowE = new float[18]; - final float[] highE = new float[18]; - final float[] meanE = new float[21]; - final float[] mem = new float[32]; - final float[] cmean = new float[8]; - final float[] std = new float[9]; - float music_prob; - float Etracker; - float lowECount; - int E_count; - int last_music; - int last_transition; - int count; - final float[] subframe_mem = new float[3]; - int analysis_offset; - final float[] pspeech = new float[200]; - final float[] pmusic = new float[200]; - float speech_confidence; - float music_confidence; - int speech_confidence_count; - int music_confidence_count; - int write_pos; - int read_pos; - int read_subframe; - final AnalysisInfo[] info = new AnalysisInfo[200]; - - TonalityAnalysisState() { - for (int c = 0; c < 200; ++c) { - this.info[c] = new AnalysisInfo(); - } - } - - void Reset() { - int c; - Arrays.MemSet(this.angle, 0.0f, 240); - Arrays.MemSet(this.d_angle, 0.0f, 240); - Arrays.MemSet(this.d2_angle, 0.0f, 240); - Arrays.MemSet(this.inmem, 0, 720); - this.mem_fill = 0; - Arrays.MemSet(this.prev_band_tonality, 0.0f, 18); - this.prev_tonality = 0.0f; - for (c = 0; c < 8; ++c) { - Arrays.MemSet(this.E[c], 0.0f, 18); - } - Arrays.MemSet(this.lowE, 0.0f, 18); - Arrays.MemSet(this.highE, 0.0f, 18); - Arrays.MemSet(this.meanE, 0.0f, 21); - Arrays.MemSet(this.mem, 0.0f, 32); - Arrays.MemSet(this.cmean, 0.0f, 8); - Arrays.MemSet(this.std, 0.0f, 9); - this.music_prob = 0.0f; - this.Etracker = 0.0f; - this.lowECount = 0.0f; - this.E_count = 0; - this.last_music = 0; - this.last_transition = 0; - this.count = 0; - Arrays.MemSet(this.subframe_mem, 0.0f, 3); - this.analysis_offset = 0; - Arrays.MemSet(this.pspeech, 0.0f, 200); - Arrays.MemSet(this.pmusic, 0.0f, 200); - this.speech_confidence = 0.0f; - this.music_confidence = 0.0f; - this.speech_confidence_count = 0; - this.music_confidence_count = 0; - this.write_pos = 0; - this.read_pos = 0; - this.read_subframe = 0; - for (c = 0; c < 200; ++c) { - this.info[c].Reset(); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/TuningParameters.java b/source/decompiled/de/maxhenkel/voicechat/concentus/TuningParameters.java deleted file mode 100644 index a0ffd2d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/TuningParameters.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class TuningParameters { - static final int BITRESERVOIR_DECAY_TIME_MS = 500; - static final float FIND_PITCH_WHITE_NOISE_FRACTION = 0.001f; - static final float FIND_PITCH_BANDWIDTH_EXPANSION = 0.99f; - static final float FIND_LPC_COND_FAC = 1.0E-5f; - static final float FIND_LTP_COND_FAC = 1.0E-5f; - static final float LTP_DAMPING = 0.05f; - static final float LTP_SMOOTHING = 0.1f; - static final float MU_LTP_QUANT_NB = 0.03f; - static final float MU_LTP_QUANT_MB = 0.025f; - static final float MU_LTP_QUANT_WB = 0.02f; - static final float MAX_SUM_LOG_GAIN_DB = 250.0f; - static final float VARIABLE_HP_SMTH_COEF1 = 0.1f; - static final float VARIABLE_HP_SMTH_COEF2 = 0.015f; - static final float VARIABLE_HP_MAX_DELTA_FREQ = 0.4f; - static final int VARIABLE_HP_MIN_CUTOFF_HZ = 60; - static final int VARIABLE_HP_MAX_CUTOFF_HZ = 100; - static final float SPEECH_ACTIVITY_DTX_THRES = 0.05f; - static final float LBRR_SPEECH_ACTIVITY_THRES = 0.3f; - static final float BG_SNR_DECR_dB = 2.0f; - static final float HARM_SNR_INCR_dB = 2.0f; - static final float SPARSE_SNR_INCR_dB = 2.0f; - static final float SPARSENESS_THRESHOLD_QNT_OFFSET = 0.75f; - static final float WARPING_MULTIPLIER = 0.015f; - static final float SHAPE_WHITE_NOISE_FRACTION = 5.0E-5f; - static final float BANDWIDTH_EXPANSION = 0.95f; - static final float LOW_RATE_BANDWIDTH_EXPANSION_DELTA = 0.01f; - static final float LOW_RATE_HARMONIC_BOOST = 0.1f; - static final float LOW_INPUT_QUALITY_HARMONIC_BOOST = 0.1f; - static final float HARMONIC_SHAPING = 0.3f; - static final float HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING = 0.2f; - static final float HP_NOISE_COEF = 0.25f; - static final float HARM_HP_NOISE_COEF = 0.35f; - static final float INPUT_TILT = 0.05f; - static final float HIGH_RATE_INPUT_TILT = 0.1f; - static final float LOW_FREQ_SHAPING = 4.0f; - static final float LOW_QUALITY_LOW_FREQ_SHAPING_DECR = 0.5f; - static final float SUBFR_SMTH_COEF = 0.4f; - static final float LAMBDA_OFFSET = 1.2f; - static final float LAMBDA_SPEECH_ACT = -0.2f; - static final float LAMBDA_DELAYED_DECISIONS = -0.05f; - static final float LAMBDA_INPUT_QUALITY = -0.1f; - static final float LAMBDA_CODING_QUALITY = -0.2f; - static final float LAMBDA_QUANT_OFFSET = 0.8f; - static final int REDUCE_BITRATE_10_MS_BPS = 2200; - static final int MAX_BANDWIDTH_SWITCH_DELAY_MS = 5000; - - TuningParameters() { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/VQ.java b/source/decompiled/de/maxhenkel/voicechat/concentus/VQ.java deleted file mode 100644 index c609a11..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/VQ.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.CWRS; -import de.maxhenkel.voicechat.concentus.EntropyCoder; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Kernels; - -class VQ { - private static int[] SPREAD_FACTOR = new int[]{15, 10, 5}; - - VQ() { - } - - static void exp_rotation1(int[] X, int X_ptr, int len, int stride, int c, int s) { - int x2; - int x1; - int i; - int Xptr = X_ptr; - int ms = Inlines.NEG16(s); - for (i = 0; i < len - stride; ++i) { - x1 = X[Xptr]; - x2 = X[Xptr + stride]; - X[Xptr + stride] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MAC16_16(Inlines.MULT16_16(c, x2), s, x1), 15)); - X[Xptr] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MAC16_16(Inlines.MULT16_16(c, x1), ms, x2), 15)); - ++Xptr; - } - Xptr = X_ptr + (len - 2 * stride - 1); - for (i = len - 2 * stride - 1; i >= 0; --i) { - x1 = X[Xptr]; - x2 = X[Xptr + stride]; - X[Xptr + stride] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MAC16_16(Inlines.MULT16_16(c, x2), s, x1), 15)); - X[Xptr] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MAC16_16(Inlines.MULT16_16(c, x1), ms, x2), 15)); - --Xptr; - } - } - - static void exp_rotation(int[] X, int X_ptr, int len, int dir, int stride, int K, int spread) { - int stride2 = 0; - if (2 * K >= len || spread == 0) { - return; - } - int factor = SPREAD_FACTOR[spread - 1]; - int gain = Inlines.celt_div(Inlines.MULT16_16(Short.MAX_VALUE, len), len + factor * K); - int theta = Inlines.HALF16(Inlines.MULT16_16_Q15(gain, gain)); - int c = Inlines.celt_cos_norm(Inlines.EXTEND32(theta)); - int s = Inlines.celt_cos_norm(Inlines.EXTEND32(Inlines.SUB16(Short.MAX_VALUE, theta))); - if (len >= 8 * stride) { - stride2 = 1; - while ((stride2 * stride2 + stride2) * stride + (stride >> 2) < len) { - ++stride2; - } - } - len = Inlines.celt_udiv(len, stride); - for (int i = 0; i < stride; ++i) { - if (dir < 0) { - if (stride2 != 0) { - VQ.exp_rotation1(X, X_ptr + i * len, len, stride2, s, c); - } - VQ.exp_rotation1(X, X_ptr + i * len, len, 1, c, s); - continue; - } - VQ.exp_rotation1(X, X_ptr + i * len, len, 1, c, (short)(0 - s)); - if (stride2 == 0) continue; - VQ.exp_rotation1(X, X_ptr + i * len, len, stride2, s, (short)(0 - c)); - } - } - - static void normalise_residual(int[] iy, int[] X, int X_ptr, int N, int Ryy, int gain) { - int k = Inlines.celt_ilog2(Ryy) >> 1; - int t = Inlines.VSHR32(Ryy, 2 * (k - 7)); - int g = Inlines.MULT16_16_P15(Inlines.celt_rsqrt_norm(t), gain); - int i = 0; - do { - X[X_ptr + i] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MULT16_16(g, iy[i]), k + 1)); - } while (++i < N); - } - - static int extract_collapse_mask(int[] iy, int N, int B) { - if (B <= 1) { - return 1; - } - int N0 = Inlines.celt_udiv(N, B); - int collapse_mask = 0; - int i = 0; - do { - int tmp = 0; - int j = 0; - do { - tmp |= iy[i * N0 + j]; - } while (++j < N0); - collapse_mask |= (tmp != 0 ? 1 : 0) << i; - } while (++i < B); - return collapse_mask; - } - - static int alg_quant(int[] X, int X_ptr, int N, int K, int spread, int B, EntropyCoder enc) { - int[] y = new int[N]; - int[] iy = new int[N]; - int[] signx = new int[N]; - Inlines.OpusAssert(K > 0, "alg_quant() needs at least one pulse"); - Inlines.OpusAssert(N > 1, "alg_quant() needs at least two dimensions"); - VQ.exp_rotation(X, X_ptr, N, 1, B, K, spread); - int sum = 0; - int j = 0; - do { - if (X[X_ptr + j] > 0) { - signx[j] = 1; - } else { - signx[j] = -1; - X[X_ptr + j] = 0 - X[X_ptr + j]; - } - iy[j] = 0; - y[j] = 0; - } while (++j < N); - int yy = 0; - int xy = 0; - int pulsesLeft = K; - if (K > N >> 1) { - j = 0; - do { - sum += X[X_ptr + j]; - } while (++j < N); - if (sum <= K) { - X[X_ptr] = 16384; - j = X_ptr + 1; - do { - X[j] = 0; - } while (++j < N + X_ptr); - sum = 16384; - } - short rcp = Inlines.EXTRACT16(Inlines.MULT16_32_Q16(K - 1, Inlines.celt_rcp(sum))); - j = 0; - do { - iy[j] = Inlines.MULT16_16_Q15(X[X_ptr + j], (int)rcp); - y[j] = iy[j]; - yy = Inlines.MAC16_16(yy, y[j], y[j]); - xy = Inlines.MAC16_16(xy, X[X_ptr + j], y[j]); - int n = j; - y[n] = y[n] * 2; - pulsesLeft -= iy[j]; - } while (++j < N); - } - Inlines.OpusAssert(pulsesLeft >= 1, "Allocated too many pulses in the quick pass"); - if (pulsesLeft > N + 3) { - int tmp = pulsesLeft; - yy = Inlines.MAC16_16(yy, tmp, tmp); - yy = Inlines.MAC16_16(yy, tmp, y[0]); - iy[0] = iy[0] + pulsesLeft; - pulsesLeft = 0; - } - int s = 1; - for (int i = 0; i < pulsesLeft; ++i) { - int best_num = -32767; - int best_den = 0; - int rshift = 1 + Inlines.celt_ilog2(K - pulsesLeft + i + 1); - int best_id = 0; - yy = Inlines.ADD16(yy, 1); - j = 0; - do { - int Rxy = Inlines.EXTRACT16(Inlines.SHR32(Inlines.ADD32(xy, Inlines.EXTEND32(X[X_ptr + j])), rshift)); - int Ryy = Inlines.ADD16(yy, y[j]); - if (Inlines.MULT16_16(best_den, Rxy = Inlines.MULT16_16_Q15(Rxy, Rxy)) <= Inlines.MULT16_16(Ryy, best_num)) continue; - best_den = Ryy; - best_num = Rxy; - best_id = j; - } while (++j < N); - xy = Inlines.ADD32(xy, Inlines.EXTEND32(X[X_ptr + best_id])); - yy = Inlines.ADD16(yy, y[best_id]); - y[best_id] = y[best_id] + 2 * s; - int n = best_id; - iy[n] = iy[n] + 1; - } - j = 0; - do { - X[X_ptr + j] = Inlines.MULT16_16(signx[j], X[X_ptr + j]); - if (signx[j] >= 0) continue; - iy[j] = -iy[j]; - } while (++j < N); - CWRS.encode_pulses(iy, N, K, enc); - int collapse_mask = VQ.extract_collapse_mask(iy, N, B); - return collapse_mask; - } - - static int alg_unquant(int[] X, int X_ptr, int N, int K, int spread, int B, EntropyCoder dec, int gain) { - int[] iy = new int[N]; - Inlines.OpusAssert(K > 0, "alg_unquant() needs at least one pulse"); - Inlines.OpusAssert(N > 1, "alg_unquant() needs at least two dimensions"); - int Ryy = CWRS.decode_pulses(iy, N, K, dec); - VQ.normalise_residual(iy, X, X_ptr, N, Ryy, gain); - VQ.exp_rotation(X, X_ptr, N, -1, B, K, spread); - int collapse_mask = VQ.extract_collapse_mask(iy, N, B); - return collapse_mask; - } - - static void renormalise_vector(int[] X, int X_ptr, int N, int gain) { - int E = 1 + Kernels.celt_inner_prod(X, X_ptr, X, X_ptr, N); - int k = Inlines.celt_ilog2(E) >> 1; - int t = Inlines.VSHR32(E, 2 * (k - 7)); - int g = Inlines.MULT16_16_P15(Inlines.celt_rsqrt_norm(t), gain); - int xptr = X_ptr; - for (int i = 0; i < N; ++i) { - X[xptr] = Inlines.EXTRACT16(Inlines.PSHR32(Inlines.MULT16_16(g, X[xptr]), k + 1)); - ++xptr; - } - } - - static int stereo_itheta(int[] X, int X_ptr, int[] Y, int Y_ptr, int stereo, int N) { - int Eside = 1; - int Emid = 1; - if (stereo != 0) { - for (int i = 0; i < N; ++i) { - int m = Inlines.ADD16(Inlines.SHR16(X[X_ptr + i], 1), Inlines.SHR16(Y[Y_ptr + i], 1)); - int s = Inlines.SUB16(Inlines.SHR16(X[X_ptr + i], 1), Inlines.SHR16(Y[Y_ptr + i], 1)); - Emid = Inlines.MAC16_16(Emid, m, m); - Eside = Inlines.MAC16_16(Eside, s, s); - } - } else { - Emid += Kernels.celt_inner_prod(X, X_ptr, X, X_ptr, N); - Eside += Kernels.celt_inner_prod(Y, Y_ptr, Y, Y_ptr, N); - } - int mid = Inlines.celt_sqrt(Emid); - int side = Inlines.celt_sqrt(Eside); - int itheta = Inlines.MULT16_16_Q15(20861, Inlines.celt_atan2p(side, mid)); - return itheta; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/VQ_WMat_EC.java b/source/decompiled/de/maxhenkel/voicechat/concentus/VQ_WMat_EC.java deleted file mode 100644 index 82ce4a6..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/VQ_WMat_EC.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.BoxedValueByte; -import de.maxhenkel.voicechat.concentus.BoxedValueInt; -import de.maxhenkel.voicechat.concentus.Inlines; - -class VQ_WMat_EC { - VQ_WMat_EC() { - } - - static void silk_VQ_WMat_EC(BoxedValueByte ind, BoxedValueInt rate_dist_Q14, BoxedValueInt gain_Q7, short[] in_Q14, int in_Q14_ptr, int[] W_Q18, int W_Q18_ptr, byte[][] cb_Q7, short[] cb_gain_Q7, short[] cl_Q5, int mu_Q9, int max_gain_Q7, int L) { - int cb_row_Q7_ptr = 0; - short[] diff_Q14 = new short[5]; - rate_dist_Q14.Val = Integer.MAX_VALUE; - for (int k = 0; k < L; ++k) { - byte[] cb_row_Q7 = cb_Q7[cb_row_Q7_ptr++]; - int gain_tmp_Q7 = cb_gain_Q7[k]; - diff_Q14[0] = (short)(in_Q14[in_Q14_ptr] - Inlines.silk_LSHIFT(cb_row_Q7[0], 7)); - diff_Q14[1] = (short)(in_Q14[in_Q14_ptr + 1] - Inlines.silk_LSHIFT(cb_row_Q7[1], 7)); - diff_Q14[2] = (short)(in_Q14[in_Q14_ptr + 2] - Inlines.silk_LSHIFT(cb_row_Q7[2], 7)); - diff_Q14[3] = (short)(in_Q14[in_Q14_ptr + 3] - Inlines.silk_LSHIFT(cb_row_Q7[3], 7)); - diff_Q14[4] = (short)(in_Q14[in_Q14_ptr + 4] - Inlines.silk_LSHIFT(cb_row_Q7[4], 7)); - int sum1_Q14 = Inlines.silk_SMULBB(mu_Q9, cl_Q5[k]); - Inlines.OpusAssert((sum1_Q14 = Inlines.silk_ADD_LSHIFT32(sum1_Q14, Inlines.silk_max(Inlines.silk_SUB32(gain_tmp_Q7, max_gain_Q7), 0), 10)) >= 0); - int sum2_Q16 = Inlines.silk_SMULWB(W_Q18[W_Q18_ptr + 1], diff_Q14[1]); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 2], diff_Q14[2]); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 3], diff_Q14[3]); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 4], diff_Q14[4]); - sum2_Q16 = Inlines.silk_LSHIFT(sum2_Q16, 1); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr], diff_Q14[0]); - sum1_Q14 = Inlines.silk_SMLAWB(sum1_Q14, sum2_Q16, diff_Q14[0]); - sum2_Q16 = Inlines.silk_SMULWB(W_Q18[W_Q18_ptr + 7], diff_Q14[2]); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 8], diff_Q14[3]); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 9], diff_Q14[4]); - sum2_Q16 = Inlines.silk_LSHIFT(sum2_Q16, 1); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 6], diff_Q14[1]); - sum1_Q14 = Inlines.silk_SMLAWB(sum1_Q14, sum2_Q16, diff_Q14[1]); - sum2_Q16 = Inlines.silk_SMULWB(W_Q18[W_Q18_ptr + 13], diff_Q14[3]); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 14], diff_Q14[4]); - sum2_Q16 = Inlines.silk_LSHIFT(sum2_Q16, 1); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 12], diff_Q14[2]); - sum1_Q14 = Inlines.silk_SMLAWB(sum1_Q14, sum2_Q16, diff_Q14[2]); - sum2_Q16 = Inlines.silk_SMULWB(W_Q18[W_Q18_ptr + 19], diff_Q14[4]); - sum2_Q16 = Inlines.silk_LSHIFT(sum2_Q16, 1); - sum2_Q16 = Inlines.silk_SMLAWB(sum2_Q16, W_Q18[W_Q18_ptr + 18], diff_Q14[3]); - sum1_Q14 = Inlines.silk_SMLAWB(sum1_Q14, sum2_Q16, diff_Q14[3]); - sum2_Q16 = Inlines.silk_SMULWB(W_Q18[W_Q18_ptr + 24], diff_Q14[4]); - sum1_Q14 = Inlines.silk_SMLAWB(sum1_Q14, sum2_Q16, diff_Q14[4]); - Inlines.OpusAssert(sum1_Q14 >= 0); - if (sum1_Q14 >= rate_dist_Q14.Val) continue; - rate_dist_Q14.Val = sum1_Q14; - ind.Val = (byte)k; - gain_Q7.Val = gain_tmp_Q7; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/VoiceActivityDetection.java b/source/decompiled/de/maxhenkel/voicechat/concentus/VoiceActivityDetection.java deleted file mode 100644 index 8813a75..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/VoiceActivityDetection.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -import de.maxhenkel.voicechat.concentus.Filters; -import de.maxhenkel.voicechat.concentus.Inlines; -import de.maxhenkel.voicechat.concentus.Sigmoid; -import de.maxhenkel.voicechat.concentus.SilkChannelEncoder; -import de.maxhenkel.voicechat.concentus.SilkVADState; - -class VoiceActivityDetection { - private static final int[] tiltWeights = new int[]{30000, 6000, -12000, -12000}; - - VoiceActivityDetection() { - } - - static int silk_VAD_Init(SilkVADState psSilk_VAD) { - int b; - int ret = 0; - psSilk_VAD.Reset(); - for (b = 0; b < 4; ++b) { - psSilk_VAD.NoiseLevelBias[b] = Inlines.silk_max_32(Inlines.silk_DIV32_16(50, (short)(b + 1)), 1); - } - for (b = 0; b < 4; ++b) { - psSilk_VAD.NL[b] = Inlines.silk_MUL(100, psSilk_VAD.NoiseLevelBias[b]); - psSilk_VAD.inv_NL[b] = Inlines.silk_DIV32(Integer.MAX_VALUE, psSilk_VAD.NL[b]); - } - psSilk_VAD.counter = 15; - for (b = 0; b < 4; ++b) { - psSilk_VAD.NrgRatioSmth_Q8[b] = 25600; - } - return ret; - } - - static int silk_VAD_GetSA_Q8(SilkChannelEncoder psEncC, short[] pIn, int pIn_ptr) { - int SNR_Q7; - int speech_nrg; - int b; - int i; - int sumSquared = 0; - int[] Xnrg = new int[4]; - int[] NrgToNoiseRatio_Q8 = new int[4]; - int[] X_offset = new int[4]; - int ret = 0; - SilkVADState psSilk_VAD = psEncC.sVAD; - Inlines.OpusAssert(true); - Inlines.OpusAssert(320 >= psEncC.frame_length); - Inlines.OpusAssert(psEncC.frame_length <= 512); - Inlines.OpusAssert(psEncC.frame_length == 8 * Inlines.silk_RSHIFT(psEncC.frame_length, 3)); - int decimated_framelength1 = Inlines.silk_RSHIFT(psEncC.frame_length, 1); - int decimated_framelength2 = Inlines.silk_RSHIFT(psEncC.frame_length, 2); - int decimated_framelength = Inlines.silk_RSHIFT(psEncC.frame_length, 3); - X_offset[0] = 0; - X_offset[1] = decimated_framelength + decimated_framelength2; - X_offset[2] = X_offset[1] + decimated_framelength; - X_offset[3] = X_offset[2] + decimated_framelength2; - short[] X = new short[X_offset[3] + decimated_framelength1]; - Filters.silk_ana_filt_bank_1(pIn, pIn_ptr, psSilk_VAD.AnaState, X, X, X_offset[3], psEncC.frame_length); - Filters.silk_ana_filt_bank_1(X, 0, psSilk_VAD.AnaState1, X, X, X_offset[2], decimated_framelength1); - Filters.silk_ana_filt_bank_1(X, 0, psSilk_VAD.AnaState2, X, X, X_offset[1], decimated_framelength2); - X[decimated_framelength - 1] = (short)Inlines.silk_RSHIFT(X[decimated_framelength - 1], 1); - short HPstateTmp = X[decimated_framelength - 1]; - for (i = decimated_framelength - 1; i > 0; --i) { - X[i - 1] = (short)Inlines.silk_RSHIFT(X[i - 1], 1); - int n = i; - X[n] = (short)(X[n] - X[i - 1]); - } - X[0] = (short)(X[0] - psSilk_VAD.HPstate); - psSilk_VAD.HPstate = HPstateTmp; - for (b = 0; b < 4; ++b) { - decimated_framelength = Inlines.silk_RSHIFT(psEncC.frame_length, Inlines.silk_min_int(4 - b, 3)); - int dec_subframe_length = Inlines.silk_RSHIFT(decimated_framelength, 2); - int dec_subframe_offset = 0; - Xnrg[b] = psSilk_VAD.XnrgSubfr[b]; - for (int s = 0; s < 4; ++s) { - sumSquared = 0; - for (i = 0; i < dec_subframe_length; ++i) { - int x_tmp = Inlines.silk_RSHIFT(X[X_offset[b] + i + dec_subframe_offset], 3); - Inlines.OpusAssert((sumSquared = Inlines.silk_SMLABB(sumSquared, x_tmp, x_tmp)) >= 0); - } - Xnrg[b] = s < 3 ? Inlines.silk_ADD_POS_SAT32(Xnrg[b], sumSquared) : Inlines.silk_ADD_POS_SAT32(Xnrg[b], Inlines.silk_RSHIFT(sumSquared, 1)); - dec_subframe_offset += dec_subframe_length; - } - psSilk_VAD.XnrgSubfr[b] = sumSquared; - } - VoiceActivityDetection.silk_VAD_GetNoiseLevels(Xnrg, psSilk_VAD); - sumSquared = 0; - int input_tilt = 0; - for (b = 0; b < 4; ++b) { - speech_nrg = Xnrg[b] - psSilk_VAD.NL[b]; - if (speech_nrg > 0) { - NrgToNoiseRatio_Q8[b] = (Xnrg[b] & 0xFF800000) == 0 ? Inlines.silk_DIV32(Inlines.silk_LSHIFT(Xnrg[b], 8), psSilk_VAD.NL[b] + 1) : Inlines.silk_DIV32(Xnrg[b], Inlines.silk_RSHIFT(psSilk_VAD.NL[b], 8) + 1); - SNR_Q7 = Inlines.silk_lin2log(NrgToNoiseRatio_Q8[b]) - 1024; - sumSquared = Inlines.silk_SMLABB(sumSquared, SNR_Q7, SNR_Q7); - if (speech_nrg < 0x100000) { - SNR_Q7 = Inlines.silk_SMULWB(Inlines.silk_LSHIFT(Inlines.silk_SQRT_APPROX(speech_nrg), 6), SNR_Q7); - } - input_tilt = Inlines.silk_SMLAWB(input_tilt, tiltWeights[b], SNR_Q7); - continue; - } - NrgToNoiseRatio_Q8[b] = 256; - } - sumSquared = Inlines.silk_DIV32_16(sumSquared, 4); - short pSNR_dB_Q7 = (short)(3 * Inlines.silk_SQRT_APPROX(sumSquared)); - int SA_Q15 = Sigmoid.silk_sigm_Q15(Inlines.silk_SMULWB(45000, pSNR_dB_Q7) - 128); - psEncC.input_tilt_Q15 = Inlines.silk_LSHIFT(Sigmoid.silk_sigm_Q15(input_tilt) - 16384, 1); - speech_nrg = 0; - for (b = 0; b < 4; ++b) { - speech_nrg += (b + 1) * Inlines.silk_RSHIFT(Xnrg[b] - psSilk_VAD.NL[b], 4); - } - if (speech_nrg <= 0) { - SA_Q15 = Inlines.silk_RSHIFT(SA_Q15, 1); - } else if (speech_nrg < 32768) { - speech_nrg = psEncC.frame_length == 10 * psEncC.fs_kHz ? Inlines.silk_LSHIFT_SAT32(speech_nrg, 16) : Inlines.silk_LSHIFT_SAT32(speech_nrg, 15); - speech_nrg = Inlines.silk_SQRT_APPROX(speech_nrg); - SA_Q15 = Inlines.silk_SMULWB(32768 + speech_nrg, SA_Q15); - } - psEncC.speech_activity_Q8 = Inlines.silk_min_int(Inlines.silk_RSHIFT(SA_Q15, 7), 255); - int smooth_coef_Q16 = Inlines.silk_SMULWB(4096, Inlines.silk_SMULWB(SA_Q15, SA_Q15)); - if (psEncC.frame_length == 10 * psEncC.fs_kHz) { - smooth_coef_Q16 >>= 1; - } - for (b = 0; b < 4; ++b) { - psSilk_VAD.NrgRatioSmth_Q8[b] = Inlines.silk_SMLAWB(psSilk_VAD.NrgRatioSmth_Q8[b], NrgToNoiseRatio_Q8[b] - psSilk_VAD.NrgRatioSmth_Q8[b], smooth_coef_Q16); - SNR_Q7 = 3 * (Inlines.silk_lin2log(psSilk_VAD.NrgRatioSmth_Q8[b]) - 1024); - psEncC.input_quality_bands_Q15[b] = Sigmoid.silk_sigm_Q15(Inlines.silk_RSHIFT(SNR_Q7 - 2048, 4)); - } - return ret; - } - - static void silk_VAD_GetNoiseLevels(int[] pX, SilkVADState psSilk_VAD) { - int min_coef = psSilk_VAD.counter < 1000 ? Inlines.silk_DIV32_16(Short.MAX_VALUE, (short)(Inlines.silk_RSHIFT(psSilk_VAD.counter, 4) + 1)) : 0; - for (int k = 0; k < 4; ++k) { - int nl = psSilk_VAD.NL[k]; - Inlines.OpusAssert(nl >= 0); - int nrg = Inlines.silk_ADD_POS_SAT32(pX[k], psSilk_VAD.NoiseLevelBias[k]); - Inlines.OpusAssert(nrg > 0); - int inv_nrg = Inlines.silk_DIV32(Integer.MAX_VALUE, nrg); - Inlines.OpusAssert(inv_nrg >= 0); - int coef = nrg > Inlines.silk_LSHIFT(nl, 3) ? 128 : (nrg < nl ? 1024 : Inlines.silk_SMULWB(Inlines.silk_SMULWW(inv_nrg, nl), 2048)); - coef = Inlines.silk_max_int(coef, min_coef); - psSilk_VAD.inv_NL[k] = Inlines.silk_SMLAWB(psSilk_VAD.inv_NL[k], inv_nrg - psSilk_VAD.inv_NL[k], coef); - Inlines.OpusAssert(psSilk_VAD.inv_NL[k] >= 0); - nl = Inlines.silk_DIV32(Integer.MAX_VALUE, psSilk_VAD.inv_NL[k]); - Inlines.OpusAssert(nl >= 0); - psSilk_VAD.NL[k] = nl = Inlines.silk_min(nl, 0xFFFFFF); - } - ++psSilk_VAD.counter; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/concentus/VorbisLayout.java b/source/decompiled/de/maxhenkel/voicechat/concentus/VorbisLayout.java deleted file mode 100644 index e0cb934..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/concentus/VorbisLayout.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.concentus; - -class VorbisLayout { - int nb_streams; - int nb_coupled_streams; - short[] mapping; - static final VorbisLayout[] vorbis_mappings = new VorbisLayout[]{new VorbisLayout(1, 0, new short[]{0}), new VorbisLayout(1, 1, new short[]{0, 1}), new VorbisLayout(2, 1, new short[]{0, 2, 1}), new VorbisLayout(2, 2, new short[]{0, 1, 2, 3}), new VorbisLayout(3, 2, new short[]{0, 4, 1, 2, 3}), new VorbisLayout(4, 2, new short[]{0, 4, 1, 2, 3, 5}), new VorbisLayout(4, 3, new short[]{0, 4, 1, 2, 3, 5, 6}), new VorbisLayout(5, 3, new short[]{0, 6, 1, 2, 3, 4, 5, 7})}; - - VorbisLayout(int streams, int coupled_streams, short[] map) { - this.nb_streams = streams; - this.nb_coupled_streams = coupled_streams; - this.mapping = map; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/config/ServerConfig.java b/source/decompiled/de/maxhenkel/voicechat/config/ServerConfig.java deleted file mode 100644 index d467657..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/config/ServerConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.config; - -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.configbuilder.ConfigBuilder; -import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry; - -public class ServerConfig { - public final ConfigEntry voiceChatPort; - public final ConfigEntry voiceChatBindAddress; - public final ConfigEntry voiceChatDistance; - public ConfigEntry whisperDistance; - public final ConfigEntry voiceChatCodec; - public final ConfigEntry voiceChatMtuSize; - public final ConfigEntry tcpRateLimit; - public final ConfigEntry keepAlive; - public final ConfigEntry groupsEnabled; - public final ConfigEntry voiceHost; - public final ConfigEntry allowRecording; - public final ConfigEntry spectatorInteraction; - public ConfigEntry spectatorPlayerPossession; - public ConfigEntry forceVoiceChat; - public ConfigEntry loginTimeout; - public ConfigEntry broadcastRange; - public ConfigEntry allowPings; - public ConfigEntry threadedServerSupport; - - public ServerConfig(ConfigBuilder builder) { - builder.header(String.format("%s server config v%s", "Simple Voice Chat", Voicechat.INSTANCE.getDescription().getVersion())); - this.voiceChatPort = builder.integerEntry("port", (Integer)24454, -1, 65535, "The port number to use for the voice chat communication.", "Audio packets are always transmitted via the UDP protocol on the port number", "specified here, independently of other networking used for the game server.", "Set this to '-1' to use the same port number that is used by the Minecraft server.", "However, it is strongly recommended NOT to use the same port number because UDP on", "it is also used by default for the server query. Doing so may crash the server!"); - this.voiceChatBindAddress = builder.stringEntry("bind_address", "", "The server IP address to bind the voice chat to", "Leave blank to use the 'server-ip' property from the 'server.properties' config file", "To bind to the wildcard IP address, use '*'"); - this.voiceChatDistance = builder.doubleEntry("max_voice_distance", (Double)48.0, 1.0, 1000000.0, "The distance to which the voice can be heard"); - this.whisperDistance = builder.doubleEntry("whisper_distance", (Double)24.0, 1.0, 1000000.0, "The distance to which the voice can be heard when whispering"); - this.voiceChatCodec = builder.enumEntry("codec", Codec.VOIP, "The Opus codec", "Valid values are 'VOIP', 'AUDIO', and 'RESTRICTED_LOWDELAY'"); - this.voiceChatMtuSize = builder.integerEntry("mtu_size", (Integer)1275, 512, 2048, "The maximum size that audio packets are allowed to have (in bytes)", "Setting this to lower values might cause issues"); - this.tcpRateLimit = builder.integerEntry("tcp_rate_limit", (Integer)16, -1, 1024, "The maximum number of packets a player can send per second", "Set this to -1 to disable the rate limit - This must be greater than 0 in all other cases", "This only applies to voice chat packets that are sent through Minecrafts networking", "This affects actions like opening/joining/leaving voice chat groups or general state changes like disabling/enabling the voice chat"); - this.keepAlive = builder.integerEntry("keep_alive", (Integer)1000, 1000, Integer.MAX_VALUE, "The frequency at which keep-alive packets are sent (in milliseconds)", "Setting this to a higher value may result in timeouts"); - this.groupsEnabled = builder.booleanEntry("enable_groups", true, "If group chats are allowed"); - this.voiceHost = builder.stringEntry("voice_host", "", "The hostname that clients should use to connect to the voice chat", "This may also include a port, e.g. 'example.com:24454'", "Do NOT change this value if you don't know what you're doing"); - this.allowRecording = builder.booleanEntry("allow_recording", true, "If players are allowed to record the voice chat audio"); - this.spectatorInteraction = builder.booleanEntry("spectator_interaction", false, "If spectators are allowed to talk to other players"); - this.spectatorPlayerPossession = builder.booleanEntry("spectator_player_possession", false, "If spectators can talk to players they are spectating"); - this.forceVoiceChat = builder.booleanEntry("force_voice_chat", false, "If players without the voice chat mod should be kicked from the server"); - this.loginTimeout = builder.integerEntry("login_timeout", (Integer)10000, 100, Integer.MAX_VALUE, "The amount of time the server should wait to check if a player has the mod installed (in milliseconds)", "Only relevant when 'force_voice_chat' is set to 'true'"); - this.broadcastRange = builder.doubleEntry("broadcast_range", (Double)-1.0, -1.0, (Double)Double.MAX_VALUE, "The range in which the voice chat should broadcast audio", "A value less than 0 means 'max_voice_distance'"); - this.allowPings = builder.booleanEntry("allow_pings", true, "If the voice chat server should reply to external pings"); - this.threadedServerSupport = builder.booleanEntry("threaded_server_support", true, "If the voice chat should support servers that run multiple threads, like Folia", "Disabling this may slightly improve performance, but can cause issues on servers that don't run everything on a single thread"); - } - - public static enum Codec { - VOIP, - AUDIO, - RESTRICTED_LOWDELAY; - - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/config/Translations.java b/source/decompiled/de/maxhenkel/voicechat/config/Translations.java deleted file mode 100644 index 27207ef..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/config/Translations.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.config; - -import de.maxhenkel.voicechat.configbuilder.ConfigBuilder; -import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry; - -public class Translations { - public final ConfigEntry forceVoicechatKickMessage; - public final ConfigEntry rateLimitKickMessage; - public final ConfigEntry voicechatNotCompatibleMessage; - public final ConfigEntry voicechatNeededForCommandMessage; - public final ConfigEntry playerCommandMessage; - public final ConfigEntry placeholderVoicechatInstalled; - public final ConfigEntry placeholderVoicechatNotInstalled; - public final ConfigEntry placeholderVoicechatDisabled; - - public Translations(ConfigBuilder builder) { - builder.header("Simple Voice Chat translations", "This file contains all server-side translations for the Simple Voice Chat plugin"); - this.forceVoicechatKickMessage = builder.stringEntry("force_voicechat_kick_message", "You need %s %s to play on this server", "The message a player gets when kicked for not having voice chat installed and the server has force_voicechat enabled", "The first parameter is the mod/plugin name and the second parameter is the mod/plugin version"); - this.rateLimitKickMessage = builder.stringEntry("rate_limit_kick_message", "Kicked for exceeding packet rate limit", "The message a player gets when kicked for sending too many voice chat packets"); - this.voicechatNotCompatibleMessage = builder.stringEntry("voicechat_not_compatible_message", "Your voice chat client version is not compatible with the server-side version.\\nPlease install version %s of %s.", "The message a player gets when joining a server with an incompatible voice chat version", "The first parameter is the mod/plugin version and the second parameter is the mod/plugin name"); - this.voicechatNeededForCommandMessage = builder.stringEntry("voicechat_needed_for_command_message", "You need to have %s installed on your client to use this command", "The message a player gets when trying to execute a command that requires the voice chat mod installed on the client side.", "The first parameter is the mod/plugin name"); - this.playerCommandMessage = builder.stringEntry("player_command_message", "This command can only be executed as a player", "The message a player gets when trying to execute a command that can only be executed as a player"); - this.placeholderVoicechatInstalled = builder.stringEntry("placeholder_api_voicechat_installed", "", "The Placeholder API string for '%voicechat_installed%'"); - this.placeholderVoicechatNotInstalled = builder.stringEntry("placeholder_api_voicechat_not_installed", "", "The Placeholder API string for '%voicechat_not_installed%'"); - this.placeholderVoicechatDisabled = builder.stringEntry("placeholder_api_voicechat_disabled", "", "The Placeholder API string for '%voicechat_disabled%'"); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/CommentedProperties.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/CommentedProperties.java deleted file mode 100644 index c118ff1..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/CommentedProperties.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder; - -import java.io.BufferedReader; -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.StringReader; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; -import javax.annotation.Nullable; - -public class CommentedProperties -implements Map { - private final boolean strict; - private final List headerComments; - private final Map properties; - - public CommentedProperties(boolean strict) { - this.strict = strict; - this.headerComments = new ArrayList(); - this.properties = new LinkedHashMap(); - } - - public CommentedProperties() { - this(true); - } - - public CommentedProperties addHeaderComment(String comment) { - this.headerComments.add(comment); - return this; - } - - public CommentedProperties setHeaderComments(List headerComments) { - this.headerComments.clear(); - this.headerComments.addAll(headerComments); - return this; - } - - void sort(Comparator comparator) { - ArrayList> list = new ArrayList>(this.properties.entrySet()); - list.sort((o1, o2) -> comparator.compare((String)o1.getKey(), (String)o2.getKey())); - this.properties.clear(); - for (Map.Entry entry : list) { - this.properties.put((String)entry.getKey(), (Property)entry.getValue()); - } - } - - @Nullable - public String get(String key) { - Objects.requireNonNull(key); - Property property = this.properties.get(key); - if (property == null) { - return null; - } - return property.value; - } - - @Nullable - public List getComments(String key) { - Objects.requireNonNull(key); - Property property = this.properties.get(key); - if (property == null) { - return null; - } - return property.comments; - } - - public CommentedProperties setComments(String key, List comments) { - Objects.requireNonNull(key); - Property property = this.properties.get(key); - if (property == null) { - this.properties.put(key, new Property(comments, "")); - return this; - } - property.comments = comments; - return this; - } - - public CommentedProperties set(String key, String value, String ... comments) { - Objects.requireNonNull(key); - Objects.requireNonNull(value); - this.properties.put(key, new Property(Arrays.asList(comments), value)); - return this; - } - - public CommentedProperties load(InputStream inputStream) throws IOException { - ArrayList headerComments = new ArrayList(); - LinkedHashMap properties = new LinkedHashMap(); - try (LineReader reader = LineReader.fromInputStream(inputStream);){ - String line; - boolean header = true; - ArrayList previousComments = new ArrayList(); - while ((line = reader.nextLine()) != null) { - if (line.trim().isEmpty()) { - if (!header) continue; - headerComments.addAll(previousComments); - previousComments.clear(); - header = false; - continue; - } - Pair pair = CommentedProperties.readLine(line); - if (pair.key == null) { - previousComments.add(pair.value); - continue; - } - Property property = new Property(pair.value); - property.comments.addAll(previousComments); - previousComments.clear(); - properties.put(pair.key, property); - header = false; - } - } - this.setHeaderComments(headerComments); - this.properties.clear(); - this.properties.putAll(properties); - return this; - } - - protected static Pair readLine(String line) throws IOException { - int c; - StringBuilder key = new StringBuilder(); - StringBuilder value = new StringBuilder(); - StringReader reader = new StringReader(line); - boolean isKey = true; - boolean isComment = false; - boolean isPrecedingBackslash = false; - boolean onlyHadWhitespace = true; - boolean isStartOfValue = false; - while ((c = reader.read()) != -1) { - boolean isWhitespace = CommentedProperties.isWhitespace(c); - if (isComment) { - if (onlyHadWhitespace && isWhitespace) continue; - onlyHadWhitespace = false; - value.append((char)c); - continue; - } - if (isPrecedingBackslash) { - if (isKey) { - key.append((char)CommentedProperties.readEscapedCharacter(c, reader)); - } else { - value.append((char)CommentedProperties.readEscapedCharacter(c, reader)); - } - isPrecedingBackslash = false; - isStartOfValue = false; - continue; - } - if (c == 92) { - isPrecedingBackslash = true; - continue; - } - if ((c == 35 || c == 33) && onlyHadWhitespace) { - isComment = true; - continue; - } - if (isKey) { - if (key.length() <= 0 && CommentedProperties.isWhitespace(c)) continue; - if (CommentedProperties.isSeparator(c)) { - isKey = false; - isStartOfValue = true; - onlyHadWhitespace = false; - continue; - } - if (CommentedProperties.isWhitespace(c)) continue; - key.append((char)c); - } else { - if (isStartOfValue && (CommentedProperties.isWhitespace(c) || CommentedProperties.isSeparator(c))) continue; - value.append((char)c); - isStartOfValue = false; - } - if (!onlyHadWhitespace || isWhitespace) continue; - onlyHadWhitespace = false; - } - return new Pair(isComment ? null : key.toString(), value.toString()); - } - - private static int readEscapedCharacter(int c, StringReader reader) throws IOException { - if (c == 117) { - int u = 0; - for (int i = 0; i < 4; ++i) { - int uc = reader.read(); - if (uc == -1) { - throw new IOException("Invalid unicode escape sequence"); - } - u <<= 4; - if (uc >= 48 && uc <= 57) { - u += uc - 48; - continue; - } - if (uc >= 97 && uc <= 102) { - u += uc - 97 + 10; - continue; - } - if (uc >= 65 && uc <= 70) { - u += uc - 65 + 10; - continue; - } - throw new IOException("Invalid unicode escape sequence"); - } - return u; - } - if (c == 116) { - return 9; - } - if (c == 114) { - return 13; - } - if (c == 110) { - return 10; - } - if (c == 102) { - return 12; - } - return c; - } - - private static boolean isWhitespace(int c) { - return c == 32 || c == 9 || c == 13 || c == 12 || Character.isWhitespace(c); - } - - private static boolean isSeparator(int c) { - return c == 61 || c == 58 || c == 32 || c == 9 || c == 12; - } - - public CommentedProperties save(OutputStream outputStream) { - try (PrintWriter writer = new PrintWriter(outputStream);){ - for (String string : CommentedProperties.removeNewLines(this.headerComments)) { - writer.print("# "); - writer.println(string); - } - if (this.headerComments.size() > 0) { - writer.println(); - } - for (Map.Entry entry : this.properties.entrySet()) { - for (String comment : CommentedProperties.removeNewLines(((Property)entry.getValue()).comments)) { - writer.print("# "); - writer.println(comment); - } - writer.print(this.escapeKey((String)entry.getKey())); - writer.print("="); - writer.println(this.escapeValue(((Property)entry.getValue()).value)); - } - writer.flush(); - } - return this; - } - - private static List removeNewLines(List comments) { - ArrayList newComments = new ArrayList(); - for (String comment : comments) { - newComments.addAll(Arrays.asList(comment.split("\\r?\\n"))); - } - return newComments; - } - - private String escapeKey(String str) { - str = this.escape(str); - str = str.replace(" ", "\\ "); - str = str.replace("=", "\\="); - str = str.replace(":", "\\:"); - return str; - } - - private String escapeValue(String str) { - str = this.escape(str); - if (this.strict) { - str = str.replace("=", "\\="); - str = str.replace(":", "\\:"); - } - if (str.startsWith(" ")) { - str = String.format("\\%s", str); - } - return str; - } - - private String escape(String str) { - str = str.replace("\\", "\\\\"); - str = str.replace("\n", "\\n"); - str = str.replace("\r", "\\n"); - str = str.replace("\t", "\\t"); - str = str.replace("#", "\\#"); - str = str.replace("!", "\\!"); - for (int i = 0; i < str.length(); ++i) { - char c = str.charAt(i); - if (Character.UnicodeBlock.of(c) == Character.UnicodeBlock.BASIC_LATIN) continue; - str = String.format("%s\\u%04X%s", str.substring(0, i), (int)c, str.substring(i + 1)); - } - return str; - } - - @Override - public int size() { - return this.properties.size(); - } - - @Override - public boolean isEmpty() { - return this.properties.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return this.properties.containsKey(key); - } - - @Override - @Deprecated - public boolean containsValue(Object value) { - for (Property property : this.properties.values()) { - if (!property.value.equals(value)) continue; - return true; - } - return false; - } - - @Override - @Nullable - @Deprecated - public String get(Object key) { - if (!(key instanceof String)) { - return null; - } - return this.get((String)key); - } - - @Override - @Deprecated - public String put(String key, String value) { - Objects.requireNonNull(key); - Objects.requireNonNull(value); - Property put = this.properties.put(key, new Property(value)); - if (put == null) { - return null; - } - return put.value; - } - - @Override - public String remove(Object key) { - Property removed = this.properties.remove(key); - if (removed == null) { - return null; - } - return removed.value; - } - - @Override - @Deprecated - public void putAll(Map map) { - for (Map.Entry entry : map.entrySet()) { - this.put(entry.getKey(), entry.getValue()); - } - } - - @Override - public void clear() { - this.headerComments.clear(); - this.properties.clear(); - } - - @Override - public Set keySet() { - return this.properties.keySet(); - } - - @Override - @Deprecated - public Collection values() { - return this.properties.values().stream().map(property -> ((Property)property).value).collect(Collectors.toList()); - } - - @Override - @Deprecated - public Set> entrySet() { - return this.properties.entrySet().stream().map(entry -> new AbstractMap.SimpleEntry((String)entry.getKey(), ((Property)entry.getValue()).value)).collect(Collectors.toSet()); - } - - protected static class Property { - private List comments; - private String value; - - public Property(List comments, String value) { - this.comments = comments; - this.value = value; - } - - public Property(String value) { - this(new ArrayList(), value); - } - } - - protected static class LineReader - implements Closeable { - private final BufferedReader reader; - - public LineReader(BufferedReader reader) { - this.reader = reader; - } - - public static LineReader fromInputStream(InputStream inputStream) { - return new LineReader(new BufferedReader(new InputStreamReader(inputStream))); - } - - @Nullable - public String nextLine() throws IOException { - String line = this.reader.readLine(); - if (line == null) { - return null; - } - if (line.endsWith("\\")) { - line = line.substring(0, line.length() - 1); - String nextLine = this.nextLine(); - if (nextLine == null) { - return line; - } - return line + nextLine; - } - return line; - } - - @Override - public void close() throws IOException { - this.reader.close(); - } - } - - protected static class Pair { - private String key; - private String value; - - public Pair(String key, String value) { - this.key = key; - this.value = value; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/CommentedPropertyConfig.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/CommentedPropertyConfig.java deleted file mode 100644 index b26328c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/CommentedPropertyConfig.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder; - -import de.maxhenkel.voicechat.configbuilder.CommentedProperties; -import de.maxhenkel.voicechat.configbuilder.Config; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.OpenOption; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.nio.file.attribute.FileAttribute; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.annotation.Nullable; - -public class CommentedPropertyConfig -implements Config { - private static final Logger LOGGER = Logger.getLogger(CommentedPropertyConfig.class.getName()); - private static final ExecutorService SAVE_EXECUTOR_SERVICE = Executors.newSingleThreadExecutor(runnable -> { - Thread thread = new Thread(runnable); - thread.setName("ConfigSaver"); - thread.setDaemon(true); - return thread; - }); - protected CommentedProperties properties; - @Nullable - protected Path path; - - protected CommentedPropertyConfig(CommentedProperties properties) { - this.properties = properties; - } - - public static Builder builder() { - return new Builder(); - } - - public String get(String key) { - return this.properties.get(key); - } - - public boolean has(String key) { - return this.properties.containsKey(key); - } - - public void set(String key, String value, String ... comments) { - this.properties.set(key, value, comments); - } - - public CommentedProperties getProperties() { - return this.properties; - } - - public void load() throws IOException { - if (this.path == null) { - return; - } - if (Files.exists(this.path, new LinkOption[0])) { - try (InputStream inputStream = Files.newInputStream(this.path, new OpenOption[0]);){ - this.properties.load(inputStream); - } - } - } - - public void reload() { - this.properties.clear(); - try { - this.load(); - } - catch (IOException e) { - LOGGER.log(Level.SEVERE, "Failed to reload config", e); - } - } - - public synchronized void saveSync() { - if (this.path == null) { - return; - } - try { - Files.createDirectories(this.path.getParent(), new FileAttribute[0]); - } - catch (Exception e) { - LOGGER.log(Level.SEVERE, "Failed to create parent directories of config", e); - } - try (OutputStream stream = Files.newOutputStream(this.path, StandardOpenOption.CREATE, StandardOpenOption.SYNC, StandardOpenOption.TRUNCATE_EXISTING);){ - this.properties.save(stream); - } - catch (Exception e) { - LOGGER.log(Level.SEVERE, "Failed to save config", e); - } - } - - public void save() { - if (this.path == null) { - return; - } - SAVE_EXECUTOR_SERVICE.execute(this::saveSync); - } - - @Override - public Map getEntries() { - return Collections.unmodifiableMap(this.properties); - } - - public static class Builder { - @Nullable - private Path path; - private boolean strict = true; - - private Builder() { - } - - public Builder path(Path path) { - this.path = path; - return this; - } - - public Builder strict(boolean strict) { - this.strict = strict; - return this; - } - - public CommentedPropertyConfig build() { - CommentedPropertyConfig config = new CommentedPropertyConfig(new CommentedProperties(this.strict)); - if (this.path != null) { - config.path = this.path.toAbsolutePath(); - } - config.reload(); - return config; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/Config.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/Config.java deleted file mode 100644 index 22e9990..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/Config.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder; - -import java.util.Map; - -public interface Config { - public Map getEntries(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/ConfigBuilder.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/ConfigBuilder.java deleted file mode 100644 index 1d6329f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/ConfigBuilder.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.ConfigBuilderImpl; -import de.maxhenkel.voicechat.configbuilder.MigratableConfig; -import de.maxhenkel.voicechat.configbuilder.MigratableConfigImpl; -import de.maxhenkel.voicechat.configbuilder.entry.BooleanConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.DoubleConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.EnumConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.FloatConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.IntegerConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.LongConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.StringConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.nio.file.Files; -import java.nio.file.LinkOption; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public interface ConfigBuilder { - public ConfigBuilder header(String ... var1); - - public BooleanConfigEntry booleanEntry(String var1, Boolean var2, String ... var3); - - public IntegerConfigEntry integerEntry(String var1, Integer var2, Integer var3, Integer var4, String ... var5); - - default public IntegerConfigEntry integerEntry(String key, Integer def, String ... comments) { - return this.integerEntry(key, def, (Integer)null, (Integer)null, comments); - } - - public LongConfigEntry longEntry(String var1, Long var2, Long var3, Long var4, String ... var5); - - default public LongConfigEntry longEntry(String key, Long def, String ... comments) { - return this.longEntry(key, def, (Long)null, (Long)null, comments); - } - - public DoubleConfigEntry doubleEntry(String var1, Double var2, Double var3, Double var4, String ... var5); - - default public DoubleConfigEntry doubleEntry(String key, Double def, String ... comments) { - return this.doubleEntry(key, def, (Double)null, (Double)null, comments); - } - - public FloatConfigEntry floatEntry(String var1, Float var2, Float var3, Float var4, String ... var5); - - default public FloatConfigEntry floatEntry(String key, Float def, String ... comments) { - return this.floatEntry(key, def, (Float)null, (Float)null, comments); - } - - public StringConfigEntry stringEntry(String var1, String var2, String ... var3); - - public > EnumConfigEntry enumEntry(String var1, E var2, String ... var3); - - public ConfigEntry entry(String var1, T var2, String ... var3); - - public static Builder builder(@Nonnull Function builderConsumer) { - return new Builder(builderConsumer); - } - - public static class Builder { - @Nonnull - private final Function builderConsumer; - @Nullable - private Path path; - private final Map, ValueSerializer> valueSerializers; - private boolean removeUnused; - private boolean strict; - private boolean keepOrder; - private boolean saveAfterBuild; - private boolean saveSyncAfterBuild; - @Nullable - private Consumer migration; - - private Builder(@Nonnull Function builderConsumer) { - this.builderConsumer = builderConsumer; - this.valueSerializers = new HashMap(); - this.removeUnused = true; - this.strict = false; - this.keepOrder = true; - this.saveAfterBuild = true; - this.saveSyncAfterBuild = false; - } - - public Builder path(Path path) { - this.path = path; - return this; - } - - public Builder addValueSerializer(Class type, ValueSerializer serializer) { - this.valueSerializers.put(type, serializer); - return this; - } - - public Builder removeUnused(boolean removeUnused) { - this.removeUnused = removeUnused; - return this; - } - - public Builder strict(boolean strict) { - this.strict = strict; - return this; - } - - public Builder keepOrder(boolean keepOrder) { - this.keepOrder = keepOrder; - return this; - } - - public Builder saveAfterBuild(boolean saveAfterBuild) { - this.saveAfterBuild = saveAfterBuild; - if (saveAfterBuild) { - this.saveSyncAfterBuild = false; - } - return this; - } - - public Builder saveSyncAfterBuild(boolean saveSyncAfterBuild) { - this.saveSyncAfterBuild = saveSyncAfterBuild; - if (saveSyncAfterBuild) { - this.saveAfterBuild = false; - } - return this; - } - - public Builder migration(Consumer migration) { - this.migration = migration; - return this; - } - - public C build() { - CommentedPropertyConfig cpc = CommentedPropertyConfig.builder().path(this.path).strict(this.strict).build(); - if (this.migration != null && this.path != null && Files.exists(this.path, new LinkOption[0])) { - MigratableConfigImpl migratableConfig = new MigratableConfigImpl(cpc); - this.migration.accept(migratableConfig); - migratableConfig.freeze(); - } - ConfigBuilderImpl builder = new ConfigBuilderImpl(cpc, this.valueSerializers); - C config = this.builderConsumer.apply(builder); - builder.freeze(); - if (this.removeUnused) { - builder.removeUnused(); - } - if (this.keepOrder) { - builder.sortEntries(); - } - if (this.saveAfterBuild) { - builder.config.save(); - } else if (this.saveSyncAfterBuild) { - builder.config.saveSync(); - } - return config; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/ConfigBuilderImpl.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/ConfigBuilderImpl.java deleted file mode 100644 index f9c7158..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/ConfigBuilderImpl.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.ConfigBuilder; -import de.maxhenkel.voicechat.configbuilder.custom.IntegerList; -import de.maxhenkel.voicechat.configbuilder.custom.StringList; -import de.maxhenkel.voicechat.configbuilder.custom.StringMap; -import de.maxhenkel.voicechat.configbuilder.custom.serializer.IntegerListValueSerializer; -import de.maxhenkel.voicechat.configbuilder.custom.serializer.StringListValueSerializer; -import de.maxhenkel.voicechat.configbuilder.custom.serializer.StringMapValueSerializer; -import de.maxhenkel.voicechat.configbuilder.custom.serializer.UUIDSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.BooleanConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.DoubleConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.EnumConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.FloatConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.GenericConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.IntegerConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.LongConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.StringConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.BooleanSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.DoubleSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.EnumSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.FloatSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.IntegerSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.LongSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.StringSerializer; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializable; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; -import javax.annotation.Nullable; - -public class ConfigBuilderImpl -implements ConfigBuilder { - protected final CommentedPropertyConfig config; - protected final Map, ValueSerializer> valueSerializers; - protected List> entries; - protected boolean frozen; - - public ConfigBuilderImpl(CommentedPropertyConfig config) { - this(config, null); - } - - public ConfigBuilderImpl(CommentedPropertyConfig config, @Nullable Map, ValueSerializer> customValueSerializers) { - this.config = config; - this.valueSerializers = ConfigBuilderImpl.getDefaultValueSerializers(); - if (customValueSerializers != null) { - this.valueSerializers.putAll(customValueSerializers); - } - this.entries = new ArrayList(); - } - - void removeUnused() { - List existingKeys = this.entries.stream().map(AbstractConfigEntry::getKey).collect(Collectors.toList()); - List toRemove = this.config.getProperties().keySet().stream().filter(s -> !existingKeys.contains(s)).collect(Collectors.toList()); - for (String key : toRemove) { - this.config.getProperties().remove(key); - } - } - - void sortEntries() { - HashMap map = new HashMap(); - for (int i = 0; i < this.entries.size(); ++i) { - map.put(this.entries.get(i).getKey(), i); - } - this.config.getProperties().sort(Comparator.comparingInt(o -> map.getOrDefault(o, Integer.MAX_VALUE))); - } - - void reloadFromDisk() { - this.config.reload(); - this.entries.forEach(AbstractConfigEntry::reload); - } - - void freeze() { - this.frozen = true; - } - - void checkFrozen() { - if (this.frozen) { - throw new IllegalStateException("ConfigBuilder is frozen"); - } - } - - @Override - public ConfigBuilderImpl header(String ... header) { - this.checkFrozen(); - this.config.getProperties().setHeaderComments(Arrays.asList(header)); - return this; - } - - @Override - public BooleanConfigEntry booleanEntry(String key, Boolean def, String ... comments) { - this.checkFrozen(); - BooleanConfigEntry entry = new BooleanConfigEntry(this.config, BooleanSerializer.INSTANCE, comments, key, def); - this.entries.add(entry); - return entry; - } - - @Override - public IntegerConfigEntry integerEntry(String key, Integer def, Integer min, Integer max, String ... comments) { - this.checkFrozen(); - IntegerConfigEntry entry = new IntegerConfigEntry(this.config, IntegerSerializer.INSTANCE, comments, key, def, min, max); - this.entries.add(entry); - return entry; - } - - @Override - public LongConfigEntry longEntry(String key, Long def, Long min, Long max, String ... comments) { - this.checkFrozen(); - LongConfigEntry entry = new LongConfigEntry(this.config, LongSerializer.INSTANCE, comments, key, def, min, max); - this.entries.add(entry); - return entry; - } - - @Override - public DoubleConfigEntry doubleEntry(String key, Double def, Double min, Double max, String ... comments) { - this.checkFrozen(); - DoubleConfigEntry entry = new DoubleConfigEntry(this.config, DoubleSerializer.INSTANCE, comments, key, def, min, max); - this.entries.add(entry); - return entry; - } - - @Override - public FloatConfigEntry floatEntry(String key, Float def, Float min, Float max, String ... comments) { - this.checkFrozen(); - FloatConfigEntry entry = new FloatConfigEntry(this.config, FloatSerializer.INSTANCE, comments, key, def, min, max); - this.entries.add(entry); - return entry; - } - - @Override - public StringConfigEntry stringEntry(String key, String def, String ... comments) { - this.checkFrozen(); - StringConfigEntry entry = new StringConfigEntry(this.config, StringSerializer.INSTANCE, comments, key, def); - this.entries.add(entry); - return entry; - } - - @Override - public > EnumConfigEntry enumEntry(String key, E def, String ... comments) { - this.checkFrozen(); - EnumConfigEntry entry = new EnumConfigEntry(this.config, new EnumSerializer(def.getClass()), comments, key, def); - this.entries.add(entry); - return entry; - } - - @Override - public ConfigEntry entry(String key, T def, String ... comments) { - this.checkFrozen(); - AbstractConfigEntry entry = this.entryInternal(key, def, comments); - this.entries.add(entry); - return entry; - } - - private AbstractConfigEntry entryInternal(String key, T def, String ... comments) { - ValueSerializer valueSerializer = this.valueSerializers.get(def.getClass()); - if (valueSerializer != null) { - return new GenericConfigEntry(this.config, valueSerializer, comments, key, def); - } - if (def instanceof Enum) { - return this.enumEntry(key, (Enum)def, comments); - } - try { - ValueSerializable annotation = def.getClass().getDeclaredAnnotation(ValueSerializable.class); - if (annotation == null) { - throw new IllegalArgumentException(String.format("Unsupported data type: %s", def.getClass().getName())); - } - Class> entryConverterClass = annotation.value(); - Constructor> constructor = entryConverterClass.getDeclaredConstructor(new Class[0]); - constructor.setAccessible(true); - constructor.newInstance(new Object[0]); - ValueSerializer converter = constructor.newInstance(new Object[0]); - return new GenericConfigEntry(this.config, converter, comments, key, def); - } - catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { - throw new IllegalArgumentException("Could not instantiate value serializer", e); - } - } - - protected static Map, ValueSerializer> getDefaultValueSerializers() { - HashMap valueSerializers = new HashMap(); - valueSerializers.put(Boolean.class, new BooleanSerializer()); - valueSerializers.put(Integer.class, new IntegerSerializer()); - valueSerializers.put(Long.class, new LongSerializer()); - valueSerializers.put(Float.class, new FloatSerializer()); - valueSerializers.put(Double.class, new DoubleSerializer()); - valueSerializers.put(String.class, new StringSerializer()); - valueSerializers.put(UUID.class, UUIDSerializer.INSTANCE); - valueSerializers.put(StringList.class, StringListValueSerializer.INSTANCE); - valueSerializers.put(IntegerList.class, IntegerListValueSerializer.INSTANCE); - valueSerializers.put(StringMap.class, StringMapValueSerializer.INSTANCE); - return valueSerializers; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/MigratableConfig.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/MigratableConfig.java deleted file mode 100644 index ecaf694..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/MigratableConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder; - -import de.maxhenkel.voicechat.configbuilder.Config; -import javax.annotation.Nullable; - -public interface MigratableConfig -extends Config { - @Nullable - public String get(String var1); - - public boolean has(String var1); - - public void set(String var1, String var2); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/MigratableConfigImpl.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/MigratableConfigImpl.java deleted file mode 100644 index d5a8f4f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/MigratableConfigImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.MigratableConfig; -import java.util.Map; -import javax.annotation.Nullable; - -class MigratableConfigImpl -implements MigratableConfig { - private final CommentedPropertyConfig config; - private boolean frozen; - - public MigratableConfigImpl(CommentedPropertyConfig config) { - this.config = config; - } - - @Override - @Nullable - public String get(String key) { - this.checkFrozen(); - return this.config.get(key); - } - - @Override - public boolean has(String key) { - this.checkFrozen(); - return this.config.has(key); - } - - @Override - public void set(String key, String value) { - this.checkFrozen(); - this.config.set(key, value, new String[0]); - } - - @Override - public Map getEntries() { - this.checkFrozen(); - return this.config.getEntries(); - } - - public void freeze() { - this.frozen = true; - } - - private void checkFrozen() { - if (this.frozen) { - throw new IllegalStateException("ConfigBuilder is frozen"); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/AbstractValueList.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/AbstractValueList.java deleted file mode 100644 index 97f8bc3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/AbstractValueList.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Objects; - -public abstract class AbstractValueList -implements List { - protected final List list; - - protected AbstractValueList(T ... values) { - this(Arrays.asList(values)); - } - - protected AbstractValueList(List values) { - this.list = Collections.unmodifiableList(values); - } - - @Override - public int size() { - return this.list.size(); - } - - @Override - public boolean isEmpty() { - return this.list.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return this.list.contains(o); - } - - @Override - public Iterator iterator() { - return this.list.iterator(); - } - - @Override - public Object[] toArray() { - return this.list.toArray(); - } - - @Override - public T[] toArray(T[] a) { - return this.list.toArray(a); - } - - @Override - public boolean add(T s) { - return (Boolean)AbstractValueList.throwException(); - } - - @Override - public boolean remove(Object o) { - return (Boolean)AbstractValueList.throwException(); - } - - @Override - public boolean containsAll(Collection c) { - return this.list.containsAll(c); - } - - @Override - public boolean addAll(Collection c) { - return (Boolean)AbstractValueList.throwException(); - } - - @Override - public boolean addAll(int index, Collection c) { - return (Boolean)AbstractValueList.throwException(); - } - - @Override - public boolean removeAll(Collection c) { - return (Boolean)AbstractValueList.throwException(); - } - - @Override - public boolean retainAll(Collection c) { - return (Boolean)AbstractValueList.throwException(); - } - - @Override - public void clear() { - AbstractValueList.throwException(); - } - - @Override - public T get(int index) { - return this.list.get(index); - } - - @Override - public T set(int index, T element) { - return AbstractValueList.throwException(); - } - - @Override - public void add(int index, T element) { - AbstractValueList.throwException(); - } - - @Override - public T remove(int index) { - return AbstractValueList.throwException(); - } - - @Override - public int indexOf(Object o) { - return this.list.indexOf(o); - } - - @Override - public int lastIndexOf(Object o) { - return this.list.lastIndexOf(o); - } - - @Override - public ListIterator listIterator() { - return this.list.listIterator(); - } - - @Override - public ListIterator listIterator(int index) { - return this.list.listIterator(index); - } - - @Override - public List subList(int fromIndex, int toIndex) { - return this.list.subList(fromIndex, toIndex); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || this.getClass() != o.getClass()) { - return false; - } - AbstractValueList that = (AbstractValueList)o; - return Objects.equals(this.list, that.list); - } - - @Override - public int hashCode() { - return this.list.hashCode(); - } - - private static T throwException() { - throw new UnsupportedOperationException("Can't modify config entries"); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/AbstractValueMap.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/AbstractValueMap.java deleted file mode 100644 index df4022c..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/AbstractValueMap.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -public class AbstractValueMap -implements Map { - protected final Map map; - - protected AbstractValueMap(Map map) { - this.map = Collections.unmodifiableMap(new LinkedHashMap(map)); - } - - @Override - public int size() { - return this.map.size(); - } - - @Override - public boolean isEmpty() { - return this.map.isEmpty(); - } - - @Override - public boolean containsKey(Object key) { - return this.map.containsKey(key); - } - - @Override - public boolean containsValue(Object value) { - return this.map.containsValue(value); - } - - @Override - public V get(Object key) { - return this.map.get(key); - } - - @Override - public V put(K key, V value) { - return (V)AbstractValueMap.throwException(); - } - - @Override - public V remove(Object key) { - return (V)AbstractValueMap.throwException(); - } - - @Override - public void putAll(Map m) { - AbstractValueMap.throwException(); - } - - @Override - public void clear() { - AbstractValueMap.throwException(); - } - - @Override - public Set keySet() { - return this.map.keySet(); - } - - @Override - public Collection values() { - return this.map.values(); - } - - @Override - public Set> entrySet() { - return this.map.entrySet(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || this.getClass() != o.getClass()) { - return false; - } - AbstractValueMap that = (AbstractValueMap)o; - return this.map.equals(that.map); - } - - @Override - public int hashCode() { - return this.map.hashCode(); - } - - private static T throwException() { - throw new UnsupportedOperationException("Can't modify config entries"); - } - - public static abstract class Builder> { - protected final Map map = new LinkedHashMap(); - - protected Builder() { - } - - public Builder put(K key, V value) { - this.map.put(key, value); - return this; - } - - public Builder putAll(Map map) { - this.map.putAll(map); - return this; - } - - public abstract M build(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/IntegerList.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/IntegerList.java deleted file mode 100644 index 3421cab..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/IntegerList.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom; - -import de.maxhenkel.voicechat.configbuilder.custom.AbstractValueList; -import java.util.List; - -public class IntegerList -extends AbstractValueList { - protected IntegerList(Integer ... values) { - super(values); - } - - protected IntegerList(List values) { - super(values); - } - - public static IntegerList of(Integer ... values) { - return new IntegerList(values); - } - - public static IntegerList of(List values) { - return new IntegerList(values); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/StringList.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/StringList.java deleted file mode 100644 index f279aab..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/StringList.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom; - -import de.maxhenkel.voicechat.configbuilder.custom.AbstractValueList; -import java.util.List; - -public class StringList -extends AbstractValueList { - protected StringList(String ... values) { - super(values); - } - - protected StringList(List values) { - super(values); - } - - public static StringList of(String ... values) { - return new StringList(values); - } - - public static StringList of(List values) { - return new StringList(values); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/StringMap.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/StringMap.java deleted file mode 100644 index de730d0..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/StringMap.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom; - -import de.maxhenkel.voicechat.configbuilder.custom.AbstractValueMap; -import java.util.Collections; -import java.util.Map; - -public class StringMap -extends AbstractValueMap { - protected StringMap(Map map) { - super(map); - } - - public static StringMap of(Map map) { - return new StringMap(map); - } - - public static StringMap of() { - return new StringMap(Collections.emptyMap()); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder - extends AbstractValueMap.Builder { - @Override - public StringMap build() { - return new StringMap(this.map); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/IntegerListValueSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/IntegerListValueSerializer.java deleted file mode 100644 index e132604..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/IntegerListValueSerializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.custom.serializer; - -import de.maxhenkel.voicechat.configbuilder.custom.IntegerList; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.util.ArrayList; -import javax.annotation.Nullable; - -public class IntegerListValueSerializer -implements ValueSerializer { - public static final IntegerListValueSerializer INSTANCE = new IntegerListValueSerializer(); - - @Override - @Nullable - public IntegerList deserialize(String str) { - ArrayList resultList = new ArrayList(); - for (String s : str.split(",")) { - try { - resultList.add(Integer.valueOf(s)); - } - catch (NumberFormatException e) { - return null; - } - } - return IntegerList.of(resultList); - } - - @Override - public String serialize(IntegerList val) { - ArrayList resultList = new ArrayList(val.size()); - for (Integer i : val) { - resultList.add(String.valueOf(i)); - } - return String.join((CharSequence)",", resultList); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/StringListValueSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/StringListValueSerializer.java deleted file mode 100644 index 793b41a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/StringListValueSerializer.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom.serializer; - -import de.maxhenkel.voicechat.configbuilder.custom.StringList; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.util.ArrayList; - -public class StringListValueSerializer -implements ValueSerializer { - public static final StringListValueSerializer INSTANCE = new StringListValueSerializer(); - - @Override - public StringList deserialize(String str) { - ArrayList resultList = new ArrayList(); - for (String s : str.split("(? resultList = new ArrayList(val.size()); - for (String str : val) { - resultList.add(str.replace(",", "\\,")); - } - return String.join((CharSequence)",", resultList); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/StringMapValueSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/StringMapValueSerializer.java deleted file mode 100644 index e3822a0..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/StringMapValueSerializer.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.custom.serializer; - -import de.maxhenkel.voicechat.configbuilder.custom.StringMap; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.annotation.Nullable; - -public class StringMapValueSerializer -implements ValueSerializer { - public static final StringMapValueSerializer INSTANCE = new StringMapValueSerializer(); - public static final Pattern QUOTE_ESCAPE_PATTERN = Pattern.compile("\"((?:(?![\"\\\\]).|\\\\.)*)\"\\s*=\\s*\"((?:(?![\"\\\\]).|\\\\.)*)\""); - - @Override - @Nullable - public StringMap deserialize(String str) { - boolean matches = QUOTE_ESCAPE_PATTERN.splitAsStream(str).allMatch(s -> s.trim().isEmpty() || s.trim().equals(",")); - if (!matches) { - return null; - } - LinkedHashMap map = new LinkedHashMap(); - Matcher matcher = QUOTE_ESCAPE_PATTERN.matcher(str); - while (matcher.find()) { - map.put(StringMapValueSerializer.unescape(matcher.group(1)), StringMapValueSerializer.unescape(matcher.group(2))); - } - return StringMap.of(map); - } - - @Override - public String serialize(StringMap val) { - ArrayList resultList = new ArrayList(val.size()); - for (Map.Entry entry : val.entrySet()) { - resultList.add("\"" + StringMapValueSerializer.escape((String)entry.getKey()) + "\"=\"" + StringMapValueSerializer.escape((String)entry.getValue()) + "\""); - } - return String.join((CharSequence)",", resultList); - } - - private static String escape(String input) { - return input.replace("\\", "\\\\").replace("\"", "\\\""); - } - - private static String unescape(String input) { - return input.replace("\\\"", "\"").replace("\\\\", "\\"); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/UUIDSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/UUIDSerializer.java deleted file mode 100644 index a0d4593..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/custom/serializer/UUIDSerializer.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.custom.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.util.UUID; - -public class UUIDSerializer -implements ValueSerializer { - public static final UUIDSerializer INSTANCE = new UUIDSerializer(); - - @Override - public UUID deserialize(String str) { - return UUID.fromString(str); - } - - @Override - public String serialize(UUID val) { - return val.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/AbstractConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/AbstractConfigEntry.java deleted file mode 100644 index 8ed87e8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/AbstractConfigEntry.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.Config; -import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.util.Objects; -import javax.annotation.Nullable; - -public abstract class AbstractConfigEntry -implements ConfigEntry { - protected final CommentedPropertyConfig config; - protected final ValueSerializer serializer; - protected String[] comments; - protected String key; - protected T def; - @Nullable - protected T value; - - public AbstractConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, T def) { - Objects.requireNonNull(config); - Objects.requireNonNull(serializer); - Objects.requireNonNull(comments); - Objects.requireNonNull(key); - Objects.requireNonNull(def); - this.config = config; - this.serializer = serializer; - this.comments = comments; - this.key = key; - this.def = def; - } - - public void reload() { - if (this.config.getProperties().containsKey(this.key)) { - T val = this.serializer.deserialize(this.config.getProperties().get(this.key)); - if (val == null) { - this.reset(); - } else { - this.value = this.fixValue(val); - this.syncEntryToProperties(); - } - } else { - this.reset(); - } - } - - @Override - public T get() { - return this.value; - } - - @Override - public AbstractConfigEntry set(T value) { - if (this.value != null && this.value.equals(value)) { - return this; - } - this.value = this.fixValue(value); - this.syncEntryToProperties(); - return this; - } - - @Override - public String getKey() { - return this.key; - } - - @Override - public AbstractConfigEntry comment(String ... comments) { - this.comments = comments; - this.syncEntryToProperties(); - return this; - } - - @Override - public String[] getComments() { - return this.comments; - } - - @Override - public ConfigEntry reset() { - this.value = this.def; - this.syncEntryToProperties(); - return this; - } - - private void syncEntryToProperties() { - String serialized = this.serializer.serialize(this.value); - if (serialized == null) { - if (this.value == this.def) { - throw new IllegalStateException("Failed to serialize default value"); - } - this.reset(); - return; - } - this.config.getProperties().set(this.key, serialized, this.comments); - } - - @Override - public ConfigEntry save() { - this.config.save(); - return this; - } - - @Override - public ConfigEntry saveSync() { - this.config.saveSync(); - return this; - } - - T fixValue(T value) { - return value; - } - - @Override - public T getDefault() { - return this.def; - } - - @Override - public Config getConfig() { - return this.config; - } - - public ValueSerializer getSerializer() { - return this.serializer; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/AbstractRangedConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/AbstractRangedConfigEntry.java deleted file mode 100644 index 5f2a066..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/AbstractRangedConfigEntry.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.RangedConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public abstract class AbstractRangedConfigEntry -extends AbstractConfigEntry -implements RangedConfigEntry { - @Nonnull - protected final T min; - @Nonnull - protected final T max; - - public AbstractRangedConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, T def, @Nullable T min, @Nullable T max) { - super(config, serializer, comments, key, def); - this.min = min != null ? min : this.minimumPossibleValue(); - this.max = max != null ? max : this.maximumPossibleValue(); - } - - @Override - @Nonnull - public T getMin() { - return this.min; - } - - @Override - @Nonnull - public T getMax() { - return this.max; - } - - @Nonnull - abstract T minimumPossibleValue(); - - @Nonnull - abstract T maximumPossibleValue(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/BooleanConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/BooleanConfigEntry.java deleted file mode 100644 index 6e432b1..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/BooleanConfigEntry.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; - -public class BooleanConfigEntry -extends AbstractConfigEntry { - public BooleanConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, Boolean def) { - super(config, serializer, comments, key, def); - this.reload(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/ConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/ConfigEntry.java deleted file mode 100644 index 1da2262..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/ConfigEntry.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.Config; - -public interface ConfigEntry { - public ConfigEntry comment(String ... var1); - - public String[] getComments(); - - public T get(); - - public ConfigEntry set(T var1); - - public String getKey(); - - public ConfigEntry reset(); - - public ConfigEntry save(); - - public ConfigEntry saveSync(); - - public T getDefault(); - - public Config getConfig(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/DoubleConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/DoubleConfigEntry.java deleted file mode 100644 index da2d53f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/DoubleConfigEntry.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class DoubleConfigEntry -extends AbstractRangedConfigEntry { - public DoubleConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, Double def, @Nullable Double min, @Nullable Double max) { - super(config, serializer, comments, key, def, min, max); - this.reload(); - } - - @Override - @Nonnull - Double minimumPossibleValue() { - return Double.MIN_VALUE; - } - - @Override - @Nonnull - Double maximumPossibleValue() { - return Double.MAX_VALUE; - } - - @Override - Double fixValue(Double value) { - return Math.max(Math.min(value, (Double)this.max), (Double)this.min); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/EnumConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/EnumConfigEntry.java deleted file mode 100644 index c3981e8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/EnumConfigEntry.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; - -public class EnumConfigEntry> -extends AbstractConfigEntry { - public EnumConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, E def) { - super(config, serializer, comments, key, def); - this.reload(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/FloatConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/FloatConfigEntry.java deleted file mode 100644 index 53442b8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/FloatConfigEntry.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class FloatConfigEntry -extends AbstractRangedConfigEntry { - public FloatConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, Float def, @Nullable Float min, @Nullable Float max) { - super(config, serializer, comments, key, def, min, max); - this.reload(); - } - - @Override - @Nonnull - Float minimumPossibleValue() { - return Float.valueOf(Float.MIN_VALUE); - } - - @Override - @Nonnull - Float maximumPossibleValue() { - return Float.valueOf(Float.MAX_VALUE); - } - - @Override - Float fixValue(Float value) { - return Float.valueOf(Math.max(Math.min(value.floatValue(), ((Float)this.max).floatValue()), ((Float)this.min).floatValue())); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/GenericConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/GenericConfigEntry.java deleted file mode 100644 index 9abe5b6..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/GenericConfigEntry.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; - -public class GenericConfigEntry -extends AbstractConfigEntry { - public GenericConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, T def) { - super(config, serializer, comments, key, def); - this.reload(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/IntegerConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/IntegerConfigEntry.java deleted file mode 100644 index 2fc1cfe..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/IntegerConfigEntry.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class IntegerConfigEntry -extends AbstractRangedConfigEntry { - public IntegerConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, Integer def, @Nullable Integer min, @Nullable Integer max) { - super(config, serializer, comments, key, def, min, max); - this.reload(); - } - - @Override - @Nonnull - Integer minimumPossibleValue() { - return Integer.MIN_VALUE; - } - - @Override - @Nonnull - Integer maximumPossibleValue() { - return Integer.MAX_VALUE; - } - - @Override - Integer fixValue(Integer value) { - return Math.max(Math.min(value, (Integer)this.max), (Integer)this.min); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/LongConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/LongConfigEntry.java deleted file mode 100644 index 868ef97..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/LongConfigEntry.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractRangedConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class LongConfigEntry -extends AbstractRangedConfigEntry { - public LongConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, Long def, @Nullable Long min, @Nullable Long max) { - super(config, serializer, comments, key, def, min, max); - this.reload(); - } - - @Override - @Nonnull - Long minimumPossibleValue() { - return Long.MIN_VALUE; - } - - @Override - @Nonnull - Long maximumPossibleValue() { - return Long.MAX_VALUE; - } - - @Override - Long fixValue(Long value) { - return Math.max(Math.min(value, (Long)this.max), (Long)this.min); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/RangedConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/RangedConfigEntry.java deleted file mode 100644 index ebe99ed..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/RangedConfigEntry.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nonnull - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.entry.ConfigEntry; -import javax.annotation.Nonnull; - -public interface RangedConfigEntry -extends ConfigEntry { - @Nonnull - public T getMin(); - - @Nonnull - public T getMax(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/StringConfigEntry.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/StringConfigEntry.java deleted file mode 100644 index e975311..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/StringConfigEntry.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.entry; - -import de.maxhenkel.voicechat.configbuilder.CommentedPropertyConfig; -import de.maxhenkel.voicechat.configbuilder.entry.AbstractConfigEntry; -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; - -public class StringConfigEntry -extends AbstractConfigEntry { - public StringConfigEntry(CommentedPropertyConfig config, ValueSerializer serializer, String[] comments, String key, String def) { - super(config, serializer, comments, key, def); - this.reload(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/BooleanSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/BooleanSerializer.java deleted file mode 100644 index 66b42e7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/BooleanSerializer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class BooleanSerializer -implements ValueSerializer { - public static final BooleanSerializer INSTANCE = new BooleanSerializer(); - - @Override - @Nullable - public Boolean deserialize(String str) { - return Boolean.valueOf(str); - } - - @Override - @Nullable - public String serialize(Boolean val) { - return String.valueOf(val); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/DoubleSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/DoubleSerializer.java deleted file mode 100644 index a6322f7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/DoubleSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class DoubleSerializer -implements ValueSerializer { - public static final DoubleSerializer INSTANCE = new DoubleSerializer(); - - @Override - @Nullable - public Double deserialize(String str) { - try { - return Double.parseDouble(str); - } - catch (NumberFormatException e) { - return null; - } - } - - @Override - @Nullable - public String serialize(Double val) { - return String.valueOf(val); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/EnumSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/EnumSerializer.java deleted file mode 100644 index d2c0dfe..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/EnumSerializer.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class EnumSerializer> -implements ValueSerializer { - protected Class enumClass; - - public EnumSerializer(Class enumClass) { - this.enumClass = enumClass; - } - - @Override - @Nullable - public E deserialize(String str) { - try { - return Enum.valueOf(this.enumClass, str); - } - catch (Exception e) { - return null; - } - } - - @Override - @Nullable - public String serialize(E val) { - return ((Enum)val).name(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/FloatSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/FloatSerializer.java deleted file mode 100644 index bb6c715..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/FloatSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class FloatSerializer -implements ValueSerializer { - public static final FloatSerializer INSTANCE = new FloatSerializer(); - - @Override - @Nullable - public Float deserialize(String str) { - try { - return Float.valueOf(Float.parseFloat(str)); - } - catch (NumberFormatException e) { - return null; - } - } - - @Override - @Nullable - public String serialize(Float val) { - return String.valueOf(val); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/IntegerSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/IntegerSerializer.java deleted file mode 100644 index af1e84f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/IntegerSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class IntegerSerializer -implements ValueSerializer { - public static final IntegerSerializer INSTANCE = new IntegerSerializer(); - - @Override - @Nullable - public Integer deserialize(String str) { - try { - return Integer.parseInt(str); - } - catch (NumberFormatException e) { - return null; - } - } - - @Override - @Nullable - public String serialize(Integer val) { - return String.valueOf(val); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/LongSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/LongSerializer.java deleted file mode 100644 index 7c46a98..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/LongSerializer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class LongSerializer -implements ValueSerializer { - public static final LongSerializer INSTANCE = new LongSerializer(); - - @Override - @Nullable - public Long deserialize(String str) { - try { - return Long.parseLong(str); - } - catch (NumberFormatException e) { - return null; - } - } - - @Override - @Nullable - public String serialize(Long val) { - return String.valueOf(val); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/StringSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/StringSerializer.java deleted file mode 100644 index b96a62e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/StringSerializer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import javax.annotation.Nullable; - -public class StringSerializer -implements ValueSerializer { - public static final StringSerializer INSTANCE = new StringSerializer(); - - @Override - @Nullable - public String deserialize(String str) { - return str; - } - - @Override - @Nullable - public String serialize(String val) { - return val; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/ValueSerializable.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/ValueSerializable.java deleted file mode 100644 index 5b3bbe3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/ValueSerializable.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import de.maxhenkel.voicechat.configbuilder.entry.serializer.ValueSerializer; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(value=RetentionPolicy.RUNTIME) -@Target(value={ElementType.TYPE}) -public @interface ValueSerializable { - public Class> value(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/ValueSerializer.java b/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/ValueSerializer.java deleted file mode 100644 index d7550e1..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/configbuilder/entry/serializer/ValueSerializer.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - */ -package de.maxhenkel.voicechat.configbuilder.entry.serializer; - -import javax.annotation.Nullable; - -public interface ValueSerializer { - @Nullable - public T deserialize(String var1); - - @Nullable - public String serialize(T var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/integration/commodore/CommodoreCommands.java b/source/decompiled/de/maxhenkel/voicechat/integration/commodore/CommodoreCommands.java deleted file mode 100644 index 7748660..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/integration/commodore/CommodoreCommands.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * com.mojang.brigadier.arguments.ArgumentType - * com.mojang.brigadier.arguments.StringArgumentType - * com.mojang.brigadier.builder.ArgumentBuilder - * com.mojang.brigadier.builder.LiteralArgumentBuilder - * com.mojang.brigadier.builder.RequiredArgumentBuilder - * com.mojang.brigadier.suggestion.SuggestionProvider - */ -package de.maxhenkel.voicechat.integration.commodore; - -import com.mojang.brigadier.arguments.ArgumentType; -import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.builder.ArgumentBuilder; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.builder.RequiredArgumentBuilder; -import com.mojang.brigadier.suggestion.SuggestionProvider; -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.commodore.Commodore; -import de.maxhenkel.voicechat.integration.commodore.GroupNameSuggestionProvider; -import de.maxhenkel.voicechat.integration.commodore.MissingArgumentTypeException; - -public class CommodoreCommands { - public static void registerCompletions(Commodore commodore) throws MissingArgumentTypeException { - ArgumentType playerArgument = CommodoreCommands.playerArgument(); - ArgumentType uuidArgument = CommodoreCommands.uuidArgument(); - if (playerArgument == null || uuidArgument == null) { - throw new MissingArgumentTypeException("Could not acquire argument types"); - } - LiteralArgumentBuilder literalBuilder = (LiteralArgumentBuilder)((LiteralArgumentBuilder)((LiteralArgumentBuilder)((LiteralArgumentBuilder)((LiteralArgumentBuilder)((LiteralArgumentBuilder)((LiteralArgumentBuilder)((LiteralArgumentBuilder)LiteralArgumentBuilder.literal((String)"voicechat").then((ArgumentBuilder)LiteralArgumentBuilder.literal((String)"help"))).then(LiteralArgumentBuilder.literal((String)"test").then((ArgumentBuilder)RequiredArgumentBuilder.argument((String)"target", playerArgument)))).then(LiteralArgumentBuilder.literal((String)"invite").then((ArgumentBuilder)RequiredArgumentBuilder.argument((String)"target", playerArgument)))).then(LiteralArgumentBuilder.literal((String)"join").then((ArgumentBuilder)RequiredArgumentBuilder.argument((String)"group_id", uuidArgument)))).then(LiteralArgumentBuilder.literal((String)"join").then(RequiredArgumentBuilder.argument((String)"group_id", uuidArgument).then((ArgumentBuilder)RequiredArgumentBuilder.argument((String)"password", (ArgumentType)StringArgumentType.string()))))).then(LiteralArgumentBuilder.literal((String)"join").then((ArgumentBuilder)RequiredArgumentBuilder.argument((String)"group_name", (ArgumentType)StringArgumentType.string()).suggests((SuggestionProvider)GroupNameSuggestionProvider.INSTANCE)))).then(LiteralArgumentBuilder.literal((String)"join").then(RequiredArgumentBuilder.argument((String)"group_name", (ArgumentType)StringArgumentType.string()).suggests((SuggestionProvider)GroupNameSuggestionProvider.INSTANCE).then((ArgumentBuilder)RequiredArgumentBuilder.argument((String)"password", (ArgumentType)StringArgumentType.string()))))).then((ArgumentBuilder)LiteralArgumentBuilder.literal((String)"leave")); - commodore.register(literalBuilder); - } - - private static ArgumentType playerArgument() { - return Voicechat.compatibility.playerArgument(); - } - - private static ArgumentType uuidArgument() { - return Voicechat.compatibility.uuidArgument(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/logging/VoicechatLogger.java b/source/decompiled/de/maxhenkel/voicechat/logging/VoicechatLogger.java deleted file mode 100644 index 097510b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/logging/VoicechatLogger.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.logging; - -import de.maxhenkel.voicechat.logging.LogLevel; - -public interface VoicechatLogger { - public void log(LogLevel var1, String var2, Object ... var3); - - public boolean isEnabled(LogLevel var1); - - default public void trace(String message, Object ... args) { - this.log(LogLevel.TRACE, message, args); - } - - default public void debug(String message, Object ... args) { - this.log(LogLevel.DEBUG, message, args); - } - - default public void info(String message, Object ... args) { - this.log(LogLevel.INFO, message, args); - } - - default public void warn(String message, Object ... args) { - this.log(LogLevel.WARN, message, args); - } - - default public void error(String message, Object ... args) { - this.log(LogLevel.ERROR, message, args); - } - - default public void fatal(String message, Object ... args) { - this.log(LogLevel.FATAL, message, args); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/net/NetManager.java b/source/decompiled/de/maxhenkel/voicechat/net/NetManager.java deleted file mode 100644 index d02c681..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/net/NetManager.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * io.netty.buffer.Unpooled - * org.bukkit.Bukkit - * org.bukkit.entity.Player - * org.bukkit.event.EventHandler - * org.bukkit.event.Listener - * org.bukkit.event.player.PlayerJoinEvent - * org.bukkit.event.player.PlayerQuitEvent - * org.bukkit.plugin.Plugin - */ -package de.maxhenkel.voicechat.net; - -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.net.AddCategoryPacket; -import de.maxhenkel.voicechat.net.AddGroupPacket; -import de.maxhenkel.voicechat.net.CreateGroupPacket; -import de.maxhenkel.voicechat.net.JoinGroupPacket; -import de.maxhenkel.voicechat.net.JoinedGroupPacket; -import de.maxhenkel.voicechat.net.LeaveGroupPacket; -import de.maxhenkel.voicechat.net.Packet; -import de.maxhenkel.voicechat.net.PlayerStatePacket; -import de.maxhenkel.voicechat.net.PlayerStatesPacket; -import de.maxhenkel.voicechat.net.RemoveCategoryPacket; -import de.maxhenkel.voicechat.net.RemoveGroupPacket; -import de.maxhenkel.voicechat.net.RemovePlayerStatePacket; -import de.maxhenkel.voicechat.net.RequestSecretPacket; -import de.maxhenkel.voicechat.net.SecretPacket; -import de.maxhenkel.voicechat.net.UpdateStatePacket; -import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import io.netty.buffer.Unpooled; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.HashSet; -import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.Plugin; - -public class NetManager -implements Listener { - private final Set packets = new HashSet(); - - public void onEnable() { - this.packets.clear(); - Bukkit.getPluginManager().registerEvents((Listener)this, (Plugin)Voicechat.INSTANCE); - try { - this.registerIncomingPacket(UpdateStatePacket.class); - this.registerIncomingPacket(RequestSecretPacket.class); - this.registerIncomingPacket(CreateGroupPacket.class); - this.registerIncomingPacket(JoinGroupPacket.class); - this.registerIncomingPacket(LeaveGroupPacket.class); - this.registerOutgoingPacket(SecretPacket.class); - this.registerOutgoingPacket(PlayerStatesPacket.class); - this.registerOutgoingPacket(PlayerStatePacket.class); - this.registerOutgoingPacket(RemovePlayerStatePacket.class); - this.registerOutgoingPacket(AddGroupPacket.class); - this.registerOutgoingPacket(RemoveGroupPacket.class); - this.registerOutgoingPacket(JoinedGroupPacket.class); - this.registerOutgoingPacket(AddCategoryPacket.class); - this.registerOutgoingPacket(RemoveCategoryPacket.class); - } - catch (Exception e) { - throw new IllegalStateException("Failed to register voice chat packets", e); - } - } - - public void onDisable() { - Set incomingChannels = Bukkit.getMessenger().getIncomingChannels((Plugin)Voicechat.INSTANCE); - Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels((Plugin)Voicechat.INSTANCE); - for (String channel : incomingChannels) { - Bukkit.getMessenger().unregisterIncomingPluginChannel((Plugin)Voicechat.INSTANCE, channel); - } - for (String channel : outgoingChannels) { - Bukkit.getMessenger().unregisterOutgoingPluginChannel((Plugin)Voicechat.INSTANCE, channel); - } - this.packets.clear(); - } - - public Set getPackets() { - return this.packets; - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels((Plugin)Voicechat.INSTANCE); - for (String channel : outgoingChannels) { - Voicechat.compatibility.addChannel(event.getPlayer(), channel); - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - Set outgoingChannels = Bukkit.getMessenger().getOutgoingChannels((Plugin)Voicechat.INSTANCE); - for (String channel : outgoingChannels) { - Voicechat.compatibility.removeChannel(event.getPlayer(), channel); - } - } - - private > void registerIncomingPacket(Class packetClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { - Constructor c = packetClass.getDeclaredConstructor(new Class[0]); - String id = ((Packet)c.newInstance(new Object[0])).getID().toString(); - this.packets.add(id); - Bukkit.getMessenger().registerIncomingPluginChannel((Plugin)Voicechat.INSTANCE, id, (s, player, bytes) -> { - Packet packet; - if (!Voicechat.SERVER.getRateLimiter().allow(player.getUniqueId())) { - Voicechat.LOGGER.warn("Player {} exceeded packet rate limit", player.getDisplayName()); - player.kickPlayer(Voicechat.TRANSLATIONS.rateLimitKickMessage.get()); - return; - } - try { - packet = (Packet)c.newInstance(new Object[0]); - } - catch (Exception e) { - Voicechat.LOGGER.error("Failed to create new packet instance of {}", packetClass.getSimpleName(), e); - return; - } - FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.wrappedBuffer((byte[])bytes)); - packet.fromBytes(buffer); - packet.onPacket(player); - }); - } - - private > void registerOutgoingPacket(Class packetClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { - String id = ((Packet)packetClass.getDeclaredConstructor(new Class[0]).newInstance(new Object[0])).getID().toString(); - this.packets.add(id); - Bukkit.getMessenger().registerOutgoingPluginChannel((Plugin)Voicechat.INSTANCE, id); - } - - public static void sendToClient(Player player, Packet p) { - Voicechat.compatibility.runTask(() -> { - if (!Voicechat.SERVER.isCompatible(player)) { - return; - } - try { - FriendlyByteBuf buf = new FriendlyByteBuf(); - p.toBytes(buf); - byte[] bytes = new byte[buf.readableBytes()]; - buf.readBytes(bytes); - player.sendPluginMessage((Plugin)Voicechat.INSTANCE, p.getID().toString(), bytes); - } - catch (Exception e) { - Voicechat.LOGGER.error("Failed to send packet to '{}'", player.getName(), e); - } - }); - } - - public static void sendMessage(Player player, String key, String ... args) { - Voicechat.compatibility.sendTranslationMessage(player, key, args); - } - - public static void sendStatusMessage(Player player, String key, String ... args) { - Voicechat.compatibility.sendStatusMessage(player, key, args); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/net/Packet.java b/source/decompiled/de/maxhenkel/voicechat/net/Packet.java deleted file mode 100644 index 97233ee..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/net/Packet.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.net; - -import de.maxhenkel.voicechat.util.FriendlyByteBuf; -import de.maxhenkel.voicechat.util.Key; -import org.bukkit.entity.Player; - -public interface Packet { - public Key getID(); - - public T fromBytes(FriendlyByteBuf var1); - - public void toBytes(FriendlyByteBuf var1); - - default public void onPacket(Player player) { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/CDL.java b/source/decompiled/de/maxhenkel/voicechat/org/json/CDL.java deleted file mode 100644 index ee27067..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/CDL.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONTokener; - -public class CDL { - @Deprecated - public CDL() { - } - - private static String getValue(JSONTokener x, char delimiter) throws JSONException { - char c; - while ((c = x.next()) == ' ' || c == '\t') { - } - if (c == '\u0000') { - return null; - } - if (c == '\"' || c == '\'') { - char q = c; - StringBuilder sb = new StringBuilder(); - while (true) { - char nextC; - if ((c = x.next()) == q && (nextC = x.next()) != '\"') { - if (nextC <= '\u0000') break; - x.back(); - break; - } - if (c == '\u0000' || c == '\n' || c == '\r') { - throw x.syntaxError("Missing close quote '" + q + "'."); - } - sb.append(c); - } - return sb.toString(); - } - if (c == delimiter) { - x.back(); - return ""; - } - x.back(); - return x.nextTo(delimiter); - } - - public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { - return CDL.rowToJSONArray(x, ','); - } - - public static JSONArray rowToJSONArray(JSONTokener x, char delimiter) throws JSONException { - JSONArray ja = new JSONArray(); - block0: while (true) { - String value = CDL.getValue(x, delimiter); - char c = x.next(); - if (value != null) { - ja.put(value); - } else { - if (ja.length() == 0 && c != delimiter) { - return null; - } - ja.put(""); - } - while (true) { - if (c == delimiter) continue block0; - if (c != ' ') { - if (c == '\n' || c == '\r' || c == '\u0000') { - return ja; - } - throw x.syntaxError("Bad character '" + c + "' (" + c + ")."); - } - c = x.next(); - } - break; - } - } - - public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException { - return CDL.rowToJSONObject(names, x, ','); - } - - public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x, char delimiter) throws JSONException { - JSONArray ja = CDL.rowToJSONArray(x, delimiter); - return ja != null ? ja.toJSONObject(names) : null; - } - - public static String rowToString(JSONArray ja) { - return CDL.rowToString(ja, ','); - } - - public static String rowToString(JSONArray ja, char delimiter) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < ja.length(); ++i) { - Object object; - if (i > 0) { - sb.append(delimiter); - } - if ((object = ja.opt(i)) == null) continue; - String string = object.toString(); - if (!(string.isEmpty() || string.indexOf(delimiter) < 0 && string.indexOf(10) < 0 && string.indexOf(13) < 0 && string.indexOf(0) < 0 && string.charAt(0) != '\"')) { - sb.append('\"'); - int length = string.length(); - for (int j = 0; j < length; ++j) { - char c = string.charAt(j); - if (c < ' ' || c == '\"') continue; - sb.append(c); - } - sb.append('\"'); - continue; - } - sb.append(string); - } - sb.append('\n'); - return sb.toString(); - } - - public static JSONArray toJSONArray(String string) throws JSONException { - return CDL.toJSONArray(string, ','); - } - - public static JSONArray toJSONArray(String string, char delimiter) throws JSONException { - return CDL.toJSONArray(new JSONTokener(string), delimiter); - } - - public static JSONArray toJSONArray(JSONTokener x) throws JSONException { - return CDL.toJSONArray(x, ','); - } - - public static JSONArray toJSONArray(JSONTokener x, char delimiter) throws JSONException { - return CDL.toJSONArray(CDL.rowToJSONArray(x, delimiter), x, delimiter); - } - - public static JSONArray toJSONArray(JSONArray names, String string) throws JSONException { - return CDL.toJSONArray(names, string, ','); - } - - public static JSONArray toJSONArray(JSONArray names, String string, char delimiter) throws JSONException { - return CDL.toJSONArray(names, new JSONTokener(string), delimiter); - } - - public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException { - return CDL.toJSONArray(names, x, ','); - } - - public static JSONArray toJSONArray(JSONArray names, JSONTokener x, char delimiter) throws JSONException { - String key; - JSONObject j; - JSONObject jo; - if (names == null || names.length() == 0) { - return null; - } - JSONArray ja = new JSONArray(); - while ((jo = CDL.rowToJSONObject(names, x, delimiter)) != null) { - ja.put(jo); - } - if (ja.length() == 0) { - return null; - } - if (ja.length() == 1 && (j = ja.getJSONObject(0)).length() == 1 && "".equals(key = j.keys().next()) && "".equals(j.get(key))) { - return null; - } - return ja; - } - - public static String toString(JSONArray ja) throws JSONException { - return CDL.toString(ja, ','); - } - - public static String toString(JSONArray ja, char delimiter) throws JSONException { - JSONArray names; - JSONObject jo = ja.optJSONObject(0); - if (jo != null && (names = jo.names()) != null) { - return CDL.rowToString(names, delimiter) + CDL.toString(names, ja, delimiter); - } - return null; - } - - public static String toString(JSONArray names, JSONArray ja) throws JSONException { - return CDL.toString(names, ja, ','); - } - - public static String toString(JSONArray names, JSONArray ja, char delimiter) throws JSONException { - if (names == null || names.length() == 0) { - return null; - } - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < ja.length(); ++i) { - JSONObject jo = ja.optJSONObject(i); - if (jo == null) continue; - sb.append(CDL.rowToString(jo.toJSONArray(names), delimiter)); - } - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/Cookie.java b/source/decompiled/de/maxhenkel/voicechat/org/json/Cookie.java deleted file mode 100644 index c45c429..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/Cookie.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONTokener; -import java.util.Locale; - -public class Cookie { - @Deprecated - public Cookie() { - } - - public static String escape(String string) { - String s = string.trim(); - int length = s.length(); - StringBuilder sb = new StringBuilder(length); - for (int i = 0; i < length; ++i) { - char c = s.charAt(i); - if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') { - sb.append('%'); - sb.append(Character.forDigit((char)(c >>> 4 & 0xF), 16)); - sb.append(Character.forDigit((char)(c & 0xF), 16)); - continue; - } - sb.append(c); - } - return sb.toString(); - } - - public static JSONObject toJSONObject(String string) { - JSONObject jo = new JSONObject(); - JSONTokener x = new JSONTokener(string); - String name = Cookie.unescape(x.nextTo('=').trim()); - if ("".equals(name)) { - throw new JSONException("Cookies must have a 'name'"); - } - jo.put("name", name); - x.next('='); - jo.put("value", Cookie.unescape(x.nextTo(';')).trim()); - x.next(); - while (x.more()) { - Object value; - name = Cookie.unescape(x.nextTo("=;")).trim().toLowerCase(Locale.ROOT); - if ("name".equalsIgnoreCase(name)) { - throw new JSONException("Illegal attribute name: 'name'"); - } - if ("value".equalsIgnoreCase(name)) { - throw new JSONException("Illegal attribute name: 'value'"); - } - if (x.next() != '=') { - value = Boolean.TRUE; - } else { - value = Cookie.unescape(x.nextTo(';')).trim(); - x.next(); - } - if ("".equals(name) || "".equals(value)) continue; - jo.put(name, value); - } - return jo; - } - - public static String toString(JSONObject jo) throws JSONException { - StringBuilder sb = new StringBuilder(); - String name = null; - Object value = null; - for (String key : jo.keySet()) { - if ("name".equalsIgnoreCase(key)) { - name = jo.getString(key).trim(); - } - if ("value".equalsIgnoreCase(key)) { - value = jo.getString(key).trim(); - } - if (name == null || value == null) continue; - break; - } - if (name == null || "".equals(name.trim())) { - throw new JSONException("Cookie does not have a name"); - } - if (value == null) { - value = ""; - } - sb.append(Cookie.escape(name)); - sb.append("="); - sb.append(Cookie.escape((String)value)); - for (String key : jo.keySet()) { - if ("name".equalsIgnoreCase(key) || "value".equalsIgnoreCase(key)) continue; - value = jo.opt(key); - if (value instanceof Boolean) { - if (!Boolean.TRUE.equals(value)) continue; - sb.append(';').append(Cookie.escape(key)); - continue; - } - sb.append(';').append(Cookie.escape(key)).append('=').append(Cookie.escape(value.toString())); - } - return sb.toString(); - } - - public static String unescape(String string) { - int length = string.length(); - StringBuilder sb = new StringBuilder(length); - for (int i = 0; i < length; ++i) { - char c = string.charAt(i); - if (c == '+') { - c = ' '; - } else if (c == '%' && i + 2 < length) { - int d = JSONTokener.dehexchar(string.charAt(i + 1)); - int e = JSONTokener.dehexchar(string.charAt(i + 2)); - if (d >= 0 && e >= 0) { - c = (char)(d * 16 + e); - i += 2; - } - } - sb.append(c); - } - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/CookieList.java b/source/decompiled/de/maxhenkel/voicechat/org/json/CookieList.java deleted file mode 100644 index 5aed590..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/CookieList.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.Cookie; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONTokener; - -public class CookieList { - @Deprecated - public CookieList() { - } - - public static JSONObject toJSONObject(String string) throws JSONException { - JSONObject jo = new JSONObject(); - JSONTokener x = new JSONTokener(string); - while (x.more()) { - String name = Cookie.unescape(x.nextTo('=')); - x.next('='); - jo.put(name, Cookie.unescape(x.nextTo(';'))); - x.next(); - } - return jo; - } - - public static String toString(JSONObject jo) throws JSONException { - boolean isEndOfPair = false; - StringBuilder sb = new StringBuilder(); - for (String key : jo.keySet()) { - Object value = jo.opt(key); - if (JSONObject.NULL.equals(value)) continue; - if (isEndOfPair) { - sb.append(';'); - } - sb.append(Cookie.escape(key)); - sb.append("="); - sb.append(Cookie.escape(value.toString())); - isEndOfPair = true; - } - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/HTTP.java b/source/decompiled/de/maxhenkel/voicechat/org/json/HTTP.java deleted file mode 100644 index 386067d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/HTTP.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.HTTPTokener; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import java.util.Locale; - -public class HTTP { - public static final String CRLF = "\r\n"; - - public static JSONObject toJSONObject(String string) throws JSONException { - JSONObject jo = new JSONObject(); - HTTPTokener x = new HTTPTokener(string); - String token = x.nextToken(); - if (token.toUpperCase(Locale.ROOT).startsWith("HTTP")) { - jo.put("HTTP-Version", token); - jo.put("Status-Code", x.nextToken()); - jo.put("Reason-Phrase", x.nextTo('\u0000')); - x.next(); - } else { - jo.put("Method", token); - jo.put("Request-URI", x.nextToken()); - jo.put("HTTP-Version", x.nextToken()); - } - while (x.more()) { - String name = x.nextTo(':'); - x.next(':'); - jo.put(name, x.nextTo('\u0000')); - x.next(); - } - return jo; - } - - public static String toString(JSONObject jo) throws JSONException { - StringBuilder sb = new StringBuilder(); - if (jo.has("Status-Code") && jo.has("Reason-Phrase")) { - sb.append(jo.getString("HTTP-Version")); - sb.append(' '); - sb.append(jo.getString("Status-Code")); - sb.append(' '); - sb.append(jo.getString("Reason-Phrase")); - } else if (jo.has("Method") && jo.has("Request-URI")) { - sb.append(jo.getString("Method")); - sb.append(' '); - sb.append('\"'); - sb.append(jo.getString("Request-URI")); - sb.append('\"'); - sb.append(' '); - sb.append(jo.getString("HTTP-Version")); - } else { - throw new JSONException("Not enough material for an HTTP header."); - } - sb.append(CRLF); - for (String key : jo.keySet()) { - String value = jo.optString(key); - if ("HTTP-Version".equals(key) || "Status-Code".equals(key) || "Reason-Phrase".equals(key) || "Method".equals(key) || "Request-URI".equals(key) || JSONObject.NULL.equals(value)) continue; - sb.append(key); - sb.append(": "); - sb.append(jo.optString(key)); - sb.append(CRLF); - } - sb.append(CRLF); - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/HTTPTokener.java b/source/decompiled/de/maxhenkel/voicechat/org/json/HTTPTokener.java deleted file mode 100644 index 0ffb14d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/HTTPTokener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONTokener; - -public class HTTPTokener -extends JSONTokener { - public HTTPTokener(String string) { - super(string); - } - - public String nextToken() throws JSONException { - char c; - StringBuilder sb = new StringBuilder(); - while (Character.isWhitespace(c = this.next())) { - } - if (c == '\"' || c == '\'') { - char q = c; - while (true) { - if ((c = this.next()) < ' ') { - throw this.syntaxError("Unterminated string."); - } - if (c == q) { - return sb.toString(); - } - sb.append(c); - } - } - while (c != '\u0000' && !Character.isWhitespace(c)) { - sb.append(c); - c = this.next(); - } - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONArray.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONArray.java deleted file mode 100644 index 66706ec..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONArray.java +++ /dev/null @@ -1,855 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONParserConfiguration; -import de.maxhenkel.voicechat.org.json.JSONPointer; -import de.maxhenkel.voicechat.org.json.JSONPointerException; -import de.maxhenkel.voicechat.org.json.JSONString; -import de.maxhenkel.voicechat.org.json.JSONTokener; -import de.maxhenkel.voicechat.org.json.StringBuilderWriter; -import java.io.IOException; -import java.io.Writer; -import java.lang.reflect.Array; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -public class JSONArray -implements Iterable { - private final ArrayList myArrayList; - - public JSONArray() { - this.myArrayList = new ArrayList(); - } - - public JSONArray(JSONTokener x) throws JSONException { - this(x, x.getJsonParserConfiguration()); - } - - public JSONArray(JSONTokener x, JSONParserConfiguration jsonParserConfiguration) throws JSONException { - this(); - boolean isInitial; - boolean bl = isInitial = x.getPrevious() == '\u0000'; - if (x.nextClean() != '[') { - throw x.syntaxError("A JSONArray text must start with '['"); - } - char nextChar = x.nextClean(); - if (nextChar == '\u0000') { - throw x.syntaxError("Expected a ',' or ']'"); - } - if (nextChar == ',' && jsonParserConfiguration.isStrictMode()) { - throw x.syntaxError("Array content starts with a ','"); - } - if (nextChar != ']') { - x.back(); - do { - if (x.nextClean() == ',') { - x.back(); - this.myArrayList.add(JSONObject.NULL); - continue; - } - x.back(); - this.myArrayList.add(x.nextValue()); - } while (!JSONArray.checkForSyntaxError(x, jsonParserConfiguration, isInitial)); - return; - } - if (isInitial && jsonParserConfiguration.isStrictMode() && x.nextClean() != '\u0000') { - throw x.syntaxError("Strict mode error: Unparsed characters found at end of input text"); - } - } - - private static boolean checkForSyntaxError(JSONTokener x, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) { - switch (x.nextClean()) { - case '\u0000': { - throw x.syntaxError("Expected a ',' or ']'"); - } - case ',': { - char nextChar = x.nextClean(); - if (nextChar == '\u0000') { - throw x.syntaxError("Expected a ',' or ']'"); - } - if (nextChar == ']') { - if (jsonParserConfiguration.isStrictMode()) { - throw x.syntaxError("Strict mode error: Expected another array element"); - } - return true; - } - if (nextChar == ',') { - if (jsonParserConfiguration.isStrictMode()) { - throw x.syntaxError("Strict mode error: Expected a valid array element"); - } - return true; - } - x.back(); - break; - } - case ']': { - if (isInitial && jsonParserConfiguration.isStrictMode() && x.nextClean() != '\u0000') { - throw x.syntaxError("Strict mode error: Unparsed characters found at end of input text"); - } - return true; - } - default: { - throw x.syntaxError("Expected a ',' or ']'"); - } - } - return false; - } - - public JSONArray(String source) throws JSONException { - this(source, new JSONParserConfiguration()); - } - - public JSONArray(String source, JSONParserConfiguration jsonParserConfiguration) throws JSONException { - this(new JSONTokener(source, jsonParserConfiguration), jsonParserConfiguration); - } - - public JSONArray(Collection collection) { - this(collection, 0, new JSONParserConfiguration()); - } - - public JSONArray(Collection collection, JSONParserConfiguration jsonParserConfiguration) { - this(collection, 0, jsonParserConfiguration); - } - - JSONArray(Collection collection, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) { - if (recursionDepth > jsonParserConfiguration.getMaxNestingDepth()) { - throw new JSONException("JSONArray has reached recursion depth limit of " + jsonParserConfiguration.getMaxNestingDepth()); - } - if (collection == null) { - this.myArrayList = new ArrayList(); - } else { - this.myArrayList = new ArrayList(collection.size()); - this.addAll(collection, true, recursionDepth, jsonParserConfiguration); - } - } - - public JSONArray(Iterable iter) { - this(); - if (iter == null) { - return; - } - this.addAll(iter, true); - } - - public JSONArray(JSONArray array) { - this.myArrayList = array == null ? new ArrayList() : new ArrayList(array.myArrayList); - } - - public JSONArray(Object array) throws JSONException { - this(); - if (!array.getClass().isArray()) { - throw new JSONException("JSONArray initial value should be a string or collection or array."); - } - this.addAll(array, true, 0); - } - - public JSONArray(int initialCapacity) throws JSONException { - if (initialCapacity < 0) { - throw new JSONException("JSONArray initial capacity cannot be negative."); - } - this.myArrayList = new ArrayList(initialCapacity); - } - - @Override - public Iterator iterator() { - return this.myArrayList.iterator(); - } - - public Object get(int index) throws JSONException { - Object object = this.opt(index); - if (object == null) { - throw new JSONException("JSONArray[" + index + "] not found."); - } - return object; - } - - public boolean getBoolean(int index) throws JSONException { - Object object = this.get(index); - if (Boolean.FALSE.equals(object) || object instanceof String && "false".equalsIgnoreCase((String)object)) { - return false; - } - if (Boolean.TRUE.equals(object) || object instanceof String && "true".equalsIgnoreCase((String)object)) { - return true; - } - throw JSONArray.wrongValueFormatException(index, "boolean", object, null); - } - - public double getDouble(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof Number) { - return ((Number)object).doubleValue(); - } - try { - return Double.parseDouble(object.toString()); - } - catch (Exception e) { - throw JSONArray.wrongValueFormatException(index, "double", object, e); - } - } - - public float getFloat(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof Number) { - return ((Number)object).floatValue(); - } - try { - return Float.parseFloat(object.toString()); - } - catch (Exception e) { - throw JSONArray.wrongValueFormatException(index, "float", object, e); - } - } - - public Number getNumber(int index) throws JSONException { - Object object = this.get(index); - try { - if (object instanceof Number) { - return (Number)object; - } - return JSONObject.stringToNumber(object.toString()); - } - catch (Exception e) { - throw JSONArray.wrongValueFormatException(index, "number", object, e); - } - } - - public > E getEnum(Class clazz, int index) throws JSONException { - E val = this.optEnum(clazz, index); - if (val == null) { - throw JSONArray.wrongValueFormatException(index, "enum of type " + JSONObject.quote(clazz.getSimpleName()), this.opt(index), null); - } - return val; - } - - public BigDecimal getBigDecimal(int index) throws JSONException { - Object object = this.get(index); - BigDecimal val = JSONObject.objectToBigDecimal(object, null); - if (val == null) { - throw JSONArray.wrongValueFormatException(index, "BigDecimal", object, null); - } - return val; - } - - public BigInteger getBigInteger(int index) throws JSONException { - Object object = this.get(index); - BigInteger val = JSONObject.objectToBigInteger(object, null); - if (val == null) { - throw JSONArray.wrongValueFormatException(index, "BigInteger", object, null); - } - return val; - } - - public int getInt(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof Number) { - return ((Number)object).intValue(); - } - try { - return Integer.parseInt(object.toString()); - } - catch (Exception e) { - throw JSONArray.wrongValueFormatException(index, "int", object, e); - } - } - - public JSONArray getJSONArray(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof JSONArray) { - return (JSONArray)object; - } - throw JSONArray.wrongValueFormatException(index, "JSONArray", object, null); - } - - public JSONObject getJSONObject(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof JSONObject) { - return (JSONObject)object; - } - throw JSONArray.wrongValueFormatException(index, "JSONObject", object, null); - } - - public long getLong(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof Number) { - return ((Number)object).longValue(); - } - try { - return Long.parseLong(object.toString()); - } - catch (Exception e) { - throw JSONArray.wrongValueFormatException(index, "long", object, e); - } - } - - public String getString(int index) throws JSONException { - Object object = this.get(index); - if (object instanceof String) { - return (String)object; - } - throw JSONArray.wrongValueFormatException(index, "String", object, null); - } - - public boolean isNull(int index) { - return JSONObject.NULL.equals(this.opt(index)); - } - - public String join(String separator) throws JSONException { - int len = this.length(); - if (len == 0) { - return ""; - } - StringBuilder sb = new StringBuilder(JSONObject.valueToString(this.myArrayList.get(0))); - for (int i = 1; i < len; ++i) { - sb.append(separator).append(JSONObject.valueToString(this.myArrayList.get(i))); - } - return sb.toString(); - } - - public int length() { - return this.myArrayList.size(); - } - - public void clear() { - this.myArrayList.clear(); - } - - public Object opt(int index) { - return index < 0 || index >= this.length() ? null : this.myArrayList.get(index); - } - - public boolean optBoolean(int index) { - return this.optBoolean(index, false); - } - - public boolean optBoolean(int index, boolean defaultValue) { - try { - return this.getBoolean(index); - } - catch (Exception e) { - return defaultValue; - } - } - - public Boolean optBooleanObject(int index) { - return this.optBooleanObject(index, false); - } - - public Boolean optBooleanObject(int index, Boolean defaultValue) { - try { - return this.getBoolean(index); - } - catch (Exception e) { - return defaultValue; - } - } - - public double optDouble(int index) { - return this.optDouble(index, Double.NaN); - } - - public double optDouble(int index, double defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.doubleValue(); - } - - public Double optDoubleObject(int index) { - return this.optDoubleObject(index, Double.NaN); - } - - public Double optDoubleObject(int index, Double defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.doubleValue(); - } - - public float optFloat(int index) { - return this.optFloat(index, Float.NaN); - } - - public float optFloat(int index, float defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.floatValue(); - } - - public Float optFloatObject(int index) { - return this.optFloatObject(index, Float.valueOf(Float.NaN)); - } - - public Float optFloatObject(int index, Float defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return Float.valueOf(val.floatValue()); - } - - public int optInt(int index) { - return this.optInt(index, 0); - } - - public int optInt(int index, int defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.intValue(); - } - - public Integer optIntegerObject(int index) { - return this.optIntegerObject(index, 0); - } - - public Integer optIntegerObject(int index, Integer defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.intValue(); - } - - public > E optEnum(Class clazz, int index) { - return this.optEnum(clazz, index, null); - } - - public > E optEnum(Class clazz, int index, E defaultValue) { - try { - Object val = this.opt(index); - if (JSONObject.NULL.equals(val)) { - return defaultValue; - } - if (clazz.isAssignableFrom(val.getClass())) { - Enum myE = (Enum)val; - return (E)myE; - } - return Enum.valueOf(clazz, val.toString()); - } - catch (IllegalArgumentException e) { - return defaultValue; - } - catch (NullPointerException e) { - return defaultValue; - } - } - - public BigInteger optBigInteger(int index, BigInteger defaultValue) { - Object val = this.opt(index); - return JSONObject.objectToBigInteger(val, defaultValue); - } - - public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) { - Object val = this.opt(index); - return JSONObject.objectToBigDecimal(val, defaultValue); - } - - public JSONArray optJSONArray(int index) { - return this.optJSONArray(index, null); - } - - public JSONArray optJSONArray(int index, JSONArray defaultValue) { - Object object = this.opt(index); - return object instanceof JSONArray ? (JSONArray)object : defaultValue; - } - - public JSONObject optJSONObject(int index) { - return this.optJSONObject(index, null); - } - - public JSONObject optJSONObject(int index, JSONObject defaultValue) { - Object object = this.opt(index); - return object instanceof JSONObject ? (JSONObject)object : defaultValue; - } - - public long optLong(int index) { - return this.optLong(index, 0L); - } - - public long optLong(int index, long defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.longValue(); - } - - public Long optLongObject(int index) { - return this.optLongObject(index, 0L); - } - - public Long optLongObject(int index, Long defaultValue) { - Number val = this.optNumber(index, null); - if (val == null) { - return defaultValue; - } - return val.longValue(); - } - - public Number optNumber(int index) { - return this.optNumber(index, null); - } - - public Number optNumber(int index, Number defaultValue) { - Object val = this.opt(index); - if (JSONObject.NULL.equals(val)) { - return defaultValue; - } - if (val instanceof Number) { - return (Number)val; - } - if (val instanceof String) { - try { - return JSONObject.stringToNumber((String)val); - } - catch (Exception e) { - return defaultValue; - } - } - return defaultValue; - } - - public String optString(int index) { - return this.optString(index, ""); - } - - public String optString(int index, String defaultValue) { - Object object = this.opt(index); - return JSONObject.NULL.equals(object) ? defaultValue : object.toString(); - } - - public JSONArray put(boolean value) { - return this.put(value ? Boolean.TRUE : Boolean.FALSE); - } - - public JSONArray put(Collection value) { - return this.put(new JSONArray(value)); - } - - public JSONArray put(double value) throws JSONException { - return this.put((Object)value); - } - - public JSONArray put(float value) throws JSONException { - return this.put(Float.valueOf(value)); - } - - public JSONArray put(int value) { - return this.put((Object)value); - } - - public JSONArray put(long value) { - return this.put((Object)value); - } - - public JSONArray put(Map value) { - return this.put(new JSONObject(value)); - } - - public JSONArray put(Object value) { - JSONObject.testValidity(value); - this.myArrayList.add(value); - return this; - } - - public JSONArray put(int index, boolean value) throws JSONException { - return this.put(index, value ? Boolean.TRUE : Boolean.FALSE); - } - - public JSONArray put(int index, Collection value) throws JSONException { - return this.put(index, new JSONArray(value)); - } - - public JSONArray put(int index, double value) throws JSONException { - return this.put(index, (Object)value); - } - - public JSONArray put(int index, float value) throws JSONException { - return this.put(index, Float.valueOf(value)); - } - - public JSONArray put(int index, int value) throws JSONException { - return this.put(index, (Object)value); - } - - public JSONArray put(int index, long value) throws JSONException { - return this.put(index, (Object)value); - } - - public JSONArray put(int index, Map value) throws JSONException { - this.put(index, new JSONObject(value, new JSONParserConfiguration())); - return this; - } - - public JSONArray put(int index, Map value, JSONParserConfiguration jsonParserConfiguration) throws JSONException { - this.put(index, new JSONObject(value, jsonParserConfiguration)); - return this; - } - - public JSONArray put(int index, Object value) throws JSONException { - if (index < 0) { - throw new JSONException("JSONArray[" + index + "] not found."); - } - if (index < this.length()) { - JSONObject.testValidity(value); - this.myArrayList.set(index, value); - return this; - } - if (index == this.length()) { - return this.put(value); - } - this.myArrayList.ensureCapacity(index + 1); - while (index != this.length()) { - this.myArrayList.add(JSONObject.NULL); - } - return this.put(value); - } - - public JSONArray putAll(Collection collection) { - this.addAll(collection, false); - return this; - } - - public JSONArray putAll(Iterable iter) { - this.addAll(iter, false); - return this; - } - - public JSONArray putAll(JSONArray array) { - this.myArrayList.addAll(array.myArrayList); - return this; - } - - public JSONArray putAll(Object array) throws JSONException { - this.addAll(array, false); - return this; - } - - public Object query(String jsonPointer) { - return this.query(new JSONPointer(jsonPointer)); - } - - public Object query(JSONPointer jsonPointer) { - return jsonPointer.queryFrom(this); - } - - public Object optQuery(String jsonPointer) { - return this.optQuery(new JSONPointer(jsonPointer)); - } - - public Object optQuery(JSONPointer jsonPointer) { - try { - return jsonPointer.queryFrom(this); - } - catch (JSONPointerException e) { - return null; - } - } - - public Object remove(int index) { - return index >= 0 && index < this.length() ? this.myArrayList.remove(index) : null; - } - - public boolean similar(Object other) { - if (!(other instanceof JSONArray)) { - return false; - } - int len = this.length(); - if (len != ((JSONArray)other).length()) { - return false; - } - for (int i = 0; i < len; ++i) { - Object valueOther; - Object valueThis = this.myArrayList.get(i); - if (valueThis == (valueOther = ((JSONArray)other).myArrayList.get(i))) continue; - if (valueThis == null) { - return false; - } - if (this.isSimilar(valueThis, valueOther)) continue; - return false; - } - return true; - } - - private boolean isSimilar(Object valueThis, Object valueOther) { - return !(valueThis instanceof JSONObject ? !((JSONObject)valueThis).similar(valueOther) : (valueThis instanceof JSONArray ? !((JSONArray)valueThis).similar(valueOther) : (valueThis instanceof Number && valueOther instanceof Number ? !JSONObject.isNumberSimilar((Number)valueThis, (Number)valueOther) : (valueThis instanceof JSONString && valueOther instanceof JSONString ? !((JSONString)valueThis).toJSONString().equals(((JSONString)valueOther).toJSONString()) : !valueThis.equals(valueOther))))); - } - - public JSONObject toJSONObject(JSONArray names) throws JSONException { - if (names == null || names.isEmpty() || this.isEmpty()) { - return null; - } - JSONObject jo = new JSONObject(names.length()); - for (int i = 0; i < names.length(); ++i) { - jo.put(names.getString(i), this.opt(i)); - } - return jo; - } - - public String toString() { - try { - return this.toString(0); - } - catch (Exception e) { - return null; - } - } - - public String toString(int indentFactor) throws JSONException { - int initialSize = this.myArrayList.size() * 2; - StringBuilderWriter sw = new StringBuilderWriter(Math.max(initialSize, 16)); - return this.write(sw, indentFactor, 0).toString(); - } - - public Writer write(Writer writer) throws JSONException { - return this.write(writer, 0, 0); - } - - public Writer write(Writer writer, int indentFactor, int indent) throws JSONException { - try { - boolean needsComma = false; - int length = this.length(); - writer.write(91); - if (length == 1) { - this.writeArrayAttempt(writer, indentFactor, indent, 0); - } else if (length != 0) { - int newIndent = indent + indentFactor; - for (int i = 0; i < length; ++i) { - if (needsComma) { - writer.write(44); - } - if (indentFactor > 0) { - writer.write(10); - } - JSONObject.indent(writer, newIndent); - this.writeArrayAttempt(writer, indentFactor, newIndent, i); - needsComma = true; - } - if (indentFactor > 0) { - writer.write(10); - } - JSONObject.indent(writer, indent); - } - writer.write(93); - return writer; - } - catch (IOException e) { - throw new JSONException(e); - } - } - - private void writeArrayAttempt(Writer writer, int indentFactor, int indent, int i) { - try { - JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, indent); - } - catch (Exception e) { - throw new JSONException("Unable to write JSONArray value at index: " + i, e); - } - } - - public List toList() { - ArrayList results = new ArrayList(this.myArrayList.size()); - for (Object element : this.myArrayList) { - if (element == null || JSONObject.NULL.equals(element)) { - results.add(null); - continue; - } - if (element instanceof JSONArray) { - results.add(((JSONArray)element).toList()); - continue; - } - if (element instanceof JSONObject) { - results.add(((JSONObject)element).toMap()); - continue; - } - results.add(element); - } - return results; - } - - public boolean isEmpty() { - return this.myArrayList.isEmpty(); - } - - private void addAll(Collection collection, boolean wrap, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) { - this.myArrayList.ensureCapacity(this.myArrayList.size() + collection.size()); - if (wrap) { - for (Object o : collection) { - this.put(JSONObject.wrap(o, recursionDepth + 1, jsonParserConfiguration)); - } - } else { - for (Object o : collection) { - this.put(o); - } - } - } - - private void addAll(Iterable iter, boolean wrap) { - if (wrap) { - for (Object o : iter) { - this.put(JSONObject.wrap(o)); - } - } else { - for (Object o : iter) { - this.put(o); - } - } - } - - private void addAll(Object array, boolean wrap) throws JSONException { - this.addAll(array, wrap, 0); - } - - private void addAll(Object array, boolean wrap, int recursionDepth) { - this.addAll(array, wrap, recursionDepth, new JSONParserConfiguration()); - } - - private void addAll(Object array, boolean wrap, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) throws JSONException { - if (array.getClass().isArray()) { - int length = Array.getLength(array); - this.myArrayList.ensureCapacity(this.myArrayList.size() + length); - if (wrap) { - for (int i = 0; i < length; ++i) { - this.put(JSONObject.wrap(Array.get(array, i), recursionDepth + 1, jsonParserConfiguration)); - } - } else { - for (int i = 0; i < length; ++i) { - this.put(Array.get(array, i)); - } - } - } else if (array instanceof JSONArray) { - this.myArrayList.addAll(((JSONArray)array).myArrayList); - } else if (array instanceof Collection) { - this.addAll((Collection)array, wrap, recursionDepth, jsonParserConfiguration); - } else if (array instanceof Iterable) { - this.addAll((Iterable)array, wrap); - } else { - throw new JSONException("JSONArray initial value should be a string or collection or array."); - } - } - - private static JSONException wrongValueFormatException(int idx, String valueType, Object value, Throwable cause) { - if (value == null) { - return new JSONException("JSONArray[" + idx + "] is not a " + valueType + " (null).", cause); - } - if (value instanceof Map || value instanceof Iterable || value instanceof JSONObject) { - return new JSONException("JSONArray[" + idx + "] is not a " + valueType + " (" + value.getClass() + ").", cause); - } - return new JSONException("JSONArray[" + idx + "] is not a " + valueType + " (" + value.getClass() + " : " + value + ").", cause); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONException.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONException.java deleted file mode 100644 index 1afc7e7..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONException.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -public class JSONException -extends RuntimeException { - private static final long serialVersionUID = 0L; - - public JSONException(String message) { - super(message); - } - - public JSONException(String message, Throwable cause) { - super(message, cause); - } - - public JSONException(Throwable cause) { - super(cause.getMessage(), cause); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONML.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONML.java deleted file mode 100644 index 516bcbb..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONML.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONMLParserConfiguration; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.XML; -import de.maxhenkel.voicechat.org.json.XMLTokener; - -public class JSONML { - @Deprecated - public JSONML() { - } - - private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja, boolean keepStrings, int currentNestingDepth) throws JSONException { - return JSONML.parse(x, arrayForm, ja, keepStrings ? JSONMLParserConfiguration.KEEP_STRINGS : JSONMLParserConfiguration.ORIGINAL, currentNestingDepth); - } - - private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja, JSONMLParserConfiguration config, int currentNestingDepth) throws JSONException { - String closeTag = null; - JSONArray newja = null; - JSONObject newjo = null; - String tagName = null; - while (true) { - Object value; - if (!x.more()) { - throw x.syntaxError("Bad XML"); - } - Object token = x.nextContent(); - if (token == XML.LT) { - token = x.nextToken(); - if (token instanceof Character) { - if (token == XML.SLASH) { - token = x.nextToken(); - if (!(token instanceof String)) { - throw new JSONException("Expected a closing name instead of '" + token + "'."); - } - if (x.nextToken() != XML.GT) { - throw x.syntaxError("Misshaped close tag"); - } - return token; - } - if (token == XML.BANG) { - char c = x.next(); - if (c == '-') { - if (x.next() == '-') { - x.skipPast("-->"); - continue; - } - x.back(); - continue; - } - if (c == '[') { - token = x.nextToken(); - if ("CDATA".equals(token) && x.next() == '[') { - if (ja == null) continue; - ja.put(x.nextCDATA()); - continue; - } - throw x.syntaxError("Expected 'CDATA['"); - } - int i = 1; - do { - if ((token = x.nextMeta()) == null) { - throw x.syntaxError("Missing '>' after ' 0); - continue; - } - if (token == XML.QUEST) { - x.skipPast("?>"); - continue; - } - throw x.syntaxError("Misshaped tag"); - } - if (!(token instanceof String)) { - throw x.syntaxError("Bad tagName '" + token + "'."); - } - tagName = (String)token; - newja = new JSONArray(); - newjo = new JSONObject(); - if (arrayForm) { - newja.put(tagName); - if (ja != null) { - ja.put(newja); - } - } else { - newjo.put("tagName", tagName); - if (ja != null) { - ja.put(newjo); - } - } - token = null; - while (true) { - if (token == null) { - token = x.nextToken(); - } - if (token == null) { - throw x.syntaxError("Misshaped tag"); - } - if (!(token instanceof String)) break; - String attribute = (String)token; - if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) { - throw x.syntaxError("Reserved attribute."); - } - token = x.nextToken(); - if (token == XML.EQ) { - token = x.nextToken(); - if (!(token instanceof String)) { - throw x.syntaxError("Missing value"); - } - newjo.accumulate(attribute, config.isKeepStrings() ? (String)token : XML.stringToValue((String)token)); - token = null; - continue; - } - newjo.accumulate(attribute, ""); - } - if (arrayForm && newjo.length() > 0) { - newja.put(newjo); - } - if (token == XML.SLASH) { - if (x.nextToken() != XML.GT) { - throw x.syntaxError("Misshaped tag"); - } - if (ja != null) continue; - if (arrayForm) { - return newja; - } - return newjo; - } - if (token != XML.GT) { - throw x.syntaxError("Misshaped tag"); - } - if (currentNestingDepth == config.getMaxNestingDepth()) { - throw x.syntaxError("Maximum nesting depth of " + config.getMaxNestingDepth() + " reached"); - } - closeTag = (String)JSONML.parse(x, arrayForm, newja, config, currentNestingDepth + 1); - if (closeTag == null) continue; - if (!closeTag.equals(tagName)) { - throw x.syntaxError("Mismatched '" + tagName + "' and '" + closeTag + "'"); - } - tagName = null; - if (!arrayForm && newja.length() > 0) { - newjo.put("childNodes", newja); - } - if (ja != null) continue; - if (arrayForm) { - return newja; - } - return newjo; - } - if (ja == null) continue; - if (token instanceof String) { - String strToken = (String)token; - value = config.isKeepStrings() ? XML.unescape(strToken) : XML.stringToValue(strToken); - } else { - value = token; - } - ja.put(value); - } - } - - public static JSONArray toJSONArray(String string) throws JSONException { - return (JSONArray)JSONML.parse(new XMLTokener(string), true, null, JSONMLParserConfiguration.ORIGINAL, 0); - } - - public static JSONArray toJSONArray(String string, boolean keepStrings) throws JSONException { - return (JSONArray)JSONML.parse(new XMLTokener(string), true, null, keepStrings, 0); - } - - public static JSONArray toJSONArray(String string, JSONMLParserConfiguration config) throws JSONException { - return (JSONArray)JSONML.parse(new XMLTokener(string), true, null, config, 0); - } - - public static JSONArray toJSONArray(XMLTokener x, JSONMLParserConfiguration config) throws JSONException { - return (JSONArray)JSONML.parse(x, true, null, config, 0); - } - - public static JSONArray toJSONArray(XMLTokener x, boolean keepStrings) throws JSONException { - return (JSONArray)JSONML.parse(x, true, null, keepStrings, 0); - } - - public static JSONArray toJSONArray(XMLTokener x) throws JSONException { - return (JSONArray)JSONML.parse(x, true, null, false, 0); - } - - public static JSONObject toJSONObject(String string) throws JSONException { - return (JSONObject)JSONML.parse(new XMLTokener(string), false, null, false, 0); - } - - public static JSONObject toJSONObject(String string, boolean keepStrings) throws JSONException { - return (JSONObject)JSONML.parse(new XMLTokener(string), false, null, keepStrings, 0); - } - - public static JSONObject toJSONObject(String string, JSONMLParserConfiguration config) throws JSONException { - return (JSONObject)JSONML.parse(new XMLTokener(string), false, null, config, 0); - } - - public static JSONObject toJSONObject(XMLTokener x) throws JSONException { - return (JSONObject)JSONML.parse(x, false, null, false, 0); - } - - public static JSONObject toJSONObject(XMLTokener x, boolean keepStrings) throws JSONException { - return (JSONObject)JSONML.parse(x, false, null, keepStrings, 0); - } - - public static JSONObject toJSONObject(XMLTokener x, JSONMLParserConfiguration config) throws JSONException { - return (JSONObject)JSONML.parse(x, false, null, config, 0); - } - - public static String toString(JSONArray ja) throws JSONException { - int length; - int i; - StringBuilder sb = new StringBuilder(); - String tagName = ja.getString(0); - XML.noSpace(tagName); - tagName = XML.escape(tagName); - sb.append('<'); - sb.append(tagName); - Object object = ja.opt(1); - if (object instanceof JSONObject) { - i = 2; - JSONObject jo = (JSONObject)object; - for (String key : jo.keySet()) { - Object value = jo.opt(key); - XML.noSpace(key); - if (value == null) continue; - sb.append(' '); - sb.append(XML.escape(key)); - sb.append('='); - sb.append('\"'); - sb.append(XML.escape(value.toString())); - sb.append('\"'); - } - } else { - i = 1; - } - if (i >= (length = ja.length())) { - sb.append('/'); - sb.append('>'); - } else { - sb.append('>'); - do { - object = ja.get(i); - ++i; - if (object == null) continue; - if (object instanceof String) { - sb.append(XML.escape(object.toString())); - continue; - } - if (object instanceof JSONObject) { - sb.append(JSONML.toString((JSONObject)object)); - continue; - } - if (object instanceof JSONArray) { - sb.append(JSONML.toString((JSONArray)object)); - continue; - } - sb.append(object.toString()); - } while (i < length); - sb.append('<'); - sb.append('/'); - sb.append(tagName); - sb.append('>'); - } - return sb.toString(); - } - - public static String toString(JSONObject jo) throws JSONException { - StringBuilder sb = new StringBuilder(); - String tagName = jo.optString("tagName"); - if (tagName == null) { - return XML.escape(jo.toString()); - } - XML.noSpace(tagName); - tagName = XML.escape(tagName); - sb.append('<'); - sb.append(tagName); - for (String key : jo.keySet()) { - if ("tagName".equals(key) || "childNodes".equals(key)) continue; - XML.noSpace(key); - Object value = jo.opt(key); - if (value == null) continue; - sb.append(' '); - sb.append(XML.escape(key)); - sb.append('='); - sb.append('\"'); - sb.append(XML.escape(value.toString())); - sb.append('\"'); - } - JSONArray ja = jo.optJSONArray("childNodes"); - if (ja == null) { - sb.append('/'); - sb.append('>'); - } else { - sb.append('>'); - int length = ja.length(); - for (int i = 0; i < length; ++i) { - Object object = ja.get(i); - if (object == null) continue; - if (object instanceof String) { - sb.append(XML.escape(object.toString())); - continue; - } - if (object instanceof JSONObject) { - sb.append(JSONML.toString((JSONObject)object)); - continue; - } - if (object instanceof JSONArray) { - sb.append(JSONML.toString((JSONArray)object)); - continue; - } - sb.append(object.toString()); - } - sb.append('<'); - sb.append('/'); - sb.append(tagName); - sb.append('>'); - } - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONMLParserConfiguration.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONMLParserConfiguration.java deleted file mode 100644 index 6c65751..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONMLParserConfiguration.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.ParserConfiguration; - -public class JSONMLParserConfiguration -extends ParserConfiguration { - public static final int DEFAULT_MAXIMUM_NESTING_DEPTH = 512; - public static final JSONMLParserConfiguration ORIGINAL = new JSONMLParserConfiguration(); - public static final JSONMLParserConfiguration KEEP_STRINGS = new JSONMLParserConfiguration().withKeepStrings(true); - - public JSONMLParserConfiguration() { - this.maxNestingDepth = 512; - } - - protected JSONMLParserConfiguration(boolean keepStrings, int maxNestingDepth) { - super(keepStrings, maxNestingDepth); - } - - @Override - protected JSONMLParserConfiguration clone() { - return new JSONMLParserConfiguration(this.keepStrings, this.maxNestingDepth); - } - - public JSONMLParserConfiguration withKeepStrings(boolean newVal) { - return (JSONMLParserConfiguration)super.withKeepStrings(newVal); - } - - public JSONMLParserConfiguration withMaxNestingDepth(int maxNestingDepth) { - return (JSONMLParserConfiguration)super.withMaxNestingDepth(maxNestingDepth); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONObject.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONObject.java deleted file mode 100644 index aff7e1d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONObject.java +++ /dev/null @@ -1,1771 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONParserConfiguration; -import de.maxhenkel.voicechat.org.json.JSONPointer; -import de.maxhenkel.voicechat.org.json.JSONPointerException; -import de.maxhenkel.voicechat.org.json.JSONPropertyIgnore; -import de.maxhenkel.voicechat.org.json.JSONPropertyName; -import de.maxhenkel.voicechat.org.json.JSONString; -import de.maxhenkel.voicechat.org.json.JSONTokener; -import de.maxhenkel.voicechat.org.json.JSONWriter; -import de.maxhenkel.voicechat.org.json.StringBuilderWriter; -import java.io.Closeable; -import java.io.IOException; -import java.io.Writer; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; -import java.util.Set; -import java.util.regex.Pattern; - -public class JSONObject { - static final Pattern NUMBER_PATTERN = Pattern.compile("-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?"); - private final Map map; - public static final Object NULL = new Null(); - private static final Set EXCLUDED_RECORD_METHOD_NAMES = Collections.unmodifiableSet(new HashSet(Arrays.asList("get", "is", "set", "toString", "hashCode", "equals", "clone", "notify", "notifyAll", "wait"))); - - public Class getMapType() { - return this.map.getClass(); - } - - public JSONObject() { - this.map = new HashMap(); - } - - public JSONObject(JSONObject jo, String ... names) { - this(names.length); - for (int i = 0; i < names.length; ++i) { - try { - this.putOnce(names[i], jo.opt(names[i])); - continue; - } - catch (Exception exception) { - // empty catch block - } - } - } - - public JSONObject(JSONTokener x) throws JSONException { - this(x, x.getJsonParserConfiguration()); - } - - public JSONObject(JSONTokener x, JSONParserConfiguration jsonParserConfiguration) throws JSONException { - this(); - boolean isInitial; - boolean bl = isInitial = x.getPrevious() == '\u0000'; - if (x.nextClean() != '{') { - throw x.syntaxError("A JSONObject text must begin with '{'"); - } - while (!this.parseJSONObject(x, jsonParserConfiguration, isInitial)) { - } - } - - private boolean parseJSONObject(JSONTokener jsonTokener, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) { - boolean doneParsing = false; - char c = jsonTokener.nextClean(); - switch (c) { - case '\u0000': { - throw jsonTokener.syntaxError("A JSONObject text must end with '}'"); - } - case '}': { - if (isInitial && jsonParserConfiguration.isStrictMode() && jsonTokener.nextClean() != '\u0000') { - throw jsonTokener.syntaxError("Strict mode error: Unparsed characters found at end of input text"); - } - return true; - } - } - Object obj = jsonTokener.nextSimpleValue(c); - String key = obj.toString(); - JSONObject.checkKeyForStrictMode(jsonTokener, jsonParserConfiguration, obj); - c = jsonTokener.nextClean(); - if (c != ':') { - throw jsonTokener.syntaxError("Expected a ':' after a key"); - } - if (key != null) { - boolean keyExists; - boolean bl = keyExists = this.opt(key) != null; - if (keyExists && !jsonParserConfiguration.isOverwriteDuplicateKey()) { - throw jsonTokener.syntaxError("Duplicate key \"" + key + "\""); - } - Object value = jsonTokener.nextValue(); - if (value != null) { - this.put(key, value); - } - } - if (JSONObject.parseEndOfKeyValuePair(jsonTokener, jsonParserConfiguration, isInitial)) { - doneParsing = true; - } - return doneParsing; - } - - private static boolean parseEndOfKeyValuePair(JSONTokener jsonTokener, JSONParserConfiguration jsonParserConfiguration, boolean isInitial) { - switch (jsonTokener.nextClean()) { - case ';': { - if (!jsonParserConfiguration.isStrictMode()) break; - throw jsonTokener.syntaxError("Strict mode error: Invalid character ';' found"); - } - case ',': { - if (jsonTokener.nextClean() == '}') { - if (jsonParserConfiguration.isStrictMode()) { - throw jsonTokener.syntaxError("Strict mode error: Expected another object element"); - } - return true; - } - if (jsonTokener.end()) { - throw jsonTokener.syntaxError("A JSONObject text must end with '}'"); - } - jsonTokener.back(); - break; - } - case '}': { - if (isInitial && jsonParserConfiguration.isStrictMode() && jsonTokener.nextClean() != '\u0000') { - throw jsonTokener.syntaxError("Strict mode error: Unparsed characters found at end of input text"); - } - return true; - } - default: { - throw jsonTokener.syntaxError("Expected a ',' or '}'"); - } - } - return false; - } - - private static void checkKeyForStrictMode(JSONTokener jsonTokener, JSONParserConfiguration jsonParserConfiguration, Object obj) { - if (jsonParserConfiguration != null && jsonParserConfiguration.isStrictMode()) { - if (obj instanceof Boolean) { - throw jsonTokener.syntaxError(String.format("Strict mode error: key '%s' cannot be boolean", obj.toString())); - } - if (obj == NULL) { - throw jsonTokener.syntaxError(String.format("Strict mode error: key '%s' cannot be null", obj.toString())); - } - if (obj instanceof Number) { - throw jsonTokener.syntaxError(String.format("Strict mode error: key '%s' cannot be number", obj.toString())); - } - } - } - - public JSONObject(Map m) { - this(m, 0, new JSONParserConfiguration()); - } - - public JSONObject(Map m, JSONParserConfiguration jsonParserConfiguration) { - this(m, 0, jsonParserConfiguration); - } - - private JSONObject(Map m, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) { - if (recursionDepth > jsonParserConfiguration.getMaxNestingDepth()) { - throw new JSONException("JSONObject has reached recursion depth limit of " + jsonParserConfiguration.getMaxNestingDepth()); - } - if (m == null) { - this.map = new HashMap(); - } else { - this.map = new HashMap(m.size()); - for (Map.Entry e : m.entrySet()) { - if (e.getKey() == null) { - throw new NullPointerException("Null key."); - } - Object value = e.getValue(); - if (value == null && !jsonParserConfiguration.isUseNativeNulls()) continue; - JSONObject.testValidity(value); - this.map.put(String.valueOf(e.getKey()), JSONObject.wrap(value, recursionDepth + 1, jsonParserConfiguration)); - } - } - } - - public JSONObject(Object bean) { - this(); - this.populateMap(bean, new JSONParserConfiguration()); - } - - public JSONObject(Object bean, JSONParserConfiguration jsonParserConfiguration) { - this(); - this.populateMap(bean, jsonParserConfiguration); - } - - private JSONObject(Object bean, Set objectsRecord) { - this(); - this.populateMap(bean, objectsRecord, new JSONParserConfiguration()); - } - - public JSONObject(Object object, String ... names) { - this(names.length); - Class c = object.getClass(); - for (int i = 0; i < names.length; ++i) { - String name = names[i]; - try { - this.putOpt(name, c.getField(name).get(object)); - continue; - } - catch (Exception exception) { - // empty catch block - } - } - } - - public JSONObject(String source) throws JSONException { - this(source, new JSONParserConfiguration()); - } - - public JSONObject(String source, JSONParserConfiguration jsonParserConfiguration) throws JSONException { - this(new JSONTokener(source, jsonParserConfiguration), jsonParserConfiguration); - } - - public JSONObject(String baseName, Locale locale) throws JSONException { - this(); - ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader()); - Enumeration keys = bundle.getKeys(); - while (keys.hasMoreElements()) { - String key = keys.nextElement(); - if (key == null) continue; - String[] path = key.split("\\."); - int last = path.length - 1; - JSONObject target = this; - for (int i = 0; i < last; ++i) { - String segment = path[i]; - JSONObject nextTarget = target.optJSONObject(segment); - if (nextTarget == null) { - nextTarget = new JSONObject(); - target.put(segment, nextTarget); - } - target = nextTarget; - } - target.put(path[last], bundle.getString(key)); - } - } - - protected JSONObject(int initialCapacity) { - this.map = new HashMap(initialCapacity); - } - - public JSONObject accumulate(String key, Object value) throws JSONException { - JSONObject.testValidity(value); - Object object = this.opt(key); - if (object == null) { - this.put(key, value instanceof JSONArray ? new JSONArray().put(value) : value); - } else if (object instanceof JSONArray) { - ((JSONArray)object).put(value); - } else { - this.put(key, new JSONArray().put(object).put(value)); - } - return this; - } - - public JSONObject append(String key, Object value) throws JSONException { - JSONObject.testValidity(value); - Object object = this.opt(key); - if (object == null) { - this.put(key, new JSONArray().put(value)); - } else if (object instanceof JSONArray) { - this.put(key, ((JSONArray)object).put(value)); - } else { - throw JSONObject.wrongValueFormatException(key, "JSONArray", null, null); - } - return this; - } - - public static String doubleToString(double d) { - if (Double.isInfinite(d) || Double.isNaN(d)) { - return "null"; - } - String string = Double.toString(d); - if (string.indexOf(46) > 0 && string.indexOf(101) < 0 && string.indexOf(69) < 0) { - while (string.endsWith("0")) { - string = string.substring(0, string.length() - 1); - } - if (string.endsWith(".")) { - string = string.substring(0, string.length() - 1); - } - } - return string; - } - - public Object get(String key) throws JSONException { - if (key == null) { - throw new JSONException("Null key."); - } - Object object = this.opt(key); - if (object == null) { - throw new JSONException("JSONObject[" + JSONObject.quote(key) + "] not found."); - } - return object; - } - - public > E getEnum(Class clazz, String key) throws JSONException { - E val = this.optEnum(clazz, key); - if (val == null) { - throw JSONObject.wrongValueFormatException(key, "enum of type " + JSONObject.quote(clazz.getSimpleName()), this.opt(key), null); - } - return val; - } - - public boolean getBoolean(String key) throws JSONException { - Object object = this.get(key); - if (Boolean.FALSE.equals(object) || object instanceof String && "false".equalsIgnoreCase((String)object)) { - return false; - } - if (Boolean.TRUE.equals(object) || object instanceof String && "true".equalsIgnoreCase((String)object)) { - return true; - } - throw JSONObject.wrongValueFormatException(key, "Boolean", object, null); - } - - public BigInteger getBigInteger(String key) throws JSONException { - Object object = this.get(key); - BigInteger ret = JSONObject.objectToBigInteger(object, null); - if (ret != null) { - return ret; - } - throw JSONObject.wrongValueFormatException(key, "BigInteger", object, null); - } - - public BigDecimal getBigDecimal(String key) throws JSONException { - Object object = this.get(key); - BigDecimal ret = JSONObject.objectToBigDecimal(object, null); - if (ret != null) { - return ret; - } - throw JSONObject.wrongValueFormatException(key, "BigDecimal", object, null); - } - - public double getDouble(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof Number) { - return ((Number)object).doubleValue(); - } - try { - return Double.parseDouble(object.toString()); - } - catch (Exception e) { - throw JSONObject.wrongValueFormatException(key, "double", object, e); - } - } - - public float getFloat(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof Number) { - return ((Number)object).floatValue(); - } - try { - return Float.parseFloat(object.toString()); - } - catch (Exception e) { - throw JSONObject.wrongValueFormatException(key, "float", object, e); - } - } - - public Number getNumber(String key) throws JSONException { - Object object = this.get(key); - try { - if (object instanceof Number) { - return (Number)object; - } - return JSONObject.stringToNumber(object.toString()); - } - catch (Exception e) { - throw JSONObject.wrongValueFormatException(key, "number", object, e); - } - } - - public int getInt(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof Number) { - return ((Number)object).intValue(); - } - try { - return Integer.parseInt(object.toString()); - } - catch (Exception e) { - throw JSONObject.wrongValueFormatException(key, "int", object, e); - } - } - - public JSONArray getJSONArray(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof JSONArray) { - return (JSONArray)object; - } - throw JSONObject.wrongValueFormatException(key, "JSONArray", object, null); - } - - public JSONObject getJSONObject(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof JSONObject) { - return (JSONObject)object; - } - throw JSONObject.wrongValueFormatException(key, "JSONObject", object, null); - } - - public long getLong(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof Number) { - return ((Number)object).longValue(); - } - try { - return Long.parseLong(object.toString()); - } - catch (Exception e) { - throw JSONObject.wrongValueFormatException(key, "long", object, e); - } - } - - public static String[] getNames(JSONObject jo) { - if (jo.isEmpty()) { - return null; - } - return jo.keySet().toArray(new String[jo.length()]); - } - - public static String[] getNames(Object object) { - if (object == null) { - return null; - } - Class klass = object.getClass(); - Field[] fields = klass.getFields(); - int length = fields.length; - if (length == 0) { - return null; - } - String[] names = new String[length]; - for (int i = 0; i < length; ++i) { - names[i] = fields[i].getName(); - } - return names; - } - - public String getString(String key) throws JSONException { - Object object = this.get(key); - if (object instanceof String) { - return (String)object; - } - throw JSONObject.wrongValueFormatException(key, "string", object, null); - } - - public boolean has(String key) { - return this.map.containsKey(key); - } - - public JSONObject increment(String key) throws JSONException { - Object value = this.opt(key); - if (value == null) { - this.put(key, 1); - } else if (value instanceof Integer) { - this.put(key, (Integer)value + 1); - } else if (value instanceof Long) { - this.put(key, (Long)value + 1L); - } else if (value instanceof BigInteger) { - this.put(key, ((BigInteger)value).add(BigInteger.ONE)); - } else if (value instanceof Float) { - this.put(key, ((Float)value).floatValue() + 1.0f); - } else if (value instanceof Double) { - this.put(key, (Double)value + 1.0); - } else if (value instanceof BigDecimal) { - this.put(key, ((BigDecimal)value).add(BigDecimal.ONE)); - } else { - throw new JSONException("Unable to increment [" + JSONObject.quote(key) + "]."); - } - return this; - } - - public boolean isNull(String key) { - return NULL.equals(this.opt(key)); - } - - public Iterator keys() { - return this.keySet().iterator(); - } - - public Set keySet() { - return this.map.keySet(); - } - - protected Set> entrySet() { - return this.map.entrySet(); - } - - public int length() { - return this.map.size(); - } - - public void clear() { - this.map.clear(); - } - - public boolean isEmpty() { - return this.map.isEmpty(); - } - - public JSONArray names() { - if (this.map.isEmpty()) { - return null; - } - return new JSONArray((Collection)this.map.keySet()); - } - - public static String numberToString(Number number) throws JSONException { - if (number == null) { - throw new JSONException("Null pointer"); - } - JSONObject.testValidity(number); - String string = number.toString(); - if (string.indexOf(46) > 0 && string.indexOf(101) < 0 && string.indexOf(69) < 0) { - while (string.endsWith("0")) { - string = string.substring(0, string.length() - 1); - } - if (string.endsWith(".")) { - string = string.substring(0, string.length() - 1); - } - } - return string; - } - - public Object opt(String key) { - return key == null ? null : this.map.get(key); - } - - public > E optEnum(Class clazz, String key) { - return this.optEnum(clazz, key, null); - } - - public > E optEnum(Class clazz, String key, E defaultValue) { - try { - Object val = this.opt(key); - if (NULL.equals(val)) { - return defaultValue; - } - if (clazz.isAssignableFrom(val.getClass())) { - Enum myE = (Enum)val; - return (E)myE; - } - return Enum.valueOf(clazz, val.toString()); - } - catch (IllegalArgumentException e) { - return defaultValue; - } - catch (NullPointerException e) { - return defaultValue; - } - } - - public boolean optBoolean(String key) { - return this.optBoolean(key, false); - } - - public boolean optBoolean(String key, boolean defaultValue) { - Object val = this.opt(key); - if (NULL.equals(val)) { - return defaultValue; - } - if (val instanceof Boolean) { - return (Boolean)val; - } - try { - return this.getBoolean(key); - } - catch (Exception e) { - return defaultValue; - } - } - - public Boolean optBooleanObject(String key) { - return this.optBooleanObject(key, false); - } - - public Boolean optBooleanObject(String key, Boolean defaultValue) { - Object val = this.opt(key); - if (NULL.equals(val)) { - return defaultValue; - } - if (val instanceof Boolean) { - return (boolean)((Boolean)val); - } - try { - return this.getBoolean(key); - } - catch (Exception e) { - return defaultValue; - } - } - - public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) { - Object val = this.opt(key); - return JSONObject.objectToBigDecimal(val, defaultValue); - } - - static BigDecimal objectToBigDecimal(Object val, BigDecimal defaultValue) { - return JSONObject.objectToBigDecimal(val, defaultValue, true); - } - - static BigDecimal objectToBigDecimal(Object val, BigDecimal defaultValue, boolean exact) { - if (NULL.equals(val)) { - return defaultValue; - } - if (val instanceof BigDecimal) { - return (BigDecimal)val; - } - if (val instanceof BigInteger) { - return new BigDecimal((BigInteger)val); - } - if (val instanceof Double || val instanceof Float) { - if (!JSONObject.numberIsFinite((Number)val)) { - return defaultValue; - } - if (exact) { - return new BigDecimal(((Number)val).doubleValue()); - } - return new BigDecimal(val.toString()); - } - if (val instanceof Long || val instanceof Integer || val instanceof Short || val instanceof Byte) { - return new BigDecimal(((Number)val).longValue()); - } - try { - return new BigDecimal(val.toString()); - } - catch (Exception e) { - return defaultValue; - } - } - - public BigInteger optBigInteger(String key, BigInteger defaultValue) { - Object val = this.opt(key); - return JSONObject.objectToBigInteger(val, defaultValue); - } - - static BigInteger objectToBigInteger(Object val, BigInteger defaultValue) { - if (NULL.equals(val)) { - return defaultValue; - } - if (val instanceof BigInteger) { - return (BigInteger)val; - } - if (val instanceof BigDecimal) { - return ((BigDecimal)val).toBigInteger(); - } - if (val instanceof Double || val instanceof Float) { - if (!JSONObject.numberIsFinite((Number)val)) { - return defaultValue; - } - return BigDecimal.valueOf(((Number)val).doubleValue()).toBigInteger(); - } - if (val instanceof Long || val instanceof Integer || val instanceof Short || val instanceof Byte) { - return BigInteger.valueOf(((Number)val).longValue()); - } - try { - String valStr = val.toString(); - if (JSONObject.isDecimalNotation(valStr)) { - return new BigDecimal(valStr).toBigInteger(); - } - return new BigInteger(valStr); - } - catch (Exception e) { - return defaultValue; - } - } - - public double optDouble(String key) { - return this.optDouble(key, Double.NaN); - } - - public double optDouble(String key, double defaultValue) { - Number val = this.optNumber(key); - if (val == null) { - return defaultValue; - } - return val.doubleValue(); - } - - public Double optDoubleObject(String key) { - return this.optDoubleObject(key, Double.NaN); - } - - public Double optDoubleObject(String key, Double defaultValue) { - Number val = this.optNumber(key); - if (val == null) { - return defaultValue; - } - return val.doubleValue(); - } - - public float optFloat(String key) { - return this.optFloat(key, Float.NaN); - } - - public float optFloat(String key, float defaultValue) { - Number val = this.optNumber(key); - if (val == null) { - return defaultValue; - } - return val.floatValue(); - } - - public Float optFloatObject(String key) { - return this.optFloatObject(key, Float.valueOf(Float.NaN)); - } - - public Float optFloatObject(String key, Float defaultValue) { - Number val = this.optNumber(key); - if (val == null) { - return defaultValue; - } - return Float.valueOf(val.floatValue()); - } - - public int optInt(String key) { - return this.optInt(key, 0); - } - - public int optInt(String key, int defaultValue) { - Number val = this.optNumber(key, null); - if (val == null) { - return defaultValue; - } - return val.intValue(); - } - - public Integer optIntegerObject(String key) { - return this.optIntegerObject(key, 0); - } - - public Integer optIntegerObject(String key, Integer defaultValue) { - Number val = this.optNumber(key, null); - if (val == null) { - return defaultValue; - } - return val.intValue(); - } - - public JSONArray optJSONArray(String key) { - return this.optJSONArray(key, null); - } - - public JSONArray optJSONArray(String key, JSONArray defaultValue) { - Object object = this.opt(key); - return object instanceof JSONArray ? (JSONArray)object : defaultValue; - } - - public JSONObject optJSONObject(String key) { - return this.optJSONObject(key, null); - } - - public JSONObject optJSONObject(String key, JSONObject defaultValue) { - Object object = this.opt(key); - return object instanceof JSONObject ? (JSONObject)object : defaultValue; - } - - public long optLong(String key) { - return this.optLong(key, 0L); - } - - public long optLong(String key, long defaultValue) { - Number val = this.optNumber(key, null); - if (val == null) { - return defaultValue; - } - return val.longValue(); - } - - public Long optLongObject(String key) { - return this.optLongObject(key, 0L); - } - - public Long optLongObject(String key, Long defaultValue) { - Number val = this.optNumber(key, null); - if (val == null) { - return defaultValue; - } - return val.longValue(); - } - - public Number optNumber(String key) { - return this.optNumber(key, null); - } - - public Number optNumber(String key, Number defaultValue) { - Object val = this.opt(key); - if (NULL.equals(val)) { - return defaultValue; - } - if (val instanceof Number) { - return (Number)val; - } - try { - return JSONObject.stringToNumber(val.toString()); - } - catch (Exception e) { - return defaultValue; - } - } - - public String optString(String key) { - return this.optString(key, ""); - } - - public String optString(String key, String defaultValue) { - Object object = this.opt(key); - return NULL.equals(object) ? defaultValue : object.toString(); - } - - private void populateMap(Object bean, JSONParserConfiguration jsonParserConfiguration) { - this.populateMap(bean, Collections.newSetFromMap(new IdentityHashMap()), jsonParserConfiguration); - } - - private void populateMap(Object bean, Set objectsRecord, JSONParserConfiguration jsonParserConfiguration) { - Method[] methods; - Class klass = bean.getClass(); - boolean isRecord = JSONObject.isRecordType(klass); - for (Method method : methods = JSONObject.getMethods(klass)) { - String key; - if (!JSONObject.isValidMethod(method) || (key = JSONObject.getKeyNameFromMethod(method, isRecord)) == null || key.isEmpty()) continue; - this.processMethod(bean, objectsRecord, jsonParserConfiguration, method, key); - } - } - - private void processMethod(Object bean, Set objectsRecord, JSONParserConfiguration jsonParserConfiguration, Method method, String key) { - try { - Object result = method.invoke(bean, new Object[0]); - if (result != null || jsonParserConfiguration.isUseNativeNulls()) { - if (objectsRecord.contains(result)) { - throw JSONObject.recursivelyDefinedObjectException(key); - } - objectsRecord.add(result); - JSONObject.testValidity(result); - this.map.put(key, JSONObject.wrap(result, objectsRecord)); - objectsRecord.remove(result); - JSONObject.closeClosable(result); - } - } - catch (IllegalAccessException illegalAccessException) { - } - catch (IllegalArgumentException illegalArgumentException) { - } - catch (InvocationTargetException invocationTargetException) { - // empty catch block - } - } - - private static boolean isRecordType(Class klass) { - try { - Method isRecordMethod = Class.class.getMethod("isRecord", new Class[0]); - return (Boolean)isRecordMethod.invoke(klass, new Object[0]); - } - catch (NoSuchMethodException e) { - return false; - } - catch (Exception e) { - return false; - } - } - - private static Method[] getMethods(Class klass) { - boolean includeSuperClass = klass.getClassLoader() != null; - return includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods(); - } - - private static boolean isValidMethodName(String name) { - return !"getClass".equals(name) && !"getDeclaringClass".equals(name); - } - - private static String getKeyNameFromMethod(Method method, boolean isRecordType) { - String key; - int forcedNameDepth; - int ignoreDepth = JSONObject.getAnnotationDepth(method, JSONPropertyIgnore.class); - if (ignoreDepth > 0 && ((forcedNameDepth = JSONObject.getAnnotationDepth(method, JSONPropertyName.class)) < 0 || ignoreDepth <= forcedNameDepth)) { - return null; - } - JSONPropertyName annotation = JSONObject.getAnnotation(method, JSONPropertyName.class); - if (JSONObject.annotationValueNotEmpty(annotation)) { - return annotation.value(); - } - String name = method.getName(); - if (name.startsWith("get") && name.length() > 3) { - key = name.substring(3); - } else if (name.startsWith("is") && name.length() > 2) { - key = name.substring(2); - } else { - if (isRecordType && JSONObject.isRecordStyleAccessor(name, method)) { - return name; - } - return null; - } - if (key.isEmpty() || Character.isLowerCase(key.charAt(0))) { - return null; - } - if (key.length() == 1) { - key = key.toLowerCase(Locale.ROOT); - } else if (!Character.isUpperCase(key.charAt(1))) { - key = key.substring(0, 1).toLowerCase(Locale.ROOT) + key.substring(1); - } - return key; - } - - private static boolean isRecordStyleAccessor(String methodName, Method method) { - if (methodName.isEmpty() || !Character.isLowerCase(methodName.charAt(0))) { - return false; - } - if (EXCLUDED_RECORD_METHOD_NAMES.contains(methodName)) { - return false; - } - Class declaringClass = method.getDeclaringClass(); - if (declaringClass == null || declaringClass == Object.class) { - return false; - } - if (Enum.class.isAssignableFrom(declaringClass) || Number.class.isAssignableFrom(declaringClass)) { - return false; - } - String className = declaringClass.getName(); - return !className.startsWith("java.") && !className.startsWith("javax."); - } - - private static boolean annotationValueNotEmpty(JSONPropertyName annotation) { - return annotation != null && annotation.value() != null && !annotation.value().isEmpty(); - } - - private static boolean isValidMethod(Method method) { - int modifiers = method.getModifiers(); - return Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && method.getParameterTypes().length == 0 && !method.isBridge() && method.getReturnType() != Void.TYPE && JSONObject.isValidMethodName(method.getName()); - } - - private static void closeClosable(Object input) { - if (input instanceof Closeable) { - try { - ((Closeable)input).close(); - } - catch (IOException iOException) { - // empty catch block - } - } - } - - private static A getAnnotation(Method m, Class annotationClass) { - if (m == null || annotationClass == null) { - return null; - } - if (m.isAnnotationPresent(annotationClass)) { - return m.getAnnotation(annotationClass); - } - Class c = m.getDeclaringClass(); - if (c.getSuperclass() == null) { - return null; - } - for (Class i : c.getInterfaces()) { - try { - Method im = i.getMethod(m.getName(), m.getParameterTypes()); - return JSONObject.getAnnotation(im, annotationClass); - } - catch (SecurityException securityException) { - } - catch (NoSuchMethodException noSuchMethodException) { - // empty catch block - } - } - if (Object.class.equals(c.getSuperclass())) { - return null; - } - try { - return JSONObject.getAnnotation(c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()), annotationClass); - } - catch (SecurityException ex) { - return null; - } - catch (NoSuchMethodException ex) { - return null; - } - } - - private static int getAnnotationDepth(Method m, Class annotationClass) { - if (m == null || annotationClass == null) { - return -1; - } - if (m.isAnnotationPresent(annotationClass)) { - return 1; - } - Class c = m.getDeclaringClass(); - if (c.getSuperclass() == null) { - return -1; - } - for (Class i : c.getInterfaces()) { - try { - Method im = i.getMethod(m.getName(), m.getParameterTypes()); - int d = JSONObject.getAnnotationDepth(im, annotationClass); - if (d <= 0) continue; - return d + 1; - } - catch (SecurityException securityException) { - } - catch (NoSuchMethodException noSuchMethodException) { - // empty catch block - } - } - if (Object.class.equals(c.getSuperclass())) { - return -1; - } - try { - int d = JSONObject.getAnnotationDepth(c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()), annotationClass); - if (d > 0) { - return d + 1; - } - return -1; - } - catch (SecurityException ex) { - return -1; - } - catch (NoSuchMethodException ex) { - return -1; - } - } - - public JSONObject put(String key, boolean value) throws JSONException { - return this.put(key, value ? Boolean.TRUE : Boolean.FALSE); - } - - public JSONObject put(String key, Collection value) throws JSONException { - return this.put(key, new JSONArray(value)); - } - - public JSONObject put(String key, double value) throws JSONException { - return this.put(key, (Object)value); - } - - public JSONObject put(String key, float value) throws JSONException { - return this.put(key, Float.valueOf(value)); - } - - public JSONObject put(String key, int value) throws JSONException { - return this.put(key, (Object)value); - } - - public JSONObject put(String key, long value) throws JSONException { - return this.put(key, (Object)value); - } - - public JSONObject put(String key, Map value) throws JSONException { - return this.put(key, new JSONObject(value)); - } - - public JSONObject put(String key, Object value) throws JSONException { - if (key == null) { - throw new NullPointerException("Null key."); - } - if (value != null) { - JSONObject.testValidity(value); - this.map.put(key, value); - } else { - this.remove(key); - } - return this; - } - - public JSONObject putOnce(String key, Object value) throws JSONException { - if (key != null && value != null) { - if (this.opt(key) != null) { - throw new JSONException("Duplicate key \"" + key + "\""); - } - return this.put(key, value); - } - return this; - } - - public JSONObject putOpt(String key, Object value) throws JSONException { - if (key != null && value != null) { - return this.put(key, value); - } - return this; - } - - public Object query(String jsonPointer) { - return this.query(new JSONPointer(jsonPointer)); - } - - public Object query(JSONPointer jsonPointer) { - return jsonPointer.queryFrom(this); - } - - public Object optQuery(String jsonPointer) { - return this.optQuery(new JSONPointer(jsonPointer)); - } - - public Object optQuery(JSONPointer jsonPointer) { - try { - return jsonPointer.queryFrom(this); - } - catch (JSONPointerException e) { - return null; - } - } - - public static String quote(String string) { - if (string == null || string.isEmpty()) { - return "\"\""; - } - StringBuilderWriter sw = new StringBuilderWriter(string.length() + 2); - try { - return JSONObject.quote(string, sw).toString(); - } - catch (IOException ignored) { - return ""; - } - } - - public static Writer quote(String string, Writer w) throws IOException { - if (string == null || string.isEmpty()) { - w.write("\"\""); - return w; - } - char c = '\u0000'; - int len = string.length(); - w.write(34); - block9: for (int i = 0; i < len; ++i) { - char b = c; - c = string.charAt(i); - switch (c) { - case '\"': - case '\\': { - w.write(92); - w.write(c); - continue block9; - } - case '/': { - if (b == '<') { - w.write(92); - } - w.write(c); - continue block9; - } - case '\b': { - w.write("\\b"); - continue block9; - } - case '\t': { - w.write("\\t"); - continue block9; - } - case '\n': { - w.write("\\n"); - continue block9; - } - case '\f': { - w.write("\\f"); - continue block9; - } - case '\r': { - w.write("\\r"); - continue block9; - } - default: { - JSONObject.writeAsHex(w, c); - } - } - } - w.write(34); - return w; - } - - private static void writeAsHex(Writer w, char c) throws IOException { - if (c < ' ' || c >= '\u0080' && c < '\u00a0' || c >= '\u2000' && c < '\u2100') { - w.write("\\u"); - String hhhh = Integer.toHexString(c); - w.write("0000", 0, 4 - hhhh.length()); - w.write(hhhh); - } else { - w.write(c); - } - } - - public Object remove(String key) { - return this.map.remove(key); - } - - public boolean similar(Object other) { - try { - if (!(other instanceof JSONObject)) { - return false; - } - if (!this.keySet().equals(((JSONObject)other).keySet())) { - return false; - } - return this.checkSimilarEntries(other); - } - catch (Exception e) { - return false; - } - } - - private boolean checkSimilarEntries(Object other) { - for (Map.Entry entry : this.entrySet()) { - Object valueOther; - String name = entry.getKey(); - Object valueThis = entry.getValue(); - if (valueThis == (valueOther = ((JSONObject)other).get(name))) continue; - if (valueThis == null) { - return false; - } - if (this.checkObjectType(valueThis, valueOther)) continue; - return false; - } - return true; - } - - private boolean checkObjectType(Object valueThis, Object valueOther) { - if (valueThis instanceof JSONObject) { - return ((JSONObject)valueThis).similar(valueOther); - } - if (valueThis instanceof JSONArray) { - return ((JSONArray)valueThis).similar(valueOther); - } - if (valueThis instanceof Number && valueOther instanceof Number) { - return JSONObject.isNumberSimilar((Number)valueThis, (Number)valueOther); - } - if (valueThis instanceof JSONString && valueOther instanceof JSONString) { - return ((JSONString)valueThis).toJSONString().equals(((JSONString)valueOther).toJSONString()); - } - return valueThis.equals(valueOther); - } - - static boolean isNumberSimilar(Number l, Number r) { - if (!JSONObject.numberIsFinite(l) || !JSONObject.numberIsFinite(r)) { - return false; - } - if (l.getClass().equals(r.getClass()) && l instanceof Comparable) { - int compareTo = ((Comparable)((Object)l)).compareTo(r); - return compareTo == 0; - } - BigDecimal lBigDecimal = JSONObject.objectToBigDecimal(l, null, false); - BigDecimal rBigDecimal = JSONObject.objectToBigDecimal(r, null, false); - if (lBigDecimal == null || rBigDecimal == null) { - return false; - } - return lBigDecimal.compareTo(rBigDecimal) == 0; - } - - private static boolean numberIsFinite(Number n) { - if (n instanceof Double && (((Double)n).isInfinite() || ((Double)n).isNaN())) { - return false; - } - return !(n instanceof Float) || !((Float)n).isInfinite() && !((Float)n).isNaN(); - } - - protected static boolean isDecimalNotation(String val) { - return val.indexOf(46) > -1 || val.indexOf(101) > -1 || val.indexOf(69) > -1 || "-0".equals(val); - } - - public static Object stringToValue(String string) { - if ("".equals(string)) { - return string; - } - if ("true".equalsIgnoreCase(string)) { - return Boolean.TRUE; - } - if ("false".equalsIgnoreCase(string)) { - return Boolean.FALSE; - } - if ("null".equalsIgnoreCase(string)) { - return NULL; - } - char initial = string.charAt(0); - if (initial >= '0' && initial <= '9' || initial == '-') { - try { - return JSONObject.stringToNumber(string); - } - catch (Exception exception) { - // empty catch block - } - } - return string; - } - - protected static Number stringToNumber(String val) throws NumberFormatException { - char initial = val.charAt(0); - if (initial >= '0' && initial <= '9' || initial == '-') { - if (JSONObject.isDecimalNotation(val)) { - return JSONObject.getNumber(val, initial); - } - JSONObject.checkForInvalidNumberFormat(val, initial); - BigInteger bi = new BigInteger(val); - if (bi.bitLength() <= 31) { - return bi.intValue(); - } - if (bi.bitLength() <= 63) { - return bi.longValue(); - } - return bi; - } - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - - private static void checkForInvalidNumberFormat(String val, char initial) { - if (initial == '0' && val.length() > 1) { - char at1 = val.charAt(1); - if (at1 >= '0' && at1 <= '9') { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - } else if (initial == '-' && val.length() > 2) { - char at1 = val.charAt(1); - char at2 = val.charAt(2); - if (at1 == '0' && at2 >= '0' && at2 <= '9') { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - } - } - - private static Number getNumber(String val, char initial) { - try { - BigDecimal bd = new BigDecimal(val); - if (initial == '-' && BigDecimal.ZERO.compareTo(bd) == 0) { - return -0.0; - } - return bd; - } - catch (NumberFormatException retryAsDouble) { - try { - Double d = Double.valueOf(val); - if (d.isNaN() || d.isInfinite()) { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - return d; - } - catch (NumberFormatException ignore) { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - } - } - - public static void testValidity(Object o) throws JSONException { - if (o instanceof Number && !JSONObject.numberIsFinite((Number)o)) { - throw new JSONException("JSON does not allow non-finite numbers."); - } - } - - public JSONArray toJSONArray(JSONArray names) throws JSONException { - if (names == null || names.isEmpty()) { - return null; - } - JSONArray ja = new JSONArray(); - for (int i = 0; i < names.length(); ++i) { - ja.put(this.opt(names.getString(i))); - } - return ja; - } - - public String toString() { - try { - return this.toString(0); - } - catch (Exception e) { - return null; - } - } - - public String toString(int indentFactor) throws JSONException { - int initialSize = this.map.size() * 6; - StringBuilderWriter w = new StringBuilderWriter(Math.max(initialSize, 16)); - return this.write(w, indentFactor, 0).toString(); - } - - public static String valueToString(Object value) throws JSONException { - return JSONWriter.valueToString(value); - } - - public static Object wrap(Object object) { - return JSONObject.wrap(object, null); - } - - static Object wrap(Object object, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) { - return JSONObject.wrap(object, null, recursionDepth, jsonParserConfiguration); - } - - private static Object wrap(Object object, Set objectsRecord) { - return JSONObject.wrap(object, objectsRecord, 0, new JSONParserConfiguration()); - } - - private static Object wrap(Object object, Set objectsRecord, int recursionDepth, JSONParserConfiguration jsonParserConfiguration) { - try { - String objectPackageName; - if (NULL.equals(object)) { - return NULL; - } - if (object instanceof JSONObject || object instanceof JSONArray || object instanceof JSONString || object instanceof String || object instanceof Byte || object instanceof Character || object instanceof Short || object instanceof Integer || object instanceof Long || object instanceof Boolean || object instanceof Float || object instanceof Double || object instanceof BigInteger || object instanceof BigDecimal || object instanceof Enum) { - return object; - } - if (object instanceof Collection) { - Collection coll = (Collection)object; - return new JSONArray(coll, recursionDepth, jsonParserConfiguration); - } - if (object.getClass().isArray()) { - return new JSONArray(object); - } - if (object instanceof Map) { - Map map = (Map)object; - return new JSONObject(map, recursionDepth, jsonParserConfiguration); - } - Package objectPackage = object.getClass().getPackage(); - String string = objectPackageName = objectPackage != null ? objectPackage.getName() : ""; - if (objectPackageName.startsWith("java.") || objectPackageName.startsWith("javax.") || object.getClass().getClassLoader() == null) { - return object.toString(); - } - if (objectsRecord != null) { - return new JSONObject(object, objectsRecord); - } - return new JSONObject(object); - } - catch (JSONException exception) { - throw exception; - } - catch (Exception exception) { - return null; - } - } - - public Writer write(Writer writer) throws JSONException { - return this.write(writer, 0, 0); - } - - static final Writer writeValue(Writer writer, Object value, int indentFactor, int indent) throws JSONException, IOException { - if (value == null || value.equals(null)) { - writer.write("null"); - } else if (value instanceof JSONString) { - JSONObject.processJsonStringToWriteValue(writer, value); - } else { - if (value instanceof String) { - JSONObject.quote(value.toString(), writer); - return writer; - } - if (value instanceof Number) { - JSONObject.processNumberToWriteValue(writer, (Number)value); - } else if (value instanceof Boolean) { - writer.write(value.toString()); - } else if (value instanceof Enum) { - writer.write(JSONObject.quote(((Enum)value).name())); - } else if (value instanceof JSONObject) { - ((JSONObject)value).write(writer, indentFactor, indent); - } else if (value instanceof JSONArray) { - ((JSONArray)value).write(writer, indentFactor, indent); - } else if (value instanceof Map) { - Map map = (Map)value; - new JSONObject(map).write(writer, indentFactor, indent); - } else if (value instanceof Collection) { - Collection coll = (Collection)value; - new JSONArray(coll).write(writer, indentFactor, indent); - } else if (value.getClass().isArray()) { - new JSONArray(value).write(writer, indentFactor, indent); - } else { - JSONObject.quote(value.toString(), writer); - } - } - return writer; - } - - private static void processJsonStringToWriteValue(Writer writer, Object value) throws IOException { - String o; - try { - o = ((JSONString)value).toJSONString(); - } - catch (Exception e) { - throw new JSONException(e); - } - writer.write(o != null ? o.toString() : JSONObject.quote(value.toString())); - } - - private static void processNumberToWriteValue(Writer writer, Number value) throws IOException { - String numberAsString = JSONObject.numberToString(value); - if (NUMBER_PATTERN.matcher(numberAsString).matches()) { - writer.write(numberAsString); - } else { - JSONObject.quote(numberAsString, writer); - } - } - - static final void indent(Writer writer, int indent) throws IOException { - for (int i = 0; i < indent; ++i) { - writer.write(32); - } - } - - public Writer write(Writer writer, int indentFactor, int indent) throws JSONException { - try { - boolean needsComma = false; - int length = this.length(); - writer.write(123); - if (length == 1) { - Map.Entry entry = this.entrySet().iterator().next(); - String key = entry.getKey(); - writer.write(JSONObject.quote(key)); - writer.write(58); - if (indentFactor > 0) { - writer.write(32); - } - JSONObject.attemptWriteValue(writer, indentFactor, indent, entry, key); - } else if (length != 0) { - this.writeContent(writer, indentFactor, indent, needsComma); - } - writer.write(125); - return writer; - } - catch (IOException exception) { - throw new JSONException(exception); - } - } - - private void writeContent(Writer writer, int indentFactor, int indent, boolean needsComma) throws IOException { - int newIndent = indent + indentFactor; - for (Map.Entry entry : this.entrySet()) { - if (needsComma) { - writer.write(44); - } - if (indentFactor > 0) { - writer.write(10); - } - JSONObject.indent(writer, newIndent); - String key = entry.getKey(); - writer.write(JSONObject.quote(key)); - writer.write(58); - if (indentFactor > 0) { - writer.write(32); - } - JSONObject.attemptWriteValue(writer, indentFactor, newIndent, entry, key); - needsComma = true; - } - if (indentFactor > 0) { - writer.write(10); - } - JSONObject.indent(writer, indent); - } - - private static void attemptWriteValue(Writer writer, int indentFactor, int indent, Map.Entry entry, String key) { - try { - JSONObject.writeValue(writer, entry.getValue(), indentFactor, indent); - } - catch (Exception e) { - throw new JSONException("Unable to write JSONObject value for key: " + key, e); - } - } - - public Map toMap() { - HashMap results = new HashMap(); - for (Map.Entry entry : this.entrySet()) { - Object value = entry.getValue() == null || NULL.equals(entry.getValue()) ? null : (entry.getValue() instanceof JSONObject ? ((JSONObject)entry.getValue()).toMap() : (entry.getValue() instanceof JSONArray ? ((JSONArray)entry.getValue()).toList() : entry.getValue())); - results.put(entry.getKey(), value); - } - return results; - } - - private static JSONException wrongValueFormatException(String key, String valueType, Object value, Throwable cause) { - if (value == null) { - return new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a " + valueType + " (null).", cause); - } - if (value instanceof Map || value instanceof Iterable || value instanceof JSONObject) { - return new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a " + valueType + " (" + value.getClass() + ").", cause); - } - return new JSONException("JSONObject[" + JSONObject.quote(key) + "] is not a " + valueType + " (" + value.getClass() + " : " + value + ").", cause); - } - - private static JSONException recursivelyDefinedObjectException(String key) { - return new JSONException("JavaBean object contains recursively defined member variable of key " + JSONObject.quote(key)); - } - - private Class getRawType(Type type) { - if (type instanceof Class) { - return (Class)type; - } - if (type instanceof ParameterizedType) { - return (Class)((ParameterizedType)type).getRawType(); - } - if (type instanceof GenericArrayType) { - return Object[].class; - } - return Object.class; - } - - private Type getElementType(Type type) { - if (type instanceof ParameterizedType) { - Type[] args = ((ParameterizedType)type).getActualTypeArguments(); - return args.length > 0 ? args[0] : Object.class; - } - return Object.class; - } - - private Type[] getMapTypes(Type type) { - Type[] args; - if (type instanceof ParameterizedType && (args = ((ParameterizedType)type).getActualTypeArguments()).length == 2) { - return args; - } - return new Type[]{Object.class, Object.class}; - } - - public static T fromJson(String jsonString, Class clazz) { - JSONObject jsonObject = new JSONObject(jsonString); - return jsonObject.fromJson(clazz); - } - - public T fromJson(Class clazz) { - try { - T obj = clazz.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]); - for (Field field : clazz.getDeclaredFields()) { - field.setAccessible(true); - String fieldName = field.getName(); - if (!this.has(fieldName)) continue; - Object value = this.get(fieldName); - Type fieldType = field.getGenericType(); - Object convertedValue = this.convertValue(value, fieldType); - field.set(obj, convertedValue); - } - return obj; - } - catch (NoSuchMethodException e) { - throw new JSONException("No no-arg constructor for class: " + clazz.getName(), e); - } - catch (Exception e) { - throw new JSONException("Failed to instantiate or set field for class: " + clazz.getName(), e); - } - } - - private Object convertValue(Object value, Type targetType) throws JSONException { - if (value == null) { - return null; - } - Class rawType = this.getRawType(targetType); - if (rawType.isAssignableFrom(value.getClass())) { - return value; - } - if (rawType == Integer.TYPE || rawType == Integer.class) { - return ((Number)value).intValue(); - } - if (rawType == Double.TYPE || rawType == Double.class) { - return ((Number)value).doubleValue(); - } - if (rawType == Float.TYPE || rawType == Float.class) { - return Float.valueOf(((Number)value).floatValue()); - } - if (rawType == Long.TYPE || rawType == Long.class) { - return ((Number)value).longValue(); - } - if (rawType == Boolean.TYPE || rawType == Boolean.class) { - return value; - } - if (rawType == String.class) { - return value; - } - if (rawType == BigDecimal.class) { - return new BigDecimal((String)value); - } - if (rawType == BigInteger.class) { - return new BigInteger((String)value); - } - if (rawType.isEnum() && value instanceof String) { - return this.stringToEnum(rawType, (String)value); - } - if (Collection.class.isAssignableFrom(rawType)) { - if (value instanceof JSONArray) { - Type elementType = this.getElementType(targetType); - return this.fromJsonArray((JSONArray)value, rawType, elementType); - } - } else { - if (Map.class.isAssignableFrom(rawType) && value instanceof JSONObject) { - Type[] mapTypes = this.getMapTypes(targetType); - Type keyType = mapTypes[0]; - Type valueType = mapTypes[1]; - return this.convertToMap((JSONObject)value, keyType, valueType, rawType); - } - if (!rawType.isPrimitive() && !rawType.isEnum() && value instanceof JSONObject) { - return ((JSONObject)value).fromJson(rawType); - } - } - return value.toString(); - } - - private Map convertToMap(JSONObject jsonMap, Type keyType, Type valueType, Class mapType) throws JSONException { - try { - HashMap createdMap = new HashMap(); - Iterator iterator = jsonMap.keySet().iterator(); - while (iterator.hasNext()) { - String keyObj; - String keyStr = keyObj = iterator.next(); - Object mapValue = jsonMap.get(keyStr); - Object convertedKey = this.convertValue(keyStr, keyType); - Object convertedValue = this.convertValue(mapValue, valueType); - createdMap.put(convertedKey, convertedValue); - } - return createdMap; - } - catch (Exception e) { - throw new JSONException("Failed to convert JSONObject to Map: " + mapType.getName(), e); - } - } - - private E stringToEnum(Class enumClass, String value) throws JSONException { - try { - Class enumType = enumClass; - Method valueOfMethod = enumType.getMethod("valueOf", String.class); - return (E)valueOfMethod.invoke(null, value); - } - catch (Exception e) { - throw new JSONException("Failed to convert string to enum: " + value + " for " + enumClass.getName(), e); - } - } - - private Collection fromJsonArray(JSONArray jsonArray, Class collectionType, Type elementType) throws JSONException { - try { - Collection collection = this.getCollection(collectionType); - for (int i = 0; i < jsonArray.length(); ++i) { - Object jsonElement = jsonArray.get(i); - Object convertedValue = this.convertValue(jsonElement, elementType); - collection.add(convertedValue); - } - return collection; - } - catch (Exception e) { - throw new JSONException("Failed to convert JSONArray to Collection: " + collectionType.getName(), e); - } - } - - private Collection getCollection(Class collectionType) throws JSONException { - if (collectionType == List.class || collectionType == ArrayList.class) { - return new ArrayList(); - } - if (collectionType == Set.class || collectionType == HashSet.class) { - return new HashSet(); - } - throw new JSONException("Unsupported Collection type: " + collectionType.getName()); - } - - private static final class Null { - private Null() { - } - - public boolean equals(Object object) { - return object == null || object == this; - } - - public int hashCode() { - return 0; - } - - public String toString() { - return "null"; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONParserConfiguration.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONParserConfiguration.java deleted file mode 100644 index 933c56f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONParserConfiguration.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.ParserConfiguration; - -public class JSONParserConfiguration -extends ParserConfiguration { - private boolean overwriteDuplicateKey = false; - private boolean useNativeNulls; - private boolean strictMode; - - @Override - protected JSONParserConfiguration clone() { - JSONParserConfiguration clone = new JSONParserConfiguration(); - clone.overwriteDuplicateKey = this.overwriteDuplicateKey; - clone.strictMode = this.strictMode; - clone.maxNestingDepth = this.maxNestingDepth; - clone.keepStrings = this.keepStrings; - clone.useNativeNulls = this.useNativeNulls; - return clone; - } - - public JSONParserConfiguration withMaxNestingDepth(int maxNestingDepth) { - JSONParserConfiguration clone = this.clone(); - clone.maxNestingDepth = maxNestingDepth; - return clone; - } - - public JSONParserConfiguration withOverwriteDuplicateKey(boolean overwriteDuplicateKey) { - JSONParserConfiguration clone = this.clone(); - clone.overwriteDuplicateKey = overwriteDuplicateKey; - return clone; - } - - public JSONParserConfiguration withUseNativeNulls(boolean useNativeNulls) { - JSONParserConfiguration clone = this.clone(); - clone.useNativeNulls = useNativeNulls; - return clone; - } - - public JSONParserConfiguration withStrictMode() { - return this.withStrictMode(true); - } - - public JSONParserConfiguration withStrictMode(boolean mode) { - JSONParserConfiguration clone = this.clone(); - clone.strictMode = mode; - return clone; - } - - public boolean isOverwriteDuplicateKey() { - return this.overwriteDuplicateKey; - } - - public boolean isUseNativeNulls() { - return this.useNativeNulls; - } - - public boolean isStrictMode() { - return this.strictMode; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPointer.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPointer.java deleted file mode 100644 index 2c4e415..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPointer.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONPointerException; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class JSONPointer { - private static final String ENCODING = "utf-8"; - private final List refTokens; - - public static Builder builder() { - return new Builder(); - } - - public JSONPointer(String pointer) { - String refs; - if (pointer == null) { - throw new NullPointerException("pointer cannot be null"); - } - if (pointer.isEmpty() || "#".equals(pointer)) { - this.refTokens = Collections.emptyList(); - return; - } - if (pointer.startsWith("#/")) { - refs = pointer.substring(2); - try { - refs = URLDecoder.decode(refs, ENCODING); - } - catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } else if (pointer.startsWith("/")) { - refs = pointer.substring(1); - } else { - throw new IllegalArgumentException("a JSON pointer should start with '/' or '#/'"); - } - this.refTokens = new ArrayList(); - int slashIdx = -1; - int prevSlashIdx = 0; - do { - String token; - if ((prevSlashIdx = slashIdx + 1) == (slashIdx = refs.indexOf(47, prevSlashIdx)) || prevSlashIdx == refs.length()) { - this.refTokens.add(""); - continue; - } - if (slashIdx >= 0) { - token = refs.substring(prevSlashIdx, slashIdx); - this.refTokens.add(JSONPointer.unescape(token)); - continue; - } - token = refs.substring(prevSlashIdx); - this.refTokens.add(JSONPointer.unescape(token)); - } while (slashIdx >= 0); - } - - public JSONPointer(List refTokens) { - this.refTokens = new ArrayList(refTokens); - } - - private static String unescape(String token) { - return token.replace("~1", "/").replace("~0", "~"); - } - - public Object queryFrom(Object document) throws JSONPointerException { - if (this.refTokens.isEmpty()) { - return document; - } - Object current = document; - for (String token : this.refTokens) { - if (current instanceof JSONObject) { - current = ((JSONObject)current).opt(JSONPointer.unescape(token)); - continue; - } - if (current instanceof JSONArray) { - current = JSONPointer.readByIndexToken(current, token); - continue; - } - throw new JSONPointerException(String.format("value [%s] is not an array or object therefore its key %s cannot be resolved", current, token)); - } - return current; - } - - private static Object readByIndexToken(Object current, String indexToken) throws JSONPointerException { - try { - int index = Integer.parseInt(indexToken); - JSONArray currentArr = (JSONArray)current; - if (index >= currentArr.length()) { - throw new JSONPointerException(String.format("index %s is out of bounds - the array has %d elements", indexToken, currentArr.length())); - } - try { - return currentArr.get(index); - } - catch (JSONException e) { - throw new JSONPointerException("Error reading value at index position " + index, e); - } - } - catch (NumberFormatException e) { - throw new JSONPointerException(String.format("%s is not an array index", indexToken), e); - } - } - - public String toString() { - StringBuilder rval = new StringBuilder(); - for (String token : this.refTokens) { - rval.append('/').append(JSONPointer.escape(token)); - } - return rval.toString(); - } - - private static String escape(String token) { - return token.replace("~", "~0").replace("/", "~1"); - } - - public String toURIFragment() { - try { - StringBuilder rval = new StringBuilder("#"); - for (String token : this.refTokens) { - rval.append('/').append(URLEncoder.encode(token, ENCODING)); - } - return rval.toString(); - } - catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - public static class Builder { - private final List refTokens = new ArrayList(); - - public JSONPointer build() { - return new JSONPointer(this.refTokens); - } - - public Builder append(String token) { - if (token == null) { - throw new NullPointerException("token cannot be null"); - } - this.refTokens.add(token); - return this; - } - - public Builder append(int arrayIndex) { - this.refTokens.add(String.valueOf(arrayIndex)); - return this; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPointerException.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPointerException.java deleted file mode 100644 index 7b3138b..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPointerException.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONException; - -public class JSONPointerException -extends JSONException { - private static final long serialVersionUID = 8872944667561856751L; - - public JSONPointerException(String message) { - super(message); - } - - public JSONPointerException(String message, Throwable cause) { - super(message, cause); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPropertyIgnore.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPropertyIgnore.java deleted file mode 100644 index 458c9ac..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPropertyIgnore.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(value=RetentionPolicy.RUNTIME) -@Target(value={ElementType.METHOD}) -public @interface JSONPropertyIgnore { -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPropertyName.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPropertyName.java deleted file mode 100644 index a5f0270..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONPropertyName.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Documented -@Retention(value=RetentionPolicy.RUNTIME) -@Target(value={ElementType.METHOD}) -public @interface JSONPropertyName { - public String value(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONString.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONString.java deleted file mode 100644 index 6549811..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONString.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -public interface JSONString { - public String toJSONString(); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONStringer.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONStringer.java deleted file mode 100644 index ca8241a..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONStringer.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONWriter; -import java.io.StringWriter; - -public class JSONStringer -extends JSONWriter { - public JSONStringer() { - super(new StringWriter()); - } - - public String toString() { - return this.mode == 'd' ? this.writer.toString() : null; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONTokener.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONTokener.java deleted file mode 100644 index c6d13bb..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONTokener.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONParserConfiguration; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.nio.charset.Charset; - -public class JSONTokener { - private long character; - private boolean eof; - private long index; - private long line; - private char previous; - private final Reader reader; - private boolean usePrevious; - private long characterPreviousLine; - private JSONParserConfiguration jsonParserConfiguration; - - public JSONTokener(Reader reader) { - this(reader, new JSONParserConfiguration()); - } - - public JSONTokener(Reader reader, JSONParserConfiguration jsonParserConfiguration) { - this.jsonParserConfiguration = jsonParserConfiguration; - this.reader = reader.markSupported() ? reader : new BufferedReader(reader); - this.eof = false; - this.usePrevious = false; - this.previous = '\u0000'; - this.index = 0L; - this.character = 1L; - this.characterPreviousLine = 0L; - this.line = 1L; - } - - public JSONTokener(InputStream inputStream) { - this(inputStream, new JSONParserConfiguration()); - } - - public JSONTokener(InputStream inputStream, JSONParserConfiguration jsonParserConfiguration) { - this(new InputStreamReader(inputStream, Charset.forName("UTF-8")), jsonParserConfiguration); - } - - public JSONTokener(String source) { - this(new StringReader(source)); - } - - public JSONTokener(String source, JSONParserConfiguration jsonParserConfiguration) { - this(new StringReader(source), jsonParserConfiguration); - } - - public JSONParserConfiguration getJsonParserConfiguration() { - return this.jsonParserConfiguration; - } - - @Deprecated - public void setJsonParserConfiguration(JSONParserConfiguration jsonParserConfiguration) { - this.jsonParserConfiguration = jsonParserConfiguration; - } - - public void back() throws JSONException { - if (this.usePrevious || this.index <= 0L) { - throw new JSONException("Stepping back two steps is not supported"); - } - this.decrementIndexes(); - this.usePrevious = true; - this.eof = false; - } - - private void decrementIndexes() { - --this.index; - if (this.previous == '\r' || this.previous == '\n') { - --this.line; - this.character = this.characterPreviousLine; - } else if (this.character > 0L) { - --this.character; - } - } - - public static int dehexchar(char c) { - if (c >= '0' && c <= '9') { - return c - 48; - } - if (c >= 'A' && c <= 'F') { - return c - 55; - } - if (c >= 'a' && c <= 'f') { - return c - 87; - } - return -1; - } - - public boolean end() { - return this.eof && !this.usePrevious; - } - - public boolean more() throws JSONException { - if (this.usePrevious) { - return true; - } - try { - this.reader.mark(1); - } - catch (IOException e) { - throw new JSONException("Unable to preserve stream position", e); - } - try { - if (this.reader.read() <= 0) { - this.eof = true; - return false; - } - this.reader.reset(); - } - catch (IOException e) { - throw new JSONException("Unable to read the next character from the stream", e); - } - return true; - } - - public char next() throws JSONException { - int c; - if (this.usePrevious) { - this.usePrevious = false; - c = this.previous; - } else { - try { - c = this.reader.read(); - } - catch (IOException exception) { - throw new JSONException(exception); - } - } - if (c <= 0) { - this.eof = true; - return '\u0000'; - } - this.incrementIndexes(c); - this.previous = (char)c; - return this.previous; - } - - protected char getPrevious() { - return this.previous; - } - - private void incrementIndexes(int c) { - if (c > 0) { - ++this.index; - if (c == 13) { - ++this.line; - this.characterPreviousLine = this.character; - this.character = 0L; - } else if (c == 10) { - if (this.previous != '\r') { - ++this.line; - this.characterPreviousLine = this.character; - } - this.character = 0L; - } else { - ++this.character; - } - } - } - - public char next(char c) throws JSONException { - char n = this.next(); - if (n != c) { - if (n > '\u0000') { - throw this.syntaxError("Expected '" + c + "' and instead saw '" + n + "'"); - } - throw this.syntaxError("Expected '" + c + "' and instead saw ''"); - } - return n; - } - - public String next(int n) throws JSONException { - if (n == 0) { - return ""; - } - char[] chars = new char[n]; - for (int pos = 0; pos < n; ++pos) { - chars[pos] = this.next(); - if (!this.end()) continue; - throw this.syntaxError("Substring bounds error"); - } - return new String(chars); - } - - public char nextClean() throws JSONException { - char c; - while ((c = this.next()) != '\u0000' && c <= ' ') { - } - return c; - } - - public String nextString(char quote) throws JSONException { - StringBuilder sb = new StringBuilder(); - block15: while (true) { - char c = this.next(); - switch (c) { - case '\u0000': - case '\n': - case '\r': { - throw this.syntaxError("Unterminated string. Character with int code " + c + " is not allowed within a quoted string."); - } - case '\\': { - c = this.next(); - switch (c) { - case 'b': { - sb.append('\b'); - continue block15; - } - case 't': { - sb.append('\t'); - continue block15; - } - case 'n': { - sb.append('\n'); - continue block15; - } - case 'f': { - sb.append('\f'); - continue block15; - } - case 'r': { - sb.append('\r'); - continue block15; - } - case 'u': { - String next = this.next(4); - try { - sb.append((char)Integer.parseInt(next, 16)); - continue block15; - } - catch (NumberFormatException e) { - throw this.syntaxError("Illegal escape. \\u must be followed by a 4 digit hexadecimal number. \\" + next + " is not valid.", e); - } - } - case '\"': - case '\'': - case '/': - case '\\': { - sb.append(c); - continue block15; - } - } - throw this.syntaxError("Illegal escape. Escape sequence \\" + c + " is not valid."); - } - } - if (c == quote) { - return sb.toString(); - } - sb.append(c); - } - } - - public String nextTo(char delimiter) throws JSONException { - StringBuilder sb = new StringBuilder(); - while (true) { - char c; - if ((c = this.next()) == delimiter || c == '\u0000' || c == '\n' || c == '\r') { - if (c != '\u0000') { - this.back(); - } - return sb.toString().trim(); - } - sb.append(c); - } - } - - public String nextTo(String delimiters) throws JSONException { - StringBuilder sb = new StringBuilder(); - while (true) { - char c; - if (delimiters.indexOf(c = this.next()) >= 0 || c == '\u0000' || c == '\n' || c == '\r') { - if (c != '\u0000') { - this.back(); - } - return sb.toString().trim(); - } - sb.append(c); - } - } - - public Object nextValue() throws JSONException { - char c = this.nextClean(); - switch (c) { - case '{': { - this.back(); - try { - return new JSONObject(this, this.jsonParserConfiguration); - } - catch (StackOverflowError e) { - throw new JSONException("JSON Array or Object depth too large to process.", e); - } - } - case '[': { - this.back(); - try { - return new JSONArray(this, this.jsonParserConfiguration); - } - catch (StackOverflowError e) { - throw new JSONException("JSON Array or Object depth too large to process.", e); - } - } - } - return this.nextSimpleValue(c); - } - - Object nextSimpleValue(char c) { - String string; - if (this.jsonParserConfiguration != null && this.jsonParserConfiguration.isStrictMode() && c == '\'') { - throw this.syntaxError("Strict mode error: Single quoted strings are not allowed"); - } - switch (c) { - case '\"': - case '\'': { - return this.nextString(c); - } - } - StringBuilder sb = new StringBuilder(); - while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { - sb.append(c); - c = this.next(); - } - if (!this.eof) { - this.back(); - } - if ("".equals(string = sb.toString().trim())) { - throw this.syntaxError("Missing value"); - } - if (this.jsonParserConfiguration != null && this.jsonParserConfiguration.isStrictMode() && string.endsWith(".")) { - throw this.syntaxError(String.format("Strict mode error: Value '%s' ends with dot", string)); - } - Object obj = JSONObject.stringToValue(string); - if (this.jsonParserConfiguration != null && this.jsonParserConfiguration.isStrictMode()) { - if (obj instanceof Boolean && !"true".equals(string) && !"false".equals(string)) { - throw this.syntaxError(String.format("Strict mode error: Value '%s' is not lowercase boolean", obj)); - } - if (obj == JSONObject.NULL && !"null".equals(string)) { - throw this.syntaxError(String.format("Strict mode error: Value '%s' is not lowercase null", obj)); - } - if (obj instanceof String) { - throw this.syntaxError(String.format("Strict mode error: Value '%s' is not surrounded by quotes", obj)); - } - } - return obj; - } - - public char skipTo(char to) throws JSONException { - char c; - try { - long startIndex = this.index; - long startCharacter = this.character; - long startLine = this.line; - this.reader.mark(1000000); - do { - if ((c = this.next()) != '\u0000') continue; - this.reader.reset(); - this.index = startIndex; - this.character = startCharacter; - this.line = startLine; - return '\u0000'; - } while (c != to); - this.reader.mark(1); - } - catch (IOException exception) { - throw new JSONException(exception); - } - this.back(); - return c; - } - - public JSONException syntaxError(String message) { - return new JSONException(message + this.toString()); - } - - public JSONException syntaxError(String message, Throwable causedBy) { - return new JSONException(message + this.toString(), causedBy); - } - - public String toString() { - return " at " + this.index + " [character " + this.character + " line " + this.line + "]"; - } - - public void close() throws IOException { - if (this.reader != null) { - this.reader.close(); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONWriter.java b/source/decompiled/de/maxhenkel/voicechat/org/json/JSONWriter.java deleted file mode 100644 index d4db3e1..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/JSONWriter.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.JSONString; -import java.io.IOException; -import java.util.Collection; -import java.util.Map; - -public class JSONWriter { - private static final int maxdepth = 200; - private boolean comma = false; - protected char mode = (char)105; - private final JSONObject[] stack = new JSONObject[200]; - private int top = 0; - protected Appendable writer; - - public JSONWriter(Appendable w) { - this.writer = w; - } - - private JSONWriter append(String string) throws JSONException { - if (string == null) { - throw new JSONException("Null pointer"); - } - if (this.mode == 'o' || this.mode == 'a') { - try { - if (this.comma && this.mode == 'a') { - this.writer.append(','); - } - this.writer.append(string); - } - catch (IOException e) { - throw new JSONException(e); - } - if (this.mode == 'o') { - this.mode = (char)107; - } - this.comma = true; - return this; - } - throw new JSONException("Value out of sequence."); - } - - public JSONWriter array() throws JSONException { - if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') { - this.push(null); - this.append("["); - this.comma = false; - return this; - } - throw new JSONException("Misplaced array."); - } - - private JSONWriter end(char m, char c) throws JSONException { - if (this.mode != m) { - throw new JSONException(m == 'a' ? "Misplaced endArray." : "Misplaced endObject."); - } - this.pop(m); - try { - this.writer.append(c); - } - catch (IOException e) { - throw new JSONException(e); - } - this.comma = true; - return this; - } - - public JSONWriter endArray() throws JSONException { - return this.end('a', ']'); - } - - public JSONWriter endObject() throws JSONException { - return this.end('k', '}'); - } - - public JSONWriter key(String string) throws JSONException { - if (string == null) { - throw new JSONException("Null key."); - } - if (this.mode == 'k') { - try { - JSONObject topObject = this.stack[this.top - 1]; - if (topObject.has(string)) { - throw new JSONException("Duplicate key \"" + string + "\""); - } - topObject.put(string, true); - if (this.comma) { - this.writer.append(','); - } - this.writer.append(JSONObject.quote(string)); - this.writer.append(':'); - this.comma = false; - this.mode = (char)111; - return this; - } - catch (IOException e) { - throw new JSONException(e); - } - } - throw new JSONException("Misplaced key."); - } - - public JSONWriter object() throws JSONException { - if (this.mode == 'i') { - this.mode = (char)111; - } - if (this.mode == 'o' || this.mode == 'a') { - this.append("{"); - this.push(new JSONObject()); - this.comma = false; - return this; - } - throw new JSONException("Misplaced object."); - } - - private void pop(char c) throws JSONException { - char m; - if (this.top <= 0) { - throw new JSONException("Nesting error."); - } - char c2 = m = this.stack[this.top - 1] == null ? (char)'a' : 'k'; - if (m != c) { - throw new JSONException("Nesting error."); - } - --this.top; - this.mode = (char)(this.top == 0 ? 100 : (this.stack[this.top - 1] == null ? 97 : 107)); - } - - private void push(JSONObject jo) throws JSONException { - if (this.top >= 200) { - throw new JSONException("Nesting too deep."); - } - this.stack[this.top] = jo; - this.mode = (char)(jo == null ? 97 : 107); - ++this.top; - } - - public static String valueToString(Object value) throws JSONException { - if (value == null || value.equals(null)) { - return "null"; - } - if (value instanceof JSONString) { - String object; - try { - object = ((JSONString)value).toJSONString(); - } - catch (Exception e) { - throw new JSONException(e); - } - if (object != null) { - return object; - } - throw new JSONException("Bad value from toJSONString: " + object); - } - if (value instanceof Number) { - String numberAsString = JSONObject.numberToString((Number)value); - if (JSONObject.NUMBER_PATTERN.matcher(numberAsString).matches()) { - return numberAsString; - } - return JSONObject.quote(numberAsString); - } - if (value instanceof Boolean || value instanceof JSONObject || value instanceof JSONArray) { - return value.toString(); - } - if (value instanceof Map) { - Map map = (Map)value; - return new JSONObject(map).toString(); - } - if (value instanceof Collection) { - Collection coll = (Collection)value; - return new JSONArray(coll).toString(); - } - if (value.getClass().isArray()) { - return new JSONArray(value).toString(); - } - if (value instanceof Enum) { - return JSONObject.quote(((Enum)value).name()); - } - return JSONObject.quote(value.toString()); - } - - public JSONWriter value(boolean b) throws JSONException { - return this.append(b ? "true" : "false"); - } - - public JSONWriter value(double d) throws JSONException { - return this.value((Object)d); - } - - public JSONWriter value(long l) throws JSONException { - return this.append(Long.toString(l)); - } - - public JSONWriter value(Object object) throws JSONException { - return this.append(JSONWriter.valueToString(object)); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/ParserConfiguration.java b/source/decompiled/de/maxhenkel/voicechat/org/json/ParserConfiguration.java deleted file mode 100644 index 0255516..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/ParserConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -public class ParserConfiguration { - public static final int UNDEFINED_MAXIMUM_NESTING_DEPTH = -1; - public static final int DEFAULT_MAXIMUM_NESTING_DEPTH = 512; - protected boolean keepStrings; - protected int maxNestingDepth; - - public ParserConfiguration() { - this.keepStrings = false; - this.maxNestingDepth = 512; - } - - protected ParserConfiguration(boolean keepStrings, int maxNestingDepth) { - this.keepStrings = keepStrings; - this.maxNestingDepth = maxNestingDepth; - } - - protected ParserConfiguration clone() { - return new ParserConfiguration(this.keepStrings, this.maxNestingDepth); - } - - public boolean isKeepStrings() { - return this.keepStrings; - } - - public T withKeepStrings(boolean newVal) { - ParserConfiguration newConfig = this.clone(); - newConfig.keepStrings = newVal; - return (T)newConfig; - } - - public int getMaxNestingDepth() { - return this.maxNestingDepth; - } - - public T withMaxNestingDepth(int maxNestingDepth) { - ParserConfiguration newConfig = this.clone(); - newConfig.maxNestingDepth = maxNestingDepth > -1 ? maxNestingDepth : -1; - return (T)newConfig; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/Property.java b/source/decompiled/de/maxhenkel/voicechat/org/json/Property.java deleted file mode 100644 index fbe5b0d..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/Property.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import java.util.Enumeration; -import java.util.Properties; - -public class Property { - public static JSONObject toJSONObject(Properties properties) throws JSONException { - JSONObject jo = new JSONObject(); - if (properties != null && !properties.isEmpty()) { - Enumeration enumProperties = properties.propertyNames(); - while (enumProperties.hasMoreElements()) { - String name = (String)enumProperties.nextElement(); - jo.put(name, properties.getProperty(name)); - } - } - return jo; - } - - public static Properties toProperties(JSONObject jo) throws JSONException { - Properties properties = new Properties(); - if (jo != null) { - for (String key : jo.keySet()) { - Object value = jo.opt(key); - if (JSONObject.NULL.equals(value)) continue; - properties.put(key, value.toString()); - } - } - return properties; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/StringBuilderWriter.java b/source/decompiled/de/maxhenkel/voicechat/org/json/StringBuilderWriter.java deleted file mode 100644 index d094217..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/StringBuilderWriter.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import java.io.IOException; -import java.io.Writer; - -public class StringBuilderWriter -extends Writer { - private final StringBuilder builder; - - public StringBuilderWriter() { - this.builder = new StringBuilder(); - this.lock = this.builder; - } - - public StringBuilderWriter(int initialSize) { - this.builder = new StringBuilder(initialSize); - this.lock = this.builder; - } - - @Override - public void write(int c) { - this.builder.append((char)c); - } - - @Override - public void write(char[] cbuf, int offset, int length) { - if (offset < 0 || offset > cbuf.length || length < 0 || offset + length > cbuf.length || offset + length < 0) { - throw new IndexOutOfBoundsException(); - } - if (length == 0) { - return; - } - this.builder.append(cbuf, offset, length); - } - - @Override - public void write(String str) { - this.builder.append(str); - } - - @Override - public void write(String str, int offset, int length) { - this.builder.append(str, offset, offset + length); - } - - @Override - public StringBuilderWriter append(CharSequence csq) { - this.write(String.valueOf(csq)); - return this; - } - - @Override - public StringBuilderWriter append(CharSequence csq, int start, int end) { - if (csq == null) { - csq = "null"; - } - return this.append(csq.subSequence(start, end)); - } - - @Override - public StringBuilderWriter append(char c) { - this.write(c); - return this; - } - - public String toString() { - return this.builder.toString(); - } - - @Override - public void flush() { - } - - @Override - public void close() throws IOException { - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/XML.java b/source/decompiled/de/maxhenkel/voicechat/org/json/XML.java deleted file mode 100644 index 7583461..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/XML.java +++ /dev/null @@ -1,623 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONArray; -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONObject; -import de.maxhenkel.voicechat.org.json.XMLParserConfiguration; -import de.maxhenkel.voicechat.org.json.XMLTokener; -import de.maxhenkel.voicechat.org.json.XMLXsiTypeConverter; -import java.io.Reader; -import java.io.StringReader; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Iterator; - -public class XML { - public static final Character AMP = Character.valueOf('&'); - public static final Character APOS = Character.valueOf('\''); - public static final Character BANG = Character.valueOf('!'); - public static final Character EQ = Character.valueOf('='); - public static final Character GT = Character.valueOf('>'); - public static final Character LT = Character.valueOf('<'); - public static final Character QUEST = Character.valueOf('?'); - public static final Character QUOT = Character.valueOf('\"'); - public static final Character SLASH = Character.valueOf('/'); - public static final String NULL_ATTR = "xsi:nil"; - public static final String TYPE_ATTR = "xsi:type"; - - private static Iterable codePointIterator(final String string) { - return new Iterable(){ - - @Override - public Iterator iterator() { - return new Iterator(){ - private int nextIndex = 0; - private int length; - { - this.length = string.length(); - } - - @Override - public boolean hasNext() { - return this.nextIndex < this.length; - } - - @Override - public Integer next() { - int result = string.codePointAt(this.nextIndex); - this.nextIndex += Character.charCount(result); - return result; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - public static String escape(String string) { - StringBuilder sb = new StringBuilder(string.length()); - block7: for (int cp : XML.codePointIterator(string)) { - switch (cp) { - case 38: { - sb.append("&"); - continue block7; - } - case 60: { - sb.append("<"); - continue block7; - } - case 62: { - sb.append(">"); - continue block7; - } - case 34: { - sb.append("""); - continue block7; - } - case 39: { - sb.append("'"); - continue block7; - } - } - if (XML.mustEscape(cp)) { - sb.append("&#x"); - sb.append(Integer.toHexString(cp)); - sb.append(';'); - continue; - } - sb.appendCodePoint(cp); - } - return sb.toString(); - } - - private static boolean mustEscape(int cp) { - return Character.isISOControl(cp) && cp != 9 && cp != 10 && cp != 13 || (cp < 32 || cp > 55295) && (cp < 57344 || cp > 65533) && (cp < 65536 || cp > 0x10FFFF); - } - - public static String unescape(String string) { - StringBuilder sb = new StringBuilder(string.length()); - int length = string.length(); - for (int i = 0; i < length; ++i) { - char c = string.charAt(i); - if (c == '&') { - int semic = string.indexOf(59, i); - if (semic > i) { - String entity = string.substring(i + 1, semic); - sb.append(XMLTokener.unescapeEntity(entity)); - i += entity.length() + 1; - continue; - } - sb.append(c); - continue; - } - sb.append(c); - } - return sb.toString(); - } - - public static void noSpace(String string) throws JSONException { - int length = string.length(); - if (length == 0) { - throw new JSONException("Empty string."); - } - for (int i = 0; i < length; ++i) { - if (!Character.isWhitespace(string.charAt(i))) continue; - throw new JSONException("'" + string + "' contains a space character."); - } - } - - private static boolean parse(XMLTokener x, JSONObject context, String name, XMLParserConfiguration config, int currentNestingDepth) throws JSONException { - Object obj; - String string; - JSONObject jsonObject = null; - Object token = x.nextToken(); - if (token == BANG) { - char c = x.next(); - if (c == '-') { - if (x.next() == '-') { - x.skipPast("-->"); - return false; - } - x.back(); - } else if (c == '[') { - token = x.nextToken(); - if ("CDATA".equals(token) && x.next() == '[') { - String string2 = x.nextCDATA(); - if (string2.length() > 0) { - context.accumulate(config.getcDataTagName(), string2); - } - return false; - } - throw x.syntaxError("Expected 'CDATA['"); - } - int i = 1; - do { - if ((token = x.nextMeta()) == null) { - throw x.syntaxError("Missing '>' after ' 0); - return false; - } - if (token == QUEST) { - x.skipPast("?>"); - return false; - } - if (token == SLASH) { - token = x.nextToken(); - if (name == null) { - throw x.syntaxError("Mismatched close tag " + token); - } - if (!token.equals(name)) { - throw x.syntaxError("Mismatched " + name + " and " + token); - } - if (x.nextToken() != GT) { - throw x.syntaxError("Misshaped close tag"); - } - return true; - } - if (token instanceof Character) { - throw x.syntaxError("Misshaped tag"); - } - String tagName = (String)token; - token = null; - jsonObject = new JSONObject(); - boolean nilAttributeFound = false; - XMLXsiTypeConverter xmlXsiTypeConverter = null; - while (true) { - if (token == null) { - token = x.nextToken(); - } - if (!(token instanceof String)) break; - string = (String)token; - token = x.nextToken(); - if (token == EQ) { - token = x.nextToken(); - if (!(token instanceof String)) { - throw x.syntaxError("Missing value"); - } - if (config.isConvertNilAttributeToNull() && NULL_ATTR.equals(string) && Boolean.parseBoolean((String)token)) { - nilAttributeFound = true; - } else if (config.getXsiTypeMap() != null && !config.getXsiTypeMap().isEmpty() && TYPE_ATTR.equals(string)) { - xmlXsiTypeConverter = config.getXsiTypeMap().get(token); - } else if (!nilAttributeFound) { - obj = XML.stringToValue((String)token); - if (obj instanceof Boolean) { - jsonObject.accumulate(string, config.isKeepBooleanAsString() ? (String)token : obj); - } else if (obj instanceof Number) { - jsonObject.accumulate(string, config.isKeepNumberAsString() ? (String)token : obj); - } else { - jsonObject.accumulate(string, XML.stringToValue((String)token)); - } - } - token = null; - continue; - } - jsonObject.accumulate(string, ""); - } - if (token == SLASH) { - if (x.nextToken() != GT) { - throw x.syntaxError("Misshaped tag"); - } - if (config.getForceList().contains(tagName)) { - if (nilAttributeFound) { - context.append(tagName, JSONObject.NULL); - } else if (jsonObject.length() > 0) { - context.append(tagName, jsonObject); - } else { - context.put(tagName, new JSONArray()); - } - } else if (nilAttributeFound) { - context.accumulate(tagName, JSONObject.NULL); - } else if (jsonObject.length() > 0) { - context.accumulate(tagName, jsonObject); - } else { - context.accumulate(tagName, ""); - } - return false; - } - if (token == GT) { - while (true) { - if ((token = x.nextContent()) == null) { - if (tagName != null) { - throw x.syntaxError("Unclosed tag " + tagName); - } - return false; - } - if (token instanceof String) { - string = (String)token; - if (string.length() <= 0) continue; - if (xmlXsiTypeConverter != null) { - jsonObject.accumulate(config.getcDataTagName(), XML.stringToValue(string, xmlXsiTypeConverter)); - continue; - } - obj = XML.stringToValue((String)token); - if (obj instanceof Boolean) { - jsonObject.accumulate(config.getcDataTagName(), config.isKeepBooleanAsString() ? (String)token : obj); - continue; - } - if (obj instanceof Number) { - jsonObject.accumulate(config.getcDataTagName(), config.isKeepNumberAsString() ? (String)token : obj); - continue; - } - if (obj == JSONObject.NULL) { - jsonObject.accumulate(config.getcDataTagName(), config.isKeepStrings() ? (String)token : obj); - continue; - } - jsonObject.accumulate(config.getcDataTagName(), XML.stringToValue((String)token)); - continue; - } - if (token != LT) continue; - if (currentNestingDepth == config.getMaxNestingDepth()) { - throw x.syntaxError("Maximum nesting depth of " + config.getMaxNestingDepth() + " reached"); - } - if (XML.parse(x, jsonObject, tagName, config, currentNestingDepth + 1)) break; - } - if (config.getForceList().contains(tagName)) { - if (jsonObject.length() == 0) { - context.put(tagName, new JSONArray()); - } else if (jsonObject.length() == 1 && jsonObject.opt(config.getcDataTagName()) != null) { - context.append(tagName, jsonObject.opt(config.getcDataTagName())); - } else { - context.append(tagName, jsonObject); - } - } else if (jsonObject.length() == 0) { - context.accumulate(tagName, ""); - } else if (jsonObject.length() == 1 && jsonObject.opt(config.getcDataTagName()) != null) { - context.accumulate(tagName, jsonObject.opt(config.getcDataTagName())); - } else { - if (!config.shouldTrimWhiteSpace()) { - XML.removeEmpty(jsonObject, config); - } - context.accumulate(tagName, jsonObject); - } - return false; - } - throw x.syntaxError("Misshaped tag"); - } - - private static void removeEmpty(JSONObject jsonObject, XMLParserConfiguration config) { - if (jsonObject.has(config.getcDataTagName())) { - Object s = jsonObject.get(config.getcDataTagName()); - if (s instanceof String) { - if (XML.isStringAllWhiteSpace(s.toString())) { - jsonObject.remove(config.getcDataTagName()); - } - } else if (s instanceof JSONArray) { - JSONArray sArray = (JSONArray)s; - for (int k = sArray.length() - 1; k >= 0; --k) { - String s1; - Object eachString = sArray.get(k); - if (!(eachString instanceof String) || !XML.isStringAllWhiteSpace(s1 = (String)eachString)) continue; - sArray.remove(k); - } - if (sArray.isEmpty()) { - jsonObject.remove(config.getcDataTagName()); - } - } - } - } - - private static boolean isStringAllWhiteSpace(String s) { - for (int k = 0; k < s.length(); ++k) { - char eachChar = s.charAt(k); - if (Character.isWhitespace(eachChar)) continue; - return false; - } - return true; - } - - private static Number stringToNumber(String val) throws NumberFormatException { - char initial = val.charAt(0); - if (initial >= '0' && initial <= '9' || initial == '-') { - BigInteger bi; - char at1; - if (XML.isDecimalNotation(val)) { - try { - BigDecimal bd = new BigDecimal(val); - if (initial == '-' && BigDecimal.ZERO.compareTo(bd) == 0) { - return -0.0; - } - return bd; - } - catch (NumberFormatException retryAsDouble) { - try { - Double d = Double.valueOf(val); - if (d.isNaN() || d.isInfinite()) { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - return d; - } - catch (NumberFormatException ignore) { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - } - } - if (initial == '0' && val.length() > 1) { - at1 = val.charAt(1); - if (at1 >= '0' && at1 <= '9') { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - } else if (initial == '-' && val.length() > 2) { - at1 = val.charAt(1); - char at2 = val.charAt(2); - if (at1 == '0' && at2 >= '0' && at2 <= '9') { - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - } - if ((bi = new BigInteger(val)).bitLength() <= 31) { - return bi.intValue(); - } - if (bi.bitLength() <= 63) { - return bi.longValue(); - } - return bi; - } - throw new NumberFormatException("val [" + val + "] is not a valid number."); - } - - private static boolean isDecimalNotation(String val) { - return val.indexOf(46) > -1 || val.indexOf(101) > -1 || val.indexOf(69) > -1 || "-0".equals(val); - } - - public static Object stringToValue(String string, XMLXsiTypeConverter typeConverter) { - if (typeConverter != null) { - return typeConverter.convert(string); - } - return XML.stringToValue(string); - } - - public static Object stringToValue(String string) { - if ("".equals(string)) { - return string; - } - if ("true".equalsIgnoreCase(string)) { - return Boolean.TRUE; - } - if ("false".equalsIgnoreCase(string)) { - return Boolean.FALSE; - } - if ("null".equalsIgnoreCase(string)) { - return JSONObject.NULL; - } - char initial = string.charAt(0); - if (initial >= '0' && initial <= '9' || initial == '-') { - try { - return XML.stringToNumber(string); - } - catch (Exception exception) { - // empty catch block - } - } - return string; - } - - public static JSONObject toJSONObject(String string) throws JSONException { - return XML.toJSONObject(string, XMLParserConfiguration.ORIGINAL); - } - - public static JSONObject toJSONObject(Reader reader) throws JSONException { - return XML.toJSONObject(reader, XMLParserConfiguration.ORIGINAL); - } - - public static JSONObject toJSONObject(Reader reader, boolean keepStrings) throws JSONException { - if (keepStrings) { - return XML.toJSONObject(reader, XMLParserConfiguration.KEEP_STRINGS); - } - return XML.toJSONObject(reader, XMLParserConfiguration.ORIGINAL); - } - - public static JSONObject toJSONObject(Reader reader, boolean keepNumberAsString, boolean keepBooleanAsString) throws JSONException { - XMLParserConfiguration xmlParserConfiguration = new XMLParserConfiguration(); - if (keepNumberAsString) { - xmlParserConfiguration = xmlParserConfiguration.withKeepNumberAsString(keepNumberAsString); - } - if (keepBooleanAsString) { - xmlParserConfiguration = xmlParserConfiguration.withKeepBooleanAsString(keepBooleanAsString); - } - return XML.toJSONObject(reader, xmlParserConfiguration); - } - - public static JSONObject toJSONObject(Reader reader, XMLParserConfiguration config) throws JSONException { - JSONObject jo = new JSONObject(); - XMLTokener x = new XMLTokener(reader, config); - while (x.more()) { - x.skipPast("<"); - if (!x.more()) continue; - XML.parse(x, jo, null, config, 0); - } - return jo; - } - - public static JSONObject toJSONObject(String string, boolean keepStrings) throws JSONException { - return XML.toJSONObject((Reader)new StringReader(string), keepStrings); - } - - public static JSONObject toJSONObject(String string, boolean keepNumberAsString, boolean keepBooleanAsString) throws JSONException { - return XML.toJSONObject(new StringReader(string), keepNumberAsString, keepBooleanAsString); - } - - public static JSONObject toJSONObject(String string, XMLParserConfiguration config) throws JSONException { - return XML.toJSONObject((Reader)new StringReader(string), config); - } - - public static String toString(Object object) throws JSONException { - return XML.toString(object, null, XMLParserConfiguration.ORIGINAL); - } - - public static String toString(Object object, String tagName) { - return XML.toString(object, tagName, XMLParserConfiguration.ORIGINAL); - } - - public static String toString(Object object, String tagName, XMLParserConfiguration config) throws JSONException { - return XML.toString(object, tagName, config, 0, 0); - } - - private static String toString(Object object, String tagName, XMLParserConfiguration config, int indentFactor, int indent) throws JSONException { - String indentationSuffix; - StringBuilder sb = new StringBuilder(); - if (object instanceof JSONObject) { - if (tagName != null) { - sb.append(XML.indent(indent)); - sb.append('<'); - sb.append(tagName); - sb.append('>'); - if (indentFactor > 0) { - sb.append("\n"); - indent += indentFactor; - } - } - JSONObject jo = (JSONObject)object; - for (String key : jo.keySet()) { - Object val; - int i; - int jaLength; - JSONArray ja; - Object value = jo.opt(key); - if (value == null) { - value = ""; - } else if (value.getClass().isArray()) { - value = new JSONArray(value); - } - if (key.equals(config.getcDataTagName())) { - if (value instanceof JSONArray) { - ja = (JSONArray)value; - jaLength = ja.length(); - for (i = 0; i < jaLength; ++i) { - if (i > 0) { - sb.append('\n'); - } - val = ja.opt(i); - sb.append(XML.escape(val.toString())); - } - continue; - } - sb.append(XML.escape(value.toString())); - continue; - } - if (value instanceof JSONArray) { - ja = (JSONArray)value; - jaLength = ja.length(); - for (i = 0; i < jaLength; ++i) { - val = ja.opt(i); - if (val instanceof JSONArray) { - sb.append('<'); - sb.append(key); - sb.append('>'); - sb.append(XML.toString(val, null, config, indentFactor, indent)); - sb.append("'); - continue; - } - sb.append(XML.toString(val, key, config, indentFactor, indent)); - } - continue; - } - if ("".equals(value)) { - if (config.isCloseEmptyTag()) { - sb.append(XML.indent(indent)); - sb.append('<'); - sb.append(key); - sb.append(">"); - sb.append(""); - if (indentFactor <= 0) continue; - sb.append("\n"); - continue; - } - sb.append(XML.indent(indent)); - sb.append('<'); - sb.append(key); - sb.append("/>"); - if (indentFactor <= 0) continue; - sb.append("\n"); - continue; - } - sb.append(XML.toString(value, key, config, indentFactor, indent)); - } - if (tagName != null) { - sb.append(XML.indent(indent - indentFactor)); - sb.append("'); - if (indentFactor > 0) { - sb.append("\n"); - } - } - return sb.toString(); - } - if (object != null && (object instanceof JSONArray || object.getClass().isArray())) { - JSONArray ja = object.getClass().isArray() ? new JSONArray(object) : (JSONArray)object; - int jaLength = ja.length(); - for (int i = 0; i < jaLength; ++i) { - Object val = ja.opt(i); - sb.append(XML.toString(val, tagName == null ? "array" : tagName, config, indentFactor, indent)); - } - return sb.toString(); - } - String string = object == null ? "null" : XML.escape(object.toString()); - String string2 = indentationSuffix = indentFactor > 0 ? "\n" : ""; - if (tagName == null) { - return XML.indent(indent) + "\"" + string + "\"" + indentationSuffix; - } - if (string.length() == 0) { - return XML.indent(indent) + "<" + tagName + "/>" + indentationSuffix; - } - return XML.indent(indent) + "<" + tagName + ">" + string + "" + indentationSuffix; - } - - public static String toString(Object object, int indentFactor) { - return XML.toString(object, null, XMLParserConfiguration.ORIGINAL, indentFactor); - } - - public static String toString(Object object, String tagName, int indentFactor) { - return XML.toString(object, tagName, XMLParserConfiguration.ORIGINAL, indentFactor); - } - - public static String toString(Object object, String tagName, XMLParserConfiguration config, int indentFactor) throws JSONException { - return XML.toString(object, tagName, config, indentFactor, 0); - } - - private static final String indent(int indent) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < indent; ++i) { - sb.append(' '); - } - return sb.toString(); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/XMLParserConfiguration.java b/source/decompiled/de/maxhenkel/voicechat/org/json/XMLParserConfiguration.java deleted file mode 100644 index 8a552e3..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/XMLParserConfiguration.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.ParserConfiguration; -import de.maxhenkel.voicechat.org.json.XMLXsiTypeConverter; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class XMLParserConfiguration -extends ParserConfiguration { - private boolean keepNumberAsString; - private boolean keepBooleanAsString; - public static final XMLParserConfiguration ORIGINAL = new XMLParserConfiguration(); - public static final XMLParserConfiguration KEEP_STRINGS = new XMLParserConfiguration().withKeepStrings(true); - private String cDataTagName; - private boolean convertNilAttributeToNull; - private boolean closeEmptyTag; - private Map> xsiTypeMap; - private Set forceList; - private boolean shouldTrimWhiteSpace; - - public XMLParserConfiguration() { - this.cDataTagName = "content"; - this.convertNilAttributeToNull = false; - this.xsiTypeMap = Collections.emptyMap(); - this.forceList = Collections.emptySet(); - this.shouldTrimWhiteSpace = true; - } - - @Deprecated - public XMLParserConfiguration(boolean keepStrings) { - this(keepStrings, "content", false); - } - - @Deprecated - public XMLParserConfiguration(String cDataTagName) { - this(false, cDataTagName, false); - } - - @Deprecated - public XMLParserConfiguration(boolean keepStrings, String cDataTagName) { - super(keepStrings, 512); - this.cDataTagName = cDataTagName; - this.convertNilAttributeToNull = false; - } - - @Deprecated - public XMLParserConfiguration(boolean keepStrings, String cDataTagName, boolean convertNilAttributeToNull) { - super(false, 512); - this.keepNumberAsString = keepStrings; - this.keepBooleanAsString = keepStrings; - this.cDataTagName = cDataTagName; - this.convertNilAttributeToNull = convertNilAttributeToNull; - } - - private XMLParserConfiguration(boolean keepStrings, String cDataTagName, boolean convertNilAttributeToNull, Map> xsiTypeMap, Set forceList, int maxNestingDepth, boolean closeEmptyTag, boolean keepNumberAsString, boolean keepBooleanAsString) { - super(false, maxNestingDepth); - this.keepNumberAsString = keepNumberAsString; - this.keepBooleanAsString = keepBooleanAsString; - this.cDataTagName = cDataTagName; - this.convertNilAttributeToNull = convertNilAttributeToNull; - this.xsiTypeMap = Collections.unmodifiableMap(xsiTypeMap); - this.forceList = Collections.unmodifiableSet(forceList); - this.closeEmptyTag = closeEmptyTag; - } - - @Override - protected XMLParserConfiguration clone() { - XMLParserConfiguration config = new XMLParserConfiguration(this.keepStrings, this.cDataTagName, this.convertNilAttributeToNull, this.xsiTypeMap, this.forceList, this.maxNestingDepth, this.closeEmptyTag, this.keepNumberAsString, this.keepBooleanAsString); - config.shouldTrimWhiteSpace = this.shouldTrimWhiteSpace; - return config; - } - - public XMLParserConfiguration withKeepStrings(boolean newVal) { - XMLParserConfiguration newConfig = this.clone(); - newConfig.keepStrings = newVal; - newConfig.keepNumberAsString = newVal; - newConfig.keepBooleanAsString = newVal; - return newConfig; - } - - public XMLParserConfiguration withKeepNumberAsString(boolean newVal) { - XMLParserConfiguration newConfig = this.clone(); - newConfig.keepNumberAsString = newVal; - newConfig.keepStrings = newConfig.keepBooleanAsString && newConfig.keepNumberAsString; - return newConfig; - } - - public XMLParserConfiguration withKeepBooleanAsString(boolean newVal) { - XMLParserConfiguration newConfig = this.clone(); - newConfig.keepBooleanAsString = newVal; - newConfig.keepStrings = newConfig.keepBooleanAsString && newConfig.keepNumberAsString; - return newConfig; - } - - public String getcDataTagName() { - return this.cDataTagName; - } - - public boolean isKeepNumberAsString() { - return this.keepNumberAsString; - } - - public boolean isKeepBooleanAsString() { - return this.keepBooleanAsString; - } - - public XMLParserConfiguration withcDataTagName(String newVal) { - XMLParserConfiguration newConfig = this.clone(); - newConfig.cDataTagName = newVal; - return newConfig; - } - - public boolean isConvertNilAttributeToNull() { - return this.convertNilAttributeToNull; - } - - public XMLParserConfiguration withConvertNilAttributeToNull(boolean newVal) { - XMLParserConfiguration newConfig = this.clone(); - newConfig.convertNilAttributeToNull = newVal; - return newConfig; - } - - public Map> getXsiTypeMap() { - return this.xsiTypeMap; - } - - public XMLParserConfiguration withXsiTypeMap(Map> xsiTypeMap) { - XMLParserConfiguration newConfig = this.clone(); - HashMap cloneXsiTypeMap = new HashMap(xsiTypeMap); - newConfig.xsiTypeMap = Collections.unmodifiableMap(cloneXsiTypeMap); - return newConfig; - } - - public Set getForceList() { - return this.forceList; - } - - public XMLParserConfiguration withForceList(Set forceList) { - XMLParserConfiguration newConfig = this.clone(); - HashSet cloneForceList = new HashSet(forceList); - newConfig.forceList = Collections.unmodifiableSet(cloneForceList); - return newConfig; - } - - public XMLParserConfiguration withMaxNestingDepth(int maxNestingDepth) { - return (XMLParserConfiguration)super.withMaxNestingDepth(maxNestingDepth); - } - - public XMLParserConfiguration withCloseEmptyTag(boolean closeEmptyTag) { - XMLParserConfiguration clonedConfiguration = this.clone(); - clonedConfiguration.closeEmptyTag = closeEmptyTag; - return clonedConfiguration; - } - - public XMLParserConfiguration withShouldTrimWhitespace(boolean shouldTrimWhiteSpace) { - XMLParserConfiguration clonedConfiguration = this.clone(); - clonedConfiguration.shouldTrimWhiteSpace = shouldTrimWhiteSpace; - return clonedConfiguration; - } - - public boolean isCloseEmptyTag() { - return this.closeEmptyTag; - } - - public boolean shouldTrimWhiteSpace() { - return this.shouldTrimWhiteSpace; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/XMLTokener.java b/source/decompiled/de/maxhenkel/voicechat/org/json/XMLTokener.java deleted file mode 100644 index b1fb94e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/XMLTokener.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -import de.maxhenkel.voicechat.org.json.JSONException; -import de.maxhenkel.voicechat.org.json.JSONTokener; -import de.maxhenkel.voicechat.org.json.XML; -import de.maxhenkel.voicechat.org.json.XMLParserConfiguration; -import java.io.Reader; -import java.util.HashMap; - -public class XMLTokener -extends JSONTokener { - public static final HashMap entity = new HashMap(8); - private XMLParserConfiguration configuration = XMLParserConfiguration.ORIGINAL; - - public XMLTokener(Reader r) { - super(r); - } - - public XMLTokener(String s) { - super(s); - } - - public XMLTokener(Reader r, XMLParserConfiguration configuration) { - super(r); - this.configuration = configuration; - } - - public String nextCDATA() throws JSONException { - StringBuilder sb = new StringBuilder(); - while (this.more()) { - char c = this.next(); - sb.append(c); - int i = sb.length() - 3; - if (i < 0 || sb.charAt(i) != ']' || sb.charAt(i + 1) != ']' || sb.charAt(i + 2) != '>') continue; - sb.setLength(i); - return sb.toString(); - } - throw this.syntaxError("Unclosed CDATA"); - } - - public Object nextContent() throws JSONException { - char c; - while (Character.isWhitespace(c = this.next()) && this.configuration.shouldTrimWhiteSpace()) { - } - if (c == '\u0000') { - return null; - } - if (c == '<') { - return XML.LT; - } - StringBuilder sb = new StringBuilder(); - while (c != '\u0000') { - if (c == '<') { - this.back(); - if (this.configuration.shouldTrimWhiteSpace()) { - return sb.toString().trim(); - } - return sb.toString(); - } - if (c == '&') { - sb.append(this.nextEntity(c)); - } else { - sb.append(c); - } - c = this.next(); - } - return sb.toString().trim(); - } - - public Object nextEntity(char ampersand) throws JSONException { - char c; - StringBuilder sb = new StringBuilder(); - while (Character.isLetterOrDigit(c = this.next()) || c == '#') { - sb.append(Character.toLowerCase(c)); - } - if (c != ';') { - throw this.syntaxError("Missing ';' in XML entity: &" + sb); - } - String string = sb.toString(); - return XMLTokener.unescapeEntity(string); - } - - static String unescapeEntity(String e) { - if (e == null || e.isEmpty()) { - return ""; - } - if (e.charAt(0) == '#') { - int cp = e.charAt(1) == 'x' || e.charAt(1) == 'X' ? Integer.parseInt(e.substring(2), 16) : Integer.parseInt(e.substring(1)); - return new String(new int[]{cp}, 0, 1); - } - Character knownEntity = entity.get(e); - if (knownEntity == null) { - return '&' + e + ';'; - } - return knownEntity.toString(); - } - - public Object nextMeta() throws JSONException { - char c; - while (Character.isWhitespace(c = this.next())) { - } - switch (c) { - case '\u0000': { - throw this.syntaxError("Misshaped meta tag"); - } - case '<': { - return XML.LT; - } - case '>': { - return XML.GT; - } - case '/': { - return XML.SLASH; - } - case '=': { - return XML.EQ; - } - case '!': { - return XML.BANG; - } - case '?': { - return XML.QUEST; - } - case '\"': - case '\'': { - char q = c; - do { - if ((c = this.next()) != '\u0000') continue; - throw this.syntaxError("Unterminated string"); - } while (c != q); - return Boolean.TRUE; - } - } - while (!Character.isWhitespace(c = this.next())) { - switch (c) { - case '\u0000': { - throw this.syntaxError("Unterminated string"); - } - case '!': - case '\"': - case '\'': - case '/': - case '<': - case '=': - case '>': - case '?': { - this.back(); - return Boolean.TRUE; - } - } - } - return Boolean.TRUE; - } - - public Object nextToken() throws JSONException { - char c; - while (Character.isWhitespace(c = this.next())) { - } - switch (c) { - case '\u0000': { - throw this.syntaxError("Misshaped element"); - } - case '<': { - throw this.syntaxError("Misplaced '<'"); - } - case '>': { - return XML.GT; - } - case '/': { - return XML.SLASH; - } - case '=': { - return XML.EQ; - } - case '!': { - return XML.BANG; - } - case '?': { - return XML.QUEST; - } - case '\"': - case '\'': { - char q = c; - StringBuilder sb = new StringBuilder(); - while (true) { - if ((c = this.next()) == '\u0000') { - throw this.syntaxError("Unterminated string"); - } - if (c == q) { - return sb.toString(); - } - if (c == '&') { - sb.append(this.nextEntity(c)); - continue; - } - sb.append(c); - } - } - } - StringBuilder sb = new StringBuilder(); - while (true) { - sb.append(c); - c = this.next(); - if (Character.isWhitespace(c)) { - return sb.toString(); - } - switch (c) { - case '\u0000': { - return sb.toString(); - } - case '!': - case '/': - case '=': - case '>': - case '?': - case '[': - case ']': { - this.back(); - return sb.toString(); - } - case '\"': - case '\'': - case '<': { - throw this.syntaxError("Bad character in a name"); - } - } - } - } - - public void skipPast(String to) { - char c; - int i; - int offset = 0; - int length = to.length(); - char[] circle = new char[length]; - for (i = 0; i < length; ++i) { - c = this.next(); - if (c == '\u0000') { - return; - } - circle[i] = c; - } - while (true) { - int j = offset; - boolean b = true; - for (i = 0; i < length; ++i) { - if (circle[j] != to.charAt(i)) { - b = false; - break; - } - if (++j < length) continue; - j -= length; - } - if (b) { - return; - } - c = this.next(); - if (c == '\u0000') { - return; - } - circle[offset] = c; - if (++offset < length) continue; - offset -= length; - } - } - - static { - entity.put("amp", XML.AMP); - entity.put("apos", XML.APOS); - entity.put("gt", XML.GT); - entity.put("lt", XML.LT); - entity.put("quot", XML.QUOT); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/org/json/XMLXsiTypeConverter.java b/source/decompiled/de/maxhenkel/voicechat/org/json/XMLXsiTypeConverter.java deleted file mode 100644 index c6f2dcb..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/org/json/XMLXsiTypeConverter.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.org.json; - -public interface XMLXsiTypeConverter { - public T convert(String var1); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/permission/PermissionManager.java b/source/decompiled/de/maxhenkel/voicechat/permission/PermissionManager.java deleted file mode 100644 index e12de96..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/permission/PermissionManager.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.permissions.Permission - * org.bukkit.permissions.PermissionDefault - */ -package de.maxhenkel.voicechat.permission; - -import org.bukkit.permissions.Permission; -import org.bukkit.permissions.PermissionDefault; - -public class PermissionManager { - public static Permission LISTEN_PERMISSION = new Permission("voicechat.listen", PermissionDefault.TRUE); - public static Permission SPEAK_PERMISSION = new Permission("voicechat.speak", PermissionDefault.TRUE); - public static Permission GROUPS_PERMISSION = new Permission("voicechat.groups", PermissionDefault.TRUE); - public static Permission ADMIN_PERMISSION = new Permission("voicechat.admin", PermissionDefault.OP); -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/PluginManager.java b/source/decompiled/de/maxhenkel/voicechat/plugins/PluginManager.java deleted file mode 100644 index a3fbed8..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/PluginManager.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.plugins; - -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.VoicechatPlugin; -import de.maxhenkel.voicechat.api.VoicechatSocket; -import de.maxhenkel.voicechat.api.VolumeCategory; -import de.maxhenkel.voicechat.api.audiolistener.AudioListener; -import de.maxhenkel.voicechat.api.audiolistener.PlayerAudioListener; -import de.maxhenkel.voicechat.api.events.CreateGroupEvent; -import de.maxhenkel.voicechat.api.events.EntitySoundPacketEvent; -import de.maxhenkel.voicechat.api.events.Event; -import de.maxhenkel.voicechat.api.events.EventRegistration; -import de.maxhenkel.voicechat.api.events.JoinGroupEvent; -import de.maxhenkel.voicechat.api.events.LeaveGroupEvent; -import de.maxhenkel.voicechat.api.events.LocationalSoundPacketEvent; -import de.maxhenkel.voicechat.api.events.MicrophonePacketEvent; -import de.maxhenkel.voicechat.api.events.PlayerConnectedEvent; -import de.maxhenkel.voicechat.api.events.PlayerDisconnectedEvent; -import de.maxhenkel.voicechat.api.events.PlayerStateChangedEvent; -import de.maxhenkel.voicechat.api.events.RegisterVolumeCategoryEvent; -import de.maxhenkel.voicechat.api.events.RemoveGroupEvent; -import de.maxhenkel.voicechat.api.events.StaticSoundPacketEvent; -import de.maxhenkel.voicechat.api.events.UnregisterVolumeCategoryEvent; -import de.maxhenkel.voicechat.api.events.VoiceDistanceEvent; -import de.maxhenkel.voicechat.api.events.VoiceHostEvent; -import de.maxhenkel.voicechat.api.events.VoicechatServerStartedEvent; -import de.maxhenkel.voicechat.api.events.VoicechatServerStartingEvent; -import de.maxhenkel.voicechat.api.events.VoicechatServerStoppedEvent; -import de.maxhenkel.voicechat.plugins.EventBuilder; -import de.maxhenkel.voicechat.plugins.impl.GroupImpl; -import de.maxhenkel.voicechat.plugins.impl.VoicechatConnectionImpl; -import de.maxhenkel.voicechat.plugins.impl.VoicechatServerApiImpl; -import de.maxhenkel.voicechat.plugins.impl.VoicechatSocketImpl; -import de.maxhenkel.voicechat.plugins.impl.audiolistener.PlayerAudioListenerImpl; -import de.maxhenkel.voicechat.plugins.impl.events.CreateGroupEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.EntitySoundPacketEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.JoinGroupEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.LeaveGroupEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.LocationalSoundPacketEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.MicrophonePacketEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.PlayerConnectedEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.PlayerDisconnectedEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.PlayerStateChangedEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.RegisterVolumeCategoryEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.RemoveGroupEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.StaticSoundPacketEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.UnregisterVolumeCategoryEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.VoiceDistanceEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.VoiceHostEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.VoicechatServerStartedEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.VoicechatServerStartingEventImpl; -import de.maxhenkel.voicechat.plugins.impl.events.VoicechatServerStoppedEventImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.EntitySoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.LocationalSoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.MicrophonePacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.SoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.StaticSoundPacketImpl; -import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; -import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; -import de.maxhenkel.voicechat.voice.common.MicPacket; -import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; -import de.maxhenkel.voicechat.voice.common.PlayerState; -import de.maxhenkel.voicechat.voice.common.SoundPacket; -import de.maxhenkel.voicechat.voice.server.Group; -import de.maxhenkel.voicechat.voice.server.Server; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.function.Consumer; -import javax.annotation.Nullable; -import org.bukkit.entity.Player; - -public class PluginManager { - private List plugins; - private Map, List>> events; - private final Map> playerAudioListeners = new ConcurrentHashMap>(); - private static PluginManager instance; - - public void init() { - Voicechat.LOGGER.info("Loading plugins", new Object[0]); - this.plugins = Voicechat.apiService.getPlugins(); - Voicechat.LOGGER.info("Loaded {} plugin(s)", this.plugins.size()); - Voicechat.LOGGER.info("Initializing plugins", new Object[0]); - for (VoicechatPlugin plugin : this.plugins) { - try { - plugin.initialize(VoicechatServerApiImpl.instance()); - } - catch (Exception e) { - Voicechat.LOGGER.error("Failed to initialize plugin '{}'", plugin.getPluginId(), e); - } - } - Voicechat.LOGGER.info("Initialized {} plugin(s)", this.plugins.size()); - this.gatherEvents(); - } - - private void gatherEvents() { - EventBuilder eventBuilder = EventBuilder.create(); - EventRegistration registration = eventBuilder::addEvent; - for (VoicechatPlugin plugin : this.plugins) { - Voicechat.LOGGER.info("Registering events for '{}'", plugin.getPluginId()); - try { - plugin.registerEvents(registration); - } - catch (Throwable t) { - Voicechat.LOGGER.error("Failed to register events for '{}'", plugin.getPluginId(), t); - } - } - this.events = eventBuilder.build(); - } - - public synchronized boolean registerAudioListener(AudioListener l) { - if (!(l instanceof PlayerAudioListener)) { - return false; - } - PlayerAudioListener listener = (PlayerAudioListener)l; - boolean exists = this.playerAudioListeners.values().stream().anyMatch(listeners -> listeners.stream().anyMatch(playerAudioListener -> playerAudioListener.getListenerId().equals(listener.getListenerId()))); - if (exists) { - return false; - } - this.playerAudioListeners.computeIfAbsent(listener.getPlayerUuid(), k -> new CopyOnWriteArrayList()).add(listener); - return true; - } - - public synchronized boolean unregisterAudioListener(UUID listenerId) { - boolean removed = this.playerAudioListeners.values().stream().anyMatch(listeners -> listeners.removeIf(listener -> listener.getListenerId().equals(listenerId))); - if (!removed) { - return false; - } - this.playerAudioListeners.values().removeIf(List::isEmpty); - return true; - } - - public List getPlayerAudioListeners(UUID playerUuid) { - return this.playerAudioListeners.getOrDefault(playerUuid, Collections.emptyList()); - } - - public void onListenerAudio(UUID playerUuid, SoundPacket packet) { - if (playerUuid.equals(packet.getSender())) { - return; - } - List listeners = this.getPlayerAudioListeners(playerUuid); - if (listeners.isEmpty()) { - return; - } - SoundPacketImpl soundPacket = packet instanceof GroupSoundPacket ? new StaticSoundPacketImpl((GroupSoundPacket)packet) : (packet instanceof PlayerSoundPacket ? new EntitySoundPacketImpl((PlayerSoundPacket)packet) : (packet instanceof LocationSoundPacket ? new LocationalSoundPacketImpl((LocationSoundPacket)packet) : new SoundPacketImpl(packet))); - for (PlayerAudioListener l : listeners) { - if (!(l instanceof PlayerAudioListenerImpl)) continue; - try { - ((PlayerAudioListenerImpl)l).getListener().accept(soundPacket); - } - catch (Throwable t) { - Voicechat.LOGGER.error("Failed to process audio listener", t); - } - } - } - - public boolean dispatchEvent(Class eventClass, T event) { - List> events = this.events.get(eventClass); - if (events == null) { - return false; - } - for (Consumer evt : events) { - try { - Consumer e = evt; - e.accept(event); - if (!event.isCancelled()) continue; - break; - } - catch (Throwable t) { - Voicechat.LOGGER.error("Failed to dispatch event '{}'", eventClass.getSimpleName(), t); - } - } - return event.isCancelled(); - } - - public VoicechatSocket getSocketImplementation() { - VoicechatServerStartingEventImpl event = new VoicechatServerStartingEventImpl(); - this.dispatchEvent(VoicechatServerStartingEvent.class, event); - VoicechatSocket socket = event.getSocketImplementation(); - if (socket == null) { - socket = new VoicechatSocketImpl(); - Voicechat.LOGGER.debug("Using default voicechat socket implementation", new Object[0]); - } else { - Voicechat.LOGGER.info("Using custom voicechat socket implementation: {}", socket.getClass().getName()); - } - return socket; - } - - public String getVoiceHost(Player player, String voiceHost) { - VoiceHostEventImpl event = new VoiceHostEventImpl(player, voiceHost); - this.dispatchEvent(VoiceHostEvent.class, event); - return event.getVoiceHost(); - } - - public void onRegisterVolumeCategory(VolumeCategory category) { - this.dispatchEvent(RegisterVolumeCategoryEvent.class, new RegisterVolumeCategoryEventImpl(category)); - } - - public void onUnregisterVolumeCategory(VolumeCategory category) { - this.dispatchEvent(UnregisterVolumeCategoryEvent.class, new UnregisterVolumeCategoryEventImpl(category)); - } - - public void onServerStarted() { - this.dispatchEvent(VoicechatServerStartedEvent.class, new VoicechatServerStartedEventImpl()); - } - - public void onServerStopped() { - this.dispatchEvent(VoicechatServerStoppedEvent.class, new VoicechatServerStoppedEventImpl()); - } - - public void onPlayerConnected(@Nullable Player player) { - if (player == null) { - return; - } - this.dispatchEvent(PlayerConnectedEvent.class, new PlayerConnectedEventImpl(VoicechatConnectionImpl.fromPlayer(player))); - } - - public void onPlayerDisconnected(UUID player) { - this.dispatchEvent(PlayerDisconnectedEvent.class, new PlayerDisconnectedEventImpl(player)); - } - - public void onPlayerStateChanged(PlayerState state) { - this.dispatchEvent(PlayerStateChangedEvent.class, new PlayerStateChangedEventImpl(state)); - } - - public boolean onJoinGroup(Player player, @Nullable Group group) { - if (group == null) { - return this.onLeaveGroup(player); - } - return this.dispatchEvent(JoinGroupEvent.class, new JoinGroupEventImpl(new GroupImpl(group), VoicechatConnectionImpl.fromPlayer(player))); - } - - public boolean onCreateGroup(@Nullable Player player, @Nullable Group group) { - if (group == null) { - if (player == null) { - return false; - } - return this.onLeaveGroup(player); - } - return this.dispatchEvent(CreateGroupEvent.class, new CreateGroupEventImpl(new GroupImpl(group), VoicechatConnectionImpl.fromPlayer(player))); - } - - public boolean onLeaveGroup(Player player) { - Group g; - UUID groupUUID; - Server server = Voicechat.SERVER.getServer(); - if (server == null) { - return false; - } - GroupImpl group = null; - PlayerState state = server.getPlayerStateManager().getState(player.getUniqueId()); - if (state != null && (groupUUID = state.getGroup()) != null && (g = server.getGroupManager().getGroup(groupUUID)) != null) { - group = new GroupImpl(g); - } - return this.dispatchEvent(LeaveGroupEvent.class, new LeaveGroupEventImpl(group, VoicechatConnectionImpl.fromPlayer(player))); - } - - public boolean onRemoveGroup(Group group) { - return this.dispatchEvent(RemoveGroupEvent.class, new RemoveGroupEventImpl(new GroupImpl(group))); - } - - public boolean onMicPacket(Player sender, PlayerState senderState, MicPacket packet) { - return this.dispatchEvent(MicrophonePacketEvent.class, new MicrophonePacketEventImpl(new MicrophonePacketImpl(packet, sender.getUniqueId()), new VoicechatConnectionImpl(sender, senderState))); - } - - public float getDistance(Player sender, PlayerState senderState, MicPacket packet, float originalDistance) { - VoiceDistanceEventImpl event = new VoiceDistanceEventImpl(new MicrophonePacketImpl(packet, sender.getUniqueId()), new VoicechatConnectionImpl(sender, senderState), originalDistance); - this.dispatchEvent(VoiceDistanceEvent.class, event); - return event.getDistance(); - } - - public boolean onSoundPacket(@Nullable Player sender, @Nullable PlayerState senderState, Player receiver, PlayerState receiverState, SoundPacket p, String source) { - VoicechatConnectionImpl senderConnection = null; - if (sender != null && senderState != null) { - senderConnection = new VoicechatConnectionImpl(sender, senderState); - } - VoicechatConnectionImpl receiverConnection = new VoicechatConnectionImpl(receiver, receiverState); - if (p instanceof LocationSoundPacket) { - return this.dispatchEvent(LocationalSoundPacketEvent.class, new LocationalSoundPacketEventImpl(new LocationalSoundPacketImpl((LocationSoundPacket)p), (VoicechatConnection)senderConnection, (VoicechatConnection)receiverConnection, source)); - } - if (p instanceof PlayerSoundPacket) { - return this.dispatchEvent(EntitySoundPacketEvent.class, new EntitySoundPacketEventImpl(new EntitySoundPacketImpl((PlayerSoundPacket)p), (VoicechatConnection)senderConnection, (VoicechatConnection)receiverConnection, source)); - } - if (p instanceof GroupSoundPacket) { - return this.dispatchEvent(StaticSoundPacketEvent.class, new StaticSoundPacketEventImpl(new StaticSoundPacketImpl((GroupSoundPacket)p), (VoicechatConnection)senderConnection, (VoicechatConnection)receiverConnection, source)); - } - return false; - } - - public static synchronized PluginManager instance() { - if (instance == null) { - instance = new PluginManager(); - } - return instance; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/PlayerImpl.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/PlayerImpl.java deleted file mode 100644 index 82b027f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/PlayerImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Entity - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.plugins.impl; - -import de.maxhenkel.voicechat.plugins.impl.EntityImpl; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public class PlayerImpl -extends EntityImpl -implements de.maxhenkel.voicechat.api.Player { - public PlayerImpl(Player entity) { - super((Entity)entity); - } - - @Override - public Object getPlayer() { - return this.entity; - } - - public Player getRealPlayer() { - return (Player)this.entity; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/ServerPlayerImpl.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/ServerPlayerImpl.java deleted file mode 100644 index e9e72ff..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/ServerPlayerImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.plugins.impl; - -import de.maxhenkel.voicechat.api.ServerLevel; -import de.maxhenkel.voicechat.api.ServerPlayer; -import de.maxhenkel.voicechat.plugins.impl.PlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.ServerLevelImpl; -import org.bukkit.entity.Player; - -public class ServerPlayerImpl -extends PlayerImpl -implements ServerPlayer { - public ServerPlayerImpl(Player entity) { - super(entity); - } - - public Player getRealServerPlayer() { - return (Player)this.entity; - } - - @Override - public ServerLevel getServerLevel() { - return new ServerLevelImpl(this.entity.getWorld()); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioSupplier.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioSupplier.java deleted file mode 100644 index f137323..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/AudioSupplier.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.plugins.impl.audiochannel; - -import java.util.Arrays; -import java.util.function.Supplier; - -public class AudioSupplier -implements Supplier { - private final short[] audioData; - private final short[] frame; - private int framePosition; - - public AudioSupplier(short[] audioData) { - this.audioData = audioData; - this.frame = new short[960]; - } - - @Override - public short[] get() { - if (this.framePosition >= this.audioData.length) { - return null; - } - Arrays.fill(this.frame, (short)0); - System.arraycopy(this.audioData, this.framePosition, this.frame, 0, Math.min(this.frame.length, this.audioData.length - this.framePosition)); - this.framePosition += this.frame.length; - return this.frame; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/StaticAudioChannelImpl.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/StaticAudioChannelImpl.java deleted file mode 100644 index fbd924f..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/audiochannel/StaticAudioChannelImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.Bukkit - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.plugins.impl.audiochannel; - -import de.maxhenkel.voicechat.api.VoicechatConnection; -import de.maxhenkel.voicechat.api.audiochannel.StaticAudioChannel; -import de.maxhenkel.voicechat.api.packets.MicrophonePacket; -import de.maxhenkel.voicechat.plugins.impl.ServerPlayerImpl; -import de.maxhenkel.voicechat.plugins.impl.VoicechatServerApiImpl; -import de.maxhenkel.voicechat.plugins.impl.audiochannel.AudioChannelImpl; -import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; -import de.maxhenkel.voicechat.voice.server.ClientConnection; -import de.maxhenkel.voicechat.voice.server.Group; -import de.maxhenkel.voicechat.voice.server.Server; -import de.maxhenkel.voicechat.voice.server.ServerGroupManager; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -public class StaticAudioChannelImpl -extends AudioChannelImpl -implements StaticAudioChannel { - protected boolean bypassGroupIsolation; - protected final Set targets = new HashSet(); - - public StaticAudioChannelImpl(UUID channelId, Server server) { - super(channelId, server); - } - - @Override - public void send(byte[] opusData) { - this.broadcast(new GroupSoundPacket(this.channelId, this.channelId, opusData, this.sequenceNumber.getAndIncrement(), this.category)); - } - - @Override - public void send(MicrophonePacket packet) { - this.send(packet.getOpusEncodedData()); - } - - @Override - public void flush() { - GroupSoundPacket packet = new GroupSoundPacket(this.channelId, this.channelId, new byte[0], this.sequenceNumber.getAndIncrement(), this.category); - this.broadcast(packet); - } - - /* - * WARNING - Removed try catching itself - possible behaviour change. - */ - private void broadcast(GroupSoundPacket packet) { - Set set = this.targets; - synchronized (set) { - ServerGroupManager groupManager = this.server.getGroupManager(); - for (UUID target : this.targets) { - Group playerGroup; - Player player; - ClientConnection connection = this.server.getConnection(target); - if (connection == null || (player = Bukkit.getPlayer((UUID)target)) == null || !this.bypassGroupIsolation && (playerGroup = groupManager.getPlayerGroup(player)) != null && playerGroup.isIsolated() || this.filter != null && !this.filter.test(new ServerPlayerImpl(player))) continue; - VoicechatServerApiImpl.sendPacket(player, packet); - } - } - } - - @Override - public void setBypassGroupIsolation(boolean bypassGroupIsolation) { - this.bypassGroupIsolation = bypassGroupIsolation; - } - - @Override - public boolean bypassesGroupIsolation() { - return this.bypassGroupIsolation; - } - - /* - * WARNING - Removed try catching itself - possible behaviour change. - */ - @Override - public void addTarget(VoicechatConnection target) { - Set set = this.targets; - synchronized (set) { - this.targets.add(target.getPlayer().getUuid()); - } - } - - /* - * WARNING - Removed try catching itself - possible behaviour change. - */ - @Override - public void removeTarget(VoicechatConnection target) { - Set set = this.targets; - synchronized (set) { - this.targets.remove(target.getPlayer().getUuid()); - } - } - - /* - * WARNING - Removed try catching itself - possible behaviour change. - */ - @Override - public void clearTargets() { - Set set = this.targets; - synchronized (set) { - this.targets.clear(); - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartedEventImpl.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartedEventImpl.java deleted file mode 100644 index 851b8ec..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStartedEventImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.plugins.impl.events; - -import de.maxhenkel.voicechat.api.events.VoicechatServerStartedEvent; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; - -public class VoicechatServerStartedEventImpl -extends ServerEventImpl -implements VoicechatServerStartedEvent { - @Override - public boolean isCancellable() { - return false; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStoppedEventImpl.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStoppedEventImpl.java deleted file mode 100644 index ba9ac36..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/events/VoicechatServerStoppedEventImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.plugins.impl.events; - -import de.maxhenkel.voicechat.api.events.VoicechatServerStoppedEvent; -import de.maxhenkel.voicechat.plugins.impl.events.ServerEventImpl; - -public class VoicechatServerStoppedEventImpl -extends ServerEventImpl -implements VoicechatServerStoppedEvent { - @Override - public boolean isCancellable() { - return false; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/MicrophonePacketImpl.java b/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/MicrophonePacketImpl.java deleted file mode 100644 index de0432e..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/plugins/impl/packets/MicrophonePacketImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.plugins.impl.packets; - -import de.maxhenkel.voicechat.api.Position; -import de.maxhenkel.voicechat.api.packets.EntitySoundPacket; -import de.maxhenkel.voicechat.api.packets.LocationalSoundPacket; -import de.maxhenkel.voicechat.api.packets.MicrophonePacket; -import de.maxhenkel.voicechat.api.packets.StaticSoundPacket; -import de.maxhenkel.voicechat.plugins.impl.PositionImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.EntitySoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.LocationalSoundPacketImpl; -import de.maxhenkel.voicechat.plugins.impl.packets.StaticSoundPacketImpl; -import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; -import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; -import de.maxhenkel.voicechat.voice.common.MicPacket; -import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; -import de.maxhenkel.voicechat.voice.common.Utils; -import java.util.Objects; -import java.util.UUID; - -public class MicrophonePacketImpl -implements MicrophonePacket { - private final MicPacket packet; - private final UUID sender; - - public MicrophonePacketImpl(MicPacket packet, UUID sender) { - this.packet = packet; - this.sender = sender; - } - - @Override - public boolean isWhispering() { - return this.packet.isWhispering(); - } - - @Override - public byte[] getOpusEncodedData() { - return this.packet.getData(); - } - - @Override - public void setOpusEncodedData(byte[] data) { - this.packet.setData(Objects.requireNonNull(data)); - } - - @Override - public EntitySoundPacket.Builder entitySoundPacketBuilder() { - return new EntitySoundPacketImpl.BuilderImpl(this.sender, this.sender, this.packet.getData(), this.packet.getSequenceNumber(), null); - } - - @Override - public LocationalSoundPacket.Builder locationalSoundPacketBuilder() { - return new LocationalSoundPacketImpl.BuilderImpl(this.sender, this.sender, this.packet.getData(), this.packet.getSequenceNumber(), null); - } - - @Override - public StaticSoundPacket.Builder staticSoundPacketBuilder() { - return new StaticSoundPacketImpl.BuilderImpl(this.sender, this.sender, this.packet.getData(), this.packet.getSequenceNumber(), null); - } - - @Override - @Deprecated - public EntitySoundPacket toEntitySoundPacket(UUID entityUuid, boolean whispering) { - return new EntitySoundPacketImpl(new PlayerSoundPacket(this.sender, entityUuid, this.packet.getData(), this.packet.getSequenceNumber(), whispering, Utils.getDefaultDistance(), null)); - } - - @Override - @Deprecated - public LocationalSoundPacket toLocationalSoundPacket(Position position) { - if (position instanceof PositionImpl) { - return new LocationalSoundPacketImpl(new LocationSoundPacket(this.sender, this.sender, ((PositionImpl)position).getPosition(), this.packet.getData(), this.packet.getSequenceNumber(), Utils.getDefaultDistance(), null)); - } - throw new IllegalArgumentException("position is not an instance of PositionImpl"); - } - - @Override - @Deprecated - public StaticSoundPacket toStaticSoundPacket() { - return new StaticSoundPacketImpl(new GroupSoundPacket(this.sender, this.sender, this.packet.getData(), this.packet.getSequenceNumber(), null)); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/Packet.java b/source/decompiled/de/maxhenkel/voicechat/voice/common/Packet.java deleted file mode 100644 index ec38293..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/Packet.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Decompiled with CFR 0.152. - */ -package de.maxhenkel.voicechat.voice.common; - -import de.maxhenkel.voicechat.util.FriendlyByteBuf; - -public interface Packet { - public T fromBytes(FriendlyByteBuf var1); - - public void toBytes(FriendlyByteBuf var1); - - default public long getTTL() { - return 10000L; - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/common/Secret.java b/source/decompiled/de/maxhenkel/voicechat/voice/common/Secret.java deleted file mode 100644 index b030976..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/voice/common/Secret.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * io.netty.buffer.ByteBuf - */ -package de.maxhenkel.voicechat.voice.common; - -import io.netty.buffer.ByteBuf; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.Arrays; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.GCMParameterSpec; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -public class Secret { - public static final int SECRET_SIZE_BYTES = 16; - public static final int IV_SIZE_BYTES = 12; - public static final int TAG_LEN_BITS = 128; - public static final String CIPHER = "AES/GCM/NoPadding"; - private static final SecureRandom RANDOM = new SecureRandom(); - private final byte[] secret; - private final SecretKeySpec keySpec; - private volatile boolean legacyProtocol; - - protected Secret(byte[] byArray) { - if (byArray == null || byArray.length != 16) { - throw new IllegalArgumentException("Voice chat secret must contain exactly 16 bytes"); - } - this.secret = (byte[])byArray.clone(); - this.keySpec = new SecretKeySpec(this.secret, "AES"); - } - - public static Secret generateNewRandomSecret() { - byte[] byArray = new byte[16]; - RANDOM.nextBytes(byArray); - return new Secret(byArray); - } - - public static Secret fromBytes(byte[] byArray) { - return new Secret(byArray); - } - - public static Secret fromBytes(ByteBuf byteBuf) { - byte[] byArray = new byte[16]; - byteBuf.readBytes(byArray); - return Secret.fromBytes(byArray); - } - - public void toBytes(ByteBuf byteBuf) { - byteBuf.writeBytes(this.secret); - } - - public byte[] getSecret() { - return (byte[])this.secret.clone(); - } - - public SecretKeySpec getKeySpec() { - return this.keySpec; - } - - public void setLegacyProtocol(boolean bl) { - this.legacyProtocol = bl; - } - - public boolean isLegacyProtocol() { - return this.legacyProtocol; - } - - public static byte[] generateIV() { - byte[] byArray = new byte[12]; - RANDOM.nextBytes(byArray); - return byArray; - } - - private static byte[] generateLegacyIV() { - byte[] byArray = new byte[16]; - RANDOM.nextBytes(byArray); - return byArray; - } - - public byte[] encrypt(byte[] byArray) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - if (this.legacyProtocol) { - byte[] byArray2 = Secret.generateLegacyIV(); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(1, (Key)this.keySpec, new IvParameterSpec(byArray2)); - byte[] byArray3 = cipher.doFinal(byArray); - byte[] byArray4 = new byte[byArray2.length + byArray3.length]; - System.arraycopy(byArray2, 0, byArray4, 0, byArray2.length); - System.arraycopy(byArray3, 0, byArray4, byArray2.length, byArray3.length); - return byArray4; - } - byte[] byArray5 = Secret.generateIV(); - Cipher cipher = Cipher.getInstance(CIPHER); - cipher.init(1, (Key)this.keySpec, new GCMParameterSpec(128, byArray5)); - byte[] byArray6 = cipher.doFinal(byArray); - byte[] byArray7 = new byte[byArray5.length + byArray6.length]; - System.arraycopy(byArray5, 0, byArray7, 0, byArray5.length); - System.arraycopy(byArray6, 0, byArray7, byArray5.length, byArray6.length); - return byArray7; - } - - public byte[] decrypt(byte[] byArray) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - if (this.legacyProtocol) { - if (byArray.length < 32 || (byArray.length - 16) % 16 != 0) { - throw new IllegalBlockSizeException("Invalid legacy AES-CBC packet size"); - } - byte[] byArray2 = Arrays.copyOfRange(byArray, 0, 16); - byte[] byArray3 = Arrays.copyOfRange(byArray, 16, byArray.length); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - cipher.init(2, (Key)this.keySpec, new IvParameterSpec(byArray2)); - return cipher.doFinal(byArray3); - } - if (byArray.length < 28) { - throw new IllegalBlockSizeException("Invalid AES-GCM packet size"); - } - byte[] byArray4 = Arrays.copyOfRange(byArray, 0, 12); - byte[] byArray5 = Arrays.copyOfRange(byArray, 12, byArray.length); - Cipher cipher = Cipher.getInstance(CIPHER); - cipher.init(2, (Key)this.keySpec, new GCMParameterSpec(128, byArray4)); - return cipher.doFinal(byArray5); - } - - public boolean equals(Object object) { - return object instanceof Secret && Arrays.equals(this.secret, ((Secret)object).secret); - } - - public int hashCode() { - return Arrays.hashCode(this.secret); - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/Server.java b/source/decompiled/de/maxhenkel/voicechat/voice/server/Server.java deleted file mode 100644 index 3cb1838..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/Server.java +++ /dev/null @@ -1,502 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * javax.annotation.Nullable - * org.bukkit.Bukkit - * org.bukkit.GameMode - * org.bukkit.Server - * org.bukkit.entity.Entity - * org.bukkit.entity.Player - */ -package de.maxhenkel.voicechat.voice.server; - -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.api.RawUdpPacket; -import de.maxhenkel.voicechat.api.VoicechatSocket; -import de.maxhenkel.voicechat.debug.CooldownTimer; -import de.maxhenkel.voicechat.debug.VoicechatUncaughtExceptionHandler; -import de.maxhenkel.voicechat.net.NetManager; -import de.maxhenkel.voicechat.permission.PermissionManager; -import de.maxhenkel.voicechat.plugins.PluginManager; -import de.maxhenkel.voicechat.voice.common.AuthenticateAckPacket; -import de.maxhenkel.voicechat.voice.common.AuthenticatePacket; -import de.maxhenkel.voicechat.voice.common.ConnectionCheckAckPacket; -import de.maxhenkel.voicechat.voice.common.ConnectionCheckPacket; -import de.maxhenkel.voicechat.voice.common.GroupSoundPacket; -import de.maxhenkel.voicechat.voice.common.KeepAlivePacket; -import de.maxhenkel.voicechat.voice.common.LocationSoundPacket; -import de.maxhenkel.voicechat.voice.common.MicPacket; -import de.maxhenkel.voicechat.voice.common.NetworkMessage; -import de.maxhenkel.voicechat.voice.common.Packet; -import de.maxhenkel.voicechat.voice.common.PingPacket; -import de.maxhenkel.voicechat.voice.common.PlayerSoundPacket; -import de.maxhenkel.voicechat.voice.common.PlayerState; -import de.maxhenkel.voicechat.voice.common.Secret; -import de.maxhenkel.voicechat.voice.common.SoundPacket; -import de.maxhenkel.voicechat.voice.common.Utils; -import de.maxhenkel.voicechat.voice.server.ClientConnection; -import de.maxhenkel.voicechat.voice.server.Group; -import de.maxhenkel.voicechat.voice.server.PingManager; -import de.maxhenkel.voicechat.voice.server.PlayerStateManager; -import de.maxhenkel.voicechat.voice.server.ServerCategoryManager; -import de.maxhenkel.voicechat.voice.server.ServerGroupManager; -import de.maxhenkel.voicechat.voice.server.ServerPlayerManager; -import java.net.InetAddress; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.nio.channels.AsynchronousCloseException; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public class Server -extends Thread { - private final Map connections; - private final Map unCheckedConnections; - private final Map secrets; - private final int port; - private final org.bukkit.Server server; - private final VoicechatSocket socket; - private final ProcessThread processThread; - private final BlockingQueue packetQueue; - private final PingManager pingManager; - private final PlayerStateManager playerStateManager; - private final ServerGroupManager groupManager; - private final ServerCategoryManager categoryManager; - - public Server() { - int configPort = Voicechat.SERVER_CONFIG.voiceChatPort.get(); - if (configPort < 0) { - Voicechat.LOGGER.info("Using the Minecraft servers port as voice chat port", new Object[0]); - this.port = Bukkit.getPort(); - } else { - this.port = configPort; - } - this.server = Bukkit.getServer(); - this.socket = PluginManager.instance().getSocketImplementation(); - this.connections = new ConcurrentHashMap(); - this.unCheckedConnections = new ConcurrentHashMap(); - this.secrets = new ConcurrentHashMap(); - this.packetQueue = new LinkedBlockingQueue(); - this.pingManager = new PingManager(this); - this.playerStateManager = new PlayerStateManager(); - this.groupManager = new ServerGroupManager(); - this.categoryManager = new ServerCategoryManager(); - this.setDaemon(true); - this.setName("VoiceChatServerThread"); - this.setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler()); - this.processThread = new ProcessThread(); - this.processThread.start(); - } - - @Override - public void run() { - try { - String bindAddress = this.getBindAddress(); - try { - InetAddress.getByName(bindAddress); - } - catch (UnknownHostException e) { - Voicechat.LOGGER.error("Failed to parse bind IP address '{}'", bindAddress, e); - Voicechat.LOGGER.info("Binding to wildcard IP address", new Object[0]); - bindAddress = ""; - } - this.socket.open(this.port, bindAddress); - if (bindAddress.isEmpty()) { - Voicechat.LOGGER.info("Voice chat server started at port {}", this.socket.getLocalPort()); - } else { - Voicechat.LOGGER.info("Voice chat server started at {}:{}", bindAddress, this.socket.getLocalPort()); - } - while (!this.socket.isClosed()) { - try { - this.packetQueue.add(this.socket.read()); - } - catch (Exception e) { - if (e instanceof SocketException && e.getCause() instanceof AsynchronousCloseException || !Voicechat.debugMode()) continue; - Voicechat.LOGGER.error("Failed to read from socket", e); - } - } - } - catch (Exception e) { - Voicechat.LOGGER.error("Voice chat server error", e); - } - } - - private String getBindAddress() { - String bindAddress; - block8: { - bindAddress = Voicechat.SERVER_CONFIG.voiceChatBindAddress.get(); - if (bindAddress.trim().equals("*")) { - bindAddress = ""; - } else if (bindAddress.trim().isEmpty()) { - try { - bindAddress = Bukkit.getIp(); - if (bindAddress.trim().isEmpty()) break block8; - try { - InetAddress address = InetAddress.getByName(bindAddress); - if (address.isLoopbackAddress()) { - bindAddress = ""; - break block8; - } - Voicechat.LOGGER.info("Using server-ip as bind address: {}", bindAddress); - } - catch (Exception e) { - Voicechat.LOGGER.warn("Invalid server-ip", e); - bindAddress = ""; - } - } - catch (Throwable t) { - Voicechat.LOGGER.warn("Failed to get server-ip from server.properties - binding to wildcard address", t); - } - } - } - return bindAddress; - } - - public Secret getSecret(UUID playerUUID) { - if (this.hasSecret(playerUUID)) { - return this.secrets.get(playerUUID); - } - Secret secret = Secret.generateNewRandomSecret(); - this.secrets.put(playerUUID, secret); - return secret; - } - - @Nullable - public Secret generateNewSecret(UUID playerUUID) { - if (this.hasSecret(playerUUID)) { - return null; - } - return this.getSecret(playerUUID); - } - - public boolean hasSecret(UUID playerUUID) { - return this.secrets.containsKey(playerUUID); - } - - public void disconnectClient(UUID playerUUID) { - this.connections.remove(playerUUID); - this.unCheckedConnections.remove(playerUUID); - this.secrets.remove(playerUUID); - PluginManager.instance().onPlayerDisconnected(playerUUID); - } - - public void close() { - this.socket.close(); - this.processThread.close(); - PluginManager.instance().onServerStopped(); - } - - public boolean isClosed() { - return !this.processThread.running; - } - - public void onMicPacket(UUID playerUuid, MicPacket packet) { - Player player = this.server.getPlayer(playerUuid); - if (player == null) { - return; - } - if (!player.hasPermission(PermissionManager.SPEAK_PERMISSION)) { - CooldownTimer.run("no-speak-" + playerUuid, () -> NetManager.sendStatusMessage(player, "message.voicechat.no_speak_permission", new String[0])); - return; - } - PlayerState state = this.playerStateManager.getState(player.getUniqueId()); - if (state == null) { - return; - } - if (!PluginManager.instance().onMicPacket(player, state, packet)) { - this.processMicPacket(player, state, packet); - } - } - - private void processMicPacket(Player player, PlayerState state, MicPacket packet) { - if (state.hasGroup()) { - Group group = this.groupManager.getGroup(state.getGroup()); - this.processGroupPacket(state, player, packet); - if (group == null || group.isOpen()) { - this.processProximityPacket(state, player, packet); - } - return; - } - this.processProximityPacket(state, player, packet); - } - - private void processGroupPacket(PlayerState senderState, Player sender, MicPacket packet) { - UUID groupId = senderState.getGroup(); - if (groupId == null) { - return; - } - GroupSoundPacket groupSoundPacket = new GroupSoundPacket(senderState.getUuid(), senderState.getUuid(), packet.getData(), packet.getSequenceNumber(), null); - for (PlayerState state : this.playerStateManager.getStates()) { - Player p; - if (!groupId.equals(state.getGroup()) || senderState.getUuid().equals(state.getUuid()) || (p = this.server.getPlayer(state.getUuid())) == null) continue; - ClientConnection connection = this.getConnection(state.getUuid()); - this.sendSoundPacket(sender, senderState, p, state, connection, groupSoundPacket, "group"); - } - } - - private void processProximityPacket(PlayerState senderState, Player sender, MicPacket packet) { - UUID groupId = senderState.getGroup(); - float distance = packet.isWhispering() ? Voicechat.SERVER_CONFIG.whisperDistance.get().floatValue() : Utils.getDefaultDistance(); - distance = PluginManager.instance().getDistance(sender, senderState, packet, distance); - SoundPacket soundPacket = null; - String source = null; - if (sender.getGameMode().equals((Object)GameMode.SPECTATOR)) { - Player spectatingPlayer; - Entity camera; - if (Voicechat.SERVER_CONFIG.spectatorPlayerPossession.get().booleanValue() && (camera = sender.getSpectatorTarget()) instanceof Player && (spectatingPlayer = (Player)camera) != sender) { - PlayerState receiverState = this.playerStateManager.getState(spectatingPlayer.getUniqueId()); - if (receiverState == null) { - return; - } - GroupSoundPacket groupSoundPacket = new GroupSoundPacket(senderState.getUuid(), senderState.getUuid(), packet.getData(), packet.getSequenceNumber(), null); - ClientConnection connection = this.getConnection(receiverState.getUuid()); - this.sendSoundPacket(sender, senderState, spectatingPlayer, receiverState, connection, groupSoundPacket, "spectator"); - return; - } - if (Voicechat.SERVER_CONFIG.spectatorInteraction.get().booleanValue()) { - soundPacket = new LocationSoundPacket(sender.getUniqueId(), sender.getUniqueId(), sender.getLocation(), packet.getData(), packet.getSequenceNumber(), distance, null); - source = "spectator"; - } - } - if (soundPacket == null) { - soundPacket = new PlayerSoundPacket(sender.getUniqueId(), sender.getUniqueId(), packet.getData(), packet.getSequenceNumber(), packet.isWhispering(), distance, null); - source = "proximity"; - } - this.broadcast(ServerPlayerManager.getPlayersInRange(sender.getWorld(), sender.getLocation(), this.getBroadcastRange(distance), p -> !p.getUniqueId().equals(sender.getUniqueId())), soundPacket, sender, senderState, groupId, source); - } - - public void sendSoundPacket(@Nullable Player sender, @Nullable PlayerState senderState, Player receiver, PlayerState receiverState, @Nullable ClientConnection connection, SoundPacket soundPacket, String source) { - PluginManager.instance().onListenerAudio(receiver.getUniqueId(), soundPacket); - if (connection == null) { - return; - } - if (receiverState.isDisabled() || receiverState.isDisconnected()) { - return; - } - if (PluginManager.instance().onSoundPacket(sender, senderState, receiver, receiverState, soundPacket, source)) { - return; - } - if (!receiver.hasPermission(PermissionManager.LISTEN_PERMISSION)) { - CooldownTimer.run(String.format("no-listen-%s", receiver.getUniqueId()), 30000L, () -> NetManager.sendStatusMessage(receiver, "message.voicechat.no_listen_permission", new String[0])); - return; - } - this.sendPacket(soundPacket, connection); - } - - public double getBroadcastRange(float minRange) { - double broadcastRange = Voicechat.SERVER_CONFIG.broadcastRange.get(); - if (broadcastRange < 0.0) { - broadcastRange = Voicechat.SERVER_CONFIG.voiceChatDistance.get() + 1.0; - } - return Math.max(broadcastRange, (double)minRange); - } - - public void broadcast(Collection players, SoundPacket packet, @Nullable Player sender, @Nullable PlayerState senderState, @Nullable UUID groupId, String source) { - for (Player player : players) { - PlayerState state = this.playerStateManager.getState(player.getUniqueId()); - if (state == null || state.hasGroup() && state.getGroup().equals(groupId)) continue; - Group receiverGroup = null; - if (state.hasGroup()) { - receiverGroup = this.groupManager.getGroup(state.getGroup()); - } - if (receiverGroup != null && receiverGroup.isIsolated()) continue; - ClientConnection connection = this.getConnection(state.getUuid()); - this.sendSoundPacket(sender, senderState, player, state, connection, packet, source); - } - } - - private void sendKeepAlives() { - long timestamp = System.currentTimeMillis(); - this.connections.values().removeIf(connection -> { - if (timestamp - connection.getLastKeepAliveResponse() >= (long)Voicechat.SERVER_CONFIG.keepAlive.get().intValue() * 10L) { - this.secrets.remove(connection.getPlayerUUID()); - Voicechat.LOGGER.info("Player {} timed out", connection.getPlayerUUID()); - Player player = this.server.getPlayer(connection.getPlayerUUID()); - if (player != null) { - Voicechat.LOGGER.info("Reconnecting player {}", player.getName()); - Voicechat.SERVER.initializePlayerConnection(player); - } else { - Voicechat.LOGGER.error("Reconnecting player {} failed (Could not find player)", connection.getPlayerUUID()); - } - this.playerStateManager.onPlayerVoicechatDisconnect(connection.getPlayerUUID()); - PluginManager.instance().onPlayerDisconnected(connection.getPlayerUUID()); - return true; - } - return false; - }); - for (ClientConnection connection2 : this.connections.values()) { - this.sendPacket(new KeepAlivePacket(), connection2); - } - } - - @Nullable - public ClientConnection getSender(NetworkMessage message) { - return this.connections.values().stream().filter(connection -> connection.getAddress().equals(message.getAddress())).findAny().orElse(null); - } - - @Nullable - public ClientConnection getUnconnectedSender(NetworkMessage message) { - return this.unCheckedConnections.values().stream().filter(connection -> connection.getAddress().equals(message.getAddress())).findAny().orElse(null); - } - - public Map getConnections() { - return this.connections; - } - - @Nullable - public ClientConnection getConnection(UUID playerID) { - return this.connections.get(playerID); - } - - public VoicechatSocket getSocket() { - return this.socket; - } - - public int getPort() { - return this.socket.getLocalPort(); - } - - public boolean sendPacket(Packet packet, ClientConnection connection) { - try { - this.sendPacketRaw(packet, connection); - return true; - } - catch (Exception e) { - Voicechat.LOGGER.error("Failed to send voice chat packet to {}", connection.getPlayerUUID()); - return false; - } - } - - public void sendPacketRaw(Packet packet, ClientConnection connection) throws Exception { - connection.send(this, new NetworkMessage(packet)); - } - - public PingManager getPingManager() { - return this.pingManager; - } - - public PlayerStateManager getPlayerStateManager() { - return this.playerStateManager; - } - - public ServerGroupManager getGroupManager() { - return this.groupManager; - } - - public ServerCategoryManager getCategoryManager() { - return this.categoryManager; - } - - private class ProcessThread - extends Thread { - private boolean running = true; - private long lastKeepAlive = 0L; - - public ProcessThread() { - this.setDaemon(true); - this.setName("VoiceChatPacketProcessingThread"); - this.setUncaughtExceptionHandler(new VoicechatUncaughtExceptionHandler()); - } - - @Override - public void run() { - while (this.running) { - try { - NetworkMessage message; - RawUdpPacket rawPacket; - Server.this.pingManager.checkTimeouts(); - long keepAliveTime = System.currentTimeMillis(); - if (keepAliveTime - this.lastKeepAlive > (long)Voicechat.SERVER_CONFIG.keepAlive.get().intValue()) { - Server.this.sendKeepAlives(); - this.lastKeepAlive = keepAliveTime; - } - if ((rawPacket = (RawUdpPacket)Server.this.packetQueue.poll(10L, TimeUnit.MILLISECONDS)) == null) continue; - try { - message = NetworkMessage.readPacketServer(rawPacket, Server.this); - } - catch (Exception e) { - CooldownTimer.run("failed_reading_packet", () -> Voicechat.LOGGER.warn("Failed to read packet from {}", rawPacket.getSocketAddress())); - continue; - } - if (message == null) continue; - if (System.currentTimeMillis() - message.getTimestamp() > message.getTTL()) { - CooldownTimer.run("ttl", () -> { - Voicechat.LOGGER.error("Dropping voice chat packets! Your Server might be overloaded!", new Object[0]); - Voicechat.LOGGER.error("Packet queue has {} packets", Server.this.packetQueue.size()); - }); - continue; - } - if (message.getPacket() instanceof AuthenticatePacket) { - AuthenticatePacket packet = (AuthenticatePacket)message.getPacket(); - Secret secret = (Secret)Server.this.secrets.get(packet.getPlayerUUID()); - if (secret != null && secret.equals(packet.getSecret())) { - ClientConnection connection = (ClientConnection)Server.this.unCheckedConnections.get(packet.getPlayerUUID()); - if (connection == null) { - connection = (ClientConnection)Server.this.connections.get(packet.getPlayerUUID()); - } - if (connection == null) { - connection = new ClientConnection(packet.getPlayerUUID(), message.getAddress()); - Server.this.unCheckedConnections.put(packet.getPlayerUUID(), connection); - Voicechat.LOGGER.info("Successfully authenticated player {}", packet.getPlayerUUID()); - } - Server.this.sendPacket(new AuthenticateAckPacket(), connection); - } - } - if (message.getPacket() instanceof ConnectionCheckPacket) { - ClientConnection connection = Server.this.getUnconnectedSender(message); - if (connection == null) { - connection = Server.this.getSender(message); - if (connection == null) continue; - Server.this.sendPacket(new ConnectionCheckAckPacket(), connection); - continue; - } - connection.setLastKeepAliveResponse(System.currentTimeMillis()); - Server.this.connections.put(connection.getPlayerUUID(), connection); - Server.this.unCheckedConnections.remove(connection.getPlayerUUID()); - Voicechat.LOGGER.info("Successfully validated connection of player {}", connection.getPlayerUUID()); - Player player = Server.this.server.getPlayer(connection.getPlayerUUID()); - if (player != null) { - Server.this.playerStateManager.onPlayerVoicechatConnect(player); - PluginManager.instance().onPlayerConnected(player); - Voicechat.LOGGER.info("Player {} ({}) successfully connected to voice chat", player.getName(), connection.getPlayerUUID()); - } - Server.this.sendPacket(new ConnectionCheckAckPacket(), connection); - continue; - } - ClientConnection conn = Server.this.getSender(message); - if (conn == null) continue; - if (message.getPacket() instanceof MicPacket) { - Server.this.onMicPacket(conn.getPlayerUUID(), (MicPacket)message.getPacket()); - continue; - } - if (message.getPacket() instanceof PingPacket) { - PingPacket packet = (PingPacket)message.getPacket(); - Server.this.pingManager.onPongPacket(packet); - continue; - } - if (!(message.getPacket() instanceof KeepAlivePacket)) continue; - conn.setLastKeepAliveResponse(System.currentTimeMillis()); - } - catch (Exception e) { - Voicechat.LOGGER.error("Voice chat server error", e); - } - } - } - - public void close() { - this.running = false; - } - } -} - diff --git a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java b/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java deleted file mode 100644 index f1886cc..0000000 --- a/source/decompiled/de/maxhenkel/voicechat/voice/server/ServerVoiceEvents.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Decompiled with CFR 0.152. - * - * Could not load the following classes: - * org.bukkit.Bukkit - * org.bukkit.entity.Player - * org.bukkit.event.EventHandler - * org.bukkit.event.Listener - * org.bukkit.event.player.PlayerJoinEvent - * org.bukkit.event.player.PlayerQuitEvent - */ -package de.maxhenkel.voicechat.voice.server; - -import de.maxhenkel.voicechat.Voicechat; -import de.maxhenkel.voicechat.compatibility.PlayerHideEvent; -import de.maxhenkel.voicechat.compatibility.PlayerShowEvent; -import de.maxhenkel.voicechat.net.NetManager; -import de.maxhenkel.voicechat.net.PacketRateLimiter; -import de.maxhenkel.voicechat.net.RequestSecretPacket; -import de.maxhenkel.voicechat.net.SecretPacket; -import de.maxhenkel.voicechat.plugins.PluginManager; -import de.maxhenkel.voicechat.voice.common.Secret; -import de.maxhenkel.voicechat.voice.server.Server; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -public class ServerVoiceEvents -implements Listener { - private static final int LEGACY_COMPATIBILITY_VERSION = 18; - private static final int CURRENT_COMPATIBILITY_VERSION = 20; - private final Map clientCompatibilities = new ConcurrentHashMap(); - private final PacketRateLimiter rateLimiter; - private Server server; - - public ServerVoiceEvents() { - this.rateLimiter = new PacketRateLimiter(Voicechat.SERVER_CONFIG.tcpRateLimit.get()); - } - - public void init() { - if (this.server != null) { - return; - } - if (!Bukkit.getOnlineMode()) { - Voicechat.LOGGER.warn("Running in offline mode - Voice chat encryption is not secure!", new Object[0]); - } - Voicechat.compatibility.registerPlayerHideEvent(this::onPlayerHide); - Voicechat.compatibility.registerPlayerShowEvent(this::onPlayerShow); - this.server = new Server(); - this.server.start(); - PluginManager.instance().onServerStarted(); - } - - public void onRequestSecretPacket(Player player, RequestSecretPacket requestSecretPacket) { - UUID uUID; - int n = requestSecretPacket.getCompatibilityVersion(); - Voicechat.LOGGER.info("Received secret request of {} ({})", player.getName(), n); - try { - uUID = player.getUniqueId(); - } - catch (UnsupportedOperationException unsupportedOperationException) { - player.kickPlayer("Tried to authenticate voice chat while still connecting"); - Voicechat.LOGGER.warn("{} tried to authenticate voice chat while still connecting", player.getName()); - return; - } - this.clientCompatibilities.put(uUID, n); - if (!ServerVoiceEvents.isSupportedCompatibilityVersion(n)) { - Voicechat.LOGGER.warn("Connected client {} has incompatible voice chat version (server={}, client={})", player.getName(), Voicechat.COMPATIBILITY_VERSION, n); - ServerVoiceEvents.sendIncompatibleMessage(player, n); - return; - } - this.initializePlayerConnection(player); - } - - private static boolean isSupportedCompatibilityVersion(int n) { - return n == 18 || n == 20; - } - - public boolean isCompatible(Player player) { - return this.isCompatible(player.getUniqueId()); - } - - public boolean isCompatible(UUID uUID) { - return ServerVoiceEvents.isSupportedCompatibilityVersion(this.clientCompatibilities.getOrDefault(uUID, -1)); - } - - public static void sendIncompatibleMessage(Player player, int n) { - if (n <= 6) { - player.sendMessage(String.format(Voicechat.TRANSLATIONS.voicechatNotCompatibleMessage.get(), "2.6.x", "Simple Voice Chat")); - } else { - Voicechat.compatibility.sendIncompatibleMessage(player, "2.6.x", "Simple Voice Chat"); - } - } - - public void initializePlayerConnection(Player player) { - if (this.server == null) { - return; - } - UUID uUID = player.getUniqueId(); - this.server.getPlayerStateManager().onPlayerCompatibilityCheckSucceeded(player); - this.server.getCategoryManager().onPlayerCompatibilityCheckSucceeded(player); - this.server.getGroupManager().onPlayerCompatibilityCheckSucceeded(player); - Secret secret = this.server.generateNewSecret(uUID); - if (secret == null) { - Voicechat.LOGGER.warn("Player already requested secret - ignoring", new Object[0]); - return; - } - secret.setLegacyProtocol(this.clientCompatibilities.getOrDefault(uUID, -1) == 18); - String string = PluginManager.instance().getVoiceHost(player, Voicechat.SERVER_CONFIG.voiceHost.get()); - NetManager.sendToClient(player, new SecretPacket(player, secret, this.server.getPort(), Voicechat.SERVER_CONFIG, string)); - Voicechat.LOGGER.info("Sent secret to {}", player.getName()); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent playerJoinEvent) { - this.server.getPlayerStateManager().onPlayerJoin(playerJoinEvent); - if (!Voicechat.SERVER_CONFIG.forceVoiceChat.get().booleanValue()) { - return; - } - Player player = playerJoinEvent.getPlayer(); - Voicechat.compatibility.runTaskLater(() -> { - if (!player.isOnline()) { - return; - } - if (!this.isCompatible(player)) { - player.kickPlayer(String.format(Voicechat.TRANSLATIONS.forceVoicechatKickMessage.get(), "Simple Voice Chat", Voicechat.INSTANCE.getDescription().getVersion())); - } - }, (long)Voicechat.SERVER_CONFIG.loginTimeout.get().intValue() / 50L); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent playerQuitEvent) { - this.server.getPlayerStateManager().onPlayerQuit(playerQuitEvent); - this.server.getGroupManager().onPlayerQuit(playerQuitEvent); - UUID uUID = playerQuitEvent.getPlayer().getUniqueId(); - this.clientCompatibilities.remove(uUID); - this.rateLimiter.onPlayerLoggedOut(playerQuitEvent.getPlayer()); - if (this.server == null) { - return; - } - this.server.disconnectClient(uUID); - Voicechat.LOGGER.info("Disconnecting client {}", playerQuitEvent.getPlayer().getName()); - } - - public void onPlayerHide(PlayerHideEvent playerHideEvent) { - this.server.getPlayerStateManager().onPlayerHide(playerHideEvent); - } - - public void onPlayerShow(PlayerShowEvent playerShowEvent) { - this.server.getPlayerStateManager().onPlayerShow(playerShowEvent); - } - - public PacketRateLimiter getRateLimiter() { - return this.rateLimiter; - } - - public Server getServer() { - return this.server; - } -} - diff --git a/source/decompiled/summary.txt b/source/decompiled/summary.txt deleted file mode 100644 index 559f9a2..0000000 --- a/source/decompiled/summary.txt +++ /dev/null @@ -1,2 +0,0 @@ -Summary for A:\Projekty\voicechat\git\AsminVoiceChat-1.0.0.jar -Decompiled with CFR 0.152 diff --git a/source/resources/CONCENTUS_LICENSE b/source/resources/CONCENTUS_LICENSE deleted file mode 100644 index 62d21b6..0000000 --- a/source/resources/CONCENTUS_LICENSE +++ /dev/null @@ -1,37 +0,0 @@ -Copyright (c) by various holding parties, including (but not limited to): -Skype Limited, Xiph.Org Foundation, CSIRO, Microsoft Corporation, -Jean-Marc Valin, Gregory Maxwell, Mark Borgerding, Timothy B. Terriberry, -Logan Stromberg. All rights are reserved by their respective holders. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of Internet Society, IETF or IETF Trust, nor the - names of specific contributors, may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -This repository and its redistributable packages contain independently compiled -versions of the Opus C reference library, which is maintained by Xiph.org and the -Opus open-source contributors. The source code for these libraries is freely available -at https://gitlab.xiph.org/xiph/opus/-/tags/v1.5.2, and all binaries are being -redistributed to you under the same terms of the general Opus license dictated above. \ No newline at end of file diff --git a/source/resources/META-INF/MANIFEST.MF b/source/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 936a396..0000000 --- a/source/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: voicechat-api-2.6.25.jar configbuilder-2.1.0.jar json-202512 - 24.jar commodore-2.2.jar Concentus-1.0.1.jar commodore-file-1.0.jar bri - gadier-1.0.18.jar -Multi-Release: true - diff --git a/source/resources/META-INF/maven/de.maxhenkel.configbuilder/configbuilder/pom.properties b/source/resources/META-INF/maven/de.maxhenkel.configbuilder/configbuilder/pom.properties deleted file mode 100644 index 083c94a..0000000 --- a/source/resources/META-INF/maven/de.maxhenkel.configbuilder/configbuilder/pom.properties +++ /dev/null @@ -1,3 +0,0 @@ -artifactId=configbuilder -groupId=de.maxhenkel.configbuilder -version=2.1.0 diff --git a/source/resources/META-INF/maven/de.maxhenkel.configbuilder/configbuilder/pom.xml b/source/resources/META-INF/maven/de.maxhenkel.configbuilder/configbuilder/pom.xml deleted file mode 100644 index 8ffeade..0000000 --- a/source/resources/META-INF/maven/de.maxhenkel.configbuilder/configbuilder/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 4.0.0 - - de.maxhenkel.configbuilder - configbuilder - 2.1.0 - - - 8 - 8 - UTF-8 - - - - - com.google.code.findbugs - jsr305 - 3.0.2 - provided - - - org.junit.jupiter - junit-jupiter - 5.9.2 - test - - - org.mockito - mockito-core - 5.4.0 - test - - - - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - verify - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - -Dfile.encoding=UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - - - - - - - henkelmax.public - https://maven.maxhenkel.de/repository/public - - - - \ No newline at end of file diff --git a/source/resources/META-INF/maven/me.lucko/commodore/pom.properties b/source/resources/META-INF/maven/me.lucko/commodore/pom.properties deleted file mode 100644 index dd61b5d..0000000 --- a/source/resources/META-INF/maven/me.lucko/commodore/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Wed Aug 03 22:00:27 BST 2022 -groupId=me.lucko -artifactId=commodore -version=2.2 diff --git a/source/resources/META-INF/maven/me.lucko/commodore/pom.xml b/source/resources/META-INF/maven/me.lucko/commodore/pom.xml deleted file mode 100644 index 05aeec3..0000000 --- a/source/resources/META-INF/maven/me.lucko/commodore/pom.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - 4.0.0 - - me.lucko - commodore - 2.2 - - commodore - Utility for using Minecraft's 1.13 'brigadier' library in Bukkit plugins. - https://github.com/lucko/commodore - - - - MIT - https://opensource.org/licenses/MIT - - - - - - Luck - git@lucko.me - https://github.com/lucko - - - - - scm:git:https://github.com/lucko/commodore.git - scm:git:git@github.com:lucko/commodore.git - https://github.com/lucko/commodore - - - - UTF-8 - 1.8 - 1.8 - - - - - me.lucko - commodore-file - 1.0 - compile - - - com.mojang - brigadier - - - - - com.mojang - brigadier - 1.0.18 - compile - - - com.google.guava - guava - - - - - io.papermc.paper - paper-api - 1.19.1-R0.1-SNAPSHOT - provided - - - io.papermc.paper - paper-mojangapi - 1.19.1-R0.1-SNAPSHOT - provided - - - - - - minecraft-repo - https://libraries.minecraft.net/ - - - papermc - https://repo.papermc.io/repository/maven-public/ - - - - - - sign - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - - - - - - ossrh - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - deployment - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.4.0 - - - attach-javadocs - - jar - - - - - - - - - - \ No newline at end of file diff --git a/source/resources/META-INF/maven/org.concentus/Concentus/pom.properties b/source/resources/META-INF/maven/org.concentus/Concentus/pom.properties deleted file mode 100644 index d1e58be..0000000 --- a/source/resources/META-INF/maven/org.concentus/Concentus/pom.properties +++ /dev/null @@ -1,3 +0,0 @@ -artifactId=Concentus -groupId=org.concentus -version=1.0.1 diff --git a/source/resources/META-INF/maven/org.concentus/Concentus/pom.xml b/source/resources/META-INF/maven/org.concentus/Concentus/pom.xml deleted file mode 100644 index 7352e4a..0000000 --- a/source/resources/META-INF/maven/org.concentus/Concentus/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - 4.0.0 - org.concentus - Concentus - 1.0.1 - jar - - UTF-8 - 1.8 - 1.8 - - Concentus - This package is a pure portable Java implementation of the Opus audio compression codec (see - https://opus-codec.org/ for more details). This package contains the Opus encoder, decoder, multistream codecs, - and repacketizer. It does NOT contain code to parse .ogg or .opus container files or to manage RTP packet - streams. - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.14.0 - - 8 - 8 - - - - maven-antrun-plugin - 3.1.0 - - - copy-and-rename-license - process-resources - - run - - - - - - - - - - - - - - - henkelmax.public - https://maven.maxhenkel.de/repository/public - - - - \ No newline at end of file diff --git a/source/resources/META-INF/maven/org.json/json/pom.properties b/source/resources/META-INF/maven/org.json/json/pom.properties deleted file mode 100644 index 8683715..0000000 --- a/source/resources/META-INF/maven/org.json/json/pom.properties +++ /dev/null @@ -1,3 +0,0 @@ -version=20251224 -groupId=org.json -artifactId=json diff --git a/source/resources/META-INF/maven/org.json/json/pom.xml b/source/resources/META-INF/maven/org.json/json/pom.xml deleted file mode 100644 index 6269edc..0000000 --- a/source/resources/META-INF/maven/org.json/json/pom.xml +++ /dev/null @@ -1,263 +0,0 @@ - - 4.0.0 - - org.json - json - 20251224 - bundle - - JSON in Java - - JSON is a light-weight, language independent, data interchange format. - See http://www.JSON.org/ - - The files in this package implement JSON encoders/decoders in Java. - It also includes the capability to convert between JSON and XML, HTTP - headers, Cookies, and CDL. - - This is a reference implementation. There are a large number of JSON packages - in Java. Perhaps someday the Java community will standardize on one. Until - then, choose carefully. - - https://github.com/douglascrockford/JSON-java - - - https://github.com/douglascrockford/JSON-java.git - scm:git:git://github.com/douglascrockford/JSON-java.git - scm:git:git@github.com:douglascrockford/JSON-java.git - - - - - Public Domain - https://github.com/stleary/JSON-java/blob/master/LICENSE - repo - - - - - - Douglas Crockford - douglas@crockford.com - - - - - UTF-8 - - - - - - ossrh - Central Repository OSSRH - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - - - - - junit - junit - 4.13.2 - test - - - com.jayway.jsonpath - json-path - 2.9.0 - test - - - org.mockito - mockito-core - 4.2.0 - test - - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.9.0 - true - - central - - - - org.apache.felix - maven-bundle-plugin - 5.1.9 - true - - - - org.json - - ${project.artifactId} - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - 1.8 - 1.8 - - -Xlint:unchecked - - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.0 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.5.0 - - - attach-javadocs - - jar - - - -Xdoclint:none - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 - true - - ossrh - https://oss.sonatype.org/ - false - - - - org.moditect - moditect-maven-plugin - 1.0.0.Final - - - add-module-infos - package - - add-module-info - - - 9 - - - module org.json { - exports org.json; - } - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - - - test-strict-mode - - - - com.google.code.maven-replacer-plugin - replacer - 1.5.3 - - - - enable-strict-mode - process-sources - - replace - - - src/main/java/org/json/JSONParserConfiguration.java - - - // this.strictMode = true; - this.strictMode = true; - - - - - - - restore-original - test - - replace - - - src/main/java/org/json/JSONParserConfiguration.java - - - this.strictMode = true; - // this.strictMode = true; - - - - - - - - - - - - diff --git a/source/resources/plugin.yml b/source/resources/plugin.yml deleted file mode 100644 index 5803eba..0000000 --- a/source/resources/plugin.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: AsminVoicechat -version: 1.0.0 -main: de.maxhenkel.voicechat.Voicechat -api-version: '1.13' -prefix: AsminVoicechat -authors: - - Asmin Studios (asmin.me) - - Max Henkel - - Matthew Wells -description: Simple Voice Chat server fork with support for 2.5 and 2.6 clients -website: https://git.asmin.me/asminme/AsminVoicechat -load: STARTUP -provides: [voicechat] -folia-supported: true -commands: - voicechat: - description: Manage voice chat - usage: Invalid command syntax -permissions: - voicechat.listen: - description: Allows to listen to voice chat - voicechat.speak: - description: Allows to speak in voice chat - voicechat.groups: - description: Allows to join groups - voicechat.admin: - description: Allows to test voice chat connections -softdepend: [PlaceholderAPI, ViaVersion]