Merge changes I7bbf776e,I1b827825 am: fe8b4a6579 * commit 'fe8b4a657979b49e1701bd92f6d5814a99e0b2be': (7237 commits) WIP: Changes after merge commit 'cb3f9bd' Make the nonlinear beamformer steerable Utilize bitrate above codec max to protect video. Enable VP9 internal resize by default. Filter overlapping RTP header extensions. Make VCMEncodedFrameCallback const. MediaCodecVideoEncoder: Add number of quality resolution downscales to Encoded callback. Remove redudant encoder rate calls. Create isolate files for nonparallel tests. Register header extensions in RtpRtcpObserver to avoid log spam. Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table ACM: Move NACK functionality inside NetEq Fix chromium-style warnings in webrtc/sound/. Create a 'webrtc_nonparallel_tests' target. Update scalability structure data according to updates in the RTP payload profile. audio_coding: rename interface -> include Rewrote perform_action_on_all_files to be parallell. Update reference indices according to updates in the RTP payload profile. Disable P2PTransport...TestFailoverControlledSide on Memcheck pass clangcl compile options to ignore warnings in gflags.cc ...
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..0a89601 --- /dev/null +++ b/.clang-format
@@ -0,0 +1,3 @@ +# Defines the Chromium style for automatic reformatting. +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +BasedOnStyle: Chromium
diff --git a/.gitignore b/.gitignore index 29ef23e..b29171c 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,6 +1,6 @@ -*.host.mk -*.target.mk +*.DS_Store *.Makefile +*.host.mk *.ncb *.ninja *.props @@ -10,6 +10,7 @@ *.sdf *.sln *.suo +*.target.mk *.targets *.user *.vcproj @@ -20,47 +21,160 @@ *.vpwhistu *.vtg *.xcodeproj +*_proto.xml +*_proto_cpp.xml *~ .*.sw? -.DS_Store +.classpath .cproject .gdb_history .gdbinit +.landmines .metadata .project .pydevproject .settings -/build -/chromium_deps -/gyp-mac-tool +.sw? /Makefile +/base +/build +/buildtools +/chromium/.gclient.tmp +/chromium/.gclient.tmp_entries +/chromium/.last_sync_chromium +/chromium/_bad_scm +/chromium/src +/google_apis +/gyp-mac-tool +/links +/links.db +/net /out -/resources -/src/supplement.gypi +/resources/**/*.aecdump +/resources/**/*.bin +/resources/**/*.chn +/resources/**/*.dat +/resources/**/*.gai +/resources/**/*.jpg +/resources/**/*.pcap +/resources/**/*.pcm +/resources/**/*.rtp +/resources/**/*.rx +/resources/**/*.wav +/resources/**/*.yuv +/resources/**/*.BIT* +/resources/**/*.INP +/resources/**/*.OUT* +/talk/examples/android/bin +/talk/examples/android/gen +/talk/examples/android/libs +/talk/examples/android/local.properties +/talk/examples/android/obj +/talk/examples/android/proguard-project.txt +/talk/examples/androidtests/bin +/talk/examples/androidtests/gen +/talk/app/webrtc/androidtests/bin +/talk/app/webrtc/androidtests/gen +/talk/app/webrtc/androidtests/libs /testing +/third_party/WebKit/Tools/Scripts +/third_party/android_platform +/third_party/android_testrunner +/third_party/android_tools +/third_party/appurify-python /third_party/asan +/third_party/ashmem +/third_party/binutils +/third_party/boringssl +/third_party/BUILD.gn +/third_party/clang_format +/third_party/class-dump +/third_party/colorama /third_party/cygwin +/third_party/directxsdk +/third_party/drmemory /third_party/expat /third_party/gaeunit -/third_party/gold -/third_party/google-gflags/src +/third_party/gflags/src /third_party/google-visualization-python +/third_party/icu +/third_party/instrumented_libraries +/third_party/ijar /third_party/jsoncpp +/third_party/jsr-305 +/third_party/junit +/third_party/junit-jar +/third_party/libc++ +/third_party/libc++abi +/third_party/libevent /third_party/libjingle /third_party/libjpeg /third_party/libjpeg_turbo /third_party/libsrtp -/third_party/libvpx +/third_party/libvpx_new +/third_party/libxml +/third_party/libudev /third_party/libyuv +/third_party/llvm /third_party/llvm-build +/third_party/lss +/third_party/mockito +/third_party/modp_b64 +/third_party/nss /third_party/oauth2 +/third_party/ocmock +/third_party/openmax_dl +/third_party/opus +/third_party/proguard /third_party/protobuf +/third_party/requests +/third_party/robolectric +/third_party/sqlite +/third_party/syzygy +/third_party/usrsctp /third_party/valgrind +/third_party/WebKit +/third_party/winsdk_samples/src /third_party/yasm +/third_party/zlib +/tools/android /tools/clang +/tools/find_depot_tools.py +/tools/generate_library_loader +/tools/gn +/tools/grit /tools/gyp +/tools/isolate_driver.py +/tools/memory +/tools/protoc_wrapper /tools/python +/tools/relocation_packer +/tools/sanitizer_options +/tools/swarming_client +/tools/tsan_suppressions /tools/valgrind +/tools/vim /tools/win +/tools/xdisplaycheck +/tools/whitespace.txt +/webrtc/examples/android/media_demo/bin +/webrtc/examples/android/media_demo/gen +/webrtc/examples/android/media_demo/libs +/webrtc/examples/android/media_demo/local.properties +/webrtc/examples/android/media_demo/obj +/webrtc/examples/android/media_demo/proguard-project.txt +/webrtc/examples/android/opensl_loopback/bin +/webrtc/examples/android/opensl_loopback/gen +/webrtc/examples/android/opensl_loopback/libs +/webrtc/examples/android/opensl_loopback/local.properties +/webrtc/examples/android/opensl_loopback/obj +/webrtc/examples/android/opensl_loopback/proguard-project.txt +/webrtc/modules/audio_device/android/test/bin/ +/webrtc/modules/audio_device/android/test/gen/ +/webrtc/modules/audio_device/android/test/libs/ +/webrtc/video_engine/test/android/bin +/webrtc/video_engine/test/android/gen +/webrtc/video_engine/test/android/libs +/webrtc/video_engine/test/android/obj /x86-generic_out/ /xcodebuild
diff --git a/.gn b/.gn new file mode 100644 index 0000000..d078116 --- /dev/null +++ b/.gn
@@ -0,0 +1,47 @@ +# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# The location of the build configuration file. +buildconfig = "//build/config/BUILDCONFIG.gn" + +# The secondary source root is a parallel directory tree where +# GN build files are placed when they can not be placed directly +# in the source tree, e.g. for third party source trees. +secondary_source = "//build/secondary/" + +# These are the targets to check headers for by default. The files in targets +# matching these patterns (see "gn help label_pattern" for format) will have +# their includes checked for proper dependencies when you run either +# "gn check" or "gn gen --check". +check_targets = [ "//webrtc/*" ] + +# These are the list of GN files that run exec_script. This whitelist exists +# to force additional review for new uses of exec_script, which is strongly +# discouraged except for gypi_to_gn calls. +exec_script_whitelist = [ + "//build/config/android/BUILD.gn", + "//build/config/android/config.gni", + "//build/config/android/internal_rules.gni", + "//build/config/android/rules.gni", + "//build/config/compiler/BUILD.gn", + "//build/config/gcc/gcc_version.gni", + "//build/config/ios/ios_sdk.gni", + "//build/config/linux/BUILD.gn", + "//build/config/linux/pkg_config.gni", + "//build/config/mac/mac_sdk.gni", + "//build/config/posix/BUILD.gn", + "//build/config/win/visual_studio_version.gni", + "//build/gn_helpers.py", + "//build/gypi_to_gn.py", + "//build/toolchain/gcc_toolchain.gni", + "//build/toolchain/mac/BUILD.gn", + "//build/toolchain/win/BUILD.gn", + "//third_party/boringssl/BUILD.gn", + "//third_party/opus/BUILD.gn", + "//webrtc/modules/video_render/BUILD.gn", +]
diff --git a/AUTHORS b/AUTHORS index 30d7be8..0d9ff5a 100644 --- a/AUTHORS +++ b/AUTHORS
@@ -1,8 +1,46 @@ # Names should be added to this file like so: # Name or Organization <email address> -Google Inc. -Mozilla Foundation +Anil Kumar <an1kumar@gmail.com> Ben Strong <bstrong@gmail.com> -Petar Jovanovic <petarj@mips.com> +Bob Withers <bwit@pobox.com> +Bridger Maxwell <bridgeyman@gmail.com> +Christophe Dumez <ch.dumez@samsung.com> +Colin Plumb +Eric Rescorla, RTFM Inc. <ekr@rtfm.com> +Giji Gangadharan <giji.g@samsung.com> +Graham Yoakum <gyoakum@skobalt.com> +Jake Hilton <jakehilton@gmail.com> +James H. Brown <jbrown@burgoyne.com> +Jiawei Ou <jiawei.ou@gmail.com> +Jie Mao <maojie0924@gmail.com> +Luke Weber <luke.weber@gmail.com> +Manish Jethani <manish.jethani@gmail.com> Martin Storsjo <martin@martin.st> +Matthias Liebig <matthias.gcode@gmail.com> +Pali Rohar +Paul Kapustin <pkapustin@gmail.com> +Rafael Lopez Diez <rafalopezdiez@gmail.com> +Ralph Giles <giles@ghostscript.com> +Robert Nagy <robert.nagy@gmail.com> +Ryan Yoakum <ryoakum@skobalt.com> +Sarah Thompson <sarah@telergy.com> +Saul Kravitz <Saul.Kravitz@celera.com> +Silviu Caragea <silviu.cpp@gmail.com> +Steve Reid <sreid@sea-to-sky.net> +Vicken Simonian <vsimon@gmail.com> +Victor Costan <costan@gmail.com> + +&yet LLC +ARM Holdings +BroadSoft Inc. +Google Inc. +Intel Corporation +MIPS Technologies +Mozilla Foundation +Opera Software ASA +Sinch AB +struktur AG +Telenor Digital AS +Temasys Communications +Vonage Holdings Corp.
diff --git a/Android.mk b/Android.mk index ee918eb..aead39e 100644 --- a/Android.mk +++ b/Android.mk
@@ -16,16 +16,23 @@ LOCAL_MODULE_TAGS := optional LOCAL_WHOLE_STATIC_LIBRARIES := \ - libwebrtc_spl \ - libwebrtc_resampler \ - libwebrtc_apm \ - libwebrtc_apm_utility \ - libwebrtc_vad \ - libwebrtc_ns \ - libwebrtc_agc \ libwebrtc_aec \ libwebrtc_aecm \ - libwebrtc_system_wrappers + libwebrtc_agc \ + libwebrtc_apm \ + libwebrtc_apm_utility \ + libwebrtc_apvad \ + libwebrtc_base \ + libwebrtc_beamformer \ + libwebrtc_common \ + libwebrtc_intell \ + libwebrtc_isac \ + libwebrtc_resampler \ + libwebrtc_ns \ + libwebrtc_spl \ + libwebrtc_system_wrappers \ + libwebrtc_transient \ + libwebrtc_vad \ # Add Neon libraries. ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) @@ -39,7 +46,6 @@ libdl \ libprotobuf-cpp-lite \ - include $(BUILD_SHARED_LIBRARY) @@ -51,10 +57,15 @@ LOCAL_MODULE_TAGS := optional LOCAL_WHOLE_STATIC_LIBRARIES := \ + libwebrtc_base \ + libwebrtc_common \ + libwebrtc_intell \ libwebrtc_isac \ libwebrtc_isacfix \ + libwebrtc_resampler \ libwebrtc_spl \ - libwebrtc_system_wrappers + libwebrtc_system_wrappers \ + ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) LOCAL_WHOLE_STATIC_LIBRARIES_arm += \ libwebrtc_isacfix_neon @@ -65,7 +76,6 @@ libcutils \ libdl \ - include $(BUILD_SHARED_LIBRARY) @@ -88,10 +98,6 @@ LOCAL_STATIC_LIBRARIES := \ libprotobuf-cpp-lite -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libdl - LOCAL_NDK_STL_VARIANT := gnustl_static LOCAL_SDK_VERSION := 14 @@ -100,22 +106,28 @@ webrtc_path := $(LOCAL_PATH) # voice -include $(webrtc_path)/src/common_audio/resampler/Android.mk -include $(webrtc_path)/src/common_audio/signal_processing/Android.mk -include $(webrtc_path)/src/common_audio/vad/Android.mk -include $(webrtc_path)/src/modules/audio_coding/codecs/isac/fix/source/Android.mk -include $(webrtc_path)/src/modules/audio_coding/codecs/isac/main/source/Android.mk -include $(webrtc_path)/src/modules/audio_processing/aec/Android.mk -include $(webrtc_path)/src/modules/audio_processing/aecm/Android.mk -include $(webrtc_path)/src/modules/audio_processing/agc/Android.mk -include $(webrtc_path)/src/modules/audio_processing/Android.mk -include $(webrtc_path)/src/modules/audio_processing/ns/Android.mk -include $(webrtc_path)/src/modules/audio_processing/utility/Android.mk -include $(webrtc_path)/src/system_wrappers/source/Android.mk +include $(webrtc_path)/webrtc/base/Android.mk +include $(webrtc_path)/webrtc/common_audio/Android.mk +include $(webrtc_path)/webrtc/common_audio/resampler/Android.mk +include $(webrtc_path)/webrtc/common_audio/signal_processing/Android.mk +include $(webrtc_path)/webrtc/common_audio/vad/Android.mk +include $(webrtc_path)/webrtc/modules/audio_coding/codecs/isac/fix/source/Android.mk +include $(webrtc_path)/webrtc/modules/audio_coding/codecs/isac/main/source/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/aec/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/aecm/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/agc/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/beamformer/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/intelligibility/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/ns/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/transient/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/utility/Android.mk +include $(webrtc_path)/webrtc/modules/audio_processing/vad/Android.mk +include $(webrtc_path)/webrtc/system_wrappers/source/Android.mk # libwebrtc_audio_coding_gnustl_static dependencies WEBRTC_STL := gnustl_static -include $(webrtc_path)/src/system_wrappers/source/Android.mk -include $(webrtc_path)/src/modules/audio_coding/codecs/isac/fix/source/Android.mk -include $(webrtc_path)/src/modules/audio_coding/codecs/isac/main/source/Android.mk -include $(webrtc_path)/src/common_audio/signal_processing/Android.mk +include $(webrtc_path)/webrtc/system_wrappers/source/Android.mk +include $(webrtc_path)/webrtc/modules/audio_coding/codecs/isac/fix/source/Android.mk +include $(webrtc_path)/webrtc/modules/audio_coding/codecs/isac/main/source/Android.mk +include $(webrtc_path)/webrtc/common_audio/signal_processing/Android.mk
diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..b7f7a06 --- /dev/null +++ b/BUILD.gn
@@ -0,0 +1,14 @@ +# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This file is copied and modified from Chromium (src/BUILD.gn). +group("root") { + deps = [ + "//webrtc", + ] +}
diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..fba26f4 --- /dev/null +++ b/COPYING
@@ -0,0 +1 @@ +Refer to talk/COPYING. \ No newline at end of file
diff --git a/DEPS b/DEPS index fe2d635..3ceff79 100644 --- a/DEPS +++ b/DEPS
@@ -1,138 +1,116 @@ -use_relative_paths = True +# This file contains dependencies for WebRTC that are not shared with Chromium. +# If you wish to add a dependency that is present in Chromium's src/DEPS or a +# directory from the Chromium checkout, you should add it to setup_links.py +# instead. vars = { - # Override root_dir in your .gclient's custom_vars to specify a custom root - # folder name. - "root_dir": "trunk", - "extra_gyp_flag": "-Dextra_gyp_flag=0", - - # Use this googlecode_url variable only if there is an internal mirror for it. - # If you do not know, use the full path while defining your new deps entry. - "googlecode_url": "http://%s.googlecode.com/svn", - "chromium_trunk" : "http://src.chromium.org/svn/trunk", - "chromium_revision": "152335", - - # External resources like video and audio files used for testing purposes. - # Downloaded on demand when needed. - "webrtc_resources_revision": "10", + 'extra_gyp_flag': '-Dextra_gyp_flag=0', + 'chromium_git': 'https://chromium.googlesource.com', + 'chromium_revision': '657e8d9a9139da0735d73fc0fc6d90a05f980319', } # NOTE: Prefer revision numbers to tags for svn deps. Use http rather than # https; the latter can cause problems for users behind proxies. deps = { - "../chromium_deps": - File(Var("chromium_trunk") + "/src/DEPS@" + Var("chromium_revision")), + # When rolling gflags, also update + # https://chromium.googlesource.com/chromium/deps/webrtc/webrtc.DEPS + 'src/third_party/gflags/src': + Var('chromium_git') + '/external/gflags/src@e7390f9185c75f8d902c05ed7d20bb94eb914d0c', # from svn revision 82 - "build": - Var("chromium_trunk") + "/src/build@" + Var("chromium_revision"), - - "testing": - Var("chromium_trunk") + "/src/testing@" + Var("chromium_revision"), - - "testing/gmock": - From("chromium_deps", "src/testing/gmock"), - - "testing/gtest": - From("chromium_deps", "src/testing/gtest"), - - "third_party/expat": - Var("chromium_trunk") + "/src/third_party/expat@" + Var("chromium_revision"), - - "third_party/google-gflags/src": - (Var("googlecode_url") % "google-gflags") + "/trunk/src@45", - - "third_party/libjpeg": - Var("chromium_trunk") + "/src/third_party/libjpeg@" + Var("chromium_revision"), - - "third_party/libjpeg_turbo": - From("chromium_deps", "src/third_party/libjpeg_turbo"), - - "third_party/libvpx/source/libvpx": - "http://git.chromium.org/webm/libvpx.git@c522217d", - - "third_party/libyuv": - (Var("googlecode_url") % "libyuv") + "/trunk@338", - - "third_party/protobuf": - Var("chromium_trunk") + "/src/third_party/protobuf@" + Var("chromium_revision"), - - "third_party/yasm": - Var("chromium_trunk") + "/src/third_party/yasm@" + Var("chromium_revision"), - - "third_party/yasm/source/patched-yasm": - From("chromium_deps", "src/third_party/yasm/source/patched-yasm"), - - "tools/clang": - Var("chromium_trunk") + "/src/tools/clang@" + Var("chromium_revision"), - - "tools/gyp": - From("chromium_deps", "src/tools/gyp"), - - "tools/python": - Var("chromium_trunk") + "/src/tools/python@" + Var("chromium_revision"), - - "tools/valgrind": - Var("chromium_trunk") + "/src/tools/valgrind@" + Var("chromium_revision"), - - # Needed by build/common.gypi. - "tools/win/supalink": - Var("chromium_trunk") + "/src/tools/win/supalink@" + Var("chromium_revision"), + 'src/third_party/junit-jar': + Var('chromium_git') + '/external/webrtc/deps/third_party/junit@f35596b476aa6e62fd3b3857b9942ddcd13ce35e', # from svn revision 3367 } deps_os = { - "win": { - # Use our own, stripped down, version of Cygwin (required by GYP). - "third_party/cygwin": - (Var("googlecode_url") % "webrtc") + "/deps/third_party/cygwin@2672", - - # Used by libjpeg-turbo. - "third_party/yasm/binaries": - From("chromium_deps", "src/third_party/yasm/binaries"), - }, - "unix": { - "third_party/gold": - From("chromium_deps", "src/third_party/gold"), + 'win': { + 'src/third_party/winsdk_samples/src': + Var('chromium_git') + '/external/webrtc/deps/third_party/winsdk_samples_v71@c0cbedd854cb610a53226d9817416c4ab9a7d1e9', # from svn revision 7951 }, } +# Define rules for which include paths are allowed in our source. +include_rules = [ + # Base is only used to build Android APK tests and may not be referenced by + # WebRTC production code. + '-base', + '-chromium', + '+external/webrtc/webrtc', # Android platform build. + '+gflags', + '+libyuv', + '+net', + '+talk', + '+testing', + '+third_party', + '+unicode', + '+webrtc', + '+vpx', +] + hooks = [ { - # Create a supplement.gypi file under trunk/src. This file will be picked - # up by gyp and used to enable the standalone build. - "pattern": ".", - "action": ["python", Var("root_dir") + "/tools/create_supplement_gypi.py", - Var("root_dir") + "/src/supplement.gypi"], + # Check for legacy named top-level dir (named 'trunk'). + 'name': 'check_root_dir_name', + 'pattern': '.', + 'action': ['python','-c', + ('import os,sys;' + 'script = os.path.join("trunk","check_root_dir.py");' + '_ = os.system("%s %s" % (sys.executable,script)) ' + 'if os.path.exists(script) else 0')], }, { - # Pull clang on mac. If nothing changed, or on non-mac platforms, this takes - # zero seconds to run. If something changed, it downloads a prebuilt clang. - "pattern": ".", - "action": ["python", Var("root_dir") + "/tools/clang/scripts/update.py", - "--mac-only"], + # Clone chromium and its deps. + 'name': 'sync chromium', + 'pattern': '.', + 'action': ['python', '-u', 'src/sync_chromium.py', + '--target-revision', Var('chromium_revision')], }, { - # Update the cygwin mount on Windows. - # This is necessary to get the correct mapping between e.g. /bin and the - # cygwin path on Windows. Without it we can't run bash scripts in actions. - # Ideally this should be solved in "pylib/gyp/msvs_emulation.py". - "pattern": ".", - "action": ["python", Var("root_dir") + "/build/win/setup_cygwin_mount.py", - "--win-only"], + # Create links to shared dependencies in Chromium. + 'name': 'setup_links', + 'pattern': '.', + 'action': ['python', 'src/setup_links.py'], }, { - # Download test resources, i.e. video and audio files. If the latest - # version is already downloaded, this takes zero seconds to run. - # If a newer version or no current download exists, it will download - # the resources and extract them. - "pattern": ".", - "action": ["python", Var("root_dir") + "/tools/resources/update.py"], + # This clobbers when necessary (based on get_landmines.py). It should be + # an early hook but it will need to be run after syncing Chromium and + # setting up the links, so the script actually exists. + 'name': 'landmines', + 'pattern': '.', + 'action': [ + 'python', + 'src/build/landmines.py', + '--landmine-scripts', + 'src/webrtc/build/get_landmines.py', + '--src-dir', + 'src', + ], + }, + { + # Pull sanitizer-instrumented third-party libraries if requested via + # GYP_DEFINES. This could be done as part of sync_chromium.py above + # but then we would need to run all the Chromium hooks each time, + # which will slow things down a lot. + 'name': 'instrumented_libraries', + 'pattern': '\\.sha1', + 'action': ['python', 'src/third_party/instrumented_libraries/scripts/download_binaries.py'], + }, + { + # Download test resources, i.e. video and audio files from Google Storage. + 'pattern': '.', + 'action': ['download_from_google_storage', + '--directory', + '--recursive', + '--num_threads=10', + '--no_auth', + '--bucket', 'chromium-webrtc-resources', + 'src/resources'], }, { # A change to a .gyp, .gypi, or to GYP itself should run the generator. - "pattern": ".", - "action": ["python", Var("root_dir") + "/build/gyp_chromium", - "--depth=" + Var("root_dir"), Var("root_dir") + "/webrtc.gyp", - Var("extra_gyp_flag")], + 'name': 'gyp', + 'pattern': '.', + 'action': ['python', 'src/webrtc/build/gyp_webrtc', + Var('extra_gyp_flag')], }, ]
diff --git a/LICENSE b/LICENSE index dd4a345..57fbdb2 100644 --- a/LICENSE +++ b/LICENSE
@@ -1 +1 @@ -Refer to src/LICENSE. +Refer to webrtc/LICENSE.
diff --git a/LICENSE_THIRD_PARTY b/LICENSE_THIRD_PARTY index d47c055..dfcf6e4 100644 --- a/LICENSE_THIRD_PARTY +++ b/LICENSE_THIRD_PARTY
@@ -1 +1 @@ -Refer to src/LICENSE_THIRD_PARTY. +Refer to webrtc/LICENSE_THIRD_PARTY and talk/LICENSE_THIRD_PARTY.
diff --git a/OWNERS b/OWNERS index b110a52..3ecf2a2 100644 --- a/OWNERS +++ b/OWNERS
@@ -1,5 +1,15 @@ -henrika@webrtc.org -niklas.enbom@webrtc.org -andrew@webrtc.org -tina.legrand@webrtc.org -tommi@webrtc.org \ No newline at end of file +andrew@webrtc.org +henrika@webrtc.org +mflodman@webrtc.org +niklas.enbom@webrtc.org +tina.legrand@webrtc.org +tommi@webrtc.org +per-file .gitignore=* +per-file AUTHORS=* +per-file .gn=kjellander@webrtc.org +per-file BUILD.gn=kjellander@webrtc.org +per-file DEPS=* +per-file PRESUBMIT.py=kjellander@webrtc.org +per-file setup_links.py=* +per-file sync_chromium.py=kjellander@webrtc.org +per-file WATCHLISTS=*
diff --git a/PRESUBMIT.py b/PRESUBMIT.py old mode 100644 new mode 100755 index 6eaa408..e7ceac9 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -6,32 +6,13 @@ # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. -import os.path +import json +import os +import platform +import re +import subprocess +import sys -# All folders in LINT_FOLDERS will be scanned by cpplint by the presubmit -# script. Note that subfolders are not included. -LINT_FOLDERS = ['src/video_engine'] - -def _LicenseHeader(input_api): - """Returns the license header regexp.""" - # Accept any year number from 2011 to the current year - current_year = int(input_api.time.strftime('%Y')) - allowed_years = (str(s) for s in reversed(xrange(2011, current_year + 1))) - years_re = '(' + '|'.join(allowed_years) + ')' - license_header = ( - r'.*? Copyright \(c\) %(year)s The WebRTC project authors\. ' - r'All Rights Reserved\.\n' - r'.*?\n' - r'.*? Use of this source code is governed by a BSD-style license\n' - r'.*? that can be found in the LICENSE file in the root of the source\n' - r'.*? tree\. An additional intellectual property rights grant can be ' - r'found\n' - r'.*? in the file PATENTS\. All contributing project authors may\n' - r'.*? be found in the AUTHORS file in the root of the source tree\.\n' - ) % { - 'year': years_re, - } - return license_header def _CheckNoIOStreamInHeaders(input_api, output_api): """Checks to make sure no .h files include <iostream>.""" @@ -46,13 +27,14 @@ files.append(f) if len(files): - return [ output_api.PresubmitError( + return [output_api.PresubmitError( 'Do not #include <iostream> in header files, since it inserts static ' + 'initialization into every file including the header. Instead, ' + '#include <ostream>. See http://crbug.com/94794', - files) ] + files)] return [] + def _CheckNoFRIEND_TEST(input_api, output_api): """Make sure that gtest's FRIEND_TEST() macro is not used, the FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be @@ -71,10 +53,6 @@ 'gtest\'s FRIEND_TEST() macro. Include testsupport/gtest_prod_util.h and ' 'use FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))] -def _IsLintWhitelisted(file_name): - """ Checks if a file is whitelisted for lint check.""" - # TODO(mflodman) Include subfolders in the check. - return (os.path.dirname(file_name) in LINT_FOLDERS) def _CheckApprovedFilesLintClean(input_api, output_api, source_file_filter=None): @@ -104,8 +82,8 @@ verbosity_level = 1 files = [] for f in input_api.AffectedSourceFiles(source_file_filter): - # Note that moved/renamed files also count as added for svn. - if (f.Action() == 'A' or _IsLintWhitelisted(f.LocalPath())): + # Note that moved/renamed files also count as added. + if f.Action() == 'A': files.append(f.AbsoluteLocalPath()) for file_name in files: @@ -122,12 +100,205 @@ return result +def _CheckNoRtcBaseDeps(input_api, gyp_files, output_api): + pattern = input_api.re.compile(r"base.gyp:rtc_base\s*'") + violating_files = [] + for f in gyp_files: + gyp_exceptions = ( + 'base_tests.gyp', + 'desktop_capture.gypi', + 'libjingle.gyp', + 'libjingle_tests.gyp', + 'p2p.gyp', + 'sound.gyp', + 'webrtc_test_common.gyp', + 'webrtc_tests.gypi', + ) + if f.LocalPath().endswith(gyp_exceptions): + continue + contents = input_api.ReadFile(f) + if pattern.search(contents): + violating_files.append(f) + if violating_files: + return [output_api.PresubmitError( + 'Depending on rtc_base is not allowed. Change your dependency to ' + 'rtc_base_approved and possibly sanitize and move the desired source ' + 'file(s) to rtc_base_approved.\nChanged GYP files:', + items=violating_files)] + return [] + +def _CheckNoSourcesAboveGyp(input_api, gyp_files, output_api): + # Disallow referencing source files with paths above the GYP file location. + source_pattern = input_api.re.compile(r'sources.*?\[(.*?)\]', + re.MULTILINE | re.DOTALL) + file_pattern = input_api.re.compile(r"'((\.\./.*?)|(<\(webrtc_root\).*?))'") + violating_gyp_files = set() + violating_source_entries = [] + for gyp_file in gyp_files: + contents = input_api.ReadFile(gyp_file) + for source_block_match in source_pattern.finditer(contents): + # Find all source list entries starting with ../ in the source block + # (exclude overrides entries). + for file_list_match in file_pattern.finditer(source_block_match.group(0)): + source_file = file_list_match.group(0) + if 'overrides/' not in source_file: + violating_source_entries.append(source_file) + violating_gyp_files.add(gyp_file) + if violating_gyp_files: + return [output_api.PresubmitError( + 'Referencing source files above the directory of the GYP file is not ' + 'allowed. Please introduce new GYP targets and/or GYP files in the ' + 'proper location instead.\n' + 'Invalid source entries:\n' + '%s\n' + 'Violating GYP files:' % '\n'.join(violating_source_entries), + items=violating_gyp_files)] + return [] + +def _CheckGypChanges(input_api, output_api): + source_file_filter = lambda x: input_api.FilterSourceFile( + x, white_list=(r'.+\.(gyp|gypi)$',)) + + gyp_files = [] + for f in input_api.AffectedSourceFiles(source_file_filter): + if f.LocalPath().startswith('webrtc'): + gyp_files.append(f) + + result = [] + if gyp_files: + result.append(output_api.PresubmitNotifyResult( + 'As you\'re changing GYP files: please make sure corresponding ' + 'BUILD.gn files are also updated.\nChanged GYP files:', + items=gyp_files)) + result.extend(_CheckNoRtcBaseDeps(input_api, gyp_files, output_api)) + result.extend(_CheckNoSourcesAboveGyp(input_api, gyp_files, output_api)) + return result + +def _CheckUnwantedDependencies(input_api, output_api): + """Runs checkdeps on #include statements added in this + change. Breaking - rules is an error, breaking ! rules is a + warning. + """ + # Copied from Chromium's src/PRESUBMIT.py. + + # We need to wait until we have an input_api object and use this + # roundabout construct to import checkdeps because this file is + # eval-ed and thus doesn't have __file__. + original_sys_path = sys.path + try: + checkdeps_path = input_api.os_path.join(input_api.PresubmitLocalPath(), + 'buildtools', 'checkdeps') + if not os.path.exists(checkdeps_path): + return [output_api.PresubmitError( + 'Cannot find checkdeps at %s\nHave you run "gclient sync" to ' + 'download Chromium and setup the symlinks?' % checkdeps_path)] + sys.path.append(checkdeps_path) + import checkdeps + from cpp_checker import CppChecker + from rules import Rule + finally: + # Restore sys.path to what it was before. + sys.path = original_sys_path + + added_includes = [] + for f in input_api.AffectedFiles(): + if not CppChecker.IsCppFile(f.LocalPath()): + continue + + changed_lines = [line for _, line in f.ChangedContents()] + added_includes.append([f.LocalPath(), changed_lines]) + + deps_checker = checkdeps.DepsChecker(input_api.PresubmitLocalPath()) + + error_descriptions = [] + warning_descriptions = [] + for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes( + added_includes): + description_with_path = '%s\n %s' % (path, rule_description) + if rule_type == Rule.DISALLOW: + error_descriptions.append(description_with_path) + else: + warning_descriptions.append(description_with_path) + + results = [] + if error_descriptions: + results.append(output_api.PresubmitError( + 'You added one or more #includes that violate checkdeps rules.', + error_descriptions)) + if warning_descriptions: + results.append(output_api.PresubmitPromptOrNotify( + 'You added one or more #includes of files that are temporarily\n' + 'allowed but being removed. Can you avoid introducing the\n' + '#include? See relevant DEPS file(s) for details and contacts.', + warning_descriptions)) + return results + + +def _RunPythonTests(input_api, output_api): + def join(*args): + return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) + + test_directories = [ + join('tools', 'autoroller', 'unittests'), + ] + + tests = [] + for directory in test_directories: + tests.extend( + input_api.canned_checks.GetUnitTestsInDirectory( + input_api, + output_api, + directory, + whitelist=[r'.+_test\.py$'])) + return input_api.RunTests(tests, parallel=True) + + def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" - # TODO(kjellander): Use presubmit_canned_checks.PanProjectChecks too. results = [] + results.extend(input_api.canned_checks.RunPylint(input_api, output_api, + black_list=(r'^.*gviz_api\.py$', + r'^.*gaeunit\.py$', + # Embedded shell-script fakes out pylint. + r'^build[\\\/].*\.py$', + r'^buildtools[\\\/].*\.py$', + r'^chromium[\\\/].*\.py$', + r'^google_apis[\\\/].*\.py$', + r'^net.*[\\\/].*\.py$', + r'^out.*[\\\/].*\.py$', + r'^testing[\\\/].*\.py$', + r'^third_party[\\\/].*\.py$', + r'^tools[\\\/]find_depot_tools.py$', + r'^tools[\\\/]clang[\\\/].*\.py$', + r'^tools[\\\/]generate_library_loader[\\\/].*\.py$', + r'^tools[\\\/]gn[\\\/].*\.py$', + r'^tools[\\\/]gyp[\\\/].*\.py$', + r'^tools[\\\/]isolate_driver.py$', + r'^tools[\\\/]protoc_wrapper[\\\/].*\.py$', + r'^tools[\\\/]python[\\\/].*\.py$', + r'^tools[\\\/]python_charts[\\\/]data[\\\/].*\.py$', + r'^tools[\\\/]refactoring[\\\/].*\.py$', + r'^tools[\\\/]swarming_client[\\\/].*\.py$', + r'^tools[\\\/]vim[\\\/].*\.py$', + # TODO(phoglund): should arguably be checked. + r'^tools[\\\/]valgrind-webrtc[\\\/].*\.py$', + r'^tools[\\\/]valgrind[\\\/].*\.py$', + r'^tools[\\\/]win[\\\/].*\.py$', + r'^xcodebuild.*[\\\/].*\.py$',), + disabled_warnings=['F0401', # Failed to import x + 'E0611', # No package y in x + 'W0232', # Class has no __init__ method + ], + pylintrc='pylintrc')) + # WebRTC can't use the presubmit_canned_checks.PanProjectChecks function since + # we need to have different license checks in talk/ and webrtc/ directories. + # Instead, hand-picked checks are included below. + + # Skip long-lines check for DEPS, GN and GYP files. + long_lines_sources = lambda x: input_api.FilterSourceFile(x, + black_list=(r'.+\.gyp$', r'.+\.gypi$', r'.+\.gn$', r'.+\.gni$', 'DEPS')) results.extend(input_api.canned_checks.CheckLongLines( - input_api, output_api)) + input_api, output_api, maxlen=80, source_file_filter=long_lines_sources)) results.extend(input_api.canned_checks.CheckChangeHasNoTabs( input_api, output_api)) results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( @@ -135,17 +306,22 @@ results.extend(input_api.canned_checks.CheckChangeTodoHasOwner( input_api, output_api)) results.extend(_CheckApprovedFilesLintClean(input_api, output_api)) - results.extend(input_api.canned_checks.CheckLicense( - input_api, output_api, _LicenseHeader(input_api))) results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) + results.extend(_CheckGypChanges(input_api, output_api)) + results.extend(_CheckUnwantedDependencies(input_api, output_api)) + results.extend(_RunPythonTests(input_api, output_api)) return results + def CheckChangeOnUpload(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) + results.extend( + input_api.canned_checks.CheckGNFormatted(input_api, output_api)) return results + def CheckChangeOnCommit(input_api, output_api): results = [] results.extend(_CommonChecks(input_api, output_api)) @@ -158,4 +334,32 @@ input_api, output_api)) results.extend(input_api.canned_checks.CheckChangeHasTestField( input_api, output_api)) + results.extend(input_api.canned_checks.CheckTreeIsOpen( + input_api, output_api, + json_url='http://webrtc-status.appspot.com/current?format=json')) return results + + +# pylint: disable=W0613 +def GetPreferredTryMasters(project, change): + cq_config_path = os.path.join( + change.RepositoryRoot(), 'infra', 'config', 'cq.cfg') + # commit_queue.py below is a script in depot_tools directory, which has a + # 'builders' command to retrieve a list of CQ builders from the CQ config. + is_win = platform.system() == 'Windows' + masters = json.loads(subprocess.check_output( + ['commit_queue', 'builders', cq_config_path], shell=is_win)) + + try_config = {} + for master in masters: + try_config.setdefault(master, {}) + for builder in masters[master]: + if 'presubmit' in builder: + # Do not trigger presubmit builders, since they're likely to fail + # (e.g. OWNERS checks before finished code review), and we're running + # local presubmit anyway. + pass + else: + try_config[master][builder] = ['defaulttests'] + + return try_config
diff --git a/README.md b/README.md new file mode 100644 index 0000000..a77ab53 --- /dev/null +++ b/README.md
@@ -0,0 +1,23 @@ +**WebRTC is a free, open software project** that provides browsers and mobile +applications with Real-Time Communications (RTC) capabilities via simple APIs. +The WebRTC components have been optimized to best serve this purpose. + +**Our mission:** To enable rich, high-quality RTC applications to be +developed for the browser, mobile platforms, and IoT devices, and allow them +all to communicate via a common set of protocols. + +The WebRTC initiative is a project supported by Google, Mozilla and Opera, +amongst others. This page is maintained by the Google Chrome team. + +### Development + +See http://www.webrtc.org/native-code/development for instructions on how to get +started developing with the native code. + +### More info + + * Official web site: http://www.webrtc.org + * Master source code repo: https://chromium.googlesource.com/external/webrtc + * Samples and reference apps: https://github.com/webrtc + * Mailing list: http://groups.google.com/group/discuss-webrtc + * Continuous build: http://build.chromium.org/p/client.webrtc
diff --git a/WATCHLISTS b/WATCHLISTS index 13551a8..c89a28e 100644 --- a/WATCHLISTS +++ b/WATCHLISTS
@@ -14,17 +14,17 @@ 'this_file': { 'filepath': '^WATCHLISTS$', }, - 'all_src': { - 'filepath': 'src/.*', + 'all_webrtc': { + # NOTE: if you like this you might like webrtc-reviews@webrtc.org! + 'filepath': 'webrtc/.*', }, 'root_files': { - # src/build/ and non-recursive contents of ./ and src/ - 'filepath': '^[^/]*$|src/[^/]*$|src/build/.*', + # webrtc/build/ and non-recursive contents of ./ and webrtc/ + 'filepath': '^[^/]*$|webrtc/[^/]*$|webrtc/build/.*', }, 'documented_interfaces': { - 'filepath': 'src/[^/]*\.h$|'\ - 'src/video_engine/main/interface/.*|'\ - 'src/voice_engine/main/interface/.*', + 'filepath': 'webrtc/[^/]*\.h$|'\ + 'webrtc/voice_engine/include/.*', }, 'build_files': { 'filepath': '\.gyp$|\.gypi$|Android\.mk$', @@ -33,82 +33,115 @@ 'filepath': '\.java$|\.xml$', }, 'video_engine': { - 'filepath': 'src/video_engine/.*', + 'filepath': 'webrtc/video_engine/.*|'\ + 'webrtc/video/.*', }, 'voice_engine': { - 'filepath': 'src/voice_engine/.*', + 'filepath': 'webrtc/voice_engine/.*', }, 'common_audio': { - 'filepath': 'src/common_audio/.*', + 'filepath': 'webrtc/common_audio/.*', + }, + 'common_video': { + 'filepath': 'webrtc/common_video/.*', }, 'video_capture': { - 'filepath': 'src/modules/video_capture/.*', + 'filepath': 'webrtc/modules/video_capture/.*', }, 'video_render': { - 'filepath': 'src/modules/video_render/.*', + 'filepath': 'webrtc/modules/video_render/.*', }, 'audio_device': { - 'filepath': 'src/modules/audio_device/.*', + 'filepath': 'webrtc/modules/audio_device/.*', }, 'audio_coding': { - 'filepath': 'src/modules/audio_coding/.*', + 'filepath': 'webrtc/modules/audio_coding/.*', }, 'neteq': { - 'filepath': 'src/modules/audio_coding/neteq/.*', + 'filepath': 'webrtc/modules/audio_coding/neteq/.*', }, 'audio_processing': { - 'filepath': 'src/modules/audio_processing/.*', - }, - 'video_codecs': { - 'filepath': 'src/modules/video_coding/codecs/.*', + 'filepath': 'webrtc/modules/audio_processing/.*', }, 'video_coding': { - 'filepath': 'src/modules/video_coding/.*', + 'filepath': 'webrtc/modules/video_coding/.*', + }, + 'video_processing': { + 'filepath': 'webrtc/modules/video_processing/.*', + }, + 'bitrate_controller': { + 'filepath': 'webrtc/modules/bitrate_controller/.*' + }, + 'remote_bitrate_estimator': { + 'filepath': 'webrtc/modules/remote_bitrate_estimator/.*' + }, + 'pacing': { + 'filepath': 'webrtc/modules/pacing/.*' }, 'rtp_rtcp': { - 'filepath': 'src/modules/rtp_rtcp/.*' + 'filepath': 'webrtc/modules/rtp_rtcp/.*' }, 'system_wrappers': { - 'filepath': 'src/system_wrappers/.*', + 'filepath': 'webrtc/system_wrappers/.*', }, }, 'WATCHLISTS': { 'this_file': [''], - 'all_src': ['tterriberry@mozilla.com', - 'giles@mozilla.com'], + 'all_webrtc': ['tterriberry@mozilla.com'], 'root_files': ['andrew@webrtc.org', - 'niklas.enbom@webrtc.org'], + 'niklas.enbom@webrtc.org', + 'yujie.mao@webrtc.org', + 'qiang.lu@intel.com', + 'peah@webrtc.org'], 'documented_interfaces': ['interface-changes@webrtc.org', 'rwolff@gocast.it'], - 'build_files': ['leozwang@webrtc.org'], - 'java_files': ['leozwang@webrtc.org'], - 'common_audio': ['bjornv@webrtc.org', - 'andrew@webrtc.org'], - 'video_engine': ['mflodman@webrtc.org', - 'perkj@webrtc.org'], - 'voice_engine': ['henrika@webrtc.org'], - 'video_capture': ['mflodman@webrtc.org', - 'perkj@webrtc.org', - 'leozwang@webrtc.org'], - 'video_render': ['mflodman@webrtc.org', + 'common_audio': ['aluebs@webrtc.org', + 'andrew@webrtc.org', + 'bjornv@webrtc.org', + 'peah@webrtc.org'], + 'video_engine': ['andresp@webrtc.org', + 'mflodman@webrtc.org', 'perkj@webrtc.org', - 'leozwang@webrtc.org'], + 'stefan@webrtc.org', + 'yujie.mao@webrtc.org', + 'solenberg@webrtc.org'], + 'voice_engine': ['henrika@webrtc.org', + 'henrik.lundin@webrtc.org', + 'solenberg@webrtc.org', + 'peah@webrtc.org'], + 'video_capture': ['mflodman@webrtc.org', + 'perkj@webrtc.org'], + 'video_render': ['mflodman@webrtc.org', + 'perkj@webrtc.org'], 'audio_device': ['henrika@webrtc.org', - 'leozwang@webrtc.org'], - 'audio_coding': ['tina.legrand@webrtc.org'], + 'peah@webrtc.org'], + 'audio_coding': ['tina.legrand@webrtc.org', + 'henrik.lundin@webrtc.org', + 'kwiberg@webrtc.org', + 'peah@webrtc.org'], 'neteq': ['henrik.lundin@webrtc.org'], - 'audio_processing': ['andrew@webrtc.org', + 'audio_processing': ['aluebs@webrtc.org', + 'andrew@webrtc.org', 'bjornv@webrtc.org', - 'leozwang@webrtc.org'], - 'video_codecs': ['henrik.lundin@webrtc.org', - 'pwestin@webrtc.org'], - 'video_coding': ['stefan@webrtc.org'], + 'kwiberg@webrtc.org', + 'henrik.lundin@webrtc.org', + 'peah@webrtc.org', + 'solenberg@webrtc.org'], + 'video_coding': ['stefan@webrtc.org', + 'mflodman@webrtc.org'], + 'video_processing': ['stefan@webrtc.org'], + 'bitrate_controller': ['stefan@webrtc.org', + 'mflodman@webrtc.org'], + 'remote_bitrate_estimator': ['stefan@webrtc.org', + 'mflodman@webrtc.org'], + 'pacing': ['stefan@webrtc.org', + 'mflodman@webrtc.org'], 'rtp_rtcp': ['mflodman@webrtc.org', - 'pwestin@webrtc.org'], + 'stefan@webrtc.org'], 'system_wrappers': ['mflodman@webrtc.org', 'henrika@webrtc.org', 'andrew@webrtc.org', - 'leozwang@webrtc.org'], + 'peah@webrtc.org'], }, }
diff --git a/all.gyp b/all.gyp new file mode 100644 index 0000000..40dbc13 --- /dev/null +++ b/all.gyp
@@ -0,0 +1,39 @@ +# Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +{ + 'variables': { + 'include_examples%': 1, + 'include_tests%': 1, + 'webrtc_root_additional_dependencies': [], + }, + 'targets': [ + { + 'target_name': 'All', + 'type': 'none', + 'dependencies': [ + 'webrtc/webrtc.gyp:*', + 'talk/libjingle.gyp:*', + '<@(webrtc_root_additional_dependencies)', + ], + 'conditions': [ + ['include_examples==1', { + 'dependencies': [ + 'webrtc/libjingle_examples.gyp:*', + 'webrtc/webrtc_examples.gyp:*', + ], + }], + ['include_tests==1', { + 'dependencies': [ + 'talk/libjingle_tests.gyp:*', + ], + }], + ], + }, + ], +}
diff --git a/android-webrtc.mk b/android-webrtc.mk index 2b8b5b9..f64a92d 100644 --- a/android-webrtc.mk +++ b/android-webrtc.mk
@@ -9,6 +9,7 @@ # These defines will apply to all source files # Think again before changing it MY_WEBRTC_COMMON_DEFS := \ + '-DWEBRTC_POSIX' \ '-DWEBRTC_LINUX' \ '-DWEBRTC_THREAD_RR' \ '-DWEBRTC_CLOCK_TYPE_REALTIME' \
diff --git a/build_overrides/OWNERS b/build_overrides/OWNERS new file mode 100644 index 0000000..0428a4a --- /dev/null +++ b/build_overrides/OWNERS
@@ -0,0 +1 @@ +kjellander@webrtc.org
diff --git a/build_overrides/README.md b/build_overrides/README.md new file mode 100644 index 0000000..906136e --- /dev/null +++ b/build_overrides/README.md
@@ -0,0 +1,7 @@ +# Build overrides in GN + +This directory is used to allow us to customize variables that differ between +WebRTC being built as standalone and as a part of Chromium. + +There's another build_overrides in Chromium that needs to contain the same +set of files with the same set of variables (but with different values).
diff --git a/build_overrides/webrtc.gni b/build_overrides/webrtc.gni new file mode 100644 index 0000000..0869397 --- /dev/null +++ b/build_overrides/webrtc.gni
@@ -0,0 +1,22 @@ +# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This file contains overrides to GN variables that applies for the WebRTC +# standalone build (i.e. not in Chromium). +# +# Every variable here needs to be present in the corresponding file in +# build_overrides/ of Chromium. + +build_with_chromium = false + +# Excluded in Chromium since its prerequisites don't require Pulse Audio. +rtc_include_pulse_audio = true + +# Chromium uses its own IO handling, so the internal ADM is only built for +# standalone WebRTC. +rtc_include_internal_audio_device = true
diff --git a/check_root_dir.py b/check_root_dir.py new file mode 100755 index 0000000..57a6e6d --- /dev/null +++ b/check_root_dir.py
@@ -0,0 +1,57 @@ +#!/usr/bin/env python +# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +"""Checks for legacy root directory and instructs the user how to upgrade.""" + +import os +import sys + +SOLUTION_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), + os.pardir) +MESSAGE = """\ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + A C T I O N R E Q I R E D +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + +It looks like you have a legacy checkout where the solution's top-level +directory is named 'trunk'. From now on, it must be named 'src'. + +What you need to do is to: + +1. Edit your .gclient file and change the solution name from 'trunk' to 'src' +2. Rename your 'trunk' directory to 'src' +3. Re-run gclient sync (or gclient runhooks)""" + + +def main(): + gclient_filename = os.path.join(SOLUTION_ROOT_DIR, '.gclient') + config_dict = {} + try: + with open(gclient_filename, 'rb') as gclient_file: + exec(gclient_file, config_dict) + for solution in config_dict.get('solutions', []): + if solution['name'] == 'trunk': + print MESSAGE + if solution.get('custom_vars', {}).get('root_dir'): + print ('4. Optional: Remove your "root_dir" entry from the ' + 'custom_vars dictionary of the solution.') + + # Remove the gclient cache file to avoid an error on the next sync. + entries_file = os.path.join(SOLUTION_ROOT_DIR, '.gclient_entries') + if os.path.exists(entries_file): + os.unlink(entries_file) + return 1 + return 0 + except Exception as e: + print >> sys.stderr, "Error while parsing .gclient: ", e + return 1 + + +if __name__ == '__main__': + sys.exit(main())
diff --git a/chromium/.gclient b/chromium/.gclient new file mode 100644 index 0000000..7f46333 --- /dev/null +++ b/chromium/.gclient
@@ -0,0 +1,24 @@ +solutions = [{ + 'name': 'src', + 'url': 'https://chromium.googlesource.com/chromium/src.git', + 'deps_file': '.DEPS.git', + 'managed': False, + 'custom_deps': { + # Skip syncing some large dependencies WebRTC will never need. + 'src/chrome/tools/test/reference_build/chrome_linux': None, + 'src/chrome/tools/test/reference_build/chrome_mac': None, + 'src/chrome/tools/test/reference_build/chrome_win': None, + 'src/native_client': None, + 'src/third_party/cld_2/src': None, + 'src/third_party/ffmpeg': None, + 'src/third_party/hunspell_dictionaries': None, + 'src/third_party/liblouis/src': None, + 'src/third_party/pdfium': None, + 'src/third_party/skia': None, + 'src/third_party/trace-viewer': None, + 'src/third_party/webrtc': None, + }, + 'safesync_url': '' +}] + +cache_dir = None
diff --git a/chromium/OWNERS b/chromium/OWNERS new file mode 100644 index 0000000..0428a4a --- /dev/null +++ b/chromium/OWNERS
@@ -0,0 +1 @@ +kjellander@webrtc.org
diff --git a/chromium/README b/chromium/README new file mode 100644 index 0000000..a47492c --- /dev/null +++ b/chromium/README
@@ -0,0 +1,5 @@ +This .gclient file is used to do download a copy of Chromium. +WebRTC uses the Chromium build toolchain and a number of shared +dependencies by creating symlinks to folders in this checkout, +using the ../setup_links.py script. +
diff --git a/codereview.settings b/codereview.settings index 1c0ceaa..c96f22c 100644 --- a/codereview.settings +++ b/codereview.settings
@@ -1,11 +1,10 @@ # This file is used by gcl to get repository specific information. -CODE_REVIEW_SERVER: webrtc-codereview.appspot.com -#CC_LIST: -#VIEW_VC: -#STATUS: +CODE_REVIEW_SERVER: codereview.webrtc.org +CC_LIST: webrtc-reviews@webrtc.org +VIEW_VC: https://chromium.googlesource.com/external/webrtc/+/ TRY_ON_UPLOAD: False -TRYSERVER_HTTP_HOST: webrtc-cb-linux-master.cbf.corp.google.com -TRYSERVER_HTTP_PORT: 9018 -#TRYSERVER_SVN_URL: -#GITCL_PREUPLOAD: -#GITCL_PREDCOMMIT: +TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-webrtc +TRYSERVER_PROJECT: webrtc +TRYSERVER_ROOT: src +PROJECT: webrtc +PENDING_REF_PREFIX: refs/pending/
diff --git a/data/audio_processing/output_data_fixed.pb b/data/audio_processing/output_data_fixed.pb index 2ca82e3..efc9563 100644 --- a/data/audio_processing/output_data_fixed.pb +++ b/data/audio_processing/output_data_fixed.pb Binary files differ
diff --git a/data/audio_processing/output_data_float.pb b/data/audio_processing/output_data_float.pb index cadc1d3..f869792 100644 --- a/data/audio_processing/output_data_float.pb +++ b/data/audio_processing/output_data_float.pb Binary files differ
diff --git a/data/audio_processing/output_data_mac.pb b/data/audio_processing/output_data_mac.pb new file mode 100644 index 0000000..2070170 --- /dev/null +++ b/data/audio_processing/output_data_mac.pb Binary files differ
diff --git a/infra/OWNERS b/infra/OWNERS new file mode 100644 index 0000000..0428a4a --- /dev/null +++ b/infra/OWNERS
@@ -0,0 +1 @@ +kjellander@webrtc.org
diff --git a/infra/config/OWNERS b/infra/config/OWNERS new file mode 100644 index 0000000..7bf1c90 --- /dev/null +++ b/infra/config/OWNERS
@@ -0,0 +1,3 @@ +set noparent +sergiyb@chromium.org +kjellander@webrtc.org
diff --git a/infra/config/README.md b/infra/config/README.md new file mode 100644 index 0000000..c036d61 --- /dev/null +++ b/infra/config/README.md
@@ -0,0 +1 @@ +This directory contains configuration files for infra services.
diff --git a/infra/config/cq.cfg b/infra/config/cq.cfg new file mode 100644 index 0000000..80f6f60 --- /dev/null +++ b/infra/config/cq.cfg
@@ -0,0 +1,64 @@ +# Commit Queue configuration file. The documentation of the format can be found +# at http://luci-config.appspot.com/schemas/projects/refs:cq.cfg. + +version: 1 +cq_name: "webrtc" +cq_status_url: "https://chromium-cq-status.appspot.com" +commit_burst_delay: 60 +max_commit_burst: 1 +hide_ref_in_committed_msg: true +target_ref: "refs/pending/heads/master" + +rietveld { + url: "https://codereview.webrtc.org" +} + + +verifiers { + reviewer_lgtm { + committer_list: "project-webrtc-committers" + } + + tree_status { + tree_status_url: "https://webrtc-status.appspot.com" + } + + try_job { + buckets { + name: "tryserver.webrtc" + builders { name: "android_dbg" } + builders { name: "android_rel" } + builders { name: "android_arm64_rel" } + builders { name: "android_clang_dbg" } + builders { name: "android_gn_dbg" } + builders { name: "android_gn_rel" } + builders { name: "ios_arm64_dbg" } + builders { name: "ios_arm64_rel" } + builders { name: "ios_dbg" } + builders { name: "ios_rel" } + builders { name: "ios32_sim_dbg" } + builders { name: "ios64_sim_dbg" } + builders { name: "linux_compile_dbg" } + builders { name: "linux_asan" } + builders { name: "linux_gn_dbg" } + builders { name: "linux_gn_rel" } + builders { name: "linux_msan" } + builders { name: "linux_rel" } + builders { name: "linux_tsan2" } + builders { name: "mac_compile_dbg" } + builders { name: "mac_compile_x64_dbg" } + builders { name: "mac_asan" } + builders { name: "mac_rel" } + builders { name: "mac_x64_gn_dbg" } + builders { name: "mac_x64_gn_rel" } + builders { name: "mac_x64_rel" } + builders { name: "presubmit" } + builders { name: "win_compile_dbg" } + builders { name: "win_rel" } + builders { name: "win_x64_gn_dbg" } + builders { name: "win_x64_gn_rel" } + builders { name: "win_x64_rel" } + builders { name: "win_drmemory_light" } + } + } +}
diff --git a/libvpx.mk b/libvpx.mk deleted file mode 100644 index 07c04dc..0000000 --- a/libvpx.mk +++ /dev/null
@@ -1,107 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -MY_LIBVPX_PATH = ../libvpx - -LOCAL_SRC_FILES = \ - $(MY_LIBVPX_PATH)/vp8/common/alloccommon.c \ - $(MY_LIBVPX_PATH)/vp8/common/blockd.c \ - $(MY_LIBVPX_PATH)/vp8/common/debugmodes.c \ - $(MY_LIBVPX_PATH)/vp8/common/entropy.c \ - $(MY_LIBVPX_PATH)/vp8/common/entropymode.c \ - $(MY_LIBVPX_PATH)/vp8/common/entropymv.c \ - $(MY_LIBVPX_PATH)/vp8/common/extend.c \ - $(MY_LIBVPX_PATH)/vp8/common/filter.c \ - $(MY_LIBVPX_PATH)/vp8/common/findnearmv.c \ - $(MY_LIBVPX_PATH)/vp8/common/generic/systemdependent.c \ - $(MY_LIBVPX_PATH)/vp8/common/idctllm.c \ - $(MY_LIBVPX_PATH)/vp8/common/invtrans.c \ - $(MY_LIBVPX_PATH)/vp8/common/loopfilter.c \ - $(MY_LIBVPX_PATH)/vp8/common/loopfilter_filters.c \ - $(MY_LIBVPX_PATH)/vp8/common/mbpitch.c \ - $(MY_LIBVPX_PATH)/vp8/common/modecont.c \ - $(MY_LIBVPX_PATH)/vp8/common/modecontext.c \ - $(MY_LIBVPX_PATH)/vp8/common/quant_common.c \ - $(MY_LIBVPX_PATH)/vp8/common/recon.c \ - $(MY_LIBVPX_PATH)/vp8/common/reconinter.c \ - $(MY_LIBVPX_PATH)/vp8/common/reconintra.c \ - $(MY_LIBVPX_PATH)/vp8/common/reconintra4x4.c \ - $(MY_LIBVPX_PATH)/vp8/common/setupintrarecon.c \ - $(MY_LIBVPX_PATH)/vp8/common/swapyv12buffer.c \ - $(MY_LIBVPX_PATH)/vp8/common/textblit.c \ - $(MY_LIBVPX_PATH)/vp8/common/treecoder.c \ - $(MY_LIBVPX_PATH)/vp8/vp8_cx_iface.c \ - $(MY_LIBVPX_PATH)/vp8/vp8_dx_iface.c \ - $(MY_LIBVPX_PATH)/vpx_config.c \ - $(MY_LIBVPX_PATH)/vpx/src/vpx_codec.c \ - $(MY_LIBVPX_PATH)/vpx/src/vpx_decoder.c \ - $(MY_LIBVPX_PATH)/vpx/src/vpx_image.c \ - $(MY_LIBVPX_PATH)/vpx_mem/vpx_mem.c \ - $(MY_LIBVPX_PATH)/vpx_scale/generic/vpxscale.c \ - $(MY_LIBVPX_PATH)/vpx_scale/generic/yv12config.c \ - $(MY_LIBVPX_PATH)/vpx_scale/generic/yv12extend.c \ - $(MY_LIBVPX_PATH)/vpx_scale/generic/gen_scalers.c \ - $(MY_LIBVPX_PATH)/vpx_scale/generic/scalesystemdependent.c \ - $(MY_LIBVPX_PATH)/vpx/src/vpx_encoder.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/bitstream.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/boolhuff.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/dct.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/encodeframe.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/encodeintra.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/encodemb.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/encodemv.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/ethreading.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/firstpass.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/generic/csystemdependent.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/mcomp.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/modecosts.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/pickinter.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/picklpf.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/psnr.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/quantize.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/ratectrl.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/rdopt.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/sad_c.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/segmentation.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/tokenize.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/treewriter.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/onyx_if.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/temporal_filter.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/variance_c.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/dboolhuff.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/decodemv.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/decodframe.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/dequantize.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/detokenize.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/generic/dsystemdependent.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/onyxd_if.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/reconintra_mt.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/threading.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/idct_blk.c \ - $(MY_LIBVPX_PATH)/vp8/common/arm/arm_systemdependent.c \ - $(MY_LIBVPX_PATH)/vp8/encoder/arm/arm_csystemdependent.c \ - $(MY_LIBVPX_PATH)/vp8/decoder/arm/arm_dsystemdependent.c \ - -LOCAL_CFLAGS := \ - -DHAVE_CONFIG_H=vpx_config.h \ - -include $(LOCAL_PATH)/third_party/libvpx/source/config/android/vpx_config.h - -LOCAL_MODULE := libwebrtc_vpx - -LOCAL_C_INCLUDES := \ - external/libvpx \ - external/libvpx/vpx_ports \ - external/libvpx/vp8/common \ - external/libvpx/vp8/encoder \ - external/libvpx/vp8 \ - external/libvpx/vpx_codec - -include $(BUILD_STATIC_LIBRARY)
diff --git a/license_template.txt b/license_template.txt index 5a3e653..39d2f5e 100644 --- a/license_template.txt +++ b/license_template.txt
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright 2011 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source
diff --git a/peerconnection/DEPS b/peerconnection/DEPS deleted file mode 100644 index efce4f0..0000000 --- a/peerconnection/DEPS +++ /dev/null
@@ -1,110 +0,0 @@ -vars = { - # Use this googlecode_url variable only if there is an internal mirror for it. - # If you do not know, use the full path while defining your new deps entry. - "googlecode_url": "http://%s.googlecode.com/svn", - "chromium_trunk" : "http://src.chromium.org/svn/trunk", - "chromium_revision": "153489", - # Still needs the libjingle_revision here because some of - # the deps have to be pulled from libjingle repository. - "libjingle_revision": "175", -} - -# NOTE: Prefer revision numbers to tags for svn deps. Use http rather than -# https; the latter can cause problems for users behind proxies. -deps = { - "trunk/chromium_deps": - File(Var("chromium_trunk") + "/src/DEPS@" + Var("chromium_revision")), - - "trunk/third_party/webrtc": - From("trunk/chromium_deps", "src/third_party/webrtc"), - - # WebRTC deps. - "trunk/third_party/libvpx": - From("trunk/chromium_deps", "src/third_party/libvpx"), - - "trunk/build": - Var("chromium_trunk") + "/src/build@" + Var("chromium_revision"), - - "trunk/testing/gtest": - From("trunk/chromium_deps", "src/testing/gtest"), - - "trunk/tools/gyp": - From("trunk/chromium_deps", "src/tools/gyp"), - - "trunk/tools/clang": - Var("chromium_trunk") + "/src/tools/clang@" + Var("chromium_revision"), - - # Needed by build/common.gypi. - "trunk/tools/win/supalink": - Var("chromium_trunk") + "/src/tools/win/supalink@" + Var("chromium_revision"), - - "trunk/third_party/protobuf": - Var("chromium_trunk") + "/src/third_party/protobuf@" + Var("chromium_revision"), - - "trunk/third_party/libjpeg_turbo/": - From("trunk/chromium_deps", "src/third_party/libjpeg_turbo"), - - "trunk/third_party/libjpeg": - Var("chromium_trunk") + "/src/third_party/libjpeg@" + Var("chromium_revision"), - - "trunk/third_party/yasm": - Var("chromium_trunk") + "/src/third_party/yasm@" + Var("chromium_revision"), - - "trunk/third_party/expat": - Var("chromium_trunk") + "/src/third_party/expat@" + Var("chromium_revision"), - - "trunk/third_party/yasm/source/patched-yasm": - From("trunk/chromium_deps", "src/third_party/yasm/source/patched-yasm"), - - "trunk/third_party/libyuv": - From("trunk/chromium_deps", "src/third_party/libyuv"), - - # libjingle deps. - "trunk/third_party/libjingle/": - File(Var("chromium_trunk") + "/src/third_party/libjingle/libjingle.gyp@" + Var("chromium_revision")), - - "trunk/third_party/libjingle/source": - From("trunk/chromium_deps", "src/third_party/libjingle/source"), - - "trunk/third_party/libjingle/overrides/talk/base": - (Var("googlecode_url") % "libjingle") + "/trunk/talk/base@" + Var("libjingle_revision"), - - "trunk/third_party/libsrtp/": - From("trunk/chromium_deps", "src/third_party/libsrtp"), - - "trunk/third_party/jsoncpp/": - Var("chromium_trunk") + "/src/third_party/jsoncpp@" + Var("chromium_revision"), - - "trunk/third_party/jsoncpp/source": - "http://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp@248", -} - -deps_os = { - "win": { - "trunk/third_party/cygwin/": - Var("chromium_trunk") + "/deps/third_party/cygwin@66844", - - # Used by libjpeg-turbo - "trunk/third_party/yasm/binaries": - From("trunk/chromium_deps", "src/third_party/yasm/binaries"), - }, - "unix": { - "trunk/third_party/gold": - From("trunk/chromium_deps", "src/third_party/gold"), - }, -} - -hooks = [ - { - # Pull clang on mac. If nothing changed, or on non-mac platforms, this takes - # zero seconds to run. If something changed, it downloads a prebuilt clang. - "pattern": ".", - "action": ["python", "trunk/tools/clang/scripts/update.py", "--mac-only"], - }, - { - # A change to a .gyp, .gypi, or to GYP itself should run the generator. - "pattern": ".", - "action": ["python", "trunk/build/gyp_chromium", "--depth=trunk", "trunk/peerconnection.gyp"], - }, -] -
diff --git a/peerconnection/OWNERS b/peerconnection/OWNERS deleted file mode 100644 index 1527445..0000000 --- a/peerconnection/OWNERS +++ /dev/null
@@ -1,5 +0,0 @@ -henrike@webrtc.org -mallinath@webrtc.org -perkj@webrtc.org -wu@webrtc.org -tommi@webrtc.org
diff --git a/peerconnection/README b/peerconnection/README deleted file mode 100644 index b7bafb2..0000000 --- a/peerconnection/README +++ /dev/null
@@ -1,12 +0,0 @@ -This folder can be used to pull together the chromium version of webrtc -and libjingle, and build the peerconnection sample client and server. This will -check out a new repository in which you can build peerconnection_server. - -Steps: -1) Create a new directory for the new repository (outside the webrtc repo): - mkdir peerconnection - cd peerconnection -2) gclient config --name trunk http://webrtc.googlecode.com/svn/trunk/peerconnection -3) gclient sync -4) cd trunk -5) make peerconnection_server peerconnection_client
diff --git a/peerconnection/base/base.gyp b/peerconnection/base/base.gyp deleted file mode 100644 index b077b34..0000000 --- a/peerconnection/base/base.gyp +++ /dev/null
@@ -1,25 +0,0 @@ -# Below are normally provided by Chromium's base.gyp and required for -# libjingle.gyp. -{ - 'targets': [ - { - 'target_name': 'base', - 'type': 'none', - 'direct_dependent_settings': { - 'include_dirs': [ - '..', - ], - }, - 'conditions': [ - ['OS == "linux"', { - 'link_settings': { - 'libraries': [ - # We need rt for clock_gettime() used in libjingle. - '-lrt', - ], - }, - }], - ], - }, - ], -}
diff --git a/peerconnection/net/net.gyp b/peerconnection/net/net.gyp deleted file mode 100644 index d653158..0000000 --- a/peerconnection/net/net.gyp +++ /dev/null
@@ -1,9 +0,0 @@ -# This is a dummy gyp file to satisfy libjingle.gyp. -{ - 'targets': [ - { - 'target_name': 'net', - 'type': 'none', - }, - ], -}
diff --git a/peerconnection/peerconnection.gyp b/peerconnection/peerconnection.gyp deleted file mode 100644 index e9c1df9..0000000 --- a/peerconnection/peerconnection.gyp +++ /dev/null
@@ -1,92 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'includes': [ 'third_party/webrtc/build/common.gypi', ], - 'variables': { - 'peerconnection_sample': 'third_party/libjingle/source/talk/examples/peerconnection', - }, - 'conditions': [ - ['OS=="win"', { - 'targets': [ - { - 'target_name': 'peerconnection_client', - 'type': 'executable', - 'sources': [ - '<(peerconnection_sample)/client/conductor.cc', - '<(peerconnection_sample)/client/conductor.h', - '<(peerconnection_sample)/client/defaults.cc', - '<(peerconnection_sample)/client/defaults.h', - '<(peerconnection_sample)/client/main.cc', - '<(peerconnection_sample)/client/main_wnd.cc', - '<(peerconnection_sample)/client/main_wnd.h', - '<(peerconnection_sample)/client/peer_connection_client.cc', - '<(peerconnection_sample)/client/peer_connection_client.h', - 'third_party/libjingle/source/talk/base/win32socketinit.cc', - 'third_party/libjingle/source/talk/base/win32socketserver.cc', - ], - 'msvs_settings': { - 'VCLinkerTool': { - 'SubSystem': '2', # Windows - }, - }, - 'dependencies': [ - 'third_party/libjingle/libjingle.gyp:libjingle_peerconnection', - ], - 'include_dirs': [ - 'src', - 'src/modules/interface', - 'third_party/libjingle/source', - ], - }, - ], # targets - }, ], # OS="win" - ['OS=="linux"', { - 'targets': [ - { - 'target_name': 'peerconnection_client', - 'type': 'executable', - 'sources': [ - '<(peerconnection_sample)/client/conductor.cc', - '<(peerconnection_sample)/client/conductor.h', - '<(peerconnection_sample)/client/defaults.cc', - '<(peerconnection_sample)/client/defaults.h', - '<(peerconnection_sample)/client/linux/main.cc', - '<(peerconnection_sample)/client/linux/main_wnd.cc', - '<(peerconnection_sample)/client/linux/main_wnd.h', - '<(peerconnection_sample)/client/peer_connection_client.cc', - '<(peerconnection_sample)/client/peer_connection_client.h', - ], - 'dependencies': [ - 'third_party/jsoncpp/jsoncpp.gyp:jsoncpp', - 'third_party/libjingle/libjingle.gyp:libjingle_peerconnection', - # TODO(tommi): Switch to this and remove specific gtk dependency - # sections below for cflags and link_settings. - # '<(DEPTH)/build/linux/system.gyp:gtk', - ], - 'include_dirs': [ - 'third_party/libjingle/source', - ], - 'cflags': [ - '<!@(pkg-config --cflags gtk+-2.0)', - ], - 'link_settings': { - 'ldflags': [ - '<!@(pkg-config --libs-only-L --libs-only-other gtk+-2.0 gthread-2.0)', - ], - 'libraries': [ - '<!@(pkg-config --libs-only-l gtk+-2.0 gthread-2.0)', - '-lX11', - '-lXext', - ], - }, - }, - ], # targets - }, ], # OS="linux" - ], -}
diff --git a/peerconnection/supplement/supplement.gypi b/peerconnection/supplement/supplement.gypi deleted file mode 100644 index 1fd012a..0000000 --- a/peerconnection/supplement/supplement.gypi +++ /dev/null
@@ -1,12 +0,0 @@ -# This file will be picked up by gyp to initialize some global settings. -{ - 'variables': { - 'build_with_chromium': 1, - 'enable_protobuf': 1, - 'enabled_libjingle_device_manager': 1, - 'include_internal_audio_device': 1, - 'include_internal_video_capture': 1, - 'include_internal_video_render': 1, - 'include_pulse_audio': 1, - } -}
diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..b8bea33 --- /dev/null +++ b/pylintrc
@@ -0,0 +1,17 @@ +[MESSAGES CONTROL] + +# Disable the message, report, category or checker with the given id(s). +# TODO(kjellander): Reduce this list to as small as possible. +disable=I0010,I0011,bad-continuation,broad-except,duplicate-code,eval-used,exec-used,fixme,invalid-name,missing-docstring,no-init,no-member,too-few-public-methods,too-many-ancestors,too-many-arguments,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-return-statements,too-many-statements + + +[REPORTS] + +# Don't write out full reports, just messages. +reports=no + + +[FORMAT] + +# We use two spaces for indents, instead of the usual four spaces or tab. +indent-string=' '
diff --git a/resources/OWNERS b/resources/OWNERS new file mode 100644 index 0000000..241e560 --- /dev/null +++ b/resources/OWNERS
@@ -0,0 +1,2 @@ +* +
diff --git a/resources/att-downlink.rx.sha1 b/resources/att-downlink.rx.sha1 new file mode 100644 index 0000000..a50a252 --- /dev/null +++ b/resources/att-downlink.rx.sha1
@@ -0,0 +1 @@ +2a4617e3497d8faa2fdccfa8964da26499eb13d6 \ No newline at end of file
diff --git a/resources/att-uplink.rx.sha1 b/resources/att-uplink.rx.sha1 new file mode 100644 index 0000000..debfe8f --- /dev/null +++ b/resources/att-uplink.rx.sha1
@@ -0,0 +1 @@ +8ea680a570df53fba206b984f38d4762481322eb \ No newline at end of file
diff --git a/resources/audio_coding/F00.BIT20.sha1 b/resources/audio_coding/F00.BIT20.sha1 new file mode 100644 index 0000000..dcbaa09 --- /dev/null +++ b/resources/audio_coding/F00.BIT20.sha1
@@ -0,0 +1 @@ +27e30ed5e0d449db1cd729c382e18455ad3834fe \ No newline at end of file
diff --git a/resources/audio_coding/F00.BIT30.sha1 b/resources/audio_coding/F00.BIT30.sha1 new file mode 100644 index 0000000..874ce9d --- /dev/null +++ b/resources/audio_coding/F00.BIT30.sha1
@@ -0,0 +1 @@ +6bafbd8667365939c327eef627fa0f94a75e5fa9 \ No newline at end of file
diff --git a/resources/audio_coding/F00.INP.sha1 b/resources/audio_coding/F00.INP.sha1 new file mode 100644 index 0000000..3166f99 --- /dev/null +++ b/resources/audio_coding/F00.INP.sha1
@@ -0,0 +1 @@ +44bb846907928e958531e805758767bf9353e03c \ No newline at end of file
diff --git a/resources/audio_coding/F00.OUT20.sha1 b/resources/audio_coding/F00.OUT20.sha1 new file mode 100644 index 0000000..9b9f4bd --- /dev/null +++ b/resources/audio_coding/F00.OUT20.sha1
@@ -0,0 +1 @@ +bb80d3c48c42bb14c8e613a8576cb77283cda3a7 \ No newline at end of file
diff --git a/resources/audio_coding/F00.OUT30.sha1 b/resources/audio_coding/F00.OUT30.sha1 new file mode 100644 index 0000000..cd62333 --- /dev/null +++ b/resources/audio_coding/F00.OUT30.sha1
@@ -0,0 +1 @@ +450b538234feff02f35b3e57fbeea5d93a41abe0 \ No newline at end of file
diff --git a/resources/audio_coding/F00_tlm10.OUT20.sha1 b/resources/audio_coding/F00_tlm10.OUT20.sha1 new file mode 100644 index 0000000..5cb8e52 --- /dev/null +++ b/resources/audio_coding/F00_tlm10.OUT20.sha1
@@ -0,0 +1 @@ +96fb5327ff7a1fe87bd4512773ce7347b4d72888 \ No newline at end of file
diff --git a/resources/audio_coding/F00_tlm10.OUT30.sha1 b/resources/audio_coding/F00_tlm10.OUT30.sha1 new file mode 100644 index 0000000..1470013 --- /dev/null +++ b/resources/audio_coding/F00_tlm10.OUT30.sha1
@@ -0,0 +1 @@ +ea527e8e61241ea73265abba5765793511c42291 \ No newline at end of file
diff --git a/resources/audio_coding/F01.BIT20.sha1 b/resources/audio_coding/F01.BIT20.sha1 new file mode 100644 index 0000000..7a26724 --- /dev/null +++ b/resources/audio_coding/F01.BIT20.sha1
@@ -0,0 +1 @@ +a6230cfa6786ba3d81510aabcaa68bd9b1610d1a \ No newline at end of file
diff --git a/resources/audio_coding/F01.BIT30.sha1 b/resources/audio_coding/F01.BIT30.sha1 new file mode 100644 index 0000000..e5a0e5a --- /dev/null +++ b/resources/audio_coding/F01.BIT30.sha1
@@ -0,0 +1 @@ +4f706d94506e0a4dc56f63940caa588e2531a455 \ No newline at end of file
diff --git a/resources/audio_coding/F01.INP.sha1 b/resources/audio_coding/F01.INP.sha1 new file mode 100644 index 0000000..a1c1b20 --- /dev/null +++ b/resources/audio_coding/F01.INP.sha1
@@ -0,0 +1 @@ +23780ea4c8893813787f7ab1dc7ab68075ad89c0 \ No newline at end of file
diff --git a/resources/audio_coding/F01.OUT20.sha1 b/resources/audio_coding/F01.OUT20.sha1 new file mode 100644 index 0000000..db6100b --- /dev/null +++ b/resources/audio_coding/F01.OUT20.sha1
@@ -0,0 +1 @@ +1ffcead0db4293f5f36abfdc7cd959d6733358d4 \ No newline at end of file
diff --git a/resources/audio_coding/F01.OUT30.sha1 b/resources/audio_coding/F01.OUT30.sha1 new file mode 100644 index 0000000..2c8e141 --- /dev/null +++ b/resources/audio_coding/F01.OUT30.sha1
@@ -0,0 +1 @@ +37b5e29f294c3612d4425775b422d7dc9b346965 \ No newline at end of file
diff --git a/resources/audio_coding/F01_tlm10.OUT20.sha1 b/resources/audio_coding/F01_tlm10.OUT20.sha1 new file mode 100644 index 0000000..d33eb7e --- /dev/null +++ b/resources/audio_coding/F01_tlm10.OUT20.sha1
@@ -0,0 +1 @@ +a5e8c268936d7c8d03edd708c675254474aed944 \ No newline at end of file
diff --git a/resources/audio_coding/F01_tlm10.OUT30.sha1 b/resources/audio_coding/F01_tlm10.OUT30.sha1 new file mode 100644 index 0000000..953656f --- /dev/null +++ b/resources/audio_coding/F01_tlm10.OUT30.sha1
@@ -0,0 +1 @@ +9893504bdaa560a4ddb67a99e6701e8d4244896a \ No newline at end of file
diff --git a/resources/audio_coding/F02.BIT20.sha1 b/resources/audio_coding/F02.BIT20.sha1 new file mode 100644 index 0000000..98f5fc5 --- /dev/null +++ b/resources/audio_coding/F02.BIT20.sha1
@@ -0,0 +1 @@ +ea44732065b09eec558af1957da21c9061c19c08 \ No newline at end of file
diff --git a/resources/audio_coding/F02.BIT30.sha1 b/resources/audio_coding/F02.BIT30.sha1 new file mode 100644 index 0000000..6e64569 --- /dev/null +++ b/resources/audio_coding/F02.BIT30.sha1
@@ -0,0 +1 @@ +40a5e2850e9e838429911cc3dbb1ff6c9bf38387 \ No newline at end of file
diff --git a/resources/audio_coding/F02.INP.sha1 b/resources/audio_coding/F02.INP.sha1 new file mode 100644 index 0000000..d686220 --- /dev/null +++ b/resources/audio_coding/F02.INP.sha1
@@ -0,0 +1 @@ +57bf2aaa27527d51085e040ccead4b99f160bb2f \ No newline at end of file
diff --git a/resources/audio_coding/F02.OUT20.sha1 b/resources/audio_coding/F02.OUT20.sha1 new file mode 100644 index 0000000..8f9fb5a --- /dev/null +++ b/resources/audio_coding/F02.OUT20.sha1
@@ -0,0 +1 @@ +13bb10aca91ddd8af71751944e18243735bdda98 \ No newline at end of file
diff --git a/resources/audio_coding/F02.OUT30.sha1 b/resources/audio_coding/F02.OUT30.sha1 new file mode 100644 index 0000000..5427662 --- /dev/null +++ b/resources/audio_coding/F02.OUT30.sha1
@@ -0,0 +1 @@ +21764cf8bb5e635e842eaf92403b22ce04732805 \ No newline at end of file
diff --git a/resources/audio_coding/F02_tlm10.OUT20.sha1 b/resources/audio_coding/F02_tlm10.OUT20.sha1 new file mode 100644 index 0000000..b8a5253 --- /dev/null +++ b/resources/audio_coding/F02_tlm10.OUT20.sha1
@@ -0,0 +1 @@ +5e0053a0de7b4708402fcc0a1b5ae024815938a3 \ No newline at end of file
diff --git a/resources/audio_coding/F02_tlm10.OUT30.sha1 b/resources/audio_coding/F02_tlm10.OUT30.sha1 new file mode 100644 index 0000000..d3bbc98 --- /dev/null +++ b/resources/audio_coding/F02_tlm10.OUT30.sha1
@@ -0,0 +1 @@ +d57986d3dc65c1cadc41419a77ed1472b73050b4 \ No newline at end of file
diff --git a/resources/audio_coding/F03.BIT20.sha1 b/resources/audio_coding/F03.BIT20.sha1 new file mode 100644 index 0000000..0ccdc7d --- /dev/null +++ b/resources/audio_coding/F03.BIT20.sha1
@@ -0,0 +1 @@ +c145a1a211103145fbb21cf1c78ab90abce83228 \ No newline at end of file
diff --git a/resources/audio_coding/F03.BIT30.sha1 b/resources/audio_coding/F03.BIT30.sha1 new file mode 100644 index 0000000..565c4c6 --- /dev/null +++ b/resources/audio_coding/F03.BIT30.sha1
@@ -0,0 +1 @@ +2ccd6fe240e41906c9f06e05cbde486c1f2bebf7 \ No newline at end of file
diff --git a/resources/audio_coding/F03.INP.sha1 b/resources/audio_coding/F03.INP.sha1 new file mode 100644 index 0000000..80dbb9c --- /dev/null +++ b/resources/audio_coding/F03.INP.sha1
@@ -0,0 +1 @@ +fb7ad10e20f2de4334f8c122c8582f18b91f0552 \ No newline at end of file
diff --git a/resources/audio_coding/F03.OUT20.sha1 b/resources/audio_coding/F03.OUT20.sha1 new file mode 100644 index 0000000..210e4f6 --- /dev/null +++ b/resources/audio_coding/F03.OUT20.sha1
@@ -0,0 +1 @@ +db4e9d9e09b55c3fe5536628c1f2f07f4bad068b \ No newline at end of file
diff --git a/resources/audio_coding/F03.OUT30.sha1 b/resources/audio_coding/F03.OUT30.sha1 new file mode 100644 index 0000000..c8a733c --- /dev/null +++ b/resources/audio_coding/F03.OUT30.sha1
@@ -0,0 +1 @@ +f48b05dce8cb0370cda4b93da45b4edc3fdd42d0 \ No newline at end of file
diff --git a/resources/audio_coding/F04.BIT20.sha1 b/resources/audio_coding/F04.BIT20.sha1 new file mode 100644 index 0000000..a304fa4 --- /dev/null +++ b/resources/audio_coding/F04.BIT20.sha1
@@ -0,0 +1 @@ +8cc1f82ee0d1b7df39840895d3e99756920b85ad \ No newline at end of file
diff --git a/resources/audio_coding/F04.BIT30.sha1 b/resources/audio_coding/F04.BIT30.sha1 new file mode 100644 index 0000000..c6cbe13 --- /dev/null +++ b/resources/audio_coding/F04.BIT30.sha1
@@ -0,0 +1 @@ +85ca3d9a5ca61c1bb9d798ba6d3551945ab7667d \ No newline at end of file
diff --git a/resources/audio_coding/F04.INP.sha1 b/resources/audio_coding/F04.INP.sha1 new file mode 100644 index 0000000..53118fc --- /dev/null +++ b/resources/audio_coding/F04.INP.sha1
@@ -0,0 +1 @@ +730581035d5af832d1b05c8f3a623ec93863b3e3 \ No newline at end of file
diff --git a/resources/audio_coding/F04.OUT20.sha1 b/resources/audio_coding/F04.OUT20.sha1 new file mode 100644 index 0000000..fd27f04 --- /dev/null +++ b/resources/audio_coding/F04.OUT20.sha1
@@ -0,0 +1 @@ +985e5ffa0b98718afadfb1f02b5595fb24a9476c \ No newline at end of file
diff --git a/resources/audio_coding/F04.OUT30.sha1 b/resources/audio_coding/F04.OUT30.sha1 new file mode 100644 index 0000000..3ccec4e --- /dev/null +++ b/resources/audio_coding/F04.OUT30.sha1
@@ -0,0 +1 @@ +8b035fb0f9ce3bdc2ae6c983e232c257a515a781 \ No newline at end of file
diff --git a/resources/audio_coding/F05.BIT20.sha1 b/resources/audio_coding/F05.BIT20.sha1 new file mode 100644 index 0000000..39d82e6 --- /dev/null +++ b/resources/audio_coding/F05.BIT20.sha1
@@ -0,0 +1 @@ +9069fecc3cd13bf901781af4ece8b374b5285984 \ No newline at end of file
diff --git a/resources/audio_coding/F05.BIT30.sha1 b/resources/audio_coding/F05.BIT30.sha1 new file mode 100644 index 0000000..513c936 --- /dev/null +++ b/resources/audio_coding/F05.BIT30.sha1
@@ -0,0 +1 @@ +44a04e133c15e013f6b4424877528a4445e28bef \ No newline at end of file
diff --git a/resources/audio_coding/F05.INP.sha1 b/resources/audio_coding/F05.INP.sha1 new file mode 100644 index 0000000..0ee0a39 --- /dev/null +++ b/resources/audio_coding/F05.INP.sha1
@@ -0,0 +1 @@ +c3dde10c32f12da58181ecaccb7aeaa515239233 \ No newline at end of file
diff --git a/resources/audio_coding/F05.OUT20.sha1 b/resources/audio_coding/F05.OUT20.sha1 new file mode 100644 index 0000000..df51452 --- /dev/null +++ b/resources/audio_coding/F05.OUT20.sha1
@@ -0,0 +1 @@ +260f51f8320d92d3c8b834c1f38879baa12a7a5a \ No newline at end of file
diff --git a/resources/audio_coding/F05.OUT30.sha1 b/resources/audio_coding/F05.OUT30.sha1 new file mode 100644 index 0000000..bcc318c --- /dev/null +++ b/resources/audio_coding/F05.OUT30.sha1
@@ -0,0 +1 @@ +72abb4c1d84a4cff1efed4d3e01280d839a9f691 \ No newline at end of file
diff --git a/resources/audio_coding/F06.BIT20.sha1 b/resources/audio_coding/F06.BIT20.sha1 new file mode 100644 index 0000000..6b6e3df --- /dev/null +++ b/resources/audio_coding/F06.BIT20.sha1
@@ -0,0 +1 @@ +b6530247acdfd7ae7b3fd80c677d71045351ad07 \ No newline at end of file
diff --git a/resources/audio_coding/F06.BIT30.sha1 b/resources/audio_coding/F06.BIT30.sha1 new file mode 100644 index 0000000..f9f7975 --- /dev/null +++ b/resources/audio_coding/F06.BIT30.sha1
@@ -0,0 +1 @@ +0318de4dc48422bfe125fd6f827e6e7114dc61bc \ No newline at end of file
diff --git a/resources/audio_coding/F06.INP.sha1 b/resources/audio_coding/F06.INP.sha1 new file mode 100644 index 0000000..1210209 --- /dev/null +++ b/resources/audio_coding/F06.INP.sha1
@@ -0,0 +1 @@ +80359cff72cbdc04a337a51c2fcc0c74890710b4 \ No newline at end of file
diff --git a/resources/audio_coding/F06.OUT20.sha1 b/resources/audio_coding/F06.OUT20.sha1 new file mode 100644 index 0000000..7d50df8 --- /dev/null +++ b/resources/audio_coding/F06.OUT20.sha1
@@ -0,0 +1 @@ +c7bc71abc973440123a517f61e3dbcb96089ee3f \ No newline at end of file
diff --git a/resources/audio_coding/F06.OUT30.sha1 b/resources/audio_coding/F06.OUT30.sha1 new file mode 100644 index 0000000..ad9219d --- /dev/null +++ b/resources/audio_coding/F06.OUT30.sha1
@@ -0,0 +1 @@ +5fde2defd2350b5ca7d3b8f8ceef75d2b7fd7f03 \ No newline at end of file
diff --git a/resources/audio_coding/READ.ME b/resources/audio_coding/READ.ME new file mode 100644 index 0000000..e42b9b3 --- /dev/null +++ b/resources/audio_coding/READ.ME
@@ -0,0 +1,18 @@ +Test files for Audio Coding Module + +testfile32kHz.pcm - mono speech file samples at 32 kHz +teststereo32kHz.pcm - stereo speech file samples at 32 kHz + +Test and reference vectors to verify correct execution of PacketCable +iLBC Fixed Point Reference Code + +Version 1.0.6 +Format: all .INP and .OUT files contain 16 bit sampled data using the +Intel (PC) format. The .BIT files are stored in the appropriate byte +sequence (big-endian format). + +*.INP - input files +*.BIT20 - bit stream files 20 ms mode +*.OUT20 - output files 20 ms mode (on a channel without packet loss) +*.BIT30 - bit stream files 30 ms mode +*.OUT30 - output files 30 ms mode (on a channel without packet loss)
diff --git a/resources/audio_coding/clean.chn.sha1 b/resources/audio_coding/clean.chn.sha1 new file mode 100644 index 0000000..6600d95 --- /dev/null +++ b/resources/audio_coding/clean.chn.sha1
@@ -0,0 +1 @@ +7fe50497b4fef1bbaca4bbb4f00c9f069ef63dc0 \ No newline at end of file
diff --git a/resources/audio_coding/music_stereo_48kHz.pcm.sha1 b/resources/audio_coding/music_stereo_48kHz.pcm.sha1 new file mode 100644 index 0000000..991cb57 --- /dev/null +++ b/resources/audio_coding/music_stereo_48kHz.pcm.sha1
@@ -0,0 +1 @@ +77b123a152911b538951cadbee45007f9d1a370c \ No newline at end of file
diff --git a/resources/audio_coding/neteq4_network_stats.dat.sha1 b/resources/audio_coding/neteq4_network_stats.dat.sha1 new file mode 100644 index 0000000..72a9499 --- /dev/null +++ b/resources/audio_coding/neteq4_network_stats.dat.sha1
@@ -0,0 +1 @@ +e5e2d0ff26d16339cf0f37a3512bfa2d390a9a9a \ No newline at end of file
diff --git a/resources/audio_coding/neteq4_network_stats_win_32.dat.sha1 b/resources/audio_coding/neteq4_network_stats_win_32.dat.sha1 new file mode 100644 index 0000000..5f46af6 --- /dev/null +++ b/resources/audio_coding/neteq4_network_stats_win_32.dat.sha1
@@ -0,0 +1 @@ +373f15261ef1dca3b61bd62d7f5e6dd085ae3eb8 \ No newline at end of file
diff --git a/resources/audio_coding/neteq4_rtcp_stats.dat.sha1 b/resources/audio_coding/neteq4_rtcp_stats.dat.sha1 new file mode 100644 index 0000000..ae63c76 --- /dev/null +++ b/resources/audio_coding/neteq4_rtcp_stats.dat.sha1
@@ -0,0 +1 @@ +948753a2087fbb5b74a3ea0b1aef8593c9c30b10 \ No newline at end of file
diff --git a/resources/audio_coding/neteq4_universal_ref.pcm.sha1 b/resources/audio_coding/neteq4_universal_ref.pcm.sha1 new file mode 100644 index 0000000..6643d54 --- /dev/null +++ b/resources/audio_coding/neteq4_universal_ref.pcm.sha1
@@ -0,0 +1 @@ +f587883b7c371ee8d87dbf1b0f07525af7d959b8 \ No newline at end of file
diff --git a/resources/audio_coding/neteq4_universal_ref_win_32.pcm.sha1 b/resources/audio_coding/neteq4_universal_ref_win_32.pcm.sha1 new file mode 100644 index 0000000..6643d54 --- /dev/null +++ b/resources/audio_coding/neteq4_universal_ref_win_32.pcm.sha1
@@ -0,0 +1 @@ +f587883b7c371ee8d87dbf1b0f07525af7d959b8 \ No newline at end of file
diff --git a/resources/audio_coding/neteq4_universal_ref_win_64.pcm.sha1 b/resources/audio_coding/neteq4_universal_ref_win_64.pcm.sha1 new file mode 100644 index 0000000..3c73ee9 --- /dev/null +++ b/resources/audio_coding/neteq4_universal_ref_win_64.pcm.sha1
@@ -0,0 +1 @@ +08266b198e7686b3cd9330813e0d2cd72fc8fdc2 \ No newline at end of file
diff --git a/resources/audio_coding/neteq_network_stats.dat.sha1 b/resources/audio_coding/neteq_network_stats.dat.sha1 new file mode 100644 index 0000000..e02ad84 --- /dev/null +++ b/resources/audio_coding/neteq_network_stats.dat.sha1
@@ -0,0 +1 @@ +e3c189b500d92fd0f10cb4c770c298cee7008749 \ No newline at end of file
diff --git a/resources/audio_coding/neteq_network_stats_win_32.dat.sha1 b/resources/audio_coding/neteq_network_stats_win_32.dat.sha1 new file mode 100644 index 0000000..a197fc1 --- /dev/null +++ b/resources/audio_coding/neteq_network_stats_win_32.dat.sha1
@@ -0,0 +1 @@ +343061419a64ca99323fc0d25a43149a5d40cf07 \ No newline at end of file
diff --git a/resources/audio_coding/neteq_rtcp_stats.dat.sha1 b/resources/audio_coding/neteq_rtcp_stats.dat.sha1 new file mode 100644 index 0000000..42d37ac --- /dev/null +++ b/resources/audio_coding/neteq_rtcp_stats.dat.sha1
@@ -0,0 +1 @@ +759d57e87517e0290144add9ba53d5c6dec1c27e \ No newline at end of file
diff --git a/resources/audio_coding/neteq_universal_new.rtp.sha1 b/resources/audio_coding/neteq_universal_new.rtp.sha1 new file mode 100644 index 0000000..f08a979 --- /dev/null +++ b/resources/audio_coding/neteq_universal_new.rtp.sha1
@@ -0,0 +1 @@ +8dd7585937f1f3b17666035a7aec5c0431d4b30b \ No newline at end of file
diff --git a/resources/audio_coding/neteq_universal_ref.pcm.sha1 b/resources/audio_coding/neteq_universal_ref.pcm.sha1 new file mode 100644 index 0000000..95e9de7 --- /dev/null +++ b/resources/audio_coding/neteq_universal_ref.pcm.sha1
@@ -0,0 +1 @@ +236da353f05d329f6c83e441b80dbfcc18706cfb \ No newline at end of file
diff --git a/resources/audio_coding/neteq_universal_ref_win_32.pcm.sha1 b/resources/audio_coding/neteq_universal_ref_win_32.pcm.sha1 new file mode 100644 index 0000000..47c90cf --- /dev/null +++ b/resources/audio_coding/neteq_universal_ref_win_32.pcm.sha1
@@ -0,0 +1 @@ +1d2d353be4345d30506866ca32fa72825c6d65b8 \ No newline at end of file
diff --git a/resources/audio_coding/speech_mono_16kHz.pcm.sha1 b/resources/audio_coding/speech_mono_16kHz.pcm.sha1 new file mode 100644 index 0000000..3cd29ed --- /dev/null +++ b/resources/audio_coding/speech_mono_16kHz.pcm.sha1
@@ -0,0 +1 @@ +89f191b706f8028e52ffd64525de1921eacd772a \ No newline at end of file
diff --git a/resources/audio_coding/speech_mono_32_48kHz.pcm.sha1 b/resources/audio_coding/speech_mono_32_48kHz.pcm.sha1 new file mode 100644 index 0000000..c3e3560 --- /dev/null +++ b/resources/audio_coding/speech_mono_32_48kHz.pcm.sha1
@@ -0,0 +1 @@ +009a3ee778767c2402b1d2c920bc2449265f5a2c \ No newline at end of file
diff --git a/resources/audio_coding/testfile32kHz.pcm.sha1 b/resources/audio_coding/testfile32kHz.pcm.sha1 new file mode 100644 index 0000000..c205a23 --- /dev/null +++ b/resources/audio_coding/testfile32kHz.pcm.sha1
@@ -0,0 +1 @@ +7e391aede4d688dea3d4f07651672e961ceec466 \ No newline at end of file
diff --git a/resources/audio_coding/teststereo32kHz.pcm.sha1 b/resources/audio_coding/teststereo32kHz.pcm.sha1 new file mode 100644 index 0000000..5b582d4 --- /dev/null +++ b/resources/audio_coding/teststereo32kHz.pcm.sha1
@@ -0,0 +1 @@ +ee18ff27c88bf0c6ea392519cf4d68d9bdba1ec1 \ No newline at end of file
diff --git a/resources/audio_coding/tlm10.chn.sha1 b/resources/audio_coding/tlm10.chn.sha1 new file mode 100644 index 0000000..801f448 --- /dev/null +++ b/resources/audio_coding/tlm10.chn.sha1
@@ -0,0 +1 @@ +21c78516c2470667a75c7ed85fe37c53a3514456 \ No newline at end of file
diff --git a/resources/audio_device/audio_short16.pcm.sha1 b/resources/audio_device/audio_short16.pcm.sha1 new file mode 100644 index 0000000..cabceb4 --- /dev/null +++ b/resources/audio_device/audio_short16.pcm.sha1
@@ -0,0 +1 @@ +18e211e4069e5a71ae15758b130c4d0357c4bcca \ No newline at end of file
diff --git a/resources/audio_device/audio_short44.pcm.sha1 b/resources/audio_device/audio_short44.pcm.sha1 new file mode 100644 index 0000000..be56c49 --- /dev/null +++ b/resources/audio_device/audio_short44.pcm.sha1
@@ -0,0 +1 @@ +7743e75662876c604ba908643938e49cde3d880a \ No newline at end of file
diff --git a/resources/audio_device/audio_short48.pcm.sha1 b/resources/audio_device/audio_short48.pcm.sha1 new file mode 100644 index 0000000..bfeab0b --- /dev/null +++ b/resources/audio_device/audio_short48.pcm.sha1
@@ -0,0 +1 @@ +23d9b291e4ec773ee1d1a6d63e61ca634e95c793 \ No newline at end of file
diff --git a/resources/audio_device/audio_short8.pcm.sha1 b/resources/audio_device/audio_short8.pcm.sha1 new file mode 100644 index 0000000..7191188 --- /dev/null +++ b/resources/audio_device/audio_short8.pcm.sha1
@@ -0,0 +1 @@ +300f82a1be0cade3651077dda6e84f23996e6110 \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_audio.pcm.sha1 b/resources/audio_processing/agc/agc_audio.pcm.sha1 new file mode 100644 index 0000000..583d38f --- /dev/null +++ b/resources/audio_processing/agc/agc_audio.pcm.sha1
@@ -0,0 +1 @@ +10a52dc6d6f15242a1aa549205657f2834353673 \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_no_circular_buffer.dat.sha1 b/resources/audio_processing/agc/agc_no_circular_buffer.dat.sha1 new file mode 100644 index 0000000..c413bb0 --- /dev/null +++ b/resources/audio_processing/agc/agc_no_circular_buffer.dat.sha1
@@ -0,0 +1 @@ +61219028e15606a3adbbc61d393575ab36b4078b \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_pitch_gain.dat.sha1 b/resources/audio_processing/agc/agc_pitch_gain.dat.sha1 new file mode 100644 index 0000000..734005a --- /dev/null +++ b/resources/audio_processing/agc/agc_pitch_gain.dat.sha1
@@ -0,0 +1 @@ +ba0c6e93a5e6d351d95385699fb9a719b6a6d0cc \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_pitch_lag.dat.sha1 b/resources/audio_processing/agc/agc_pitch_lag.dat.sha1 new file mode 100644 index 0000000..781e7a8 --- /dev/null +++ b/resources/audio_processing/agc/agc_pitch_lag.dat.sha1
@@ -0,0 +1 @@ +590c6fe033665d11fa70dbbbd3e7d8f0b8a616ce \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_spectral_peak.dat.sha1 b/resources/audio_processing/agc/agc_spectral_peak.dat.sha1 new file mode 100644 index 0000000..473becc --- /dev/null +++ b/resources/audio_processing/agc/agc_spectral_peak.dat.sha1
@@ -0,0 +1 @@ +3a5a28763e3ad5cd0f2833a90b685f4da97c2002 \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_vad.dat.sha1 b/resources/audio_processing/agc/agc_vad.dat.sha1 new file mode 100644 index 0000000..fd704a0 --- /dev/null +++ b/resources/audio_processing/agc/agc_vad.dat.sha1
@@ -0,0 +1 @@ +7cae05c6902812609fa23ac04037485503b0924d \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_voicing_prob.dat.sha1 b/resources/audio_processing/agc/agc_voicing_prob.dat.sha1 new file mode 100644 index 0000000..f0d1d10 --- /dev/null +++ b/resources/audio_processing/agc/agc_voicing_prob.dat.sha1
@@ -0,0 +1 @@ +b1ea860f0bfad3e86fedc43cd8752821e0d75a46 \ No newline at end of file
diff --git a/resources/audio_processing/agc/agc_with_circular_buffer.dat.sha1 b/resources/audio_processing/agc/agc_with_circular_buffer.dat.sha1 new file mode 100644 index 0000000..996a4ce --- /dev/null +++ b/resources/audio_processing/agc/agc_with_circular_buffer.dat.sha1
@@ -0,0 +1 @@ +49402cfaa36be32320167a65c8e96f70548f5257 \ No newline at end of file
diff --git a/resources/audio_processing/transient/ajm-macbook-1-spke16m.pcm.sha1 b/resources/audio_processing/transient/ajm-macbook-1-spke16m.pcm.sha1 new file mode 100644 index 0000000..654fad5 --- /dev/null +++ b/resources/audio_processing/transient/ajm-macbook-1-spke16m.pcm.sha1
@@ -0,0 +1 @@ +04155a7e186deb7524e3013476de3eaabd59a1f8 \ No newline at end of file
diff --git a/resources/audio_processing/transient/audio16kHz.pcm.sha1 b/resources/audio_processing/transient/audio16kHz.pcm.sha1 new file mode 100644 index 0000000..b35750c --- /dev/null +++ b/resources/audio_processing/transient/audio16kHz.pcm.sha1
@@ -0,0 +1 @@ +81cb7e547fad2894b5702fa571f9eb55ed6e1096 \ No newline at end of file
diff --git a/resources/audio_processing/transient/audio32kHz.pcm.sha1 b/resources/audio_processing/transient/audio32kHz.pcm.sha1 new file mode 100644 index 0000000..f6728e7 --- /dev/null +++ b/resources/audio_processing/transient/audio32kHz.pcm.sha1
@@ -0,0 +1 @@ +81cfcff6b0d70938fe74060ba0303504c31c6d7e \ No newline at end of file
diff --git a/resources/audio_processing/transient/audio48kHz.pcm.sha1 b/resources/audio_processing/transient/audio48kHz.pcm.sha1 new file mode 100644 index 0000000..126ff85 --- /dev/null +++ b/resources/audio_processing/transient/audio48kHz.pcm.sha1
@@ -0,0 +1 @@ +01278951e13675a3467782e1d2f18273c05eef50 \ No newline at end of file
diff --git a/resources/audio_processing/transient/audio8kHz.pcm.sha1 b/resources/audio_processing/transient/audio8kHz.pcm.sha1 new file mode 100644 index 0000000..7f44983 --- /dev/null +++ b/resources/audio_processing/transient/audio8kHz.pcm.sha1
@@ -0,0 +1 @@ +5fcb4621ea0f50c3fc9a63e4720ff52631258437 \ No newline at end of file
diff --git a/resources/audio_processing/transient/detect16kHz.dat.sha1 b/resources/audio_processing/transient/detect16kHz.dat.sha1 new file mode 100644 index 0000000..333e7c5 --- /dev/null +++ b/resources/audio_processing/transient/detect16kHz.dat.sha1
@@ -0,0 +1 @@ +35639dd1b73b678360897975a91a7c8af0be3644 \ No newline at end of file
diff --git a/resources/audio_processing/transient/detect32kHz.dat.sha1 b/resources/audio_processing/transient/detect32kHz.dat.sha1 new file mode 100644 index 0000000..ff9485c --- /dev/null +++ b/resources/audio_processing/transient/detect32kHz.dat.sha1
@@ -0,0 +1 @@ +c9d3d0b81262ffaba7d358ad534e6fcb27c00076 \ No newline at end of file
diff --git a/resources/audio_processing/transient/detect48kHz.dat.sha1 b/resources/audio_processing/transient/detect48kHz.dat.sha1 new file mode 100644 index 0000000..0410b9a --- /dev/null +++ b/resources/audio_processing/transient/detect48kHz.dat.sha1
@@ -0,0 +1 @@ +f46a3380c9285324e583965ef547fcaa1650f8b8 \ No newline at end of file
diff --git a/resources/audio_processing/transient/detect8kHz.dat.sha1 b/resources/audio_processing/transient/detect8kHz.dat.sha1 new file mode 100644 index 0000000..30c19bd --- /dev/null +++ b/resources/audio_processing/transient/detect8kHz.dat.sha1
@@ -0,0 +1 @@ +f625c14d134d69ad38b67295459406fc9947a705 \ No newline at end of file
diff --git a/resources/audio_processing/transient/double-utils.dat.sha1 b/resources/audio_processing/transient/double-utils.dat.sha1 new file mode 100644 index 0000000..3895184 --- /dev/null +++ b/resources/audio_processing/transient/double-utils.dat.sha1
@@ -0,0 +1 @@ +c26083880cd227178917b4df230520dbfb9b9bb1 \ No newline at end of file
diff --git a/resources/audio_processing/transient/float-utils.dat.sha1 b/resources/audio_processing/transient/float-utils.dat.sha1 new file mode 100644 index 0000000..1817c60 --- /dev/null +++ b/resources/audio_processing/transient/float-utils.dat.sha1
@@ -0,0 +1 @@ +0eaaf21344b4b030d6c0fb6dcc419e7d3959a148 \ No newline at end of file
diff --git a/resources/audio_processing/transient/suppressed16kHz.pcm.sha1 b/resources/audio_processing/transient/suppressed16kHz.pcm.sha1 new file mode 100644 index 0000000..7ea55c3 --- /dev/null +++ b/resources/audio_processing/transient/suppressed16kHz.pcm.sha1
@@ -0,0 +1 @@ +9781792dc39d7aada6418370246eef9f544ca47b \ No newline at end of file
diff --git a/resources/audio_processing/transient/suppressed32kHz.pcm.sha1 b/resources/audio_processing/transient/suppressed32kHz.pcm.sha1 new file mode 100644 index 0000000..5f49bc0 --- /dev/null +++ b/resources/audio_processing/transient/suppressed32kHz.pcm.sha1
@@ -0,0 +1 @@ +8b2bd11b591521178232aae598e6df0d001051c4 \ No newline at end of file
diff --git a/resources/audio_processing/transient/suppressed8kHz.pcm.sha1 b/resources/audio_processing/transient/suppressed8kHz.pcm.sha1 new file mode 100644 index 0000000..b0086da --- /dev/null +++ b/resources/audio_processing/transient/suppressed8kHz.pcm.sha1
@@ -0,0 +1 @@ +8a6c7ed696f9791f8cb5c5b061f07eb019affd49 \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd0.dat.sha1 b/resources/audio_processing/transient/wpd0.dat.sha1 new file mode 100644 index 0000000..9d9edd3 --- /dev/null +++ b/resources/audio_processing/transient/wpd0.dat.sha1
@@ -0,0 +1 @@ +7c01839f888fe6e10276e1819bd5207668345dcf \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd1.dat.sha1 b/resources/audio_processing/transient/wpd1.dat.sha1 new file mode 100644 index 0000000..59ff085 --- /dev/null +++ b/resources/audio_processing/transient/wpd1.dat.sha1
@@ -0,0 +1 @@ +f7553df9abca91401715185d97d1d9c20a2ecb9b \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd2.dat.sha1 b/resources/audio_processing/transient/wpd2.dat.sha1 new file mode 100644 index 0000000..3161de8 --- /dev/null +++ b/resources/audio_processing/transient/wpd2.dat.sha1
@@ -0,0 +1 @@ +0455d7042c64075e793285753a98f02268e6238b \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd3.dat.sha1 b/resources/audio_processing/transient/wpd3.dat.sha1 new file mode 100644 index 0000000..1a3b6f6 --- /dev/null +++ b/resources/audio_processing/transient/wpd3.dat.sha1
@@ -0,0 +1 @@ +941cc5d0bfccfd1d6bd68a1d882975202f22b6de \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd4.dat.sha1 b/resources/audio_processing/transient/wpd4.dat.sha1 new file mode 100644 index 0000000..3e05085 --- /dev/null +++ b/resources/audio_processing/transient/wpd4.dat.sha1
@@ -0,0 +1 @@ +a16139b3750a13b62327e2a78ea008493a2b508b \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd5.dat.sha1 b/resources/audio_processing/transient/wpd5.dat.sha1 new file mode 100644 index 0000000..aef4367 --- /dev/null +++ b/resources/audio_processing/transient/wpd5.dat.sha1
@@ -0,0 +1 @@ +6bf9272123656bc0561550a40734245709bbac10 \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd6.dat.sha1 b/resources/audio_processing/transient/wpd6.dat.sha1 new file mode 100644 index 0000000..355c31e --- /dev/null +++ b/resources/audio_processing/transient/wpd6.dat.sha1
@@ -0,0 +1 @@ +6a2667c6c4b3794776af1dabacc3575791023168 \ No newline at end of file
diff --git a/resources/audio_processing/transient/wpd7.dat.sha1 b/resources/audio_processing/transient/wpd7.dat.sha1 new file mode 100644 index 0000000..daf85ed --- /dev/null +++ b/resources/audio_processing/transient/wpd7.dat.sha1
@@ -0,0 +1 @@ +620cf1f732c99003ff0e5d6ae3350c0a2ea2a9d7 \ No newline at end of file
diff --git a/resources/audioproc.aecdump.sha1 b/resources/audioproc.aecdump.sha1 new file mode 100644 index 0000000..78cbd98 --- /dev/null +++ b/resources/audioproc.aecdump.sha1
@@ -0,0 +1 @@ +8b53334fec495185a82a759104240b2c01e449b6 \ No newline at end of file
diff --git a/resources/deflicker_before_cif_short.yuv.sha1 b/resources/deflicker_before_cif_short.yuv.sha1 new file mode 100644 index 0000000..d2f5a93 --- /dev/null +++ b/resources/deflicker_before_cif_short.yuv.sha1
@@ -0,0 +1 @@ +849f88896b1d00c2625c247e9e06a19d2ae0175c \ No newline at end of file
diff --git a/resources/difficult_photo_1850_1110.yuv.sha1 b/resources/difficult_photo_1850_1110.yuv.sha1 new file mode 100644 index 0000000..4da531f --- /dev/null +++ b/resources/difficult_photo_1850_1110.yuv.sha1
@@ -0,0 +1 @@ +6006efc8095f2aa4b30879ec37d5baad261f8ab0 \ No newline at end of file
diff --git a/resources/e2e_audio_in.pcm.sha1 b/resources/e2e_audio_in.pcm.sha1 new file mode 100644 index 0000000..2b37e46 --- /dev/null +++ b/resources/e2e_audio_in.pcm.sha1
@@ -0,0 +1 @@ +892d292c1dcd3b5cee5c71d8fa5d21118fbfe3f7 \ No newline at end of file
diff --git a/resources/far16_stereo.pcm.sha1 b/resources/far16_stereo.pcm.sha1 new file mode 100644 index 0000000..6d46dfc --- /dev/null +++ b/resources/far16_stereo.pcm.sha1
@@ -0,0 +1 @@ +7e5972e147a7d5e9817b09c8b6c5e93d307032aa \ No newline at end of file
diff --git a/resources/far32_stereo.pcm.sha1 b/resources/far32_stereo.pcm.sha1 new file mode 100644 index 0000000..af4e5ec --- /dev/null +++ b/resources/far32_stereo.pcm.sha1
@@ -0,0 +1 @@ +f143c04d4ab848e97f5bbb19f0799097a0d93c44 \ No newline at end of file
diff --git a/resources/far44_stereo.pcm.sha1 b/resources/far44_stereo.pcm.sha1 new file mode 100644 index 0000000..56f4adc --- /dev/null +++ b/resources/far44_stereo.pcm.sha1
@@ -0,0 +1 @@ +f812b1cfff98da276973e947b1ba177cd462f58a \ No newline at end of file
diff --git a/resources/far48_stereo.pcm.sha1 b/resources/far48_stereo.pcm.sha1 new file mode 100644 index 0000000..9b74ce8 --- /dev/null +++ b/resources/far48_stereo.pcm.sha1
@@ -0,0 +1 @@ +69c679d06f275c1bb4a616dc626a9a893d9c11f9 \ No newline at end of file
diff --git a/resources/far8_stereo.pcm.sha1 b/resources/far8_stereo.pcm.sha1 new file mode 100644 index 0000000..ac1b0b3 --- /dev/null +++ b/resources/far8_stereo.pcm.sha1
@@ -0,0 +1 @@ +6f543f892cd3740a3a1366a486a892766d1f0a79 \ No newline at end of file
diff --git a/resources/foremanColorEnhanced_cif_short.yuv.sha1 b/resources/foremanColorEnhanced_cif_short.yuv.sha1 new file mode 100644 index 0000000..f2514ae --- /dev/null +++ b/resources/foremanColorEnhanced_cif_short.yuv.sha1
@@ -0,0 +1 @@ +ce229fea854fbce532fe430b5b5a8c9b5db65d94 \ No newline at end of file
diff --git a/resources/foreman_cif.yuv.sha1 b/resources/foreman_cif.yuv.sha1 new file mode 100644 index 0000000..0891d20 --- /dev/null +++ b/resources/foreman_cif.yuv.sha1
@@ -0,0 +1 @@ +db8cc13114cfe550fefa264ea70427e1fa4f9bba \ No newline at end of file
diff --git a/resources/foreman_cif_short.yuv.sha1 b/resources/foreman_cif_short.yuv.sha1 new file mode 100644 index 0000000..81847eb --- /dev/null +++ b/resources/foreman_cif_short.yuv.sha1
@@ -0,0 +1 @@ +7398e204d06b34fcd09533523ec418af9b5caf80 \ No newline at end of file
diff --git a/resources/google-wifi-3mbps.rx.sha1 b/resources/google-wifi-3mbps.rx.sha1 new file mode 100644 index 0000000..cdd48ea --- /dev/null +++ b/resources/google-wifi-3mbps.rx.sha1
@@ -0,0 +1 @@ +7d88683e3113fe8174a72800232023756eefce33 \ No newline at end of file
diff --git a/resources/images/captureDeviceImage.jpg.sha1 b/resources/images/captureDeviceImage.jpg.sha1 new file mode 100644 index 0000000..7e73992 --- /dev/null +++ b/resources/images/captureDeviceImage.jpg.sha1
@@ -0,0 +1 @@ +0a1ae77fb59833b6485903912ae57d9e5b08dba8 \ No newline at end of file
diff --git a/resources/images/renderStartImage.jpg.sha1 b/resources/images/renderStartImage.jpg.sha1 new file mode 100644 index 0000000..cbfbff3 --- /dev/null +++ b/resources/images/renderStartImage.jpg.sha1
@@ -0,0 +1 @@ +74c1c0747a9fcab42400b4fb03a14578eede047e \ No newline at end of file
diff --git a/resources/images/renderTimeoutImage.jpg.sha1 b/resources/images/renderTimeoutImage.jpg.sha1 new file mode 100644 index 0000000..ca14f0e --- /dev/null +++ b/resources/images/renderTimeoutImage.jpg.sha1
@@ -0,0 +1 @@ +9506e097bb8d2a3fd535a62630cbfff2faadd89b \ No newline at end of file
diff --git a/resources/images/webrtc_logo.jpg.sha1 b/resources/images/webrtc_logo.jpg.sha1 new file mode 100644 index 0000000..9c3ddb5 --- /dev/null +++ b/resources/images/webrtc_logo.jpg.sha1
@@ -0,0 +1 @@ +bb77f4c608f8b45d7b1815bce10f3e38b198028c \ No newline at end of file
diff --git a/resources/near16_stereo.pcm.sha1 b/resources/near16_stereo.pcm.sha1 new file mode 100644 index 0000000..c71f233 --- /dev/null +++ b/resources/near16_stereo.pcm.sha1
@@ -0,0 +1 @@ +42ef52b80a02f28fde9ccc6299543bbde882bea9 \ No newline at end of file
diff --git a/resources/near32_stereo.pcm.sha1 b/resources/near32_stereo.pcm.sha1 new file mode 100644 index 0000000..7c2740b --- /dev/null +++ b/resources/near32_stereo.pcm.sha1
@@ -0,0 +1 @@ +ee9615ce39f2746b1b6ded5b2e31cdbc4b86c401 \ No newline at end of file
diff --git a/resources/near44_stereo.pcm.sha1 b/resources/near44_stereo.pcm.sha1 new file mode 100644 index 0000000..12dceb7 --- /dev/null +++ b/resources/near44_stereo.pcm.sha1
@@ -0,0 +1 @@ +88f6962dd4a7ed9dcbc58b106c162ea5cb8a3f5a \ No newline at end of file
diff --git a/resources/near48_stereo.pcm.sha1 b/resources/near48_stereo.pcm.sha1 new file mode 100644 index 0000000..e464ed3 --- /dev/null +++ b/resources/near48_stereo.pcm.sha1
@@ -0,0 +1 @@ +6c63f53a6ea6b25b91616a7d03c56cd08362ca22 \ No newline at end of file
diff --git a/resources/near8_stereo.pcm.sha1 b/resources/near8_stereo.pcm.sha1 new file mode 100644 index 0000000..02777a5 --- /dev/null +++ b/resources/near8_stereo.pcm.sha1
@@ -0,0 +1 @@ +5e09588dee0d3d2e89c9bdc9ff111b4f29b416be \ No newline at end of file
diff --git a/resources/paris_qcif.yuv.sha1 b/resources/paris_qcif.yuv.sha1 new file mode 100644 index 0000000..970c87a --- /dev/null +++ b/resources/paris_qcif.yuv.sha1
@@ -0,0 +1 @@ +d19fb2879d091324c699987ab280da82af200933 \ No newline at end of file
diff --git a/resources/photo_1850_1110.yuv.sha1 b/resources/photo_1850_1110.yuv.sha1 new file mode 100644 index 0000000..bf39d82 --- /dev/null +++ b/resources/photo_1850_1110.yuv.sha1
@@ -0,0 +1 @@ +c43aac0ccbf1b6f0922d1db5925d9e05d263a360 \ No newline at end of file
diff --git a/resources/presentation_1850_1110.yuv.sha1 b/resources/presentation_1850_1110.yuv.sha1 new file mode 100644 index 0000000..5fc93b6 --- /dev/null +++ b/resources/presentation_1850_1110.yuv.sha1
@@ -0,0 +1 @@ +9f1112d34e6a6e3039c3564bdbdf0913a9f62688 \ No newline at end of file
diff --git a/resources/ref03.aecdump.sha1 b/resources/ref03.aecdump.sha1 new file mode 100644 index 0000000..1a6db3e --- /dev/null +++ b/resources/ref03.aecdump.sha1
@@ -0,0 +1 @@ +04f9f47938efa99d0389672ff2d83c10f04a1752 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_AST.bin.sha1 new file mode 100644 index 0000000..0e1c108 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_AST.bin.sha1
@@ -0,0 +1 @@ +27bca982f40243ce6a491c05792f271166776eb9 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_TOF.bin.sha1 new file mode 100644 index 0000000..0e1c108 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_0_TOF.bin.sha1
@@ -0,0 +1 @@ +27bca982f40243ce6a491c05792f271166776eb9 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_1_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_1_AST.bin.sha1 new file mode 100644 index 0000000..781691f --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_1_AST.bin.sha1
@@ -0,0 +1 @@ +2437de4b814694bfae0c7d47f851e356d8302796 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_1_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_1_TOF.bin.sha1 new file mode 100644 index 0000000..781691f --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke1_1_TOF.bin.sha1
@@ -0,0 +1 @@ +2437de4b814694bfae0c7d47f851e356d8302796 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_0_AST.bin.sha1 new file mode 100644 index 0000000..9a18507 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_0_AST.bin.sha1
@@ -0,0 +1 @@ +c2d507d2d3edadab06942736a81c6ca3221e23c7 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_0_TOF.bin.sha1 new file mode 100644 index 0000000..9a18507 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_0_TOF.bin.sha1
@@ -0,0 +1 @@ +c2d507d2d3edadab06942736a81c6ca3221e23c7 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_1_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_1_AST.bin.sha1 new file mode 100644 index 0000000..46ee7df --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_1_AST.bin.sha1
@@ -0,0 +1 @@ +feeeed364dc66dea552b26271094ff11707a1e65 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_1_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_1_TOF.bin.sha1 new file mode 100644 index 0000000..46ee7df --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingChoke2_1_TOF.bin.sha1
@@ -0,0 +1 @@ +feeeed364dc66dea552b26271094ff11707a1e65 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingDelay1_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingDelay1_0_AST.bin.sha1 new file mode 100644 index 0000000..21cf98c --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingDelay1_0_AST.bin.sha1
@@ -0,0 +1 @@ +333ad9b7310be8d9c6a36c2b1fa63999a1098b88 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingDelay1_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingDelay1_0_TOF.bin.sha1 new file mode 100644 index 0000000..21cf98c --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingDelay1_0_TOF.bin.sha1
@@ -0,0 +1 @@ +333ad9b7310be8d9c6a36c2b1fa63999a1098b88 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingLoss1_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingLoss1_0_AST.bin.sha1 new file mode 100644 index 0000000..2fff908 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingLoss1_0_AST.bin.sha1
@@ -0,0 +1 @@ +95a356db2eb39fd1bbf1ece1cfbf673b1f893487 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingLoss1_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingLoss1_0_TOF.bin.sha1 new file mode 100644 index 0000000..2fff908 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_IncreasingLoss1_0_TOF.bin.sha1
@@ -0,0 +1 @@ +95a356db2eb39fd1bbf1ece1cfbf673b1f893487 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_Multi1_1_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_Multi1_1_AST.bin.sha1 new file mode 100644 index 0000000..8e70aa2 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_Multi1_1_AST.bin.sha1
@@ -0,0 +1 @@ +d7814fe1106ee4d030bb5c4316765615f4b747dd \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_Multi1_1_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_Multi1_1_TOF.bin.sha1 new file mode 100644 index 0000000..8e70aa2 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_Multi1_1_TOF.bin.sha1
@@ -0,0 +1 @@ +d7814fe1106ee4d030bb5c4316765615f4b747dd \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_0_AST.bin.sha1 new file mode 100644 index 0000000..473aaa6 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_0_AST.bin.sha1
@@ -0,0 +1 @@ +dba0be49e995fec988bb92d8d62b9e39b3f01bbe \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_0_TOF.bin.sha1 new file mode 100644 index 0000000..473aaa6 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_0_TOF.bin.sha1
@@ -0,0 +1 @@ +dba0be49e995fec988bb92d8d62b9e39b3f01bbe \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_1_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_1_AST.bin.sha1 new file mode 100644 index 0000000..5d617bb --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_1_AST.bin.sha1
@@ -0,0 +1 @@ +091869a91d200add958904c0b5a42d47b1f5f9ac \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_1_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_1_TOF.bin.sha1 new file mode 100644 index 0000000..5d617bb --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyChoke_1_TOF.bin.sha1
@@ -0,0 +1 @@ +091869a91d200add958904c0b5a42d47b1f5f9ac \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyDelay_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyDelay_0_AST.bin.sha1 new file mode 100644 index 0000000..fcc16b6 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyDelay_0_AST.bin.sha1
@@ -0,0 +1 @@ +988a157505bb3b938c813282d90cb445a5cea19b \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyDelay_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyDelay_0_TOF.bin.sha1 new file mode 100644 index 0000000..fcc16b6 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyDelay_0_TOF.bin.sha1
@@ -0,0 +1 @@ +988a157505bb3b938c813282d90cb445a5cea19b \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyLoss_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyLoss_0_AST.bin.sha1 new file mode 100644 index 0000000..8395bcf --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyLoss_0_AST.bin.sha1
@@ -0,0 +1 @@ +e367a4e6b3ba1b4cd6ac2e71b55cdaed3b63a739 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyLoss_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyLoss_0_TOF.bin.sha1 new file mode 100644 index 0000000..8395bcf --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_SteadyLoss_0_TOF.bin.sha1
@@ -0,0 +1 @@ +e367a4e6b3ba1b4cd6ac2e71b55cdaed3b63a739 \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_UnlimitedSpeed_0_AST.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_UnlimitedSpeed_0_AST.bin.sha1 new file mode 100644 index 0000000..df83598 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_UnlimitedSpeed_0_AST.bin.sha1
@@ -0,0 +1 @@ +26e5e14a114a869a0777458520e6c27b5791863d \ No newline at end of file
diff --git a/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_UnlimitedSpeed_0_TOF.bin.sha1 b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_UnlimitedSpeed_0_TOF.bin.sha1 new file mode 100644 index 0000000..df83598 --- /dev/null +++ b/resources/remote_bitrate_estimator/VideoSendersTest_BweTest_UnlimitedSpeed_0_TOF.bin.sha1
@@ -0,0 +1 @@ +26e5e14a114a869a0777458520e6c27b5791863d \ No newline at end of file
diff --git a/resources/rtp_rtcp/H263Foreman_CIF_Iframe.bin.sha1 b/resources/rtp_rtcp/H263Foreman_CIF_Iframe.bin.sha1 new file mode 100644 index 0000000..d2711f7 --- /dev/null +++ b/resources/rtp_rtcp/H263Foreman_CIF_Iframe.bin.sha1
@@ -0,0 +1 @@ +85ed12110295095577b9ea6d022a8cdd44548ee0 \ No newline at end of file
diff --git a/resources/rtp_rtcp/H263Foreman_CIF_Pframe.bin.sha1 b/resources/rtp_rtcp/H263Foreman_CIF_Pframe.bin.sha1 new file mode 100644 index 0000000..064c5cc --- /dev/null +++ b/resources/rtp_rtcp/H263Foreman_CIF_Pframe.bin.sha1
@@ -0,0 +1 @@ +d67b2b6eb37491df9d840cfe04207d4d0b57f70e \ No newline at end of file
diff --git a/resources/rtp_rtcp/H263_CIF_IFRAME.bin.sha1 b/resources/rtp_rtcp/H263_CIF_IFRAME.bin.sha1 new file mode 100644 index 0000000..d2711f7 --- /dev/null +++ b/resources/rtp_rtcp/H263_CIF_IFRAME.bin.sha1
@@ -0,0 +1 @@ +85ed12110295095577b9ea6d022a8cdd44548ee0 \ No newline at end of file
diff --git a/resources/rtp_rtcp/H263_CIF_PFRAME.bin.sha1 b/resources/rtp_rtcp/H263_CIF_PFRAME.bin.sha1 new file mode 100644 index 0000000..f981f73 --- /dev/null +++ b/resources/rtp_rtcp/H263_CIF_PFRAME.bin.sha1
@@ -0,0 +1 @@ +1d495b3f93f8f0d60b76bae8776b0775f8ee4446 \ No newline at end of file
diff --git a/resources/rtp_rtcp/H263_QCIF_IFRAME.bin.sha1 b/resources/rtp_rtcp/H263_QCIF_IFRAME.bin.sha1 new file mode 100644 index 0000000..b95a8c4 --- /dev/null +++ b/resources/rtp_rtcp/H263_QCIF_IFRAME.bin.sha1
@@ -0,0 +1 @@ +5ef822c6ac7694d7a4b920e207b042ab1177c1f4 \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR0.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR0.bin.sha1 new file mode 100644 index 0000000..ab68000 --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR0.bin.sha1
@@ -0,0 +1 @@ +cba9c86bec43f8d0a215b812e5667ad51eeb9733 \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR1.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR1.bin.sha1 new file mode 100644 index 0000000..6eadd5b --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR1.bin.sha1
@@ -0,0 +1 @@ +c461ac9291e538772cf371b04bae25b42227ad6a \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR2.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR2.bin.sha1 new file mode 100644 index 0000000..f610f23 --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR2.bin.sha1
@@ -0,0 +1 @@ +6c9c38e3dd31768d485541753babd5174dc3487a \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR3.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR3.bin.sha1 new file mode 100644 index 0000000..545e07b --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR3.bin.sha1
@@ -0,0 +1 @@ +0d34c8c1894500a27e63fc978ad2db51e6d4fe04 \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR4.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR4.bin.sha1 new file mode 100644 index 0000000..6959876 --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR4.bin.sha1
@@ -0,0 +1 @@ +ceb51910e84bd3798a0cac78c599f1516223ae69 \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR4_1.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR4_1.bin.sha1 new file mode 100644 index 0000000..221ec08 --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR4_1.bin.sha1
@@ -0,0 +1 @@ +d2766d4dd086f8a79a8e8dee14194c9547b7dec1 \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR4_2.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR4_2.bin.sha1 new file mode 100644 index 0000000..a115e25 --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR4_2.bin.sha1
@@ -0,0 +1 @@ +2eccb3f70d583a0674279d7eb103d11c04c8cd88 \ No newline at end of file
diff --git a/resources/rtp_rtcp/RTCPPacketTMMBR5.bin.sha1 b/resources/rtp_rtcp/RTCPPacketTMMBR5.bin.sha1 new file mode 100644 index 0000000..3377180 --- /dev/null +++ b/resources/rtp_rtcp/RTCPPacketTMMBR5.bin.sha1
@@ -0,0 +1 @@ +69715a94c0eefe399250fa0a039d4909937426b1 \ No newline at end of file
diff --git a/resources/short_mixed_mono_48.dat.sha1 b/resources/short_mixed_mono_48.dat.sha1 new file mode 100644 index 0000000..efc5745 --- /dev/null +++ b/resources/short_mixed_mono_48.dat.sha1
@@ -0,0 +1 @@ +6d3d824f7f73e1ab852982a7b53d52cfcbbf72cc \ No newline at end of file
diff --git a/resources/short_mixed_mono_48.pcm.sha1 b/resources/short_mixed_mono_48.pcm.sha1 new file mode 100644 index 0000000..a3683e9 --- /dev/null +++ b/resources/short_mixed_mono_48.pcm.sha1
@@ -0,0 +1 @@ +b379bbabb2203b3fb641e68fd049d8b32b30fd92 \ No newline at end of file
diff --git a/resources/short_mixed_stereo_48.dat.sha1 b/resources/short_mixed_stereo_48.dat.sha1 new file mode 100644 index 0000000..6eca334 --- /dev/null +++ b/resources/short_mixed_stereo_48.dat.sha1
@@ -0,0 +1 @@ +1b4fb326753834d492af1be034da300a3b9653a0 \ No newline at end of file
diff --git a/resources/short_mixed_stereo_48.pcm.sha1 b/resources/short_mixed_stereo_48.pcm.sha1 new file mode 100644 index 0000000..e418f08 --- /dev/null +++ b/resources/short_mixed_stereo_48.pcm.sha1
@@ -0,0 +1 @@ +01014353790b866c80b24084133ace99fbe6c5f1 \ No newline at end of file
diff --git a/resources/speech_and_misc_wb.pcm.sha1 b/resources/speech_and_misc_wb.pcm.sha1 new file mode 100644 index 0000000..47ae524 --- /dev/null +++ b/resources/speech_and_misc_wb.pcm.sha1
@@ -0,0 +1 @@ +0f0326ac7689cb62fb515402bb5e7248ab4ebdcb \ No newline at end of file
diff --git a/resources/sprint-downlink.rx.sha1 b/resources/sprint-downlink.rx.sha1 new file mode 100644 index 0000000..946840f --- /dev/null +++ b/resources/sprint-downlink.rx.sha1
@@ -0,0 +1 @@ +fd7ea55f4009359a78928af5c43e84b2b4101f50 \ No newline at end of file
diff --git a/resources/sprint-uplink.rx.sha1 b/resources/sprint-uplink.rx.sha1 new file mode 100644 index 0000000..6165ad2 --- /dev/null +++ b/resources/sprint-uplink.rx.sha1
@@ -0,0 +1 @@ +46ac4f207c9437b1c4a35c3e398da65354f49742 \ No newline at end of file
diff --git a/resources/synthetic-trace.rx.sha1 b/resources/synthetic-trace.rx.sha1 new file mode 100644 index 0000000..12f4417 --- /dev/null +++ b/resources/synthetic-trace.rx.sha1
@@ -0,0 +1 @@ +72c5686ceebec94c9388ba9869d98caaf3a8b4a9 \ No newline at end of file
diff --git a/resources/tmobile-downlink.rx.sha1 b/resources/tmobile-downlink.rx.sha1 new file mode 100644 index 0000000..9d5981a --- /dev/null +++ b/resources/tmobile-downlink.rx.sha1
@@ -0,0 +1 @@ +1998229c3ded7222faa4fcb85d1237ef54766c58 \ No newline at end of file
diff --git a/resources/tmobile-uplink.rx.sha1 b/resources/tmobile-uplink.rx.sha1 new file mode 100644 index 0000000..1a22637 --- /dev/null +++ b/resources/tmobile-uplink.rx.sha1
@@ -0,0 +1 @@ +13acfb4cf4240e298d8e5f22e76125574848831e \ No newline at end of file
diff --git a/resources/utility/encapsulated_pcm16b_8khz.wav.sha1 b/resources/utility/encapsulated_pcm16b_8khz.wav.sha1 new file mode 100644 index 0000000..480cfea --- /dev/null +++ b/resources/utility/encapsulated_pcm16b_8khz.wav.sha1
@@ -0,0 +1 @@ +43092df43f4093e474c41cd74e3085e7ca401c7d \ No newline at end of file
diff --git a/resources/utility/encapsulated_pcmu_8khz.wav.sha1 b/resources/utility/encapsulated_pcmu_8khz.wav.sha1 new file mode 100644 index 0000000..e2269f7 --- /dev/null +++ b/resources/utility/encapsulated_pcmu_8khz.wav.sha1
@@ -0,0 +1 @@ +d96caa3ff9c48559ec37784791887994d28f3b5a \ No newline at end of file
diff --git a/resources/verizon3g-downlink.rx.sha1 b/resources/verizon3g-downlink.rx.sha1 new file mode 100644 index 0000000..215beb7 --- /dev/null +++ b/resources/verizon3g-downlink.rx.sha1
@@ -0,0 +1 @@ +f35cb94b893912b5312eb74c63d36b65426576e0 \ No newline at end of file
diff --git a/resources/verizon3g-uplink.rx.sha1 b/resources/verizon3g-uplink.rx.sha1 new file mode 100644 index 0000000..55f6330 --- /dev/null +++ b/resources/verizon3g-uplink.rx.sha1
@@ -0,0 +1 @@ +87d02bc510eac4b8b4a2453687c6b49f39aa481c \ No newline at end of file
diff --git a/resources/verizon4g-downlink.rx.sha1 b/resources/verizon4g-downlink.rx.sha1 new file mode 100644 index 0000000..c09d0ad --- /dev/null +++ b/resources/verizon4g-downlink.rx.sha1
@@ -0,0 +1 @@ +07716dffe2905abde0ae7bec475106e476bc9b25 \ No newline at end of file
diff --git a/resources/verizon4g-uplink.rx.sha1 b/resources/verizon4g-uplink.rx.sha1 new file mode 100644 index 0000000..8ad9afb --- /dev/null +++ b/resources/verizon4g-uplink.rx.sha1
@@ -0,0 +1 @@ +2d32cd78d75549a5d0795bb9fbe35a00663f949a \ No newline at end of file
diff --git a/resources/video_coding/frame-ethernet-ii.pcap.sha1 b/resources/video_coding/frame-ethernet-ii.pcap.sha1 new file mode 100644 index 0000000..fd58843 --- /dev/null +++ b/resources/video_coding/frame-ethernet-ii.pcap.sha1
@@ -0,0 +1 @@ +55e9558ecac792cbaa492bdfc081cf2e274b3857 \ No newline at end of file
diff --git a/resources/video_coding/frame-loopback.pcap.sha1 b/resources/video_coding/frame-loopback.pcap.sha1 new file mode 100644 index 0000000..bd0000f --- /dev/null +++ b/resources/video_coding/frame-loopback.pcap.sha1
@@ -0,0 +1 @@ +04f8d1fb98e122757b1c5d032fd5d8976127fbbf \ No newline at end of file
diff --git a/resources/video_coding/pltype103.rtp.sha1 b/resources/video_coding/pltype103.rtp.sha1 new file mode 100644 index 0000000..d4e3aba --- /dev/null +++ b/resources/video_coding/pltype103.rtp.sha1
@@ -0,0 +1 @@ +1770f2f2a6d13b403ad9e4e577052a72b52a3ea6 \ No newline at end of file
diff --git a/resources/video_coding/pltype103_header_only.rtp.sha1 b/resources/video_coding/pltype103_header_only.rtp.sha1 new file mode 100644 index 0000000..eee5aa9 --- /dev/null +++ b/resources/video_coding/pltype103_header_only.rtp.sha1
@@ -0,0 +1 @@ +2a77f0d030aa96f51f0a96e971b42c3b11fe006b \ No newline at end of file
diff --git a/resources/video_coding/ssrcs-2.pcap.sha1 b/resources/video_coding/ssrcs-2.pcap.sha1 new file mode 100644 index 0000000..bd0000f --- /dev/null +++ b/resources/video_coding/ssrcs-2.pcap.sha1
@@ -0,0 +1 @@ +04f8d1fb98e122757b1c5d032fd5d8976127fbbf \ No newline at end of file
diff --git a/resources/video_coding/ssrcs-3.pcap.sha1 b/resources/video_coding/ssrcs-3.pcap.sha1 new file mode 100644 index 0000000..fd58843 --- /dev/null +++ b/resources/video_coding/ssrcs-3.pcap.sha1
@@ -0,0 +1 @@ +55e9558ecac792cbaa492bdfc081cf2e274b3857 \ No newline at end of file
diff --git a/resources/video_engine/renderStartImage.jpg.sha1 b/resources/video_engine/renderStartImage.jpg.sha1 new file mode 100644 index 0000000..cbfbff3 --- /dev/null +++ b/resources/video_engine/renderStartImage.jpg.sha1
@@ -0,0 +1 @@ +74c1c0747a9fcab42400b4fb03a14578eede047e \ No newline at end of file
diff --git a/resources/video_engine/renderTimeoutImage.jpg.sha1 b/resources/video_engine/renderTimeoutImage.jpg.sha1 new file mode 100644 index 0000000..ca14f0e --- /dev/null +++ b/resources/video_engine/renderTimeoutImage.jpg.sha1
@@ -0,0 +1 @@ +9506e097bb8d2a3fd535a62630cbfff2faadd89b \ No newline at end of file
diff --git a/resources/voice_engine/audio_long16.pcm.sha1 b/resources/voice_engine/audio_long16.pcm.sha1 new file mode 100644 index 0000000..fbc8d7b --- /dev/null +++ b/resources/voice_engine/audio_long16.pcm.sha1
@@ -0,0 +1 @@ +51bb93b2779e80274a03616fc256d35e96c03ffa \ No newline at end of file
diff --git a/resources/voice_engine/audio_long16.wav.sha1 b/resources/voice_engine/audio_long16.wav.sha1 new file mode 100644 index 0000000..5e0c3ab --- /dev/null +++ b/resources/voice_engine/audio_long16.wav.sha1
@@ -0,0 +1 @@ +dedb607bb5d659a10907bf7300e23330f2ae1bf6 \ No newline at end of file
diff --git a/resources/voice_engine/audio_long16big_endian.pcm.sha1 b/resources/voice_engine/audio_long16big_endian.pcm.sha1 new file mode 100644 index 0000000..3ae046a --- /dev/null +++ b/resources/voice_engine/audio_long16big_endian.pcm.sha1
@@ -0,0 +1 @@ +aaba3f51a83ad0087748c8cd63635ae59aabb3bc \ No newline at end of file
diff --git a/resources/voice_engine/audio_long16noise.pcm.sha1 b/resources/voice_engine/audio_long16noise.pcm.sha1 new file mode 100644 index 0000000..f04de6c --- /dev/null +++ b/resources/voice_engine/audio_long16noise.pcm.sha1
@@ -0,0 +1 @@ +573e82889a25b1db477e64eb4389907397ba19c7 \ No newline at end of file
diff --git a/resources/voice_engine/audio_long8.pcm.sha1 b/resources/voice_engine/audio_long8.pcm.sha1 new file mode 100644 index 0000000..eb36c71 --- /dev/null +++ b/resources/voice_engine/audio_long8.pcm.sha1
@@ -0,0 +1 @@ +20db24815301978aa4106189e6506c80cfe855ac \ No newline at end of file
diff --git a/resources/voice_engine/audio_long8mulaw.wav.sha1 b/resources/voice_engine/audio_long8mulaw.wav.sha1 new file mode 100644 index 0000000..f84f140 --- /dev/null +++ b/resources/voice_engine/audio_long8mulaw.wav.sha1
@@ -0,0 +1 @@ +07d014fe9688311e5a57113e45478dddf7c0f232 \ No newline at end of file
diff --git a/resources/voice_engine/audio_short16.pcm.sha1 b/resources/voice_engine/audio_short16.pcm.sha1 new file mode 100644 index 0000000..cabceb4 --- /dev/null +++ b/resources/voice_engine/audio_short16.pcm.sha1
@@ -0,0 +1 @@ +18e211e4069e5a71ae15758b130c4d0357c4bcca \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny11.wav.sha1 b/resources/voice_engine/audio_tiny11.wav.sha1 new file mode 100644 index 0000000..09759e8 --- /dev/null +++ b/resources/voice_engine/audio_tiny11.wav.sha1
@@ -0,0 +1 @@ +504d65e99c4d9bba557d630191b31148d952b6c6 \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny16.wav.sha1 b/resources/voice_engine/audio_tiny16.wav.sha1 new file mode 100644 index 0000000..186ebc5 --- /dev/null +++ b/resources/voice_engine/audio_tiny16.wav.sha1
@@ -0,0 +1 @@ +d3d8cc02820f6280ec8a913c3cd6a5bd6e312105 \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny22.wav.sha1 b/resources/voice_engine/audio_tiny22.wav.sha1 new file mode 100644 index 0000000..0897c80 --- /dev/null +++ b/resources/voice_engine/audio_tiny22.wav.sha1
@@ -0,0 +1 @@ +98d7f0bedbc6a52b087db8dca64e8ea80e6894f2 \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny32.wav.sha1 b/resources/voice_engine/audio_tiny32.wav.sha1 new file mode 100644 index 0000000..7128020 --- /dev/null +++ b/resources/voice_engine/audio_tiny32.wav.sha1
@@ -0,0 +1 @@ +f85e5869aa8e4f82f08c8c2e7b4c7b10240d8c2a \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny44.wav.sha1 b/resources/voice_engine/audio_tiny44.wav.sha1 new file mode 100644 index 0000000..6fc4baf --- /dev/null +++ b/resources/voice_engine/audio_tiny44.wav.sha1
@@ -0,0 +1 @@ +93d274a25d1b0d84ce18a9d4d9aa5e08f4dd13d6 \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny48.wav.sha1 b/resources/voice_engine/audio_tiny48.wav.sha1 new file mode 100644 index 0000000..31b229e --- /dev/null +++ b/resources/voice_engine/audio_tiny48.wav.sha1
@@ -0,0 +1 @@ +a572d9d2a4d740529613e032d27408855f1f08b4 \ No newline at end of file
diff --git a/resources/voice_engine/audio_tiny8.wav.sha1 b/resources/voice_engine/audio_tiny8.wav.sha1 new file mode 100644 index 0000000..720e5c7 --- /dev/null +++ b/resources/voice_engine/audio_tiny8.wav.sha1
@@ -0,0 +1 @@ +a2c0567c7eb38c4032a69ed553edac4ac9cd6408 \ No newline at end of file
diff --git a/resources/web_screenshot_1850_1110.yuv.sha1 b/resources/web_screenshot_1850_1110.yuv.sha1 new file mode 100644 index 0000000..48b0c11 --- /dev/null +++ b/resources/web_screenshot_1850_1110.yuv.sha1
@@ -0,0 +1 @@ +74c974b0ed28003c3a3b6a2923e5373478dfd145 \ No newline at end of file
diff --git a/setup_links.py b/setup_links.py new file mode 100755 index 0000000..9aeb1e8 --- /dev/null +++ b/setup_links.py
@@ -0,0 +1,518 @@ +#!/usr/bin/env python +# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +"""Setup links to a Chromium checkout for WebRTC. + +WebRTC standalone shares a lot of dependencies and build tools with Chromium. +To do this, many of the paths of a Chromium checkout is emulated by creating +symlinks to files and directories. This script handles the setup of symlinks to +achieve this. + +It also handles cleanup of the legacy Subversion-based approach that was used +before Chrome switched over their master repo from Subversion to Git. +""" + + +import ctypes +import errno +import logging +import optparse +import os +import shelve +import shutil +import subprocess +import sys +import textwrap + + +DIRECTORIES = [ + 'build', + 'buildtools', + 'google_apis', # Needed by build/common.gypi. + 'net', + 'testing', + 'third_party/binutils', + 'third_party/boringssl', + 'third_party/colorama', + 'third_party/drmemory', + 'third_party/expat', + 'third_party/icu', + 'third_party/instrumented_libraries', + 'third_party/jsoncpp', + 'third_party/libjpeg', + 'third_party/libjpeg_turbo', + 'third_party/libsrtp', + 'third_party/libudev', + 'third_party/libvpx_new', + 'third_party/libyuv', + 'third_party/llvm-build', + 'third_party/lss', + 'third_party/nss', + 'third_party/ocmock', + 'third_party/openmax_dl', + 'third_party/opus', + 'third_party/proguard', + 'third_party/protobuf', + 'third_party/sqlite', + 'third_party/syzygy', + 'third_party/usrsctp', + 'third_party/yasm', + 'third_party/zlib', + 'tools/clang', + 'tools/generate_library_loader', + 'tools/gn', + 'tools/gyp', + 'tools/memory', + 'tools/protoc_wrapper', + 'tools/python', + 'tools/swarming_client', + 'tools/valgrind', + 'tools/vim', + 'tools/win', + 'tools/xdisplaycheck', +] + +from sync_chromium import get_target_os_list +target_os = get_target_os_list() +if 'android' in target_os: + DIRECTORIES += [ + 'base', + 'third_party/android_platform', + 'third_party/android_testrunner', + 'third_party/android_tools', + 'third_party/appurify-python', + 'third_party/ashmem', + 'third_party/ijar', + 'third_party/jsr-305', + 'third_party/junit', + 'third_party/libevent', + 'third_party/libxml', + 'third_party/mockito', + 'third_party/modp_b64', + 'third_party/requests', + 'third_party/robolectric', + 'tools/android', + 'tools/grit', + 'tools/relocation_packer' + ] +if 'ios' in target_os: + DIRECTORIES.append('third_party/class-dump') + +FILES = { + 'tools/find_depot_tools.py': None, + 'tools/isolate_driver.py': None, + 'third_party/BUILD.gn': None, +} + +ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) +CHROMIUM_CHECKOUT = os.path.join('chromium', 'src') +LINKS_DB = 'links' + +# Version management to make future upgrades/downgrades easier to support. +SCHEMA_VERSION = 1 + + +def query_yes_no(question, default=False): + """Ask a yes/no question via raw_input() and return their answer. + + Modified from http://stackoverflow.com/a/3041990. + """ + prompt = " [%s/%%s]: " + prompt = prompt % ('Y' if default is True else 'y') + prompt = prompt % ('N' if default is False else 'n') + + if default is None: + default = 'INVALID' + + while True: + sys.stdout.write(question + prompt) + choice = raw_input().lower() + if choice == '' and default != 'INVALID': + return default + + if 'yes'.startswith(choice): + return True + elif 'no'.startswith(choice): + return False + + print "Please respond with 'yes' or 'no' (or 'y' or 'n')." + + +# Actions +class Action(object): + def __init__(self, dangerous): + self.dangerous = dangerous + + def announce(self, planning): + """Log a description of this action. + + Args: + planning - True iff we're in the planning stage, False if we're in the + doit stage. + """ + pass + + def doit(self, links_db): + """Execute the action, recording what we did to links_db, if necessary.""" + pass + + +class Remove(Action): + def __init__(self, path, dangerous): + super(Remove, self).__init__(dangerous) + self._priority = 0 + self._path = path + + def announce(self, planning): + log = logging.warn + filesystem_type = 'file' + if not self.dangerous: + log = logging.info + filesystem_type = 'link' + if planning: + log('Planning to remove %s: %s', filesystem_type, self._path) + else: + log('Removing %s: %s', filesystem_type, self._path) + + def doit(self, _): + os.remove(self._path) + + +class Rmtree(Action): + def __init__(self, path): + super(Rmtree, self).__init__(dangerous=True) + self._priority = 0 + self._path = path + + def announce(self, planning): + if planning: + logging.warn('Planning to remove directory: %s', self._path) + else: + logging.warn('Removing directory: %s', self._path) + + def doit(self, _): + if sys.platform.startswith('win'): + # shutil.rmtree() doesn't work on Windows if any of the directories are + # read-only, which svn repositories are. + subprocess.check_call(['rd', '/q', '/s', self._path], shell=True) + else: + shutil.rmtree(self._path) + + +class Makedirs(Action): + def __init__(self, path): + super(Makedirs, self).__init__(dangerous=False) + self._priority = 1 + self._path = path + + def doit(self, _): + try: + os.makedirs(self._path) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + +class Symlink(Action): + def __init__(self, source_path, link_path): + super(Symlink, self).__init__(dangerous=False) + self._priority = 2 + self._source_path = source_path + self._link_path = link_path + + def announce(self, planning): + if planning: + logging.info( + 'Planning to create link from %s to %s', self._link_path, + self._source_path) + else: + logging.debug( + 'Linking from %s to %s', self._link_path, self._source_path) + + def doit(self, links_db): + # Files not in the root directory need relative path calculation. + # On Windows, use absolute paths instead since NTFS doesn't seem to support + # relative paths for symlinks. + if sys.platform.startswith('win'): + source_path = os.path.abspath(self._source_path) + else: + if os.path.dirname(self._link_path) != self._link_path: + source_path = os.path.relpath(self._source_path, + os.path.dirname(self._link_path)) + + os.symlink(source_path, os.path.abspath(self._link_path)) + links_db[self._source_path] = self._link_path + + +class LinkError(IOError): + """Failed to create a link.""" + pass + + +# Handles symlink creation on the different platforms. +if sys.platform.startswith('win'): + def symlink(source_path, link_path): + flag = 1 if os.path.isdir(source_path) else 0 + if not ctypes.windll.kernel32.CreateSymbolicLinkW( + unicode(link_path), unicode(source_path), flag): + raise OSError('Failed to create symlink to %s. Notice that only NTFS ' + 'version 5.0 and up has all the needed APIs for ' + 'creating symlinks.' % source_path) + os.symlink = symlink + + +class WebRTCLinkSetup(object): + def __init__(self, links_db, force=False, dry_run=False, prompt=False): + self._force = force + self._dry_run = dry_run + self._prompt = prompt + self._links_db = links_db + + def CreateLinks(self, on_bot): + logging.debug('CreateLinks') + # First, make a plan of action + actions = [] + + for source_path, link_path in FILES.iteritems(): + actions += self._ActionForPath( + source_path, link_path, check_fn=os.path.isfile, check_msg='files') + for source_dir in DIRECTORIES: + actions += self._ActionForPath( + source_dir, None, check_fn=os.path.isdir, + check_msg='directories') + + if not on_bot and self._force: + # When making the manual switch from legacy SVN checkouts to the new + # Git-based Chromium DEPS, the .gclient_entries file that contains cached + # URLs for all DEPS entries must be removed to avoid future sync problems. + entries_file = os.path.join(os.path.dirname(ROOT_DIR), '.gclient_entries') + if os.path.exists(entries_file): + actions.append(Remove(entries_file, dangerous=True)) + + actions.sort() + + if self._dry_run: + for action in actions: + action.announce(planning=True) + logging.info('Not doing anything because dry-run was specified.') + sys.exit(0) + + if any(a.dangerous for a in actions): + logging.warn('Dangerous actions:') + for action in (a for a in actions if a.dangerous): + action.announce(planning=True) + print + + if not self._force: + logging.error(textwrap.dedent("""\ + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + A C T I O N R E Q I R E D + @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + + Because chromium/src is transitioning to Git (from SVN), we needed to + change the way that the WebRTC standalone checkout works. Instead of + individually syncing subdirectories of Chromium in SVN, we're now + syncing Chromium (and all of its DEPS, as defined by its own DEPS file), + into the `chromium/src` directory. + + As such, all Chromium directories which are currently pulled by DEPS are + now replaced with a symlink into the full Chromium checkout. + + To avoid disrupting developers, we've chosen to not delete your + directories forcibly, in case you have some work in progress in one of + them :). + + ACTION REQUIRED: + Before running `gclient sync|runhooks` again, you must run: + %s%s --force + + Which will replace all directories which now must be symlinks, after + prompting with a summary of the work-to-be-done. + """), 'python ' if sys.platform.startswith('win') else '', sys.argv[0]) + sys.exit(1) + elif self._prompt: + if not query_yes_no('Would you like to perform the above plan?'): + sys.exit(1) + + for action in actions: + action.announce(planning=False) + action.doit(self._links_db) + + if not on_bot and self._force: + logging.info('Completed!\n\nNow run `gclient sync|runhooks` again to ' + 'let the remaining hooks (that probably were interrupted) ' + 'execute.') + + def CleanupLinks(self): + logging.debug('CleanupLinks') + for source, link_path in self._links_db.iteritems(): + if source == 'SCHEMA_VERSION': + continue + if os.path.islink(link_path) or sys.platform.startswith('win'): + # os.path.islink() always returns false on Windows + # See http://bugs.python.org/issue13143. + logging.debug('Removing link to %s at %s', source, link_path) + if not self._dry_run: + if os.path.exists(link_path): + if sys.platform.startswith('win') and os.path.isdir(link_path): + subprocess.check_call(['rmdir', '/q', '/s', link_path], + shell=True) + else: + os.remove(link_path) + del self._links_db[source] + + @staticmethod + def _ActionForPath(source_path, link_path=None, check_fn=None, + check_msg=None): + """Create zero or more Actions to link to a file or directory. + + This will be a symlink on POSIX platforms. On Windows this requires + that NTFS is version 5.0 or higher (Vista or newer). + + Args: + source_path: Path relative to the Chromium checkout root. + For readability, the path may contain slashes, which will + automatically be converted to the right path delimiter on Windows. + link_path: The location for the link to create. If omitted it will be the + same path as source_path. + check_fn: A function returning true if the type of filesystem object is + correct for the attempted call. Otherwise an error message with + check_msg will be printed. + check_msg: String used to inform the user of an invalid attempt to create + a file. + Returns: + A list of Action objects. + """ + def fix_separators(path): + if sys.platform.startswith('win'): + return path.replace(os.altsep, os.sep) + else: + return path + + assert check_fn + assert check_msg + link_path = link_path or source_path + link_path = fix_separators(link_path) + + source_path = fix_separators(source_path) + source_path = os.path.join(CHROMIUM_CHECKOUT, source_path) + if os.path.exists(source_path) and not check_fn: + raise LinkError('_LinkChromiumPath can only be used to link to %s: ' + 'Tried to link to: %s' % (check_msg, source_path)) + + if not os.path.exists(source_path): + logging.debug('Silently ignoring missing source: %s. This is to avoid ' + 'errors on platform-specific dependencies.', source_path) + return [] + + actions = [] + + if os.path.exists(link_path) or os.path.islink(link_path): + if os.path.islink(link_path): + actions.append(Remove(link_path, dangerous=False)) + elif os.path.isfile(link_path): + actions.append(Remove(link_path, dangerous=True)) + elif os.path.isdir(link_path): + actions.append(Rmtree(link_path)) + else: + raise LinkError('Don\'t know how to plan: %s' % link_path) + + # Create parent directories to the target link if needed. + target_parent_dirs = os.path.dirname(link_path) + if (target_parent_dirs and + target_parent_dirs != link_path and + not os.path.exists(target_parent_dirs)): + actions.append(Makedirs(target_parent_dirs)) + + actions.append(Symlink(source_path, link_path)) + + return actions + +def _initialize_database(filename): + links_database = shelve.open(filename) + + # Wipe the database if this version of the script ends up looking at a + # newer (future) version of the links db, just to be sure. + version = links_database.get('SCHEMA_VERSION') + if version and version != SCHEMA_VERSION: + logging.info('Found database with schema version %s while this script only ' + 'supports %s. Wiping previous database contents.', version, + SCHEMA_VERSION) + links_database.clear() + links_database['SCHEMA_VERSION'] = SCHEMA_VERSION + return links_database + + +def main(): + on_bot = os.environ.get('CHROME_HEADLESS') == '1' + + parser = optparse.OptionParser() + parser.add_option('-d', '--dry-run', action='store_true', default=False, + help='Print what would be done, but don\'t perform any ' + 'operations. This will automatically set logging to ' + 'verbose.') + parser.add_option('-c', '--clean-only', action='store_true', default=False, + help='Only clean previously created links, don\'t create ' + 'new ones. This will automatically set logging to ' + 'verbose.') + parser.add_option('-f', '--force', action='store_true', default=on_bot, + help='Force link creation. CAUTION: This deletes existing ' + 'folders and files in the locations where links are ' + 'about to be created.') + parser.add_option('-n', '--no-prompt', action='store_false', dest='prompt', + default=(not on_bot), + help='Prompt if we\'re planning to do a dangerous action') + parser.add_option('-v', '--verbose', action='store_const', + const=logging.DEBUG, default=logging.INFO, + help='Print verbose output for debugging.') + options, _ = parser.parse_args() + + if options.dry_run or options.force or options.clean_only: + options.verbose = logging.DEBUG + logging.basicConfig(format='%(message)s', level=options.verbose) + + # Work from the root directory of the checkout. + script_dir = os.path.dirname(os.path.abspath(__file__)) + os.chdir(script_dir) + + if sys.platform.startswith('win'): + def is_admin(): + try: + return os.getuid() == 0 + except AttributeError: + return ctypes.windll.shell32.IsUserAnAdmin() != 0 + if not is_admin(): + logging.error('On Windows, you now need to have administrator ' + 'privileges for the shell running %s (or ' + '`gclient sync|runhooks`).\nPlease start another command ' + 'prompt as Administrator and try again.', sys.argv[0]) + return 1 + + if not os.path.exists(CHROMIUM_CHECKOUT): + logging.error('Cannot find a Chromium checkout at %s. Did you run "gclient ' + 'sync" before running this script?', CHROMIUM_CHECKOUT) + return 2 + + links_database = _initialize_database(LINKS_DB) + try: + symlink_creator = WebRTCLinkSetup(links_database, options.force, + options.dry_run, options.prompt) + symlink_creator.CleanupLinks() + if not options.clean_only: + symlink_creator.CreateLinks(on_bot) + except LinkError as e: + print >> sys.stderr, e.message + return 3 + finally: + links_database.close() + return 0 + + +if __name__ == '__main__': + sys.exit(main())
diff --git a/src/LICENSE_THIRD_PARTY b/src/LICENSE_THIRD_PARTY deleted file mode 100644 index e19708a..0000000 --- a/src/LICENSE_THIRD_PARTY +++ /dev/null
@@ -1,27 +0,0 @@ -This source tree contains third party source code which is governed by third -party licenses. This file contains references to files which are under other -licenses than the one provided in the LICENSE file in the root of the source -tree. - -Files governed by third party licenses: -common_audio/signal_processing/spl_sqrt_floor.c -common_audio/signal_processing/spl_sqrt_floor.s -modules/audio_coding/codecs/G711/main/source/g711.h -modules/audio_coding/codecs/G711/main/source/g711.c -modules/audio_coding/codecs/G722/main/source/g722_decode.h -modules/audio_coding/codecs/G722/main/source/g722_decode.c -modules/audio_coding/codecs/G722/main/source/g722_encode.h -modules/audio_coding/codecs/G722/main/source/g722_encode.c -modules/audio_coding/codecs/iSAC/main/source/fft.c -modules/audio_device/main/source/Mac/portaudio/pa_memorybarrier.h -modules/audio_device/main/source/Mac/portaudio/pa_ringbuffer.h -modules/audio_device/main/source/Mac/portaudio/pa_ringbuffer.c -modules/audio_processing/utility/fft4g.c -modules/audio_processing/aec/aec_rdft.c -system_wrappers/interface/fix_interlocked_exchange_pointer_windows.h -system_wrappers/interface/scoped_ptr.h -system_wrappers/interface/scoped_refptr.h -system_wrappers/source/condition_variable_windows.cc -system_wrappers/source/spreadsortlib/constants.hpp -system_wrappers/source/spreadsortlib/spreadsort.hpp -system_wrappers/source/thread_windows_set_name.h
diff --git a/src/build/arm_neon.gypi b/src/build/arm_neon.gypi deleted file mode 100644 index 53c3b53..0000000 --- a/src/build/arm_neon.gypi +++ /dev/null
@@ -1,35 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -# This file sets correct neon flags. Include it if you want to build -# source with neon intrinsics. -# To use this, create a gyp target with the following form: -# { -# 'target_name': 'my_lib', -# 'type': 'static_library', -# 'sources': [ -# 'foo.c', -# 'bar.cc', -# ], -# 'includes': ['path/to/this/gypi/file'], -# } - -{ - 'conditions': [ - ['OS=="android"', { - 'cflags!': [ - '-mfpu=vfpv3-d16', - ], - 'cflags': [ - '-mfpu=neon', - '-mfloat-abi=softfp', - '-flax-vector-conversions', - ], - }], - ], -}
diff --git a/src/build/common.gypi b/src/build/common.gypi deleted file mode 100644 index aa72ea5..0000000 --- a/src/build/common.gypi +++ /dev/null
@@ -1,208 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -# This file contains common settings for building WebRTC components. - -{ - # Nesting is required in order to use variables for setting other variables. - 'variables': { - 'variables': { - 'variables': { - 'variables': { - # This will be set to zero in the supplement.gypi triggered by a - # gclient hook in the standalone build. - 'build_with_chromium%': 1, - }, - 'build_with_chromium%': '<(build_with_chromium)', - - 'conditions': [ - ['build_with_chromium==1', { - 'webrtc_root%': '<(DEPTH)/third_party/webrtc', - }, { - 'webrtc_root%': '<(DEPTH)/src', - }], - ], - }, - 'build_with_chromium%': '<(build_with_chromium)', - 'webrtc_root%': '<(webrtc_root)', - - 'webrtc_vp8_dir%': '<(webrtc_root)/modules/video_coding/codecs/vp8', - }, - 'build_with_chromium%': '<(build_with_chromium)', - 'webrtc_root%': '<(webrtc_root)', - 'webrtc_vp8_dir%': '<(webrtc_vp8_dir)', - - # The Chromium common.gypi we use treats all gyp files without - # chromium_code==1 as third party code. This disables many of the - # preferred warning settings. - # - # We can set this here to have WebRTC code treated as Chromium code. Our - # third party code will still have the reduced warning settings. - 'chromium_code': 1, - - # Adds video support to dependencies shared by voice and video engine. - # This should normally be enabled; the intended use is to disable only - # when building voice engine exclusively. - 'enable_video%': 1, - - # Selects fixed-point code where possible. - 'prefer_fixed_point%': 0, - - # Enable data logging. Produces text files with data logged within engines - # which can be easily parsed for offline processing. - 'enable_data_logging%': 0, - - # Disable these to not build components which can be externally provided. - 'build_libjpeg%': 1, - 'build_libyuv%': 1, - - 'libyuv_dir%': '<(DEPTH)/third_party/libyuv', - - 'conditions': [ - ['build_with_chromium==1', { - # Exclude pulse audio on Chromium since its prerequisites don't require - # pulse audio. - 'include_pulse_audio%': 0, - - # Exclude internal ADM since Chromium uses its own IO handling. - 'include_internal_audio_device%': 0, - - # Exclude internal VCM in Chromium build. - 'include_internal_video_capture%': 0, - - # Exclude internal video render module in Chromium build. - 'include_internal_video_render%': 0, - - 'include_video_engine_file_api%': 0, - - 'include_tests%': 0, - - # Disable the use of protocol buffers in production code. - 'enable_protobuf%': 0, - }, { # Settings for the standalone (not-in-Chromium) build. - 'include_pulse_audio%': 1, - 'include_internal_audio_device%': 1, - 'include_internal_video_capture%': 1, - 'include_internal_video_render%': 1, - 'include_video_engine_file_api%': 1, - 'enable_protobuf%': 1, - 'include_tests%': 1, - - # TODO(andrew): For now, disable the Chrome plugins, which causes a - # flood of chromium-style warnings. Investigate enabling them: - # http://code.google.com/p/webrtc/issues/detail?id=163 - 'clang_use_chrome_plugins%': 0, - }], - ], # conditions - }, - 'target_defaults': { - 'include_dirs': [ - # TODO(andrew): we should be able to just use <(webrtc_root) here. - '..','../..', - ], - 'defines': [ - # TODO(leozwang): Run this as a gclient hook rather than at build-time: - # http://code.google.com/p/webrtc/issues/detail?id=687 - 'WEBRTC_SVNREVISION="Unavailable(issue687)"', - #'WEBRTC_SVNREVISION="<!(python <(webrtc_root)/build/version.py)"', - ], - 'conditions': [ - ['build_with_chromium==1', { - 'defines': [ - # Changes settings for Chromium build. - 'WEBRTC_CHROMIUM_BUILD', - ], - }, { - 'conditions': [ - ['os_posix==1', { - 'cflags': [ - '-Wextra', - # We need to repeat some flags from Chromium's common.gypi here - # that get overridden by -Wextra. - '-Wno-unused-parameter', - '-Wno-missing-field-initializers', - ], - 'cflags_cc': [ - # This is enabled for clang; enable for gcc as well. - '-Woverloaded-virtual', - ], - }], - ], - }], - ['target_arch=="arm"', { - 'prefer_fixed_point%': 1, - 'defines': [ - 'WEBRTC_ARCH_ARM', - ], - 'conditions': [ - ['armv7==1', { - 'defines': [ - 'WEBRTC_ARCH_ARM_V7', - 'WEBRTC_DETECT_ARM_NEON', - ], - }], - ['arm_neon==1', { - 'defines': [ - 'WEBRTC_ARCH_ARM_NEON', - ], - 'defines!': [ - 'WEBRTC_DETECT_ARM_NEON', - ], - }], - ], - }], - ['OS=="linux"', { - 'defines': [ - 'WEBRTC_LINUX', - 'WEBRTC_THREAD_RR', - # TODO(andrew): can we select this automatically? - # Define this if the Linux system does not support CLOCK_MONOTONIC. - #'WEBRTC_CLOCK_TYPE_REALTIME', - ], - }], - ['OS=="mac"', { - 'defines': [ - 'WEBRTC_MAC', - 'WEBRTC_MAC_INTEL', # TODO(andrew): remove this. - 'WEBRTC_THREAD_RR', - 'WEBRTC_CLOCK_TYPE_REALTIME', - ], - }], - ['OS=="win"', { - 'defines': [ - 'WEBRTC_WIN', - ], - # TODO(andrew): enable all warnings when possible. - # 4389: Signed/unsigned mismatch. - # 4373: MSVC legacy warning for ignoring const / volatile in - # signatures. TODO(phoglund): get rid of 4373 supression when - # http://code.google.com/p/webrtc/issues/detail?id=261 is solved. - 'msvs_disabled_warnings': [4389, 4373], - - # Re-enable some warnings that Chromium disables. - 'msvs_disabled_warnings!': [4189,], - }], - ['OS=="android"', { - # TODO(kma): Remove prefer_fixed_point for Android. - 'prefer_fixed_point%': 1, - 'defines': [ - 'WEBRTC_LINUX', - 'WEBRTC_ANDROID', - # TODO(leozwang): Investigate CLOCK_REALTIME and CLOCK_MONOTONIC - # support on Android. Keep WEBRTC_CLOCK_TYPE_REALTIME for now, - # remove it after I verify that CLOCK_MONOTONIC is fully functional - # with condition and event functions in system_wrappers. - 'WEBRTC_CLOCK_TYPE_REALTIME', - 'WEBRTC_THREAD_RR', - 'WEBRTC_ANDROID_OPENSLES', - ], - }], - ], # conditions - }, # target_defaults -} -
diff --git a/src/build/generate_asm_header.py b/src/build/generate_asm_header.py deleted file mode 100644 index 7d275ef..0000000 --- a/src/build/generate_asm_header.py +++ /dev/null
@@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -"""This script generates a C header file of offsets from an ARM assembler file. - -It parses an ARM assembler generated .S file, finds declarations of variables -whose names start with the string specified as the third argument in the -command-line, translates the variable names and values into constant defines and -writes them into a header file. -""" - -import sys - -def usage(): - print("Usage: generate_asm_header.py " + - "<input filename> <output filename> <variable name pattern>") - sys.exit(1) - -def main(argv): - if len(argv) != 3: - usage() - - infile = open(argv[0]) - outfile = open(argv[1], 'w') - - for line in infile: # Iterate though all the lines in the input file. - if line.startswith(argv[2]): - outfile.write('#define ') - outfile.write(line.split(':')[0]) # Write the constant name. - outfile.write(' ') - - if line.find('.word') >= 0: - outfile.write(line.split('.word')[1]) # Write the constant value. - - infile.close() - outfile.close() - -if __name__ == "__main__": - main(sys.argv[1:])
diff --git a/src/build/merge_libs.gyp b/src/build/merge_libs.gyp deleted file mode 100644 index d247189..0000000 --- a/src/build/merge_libs.gyp +++ /dev/null
@@ -1,43 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'includes': [ 'common.gypi', ], - 'targets': [ - { - 'target_name': 'no_op', - 'type': 'executable', - 'dependencies': [ - '../video_engine/video_engine.gyp:video_engine_core', - ], - 'sources': [ 'no_op.cc', ], - }, - { - 'target_name': 'merged_lib', - 'type': 'none', - 'dependencies': [ - 'no_op', - ], - 'actions': [ - { - 'variables': { - 'output_lib_name': 'webrtc', - 'output_lib': '<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(output_lib_name)<(STATIC_LIB_SUFFIX)', - }, - 'action_name': 'merge_libs', - 'inputs': ['<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)no_op<(EXECUTABLE_SUFFIX)'], - 'outputs': ['<(output_lib)'], - 'action': ['python', - 'merge_libs.py', - '<(PRODUCT_DIR)', - '<(output_lib)',], - }, - ], - }, - ], -}
diff --git a/src/build/merge_libs.py b/src/build/merge_libs.py deleted file mode 100644 index 31c5efb..0000000 --- a/src/build/merge_libs.py +++ /dev/null
@@ -1,58 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -# Searches for libraries and/or object files on the specified path and -# merges them into a single library. - -import subprocess -import sys - -if __name__ == '__main__': - if len(sys.argv) != 3: - sys.stderr.write('Usage: ' + sys.argv[0] + ' <search_path> <output_lib>\n') - sys.exit(2) - - search_path = sys.argv[1] - output_lib = sys.argv[2] - - from subprocess import call, PIPE - if sys.platform.startswith('linux'): - call(["rm -f " + output_lib], shell=True) - call(["rm -rf " + search_path + "/obj.target/*do_not_use*"], shell=True) - call(["ar crs " + output_lib + " $(find " + search_path + - "/obj.target -name *\.o)"], shell=True) - call(["ar crs " + output_lib + " $(find " + search_path + - "/obj/gen -name *\.o)"], shell=True) - - elif sys.platform == 'darwin': - call(["rm -f " + output_lib], shell=True) - call(["rm -f " + search_path + "/*do_not_use*"], shell=True) - call(["libtool -static -v -o " + output_lib + " " + search_path + "/*.a"], - shell=True) - - elif sys.platform == 'win32': - # We need to execute a batch file to set some environment variables for the - # lib command. VS 8 uses vsvars.bat and VS 9 uses vsvars32.bat. It's - # required that at least one of them is in the system PATH. We try both and - # suppress stderr and stdout to fail silently. - call(["vsvars.bat"], stderr=PIPE, stdout=PIPE, shell=True) - call(["vsvars32.bat"], stderr=PIPE, stdout=PIPE, shell=True) - call(["del " + output_lib], shell=True) - call(["del /F /S /Q " + search_path + "/lib/*do_not_use*"], - shell=True) - call(["lib /OUT:" + output_lib + " " + search_path + "/lib/*.lib"], - shell=True) - - else: - sys.stderr.write('Platform not supported: %r\n\n' % sys.platform) - sys.exit(1) - - sys.exit(0) -
diff --git a/src/build/protoc.gypi b/src/build/protoc.gypi deleted file mode 100644 index 70bf71e..0000000 --- a/src/build/protoc.gypi +++ /dev/null
@@ -1,97 +0,0 @@ -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# It was necessary to copy this file to WebRTC, because the path to -# build/common.gypi is different for the standalone and Chromium builds. Gyp -# doesn't permit conditional inclusion or variable expansion in include paths. -# http://code.google.com/p/gyp/wiki/InputFormatReference#Including_Other_Files - -# This file is meant to be included into a target to provide a rule -# to invoke protoc in a consistent manner. -# -# To use this, create a gyp target with the following form: -# { -# 'target_name': 'my_proto_lib', -# 'type': 'static_library', -# 'sources': [ -# 'foo.proto', -# 'bar.proto', -# ], -# 'variables': { -# # Optional, see below: 'proto_in_dir': '.' -# 'proto_out_dir': 'dir/for/my_proto_lib' -# }, -# 'includes': ['path/to/this/gypi/file'], -# } -# If necessary, you may add normal .cc files to the sources list or other gyp -# dependencies. The proto headers are guaranteed to be generated before any -# source files, even within this target, are compiled. -# -# The 'proto_in_dir' variable must be the relative path to the -# directory containing the .proto files. If left out, it defaults to '.'. -# -# The 'proto_out_dir' variable specifies the path suffix that output -# files are generated under. Targets that gyp-depend on my_proto_lib -# will be able to include the resulting proto headers with an include -# like: -# #include "dir/for/my_proto_lib/foo.pb.h" -# -# Implementation notes: -# A proto_out_dir of foo/bar produces -# <(SHARED_INTERMEDIATE_DIR)/protoc_out/foo/bar/{file1,file2}.pb.{cc,h} -# <(SHARED_INTERMEDIATE_DIR)/pyproto/foo/bar/{file1,file2}_pb2.py - -{ - 'variables': { - 'protoc': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)protoc<(EXECUTABLE_SUFFIX)', - 'cc_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out/<(proto_out_dir)', - 'py_dir': '<(PRODUCT_DIR)/pyproto/<(proto_out_dir)', - 'proto_in_dir%': '.', - }, - 'rules': [ - { - 'rule_name': 'genproto', - 'extension': 'proto', - 'inputs': [ - '<(protoc)', - ], - 'outputs': [ - '<(py_dir)/<(RULE_INPUT_ROOT)_pb2.py', - '<(cc_dir)/<(RULE_INPUT_ROOT).pb.cc', - '<(cc_dir)/<(RULE_INPUT_ROOT).pb.h', - ], - 'action': [ - '<(protoc)', - '--proto_path=<(proto_in_dir)', - # Naively you'd use <(RULE_INPUT_PATH) here, but protoc requires - # --proto_path is a strict prefix of the path given as an argument. - '<(proto_in_dir)/<(RULE_INPUT_ROOT)<(RULE_INPUT_EXT)', - '--cpp_out=<(cc_dir)', - '--python_out=<(py_dir)', - ], - 'message': 'Generating C++ and Python code from <(RULE_INPUT_PATH)', - 'process_outputs_as_sources': 1, - }, - ], - 'dependencies': [ - '<(DEPTH)/third_party/protobuf/protobuf.gyp:protoc#host', - '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', - ], - 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)/protoc_out', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - '<(SHARED_INTERMEDIATE_DIR)/protoc_out', - ] - }, - 'export_dependent_settings': [ - # The generated headers reference headers within protobuf_lite, - # so dependencies must be able to find those headers too. - '<(DEPTH)/third_party/protobuf/protobuf.gyp:protobuf_lite', - ], - # This target exports a hard dependency because it generates header - # files. - 'hard_dependency': 1, -}
diff --git a/src/build/version.py b/src/build/version.py deleted file mode 100755 index ff67565..0000000 --- a/src/build/version.py +++ /dev/null
@@ -1,61 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -"""Get svn revision of working copy - -This script tries to get the svn revision as much as it can. It supports -both git-svn and svn. It will fail if not in a git-svn or svn repository; -in this case the script will return "n/a". -This script is a simplified version of lastchange.py which is in Chromium's -src/build/util folder. -""" - -import os -import subprocess -import sys - -def popen_cmd_and_get_output(cmd, directory): - """Return (status, output) of executing cmd in a shell.""" - try: - proc = subprocess.Popen(cmd, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=directory, - shell=(sys.platform=='win32')) - except OSError: - # command is apparently either not installed or not executable. - return None - if not proc: - return None - - for line in proc.stdout: - line = line.strip() - if not line: - continue - words = line.split() - for index, word in enumerate(words): - if word == "Revision:": - return words[index+1] - # return None if cannot find keyword Revision - return None - -def main(): - directory = os.path.dirname(sys.argv[0]); - version = popen_cmd_and_get_output(['git', 'svn', 'info'], directory) - if version == None: - version = popen_cmd_and_get_output(['svn', 'info'], directory) - if version == None: - print "n/a" - return 0 - print version - return 0 - -if __name__ == '__main__': - sys.exit(main())
diff --git a/src/common_audio/OWNERS b/src/common_audio/OWNERS deleted file mode 100644 index 84582f2..0000000 --- a/src/common_audio/OWNERS +++ /dev/null
@@ -1,4 +0,0 @@ -bjornv@webrtc.org -tina.legrand@webrtc.org -jan.skoglund@webrtc.org -andrew@webrtc.org
diff --git a/src/common_audio/common_audio.gyp b/src/common_audio/common_audio.gyp deleted file mode 100644 index 3d3da3f..0000000 --- a/src/common_audio/common_audio.gyp +++ /dev/null
@@ -1,16 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'includes': [ - '../build/common.gypi', - 'signal_processing/signal_processing.gypi', - 'resampler/resampler.gypi', - 'vad/vad.gypi', - ], -}
diff --git a/src/common_audio/resampler/Android.mk b/src/common_audio/resampler/Android.mk deleted file mode 100644 index 842e9e4..0000000 --- a/src/common_audio/resampler/Android.mk +++ /dev/null
@@ -1,50 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -include $(LOCAL_PATH)/../../../android-webrtc.mk - -LOCAL_ARM_MODE := arm -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libwebrtc_resampler -LOCAL_MODULE_TAGS := optional -LOCAL_CPP_EXTENSION := .cc -LOCAL_SRC_FILES := resampler.cc - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := \ - $(MY_WEBRTC_COMMON_DEFS) - -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) -LOCAL_CFLAGS_x86 := $(MY_WEBRTC_COMMON_DEFS_x86) -LOCAL_CFLAGS_mips := $(MY_WEBRTC_COMMON_DEFS_mips) -LOCAL_CFLAGS_arm64 := $(MY_WEBRTC_COMMON_DEFS_arm64) -LOCAL_CFLAGS_x86_64 := $(MY_WEBRTC_COMMON_DEFS_x86_64) -LOCAL_CFLAGS_mips64 := $(MY_WEBRTC_COMMON_DEFS_mips64) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/../.. \ - $(LOCAL_PATH)/../signal_processing/include - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - libdl - -LOCAL_SHARED_LIBRARIES += libdl - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -endif - -include $(BUILD_STATIC_LIBRARY)
diff --git a/src/common_audio/resampler/include/resampler.h b/src/common_audio/resampler/include/resampler.h deleted file mode 100644 index 38e6bd3..0000000 --- a/src/common_audio/resampler/include/resampler.h +++ /dev/null
@@ -1,116 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * A wrapper for resampling a numerous amount of sampling combinations. - */ - -#ifndef WEBRTC_RESAMPLER_RESAMPLER_H_ -#define WEBRTC_RESAMPLER_RESAMPLER_H_ - -#include "typedefs.h" - -namespace webrtc -{ - -// TODO(andrew): the implementation depends on the exact values of this enum. -// It should be rewritten in a less fragile way. -enum ResamplerType -{ - // 4 MSB = Number of channels - // 4 LSB = Synchronous or asynchronous - - kResamplerSynchronous = 0x10, - kResamplerAsynchronous = 0x11, - kResamplerSynchronousStereo = 0x20, - kResamplerAsynchronousStereo = 0x21, - kResamplerInvalid = 0xff -}; - -// TODO(andrew): doesn't need to be part of the interface. -enum ResamplerMode -{ - kResamplerMode1To1, - kResamplerMode1To2, - kResamplerMode1To3, - kResamplerMode1To4, - kResamplerMode1To6, - kResamplerMode1To12, - kResamplerMode2To3, - kResamplerMode2To11, - kResamplerMode4To11, - kResamplerMode8To11, - kResamplerMode11To16, - kResamplerMode11To32, - kResamplerMode2To1, - kResamplerMode3To1, - kResamplerMode4To1, - kResamplerMode6To1, - kResamplerMode12To1, - kResamplerMode3To2, - kResamplerMode11To2, - kResamplerMode11To4, - kResamplerMode11To8 -}; - -class Resampler -{ - -public: - Resampler(); - // TODO(andrew): use an init function instead. - Resampler(int inFreq, int outFreq, ResamplerType type); - ~Resampler(); - - // Reset all states - int Reset(int inFreq, int outFreq, ResamplerType type); - - // Reset all states if any parameter has changed - int ResetIfNeeded(int inFreq, int outFreq, ResamplerType type); - - // Synchronous resampling, all output samples are written to samplesOut - int Push(const WebRtc_Word16* samplesIn, int lengthIn, WebRtc_Word16* samplesOut, - int maxLen, int &outLen); - - // Asynchronous resampling, input - int Insert(WebRtc_Word16* samplesIn, int lengthIn); - - // Asynchronous resampling output, remaining samples are buffered - int Pull(WebRtc_Word16* samplesOut, int desiredLen, int &outLen); - -private: - // Generic pointers since we don't know what states we'll need - void* state1_; - void* state2_; - void* state3_; - - // Storage if needed - WebRtc_Word16* in_buffer_; - WebRtc_Word16* out_buffer_; - int in_buffer_size_; - int out_buffer_size_; - int in_buffer_size_max_; - int out_buffer_size_max_; - - // State - int my_in_frequency_khz_; - int my_out_frequency_khz_; - ResamplerMode my_mode_; - ResamplerType my_type_; - - // Extra instance for stereo - Resampler* slave_left_; - Resampler* slave_right_; -}; - -} // namespace webrtc - -#endif // WEBRTC_RESAMPLER_RESAMPLER_H_
diff --git a/src/common_audio/resampler/resampler.cc b/src/common_audio/resampler/resampler.cc deleted file mode 100644 index 2db27b1..0000000 --- a/src/common_audio/resampler/resampler.cc +++ /dev/null
@@ -1,1084 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * A wrapper for resampling a numerous amount of sampling combinations. - */ - -#include <stdlib.h> -#include <string.h> - -#include "signal_processing_library.h" -#include "resampler.h" - - -namespace webrtc -{ - -Resampler::Resampler() -{ - state1_ = NULL; - state2_ = NULL; - state3_ = NULL; - in_buffer_ = NULL; - out_buffer_ = NULL; - in_buffer_size_ = 0; - out_buffer_size_ = 0; - in_buffer_size_max_ = 0; - out_buffer_size_max_ = 0; - // we need a reset before we will work - my_in_frequency_khz_ = 0; - my_out_frequency_khz_ = 0; - my_mode_ = kResamplerMode1To1; - my_type_ = kResamplerInvalid; - slave_left_ = NULL; - slave_right_ = NULL; -} - -Resampler::Resampler(int inFreq, int outFreq, ResamplerType type) -{ - state1_ = NULL; - state2_ = NULL; - state3_ = NULL; - in_buffer_ = NULL; - out_buffer_ = NULL; - in_buffer_size_ = 0; - out_buffer_size_ = 0; - in_buffer_size_max_ = 0; - out_buffer_size_max_ = 0; - // we need a reset before we will work - my_in_frequency_khz_ = 0; - my_out_frequency_khz_ = 0; - my_mode_ = kResamplerMode1To1; - my_type_ = kResamplerInvalid; - slave_left_ = NULL; - slave_right_ = NULL; - - Reset(inFreq, outFreq, type); -} - -Resampler::~Resampler() -{ - if (state1_) - { - free(state1_); - } - if (state2_) - { - free(state2_); - } - if (state3_) - { - free(state3_); - } - if (in_buffer_) - { - free(in_buffer_); - } - if (out_buffer_) - { - free(out_buffer_); - } - if (slave_left_) - { - delete slave_left_; - } - if (slave_right_) - { - delete slave_right_; - } -} - -int Resampler::ResetIfNeeded(int inFreq, int outFreq, ResamplerType type) -{ - int tmpInFreq_kHz = inFreq / 1000; - int tmpOutFreq_kHz = outFreq / 1000; - - if ((tmpInFreq_kHz != my_in_frequency_khz_) || (tmpOutFreq_kHz != my_out_frequency_khz_) - || (type != my_type_)) - { - return Reset(inFreq, outFreq, type); - } else - { - return 0; - } -} - -int Resampler::Reset(int inFreq, int outFreq, ResamplerType type) -{ - - if (state1_) - { - free(state1_); - state1_ = NULL; - } - if (state2_) - { - free(state2_); - state2_ = NULL; - } - if (state3_) - { - free(state3_); - state3_ = NULL; - } - if (in_buffer_) - { - free(in_buffer_); - in_buffer_ = NULL; - } - if (out_buffer_) - { - free(out_buffer_); - out_buffer_ = NULL; - } - if (slave_left_) - { - delete slave_left_; - slave_left_ = NULL; - } - if (slave_right_) - { - delete slave_right_; - slave_right_ = NULL; - } - - in_buffer_size_ = 0; - out_buffer_size_ = 0; - in_buffer_size_max_ = 0; - out_buffer_size_max_ = 0; - - // This might be overridden if parameters are not accepted. - my_type_ = type; - - // Start with a math exercise, Euclid's algorithm to find the gcd: - - int a = inFreq; - int b = outFreq; - int c = a % b; - while (c != 0) - { - a = b; - b = c; - c = a % b; - } - // b is now the gcd; - - // We need to track what domain we're in. - my_in_frequency_khz_ = inFreq / 1000; - my_out_frequency_khz_ = outFreq / 1000; - - // Scale with GCD - inFreq = inFreq / b; - outFreq = outFreq / b; - - // Do we need stereo? - if ((my_type_ & 0xf0) == 0x20) - { - // Change type to mono - type = static_cast<ResamplerType>( - ((static_cast<int>(type) & 0x0f) + 0x10)); - slave_left_ = new Resampler(inFreq, outFreq, type); - slave_right_ = new Resampler(inFreq, outFreq, type); - } - - if (inFreq == outFreq) - { - my_mode_ = kResamplerMode1To1; - } else if (inFreq == 1) - { - switch (outFreq) - { - case 2: - my_mode_ = kResamplerMode1To2; - break; - case 3: - my_mode_ = kResamplerMode1To3; - break; - case 4: - my_mode_ = kResamplerMode1To4; - break; - case 6: - my_mode_ = kResamplerMode1To6; - break; - case 12: - my_mode_ = kResamplerMode1To12; - break; - default: - my_type_ = kResamplerInvalid; - return -1; - } - } else if (outFreq == 1) - { - switch (inFreq) - { - case 2: - my_mode_ = kResamplerMode2To1; - break; - case 3: - my_mode_ = kResamplerMode3To1; - break; - case 4: - my_mode_ = kResamplerMode4To1; - break; - case 6: - my_mode_ = kResamplerMode6To1; - break; - case 12: - my_mode_ = kResamplerMode12To1; - break; - default: - my_type_ = kResamplerInvalid; - return -1; - } - } else if ((inFreq == 2) && (outFreq == 3)) - { - my_mode_ = kResamplerMode2To3; - } else if ((inFreq == 2) && (outFreq == 11)) - { - my_mode_ = kResamplerMode2To11; - } else if ((inFreq == 4) && (outFreq == 11)) - { - my_mode_ = kResamplerMode4To11; - } else if ((inFreq == 8) && (outFreq == 11)) - { - my_mode_ = kResamplerMode8To11; - } else if ((inFreq == 3) && (outFreq == 2)) - { - my_mode_ = kResamplerMode3To2; - } else if ((inFreq == 11) && (outFreq == 2)) - { - my_mode_ = kResamplerMode11To2; - } else if ((inFreq == 11) && (outFreq == 4)) - { - my_mode_ = kResamplerMode11To4; - } else if ((inFreq == 11) && (outFreq == 16)) - { - my_mode_ = kResamplerMode11To16; - } else if ((inFreq == 11) && (outFreq == 32)) - { - my_mode_ = kResamplerMode11To32; - } else if ((inFreq == 11) && (outFreq == 8)) - { - my_mode_ = kResamplerMode11To8; - } else - { - my_type_ = kResamplerInvalid; - return -1; - } - - // Now create the states we need - switch (my_mode_) - { - case kResamplerMode1To1: - // No state needed; - break; - case kResamplerMode1To2: - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode1To3: - state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); - WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state1_); - break; - case kResamplerMode1To4: - // 1:2 - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - // 2:4 - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode1To6: - // 1:2 - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - // 2:6 - state2_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); - WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state2_); - break; - case kResamplerMode1To12: - // 1:2 - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - // 2:4 - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - // 4:12 - state3_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); - WebRtcSpl_ResetResample16khzTo48khz( - (WebRtcSpl_State16khzTo48khz*) state3_); - break; - case kResamplerMode2To3: - // 2:6 - state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); - WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state1_); - // 6:3 - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode2To11: - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - - state2_ = malloc(sizeof(WebRtcSpl_State8khzTo22khz)); - WebRtcSpl_ResetResample8khzTo22khz((WebRtcSpl_State8khzTo22khz *)state2_); - break; - case kResamplerMode4To11: - state1_ = malloc(sizeof(WebRtcSpl_State8khzTo22khz)); - WebRtcSpl_ResetResample8khzTo22khz((WebRtcSpl_State8khzTo22khz *)state1_); - break; - case kResamplerMode8To11: - state1_ = malloc(sizeof(WebRtcSpl_State16khzTo22khz)); - WebRtcSpl_ResetResample16khzTo22khz((WebRtcSpl_State16khzTo22khz *)state1_); - break; - case kResamplerMode11To16: - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - - state2_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz)); - WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state2_); - break; - case kResamplerMode11To32: - // 11 -> 22 - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - - // 22 -> 16 - state2_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz)); - WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state2_); - - // 16 -> 32 - state3_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state3_, 0, 8 * sizeof(WebRtc_Word32)); - - break; - case kResamplerMode2To1: - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode3To1: - state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); - WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state1_); - break; - case kResamplerMode4To1: - // 4:2 - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - // 2:1 - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode6To1: - // 6:2 - state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); - WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state1_); - // 2:1 - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode12To1: - // 12:4 - state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); - WebRtcSpl_ResetResample48khzTo16khz( - (WebRtcSpl_State48khzTo16khz*) state1_); - // 4:2 - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - // 2:1 - state3_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state3_, 0, 8 * sizeof(WebRtc_Word32)); - break; - case kResamplerMode3To2: - // 3:6 - state1_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); - // 6:2 - state2_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); - WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state2_); - break; - case kResamplerMode11To2: - state1_ = malloc(sizeof(WebRtcSpl_State22khzTo8khz)); - WebRtcSpl_ResetResample22khzTo8khz((WebRtcSpl_State22khzTo8khz *)state1_); - - state2_ = malloc(8 * sizeof(WebRtc_Word32)); - memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); - - break; - case kResamplerMode11To4: - state1_ = malloc(sizeof(WebRtcSpl_State22khzTo8khz)); - WebRtcSpl_ResetResample22khzTo8khz((WebRtcSpl_State22khzTo8khz *)state1_); - break; - case kResamplerMode11To8: - state1_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz)); - WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state1_); - break; - - } - - return 0; -} - -// Synchronous resampling, all output samples are written to samplesOut -int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16* samplesOut, - int maxLen, int &outLen) -{ - // Check that the resampler is not in asynchronous mode - if (my_type_ & 0x0f) - { - return -1; - } - - // Do we have a stereo signal? - if ((my_type_ & 0xf0) == 0x20) - { - - // Split up the signal and call the slave object for each channel - - WebRtc_Word16* left = (WebRtc_Word16*)malloc(lengthIn * sizeof(WebRtc_Word16) / 2); - WebRtc_Word16* right = (WebRtc_Word16*)malloc(lengthIn * sizeof(WebRtc_Word16) / 2); - WebRtc_Word16* out_left = (WebRtc_Word16*)malloc(maxLen / 2 * sizeof(WebRtc_Word16)); - WebRtc_Word16* out_right = - (WebRtc_Word16*)malloc(maxLen / 2 * sizeof(WebRtc_Word16)); - int res = 0; - for (int i = 0; i < lengthIn; i += 2) - { - left[i >> 1] = samplesIn[i]; - right[i >> 1] = samplesIn[i + 1]; - } - - // It's OK to overwrite the local parameter, since it's just a copy - lengthIn = lengthIn / 2; - - int actualOutLen_left = 0; - int actualOutLen_right = 0; - // Do resampling for right channel - res |= slave_left_->Push(left, lengthIn, out_left, maxLen / 2, actualOutLen_left); - res |= slave_right_->Push(right, lengthIn, out_right, maxLen / 2, actualOutLen_right); - if (res || (actualOutLen_left != actualOutLen_right)) - { - free(left); - free(right); - free(out_left); - free(out_right); - return -1; - } - - // Reassemble the signal - for (int i = 0; i < actualOutLen_left; i++) - { - samplesOut[i * 2] = out_left[i]; - samplesOut[i * 2 + 1] = out_right[i]; - } - outLen = 2 * actualOutLen_left; - - free(left); - free(right); - free(out_left); - free(out_right); - - return 0; - } - - // Containers for temp samples - WebRtc_Word16* tmp; - WebRtc_Word16* tmp_2; - // tmp data for resampling routines - WebRtc_Word32* tmp_mem; - - switch (my_mode_) - { - case kResamplerMode1To1: - memcpy(samplesOut, samplesIn, lengthIn * sizeof(WebRtc_Word16)); - outLen = lengthIn; - break; - case kResamplerMode1To2: - if (maxLen < (lengthIn * 2)) - { - return -1; - } - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, (WebRtc_Word32*)state1_); - outLen = lengthIn * 2; - return 0; - case kResamplerMode1To3: - - // We can only handle blocks of 160 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 160) != 0) - { - return -1; - } - if (maxLen < (lengthIn * 3)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(336 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 160) - { - WebRtcSpl_Resample16khzTo48khz(samplesIn + i, samplesOut + i * 3, - (WebRtcSpl_State16khzTo48khz *)state1_, - tmp_mem); - } - outLen = lengthIn * 3; - free(tmp_mem); - return 0; - case kResamplerMode1To4: - if (maxLen < (lengthIn * 4)) - { - return -1; - } - - tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * 2 * lengthIn); - // 1:2 - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); - // 2:4 - WebRtcSpl_UpsampleBy2(tmp, lengthIn * 2, samplesOut, (WebRtc_Word32*)state2_); - outLen = lengthIn * 4; - free(tmp); - return 0; - case kResamplerMode1To6: - // We can only handle blocks of 80 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 80) != 0) - { - return -1; - } - if (maxLen < (lengthIn * 6)) - { - return -1; - } - - //1:2 - - tmp_mem = (WebRtc_Word32*)malloc(336 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * 2 * lengthIn); - - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); - outLen = lengthIn * 2; - - for (int i = 0; i < outLen; i += 160) - { - WebRtcSpl_Resample16khzTo48khz(tmp + i, samplesOut + i * 3, - (WebRtcSpl_State16khzTo48khz *)state2_, - tmp_mem); - } - outLen = outLen * 3; - free(tmp_mem); - free(tmp); - - return 0; - case kResamplerMode1To12: - // We can only handle blocks of 40 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 40) != 0) { - return -1; - } - if (maxLen < (lengthIn * 12)) { - return -1; - } - - tmp_mem = (WebRtc_Word32*) malloc(336 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*) malloc(sizeof(WebRtc_Word16) * 4 * lengthIn); - //1:2 - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, - (WebRtc_Word32*) state1_); - outLen = lengthIn * 2; - //2:4 - WebRtcSpl_UpsampleBy2(samplesOut, outLen, tmp, (WebRtc_Word32*) state2_); - outLen = outLen * 2; - // 4:12 - for (int i = 0; i < outLen; i += 160) { - // WebRtcSpl_Resample16khzTo48khz() takes a block of 160 samples - // as input and outputs a resampled block of 480 samples. The - // data is now actually in 32 kHz sampling rate, despite the - // function name, and with a resampling factor of three becomes - // 96 kHz. - WebRtcSpl_Resample16khzTo48khz(tmp + i, samplesOut + i * 3, - (WebRtcSpl_State16khzTo48khz*) state3_, - tmp_mem); - } - outLen = outLen * 3; - free(tmp_mem); - free(tmp); - - return 0; - case kResamplerMode2To3: - if (maxLen < (lengthIn * 3 / 2)) - { - return -1; - } - // 2:6 - // We can only handle blocks of 160 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 160) != 0) - { - return -1; - } - tmp = static_cast<WebRtc_Word16*> (malloc(sizeof(WebRtc_Word16) * lengthIn * 3)); - tmp_mem = (WebRtc_Word32*)malloc(336 * sizeof(WebRtc_Word32)); - for (int i = 0; i < lengthIn; i += 160) - { - WebRtcSpl_Resample16khzTo48khz(samplesIn + i, tmp + i * 3, - (WebRtcSpl_State16khzTo48khz *)state1_, - tmp_mem); - } - lengthIn = lengthIn * 3; - // 6:3 - WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (WebRtc_Word32*)state2_); - outLen = lengthIn / 2; - free(tmp); - free(tmp_mem); - return 0; - case kResamplerMode2To11: - - // We can only handle blocks of 80 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 80) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 11) / 2)) - { - return -1; - } - tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * 2 * lengthIn); - // 1:2 - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); - lengthIn *= 2; - - tmp_mem = (WebRtc_Word32*)malloc(98 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 80) - { - WebRtcSpl_Resample8khzTo22khz(tmp + i, samplesOut + (i * 11) / 4, - (WebRtcSpl_State8khzTo22khz *)state2_, - tmp_mem); - } - outLen = (lengthIn * 11) / 4; - free(tmp_mem); - free(tmp); - return 0; - case kResamplerMode4To11: - - // We can only handle blocks of 80 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 80) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 11) / 4)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(98 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 80) - { - WebRtcSpl_Resample8khzTo22khz(samplesIn + i, samplesOut + (i * 11) / 4, - (WebRtcSpl_State8khzTo22khz *)state1_, - tmp_mem); - } - outLen = (lengthIn * 11) / 4; - free(tmp_mem); - return 0; - case kResamplerMode8To11: - // We can only handle blocks of 160 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 160) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 11) / 8)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(88 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 160) - { - WebRtcSpl_Resample16khzTo22khz(samplesIn + i, samplesOut + (i * 11) / 8, - (WebRtcSpl_State16khzTo22khz *)state1_, - tmp_mem); - } - outLen = (lengthIn * 11) / 8; - free(tmp_mem); - return 0; - - case kResamplerMode11To16: - // We can only handle blocks of 110 samples - if ((lengthIn % 110) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 16) / 11)) - { - return -1; - } - - tmp_mem = (WebRtc_Word32*)malloc(104 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*)malloc((sizeof(WebRtc_Word16) * lengthIn * 2)); - - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); - - for (int i = 0; i < (lengthIn * 2); i += 220) - { - WebRtcSpl_Resample22khzTo16khz(tmp + i, samplesOut + (i / 220) * 160, - (WebRtcSpl_State22khzTo16khz *)state2_, - tmp_mem); - } - - outLen = (lengthIn * 16) / 11; - - free(tmp_mem); - free(tmp); - return 0; - - case kResamplerMode11To32: - - // We can only handle blocks of 110 samples - if ((lengthIn % 110) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 32) / 11)) - { - return -1; - } - - tmp_mem = (WebRtc_Word32*)malloc(104 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*)malloc((sizeof(WebRtc_Word16) * lengthIn * 2)); - - // 11 -> 22 kHz in samplesOut - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, (WebRtc_Word32*)state1_); - - // 22 -> 16 in tmp - for (int i = 0; i < (lengthIn * 2); i += 220) - { - WebRtcSpl_Resample22khzTo16khz(samplesOut + i, tmp + (i / 220) * 160, - (WebRtcSpl_State22khzTo16khz *)state2_, - tmp_mem); - } - - // 16 -> 32 in samplesOut - WebRtcSpl_UpsampleBy2(tmp, (lengthIn * 16) / 11, samplesOut, - (WebRtc_Word32*)state3_); - - outLen = (lengthIn * 32) / 11; - - free(tmp_mem); - free(tmp); - return 0; - - case kResamplerMode2To1: - if (maxLen < (lengthIn / 2)) - { - return -1; - } - WebRtcSpl_DownsampleBy2(samplesIn, lengthIn, samplesOut, (WebRtc_Word32*)state1_); - outLen = lengthIn / 2; - return 0; - case kResamplerMode3To1: - // We can only handle blocks of 480 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 480) != 0) - { - return -1; - } - if (maxLen < (lengthIn / 3)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(496 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 480) - { - WebRtcSpl_Resample48khzTo16khz(samplesIn + i, samplesOut + i / 3, - (WebRtcSpl_State48khzTo16khz *)state1_, - tmp_mem); - } - outLen = lengthIn / 3; - free(tmp_mem); - return 0; - case kResamplerMode4To1: - if (maxLen < (lengthIn / 4)) - { - return -1; - } - tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * lengthIn / 2); - // 4:2 - WebRtcSpl_DownsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); - // 2:1 - WebRtcSpl_DownsampleBy2(tmp, lengthIn / 2, samplesOut, (WebRtc_Word32*)state2_); - outLen = lengthIn / 4; - free(tmp); - return 0; - - case kResamplerMode6To1: - // We can only handle blocks of 480 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 480) != 0) - { - return -1; - } - if (maxLen < (lengthIn / 6)) - { - return -1; - } - - tmp_mem = (WebRtc_Word32*)malloc(496 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*)malloc((sizeof(WebRtc_Word16) * lengthIn) / 3); - - for (int i = 0; i < lengthIn; i += 480) - { - WebRtcSpl_Resample48khzTo16khz(samplesIn + i, tmp + i / 3, - (WebRtcSpl_State48khzTo16khz *)state1_, - tmp_mem); - } - outLen = lengthIn / 3; - free(tmp_mem); - WebRtcSpl_DownsampleBy2(tmp, outLen, samplesOut, (WebRtc_Word32*)state2_); - free(tmp); - outLen = outLen / 2; - return 0; - case kResamplerMode12To1: - // We can only handle blocks of 480 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 480) != 0) { - return -1; - } - if (maxLen < (lengthIn / 12)) { - return -1; - } - - tmp_mem = (WebRtc_Word32*) malloc(496 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*) malloc((sizeof(WebRtc_Word16) * lengthIn) / 3); - tmp_2 = (WebRtc_Word16*) malloc((sizeof(WebRtc_Word16) * lengthIn) / 6); - // 12:4 - for (int i = 0; i < lengthIn; i += 480) { - // WebRtcSpl_Resample48khzTo16khz() takes a block of 480 samples - // as input and outputs a resampled block of 160 samples. The - // data is now actually in 96 kHz sampling rate, despite the - // function name, and with a resampling factor of 1/3 becomes - // 32 kHz. - WebRtcSpl_Resample48khzTo16khz(samplesIn + i, tmp + i / 3, - (WebRtcSpl_State48khzTo16khz*) state1_, - tmp_mem); - } - outLen = lengthIn / 3; - free(tmp_mem); - // 4:2 - WebRtcSpl_DownsampleBy2(tmp, outLen, tmp_2, - (WebRtc_Word32*) state2_); - outLen = outLen / 2; - free(tmp); - // 2:1 - WebRtcSpl_DownsampleBy2(tmp_2, outLen, samplesOut, - (WebRtc_Word32*) state3_); - free(tmp_2); - outLen = outLen / 2; - return 0; - case kResamplerMode3To2: - if (maxLen < (lengthIn * 2 / 3)) - { - return -1; - } - // 3:6 - tmp = static_cast<WebRtc_Word16*> (malloc(sizeof(WebRtc_Word16) * lengthIn * 2)); - WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); - lengthIn *= 2; - // 6:2 - // We can only handle blocks of 480 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 480) != 0) - { - free(tmp); - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(496 * sizeof(WebRtc_Word32)); - for (int i = 0; i < lengthIn; i += 480) - { - WebRtcSpl_Resample48khzTo16khz(tmp + i, samplesOut + i / 3, - (WebRtcSpl_State48khzTo16khz *)state2_, - tmp_mem); - } - outLen = lengthIn / 3; - free(tmp); - free(tmp_mem); - return 0; - case kResamplerMode11To2: - // We can only handle blocks of 220 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 220) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 2) / 11)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(126 * sizeof(WebRtc_Word32)); - tmp = (WebRtc_Word16*)malloc((lengthIn * 4) / 11 * sizeof(WebRtc_Word16)); - - for (int i = 0; i < lengthIn; i += 220) - { - WebRtcSpl_Resample22khzTo8khz(samplesIn + i, tmp + (i * 4) / 11, - (WebRtcSpl_State22khzTo8khz *)state1_, - tmp_mem); - } - lengthIn = (lengthIn * 4) / 11; - - WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (WebRtc_Word32*)state2_); - outLen = lengthIn / 2; - - free(tmp_mem); - free(tmp); - return 0; - case kResamplerMode11To4: - // We can only handle blocks of 220 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 220) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 4) / 11)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(126 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 220) - { - WebRtcSpl_Resample22khzTo8khz(samplesIn + i, samplesOut + (i * 4) / 11, - (WebRtcSpl_State22khzTo8khz *)state1_, - tmp_mem); - } - outLen = (lengthIn * 4) / 11; - free(tmp_mem); - return 0; - case kResamplerMode11To8: - // We can only handle blocks of 160 samples - // Can be fixed, but I don't think it's needed - if ((lengthIn % 220) != 0) - { - return -1; - } - if (maxLen < ((lengthIn * 8) / 11)) - { - return -1; - } - tmp_mem = (WebRtc_Word32*)malloc(104 * sizeof(WebRtc_Word32)); - - for (int i = 0; i < lengthIn; i += 220) - { - WebRtcSpl_Resample22khzTo16khz(samplesIn + i, samplesOut + (i * 8) / 11, - (WebRtcSpl_State22khzTo16khz *)state1_, - tmp_mem); - } - outLen = (lengthIn * 8) / 11; - free(tmp_mem); - return 0; - break; - - } - return 0; -} - -// Asynchronous resampling, input -int Resampler::Insert(WebRtc_Word16 * samplesIn, int lengthIn) -{ - if (my_type_ != kResamplerAsynchronous) - { - return -1; - } - int sizeNeeded, tenMsblock; - - // Determine need for size of outBuffer - sizeNeeded = out_buffer_size_ + ((lengthIn + in_buffer_size_) * my_out_frequency_khz_) - / my_in_frequency_khz_; - if (sizeNeeded > out_buffer_size_max_) - { - // Round the value upwards to complete 10 ms blocks - tenMsblock = my_out_frequency_khz_ * 10; - sizeNeeded = (sizeNeeded / tenMsblock + 1) * tenMsblock; - out_buffer_ = (WebRtc_Word16*)realloc(out_buffer_, sizeNeeded * sizeof(WebRtc_Word16)); - out_buffer_size_max_ = sizeNeeded; - } - - // If we need to use inBuffer, make sure all input data fits there. - - tenMsblock = my_in_frequency_khz_ * 10; - if (in_buffer_size_ || (lengthIn % tenMsblock)) - { - // Check if input buffer size is enough - if ((in_buffer_size_ + lengthIn) > in_buffer_size_max_) - { - // Round the value upwards to complete 10 ms blocks - sizeNeeded = ((in_buffer_size_ + lengthIn) / tenMsblock + 1) * tenMsblock; - in_buffer_ = (WebRtc_Word16*)realloc(in_buffer_, - sizeNeeded * sizeof(WebRtc_Word16)); - in_buffer_size_max_ = sizeNeeded; - } - // Copy in data to input buffer - memcpy(in_buffer_ + in_buffer_size_, samplesIn, lengthIn * sizeof(WebRtc_Word16)); - - // Resample all available 10 ms blocks - int lenOut; - int dataLenToResample = (in_buffer_size_ / tenMsblock) * tenMsblock; - Push(in_buffer_, dataLenToResample, out_buffer_ + out_buffer_size_, - out_buffer_size_max_ - out_buffer_size_, lenOut); - out_buffer_size_ += lenOut; - - // Save the rest - memmove(in_buffer_, in_buffer_ + dataLenToResample, - (in_buffer_size_ - dataLenToResample) * sizeof(WebRtc_Word16)); - in_buffer_size_ -= dataLenToResample; - } else - { - // Just resample - int lenOut; - Push(in_buffer_, lengthIn, out_buffer_ + out_buffer_size_, - out_buffer_size_max_ - out_buffer_size_, lenOut); - out_buffer_size_ += lenOut; - } - - return 0; -} - -// Asynchronous resampling output, remaining samples are buffered -int Resampler::Pull(WebRtc_Word16* samplesOut, int desiredLen, int &outLen) -{ - if (my_type_ != kResamplerAsynchronous) - { - return -1; - } - - // Check that we have enough data - if (desiredLen <= out_buffer_size_) - { - // Give out the date - memcpy(samplesOut, out_buffer_, desiredLen * sizeof(WebRtc_Word32)); - - // Shuffle down remaining - memmove(out_buffer_, out_buffer_ + desiredLen, - (out_buffer_size_ - desiredLen) * sizeof(WebRtc_Word16)); - - // Update remaining size - out_buffer_size_ -= desiredLen; - - return 0; - } else - { - return -1; - } -} - -} // namespace webrtc
diff --git a/src/common_audio/resampler/resampler.gypi b/src/common_audio/resampler/resampler.gypi deleted file mode 100644 index 75997fd..0000000 --- a/src/common_audio/resampler/resampler.gypi +++ /dev/null
@@ -1,55 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'resampler', - 'type': '<(library)', - 'dependencies': [ - 'signal_processing', - ], - 'include_dirs': [ - 'include', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - ], - }, - 'sources': [ - 'include/resampler.h', - 'resampler.cc', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets' : [ - { - 'target_name': 'resampler_unittests', - 'type': 'executable', - 'dependencies': [ - 'resampler', - '<(webrtc_root)/test/test.gyp:test_support_main', - '<(DEPTH)/testing/gtest.gyp:gtest', - ], - 'sources': [ - 'resampler_unittest.cc', - ], - }, # resampler_unittests - ], # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/common_audio/resampler/resampler_unittest.cc b/src/common_audio/resampler/resampler_unittest.cc deleted file mode 100644 index 9b1061a..0000000 --- a/src/common_audio/resampler/resampler_unittest.cc +++ /dev/null
@@ -1,143 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "gtest/gtest.h" - -#include "common_audio/resampler/include/resampler.h" - -// TODO(andrew): this is a work-in-progress. Many more tests are needed. - -namespace webrtc { -namespace { -const ResamplerType kTypes[] = { - kResamplerSynchronous, - kResamplerAsynchronous, - kResamplerSynchronousStereo, - kResamplerAsynchronousStereo - // kResamplerInvalid excluded -}; -const size_t kTypesSize = sizeof(kTypes) / sizeof(*kTypes); - -// Rates we must support. -const int kMaxRate = 96000; -const int kRates[] = { - 8000, - 16000, - 32000, - 44000, - 48000, - kMaxRate -}; -const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); -const int kMaxChannels = 2; -const size_t kDataSize = static_cast<size_t> (kMaxChannels * kMaxRate / 100); - -// TODO(andrew): should we be supporting these combinations? -bool ValidRates(int in_rate, int out_rate) { - // Not the most compact notation, for clarity. - if ((in_rate == 44000 && (out_rate == 48000 || out_rate == 96000)) || - (out_rate == 44000 && (in_rate == 48000 || in_rate == 96000))) { - return false; - } - - return true; -} - -class ResamplerTest : public testing::Test { - protected: - ResamplerTest(); - virtual void SetUp(); - virtual void TearDown(); - - Resampler rs_; - int16_t data_in_[kDataSize]; - int16_t data_out_[kDataSize]; -}; - -ResamplerTest::ResamplerTest() {} - -void ResamplerTest::SetUp() { - // Initialize input data with anything. The tests are content independent. - memset(data_in_, 1, sizeof(data_in_)); -} - -void ResamplerTest::TearDown() {} - -TEST_F(ResamplerTest, Reset) { - // The only failure mode for the constructor is if Reset() fails. For the - // time being then (until an Init function is added), we rely on Reset() - // to test the constructor. - - // Check that all required combinations are supported. - for (size_t i = 0; i < kRatesSize; ++i) { - for (size_t j = 0; j < kRatesSize; ++j) { - for (size_t k = 0; k < kTypesSize; ++k) { - std::ostringstream ss; - ss << "Input rate: " << kRates[i] << ", output rate: " << kRates[j] - << ", type: " << kTypes[k]; - SCOPED_TRACE(ss.str()); - if (ValidRates(kRates[i], kRates[j])) - EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], kTypes[k])); - else - EXPECT_EQ(-1, rs_.Reset(kRates[i], kRates[j], kTypes[k])); - } - } - } -} - -// TODO(tlegrand): Replace code inside the two tests below with a function -// with number of channels and ResamplerType as input. -TEST_F(ResamplerTest, Synchronous) { - for (size_t i = 0; i < kRatesSize; ++i) { - for (size_t j = 0; j < kRatesSize; ++j) { - std::ostringstream ss; - ss << "Input rate: " << kRates[i] << ", output rate: " << kRates[j]; - SCOPED_TRACE(ss.str()); - - if (ValidRates(kRates[i], kRates[j])) { - int in_length = kRates[i] / 100; - int out_length = 0; - EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], kResamplerSynchronous)); - EXPECT_EQ(0, rs_.Push(data_in_, in_length, data_out_, kDataSize, - out_length)); - EXPECT_EQ(kRates[j] / 100, out_length); - } else { - EXPECT_EQ(-1, rs_.Reset(kRates[i], kRates[j], kResamplerSynchronous)); - } - } - } -} - -TEST_F(ResamplerTest, SynchronousStereo) { - // Number of channels is 2, stereo mode. - const int kChannels = 2; - for (size_t i = 0; i < kRatesSize; ++i) { - for (size_t j = 0; j < kRatesSize; ++j) { - std::ostringstream ss; - ss << "Input rate: " << kRates[i] << ", output rate: " << kRates[j]; - SCOPED_TRACE(ss.str()); - - if (ValidRates(kRates[i], kRates[j])) { - int in_length = kChannels * kRates[i] / 100; - int out_length = 0; - EXPECT_EQ(0, rs_.Reset(kRates[i], kRates[j], - kResamplerSynchronousStereo)); - EXPECT_EQ(0, rs_.Push(data_in_, in_length, data_out_, kDataSize, - out_length)); - EXPECT_EQ(kChannels * kRates[j] / 100, out_length); - } else { - EXPECT_EQ(-1, rs_.Reset(kRates[i], kRates[j], - kResamplerSynchronousStereo)); - } - } - } -} -} // namespace -} // namespace webrtc
diff --git a/src/common_audio/signal_processing/Android.mk b/src/common_audio/signal_processing/Android.mk deleted file mode 100644 index c28cced..0000000 --- a/src/common_audio/signal_processing/Android.mk +++ /dev/null
@@ -1,103 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -include $(LOCAL_PATH)/../../../android-webrtc.mk - -LOCAL_ARM_MODE := arm -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libwebrtc_spl -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := \ - auto_corr_to_refl_coef.c \ - auto_correlation.c \ - complex_fft.c \ - copy_set_operations.c \ - division_operations.c \ - dot_product_with_scale.c \ - energy.c \ - filter_ar.c \ - filter_ma_fast_q12.c \ - get_hanning_window.c \ - get_scaling_square.c \ - ilbc_specific_functions.c \ - levinson_durbin.c \ - lpc_to_refl_coef.c \ - min_max_operations.c \ - randomization_functions.c \ - refl_coef_to_lpc.c \ - resample.c \ - resample_48khz.c \ - resample_by_2.c \ - resample_by_2_internal.c \ - resample_fractional.c \ - spl_sqrt.c \ - spl_version.c \ - splitting_filter.c \ - sqrt_of_one_minus_x_squared.c \ - vector_scaling_operations.c - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := \ - $(MY_WEBRTC_COMMON_DEFS) - -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) -LOCAL_CFLAGS_x86 := $(MY_WEBRTC_COMMON_DEFS_x86) -LOCAL_CFLAGS_mips := $(MY_WEBRTC_COMMON_DEFS_mips) -LOCAL_CFLAGS_arm64 := $(MY_WEBRTC_COMMON_DEFS_arm64) -LOCAL_CFLAGS_x86_64 := $(MY_WEBRTC_COMMON_DEFS_x86_64) -LOCAL_CFLAGS_mips64 := $(MY_WEBRTC_COMMON_DEFS_mips64) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/../.. - -# Some new .s files have compilation error with AOSP configuration, -# so they are not used. The next merge of upstream .S file might work. -#ifeq ($(ARCH_ARM_HAVE_NEON),true) -#LOCAL_SRC_FILES += \ -# cross_correlation_neon.s \ -# downsample_fast_neon.s \ -# min_max_operations_neon.s \ -# vector_scaling_operations_neon.s -#LOCAL_CFLAGS += \ -# $(MY_ARM_CFLAGS_NEON) -#else -LOCAL_SRC_FILES += \ - cross_correlation.c \ - downsample_fast.c -#endif - -#ifeq ($(ARCH_ARM_HAVE_ARMV7A),true_skip) -#LOCAL_SRC_FILES += \ -# filter_ar_fast_q12_armv7.s -#else -LOCAL_SRC_FILES += \ - filter_ar_fast_q12.c -#endif - -ifeq ($(TARGET_ARCH),arm) -LOCAL_SRC_FILES += \ - complex_bit_reverse_arm.s \ - spl_sqrt_floor_arm.s -else -LOCAL_SRC_FILES += \ - complex_bit_reverse.c \ - spl_sqrt_floor.c -endif - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -endif - -include $(BUILD_STATIC_LIBRARY)
diff --git a/src/common_audio/signal_processing/auto_corr_to_refl_coef.c b/src/common_audio/signal_processing/auto_corr_to_refl_coef.c deleted file mode 100644 index b7e8858..0000000 --- a/src/common_audio/signal_processing/auto_corr_to_refl_coef.c +++ /dev/null
@@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_AutoCorrToReflCoef(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32 *R, int use_order, WebRtc_Word16 *K) -{ - int i, n; - WebRtc_Word16 tmp; - G_CONST WebRtc_Word32 *rptr; - WebRtc_Word32 L_num, L_den; - WebRtc_Word16 *acfptr, *pptr, *wptr, *p1ptr, *w1ptr, ACF[WEBRTC_SPL_MAX_LPC_ORDER], - P[WEBRTC_SPL_MAX_LPC_ORDER], W[WEBRTC_SPL_MAX_LPC_ORDER]; - - // Initialize loop and pointers. - acfptr = ACF; - rptr = R; - pptr = P; - p1ptr = &P[1]; - w1ptr = &W[1]; - wptr = w1ptr; - - // First loop; n=0. Determine shifting. - tmp = WebRtcSpl_NormW32(*R); - *acfptr = (WebRtc_Word16)((*rptr++ << tmp) >> 16); - *pptr++ = *acfptr++; - - // Initialize ACF, P and W. - for (i = 1; i <= use_order; i++) - { - *acfptr = (WebRtc_Word16)((*rptr++ << tmp) >> 16); - *wptr++ = *acfptr; - *pptr++ = *acfptr++; - } - - // Compute reflection coefficients. - for (n = 1; n <= use_order; n++, K++) - { - tmp = WEBRTC_SPL_ABS_W16(*p1ptr); - if (*P < tmp) - { - for (i = n; i <= use_order; i++) - *K++ = 0; - - return; - } - - // Division: WebRtcSpl_div(tmp, *P) - *K = 0; - if (tmp != 0) - { - L_num = tmp; - L_den = *P; - i = 15; - while (i--) - { - (*K) <<= 1; - L_num <<= 1; - if (L_num >= L_den) - { - L_num -= L_den; - (*K)++; - } - } - if (*p1ptr > 0) - *K = -*K; - } - - // Last iteration; don't do Schur recursion. - if (n == use_order) - return; - - // Schur recursion. - pptr = P; - wptr = w1ptr; - tmp = (WebRtc_Word16)(((WebRtc_Word32)*p1ptr * (WebRtc_Word32)*K + 16384) >> 15); - *pptr = WEBRTC_SPL_ADD_SAT_W16( *pptr, tmp ); - pptr++; - for (i = 1; i <= use_order - n; i++) - { - tmp = (WebRtc_Word16)(((WebRtc_Word32)*wptr * (WebRtc_Word32)*K + 16384) >> 15); - *pptr = WEBRTC_SPL_ADD_SAT_W16( *(pptr+1), tmp ); - pptr++; - tmp = (WebRtc_Word16)(((WebRtc_Word32)*pptr * (WebRtc_Word32)*K + 16384) >> 15); - *wptr = WEBRTC_SPL_ADD_SAT_W16( *wptr, tmp ); - wptr++; - } - } -}
diff --git a/src/common_audio/signal_processing/auto_correlation.c b/src/common_audio/signal_processing/auto_correlation.c deleted file mode 100644 index bd954cf..0000000 --- a/src/common_audio/signal_processing/auto_correlation.c +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "signal_processing_library.h" - -int WebRtcSpl_AutoCorrelation(const int16_t* in_vector, - int in_vector_length, - int order, - int32_t* result, - int* scale) { - int32_t sum = 0; - int i = 0, j = 0; - int16_t smax = 0; - int scaling = 0; - - if (order > in_vector_length) { - /* Undefined */ - return -1; - } else if (order < 0) { - order = in_vector_length; - } - - // Find the maximum absolute value of the samples. - smax = WebRtcSpl_MaxAbsValueW16(in_vector, in_vector_length); - - // In order to avoid overflow when computing the sum we should scale the - // samples so that (in_vector_length * smax * smax) will not overflow. - if (smax == 0) { - scaling = 0; - } else { - // Number of bits in the sum loop. - int nbits = WebRtcSpl_GetSizeInBits(in_vector_length); - // Number of bits to normalize smax. - int t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); - - if (t > nbits) { - scaling = 0; - } else { - scaling = nbits - t; - } - } - - // Perform the actual correlation calculation. - for (i = 0; i < order + 1; i++) { - sum = 0; - /* Unroll the loop to improve performance. */ - for (j = 0; j < in_vector_length - i - 3; j += 4) { - sum += (in_vector[j + 0] * in_vector[i + j + 0]) >> scaling; - sum += (in_vector[j + 1] * in_vector[i + j + 1]) >> scaling; - sum += (in_vector[j + 2] * in_vector[i + j + 2]) >> scaling; - sum += (in_vector[j + 3] * in_vector[i + j + 3]) >> scaling; - } - for (; j < in_vector_length - i; j++) { - sum += (in_vector[j] * in_vector[i + j]) >> scaling; - } - *result++ = sum; - } - - *scale = scaling; - return order + 1; -}
diff --git a/src/common_audio/signal_processing/complex_bit_reverse.c b/src/common_audio/signal_processing/complex_bit_reverse.c deleted file mode 100644 index 02fde1e..0000000 --- a/src/common_audio/signal_processing/complex_bit_reverse.c +++ /dev/null
@@ -1,109 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "signal_processing_library.h" - -/* Tables for data buffer indexes that are bit reversed and thus need to be - * swapped. Note that, index_7[{0, 2, 4, ...}] are for the left side of the swap - * operations, while index_7[{1, 3, 5, ...}] are for the right side of the - * operation. Same for index_8. - */ - -/* Indexes for the case of stages == 7. */ -static const int16_t index_7[112] = { - 1, 64, 2, 32, 3, 96, 4, 16, 5, 80, 6, 48, 7, 112, 9, 72, 10, 40, 11, 104, - 12, 24, 13, 88, 14, 56, 15, 120, 17, 68, 18, 36, 19, 100, 21, 84, 22, 52, - 23, 116, 25, 76, 26, 44, 27, 108, 29, 92, 30, 60, 31, 124, 33, 66, 35, 98, - 37, 82, 38, 50, 39, 114, 41, 74, 43, 106, 45, 90, 46, 58, 47, 122, 49, 70, - 51, 102, 53, 86, 55, 118, 57, 78, 59, 110, 61, 94, 63, 126, 67, 97, 69, - 81, 71, 113, 75, 105, 77, 89, 79, 121, 83, 101, 87, 117, 91, 109, 95, 125, - 103, 115, 111, 123 -}; - -/* Indexes for the case of stages == 8. */ -static const int16_t index_8[240] = { - 1, 128, 2, 64, 3, 192, 4, 32, 5, 160, 6, 96, 7, 224, 8, 16, 9, 144, 10, 80, - 11, 208, 12, 48, 13, 176, 14, 112, 15, 240, 17, 136, 18, 72, 19, 200, 20, - 40, 21, 168, 22, 104, 23, 232, 25, 152, 26, 88, 27, 216, 28, 56, 29, 184, - 30, 120, 31, 248, 33, 132, 34, 68, 35, 196, 37, 164, 38, 100, 39, 228, 41, - 148, 42, 84, 43, 212, 44, 52, 45, 180, 46, 116, 47, 244, 49, 140, 50, 76, - 51, 204, 53, 172, 54, 108, 55, 236, 57, 156, 58, 92, 59, 220, 61, 188, 62, - 124, 63, 252, 65, 130, 67, 194, 69, 162, 70, 98, 71, 226, 73, 146, 74, 82, - 75, 210, 77, 178, 78, 114, 79, 242, 81, 138, 83, 202, 85, 170, 86, 106, 87, - 234, 89, 154, 91, 218, 93, 186, 94, 122, 95, 250, 97, 134, 99, 198, 101, - 166, 103, 230, 105, 150, 107, 214, 109, 182, 110, 118, 111, 246, 113, 142, - 115, 206, 117, 174, 119, 238, 121, 158, 123, 222, 125, 190, 127, 254, 131, - 193, 133, 161, 135, 225, 137, 145, 139, 209, 141, 177, 143, 241, 147, 201, - 149, 169, 151, 233, 155, 217, 157, 185, 159, 249, 163, 197, 167, 229, 171, - 213, 173, 181, 175, 245, 179, 205, 183, 237, 187, 221, 191, 253, 199, 227, - 203, 211, 207, 243, 215, 235, 223, 251, 239, 247 -}; - -void WebRtcSpl_ComplexBitReverse(int16_t* __restrict complex_data, int stages) { - /* For any specific value of stages, we know exactly the indexes that are - * bit reversed. Currently (Feb. 2012) in WebRTC the only possible values of - * stages are 7 and 8, so we use tables to save unnecessary iterations and - * calculations for these two cases. - */ - if (stages == 7 || stages == 8) { - int m = 0; - int length = 112; - const int16_t* index = index_7; - - if (stages == 8) { - length = 240; - index = index_8; - } - - /* Decimation in time. Swap the elements with bit-reversed indexes. */ - for (m = 0; m < length; m += 2) { - /* We declare a int32_t* type pointer, to load both the 16-bit real - * and imaginary elements from complex_data in one instruction, reducing - * complexity. - */ - int32_t* complex_data_ptr = (int32_t*)complex_data; - int32_t temp = 0; - - temp = complex_data_ptr[index[m]]; /* Real and imaginary */ - complex_data_ptr[index[m]] = complex_data_ptr[index[m + 1]]; - complex_data_ptr[index[m + 1]] = temp; - } - } - else { - int m = 0, mr = 0, l = 0; - int n = 1 << stages; - int nn = n - 1; - - /* Decimation in time - re-order data */ - for (m = 1; m <= nn; ++m) { - int32_t* complex_data_ptr = (int32_t*)complex_data; - int32_t temp = 0; - - /* Find out indexes that are bit-reversed. */ - l = n; - do { - l >>= 1; - } while (l > nn - mr); - mr = (mr & (l - 1)) + l; - - if (mr <= m) { - continue; - } - - /* Swap the elements with bit-reversed indexes. - * This is similar to the loop in the stages == 7 or 8 cases. - */ - temp = complex_data_ptr[m]; /* Real and imaginary */ - complex_data_ptr[m] = complex_data_ptr[mr]; - complex_data_ptr[mr] = temp; - } - } -} -
diff --git a/src/common_audio/signal_processing/complex_bit_reverse_arm.s b/src/common_audio/signal_processing/complex_bit_reverse_arm.s deleted file mode 100644 index 4828077..0000000 --- a/src/common_audio/signal_processing/complex_bit_reverse_arm.s +++ /dev/null
@@ -1,126 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ This file contains the function WebRtcSpl_ComplexBitReverse(), optimized -@ for ARMv5 platforms. -@ Reference C code is in file complex_bit_reverse.c. Bit-exact. - -.arch armv5 - -.global WebRtcSpl_ComplexBitReverse - -.align 2 - -WebRtcSpl_ComplexBitReverse: -.fnstart - - push {r4-r7} - - cmp r1, #7 - adr r3, index_7 @ Table pointer. - mov r4, #112 @ Number of interations. - beq PRE_LOOP_STAGES_7_OR_8 - - cmp r1, #8 - adr r3, index_8 @ Table pointer. - mov r4, #240 @ Number of interations. - beq PRE_LOOP_STAGES_7_OR_8 - - mov r3, #1 @ Initialize m. - mov r1, r3, asl r1 @ n = 1 << stages; - subs r6, r1, #1 @ nn = n - 1; - ble END - - mov r5, r0 @ &complex_data - mov r4, #0 @ ml - -LOOP_GENERIC: - rsb r12, r4, r6 @ l > nn - mr - mov r2, r1 @ n - -LOOP_SHIFT: - asr r2, #1 @ l >>= 1; - cmp r2, r12 - bgt LOOP_SHIFT - - sub r12, r2, #1 - and r4, r12, r4 - add r4, r2 @ mr = (mr & (l - 1)) + l; - cmp r4, r3 @ mr <= m ? - ble UPDATE_REGISTERS - - mov r12, r4, asl #2 - ldr r7, [r5, #4] @ complex_data[2 * m, 2 * m + 1]. - @ Offset 4 due to m incrementing from 1. - ldr r2, [r0, r12] @ complex_data[2 * mr, 2 * mr + 1]. - str r7, [r0, r12] - str r2, [r5, #4] - -UPDATE_REGISTERS: - add r3, r3, #1 - add r5, #4 - cmp r3, r1 - bne LOOP_GENERIC - - b END - -PRE_LOOP_STAGES_7_OR_8: - add r4, r3, r4, asl #1 - -LOOP_STAGES_7_OR_8: - ldrsh r2, [r3], #2 @ index[m] - ldrsh r5, [r3], #2 @ index[m + 1] - ldr r1, [r0, r2] @ complex_data[index[m], index[m] + 1] - ldr r12, [r0, r5] @ complex_data[index[m + 1], index[m + 1] + 1] - cmp r3, r4 - str r1, [r0, r5] - str r12, [r0, r2] - bne LOOP_STAGES_7_OR_8 - -END: - pop {r4-r7} - bx lr - -.fnend - - -@ The index tables. Note the values are doubles of the actual indexes for 16-bit -@ elements, different from the generic C code. It actually provides byte offsets -@ for the indexes. - -.align 2 -index_7: @ Indexes for stages == 7. - .hword 4, 256, 8, 128, 12, 384, 16, 64, 20, 320, 24, 192, 28, 448, 36, 288 - .hword 40, 160, 44, 416, 48, 96, 52, 352, 56, 224, 60, 480, 68, 272, 72, 144 - .hword 76, 400, 84, 336, 88, 208, 92, 464, 100, 304, 104, 176, 108, 432, 116 - .hword 368, 120, 240, 124, 496, 132, 264, 140, 392, 148, 328, 152, 200, 156 - .hword 456, 164, 296, 172, 424, 180, 360, 184, 232, 188, 488, 196, 280, 204 - .hword 408, 212, 344, 220, 472, 228, 312, 236, 440, 244, 376, 252, 504, 268 - .hword 388, 276, 324, 284, 452, 300, 420, 308, 356, 316, 484, 332, 404, 348 - .hword 468, 364, 436, 380, 500, 412, 460, 444, 492 - -index_8: @ Indexes for stages == 8. - .hword 4, 512, 8, 256, 12, 768, 16, 128, 20, 640, 24, 384, 28, 896, 32, 64 - .hword 36, 576, 40, 320, 44, 832, 48, 192, 52, 704, 56, 448, 60, 960, 68, 544 - .hword 72, 288, 76, 800, 80, 160, 84, 672, 88, 416, 92, 928, 100, 608, 104 - .hword 352, 108, 864, 112, 224, 116, 736, 120, 480, 124, 992, 132, 528, 136 - .hword 272, 140, 784, 148, 656, 152, 400, 156, 912, 164, 592, 168, 336, 172 - .hword 848, 176, 208, 180, 720, 184, 464, 188, 976, 196, 560, 200, 304, 204 - .hword 816, 212, 688, 216, 432, 220, 944, 228, 624, 232, 368, 236, 880, 244 - .hword 752, 248, 496, 252, 1008, 260, 520, 268, 776, 276, 648, 280, 392, 284 - .hword 904, 292, 584, 296, 328, 300, 840, 308, 712, 312, 456, 316, 968, 324 - .hword 552, 332, 808, 340, 680, 344, 424, 348, 936, 356, 616, 364, 872, 372 - .hword 744, 376, 488, 380, 1000, 388, 536, 396, 792, 404, 664, 412, 920, 420 - .hword 600, 428, 856, 436, 728, 440, 472, 444, 984, 452, 568, 460, 824, 468 - .hword 696, 476, 952, 484, 632, 492, 888, 500, 760, 508, 1016, 524, 772, 532 - .hword 644, 540, 900, 548, 580, 556, 836, 564, 708, 572, 964, 588, 804, 596 - .hword 676, 604, 932, 620, 868, 628, 740, 636, 996, 652, 788, 668, 916, 684 - .hword 852, 692, 724, 700, 980, 716, 820, 732, 948, 748, 884, 764, 1012, 796 - .hword 908, 812, 844, 828, 972, 860, 940, 892, 1004, 956, 988
diff --git a/src/common_audio/signal_processing/complex_fft.c b/src/common_audio/signal_processing/complex_fft.c deleted file mode 100644 index 3f06ab3..0000000 --- a/src/common_audio/signal_processing/complex_fft.c +++ /dev/null
@@ -1,425 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_ComplexFFT(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -#define CFFTSFT 14 -#define CFFTRND 1 -#define CFFTRND2 16384 - -#define CIFFTSFT 14 -#define CIFFTRND 1 - -static const WebRtc_Word16 kSinTable1024[] = { - 0, 201, 402, 603, 804, 1005, 1206, 1406, - 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, - 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608, - 4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195, - 6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766, - 7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319, - 9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849, - 11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353, - 12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827, - 14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268, - 15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672, - 16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036, - 18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357, - 19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631, - 20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855, - 22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027, - 23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143, - 24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201, - 25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198, - 26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132, - 27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001, - 28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802, - 28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534, - 29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195, - 30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783, - 30851, 30918, 30984, 31049, - 31113, 31175, 31236, 31297, - 31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735, - 31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097, - 32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382, - 32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588, - 32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717, - 32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766, - 32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736, - 32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628, - 32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441, - 32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176, - 32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833, - 31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413, - 31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918, - 30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349, - 30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706, - 29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992, - 28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208, - 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355, - 27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437, - 26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456, - 25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413, - 24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311, - 23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153, - 22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942, - 20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680, - 19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371, - 18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017, - 16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623, - 15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191, - 14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724, - 12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227, - 11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703, - 9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156, - 7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589, - 6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006, - 4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411, - 3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808, - 1607, 1406, 1206, 1005, 804, 603, 402, 201, - 0, -201, -402, -603, -804, -1005, -1206, -1406, - -1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011, - -3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608, - -4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195, - -6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766, - -7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319, - -9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849, - -11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353, - -12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827, - -14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268, - -15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672, - -16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036, - -18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357, - -19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631, - -20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855, - -22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027, - -23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143, - -24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201, - -25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198, - -26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132, - -27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001, - -28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802, - -28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534, - -29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195, - -30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783, - -30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297, - -31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735, - -31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097, - -32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382, - -32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588, - -32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717, - -32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766, - -32767, -32766, -32764, -32761, -32757, -32751, -32744, -32736, - -32727, -32717, -32705, -32692, -32678, -32662, -32646, -32628, - -32609, -32588, -32567, -32544, -32520, -32495, -32468, -32441, - -32412, -32382, -32350, -32318, -32284, -32249, -32213, -32176, - -32137, -32097, -32056, -32014, -31970, -31926, -31880, -31833, - -31785, -31735, -31684, -31633, -31580, -31525, -31470, -31413, - -31356, -31297, -31236, -31175, -31113, -31049, -30984, -30918, - -30851, -30783, -30713, -30643, -30571, -30498, -30424, -30349, - -30272, -30195, -30116, -30036, -29955, -29873, -29790, -29706, - -29621, -29534, -29446, -29358, -29268, -29177, -29085, -28992, - -28897, -28802, -28706, -28608, -28510, -28410, -28309, -28208, - -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27355, - -27244, -27132, -27019, -26905, -26789, -26673, -26556, -26437, - -26318, -26198, -26077, -25954, -25831, -25707, -25582, -25456, - -25329, -25201, -25072, -24942, -24811, -24679, -24546, -24413, - -24278, -24143, -24006, -23869, -23731, -23592, -23452, -23311, - -23169, -23027, -22883, -22739, -22594, -22448, -22301, -22153, - -22004, -21855, -21705, -21554, -21402, -21249, -21096, -20942, - -20787, -20631, -20474, -20317, -20159, -20000, -19840, -19680, - -19519, -19357, -19194, -19031, -18867, -18702, -18537, -18371, - -18204, -18036, -17868, -17699, -17530, -17360, -17189, -17017, - -16845, -16672, -16499, -16325, -16150, -15975, -15799, -15623, - -15446, -15268, -15090, -14911, -14732, -14552, -14372, -14191, - -14009, -13827, -13645, -13462, -13278, -13094, -12909, -12724, - -12539, -12353, -12166, -11980, -11792, -11604, -11416, -11227, - -11038, -10849, -10659, -10469, -10278, -10087, -9895, -9703, - -9511, -9319, -9126, -8932, -8739, -8545, -8351, -8156, - -7961, -7766, -7571, -7375, -7179, -6982, -6786, -6589, - -6392, -6195, -5997, -5799, -5601, -5403, -5205, -5006, - -4807, -4608, -4409, -4210, -4011, -3811, -3611, -3411, - -3211, -3011, -2811, -2610, -2410, -2209, -2009, -1808, - -1607, -1406, -1206, -1005, -804, -603, -402, -201 -}; - -int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode) -{ - int i, j, l, k, istep, n, m; - WebRtc_Word16 wr, wi; - WebRtc_Word32 tr32, ti32, qr32, qi32; - - /* The 1024-value is a constant given from the size of kSinTable1024[], - * and should not be changed depending on the input parameter 'stages' - */ - n = 1 << stages; - if (n > 1024) - return -1; - - l = 1; - k = 10 - 1; /* Constant for given kSinTable1024[]. Do not change - depending on the input parameter 'stages' */ - - if (mode == 0) - { - // mode==0: Low-complexity and Low-accuracy mode - while (l < n) - { - istep = l << 1; - - for (m = 0; m < l; ++m) - { - j = m << k; - - /* The 256-value is a constant given as 1/4 of the size of - * kSinTable1024[], and should not be changed depending on the input - * parameter 'stages'. It will result in 0 <= j < N_SINE_WAVE/2 - */ - wr = kSinTable1024[j + 256]; - wi = -kSinTable1024[j]; - - for (i = m; i < n; i += istep) - { - j = i + l; - - tr32 = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j]) - - WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j + 1])), 15); - - ti32 = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1]) - + WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j])), 15); - - qr32 = (WebRtc_Word32)frfi[2 * i]; - qi32 = (WebRtc_Word32)frfi[2 * i + 1]; - frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 - tr32, 1); - frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 - ti32, 1); - frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 + tr32, 1); - frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 + ti32, 1); - } - } - - --k; - l = istep; - - } - - } else - { - // mode==1: High-complexity and High-accuracy mode - while (l < n) - { - istep = l << 1; - - for (m = 0; m < l; ++m) - { - j = m << k; - - /* The 256-value is a constant given as 1/4 of the size of - * kSinTable1024[], and should not be changed depending on the input - * parameter 'stages'. It will result in 0 <= j < N_SINE_WAVE/2 - */ - wr = kSinTable1024[j + 256]; - wi = -kSinTable1024[j]; - -#ifdef WEBRTC_ARCH_ARM_V7 - WebRtc_Word32 wri; - WebRtc_Word32 frfi_r; - __asm__("pkhbt %0, %1, %2, lsl #16" : "=r"(wri) : - "r"((WebRtc_Word32)wr), "r"((WebRtc_Word32)wi)); -#endif - - for (i = m; i < n; i += istep) - { - j = i + l; - -#ifdef WEBRTC_ARCH_ARM_V7 - __asm__("pkhbt %0, %1, %2, lsl #16" : "=r"(frfi_r) : - "r"((WebRtc_Word32)frfi[2*j]), "r"((WebRtc_Word32)frfi[2*j +1])); - __asm__("smlsd %0, %1, %2, %3" : "=r"(tr32) : - "r"(wri), "r"(frfi_r), "r"(CFFTRND)); - __asm__("smladx %0, %1, %2, %3" : "=r"(ti32) : - "r"(wri), "r"(frfi_r), "r"(CFFTRND)); - -#else - tr32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j]) - - WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j + 1]) + CFFTRND; - - ti32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1]) - + WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j]) + CFFTRND; -#endif - - tr32 = WEBRTC_SPL_RSHIFT_W32(tr32, 15 - CFFTSFT); - ti32 = WEBRTC_SPL_RSHIFT_W32(ti32, 15 - CFFTSFT); - - qr32 = ((WebRtc_Word32)frfi[2 * i]) << CFFTSFT; - qi32 = ((WebRtc_Word32)frfi[2 * i + 1]) << CFFTSFT; - - frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (qr32 - tr32 + CFFTRND2), 1 + CFFTSFT); - frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (qi32 - ti32 + CFFTRND2), 1 + CFFTSFT); - frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (qr32 + tr32 + CFFTRND2), 1 + CFFTSFT); - frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (qi32 + ti32 + CFFTRND2), 1 + CFFTSFT); - } - } - - --k; - l = istep; - } - } - return 0; -} - -int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode) -{ - int i, j, l, k, istep, n, m, scale, shift; - WebRtc_Word16 wr, wi; - WebRtc_Word32 tr32, ti32, qr32, qi32; - WebRtc_Word32 tmp32, round2; - - /* The 1024-value is a constant given from the size of kSinTable1024[], - * and should not be changed depending on the input parameter 'stages' - */ - n = 1 << stages; - if (n > 1024) - return -1; - - scale = 0; - - l = 1; - k = 10 - 1; /* Constant for given kSinTable1024[]. Do not change - depending on the input parameter 'stages' */ - - while (l < n) - { - // variable scaling, depending upon data - shift = 0; - round2 = 8192; - - tmp32 = (WebRtc_Word32)WebRtcSpl_MaxAbsValueW16(frfi, 2 * n); - if (tmp32 > 13573) - { - shift++; - scale++; - round2 <<= 1; - } - if (tmp32 > 27146) - { - shift++; - scale++; - round2 <<= 1; - } - - istep = l << 1; - - if (mode == 0) - { - // mode==0: Low-complexity and Low-accuracy mode - for (m = 0; m < l; ++m) - { - j = m << k; - - /* The 256-value is a constant given as 1/4 of the size of - * kSinTable1024[], and should not be changed depending on the input - * parameter 'stages'. It will result in 0 <= j < N_SINE_WAVE/2 - */ - wr = kSinTable1024[j + 256]; - wi = kSinTable1024[j]; - - for (i = m; i < n; i += istep) - { - j = i + l; - - tr32 = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16_RSFT(wr, frfi[2 * j], 0) - - WEBRTC_SPL_MUL_16_16_RSFT(wi, frfi[2 * j + 1], 0)), 15); - - ti32 = WEBRTC_SPL_RSHIFT_W32( - (WEBRTC_SPL_MUL_16_16_RSFT(wr, frfi[2 * j + 1], 0) - + WEBRTC_SPL_MUL_16_16_RSFT(wi,frfi[2*j],0)), 15); - - qr32 = (WebRtc_Word32)frfi[2 * i]; - qi32 = (WebRtc_Word32)frfi[2 * i + 1]; - frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 - tr32, shift); - frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 - ti32, shift); - frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 + tr32, shift); - frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 + ti32, shift); - } - } - } else - { - // mode==1: High-complexity and High-accuracy mode - - for (m = 0; m < l; ++m) - { - j = m << k; - - /* The 256-value is a constant given as 1/4 of the size of - * kSinTable1024[], and should not be changed depending on the input - * parameter 'stages'. It will result in 0 <= j < N_SINE_WAVE/2 - */ - wr = kSinTable1024[j + 256]; - wi = kSinTable1024[j]; - -#ifdef WEBRTC_ARCH_ARM_V7 - WebRtc_Word32 wri; - WebRtc_Word32 frfi_r; - __asm__("pkhbt %0, %1, %2, lsl #16" : "=r"(wri) : - "r"((WebRtc_Word32)wr), "r"((WebRtc_Word32)wi)); -#endif - - for (i = m; i < n; i += istep) - { - j = i + l; - -#ifdef WEBRTC_ARCH_ARM_V7 - __asm__("pkhbt %0, %1, %2, lsl #16" : "=r"(frfi_r) : - "r"((WebRtc_Word32)frfi[2*j]), "r"((WebRtc_Word32)frfi[2*j +1])); - __asm__("smlsd %0, %1, %2, %3" : "=r"(tr32) : - "r"(wri), "r"(frfi_r), "r"(CIFFTRND)); - __asm__("smladx %0, %1, %2, %3" : "=r"(ti32) : - "r"(wri), "r"(frfi_r), "r"(CIFFTRND)); -#else - - tr32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j]) - - WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j + 1]) + CIFFTRND; - - ti32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1]) - + WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j]) + CIFFTRND; -#endif - tr32 = WEBRTC_SPL_RSHIFT_W32(tr32, 15 - CIFFTSFT); - ti32 = WEBRTC_SPL_RSHIFT_W32(ti32, 15 - CIFFTSFT); - - qr32 = ((WebRtc_Word32)frfi[2 * i]) << CIFFTSFT; - qi32 = ((WebRtc_Word32)frfi[2 * i + 1]) << CIFFTSFT; - - frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((qr32 - tr32+round2), - shift+CIFFTSFT); - frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (qi32 - ti32 + round2), shift + CIFFTSFT); - frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((qr32 + tr32 + round2), - shift + CIFFTSFT); - frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (qi32 + ti32 + round2), shift + CIFFTSFT); - } - } - - } - --k; - l = istep; - } - return scale; -}
diff --git a/src/common_audio/signal_processing/copy_set_operations.c b/src/common_audio/signal_processing/copy_set_operations.c deleted file mode 100644 index 8247337..0000000 --- a/src/common_audio/signal_processing/copy_set_operations.c +++ /dev/null
@@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the implementation of functions - * WebRtcSpl_MemSetW16() - * WebRtcSpl_MemSetW32() - * WebRtcSpl_MemCpyReversedOrder() - * WebRtcSpl_CopyFromEndW16() - * WebRtcSpl_ZerosArrayW16() - * WebRtcSpl_ZerosArrayW32() - * WebRtcSpl_OnesArrayW16() - * WebRtcSpl_OnesArrayW32() - * - * The description header can be found in signal_processing_library.h - * - */ - -#include <string.h> -#include "signal_processing_library.h" - - -void WebRtcSpl_MemSetW16(WebRtc_Word16 *ptr, WebRtc_Word16 set_value, int length) -{ - int j; - WebRtc_Word16 *arrptr = ptr; - - for (j = length; j > 0; j--) - { - *arrptr++ = set_value; - } -} - -void WebRtcSpl_MemSetW32(WebRtc_Word32 *ptr, WebRtc_Word32 set_value, int length) -{ - int j; - WebRtc_Word32 *arrptr = ptr; - - for (j = length; j > 0; j--) - { - *arrptr++ = set_value; - } -} - -void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* dest, WebRtc_Word16* source, int length) -{ - int j; - WebRtc_Word16* destPtr = dest; - WebRtc_Word16* sourcePtr = source; - - for (j = 0; j < length; j++) - { - *destPtr-- = *sourcePtr++; - } -} - -WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16 *vector_in, - WebRtc_Word16 length, - WebRtc_Word16 samples, - WebRtc_Word16 *vector_out) -{ - // Copy the last <samples> of the input vector to vector_out - WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples); - - return samples; -} - -WebRtc_Word16 WebRtcSpl_ZerosArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length) -{ - WebRtcSpl_MemSetW16(vector, 0, length); - return length; -} - -WebRtc_Word16 WebRtcSpl_ZerosArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length) -{ - WebRtcSpl_MemSetW32(vector, 0, length); - return length; -} - -WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length) -{ - WebRtc_Word16 i; - WebRtc_Word16 *tmpvec = vector; - for (i = 0; i < length; i++) - { - *tmpvec++ = 1; - } - return length; -} - -WebRtc_Word16 WebRtcSpl_OnesArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length) -{ - WebRtc_Word16 i; - WebRtc_Word32 *tmpvec = vector; - for (i = 0; i < length; i++) - { - *tmpvec++ = 1; - } - return length; -}
diff --git a/src/common_audio/signal_processing/cross_correlation.c b/src/common_audio/signal_processing/cross_correlation.c deleted file mode 100644 index cf7705c..0000000 --- a/src/common_audio/signal_processing/cross_correlation.c +++ /dev/null
@@ -1,30 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_CrossCorrelation(int32_t* cross_correlation, - const int16_t* seq1, - const int16_t* seq2, - int16_t dim_seq, - int16_t dim_cross_correlation, - int16_t right_shifts, - int16_t step_seq2) { - int i = 0, j = 0; - - for (i = 0; i < dim_cross_correlation; i++) { - *cross_correlation = 0; - /* Unrolling doesn't seem to improve performance. */ - for (j = 0; j < dim_seq; j++) { - *cross_correlation += (seq1[j] * seq2[step_seq2 * i + j]) >> right_shifts; - } - cross_correlation++; - } -}
diff --git a/src/common_audio/signal_processing/cross_correlation_neon.s b/src/common_audio/signal_processing/cross_correlation_neon.s deleted file mode 100644 index e9b1c69..0000000 --- a/src/common_audio/signal_processing/cross_correlation_neon.s +++ /dev/null
@@ -1,168 +0,0 @@ -@ -@ Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ cross_correlation_neon.s -@ This file contains the function WebRtcSpl_CrossCorrelation(), -@ optimized for ARM Neon platform. -@ -@ Reference Ccode at end of this file. -@ Output is bit-exact with the reference C code, but not with the generic -@ C code in file cross_correlation.c, due to reduction of shift operations -@ from using Neon registers. - -@ Register usage: -@ -@ r0: *cross_correlation (function argument) -@ r1: *seq1 (function argument) -@ r2: *seq2 (function argument) -@ r3: dim_seq (function argument); then, total iteration of LOOP_DIM_SEQ -@ r4: counter for LOOP_DIM_CROSS_CORRELATION -@ r5: seq2_ptr -@ r6: seq1_ptr -@ r7: Total iteration of LOOP_DIM_SEQ_RESIDUAL -@ r8, r9, r10, r11, r12: scratch - -.arch armv7-a -.fpu neon - -.align 2 -.global WebRtcSpl_CrossCorrelation - -WebRtcSpl_CrossCorrelation: - -.fnstart - -.save {r4-r11} - push {r4-r11} - - @ Put the shift value (-right_shifts) into a Neon register. - ldrsh r10, [sp, #36] - rsb r10, r10, #0 - mov r8, r10, asr #31 - vmov.32 d16, r10, r8 - - @ Initialize loop counters. - and r7, r3, #7 @ inner_loop_len2 = dim_seq % 8; - asr r3, r3, #3 @ inner_loop_len1 = dim_seq / 8; - ldrsh r4, [sp, #32] @ dim_cross_correlation - -LOOP_DIM_CROSS_CORRELATION: - vmov.i32 q9, #0 - vmov.i32 q14, #0 - movs r8, r3 @ inner_loop_len1 - mov r6, r1 @ seq1_ptr - mov r5, r2 @ seq2_ptr - ble POST_LOOP_DIM_SEQ - -LOOP_DIM_SEQ: - vld1.16 {d20, d21}, [r6]! @ seq1_ptr - vld1.16 {d22, d23}, [r5]! @ seq2_ptr - subs r8, r8, #1 - vmull.s16 q12, d20, d22 - vmull.s16 q13, d21, d23 - vpadal.s32 q9, q12 - vpadal.s32 q14, q13 - bgt LOOP_DIM_SEQ - -POST_LOOP_DIM_SEQ: - movs r10, r7 @ Loop counter - mov r12, #0 - mov r8, #0 - ble POST_LOOP_DIM_SEQ_RESIDUAL - -LOOP_DIM_SEQ_RESIDUAL: - ldrh r11, [r6], #2 - ldrh r9, [r5], #2 - smulbb r11, r11, r9 - adds r8, r8, r11 - adc r12, r12, r11, asr #31 - subs r10, #1 - bgt LOOP_DIM_SEQ_RESIDUAL - -POST_LOOP_DIM_SEQ_RESIDUAL: @ Sum the results up and do the shift. - vadd.i64 d18, d19 - vadd.i64 d28, d29 - vadd.i64 d18, d28 - vmov.32 d17[0], r8 - vmov.32 d17[1], r12 - vadd.i64 d17, d18 - vshl.s64 d17, d16 - vst1.32 d17[0], [r0]! @ Store the output - - ldr r8, [sp, #40] @ step_seq2 - add r2, r8, lsl #1 @ prepare for seq2_ptr(r5) in the next loop. - - subs r4, #1 - bgt LOOP_DIM_CROSS_CORRELATION - - pop {r4-r11} - bx lr - -.fnend - - -@ TODO(kma): Place this piece of reference code into a C code file. -@ void WebRtcSpl_CrossCorrelation(WebRtc_Word32* cross_correlation, -@ WebRtc_Word16* seq1, -@ WebRtc_Word16* seq2, -@ WebRtc_Word16 dim_seq, -@ WebRtc_Word16 dim_cross_correlation, -@ WebRtc_Word16 right_shifts, -@ WebRtc_Word16 step_seq2) { -@ int i = 0; -@ int j = 0; -@ int inner_loop_len1 = dim_seq >> 3; -@ int inner_loop_len2 = dim_seq - (inner_loop_len1 << 3); -@ -@ assert(dim_cross_correlation > 0); -@ assert(dim_seq > 0); -@ -@ for (i = 0; i < dim_cross_correlation; i++) { -@ int16_t *seq1_ptr = seq1; -@ int16_t *seq2_ptr = seq2 + (step_seq2 * i); -@ int64_t sum = 0; -@ -@ for (j = inner_loop_len1; j > 0; j -= 1) { -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ } -@ -@ // Calculate the rest of the samples. -@ for (j = inner_loop_len2; j > 0; j -= 1) { -@ sum += WEBRTC_SPL_MUL_16_16(*seq1_ptr, *seq2_ptr); -@ seq1_ptr++; -@ seq2_ptr++; -@ } -@ -@ *cross_correlation++ = (int32_t)(sum >> right_shifts); -@ } -@ }
diff --git a/src/common_audio/signal_processing/division_operations.c b/src/common_audio/signal_processing/division_operations.c deleted file mode 100644 index b143373..0000000 --- a/src/common_audio/signal_processing/division_operations.c +++ /dev/null
@@ -1,144 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains implementations of the divisions - * WebRtcSpl_DivU32U16() - * WebRtcSpl_DivW32W16() - * WebRtcSpl_DivW32W16ResW16() - * WebRtcSpl_DivResultInQ31() - * WebRtcSpl_DivW32HiLow() - * - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -WebRtc_UWord32 WebRtcSpl_DivU32U16(WebRtc_UWord32 num, WebRtc_UWord16 den) -{ - // Guard against division with 0 - if (den != 0) - { - return (WebRtc_UWord32)(num / den); - } else - { - return (WebRtc_UWord32)0xFFFFFFFF; - } -} - -WebRtc_Word32 WebRtcSpl_DivW32W16(WebRtc_Word32 num, WebRtc_Word16 den) -{ - // Guard against division with 0 - if (den != 0) - { - return (WebRtc_Word32)(num / den); - } else - { - return (WebRtc_Word32)0x7FFFFFFF; - } -} - -WebRtc_Word16 WebRtcSpl_DivW32W16ResW16(WebRtc_Word32 num, WebRtc_Word16 den) -{ - // Guard against division with 0 - if (den != 0) - { - return (WebRtc_Word16)(num / den); - } else - { - return (WebRtc_Word16)0x7FFF; - } -} - -WebRtc_Word32 WebRtcSpl_DivResultInQ31(WebRtc_Word32 num, WebRtc_Word32 den) -{ - WebRtc_Word32 L_num = num; - WebRtc_Word32 L_den = den; - WebRtc_Word32 div = 0; - int k = 31; - int change_sign = 0; - - if (num == 0) - return 0; - - if (num < 0) - { - change_sign++; - L_num = -num; - } - if (den < 0) - { - change_sign++; - L_den = -den; - } - while (k--) - { - div <<= 1; - L_num <<= 1; - if (L_num >= L_den) - { - L_num -= L_den; - div++; - } - } - if (change_sign == 1) - { - div = -div; - } - return div; -} - -WebRtc_Word32 WebRtcSpl_DivW32HiLow(WebRtc_Word32 num, WebRtc_Word16 den_hi, - WebRtc_Word16 den_low) -{ - WebRtc_Word16 approx, tmp_hi, tmp_low, num_hi, num_low; - WebRtc_Word32 tmpW32; - - approx = (WebRtc_Word16)WebRtcSpl_DivW32W16((WebRtc_Word32)0x1FFFFFFF, den_hi); - // result in Q14 (Note: 3FFFFFFF = 0.5 in Q30) - - // tmpW32 = 1/den = approx * (2.0 - den * approx) (in Q30) - tmpW32 = (WEBRTC_SPL_MUL_16_16(den_hi, approx) << 1) - + ((WEBRTC_SPL_MUL_16_16(den_low, approx) >> 15) << 1); - // tmpW32 = den * approx - - tmpW32 = (WebRtc_Word32)0x7fffffffL - tmpW32; // result in Q30 (tmpW32 = 2.0-(den*approx)) - - // Store tmpW32 in hi and low format - tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); - tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - - // tmpW32 = 1/den in Q29 - tmpW32 = ((WEBRTC_SPL_MUL_16_16(tmp_hi, approx) + (WEBRTC_SPL_MUL_16_16(tmp_low, approx) - >> 15)) << 1); - - // 1/den in hi and low format - tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); - tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - - // Store num in hi and low format - num_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(num, 16); - num_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((num - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)num_hi, 16)), 1); - - // num * (1/den) by 32 bit multiplication (result in Q28) - - tmpW32 = (WEBRTC_SPL_MUL_16_16(num_hi, tmp_hi) + (WEBRTC_SPL_MUL_16_16(num_hi, tmp_low) - >> 15) + (WEBRTC_SPL_MUL_16_16(num_low, tmp_hi) >> 15)); - - // Put result in Q31 (convert from Q28) - tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3); - - return tmpW32; -}
diff --git a/src/common_audio/signal_processing/dot_product_with_scale.c b/src/common_audio/signal_processing/dot_product_with_scale.c deleted file mode 100644 index 4868260..0000000 --- a/src/common_audio/signal_processing/dot_product_with_scale.c +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "signal_processing_library.h" - -int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, - const int16_t* vector2, - int length, - int scaling) { - int32_t sum = 0; - int i = 0; - - /* Unroll the loop to improve performance. */ - for (i = 0; i < length - 3; i += 4) { - sum += (vector1[i + 0] * vector2[i + 0]) >> scaling; - sum += (vector1[i + 1] * vector2[i + 1]) >> scaling; - sum += (vector1[i + 2] * vector2[i + 2]) >> scaling; - sum += (vector1[i + 3] * vector2[i + 3]) >> scaling; - } - for (; i < length; i++) { - sum += (vector1[i] * vector2[i]) >> scaling; - } - - return sum; -}
diff --git a/src/common_audio/signal_processing/downsample_fast.c b/src/common_audio/signal_processing/downsample_fast.c deleted file mode 100644 index 526cdca..0000000 --- a/src/common_audio/signal_processing/downsample_fast.c +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "signal_processing_library.h" - -// TODO(Bjornv): Change the function parameter order to WebRTC code style. -int WebRtcSpl_DownsampleFast(const int16_t* data_in, - int data_in_length, - int16_t* data_out, - int data_out_length, - const int16_t* __restrict coefficients, - int coefficients_length, - int factor, - int delay) { - int i = 0; - int j = 0; - int32_t out_s32 = 0; - int endpos = delay + factor * (data_out_length - 1) + 1; - - // Return error if any of the running conditions doesn't meet. - if (data_out_length <= 0 || coefficients_length <= 0 - || data_in_length < endpos) { - return -1; - } - - for (i = delay; i < endpos; i += factor) { - out_s32 = 2048; // Round value, 0.5 in Q12. - - for (j = 0; j < coefficients_length; j++) { - out_s32 += coefficients[j] * data_in[i - j]; // Q12. - } - - out_s32 >>= 12; // Q0. - - // Saturate and store the output. - *data_out++ = WebRtcSpl_SatW32ToW16(out_s32); - } - - return 0; -}
diff --git a/src/common_audio/signal_processing/downsample_fast_neon.s b/src/common_audio/signal_processing/downsample_fast_neon.s deleted file mode 100644 index 906b0a1..0000000 --- a/src/common_audio/signal_processing/downsample_fast_neon.s +++ /dev/null
@@ -1,222 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ This file contains the function WebRtcSpl_DownsampleFast(), optimized for -@ ARM Neon platform. The description header can be found in -@ signal_processing_library.h -@ -@ The reference C code is in file downsample_fast.c. Bit-exact. - -.arch armv7-a -.fpu neon - -.align 2 -.global WebRtcSpl_DownsampleFast - -WebRtcSpl_DownsampleFast: - -.fnstart - -.save {r4-r11} - push {r4-r11} - - cmp r3, #0 @ data_out_length <= 0? - movle r0, #-1 - ble END - - ldrsh r12, [sp, #44] - ldr r5, [sp, #40] @ r5: factor - add r4, r12, #1 @ r4: delay + 1 - sub r3, r3, #1 @ r3: data_out_length - 1 - smulbb r3, r5, r3 - ldr r8, [sp, #32] @ &coefficients[0] - mov r9, r12 @ Iteration counter for outer loops. - add r3, r4 @ delay + factor * (out_length-1) +1 - - cmp r3, r1 @ data_in_length < endpos? - movgt r0, #-1 - bgt END - - @ Initializations. - sub r3, r5, asl #3 - add r11, r0, r12, asl #1 @ &data_in[delay] - ldr r0, [sp, #36] @ coefficients_length - add r3, r5 @ endpos - factor * 7 - - cmp r0, #0 @ coefficients_length <= 0 ? - movle r0, #-1 - ble END - - add r8, r0, asl #1 @ &coeffieient[coefficients_length] - cmp r9, r3 - bge POST_LOOP_ENDPOS @ branch when Iteration < 8 times. - -@ -@ First part, unroll the loop 8 times, with 3 subcases (factor == 2, 4, others) -@ - mov r4, #-2 - - @ Direct program flow to the right channel. - - @ r10 is an offset to &data_in[] in the loop. After an iteration, we need to - @ move the pointer back to original after advancing 16 bytes by a vld1, and - @ then move 2 bytes forward to increment one more sample. - cmp r5, #2 - moveq r10, #-14 - beq LOOP_ENDPOS_FACTOR2 @ Branch when factor == 2 - - @ Similar here, for r10, we need to move the pointer back to original after - @ advancing 32 bytes, then move 2 bytes forward to increment one sample. - cmp r5, #4 - moveq r10, #-30 - beq LOOP_ENDPOS_FACTOR4 @ Branch when factor == 4 - - @ For r10, we need to move the pointer back to original after advancing - @ (factor * 7 * 2) bytes, then move 2 bytes forward to increment one sample. - mov r10, r5, asl #4 - rsb r10, #2 - add r10, r5, asl #1 - lsl r5, #1 @ r5 = factor * sizeof(data_in) - -@ The general case (factor != 2 && factor != 4) -LOOP_ENDPOS_GENERAL: - @ Initializations. - vmov.i32 q2, #2048 - vmov.i32 q3, #2048 - sub r7, r8, #2 - sub r12, r0, #1 @ coefficients_length - 1 - sub r1, r11, r12, asl #1 @ &data_in[i - j] - -LOOP_COEFF_LENGTH_GENERAL: - vld1.16 {d2[], d3[]}, [r7], r4 @ coefficients[j] - vld1.16 d0[0], [r1], r5 @ data_in[i - j] - vld1.16 d0[1], [r1], r5 @ data_in[i + factor - j] - vld1.16 d0[2], [r1], r5 @ data_in[i + factor * 2 - j] - vld1.16 d0[3], [r1], r5 @ data_in[i + factor * 3 - j] - vld1.16 d1[0], [r1], r5 @ data_in[i + factor * 4 - j] - vld1.16 d1[1], [r1], r5 @ data_in[i + factor * 5 - j] - vld1.16 d1[2], [r1], r5 @ data_in[i + factor * 6 - j] - vld1.16 d1[3], [r1], r10 @ data_in[i + factor * 7 - j] - subs r12, #1 - vmlal.s16 q2, d0, d2 - vmlal.s16 q3, d1, d3 - bge LOOP_COEFF_LENGTH_GENERAL - - @ Shift, saturate, and store the result. - vqshrn.s32 d0, q2, #12 - vqshrn.s32 d1, q3, #12 - vst1.16 {d0, d1}, [r2]! - - add r11, r5, asl #3 @ r11 -> &data_in[i + factor * 8] - add r9, r5, asl #2 @ Counter i = delay + factor * 8. - cmp r9, r3 @ i < endpos - factor * 7 ? - blt LOOP_ENDPOS_GENERAL - asr r5, #1 @ Restore r5 to the value of factor. - b POST_LOOP_ENDPOS - -@ The case for factor == 2. -LOOP_ENDPOS_FACTOR2: - @ Initializations. - vmov.i32 q2, #2048 - vmov.i32 q3, #2048 - sub r7, r8, #2 - sub r12, r0, #1 @ coefficients_length - 1 - sub r1, r11, r12, asl #1 @ &data_in[i - j] - -LOOP_COEFF_LENGTH_FACTOR2: - vld1.16 {d16[], d17[]}, [r7], r4 @ coefficients[j] - vld2.16 {d0, d1}, [r1]! @ data_in[] - vld2.16 {d2, d3}, [r1], r10 @ data_in[] - subs r12, #1 - vmlal.s16 q2, d0, d16 - vmlal.s16 q3, d2, d17 - bge LOOP_COEFF_LENGTH_FACTOR2 - - @ Shift, saturate, and store the result. - vqshrn.s32 d0, q2, #12 - vqshrn.s32 d1, q3, #12 - vst1.16 {d0, d1}, [r2]! - - add r11, r5, asl #4 @ r11 -> &data_in[i + factor * 8] - add r9, r5, asl #3 @ Counter i = delay + factor * 8. - cmp r9, r3 @ i < endpos - factor * 7 ? - blt LOOP_ENDPOS_FACTOR2 - b POST_LOOP_ENDPOS - -@ The case for factor == 4. -LOOP_ENDPOS_FACTOR4: - @ Initializations. - vmov.i32 q2, #2048 - vmov.i32 q3, #2048 - sub r7, r8, #2 - sub r12, r0, #1 @ coefficients_length - 1 - sub r1, r11, r12, asl #1 @ &data_in[i - j] - -LOOP_COEFF_LENGTH_FACTOR4: - vld1.16 {d16[], d17[]}, [r7], r4 @ coefficients[j] - vld4.16 {d0, d1, d2, d3}, [r1]! @ data_in[] - vld4.16 {d18, d19, d20, d21}, [r1], r10 @ data_in[] - subs r12, #1 - vmlal.s16 q2, d0, d16 - vmlal.s16 q3, d18, d17 - bge LOOP_COEFF_LENGTH_FACTOR4 - - @ Shift, saturate, and store the result. - vqshrn.s32 d0, q2, #12 - vqshrn.s32 d1, q3, #12 - vst1.16 {d0, d1}, [r2]! - - add r11, r5, asl #4 @ r11 -> &data_in[i + factor * 8] - add r9, r5, asl #3 @ Counter i = delay + factor * 8. - cmp r9, r3 @ i < endpos - factor * 7 ? - blt LOOP_ENDPOS_FACTOR4 - -@ -@ Second part, do the rest iterations (if any). -@ - -POST_LOOP_ENDPOS: - add r3, r5, asl #3 - sub r3, r5 @ Restore r3 to endpos. - cmp r9, r3 - movge r0, #0 - bge END - -LOOP2_ENDPOS: - @ Initializations. - mov r7, r8 - sub r12, r0, #1 @ coefficients_length - 1 - sub r6, r11, r12, asl #1 @ &data_in[i - j] - - mov r1, #2048 - -LOOP2_COEFF_LENGTH: - ldrsh r4, [r7, #-2]! @ coefficients[j] - ldrsh r10, [r6], #2 @ data_in[i - j] - smlabb r1, r4, r10, r1 - subs r12, #1 - bge LOOP2_COEFF_LENGTH - - @ Shift, saturate, and store the result. - ssat r1, #16, r1, asr #12 - strh r1, [r2], #2 - - add r11, r5, asl #1 @ r11 -> &data_in[i + factor] - add r9, r5 @ Counter i = delay + factor. - cmp r9, r3 @ i < endpos? - blt LOOP2_ENDPOS - - mov r0, #0 - -END: - pop {r4-r11} - bx lr - -.fnend
diff --git a/src/common_audio/signal_processing/energy.c b/src/common_audio/signal_processing/energy.c deleted file mode 100644 index e8fdf94..0000000 --- a/src/common_audio/signal_processing/energy.c +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_Energy(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -WebRtc_Word32 WebRtcSpl_Energy(WebRtc_Word16* vector, int vector_length, int* scale_factor) -{ - WebRtc_Word32 en = 0; - int i; - int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); - int looptimes = vector_length; - WebRtc_Word16 *vectorptr = vector; - - for (i = 0; i < looptimes; i++) - { - en += WEBRTC_SPL_MUL_16_16_RSFT(*vectorptr, *vectorptr, scaling); - vectorptr++; - } - *scale_factor = scaling; - - return en; -}
diff --git a/src/common_audio/signal_processing/filter_ar.c b/src/common_audio/signal_processing/filter_ar.c deleted file mode 100644 index 24e83a6..0000000 --- a/src/common_audio/signal_processing/filter_ar.c +++ /dev/null
@@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_FilterAR(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -int WebRtcSpl_FilterAR(G_CONST WebRtc_Word16* a, - int a_length, - G_CONST WebRtc_Word16* x, - int x_length, - WebRtc_Word16* state, - int state_length, - WebRtc_Word16* state_low, - int state_low_length, - WebRtc_Word16* filtered, - WebRtc_Word16* filtered_low, - int filtered_low_length) -{ - WebRtc_Word32 o; - WebRtc_Word32 oLOW; - int i, j, stop; - G_CONST WebRtc_Word16* x_ptr = &x[0]; - WebRtc_Word16* filteredFINAL_ptr = filtered; - WebRtc_Word16* filteredFINAL_LOW_ptr = filtered_low; - - for (i = 0; i < x_length; i++) - { - // Calculate filtered[i] and filtered_low[i] - G_CONST WebRtc_Word16* a_ptr = &a[1]; - WebRtc_Word16* filtered_ptr = &filtered[i - 1]; - WebRtc_Word16* filtered_low_ptr = &filtered_low[i - 1]; - WebRtc_Word16* state_ptr = &state[state_length - 1]; - WebRtc_Word16* state_low_ptr = &state_low[state_length - 1]; - - o = (WebRtc_Word32)(*x_ptr++) << 12; - oLOW = (WebRtc_Word32)0; - - stop = (i < a_length) ? i + 1 : a_length; - for (j = 1; j < stop; j++) - { - o -= WEBRTC_SPL_MUL_16_16(*a_ptr, *filtered_ptr--); - oLOW -= WEBRTC_SPL_MUL_16_16(*a_ptr++, *filtered_low_ptr--); - } - for (j = i + 1; j < a_length; j++) - { - o -= WEBRTC_SPL_MUL_16_16(*a_ptr, *state_ptr--); - oLOW -= WEBRTC_SPL_MUL_16_16(*a_ptr++, *state_low_ptr--); - } - - o += (oLOW >> 12); - *filteredFINAL_ptr = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); - *filteredFINAL_LOW_ptr++ = (WebRtc_Word16)(o - ((WebRtc_Word32)(*filteredFINAL_ptr++) - << 12)); - } - - // Save the filter state - if (x_length >= state_length) - { - WebRtcSpl_CopyFromEndW16(filtered, x_length, a_length - 1, state); - WebRtcSpl_CopyFromEndW16(filtered_low, x_length, a_length - 1, state_low); - } else - { - for (i = 0; i < state_length - x_length; i++) - { - state[i] = state[i + x_length]; - state_low[i] = state_low[i + x_length]; - } - for (i = 0; i < x_length; i++) - { - state[state_length - x_length + i] = filtered[i]; - state[state_length - x_length + i] = filtered_low[i]; - } - } - - return x_length; -}
diff --git a/src/common_audio/signal_processing/filter_ar_fast_q12.c b/src/common_audio/signal_processing/filter_ar_fast_q12.c deleted file mode 100644 index 0402302..0000000 --- a/src/common_audio/signal_processing/filter_ar_fast_q12.c +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include <assert.h> - -#include "signal_processing_library.h" - -// TODO(bjornv): Change the return type to report errors. - -void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, - int16_t* data_out, - const int16_t* __restrict coefficients, - int coefficients_length, - int data_length) { - int i = 0; - int j = 0; - - assert(data_length > 0); - assert(coefficients_length > 1); - - for (i = 0; i < data_length; i++) { - int32_t output = 0; - int32_t sum = 0; - - for (j = coefficients_length - 1; j > 0; j--) { - sum += coefficients[j] * data_out[i - j]; - } - - output = coefficients[0] * data_in[i]; - output -= sum; - - // Saturate and store the output. - output = WEBRTC_SPL_SAT(134215679, output, -134217728); - data_out[i] = (int16_t)((output + 2048) >> 12); - } -} -
diff --git a/src/common_audio/signal_processing/filter_ar_fast_q12_armv7.s b/src/common_audio/signal_processing/filter_ar_fast_q12_armv7.s deleted file mode 100644 index 5591bb8..0000000 --- a/src/common_audio/signal_processing/filter_ar_fast_q12_armv7.s +++ /dev/null
@@ -1,223 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ This file contains the function WebRtcSpl_FilterARFastQ12(), optimized for -@ ARMv7 platform. The description header can be found in -@ signal_processing_library.h -@ -@ Output is bit-exact with the generic C code as in filter_ar_fast_q12.c, and -@ the reference C code at end of this file. - -@ Assumptions: -@ (1) data_length > 0 -@ (2) coefficients_length > 1 - -@ Register usage: -@ -@ r0: &data_in[i] -@ r1: &data_out[i], for result ouput -@ r2: &coefficients[0] -@ r3: coefficients_length -@ r4: Iteration counter for the outer loop. -@ r5: data_out[j] as multiplication inputs -@ r6: Calculated value for output data_out[]; interation counter for inner loop -@ r7: Partial sum of a filtering multiplication results -@ r8: Partial sum of a filtering multiplication results -@ r9: &data_out[], for filtering input; data_in[i] -@ r10: coefficients[j] -@ r11: Scratch -@ r12: &coefficients[j] - -.arch armv7-a - -.align 2 -.global WebRtcSpl_FilterARFastQ12 - -WebRtcSpl_FilterARFastQ12: - -.fnstart - -.save {r4-r11} - push {r4-r11} - - ldrsh r12, [sp, #32] @ data_length - subs r4, r12, #1 - beq ODD_LENGTH @ jump if data_length == 1 - -LOOP_LENGTH: - add r12, r2, r3, lsl #1 - sub r12, #4 @ &coefficients[coefficients_length - 2] - sub r9, r1, r3, lsl #1 - add r9, #2 @ &data_out[i - coefficients_length + 1] - ldr r5, [r9], #4 @ data_out[i - coefficients_length + {1,2}] - - mov r7, #0 @ sum1 - mov r8, #0 @ sum2 - subs r6, r3, #3 @ Iteration counter for inner loop. - beq ODD_A_LENGTH @ branch if coefficients_length == 3 - blt POST_LOOP_A_LENGTH @ branch if coefficients_length == 2 - -LOOP_A_LENGTH: - ldr r10, [r12], #-4 @ coefficients[j - 1], coefficients[j] - subs r6, #2 - smlatt r8, r10, r5, r8 @ sum2 += coefficients[j] * data_out[i - j + 1]; - smlatb r7, r10, r5, r7 @ sum1 += coefficients[j] * data_out[i - j]; - smlabt r7, r10, r5, r7 @ coefficients[j - 1] * data_out[i - j + 1]; - ldr r5, [r9], #4 @ data_out[i - j + 2], data_out[i - j + 3] - smlabb r8, r10, r5, r8 @ coefficients[j - 1] * data_out[i - j + 2]; - bgt LOOP_A_LENGTH - blt POST_LOOP_A_LENGTH - -ODD_A_LENGTH: - ldrsh r10, [r12, #2] @ Filter coefficients coefficients[2] - sub r12, #2 @ &coefficients[0] - smlabb r7, r10, r5, r7 @ sum1 += coefficients[2] * data_out[i - 2]; - smlabt r8, r10, r5, r8 @ sum2 += coefficients[2] * data_out[i - 1]; - ldr r5, [r9, #-2] @ data_out[i - 1], data_out[i] - -POST_LOOP_A_LENGTH: - ldr r10, [r12] @ coefficients[0], coefficients[1] - smlatb r7, r10, r5, r7 @ sum1 += coefficients[1] * data_out[i - 1]; - - ldr r9, [r0], #4 @ data_in[i], data_in[i + 1] - smulbb r6, r10, r9 @ output1 = coefficients[0] * data_in[i]; - sub r6, r7 @ output1 -= sum1; - - sbfx r11, r6, #12, #16 - ssat r7, #16, r6, asr #12 - cmp r7, r11 - addeq r6, r6, #2048 - ssat r6, #16, r6, asr #12 - strh r6, [r1], #2 @ Store data_out[i] - - smlatb r8, r10, r6, r8 @ sum2 += coefficients[1] * data_out[i]; - smulbt r6, r10, r9 @ output2 = coefficients[0] * data_in[i + 1]; - sub r6, r8 @ output1 -= sum1; - - sbfx r11, r6, #12, #16 - ssat r7, #16, r6, asr #12 - cmp r7, r11 - addeq r6, r6, #2048 - ssat r6, #16, r6, asr #12 - strh r6, [r1], #2 @ Store data_out[i + 1] - - subs r4, #2 - bgt LOOP_LENGTH - blt END @ For even data_length, it's done. Jump to END. - -@ Process i = data_length -1, for the case of an odd length. -ODD_LENGTH: - add r12, r2, r3, lsl #1 - sub r12, #4 @ &coefficients[coefficients_length - 2] - sub r9, r1, r3, lsl #1 - add r9, #2 @ &data_out[i - coefficients_length + 1] - mov r7, #0 @ sum1 - mov r8, #0 @ sum1 - subs r6, r3, #2 @ inner loop counter - beq EVEN_A_LENGTH @ branch if coefficients_length == 2 - -LOOP2_A_LENGTH: - ldr r10, [r12], #-4 @ coefficients[j - 1], coefficients[j] - ldr r5, [r9], #4 @ data_out[i - j], data_out[i - j + 1] - subs r6, #2 - smlatb r7, r10, r5, r7 @ sum1 += coefficients[j] * data_out[i - j]; - smlabt r8, r10, r5, r8 @ coefficients[j - 1] * data_out[i - j + 1]; - bgt LOOP2_A_LENGTH - addlt r12, #2 - blt POST_LOOP2_A_LENGTH - -EVEN_A_LENGTH: - ldrsh r10, [r12, #2] @ Filter coefficients coefficients[1] - ldrsh r5, [r9] @ data_out[i - 1] - smlabb r7, r10, r5, r7 @ sum1 += coefficients[1] * data_out[i - 1]; - -POST_LOOP2_A_LENGTH: - ldrsh r10, [r12] @ Filter coefficients coefficients[0] - ldrsh r9, [r0] @ data_in[i] - smulbb r6, r10, r9 @ output1 = coefficients[0] * data_in[i]; - sub r6, r7 @ output1 -= sum1; - sub r6, r8 @ output1 -= sum1; - sbfx r8, r6, #12, #16 - ssat r7, #16, r6, asr #12 - cmp r7, r8 - addeq r6, r6, #2048 - ssat r6, #16, r6, asr #12 - strh r6, [r1] @ Store the data_out[i] - -END: - pop {r4-r11} - bx lr - -.fnend - - -@Reference C code: -@ -@void WebRtcSpl_FilterARFastQ12(int16_t* data_in, -@ int16_t* data_out, -@ int16_t* __restrict coefficients, -@ int coefficients_length, -@ int data_length) { -@ int i = 0; -@ int j = 0; -@ -@ for (i = 0; i < data_length - 1; i += 2) { -@ int32_t output1 = 0; -@ int32_t sum1 = 0; -@ int32_t output2 = 0; -@ int32_t sum2 = 0; -@ -@ for (j = coefficients_length - 1; j > 2; j -= 2) { -@ sum1 += coefficients[j] * data_out[i - j]; -@ sum1 += coefficients[j - 1] * data_out[i - j + 1]; -@ sum2 += coefficients[j] * data_out[i - j + 1]; -@ sum2 += coefficients[j - 1] * data_out[i - j + 2]; -@ } -@ -@ if (j == 2) { -@ sum1 += coefficients[2] * data_out[i - 2]; -@ sum2 += coefficients[2] * data_out[i - 1]; -@ } -@ -@ sum1 += coefficients[1] * data_out[i - 1]; -@ output1 = coefficients[0] * data_in[i]; -@ output1 -= sum1; -@ // Saturate and store the output. -@ output1 = WEBRTC_SPL_SAT(134215679, output1, -134217728); -@ data_out[i] = (int16_t)((output1 + 2048) >> 12); -@ -@ sum2 += coefficients[1] * data_out[i]; -@ output2 = coefficients[0] * data_in[i + 1]; -@ output2 -= sum2; -@ // Saturate and store the output. -@ output2 = WEBRTC_SPL_SAT(134215679, output2, -134217728); -@ data_out[i + 1] = (int16_t)((output2 + 2048) >> 12); -@ } -@ -@ if (i == data_length - 1) { -@ int32_t output1 = 0; -@ int32_t sum1 = 0; -@ -@ for (j = coefficients_length - 1; j > 1; j -= 2) { -@ sum1 += coefficients[j] * data_out[i - j]; -@ sum1 += coefficients[j - 1] * data_out[i - j + 1]; -@ } -@ -@ if (j == 1) { -@ sum1 += coefficients[1] * data_out[i - 1]; -@ } -@ -@ output1 = coefficients[0] * data_in[i]; -@ output1 -= sum1; -@ // Saturate and store the output. -@ output1 = WEBRTC_SPL_SAT(134215679, output1, -134217728); -@ data_out[i] = (int16_t)((output1 + 2048) >> 12); -@ } -@}
diff --git a/src/common_audio/signal_processing/filter_ma_fast_q12.c b/src/common_audio/signal_processing/filter_ma_fast_q12.c deleted file mode 100644 index 19ad9b1..0000000 --- a/src/common_audio/signal_processing/filter_ma_fast_q12.c +++ /dev/null
@@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_FilterMAFastQ12(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_FilterMAFastQ12(WebRtc_Word16* in_ptr, - WebRtc_Word16* out_ptr, - WebRtc_Word16* B, - WebRtc_Word16 B_length, - WebRtc_Word16 length) -{ - WebRtc_Word32 o; - int i, j; - for (i = 0; i < length; i++) - { - G_CONST WebRtc_Word16* b_ptr = &B[0]; - G_CONST WebRtc_Word16* x_ptr = &in_ptr[i]; - - o = (WebRtc_Word32)0; - - for (j = 0; j < B_length; j++) - { - o += WEBRTC_SPL_MUL_16_16(*b_ptr++, *x_ptr--); - } - - // If output is higher than 32768, saturate it. Same with negative side - // 2^27 = 134217728, which corresponds to 32768 in Q12 - - // Saturate the output - o = WEBRTC_SPL_SAT((WebRtc_Word32)134215679, o, (WebRtc_Word32)-134217728); - - *out_ptr++ = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); - } - return; -}
diff --git a/src/common_audio/signal_processing/get_hanning_window.c b/src/common_audio/signal_processing/get_hanning_window.c deleted file mode 100644 index 6d67e60..0000000 --- a/src/common_audio/signal_processing/get_hanning_window.c +++ /dev/null
@@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_GetHanningWindow(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -// Hanning table with 256 entries -static const WebRtc_Word16 kHanningTable[] = { - 1, 2, 6, 10, 15, 22, 30, 39, - 50, 62, 75, 89, 104, 121, 138, 157, - 178, 199, 222, 246, 271, 297, 324, 353, - 383, 413, 446, 479, 513, 549, 586, 624, - 663, 703, 744, 787, 830, 875, 920, 967, - 1015, 1064, 1114, 1165, 1218, 1271, 1325, 1381, - 1437, 1494, 1553, 1612, 1673, 1734, 1796, 1859, - 1924, 1989, 2055, 2122, 2190, 2259, 2329, 2399, - 2471, 2543, 2617, 2691, 2765, 2841, 2918, 2995, - 3073, 3152, 3232, 3312, 3393, 3475, 3558, 3641, - 3725, 3809, 3895, 3980, 4067, 4154, 4242, 4330, - 4419, 4509, 4599, 4689, 4781, 4872, 4964, 5057, - 5150, 5244, 5338, 5432, 5527, 5622, 5718, 5814, - 5910, 6007, 6104, 6202, 6299, 6397, 6495, 6594, - 6693, 6791, 6891, 6990, 7090, 7189, 7289, 7389, - 7489, 7589, 7690, 7790, 7890, 7991, 8091, 8192, - 8293, 8393, 8494, 8594, 8694, 8795, 8895, 8995, - 9095, 9195, 9294, 9394, 9493, 9593, 9691, 9790, - 9889, 9987, 10085, 10182, 10280, 10377, 10474, 10570, -10666, 10762, 10857, 10952, 11046, 11140, 11234, 11327, -11420, 11512, 11603, 11695, 11785, 11875, 11965, 12054, -12142, 12230, 12317, 12404, 12489, 12575, 12659, 12743, -12826, 12909, 12991, 13072, 13152, 13232, 13311, 13389, -13466, 13543, 13619, 13693, 13767, 13841, 13913, 13985, -14055, 14125, 14194, 14262, 14329, 14395, 14460, 14525, -14588, 14650, 14711, 14772, 14831, 14890, 14947, 15003, -15059, 15113, 15166, 15219, 15270, 15320, 15369, 15417, -15464, 15509, 15554, 15597, 15640, 15681, 15721, 15760, -15798, 15835, 15871, 15905, 15938, 15971, 16001, 16031, -16060, 16087, 16113, 16138, 16162, 16185, 16206, 16227, -16246, 16263, 16280, 16295, 16309, 16322, 16334, 16345, -16354, 16362, 16369, 16374, 16378, 16382, 16383, 16384 -}; - -void WebRtcSpl_GetHanningWindow(WebRtc_Word16 *v, WebRtc_Word16 size) -{ - int jj; - WebRtc_Word16 *vptr1; - - WebRtc_Word32 index; - WebRtc_Word32 factor = ((WebRtc_Word32)0x40000000); - - factor = WebRtcSpl_DivW32W16(factor, size); - if (size < 513) - index = (WebRtc_Word32)-0x200000; - else - index = (WebRtc_Word32)-0x100000; - vptr1 = v; - - for (jj = 0; jj < size; jj++) - { - index += factor; - (*vptr1++) = kHanningTable[index >> 22]; - } - -}
diff --git a/src/common_audio/signal_processing/get_scaling_square.c b/src/common_audio/signal_processing/get_scaling_square.c deleted file mode 100644 index dccbf33..0000000 --- a/src/common_audio/signal_processing/get_scaling_square.c +++ /dev/null
@@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_GetScalingSquare(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -int WebRtcSpl_GetScalingSquare(WebRtc_Word16 *in_vector, int in_vector_length, int times) -{ - int nbits = WebRtcSpl_GetSizeInBits(times); - int i; - WebRtc_Word16 smax = -1; - WebRtc_Word16 sabs; - WebRtc_Word16 *sptr = in_vector; - int t; - int looptimes = in_vector_length; - - for (i = looptimes; i > 0; i--) - { - sabs = (*sptr > 0 ? *sptr++ : -*sptr++); - smax = (sabs > smax ? sabs : smax); - } - t = WebRtcSpl_NormW32(WEBRTC_SPL_MUL(smax, smax)); - - if (smax == 0) - { - return 0; // Since norm(0) returns 0 - } else - { - return (t > nbits) ? 0 : nbits - t; - } -}
diff --git a/src/common_audio/signal_processing/ilbc_specific_functions.c b/src/common_audio/signal_processing/ilbc_specific_functions.c deleted file mode 100644 index 3588ba4..0000000 --- a/src/common_audio/signal_processing/ilbc_specific_functions.c +++ /dev/null
@@ -1,101 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains implementations of the iLBC specific functions - * WebRtcSpl_ReverseOrderMultArrayElements() - * WebRtcSpl_ElementwiseVectorMult() - * WebRtcSpl_AddVectorsAndShift() - * WebRtcSpl_AddAffineVectorToVector() - * WebRtcSpl_AffineTransformVector() - * - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_ReverseOrderMultArrayElements(WebRtc_Word16 *out, G_CONST WebRtc_Word16 *in, - G_CONST WebRtc_Word16 *win, - WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts) -{ - int i; - WebRtc_Word16 *outptr = out; - G_CONST WebRtc_Word16 *inptr = in; - G_CONST WebRtc_Word16 *winptr = win; - for (i = 0; i < vector_length; i++) - { - (*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, - *winptr--, right_shifts); - } -} - -void WebRtcSpl_ElementwiseVectorMult(WebRtc_Word16 *out, G_CONST WebRtc_Word16 *in, - G_CONST WebRtc_Word16 *win, WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts) -{ - int i; - WebRtc_Word16 *outptr = out; - G_CONST WebRtc_Word16 *inptr = in; - G_CONST WebRtc_Word16 *winptr = win; - for (i = 0; i < vector_length; i++) - { - (*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, - *winptr++, right_shifts); - } -} - -void WebRtcSpl_AddVectorsAndShift(WebRtc_Word16 *out, G_CONST WebRtc_Word16 *in1, - G_CONST WebRtc_Word16 *in2, WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts) -{ - int i; - WebRtc_Word16 *outptr = out; - G_CONST WebRtc_Word16 *in1ptr = in1; - G_CONST WebRtc_Word16 *in2ptr = in2; - for (i = vector_length; i > 0; i--) - { - (*outptr++) = (WebRtc_Word16)(((*in1ptr++) + (*in2ptr++)) >> right_shifts); - } -} - -void WebRtcSpl_AddAffineVectorToVector(WebRtc_Word16 *out, WebRtc_Word16 *in, - WebRtc_Word16 gain, WebRtc_Word32 add_constant, - WebRtc_Word16 right_shifts, int vector_length) -{ - WebRtc_Word16 *inPtr; - WebRtc_Word16 *outPtr; - int i; - - inPtr = in; - outPtr = out; - for (i = 0; i < vector_length; i++) - { - (*outPtr++) += (WebRtc_Word16)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) - + (WebRtc_Word32)add_constant) >> right_shifts); - } -} - -void WebRtcSpl_AffineTransformVector(WebRtc_Word16 *out, WebRtc_Word16 *in, - WebRtc_Word16 gain, WebRtc_Word32 add_constant, - WebRtc_Word16 right_shifts, int vector_length) -{ - WebRtc_Word16 *inPtr; - WebRtc_Word16 *outPtr; - int i; - - inPtr = in; - outPtr = out; - for (i = 0; i < vector_length; i++) - { - (*outPtr++) = (WebRtc_Word16)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) - + (WebRtc_Word32)add_constant) >> right_shifts); - } -}
diff --git a/src/common_audio/signal_processing/include/signal_processing_library.h b/src/common_audio/signal_processing/include/signal_processing_library.h deleted file mode 100644 index 1da9078..0000000 --- a/src/common_audio/signal_processing/include/signal_processing_library.h +++ /dev/null
@@ -1,1651 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This header file includes all of the fix point signal processing library (SPL) function - * descriptions and declarations. - * For specific function calls, see bottom of file. - */ - -#ifndef WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_ -#define WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_ - -#include <string.h> -#include "typedefs.h" - -#ifdef ARM_WINM -#include <Armintr.h> // intrinsic file for windows mobile -#endif - -// Macros specific for the fixed point implementation -#define WEBRTC_SPL_WORD16_MAX 32767 -#define WEBRTC_SPL_WORD16_MIN -32768 -#define WEBRTC_SPL_WORD32_MAX (WebRtc_Word32)0x7fffffff -#define WEBRTC_SPL_WORD32_MIN (WebRtc_Word32)0x80000000 -#define WEBRTC_SPL_MAX_LPC_ORDER 14 -#define WEBRTC_SPL_MAX_SEED_USED 0x80000000L -#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value -#define WEBRTC_SPL_MAX(A, B) (A > B ? A : B) // Get max value -// TODO(kma/bjorn): For the next two macros, investigate how to correct the code -// for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN. -#define WEBRTC_SPL_ABS_W16(a) \ - (((WebRtc_Word16)a >= 0) ? ((WebRtc_Word16)a) : -((WebRtc_Word16)a)) -#define WEBRTC_SPL_ABS_W32(a) \ - (((WebRtc_Word32)a >= 0) ? ((WebRtc_Word32)a) : -((WebRtc_Word32)a)) - -#ifdef WEBRTC_ARCH_LITTLE_ENDIAN -#define WEBRTC_SPL_GET_BYTE(a, nr) (((WebRtc_Word8 *)a)[nr]) -#define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \ - (((WebRtc_Word8 *)d_ptr)[index] = (val)) -#else -#define WEBRTC_SPL_GET_BYTE(a, nr) \ - ((((WebRtc_Word16 *)a)[nr >> 1]) >> (((nr + 1) & 0x1) * 8) & 0x00ff) -#define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \ - ((WebRtc_Word16 *)d_ptr)[index >> 1] = \ - ((((WebRtc_Word16 *)d_ptr)[index >> 1]) \ - & (0x00ff << (8 * ((index) & 0x1)))) | (val << (8 * ((index + 1) & 0x1))) -#endif - -#define WEBRTC_SPL_MUL(a, b) \ - ((WebRtc_Word32) ((WebRtc_Word32)(a) * (WebRtc_Word32)(b))) -#define WEBRTC_SPL_UMUL(a, b) \ - ((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord32)(b))) -#define WEBRTC_SPL_UMUL_RSFT16(a, b) \ - ((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord32)(b)) >> 16) -#define WEBRTC_SPL_UMUL_16_16(a, b) \ - ((WebRtc_UWord32) (WebRtc_UWord16)(a) * (WebRtc_UWord16)(b)) -#define WEBRTC_SPL_UMUL_16_16_RSFT16(a, b) \ - (((WebRtc_UWord32) (WebRtc_UWord16)(a) * (WebRtc_UWord16)(b)) >> 16) -#define WEBRTC_SPL_UMUL_32_16(a, b) \ - ((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord16)(b))) -#define WEBRTC_SPL_UMUL_32_16_RSFT16(a, b) \ - ((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord16)(b)) >> 16) -#define WEBRTC_SPL_MUL_16_U16(a, b) \ - ((WebRtc_Word32)(WebRtc_Word16)(a) * (WebRtc_UWord16)(b)) -#define WEBRTC_SPL_DIV(a, b) \ - ((WebRtc_Word32) ((WebRtc_Word32)(a) / (WebRtc_Word32)(b))) -#define WEBRTC_SPL_UDIV(a, b) \ - ((WebRtc_UWord32) ((WebRtc_UWord32)(a) / (WebRtc_UWord32)(b))) - -#ifndef WEBRTC_ARCH_ARM_V7 -// For ARMv7 platforms, these are inline functions in spl_inl_armv7.h -#define WEBRTC_SPL_MUL_16_16(a, b) \ - ((WebRtc_Word32) (((WebRtc_Word16)(a)) * ((WebRtc_Word16)(b)))) -#define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \ - (WEBRTC_SPL_MUL_16_16(a, b >> 16) \ - + ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15)) -#define WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, b32) \ - ((WebRtc_Word32)(WEBRTC_SPL_MUL_16_32_RSFT16(a32a, b32) \ - + (WEBRTC_SPL_MUL_16_32_RSFT16(a32b, b32) >> 16))) -#define WEBRTC_SPL_MUL_32_32_RSFT32BI(a32, b32) \ - ((WebRtc_Word32)(WEBRTC_SPL_MUL_16_32_RSFT16(( \ - (WebRtc_Word16)(a32 >> 16)), b32) + \ - (WEBRTC_SPL_MUL_16_32_RSFT16(( \ - (WebRtc_Word16)((a32 & 0x0000FFFF) >> 1)), b32) >> 15))) -#endif - -#define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 5) \ - + (((WEBRTC_SPL_MUL_16_U16(a, (WebRtc_UWord16)(b)) >> 1) + 0x0200) >> 10)) -#define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 2) \ - + (((WEBRTC_SPL_MUL_16_U16(a, (WebRtc_UWord16)(b)) >> 1) + 0x1000) >> 13)) -#define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 1) \ - + (((WEBRTC_SPL_MUL_16_U16(a, (WebRtc_UWord16)(b)) >> 1) + 0x2000) >> 14)) - -#ifdef ARM_WINM -#define WEBRTC_SPL_MUL_16_16(a, b) \ - _SmulLo_SW_SL((WebRtc_Word16)(a), (WebRtc_Word16)(b)) -#endif - -#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \ - (WEBRTC_SPL_MUL_16_16(a, b) >> (c)) - -#define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \ - ((WEBRTC_SPL_MUL_16_16(a, b) + ((WebRtc_Word32) \ - (((WebRtc_Word32)1) << ((c) - 1)))) >> (c)) -#define WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, b) + ((WebRtc_Word32) (1 << 14))) >> 15) - -// C + the 32 most significant bits of A * B -#define WEBRTC_SPL_SCALEDIFF32(A, B, C) \ - (C + (B >> 16) * A + (((WebRtc_UWord32)(0x0000FFFF & B) * A) >> 16)) - -#define WEBRTC_SPL_ADD_SAT_W32(a, b) WebRtcSpl_AddSatW32(a, b) -#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b) -#define WEBRTC_SPL_MUL_32_16(a, b) ((a) * (b)) - -#define WEBRTC_SPL_SUB_SAT_W32(a, b) WebRtcSpl_SubSatW32(a, b) -#define WEBRTC_SPL_ADD_SAT_W16(a, b) WebRtcSpl_AddSatW16(a, b) -#define WEBRTC_SPL_SUB_SAT_W16(a, b) WebRtcSpl_SubSatW16(a, b) - -// We cannot do casting here due to signed/unsigned problem -#define WEBRTC_SPL_IS_NEG(a) ((a) & 0x80000000) -// Shifting with negative numbers allowed -// Positive means left shift -#define WEBRTC_SPL_SHIFT_W16(x, c) \ - (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c)))) -#define WEBRTC_SPL_SHIFT_W32(x, c) \ - (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c)))) - -// Shifting with negative numbers not allowed -// We cannot do casting here due to signed/unsigned problem -#define WEBRTC_SPL_RSHIFT_W16(x, c) ((x) >> (c)) -#define WEBRTC_SPL_LSHIFT_W16(x, c) ((x) << (c)) -#define WEBRTC_SPL_RSHIFT_W32(x, c) ((x) >> (c)) -#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c)) - -#define WEBRTC_SPL_RSHIFT_U16(x, c) ((WebRtc_UWord16)(x) >> (c)) -#define WEBRTC_SPL_LSHIFT_U16(x, c) ((WebRtc_UWord16)(x) << (c)) -#define WEBRTC_SPL_RSHIFT_U32(x, c) ((WebRtc_UWord32)(x) >> (c)) -#define WEBRTC_SPL_LSHIFT_U32(x, c) ((WebRtc_UWord32)(x) << (c)) - -#define WEBRTC_SPL_VNEW(t, n) (t *) malloc (sizeof (t) * (n)) -#define WEBRTC_SPL_FREE free - -#define WEBRTC_SPL_RAND(a) \ - ((WebRtc_Word16)(WEBRTC_SPL_MUL_16_16_RSFT((a), 18816, 7) & 0x00007fff)) - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define WEBRTC_SPL_MEMCPY_W8(v1, v2, length) \ - memcpy(v1, v2, (length) * sizeof(char)) -#define WEBRTC_SPL_MEMCPY_W16(v1, v2, length) \ - memcpy(v1, v2, (length) * sizeof(WebRtc_Word16)) - -#define WEBRTC_SPL_MEMMOVE_W16(v1, v2, length) \ - memmove(v1, v2, (length) * sizeof(WebRtc_Word16)) - -// inline functions: -#include "spl_inl.h" - -// Get SPL Version -WebRtc_Word16 WebRtcSpl_get_version(char* version, - WebRtc_Word16 length_in_bytes); - -int WebRtcSpl_GetScalingSquare(WebRtc_Word16* in_vector, - int in_vector_length, - int times); - -// Copy and set operations. Implementation in copy_set_operations.c. -// Descriptions at bottom of file. -void WebRtcSpl_MemSetW16(WebRtc_Word16* vector, - WebRtc_Word16 set_value, - int vector_length); -void WebRtcSpl_MemSetW32(WebRtc_Word32* vector, - WebRtc_Word32 set_value, - int vector_length); -void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* out_vector, - WebRtc_Word16* in_vector, - int vector_length); -WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16* in_vector, - WebRtc_Word16 in_vector_length, - WebRtc_Word16 samples, - WebRtc_Word16* out_vector); -WebRtc_Word16 WebRtcSpl_ZerosArrayW16(WebRtc_Word16* vector, - WebRtc_Word16 vector_length); -WebRtc_Word16 WebRtcSpl_ZerosArrayW32(WebRtc_Word32* vector, - WebRtc_Word16 vector_length); -WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16* vector, - WebRtc_Word16 vector_length); -WebRtc_Word16 WebRtcSpl_OnesArrayW32(WebRtc_Word32* vector, - WebRtc_Word16 vector_length); -// End: Copy and set operations. - - -// Minimum and maximum operations. Implementation in min_max_operations.c. - -// Returns the largest absolute value in a signed 16-bit vector. -// -// Input: -// - vector : 16-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Maximum absolute value in vector; -// or -1, if (vector == NULL || length <= 0). -int16_t WebRtcSpl_MaxAbsValueW16(const int16_t* vector, int length); - -// Returns the largest absolute value in a signed 32-bit vector. -// -// Input: -// - vector : 32-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Maximum absolute value in vector; -// or -1, if (vector == NULL || length <= 0). -int32_t WebRtcSpl_MaxAbsValueW32(const int32_t* vector, int length); - -// Returns the maximum value of a 16-bit vector. -// -// Input: -// - vector : 16-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Maximum sample value in |vector|. -// If (vector == NULL || length <= 0) WEBRTC_SPL_WORD16_MIN -// is returned. Note that WEBRTC_SPL_WORD16_MIN is a feasible -// value and we can't catch errors purely based on it. -int16_t WebRtcSpl_MaxValueW16(const int16_t* vector, int length); - -// Returns the maximum value of a 32-bit vector. -// -// Input: -// - vector : 32-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Maximum sample value in |vector|. -// If (vector == NULL || length <= 0) WEBRTC_SPL_WORD32_MIN -// is returned. Note that WEBRTC_SPL_WORD32_MIN is a feasible -// value and we can't catch errors purely based on it. -int32_t WebRtcSpl_MaxValueW32(const int32_t* vector, int length); - -// Returns the minimum value of a 16-bit vector. -// -// Input: -// - vector : 16-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Minimum sample value in |vector|. -// If (vector == NULL || length <= 0) WEBRTC_SPL_WORD16_MAX -// is returned. Note that WEBRTC_SPL_WORD16_MAX is a feasible -// value and we can't catch errors purely based on it. -int16_t WebRtcSpl_MinValueW16(const int16_t* vector, int length); - -// Returns the minimum value of a 32-bit vector. -// -// Input: -// - vector : 32-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Minimum sample value in |vector|. -// If (vector == NULL || length <= 0) WEBRTC_SPL_WORD32_MAX -// is returned. Note that WEBRTC_SPL_WORD32_MAX is a feasible -// value and we can't catch errors purely based on it. -int32_t WebRtcSpl_MinValueW32(const int32_t* vector, int length); - -// Returns the vector index to the largest absolute value of a 16-bit vector. -// -// Input: -// - vector : 16-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Index to the maximum absolute value in vector, or -1, -// if (vector == NULL || length <= 0). -// If there are multiple equal maxima, return the index of the -// first. -32768 will always have precedence over 32767 (despite -// -32768 presenting an int16 absolute value of 32767); -int WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, int length); - -// Returns the vector index to the maximum sample value of a 16-bit vector. -// -// Input: -// - vector : 16-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Index to the maximum value in vector (if multiple -// indexes have the maximum, return the first); -// or -1, if (vector == NULL || length <= 0). -int WebRtcSpl_MaxIndexW16(const int16_t* vector, int length); - -// Returns the vector index to the maximum sample value of a 32-bit vector. -// -// Input: -// - vector : 32-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Index to the maximum value in vector (if multiple -// indexes have the maximum, return the first); -// or -1, if (vector == NULL || length <= 0). -int WebRtcSpl_MaxIndexW32(const int32_t* vector, int length); - -// Returns the vector index to the minimum sample value of a 16-bit vector. -// -// Input: -// - vector : 16-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Index to the mimimum value in vector (if multiple -// indexes have the minimum, return the first); -// or -1, if (vector == NULL || length <= 0). -int WebRtcSpl_MinIndexW16(const int16_t* vector, int length); - -// Returns the vector index to the minimum sample value of a 32-bit vector. -// -// Input: -// - vector : 32-bit input vector. -// - length : Number of samples in vector. -// -// Return value : Index to the mimimum value in vector (if multiple -// indexes have the minimum, return the first); -// or -1, if (vector == NULL || length <= 0). -int WebRtcSpl_MinIndexW32(const int32_t* vector, int length); - -// End: Minimum and maximum operations. - - -// Vector scaling operations. Implementation in vector_scaling_operations.c. -// Description at bottom of file. -void WebRtcSpl_VectorBitShiftW16(WebRtc_Word16* out_vector, - WebRtc_Word16 vector_length, - G_CONST WebRtc_Word16* in_vector, - WebRtc_Word16 right_shifts); -void WebRtcSpl_VectorBitShiftW32(WebRtc_Word32* out_vector, - WebRtc_Word16 vector_length, - G_CONST WebRtc_Word32* in_vector, - WebRtc_Word16 right_shifts); -void WebRtcSpl_VectorBitShiftW32ToW16(WebRtc_Word16* out_vector, - WebRtc_Word16 vector_length, - G_CONST WebRtc_Word32* in_vector, - WebRtc_Word16 right_shifts); - -void WebRtcSpl_ScaleVector(G_CONST WebRtc_Word16* in_vector, - WebRtc_Word16* out_vector, - WebRtc_Word16 gain, - WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts); -void WebRtcSpl_ScaleVectorWithSat(G_CONST WebRtc_Word16* in_vector, - WebRtc_Word16* out_vector, - WebRtc_Word16 gain, - WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts); -void WebRtcSpl_ScaleAndAddVectors(G_CONST WebRtc_Word16* in_vector1, - WebRtc_Word16 gain1, int right_shifts1, - G_CONST WebRtc_Word16* in_vector2, - WebRtc_Word16 gain2, int right_shifts2, - WebRtc_Word16* out_vector, - int vector_length); - -// Performs the vector operation: -// out_vector[k] = ((scale1 * in_vector1[k]) + (scale2 * in_vector2[k]) -// + round_value) >> right_shifts, -// where round_value = (1 << right_shifts) >> 1. -// -// Input: -// - in_vector1 : Input vector 1 -// - in_vector1_scale : Gain to be used for vector 1 -// - in_vector2 : Input vector 2 -// - in_vector2_scale : Gain to be used for vector 2 -// - right_shifts : Number of right bit shifts to be applied -// - length : Number of elements in the input vectors -// -// Output: -// - out_vector : Output vector -// Return value : 0 if OK, -1 if (in_vector1 == NULL -// || in_vector2 == NULL || out_vector == NULL -// || length <= 0 || right_shift < 0). -int WebRtcSpl_ScaleAndAddVectorsWithRound(const int16_t* in_vector1, - int16_t in_vector1_scale, - const int16_t* in_vector2, - int16_t in_vector2_scale, - int right_shifts, - int16_t* out_vector, - int length); - -// End: Vector scaling operations. - -// iLBC specific functions. Implementations in ilbc_specific_functions.c. -// Description at bottom of file. -void WebRtcSpl_ReverseOrderMultArrayElements(WebRtc_Word16* out_vector, - G_CONST WebRtc_Word16* in_vector, - G_CONST WebRtc_Word16* window, - WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts); -void WebRtcSpl_ElementwiseVectorMult(WebRtc_Word16* out_vector, - G_CONST WebRtc_Word16* in_vector, - G_CONST WebRtc_Word16* window, - WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts); -void WebRtcSpl_AddVectorsAndShift(WebRtc_Word16* out_vector, - G_CONST WebRtc_Word16* in_vector1, - G_CONST WebRtc_Word16* in_vector2, - WebRtc_Word16 vector_length, - WebRtc_Word16 right_shifts); -void WebRtcSpl_AddAffineVectorToVector(WebRtc_Word16* out_vector, - WebRtc_Word16* in_vector, - WebRtc_Word16 gain, - WebRtc_Word32 add_constant, - WebRtc_Word16 right_shifts, - int vector_length); -void WebRtcSpl_AffineTransformVector(WebRtc_Word16* out_vector, - WebRtc_Word16* in_vector, - WebRtc_Word16 gain, - WebRtc_Word32 add_constant, - WebRtc_Word16 right_shifts, - int vector_length); -// End: iLBC specific functions. - -// Signal processing operations. - -// A 32-bit fix-point implementation of auto-correlation computation -// -// Input: -// - in_vector : Vector to calculate autocorrelation upon -// - in_vector_length : Length (in samples) of |vector| -// - order : The order up to which the autocorrelation should be -// calculated -// -// Output: -// - result : auto-correlation values (values should be seen -// relative to each other since the absolute values -// might have been down shifted to avoid overflow) -// -// - scale : The number of left shifts required to obtain the -// auto-correlation in Q0 -// -// Return value : -// - -1, if |order| > |in_vector_length|; -// - Number of samples in |result|, i.e. (order+1), otherwise. -int WebRtcSpl_AutoCorrelation(const int16_t* in_vector, - int in_vector_length, - int order, - int32_t* result, - int* scale); - -// A 32-bit fix-point implementation of the Levinson-Durbin algorithm that -// does NOT use the 64 bit class -// -// Input: -// - auto_corr : Vector with autocorrelation values of length >= -// |use_order|+1 -// - use_order : The LPC filter order (support up to order 20) -// -// Output: -// - lpc_coef : lpc_coef[0..use_order] LPC coefficients in Q12 -// - refl_coef : refl_coef[0...use_order-1]| Reflection coefficients in -// Q15 -// -// Return value : 1 for stable 0 for unstable -WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32* auto_corr, - WebRtc_Word16* lpc_coef, - WebRtc_Word16* refl_coef, - WebRtc_Word16 order); - -// Converts reflection coefficients |refl_coef| to LPC coefficients |lpc_coef|. -// This version is a 16 bit operation. -// -// NOTE: The 16 bit refl_coef -> lpc_coef conversion might result in a -// "slightly unstable" filter (i.e., a pole just outside the unit circle) in -// "rare" cases even if the reflection coefficients are stable. -// -// Input: -// - refl_coef : Reflection coefficients in Q15 that should be converted -// to LPC coefficients -// - use_order : Number of coefficients in |refl_coef| -// -// Output: -// - lpc_coef : LPC coefficients in Q12 -void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16* refl_coef, - int use_order, - WebRtc_Word16* lpc_coef); - -// Converts LPC coefficients |lpc_coef| to reflection coefficients |refl_coef|. -// This version is a 16 bit operation. -// The conversion is implemented by the step-down algorithm. -// -// Input: -// - lpc_coef : LPC coefficients in Q12, that should be converted to -// reflection coefficients -// - use_order : Number of coefficients in |lpc_coef| -// -// Output: -// - refl_coef : Reflection coefficients in Q15. -void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* lpc_coef, - int use_order, - WebRtc_Word16* refl_coef); - -// Calculates reflection coefficients (16 bit) from auto-correlation values -// -// Input: -// - auto_corr : Auto-correlation values -// - use_order : Number of coefficients wanted be calculated -// -// Output: -// - refl_coef : Reflection coefficients in Q15. -void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32* auto_corr, - int use_order, - WebRtc_Word16* refl_coef); - -// Calculates the cross-correlation between two sequences |seq1| and |seq2|. -// |seq1| is fixed and |seq2| slides as the pointer is increased with the -// amount |step_seq2|. Note the arguments should obey the relationship: -// |dim_seq| - 1 + |step_seq2| * (|dim_cross_correlation| - 1) < -// buffer size of |seq2| -// -// Input: -// - seq1 : First sequence (fixed throughout the correlation) -// - seq2 : Second sequence (slides |step_vector2| for each -// new correlation) -// - dim_seq : Number of samples to use in the cross-correlation -// - dim_cross_correlation : Number of cross-correlations to calculate (the -// start position for |vector2| is updated for each -// new one) -// - right_shifts : Number of right bit shifts to use. This will -// become the output Q-domain. -// - step_seq2 : How many (positive or negative) steps the -// |vector2| pointer should be updated for each new -// cross-correlation value. -// -// Output: -// - cross_correlation : The cross-correlation in Q(-right_shifts) -void WebRtcSpl_CrossCorrelation(int32_t* cross_correlation, - const int16_t* seq1, - const int16_t* seq2, - int16_t dim_seq, - int16_t dim_cross_correlation, - int16_t right_shifts, - int16_t step_seq2); - -// Creates (the first half of) a Hanning window. Size must be at least 1 and -// at most 512. -// -// Input: -// - size : Length of the requested Hanning window (1 to 512) -// -// Output: -// - window : Hanning vector in Q14. -void WebRtcSpl_GetHanningWindow(WebRtc_Word16* window, WebRtc_Word16 size); - -// Calculates y[k] = sqrt(1 - x[k]^2) for each element of the input vector -// |in_vector|. Input and output values are in Q15. -// -// Inputs: -// - in_vector : Values to calculate sqrt(1 - x^2) of -// - vector_length : Length of vector |in_vector| -// -// Output: -// - out_vector : Output values in Q15 -void WebRtcSpl_SqrtOfOneMinusXSquared(WebRtc_Word16* in_vector, - int vector_length, - WebRtc_Word16* out_vector); -// End: Signal processing operations. - -// Randomization functions. Implementations collected in randomization_functions.c and -// descriptions at bottom of this file. -WebRtc_UWord32 WebRtcSpl_IncreaseSeed(WebRtc_UWord32* seed); -WebRtc_Word16 WebRtcSpl_RandU(WebRtc_UWord32* seed); -WebRtc_Word16 WebRtcSpl_RandN(WebRtc_UWord32* seed); -WebRtc_Word16 WebRtcSpl_RandUArray(WebRtc_Word16* vector, - WebRtc_Word16 vector_length, - WebRtc_UWord32* seed); -// End: Randomization functions. - -// Math functions -WebRtc_Word32 WebRtcSpl_Sqrt(WebRtc_Word32 value); -WebRtc_Word32 WebRtcSpl_SqrtFloor(WebRtc_Word32 value); - -// Divisions. Implementations collected in division_operations.c and -// descriptions at bottom of this file. -WebRtc_UWord32 WebRtcSpl_DivU32U16(WebRtc_UWord32 num, WebRtc_UWord16 den); -WebRtc_Word32 WebRtcSpl_DivW32W16(WebRtc_Word32 num, WebRtc_Word16 den); -WebRtc_Word16 WebRtcSpl_DivW32W16ResW16(WebRtc_Word32 num, WebRtc_Word16 den); -WebRtc_Word32 WebRtcSpl_DivResultInQ31(WebRtc_Word32 num, WebRtc_Word32 den); -WebRtc_Word32 WebRtcSpl_DivW32HiLow(WebRtc_Word32 num, WebRtc_Word16 den_hi, - WebRtc_Word16 den_low); -// End: Divisions. - -WebRtc_Word32 WebRtcSpl_Energy(WebRtc_Word16* vector, - int vector_length, - int* scale_factor); - -// Calculates the dot product between two (WebRtc_Word16) vectors. -// -// Input: -// - vector1 : Vector 1 -// - vector2 : Vector 2 -// - vector_length : Number of samples used in the dot product -// - scaling : The number of right bit shifts to apply on each term -// during calculation to avoid overflow, i.e., the -// output will be in Q(-|scaling|) -// -// Return value : The dot product in Q(-scaling) -int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1, - const int16_t* vector2, - int length, - int scaling); - -// Filter operations. -int WebRtcSpl_FilterAR(G_CONST WebRtc_Word16* ar_coef, int ar_coef_length, - G_CONST WebRtc_Word16* in_vector, int in_vector_length, - WebRtc_Word16* filter_state, int filter_state_length, - WebRtc_Word16* filter_state_low, - int filter_state_low_length, WebRtc_Word16* out_vector, - WebRtc_Word16* out_vector_low, int out_vector_low_length); - -void WebRtcSpl_FilterMAFastQ12(WebRtc_Word16* in_vector, - WebRtc_Word16* out_vector, - WebRtc_Word16* ma_coef, - WebRtc_Word16 ma_coef_length, - WebRtc_Word16 vector_length); - -// Performs a AR filtering on a vector in Q12 -// Input: -// - data_in : Input samples -// - data_out : State information in positions -// data_out[-order] .. data_out[-1] -// - coefficients : Filter coefficients (in Q12) -// - coefficients_length: Number of coefficients (order+1) -// - data_length : Number of samples to be filtered -// Output: -// - data_out : Filtered samples -void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, - int16_t* data_out, - const int16_t* __restrict coefficients, - int coefficients_length, - int data_length); - -// Performs a MA down sampling filter on a vector -// Input: -// - data_in : Input samples (state in positions -// data_in[-order] .. data_in[-1]) -// - data_in_length : Number of samples in |data_in| to be filtered. -// This must be at least -// |delay| + |factor|*(|out_vector_length|-1) + 1) -// - data_out_length : Number of down sampled samples desired -// - coefficients : Filter coefficients (in Q12) -// - coefficients_length: Number of coefficients (order+1) -// - factor : Decimation factor -// - delay : Delay of filter (compensated for in out_vector) -// Output: -// - data_out : Filtered samples -// Return value : 0 if OK, -1 if |in_vector| is too short -int WebRtcSpl_DownsampleFast(const int16_t* data_in, - int data_in_length, - int16_t* data_out, - int data_out_length, - const int16_t* __restrict coefficients, - int coefficients_length, - int factor, - int delay); - -// End: Filter operations. - -// FFT operations - -int WebRtcSpl_ComplexFFT(WebRtc_Word16 vector[], int stages, int mode); -int WebRtcSpl_ComplexIFFT(WebRtc_Word16 vector[], int stages, int mode); - -// Treat a 16-bit complex data buffer |complex_data| as an array of 32-bit -// values, and swap elements whose indexes are bit-reverses of each other. -// -// Input: -// - complex_data : Complex data buffer containing 2^|stages| real -// elements interleaved with 2^|stages| imaginary -// elements: [Re Im Re Im Re Im....] -// - stages : Number of FFT stages. Must be at least 3 and at most -// 10, since the table WebRtcSpl_kSinTable1024[] is 1024 -// elements long. -// -// Output: -// - complex_data : The complex data buffer. - -void WebRtcSpl_ComplexBitReverse(int16_t* __restrict complex_data, int stages); - -// End: FFT operations - -/************************************************************ - * - * RESAMPLING FUNCTIONS AND THEIR STRUCTS ARE DEFINED BELOW - * - ************************************************************/ - -/******************************************************************* - * resample.c - * - * Includes the following resampling combinations - * 22 kHz -> 16 kHz - * 16 kHz -> 22 kHz - * 22 kHz -> 8 kHz - * 8 kHz -> 22 kHz - * - ******************************************************************/ - -// state structure for 22 -> 16 resampler -typedef struct -{ - WebRtc_Word32 S_22_44[8]; - WebRtc_Word32 S_44_32[8]; - WebRtc_Word32 S_32_16[8]; -} WebRtcSpl_State22khzTo16khz; - -void WebRtcSpl_Resample22khzTo16khz(const WebRtc_Word16* in, - WebRtc_Word16* out, - WebRtcSpl_State22khzTo16khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample22khzTo16khz(WebRtcSpl_State22khzTo16khz* state); - -// state structure for 16 -> 22 resampler -typedef struct -{ - WebRtc_Word32 S_16_32[8]; - WebRtc_Word32 S_32_22[8]; -} WebRtcSpl_State16khzTo22khz; - -void WebRtcSpl_Resample16khzTo22khz(const WebRtc_Word16* in, - WebRtc_Word16* out, - WebRtcSpl_State16khzTo22khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample16khzTo22khz(WebRtcSpl_State16khzTo22khz* state); - -// state structure for 22 -> 8 resampler -typedef struct -{ - WebRtc_Word32 S_22_22[16]; - WebRtc_Word32 S_22_16[8]; - WebRtc_Word32 S_16_8[8]; -} WebRtcSpl_State22khzTo8khz; - -void WebRtcSpl_Resample22khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State22khzTo8khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample22khzTo8khz(WebRtcSpl_State22khzTo8khz* state); - -// state structure for 8 -> 22 resampler -typedef struct -{ - WebRtc_Word32 S_8_16[8]; - WebRtc_Word32 S_16_11[8]; - WebRtc_Word32 S_11_22[8]; -} WebRtcSpl_State8khzTo22khz; - -void WebRtcSpl_Resample8khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State8khzTo22khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state); - -/******************************************************************* - * resample_fractional.c - * Functions for internal use in the other resample functions - * - * Includes the following resampling combinations - * 48 kHz -> 32 kHz - * 32 kHz -> 24 kHz - * 44 kHz -> 32 kHz - * - ******************************************************************/ - -void WebRtcSpl_Resample48khzTo32khz(const WebRtc_Word32* In, WebRtc_Word32* Out, - const WebRtc_Word32 K); - -void WebRtcSpl_Resample32khzTo24khz(const WebRtc_Word32* In, WebRtc_Word32* Out, - const WebRtc_Word32 K); - -void WebRtcSpl_Resample44khzTo32khz(const WebRtc_Word32* In, WebRtc_Word32* Out, - const WebRtc_Word32 K); - -/******************************************************************* - * resample_48khz.c - * - * Includes the following resampling combinations - * 48 kHz -> 16 kHz - * 16 kHz -> 48 kHz - * 48 kHz -> 8 kHz - * 8 kHz -> 48 kHz - * - ******************************************************************/ - -typedef struct -{ - WebRtc_Word32 S_48_48[16]; - WebRtc_Word32 S_48_32[8]; - WebRtc_Word32 S_32_16[8]; -} WebRtcSpl_State48khzTo16khz; - -void WebRtcSpl_Resample48khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State48khzTo16khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state); - -typedef struct -{ - WebRtc_Word32 S_16_32[8]; - WebRtc_Word32 S_32_24[8]; - WebRtc_Word32 S_24_48[8]; -} WebRtcSpl_State16khzTo48khz; - -void WebRtcSpl_Resample16khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State16khzTo48khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state); - -typedef struct -{ - WebRtc_Word32 S_48_24[8]; - WebRtc_Word32 S_24_24[16]; - WebRtc_Word32 S_24_16[8]; - WebRtc_Word32 S_16_8[8]; -} WebRtcSpl_State48khzTo8khz; - -void WebRtcSpl_Resample48khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State48khzTo8khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state); - -typedef struct -{ - WebRtc_Word32 S_8_16[8]; - WebRtc_Word32 S_16_12[8]; - WebRtc_Word32 S_12_24[8]; - WebRtc_Word32 S_24_48[8]; -} WebRtcSpl_State8khzTo48khz; - -void WebRtcSpl_Resample8khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State8khzTo48khz* state, - WebRtc_Word32* tmpmem); - -void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state); - -/******************************************************************* - * resample_by_2.c - * - * Includes down and up sampling by a factor of two. - * - ******************************************************************/ - -void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, const WebRtc_Word16 len, - WebRtc_Word16* out, WebRtc_Word32* filtState); - -void WebRtcSpl_UpsampleBy2(const WebRtc_Word16* in, WebRtc_Word16 len, WebRtc_Word16* out, - WebRtc_Word32* filtState); - -/************************************************************ - * END OF RESAMPLING FUNCTIONS - ************************************************************/ -void WebRtcSpl_AnalysisQMF(const WebRtc_Word16* in_data, - WebRtc_Word16* low_band, - WebRtc_Word16* high_band, - WebRtc_Word32* filter_state1, - WebRtc_Word32* filter_state2); -void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band, - const WebRtc_Word16* high_band, - WebRtc_Word16* out_data, - WebRtc_Word32* filter_state1, - WebRtc_Word32* filter_state2); - -#ifdef __cplusplus -} -#endif // __cplusplus -#endif // WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_ - -// -// WebRtcSpl_AddSatW16(...) -// WebRtcSpl_AddSatW32(...) -// -// Returns the result of a saturated 16-bit, respectively 32-bit, addition of -// the numbers specified by the |var1| and |var2| parameters. -// -// Input: -// - var1 : Input variable 1 -// - var2 : Input variable 2 -// -// Return value : Added and saturated value -// - -// -// WebRtcSpl_SubSatW16(...) -// WebRtcSpl_SubSatW32(...) -// -// Returns the result of a saturated 16-bit, respectively 32-bit, subtraction -// of the numbers specified by the |var1| and |var2| parameters. -// -// Input: -// - var1 : Input variable 1 -// - var2 : Input variable 2 -// -// Returned value : Subtracted and saturated value -// - -// -// WebRtcSpl_GetSizeInBits(...) -// -// Returns the # of bits that are needed at the most to represent the number -// specified by the |value| parameter. -// -// Input: -// - value : Input value -// -// Return value : Number of bits needed to represent |value| -// - -// -// WebRtcSpl_NormW32(...) -// -// Norm returns the # of left shifts required to 32-bit normalize the 32-bit -// signed number specified by the |value| parameter. -// -// Input: -// - value : Input value -// -// Return value : Number of bit shifts needed to 32-bit normalize |value| -// - -// -// WebRtcSpl_NormW16(...) -// -// Norm returns the # of left shifts required to 16-bit normalize the 16-bit -// signed number specified by the |value| parameter. -// -// Input: -// - value : Input value -// -// Return value : Number of bit shifts needed to 32-bit normalize |value| -// - -// -// WebRtcSpl_NormU32(...) -// -// Norm returns the # of left shifts required to 32-bit normalize the unsigned -// 32-bit number specified by the |value| parameter. -// -// Input: -// - value : Input value -// -// Return value : Number of bit shifts needed to 32-bit normalize |value| -// - -// -// WebRtcSpl_GetScalingSquare(...) -// -// Returns the # of bits required to scale the samples specified in the -// |in_vector| parameter so that, if the squares of the samples are added the -// # of times specified by the |times| parameter, the 32-bit addition will not -// overflow (result in WebRtc_Word32). -// -// Input: -// - in_vector : Input vector to check scaling on -// - in_vector_length : Samples in |in_vector| -// - times : Number of additions to be performed -// -// Return value : Number of right bit shifts needed to avoid -// overflow in the addition calculation -// - -// -// WebRtcSpl_MemSetW16(...) -// -// Sets all the values in the WebRtc_Word16 vector |vector| of length -// |vector_length| to the specified value |set_value| -// -// Input: -// - vector : Pointer to the WebRtc_Word16 vector -// - set_value : Value specified -// - vector_length : Length of vector -// - -// -// WebRtcSpl_MemSetW32(...) -// -// Sets all the values in the WebRtc_Word32 vector |vector| of length -// |vector_length| to the specified value |set_value| -// -// Input: -// - vector : Pointer to the WebRtc_Word16 vector -// - set_value : Value specified -// - vector_length : Length of vector -// - -// -// WebRtcSpl_MemCpyReversedOrder(...) -// -// Copies all the values from the source WebRtc_Word16 vector |in_vector| to a -// destination WebRtc_Word16 vector |out_vector|. It is done in reversed order, -// meaning that the first sample of |in_vector| is copied to the last sample of -// the |out_vector|. The procedure continues until the last sample of -// |in_vector| has been copied to the first sample of |out_vector|. This -// creates a reversed vector. Used in e.g. prediction in iLBC. -// -// Input: -// - in_vector : Pointer to the first sample in a WebRtc_Word16 vector -// of length |length| -// - vector_length : Number of elements to copy -// -// Output: -// - out_vector : Pointer to the last sample in a WebRtc_Word16 vector -// of length |length| -// - -// -// WebRtcSpl_CopyFromEndW16(...) -// -// Copies the rightmost |samples| of |in_vector| (of length |in_vector_length|) -// to the vector |out_vector|. -// -// Input: -// - in_vector : Input vector -// - in_vector_length : Number of samples in |in_vector| -// - samples : Number of samples to extract (from right side) -// from |in_vector| -// -// Output: -// - out_vector : Vector with the requested samples -// -// Return value : Number of copied samples in |out_vector| -// - -// -// WebRtcSpl_ZerosArrayW16(...) -// WebRtcSpl_ZerosArrayW32(...) -// -// Inserts the value "zero" in all positions of a w16 and a w32 vector -// respectively. -// -// Input: -// - vector_length : Number of samples in vector -// -// Output: -// - vector : Vector containing all zeros -// -// Return value : Number of samples in vector -// - -// -// WebRtcSpl_OnesArrayW16(...) -// WebRtcSpl_OnesArrayW32(...) -// -// Inserts the value "one" in all positions of a w16 and a w32 vector -// respectively. -// -// Input: -// - vector_length : Number of samples in vector -// -// Output: -// - vector : Vector containing all ones -// -// Return value : Number of samples in vector -// - -// -// WebRtcSpl_VectorBitShiftW16(...) -// WebRtcSpl_VectorBitShiftW32(...) -// -// Bit shifts all the values in a vector up or downwards. Different calls for -// WebRtc_Word16 and WebRtc_Word32 vectors respectively. -// -// Input: -// - vector_length : Length of vector -// - in_vector : Pointer to the vector that should be bit shifted -// - right_shifts : Number of right bit shifts (negative value gives left -// shifts) -// -// Output: -// - out_vector : Pointer to the result vector (can be the same as -// |in_vector|) -// - -// -// WebRtcSpl_VectorBitShiftW32ToW16(...) -// -// Bit shifts all the values in a WebRtc_Word32 vector up or downwards and -// stores the result as a WebRtc_Word16 vector -// -// Input: -// - vector_length : Length of vector -// - in_vector : Pointer to the vector that should be bit shifted -// - right_shifts : Number of right bit shifts (negative value gives left -// shifts) -// -// Output: -// - out_vector : Pointer to the result vector (can be the same as -// |in_vector|) -// - -// -// WebRtcSpl_ScaleVector(...) -// -// Performs the vector operation: -// out_vector[k] = (gain*in_vector[k])>>right_shifts -// -// Input: -// - in_vector : Input vector -// - gain : Scaling gain -// - vector_length : Elements in the |in_vector| -// - right_shifts : Number of right bit shifts applied -// -// Output: -// - out_vector : Output vector (can be the same as |in_vector|) -// - -// -// WebRtcSpl_ScaleVectorWithSat(...) -// -// Performs the vector operation: -// out_vector[k] = SATURATE( (gain*in_vector[k])>>right_shifts ) -// -// Input: -// - in_vector : Input vector -// - gain : Scaling gain -// - vector_length : Elements in the |in_vector| -// - right_shifts : Number of right bit shifts applied -// -// Output: -// - out_vector : Output vector (can be the same as |in_vector|) -// - -// -// WebRtcSpl_ScaleAndAddVectors(...) -// -// Performs the vector operation: -// out_vector[k] = (gain1*in_vector1[k])>>right_shifts1 -// + (gain2*in_vector2[k])>>right_shifts2 -// -// Input: -// - in_vector1 : Input vector 1 -// - gain1 : Gain to be used for vector 1 -// - right_shifts1 : Right bit shift to be used for vector 1 -// - in_vector2 : Input vector 2 -// - gain2 : Gain to be used for vector 2 -// - right_shifts2 : Right bit shift to be used for vector 2 -// - vector_length : Elements in the input vectors -// -// Output: -// - out_vector : Output vector -// - -// -// WebRtcSpl_ReverseOrderMultArrayElements(...) -// -// Performs the vector operation: -// out_vector[n] = (in_vector[n]*window[-n])>>right_shifts -// -// Input: -// - in_vector : Input vector -// - window : Window vector (should be reversed). The pointer -// should be set to the last value in the vector -// - right_shifts : Number of right bit shift to be applied after the -// multiplication -// - vector_length : Number of elements in |in_vector| -// -// Output: -// - out_vector : Output vector (can be same as |in_vector|) -// - -// -// WebRtcSpl_ElementwiseVectorMult(...) -// -// Performs the vector operation: -// out_vector[n] = (in_vector[n]*window[n])>>right_shifts -// -// Input: -// - in_vector : Input vector -// - window : Window vector. -// - right_shifts : Number of right bit shift to be applied after the -// multiplication -// - vector_length : Number of elements in |in_vector| -// -// Output: -// - out_vector : Output vector (can be same as |in_vector|) -// - -// -// WebRtcSpl_AddVectorsAndShift(...) -// -// Performs the vector operation: -// out_vector[k] = (in_vector1[k] + in_vector2[k])>>right_shifts -// -// Input: -// - in_vector1 : Input vector 1 -// - in_vector2 : Input vector 2 -// - right_shifts : Number of right bit shift to be applied after the -// multiplication -// - vector_length : Number of elements in |in_vector1| and |in_vector2| -// -// Output: -// - out_vector : Output vector (can be same as |in_vector1|) -// - -// -// WebRtcSpl_AddAffineVectorToVector(...) -// -// Adds an affine transformed vector to another vector |out_vector|, i.e, -// performs -// out_vector[k] += (in_vector[k]*gain+add_constant)>>right_shifts -// -// Input: -// - in_vector : Input vector -// - gain : Gain value, used to multiply the in vector with -// - add_constant : Constant value to add (usually 1<<(right_shifts-1), -// but others can be used as well -// - right_shifts : Number of right bit shifts (0-16) -// - vector_length : Number of samples in |in_vector| and |out_vector| -// -// Output: -// - out_vector : Vector with the output -// - -// -// WebRtcSpl_AffineTransformVector(...) -// -// Affine transforms a vector, i.e, performs -// out_vector[k] = (in_vector[k]*gain+add_constant)>>right_shifts -// -// Input: -// - in_vector : Input vector -// - gain : Gain value, used to multiply the in vector with -// - add_constant : Constant value to add (usually 1<<(right_shifts-1), -// but others can be used as well -// - right_shifts : Number of right bit shifts (0-16) -// - vector_length : Number of samples in |in_vector| and |out_vector| -// -// Output: -// - out_vector : Vector with the output -// - -// -// WebRtcSpl_IncreaseSeed(...) -// -// Increases the seed (and returns the new value) -// -// Input: -// - seed : Seed for random calculation -// -// Output: -// - seed : Updated seed value -// -// Return value : The new seed value -// - -// -// WebRtcSpl_RandU(...) -// -// Produces a uniformly distributed value in the WebRtc_Word16 range -// -// Input: -// - seed : Seed for random calculation -// -// Output: -// - seed : Updated seed value -// -// Return value : Uniformly distributed value in the range -// [Word16_MIN...Word16_MAX] -// - -// -// WebRtcSpl_RandN(...) -// -// Produces a normal distributed value in the WebRtc_Word16 range -// -// Input: -// - seed : Seed for random calculation -// -// Output: -// - seed : Updated seed value -// -// Return value : N(0,1) value in the Q13 domain -// - -// -// WebRtcSpl_RandUArray(...) -// -// Produces a uniformly distributed vector with elements in the WebRtc_Word16 -// range -// -// Input: -// - vector_length : Samples wanted in the vector -// - seed : Seed for random calculation -// -// Output: -// - vector : Vector with the uniform values -// - seed : Updated seed value -// -// Return value : Number of samples in vector, i.e., |vector_length| -// - -// -// WebRtcSpl_Sqrt(...) -// -// Returns the square root of the input value |value|. The precision of this -// function is integer precision, i.e., sqrt(8) gives 2 as answer. -// If |value| is a negative number then 0 is returned. -// -// Algorithm: -// -// A sixth order Taylor Series expansion is used here to compute the square -// root of a number y^0.5 = (1+x)^0.5 -// where -// x = y-1 -// = 1+(x/2)-0.5*((x/2)^2+0.5*((x/2)^3-0.625*((x/2)^4+0.875*((x/2)^5) -// 0.5 <= x < 1 -// -// Input: -// - value : Value to calculate sqrt of -// -// Return value : Result of the sqrt calculation -// - -// -// WebRtcSpl_SqrtFloor(...) -// -// Returns the square root of the input value |value|. The precision of this -// function is rounding down integer precision, i.e., sqrt(8) gives 2 as answer. -// If |value| is a negative number then 0 is returned. -// -// Algorithm: -// -// An iterative 4 cylce/bit routine -// -// Input: -// - value : Value to calculate sqrt of -// -// Return value : Result of the sqrt calculation -// - -// -// WebRtcSpl_DivU32U16(...) -// -// Divides a WebRtc_UWord32 |num| by a WebRtc_UWord16 |den|. -// -// If |den|==0, (WebRtc_UWord32)0xFFFFFFFF is returned. -// -// Input: -// - num : Numerator -// - den : Denominator -// -// Return value : Result of the division (as a WebRtc_UWord32), i.e., the -// integer part of num/den. -// - -// -// WebRtcSpl_DivW32W16(...) -// -// Divides a WebRtc_Word32 |num| by a WebRtc_Word16 |den|. -// -// If |den|==0, (WebRtc_Word32)0x7FFFFFFF is returned. -// -// Input: -// - num : Numerator -// - den : Denominator -// -// Return value : Result of the division (as a WebRtc_Word32), i.e., the -// integer part of num/den. -// - -// -// WebRtcSpl_DivW32W16ResW16(...) -// -// Divides a WebRtc_Word32 |num| by a WebRtc_Word16 |den|, assuming that the -// result is less than 32768, otherwise an unpredictable result will occur. -// -// If |den|==0, (WebRtc_Word16)0x7FFF is returned. -// -// Input: -// - num : Numerator -// - den : Denominator -// -// Return value : Result of the division (as a WebRtc_Word16), i.e., the -// integer part of num/den. -// - -// -// WebRtcSpl_DivResultInQ31(...) -// -// Divides a WebRtc_Word32 |num| by a WebRtc_Word16 |den|, assuming that the -// absolute value of the denominator is larger than the numerator, otherwise -// an unpredictable result will occur. -// -// Input: -// - num : Numerator -// - den : Denominator -// -// Return value : Result of the division in Q31. -// - -// -// WebRtcSpl_DivW32HiLow(...) -// -// Divides a WebRtc_Word32 |num| by a denominator in hi, low format. The -// absolute value of the denominator has to be larger (or equal to) the -// numerator. -// -// Input: -// - num : Numerator -// - den_hi : High part of denominator -// - den_low : Low part of denominator -// -// Return value : Divided value in Q31 -// - -// -// WebRtcSpl_Energy(...) -// -// Calculates the energy of a vector -// -// Input: -// - vector : Vector which the energy should be calculated on -// - vector_length : Number of samples in vector -// -// Output: -// - scale_factor : Number of left bit shifts needed to get the physical -// energy value, i.e, to get the Q0 value -// -// Return value : Energy value in Q(-|scale_factor|) -// - -// -// WebRtcSpl_FilterAR(...) -// -// Performs a 32-bit AR filtering on a vector in Q12 -// -// Input: -// - ar_coef : AR-coefficient vector (values in Q12), -// ar_coef[0] must be 4096. -// - ar_coef_length : Number of coefficients in |ar_coef|. -// - in_vector : Vector to be filtered. -// - in_vector_length : Number of samples in |in_vector|. -// - filter_state : Current state (higher part) of the filter. -// - filter_state_length : Length (in samples) of |filter_state|. -// - filter_state_low : Current state (lower part) of the filter. -// - filter_state_low_length : Length (in samples) of |filter_state_low|. -// - out_vector_low_length : Maximum length (in samples) of -// |out_vector_low|. -// -// Output: -// - filter_state : Updated state (upper part) vector. -// - filter_state_low : Updated state (lower part) vector. -// - out_vector : Vector containing the upper part of the -// filtered values. -// - out_vector_low : Vector containing the lower part of the -// filtered values. -// -// Return value : Number of samples in the |out_vector|. -// - -// -// WebRtcSpl_FilterMAFastQ12(...) -// -// Performs a MA filtering on a vector in Q12 -// -// Input: -// - in_vector : Input samples (state in positions -// in_vector[-order] .. in_vector[-1]) -// - ma_coef : Filter coefficients (in Q12) -// - ma_coef_length : Number of B coefficients (order+1) -// - vector_length : Number of samples to be filtered -// -// Output: -// - out_vector : Filtered samples -// - -// -// WebRtcSpl_ComplexIFFT(...) -// -// Complex Inverse FFT -// -// Computes an inverse complex 2^|stages|-point FFT on the input vector, which -// is in bit-reversed order. The original content of the vector is destroyed in -// the process, since the input is overwritten by the output, normal-ordered, -// FFT vector. With X as the input complex vector, y as the output complex -// vector and with M = 2^|stages|, the following is computed: -// -// M-1 -// y(k) = sum[X(i)*[cos(2*pi*i*k/M) + j*sin(2*pi*i*k/M)]] -// i=0 -// -// The implementations are optimized for speed, not for code size. It uses the -// decimation-in-time algorithm with radix-2 butterfly technique. -// -// Input: -// - vector : In pointer to complex vector containing 2^|stages| -// real elements interleaved with 2^|stages| imaginary -// elements. -// [ReImReImReIm....] -// The elements are in Q(-scale) domain, see more on Return -// Value below. -// -// - stages : Number of FFT stages. Must be at least 3 and at most 10, -// since the table WebRtcSpl_kSinTable1024[] is 1024 -// elements long. -// -// - mode : This parameter gives the user to choose how the FFT -// should work. -// mode==0: Low-complexity and Low-accuracy mode -// mode==1: High-complexity and High-accuracy mode -// -// Output: -// - vector : Out pointer to the FFT vector (the same as input). -// -// Return Value : The scale value that tells the number of left bit shifts -// that the elements in the |vector| should be shifted with -// in order to get Q0 values, i.e. the physically correct -// values. The scale parameter is always 0 or positive, -// except if N>1024 (|stages|>10), which returns a scale -// value of -1, indicating error. -// - -// -// WebRtcSpl_ComplexFFT(...) -// -// Complex FFT -// -// Computes a complex 2^|stages|-point FFT on the input vector, which is in -// bit-reversed order. The original content of the vector is destroyed in -// the process, since the input is overwritten by the output, normal-ordered, -// FFT vector. With x as the input complex vector, Y as the output complex -// vector and with M = 2^|stages|, the following is computed: -// -// M-1 -// Y(k) = 1/M * sum[x(i)*[cos(2*pi*i*k/M) + j*sin(2*pi*i*k/M)]] -// i=0 -// -// The implementations are optimized for speed, not for code size. It uses the -// decimation-in-time algorithm with radix-2 butterfly technique. -// -// This routine prevents overflow by scaling by 2 before each FFT stage. This is -// a fixed scaling, for proper normalization - there will be log2(n) passes, so -// this results in an overall factor of 1/n, distributed to maximize arithmetic -// accuracy. -// -// Input: -// - vector : In pointer to complex vector containing 2^|stages| real -// elements interleaved with 2^|stages| imaginary elements. -// [ReImReImReIm....] -// The output is in the Q0 domain. -// -// - stages : Number of FFT stages. Must be at least 3 and at most 10, -// since the table WebRtcSpl_kSinTable1024[] is 1024 -// elements long. -// -// - mode : This parameter gives the user to choose how the FFT -// should work. -// mode==0: Low-complexity and Low-accuracy mode -// mode==1: High-complexity and High-accuracy mode -// -// Output: -// - vector : The output FFT vector is in the Q0 domain. -// -// Return value : The scale parameter is always 0, except if N>1024, -// which returns a scale value of -1, indicating error. -// - -// -// WebRtcSpl_AnalysisQMF(...) -// -// Splits a 0-2*F Hz signal into two sub bands: 0-F Hz and F-2*F Hz. The -// current version has F = 8000, therefore, a super-wideband audio signal is -// split to lower-band 0-8 kHz and upper-band 8-16 kHz. -// -// Input: -// - in_data : Wide band speech signal, 320 samples (10 ms) -// -// Input & Output: -// - filter_state1 : Filter state for first All-pass filter -// - filter_state2 : Filter state for second All-pass filter -// -// Output: -// - low_band : Lower-band signal 0-8 kHz band, 160 samples (10 ms) -// - high_band : Upper-band signal 8-16 kHz band (flipped in frequency -// domain), 160 samples (10 ms) -// - -// -// WebRtcSpl_SynthesisQMF(...) -// -// Combines the two sub bands (0-F and F-2*F Hz) into a signal of 0-2*F -// Hz, (current version has F = 8000 Hz). So the filter combines lower-band -// (0-8 kHz) and upper-band (8-16 kHz) channels to obtain super-wideband 0-16 -// kHz audio. -// -// Input: -// - low_band : The signal with the 0-8 kHz band, 160 samples (10 ms) -// - high_band : The signal with the 8-16 kHz band, 160 samples (10 ms) -// -// Input & Output: -// - filter_state1 : Filter state for first All-pass filter -// - filter_state2 : Filter state for second All-pass filter -// -// Output: -// - out_data : Super-wideband speech signal, 0-16 kHz -// - -// WebRtc_Word16 WebRtcSpl_SatW32ToW16(...) -// -// This function saturates a 32-bit word into a 16-bit word. -// -// Input: -// - value32 : The value of a 32-bit word. -// -// Output: -// - out16 : the saturated 16-bit word. -// - -// int32_t WebRtc_MulAccumW16(...) -// -// This function multiply a 16-bit word by a 16-bit word, and accumulate this -// value to a 32-bit integer. -// -// Input: -// - a : The value of the first 16-bit word. -// - b : The value of the second 16-bit word. -// - c : The value of an 32-bit integer. -// -// Return Value: The value of a * b + c. -// - -// WebRtc_Word16 WebRtcSpl_get_version(...) -// -// This function gives the version string of the Signal Processing Library. -// -// Input: -// - length_in_bytes : The size of Allocated space (in Bytes) where -// the version number is written to (in string format). -// -// Output: -// - version : Pointer to a buffer where the version number is written to. -//
diff --git a/src/common_audio/signal_processing/include/spl_inl.h b/src/common_audio/signal_processing/include/spl_inl.h deleted file mode 100644 index 1cde181..0000000 --- a/src/common_audio/signal_processing/include/spl_inl.h +++ /dev/null
@@ -1,163 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -// This header file includes the inline functions in -// the fix point signal processing library. - -#ifndef WEBRTC_SPL_SPL_INL_H_ -#define WEBRTC_SPL_SPL_INL_H_ - -#ifdef WEBRTC_ARCH_ARM_V7 -#include "spl_inl_armv7.h" -#else - -static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { - WebRtc_Word16 out16 = (WebRtc_Word16) value32; - - if (value32 > 32767) - out16 = 32767; - else if (value32 < -32768) - out16 = -32768; - - return out16; -} - -static __inline WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a, - WebRtc_Word16 b) { - return WebRtcSpl_SatW32ToW16((WebRtc_Word32) a + (WebRtc_Word32) b); -} - -static __inline WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, - WebRtc_Word16 var2) { - return WebRtcSpl_SatW32ToW16((WebRtc_Word32) var1 - (WebRtc_Word32) var2); -} - -static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) { - int bits; - - if (0xFFFF0000 & n) { - bits = 16; - } else { - bits = 0; - } - if (0x0000FF00 & (n >> bits)) bits += 8; - if (0x000000F0 & (n >> bits)) bits += 4; - if (0x0000000C & (n >> bits)) bits += 2; - if (0x00000002 & (n >> bits)) bits += 1; - if (0x00000001 & (n >> bits)) bits += 1; - - return bits; -} - -static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { - int zeros; - - if (a <= 0) a ^= 0xFFFFFFFF; - - if (!(0xFFFF8000 & a)) { - zeros = 16; - } else { - zeros = 0; - } - if (!(0xFF800000 & (a << zeros))) zeros += 8; - if (!(0xF8000000 & (a << zeros))) zeros += 4; - if (!(0xE0000000 & (a << zeros))) zeros += 2; - if (!(0xC0000000 & (a << zeros))) zeros += 1; - - return zeros; -} - -static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) { - int zeros; - - if (a == 0) return 0; - - if (!(0xFFFF0000 & a)) { - zeros = 16; - } else { - zeros = 0; - } - if (!(0xFF000000 & (a << zeros))) zeros += 8; - if (!(0xF0000000 & (a << zeros))) zeros += 4; - if (!(0xC0000000 & (a << zeros))) zeros += 2; - if (!(0x80000000 & (a << zeros))) zeros += 1; - - return zeros; -} - -static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { - int zeros; - - if (a <= 0) a ^= 0xFFFF; - - if (!(0xFF80 & a)) { - zeros = 8; - } else { - zeros = 0; - } - if (!(0xF800 & (a << zeros))) zeros += 4; - if (!(0xE000 & (a << zeros))) zeros += 2; - if (!(0xC000 & (a << zeros))) zeros += 1; - - return zeros; -} - -static __inline int32_t WebRtc_MulAccumW16(int16_t a, - int16_t b, - int32_t c) { - return (a * b + c); -} - -#endif // WEBRTC_ARCH_ARM_V7 - -// The following functions have no optimized versions. -// TODO(kma): Consider saturating add/sub instructions in X86 platform. -static __inline WebRtc_Word32 WebRtcSpl_AddSatW32(WebRtc_Word32 l_var1, - WebRtc_Word32 l_var2) { - WebRtc_Word32 l_sum; - - // Perform long addition - l_sum = l_var1 + l_var2; - - if (l_var1 < 0) { // Check for underflow. - if ((l_var2 < 0) && (l_sum >= 0)) { - l_sum = (WebRtc_Word32)0x80000000; - } - } else { // Check for overflow. - if ((l_var2 > 0) && (l_sum < 0)) { - l_sum = (WebRtc_Word32)0x7FFFFFFF; - } - } - - return l_sum; -} - -static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1, - WebRtc_Word32 l_var2) { - WebRtc_Word32 l_diff; - - // Perform subtraction. - l_diff = l_var1 - l_var2; - - if (l_var1 < 0) { // Check for underflow. - if ((l_var2 > 0) && (l_diff > 0)) { - l_diff = (WebRtc_Word32)0x80000000; - } - } else { // Check for overflow. - if ((l_var2 < 0) && (l_diff < 0)) { - l_diff = (WebRtc_Word32)0x7FFFFFFF; - } - } - - return l_diff; -} - -#endif // WEBRTC_SPL_SPL_INL_H_
diff --git a/src/common_audio/signal_processing/include/spl_inl_armv7.h b/src/common_audio/signal_processing/include/spl_inl_armv7.h deleted file mode 100644 index 2eff496..0000000 --- a/src/common_audio/signal_processing/include/spl_inl_armv7.h +++ /dev/null
@@ -1,161 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* This header file includes the inline functions for ARM processors in - * the fix point signal processing library. - */ - -#ifndef WEBRTC_SPL_SPL_INL_ARMV7_H_ -#define WEBRTC_SPL_SPL_INL_ARMV7_H_ - -/* TODO(kma): Replace some assembly code with GCC intrinsics - * (e.g. __builtin_clz). - */ - -/* This function produces result that is not bit exact with that by the generic - * C version in some cases, although the former is at least as accurate as the - * later. - */ -static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_32_RSFT16(WebRtc_Word16 a, - WebRtc_Word32 b) { - WebRtc_Word32 tmp = 0; - __asm __volatile ("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a)); - return tmp; -} - -/* This function produces result that is not bit exact with that by the generic - * C version in some cases, although the former is at least as accurate as the - * later. - */ -static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32(WebRtc_Word16 a, - WebRtc_Word16 b, - WebRtc_Word32 c) { - WebRtc_Word32 tmp = 0; - __asm __volatile ( - "pkhbt %[tmp], %[b], %[a], lsl #16\n\t" - "smmulr %[tmp], %[tmp], %[c]\n\t" - :[tmp]"+r"(tmp) - :[a]"r"(a), - [b]"r"(b), - [c]"r"(c) - ); - return tmp; -} - -static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32BI(WebRtc_Word32 a, - WebRtc_Word32 b) { - WebRtc_Word32 tmp = 0; - __asm volatile ("smmulr %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); - return tmp; -} - -static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_16(WebRtc_Word16 a, - WebRtc_Word16 b) { - WebRtc_Word32 tmp = 0; - __asm __volatile ("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); - return tmp; -} - -static __inline int32_t WebRtc_MulAccumW16(int16_t a, - int16_t b, - int32_t c) { - int32_t tmp = 0; - __asm __volatile ("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c)); - return tmp; -} - -static __inline WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a, - WebRtc_Word16 b) { - WebRtc_Word32 s_sum = 0; - - __asm __volatile ("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b)); - - return (WebRtc_Word16) s_sum; -} - -/* TODO(kma): find the cause of unittest errors by the next two functions: - * http://code.google.com/p/webrtc/issues/detail?id=740. - */ -#if 0 -static __inline WebRtc_Word32 WebRtcSpl_AddSatW32(WebRtc_Word32 l_var1, - WebRtc_Word32 l_var2) { - WebRtc_Word32 l_sum = 0; - - __asm __volatile ("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2)); - - return l_sum; -} - -static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1, - WebRtc_Word32 l_var2) { - WebRtc_Word32 l_sub = 0; - - __asm __volatile ("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2)); - - return l_sub; -} -#endif - -static __inline WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, - WebRtc_Word16 var2) { - WebRtc_Word32 s_sub = 0; - - __asm __volatile ("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2)); - - return (WebRtc_Word16)s_sub; -} - -static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) { - WebRtc_Word32 tmp = 0; - - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n)); - - return (WebRtc_Word16)(32 - tmp); -} - -static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { - WebRtc_Word32 tmp = 0; - - if (a <= 0) a ^= 0xFFFFFFFF; - - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); - - return tmp - 1; -} - -static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) { - int tmp = 0; - - if (a == 0) return 0; - - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); - - return tmp; -} - -static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { - WebRtc_Word32 tmp = 0; - - if (a <= 0) a ^= 0xFFFFFFFF; - - __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(a)); - - return tmp - 17; -} - -static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { - WebRtc_Word16 out16 = 0; - - __asm __volatile ("ssat %r0, #16, %r1" : "=r"(out16) : "r"(value32)); - - return out16; -} -#endif // WEBRTC_SPL_SPL_INL_ARMV7_H_
diff --git a/src/common_audio/signal_processing/levinson_durbin.c b/src/common_audio/signal_processing/levinson_durbin.c deleted file mode 100644 index 4e11cdb..0000000 --- a/src/common_audio/signal_processing/levinson_durbin.c +++ /dev/null
@@ -1,259 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_LevinsonDurbin(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -#define SPL_LEVINSON_MAXORDER 20 - -WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRtc_Word16 *K, - WebRtc_Word16 order) -{ - WebRtc_Word16 i, j; - // Auto-correlation coefficients in high precision - WebRtc_Word16 R_hi[SPL_LEVINSON_MAXORDER + 1], R_low[SPL_LEVINSON_MAXORDER + 1]; - // LPC coefficients in high precision - WebRtc_Word16 A_hi[SPL_LEVINSON_MAXORDER + 1], A_low[SPL_LEVINSON_MAXORDER + 1]; - // LPC coefficients for next iteration - WebRtc_Word16 A_upd_hi[SPL_LEVINSON_MAXORDER + 1], A_upd_low[SPL_LEVINSON_MAXORDER + 1]; - // Reflection coefficient in high precision - WebRtc_Word16 K_hi, K_low; - // Prediction gain Alpha in high precision and with scale factor - WebRtc_Word16 Alpha_hi, Alpha_low, Alpha_exp; - WebRtc_Word16 tmp_hi, tmp_low; - WebRtc_Word32 temp1W32, temp2W32, temp3W32; - WebRtc_Word16 norm; - - // Normalize the autocorrelation R[0]...R[order+1] - - norm = WebRtcSpl_NormW32(R[0]); - - for (i = order; i >= 0; i--) - { - temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm); - // Put R in hi and low format - R_hi[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - R_low[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[i], 16)), 1); - } - - // K = A[1] = -R[1] / R[0] - - temp2W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[1],16) - + WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_low[1],1); // R[1] in Q31 - temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); // abs R[1] - temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); // abs(R[1])/R[0] in Q31 - // Put back the sign on R[1] - if (temp2W32 > 0) - { - temp1W32 = -temp1W32; - } - - // Put K in hi and low format - K_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - K_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)K_hi, 16)), 1); - - // Store first reflection coefficient - K[0] = K_hi; - - temp1W32 = WEBRTC_SPL_RSHIFT_W32(temp1W32, 4); // A[1] in Q27 - - // Put A[1] in hi and low format - A_hi[1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - A_low[1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[1], 16)), 1); - - // Alpha = R[0] * (1-K^2) - - temp1W32 = (((WEBRTC_SPL_MUL_16_16(K_hi, K_low) >> 14) + WEBRTC_SPL_MUL_16_16(K_hi, K_hi)) - << 1); // temp1W32 = k^2 in Q31 - - temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0 - temp1W32 = (WebRtc_Word32)0x7fffffffL - temp1W32; // temp1W32 = (1 - K[0]*K[0]) in Q31 - - // Store temp1W32 = 1 - K[0]*K[0] on hi and low format - tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - - // Calculate Alpha in Q31 - temp1W32 = ((WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_hi) - + (WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_low) >> 15) - + (WEBRTC_SPL_MUL_16_16(R_low[0], tmp_hi) >> 15)) << 1); - - // Normalize Alpha and put it in hi and low format - - Alpha_exp = WebRtcSpl_NormW32(temp1W32); - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, Alpha_exp); - Alpha_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - Alpha_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)Alpha_hi, 16)), 1); - - // Perform the iterative calculations in the Levinson-Durbin algorithm - - for (i = 2; i <= order; i++) - { - /* ---- - temp1W32 = R[i] + > R[j]*A[i-j] - / - ---- - j=1..i-1 - */ - - temp1W32 = 0; - - for (j = 1; j < i; j++) - { - // temp1W32 is in Q31 - temp1W32 += ((WEBRTC_SPL_MUL_16_16(R_hi[j], A_hi[i-j]) << 1) - + (((WEBRTC_SPL_MUL_16_16(R_hi[j], A_low[i-j]) >> 15) - + (WEBRTC_SPL_MUL_16_16(R_low[j], A_hi[i-j]) >> 15)) << 1)); - } - - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4); - temp1W32 += (WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[i], 16) - + WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_low[i], 1)); - - // K = -temp1W32 / Alpha - temp2W32 = WEBRTC_SPL_ABS_W32(temp1W32); // abs(temp1W32) - temp3W32 = WebRtcSpl_DivW32HiLow(temp2W32, Alpha_hi, Alpha_low); // abs(temp1W32)/Alpha - - // Put the sign of temp1W32 back again - if (temp1W32 > 0) - { - temp3W32 = -temp3W32; - } - - // Use the Alpha shifts from earlier to de-normalize - norm = WebRtcSpl_NormW32(temp3W32); - if ((Alpha_exp <= norm) || (temp3W32 == 0)) - { - temp3W32 = WEBRTC_SPL_LSHIFT_W32(temp3W32, Alpha_exp); - } else - { - if (temp3W32 > 0) - { - temp3W32 = (WebRtc_Word32)0x7fffffffL; - } else - { - temp3W32 = (WebRtc_Word32)0x80000000L; - } - } - - // Put K on hi and low format - K_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp3W32, 16); - K_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp3W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)K_hi, 16)), 1); - - // Store Reflection coefficient in Q15 - K[i - 1] = K_hi; - - // Test for unstable filter. - // If unstable return 0 and let the user decide what to do in that case - - if ((WebRtc_Word32)WEBRTC_SPL_ABS_W16(K_hi) > (WebRtc_Word32)32750) - { - return 0; // Unstable filter - } - - /* - Compute updated LPC coefficient: Anew[i] - Anew[j]= A[j] + K*A[i-j] for j=1..i-1 - Anew[i]= K - */ - - for (j = 1; j < i; j++) - { - // temp1W32 = A[j] in Q27 - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[j],16) - + WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_low[j],1); - - // temp1W32 += K*A[i-j] in Q27 - temp1W32 += ((WEBRTC_SPL_MUL_16_16(K_hi, A_hi[i-j]) - + (WEBRTC_SPL_MUL_16_16(K_hi, A_low[i-j]) >> 15) - + (WEBRTC_SPL_MUL_16_16(K_low, A_hi[i-j]) >> 15)) << 1); - - // Put Anew in hi and low format - A_upd_hi[j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - A_upd_low[j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_upd_hi[j], 16)), 1); - } - - // temp3W32 = K in Q27 (Convert from Q31 to Q27) - temp3W32 = WEBRTC_SPL_RSHIFT_W32(temp3W32, 4); - - // Store Anew in hi and low format - A_upd_hi[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp3W32, 16); - A_upd_low[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp3W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_upd_hi[i], 16)), 1); - - // Alpha = Alpha * (1-K^2) - - temp1W32 = (((WEBRTC_SPL_MUL_16_16(K_hi, K_low) >> 14) - + WEBRTC_SPL_MUL_16_16(K_hi, K_hi)) << 1); // K*K in Q31 - - temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0 - temp1W32 = (WebRtc_Word32)0x7fffffffL - temp1W32; // 1 - K*K in Q31 - - // Convert 1- K^2 in hi and low format - tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - - // Calculate Alpha = Alpha * (1-K^2) in Q31 - temp1W32 = ((WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_hi) - + (WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_low) >> 15) - + (WEBRTC_SPL_MUL_16_16(Alpha_low, tmp_hi) >> 15)) << 1); - - // Normalize Alpha and store it on hi and low format - - norm = WebRtcSpl_NormW32(temp1W32); - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, norm); - - Alpha_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - Alpha_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)Alpha_hi, 16)), 1); - - // Update the total normalization of Alpha - Alpha_exp = Alpha_exp + norm; - - // Update A[] - - for (j = 1; j <= i; j++) - { - A_hi[j] = A_upd_hi[j]; - A_low[j] = A_upd_low[j]; - } - } - - /* - Set A[0] to 1.0 and store the A[i] i=1...order in Q12 - (Convert from Q27 and use rounding) - */ - - A[0] = 4096; - - for (i = 1; i <= order; i++) - { - // temp1W32 in Q27 - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[i], 16) - + WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_low[i], 1); - // Round and store upper word - A[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32<<1)+(WebRtc_Word32)32768, 16); - } - return 1; // Stable filters -}
diff --git a/src/common_audio/signal_processing/lpc_to_refl_coef.c b/src/common_audio/signal_processing/lpc_to_refl_coef.c deleted file mode 100644 index 2cb83c2..0000000 --- a/src/common_audio/signal_processing/lpc_to_refl_coef.c +++ /dev/null
@@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_LpcToReflCoef(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -#define SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER 50 - -void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* a16, int use_order, WebRtc_Word16* k16) -{ - int m, k; - WebRtc_Word32 tmp32[SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER]; - WebRtc_Word32 tmp_inv_denom32; - WebRtc_Word16 tmp_inv_denom16; - - k16[use_order - 1] = WEBRTC_SPL_LSHIFT_W16(a16[use_order], 3); //Q12<<3 => Q15 - for (m = use_order - 1; m > 0; m--) - { - // (1 - k^2) in Q30 - tmp_inv_denom32 = ((WebRtc_Word32)1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); - // (1 - k^2) in Q15 - tmp_inv_denom16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp_inv_denom32, 15); - - for (k = 1; k <= m; k++) - { - // tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]); - - // [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28 - tmp32[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)a16[k], 16) - - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(k16[m], a16[m-k+1]), 1); - - tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13 - } - - for (k = 1; k < m; k++) - { - a16[k] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32[k], 1); //Q13>>1 => Q12 - } - - tmp32[m] = WEBRTC_SPL_SAT(8191, tmp32[m], -8191); - k16[m - 1] = (WebRtc_Word16)WEBRTC_SPL_LSHIFT_W32(tmp32[m], 2); //Q13<<2 => Q15 - } - return; -}
diff --git a/src/common_audio/signal_processing/min_max_operations.c b/src/common_audio/signal_processing/min_max_operations.c deleted file mode 100644 index d3539d7..0000000 --- a/src/common_audio/signal_processing/min_max_operations.c +++ /dev/null
@@ -1,247 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * This file contains the implementation of functions - * WebRtcSpl_MaxAbsValueW16() - * WebRtcSpl_MaxAbsValueW32() - * WebRtcSpl_MaxValueW16() - * WebRtcSpl_MaxValueW32() - * WebRtcSpl_MinValueW16() - * WebRtcSpl_MinValueW32() - * WebRtcSpl_MaxAbsIndexW16() - * WebRtcSpl_MaxIndexW16() - * WebRtcSpl_MaxIndexW32() - * WebRtcSpl_MinIndexW16() - * WebRtcSpl_MinIndexW32() - * - */ - -#include "signal_processing_library.h" - -#include <stdlib.h> - -// TODO(bjorn/kma): Consolidate function pairs (e.g. combine -// WebRtcSpl_MaxAbsValueW16 and WebRtcSpl_MaxAbsIndexW16 into a single one.) - -// TODO(kma): Move the code in the #ifndef block into min_max_operations_c.c. -#ifndef WEBRTC_ARCH_ARM_NEON - -// Maximum absolute value of word16 vector. -int16_t WebRtcSpl_MaxAbsValueW16(const int16_t* vector, int length) { - int i = 0, absolute = 0, maximum = 0; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - absolute = abs((int)vector[i]); - - if (absolute > maximum) { - maximum = absolute; - } - } - - // Guard the case for abs(-32768). - if (maximum > WEBRTC_SPL_WORD16_MAX) { - maximum = WEBRTC_SPL_WORD16_MAX; - } - - return (int16_t)maximum; -} - -// Maximum absolute value of word32 vector. -int32_t WebRtcSpl_MaxAbsValueW32(const int32_t* vector, int length) { - // Use uint32_t for the local variables, to accommodate the return value - // of abs(0x80000000), which is 0x80000000. - - uint32_t absolute = 0, maximum = 0; - int i = 0; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - absolute = abs((int)vector[i]); - if (absolute > maximum) { - maximum = absolute; - } - } - - maximum = WEBRTC_SPL_MIN(maximum, WEBRTC_SPL_WORD32_MAX); - - return (int32_t)maximum; -} - -// Maximum value of word16 vector. -int16_t WebRtcSpl_MaxValueW16(const int16_t* vector, int length) { - int16_t maximum = WEBRTC_SPL_WORD16_MIN; - int i = 0; - - if (vector == NULL || length <= 0) { - return maximum; - } - - for (i = 0; i < length; i++) { - if (vector[i] > maximum) - maximum = vector[i]; - } - return maximum; -} - -// Maximum value of word32 vector. -int32_t WebRtcSpl_MaxValueW32(const int32_t* vector, int length) { - int32_t maximum = WEBRTC_SPL_WORD32_MIN; - int i = 0; - - if (vector == NULL || length <= 0) { - return maximum; - } - - for (i = 0; i < length; i++) { - if (vector[i] > maximum) - maximum = vector[i]; - } - return maximum; -} - -// Minimum value of word16 vector. -int16_t WebRtcSpl_MinValueW16(const int16_t* vector, int length) { - int16_t minimum = WEBRTC_SPL_WORD16_MAX; - int i = 0; - - if (vector == NULL || length <= 0) { - return minimum; - } - - for (i = 0; i < length; i++) { - if (vector[i] < minimum) - minimum = vector[i]; - } - return minimum; -} - -// Minimum value of word32 vector. -int32_t WebRtcSpl_MinValueW32(const int32_t* vector, int length) { - int32_t minimum = WEBRTC_SPL_WORD32_MAX; - int i = 0; - - if (vector == NULL || length <= 0) { - return minimum; - } - - for (i = 0; i < length; i++) { - if (vector[i] < minimum) - minimum = vector[i]; - } - return minimum; -} -#endif // WEBRTC_ARCH_ARM_NEON - - -// Index of maximum absolute value in a word16 vector. -int WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, int length) { - // Use type int for local variables, to accomodate the value of abs(-32768). - - int i = 0, absolute = 0, maximum = 0, index = 0; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - absolute = abs((int)vector[i]); - - if (absolute > maximum) { - maximum = absolute; - index = i; - } - } - - return index; -} - -// Index of maximum value in a word16 vector. -int WebRtcSpl_MaxIndexW16(const int16_t* vector, int length) { - int i = 0, index = 0; - int16_t maximum = WEBRTC_SPL_WORD16_MIN; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - if (vector[i] > maximum) { - maximum = vector[i]; - index = i; - } - } - - return index; -} - -// Index of maximum value in a word32 vector. -int WebRtcSpl_MaxIndexW32(const int32_t* vector, int length) { - int i = 0, index = 0; - int32_t maximum = WEBRTC_SPL_WORD32_MIN; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - if (vector[i] > maximum) { - maximum = vector[i]; - index = i; - } - } - - return index; -} - -// Index of minimum value in a word16 vector. -int WebRtcSpl_MinIndexW16(const int16_t* vector, int length) { - int i = 0, index = 0; - int16_t minimum = WEBRTC_SPL_WORD16_MAX; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - if (vector[i] < minimum) { - minimum = vector[i]; - index = i; - } - } - - return index; -} - -// Index of minimum value in a word32 vector. -int WebRtcSpl_MinIndexW32(const int32_t* vector, int length) { - int i = 0, index = 0; - int32_t minimum = WEBRTC_SPL_WORD32_MAX; - - if (vector == NULL || length <= 0) { - return -1; - } - - for (i = 0; i < length; i++) { - if (vector[i] < minimum) { - minimum = vector[i]; - index = i; - } - } - - return index; -}
diff --git a/src/common_audio/signal_processing/min_max_operations_neon.s b/src/common_audio/signal_processing/min_max_operations_neon.s deleted file mode 100644 index 01831ef..0000000 --- a/src/common_audio/signal_processing/min_max_operations_neon.s +++ /dev/null
@@ -1,305 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ This file contains the function WebRtcSpl_MaxAbsValueW16(), optimized for -@ ARM Neon platform. The description header can be found in -@ signal_processing_library.h -@ -@ The reference C code is in file min_max_operations.c. Code here is basically -@ a loop unrolling by 8 with Neon instructions. Bit-exact. - -.arch armv7-a -.fpu neon -.global WebRtcSpl_MaxAbsValueW16 -.global WebRtcSpl_MaxAbsValueW32 -.global WebRtcSpl_MaxValueW16 -.global WebRtcSpl_MaxValueW32 -.global WebRtcSpl_MinValueW16 -.global WebRtcSpl_MinValueW32 -.align 2 - -@ int16_t WebRtcSpl_MaxAbsValueW16(const int16_t* vector, int length); -WebRtcSpl_MaxAbsValueW16: -.fnstart - - mov r2, #-1 @ Initialize the return value. - cmp r0, #0 - beq END_MAX_ABS_VALUE_W16 - cmp r1, #0 - ble END_MAX_ABS_VALUE_W16 - - cmp r1, #8 - blt LOOP_MAX_ABS_VALUE_W16 - - vmov.i16 q12, #0 - sub r1, #8 @ Counter for loops - -LOOP_UNROLLED_BY_8_MAX_ABS_VALUE_W16: - vld1.16 {q13}, [r0]! - subs r1, #8 - vabs.s16 q13, q13 @ Note vabs doesn't change the value of -32768. - vmax.u16 q12, q13 @ Use u16 so we don't lose the value -32768. - bge LOOP_UNROLLED_BY_8_MAX_ABS_VALUE_W16 - - @ Find the maximum value in the Neon registers and move it to r2. - vmax.u16 d24, d25 - vpmax.u16 d24, d24 - vpmax.u16 d24, d24 - adds r1, #8 - vmov.u16 r2, d24[0] - beq END_MAX_ABS_VALUE_W16 - -LOOP_MAX_ABS_VALUE_W16: - ldrsh r3, [r0], #2 - eor r12, r3, r3, asr #31 @ eor and then sub, to get absolute value. - sub r12, r12, r3, asr #31 - cmp r2, r12 - movlt r2, r12 - subs r1, #1 - bne LOOP_MAX_ABS_VALUE_W16 - -END_MAX_ABS_VALUE_W16: - cmp r2, #0x8000 @ Guard against the case for -32768. - subeq r2, #1 - mov r0, r2 - bx lr - -.fnend - -@ int32_t WebRtcSpl_MaxAbsValueW32(const int32_t* vector, int length); -WebRtcSpl_MaxAbsValueW32: -.fnstart - - cmp r0, #0 - moveq r0, #-1 - beq EXIT @ Return -1 for a NULL pointer. - cmp r1, #0 @ length - movle r0, #-1 - ble EXIT @ Return -1 if length <= 0. - - vmov.i32 q11, #0 - vmov.i32 q12, #0 - cmp r1, #8 - blt LOOP_MAX_ABS_VALUE_W32 - - sub r1, #8 @ Counter for loops - -LOOP_UNROLLED_BY_8_MAX_ABS_VALUE_W32: - vld1.32 {q13, q14}, [r0]! - subs r1, #8 @ Counter for loops - vabs.s32 q13, q13 @ vabs doesn't change the value of 0x80000000. - vabs.s32 q14, q14 - vmax.u32 q11, q13 @ Use u32 so we don't lose the value 0x80000000. - vmax.u32 q12, q14 - bge LOOP_UNROLLED_BY_8_MAX_ABS_VALUE_W32 - - @ Find the maximum value in the Neon registers and move it to r2. - vmax.u32 q12, q11 - vmax.u32 d24, d25 - vpmax.u32 d24, d24 - adds r1, #8 - vmov.u32 r2, d24[0] - beq END_MAX_ABS_VALUE_W32 - -LOOP_MAX_ABS_VALUE_W32: - ldr r3, [r0], #4 - eor r12, r3, r3, asr #31 @ eor and then sub, to get absolute value. - sub r12, r12, r3, asr #31 - cmp r2, r12 - movcc r2, r12 - subs r1, #1 - bne LOOP_MAX_ABS_VALUE_W32 - -END_MAX_ABS_VALUE_W32: - mvn r0, #0x80000000 @ Guard against the case for 0x80000000. - cmp r2, r0 - movcc r0, r2 - -EXIT: - bx lr - -.fnend - -@ int16_t WebRtcSpl_MaxValueW16(const int16_t* vector, int length); -WebRtcSpl_MaxValueW16: -.fnstart - - mov r2, #0x8000 @ Initialize the return value. - cmp r0, #0 - beq END_MAX_VALUE_W16 - cmp r1, #0 - ble END_MAX_VALUE_W16 - - vmov.i16 q12, #0x8000 - cmp r1, #8 - blt LOOP_MAX_VALUE_W16 - - sub r1, #8 @ Counter for loops - -LOOP_UNROLLED_BY_8_MAX_VALUE_W16: - vld1.16 {q13}, [r0]! - subs r1, #8 - vmax.s16 q12, q13 - bge LOOP_UNROLLED_BY_8_MAX_VALUE_W16 - - @ Find the maximum value in the Neon registers and move it to r2. - vmax.s16 d24, d25 - vpmax.s16 d24, d24 - vpmax.s16 d24, d24 - adds r1, #8 - vmov.u16 r2, d24[0] - beq END_MAX_VALUE_W16 - -LOOP_MAX_VALUE_W16: - ldrsh r3, [r0], #2 - cmp r2, r3 - movlt r2, r3 - subs r1, #1 - bne LOOP_MAX_VALUE_W16 - -END_MAX_VALUE_W16: - mov r0, r2 - bx lr - -.fnend - -@ int32_t WebRtcSpl_MaxValueW32(const int32_t* vector, int length); -WebRtcSpl_MaxValueW32: -.fnstart - - mov r2, #0x80000000 @ Initialize the return value. - cmp r0, #0 - beq END_MAX_VALUE_W32 - cmp r1, #0 - ble END_MAX_VALUE_W32 - - vmov.i32 q11, #0x80000000 - vmov.i32 q12, #0x80000000 - cmp r1, #8 - blt LOOP_MAX_VALUE_W32 - - sub r1, #8 @ Counter for loops - -LOOP_UNROLLED_BY_8_MAX_VALUE_W32: - vld1.32 {q13, q14}, [r0]! - subs r1, #8 - vmax.s32 q11, q13 - vmax.s32 q12, q14 - bge LOOP_UNROLLED_BY_8_MAX_VALUE_W32 - - @ Find the maximum value in the Neon registers and move it to r2. - vmax.s32 q12, q11 - vpmax.s32 d24, d25 - vpmax.s32 d24, d24 - adds r1, #8 - vmov.s32 r2, d24[0] - beq END_MAX_VALUE_W32 - -LOOP_MAX_VALUE_W32: - ldr r3, [r0], #4 - cmp r2, r3 - movlt r2, r3 - subs r1, #1 - bne LOOP_MAX_VALUE_W32 - -END_MAX_VALUE_W32: - mov r0, r2 - bx lr - -.fnend - -@ int16_t WebRtcSpl_MinValueW16(const int16_t* vector, int length); -WebRtcSpl_MinValueW16: -.fnstart - - movw r2, #0x7FFF @ Initialize the return value. - cmp r0, #0 - beq END_MIN_VALUE_W16 - cmp r1, #0 - ble END_MIN_VALUE_W16 - - vmov.i16 q12, #0x7FFF - cmp r1, #8 - blt LOOP_MIN_VALUE_W16 - - sub r1, #8 @ Counter for loops - -LOOP_UNROLLED_BY_8_MIN_VALUE_W16: - vld1.16 {q13}, [r0]! - subs r1, #8 - vmin.s16 q12, q13 - bge LOOP_UNROLLED_BY_8_MIN_VALUE_W16 - - @ Find the maximum value in the Neon registers and move it to r2. - vmin.s16 d24, d25 - vpmin.s16 d24, d24 - vpmin.s16 d24, d24 - adds r1, #8 - vmov.s16 r2, d24[0] - sxth r2, r2 - beq END_MIN_VALUE_W16 - -LOOP_MIN_VALUE_W16: - ldrsh r3, [r0], #2 - cmp r2, r3 - movge r2, r3 - subs r1, #1 - bne LOOP_MIN_VALUE_W16 - -END_MIN_VALUE_W16: - mov r0, r2 - bx lr - -.fnend - -@ int32_t WebRtcSpl_MinValueW32(const int32_t* vector, int length); -WebRtcSpl_MinValueW32: -.fnstart - - mov r2, #0x7FFFFFFF @ Initialize the return value. - cmp r0, #0 - beq END_MIN_VALUE_W32 - cmp r1, #0 - ble END_MIN_VALUE_W32 - - vdup.32 q11, r2 - vdup.32 q12, r2 - cmp r1, #8 - blt LOOP_MIN_VALUE_W32 - - sub r1, #8 @ Counter for loops - -LOOP_UNROLLED_BY_8_MIN_VALUE_W32: - vld1.32 {q13, q14}, [r0]! - subs r1, #8 - vmin.s32 q11, q13 - vmin.s32 q12, q14 - bge LOOP_UNROLLED_BY_8_MIN_VALUE_W32 - - @ Find the maximum value in the Neon registers and move it to r2. - vmin.s32 q12, q11 - vpmin.s32 d24, d25 - vpmin.s32 d24, d24 - adds r1, #8 - vmov.s32 r2, d24[0] - beq END_MIN_VALUE_W32 - -LOOP_MIN_VALUE_W32: - ldr r3, [r0], #4 - cmp r2, r3 - movge r2, r3 - subs r1, #1 - bne LOOP_MIN_VALUE_W32 - -END_MIN_VALUE_W32: - mov r0, r2 - bx lr - -.fnend
diff --git a/src/common_audio/signal_processing/randomization_functions.c b/src/common_audio/signal_processing/randomization_functions.c deleted file mode 100644 index 04271ad..0000000 --- a/src/common_audio/signal_processing/randomization_functions.c +++ /dev/null
@@ -1,119 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains implementations of the randomization functions - * WebRtcSpl_IncreaseSeed() - * WebRtcSpl_RandU() - * WebRtcSpl_RandN() - * WebRtcSpl_RandUArray() - * - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -static const WebRtc_Word16 kRandNTable[] = { - 9178, -7260, 40, 10189, 4894, -3531, -13779, 14764, - -4008, -8884, -8990, 1008, 7368, 5184, 3251, -5817, - -9786, 5963, 1770, 8066, -7135, 10772, -2298, 1361, - 6484, 2241, -8633, 792, 199, -3344, 6553, -10079, - -15040, 95, 11608, -12469, 14161, -4176, 2476, 6403, - 13685, -16005, 6646, 2239, 10916, -3004, -602, -3141, - 2142, 14144, -5829, 5305, 8209, 4713, 2697, -5112, - 16092, -1210, -2891, -6631, -5360, -11878, -6781, -2739, - -6392, 536, 10923, 10872, 5059, -4748, -7770, 5477, - 38, -1025, -2892, 1638, 6304, 14375, -11028, 1553, - -1565, 10762, -393, 4040, 5257, 12310, 6554, -4799, - 4899, -6354, 1603, -1048, -2220, 8247, -186, -8944, - -12004, 2332, 4801, -4933, 6371, 131, 8614, -5927, - -8287, -22760, 4033, -15162, 3385, 3246, 3153, -5250, - 3766, 784, 6494, -62, 3531, -1582, 15572, 662, - -3952, -330, -3196, 669, 7236, -2678, -6569, 23319, - -8645, -741, 14830, -15976, 4903, 315, -11342, 10311, - 1858, -7777, 2145, 5436, 5677, -113, -10033, 826, - -1353, 17210, 7768, 986, -1471, 8291, -4982, 8207, - -14911, -6255, -2449, -11881, -7059, -11703, -4338, 8025, - 7538, -2823, -12490, 9470, -1613, -2529, -10092, -7807, - 9480, 6970, -12844, 5123, 3532, 4816, 4803, -8455, - -5045, 14032, -4378, -1643, 5756, -11041, -2732, -16618, - -6430, -18375, -3320, 6098, 5131, -4269, -8840, 2482, - -7048, 1547, -21890, -6505, -7414, -424, -11722, 7955, - 1653, -17299, 1823, 473, -9232, 3337, 1111, 873, - 4018, -8982, 9889, 3531, -11763, -3799, 7373, -4539, - 3231, 7054, -8537, 7616, 6244, 16635, 447, -2915, - 13967, 705, -2669, -1520, -1771, -16188, 5956, 5117, - 6371, -9936, -1448, 2480, 5128, 7550, -8130, 5236, - 8213, -6443, 7707, -1950, -13811, 7218, 7031, -3883, - 67, 5731, -2874, 13480, -3743, 9298, -3280, 3552, - -4425, -18, -3785, -9988, -5357, 5477, -11794, 2117, - 1416, -9935, 3376, 802, -5079, -8243, 12652, 66, - 3653, -2368, 6781, -21895, -7227, 2487, 7839, -385, - 6646, -7016, -4658, 5531, -1705, 834, 129, 3694, - -1343, 2238, -22640, -6417, -11139, 11301, -2945, -3494, - -5626, 185, -3615, -2041, -7972, -3106, -60, -23497, - -1566, 17064, 3519, 2518, 304, -6805, -10269, 2105, - 1936, -426, -736, -8122, -1467, 4238, -6939, -13309, - 360, 7402, -7970, 12576, 3287, 12194, -6289, -16006, - 9171, 4042, -9193, 9123, -2512, 6388, -4734, -8739, - 1028, -5406, -1696, 5889, -666, -4736, 4971, 3565, - 9362, -6292, 3876, -3652, -19666, 7523, -4061, 391, - -11773, 7502, -3763, 4929, -9478, 13278, 2805, 4496, - 7814, 16419, 12455, -14773, 2127, -2746, 3763, 4847, - 3698, 6978, 4751, -6957, -3581, -45, 6252, 1513, - -4797, -7925, 11270, 16188, -2359, -5269, 9376, -10777, - 7262, 20031, -6515, -2208, -5353, 8085, -1341, -1303, - 7333, 5576, 3625, 5763, -7931, 9833, -3371, -10305, - 6534, -13539, -9971, 997, 8464, -4064, -1495, 1857, - 13624, 5458, 9490, -11086, -4524, 12022, -550, -198, - 408, -8455, -7068, 10289, 9712, -3366, 9028, -7621, - -5243, 2362, 6909, 4672, -4933, -1799, 4709, -4563, - -62, -566, 1624, -7010, 14730, -17791, -3697, -2344, - -1741, 7099, -9509, -6855, -1989, 3495, -2289, 2031, - 12784, 891, 14189, -3963, -5683, 421, -12575, 1724, - -12682, -5970, -8169, 3143, -1824, -5488, -5130, 8536, - 12799, 794, 5738, 3459, -11689, -258, -3738, -3775, - -8742, 2333, 8312, -9383, 10331, 13119, 8398, 10644, - -19433, -6446, -16277, -11793, 16284, 9345, 15222, 15834, - 2009, -7349, 130, -14547, 338, -5998, 3337, 21492, - 2406, 7703, -951, 11196, -564, 3406, 2217, 4806, - 2374, -5797, 11839, 8940, -11874, 18213, 2855, 10492 -}; - -WebRtc_UWord32 WebRtcSpl_IncreaseSeed(WebRtc_UWord32 *seed) -{ - seed[0] = (seed[0] * ((WebRtc_Word32)69069) + 1) & (WEBRTC_SPL_MAX_SEED_USED - 1); - return seed[0]; -} - -WebRtc_Word16 WebRtcSpl_RandU(WebRtc_UWord32 *seed) -{ - return (WebRtc_Word16)(WebRtcSpl_IncreaseSeed(seed) >> 16); -} - -WebRtc_Word16 WebRtcSpl_RandN(WebRtc_UWord32 *seed) -{ - return kRandNTable[WebRtcSpl_IncreaseSeed(seed) >> 23]; -} - -// Creates an array of uniformly distributed variables -WebRtc_Word16 WebRtcSpl_RandUArray(WebRtc_Word16* vector, - WebRtc_Word16 vector_length, - WebRtc_UWord32* seed) -{ - int i; - for (i = 0; i < vector_length; i++) - { - vector[i] = WebRtcSpl_RandU(seed); - } - return vector_length; -}
diff --git a/src/common_audio/signal_processing/refl_coef_to_lpc.c b/src/common_audio/signal_processing/refl_coef_to_lpc.c deleted file mode 100644 index d07804d..0000000 --- a/src/common_audio/signal_processing/refl_coef_to_lpc.c +++ /dev/null
@@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_ReflCoefToLpc(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16 *k, int use_order, WebRtc_Word16 *a) -{ - WebRtc_Word16 any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; - WebRtc_Word16 *aptr, *aptr2, *anyptr; - G_CONST WebRtc_Word16 *kptr; - int m, i; - - kptr = k; - *a = 4096; // i.e., (Word16_MAX >> 3)+1. - *any = *a; - a[1] = WEBRTC_SPL_RSHIFT_W16((*k), 3); - - for (m = 1; m < use_order; m++) - { - kptr++; - aptr = a; - aptr++; - aptr2 = &a[m]; - anyptr = any; - anyptr++; - - any[m + 1] = WEBRTC_SPL_RSHIFT_W16((*kptr), 3); - for (i = 0; i < m; i++) - { - *anyptr = (*aptr) - + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15); - anyptr++; - aptr++; - aptr2--; - } - - aptr = a; - anyptr = any; - for (i = 0; i < (m + 2); i++) - { - *aptr = *anyptr; - aptr++; - anyptr++; - } - } -}
diff --git a/src/common_audio/signal_processing/resample.c b/src/common_audio/signal_processing/resample.c deleted file mode 100644 index 19d1778..0000000 --- a/src/common_audio/signal_processing/resample.c +++ /dev/null
@@ -1,505 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the resampling functions for 22 kHz. - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" -#include "resample_by_2_internal.h" - -// Declaration of internally used functions -static void WebRtcSpl_32khzTo22khzIntToShort(const WebRtc_Word32 *In, WebRtc_Word16 *Out, - const WebRtc_Word32 K); - -void WebRtcSpl_32khzTo22khzIntToInt(const WebRtc_Word32 *In, WebRtc_Word32 *Out, - const WebRtc_Word32 K); - -// interpolation coefficients -static const WebRtc_Word16 kCoefficients32To22[5][9] = { - {127, -712, 2359, -6333, 23456, 16775, -3695, 945, -154}, - {-39, 230, -830, 2785, 32366, -2324, 760, -218, 38}, - {117, -663, 2222, -6133, 26634, 13070, -3174, 831, -137}, - {-77, 457, -1677, 5958, 31175, -4136, 1405, -408, 71}, - { 98, -560, 1900, -5406, 29240, 9423, -2480, 663, -110} -}; - -////////////////////// -// 22 kHz -> 16 kHz // -////////////////////// - -// number of subblocks; options: 1, 2, 4, 5, 10 -#define SUB_BLOCKS_22_16 5 - -// 22 -> 16 resampler -void WebRtcSpl_Resample22khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State22khzTo16khz* state, WebRtc_Word32* tmpmem) -{ - int k; - - // process two blocks of 10/SUB_BLOCKS_22_16 ms (to reduce temp buffer size) - for (k = 0; k < SUB_BLOCKS_22_16; k++) - { - ///// 22 --> 44 ///// - // WebRtc_Word16 in[220/SUB_BLOCKS_22_16] - // WebRtc_Word32 out[440/SUB_BLOCKS_22_16] - ///// - WebRtcSpl_UpBy2ShortToInt(in, 220 / SUB_BLOCKS_22_16, tmpmem + 16, state->S_22_44); - - ///// 44 --> 32 ///// - // WebRtc_Word32 in[440/SUB_BLOCKS_22_16] - // WebRtc_Word32 out[320/SUB_BLOCKS_22_16] - ///// - // copy state to and from input array - tmpmem[8] = state->S_44_32[0]; - tmpmem[9] = state->S_44_32[1]; - tmpmem[10] = state->S_44_32[2]; - tmpmem[11] = state->S_44_32[3]; - tmpmem[12] = state->S_44_32[4]; - tmpmem[13] = state->S_44_32[5]; - tmpmem[14] = state->S_44_32[6]; - tmpmem[15] = state->S_44_32[7]; - state->S_44_32[0] = tmpmem[440 / SUB_BLOCKS_22_16 + 8]; - state->S_44_32[1] = tmpmem[440 / SUB_BLOCKS_22_16 + 9]; - state->S_44_32[2] = tmpmem[440 / SUB_BLOCKS_22_16 + 10]; - state->S_44_32[3] = tmpmem[440 / SUB_BLOCKS_22_16 + 11]; - state->S_44_32[4] = tmpmem[440 / SUB_BLOCKS_22_16 + 12]; - state->S_44_32[5] = tmpmem[440 / SUB_BLOCKS_22_16 + 13]; - state->S_44_32[6] = tmpmem[440 / SUB_BLOCKS_22_16 + 14]; - state->S_44_32[7] = tmpmem[440 / SUB_BLOCKS_22_16 + 15]; - - WebRtcSpl_Resample44khzTo32khz(tmpmem + 8, tmpmem, 40 / SUB_BLOCKS_22_16); - - ///// 32 --> 16 ///// - // WebRtc_Word32 in[320/SUB_BLOCKS_22_16] - // WebRtc_Word32 out[160/SUB_BLOCKS_22_16] - ///// - WebRtcSpl_DownBy2IntToShort(tmpmem, 320 / SUB_BLOCKS_22_16, out, state->S_32_16); - - // move input/output pointers 10/SUB_BLOCKS_22_16 ms seconds ahead - in += 220 / SUB_BLOCKS_22_16; - out += 160 / SUB_BLOCKS_22_16; - } -} - -// initialize state of 22 -> 16 resampler -void WebRtcSpl_ResetResample22khzTo16khz(WebRtcSpl_State22khzTo16khz* state) -{ - int k; - for (k = 0; k < 8; k++) - { - state->S_22_44[k] = 0; - state->S_44_32[k] = 0; - state->S_32_16[k] = 0; - } -} - -////////////////////// -// 16 kHz -> 22 kHz // -////////////////////// - -// number of subblocks; options: 1, 2, 4, 5, 10 -#define SUB_BLOCKS_16_22 4 - -// 16 -> 22 resampler -void WebRtcSpl_Resample16khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State16khzTo22khz* state, WebRtc_Word32* tmpmem) -{ - int k; - - // process two blocks of 10/SUB_BLOCKS_16_22 ms (to reduce temp buffer size) - for (k = 0; k < SUB_BLOCKS_16_22; k++) - { - ///// 16 --> 32 ///// - // WebRtc_Word16 in[160/SUB_BLOCKS_16_22] - // WebRtc_Word32 out[320/SUB_BLOCKS_16_22] - ///// - WebRtcSpl_UpBy2ShortToInt(in, 160 / SUB_BLOCKS_16_22, tmpmem + 8, state->S_16_32); - - ///// 32 --> 22 ///// - // WebRtc_Word32 in[320/SUB_BLOCKS_16_22] - // WebRtc_Word32 out[220/SUB_BLOCKS_16_22] - ///// - // copy state to and from input array - tmpmem[0] = state->S_32_22[0]; - tmpmem[1] = state->S_32_22[1]; - tmpmem[2] = state->S_32_22[2]; - tmpmem[3] = state->S_32_22[3]; - tmpmem[4] = state->S_32_22[4]; - tmpmem[5] = state->S_32_22[5]; - tmpmem[6] = state->S_32_22[6]; - tmpmem[7] = state->S_32_22[7]; - state->S_32_22[0] = tmpmem[320 / SUB_BLOCKS_16_22]; - state->S_32_22[1] = tmpmem[320 / SUB_BLOCKS_16_22 + 1]; - state->S_32_22[2] = tmpmem[320 / SUB_BLOCKS_16_22 + 2]; - state->S_32_22[3] = tmpmem[320 / SUB_BLOCKS_16_22 + 3]; - state->S_32_22[4] = tmpmem[320 / SUB_BLOCKS_16_22 + 4]; - state->S_32_22[5] = tmpmem[320 / SUB_BLOCKS_16_22 + 5]; - state->S_32_22[6] = tmpmem[320 / SUB_BLOCKS_16_22 + 6]; - state->S_32_22[7] = tmpmem[320 / SUB_BLOCKS_16_22 + 7]; - - WebRtcSpl_32khzTo22khzIntToShort(tmpmem, out, 20 / SUB_BLOCKS_16_22); - - // move input/output pointers 10/SUB_BLOCKS_16_22 ms seconds ahead - in += 160 / SUB_BLOCKS_16_22; - out += 220 / SUB_BLOCKS_16_22; - } -} - -// initialize state of 16 -> 22 resampler -void WebRtcSpl_ResetResample16khzTo22khz(WebRtcSpl_State16khzTo22khz* state) -{ - int k; - for (k = 0; k < 8; k++) - { - state->S_16_32[k] = 0; - state->S_32_22[k] = 0; - } -} - -////////////////////// -// 22 kHz -> 8 kHz // -////////////////////// - -// number of subblocks; options: 1, 2, 5, 10 -#define SUB_BLOCKS_22_8 2 - -// 22 -> 8 resampler -void WebRtcSpl_Resample22khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State22khzTo8khz* state, WebRtc_Word32* tmpmem) -{ - int k; - - // process two blocks of 10/SUB_BLOCKS_22_8 ms (to reduce temp buffer size) - for (k = 0; k < SUB_BLOCKS_22_8; k++) - { - ///// 22 --> 22 lowpass ///// - // WebRtc_Word16 in[220/SUB_BLOCKS_22_8] - // WebRtc_Word32 out[220/SUB_BLOCKS_22_8] - ///// - WebRtcSpl_LPBy2ShortToInt(in, 220 / SUB_BLOCKS_22_8, tmpmem + 16, state->S_22_22); - - ///// 22 --> 16 ///// - // WebRtc_Word32 in[220/SUB_BLOCKS_22_8] - // WebRtc_Word32 out[160/SUB_BLOCKS_22_8] - ///// - // copy state to and from input array - tmpmem[8] = state->S_22_16[0]; - tmpmem[9] = state->S_22_16[1]; - tmpmem[10] = state->S_22_16[2]; - tmpmem[11] = state->S_22_16[3]; - tmpmem[12] = state->S_22_16[4]; - tmpmem[13] = state->S_22_16[5]; - tmpmem[14] = state->S_22_16[6]; - tmpmem[15] = state->S_22_16[7]; - state->S_22_16[0] = tmpmem[220 / SUB_BLOCKS_22_8 + 8]; - state->S_22_16[1] = tmpmem[220 / SUB_BLOCKS_22_8 + 9]; - state->S_22_16[2] = tmpmem[220 / SUB_BLOCKS_22_8 + 10]; - state->S_22_16[3] = tmpmem[220 / SUB_BLOCKS_22_8 + 11]; - state->S_22_16[4] = tmpmem[220 / SUB_BLOCKS_22_8 + 12]; - state->S_22_16[5] = tmpmem[220 / SUB_BLOCKS_22_8 + 13]; - state->S_22_16[6] = tmpmem[220 / SUB_BLOCKS_22_8 + 14]; - state->S_22_16[7] = tmpmem[220 / SUB_BLOCKS_22_8 + 15]; - - WebRtcSpl_Resample44khzTo32khz(tmpmem + 8, tmpmem, 20 / SUB_BLOCKS_22_8); - - ///// 16 --> 8 ///// - // WebRtc_Word32 in[160/SUB_BLOCKS_22_8] - // WebRtc_Word32 out[80/SUB_BLOCKS_22_8] - ///// - WebRtcSpl_DownBy2IntToShort(tmpmem, 160 / SUB_BLOCKS_22_8, out, state->S_16_8); - - // move input/output pointers 10/SUB_BLOCKS_22_8 ms seconds ahead - in += 220 / SUB_BLOCKS_22_8; - out += 80 / SUB_BLOCKS_22_8; - } -} - -// initialize state of 22 -> 8 resampler -void WebRtcSpl_ResetResample22khzTo8khz(WebRtcSpl_State22khzTo8khz* state) -{ - int k; - for (k = 0; k < 8; k++) - { - state->S_22_22[k] = 0; - state->S_22_22[k + 8] = 0; - state->S_22_16[k] = 0; - state->S_16_8[k] = 0; - } -} - -////////////////////// -// 8 kHz -> 22 kHz // -////////////////////// - -// number of subblocks; options: 1, 2, 5, 10 -#define SUB_BLOCKS_8_22 2 - -// 8 -> 22 resampler -void WebRtcSpl_Resample8khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State8khzTo22khz* state, WebRtc_Word32* tmpmem) -{ - int k; - - // process two blocks of 10/SUB_BLOCKS_8_22 ms (to reduce temp buffer size) - for (k = 0; k < SUB_BLOCKS_8_22; k++) - { - ///// 8 --> 16 ///// - // WebRtc_Word16 in[80/SUB_BLOCKS_8_22] - // WebRtc_Word32 out[160/SUB_BLOCKS_8_22] - ///// - WebRtcSpl_UpBy2ShortToInt(in, 80 / SUB_BLOCKS_8_22, tmpmem + 18, state->S_8_16); - - ///// 16 --> 11 ///// - // WebRtc_Word32 in[160/SUB_BLOCKS_8_22] - // WebRtc_Word32 out[110/SUB_BLOCKS_8_22] - ///// - // copy state to and from input array - tmpmem[10] = state->S_16_11[0]; - tmpmem[11] = state->S_16_11[1]; - tmpmem[12] = state->S_16_11[2]; - tmpmem[13] = state->S_16_11[3]; - tmpmem[14] = state->S_16_11[4]; - tmpmem[15] = state->S_16_11[5]; - tmpmem[16] = state->S_16_11[6]; - tmpmem[17] = state->S_16_11[7]; - state->S_16_11[0] = tmpmem[160 / SUB_BLOCKS_8_22 + 10]; - state->S_16_11[1] = tmpmem[160 / SUB_BLOCKS_8_22 + 11]; - state->S_16_11[2] = tmpmem[160 / SUB_BLOCKS_8_22 + 12]; - state->S_16_11[3] = tmpmem[160 / SUB_BLOCKS_8_22 + 13]; - state->S_16_11[4] = tmpmem[160 / SUB_BLOCKS_8_22 + 14]; - state->S_16_11[5] = tmpmem[160 / SUB_BLOCKS_8_22 + 15]; - state->S_16_11[6] = tmpmem[160 / SUB_BLOCKS_8_22 + 16]; - state->S_16_11[7] = tmpmem[160 / SUB_BLOCKS_8_22 + 17]; - - WebRtcSpl_32khzTo22khzIntToInt(tmpmem + 10, tmpmem, 10 / SUB_BLOCKS_8_22); - - ///// 11 --> 22 ///// - // WebRtc_Word32 in[110/SUB_BLOCKS_8_22] - // WebRtc_Word16 out[220/SUB_BLOCKS_8_22] - ///// - WebRtcSpl_UpBy2IntToShort(tmpmem, 110 / SUB_BLOCKS_8_22, out, state->S_11_22); - - // move input/output pointers 10/SUB_BLOCKS_8_22 ms seconds ahead - in += 80 / SUB_BLOCKS_8_22; - out += 220 / SUB_BLOCKS_8_22; - } -} - -// initialize state of 8 -> 22 resampler -void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state) -{ - int k; - for (k = 0; k < 8; k++) - { - state->S_8_16[k] = 0; - state->S_16_11[k] = 0; - state->S_11_22[k] = 0; - } -} - -// compute two inner-products and store them to output array -static void WebRtcSpl_DotProdIntToInt(const WebRtc_Word32* in1, const WebRtc_Word32* in2, - const WebRtc_Word16* coef_ptr, WebRtc_Word32* out1, - WebRtc_Word32* out2) -{ - WebRtc_Word32 tmp1 = 16384; - WebRtc_Word32 tmp2 = 16384; - WebRtc_Word16 coef; - - coef = coef_ptr[0]; - tmp1 += coef * in1[0]; - tmp2 += coef * in2[-0]; - - coef = coef_ptr[1]; - tmp1 += coef * in1[1]; - tmp2 += coef * in2[-1]; - - coef = coef_ptr[2]; - tmp1 += coef * in1[2]; - tmp2 += coef * in2[-2]; - - coef = coef_ptr[3]; - tmp1 += coef * in1[3]; - tmp2 += coef * in2[-3]; - - coef = coef_ptr[4]; - tmp1 += coef * in1[4]; - tmp2 += coef * in2[-4]; - - coef = coef_ptr[5]; - tmp1 += coef * in1[5]; - tmp2 += coef * in2[-5]; - - coef = coef_ptr[6]; - tmp1 += coef * in1[6]; - tmp2 += coef * in2[-6]; - - coef = coef_ptr[7]; - tmp1 += coef * in1[7]; - tmp2 += coef * in2[-7]; - - coef = coef_ptr[8]; - *out1 = tmp1 + coef * in1[8]; - *out2 = tmp2 + coef * in2[-8]; -} - -// compute two inner-products and store them to output array -static void WebRtcSpl_DotProdIntToShort(const WebRtc_Word32* in1, const WebRtc_Word32* in2, - const WebRtc_Word16* coef_ptr, WebRtc_Word16* out1, - WebRtc_Word16* out2) -{ - WebRtc_Word32 tmp1 = 16384; - WebRtc_Word32 tmp2 = 16384; - WebRtc_Word16 coef; - - coef = coef_ptr[0]; - tmp1 += coef * in1[0]; - tmp2 += coef * in2[-0]; - - coef = coef_ptr[1]; - tmp1 += coef * in1[1]; - tmp2 += coef * in2[-1]; - - coef = coef_ptr[2]; - tmp1 += coef * in1[2]; - tmp2 += coef * in2[-2]; - - coef = coef_ptr[3]; - tmp1 += coef * in1[3]; - tmp2 += coef * in2[-3]; - - coef = coef_ptr[4]; - tmp1 += coef * in1[4]; - tmp2 += coef * in2[-4]; - - coef = coef_ptr[5]; - tmp1 += coef * in1[5]; - tmp2 += coef * in2[-5]; - - coef = coef_ptr[6]; - tmp1 += coef * in1[6]; - tmp2 += coef * in2[-6]; - - coef = coef_ptr[7]; - tmp1 += coef * in1[7]; - tmp2 += coef * in2[-7]; - - coef = coef_ptr[8]; - tmp1 += coef * in1[8]; - tmp2 += coef * in2[-8]; - - // scale down, round and saturate - tmp1 >>= 15; - if (tmp1 > (WebRtc_Word32)0x00007FFF) - tmp1 = 0x00007FFF; - if (tmp1 < (WebRtc_Word32)0xFFFF8000) - tmp1 = 0xFFFF8000; - tmp2 >>= 15; - if (tmp2 > (WebRtc_Word32)0x00007FFF) - tmp2 = 0x00007FFF; - if (tmp2 < (WebRtc_Word32)0xFFFF8000) - tmp2 = 0xFFFF8000; - *out1 = (WebRtc_Word16)tmp1; - *out2 = (WebRtc_Word16)tmp2; -} - -// Resampling ratio: 11/16 -// input: WebRtc_Word32 (normalized, not saturated) :: size 16 * K -// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 11 * K -// K: Number of blocks - -void WebRtcSpl_32khzTo22khzIntToInt(const WebRtc_Word32* In, - WebRtc_Word32* Out, - const WebRtc_Word32 K) -{ - ///////////////////////////////////////////////////////////// - // Filter operation: - // - // Perform resampling (16 input samples -> 11 output samples); - // process in sub blocks of size 16 samples. - WebRtc_Word32 m; - - for (m = 0; m < K; m++) - { - // first output sample - Out[0] = ((WebRtc_Word32)In[3] << 15) + (1 << 14); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToInt(&In[0], &In[22], kCoefficients32To22[0], &Out[1], &Out[10]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToInt(&In[2], &In[20], kCoefficients32To22[1], &Out[2], &Out[9]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToInt(&In[3], &In[19], kCoefficients32To22[2], &Out[3], &Out[8]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToInt(&In[5], &In[17], kCoefficients32To22[3], &Out[4], &Out[7]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToInt(&In[6], &In[16], kCoefficients32To22[4], &Out[5], &Out[6]); - - // update pointers - In += 16; - Out += 11; - } -} - -// Resampling ratio: 11/16 -// input: WebRtc_Word32 (normalized, not saturated) :: size 16 * K -// output: WebRtc_Word16 (saturated) :: size 11 * K -// K: Number of blocks - -void WebRtcSpl_32khzTo22khzIntToShort(const WebRtc_Word32 *In, - WebRtc_Word16 *Out, - const WebRtc_Word32 K) -{ - ///////////////////////////////////////////////////////////// - // Filter operation: - // - // Perform resampling (16 input samples -> 11 output samples); - // process in sub blocks of size 16 samples. - WebRtc_Word32 tmp; - WebRtc_Word32 m; - - for (m = 0; m < K; m++) - { - // first output sample - tmp = In[3]; - if (tmp > (WebRtc_Word32)0x00007FFF) - tmp = 0x00007FFF; - if (tmp < (WebRtc_Word32)0xFFFF8000) - tmp = 0xFFFF8000; - Out[0] = (WebRtc_Word16)tmp; - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToShort(&In[0], &In[22], kCoefficients32To22[0], &Out[1], &Out[10]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToShort(&In[2], &In[20], kCoefficients32To22[1], &Out[2], &Out[9]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToShort(&In[3], &In[19], kCoefficients32To22[2], &Out[3], &Out[8]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToShort(&In[5], &In[17], kCoefficients32To22[3], &Out[4], &Out[7]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_DotProdIntToShort(&In[6], &In[16], kCoefficients32To22[4], &Out[5], &Out[6]); - - // update pointers - In += 16; - Out += 11; - } -}
diff --git a/src/common_audio/signal_processing/resample_48khz.c b/src/common_audio/signal_processing/resample_48khz.c deleted file mode 100644 index 31cbe6b..0000000 --- a/src/common_audio/signal_processing/resample_48khz.c +++ /dev/null
@@ -1,186 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains resampling functions between 48 kHz and nb/wb. - * The description header can be found in signal_processing_library.h - * - */ - -#include <string.h> -#include "signal_processing_library.h" -#include "resample_by_2_internal.h" - -//////////////////////////// -///// 48 kHz -> 16 kHz ///// -//////////////////////////// - -// 48 -> 16 resampler -void WebRtcSpl_Resample48khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State48khzTo16khz* state, WebRtc_Word32* tmpmem) -{ - ///// 48 --> 48(LP) ///// - // WebRtc_Word16 in[480] - // WebRtc_Word32 out[480] - ///// - WebRtcSpl_LPBy2ShortToInt(in, 480, tmpmem + 16, state->S_48_48); - - ///// 48 --> 32 ///// - // WebRtc_Word32 in[480] - // WebRtc_Word32 out[320] - ///// - // copy state to and from input array - memcpy(tmpmem + 8, state->S_48_32, 8 * sizeof(WebRtc_Word32)); - memcpy(state->S_48_32, tmpmem + 488, 8 * sizeof(WebRtc_Word32)); - WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 160); - - ///// 32 --> 16 ///// - // WebRtc_Word32 in[320] - // WebRtc_Word16 out[160] - ///// - WebRtcSpl_DownBy2IntToShort(tmpmem, 320, out, state->S_32_16); -} - -// initialize state of 48 -> 16 resampler -void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state) -{ - memset(state->S_48_48, 0, 16 * sizeof(WebRtc_Word32)); - memset(state->S_48_32, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_32_16, 0, 8 * sizeof(WebRtc_Word32)); -} - -//////////////////////////// -///// 16 kHz -> 48 kHz ///// -//////////////////////////// - -// 16 -> 48 resampler -void WebRtcSpl_Resample16khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State16khzTo48khz* state, WebRtc_Word32* tmpmem) -{ - ///// 16 --> 32 ///// - // WebRtc_Word16 in[160] - // WebRtc_Word32 out[320] - ///// - WebRtcSpl_UpBy2ShortToInt(in, 160, tmpmem + 16, state->S_16_32); - - ///// 32 --> 24 ///// - // WebRtc_Word32 in[320] - // WebRtc_Word32 out[240] - // copy state to and from input array - ///// - memcpy(tmpmem + 8, state->S_32_24, 8 * sizeof(WebRtc_Word32)); - memcpy(state->S_32_24, tmpmem + 328, 8 * sizeof(WebRtc_Word32)); - WebRtcSpl_Resample32khzTo24khz(tmpmem + 8, tmpmem, 80); - - ///// 24 --> 48 ///// - // WebRtc_Word32 in[240] - // WebRtc_Word16 out[480] - ///// - WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48); -} - -// initialize state of 16 -> 48 resampler -void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state) -{ - memset(state->S_16_32, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_32_24, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_24_48, 0, 8 * sizeof(WebRtc_Word32)); -} - -//////////////////////////// -///// 48 kHz -> 8 kHz ///// -//////////////////////////// - -// 48 -> 8 resampler -void WebRtcSpl_Resample48khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State48khzTo8khz* state, WebRtc_Word32* tmpmem) -{ - ///// 48 --> 24 ///// - // WebRtc_Word16 in[480] - // WebRtc_Word32 out[240] - ///// - WebRtcSpl_DownBy2ShortToInt(in, 480, tmpmem + 256, state->S_48_24); - - ///// 24 --> 24(LP) ///// - // WebRtc_Word32 in[240] - // WebRtc_Word32 out[240] - ///// - WebRtcSpl_LPBy2IntToInt(tmpmem + 256, 240, tmpmem + 16, state->S_24_24); - - ///// 24 --> 16 ///// - // WebRtc_Word32 in[240] - // WebRtc_Word32 out[160] - ///// - // copy state to and from input array - memcpy(tmpmem + 8, state->S_24_16, 8 * sizeof(WebRtc_Word32)); - memcpy(state->S_24_16, tmpmem + 248, 8 * sizeof(WebRtc_Word32)); - WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 80); - - ///// 16 --> 8 ///// - // WebRtc_Word32 in[160] - // WebRtc_Word16 out[80] - ///// - WebRtcSpl_DownBy2IntToShort(tmpmem, 160, out, state->S_16_8); -} - -// initialize state of 48 -> 8 resampler -void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state) -{ - memset(state->S_48_24, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_24_24, 0, 16 * sizeof(WebRtc_Word32)); - memset(state->S_24_16, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_16_8, 0, 8 * sizeof(WebRtc_Word32)); -} - -//////////////////////////// -///// 8 kHz -> 48 kHz ///// -//////////////////////////// - -// 8 -> 48 resampler -void WebRtcSpl_Resample8khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, - WebRtcSpl_State8khzTo48khz* state, WebRtc_Word32* tmpmem) -{ - ///// 8 --> 16 ///// - // WebRtc_Word16 in[80] - // WebRtc_Word32 out[160] - ///// - WebRtcSpl_UpBy2ShortToInt(in, 80, tmpmem + 264, state->S_8_16); - - ///// 16 --> 12 ///// - // WebRtc_Word32 in[160] - // WebRtc_Word32 out[120] - ///// - // copy state to and from input array - memcpy(tmpmem + 256, state->S_16_12, 8 * sizeof(WebRtc_Word32)); - memcpy(state->S_16_12, tmpmem + 416, 8 * sizeof(WebRtc_Word32)); - WebRtcSpl_Resample32khzTo24khz(tmpmem + 256, tmpmem + 240, 40); - - ///// 12 --> 24 ///// - // WebRtc_Word32 in[120] - // WebRtc_Word16 out[240] - ///// - WebRtcSpl_UpBy2IntToInt(tmpmem + 240, 120, tmpmem, state->S_12_24); - - ///// 24 --> 48 ///// - // WebRtc_Word32 in[240] - // WebRtc_Word16 out[480] - ///// - WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48); -} - -// initialize state of 8 -> 48 resampler -void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state) -{ - memset(state->S_8_16, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_16_12, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_12_24, 0, 8 * sizeof(WebRtc_Word32)); - memset(state->S_24_48, 0, 8 * sizeof(WebRtc_Word32)); -}
diff --git a/src/common_audio/signal_processing/resample_by_2.c b/src/common_audio/signal_processing/resample_by_2.c deleted file mode 100644 index c1d8b37..0000000 --- a/src/common_audio/signal_processing/resample_by_2.c +++ /dev/null
@@ -1,181 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the resampling by two functions. - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -#ifdef WEBRTC_ARCH_ARM_V7 - -// allpass filter coefficients. -static const WebRtc_UWord32 kResampleAllpass1[3] = {3284, 24441, 49528 << 15}; -static const WebRtc_UWord32 kResampleAllpass2[3] = - {12199, 37471 << 15, 60255 << 15}; - -// Multiply two 32-bit values and accumulate to another input value. -// Return: state + ((diff * tbl_value) >> 16) - -static __inline WebRtc_Word32 MUL_ACCUM_1(WebRtc_Word32 tbl_value, - WebRtc_Word32 diff, - WebRtc_Word32 state) { - WebRtc_Word32 result; - __asm__("smlawb %r0, %r1, %r2, %r3": "=r"(result): "r"(diff), - "r"(tbl_value), "r"(state)); - return result; -} - -// Multiply two 32-bit values and accumulate to another input value. -// Return: Return: state + (((diff << 1) * tbl_value) >> 32) -// -// The reason to introduce this function is that, in case we can't use smlawb -// instruction (in MUL_ACCUM_1) due to input value range, we can still use -// smmla to save some cycles. - -static __inline WebRtc_Word32 MUL_ACCUM_2(WebRtc_Word32 tbl_value, - WebRtc_Word32 diff, - WebRtc_Word32 state) { - WebRtc_Word32 result; - __asm__("smmla %r0, %r1, %r2, %r3": "=r"(result): "r"(diff << 1), - "r"(tbl_value), "r"(state)); - return result; -} - -#else - -// allpass filter coefficients. -static const WebRtc_UWord16 kResampleAllpass1[3] = {3284, 24441, 49528}; -static const WebRtc_UWord16 kResampleAllpass2[3] = {12199, 37471, 60255}; - -// Multiply a 32-bit value with a 16-bit value and accumulate to another input: -#define MUL_ACCUM_1(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) -#define MUL_ACCUM_2(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) - -#endif // WEBRTC_ARCH_ARM_V7 - - -// decimator -void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, const WebRtc_Word16 len, - WebRtc_Word16* out, WebRtc_Word32* filtState) { - WebRtc_Word32 tmp1, tmp2, diff, in32, out32; - WebRtc_Word16 i; - - register WebRtc_Word32 state0 = filtState[0]; - register WebRtc_Word32 state1 = filtState[1]; - register WebRtc_Word32 state2 = filtState[2]; - register WebRtc_Word32 state3 = filtState[3]; - register WebRtc_Word32 state4 = filtState[4]; - register WebRtc_Word32 state5 = filtState[5]; - register WebRtc_Word32 state6 = filtState[6]; - register WebRtc_Word32 state7 = filtState[7]; - - for (i = (len >> 1); i > 0; i--) { - // lower allpass filter - in32 = (WebRtc_Word32)(*in++) << 10; - diff = in32 - state1; - tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); - state0 = in32; - diff = tmp1 - state2; - tmp2 = MUL_ACCUM_2(kResampleAllpass2[1], diff, state1); - state1 = tmp1; - diff = tmp2 - state3; - state3 = MUL_ACCUM_2(kResampleAllpass2[2], diff, state2); - state2 = tmp2; - - // upper allpass filter - in32 = (WebRtc_Word32)(*in++) << 10; - diff = in32 - state5; - tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); - state4 = in32; - diff = tmp1 - state6; - tmp2 = MUL_ACCUM_1(kResampleAllpass1[1], diff, state5); - state5 = tmp1; - diff = tmp2 - state7; - state7 = MUL_ACCUM_2(kResampleAllpass1[2], diff, state6); - state6 = tmp2; - - // add two allpass outputs, divide by two and round - out32 = (state3 + state7 + 1024) >> 11; - - // limit amplitude to prevent wrap-around, and write to output array - *out++ = WebRtcSpl_SatW32ToW16(out32); - } - - filtState[0] = state0; - filtState[1] = state1; - filtState[2] = state2; - filtState[3] = state3; - filtState[4] = state4; - filtState[5] = state5; - filtState[6] = state6; - filtState[7] = state7; -} - - -void WebRtcSpl_UpsampleBy2(const WebRtc_Word16* in, WebRtc_Word16 len, - WebRtc_Word16* out, WebRtc_Word32* filtState) { - WebRtc_Word32 tmp1, tmp2, diff, in32, out32; - WebRtc_Word16 i; - - register WebRtc_Word32 state0 = filtState[0]; - register WebRtc_Word32 state1 = filtState[1]; - register WebRtc_Word32 state2 = filtState[2]; - register WebRtc_Word32 state3 = filtState[3]; - register WebRtc_Word32 state4 = filtState[4]; - register WebRtc_Word32 state5 = filtState[5]; - register WebRtc_Word32 state6 = filtState[6]; - register WebRtc_Word32 state7 = filtState[7]; - - for (i = len; i > 0; i--) { - // lower allpass filter - in32 = (WebRtc_Word32)(*in++) << 10; - diff = in32 - state1; - tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state0); - state0 = in32; - diff = tmp1 - state2; - tmp2 = MUL_ACCUM_1(kResampleAllpass1[1], diff, state1); - state1 = tmp1; - diff = tmp2 - state3; - state3 = MUL_ACCUM_2(kResampleAllpass1[2], diff, state2); - state2 = tmp2; - - // round; limit amplitude to prevent wrap-around; write to output array - out32 = (state3 + 512) >> 10; - *out++ = WebRtcSpl_SatW32ToW16(out32); - - // upper allpass filter - diff = in32 - state5; - tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state4); - state4 = in32; - diff = tmp1 - state6; - tmp2 = MUL_ACCUM_2(kResampleAllpass2[1], diff, state5); - state5 = tmp1; - diff = tmp2 - state7; - state7 = MUL_ACCUM_2(kResampleAllpass2[2], diff, state6); - state6 = tmp2; - - // round; limit amplitude to prevent wrap-around; write to output array - out32 = (state7 + 512) >> 10; - *out++ = WebRtcSpl_SatW32ToW16(out32); - } - - filtState[0] = state0; - filtState[1] = state1; - filtState[2] = state2; - filtState[3] = state3; - filtState[4] = state4; - filtState[5] = state5; - filtState[6] = state6; - filtState[7] = state7; -}
diff --git a/src/common_audio/signal_processing/resample_by_2_internal.c b/src/common_audio/signal_processing/resample_by_2_internal.c deleted file mode 100644 index cbd2395..0000000 --- a/src/common_audio/signal_processing/resample_by_2_internal.c +++ /dev/null
@@ -1,679 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This header file contains some internal resampling functions. - * - */ - -#include "resample_by_2_internal.h" - -// allpass filter coefficients. -static const WebRtc_Word16 kResampleAllpass[2][3] = { - {821, 6110, 12382}, - {3050, 9368, 15063} -}; - -// -// decimator -// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) OVERWRITTEN! -// output: WebRtc_Word16 (saturated) (of length len/2) -// state: filter state array; length = 8 - -void WebRtcSpl_DownBy2IntToShort(WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, - WebRtc_Word32 *state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - len >>= 1; - - // lower allpass filter (operates on even input samples) - for (i = 0; i < len; i++) - { - tmp0 = in[i << 1]; - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // divide by two and store temporarily - in[i << 1] = (state[3] >> 1); - } - - in++; - - // upper allpass filter (operates on odd input samples) - for (i = 0; i < len; i++) - { - tmp0 = in[i << 1]; - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // divide by two and store temporarily - in[i << 1] = (state[7] >> 1); - } - - in--; - - // combine allpass outputs - for (i = 0; i < len; i += 2) - { - // divide by two, add both allpass outputs and round - tmp0 = (in[i << 1] + in[(i << 1) + 1]) >> 15; - tmp1 = (in[(i << 1) + 2] + in[(i << 1) + 3]) >> 15; - if (tmp0 > (WebRtc_Word32)0x00007FFF) - tmp0 = 0x00007FFF; - if (tmp0 < (WebRtc_Word32)0xFFFF8000) - tmp0 = 0xFFFF8000; - out[i] = (WebRtc_Word16)tmp0; - if (tmp1 > (WebRtc_Word32)0x00007FFF) - tmp1 = 0x00007FFF; - if (tmp1 < (WebRtc_Word32)0xFFFF8000) - tmp1 = 0xFFFF8000; - out[i + 1] = (WebRtc_Word16)tmp1; - } -} - -// -// decimator -// input: WebRtc_Word16 -// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) (of length len/2) -// state: filter state array; length = 8 - -void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in, - WebRtc_Word32 len, - WebRtc_Word32 *out, - WebRtc_Word32 *state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - len >>= 1; - - // lower allpass filter (operates on even input samples) - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // divide by two and store temporarily - out[i] = (state[3] >> 1); - } - - in++; - - // upper allpass filter (operates on odd input samples) - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // divide by two and store temporarily - out[i] += (state[7] >> 1); - } - - in--; -} - -// -// interpolator -// input: WebRtc_Word16 -// output: WebRtc_Word32 (normalized, not saturated) (of length len*2) -// state: filter state array; length = 8 -void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, WebRtc_Word32 *out, - WebRtc_Word32 *state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - // upper allpass filter (generates odd output samples) - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i] << 15) + (1 << 14); - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // scale down, round and store - out[i << 1] = state[7] >> 15; - } - - out++; - - // lower allpass filter (generates even output samples) - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i] << 15) + (1 << 14); - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // scale down, round and store - out[i << 1] = state[3] >> 15; - } -} - -// -// interpolator -// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) -// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) (of length len*2) -// state: filter state array; length = 8 -void WebRtcSpl_UpBy2IntToInt(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word32 *out, - WebRtc_Word32 *state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - // upper allpass filter (generates odd output samples) - for (i = 0; i < len; i++) - { - tmp0 = in[i]; - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // scale down, round and store - out[i << 1] = state[7]; - } - - out++; - - // lower allpass filter (generates even output samples) - for (i = 0; i < len; i++) - { - tmp0 = in[i]; - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // scale down, round and store - out[i << 1] = state[3]; - } -} - -// -// interpolator -// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) -// output: WebRtc_Word16 (saturated) (of length len*2) -// state: filter state array; length = 8 -void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, - WebRtc_Word32 *state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - // upper allpass filter (generates odd output samples) - for (i = 0; i < len; i++) - { - tmp0 = in[i]; - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // scale down, saturate and store - tmp1 = state[7] >> 15; - if (tmp1 > (WebRtc_Word32)0x00007FFF) - tmp1 = 0x00007FFF; - if (tmp1 < (WebRtc_Word32)0xFFFF8000) - tmp1 = 0xFFFF8000; - out[i << 1] = (WebRtc_Word16)tmp1; - } - - out++; - - // lower allpass filter (generates even output samples) - for (i = 0; i < len; i++) - { - tmp0 = in[i]; - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // scale down, saturate and store - tmp1 = state[3] >> 15; - if (tmp1 > (WebRtc_Word32)0x00007FFF) - tmp1 = 0x00007FFF; - if (tmp1 < (WebRtc_Word32)0xFFFF8000) - tmp1 = 0xFFFF8000; - out[i << 1] = (WebRtc_Word16)tmp1; - } -} - -// lowpass filter -// input: WebRtc_Word16 -// output: WebRtc_Word32 (normalized, not saturated) -// state: filter state array; length = 8 -void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, WebRtc_Word32* out, - WebRtc_Word32* state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - len >>= 1; - - // lower allpass filter: odd input -> even output samples - in++; - // initial state of polyphase delay element - tmp0 = state[12]; - for (i = 0; i < len; i++) - { - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // scale down, round and store - out[i << 1] = state[3] >> 1; - tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); - } - in--; - - // upper allpass filter: even input -> even output samples - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // average the two allpass outputs, scale down and store - out[i << 1] = (out[i << 1] + (state[7] >> 1)) >> 15; - } - - // switch to odd output samples - out++; - - // lower allpass filter: even input -> odd output samples - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); - diff = tmp0 - state[9]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[8] + diff * kResampleAllpass[1][0]; - state[8] = tmp0; - diff = tmp1 - state[10]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[9] + diff * kResampleAllpass[1][1]; - state[9] = tmp1; - diff = tmp0 - state[11]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[11] = state[10] + diff * kResampleAllpass[1][2]; - state[10] = tmp0; - - // scale down, round and store - out[i << 1] = state[11] >> 1; - } - - // upper allpass filter: odd input -> odd output samples - in++; - for (i = 0; i < len; i++) - { - tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); - diff = tmp0 - state[13]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[12] + diff * kResampleAllpass[0][0]; - state[12] = tmp0; - diff = tmp1 - state[14]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[13] + diff * kResampleAllpass[0][1]; - state[13] = tmp1; - diff = tmp0 - state[15]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[15] = state[14] + diff * kResampleAllpass[0][2]; - state[14] = tmp0; - - // average the two allpass outputs, scale down and store - out[i << 1] = (out[i << 1] + (state[15] >> 1)) >> 15; - } -} - -// lowpass filter -// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) -// output: WebRtc_Word32 (normalized, not saturated) -// state: filter state array; length = 8 -void WebRtcSpl_LPBy2IntToInt(const WebRtc_Word32* in, WebRtc_Word32 len, WebRtc_Word32* out, - WebRtc_Word32* state) -{ - WebRtc_Word32 tmp0, tmp1, diff; - WebRtc_Word32 i; - - len >>= 1; - - // lower allpass filter: odd input -> even output samples - in++; - // initial state of polyphase delay element - tmp0 = state[12]; - for (i = 0; i < len; i++) - { - diff = tmp0 - state[1]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[0] + diff * kResampleAllpass[1][0]; - state[0] = tmp0; - diff = tmp1 - state[2]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[1] + diff * kResampleAllpass[1][1]; - state[1] = tmp1; - diff = tmp0 - state[3]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[3] = state[2] + diff * kResampleAllpass[1][2]; - state[2] = tmp0; - - // scale down, round and store - out[i << 1] = state[3] >> 1; - tmp0 = in[i << 1]; - } - in--; - - // upper allpass filter: even input -> even output samples - for (i = 0; i < len; i++) - { - tmp0 = in[i << 1]; - diff = tmp0 - state[5]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[4] + diff * kResampleAllpass[0][0]; - state[4] = tmp0; - diff = tmp1 - state[6]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[5] + diff * kResampleAllpass[0][1]; - state[5] = tmp1; - diff = tmp0 - state[7]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[7] = state[6] + diff * kResampleAllpass[0][2]; - state[6] = tmp0; - - // average the two allpass outputs, scale down and store - out[i << 1] = (out[i << 1] + (state[7] >> 1)) >> 15; - } - - // switch to odd output samples - out++; - - // lower allpass filter: even input -> odd output samples - for (i = 0; i < len; i++) - { - tmp0 = in[i << 1]; - diff = tmp0 - state[9]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[8] + diff * kResampleAllpass[1][0]; - state[8] = tmp0; - diff = tmp1 - state[10]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[9] + diff * kResampleAllpass[1][1]; - state[9] = tmp1; - diff = tmp0 - state[11]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[11] = state[10] + diff * kResampleAllpass[1][2]; - state[10] = tmp0; - - // scale down, round and store - out[i << 1] = state[11] >> 1; - } - - // upper allpass filter: odd input -> odd output samples - in++; - for (i = 0; i < len; i++) - { - tmp0 = in[i << 1]; - diff = tmp0 - state[13]; - // scale down and round - diff = (diff + (1 << 13)) >> 14; - tmp1 = state[12] + diff * kResampleAllpass[0][0]; - state[12] = tmp0; - diff = tmp1 - state[14]; - // scale down and round - diff = diff >> 14; - if (diff < 0) - diff += 1; - tmp0 = state[13] + diff * kResampleAllpass[0][1]; - state[13] = tmp1; - diff = tmp0 - state[15]; - // scale down and truncate - diff = diff >> 14; - if (diff < 0) - diff += 1; - state[15] = state[14] + diff * kResampleAllpass[0][2]; - state[14] = tmp0; - - // average the two allpass outputs, scale down and store - out[i << 1] = (out[i << 1] + (state[15] >> 1)) >> 15; - } -}
diff --git a/src/common_audio/signal_processing/resample_by_2_internal.h b/src/common_audio/signal_processing/resample_by_2_internal.h deleted file mode 100644 index b6ac9f0..0000000 --- a/src/common_audio/signal_processing/resample_by_2_internal.h +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This header file contains some internal resampling functions. - * - */ - -#ifndef WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ -#define WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ - -#include "typedefs.h" - -/******************************************************************* - * resample_by_2_fast.c - * Functions for internal use in the other resample functions - ******************************************************************/ -void WebRtcSpl_DownBy2IntToShort(WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, - WebRtc_Word32 *state); - -void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, - WebRtc_Word32 *out, WebRtc_Word32 *state); - -void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, - WebRtc_Word32 *out, WebRtc_Word32 *state); - -void WebRtcSpl_UpBy2IntToInt(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word32 *out, - WebRtc_Word32 *state); - -void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, - WebRtc_Word16 *out, WebRtc_Word32 *state); - -void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, - WebRtc_Word32* out, WebRtc_Word32* state); - -void WebRtcSpl_LPBy2IntToInt(const WebRtc_Word32* in, WebRtc_Word32 len, WebRtc_Word32* out, - WebRtc_Word32* state); - -#endif // WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_
diff --git a/src/common_audio/signal_processing/resample_fractional.c b/src/common_audio/signal_processing/resample_fractional.c deleted file mode 100644 index 51003d4..0000000 --- a/src/common_audio/signal_processing/resample_fractional.c +++ /dev/null
@@ -1,242 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the resampling functions between 48, 44, 32 and 24 kHz. - * The description headers can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -// interpolation coefficients -static const WebRtc_Word16 kCoefficients48To32[2][8] = { - {778, -2050, 1087, 23285, 12903, -3783, 441, 222}, - {222, 441, -3783, 12903, 23285, 1087, -2050, 778} -}; - -static const WebRtc_Word16 kCoefficients32To24[3][8] = { - {767, -2362, 2434, 24406, 10620, -3838, 721, 90}, - {386, -381, -2646, 19062, 19062, -2646, -381, 386}, - {90, 721, -3838, 10620, 24406, 2434, -2362, 767} -}; - -static const WebRtc_Word16 kCoefficients44To32[4][9] = { - {117, -669, 2245, -6183, 26267, 13529, -3245, 845, -138}, - {-101, 612, -2283, 8532, 29790, -5138, 1789, -524, 91}, - {50, -292, 1016, -3064, 32010, 3933, -1147, 315, -53}, - {-156, 974, -3863, 18603, 21691, -6246, 2353, -712, 126} -}; - -// Resampling ratio: 2/3 -// input: WebRtc_Word32 (normalized, not saturated) :: size 3 * K -// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 2 * K -// K: number of blocks - -void WebRtcSpl_Resample48khzTo32khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out, - const WebRtc_Word32 K) -{ - ///////////////////////////////////////////////////////////// - // Filter operation: - // - // Perform resampling (3 input samples -> 2 output samples); - // process in sub blocks of size 3 samples. - WebRtc_Word32 tmp; - WebRtc_Word32 m; - - for (m = 0; m < K; m++) - { - tmp = 1 << 14; - tmp += kCoefficients48To32[0][0] * In[0]; - tmp += kCoefficients48To32[0][1] * In[1]; - tmp += kCoefficients48To32[0][2] * In[2]; - tmp += kCoefficients48To32[0][3] * In[3]; - tmp += kCoefficients48To32[0][4] * In[4]; - tmp += kCoefficients48To32[0][5] * In[5]; - tmp += kCoefficients48To32[0][6] * In[6]; - tmp += kCoefficients48To32[0][7] * In[7]; - Out[0] = tmp; - - tmp = 1 << 14; - tmp += kCoefficients48To32[1][0] * In[1]; - tmp += kCoefficients48To32[1][1] * In[2]; - tmp += kCoefficients48To32[1][2] * In[3]; - tmp += kCoefficients48To32[1][3] * In[4]; - tmp += kCoefficients48To32[1][4] * In[5]; - tmp += kCoefficients48To32[1][5] * In[6]; - tmp += kCoefficients48To32[1][6] * In[7]; - tmp += kCoefficients48To32[1][7] * In[8]; - Out[1] = tmp; - - // update pointers - In += 3; - Out += 2; - } -} - -// Resampling ratio: 3/4 -// input: WebRtc_Word32 (normalized, not saturated) :: size 4 * K -// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 3 * K -// K: number of blocks - -void WebRtcSpl_Resample32khzTo24khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out, - const WebRtc_Word32 K) -{ - ///////////////////////////////////////////////////////////// - // Filter operation: - // - // Perform resampling (4 input samples -> 3 output samples); - // process in sub blocks of size 4 samples. - WebRtc_Word32 m; - WebRtc_Word32 tmp; - - for (m = 0; m < K; m++) - { - tmp = 1 << 14; - tmp += kCoefficients32To24[0][0] * In[0]; - tmp += kCoefficients32To24[0][1] * In[1]; - tmp += kCoefficients32To24[0][2] * In[2]; - tmp += kCoefficients32To24[0][3] * In[3]; - tmp += kCoefficients32To24[0][4] * In[4]; - tmp += kCoefficients32To24[0][5] * In[5]; - tmp += kCoefficients32To24[0][6] * In[6]; - tmp += kCoefficients32To24[0][7] * In[7]; - Out[0] = tmp; - - tmp = 1 << 14; - tmp += kCoefficients32To24[1][0] * In[1]; - tmp += kCoefficients32To24[1][1] * In[2]; - tmp += kCoefficients32To24[1][2] * In[3]; - tmp += kCoefficients32To24[1][3] * In[4]; - tmp += kCoefficients32To24[1][4] * In[5]; - tmp += kCoefficients32To24[1][5] * In[6]; - tmp += kCoefficients32To24[1][6] * In[7]; - tmp += kCoefficients32To24[1][7] * In[8]; - Out[1] = tmp; - - tmp = 1 << 14; - tmp += kCoefficients32To24[2][0] * In[2]; - tmp += kCoefficients32To24[2][1] * In[3]; - tmp += kCoefficients32To24[2][2] * In[4]; - tmp += kCoefficients32To24[2][3] * In[5]; - tmp += kCoefficients32To24[2][4] * In[6]; - tmp += kCoefficients32To24[2][5] * In[7]; - tmp += kCoefficients32To24[2][6] * In[8]; - tmp += kCoefficients32To24[2][7] * In[9]; - Out[2] = tmp; - - // update pointers - In += 4; - Out += 3; - } -} - -// -// fractional resampling filters -// Fout = 11/16 * Fin -// Fout = 8/11 * Fin -// - -// compute two inner-products and store them to output array -static void WebRtcSpl_ResampDotProduct(const WebRtc_Word32 *in1, const WebRtc_Word32 *in2, - const WebRtc_Word16 *coef_ptr, WebRtc_Word32 *out1, - WebRtc_Word32 *out2) -{ - WebRtc_Word32 tmp1 = 16384; - WebRtc_Word32 tmp2 = 16384; - WebRtc_Word16 coef; - - coef = coef_ptr[0]; - tmp1 += coef * in1[0]; - tmp2 += coef * in2[-0]; - - coef = coef_ptr[1]; - tmp1 += coef * in1[1]; - tmp2 += coef * in2[-1]; - - coef = coef_ptr[2]; - tmp1 += coef * in1[2]; - tmp2 += coef * in2[-2]; - - coef = coef_ptr[3]; - tmp1 += coef * in1[3]; - tmp2 += coef * in2[-3]; - - coef = coef_ptr[4]; - tmp1 += coef * in1[4]; - tmp2 += coef * in2[-4]; - - coef = coef_ptr[5]; - tmp1 += coef * in1[5]; - tmp2 += coef * in2[-5]; - - coef = coef_ptr[6]; - tmp1 += coef * in1[6]; - tmp2 += coef * in2[-6]; - - coef = coef_ptr[7]; - tmp1 += coef * in1[7]; - tmp2 += coef * in2[-7]; - - coef = coef_ptr[8]; - *out1 = tmp1 + coef * in1[8]; - *out2 = tmp2 + coef * in2[-8]; -} - -// Resampling ratio: 8/11 -// input: WebRtc_Word32 (normalized, not saturated) :: size 11 * K -// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 8 * K -// K: number of blocks - -void WebRtcSpl_Resample44khzTo32khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out, - const WebRtc_Word32 K) -{ - ///////////////////////////////////////////////////////////// - // Filter operation: - // - // Perform resampling (11 input samples -> 8 output samples); - // process in sub blocks of size 11 samples. - WebRtc_Word32 tmp; - WebRtc_Word32 m; - - for (m = 0; m < K; m++) - { - tmp = 1 << 14; - - // first output sample - Out[0] = ((WebRtc_Word32)In[3] << 15) + tmp; - - // sum and accumulate filter coefficients and input samples - tmp += kCoefficients44To32[3][0] * In[5]; - tmp += kCoefficients44To32[3][1] * In[6]; - tmp += kCoefficients44To32[3][2] * In[7]; - tmp += kCoefficients44To32[3][3] * In[8]; - tmp += kCoefficients44To32[3][4] * In[9]; - tmp += kCoefficients44To32[3][5] * In[10]; - tmp += kCoefficients44To32[3][6] * In[11]; - tmp += kCoefficients44To32[3][7] * In[12]; - tmp += kCoefficients44To32[3][8] * In[13]; - Out[4] = tmp; - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_ResampDotProduct(&In[0], &In[17], kCoefficients44To32[0], &Out[1], &Out[7]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_ResampDotProduct(&In[2], &In[15], kCoefficients44To32[1], &Out[2], &Out[6]); - - // sum and accumulate filter coefficients and input samples - WebRtcSpl_ResampDotProduct(&In[3], &In[14], kCoefficients44To32[2], &Out[3], &Out[5]); - - // update pointers - In += 11; - Out += 8; - } -}
diff --git a/src/common_audio/signal_processing/signal_processing.gypi b/src/common_audio/signal_processing/signal_processing.gypi deleted file mode 100644 index 2edc808..0000000 --- a/src/common_audio/signal_processing/signal_processing.gypi +++ /dev/null
@@ -1,99 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'signal_processing', - 'type': '<(library)', - 'include_dirs': [ - 'include', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - ], - }, - 'sources': [ - 'include/signal_processing_library.h', - 'include/spl_inl.h', - 'auto_corr_to_refl_coef.c', - 'auto_correlation.c', - 'complex_fft.c', - 'complex_bit_reverse.c', - 'copy_set_operations.c', - 'cross_correlation.c', - 'division_operations.c', - 'dot_product_with_scale.c', - 'downsample_fast.c', - 'energy.c', - 'filter_ar.c', - 'filter_ar_fast_q12.c', - 'filter_ma_fast_q12.c', - 'get_hanning_window.c', - 'get_scaling_square.c', - 'ilbc_specific_functions.c', - 'levinson_durbin.c', - 'lpc_to_refl_coef.c', - 'min_max_operations.c', - 'randomization_functions.c', - 'refl_coef_to_lpc.c', - 'resample.c', - 'resample_48khz.c', - 'resample_by_2.c', - 'resample_by_2_internal.c', - 'resample_by_2_internal.h', - 'resample_fractional.c', - 'spl_sqrt.c', - 'spl_sqrt_floor.c', - 'spl_version.c', - 'splitting_filter.c', - 'sqrt_of_one_minus_x_squared.c', - 'vector_scaling_operations.c', - ], - 'conditions': [ - ['target_arch=="arm"', { - 'sources': [ - 'spl_sqrt_floor_arm.s', - ], - 'sources!': [ - 'spl_sqrt_floor.c', - ], - 'conditions': [ - ['armv7==1', { - 'sources': [ - 'filter_ar_fast_q12_armv7.s', - ], - 'sources!': [ - 'filter_ar_fast_q12.c', - ], - }], - ], - }], - ], - }, # spl - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'signal_processing_unittests', - 'type': 'executable', - 'dependencies': [ - 'signal_processing', - '<(webrtc_root)/test/test.gyp:test_support_main', - '<(DEPTH)/testing/gtest.gyp:gtest', - ], - 'sources': [ - 'signal_processing_unittest.cc', - ], - }, # spl_unittests - ], # targets - }], # include_tests - ], # conditions -}
diff --git a/src/common_audio/signal_processing/signal_processing_unittest.cc b/src/common_audio/signal_processing/signal_processing_unittest.cc deleted file mode 100644 index a7c69b2..0000000 --- a/src/common_audio/signal_processing/signal_processing_unittest.cc +++ /dev/null
@@ -1,596 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "signal_processing_library.h" -#include "gtest/gtest.h" - -static const int kVector16Size = 9; -static const int16_t vector16[kVector16Size] = {1, -15511, 4323, 1963, - WEBRTC_SPL_WORD16_MAX, 0, WEBRTC_SPL_WORD16_MIN + 5, -3333, 345}; - -class SplTest : public testing::Test { - protected: - virtual ~SplTest() { - } - void SetUp() { - } - void TearDown() { - } -}; - -TEST_F(SplTest, MacroTest) { - // Macros with inputs. - int A = 10; - int B = 21; - int a = -3; - int b = WEBRTC_SPL_WORD32_MAX; - int nr = 2; - int d_ptr2 = 0; - - EXPECT_EQ(10, WEBRTC_SPL_MIN(A, B)); - EXPECT_EQ(21, WEBRTC_SPL_MAX(A, B)); - - EXPECT_EQ(3, WEBRTC_SPL_ABS_W16(a)); - EXPECT_EQ(3, WEBRTC_SPL_ABS_W32(a)); - EXPECT_EQ(0, WEBRTC_SPL_GET_BYTE(&B, nr)); - WEBRTC_SPL_SET_BYTE(&d_ptr2, 1, nr); - EXPECT_EQ(65536, d_ptr2); - - EXPECT_EQ(-63, WEBRTC_SPL_MUL(a, B)); - EXPECT_EQ(-2147483645, WEBRTC_SPL_MUL(a, b)); - EXPECT_EQ(2147483651u, WEBRTC_SPL_UMUL(a, b)); - b = WEBRTC_SPL_WORD16_MAX >> 1; - EXPECT_EQ(65535u, WEBRTC_SPL_UMUL_RSFT16(a, b)); - EXPECT_EQ(1073627139u, WEBRTC_SPL_UMUL_16_16(a, b)); - EXPECT_EQ(16382u, WEBRTC_SPL_UMUL_16_16_RSFT16(a, b)); - EXPECT_EQ(4294918147u, WEBRTC_SPL_UMUL_32_16(a, b)); - EXPECT_EQ(65535u, WEBRTC_SPL_UMUL_32_16_RSFT16(a, b)); - EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_U16(a, b)); - - a = b; - b = -3; - EXPECT_EQ(-5461, WEBRTC_SPL_DIV(a, b)); - EXPECT_EQ(0u, WEBRTC_SPL_UDIV(a, b)); - - EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT16(a, b)); - EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_32_RSFT15(a, b)); - EXPECT_EQ(-3, WEBRTC_SPL_MUL_16_32_RSFT14(a, b)); - EXPECT_EQ(-24, WEBRTC_SPL_MUL_16_32_RSFT11(a, b)); - - int a32 = WEBRTC_SPL_WORD32_MAX; - int a32a = (WEBRTC_SPL_WORD32_MAX >> 16); - int a32b = (WEBRTC_SPL_WORD32_MAX & 0x0000ffff); - EXPECT_EQ(5, WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, A)); - EXPECT_EQ(5, WEBRTC_SPL_MUL_32_32_RSFT32BI(a32, A)); - - EXPECT_EQ(-12288, WEBRTC_SPL_MUL_16_16_RSFT(a, b, 2)); - EXPECT_EQ(-12287, WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, 2)); - EXPECT_EQ(-1, WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(a, b)); - - EXPECT_EQ(16380, WEBRTC_SPL_ADD_SAT_W32(a, b)); - EXPECT_EQ(21, WEBRTC_SPL_SAT(a, A, B)); - EXPECT_EQ(21, WEBRTC_SPL_SAT(a, B, A)); - EXPECT_EQ(-49149, WEBRTC_SPL_MUL_32_16(a, b)); - - EXPECT_EQ(16386, WEBRTC_SPL_SUB_SAT_W32(a, b)); - EXPECT_EQ(16380, WEBRTC_SPL_ADD_SAT_W16(a, b)); - EXPECT_EQ(16386, WEBRTC_SPL_SUB_SAT_W16(a, b)); - - EXPECT_TRUE(WEBRTC_SPL_IS_NEG(b)); - - // Shifting with negative numbers allowed - int shift_amount = 1; // Workaround compiler warning using variable here. - // Positive means left shift - EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W16(a, shift_amount)); - EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W32(a, shift_amount)); - - // Shifting with negative numbers not allowed - // We cannot do casting here due to signed/unsigned problem - EXPECT_EQ(8191, WEBRTC_SPL_RSHIFT_W16(a, 1)); - EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W16(a, 1)); - EXPECT_EQ(8191, WEBRTC_SPL_RSHIFT_W32(a, 1)); - EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1)); - - EXPECT_EQ(8191, WEBRTC_SPL_RSHIFT_U16(a, 1)); - EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_U16(a, 1)); - EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1)); - EXPECT_EQ(32766u, WEBRTC_SPL_LSHIFT_U32(a, 1)); - - EXPECT_EQ(1470, WEBRTC_SPL_RAND(A)); - - EXPECT_EQ(-49149, WEBRTC_SPL_MUL_16_16(a, b)); - EXPECT_EQ(1073676289, WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_WORD16_MAX, - WEBRTC_SPL_WORD16_MAX)); - EXPECT_EQ(1073709055, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MAX, - WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, - WEBRTC_SPL_WORD32_MIN)); -#ifdef WEBRTC_ARCH_ARM_V7 - EXPECT_EQ(-1073741824, - WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, - WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(0x3fffffff, WEBRTC_SPL_MUL_32_32_RSFT32(WEBRTC_SPL_WORD16_MAX, - 0xffff, WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(0x3fffffff, WEBRTC_SPL_MUL_32_32_RSFT32BI(WEBRTC_SPL_WORD32_MAX, - WEBRTC_SPL_WORD32_MAX)); -#else - EXPECT_EQ(-1073741823, - WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, - WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(0x3fff7ffe, WEBRTC_SPL_MUL_32_32_RSFT32(WEBRTC_SPL_WORD16_MAX, - 0xffff, WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(0x3ffffffd, WEBRTC_SPL_MUL_32_32_RSFT32BI(WEBRTC_SPL_WORD32_MAX, - WEBRTC_SPL_WORD32_MAX)); -#endif -} - -TEST_F(SplTest, InlineTest) { - WebRtc_Word16 a16 = 121; - WebRtc_Word16 b16 = -17; - WebRtc_Word32 a32 = 111121; - WebRtc_Word32 b32 = -1711; - char bVersion[8]; - - EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32)); - EXPECT_EQ(14, WebRtcSpl_NormW32(a32)); - EXPECT_EQ(4, WebRtcSpl_NormW16(b32)); - EXPECT_EQ(15, WebRtcSpl_NormU32(a32)); - - EXPECT_EQ(104, WebRtcSpl_AddSatW16(a16, b16)); - EXPECT_EQ(138, WebRtcSpl_SubSatW16(a16, b16)); - - EXPECT_EQ(109410, WebRtcSpl_AddSatW32(a32, b32)); - EXPECT_EQ(112832, WebRtcSpl_SubSatW32(a32, b32)); - a32 = 0x80000000; - b32 = 0x80000000; - // Cast to signed int to avoid compiler complaint on gtest.h. - EXPECT_EQ(static_cast<int>(0x80000000), WebRtcSpl_AddSatW32(a32, b32)); - a32 = 0x7fffffff; - b32 = 0x7fffffff; - EXPECT_EQ(0x7fffffff, WebRtcSpl_AddSatW32(a32, b32)); - a32 = 0; - b32 = 0x80000000; - EXPECT_EQ(0x7fffffff, WebRtcSpl_SubSatW32(a32, b32)); - a32 = 0x7fffffff; - b32 = 0x80000000; - EXPECT_EQ(0x7fffffff, WebRtcSpl_SubSatW32(a32, b32)); - a32 = 0x80000000; - b32 = 0x7fffffff; - EXPECT_EQ(static_cast<int>(0x80000000), WebRtcSpl_SubSatW32(a32, b32)); - - EXPECT_EQ(0, WebRtcSpl_get_version(bVersion, 8)); -} - -TEST_F(SplTest, MathOperationsTest) { - int A = 1134567892; - WebRtc_Word32 num = 117; - WebRtc_Word32 den = -5; - WebRtc_UWord16 denU = 5; - EXPECT_EQ(33700, WebRtcSpl_Sqrt(A)); - EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A)); - - - EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num)); - EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (WebRtc_Word16)den)); - EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (WebRtc_Word16)den)); - EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU)); - EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256)); -} - -TEST_F(SplTest, BasicArrayOperationsTest) { - const int kVectorSize = 4; - int B[] = {4, 12, 133, 1100}; - WebRtc_UWord8 b8[kVectorSize]; - WebRtc_Word16 b16[kVectorSize]; - WebRtc_Word32 b32[kVectorSize]; - - WebRtc_UWord8 bTmp8[kVectorSize]; - WebRtc_Word16 bTmp16[kVectorSize]; - WebRtc_Word32 bTmp32[kVectorSize]; - - WebRtcSpl_MemSetW16(b16, 3, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(3, b16[kk]); - } - EXPECT_EQ(kVectorSize, WebRtcSpl_ZerosArrayW16(b16, kVectorSize)); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(0, b16[kk]); - } - EXPECT_EQ(kVectorSize, WebRtcSpl_OnesArrayW16(b16, kVectorSize)); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(1, b16[kk]); - } - WebRtcSpl_MemSetW32(b32, 3, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(3, b32[kk]); - } - EXPECT_EQ(kVectorSize, WebRtcSpl_ZerosArrayW32(b32, kVectorSize)); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(0, b32[kk]); - } - EXPECT_EQ(kVectorSize, WebRtcSpl_OnesArrayW32(b32, kVectorSize)); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(1, b32[kk]); - } - for (int kk = 0; kk < kVectorSize; ++kk) { - bTmp8[kk] = (WebRtc_Word8)kk; - bTmp16[kk] = (WebRtc_Word16)kk; - bTmp32[kk] = (WebRtc_Word32)kk; - } - WEBRTC_SPL_MEMCPY_W8(b8, bTmp8, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(b8[kk], bTmp8[kk]); - } - WEBRTC_SPL_MEMCPY_W16(b16, bTmp16, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(b16[kk], bTmp16[kk]); - } -// WEBRTC_SPL_MEMCPY_W32(b32, bTmp32, kVectorSize); -// for (int kk = 0; kk < kVectorSize; ++kk) { -// EXPECT_EQ(b32[kk], bTmp32[kk]); -// } - EXPECT_EQ(2, WebRtcSpl_CopyFromEndW16(b16, kVectorSize, 2, bTmp16)); - for (int kk = 0; kk < 2; ++kk) { - EXPECT_EQ(kk+2, bTmp16[kk]); - } - - for (int kk = 0; kk < kVectorSize; ++kk) { - b32[kk] = B[kk]; - b16[kk] = (WebRtc_Word16)B[kk]; - } - WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]>>1), bTmp16[kk]); - } - WebRtcSpl_VectorBitShiftW16(bTmp16, kVectorSize, b16, 1); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]>>1), bTmp16[kk]); - } - WebRtcSpl_VectorBitShiftW32(bTmp32, kVectorSize, b32, 1); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]>>1), bTmp32[kk]); - } - - WebRtcSpl_MemCpyReversedOrder(&bTmp16[3], b16, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(b16[3-kk], bTmp16[kk]); - } -} - -TEST_F(SplTest, ExeptionsHandlingMinMaxOperationsTest) { - // Test how the functions handle exceptional cases. - const int kVectorSize = 2; - int16_t vector16[kVectorSize] = {0}; - int32_t vector32[kVectorSize] = {0}; - - EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW16(vector16, 0)); - EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW16(NULL, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, WebRtcSpl_MaxValueW16(vector16, 0)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, WebRtcSpl_MaxValueW16(NULL, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, WebRtcSpl_MinValueW16(vector16, 0)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, WebRtcSpl_MinValueW16(NULL, kVectorSize)); - EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW32(vector32, 0)); - EXPECT_EQ(-1, WebRtcSpl_MaxAbsValueW32(NULL, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, WebRtcSpl_MaxValueW32(vector32, 0)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, WebRtcSpl_MaxValueW32(NULL, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, WebRtcSpl_MinValueW32(vector32, 0)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, WebRtcSpl_MinValueW32(NULL, kVectorSize)); - EXPECT_EQ(-1, WebRtcSpl_MaxAbsIndexW16(vector16, 0)); - EXPECT_EQ(-1, WebRtcSpl_MaxAbsIndexW16(NULL, kVectorSize)); - EXPECT_EQ(-1, WebRtcSpl_MaxIndexW16(vector16, 0)); - EXPECT_EQ(-1, WebRtcSpl_MaxIndexW16(NULL, kVectorSize)); - EXPECT_EQ(-1, WebRtcSpl_MaxIndexW32(vector32, 0)); - EXPECT_EQ(-1, WebRtcSpl_MaxIndexW32(NULL, kVectorSize)); - EXPECT_EQ(-1, WebRtcSpl_MinIndexW16(vector16, 0)); - EXPECT_EQ(-1, WebRtcSpl_MinIndexW16(NULL, kVectorSize)); - EXPECT_EQ(-1, WebRtcSpl_MinIndexW32(vector32, 0)); - EXPECT_EQ(-1, WebRtcSpl_MinIndexW32(NULL, kVectorSize)); -} - -TEST_F(SplTest, MinMaxOperationsTest) { - const int kVectorSize = 17; - - // Vectors to test the cases where minimum values have to be caught - // outside of the unrolled loops in ARM-Neon. - int16_t vector16[kVectorSize] = {-1, 7485, 0, 3333, - -18283, 0, 12334, -29871, 988, -3333, - 345, -456, 222, 999, 888, 8774, WEBRTC_SPL_WORD16_MIN}; - int32_t vector32[kVectorSize] = {-1, 0, 283211, 3333, - 8712345, 0, -3333, 89345, -374585456, 222, 999, 122345334, - -12389756, -987329871, 888, -2, WEBRTC_SPL_WORD32_MIN}; - - EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, - WebRtcSpl_MinValueW16(vector16, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, - WebRtcSpl_MinValueW32(vector32, kVectorSize)); - EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MinIndexW16(vector16, kVectorSize)); - EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MinIndexW32(vector32, kVectorSize)); - - // Test the cases where maximum values have to be caught - // outside of the unrolled loops in ARM-Neon. - vector16[kVectorSize - 1] = WEBRTC_SPL_WORD16_MAX; - vector32[kVectorSize - 1] = WEBRTC_SPL_WORD32_MAX; - - EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, - WebRtcSpl_MaxAbsValueW16(vector16, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, - WebRtcSpl_MaxValueW16(vector16, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, - WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, - WebRtcSpl_MaxValueW32(vector32, kVectorSize)); - EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); - EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); - EXPECT_EQ(kVectorSize - 1, WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); - - // Test the cases where multiple maximum and minimum values are present. - vector16[1] = WEBRTC_SPL_WORD16_MAX; - vector16[6] = WEBRTC_SPL_WORD16_MIN; - vector16[11] = WEBRTC_SPL_WORD16_MIN; - vector32[1] = WEBRTC_SPL_WORD32_MAX; - vector32[6] = WEBRTC_SPL_WORD32_MIN; - vector32[11] = WEBRTC_SPL_WORD32_MIN; - - EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, - WebRtcSpl_MaxAbsValueW16(vector16, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MAX, - WebRtcSpl_MaxValueW16(vector16, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD16_MIN, - WebRtcSpl_MinValueW16(vector16, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, - WebRtcSpl_MaxAbsValueW32(vector32, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MAX, - WebRtcSpl_MaxValueW32(vector32, kVectorSize)); - EXPECT_EQ(WEBRTC_SPL_WORD32_MIN, - WebRtcSpl_MinValueW32(vector32, kVectorSize)); - EXPECT_EQ(6, WebRtcSpl_MaxAbsIndexW16(vector16, kVectorSize)); - EXPECT_EQ(1, WebRtcSpl_MaxIndexW16(vector16, kVectorSize)); - EXPECT_EQ(1, WebRtcSpl_MaxIndexW32(vector32, kVectorSize)); - EXPECT_EQ(6, WebRtcSpl_MinIndexW16(vector16, kVectorSize)); - EXPECT_EQ(6, WebRtcSpl_MinIndexW32(vector32, kVectorSize)); -} - -TEST_F(SplTest, VectorOperationsTest) { - const int kVectorSize = 4; - int B[] = {4, 12, 133, 1100}; - WebRtc_Word16 a16[kVectorSize]; - WebRtc_Word16 b16[kVectorSize]; - WebRtc_Word16 bTmp16[kVectorSize]; - - for (int kk = 0; kk < kVectorSize; ++kk) { - a16[kk] = B[kk]; - b16[kk] = B[kk]; - } - - WebRtcSpl_AffineTransformVector(bTmp16, b16, 3, 7, 2, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]*3+7)>>2, bTmp16[kk]); - } - WebRtcSpl_ScaleAndAddVectorsWithRound(b16, 3, b16, 2, 2, bTmp16, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((B[kk]*3+B[kk]*2+2)>>2, bTmp16[kk]); - } - - WebRtcSpl_AddAffineVectorToVector(bTmp16, b16, 3, 7, 2, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(((B[kk]*3+B[kk]*2+2)>>2)+((b16[kk]*3+7)>>2), bTmp16[kk]); - } - - WebRtcSpl_ScaleVector(b16, bTmp16, 13, kVectorSize, 2); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); - } - WebRtcSpl_ScaleVectorWithSat(b16, bTmp16, 13, kVectorSize, 2); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((b16[kk]*13)>>2, bTmp16[kk]); - } - WebRtcSpl_ScaleAndAddVectors(a16, 13, 2, b16, 7, 2, bTmp16, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(((a16[kk]*13)>>2)+((b16[kk]*7)>>2), bTmp16[kk]); - } - - WebRtcSpl_AddVectorsAndShift(bTmp16, a16, b16, kVectorSize, 2); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(B[kk] >> 1, bTmp16[kk]); - } - WebRtcSpl_ReverseOrderMultArrayElements(bTmp16, a16, &b16[3], kVectorSize, 2); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((a16[kk]*b16[3-kk])>>2, bTmp16[kk]); - } - WebRtcSpl_ElementwiseVectorMult(bTmp16, a16, b16, kVectorSize, 6); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ((a16[kk]*b16[kk])>>6, bTmp16[kk]); - } - - WebRtcSpl_SqrtOfOneMinusXSquared(b16, kVectorSize, bTmp16); - for (int kk = 0; kk < kVectorSize - 1; ++kk) { - EXPECT_EQ(32767, bTmp16[kk]); - } - EXPECT_EQ(32749, bTmp16[kVectorSize - 1]); - - EXPECT_EQ(0, WebRtcSpl_GetScalingSquare(b16, kVectorSize, 1)); -} - -TEST_F(SplTest, EstimatorsTest) { - const int kVectorSize = 4; - int B[] = {4, 12, 133, 1100}; - WebRtc_Word16 b16[kVectorSize]; - WebRtc_Word32 b32[kVectorSize]; - WebRtc_Word16 bTmp16[kVectorSize]; - - for (int kk = 0; kk < kVectorSize; ++kk) { - b16[kk] = B[kk]; - b32[kk] = B[kk]; - } - - EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(b32, b16, bTmp16, 2)); -} - -TEST_F(SplTest, FilterTest) { - const int kVectorSize = 4; - const int kFilterOrder = 3; - WebRtc_Word16 A[] = {1, 2, 33, 100}; - WebRtc_Word16 A5[] = {1, 2, 33, 100, -5}; - WebRtc_Word16 B[] = {4, 12, 133, 110}; - WebRtc_Word16 data_in[kVectorSize]; - WebRtc_Word16 data_out[kVectorSize]; - WebRtc_Word16 bTmp16Low[kVectorSize]; - WebRtc_Word16 bState[kVectorSize]; - WebRtc_Word16 bStateLow[kVectorSize]; - - WebRtcSpl_ZerosArrayW16(bState, kVectorSize); - WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize); - - for (int kk = 0; kk < kVectorSize; ++kk) { - data_in[kk] = A[kk]; - data_out[kk] = 0; - } - - // MA filters. - // Note that the input data has |kFilterOrder| states before the actual - // data (one sample). - WebRtcSpl_FilterMAFastQ12(&data_in[kFilterOrder], data_out, B, - kFilterOrder + 1, 1); - EXPECT_EQ(0, data_out[0]); - // AR filters. - // Note that the output data has |kFilterOrder| states before the actual - // data (one sample). - WebRtcSpl_FilterARFastQ12(data_in, &data_out[kFilterOrder], A, - kFilterOrder + 1, 1); - EXPECT_EQ(0, data_out[kFilterOrder]); - - EXPECT_EQ(kVectorSize, WebRtcSpl_FilterAR(A5, - 5, - data_in, - kVectorSize, - bState, - kVectorSize, - bStateLow, - kVectorSize, - data_out, - bTmp16Low, - kVectorSize)); -} - -TEST_F(SplTest, RandTest) { - const int kVectorSize = 4; - WebRtc_Word16 BU[] = {3653, 12446, 8525, 30691}; - WebRtc_Word16 b16[kVectorSize]; - WebRtc_UWord32 bSeed = 100000; - - EXPECT_EQ(464449057u, WebRtcSpl_IncreaseSeed(&bSeed)); - EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed)); - EXPECT_EQ(-9786, WebRtcSpl_RandN(&bSeed)); - EXPECT_EQ(kVectorSize, WebRtcSpl_RandUArray(b16, kVectorSize, &bSeed)); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(BU[kk], b16[kk]); - } -} - -TEST_F(SplTest, DotProductWithScaleTest) { - EXPECT_EQ(605362796, WebRtcSpl_DotProductWithScale(vector16, - vector16, kVector16Size, 2)); -} - -TEST_F(SplTest, CrossCorrelationTest) { - // Note the function arguments relation specificed by API. - const int kCrossCorrelationDimension = 3; - const int kShift = 2; - const int kStep = 1; - const int kSeqDimension = 6; - - const int16_t vector16_b[kVector16Size] = {1, 4323, 1963, - WEBRTC_SPL_WORD16_MAX, WEBRTC_SPL_WORD16_MIN + 5, -3333, -876, 8483, 142}; - const int32_t expected[3] = {-266947903, -15579555, -171282001}; - int32_t vector32[kCrossCorrelationDimension] = {0}; - - WebRtcSpl_CrossCorrelation(vector32, vector16, vector16_b, kSeqDimension, - kCrossCorrelationDimension, kShift, kStep); - - for (int i = 0; i < kCrossCorrelationDimension; ++i) { - EXPECT_EQ(expected[i], vector32[i]); - } -} - -TEST_F(SplTest, AutoCorrelationTest) { - int scale = 0; - int32_t vector32[kVector16Size]; - const int32_t expected[kVector16Size] = {302681398, 14223410, -121705063, - -85221647, -17104971, 61806945, 6644603, -669329, 43}; - - EXPECT_EQ(-1, WebRtcSpl_AutoCorrelation(vector16, - kVector16Size, kVector16Size + 1, vector32, &scale)); - EXPECT_EQ(kVector16Size, WebRtcSpl_AutoCorrelation(vector16, - kVector16Size, kVector16Size - 1, vector32, &scale)); - EXPECT_EQ(3, scale); - for (int i = 0; i < kVector16Size; ++i) { - EXPECT_EQ(expected[i], vector32[i]); - } -} - -TEST_F(SplTest, SignalProcessingTest) { - const int kVectorSize = 4; - int A[] = {1, 2, 33, 100}; - const WebRtc_Word16 kHanning[4] = { 2399, 8192, 13985, 16384 }; - WebRtc_Word16 b16[kVectorSize]; - - WebRtc_Word16 bTmp16[kVectorSize]; - - int bScale = 0; - - for (int kk = 0; kk < kVectorSize; ++kk) { - b16[kk] = A[kk]; - } - - // TODO(bjornv): Activate the Reflection Coefficient tests when refactoring. -// WebRtcSpl_ReflCoefToLpc(b16, kVectorSize, bTmp16); -//// for (int kk = 0; kk < kVectorSize; ++kk) { -//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]); -//// } -// WebRtcSpl_LpcToReflCoef(bTmp16, kVectorSize, b16); -//// for (int kk = 0; kk < kVectorSize; ++kk) { -//// EXPECT_EQ(a16[kk], b16[kk]); -//// } -// WebRtcSpl_AutoCorrToReflCoef(b32, kVectorSize, bTmp16); -//// for (int kk = 0; kk < kVectorSize; ++kk) { -//// EXPECT_EQ(aTmp16[kk], bTmp16[kk]); -//// } - - WebRtcSpl_GetHanningWindow(bTmp16, kVectorSize); - for (int kk = 0; kk < kVectorSize; ++kk) { - EXPECT_EQ(kHanning[kk], bTmp16[kk]); - } - - for (int kk = 0; kk < kVectorSize; ++kk) { - b16[kk] = A[kk]; - } - EXPECT_EQ(11094 , WebRtcSpl_Energy(b16, kVectorSize, &bScale)); - EXPECT_EQ(0, bScale); -} - -TEST_F(SplTest, FFTTest) { - WebRtc_Word16 B[] = {1, 2, 33, 100, - 2, 3, 34, 101, - 3, 4, 35, 102, - 4, 5, 36, 103}; - - EXPECT_EQ(0, WebRtcSpl_ComplexFFT(B, 3, 1)); -// for (int kk = 0; kk < 16; ++kk) { -// EXPECT_EQ(A[kk], B[kk]); -// } - EXPECT_EQ(0, WebRtcSpl_ComplexIFFT(B, 3, 1)); -// for (int kk = 0; kk < 16; ++kk) { -// EXPECT_EQ(A[kk], B[kk]); -// } - WebRtcSpl_ComplexBitReverse(B, 3); - for (int kk = 0; kk < 16; ++kk) { - //EXPECT_EQ(A[kk], B[kk]); - } -}
diff --git a/src/common_audio/signal_processing/spl_sqrt.c b/src/common_audio/signal_processing/spl_sqrt.c deleted file mode 100644 index cfe2cd3..0000000 --- a/src/common_audio/signal_processing/spl_sqrt.c +++ /dev/null
@@ -1,184 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_Sqrt(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -WebRtc_Word32 WebRtcSpl_SqrtLocal(WebRtc_Word32 in); - -WebRtc_Word32 WebRtcSpl_SqrtLocal(WebRtc_Word32 in) -{ - - WebRtc_Word16 x_half, t16; - WebRtc_Word32 A, B, x2; - - /* The following block performs: - y=in/2 - x=y-2^30 - x_half=x/2^31 - t = 1 + (x_half) - 0.5*((x_half)^2) + 0.5*((x_half)^3) - 0.625*((x_half)^4) - + 0.875*((x_half)^5) - */ - - B = in; - - B = WEBRTC_SPL_RSHIFT_W32(B, 1); // B = in/2 - B = B - ((WebRtc_Word32)0x40000000); // B = in/2 - 1/2 - x_half = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(B, 16);// x_half = x/2 = (in-1)/2 - B = B + ((WebRtc_Word32)0x40000000); // B = 1 + x/2 - B = B + ((WebRtc_Word32)0x40000000); // Add 0.5 twice (since 1.0 does not exist in Q31) - - x2 = ((WebRtc_Word32)x_half) * ((WebRtc_Word32)x_half) * 2; // A = (x/2)^2 - A = -x2; // A = -(x/2)^2 - B = B + (A >> 1); // B = 1 + x/2 - 0.5*(x/2)^2 - - A = WEBRTC_SPL_RSHIFT_W32(A, 16); - A = A * A * 2; // A = (x/2)^4 - t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); - B = B + WEBRTC_SPL_MUL_16_16(-20480, t16) * 2; // B = B - 0.625*A - // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 - - t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); - A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = (x/2)^5 - t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); - B = B + WEBRTC_SPL_MUL_16_16(28672, t16) * 2; // B = B + 0.875*A - // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 + 0.875*(x/2)^5 - - t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(x2, 16); - A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = x/2^3 - - B = B + (A >> 1); // B = B + 0.5*A - // After this, B = 1 + x/2 - 0.5*(x/2)^2 + 0.5*(x/2)^3 - 0.625*(x/2)^4 + 0.875*(x/2)^5 - - B = B + ((WebRtc_Word32)32768); // Round off bit - - return B; -} - -WebRtc_Word32 WebRtcSpl_Sqrt(WebRtc_Word32 value) -{ - /* - Algorithm: - - Six term Taylor Series is used here to compute the square root of a number - y^0.5 = (1+x)^0.5 where x = y-1 - = 1+(x/2)-0.5*((x/2)^2+0.5*((x/2)^3-0.625*((x/2)^4+0.875*((x/2)^5) - 0.5 <= x < 1 - - Example of how the algorithm works, with ut=sqrt(in), and - with in=73632 and ut=271 (even shift value case): - - in=73632 - y= in/131072 - x=y-1 - t = 1 + (x/2) - 0.5*((x/2)^2) + 0.5*((x/2)^3) - 0.625*((x/2)^4) + 0.875*((x/2)^5) - ut=t*(1/sqrt(2))*512 - - or: - - in=73632 - in2=73632*2^14 - y= in2/2^31 - x=y-1 - t = 1 + (x/2) - 0.5*((x/2)^2) + 0.5*((x/2)^3) - 0.625*((x/2)^4) + 0.875*((x/2)^5) - ut=t*(1/sqrt(2)) - ut2=ut*2^9 - - which gives: - - in = 73632 - in2 = 1206386688 - y = 0.56176757812500 - x = -0.43823242187500 - t = 0.74973506527313 - ut = 0.53014274874797 - ut2 = 2.714330873589594e+002 - - or: - - in=73632 - in2=73632*2^14 - y=in2/2 - x=y-2^30 - x_half=x/2^31 - t = 1 + (x_half) - 0.5*((x_half)^2) + 0.5*((x_half)^3) - 0.625*((x_half)^4) - + 0.875*((x_half)^5) - ut=t*(1/sqrt(2)) - ut2=ut*2^9 - - which gives: - - in = 73632 - in2 = 1206386688 - y = 603193344 - x = -470548480 - x_half = -0.21911621093750 - t = 0.74973506527313 - ut = 0.53014274874797 - ut2 = 2.714330873589594e+002 - - */ - - WebRtc_Word16 x_norm, nshift, t16, sh; - WebRtc_Word32 A; - - WebRtc_Word16 k_sqrt_2 = 23170; // 1/sqrt2 (==5a82) - - A = value; - - if (A == 0) - return (WebRtc_Word32)0; // sqrt(0) = 0 - - sh = WebRtcSpl_NormW32(A); // # shifts to normalize A - A = WEBRTC_SPL_LSHIFT_W32(A, sh); // Normalize A - if (A < (WEBRTC_SPL_WORD32_MAX - 32767)) - { - A = A + ((WebRtc_Word32)32768); // Round off bit - } else - { - A = WEBRTC_SPL_WORD32_MAX; - } - - x_norm = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); // x_norm = AH - - nshift = WEBRTC_SPL_RSHIFT_W16(sh, 1); // nshift = sh>>1 - nshift = -nshift; // Negate the power for later de-normalization - - A = (WebRtc_Word32)WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)x_norm, 16); - A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16) - A = WebRtcSpl_SqrtLocal(A); // A = sqrt(A) - - if ((-2 * nshift) == sh) - { // Even shift value case - - t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); // t16 = AH - - A = WEBRTC_SPL_MUL_16_16(k_sqrt_2, t16) * 2; // A = 1/sqrt(2)*t16 - A = A + ((WebRtc_Word32)32768); // Round off - A = A & ((WebRtc_Word32)0x7fff0000); // Round off - - A = WEBRTC_SPL_RSHIFT_W32(A, 15); // A = A>>16 - - } else - { - A = WEBRTC_SPL_RSHIFT_W32(A, 16); // A = A>>16 - } - - A = A & ((WebRtc_Word32)0x0000ffff); - A = (WebRtc_Word32)WEBRTC_SPL_SHIFT_W32(A, nshift); // De-normalize the result - - return A; -}
diff --git a/src/common_audio/signal_processing/spl_sqrt_floor.c b/src/common_audio/signal_processing/spl_sqrt_floor.c deleted file mode 100644 index f0e8ae2..0000000 --- a/src/common_audio/signal_processing/spl_sqrt_floor.c +++ /dev/null
@@ -1,54 +0,0 @@ -/* - * Written by Wilco Dijkstra, 1996. Refer to file LICENSE under - * trunk/third_party_mods/sqrt_floor. - * - * Minor modifications in code style for WebRTC, 2012. - */ - -#include "signal_processing_library.h" - -/* - * Algorithm: - * Successive approximation of the equation (root + delta) ^ 2 = N - * until delta < 1. If delta < 1 we have the integer part of SQRT (N). - * Use delta = 2^i for i = 15 .. 0. - * - * Output precision is 16 bits. Note for large input values (close to - * 0x7FFFFFFF), bit 15 (the highest bit of the low 16-bit half word) - * contains the MSB information (a non-sign value). Do with caution - * if you need to cast the output to int16_t type. - * - * If the input value is negative, it returns 0. - */ - -#define WEBRTC_SPL_SQRT_ITER(N) \ - try1 = root + (1 << (N)); \ - if (value >= try1 << (N)) \ - { \ - value -= try1 << (N); \ - root |= 2 << (N); \ - } - -int32_t WebRtcSpl_SqrtFloor(int32_t value) -{ - int32_t root = 0, try1; - - WEBRTC_SPL_SQRT_ITER (15); - WEBRTC_SPL_SQRT_ITER (14); - WEBRTC_SPL_SQRT_ITER (13); - WEBRTC_SPL_SQRT_ITER (12); - WEBRTC_SPL_SQRT_ITER (11); - WEBRTC_SPL_SQRT_ITER (10); - WEBRTC_SPL_SQRT_ITER ( 9); - WEBRTC_SPL_SQRT_ITER ( 8); - WEBRTC_SPL_SQRT_ITER ( 7); - WEBRTC_SPL_SQRT_ITER ( 6); - WEBRTC_SPL_SQRT_ITER ( 5); - WEBRTC_SPL_SQRT_ITER ( 4); - WEBRTC_SPL_SQRT_ITER ( 3); - WEBRTC_SPL_SQRT_ITER ( 2); - WEBRTC_SPL_SQRT_ITER ( 1); - WEBRTC_SPL_SQRT_ITER ( 0); - - return root >> 1; -}
diff --git a/src/common_audio/signal_processing/spl_sqrt_floor_arm.s b/src/common_audio/signal_processing/spl_sqrt_floor_arm.s deleted file mode 100644 index cfd9ed0..0000000 --- a/src/common_audio/signal_processing/spl_sqrt_floor_arm.s +++ /dev/null
@@ -1,88 +0,0 @@ -@ Written by Wilco Dijkstra, 1996. Refer to file LICENSE under -@ trunk/third_party_mods/sqrt_floor. -@ -@ Minor modifications in code style for WebRTC, 2012. -@ Output is bit-exact with the reference C code in spl_sqrt_floor.c. - -@ Input : r0 32 bit unsigned integer -@ Output: r0 = INT (SQRT (r0)), precision is 16 bits -@ Registers touched: r1, r2 - -.global WebRtcSpl_SqrtFloor - -.align 2 -WebRtcSpl_SqrtFloor: -.fnstart - mov r1, #3 << 30 - mov r2, #1 << 30 - - @ unroll for i = 0 .. 15 - - cmp r0, r2, ror #2 * 0 - subhs r0, r0, r2, ror #2 * 0 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 1 - subhs r0, r0, r2, ror #2 * 1 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 2 - subhs r0, r0, r2, ror #2 * 2 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 3 - subhs r0, r0, r2, ror #2 * 3 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 4 - subhs r0, r0, r2, ror #2 * 4 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 5 - subhs r0, r0, r2, ror #2 * 5 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 6 - subhs r0, r0, r2, ror #2 * 6 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 7 - subhs r0, r0, r2, ror #2 * 7 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 8 - subhs r0, r0, r2, ror #2 * 8 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 9 - subhs r0, r0, r2, ror #2 * 9 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 10 - subhs r0, r0, r2, ror #2 * 10 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 11 - subhs r0, r0, r2, ror #2 * 11 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 12 - subhs r0, r0, r2, ror #2 * 12 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 13 - subhs r0, r0, r2, ror #2 * 13 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 14 - subhs r0, r0, r2, ror #2 * 14 - adc r2, r1, r2, lsl #1 - - cmp r0, r2, ror #2 * 15 - subhs r0, r0, r2, ror #2 * 15 - adc r2, r1, r2, lsl #1 - - bic r0, r2, #3 << 30 @ for rounding add: cmp r0, r2 adc r2, #1 - bx lr - -.fnend
diff --git a/src/common_audio/signal_processing/spl_version.c b/src/common_audio/signal_processing/spl_version.c deleted file mode 100644 index 936925e..0000000 --- a/src/common_audio/signal_processing/spl_version.c +++ /dev/null
@@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_get_version(). - * The description header can be found in signal_processing_library.h - * - */ - -#include <string.h> -#include "signal_processing_library.h" - -WebRtc_Word16 WebRtcSpl_get_version(char* version, WebRtc_Word16 length_in_bytes) -{ - strncpy(version, "1.2.0", length_in_bytes); - return 0; -}
diff --git a/src/common_audio/signal_processing/splitting_filter.c b/src/common_audio/signal_processing/splitting_filter.c deleted file mode 100644 index f1acf67..0000000 --- a/src/common_audio/signal_processing/splitting_filter.c +++ /dev/null
@@ -1,198 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * This file contains the splitting filter functions. - * - */ - -#include "signal_processing_library.h" - -// Number of samples in a low/high-band frame. -enum -{ - kBandFrameLength = 160 -}; - -// QMF filter coefficients in Q16. -static const WebRtc_UWord16 WebRtcSpl_kAllPassFilter1[3] = {6418, 36982, 57261}; -static const WebRtc_UWord16 WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010}; - -/////////////////////////////////////////////////////////////////////////////////////////////// -// WebRtcSpl_AllPassQMF(...) -// -// Allpass filter used by the analysis and synthesis parts of the QMF filter. -// -// Input: -// - in_data : Input data sequence (Q10) -// - data_length : Length of data sequence (>2) -// - filter_coefficients : Filter coefficients (length 3, Q16) -// -// Input & Output: -// - filter_state : Filter state (length 6, Q10). -// -// Output: -// - out_data : Output data sequence (Q10), length equal to -// |data_length| -// - -void WebRtcSpl_AllPassQMF(WebRtc_Word32* in_data, const WebRtc_Word16 data_length, - WebRtc_Word32* out_data, const WebRtc_UWord16* filter_coefficients, - WebRtc_Word32* filter_state) -{ - // The procedure is to filter the input with three first order all pass filters - // (cascade operations). - // - // a_3 + q^-1 a_2 + q^-1 a_1 + q^-1 - // y[n] = ----------- ----------- ----------- x[n] - // 1 + a_3q^-1 1 + a_2q^-1 1 + a_1q^-1 - // - // The input vector |filter_coefficients| includes these three filter coefficients. - // The filter state contains the in_data state, in_data[-1], followed by - // the out_data state, out_data[-1]. This is repeated for each cascade. - // The first cascade filter will filter the |in_data| and store the output in - // |out_data|. The second will the take the |out_data| as input and make an - // intermediate storage in |in_data|, to save memory. The third, and final, cascade - // filter operation takes the |in_data| (which is the output from the previous cascade - // filter) and store the output in |out_data|. - // Note that the input vector values are changed during the process. - WebRtc_Word16 k; - WebRtc_Word32 diff; - // First all-pass cascade; filter from in_data to out_data. - - // Let y_i[n] indicate the output of cascade filter i (with filter coefficient a_i) at - // vector position n. Then the final output will be y[n] = y_3[n] - - // First loop, use the states stored in memory. - // "diff" should be safe from wrap around since max values are 2^25 - diff = WEBRTC_SPL_SUB_SAT_W32(in_data[0], filter_state[1]); // = (x[0] - y_1[-1]) - // y_1[0] = x[-1] + a_1 * (x[0] - y_1[-1]) - out_data[0] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[0], diff, filter_state[0]); - - // For the remaining loops, use previous values. - for (k = 1; k < data_length; k++) - { - diff = WEBRTC_SPL_SUB_SAT_W32(in_data[k], out_data[k - 1]); // = (x[n] - y_1[n-1]) - // y_1[n] = x[n-1] + a_1 * (x[n] - y_1[n-1]) - out_data[k] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[0], diff, in_data[k - 1]); - } - - // Update states. - filter_state[0] = in_data[data_length - 1]; // x[N-1], becomes x[-1] next time - filter_state[1] = out_data[data_length - 1]; // y_1[N-1], becomes y_1[-1] next time - - // Second all-pass cascade; filter from out_data to in_data. - diff = WEBRTC_SPL_SUB_SAT_W32(out_data[0], filter_state[3]); // = (y_1[0] - y_2[-1]) - // y_2[0] = y_1[-1] + a_2 * (y_1[0] - y_2[-1]) - in_data[0] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[1], diff, filter_state[2]); - for (k = 1; k < data_length; k++) - { - diff = WEBRTC_SPL_SUB_SAT_W32(out_data[k], in_data[k - 1]); // =(y_1[n] - y_2[n-1]) - // y_2[0] = y_1[-1] + a_2 * (y_1[0] - y_2[-1]) - in_data[k] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[1], diff, out_data[k-1]); - } - - filter_state[2] = out_data[data_length - 1]; // y_1[N-1], becomes y_1[-1] next time - filter_state[3] = in_data[data_length - 1]; // y_2[N-1], becomes y_2[-1] next time - - // Third all-pass cascade; filter from in_data to out_data. - diff = WEBRTC_SPL_SUB_SAT_W32(in_data[0], filter_state[5]); // = (y_2[0] - y[-1]) - // y[0] = y_2[-1] + a_3 * (y_2[0] - y[-1]) - out_data[0] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[2], diff, filter_state[4]); - for (k = 1; k < data_length; k++) - { - diff = WEBRTC_SPL_SUB_SAT_W32(in_data[k], out_data[k - 1]); // = (y_2[n] - y[n-1]) - // y[n] = y_2[n-1] + a_3 * (y_2[n] - y[n-1]) - out_data[k] = WEBRTC_SPL_SCALEDIFF32(filter_coefficients[2], diff, in_data[k-1]); - } - filter_state[4] = in_data[data_length - 1]; // y_2[N-1], becomes y_2[-1] next time - filter_state[5] = out_data[data_length - 1]; // y[N-1], becomes y[-1] next time -} - -void WebRtcSpl_AnalysisQMF(const WebRtc_Word16* in_data, WebRtc_Word16* low_band, - WebRtc_Word16* high_band, WebRtc_Word32* filter_state1, - WebRtc_Word32* filter_state2) -{ - WebRtc_Word16 i; - WebRtc_Word16 k; - WebRtc_Word32 tmp; - WebRtc_Word32 half_in1[kBandFrameLength]; - WebRtc_Word32 half_in2[kBandFrameLength]; - WebRtc_Word32 filter1[kBandFrameLength]; - WebRtc_Word32 filter2[kBandFrameLength]; - - // Split even and odd samples. Also shift them to Q10. - for (i = 0, k = 0; i < kBandFrameLength; i++, k += 2) - { - half_in2[i] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)in_data[k], 10); - half_in1[i] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)in_data[k + 1], 10); - } - - // All pass filter even and odd samples, independently. - WebRtcSpl_AllPassQMF(half_in1, kBandFrameLength, filter1, WebRtcSpl_kAllPassFilter1, - filter_state1); - WebRtcSpl_AllPassQMF(half_in2, kBandFrameLength, filter2, WebRtcSpl_kAllPassFilter2, - filter_state2); - - // Take the sum and difference of filtered version of odd and even - // branches to get upper & lower band. - for (i = 0; i < kBandFrameLength; i++) - { - tmp = filter1[i] + filter2[i] + 1024; - tmp = WEBRTC_SPL_RSHIFT_W32(tmp, 11); - low_band[i] = WebRtcSpl_SatW32ToW16(tmp); - - tmp = filter1[i] - filter2[i] + 1024; - tmp = WEBRTC_SPL_RSHIFT_W32(tmp, 11); - high_band[i] = WebRtcSpl_SatW32ToW16(tmp); - } -} - -void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band, const WebRtc_Word16* high_band, - WebRtc_Word16* out_data, WebRtc_Word32* filter_state1, - WebRtc_Word32* filter_state2) -{ - WebRtc_Word32 tmp; - WebRtc_Word32 half_in1[kBandFrameLength]; - WebRtc_Word32 half_in2[kBandFrameLength]; - WebRtc_Word32 filter1[kBandFrameLength]; - WebRtc_Word32 filter2[kBandFrameLength]; - WebRtc_Word16 i; - WebRtc_Word16 k; - - // Obtain the sum and difference channels out of upper and lower-band channels. - // Also shift to Q10 domain. - for (i = 0; i < kBandFrameLength; i++) - { - tmp = (WebRtc_Word32)low_band[i] + (WebRtc_Word32)high_band[i]; - half_in1[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10); - tmp = (WebRtc_Word32)low_band[i] - (WebRtc_Word32)high_band[i]; - half_in2[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10); - } - - // all-pass filter the sum and difference channels - WebRtcSpl_AllPassQMF(half_in1, kBandFrameLength, filter1, WebRtcSpl_kAllPassFilter2, - filter_state1); - WebRtcSpl_AllPassQMF(half_in2, kBandFrameLength, filter2, WebRtcSpl_kAllPassFilter1, - filter_state2); - - // The filtered signals are even and odd samples of the output. Combine - // them. The signals are Q10 should shift them back to Q0 and take care of - // saturation. - for (i = 0, k = 0; i < kBandFrameLength; i++) - { - tmp = WEBRTC_SPL_RSHIFT_W32(filter2[i] + 512, 10); - out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); - - tmp = WEBRTC_SPL_RSHIFT_W32(filter1[i] + 512, 10); - out_data[k++] = WebRtcSpl_SatW32ToW16(tmp); - } - -}
diff --git a/src/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c b/src/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c deleted file mode 100644 index 9fb2c73..0000000 --- a/src/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the function WebRtcSpl_SqrtOfOneMinusXSquared(). - * The description header can be found in signal_processing_library.h - * - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_SqrtOfOneMinusXSquared(WebRtc_Word16 *xQ15, int vector_length, - WebRtc_Word16 *yQ15) -{ - WebRtc_Word32 sq; - int m; - WebRtc_Word16 tmp; - - for (m = 0; m < vector_length; m++) - { - tmp = xQ15[m]; - sq = WEBRTC_SPL_MUL_16_16(tmp, tmp); // x^2 in Q30 - sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 - sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 - yQ15[m] = (WebRtc_Word16)sq; - } -}
diff --git a/src/common_audio/signal_processing/vector_scaling_operations.c b/src/common_audio/signal_processing/vector_scaling_operations.c deleted file mode 100644 index 91d9671..0000000 --- a/src/common_audio/signal_processing/vector_scaling_operations.c +++ /dev/null
@@ -1,176 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains implementations of the functions - * WebRtcSpl_VectorBitShiftW16() - * WebRtcSpl_VectorBitShiftW32() - * WebRtcSpl_VectorBitShiftW32ToW16() - * WebRtcSpl_ScaleVector() - * WebRtcSpl_ScaleVectorWithSat() - * WebRtcSpl_ScaleAndAddVectors() - * WebRtcSpl_ScaleAndAddVectorsWithRound() - */ - -#include "signal_processing_library.h" - -void WebRtcSpl_VectorBitShiftW16(WebRtc_Word16 *res, - WebRtc_Word16 length, - G_CONST WebRtc_Word16 *in, - WebRtc_Word16 right_shifts) -{ - int i; - - if (right_shifts > 0) - { - for (i = length; i > 0; i--) - { - (*res++) = ((*in++) >> right_shifts); - } - } else - { - for (i = length; i > 0; i--) - { - (*res++) = ((*in++) << (-right_shifts)); - } - } -} - -void WebRtcSpl_VectorBitShiftW32(WebRtc_Word32 *out_vector, - WebRtc_Word16 vector_length, - G_CONST WebRtc_Word32 *in_vector, - WebRtc_Word16 right_shifts) -{ - int i; - - if (right_shifts > 0) - { - for (i = vector_length; i > 0; i--) - { - (*out_vector++) = ((*in_vector++) >> right_shifts); - } - } else - { - for (i = vector_length; i > 0; i--) - { - (*out_vector++) = ((*in_vector++) << (-right_shifts)); - } - } -} - -void WebRtcSpl_VectorBitShiftW32ToW16(WebRtc_Word16 *res, - WebRtc_Word16 length, - G_CONST WebRtc_Word32 *in, - WebRtc_Word16 right_shifts) -{ - int i; - - if (right_shifts >= 0) - { - for (i = length; i > 0; i--) - { - (*res++) = (WebRtc_Word16)((*in++) >> right_shifts); - } - } else - { - WebRtc_Word16 left_shifts = -right_shifts; - for (i = length; i > 0; i--) - { - (*res++) = (WebRtc_Word16)((*in++) << left_shifts); - } - } -} - -void WebRtcSpl_ScaleVector(G_CONST WebRtc_Word16 *in_vector, WebRtc_Word16 *out_vector, - WebRtc_Word16 gain, WebRtc_Word16 in_vector_length, - WebRtc_Word16 right_shifts) -{ - // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts - int i; - G_CONST WebRtc_Word16 *inptr; - WebRtc_Word16 *outptr; - - inptr = in_vector; - outptr = out_vector; - - for (i = 0; i < in_vector_length; i++) - { - (*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts); - } -} - -void WebRtcSpl_ScaleVectorWithSat(G_CONST WebRtc_Word16 *in_vector, WebRtc_Word16 *out_vector, - WebRtc_Word16 gain, WebRtc_Word16 in_vector_length, - WebRtc_Word16 right_shifts) -{ - // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts - int i; - WebRtc_Word32 tmpW32; - G_CONST WebRtc_Word16 *inptr; - WebRtc_Word16 *outptr; - - inptr = in_vector; - outptr = out_vector; - - for (i = 0; i < in_vector_length; i++) - { - tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts); - (*outptr++) = WebRtcSpl_SatW32ToW16(tmpW32); - } -} - -void WebRtcSpl_ScaleAndAddVectors(G_CONST WebRtc_Word16 *in1, WebRtc_Word16 gain1, int shift1, - G_CONST WebRtc_Word16 *in2, WebRtc_Word16 gain2, int shift2, - WebRtc_Word16 *out, int vector_length) -{ - // Performs vector operation: out = (gain1*in1)>>shift1 + (gain2*in2)>>shift2 - int i; - G_CONST WebRtc_Word16 *in1ptr; - G_CONST WebRtc_Word16 *in2ptr; - WebRtc_Word16 *outptr; - - in1ptr = in1; - in2ptr = in2; - outptr = out; - - for (i = 0; i < vector_length; i++) - { - (*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(gain1, *in1ptr++, shift1) - + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(gain2, *in2ptr++, shift2); - } -} - -#ifndef WEBRTC_ARCH_ARM_NEON -int WebRtcSpl_ScaleAndAddVectorsWithRound(const int16_t* in_vector1, - int16_t in_vector1_scale, - const int16_t* in_vector2, - int16_t in_vector2_scale, - int right_shifts, - int16_t* out_vector, - int length) { - int i = 0; - int round_value = (1 << right_shifts) >> 1; - - if (in_vector1 == NULL || in_vector2 == NULL || out_vector == NULL || - length <= 0 || right_shifts < 0) { - return -1; - } - - for (i = 0; i < length; i++) { - out_vector[i] = (int16_t)(( - WEBRTC_SPL_MUL_16_16(in_vector1[i], in_vector1_scale) - + WEBRTC_SPL_MUL_16_16(in_vector2[i], in_vector2_scale) - + round_value) >> right_shifts); - } - - return 0; -} -#endif // WEBRTC_ARCH_ARM_NEON
diff --git a/src/common_audio/signal_processing/vector_scaling_operations_neon.s b/src/common_audio/signal_processing/vector_scaling_operations_neon.s deleted file mode 100644 index 003943b..0000000 --- a/src/common_audio/signal_processing/vector_scaling_operations_neon.s +++ /dev/null
@@ -1,88 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ vector_scaling_operations_neon.s -@ This file contains the function WebRtcSpl_ScaleAndAddVectorsWithRound(), -@ optimized for ARM Neon platform. Output is bit-exact with the reference -@ C code in vector_scaling_operations.c. - -.arch armv7-a -.fpu neon - -.align 2 -.global WebRtcSpl_ScaleAndAddVectorsWithRound - -WebRtcSpl_ScaleAndAddVectorsWithRound: -.fnstart - - push {r4-r9} - - ldr r4, [sp, #32] @ length - ldr r5, [sp, #28] @ out_vector - ldrsh r6, [sp, #24] @ right_shifts - - cmp r4, #0 - ble END @ Return if length <= 0. - - cmp r4, #8 - blt SET_ROUND_VALUE - - vdup.16 d26, r1 @ in_vector1_scale - vdup.16 d27, r3 @ in_vector2_scale - - @ Neon instructions can only right shift by an immediate value. To shift right - @ by a register value, we have to do a left shift left by the negative value. - rsb r7, r6, #0 - vdup.16 q12, r7 @ -right_shifts - - bic r7, r4, #7 @ Counter for LOOP_UNROLLED_BY_8: length / 8 * 8. - -LOOP_UNROLLED_BY_8: - vld1.16 {d28, d29}, [r0]! @ in_vector1[] - vld1.16 {d30, d31}, [r2]! @ in_vector2[] - vmull.s16 q0, d28, d26 - vmull.s16 q1, d29, d26 - vmull.s16 q2, d30, d27 - vmull.s16 q3, d31, d27 - vadd.s32 q0, q2 - vadd.s32 q1, q3 - vrshl.s32 q0, q12 @ Round shift right by right_shifts. - vrshl.s32 q1, q12 - vmovn.i32 d0, q0 @ Cast to 16 bit values. - vmovn.i32 d1, q1 - subs r7, #8 - vst1.16 {d0, d1}, [r5]! - bgt LOOP_UNROLLED_BY_8 - - ands r4, #0xFF @ Counter for LOOP_NO_UNROLLING: length % 8. - beq END - -SET_ROUND_VALUE: - mov r9, #1 - lsl r9, r6 - lsr r9, #1 - -LOOP_NO_UNROLLING: - ldrh r7, [r0], #2 - ldrh r8, [r2], #2 - smulbb r7, r7, r1 - smulbb r8, r8, r3 - subs r4, #1 - add r7, r9 - add r7, r8 - asr r7, r6 - strh r7, [r5], #2 - bne LOOP_NO_UNROLLING - -END: - pop {r4-r9} - bx lr - -.fnend
diff --git a/src/common_audio/signal_processing/webrtc_fft_t_1024_8.c b/src/common_audio/signal_processing/webrtc_fft_t_1024_8.c deleted file mode 100644 index b587380..0000000 --- a/src/common_audio/signal_processing/webrtc_fft_t_1024_8.c +++ /dev/null
@@ -1,704 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the Q14 radix-8 tables used in ARM9e optimizations. - * - */ - -extern const int s_Q14S_8; -const int s_Q14S_8 = 1024; -extern const unsigned short t_Q14S_8[2032]; -const unsigned short t_Q14S_8[2032] = { - 0x4000,0x0000 ,0x4000,0x0000 ,0x4000,0x0000 , - 0x22a3,0x187e ,0x3249,0x0c7c ,0x11a8,0x238e , - 0x0000,0x2d41 ,0x22a3,0x187e ,0xdd5d,0x3b21 , - 0xdd5d,0x3b21 ,0x11a8,0x238e ,0xb4be,0x3ec5 , - 0xc000,0x4000 ,0x0000,0x2d41 ,0xa57e,0x2d41 , - 0xac61,0x3b21 ,0xee58,0x3537 ,0xb4be,0x0c7c , - 0xa57e,0x2d41 ,0xdd5d,0x3b21 ,0xdd5d,0xe782 , - 0xac61,0x187e ,0xcdb7,0x3ec5 ,0x11a8,0xcac9 , - 0x4000,0x0000 ,0x4000,0x0000 ,0x4000,0x0000 , - 0x396b,0x0646 ,0x3cc8,0x0324 ,0x35eb,0x0964 , - 0x3249,0x0c7c ,0x396b,0x0646 ,0x2aaa,0x1294 , - 0x2aaa,0x1294 ,0x35eb,0x0964 ,0x1e7e,0x1b5d , - 0x22a3,0x187e ,0x3249,0x0c7c ,0x11a8,0x238e , - 0x1a46,0x1e2b ,0x2e88,0x0f8d ,0x0471,0x2afb , - 0x11a8,0x238e ,0x2aaa,0x1294 ,0xf721,0x3179 , - 0x08df,0x289a ,0x26b3,0x1590 ,0xea02,0x36e5 , - 0x0000,0x2d41 ,0x22a3,0x187e ,0xdd5d,0x3b21 , - 0xf721,0x3179 ,0x1e7e,0x1b5d ,0xd178,0x3e15 , - 0xee58,0x3537 ,0x1a46,0x1e2b ,0xc695,0x3fb1 , - 0xe5ba,0x3871 ,0x15fe,0x20e7 ,0xbcf0,0x3fec , - 0xdd5d,0x3b21 ,0x11a8,0x238e ,0xb4be,0x3ec5 , - 0xd556,0x3d3f ,0x0d48,0x2620 ,0xae2e,0x3c42 , - 0xcdb7,0x3ec5 ,0x08df,0x289a ,0xa963,0x3871 , - 0xc695,0x3fb1 ,0x0471,0x2afb ,0xa678,0x3368 , - 0xc000,0x4000 ,0x0000,0x2d41 ,0xa57e,0x2d41 , - 0xba09,0x3fb1 ,0xfb8f,0x2f6c ,0xa678,0x2620 , - 0xb4be,0x3ec5 ,0xf721,0x3179 ,0xa963,0x1e2b , - 0xb02d,0x3d3f ,0xf2b8,0x3368 ,0xae2e,0x1590 , - 0xac61,0x3b21 ,0xee58,0x3537 ,0xb4be,0x0c7c , - 0xa963,0x3871 ,0xea02,0x36e5 ,0xbcf0,0x0324 , - 0xa73b,0x3537 ,0xe5ba,0x3871 ,0xc695,0xf9ba , - 0xa5ed,0x3179 ,0xe182,0x39db ,0xd178,0xf073 , - 0xa57e,0x2d41 ,0xdd5d,0x3b21 ,0xdd5d,0xe782 , - 0xa5ed,0x289a ,0xd94d,0x3c42 ,0xea02,0xdf19 , - 0xa73b,0x238e ,0xd556,0x3d3f ,0xf721,0xd766 , - 0xa963,0x1e2b ,0xd178,0x3e15 ,0x0471,0xd094 , - 0xac61,0x187e ,0xcdb7,0x3ec5 ,0x11a8,0xcac9 , - 0xb02d,0x1294 ,0xca15,0x3f4f ,0x1e7e,0xc625 , - 0xb4be,0x0c7c ,0xc695,0x3fb1 ,0x2aaa,0xc2c1 , - 0xba09,0x0646 ,0xc338,0x3fec ,0x35eb,0xc0b1 , - 0x4000,0x0000 ,0x4000,0x0000 ,0x4000,0x0000 , - 0x3e69,0x0192 ,0x3f36,0x00c9 ,0x3d9a,0x025b , - 0x3cc8,0x0324 ,0x3e69,0x0192 ,0x3b1e,0x04b5 , - 0x3b1e,0x04b5 ,0x3d9a,0x025b ,0x388e,0x070e , - 0x396b,0x0646 ,0x3cc8,0x0324 ,0x35eb,0x0964 , - 0x37af,0x07d6 ,0x3bf4,0x03ed ,0x3334,0x0bb7 , - 0x35eb,0x0964 ,0x3b1e,0x04b5 ,0x306c,0x0e06 , - 0x341e,0x0af1 ,0x3a46,0x057e ,0x2d93,0x1050 , - 0x3249,0x0c7c ,0x396b,0x0646 ,0x2aaa,0x1294 , - 0x306c,0x0e06 ,0x388e,0x070e ,0x27b3,0x14d2 , - 0x2e88,0x0f8d ,0x37af,0x07d6 ,0x24ae,0x1709 , - 0x2c9d,0x1112 ,0x36ce,0x089d ,0x219c,0x1937 , - 0x2aaa,0x1294 ,0x35eb,0x0964 ,0x1e7e,0x1b5d , - 0x28b2,0x1413 ,0x3505,0x0a2b ,0x1b56,0x1d79 , - 0x26b3,0x1590 ,0x341e,0x0af1 ,0x1824,0x1f8c , - 0x24ae,0x1709 ,0x3334,0x0bb7 ,0x14ea,0x2193 , - 0x22a3,0x187e ,0x3249,0x0c7c ,0x11a8,0x238e , - 0x2093,0x19ef ,0x315b,0x0d41 ,0x0e61,0x257e , - 0x1e7e,0x1b5d ,0x306c,0x0e06 ,0x0b14,0x2760 , - 0x1c64,0x1cc6 ,0x2f7b,0x0eca ,0x07c4,0x2935 , - 0x1a46,0x1e2b ,0x2e88,0x0f8d ,0x0471,0x2afb , - 0x1824,0x1f8c ,0x2d93,0x1050 ,0x011c,0x2cb2 , - 0x15fe,0x20e7 ,0x2c9d,0x1112 ,0xfdc7,0x2e5a , - 0x13d5,0x223d ,0x2ba4,0x11d3 ,0xfa73,0x2ff2 , - 0x11a8,0x238e ,0x2aaa,0x1294 ,0xf721,0x3179 , - 0x0f79,0x24da ,0x29af,0x1354 ,0xf3d2,0x32ef , - 0x0d48,0x2620 ,0x28b2,0x1413 ,0xf087,0x3453 , - 0x0b14,0x2760 ,0x27b3,0x14d2 ,0xed41,0x35a5 , - 0x08df,0x289a ,0x26b3,0x1590 ,0xea02,0x36e5 , - 0x06a9,0x29ce ,0x25b1,0x164c ,0xe6cb,0x3812 , - 0x0471,0x2afb ,0x24ae,0x1709 ,0xe39c,0x392b , - 0x0239,0x2c21 ,0x23a9,0x17c4 ,0xe077,0x3a30 , - 0x0000,0x2d41 ,0x22a3,0x187e ,0xdd5d,0x3b21 , - 0xfdc7,0x2e5a ,0x219c,0x1937 ,0xda4f,0x3bfd , - 0xfb8f,0x2f6c ,0x2093,0x19ef ,0xd74e,0x3cc5 , - 0xf957,0x3076 ,0x1f89,0x1aa7 ,0xd45c,0x3d78 , - 0xf721,0x3179 ,0x1e7e,0x1b5d ,0xd178,0x3e15 , - 0xf4ec,0x3274 ,0x1d72,0x1c12 ,0xcea5,0x3e9d , - 0xf2b8,0x3368 ,0x1c64,0x1cc6 ,0xcbe2,0x3f0f , - 0xf087,0x3453 ,0x1b56,0x1d79 ,0xc932,0x3f6b , - 0xee58,0x3537 ,0x1a46,0x1e2b ,0xc695,0x3fb1 , - 0xec2b,0x3612 ,0x1935,0x1edc ,0xc40c,0x3fe1 , - 0xea02,0x36e5 ,0x1824,0x1f8c ,0xc197,0x3ffb , - 0xe7dc,0x37b0 ,0x1711,0x203a ,0xbf38,0x3fff , - 0xe5ba,0x3871 ,0x15fe,0x20e7 ,0xbcf0,0x3fec , - 0xe39c,0x392b ,0x14ea,0x2193 ,0xbabf,0x3fc4 , - 0xe182,0x39db ,0x13d5,0x223d ,0xb8a6,0x3f85 , - 0xdf6d,0x3a82 ,0x12bf,0x22e7 ,0xb6a5,0x3f30 , - 0xdd5d,0x3b21 ,0x11a8,0x238e ,0xb4be,0x3ec5 , - 0xdb52,0x3bb6 ,0x1091,0x2435 ,0xb2f2,0x3e45 , - 0xd94d,0x3c42 ,0x0f79,0x24da ,0xb140,0x3daf , - 0xd74e,0x3cc5 ,0x0e61,0x257e ,0xafa9,0x3d03 , - 0xd556,0x3d3f ,0x0d48,0x2620 ,0xae2e,0x3c42 , - 0xd363,0x3daf ,0x0c2e,0x26c1 ,0xacd0,0x3b6d , - 0xd178,0x3e15 ,0x0b14,0x2760 ,0xab8e,0x3a82 , - 0xcf94,0x3e72 ,0x09fa,0x27fe ,0xaa6a,0x3984 , - 0xcdb7,0x3ec5 ,0x08df,0x289a ,0xa963,0x3871 , - 0xcbe2,0x3f0f ,0x07c4,0x2935 ,0xa87b,0x374b , - 0xca15,0x3f4f ,0x06a9,0x29ce ,0xa7b1,0x3612 , - 0xc851,0x3f85 ,0x058d,0x2a65 ,0xa705,0x34c6 , - 0xc695,0x3fb1 ,0x0471,0x2afb ,0xa678,0x3368 , - 0xc4e2,0x3fd4 ,0x0355,0x2b8f ,0xa60b,0x31f8 , - 0xc338,0x3fec ,0x0239,0x2c21 ,0xa5bc,0x3076 , - 0xc197,0x3ffb ,0x011c,0x2cb2 ,0xa58d,0x2ee4 , - 0xc000,0x4000 ,0x0000,0x2d41 ,0xa57e,0x2d41 , - 0xbe73,0x3ffb ,0xfee4,0x2dcf ,0xa58d,0x2b8f , - 0xbcf0,0x3fec ,0xfdc7,0x2e5a ,0xa5bc,0x29ce , - 0xbb77,0x3fd4 ,0xfcab,0x2ee4 ,0xa60b,0x27fe , - 0xba09,0x3fb1 ,0xfb8f,0x2f6c ,0xa678,0x2620 , - 0xb8a6,0x3f85 ,0xfa73,0x2ff2 ,0xa705,0x2435 , - 0xb74d,0x3f4f ,0xf957,0x3076 ,0xa7b1,0x223d , - 0xb600,0x3f0f ,0xf83c,0x30f9 ,0xa87b,0x203a , - 0xb4be,0x3ec5 ,0xf721,0x3179 ,0xa963,0x1e2b , - 0xb388,0x3e72 ,0xf606,0x31f8 ,0xaa6a,0x1c12 , - 0xb25e,0x3e15 ,0xf4ec,0x3274 ,0xab8e,0x19ef , - 0xb140,0x3daf ,0xf3d2,0x32ef ,0xacd0,0x17c4 , - 0xb02d,0x3d3f ,0xf2b8,0x3368 ,0xae2e,0x1590 , - 0xaf28,0x3cc5 ,0xf19f,0x33df ,0xafa9,0x1354 , - 0xae2e,0x3c42 ,0xf087,0x3453 ,0xb140,0x1112 , - 0xad41,0x3bb6 ,0xef6f,0x34c6 ,0xb2f2,0x0eca , - 0xac61,0x3b21 ,0xee58,0x3537 ,0xb4be,0x0c7c , - 0xab8e,0x3a82 ,0xed41,0x35a5 ,0xb6a5,0x0a2b , - 0xaac8,0x39db ,0xec2b,0x3612 ,0xb8a6,0x07d6 , - 0xaa0f,0x392b ,0xeb16,0x367d ,0xbabf,0x057e , - 0xa963,0x3871 ,0xea02,0x36e5 ,0xbcf0,0x0324 , - 0xa8c5,0x37b0 ,0xe8ef,0x374b ,0xbf38,0x00c9 , - 0xa834,0x36e5 ,0xe7dc,0x37b0 ,0xc197,0xfe6e , - 0xa7b1,0x3612 ,0xe6cb,0x3812 ,0xc40c,0xfc13 , - 0xa73b,0x3537 ,0xe5ba,0x3871 ,0xc695,0xf9ba , - 0xa6d3,0x3453 ,0xe4aa,0x38cf ,0xc932,0xf763 , - 0xa678,0x3368 ,0xe39c,0x392b ,0xcbe2,0xf50f , - 0xa62c,0x3274 ,0xe28e,0x3984 ,0xcea5,0xf2bf , - 0xa5ed,0x3179 ,0xe182,0x39db ,0xd178,0xf073 , - 0xa5bc,0x3076 ,0xe077,0x3a30 ,0xd45c,0xee2d , - 0xa599,0x2f6c ,0xdf6d,0x3a82 ,0xd74e,0xebed , - 0xa585,0x2e5a ,0xde64,0x3ad3 ,0xda4f,0xe9b4 , - 0xa57e,0x2d41 ,0xdd5d,0x3b21 ,0xdd5d,0xe782 , - 0xa585,0x2c21 ,0xdc57,0x3b6d ,0xe077,0xe559 , - 0xa599,0x2afb ,0xdb52,0x3bb6 ,0xe39c,0xe33a , - 0xa5bc,0x29ce ,0xda4f,0x3bfd ,0xe6cb,0xe124 , - 0xa5ed,0x289a ,0xd94d,0x3c42 ,0xea02,0xdf19 , - 0xa62c,0x2760 ,0xd84d,0x3c85 ,0xed41,0xdd19 , - 0xa678,0x2620 ,0xd74e,0x3cc5 ,0xf087,0xdb26 , - 0xa6d3,0x24da ,0xd651,0x3d03 ,0xf3d2,0xd93f , - 0xa73b,0x238e ,0xd556,0x3d3f ,0xf721,0xd766 , - 0xa7b1,0x223d ,0xd45c,0x3d78 ,0xfa73,0xd59b , - 0xa834,0x20e7 ,0xd363,0x3daf ,0xfdc7,0xd3df , - 0xa8c5,0x1f8c ,0xd26d,0x3de3 ,0x011c,0xd231 , - 0xa963,0x1e2b ,0xd178,0x3e15 ,0x0471,0xd094 , - 0xaa0f,0x1cc6 ,0xd085,0x3e45 ,0x07c4,0xcf07 , - 0xaac8,0x1b5d ,0xcf94,0x3e72 ,0x0b14,0xcd8c , - 0xab8e,0x19ef ,0xcea5,0x3e9d ,0x0e61,0xcc21 , - 0xac61,0x187e ,0xcdb7,0x3ec5 ,0x11a8,0xcac9 , - 0xad41,0x1709 ,0xcccc,0x3eeb ,0x14ea,0xc983 , - 0xae2e,0x1590 ,0xcbe2,0x3f0f ,0x1824,0xc850 , - 0xaf28,0x1413 ,0xcafb,0x3f30 ,0x1b56,0xc731 , - 0xb02d,0x1294 ,0xca15,0x3f4f ,0x1e7e,0xc625 , - 0xb140,0x1112 ,0xc932,0x3f6b ,0x219c,0xc52d , - 0xb25e,0x0f8d ,0xc851,0x3f85 ,0x24ae,0xc44a , - 0xb388,0x0e06 ,0xc772,0x3f9c ,0x27b3,0xc37b , - 0xb4be,0x0c7c ,0xc695,0x3fb1 ,0x2aaa,0xc2c1 , - 0xb600,0x0af1 ,0xc5ba,0x3fc4 ,0x2d93,0xc21d , - 0xb74d,0x0964 ,0xc4e2,0x3fd4 ,0x306c,0xc18e , - 0xb8a6,0x07d6 ,0xc40c,0x3fe1 ,0x3334,0xc115 , - 0xba09,0x0646 ,0xc338,0x3fec ,0x35eb,0xc0b1 , - 0xbb77,0x04b5 ,0xc266,0x3ff5 ,0x388e,0xc064 , - 0xbcf0,0x0324 ,0xc197,0x3ffb ,0x3b1e,0xc02c , - 0xbe73,0x0192 ,0xc0ca,0x3fff ,0x3d9a,0xc00b , - 0x4000,0x0000 ,0x3f9b,0x0065 ,0x3f36,0x00c9 , - 0x3ed0,0x012e ,0x3e69,0x0192 ,0x3e02,0x01f7 , - 0x3d9a,0x025b ,0x3d31,0x02c0 ,0x3cc8,0x0324 , - 0x3c5f,0x0388 ,0x3bf4,0x03ed ,0x3b8a,0x0451 , - 0x3b1e,0x04b5 ,0x3ab2,0x051a ,0x3a46,0x057e , - 0x39d9,0x05e2 ,0x396b,0x0646 ,0x38fd,0x06aa , - 0x388e,0x070e ,0x381f,0x0772 ,0x37af,0x07d6 , - 0x373f,0x0839 ,0x36ce,0x089d ,0x365d,0x0901 , - 0x35eb,0x0964 ,0x3578,0x09c7 ,0x3505,0x0a2b , - 0x3492,0x0a8e ,0x341e,0x0af1 ,0x33a9,0x0b54 , - 0x3334,0x0bb7 ,0x32bf,0x0c1a ,0x3249,0x0c7c , - 0x31d2,0x0cdf ,0x315b,0x0d41 ,0x30e4,0x0da4 , - 0x306c,0x0e06 ,0x2ff4,0x0e68 ,0x2f7b,0x0eca , - 0x2f02,0x0f2b ,0x2e88,0x0f8d ,0x2e0e,0x0fee , - 0x2d93,0x1050 ,0x2d18,0x10b1 ,0x2c9d,0x1112 , - 0x2c21,0x1173 ,0x2ba4,0x11d3 ,0x2b28,0x1234 , - 0x2aaa,0x1294 ,0x2a2d,0x12f4 ,0x29af,0x1354 , - 0x2931,0x13b4 ,0x28b2,0x1413 ,0x2833,0x1473 , - 0x27b3,0x14d2 ,0x2733,0x1531 ,0x26b3,0x1590 , - 0x2632,0x15ee ,0x25b1,0x164c ,0x252f,0x16ab , - 0x24ae,0x1709 ,0x242b,0x1766 ,0x23a9,0x17c4 , - 0x2326,0x1821 ,0x22a3,0x187e ,0x221f,0x18db , - 0x219c,0x1937 ,0x2117,0x1993 ,0x2093,0x19ef , - 0x200e,0x1a4b ,0x1f89,0x1aa7 ,0x1f04,0x1b02 , - 0x1e7e,0x1b5d ,0x1df8,0x1bb8 ,0x1d72,0x1c12 , - 0x1ceb,0x1c6c ,0x1c64,0x1cc6 ,0x1bdd,0x1d20 , - 0x1b56,0x1d79 ,0x1ace,0x1dd3 ,0x1a46,0x1e2b , - 0x19be,0x1e84 ,0x1935,0x1edc ,0x18ad,0x1f34 , - 0x1824,0x1f8c ,0x179b,0x1fe3 ,0x1711,0x203a , - 0x1688,0x2091 ,0x15fe,0x20e7 ,0x1574,0x213d , - 0x14ea,0x2193 ,0x145f,0x21e8 ,0x13d5,0x223d , - 0x134a,0x2292 ,0x12bf,0x22e7 ,0x1234,0x233b , - 0x11a8,0x238e ,0x111d,0x23e2 ,0x1091,0x2435 , - 0x1005,0x2488 ,0x0f79,0x24da ,0x0eed,0x252c , - 0x0e61,0x257e ,0x0dd4,0x25cf ,0x0d48,0x2620 , - 0x0cbb,0x2671 ,0x0c2e,0x26c1 ,0x0ba1,0x2711 , - 0x0b14,0x2760 ,0x0a87,0x27af ,0x09fa,0x27fe , - 0x096d,0x284c ,0x08df,0x289a ,0x0852,0x28e7 , - 0x07c4,0x2935 ,0x0736,0x2981 ,0x06a9,0x29ce , - 0x061b,0x2a1a ,0x058d,0x2a65 ,0x04ff,0x2ab0 , - 0x0471,0x2afb ,0x03e3,0x2b45 ,0x0355,0x2b8f , - 0x02c7,0x2bd8 ,0x0239,0x2c21 ,0x01aa,0x2c6a , - 0x011c,0x2cb2 ,0x008e,0x2cfa ,0x0000,0x2d41 , - 0xff72,0x2d88 ,0xfee4,0x2dcf ,0xfe56,0x2e15 , - 0xfdc7,0x2e5a ,0xfd39,0x2e9f ,0xfcab,0x2ee4 , - 0xfc1d,0x2f28 ,0xfb8f,0x2f6c ,0xfb01,0x2faf , - 0xfa73,0x2ff2 ,0xf9e5,0x3034 ,0xf957,0x3076 , - 0xf8ca,0x30b8 ,0xf83c,0x30f9 ,0xf7ae,0x3139 , - 0xf721,0x3179 ,0xf693,0x31b9 ,0xf606,0x31f8 , - 0xf579,0x3236 ,0xf4ec,0x3274 ,0xf45f,0x32b2 , - 0xf3d2,0x32ef ,0xf345,0x332c ,0xf2b8,0x3368 , - 0xf22c,0x33a3 ,0xf19f,0x33df ,0xf113,0x3419 , - 0xf087,0x3453 ,0xeffb,0x348d ,0xef6f,0x34c6 , - 0xeee3,0x34ff ,0xee58,0x3537 ,0xedcc,0x356e , - 0xed41,0x35a5 ,0xecb6,0x35dc ,0xec2b,0x3612 , - 0xeba1,0x3648 ,0xeb16,0x367d ,0xea8c,0x36b1 , - 0xea02,0x36e5 ,0xe978,0x3718 ,0xe8ef,0x374b , - 0xe865,0x377e ,0xe7dc,0x37b0 ,0xe753,0x37e1 , - 0xe6cb,0x3812 ,0xe642,0x3842 ,0xe5ba,0x3871 , - 0xe532,0x38a1 ,0xe4aa,0x38cf ,0xe423,0x38fd , - 0xe39c,0x392b ,0xe315,0x3958 ,0xe28e,0x3984 , - 0xe208,0x39b0 ,0xe182,0x39db ,0xe0fc,0x3a06 , - 0xe077,0x3a30 ,0xdff2,0x3a59 ,0xdf6d,0x3a82 , - 0xdee9,0x3aab ,0xde64,0x3ad3 ,0xdde1,0x3afa , - 0xdd5d,0x3b21 ,0xdcda,0x3b47 ,0xdc57,0x3b6d , - 0xdbd5,0x3b92 ,0xdb52,0x3bb6 ,0xdad1,0x3bda , - 0xda4f,0x3bfd ,0xd9ce,0x3c20 ,0xd94d,0x3c42 , - 0xd8cd,0x3c64 ,0xd84d,0x3c85 ,0xd7cd,0x3ca5 , - 0xd74e,0x3cc5 ,0xd6cf,0x3ce4 ,0xd651,0x3d03 , - 0xd5d3,0x3d21 ,0xd556,0x3d3f ,0xd4d8,0x3d5b , - 0xd45c,0x3d78 ,0xd3df,0x3d93 ,0xd363,0x3daf , - 0xd2e8,0x3dc9 ,0xd26d,0x3de3 ,0xd1f2,0x3dfc , - 0xd178,0x3e15 ,0xd0fe,0x3e2d ,0xd085,0x3e45 , - 0xd00c,0x3e5c ,0xcf94,0x3e72 ,0xcf1c,0x3e88 , - 0xcea5,0x3e9d ,0xce2e,0x3eb1 ,0xcdb7,0x3ec5 , - 0xcd41,0x3ed8 ,0xcccc,0x3eeb ,0xcc57,0x3efd , - 0xcbe2,0x3f0f ,0xcb6e,0x3f20 ,0xcafb,0x3f30 , - 0xca88,0x3f40 ,0xca15,0x3f4f ,0xc9a3,0x3f5d , - 0xc932,0x3f6b ,0xc8c1,0x3f78 ,0xc851,0x3f85 , - 0xc7e1,0x3f91 ,0xc772,0x3f9c ,0xc703,0x3fa7 , - 0xc695,0x3fb1 ,0xc627,0x3fbb ,0xc5ba,0x3fc4 , - 0xc54e,0x3fcc ,0xc4e2,0x3fd4 ,0xc476,0x3fdb , - 0xc40c,0x3fe1 ,0xc3a1,0x3fe7 ,0xc338,0x3fec , - 0xc2cf,0x3ff1 ,0xc266,0x3ff5 ,0xc1fe,0x3ff8 , - 0xc197,0x3ffb ,0xc130,0x3ffd ,0xc0ca,0x3fff , - 0xc065,0x4000 ,0xc000,0x4000 ,0xbf9c,0x4000 , - 0xbf38,0x3fff ,0xbed5,0x3ffd ,0xbe73,0x3ffb , - 0xbe11,0x3ff8 ,0xbdb0,0x3ff5 ,0xbd50,0x3ff1 , - 0xbcf0,0x3fec ,0xbc91,0x3fe7 ,0xbc32,0x3fe1 , - 0xbbd4,0x3fdb ,0xbb77,0x3fd4 ,0xbb1b,0x3fcc , - 0xbabf,0x3fc4 ,0xba64,0x3fbb ,0xba09,0x3fb1 , - 0xb9af,0x3fa7 ,0xb956,0x3f9c ,0xb8fd,0x3f91 , - 0xb8a6,0x3f85 ,0xb84f,0x3f78 ,0xb7f8,0x3f6b , - 0xb7a2,0x3f5d ,0xb74d,0x3f4f ,0xb6f9,0x3f40 , - 0xb6a5,0x3f30 ,0xb652,0x3f20 ,0xb600,0x3f0f , - 0xb5af,0x3efd ,0xb55e,0x3eeb ,0xb50e,0x3ed8 , - 0xb4be,0x3ec5 ,0xb470,0x3eb1 ,0xb422,0x3e9d , - 0xb3d5,0x3e88 ,0xb388,0x3e72 ,0xb33d,0x3e5c , - 0xb2f2,0x3e45 ,0xb2a7,0x3e2d ,0xb25e,0x3e15 , - 0xb215,0x3dfc ,0xb1cd,0x3de3 ,0xb186,0x3dc9 , - 0xb140,0x3daf ,0xb0fa,0x3d93 ,0xb0b5,0x3d78 , - 0xb071,0x3d5b ,0xb02d,0x3d3f ,0xafeb,0x3d21 , - 0xafa9,0x3d03 ,0xaf68,0x3ce4 ,0xaf28,0x3cc5 , - 0xaee8,0x3ca5 ,0xaea9,0x3c85 ,0xae6b,0x3c64 , - 0xae2e,0x3c42 ,0xadf2,0x3c20 ,0xadb6,0x3bfd , - 0xad7b,0x3bda ,0xad41,0x3bb6 ,0xad08,0x3b92 , - 0xacd0,0x3b6d ,0xac98,0x3b47 ,0xac61,0x3b21 , - 0xac2b,0x3afa ,0xabf6,0x3ad3 ,0xabc2,0x3aab , - 0xab8e,0x3a82 ,0xab5b,0x3a59 ,0xab29,0x3a30 , - 0xaaf8,0x3a06 ,0xaac8,0x39db ,0xaa98,0x39b0 , - 0xaa6a,0x3984 ,0xaa3c,0x3958 ,0xaa0f,0x392b , - 0xa9e3,0x38fd ,0xa9b7,0x38cf ,0xa98d,0x38a1 , - 0xa963,0x3871 ,0xa93a,0x3842 ,0xa912,0x3812 , - 0xa8eb,0x37e1 ,0xa8c5,0x37b0 ,0xa89f,0x377e , - 0xa87b,0x374b ,0xa857,0x3718 ,0xa834,0x36e5 , - 0xa812,0x36b1 ,0xa7f1,0x367d ,0xa7d0,0x3648 , - 0xa7b1,0x3612 ,0xa792,0x35dc ,0xa774,0x35a5 , - 0xa757,0x356e ,0xa73b,0x3537 ,0xa71f,0x34ff , - 0xa705,0x34c6 ,0xa6eb,0x348d ,0xa6d3,0x3453 , - 0xa6bb,0x3419 ,0xa6a4,0x33df ,0xa68e,0x33a3 , - 0xa678,0x3368 ,0xa664,0x332c ,0xa650,0x32ef , - 0xa63e,0x32b2 ,0xa62c,0x3274 ,0xa61b,0x3236 , - 0xa60b,0x31f8 ,0xa5fb,0x31b9 ,0xa5ed,0x3179 , - 0xa5e0,0x3139 ,0xa5d3,0x30f9 ,0xa5c7,0x30b8 , - 0xa5bc,0x3076 ,0xa5b2,0x3034 ,0xa5a9,0x2ff2 , - 0xa5a1,0x2faf ,0xa599,0x2f6c ,0xa593,0x2f28 , - 0xa58d,0x2ee4 ,0xa588,0x2e9f ,0xa585,0x2e5a , - 0xa581,0x2e15 ,0xa57f,0x2dcf ,0xa57e,0x2d88 , - 0xa57e,0x2d41 ,0xa57e,0x2cfa ,0xa57f,0x2cb2 , - 0xa581,0x2c6a ,0xa585,0x2c21 ,0xa588,0x2bd8 , - 0xa58d,0x2b8f ,0xa593,0x2b45 ,0xa599,0x2afb , - 0xa5a1,0x2ab0 ,0xa5a9,0x2a65 ,0xa5b2,0x2a1a , - 0xa5bc,0x29ce ,0xa5c7,0x2981 ,0xa5d3,0x2935 , - 0xa5e0,0x28e7 ,0xa5ed,0x289a ,0xa5fb,0x284c , - 0xa60b,0x27fe ,0xa61b,0x27af ,0xa62c,0x2760 , - 0xa63e,0x2711 ,0xa650,0x26c1 ,0xa664,0x2671 , - 0xa678,0x2620 ,0xa68e,0x25cf ,0xa6a4,0x257e , - 0xa6bb,0x252c ,0xa6d3,0x24da ,0xa6eb,0x2488 , - 0xa705,0x2435 ,0xa71f,0x23e2 ,0xa73b,0x238e , - 0xa757,0x233b ,0xa774,0x22e7 ,0xa792,0x2292 , - 0xa7b1,0x223d ,0xa7d0,0x21e8 ,0xa7f1,0x2193 , - 0xa812,0x213d ,0xa834,0x20e7 ,0xa857,0x2091 , - 0xa87b,0x203a ,0xa89f,0x1fe3 ,0xa8c5,0x1f8c , - 0xa8eb,0x1f34 ,0xa912,0x1edc ,0xa93a,0x1e84 , - 0xa963,0x1e2b ,0xa98d,0x1dd3 ,0xa9b7,0x1d79 , - 0xa9e3,0x1d20 ,0xaa0f,0x1cc6 ,0xaa3c,0x1c6c , - 0xaa6a,0x1c12 ,0xaa98,0x1bb8 ,0xaac8,0x1b5d , - 0xaaf8,0x1b02 ,0xab29,0x1aa7 ,0xab5b,0x1a4b , - 0xab8e,0x19ef ,0xabc2,0x1993 ,0xabf6,0x1937 , - 0xac2b,0x18db ,0xac61,0x187e ,0xac98,0x1821 , - 0xacd0,0x17c4 ,0xad08,0x1766 ,0xad41,0x1709 , - 0xad7b,0x16ab ,0xadb6,0x164c ,0xadf2,0x15ee , - 0xae2e,0x1590 ,0xae6b,0x1531 ,0xaea9,0x14d2 , - 0xaee8,0x1473 ,0xaf28,0x1413 ,0xaf68,0x13b4 , - 0xafa9,0x1354 ,0xafeb,0x12f4 ,0xb02d,0x1294 , - 0xb071,0x1234 ,0xb0b5,0x11d3 ,0xb0fa,0x1173 , - 0xb140,0x1112 ,0xb186,0x10b1 ,0xb1cd,0x1050 , - 0xb215,0x0fee ,0xb25e,0x0f8d ,0xb2a7,0x0f2b , - 0xb2f2,0x0eca ,0xb33d,0x0e68 ,0xb388,0x0e06 , - 0xb3d5,0x0da4 ,0xb422,0x0d41 ,0xb470,0x0cdf , - 0xb4be,0x0c7c ,0xb50e,0x0c1a ,0xb55e,0x0bb7 , - 0xb5af,0x0b54 ,0xb600,0x0af1 ,0xb652,0x0a8e , - 0xb6a5,0x0a2b ,0xb6f9,0x09c7 ,0xb74d,0x0964 , - 0xb7a2,0x0901 ,0xb7f8,0x089d ,0xb84f,0x0839 , - 0xb8a6,0x07d6 ,0xb8fd,0x0772 ,0xb956,0x070e , - 0xb9af,0x06aa ,0xba09,0x0646 ,0xba64,0x05e2 , - 0xbabf,0x057e ,0xbb1b,0x051a ,0xbb77,0x04b5 , - 0xbbd4,0x0451 ,0xbc32,0x03ed ,0xbc91,0x0388 , - 0xbcf0,0x0324 ,0xbd50,0x02c0 ,0xbdb0,0x025b , - 0xbe11,0x01f7 ,0xbe73,0x0192 ,0xbed5,0x012e , - 0xbf38,0x00c9 ,0xbf9c,0x0065 }; - - -extern const int s_Q14R_8; -const int s_Q14R_8 = 1024; -extern const unsigned short t_Q14R_8[2032]; -const unsigned short t_Q14R_8[2032] = { - 0x4000,0x0000 ,0x4000,0x0000 ,0x4000,0x0000 , - 0x3b21,0x187e ,0x3ec5,0x0c7c ,0x3537,0x238e , - 0x2d41,0x2d41 ,0x3b21,0x187e ,0x187e,0x3b21 , - 0x187e,0x3b21 ,0x3537,0x238e ,0xf384,0x3ec5 , - 0x0000,0x4000 ,0x2d41,0x2d41 ,0xd2bf,0x2d41 , - 0xe782,0x3b21 ,0x238e,0x3537 ,0xc13b,0x0c7c , - 0xd2bf,0x2d41 ,0x187e,0x3b21 ,0xc4df,0xe782 , - 0xc4df,0x187e ,0x0c7c,0x3ec5 ,0xdc72,0xcac9 , - 0x4000,0x0000 ,0x4000,0x0000 ,0x4000,0x0000 , - 0x3fb1,0x0646 ,0x3fec,0x0324 ,0x3f4f,0x0964 , - 0x3ec5,0x0c7c ,0x3fb1,0x0646 ,0x3d3f,0x1294 , - 0x3d3f,0x1294 ,0x3f4f,0x0964 ,0x39db,0x1b5d , - 0x3b21,0x187e ,0x3ec5,0x0c7c ,0x3537,0x238e , - 0x3871,0x1e2b ,0x3e15,0x0f8d ,0x2f6c,0x2afb , - 0x3537,0x238e ,0x3d3f,0x1294 ,0x289a,0x3179 , - 0x3179,0x289a ,0x3c42,0x1590 ,0x20e7,0x36e5 , - 0x2d41,0x2d41 ,0x3b21,0x187e ,0x187e,0x3b21 , - 0x289a,0x3179 ,0x39db,0x1b5d ,0x0f8d,0x3e15 , - 0x238e,0x3537 ,0x3871,0x1e2b ,0x0646,0x3fb1 , - 0x1e2b,0x3871 ,0x36e5,0x20e7 ,0xfcdc,0x3fec , - 0x187e,0x3b21 ,0x3537,0x238e ,0xf384,0x3ec5 , - 0x1294,0x3d3f ,0x3368,0x2620 ,0xea70,0x3c42 , - 0x0c7c,0x3ec5 ,0x3179,0x289a ,0xe1d5,0x3871 , - 0x0646,0x3fb1 ,0x2f6c,0x2afb ,0xd9e0,0x3368 , - 0x0000,0x4000 ,0x2d41,0x2d41 ,0xd2bf,0x2d41 , - 0xf9ba,0x3fb1 ,0x2afb,0x2f6c ,0xcc98,0x2620 , - 0xf384,0x3ec5 ,0x289a,0x3179 ,0xc78f,0x1e2b , - 0xed6c,0x3d3f ,0x2620,0x3368 ,0xc3be,0x1590 , - 0xe782,0x3b21 ,0x238e,0x3537 ,0xc13b,0x0c7c , - 0xe1d5,0x3871 ,0x20e7,0x36e5 ,0xc014,0x0324 , - 0xdc72,0x3537 ,0x1e2b,0x3871 ,0xc04f,0xf9ba , - 0xd766,0x3179 ,0x1b5d,0x39db ,0xc1eb,0xf073 , - 0xd2bf,0x2d41 ,0x187e,0x3b21 ,0xc4df,0xe782 , - 0xce87,0x289a ,0x1590,0x3c42 ,0xc91b,0xdf19 , - 0xcac9,0x238e ,0x1294,0x3d3f ,0xce87,0xd766 , - 0xc78f,0x1e2b ,0x0f8d,0x3e15 ,0xd505,0xd094 , - 0xc4df,0x187e ,0x0c7c,0x3ec5 ,0xdc72,0xcac9 , - 0xc2c1,0x1294 ,0x0964,0x3f4f ,0xe4a3,0xc625 , - 0xc13b,0x0c7c ,0x0646,0x3fb1 ,0xed6c,0xc2c1 , - 0xc04f,0x0646 ,0x0324,0x3fec ,0xf69c,0xc0b1 , - 0x4000,0x0000 ,0x4000,0x0000 ,0x4000,0x0000 , - 0x3ffb,0x0192 ,0x3fff,0x00c9 ,0x3ff5,0x025b , - 0x3fec,0x0324 ,0x3ffb,0x0192 ,0x3fd4,0x04b5 , - 0x3fd4,0x04b5 ,0x3ff5,0x025b ,0x3f9c,0x070e , - 0x3fb1,0x0646 ,0x3fec,0x0324 ,0x3f4f,0x0964 , - 0x3f85,0x07d6 ,0x3fe1,0x03ed ,0x3eeb,0x0bb7 , - 0x3f4f,0x0964 ,0x3fd4,0x04b5 ,0x3e72,0x0e06 , - 0x3f0f,0x0af1 ,0x3fc4,0x057e ,0x3de3,0x1050 , - 0x3ec5,0x0c7c ,0x3fb1,0x0646 ,0x3d3f,0x1294 , - 0x3e72,0x0e06 ,0x3f9c,0x070e ,0x3c85,0x14d2 , - 0x3e15,0x0f8d ,0x3f85,0x07d6 ,0x3bb6,0x1709 , - 0x3daf,0x1112 ,0x3f6b,0x089d ,0x3ad3,0x1937 , - 0x3d3f,0x1294 ,0x3f4f,0x0964 ,0x39db,0x1b5d , - 0x3cc5,0x1413 ,0x3f30,0x0a2b ,0x38cf,0x1d79 , - 0x3c42,0x1590 ,0x3f0f,0x0af1 ,0x37b0,0x1f8c , - 0x3bb6,0x1709 ,0x3eeb,0x0bb7 ,0x367d,0x2193 , - 0x3b21,0x187e ,0x3ec5,0x0c7c ,0x3537,0x238e , - 0x3a82,0x19ef ,0x3e9d,0x0d41 ,0x33df,0x257e , - 0x39db,0x1b5d ,0x3e72,0x0e06 ,0x3274,0x2760 , - 0x392b,0x1cc6 ,0x3e45,0x0eca ,0x30f9,0x2935 , - 0x3871,0x1e2b ,0x3e15,0x0f8d ,0x2f6c,0x2afb , - 0x37b0,0x1f8c ,0x3de3,0x1050 ,0x2dcf,0x2cb2 , - 0x36e5,0x20e7 ,0x3daf,0x1112 ,0x2c21,0x2e5a , - 0x3612,0x223d ,0x3d78,0x11d3 ,0x2a65,0x2ff2 , - 0x3537,0x238e ,0x3d3f,0x1294 ,0x289a,0x3179 , - 0x3453,0x24da ,0x3d03,0x1354 ,0x26c1,0x32ef , - 0x3368,0x2620 ,0x3cc5,0x1413 ,0x24da,0x3453 , - 0x3274,0x2760 ,0x3c85,0x14d2 ,0x22e7,0x35a5 , - 0x3179,0x289a ,0x3c42,0x1590 ,0x20e7,0x36e5 , - 0x3076,0x29ce ,0x3bfd,0x164c ,0x1edc,0x3812 , - 0x2f6c,0x2afb ,0x3bb6,0x1709 ,0x1cc6,0x392b , - 0x2e5a,0x2c21 ,0x3b6d,0x17c4 ,0x1aa7,0x3a30 , - 0x2d41,0x2d41 ,0x3b21,0x187e ,0x187e,0x3b21 , - 0x2c21,0x2e5a ,0x3ad3,0x1937 ,0x164c,0x3bfd , - 0x2afb,0x2f6c ,0x3a82,0x19ef ,0x1413,0x3cc5 , - 0x29ce,0x3076 ,0x3a30,0x1aa7 ,0x11d3,0x3d78 , - 0x289a,0x3179 ,0x39db,0x1b5d ,0x0f8d,0x3e15 , - 0x2760,0x3274 ,0x3984,0x1c12 ,0x0d41,0x3e9d , - 0x2620,0x3368 ,0x392b,0x1cc6 ,0x0af1,0x3f0f , - 0x24da,0x3453 ,0x38cf,0x1d79 ,0x089d,0x3f6b , - 0x238e,0x3537 ,0x3871,0x1e2b ,0x0646,0x3fb1 , - 0x223d,0x3612 ,0x3812,0x1edc ,0x03ed,0x3fe1 , - 0x20e7,0x36e5 ,0x37b0,0x1f8c ,0x0192,0x3ffb , - 0x1f8c,0x37b0 ,0x374b,0x203a ,0xff37,0x3fff , - 0x1e2b,0x3871 ,0x36e5,0x20e7 ,0xfcdc,0x3fec , - 0x1cc6,0x392b ,0x367d,0x2193 ,0xfa82,0x3fc4 , - 0x1b5d,0x39db ,0x3612,0x223d ,0xf82a,0x3f85 , - 0x19ef,0x3a82 ,0x35a5,0x22e7 ,0xf5d5,0x3f30 , - 0x187e,0x3b21 ,0x3537,0x238e ,0xf384,0x3ec5 , - 0x1709,0x3bb6 ,0x34c6,0x2435 ,0xf136,0x3e45 , - 0x1590,0x3c42 ,0x3453,0x24da ,0xeeee,0x3daf , - 0x1413,0x3cc5 ,0x33df,0x257e ,0xecac,0x3d03 , - 0x1294,0x3d3f ,0x3368,0x2620 ,0xea70,0x3c42 , - 0x1112,0x3daf ,0x32ef,0x26c1 ,0xe83c,0x3b6d , - 0x0f8d,0x3e15 ,0x3274,0x2760 ,0xe611,0x3a82 , - 0x0e06,0x3e72 ,0x31f8,0x27fe ,0xe3ee,0x3984 , - 0x0c7c,0x3ec5 ,0x3179,0x289a ,0xe1d5,0x3871 , - 0x0af1,0x3f0f ,0x30f9,0x2935 ,0xdfc6,0x374b , - 0x0964,0x3f4f ,0x3076,0x29ce ,0xddc3,0x3612 , - 0x07d6,0x3f85 ,0x2ff2,0x2a65 ,0xdbcb,0x34c6 , - 0x0646,0x3fb1 ,0x2f6c,0x2afb ,0xd9e0,0x3368 , - 0x04b5,0x3fd4 ,0x2ee4,0x2b8f ,0xd802,0x31f8 , - 0x0324,0x3fec ,0x2e5a,0x2c21 ,0xd632,0x3076 , - 0x0192,0x3ffb ,0x2dcf,0x2cb2 ,0xd471,0x2ee4 , - 0x0000,0x4000 ,0x2d41,0x2d41 ,0xd2bf,0x2d41 , - 0xfe6e,0x3ffb ,0x2cb2,0x2dcf ,0xd11c,0x2b8f , - 0xfcdc,0x3fec ,0x2c21,0x2e5a ,0xcf8a,0x29ce , - 0xfb4b,0x3fd4 ,0x2b8f,0x2ee4 ,0xce08,0x27fe , - 0xf9ba,0x3fb1 ,0x2afb,0x2f6c ,0xcc98,0x2620 , - 0xf82a,0x3f85 ,0x2a65,0x2ff2 ,0xcb3a,0x2435 , - 0xf69c,0x3f4f ,0x29ce,0x3076 ,0xc9ee,0x223d , - 0xf50f,0x3f0f ,0x2935,0x30f9 ,0xc8b5,0x203a , - 0xf384,0x3ec5 ,0x289a,0x3179 ,0xc78f,0x1e2b , - 0xf1fa,0x3e72 ,0x27fe,0x31f8 ,0xc67c,0x1c12 , - 0xf073,0x3e15 ,0x2760,0x3274 ,0xc57e,0x19ef , - 0xeeee,0x3daf ,0x26c1,0x32ef ,0xc493,0x17c4 , - 0xed6c,0x3d3f ,0x2620,0x3368 ,0xc3be,0x1590 , - 0xebed,0x3cc5 ,0x257e,0x33df ,0xc2fd,0x1354 , - 0xea70,0x3c42 ,0x24da,0x3453 ,0xc251,0x1112 , - 0xe8f7,0x3bb6 ,0x2435,0x34c6 ,0xc1bb,0x0eca , - 0xe782,0x3b21 ,0x238e,0x3537 ,0xc13b,0x0c7c , - 0xe611,0x3a82 ,0x22e7,0x35a5 ,0xc0d0,0x0a2b , - 0xe4a3,0x39db ,0x223d,0x3612 ,0xc07b,0x07d6 , - 0xe33a,0x392b ,0x2193,0x367d ,0xc03c,0x057e , - 0xe1d5,0x3871 ,0x20e7,0x36e5 ,0xc014,0x0324 , - 0xe074,0x37b0 ,0x203a,0x374b ,0xc001,0x00c9 , - 0xdf19,0x36e5 ,0x1f8c,0x37b0 ,0xc005,0xfe6e , - 0xddc3,0x3612 ,0x1edc,0x3812 ,0xc01f,0xfc13 , - 0xdc72,0x3537 ,0x1e2b,0x3871 ,0xc04f,0xf9ba , - 0xdb26,0x3453 ,0x1d79,0x38cf ,0xc095,0xf763 , - 0xd9e0,0x3368 ,0x1cc6,0x392b ,0xc0f1,0xf50f , - 0xd8a0,0x3274 ,0x1c12,0x3984 ,0xc163,0xf2bf , - 0xd766,0x3179 ,0x1b5d,0x39db ,0xc1eb,0xf073 , - 0xd632,0x3076 ,0x1aa7,0x3a30 ,0xc288,0xee2d , - 0xd505,0x2f6c ,0x19ef,0x3a82 ,0xc33b,0xebed , - 0xd3df,0x2e5a ,0x1937,0x3ad3 ,0xc403,0xe9b4 , - 0xd2bf,0x2d41 ,0x187e,0x3b21 ,0xc4df,0xe782 , - 0xd1a6,0x2c21 ,0x17c4,0x3b6d ,0xc5d0,0xe559 , - 0xd094,0x2afb ,0x1709,0x3bb6 ,0xc6d5,0xe33a , - 0xcf8a,0x29ce ,0x164c,0x3bfd ,0xc7ee,0xe124 , - 0xce87,0x289a ,0x1590,0x3c42 ,0xc91b,0xdf19 , - 0xcd8c,0x2760 ,0x14d2,0x3c85 ,0xca5b,0xdd19 , - 0xcc98,0x2620 ,0x1413,0x3cc5 ,0xcbad,0xdb26 , - 0xcbad,0x24da ,0x1354,0x3d03 ,0xcd11,0xd93f , - 0xcac9,0x238e ,0x1294,0x3d3f ,0xce87,0xd766 , - 0xc9ee,0x223d ,0x11d3,0x3d78 ,0xd00e,0xd59b , - 0xc91b,0x20e7 ,0x1112,0x3daf ,0xd1a6,0xd3df , - 0xc850,0x1f8c ,0x1050,0x3de3 ,0xd34e,0xd231 , - 0xc78f,0x1e2b ,0x0f8d,0x3e15 ,0xd505,0xd094 , - 0xc6d5,0x1cc6 ,0x0eca,0x3e45 ,0xd6cb,0xcf07 , - 0xc625,0x1b5d ,0x0e06,0x3e72 ,0xd8a0,0xcd8c , - 0xc57e,0x19ef ,0x0d41,0x3e9d ,0xda82,0xcc21 , - 0xc4df,0x187e ,0x0c7c,0x3ec5 ,0xdc72,0xcac9 , - 0xc44a,0x1709 ,0x0bb7,0x3eeb ,0xde6d,0xc983 , - 0xc3be,0x1590 ,0x0af1,0x3f0f ,0xe074,0xc850 , - 0xc33b,0x1413 ,0x0a2b,0x3f30 ,0xe287,0xc731 , - 0xc2c1,0x1294 ,0x0964,0x3f4f ,0xe4a3,0xc625 , - 0xc251,0x1112 ,0x089d,0x3f6b ,0xe6c9,0xc52d , - 0xc1eb,0x0f8d ,0x07d6,0x3f85 ,0xe8f7,0xc44a , - 0xc18e,0x0e06 ,0x070e,0x3f9c ,0xeb2e,0xc37b , - 0xc13b,0x0c7c ,0x0646,0x3fb1 ,0xed6c,0xc2c1 , - 0xc0f1,0x0af1 ,0x057e,0x3fc4 ,0xefb0,0xc21d , - 0xc0b1,0x0964 ,0x04b5,0x3fd4 ,0xf1fa,0xc18e , - 0xc07b,0x07d6 ,0x03ed,0x3fe1 ,0xf449,0xc115 , - 0xc04f,0x0646 ,0x0324,0x3fec ,0xf69c,0xc0b1 , - 0xc02c,0x04b5 ,0x025b,0x3ff5 ,0xf8f2,0xc064 , - 0xc014,0x0324 ,0x0192,0x3ffb ,0xfb4b,0xc02c , - 0xc005,0x0192 ,0x00c9,0x3fff ,0xfda5,0xc00b , - 0x4000,0x0000 ,0x4000,0x0065 ,0x3fff,0x00c9 , - 0x3ffd,0x012e ,0x3ffb,0x0192 ,0x3ff8,0x01f7 , - 0x3ff5,0x025b ,0x3ff1,0x02c0 ,0x3fec,0x0324 , - 0x3fe7,0x0388 ,0x3fe1,0x03ed ,0x3fdb,0x0451 , - 0x3fd4,0x04b5 ,0x3fcc,0x051a ,0x3fc4,0x057e , - 0x3fbb,0x05e2 ,0x3fb1,0x0646 ,0x3fa7,0x06aa , - 0x3f9c,0x070e ,0x3f91,0x0772 ,0x3f85,0x07d6 , - 0x3f78,0x0839 ,0x3f6b,0x089d ,0x3f5d,0x0901 , - 0x3f4f,0x0964 ,0x3f40,0x09c7 ,0x3f30,0x0a2b , - 0x3f20,0x0a8e ,0x3f0f,0x0af1 ,0x3efd,0x0b54 , - 0x3eeb,0x0bb7 ,0x3ed8,0x0c1a ,0x3ec5,0x0c7c , - 0x3eb1,0x0cdf ,0x3e9d,0x0d41 ,0x3e88,0x0da4 , - 0x3e72,0x0e06 ,0x3e5c,0x0e68 ,0x3e45,0x0eca , - 0x3e2d,0x0f2b ,0x3e15,0x0f8d ,0x3dfc,0x0fee , - 0x3de3,0x1050 ,0x3dc9,0x10b1 ,0x3daf,0x1112 , - 0x3d93,0x1173 ,0x3d78,0x11d3 ,0x3d5b,0x1234 , - 0x3d3f,0x1294 ,0x3d21,0x12f4 ,0x3d03,0x1354 , - 0x3ce4,0x13b4 ,0x3cc5,0x1413 ,0x3ca5,0x1473 , - 0x3c85,0x14d2 ,0x3c64,0x1531 ,0x3c42,0x1590 , - 0x3c20,0x15ee ,0x3bfd,0x164c ,0x3bda,0x16ab , - 0x3bb6,0x1709 ,0x3b92,0x1766 ,0x3b6d,0x17c4 , - 0x3b47,0x1821 ,0x3b21,0x187e ,0x3afa,0x18db , - 0x3ad3,0x1937 ,0x3aab,0x1993 ,0x3a82,0x19ef , - 0x3a59,0x1a4b ,0x3a30,0x1aa7 ,0x3a06,0x1b02 , - 0x39db,0x1b5d ,0x39b0,0x1bb8 ,0x3984,0x1c12 , - 0x3958,0x1c6c ,0x392b,0x1cc6 ,0x38fd,0x1d20 , - 0x38cf,0x1d79 ,0x38a1,0x1dd3 ,0x3871,0x1e2b , - 0x3842,0x1e84 ,0x3812,0x1edc ,0x37e1,0x1f34 , - 0x37b0,0x1f8c ,0x377e,0x1fe3 ,0x374b,0x203a , - 0x3718,0x2091 ,0x36e5,0x20e7 ,0x36b1,0x213d , - 0x367d,0x2193 ,0x3648,0x21e8 ,0x3612,0x223d , - 0x35dc,0x2292 ,0x35a5,0x22e7 ,0x356e,0x233b , - 0x3537,0x238e ,0x34ff,0x23e2 ,0x34c6,0x2435 , - 0x348d,0x2488 ,0x3453,0x24da ,0x3419,0x252c , - 0x33df,0x257e ,0x33a3,0x25cf ,0x3368,0x2620 , - 0x332c,0x2671 ,0x32ef,0x26c1 ,0x32b2,0x2711 , - 0x3274,0x2760 ,0x3236,0x27af ,0x31f8,0x27fe , - 0x31b9,0x284c ,0x3179,0x289a ,0x3139,0x28e7 , - 0x30f9,0x2935 ,0x30b8,0x2981 ,0x3076,0x29ce , - 0x3034,0x2a1a ,0x2ff2,0x2a65 ,0x2faf,0x2ab0 , - 0x2f6c,0x2afb ,0x2f28,0x2b45 ,0x2ee4,0x2b8f , - 0x2e9f,0x2bd8 ,0x2e5a,0x2c21 ,0x2e15,0x2c6a , - 0x2dcf,0x2cb2 ,0x2d88,0x2cfa ,0x2d41,0x2d41 , - 0x2cfa,0x2d88 ,0x2cb2,0x2dcf ,0x2c6a,0x2e15 , - 0x2c21,0x2e5a ,0x2bd8,0x2e9f ,0x2b8f,0x2ee4 , - 0x2b45,0x2f28 ,0x2afb,0x2f6c ,0x2ab0,0x2faf , - 0x2a65,0x2ff2 ,0x2a1a,0x3034 ,0x29ce,0x3076 , - 0x2981,0x30b8 ,0x2935,0x30f9 ,0x28e7,0x3139 , - 0x289a,0x3179 ,0x284c,0x31b9 ,0x27fe,0x31f8 , - 0x27af,0x3236 ,0x2760,0x3274 ,0x2711,0x32b2 , - 0x26c1,0x32ef ,0x2671,0x332c ,0x2620,0x3368 , - 0x25cf,0x33a3 ,0x257e,0x33df ,0x252c,0x3419 , - 0x24da,0x3453 ,0x2488,0x348d ,0x2435,0x34c6 , - 0x23e2,0x34ff ,0x238e,0x3537 ,0x233b,0x356e , - 0x22e7,0x35a5 ,0x2292,0x35dc ,0x223d,0x3612 , - 0x21e8,0x3648 ,0x2193,0x367d ,0x213d,0x36b1 , - 0x20e7,0x36e5 ,0x2091,0x3718 ,0x203a,0x374b , - 0x1fe3,0x377e ,0x1f8c,0x37b0 ,0x1f34,0x37e1 , - 0x1edc,0x3812 ,0x1e84,0x3842 ,0x1e2b,0x3871 , - 0x1dd3,0x38a1 ,0x1d79,0x38cf ,0x1d20,0x38fd , - 0x1cc6,0x392b ,0x1c6c,0x3958 ,0x1c12,0x3984 , - 0x1bb8,0x39b0 ,0x1b5d,0x39db ,0x1b02,0x3a06 , - 0x1aa7,0x3a30 ,0x1a4b,0x3a59 ,0x19ef,0x3a82 , - 0x1993,0x3aab ,0x1937,0x3ad3 ,0x18db,0x3afa , - 0x187e,0x3b21 ,0x1821,0x3b47 ,0x17c4,0x3b6d , - 0x1766,0x3b92 ,0x1709,0x3bb6 ,0x16ab,0x3bda , - 0x164c,0x3bfd ,0x15ee,0x3c20 ,0x1590,0x3c42 , - 0x1531,0x3c64 ,0x14d2,0x3c85 ,0x1473,0x3ca5 , - 0x1413,0x3cc5 ,0x13b4,0x3ce4 ,0x1354,0x3d03 , - 0x12f4,0x3d21 ,0x1294,0x3d3f ,0x1234,0x3d5b , - 0x11d3,0x3d78 ,0x1173,0x3d93 ,0x1112,0x3daf , - 0x10b1,0x3dc9 ,0x1050,0x3de3 ,0x0fee,0x3dfc , - 0x0f8d,0x3e15 ,0x0f2b,0x3e2d ,0x0eca,0x3e45 , - 0x0e68,0x3e5c ,0x0e06,0x3e72 ,0x0da4,0x3e88 , - 0x0d41,0x3e9d ,0x0cdf,0x3eb1 ,0x0c7c,0x3ec5 , - 0x0c1a,0x3ed8 ,0x0bb7,0x3eeb ,0x0b54,0x3efd , - 0x0af1,0x3f0f ,0x0a8e,0x3f20 ,0x0a2b,0x3f30 , - 0x09c7,0x3f40 ,0x0964,0x3f4f ,0x0901,0x3f5d , - 0x089d,0x3f6b ,0x0839,0x3f78 ,0x07d6,0x3f85 , - 0x0772,0x3f91 ,0x070e,0x3f9c ,0x06aa,0x3fa7 , - 0x0646,0x3fb1 ,0x05e2,0x3fbb ,0x057e,0x3fc4 , - 0x051a,0x3fcc ,0x04b5,0x3fd4 ,0x0451,0x3fdb , - 0x03ed,0x3fe1 ,0x0388,0x3fe7 ,0x0324,0x3fec , - 0x02c0,0x3ff1 ,0x025b,0x3ff5 ,0x01f7,0x3ff8 , - 0x0192,0x3ffb ,0x012e,0x3ffd ,0x00c9,0x3fff , - 0x0065,0x4000 ,0x0000,0x4000 ,0xff9b,0x4000 , - 0xff37,0x3fff ,0xfed2,0x3ffd ,0xfe6e,0x3ffb , - 0xfe09,0x3ff8 ,0xfda5,0x3ff5 ,0xfd40,0x3ff1 , - 0xfcdc,0x3fec ,0xfc78,0x3fe7 ,0xfc13,0x3fe1 , - 0xfbaf,0x3fdb ,0xfb4b,0x3fd4 ,0xfae6,0x3fcc , - 0xfa82,0x3fc4 ,0xfa1e,0x3fbb ,0xf9ba,0x3fb1 , - 0xf956,0x3fa7 ,0xf8f2,0x3f9c ,0xf88e,0x3f91 , - 0xf82a,0x3f85 ,0xf7c7,0x3f78 ,0xf763,0x3f6b , - 0xf6ff,0x3f5d ,0xf69c,0x3f4f ,0xf639,0x3f40 , - 0xf5d5,0x3f30 ,0xf572,0x3f20 ,0xf50f,0x3f0f , - 0xf4ac,0x3efd ,0xf449,0x3eeb ,0xf3e6,0x3ed8 , - 0xf384,0x3ec5 ,0xf321,0x3eb1 ,0xf2bf,0x3e9d , - 0xf25c,0x3e88 ,0xf1fa,0x3e72 ,0xf198,0x3e5c , - 0xf136,0x3e45 ,0xf0d5,0x3e2d ,0xf073,0x3e15 , - 0xf012,0x3dfc ,0xefb0,0x3de3 ,0xef4f,0x3dc9 , - 0xeeee,0x3daf ,0xee8d,0x3d93 ,0xee2d,0x3d78 , - 0xedcc,0x3d5b ,0xed6c,0x3d3f ,0xed0c,0x3d21 , - 0xecac,0x3d03 ,0xec4c,0x3ce4 ,0xebed,0x3cc5 , - 0xeb8d,0x3ca5 ,0xeb2e,0x3c85 ,0xeacf,0x3c64 , - 0xea70,0x3c42 ,0xea12,0x3c20 ,0xe9b4,0x3bfd , - 0xe955,0x3bda ,0xe8f7,0x3bb6 ,0xe89a,0x3b92 , - 0xe83c,0x3b6d ,0xe7df,0x3b47 ,0xe782,0x3b21 , - 0xe725,0x3afa ,0xe6c9,0x3ad3 ,0xe66d,0x3aab , - 0xe611,0x3a82 ,0xe5b5,0x3a59 ,0xe559,0x3a30 , - 0xe4fe,0x3a06 ,0xe4a3,0x39db ,0xe448,0x39b0 , - 0xe3ee,0x3984 ,0xe394,0x3958 ,0xe33a,0x392b , - 0xe2e0,0x38fd ,0xe287,0x38cf ,0xe22d,0x38a1 , - 0xe1d5,0x3871 ,0xe17c,0x3842 ,0xe124,0x3812 , - 0xe0cc,0x37e1 ,0xe074,0x37b0 ,0xe01d,0x377e , - 0xdfc6,0x374b ,0xdf6f,0x3718 ,0xdf19,0x36e5 , - 0xdec3,0x36b1 ,0xde6d,0x367d ,0xde18,0x3648 , - 0xddc3,0x3612 ,0xdd6e,0x35dc ,0xdd19,0x35a5 , - 0xdcc5,0x356e ,0xdc72,0x3537 ,0xdc1e,0x34ff , - 0xdbcb,0x34c6 ,0xdb78,0x348d ,0xdb26,0x3453 , - 0xdad4,0x3419 ,0xda82,0x33df ,0xda31,0x33a3 , - 0xd9e0,0x3368 ,0xd98f,0x332c ,0xd93f,0x32ef , - 0xd8ef,0x32b2 ,0xd8a0,0x3274 ,0xd851,0x3236 , - 0xd802,0x31f8 ,0xd7b4,0x31b9 ,0xd766,0x3179 , - 0xd719,0x3139 ,0xd6cb,0x30f9 ,0xd67f,0x30b8 , - 0xd632,0x3076 ,0xd5e6,0x3034 ,0xd59b,0x2ff2 , - 0xd550,0x2faf ,0xd505,0x2f6c ,0xd4bb,0x2f28 , - 0xd471,0x2ee4 ,0xd428,0x2e9f ,0xd3df,0x2e5a , - 0xd396,0x2e15 ,0xd34e,0x2dcf ,0xd306,0x2d88 , - 0xd2bf,0x2d41 ,0xd278,0x2cfa ,0xd231,0x2cb2 , - 0xd1eb,0x2c6a ,0xd1a6,0x2c21 ,0xd161,0x2bd8 , - 0xd11c,0x2b8f ,0xd0d8,0x2b45 ,0xd094,0x2afb , - 0xd051,0x2ab0 ,0xd00e,0x2a65 ,0xcfcc,0x2a1a , - 0xcf8a,0x29ce ,0xcf48,0x2981 ,0xcf07,0x2935 , - 0xcec7,0x28e7 ,0xce87,0x289a ,0xce47,0x284c , - 0xce08,0x27fe ,0xcdca,0x27af ,0xcd8c,0x2760 , - 0xcd4e,0x2711 ,0xcd11,0x26c1 ,0xccd4,0x2671 , - 0xcc98,0x2620 ,0xcc5d,0x25cf ,0xcc21,0x257e , - 0xcbe7,0x252c ,0xcbad,0x24da ,0xcb73,0x2488 , - 0xcb3a,0x2435 ,0xcb01,0x23e2 ,0xcac9,0x238e , - 0xca92,0x233b ,0xca5b,0x22e7 ,0xca24,0x2292 , - 0xc9ee,0x223d ,0xc9b8,0x21e8 ,0xc983,0x2193 , - 0xc94f,0x213d ,0xc91b,0x20e7 ,0xc8e8,0x2091 , - 0xc8b5,0x203a ,0xc882,0x1fe3 ,0xc850,0x1f8c , - 0xc81f,0x1f34 ,0xc7ee,0x1edc ,0xc7be,0x1e84 , - 0xc78f,0x1e2b ,0xc75f,0x1dd3 ,0xc731,0x1d79 , - 0xc703,0x1d20 ,0xc6d5,0x1cc6 ,0xc6a8,0x1c6c , - 0xc67c,0x1c12 ,0xc650,0x1bb8 ,0xc625,0x1b5d , - 0xc5fa,0x1b02 ,0xc5d0,0x1aa7 ,0xc5a7,0x1a4b , - 0xc57e,0x19ef ,0xc555,0x1993 ,0xc52d,0x1937 , - 0xc506,0x18db ,0xc4df,0x187e ,0xc4b9,0x1821 , - 0xc493,0x17c4 ,0xc46e,0x1766 ,0xc44a,0x1709 , - 0xc426,0x16ab ,0xc403,0x164c ,0xc3e0,0x15ee , - 0xc3be,0x1590 ,0xc39c,0x1531 ,0xc37b,0x14d2 , - 0xc35b,0x1473 ,0xc33b,0x1413 ,0xc31c,0x13b4 , - 0xc2fd,0x1354 ,0xc2df,0x12f4 ,0xc2c1,0x1294 , - 0xc2a5,0x1234 ,0xc288,0x11d3 ,0xc26d,0x1173 , - 0xc251,0x1112 ,0xc237,0x10b1 ,0xc21d,0x1050 , - 0xc204,0x0fee ,0xc1eb,0x0f8d ,0xc1d3,0x0f2b , - 0xc1bb,0x0eca ,0xc1a4,0x0e68 ,0xc18e,0x0e06 , - 0xc178,0x0da4 ,0xc163,0x0d41 ,0xc14f,0x0cdf , - 0xc13b,0x0c7c ,0xc128,0x0c1a ,0xc115,0x0bb7 , - 0xc103,0x0b54 ,0xc0f1,0x0af1 ,0xc0e0,0x0a8e , - 0xc0d0,0x0a2b ,0xc0c0,0x09c7 ,0xc0b1,0x0964 , - 0xc0a3,0x0901 ,0xc095,0x089d ,0xc088,0x0839 , - 0xc07b,0x07d6 ,0xc06f,0x0772 ,0xc064,0x070e , - 0xc059,0x06aa ,0xc04f,0x0646 ,0xc045,0x05e2 , - 0xc03c,0x057e ,0xc034,0x051a ,0xc02c,0x04b5 , - 0xc025,0x0451 ,0xc01f,0x03ed ,0xc019,0x0388 , - 0xc014,0x0324 ,0xc00f,0x02c0 ,0xc00b,0x025b , - 0xc008,0x01f7 ,0xc005,0x0192 ,0xc003,0x012e , - 0xc001,0x00c9 ,0xc000,0x0065 };
diff --git a/src/common_audio/signal_processing/webrtc_fft_t_rad.c b/src/common_audio/signal_processing/webrtc_fft_t_rad.c deleted file mode 100644 index 13fbd9f..0000000 --- a/src/common_audio/signal_processing/webrtc_fft_t_rad.c +++ /dev/null
@@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This file contains the Q14 radix-2 tables used in ARM9E optimization routines. - * - */ - -extern const unsigned short t_Q14S_rad8[2]; -const unsigned short t_Q14S_rad8[2] = { 0x0000,0x2d41 }; - -//extern const int t_Q30S_rad8[2]; -//const int t_Q30S_rad8[2] = { 0x00000000,0x2d413ccd }; - -extern const unsigned short t_Q14R_rad8[2]; -const unsigned short t_Q14R_rad8[2] = { 0x2d41,0x2d41 }; - -//extern const int t_Q30R_rad8[2]; -//const int t_Q30R_rad8[2] = { 0x2d413ccd,0x2d413ccd };
diff --git a/src/common_audio/vad/Android.mk b/src/common_audio/vad/Android.mk deleted file mode 100644 index 33934ec..0000000 --- a/src/common_audio/vad/Android.mk +++ /dev/null
@@ -1,53 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -include $(LOCAL_PATH)/../../../android-webrtc.mk - -LOCAL_ARM_MODE := arm -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libwebrtc_vad -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := \ - webrtc_vad.c \ - vad_core.c \ - vad_filterbank.c \ - vad_gmm.c \ - vad_sp.c - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := \ - $(MY_WEBRTC_COMMON_DEFS) - -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) -LOCAL_CFLAGS_x86 := $(MY_WEBRTC_COMMON_DEFS_x86) -LOCAL_CFLAGS_mips := $(MY_WEBRTC_COMMON_DEFS_mips) -LOCAL_CFLAGS_arm64 := $(MY_WEBRTC_COMMON_DEFS_arm64) -LOCAL_CFLAGS_x86_64 := $(MY_WEBRTC_COMMON_DEFS_x86_64) -LOCAL_CFLAGS_mips64 := $(MY_WEBRTC_COMMON_DEFS_mips64) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/../.. \ - $(LOCAL_PATH)/../signal_processing/include - -LOCAL_SHARED_LIBRARIES := \ - libdl - -LOCAL_SHARED_LIBRARIES += libdl - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -endif - -include $(BUILD_STATIC_LIBRARY)
diff --git a/src/common_audio/vad/include/webrtc_vad.h b/src/common_audio/vad/include/webrtc_vad.h deleted file mode 100644 index edc7494..0000000 --- a/src/common_audio/vad/include/webrtc_vad.h +++ /dev/null
@@ -1,90 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This header file includes the VAD API calls. Specific function calls are given below. - */ - -#ifndef WEBRTC_COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_ // NOLINT -#define WEBRTC_COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_ - -#include "typedefs.h" // NOLINT - -typedef struct WebRtcVadInst VadInst; - -#ifdef __cplusplus -extern "C" { -#endif - -// Creates an instance to the VAD structure. -// -// - handle [o] : Pointer to the VAD instance that should be created. -// -// returns : 0 - (OK), -1 - (Error) -int WebRtcVad_Create(VadInst** handle); - -// Frees the dynamic memory of a specified VAD instance. -// -// - handle [i] : Pointer to VAD instance that should be freed. -// -// returns : 0 - (OK), -1 - (NULL pointer in) -int WebRtcVad_Free(VadInst* handle); - -// Initializes a VAD instance. -// -// - handle [i/o] : Instance that should be initialized. -// -// returns : 0 - (OK), -// -1 - (NULL pointer or Default mode could not be set). -int WebRtcVad_Init(VadInst* handle); - -// Sets the VAD operating mode. A more aggressive (higher mode) VAD is more -// restrictive in reporting speech. Put in other words the probability of being -// speech when the VAD returns 1 is increased with increasing mode. As a -// consequence also the missed detection rate goes up. -// -// - handle [i/o] : VAD instance. -// - mode [i] : Aggressiveness mode (0, 1, 2, or 3). -// -// returns : 0 - (OK), -// -1 - (NULL pointer, mode could not be set or the VAD instance -// has not been initialized). -int WebRtcVad_set_mode(VadInst* handle, int mode); - -// Calculates a VAD decision for the |audio_frame|. For valid sampling rates -// frame lengths, see the description of WebRtcVad_ValidRatesAndFrameLengths(). -// -// - handle [i/o] : VAD Instance. Needs to be initialized by -// WebRtcVad_Init() before call. -// - fs [i] : Sampling frequency (Hz): 8000, 16000, or 32000 -// - audio_frame [i] : Audio frame buffer. -// - frame_length [i] : Length of audio frame buffer in number of samples. -// -// returns : 1 - (Active Voice), -// 0 - (Non-active Voice), -// -1 - (Error) -int WebRtcVad_Process(VadInst* handle, int fs, int16_t* audio_frame, - int frame_length); - -// Checks for valid combinations of |rate| and |frame_length|. We support 10, -// 20 and 30 ms frames and the rates 8000, 16000 and 32000 Hz. -// -// - rate [i] : Sampling frequency (Hz). -// - frame_length [i] : Speech frame buffer length in number of samples. -// -// returns : 0 - (valid combination), -1 - (invalid combination) -int WebRtcVad_ValidRateAndFrameLength(int rate, int frame_length); - -#ifdef __cplusplus -} -#endif - -#endif // WEBRTC_COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_ // NOLINT
diff --git a/src/common_audio/vad/vad.gypi b/src/common_audio/vad/vad.gypi deleted file mode 100644 index 5a9466c..0000000 --- a/src/common_audio/vad/vad.gypi +++ /dev/null
@@ -1,68 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'vad', - 'type': '<(library)', - 'dependencies': [ - 'signal_processing', - ], - 'include_dirs': [ - 'include', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - ], - }, - 'sources': [ - 'include/webrtc_vad.h', - 'webrtc_vad.c', - 'vad_core.c', - 'vad_core.h', - 'vad_filterbank.c', - 'vad_filterbank.h', - 'vad_gmm.c', - 'vad_gmm.h', - 'vad_sp.c', - 'vad_sp.h', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets' : [ - { - 'target_name': 'vad_unittests', - 'type': 'executable', - 'dependencies': [ - 'vad', - '<(webrtc_root)/test/test.gyp:test_support_main', - '<(DEPTH)/testing/gtest.gyp:gtest', - ], - 'sources': [ - 'vad_core_unittest.cc', - 'vad_filterbank_unittest.cc', - 'vad_gmm_unittest.cc', - 'vad_sp_unittest.cc', - 'vad_unittest.cc', - 'vad_unittest.h', - ], - }, # vad_unittests - ], # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/common_audio/vad/vad_core.c b/src/common_audio/vad/vad_core.c deleted file mode 100644 index 1e9053f..0000000 --- a/src/common_audio/vad/vad_core.c +++ /dev/null
@@ -1,654 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "vad_core.h" - -#include "signal_processing_library.h" -#include "typedefs.h" -#include "vad_filterbank.h" -#include "vad_gmm.h" -#include "vad_sp.h" - -// Spectrum Weighting -static const int16_t kSpectrumWeight[kNumChannels] = { 6, 8, 10, 12, 14, 16 }; -static const int16_t kNoiseUpdateConst = 655; // Q15 -static const int16_t kSpeechUpdateConst = 6554; // Q15 -static const int16_t kBackEta = 154; // Q8 -// Minimum difference between the two models, Q5 -static const int16_t kMinimumDifference[kNumChannels] = { - 544, 544, 576, 576, 576, 576 }; -// Upper limit of mean value for speech model, Q7 -static const int16_t kMaximumSpeech[kNumChannels] = { - 11392, 11392, 11520, 11520, 11520, 11520 }; -// Minimum value for mean value -static const int16_t kMinimumMean[kNumGaussians] = { 640, 768 }; -// Upper limit of mean value for noise model, Q7 -static const int16_t kMaximumNoise[kNumChannels] = { - 9216, 9088, 8960, 8832, 8704, 8576 }; -// Start values for the Gaussian models, Q7 -// Weights for the two Gaussians for the six channels (noise) -static const int16_t kNoiseDataWeights[kTableSize] = { - 34, 62, 72, 66, 53, 25, 94, 66, 56, 62, 75, 103 }; -// Weights for the two Gaussians for the six channels (speech) -static const int16_t kSpeechDataWeights[kTableSize] = { - 48, 82, 45, 87, 50, 47, 80, 46, 83, 41, 78, 81 }; -// Means for the two Gaussians for the six channels (noise) -static const int16_t kNoiseDataMeans[kTableSize] = { - 6738, 4892, 7065, 6715, 6771, 3369, 7646, 3863, 7820, 7266, 5020, 4362 }; -// Means for the two Gaussians for the six channels (speech) -static const int16_t kSpeechDataMeans[kTableSize] = { - 8306, 10085, 10078, 11823, 11843, 6309, 9473, 9571, 10879, 7581, 8180, 7483 -}; -// Stds for the two Gaussians for the six channels (noise) -static const int16_t kNoiseDataStds[kTableSize] = { - 378, 1064, 493, 582, 688, 593, 474, 697, 475, 688, 421, 455 }; -// Stds for the two Gaussians for the six channels (speech) -static const int16_t kSpeechDataStds[kTableSize] = { - 555, 505, 567, 524, 585, 1231, 509, 828, 492, 1540, 1079, 850 }; - -// Constants used in GmmProbability(). -// -// Maximum number of counted speech (VAD = 1) frames in a row. -static const int16_t kMaxSpeechFrames = 6; -// Minimum standard deviation for both speech and noise. -static const int16_t kMinStd = 384; - -// Constants in WebRtcVad_InitCore(). -// Default aggressiveness mode. -static const short kDefaultMode = 0; -static const int kInitCheck = 42; - -// Constants used in WebRtcVad_set_mode_core(). -// -// Thresholds for different frame lengths (10 ms, 20 ms and 30 ms). -// -// Mode 0, Quality. -static const int16_t kOverHangMax1Q[3] = { 8, 4, 3 }; -static const int16_t kOverHangMax2Q[3] = { 14, 7, 5 }; -static const int16_t kLocalThresholdQ[3] = { 24, 21, 24 }; -static const int16_t kGlobalThresholdQ[3] = { 57, 48, 57 }; -// Mode 1, Low bitrate. -static const int16_t kOverHangMax1LBR[3] = { 8, 4, 3 }; -static const int16_t kOverHangMax2LBR[3] = { 14, 7, 5 }; -static const int16_t kLocalThresholdLBR[3] = { 37, 32, 37 }; -static const int16_t kGlobalThresholdLBR[3] = { 100, 80, 100 }; -// Mode 2, Aggressive. -static const int16_t kOverHangMax1AGG[3] = { 6, 3, 2 }; -static const int16_t kOverHangMax2AGG[3] = { 9, 5, 3 }; -static const int16_t kLocalThresholdAGG[3] = { 82, 78, 82 }; -static const int16_t kGlobalThresholdAGG[3] = { 285, 260, 285 }; -// Mode 3, Very aggressive. -static const int16_t kOverHangMax1VAG[3] = { 6, 3, 2 }; -static const int16_t kOverHangMax2VAG[3] = { 9, 5, 3 }; -static const int16_t kLocalThresholdVAG[3] = { 94, 94, 94 }; -static const int16_t kGlobalThresholdVAG[3] = { 1100, 1050, 1100 }; - -// Calculates the weighted average w.r.t. number of Gaussians. The |data| are -// updated with an |offset| before averaging. -// -// - data [i/o] : Data to average. -// - offset [i] : An offset added to |data|. -// - weights [i] : Weights used for averaging. -// -// returns : The weighted average. -static int32_t WeightedAverage(int16_t* data, int16_t offset, - const int16_t* weights) { - int k; - int32_t weighted_average = 0; - - for (k = 0; k < kNumGaussians; k++) { - data[k * kNumChannels] += offset; - weighted_average += data[k * kNumChannels] * weights[k * kNumChannels]; - } - return weighted_average; -} - -// Calculates the probabilities for both speech and background noise using -// Gaussian Mixture Models (GMM). A hypothesis-test is performed to decide which -// type of signal is most probable. -// -// - self [i/o] : Pointer to VAD instance -// - features [i] : Feature vector of length |kNumChannels| -// = log10(energy in frequency band) -// - total_power [i] : Total power in audio frame. -// - frame_length [i] : Number of input samples -// -// - returns : the VAD decision (0 - noise, 1 - speech). -static int16_t GmmProbability(VadInstT* self, int16_t* features, - int16_t total_power, int frame_length) { - int channel, k; - int16_t feature_minimum; - int16_t h0, h1; - int16_t log_likelihood_ratio; - int16_t vadflag = 0; - int16_t shifts_h0, shifts_h1; - int16_t tmp_s16, tmp1_s16, tmp2_s16; - int16_t diff; - int gaussian; - int16_t nmk, nmk2, nmk3, smk, smk2, nsk, ssk; - int16_t delt, ndelt; - int16_t maxspe, maxmu; - int16_t deltaN[kTableSize], deltaS[kTableSize]; - int16_t ngprvec[kTableSize] = { 0 }; // Conditional probability = 0. - int16_t sgprvec[kTableSize] = { 0 }; // Conditional probability = 0. - int32_t h0_test, h1_test; - int32_t tmp1_s32, tmp2_s32; - int32_t sum_log_likelihood_ratios = 0; - int32_t noise_global_mean, speech_global_mean; - int32_t noise_probability[kNumGaussians], speech_probability[kNumGaussians]; - int16_t overhead1, overhead2, individualTest, totalTest; - - // Set various thresholds based on frame lengths (80, 160 or 240 samples). - if (frame_length == 80) { - overhead1 = self->over_hang_max_1[0]; - overhead2 = self->over_hang_max_2[0]; - individualTest = self->individual[0]; - totalTest = self->total[0]; - } else if (frame_length == 160) { - overhead1 = self->over_hang_max_1[1]; - overhead2 = self->over_hang_max_2[1]; - individualTest = self->individual[1]; - totalTest = self->total[1]; - } else { - overhead1 = self->over_hang_max_1[2]; - overhead2 = self->over_hang_max_2[2]; - individualTest = self->individual[2]; - totalTest = self->total[2]; - } - - if (total_power > kMinEnergy) { - // The signal power of current frame is large enough for processing. The - // processing consists of two parts: - // 1) Calculating the likelihood of speech and thereby a VAD decision. - // 2) Updating the underlying model, w.r.t., the decision made. - - // The detection scheme is an LRT with hypothesis - // H0: Noise - // H1: Speech - // - // We combine a global LRT with local tests, for each frequency sub-band, - // here defined as |channel|. - for (channel = 0; channel < kNumChannels; channel++) { - // For each channel we model the probability with a GMM consisting of - // |kNumGaussians|, with different means and standard deviations depending - // on H0 or H1. - h0_test = 0; - h1_test = 0; - for (k = 0; k < kNumGaussians; k++) { - gaussian = channel + k * kNumChannels; - // Probability under H0, that is, probability of frame being noise. - // Value given in Q27 = Q7 * Q20. - tmp1_s32 = WebRtcVad_GaussianProbability(features[channel], - self->noise_means[gaussian], - self->noise_stds[gaussian], - &deltaN[gaussian]); - noise_probability[k] = kNoiseDataWeights[gaussian] * tmp1_s32; - h0_test += noise_probability[k]; // Q27 - - // Probability under H1, that is, probability of frame being speech. - // Value given in Q27 = Q7 * Q20. - tmp1_s32 = WebRtcVad_GaussianProbability(features[channel], - self->speech_means[gaussian], - self->speech_stds[gaussian], - &deltaS[gaussian]); - speech_probability[k] = kSpeechDataWeights[gaussian] * tmp1_s32; - h1_test += speech_probability[k]; // Q27 - } - - // Calculate the log likelihood ratio: log2(Pr{X|H1} / Pr{X|H1}). - // Approximation: - // log2(Pr{X|H1} / Pr{X|H1}) = log2(Pr{X|H1}*2^Q) - log2(Pr{X|H1}*2^Q) - // = log2(h1_test) - log2(h0_test) - // = log2(2^(31-shifts_h1)*(1+b1)) - // - log2(2^(31-shifts_h0)*(1+b0)) - // = shifts_h0 - shifts_h1 - // + log2(1+b1) - log2(1+b0) - // ~= shifts_h0 - shifts_h1 - // - // Note that b0 and b1 are values less than 1, hence, 0 <= log2(1+b0) < 1. - // Further, b0 and b1 are independent and on the average the two terms - // cancel. - shifts_h0 = WebRtcSpl_NormW32(h0_test); - shifts_h1 = WebRtcSpl_NormW32(h1_test); - if (h0_test == 0) { - shifts_h0 = 31; - } - if (h1_test == 0) { - shifts_h1 = 31; - } - log_likelihood_ratio = shifts_h0 - shifts_h1; - - // Update |sum_log_likelihood_ratios| with spectrum weighting. This is - // used for the global VAD decision. - sum_log_likelihood_ratios += - (int32_t) (log_likelihood_ratio * kSpectrumWeight[channel]); - - // Local VAD decision. - if ((log_likelihood_ratio << 2) > individualTest) { - vadflag = 1; - } - - // TODO(bjornv): The conditional probabilities below are applied on the - // hard coded number of Gaussians set to two. Find a way to generalize. - // Calculate local noise probabilities used later when updating the GMM. - h0 = (int16_t) (h0_test >> 12); // Q15 - if (h0 > 0) { - // High probability of noise. Assign conditional probabilities for each - // Gaussian in the GMM. - tmp1_s32 = (noise_probability[0] & 0xFFFFF000) << 2; // Q29 - ngprvec[channel] = (int16_t) WebRtcSpl_DivW32W16(tmp1_s32, h0); // Q14 - ngprvec[channel + kNumChannels] = 16384 - ngprvec[channel]; - } else { - // Low noise probability. Assign conditional probability 1 to the first - // Gaussian and 0 to the rest (which is already set at initialization). - ngprvec[channel] = 16384; - } - - // Calculate local speech probabilities used later when updating the GMM. - h1 = (int16_t) (h1_test >> 12); // Q15 - if (h1 > 0) { - // High probability of speech. Assign conditional probabilities for each - // Gaussian in the GMM. Otherwise use the initialized values, i.e., 0. - tmp1_s32 = (speech_probability[0] & 0xFFFFF000) << 2; // Q29 - sgprvec[channel] = (int16_t) WebRtcSpl_DivW32W16(tmp1_s32, h1); // Q14 - sgprvec[channel + kNumChannels] = 16384 - sgprvec[channel]; - } - } - - // Make a global VAD decision. - vadflag |= (sum_log_likelihood_ratios >= totalTest); - - // Update the model parameters. - maxspe = 12800; - for (channel = 0; channel < kNumChannels; channel++) { - - // Get minimum value in past which is used for long term correction in Q4. - feature_minimum = WebRtcVad_FindMinimum(self, features[channel], channel); - - // Compute the "global" mean, that is the sum of the two means weighted. - noise_global_mean = WeightedAverage(&self->noise_means[channel], 0, - &kNoiseDataWeights[channel]); - tmp1_s16 = (int16_t) (noise_global_mean >> 6); // Q8 - - for (k = 0; k < kNumGaussians; k++) { - gaussian = channel + k * kNumChannels; - - nmk = self->noise_means[gaussian]; - smk = self->speech_means[gaussian]; - nsk = self->noise_stds[gaussian]; - ssk = self->speech_stds[gaussian]; - - // Update noise mean vector if the frame consists of noise only. - nmk2 = nmk; - if (!vadflag) { - // deltaN = (x-mu)/sigma^2 - // ngprvec[k] = |noise_probability[k]| / - // (|noise_probability[0]| + |noise_probability[1]|) - - // (Q14 * Q11 >> 11) = Q14. - delt = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(ngprvec[gaussian], - deltaN[gaussian], - 11); - // Q7 + (Q14 * Q15 >> 22) = Q7. - nmk2 = nmk + (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(delt, - kNoiseUpdateConst, - 22); - } - - // Long term correction of the noise mean. - // Q8 - Q8 = Q8. - ndelt = (feature_minimum << 4) - tmp1_s16; - // Q7 + (Q8 * Q8) >> 9 = Q7. - nmk3 = nmk2 + (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(ndelt, kBackEta, 9); - - // Control that the noise mean does not drift to much. - tmp_s16 = (int16_t) ((k + 5) << 7); - if (nmk3 < tmp_s16) { - nmk3 = tmp_s16; - } - tmp_s16 = (int16_t) ((72 + k - channel) << 7); - if (nmk3 > tmp_s16) { - nmk3 = tmp_s16; - } - self->noise_means[gaussian] = nmk3; - - if (vadflag) { - // Update speech mean vector: - // |deltaS| = (x-mu)/sigma^2 - // sgprvec[k] = |speech_probability[k]| / - // (|speech_probability[0]| + |speech_probability[1]|) - - // (Q14 * Q11) >> 11 = Q14. - delt = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(sgprvec[gaussian], - deltaS[gaussian], - 11); - // Q14 * Q15 >> 21 = Q8. - tmp_s16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(delt, - kSpeechUpdateConst, - 21); - // Q7 + (Q8 >> 1) = Q7. With rounding. - smk2 = smk + ((tmp_s16 + 1) >> 1); - - // Control that the speech mean does not drift to much. - maxmu = maxspe + 640; - if (smk2 < kMinimumMean[k]) { - smk2 = kMinimumMean[k]; - } - if (smk2 > maxmu) { - smk2 = maxmu; - } - self->speech_means[gaussian] = smk2; // Q7. - - // (Q7 >> 3) = Q4. With rounding. - tmp_s16 = ((smk + 4) >> 3); - - tmp_s16 = features[channel] - tmp_s16; // Q4 - // (Q11 * Q4 >> 3) = Q12. - tmp1_s32 = WEBRTC_SPL_MUL_16_16_RSFT(deltaS[gaussian], tmp_s16, 3); - tmp2_s32 = tmp1_s32 - 4096; - tmp_s16 = sgprvec[gaussian] >> 2; - // (Q14 >> 2) * Q12 = Q24. - tmp1_s32 = tmp_s16 * tmp2_s32; - - tmp2_s32 = tmp1_s32 >> 4; // Q20 - - // 0.1 * Q20 / Q7 = Q13. - if (tmp2_s32 > 0) { - tmp_s16 = (int16_t) WebRtcSpl_DivW32W16(tmp2_s32, ssk * 10); - } else { - tmp_s16 = (int16_t) WebRtcSpl_DivW32W16(-tmp2_s32, ssk * 10); - tmp_s16 = -tmp_s16; - } - // Divide by 4 giving an update factor of 0.025 (= 0.1 / 4). - // Note that division by 4 equals shift by 2, hence, - // (Q13 >> 8) = (Q13 >> 6) / 4 = Q7. - tmp_s16 += 128; // Rounding. - ssk += (tmp_s16 >> 8); - if (ssk < kMinStd) { - ssk = kMinStd; - } - self->speech_stds[gaussian] = ssk; - } else { - // Update GMM variance vectors. - // deltaN * (features[channel] - nmk) - 1 - // Q4 - (Q7 >> 3) = Q4. - tmp_s16 = features[channel] - (nmk >> 3); - // (Q11 * Q4 >> 3) = Q12. - tmp1_s32 = WEBRTC_SPL_MUL_16_16_RSFT(deltaN[gaussian], tmp_s16, 3); - tmp1_s32 -= 4096; - - // (Q14 >> 2) * Q12 = Q24. - tmp_s16 = (ngprvec[gaussian] + 2) >> 2; - tmp2_s32 = tmp_s16 * tmp1_s32; - // Q20 * approx 0.001 (2^-10=0.0009766), hence, - // (Q24 >> 14) = (Q24 >> 4) / 2^10 = Q20. - tmp1_s32 = tmp2_s32 >> 14; - - // Q20 / Q7 = Q13. - if (tmp1_s32 > 0) { - tmp_s16 = (int16_t) WebRtcSpl_DivW32W16(tmp1_s32, nsk); - } else { - tmp_s16 = (int16_t) WebRtcSpl_DivW32W16(-tmp1_s32, nsk); - tmp_s16 = -tmp_s16; - } - tmp_s16 += 32; // Rounding - nsk += tmp_s16 >> 6; // Q13 >> 6 = Q7. - if (nsk < kMinStd) { - nsk = kMinStd; - } - self->noise_stds[gaussian] = nsk; - } - } - - // Separate models if they are too close. - // |noise_global_mean| in Q14 (= Q7 * Q7). - noise_global_mean = WeightedAverage(&self->noise_means[channel], 0, - &kNoiseDataWeights[channel]); - - // |speech_global_mean| in Q14 (= Q7 * Q7). - speech_global_mean = WeightedAverage(&self->speech_means[channel], 0, - &kSpeechDataWeights[channel]); - - // |diff| = "global" speech mean - "global" noise mean. - // (Q14 >> 9) - (Q14 >> 9) = Q5. - diff = (int16_t) (speech_global_mean >> 9) - - (int16_t) (noise_global_mean >> 9); - if (diff < kMinimumDifference[channel]) { - tmp_s16 = kMinimumDifference[channel] - diff; - - // |tmp1_s16| = ~0.8 * (kMinimumDifference - diff) in Q7. - // |tmp2_s16| = ~0.2 * (kMinimumDifference - diff) in Q7. - tmp1_s16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(13, tmp_s16, 2); - tmp2_s16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(3, tmp_s16, 2); - - // Move Gaussian means for speech model by |tmp1_s16| and update - // |speech_global_mean|. Note that |self->speech_means[channel]| is - // changed after the call. - speech_global_mean = WeightedAverage(&self->speech_means[channel], - tmp1_s16, - &kSpeechDataWeights[channel]); - - // Move Gaussian means for noise model by -|tmp2_s16| and update - // |noise_global_mean|. Note that |self->noise_means[channel]| is - // changed after the call. - noise_global_mean = WeightedAverage(&self->noise_means[channel], - -tmp2_s16, - &kNoiseDataWeights[channel]); - } - - // Control that the speech & noise means do not drift to much. - maxspe = kMaximumSpeech[channel]; - tmp2_s16 = (int16_t) (speech_global_mean >> 7); - if (tmp2_s16 > maxspe) { - // Upper limit of speech model. - tmp2_s16 -= maxspe; - - for (k = 0; k < kNumGaussians; k++) { - self->speech_means[channel + k * kNumChannels] -= tmp2_s16; - } - } - - tmp2_s16 = (int16_t) (noise_global_mean >> 7); - if (tmp2_s16 > kMaximumNoise[channel]) { - tmp2_s16 -= kMaximumNoise[channel]; - - for (k = 0; k < kNumGaussians; k++) { - self->noise_means[channel + k * kNumChannels] -= tmp2_s16; - } - } - } - self->frame_counter++; - } - - // Smooth with respect to transition hysteresis. - if (!vadflag) { - if (self->over_hang > 0) { - vadflag = 2 + self->over_hang; - self->over_hang--; - } - self->num_of_speech = 0; - } else { - self->num_of_speech++; - if (self->num_of_speech > kMaxSpeechFrames) { - self->num_of_speech = kMaxSpeechFrames; - self->over_hang = overhead2; - } else { - self->over_hang = overhead1; - } - } - return vadflag; -} - -// Initialize the VAD. Set aggressiveness mode to default value. -int WebRtcVad_InitCore(VadInstT* self) { - int i; - - if (self == NULL) { - return -1; - } - - // Initialization of general struct variables. - self->vad = 1; // Speech active (=1). - self->frame_counter = 0; - self->over_hang = 0; - self->num_of_speech = 0; - - // Initialization of downsampling filter state. - memset(self->downsampling_filter_states, 0, - sizeof(self->downsampling_filter_states)); - - // Read initial PDF parameters. - for (i = 0; i < kTableSize; i++) { - self->noise_means[i] = kNoiseDataMeans[i]; - self->speech_means[i] = kSpeechDataMeans[i]; - self->noise_stds[i] = kNoiseDataStds[i]; - self->speech_stds[i] = kSpeechDataStds[i]; - } - - // Initialize Index and Minimum value vectors. - for (i = 0; i < 16 * kNumChannels; i++) { - self->low_value_vector[i] = 10000; - self->index_vector[i] = 0; - } - - // Initialize splitting filter states. - memset(self->upper_state, 0, sizeof(self->upper_state)); - memset(self->lower_state, 0, sizeof(self->lower_state)); - - // Initialize high pass filter states. - memset(self->hp_filter_state, 0, sizeof(self->hp_filter_state)); - - // Initialize mean value memory, for WebRtcVad_FindMinimum(). - for (i = 0; i < kNumChannels; i++) { - self->mean_value[i] = 1600; - } - - // Set aggressiveness mode to default (=|kDefaultMode|). - if (WebRtcVad_set_mode_core(self, kDefaultMode) != 0) { - return -1; - } - - self->init_flag = kInitCheck; - - return 0; -} - -// Set aggressiveness mode -int WebRtcVad_set_mode_core(VadInstT* self, int mode) { - int return_value = 0; - - switch (mode) { - case 0: - // Quality mode. - memcpy(self->over_hang_max_1, kOverHangMax1Q, - sizeof(self->over_hang_max_1)); - memcpy(self->over_hang_max_2, kOverHangMax2Q, - sizeof(self->over_hang_max_2)); - memcpy(self->individual, kLocalThresholdQ, - sizeof(self->individual)); - memcpy(self->total, kGlobalThresholdQ, - sizeof(self->total)); - break; - case 1: - // Low bitrate mode. - memcpy(self->over_hang_max_1, kOverHangMax1LBR, - sizeof(self->over_hang_max_1)); - memcpy(self->over_hang_max_2, kOverHangMax2LBR, - sizeof(self->over_hang_max_2)); - memcpy(self->individual, kLocalThresholdLBR, - sizeof(self->individual)); - memcpy(self->total, kGlobalThresholdLBR, - sizeof(self->total)); - break; - case 2: - // Aggressive mode. - memcpy(self->over_hang_max_1, kOverHangMax1AGG, - sizeof(self->over_hang_max_1)); - memcpy(self->over_hang_max_2, kOverHangMax2AGG, - sizeof(self->over_hang_max_2)); - memcpy(self->individual, kLocalThresholdAGG, - sizeof(self->individual)); - memcpy(self->total, kGlobalThresholdAGG, - sizeof(self->total)); - break; - case 3: - // Very aggressive mode. - memcpy(self->over_hang_max_1, kOverHangMax1VAG, - sizeof(self->over_hang_max_1)); - memcpy(self->over_hang_max_2, kOverHangMax2VAG, - sizeof(self->over_hang_max_2)); - memcpy(self->individual, kLocalThresholdVAG, - sizeof(self->individual)); - memcpy(self->total, kGlobalThresholdVAG, - sizeof(self->total)); - break; - default: - return_value = -1; - break; - } - - return return_value; -} - -// Calculate VAD decision by first extracting feature values and then calculate -// probability for both speech and background noise. - -int WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame, - int frame_length) -{ - int len, vad; - int16_t speechWB[480]; // Downsampled speech frame: 960 samples (30ms in SWB) - int16_t speechNB[240]; // Downsampled speech frame: 480 samples (30ms in WB) - - - // Downsample signal 32->16->8 before doing VAD - WebRtcVad_Downsampling(speech_frame, speechWB, &(inst->downsampling_filter_states[2]), - frame_length); - len = WEBRTC_SPL_RSHIFT_W16(frame_length, 1); - - WebRtcVad_Downsampling(speechWB, speechNB, inst->downsampling_filter_states, len); - len = WEBRTC_SPL_RSHIFT_W16(len, 1); - - // Do VAD on an 8 kHz signal - vad = WebRtcVad_CalcVad8khz(inst, speechNB, len); - - return vad; -} - -int WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame, - int frame_length) -{ - int len, vad; - int16_t speechNB[240]; // Downsampled speech frame: 480 samples (30ms in WB) - - // Wideband: Downsample signal before doing VAD - WebRtcVad_Downsampling(speech_frame, speechNB, inst->downsampling_filter_states, - frame_length); - - len = WEBRTC_SPL_RSHIFT_W16(frame_length, 1); - vad = WebRtcVad_CalcVad8khz(inst, speechNB, len); - - return vad; -} - -int WebRtcVad_CalcVad8khz(VadInstT* inst, int16_t* speech_frame, - int frame_length) -{ - int16_t feature_vector[kNumChannels], total_power; - - // Get power in the bands - total_power = WebRtcVad_CalculateFeatures(inst, speech_frame, frame_length, - feature_vector); - - // Make a VAD - inst->vad = GmmProbability(inst, feature_vector, total_power, frame_length); - - return inst->vad; -}
diff --git a/src/common_audio/vad/vad_core.h b/src/common_audio/vad/vad_core.h deleted file mode 100644 index 00d39a4..0000000 --- a/src/common_audio/vad/vad_core.h +++ /dev/null
@@ -1,110 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - * This header file includes the descriptions of the core VAD calls. - */ - -#ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_CORE_H_ -#define WEBRTC_COMMON_AUDIO_VAD_VAD_CORE_H_ - -#include "typedefs.h" - -enum { kNumChannels = 6 }; // Number of frequency bands (named channels). -enum { kNumGaussians = 2 }; // Number of Gaussians per channel in the GMM. -enum { kTableSize = kNumChannels * kNumGaussians }; -enum { kMinEnergy = 10 }; // Minimum energy required to trigger audio signal. - -typedef struct VadInstT_ -{ - - int vad; - int32_t downsampling_filter_states[4]; - int16_t noise_means[kTableSize]; - int16_t speech_means[kTableSize]; - int16_t noise_stds[kTableSize]; - int16_t speech_stds[kTableSize]; - // TODO(bjornv): Change to |frame_count|. - int32_t frame_counter; - int16_t over_hang; // Over Hang - int16_t num_of_speech; - // TODO(bjornv): Change to |age_vector|. - int16_t index_vector[16 * kNumChannels]; - int16_t low_value_vector[16 * kNumChannels]; - // TODO(bjornv): Change to |median|. - int16_t mean_value[kNumChannels]; - int16_t upper_state[5]; - int16_t lower_state[5]; - int16_t hp_filter_state[4]; - int16_t over_hang_max_1[3]; - int16_t over_hang_max_2[3]; - int16_t individual[3]; - int16_t total[3]; - - int init_flag; - -} VadInstT; - -// Initializes the core VAD component. The default aggressiveness mode is -// controlled by |kDefaultMode| in vad_core.c. -// -// - self [i/o] : Instance that should be initialized -// -// returns : 0 (OK), -1 (NULL pointer in or if the default mode can't be -// set) -int WebRtcVad_InitCore(VadInstT* self); - -/**************************************************************************** - * WebRtcVad_set_mode_core(...) - * - * This function changes the VAD settings - * - * Input: - * - inst : VAD instance - * - mode : Aggressiveness degree - * 0 (High quality) - 3 (Highly aggressive) - * - * Output: - * - inst : Changed instance - * - * Return value : 0 - Ok - * -1 - Error - */ - -int WebRtcVad_set_mode_core(VadInstT* self, int mode); - -/**************************************************************************** - * WebRtcVad_CalcVad32khz(...) - * WebRtcVad_CalcVad16khz(...) - * WebRtcVad_CalcVad8khz(...) - * - * Calculate probability for active speech and make VAD decision. - * - * Input: - * - inst : Instance that should be initialized - * - speech_frame : Input speech frame - * - frame_length : Number of input samples - * - * Output: - * - inst : Updated filter states etc. - * - * Return value : VAD decision - * 0 - No active speech - * 1-6 - Active speech - */ -int WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame, - int frame_length); -int WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame, - int frame_length); -int WebRtcVad_CalcVad8khz(VadInstT* inst, int16_t* speech_frame, - int frame_length); - -#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_CORE_H_
diff --git a/src/common_audio/vad/vad_core_unittest.cc b/src/common_audio/vad/vad_core_unittest.cc deleted file mode 100644 index 141b796..0000000 --- a/src/common_audio/vad/vad_core_unittest.cc +++ /dev/null
@@ -1,99 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <stdlib.h> - -#include "gtest/gtest.h" -#include "typedefs.h" -#include "vad_unittest.h" - -extern "C" { -#include "vad_core.h" -} - -namespace { - -TEST_F(VadTest, InitCore) { - // Test WebRtcVad_InitCore(). - VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT))); - - // NULL pointer test. - EXPECT_EQ(-1, WebRtcVad_InitCore(NULL)); - - // Verify return = 0 for non-NULL pointer. - EXPECT_EQ(0, WebRtcVad_InitCore(self)); - // Verify init_flag is set. - EXPECT_EQ(42, self->init_flag); - - free(self); -} - -TEST_F(VadTest, set_mode_core) { - VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT))); - - // TODO(bjornv): Add NULL pointer check if we take care of it in - // vad_core.c - - ASSERT_EQ(0, WebRtcVad_InitCore(self)); - // Test WebRtcVad_set_mode_core(). - // Invalid modes should return -1. - EXPECT_EQ(-1, WebRtcVad_set_mode_core(self, -1)); - EXPECT_EQ(-1, WebRtcVad_set_mode_core(self, 1000)); - // Valid modes should return 0. - for (size_t j = 0; j < kModesSize; ++j) { - EXPECT_EQ(0, WebRtcVad_set_mode_core(self, kModes[j])); - } - - free(self); -} - -TEST_F(VadTest, CalcVad) { - VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT))); - int16_t speech[kMaxFrameLength]; - - // TODO(bjornv): Add NULL pointer check if we take care of it in - // vad_core.c - - // Test WebRtcVad_CalcVadXXkhz() - // Verify that all zeros in gives VAD = 0 out. - memset(speech, 0, sizeof(speech)); - ASSERT_EQ(0, WebRtcVad_InitCore(self)); - for (size_t j = 0; j < kFrameLengthsSize; ++j) { - if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { - EXPECT_EQ(0, WebRtcVad_CalcVad8khz(self, speech, kFrameLengths[j])); - } - if (ValidRatesAndFrameLengths(16000, kFrameLengths[j])) { - EXPECT_EQ(0, WebRtcVad_CalcVad16khz(self, speech, kFrameLengths[j])); - } - if (ValidRatesAndFrameLengths(32000, kFrameLengths[j])) { - EXPECT_EQ(0, WebRtcVad_CalcVad32khz(self, speech, kFrameLengths[j])); - } - } - - // Construct a speech signal that will trigger the VAD in all modes. It is - // known that (i * i) will wrap around, but that doesn't matter in this case. - for (int16_t i = 0; i < kMaxFrameLength; ++i) { - speech[i] = (i * i); - } - for (size_t j = 0; j < kFrameLengthsSize; ++j) { - if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { - EXPECT_EQ(1, WebRtcVad_CalcVad8khz(self, speech, kFrameLengths[j])); - } - if (ValidRatesAndFrameLengths(16000, kFrameLengths[j])) { - EXPECT_EQ(1, WebRtcVad_CalcVad16khz(self, speech, kFrameLengths[j])); - } - if (ValidRatesAndFrameLengths(32000, kFrameLengths[j])) { - EXPECT_EQ(1, WebRtcVad_CalcVad32khz(self, speech, kFrameLengths[j])); - } - } - - free(self); -} -} // namespace
diff --git a/src/common_audio/vad/vad_filterbank.c b/src/common_audio/vad/vad_filterbank.c deleted file mode 100644 index b626ad0..0000000 --- a/src/common_audio/vad/vad_filterbank.c +++ /dev/null
@@ -1,334 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "vad_filterbank.h" - -#include <assert.h> - -#include "signal_processing_library.h" -#include "typedefs.h" - -// Constants used in LogOfEnergy(). -static const int16_t kLogConst = 24660; // 160*log10(2) in Q9. -static const int16_t kLogEnergyIntPart = 14336; // 14 in Q10 - -// Coefficients used by HighPassFilter, Q14. -static const int16_t kHpZeroCoefs[3] = { 6631, -13262, 6631 }; -static const int16_t kHpPoleCoefs[3] = { 16384, -7756, 5620 }; - -// Allpass filter coefficients, upper and lower, in Q15. -// Upper: 0.64, Lower: 0.17 -static const int16_t kAllPassCoefsQ15[2] = { 20972, 5571 }; - -// Adjustment for division with two in SplitFilter. -static const int16_t kOffsetVector[6] = { 368, 368, 272, 176, 176, 176 }; - -// High pass filtering, with a cut-off frequency at 80 Hz, if the |data_in| is -// sampled at 500 Hz. -// -// - data_in [i] : Input audio data sampled at 500 Hz. -// - data_length [i] : Length of input and output data. -// - filter_state [i/o] : State of the filter. -// - data_out [o] : Output audio data in the frequency interval -// 80 - 250 Hz. -static void HighPassFilter(const int16_t* data_in, int data_length, - int16_t* filter_state, int16_t* data_out) { - int i; - const int16_t* in_ptr = data_in; - int16_t* out_ptr = data_out; - int32_t tmp32 = 0; - - - // The sum of the absolute values of the impulse response: - // The zero/pole-filter has a max amplification of a single sample of: 1.4546 - // Impulse response: 0.4047 -0.6179 -0.0266 0.1993 0.1035 -0.0194 - // The all-zero section has a max amplification of a single sample of: 1.6189 - // Impulse response: 0.4047 -0.8094 0.4047 0 0 0 - // The all-pole section has a max amplification of a single sample of: 1.9931 - // Impulse response: 1.0000 0.4734 -0.1189 -0.2187 -0.0627 0.04532 - - for (i = 0; i < data_length; i++) { - // All-zero section (filter coefficients in Q14). - tmp32 = WEBRTC_SPL_MUL_16_16(kHpZeroCoefs[0], *in_ptr); - tmp32 += WEBRTC_SPL_MUL_16_16(kHpZeroCoefs[1], filter_state[0]); - tmp32 += WEBRTC_SPL_MUL_16_16(kHpZeroCoefs[2], filter_state[1]); - filter_state[1] = filter_state[0]; - filter_state[0] = *in_ptr++; - - // All-pole section (filter coefficients in Q14). - tmp32 -= WEBRTC_SPL_MUL_16_16(kHpPoleCoefs[1], filter_state[2]); - tmp32 -= WEBRTC_SPL_MUL_16_16(kHpPoleCoefs[2], filter_state[3]); - filter_state[3] = filter_state[2]; - filter_state[2] = (int16_t) (tmp32 >> 14); - *out_ptr++ = filter_state[2]; - } -} - -// All pass filtering of |data_in|, used before splitting the signal into two -// frequency bands (low pass vs high pass). -// Note that |data_in| and |data_out| can NOT correspond to the same address. -// -// - data_in [i] : Input audio signal given in Q0. -// - data_length [i] : Length of input and output data. -// - filter_coefficient [i] : Given in Q15. -// - filter_state [i/o] : State of the filter given in Q(-1). -// - data_out [o] : Output audio signal given in Q(-1). -static void AllPassFilter(const int16_t* data_in, int data_length, - int16_t filter_coefficient, int16_t* filter_state, - int16_t* data_out) { - // The filter can only cause overflow (in the w16 output variable) - // if more than 4 consecutive input numbers are of maximum value and - // has the the same sign as the impulse responses first taps. - // First 6 taps of the impulse response: - // 0.6399 0.5905 -0.3779 0.2418 -0.1547 0.0990 - - int i; - int16_t tmp16 = 0; - int32_t tmp32 = 0; - int32_t state32 = ((int32_t) (*filter_state) << 16); // Q15 - - for (i = 0; i < data_length; i++) { - tmp32 = state32 + WEBRTC_SPL_MUL_16_16(filter_coefficient, *data_in); - tmp16 = (int16_t) (tmp32 >> 16); // Q(-1) - *data_out++ = tmp16; - state32 = (((int32_t) (*data_in)) << 14); // Q14 - state32 -= WEBRTC_SPL_MUL_16_16(filter_coefficient, tmp16); // Q14 - state32 <<= 1; // Q15. - data_in += 2; - } - - *filter_state = (int16_t) (state32 >> 16); // Q(-1) -} - -// Splits |data_in| into |hp_data_out| and |lp_data_out| corresponding to -// an upper (high pass) part and a lower (low pass) part respectively. -// -// - data_in [i] : Input audio data to be split into two frequency bands. -// - data_length [i] : Length of |data_in|. -// - upper_state [i/o] : State of the upper filter, given in Q(-1). -// - lower_state [i/o] : State of the lower filter, given in Q(-1). -// - hp_data_out [o] : Output audio data of the upper half of the spectrum. -// The length is |data_length| / 2. -// - lp_data_out [o] : Output audio data of the lower half of the spectrum. -// The length is |data_length| / 2. -static void SplitFilter(const int16_t* data_in, int data_length, - int16_t* upper_state, int16_t* lower_state, - int16_t* hp_data_out, int16_t* lp_data_out) { - int i; - int half_length = data_length >> 1; // Downsampling by 2. - int16_t tmp_out; - - // All-pass filtering upper branch. - AllPassFilter(&data_in[0], half_length, kAllPassCoefsQ15[0], upper_state, - hp_data_out); - - // All-pass filtering lower branch. - AllPassFilter(&data_in[1], half_length, kAllPassCoefsQ15[1], lower_state, - lp_data_out); - - // Make LP and HP signals. - for (i = 0; i < half_length; i++) { - tmp_out = *hp_data_out; - *hp_data_out++ -= *lp_data_out; - *lp_data_out++ += tmp_out; - } -} - -// Calculates the energy of |data_in| in dB, and also updates an overall -// |total_energy| if necessary. -// -// - data_in [i] : Input audio data for energy calculation. -// - data_length [i] : Length of input data. -// - offset [i] : Offset value added to |log_energy|. -// - total_energy [i/o] : An external energy updated with the energy of -// |data_in|. -// NOTE: |total_energy| is only updated if -// |total_energy| <= |kMinEnergy|. -// - log_energy [o] : 10 * log10("energy of |data_in|") given in Q4. -static void LogOfEnergy(const int16_t* data_in, int data_length, - int16_t offset, int16_t* total_energy, - int16_t* log_energy) { - // |tot_rshifts| accumulates the number of right shifts performed on |energy|. - int tot_rshifts = 0; - // The |energy| will be normalized to 15 bits. We use unsigned integer because - // we eventually will mask out the fractional part. - uint32_t energy = 0; - - assert(data_in != NULL); - assert(data_length > 0); - - energy = (uint32_t) WebRtcSpl_Energy((int16_t*) data_in, data_length, - &tot_rshifts); - - if (energy != 0) { - // By construction, normalizing to 15 bits is equivalent with 17 leading - // zeros of an unsigned 32 bit value. - int normalizing_rshifts = 17 - WebRtcSpl_NormU32(energy); - // In a 15 bit representation the leading bit is 2^14. log2(2^14) in Q10 is - // (14 << 10), which is what we initialize |log2_energy| with. For a more - // detailed derivations, see below. - int16_t log2_energy = kLogEnergyIntPart; - - tot_rshifts += normalizing_rshifts; - // Normalize |energy| to 15 bits. - // |tot_rshifts| is now the total number of right shifts performed on - // |energy| after normalization. This means that |energy| is in - // Q(-tot_rshifts). - if (normalizing_rshifts < 0) { - energy <<= -normalizing_rshifts; - } else { - energy >>= normalizing_rshifts; - } - - // Calculate the energy of |data_in| in dB, in Q4. - // - // 10 * log10("true energy") in Q4 = 2^4 * 10 * log10("true energy") = - // 160 * log10(|energy| * 2^|tot_rshifts|) = - // 160 * log10(2) * log2(|energy| * 2^|tot_rshifts|) = - // 160 * log10(2) * (log2(|energy|) + log2(2^|tot_rshifts|)) = - // (160 * log10(2)) * (log2(|energy|) + |tot_rshifts|) = - // |kLogConst| * (|log2_energy| + |tot_rshifts|) - // - // We know by construction that |energy| is normalized to 15 bits. Hence, - // |energy| = 2^14 + frac_Q15, where frac_Q15 is a fractional part in Q15. - // Further, we'd like |log2_energy| in Q10 - // log2(|energy|) in Q10 = 2^10 * log2(2^14 + frac_Q15) = - // 2^10 * log2(2^14 * (1 + frac_Q15 * 2^-14)) = - // 2^10 * (14 + log2(1 + frac_Q15 * 2^-14)) ~= - // (14 << 10) + 2^10 * (frac_Q15 * 2^-14) = - // (14 << 10) + (frac_Q15 * 2^-4) = (14 << 10) + (frac_Q15 >> 4) - // - // Note that frac_Q15 = (|energy| & 0x00003FFF) - - // Calculate and add the fractional part to |log2_energy|. - log2_energy += (int16_t) ((energy & 0x00003FFF) >> 4); - - // |kLogConst| is in Q9, |log2_energy| in Q10 and |tot_rshifts| in Q0. - // Note that we in our derivation above have accounted for an output in Q4. - *log_energy = (int16_t) (WEBRTC_SPL_MUL_16_16_RSFT( - kLogConst, log2_energy, 19) + - WEBRTC_SPL_MUL_16_16_RSFT(tot_rshifts, kLogConst, 9)); - - if (*log_energy < 0) { - *log_energy = 0; - } - } else { - *log_energy = offset; - return; - } - - *log_energy += offset; - - // Update the approximate |total_energy| with the energy of |data_in|, if - // |total_energy| has not exceeded |kMinEnergy|. |total_energy| is used as an - // energy indicator in WebRtcVad_GmmProbability() in vad_core.c. - if (*total_energy <= kMinEnergy) { - if (tot_rshifts >= 0) { - // We know by construction that the |energy| > |kMinEnergy| in Q0, so add - // an arbitrary value such that |total_energy| exceeds |kMinEnergy|. - *total_energy += kMinEnergy + 1; - } else { - // By construction |energy| is represented by 15 bits, hence any number of - // right shifted |energy| will fit in an int16_t. In addition, adding the - // value to |total_energy| is wrap around safe as long as - // |kMinEnergy| < 8192. - *total_energy += (int16_t) (energy >> -tot_rshifts); // Q0. - } - } -} - -int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in, - int data_length, int16_t* features) { - int16_t total_energy = 0; - // We expect |data_length| to be 80, 160 or 240 samples, which corresponds to - // 10, 20 or 30 ms in 8 kHz. Therefore, the intermediate downsampled data will - // have at most 120 samples after the first split and at most 60 samples after - // the second split. - int16_t hp_120[120], lp_120[120]; - int16_t hp_60[60], lp_60[60]; - const int half_data_length = data_length >> 1; - int length = half_data_length; // |data_length| / 2, corresponds to - // bandwidth = 2000 Hz after downsampling. - - // Initialize variables for the first SplitFilter(). - int frequency_band = 0; - const int16_t* in_ptr = data_in; // [0 - 4000] Hz. - int16_t* hp_out_ptr = hp_120; // [2000 - 4000] Hz. - int16_t* lp_out_ptr = lp_120; // [0 - 2000] Hz. - - assert(data_length >= 0); - assert(data_length <= 240); - assert(4 < kNumChannels - 1); // Checking maximum |frequency_band|. - - // Split at 2000 Hz and downsample. - SplitFilter(in_ptr, data_length, &self->upper_state[frequency_band], - &self->lower_state[frequency_band], hp_out_ptr, lp_out_ptr); - - // For the upper band (2000 Hz - 4000 Hz) split at 3000 Hz and downsample. - frequency_band = 1; - in_ptr = hp_120; // [2000 - 4000] Hz. - hp_out_ptr = hp_60; // [3000 - 4000] Hz. - lp_out_ptr = lp_60; // [2000 - 3000] Hz. - SplitFilter(in_ptr, length, &self->upper_state[frequency_band], - &self->lower_state[frequency_band], hp_out_ptr, lp_out_ptr); - - // Energy in 3000 Hz - 4000 Hz. - length >>= 1; // |data_length| / 4 <=> bandwidth = 1000 Hz. - - LogOfEnergy(hp_60, length, kOffsetVector[5], &total_energy, &features[5]); - - // Energy in 2000 Hz - 3000 Hz. - LogOfEnergy(lp_60, length, kOffsetVector[4], &total_energy, &features[4]); - - // For the lower band (0 Hz - 2000 Hz) split at 1000 Hz and downsample. - frequency_band = 2; - in_ptr = lp_120; // [0 - 2000] Hz. - hp_out_ptr = hp_60; // [1000 - 2000] Hz. - lp_out_ptr = lp_60; // [0 - 1000] Hz. - length = half_data_length; // |data_length| / 2 <=> bandwidth = 2000 Hz. - SplitFilter(in_ptr, length, &self->upper_state[frequency_band], - &self->lower_state[frequency_band], hp_out_ptr, lp_out_ptr); - - // Energy in 1000 Hz - 2000 Hz. - length >>= 1; // |data_length| / 4 <=> bandwidth = 1000 Hz. - LogOfEnergy(hp_60, length, kOffsetVector[3], &total_energy, &features[3]); - - // For the lower band (0 Hz - 1000 Hz) split at 500 Hz and downsample. - frequency_band = 3; - in_ptr = lp_60; // [0 - 1000] Hz. - hp_out_ptr = hp_120; // [500 - 1000] Hz. - lp_out_ptr = lp_120; // [0 - 500] Hz. - SplitFilter(in_ptr, length, &self->upper_state[frequency_band], - &self->lower_state[frequency_band], hp_out_ptr, lp_out_ptr); - - // Energy in 500 Hz - 1000 Hz. - length >>= 1; // |data_length| / 8 <=> bandwidth = 500 Hz. - LogOfEnergy(hp_120, length, kOffsetVector[2], &total_energy, &features[2]); - - // For the lower band (0 Hz - 500 Hz) split at 250 Hz and downsample. - frequency_band = 4; - in_ptr = lp_120; // [0 - 500] Hz. - hp_out_ptr = hp_60; // [250 - 500] Hz. - lp_out_ptr = lp_60; // [0 - 250] Hz. - SplitFilter(in_ptr, length, &self->upper_state[frequency_band], - &self->lower_state[frequency_band], hp_out_ptr, lp_out_ptr); - - // Energy in 250 Hz - 500 Hz. - length >>= 1; // |data_length| / 16 <=> bandwidth = 250 Hz. - LogOfEnergy(hp_60, length, kOffsetVector[1], &total_energy, &features[1]); - - // Remove 0 Hz - 80 Hz, by high pass filtering the lower band. - HighPassFilter(lp_60, length, self->hp_filter_state, hp_120); - - // Energy in 80 Hz - 250 Hz. - LogOfEnergy(hp_120, length, kOffsetVector[0], &total_energy, &features[0]); - - return total_energy; -}
diff --git a/src/common_audio/vad/vad_filterbank.h b/src/common_audio/vad/vad_filterbank.h deleted file mode 100644 index b5fd69e..0000000 --- a/src/common_audio/vad/vad_filterbank.h +++ /dev/null
@@ -1,44 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * This file includes feature calculating functionality used in vad_core.c. - */ - -#ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ -#define WEBRTC_COMMON_AUDIO_VAD_VAD_FILTERBANK_H_ - -#include "typedefs.h" -#include "vad_core.h" - -// Takes |data_length| samples of |data_in| and calculates the logarithm of the -// energy of each of the |kNumChannels| = 6 frequency bands used by the VAD: -// 80 Hz - 250 Hz -// 250 Hz - 500 Hz -// 500 Hz - 1000 Hz -// 1000 Hz - 2000 Hz -// 2000 Hz - 3000 Hz -// 3000 Hz - 4000 Hz -// -// The values are given in Q4 and written to |features|. Further, an approximate -// overall energy is returned. The return value is used in -// WebRtcVad_GmmProbability() as a signal indicator, hence it is arbitrary above -// the threshold |kMinEnergy|. -// -// - self [i/o] : State information of the VAD. -// - data_in [i] : Input audio data, for feature extraction. -// - data_length [i] : Audio data size, in number of samples. -// - features [o] : 10 * log10(energy in each frequency band), Q4. -// - returns : Total energy of the signal (NOTE! This value is not -// exact. It is only used in a comparison.) -int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in, - int data_length, int16_t* features); - -#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_FILTERBANK_H_
diff --git a/src/common_audio/vad/vad_filterbank_unittest.cc b/src/common_audio/vad/vad_filterbank_unittest.cc deleted file mode 100644 index ef01146..0000000 --- a/src/common_audio/vad/vad_filterbank_unittest.cc +++ /dev/null
@@ -1,92 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <stdlib.h> - -#include "gtest/gtest.h" -#include "typedefs.h" -#include "vad_unittest.h" - -extern "C" { -#include "vad_core.h" -#include "vad_filterbank.h" -} - -namespace { - -enum { kNumValidFrameLengths = 3 }; - -TEST_F(VadTest, vad_filterbank) { - VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT))); - static const int16_t kReference[kNumValidFrameLengths] = { 48, 11, 11 }; - static const int16_t kFeatures[kNumValidFrameLengths * kNumChannels] = { - 1213, 759, 587, 462, 434, 272, - 1479, 1385, 1291, 1200, 1103, 1099, - 1732, 1692, 1681, 1629, 1436, 1436 - }; - static const int16_t kOffsetVector[kNumChannels] = { - 368, 368, 272, 176, 176, 176 }; - int16_t features[kNumChannels]; - - // Construct a speech signal that will trigger the VAD in all modes. It is - // known that (i * i) will wrap around, but that doesn't matter in this case. - int16_t speech[kMaxFrameLength]; - for (int16_t i = 0; i < kMaxFrameLength; ++i) { - speech[i] = (i * i); - } - - int frame_length_index = 0; - ASSERT_EQ(0, WebRtcVad_InitCore(self)); - for (size_t j = 0; j < kFrameLengthsSize; ++j) { - if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { - EXPECT_EQ(kReference[frame_length_index], - WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], - features)); - for (int k = 0; k < kNumChannels; ++k) { - EXPECT_EQ(kFeatures[k + frame_length_index * kNumChannels], - features[k]); - } - frame_length_index++; - } - } - EXPECT_EQ(kNumValidFrameLengths, frame_length_index); - - // Verify that all zeros in gives kOffsetVector out. - memset(speech, 0, sizeof(speech)); - ASSERT_EQ(0, WebRtcVad_InitCore(self)); - for (size_t j = 0; j < kFrameLengthsSize; ++j) { - if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { - EXPECT_EQ(0, WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], - features)); - for (int k = 0; k < kNumChannels; ++k) { - EXPECT_EQ(kOffsetVector[k], features[k]); - } - } - } - - // Verify that all ones in gives kOffsetVector out. Any other constant input - // will have a small impact in the sub bands. - for (int16_t i = 0; i < kMaxFrameLength; ++i) { - speech[i] = 1; - } - for (size_t j = 0; j < kFrameLengthsSize; ++j) { - if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { - ASSERT_EQ(0, WebRtcVad_InitCore(self)); - EXPECT_EQ(0, WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], - features)); - for (int k = 0; k < kNumChannels; ++k) { - EXPECT_EQ(kOffsetVector[k], features[k]); - } - } - } - - free(self); -} -} // namespace
diff --git a/src/common_audio/vad/vad_gmm.c b/src/common_audio/vad/vad_gmm.c deleted file mode 100644 index 20a703a..0000000 --- a/src/common_audio/vad/vad_gmm.c +++ /dev/null
@@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "vad_gmm.h" - -#include "signal_processing_library.h" -#include "typedefs.h" - -static const int32_t kCompVar = 22005; -static const int16_t kLog2Exp = 5909; // log2(exp(1)) in Q12. - -// For a normal distribution, the probability of |input| is calculated and -// returned (in Q20). The formula for normal distributed probability is -// -// 1 / s * exp(-(x - m)^2 / (2 * s^2)) -// -// where the parameters are given in the following Q domains: -// m = |mean| (Q7) -// s = |std| (Q7) -// x = |input| (Q4) -// in addition to the probability we output |delta| (in Q11) used when updating -// the noise/speech model. -int32_t WebRtcVad_GaussianProbability(int16_t input, - int16_t mean, - int16_t std, - int16_t* delta) { - int16_t tmp16, inv_std, inv_std2, exp_value = 0; - int32_t tmp32; - - // Calculate |inv_std| = 1 / s, in Q10. - // 131072 = 1 in Q17, and (|std| >> 1) is for rounding instead of truncation. - // Q-domain: Q17 / Q7 = Q10. - tmp32 = (int32_t) 131072 + (int32_t) (std >> 1); - inv_std = (int16_t) WebRtcSpl_DivW32W16(tmp32, std); - - // Calculate |inv_std2| = 1 / s^2, in Q14. - tmp16 = (inv_std >> 2); // Q10 -> Q8. - // Q-domain: (Q8 * Q8) >> 2 = Q14. - inv_std2 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(tmp16, tmp16, 2); - // TODO(bjornv): Investigate if changing to - // |inv_std2| = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(|inv_std|, |inv_std|, 6); - // gives better accuracy. - - tmp16 = (input << 3); // Q4 -> Q7 - tmp16 = tmp16 - mean; // Q7 - Q7 = Q7 - - // To be used later, when updating noise/speech model. - // |delta| = (x - m) / s^2, in Q11. - // Q-domain: (Q14 * Q7) >> 10 = Q11. - *delta = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(inv_std2, tmp16, 10); - - // Calculate the exponent |tmp32| = (x - m)^2 / (2 * s^2), in Q10. Replacing - // division by two with one shift. - // Q-domain: (Q11 * Q7) >> 8 = Q10. - tmp32 = WEBRTC_SPL_MUL_16_16_RSFT(*delta, tmp16, 9); - - // If the exponent is small enough to give a non-zero probability we calculate - // |exp_value| ~= exp(-(x - m)^2 / (2 * s^2)) - // ~= exp2(-log2(exp(1)) * |tmp32|). - if (tmp32 < kCompVar) { - // Calculate |tmp16| = log2(exp(1)) * |tmp32|, in Q10. - // Q-domain: (Q12 * Q10) >> 12 = Q10. - tmp16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(kLog2Exp, (int16_t) tmp32, 12); - tmp16 = -tmp16; - exp_value = (0x0400 | (tmp16 & 0x03FF)); - tmp16 ^= 0xFFFF; - tmp16 >>= 10; - tmp16 += 1; - // Get |exp_value| = exp(-|tmp32|) in Q10. - exp_value >>= tmp16; - } - - // Calculate and return (1 / s) * exp(-(x - m)^2 / (2 * s^2)), in Q20. - // Q-domain: Q10 * Q10 = Q20. - return WEBRTC_SPL_MUL_16_16(inv_std, exp_value); -}
diff --git a/src/common_audio/vad/vad_gmm.h b/src/common_audio/vad/vad_gmm.h deleted file mode 100644 index 2333af7..0000000 --- a/src/common_audio/vad/vad_gmm.h +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// Gaussian probability calculations internally used in vad_core.c. - -#ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ -#define WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_ - -#include "typedefs.h" - -// Calculates the probability for |input|, given that |input| comes from a -// normal distribution with mean and standard deviation (|mean|, |std|). -// -// Inputs: -// - input : input sample in Q4. -// - mean : mean input in the statistical model, Q7. -// - std : standard deviation, Q7. -// -// Output: -// -// - delta : input used when updating the model, Q11. -// |delta| = (|input| - |mean|) / |std|^2. -// -// Return: -// (probability for |input|) = -// 1 / |std| * exp(-(|input| - |mean|)^2 / (2 * |std|^2)); -int32_t WebRtcVad_GaussianProbability(int16_t input, - int16_t mean, - int16_t std, - int16_t* delta); - -#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_GMM_H_
diff --git a/src/common_audio/vad/vad_gmm_unittest.cc b/src/common_audio/vad/vad_gmm_unittest.cc deleted file mode 100644 index 205435a..0000000 --- a/src/common_audio/vad/vad_gmm_unittest.cc +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "gtest/gtest.h" -#include "typedefs.h" -#include "vad_unittest.h" - -extern "C" { -#include "vad_gmm.h" -} - -namespace { - -TEST_F(VadTest, vad_gmm) { - int16_t delta = 0; - // Input value at mean. - EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(0, 0, 128, &delta)); - EXPECT_EQ(0, delta); - EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(16, 128, 128, &delta)); - EXPECT_EQ(0, delta); - EXPECT_EQ(1048576, WebRtcVad_GaussianProbability(-16, -128, 128, &delta)); - EXPECT_EQ(0, delta); - - // Largest possible input to give non-zero probability. - EXPECT_EQ(1024, WebRtcVad_GaussianProbability(59, 0, 128, &delta)); - EXPECT_EQ(7552, delta); - EXPECT_EQ(1024, WebRtcVad_GaussianProbability(75, 128, 128, &delta)); - EXPECT_EQ(7552, delta); - EXPECT_EQ(1024, WebRtcVad_GaussianProbability(-75, -128, 128, &delta)); - EXPECT_EQ(-7552, delta); - - // Too large input, should give zero probability. - EXPECT_EQ(0, WebRtcVad_GaussianProbability(105, 0, 128, &delta)); - EXPECT_EQ(13440, delta); -} -} // namespace
diff --git a/src/common_audio/vad/vad_sp.c b/src/common_audio/vad/vad_sp.c deleted file mode 100644 index 9e531c4..0000000 --- a/src/common_audio/vad/vad_sp.c +++ /dev/null
@@ -1,179 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "common_audio/vad/vad_sp.h" - -#include <assert.h> - -#include "common_audio/signal_processing/include/signal_processing_library.h" -#include "common_audio/vad/vad_core.h" -#include "typedefs.h" - -// Allpass filter coefficients, upper and lower, in Q13. -// Upper: 0.64, Lower: 0.17. -static const int16_t kAllPassCoefsQ13[2] = { 5243, 1392 }; // Q13. -static const int16_t kSmoothingDown = 6553; // 0.2 in Q15. -static const int16_t kSmoothingUp = 32439; // 0.99 in Q15. - -// TODO(bjornv): Move this function to vad_filterbank.c. -// Downsampling filter based on splitting filter and allpass functions. -void WebRtcVad_Downsampling(int16_t* signal_in, - int16_t* signal_out, - int32_t* filter_state, - int in_length) { - int16_t tmp16_1 = 0, tmp16_2 = 0; - int32_t tmp32_1 = filter_state[0]; - int32_t tmp32_2 = filter_state[1]; - int n = 0; - int half_length = (in_length >> 1); // Downsampling by 2 gives half length. - - // Filter coefficients in Q13, filter state in Q0. - for (n = 0; n < half_length; n++) { - // All-pass filtering upper branch. - tmp16_1 = (int16_t) ((tmp32_1 >> 1) + - WEBRTC_SPL_MUL_16_16_RSFT(kAllPassCoefsQ13[0], *signal_in, 14)); - *signal_out = tmp16_1; - tmp32_1 = (int32_t) (*signal_in++) - - WEBRTC_SPL_MUL_16_16_RSFT(kAllPassCoefsQ13[0], tmp16_1, 12); - - // All-pass filtering lower branch. - tmp16_2 = (int16_t) ((tmp32_2 >> 1) + - WEBRTC_SPL_MUL_16_16_RSFT(kAllPassCoefsQ13[1], *signal_in, 14)); - *signal_out++ += tmp16_2; - tmp32_2 = (int32_t) (*signal_in++) - - WEBRTC_SPL_MUL_16_16_RSFT(kAllPassCoefsQ13[1], tmp16_2, 12); - } - // Store the filter states. - filter_state[0] = tmp32_1; - filter_state[1] = tmp32_2; -} - -// Inserts |feature_value| into |low_value_vector|, if it is one of the 16 -// smallest values the last 100 frames. Then calculates and returns the median -// of the five smallest values. -int16_t WebRtcVad_FindMinimum(VadInstT* self, - int16_t feature_value, - int channel) { - int i = 0, j = 0; - int position = -1; - // Offset to beginning of the 16 minimum values in memory. - const int offset = (channel << 4); - int16_t current_median = 1600; - int16_t alpha = 0; - int32_t tmp32 = 0; - // Pointer to memory for the 16 minimum values and the age of each value of - // the |channel|. - int16_t* age = &self->index_vector[offset]; - int16_t* smallest_values = &self->low_value_vector[offset]; - - assert(channel < kNumChannels); - - // Each value in |smallest_values| is getting 1 loop older. Update |age|, and - // remove old values. - for (i = 0; i < 16; i++) { - if (age[i] != 100) { - age[i]++; - } else { - // Too old value. Remove from memory and shift larger values downwards. - for (j = i; j < 16; j++) { - smallest_values[j] = smallest_values[j + 1]; - age[j] = age[j + 1]; - } - age[15] = 101; - smallest_values[15] = 10000; - } - } - - // Check if |feature_value| is smaller than any of the values in - // |smallest_values|. If so, find the |position| where to insert the new value - // (|feature_value|). - if (feature_value < smallest_values[7]) { - if (feature_value < smallest_values[3]) { - if (feature_value < smallest_values[1]) { - if (feature_value < smallest_values[0]) { - position = 0; - } else { - position = 1; - } - } else if (feature_value < smallest_values[2]) { - position = 2; - } else { - position = 3; - } - } else if (feature_value < smallest_values[5]) { - if (feature_value < smallest_values[4]) { - position = 4; - } else { - position = 5; - } - } else if (feature_value < smallest_values[6]) { - position = 6; - } else { - position = 7; - } - } else if (feature_value < smallest_values[15]) { - if (feature_value < smallest_values[11]) { - if (feature_value < smallest_values[9]) { - if (feature_value < smallest_values[8]) { - position = 8; - } else { - position = 9; - } - } else if (feature_value < smallest_values[10]) { - position = 10; - } else { - position = 11; - } - } else if (feature_value < smallest_values[13]) { - if (feature_value < smallest_values[12]) { - position = 12; - } else { - position = 13; - } - } else if (feature_value < smallest_values[14]) { - position = 14; - } else { - position = 15; - } - } - - // If we have detected a new small value, insert it at the correct position - // and shift larger values up. - if (position > -1) { - for (i = 15; i > position; i--) { - smallest_values[i] = smallest_values[i - 1]; - age[i] = age[i - 1]; - } - smallest_values[position] = feature_value; - age[position] = 1; - } - - // Get |current_median|. - if (self->frame_counter > 2) { - current_median = smallest_values[2]; - } else if (self->frame_counter > 0) { - current_median = smallest_values[0]; - } - - // Smooth the median value. - if (self->frame_counter > 0) { - if (current_median < self->mean_value[channel]) { - alpha = kSmoothingDown; // 0.2 in Q15. - } else { - alpha = kSmoothingUp; // 0.99 in Q15. - } - } - tmp32 = WEBRTC_SPL_MUL_16_16(alpha + 1, self->mean_value[channel]); - tmp32 += WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_WORD16_MAX - alpha, current_median); - tmp32 += 16384; - self->mean_value[channel] = (int16_t) (tmp32 >> 15); - - return self->mean_value[channel]; -}
diff --git a/src/common_audio/vad/vad_sp.h b/src/common_audio/vad/vad_sp.h deleted file mode 100644 index 9e8b204..0000000 --- a/src/common_audio/vad/vad_sp.h +++ /dev/null
@@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -// This file includes specific signal processing tools used in vad_core.c. - -#ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_SP_H_ -#define WEBRTC_COMMON_AUDIO_VAD_VAD_SP_H_ - -#include "typedefs.h" -#include "vad_core.h" - -// Downsamples the signal by a factor 2, eg. 32->16 or 16->8. -// -// Inputs: -// - signal_in : Input signal. -// - in_length : Length of input signal in samples. -// -// Input & Output: -// - filter_state : Current filter states of the two all-pass filters. The -// |filter_state| is updated after all samples have been -// processed. -// -// Output: -// - signal_out : Downsampled signal (of length |in_length| / 2). -void WebRtcVad_Downsampling(int16_t* signal_in, - int16_t* signal_out, - int32_t* filter_state, - int in_length); - -// Updates and returns the smoothed feature minimum. As minimum we use the -// median of the five smallest feature values in a 100 frames long window. -// As long as |handle->frame_counter| is zero, that is, we haven't received any -// "valid" data, FindMinimum() outputs the default value of 1600. -// -// Inputs: -// - feature_value : New feature value to update with. -// - channel : Channel number. -// -// Input & Output: -// - handle : State information of the VAD. -// -// Returns: -// : Smoothed minimum value for a moving window. -int16_t WebRtcVad_FindMinimum(VadInstT* handle, - int16_t feature_value, - int channel); - -#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_SP_H_
diff --git a/src/common_audio/vad/vad_sp_unittest.cc b/src/common_audio/vad/vad_sp_unittest.cc deleted file mode 100644 index 2b25316..0000000 --- a/src/common_audio/vad/vad_sp_unittest.cc +++ /dev/null
@@ -1,75 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <stdlib.h> - -#include "gtest/gtest.h" -#include "typedefs.h" -#include "vad_unittest.h" - -extern "C" { -#include "vad_core.h" -#include "vad_sp.h" -} - -namespace { - -TEST_F(VadTest, vad_sp) { - VadInstT* self = reinterpret_cast<VadInstT*>(malloc(sizeof(VadInstT))); - int16_t zeros[kMaxFrameLength] = { 0 }; - int32_t state[2] = { 0 }; - int16_t data_in[kMaxFrameLength]; - int16_t data_out[kMaxFrameLength]; - - // We expect the first value to be 1600 as long as |frame_counter| is zero, - // which is true for the first iteration. - static const int16_t kReferenceMin[32] = { - 1600, 720, 509, 512, 532, 552, 570, 588, - 606, 624, 642, 659, 675, 691, 707, 723, - 1600, 544, 502, 522, 542, 561, 579, 597, - 615, 633, 651, 667, 683, 699, 715, 731 - }; - - // Construct a speech signal that will trigger the VAD in all modes. It is - // known that (i * i) will wrap around, but that doesn't matter in this case. - for (int16_t i = 0; i < kMaxFrameLength; ++i) { - data_in[i] = (i * i); - } - // Input values all zeros, expect all zeros out. - WebRtcVad_Downsampling(zeros, data_out, state, - static_cast<int>(kMaxFrameLength)); - EXPECT_EQ(0, state[0]); - EXPECT_EQ(0, state[1]); - for (int16_t i = 0; i < kMaxFrameLength / 2; ++i) { - EXPECT_EQ(0, data_out[i]); - } - // Make a simple non-zero data test. - WebRtcVad_Downsampling(data_in, data_out, state, - static_cast<int>(kMaxFrameLength)); - EXPECT_EQ(207, state[0]); - EXPECT_EQ(2270, state[1]); - - ASSERT_EQ(0, WebRtcVad_InitCore(self)); - // TODO(bjornv): Replace this part of the test with taking values from an - // array and calculate the reference value here. Make sure the values are not - // ordered. - for (int16_t i = 0; i < 16; ++i) { - int16_t value = 500 * (i + 1); - for (int j = 0; j < kNumChannels; ++j) { - // Use values both above and below initialized value. - EXPECT_EQ(kReferenceMin[i], WebRtcVad_FindMinimum(self, value, j)); - EXPECT_EQ(kReferenceMin[i + 16], WebRtcVad_FindMinimum(self, 12000, j)); - } - self->frame_counter++; - } - - free(self); -} -} // namespace
diff --git a/src/common_audio/vad/vad_unittest.cc b/src/common_audio/vad/vad_unittest.cc deleted file mode 100644 index b31217c..0000000 --- a/src/common_audio/vad/vad_unittest.cc +++ /dev/null
@@ -1,141 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "vad_unittest.h" - -#include <stdlib.h> - -#include "gtest/gtest.h" - -#include "common_audio/signal_processing/include/signal_processing_library.h" -#include "common_audio/vad/include/webrtc_vad.h" -#include "typedefs.h" - -VadTest::VadTest() {} - -void VadTest::SetUp() {} - -void VadTest::TearDown() {} - -// Returns true if the rate and frame length combination is valid. -bool VadTest::ValidRatesAndFrameLengths(int rate, int frame_length) { - if (rate == 8000) { - if (frame_length == 80 || frame_length == 160 || frame_length == 240) { - return true; - } - return false; - } else if (rate == 16000) { - if (frame_length == 160 || frame_length == 320 || frame_length == 480) { - return true; - } - return false; - } - if (rate == 32000) { - if (frame_length == 320 || frame_length == 640 || frame_length == 960) { - return true; - } - return false; - } - - return false; -} - -namespace { - -TEST_F(VadTest, ApiTest) { - // This API test runs through the APIs for all possible valid and invalid - // combinations. - - VadInst* handle = NULL; - int16_t zeros[kMaxFrameLength] = { 0 }; - - // Construct a speech signal that will trigger the VAD in all modes. It is - // known that (i * i) will wrap around, but that doesn't matter in this case. - int16_t speech[kMaxFrameLength]; - for (int16_t i = 0; i < kMaxFrameLength; i++) { - speech[i] = (i * i); - } - - // NULL instance tests - EXPECT_EQ(-1, WebRtcVad_Create(NULL)); - EXPECT_EQ(-1, WebRtcVad_Init(NULL)); - EXPECT_EQ(-1, WebRtcVad_Free(NULL)); - EXPECT_EQ(-1, WebRtcVad_set_mode(NULL, kModes[0])); - EXPECT_EQ(-1, WebRtcVad_Process(NULL, kRates[0], speech, kFrameLengths[0])); - - // WebRtcVad_Create() - ASSERT_EQ(0, WebRtcVad_Create(&handle)); - - // Not initialized tests - EXPECT_EQ(-1, WebRtcVad_Process(handle, kRates[0], speech, kFrameLengths[0])); - EXPECT_EQ(-1, WebRtcVad_set_mode(handle, kModes[0])); - - // WebRtcVad_Init() test - ASSERT_EQ(0, WebRtcVad_Init(handle)); - - // WebRtcVad_set_mode() invalid modes tests. Tries smallest supported value - // minus one and largest supported value plus one. - EXPECT_EQ(-1, WebRtcVad_set_mode(handle, - WebRtcSpl_MinValueW32(kModes, - kModesSize) - 1)); - EXPECT_EQ(-1, WebRtcVad_set_mode(handle, - WebRtcSpl_MaxValueW32(kModes, - kModesSize) + 1)); - - // WebRtcVad_Process() tests - // NULL speech pointer - EXPECT_EQ(-1, WebRtcVad_Process(handle, kRates[0], NULL, kFrameLengths[0])); - // Invalid sampling rate - EXPECT_EQ(-1, WebRtcVad_Process(handle, 9999, speech, kFrameLengths[0])); - // All zeros as input should work - EXPECT_EQ(0, WebRtcVad_Process(handle, kRates[0], zeros, kFrameLengths[0])); - for (size_t k = 0; k < kModesSize; k++) { - // Test valid modes - EXPECT_EQ(0, WebRtcVad_set_mode(handle, kModes[k])); - // Loop through sampling rate and frame length combinations - for (size_t i = 0; i < kRatesSize; i++) { - for (size_t j = 0; j < kFrameLengthsSize; j++) { - if (ValidRatesAndFrameLengths(kRates[i], kFrameLengths[j])) { - EXPECT_EQ(1, WebRtcVad_Process(handle, - kRates[i], - speech, - kFrameLengths[j])); - } else { - EXPECT_EQ(-1, WebRtcVad_Process(handle, - kRates[i], - speech, - kFrameLengths[j])); - } - } - } - } - - EXPECT_EQ(0, WebRtcVad_Free(handle)); -} - -TEST_F(VadTest, ValidRatesFrameLengths) { - // This test verifies valid and invalid rate/frame_length combinations. We - // loop through sampling rates and frame lengths from negative values to - // values larger than possible. - for (int16_t rate = -1; rate <= kRates[kRatesSize - 1] + 1; rate++) { - for (int16_t frame_length = -1; frame_length <= kMaxFrameLength + 1; - frame_length++) { - if (ValidRatesAndFrameLengths(rate, frame_length)) { - EXPECT_EQ(0, WebRtcVad_ValidRateAndFrameLength(rate, frame_length)); - } else { - EXPECT_EQ(-1, WebRtcVad_ValidRateAndFrameLength(rate, frame_length)); - } - } - } -} - -// TODO(bjornv): Add a process test, run on file. - -} // namespace
diff --git a/src/common_audio/vad/vad_unittest.h b/src/common_audio/vad/vad_unittest.h deleted file mode 100644 index 3069801..0000000 --- a/src/common_audio/vad/vad_unittest.h +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H -#define WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H - -#include <stddef.h> // size_t - -#include "gtest/gtest.h" - -#include "typedefs.h" - -namespace { - -// Modes we support -const int kModes[] = { 0, 1, 2, 3 }; -const size_t kModesSize = sizeof(kModes) / sizeof(*kModes); - -// Rates we support. -const int kRates[] = { 8000, 12000, 16000, 24000, 32000 }; -const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates); - -// Frame lengths we support. -const int kMaxFrameLength = 960; -const int kFrameLengths[] = { 80, 120, 160, 240, 320, 480, 640, - kMaxFrameLength }; -const size_t kFrameLengthsSize = sizeof(kFrameLengths) / sizeof(*kFrameLengths); - -} // namespace - -class VadTest : public ::testing::Test { - protected: - VadTest(); - virtual void SetUp(); - virtual void TearDown(); - - // Returns true if the rate and frame length combination is valid. - bool ValidRatesAndFrameLengths(int rate, int frame_length); -}; - -#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H
diff --git a/src/common_audio/vad/webrtc_vad.c b/src/common_audio/vad/webrtc_vad.c deleted file mode 100644 index ab2e492..0000000 --- a/src/common_audio/vad/webrtc_vad.c +++ /dev/null
@@ -1,130 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "common_audio/vad/include/webrtc_vad.h" - -#include <stdlib.h> -#include <string.h> - -#include "common_audio/vad/vad_core.h" -#include "typedefs.h" - -static const int kInitCheck = 42; -static const int kValidRates[] = { 8000, 16000, 32000 }; -static const size_t kRatesSize = sizeof(kValidRates) / sizeof(*kValidRates); -static const int kMaxFrameLengthMs = 30; - -int WebRtcVad_Create(VadInst** handle) { - VadInstT* self = NULL; - - if (handle == NULL) { - return -1; - } - - *handle = NULL; - self = (VadInstT*) malloc(sizeof(VadInstT)); - *handle = (VadInst*) self; - - if (self == NULL) { - return -1; - } - - self->init_flag = 0; - - return 0; -} - -int WebRtcVad_Free(VadInst* handle) { - if (handle == NULL) { - return -1; - } - - free(handle); - - return 0; -} - -// TODO(bjornv): Move WebRtcVad_InitCore() code here. -int WebRtcVad_Init(VadInst* handle) { - // Initialize the core VAD component. - return WebRtcVad_InitCore((VadInstT*) handle); -} - -// TODO(bjornv): Move WebRtcVad_set_mode_core() code here. -int WebRtcVad_set_mode(VadInst* handle, int mode) { - VadInstT* self = (VadInstT*) handle; - - if (handle == NULL) { - return -1; - } - if (self->init_flag != kInitCheck) { - return -1; - } - - return WebRtcVad_set_mode_core(self, mode); -} - -int WebRtcVad_Process(VadInst* handle, int fs, int16_t* audio_frame, - int frame_length) { - int vad = -1; - VadInstT* self = (VadInstT*) handle; - - if (handle == NULL) { - return -1; - } - - if (self->init_flag != kInitCheck) { - return -1; - } - if (audio_frame == NULL) { - return -1; - } - if (WebRtcVad_ValidRateAndFrameLength(fs, frame_length) != 0) { - return -1; - } - - if (fs == 32000) { - vad = WebRtcVad_CalcVad32khz(self, audio_frame, frame_length); - } else if (fs == 16000) { - vad = WebRtcVad_CalcVad16khz(self, audio_frame, frame_length); - } else if (fs == 8000) { - vad = WebRtcVad_CalcVad8khz(self, audio_frame, frame_length); - } - - if (vad > 0) { - vad = 1; - } - return vad; -} - -int WebRtcVad_ValidRateAndFrameLength(int rate, int frame_length) { - int return_value = -1; - size_t i; - int valid_length_ms; - int valid_length; - - // We only allow 10, 20 or 30 ms frames. Loop through valid frame rates and - // see if we have a matching pair. - for (i = 0; i < kRatesSize; i++) { - if (kValidRates[i] == rate) { - for (valid_length_ms = 10; valid_length_ms <= kMaxFrameLengthMs; - valid_length_ms += 10) { - valid_length = (kValidRates[i] / 1000 * valid_length_ms); - if (frame_length == valid_length) { - return_value = 0; - break; - } - } - break; - } - } - - return return_value; -}
diff --git a/src/common_types.h b/src/common_types.h deleted file mode 100644 index 122c7ee..0000000 --- a/src/common_types.h +++ /dev/null
@@ -1,610 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_COMMON_TYPES_H -#define WEBRTC_COMMON_TYPES_H - -#include "typedefs.h" - -#if defined(_MSC_VER) -// Disable "new behavior: elements of array will be default initialized" -// warning. Affects OverUseDetectorOptions. -#pragma warning(disable:4351) -#endif - -#ifdef WEBRTC_EXPORT -#define WEBRTC_DLLEXPORT _declspec(dllexport) -#elif WEBRTC_DLL -#define WEBRTC_DLLEXPORT _declspec(dllimport) -#else -#define WEBRTC_DLLEXPORT -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#define RTP_PAYLOAD_NAME_SIZE 32 - -namespace webrtc { - -class InStream -{ -public: - virtual int Read(void *buf,int len) = 0; - virtual int Rewind() {return -1;} - virtual ~InStream() {} -protected: - InStream() {} -}; - -class OutStream -{ -public: - virtual bool Write(const void *buf,int len) = 0; - virtual int Rewind() {return -1;} - virtual ~OutStream() {} -protected: - OutStream() {} -}; - -enum TraceModule -{ - // not a module, triggered from the engine code - kTraceVoice = 0x0001, - // not a module, triggered from the engine code - kTraceVideo = 0x0002, - // not a module, triggered from the utility code - kTraceUtility = 0x0003, - kTraceRtpRtcp = 0x0004, - kTraceTransport = 0x0005, - kTraceSrtp = 0x0006, - kTraceAudioCoding = 0x0007, - kTraceAudioMixerServer = 0x0008, - kTraceAudioMixerClient = 0x0009, - kTraceFile = 0x000a, - kTraceAudioProcessing = 0x000b, - kTraceVideoCoding = 0x0010, - kTraceVideoMixer = 0x0011, - kTraceAudioDevice = 0x0012, - kTraceVideoRenderer = 0x0014, - kTraceVideoCapture = 0x0015, - kTraceVideoPreocessing = 0x0016 -}; - -enum TraceLevel -{ - kTraceNone = 0x0000, // no trace - kTraceStateInfo = 0x0001, - kTraceWarning = 0x0002, - kTraceError = 0x0004, - kTraceCritical = 0x0008, - kTraceApiCall = 0x0010, - kTraceDefault = 0x00ff, - - kTraceModuleCall = 0x0020, - kTraceMemory = 0x0100, // memory info - kTraceTimer = 0x0200, // timing info - kTraceStream = 0x0400, // "continuous" stream of data - - // used for debug purposes - kTraceDebug = 0x0800, // debug - kTraceInfo = 0x1000, // debug info - - kTraceAll = 0xffff -}; - -// External Trace API -class TraceCallback -{ -public: - virtual void Print(const TraceLevel level, - const char *traceString, - const int length) = 0; -protected: - virtual ~TraceCallback() {} - TraceCallback() {} -}; - - -enum FileFormats -{ - kFileFormatWavFile = 1, - kFileFormatCompressedFile = 2, - kFileFormatAviFile = 3, - kFileFormatPreencodedFile = 4, - kFileFormatPcm16kHzFile = 7, - kFileFormatPcm8kHzFile = 8, - kFileFormatPcm32kHzFile = 9 -}; - - -enum ProcessingTypes -{ - kPlaybackPerChannel = 0, - kPlaybackAllChannelsMixed, - kRecordingPerChannel, - kRecordingAllChannelsMixed -}; - -// Encryption enums -enum CipherTypes -{ - kCipherNull = 0, - kCipherAes128CounterMode = 1 -}; - -enum AuthenticationTypes -{ - kAuthNull = 0, - kAuthHmacSha1 = 3 -}; - -enum SecurityLevels -{ - kNoProtection = 0, - kEncryption = 1, - kAuthentication = 2, - kEncryptionAndAuthentication = 3 -}; - -// Interface for encrypting and decrypting regular data and rtp/rtcp packets. -// Implement this interface if you wish to provide an encryption scheme to -// the voice or video engines. -class Encryption -{ -public: - // Encrypt the given data. - // - // Args: - // channel: The channel to encrypt data for. - // in_data: The data to encrypt. This data is bytes_in bytes long. - // out_data: The buffer to write the encrypted data to. You may write more - // bytes of encrypted data than what you got as input, up to a maximum - // of webrtc::kViEMaxMtu if you are encrypting in the video engine, or - // webrtc::kVoiceEngineMaxIpPacketSizeBytes for the voice engine. - // bytes_in: The number of bytes in the input buffer. - // bytes_out: The number of bytes written in out_data. - virtual void encrypt( - int channel, - unsigned char* in_data, - unsigned char* out_data, - int bytes_in, - int* bytes_out) = 0; - - // Decrypts the given data. This should reverse the effects of encrypt(). - // - // Args: - // channel_no: The channel to decrypt data for. - // in_data: The data to decrypt. This data is bytes_in bytes long. - // out_data: The buffer to write the decrypted data to. You may write more - // bytes of decrypted data than what you got as input, up to a maximum - // of webrtc::kViEMaxMtu if you are encrypting in the video engine, or - // webrtc::kVoiceEngineMaxIpPacketSizeBytes for the voice engine. - // bytes_in: The number of bytes in the input buffer. - // bytes_out: The number of bytes written in out_data. - virtual void decrypt( - int channel, - unsigned char* in_data, - unsigned char* out_data, - int bytes_in, - int* bytes_out) = 0; - - // Encrypts a RTCP packet. Otherwise, this method has the same contract as - // encrypt(). - virtual void encrypt_rtcp( - int channel, - unsigned char* in_data, - unsigned char* out_data, - int bytes_in, - int* bytes_out) = 0; - - // Decrypts a RTCP packet. Otherwise, this method has the same contract as - // decrypt(). - virtual void decrypt_rtcp( - int channel, - unsigned char* in_data, - unsigned char* out_data, - int bytes_in, - int* bytes_out) = 0; - -protected: - virtual ~Encryption() {} - Encryption() {} -}; - -// External transport callback interface -class Transport -{ -public: - virtual int SendPacket(int channel, const void *data, int len) = 0; - virtual int SendRTCPPacket(int channel, const void *data, int len) = 0; - -protected: - virtual ~Transport() {} - Transport() {} -}; - -// ================================================================== -// Voice specific types -// ================================================================== - -// Each codec supported can be described by this structure. -struct CodecInst -{ - int pltype; - char plname[RTP_PAYLOAD_NAME_SIZE]; - int plfreq; - int pacsize; - int channels; - int rate; -}; - -enum FrameType -{ - kFrameEmpty = 0, - kAudioFrameSpeech = 1, - kAudioFrameCN = 2, - kVideoFrameKey = 3, // independent frame - kVideoFrameDelta = 4, // depends on the previus frame - kVideoFrameGolden = 5, // depends on a old known previus frame - kVideoFrameAltRef = 6 -}; - -// RTP -enum {kRtpCsrcSize = 15}; // RFC 3550 page 13 - -enum RTPDirections -{ - kRtpIncoming = 0, - kRtpOutgoing -}; - -enum PayloadFrequencies -{ - kFreq8000Hz = 8000, - kFreq16000Hz = 16000, - kFreq32000Hz = 32000 -}; - -enum VadModes // degree of bandwidth reduction -{ - kVadConventional = 0, // lowest reduction - kVadAggressiveLow, - kVadAggressiveMid, - kVadAggressiveHigh // highest reduction -}; - -struct NetworkStatistics // NETEQ statistics -{ - // current jitter buffer size in ms - WebRtc_UWord16 currentBufferSize; - // preferred (optimal) buffer size in ms - WebRtc_UWord16 preferredBufferSize; - // adding extra delay due to "peaky jitter" - bool jitterPeaksFound; - // loss rate (network + late) in percent (in Q14) - WebRtc_UWord16 currentPacketLossRate; - // late loss rate in percent (in Q14) - WebRtc_UWord16 currentDiscardRate; - // fraction (of original stream) of synthesized speech inserted through - // expansion (in Q14) - WebRtc_UWord16 currentExpandRate; - // fraction of synthesized speech inserted through pre-emptive expansion - // (in Q14) - WebRtc_UWord16 currentPreemptiveRate; - // fraction of data removed through acceleration (in Q14) - WebRtc_UWord16 currentAccelerateRate; - // clock-drift in parts-per-million (negative or positive) - int32_t clockDriftPPM; - // average packet waiting time in the jitter buffer (ms) - int meanWaitingTimeMs; - // median packet waiting time in the jitter buffer (ms) - int medianWaitingTimeMs; - // min packet waiting time in the jitter buffer (ms) - int minWaitingTimeMs; - // max packet waiting time in the jitter buffer (ms) - int maxWaitingTimeMs; -}; - -typedef struct -{ - int min; // minumum - int max; // maximum - int average; // average -} StatVal; - -typedef struct // All levels are reported in dBm0 -{ - StatVal speech_rx; // long-term speech levels on receiving side - StatVal speech_tx; // long-term speech levels on transmitting side - StatVal noise_rx; // long-term noise/silence levels on receiving side - StatVal noise_tx; // long-term noise/silence levels on transmitting side -} LevelStatistics; - -typedef struct // All levels are reported in dB -{ - StatVal erl; // Echo Return Loss - StatVal erle; // Echo Return Loss Enhancement - StatVal rerl; // RERL = ERL + ERLE - // Echo suppression inside EC at the point just before its NLP - StatVal a_nlp; -} EchoStatistics; - -enum TelephoneEventDetectionMethods -{ - kInBand = 0, - kOutOfBand = 1, - kInAndOutOfBand = 2 -}; - -enum NsModes // type of Noise Suppression -{ - kNsUnchanged = 0, // previously set mode - kNsDefault, // platform default - kNsConference, // conferencing default - kNsLowSuppression, // lowest suppression - kNsModerateSuppression, - kNsHighSuppression, - kNsVeryHighSuppression, // highest suppression -}; - -enum AgcModes // type of Automatic Gain Control -{ - kAgcUnchanged = 0, // previously set mode - kAgcDefault, // platform default - // adaptive mode for use when analog volume control exists (e.g. for - // PC softphone) - kAgcAdaptiveAnalog, - // scaling takes place in the digital domain (e.g. for conference servers - // and embedded devices) - kAgcAdaptiveDigital, - // can be used on embedded devices where the capture signal level - // is predictable - kAgcFixedDigital -}; - -// EC modes -enum EcModes // type of Echo Control -{ - kEcUnchanged = 0, // previously set mode - kEcDefault, // platform default - kEcConference, // conferencing default (aggressive AEC) - kEcAec, // Acoustic Echo Cancellation - kEcAecm, // AEC mobile -}; - -// AECM modes -enum AecmModes // mode of AECM -{ - kAecmQuietEarpieceOrHeadset = 0, - // Quiet earpiece or headset use - kAecmEarpiece, // most earpiece use - kAecmLoudEarpiece, // Loud earpiece or quiet speakerphone use - kAecmSpeakerphone, // most speakerphone use (default) - kAecmLoudSpeakerphone // Loud speakerphone -}; - -// AGC configuration -typedef struct -{ - unsigned short targetLeveldBOv; - unsigned short digitalCompressionGaindB; - bool limiterEnable; -} AgcConfig; // AGC configuration parameters - -enum StereoChannel -{ - kStereoLeft = 0, - kStereoRight, - kStereoBoth -}; - -// Audio device layers -enum AudioLayers -{ - kAudioPlatformDefault = 0, - kAudioWindowsWave = 1, - kAudioWindowsCore = 2, - kAudioLinuxAlsa = 3, - kAudioLinuxPulse = 4 -}; - -enum NetEqModes // NetEQ playout configurations -{ - // Optimized trade-off between low delay and jitter robustness for two-way - // communication. - kNetEqDefault = 0, - // Improved jitter robustness at the cost of increased delay. Can be - // used in one-way communication. - kNetEqStreaming = 1, - // Optimzed for decodability of fax signals rather than for perceived audio - // quality. - kNetEqFax = 2, -}; - -enum NetEqBgnModes // NetEQ Background Noise (BGN) configurations -{ - // BGN is always on and will be generated when the incoming RTP stream - // stops (default). - kBgnOn = 0, - // The BGN is faded to zero (complete silence) after a few seconds. - kBgnFade = 1, - // BGN is not used at all. Silence is produced after speech extrapolation - // has faded. - kBgnOff = 2, -}; - -enum OnHoldModes // On Hold direction -{ - kHoldSendAndPlay = 0, // Put both sending and playing in on-hold state. - kHoldSendOnly, // Put only sending in on-hold state. - kHoldPlayOnly // Put only playing in on-hold state. -}; - -enum AmrMode -{ - kRfc3267BwEfficient = 0, - kRfc3267OctetAligned = 1, - kRfc3267FileStorage = 2, -}; - -// ================================================================== -// Video specific types -// ================================================================== - -// Raw video types -enum RawVideoType -{ - kVideoI420 = 0, - kVideoYV12 = 1, - kVideoYUY2 = 2, - kVideoUYVY = 3, - kVideoIYUV = 4, - kVideoARGB = 5, - kVideoRGB24 = 6, - kVideoRGB565 = 7, - kVideoARGB4444 = 8, - kVideoARGB1555 = 9, - kVideoMJPEG = 10, - kVideoNV12 = 11, - kVideoNV21 = 12, - kVideoBGRA = 13, - kVideoUnknown = 99 -}; - -// Video codec -enum { kConfigParameterSize = 128}; -enum { kPayloadNameSize = 32}; -enum { kMaxSimulcastStreams = 4}; -enum { kMaxTemporalStreams = 4}; - -enum VideoCodecComplexity -{ - kComplexityNormal = 0, - kComplexityHigh = 1, - kComplexityHigher = 2, - kComplexityMax = 3 -}; - -enum VideoCodecProfile -{ - kProfileBase = 0x00, - kProfileMain = 0x01 -}; - -enum VP8ResilienceMode { - kResilienceOff, // The stream produced by the encoder requires a - // recovery frame (typically a key frame) to be - // decodable after a packet loss. - kResilientStream, // A stream produced by the encoder is resilient to - // packet losses, but packets within a frame subsequent - // to a loss can't be decoded. - kResilientFrames // Same as kResilientStream but with added resilience - // within a frame. -}; - -// VP8 specific -struct VideoCodecVP8 -{ - bool pictureLossIndicationOn; - bool feedbackModeOn; - VideoCodecComplexity complexity; - VP8ResilienceMode resilience; - unsigned char numberOfTemporalLayers; - bool denoisingOn; - bool errorConcealmentOn; - bool automaticResizeOn; - bool frameDroppingOn; -}; - -// Unknown specific -struct VideoCodecGeneric -{ -}; - -// Video codec types -enum VideoCodecType -{ - kVideoCodecVP8, - kVideoCodecI420, - kVideoCodecRED, - kVideoCodecULPFEC, - kVideoCodecUnknown -}; - -union VideoCodecUnion -{ - VideoCodecVP8 VP8; - VideoCodecGeneric Generic; -}; - - -// Simulcast is when the same stream is encoded multiple times with different -// settings such as resolution. -struct SimulcastStream -{ - unsigned short width; - unsigned short height; - unsigned char numberOfTemporalLayers; - unsigned int maxBitrate; - unsigned int qpMax; // minimum quality -}; - -// Common video codec properties -struct VideoCodec -{ - VideoCodecType codecType; - char plName[kPayloadNameSize]; - unsigned char plType; - - unsigned short width; - unsigned short height; - - unsigned int startBitrate; - unsigned int maxBitrate; - unsigned int minBitrate; - unsigned char maxFramerate; - - VideoCodecUnion codecSpecific; - - unsigned int qpMax; - unsigned char numberOfSimulcastStreams; - SimulcastStream simulcastStream[kMaxSimulcastStreams]; -}; - -// Bandwidth over-use detector options. These are used to drive -// experimentation with bandwidth estimation parameters. -// See modules/remote_bitrate_estimator/overuse_detector.h -struct OverUseDetectorOptions { - OverUseDetectorOptions() - : initial_slope(8.0/512.0), - initial_offset(0), - initial_e(), - initial_process_noise(), - initial_avg_noise(0.0), - initial_var_noise(500), - initial_threshold(25.0) { - initial_e[0][0] = 100; - initial_e[1][1] = 1e-1; - initial_e[0][1] = initial_e[1][0] = 0; - initial_process_noise[0] = 1e-10; - initial_process_noise[1] = 1e-2; - } - double initial_slope; - double initial_offset; - double initial_e[2][2]; - double initial_process_noise[2]; - double initial_avg_noise; - double initial_var_noise; - double initial_threshold; -}; -} // namespace webrtc -#endif // WEBRTC_COMMON_TYPES_H
diff --git a/src/common_video/OWNERS b/src/common_video/OWNERS deleted file mode 100644 index 7183cf2..0000000 --- a/src/common_video/OWNERS +++ /dev/null
@@ -1,4 +0,0 @@ -stefan@webrtc.org -mikhal@webrtc.org -marpan@webrtc.org -henrik.lundin@webrtc.org
diff --git a/src/common_video/common_video.gyp b/src/common_video/common_video.gyp deleted file mode 100644 index 3adb56c..0000000 --- a/src/common_video/common_video.gyp +++ /dev/null
@@ -1,15 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'includes': [ - '../build/common.gypi', - 'libyuv/libyuv.gypi', - 'jpeg/jpeg.gypi', - ], -}
diff --git a/src/common_video/interface/video_image.h b/src/common_video/interface/video_image.h deleted file mode 100644 index 8e48b44..0000000 --- a/src/common_video/interface/video_image.h +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef COMMON_VIDEO_INTERFACE_VIDEO_IMAGE_H -#define COMMON_VIDEO_INTERFACE_VIDEO_IMAGE_H - -#include "typedefs.h" -#include <stdlib.h> - -namespace webrtc -{ - -enum VideoFrameType -{ - kKeyFrame = 0, - kDeltaFrame = 1, - kGoldenFrame = 2, - kAltRefFrame = 3, - kSkipFrame = 4 -}; - -class EncodedImage -{ -public: - EncodedImage() - : _encodedWidth(0), - _encodedHeight(0), - _timeStamp(0), - capture_time_ms_(0), - _frameType(kDeltaFrame), - _buffer(NULL), - _length(0), - _size(0), - _completeFrame(false) {} - - EncodedImage(WebRtc_UWord8* buffer, - WebRtc_UWord32 length, - WebRtc_UWord32 size) - : _encodedWidth(0), - _encodedHeight(0), - _timeStamp(0), - capture_time_ms_(0), - _frameType(kDeltaFrame), - _buffer(buffer), - _length(length), - _size(size), - _completeFrame(false) {} - - WebRtc_UWord32 _encodedWidth; - WebRtc_UWord32 _encodedHeight; - WebRtc_UWord32 _timeStamp; - int64_t capture_time_ms_; - VideoFrameType _frameType; - WebRtc_UWord8* _buffer; - WebRtc_UWord32 _length; - WebRtc_UWord32 _size; - bool _completeFrame; -}; - -} // namespace webrtc - -#endif // COMMON_VIDEO_INTERFACE_VIDEO_IMAGE_H
diff --git a/src/common_video/jpeg/data_manager.cc b/src/common_video/jpeg/data_manager.cc deleted file mode 100644 index a5a7a48..0000000 --- a/src/common_video/jpeg/data_manager.cc +++ /dev/null
@@ -1,86 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "common_video/jpeg/data_manager.h" - -namespace webrtc -{ - -typedef struct -{ - jpeg_source_mgr mgr; - JOCTET* next_input_byte; - size_t bytes_in_buffer; /* # of byte spaces remaining in buffer */ -} DataSrcMgr; - -void -jpegSetSrcBuffer(j_decompress_ptr cinfo, JOCTET* srcBuffer, size_t bufferSize) -{ - DataSrcMgr* src; - if (cinfo->src == NULL) - { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, - JPOOL_PERMANENT, sizeof(DataSrcMgr)); - } - - // Setting required functionality - src = (DataSrcMgr*) cinfo->src; - src->mgr.init_source = initSrc;; - src->mgr.fill_input_buffer = fillInputBuffer; - src->mgr.skip_input_data = skipInputData; - src->mgr.resync_to_restart = jpeg_resync_to_restart; // use default - src->mgr.term_source = termSource; - // setting buffer/src - src->bytes_in_buffer = bufferSize; - src->next_input_byte = srcBuffer; - -} - - -void -initSrc(j_decompress_ptr cinfo) -{ - DataSrcMgr *src = (DataSrcMgr*)cinfo->src; - src->mgr.next_input_byte = src->next_input_byte; - src->mgr.bytes_in_buffer = src->bytes_in_buffer; -} - -boolean -fillInputBuffer(j_decompress_ptr cinfo) -{ - return false; -} - - -void -skipInputData(j_decompress_ptr cinfo, long num_bytes) -{ - DataSrcMgr* src = (DataSrcMgr*)cinfo->src; - if (num_bytes > 0) - { - if ((unsigned long)num_bytes > src->mgr.bytes_in_buffer) - src->mgr.bytes_in_buffer = 0; - else - { - src->mgr.next_input_byte += num_bytes; - src->mgr.bytes_in_buffer -= num_bytes; - } - } -} - - -void -termSource (j_decompress_ptr cinfo) -{ - // -} - -} // end of namespace webrtc
diff --git a/src/common_video/jpeg/data_manager.h b/src/common_video/jpeg/data_manager.h deleted file mode 100644 index 61609ec..0000000 --- a/src/common_video/jpeg/data_manager.h +++ /dev/null
@@ -1,68 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * Jpeg source data manager - */ - -#ifndef WEBRTC_COMMON_VIDEO_JPEG_DATA_MANAGER -#define WEBRTC_COMMON_VIDEO_JPEG_DATA_MANAGER - -#include <stdio.h> -extern "C" { -#if defined(USE_SYSTEM_LIBJPEG) -#include <jpeglib.h> -#else -#include "jpeglib.h" -#endif -} - -namespace webrtc -{ - -// Source manager: - - -// a general function that will set these values -void -jpegSetSrcBuffer(j_decompress_ptr cinfo, JOCTET* srcBuffer, size_t bufferSize); - - -// Initialize source. This is called by jpeg_read_header() before any -// data is actually read. - -void -initSrc(j_decompress_ptr cinfo); - - -// Fill input buffer -// This is called whenever bytes_in_buffer has reached zero and more -// data is wanted. - -boolean -fillInputBuffer(j_decompress_ptr cinfo); - -// Skip input data -// Skip num_bytes worth of data. - -void -skipInputData(j_decompress_ptr cinfo, long num_bytes); - - - - -// Terminate source -void -termSource (j_decompress_ptr cinfo); - -} // end of namespace webrtc - - -#endif /* WEBRTC_COMMON_VIDEO_JPEG_DATA_MANAGER */
diff --git a/src/common_video/jpeg/include/jpeg.h b/src/common_video/jpeg/include/jpeg.h deleted file mode 100644 index 10c0461..0000000 --- a/src/common_video/jpeg/include/jpeg.h +++ /dev/null
@@ -1,81 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_COMMON_VIDEO_JPEG -#define WEBRTC_COMMON_VIDEO_JPEG - -#include "typedefs.h" -#include "modules/interface/module_common_types.h" // VideoFrame -#include "common_video/interface/video_image.h" // EncodedImage - -// jpeg forward declaration -struct jpeg_compress_struct; -struct jpeg_decompress_struct; - -namespace webrtc -{ - -class JpegEncoder -{ -public: - JpegEncoder(); - ~JpegEncoder(); - -// SetFileName -// Input: -// - fileName - Pointer to input vector (should be less than 256) to which the -// compressed file will be written to -// Output: -// - 0 : OK -// - (-1) : Error - WebRtc_Word32 SetFileName(const char* fileName); - -// Encode an I420 image. The encoded image is saved to a file -// -// Input: -// - inputImage : Image to be encoded -// -// Output: -// - 0 : OK -// - (-1) : Error - WebRtc_Word32 Encode(const VideoFrame& inputImage); - -private: - - jpeg_compress_struct* _cinfo; - char _fileName[257]; -}; - -class JpegDecoder -{ - public: - JpegDecoder(); - ~JpegDecoder(); - -// Decodes a JPEG-stream -// Supports 1 image component. 3 interleaved image components, -// YCbCr sub-sampling 4:4:4, 4:2:2, 4:2:0. -// -// Input: -// - inputImage : encoded image to be decoded. -// - outputImage : VideoFrame to store decoded output. -// -// Output: -// - 0 : OK -// - (-1) : Error - WebRtc_Word32 Decode(const EncodedImage& inputImage, - VideoFrame& outputImage); - private: - jpeg_decompress_struct* _cinfo; -}; - - -} -#endif /* WEBRTC_COMMON_VIDEO_JPEG */
diff --git a/src/common_video/jpeg/jpeg.cc b/src/common_video/jpeg/jpeg.cc deleted file mode 100644 index 93bc251..0000000 --- a/src/common_video/jpeg/jpeg.cc +++ /dev/null
@@ -1,366 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#if defined(WIN32) - #include <basetsd.h> -#endif -#include <setjmp.h> -#include <stdio.h> -#include <string.h> - -#include "common_video/jpeg/include/jpeg.h" -#include "common_video/jpeg/data_manager.h" -#include "common_video/libyuv/include/webrtc_libyuv.h" - -extern "C" { -#if defined(USE_SYSTEM_LIBJPEG) -#include <jpeglib.h> -#else -#include "jpeglib.h" -#endif -} - - -namespace webrtc -{ - -// Error handler -struct myErrorMgr { - - struct jpeg_error_mgr pub; - jmp_buf setjmp_buffer; -}; -typedef struct myErrorMgr * myErrorPtr; - -METHODDEF(void) -MyErrorExit (j_common_ptr cinfo) -{ - myErrorPtr myerr = (myErrorPtr) cinfo->err; - - // Return control to the setjmp point - longjmp(myerr->setjmp_buffer, 1); -} - -JpegEncoder::JpegEncoder() -{ - _cinfo = new jpeg_compress_struct; - strcpy(_fileName, "Snapshot.jpg"); -} - -JpegEncoder::~JpegEncoder() -{ - if (_cinfo != NULL) - { - delete _cinfo; - _cinfo = NULL; - } -} - - -WebRtc_Word32 -JpegEncoder::SetFileName(const char* fileName) -{ - if (!fileName) - { - return -1; - } - - if (fileName) - { - strncpy(_fileName, fileName, 256); - _fileName[256] = 0; - } - return 0; -} - - -WebRtc_Word32 -JpegEncoder::Encode(const VideoFrame& inputImage) -{ - if (inputImage.Buffer() == NULL || inputImage.Size() == 0) - { - return -1; - } - if (inputImage.Width() < 1 || inputImage.Height() < 1) - { - return -1; - } - - FILE* outFile = NULL; - - const WebRtc_UWord32 width = inputImage.Width(); - const WebRtc_UWord32 height = inputImage.Height(); - - // Set error handler - myErrorMgr jerr; - _cinfo->err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = MyErrorExit; - // Establish the setjmp return context - if (setjmp(jerr.setjmp_buffer)) - { - // If we get here, the JPEG code has signaled an error. - jpeg_destroy_compress(_cinfo); - if (outFile != NULL) - { - fclose(outFile); - } - return -1; - } - - if ((outFile = fopen(_fileName, "wb")) == NULL) - { - return -2; - } - // Create a compression object - jpeg_create_compress(_cinfo); - - // Setting destination file - jpeg_stdio_dest(_cinfo, outFile); - - // Set parameters for compression - _cinfo->in_color_space = JCS_YCbCr; - jpeg_set_defaults(_cinfo); - - _cinfo->image_width = width; - _cinfo->image_height = height; - _cinfo->input_components = 3; - - _cinfo->comp_info[0].h_samp_factor = 2; // Y - _cinfo->comp_info[0].v_samp_factor = 2; - _cinfo->comp_info[1].h_samp_factor = 1; // U - _cinfo->comp_info[1].v_samp_factor = 1; - _cinfo->comp_info[2].h_samp_factor = 1; // V - _cinfo->comp_info[2].v_samp_factor = 1; - _cinfo->raw_data_in = TRUE; - - WebRtc_UWord32 height16 = (height + 15) & ~15; - WebRtc_UWord8* imgPtr = inputImage.Buffer(); - WebRtc_UWord8* origImagePtr = NULL; - if (height16 != height) - { - // Copy image to an adequate size buffer - WebRtc_UWord32 requiredSize = CalcBufferSize(kI420, width, height16); - origImagePtr = new WebRtc_UWord8[requiredSize]; - memset(origImagePtr, 0, requiredSize); - memcpy(origImagePtr, inputImage.Buffer(), inputImage.Length()); - imgPtr = origImagePtr; - } - - jpeg_start_compress(_cinfo, TRUE); - - JSAMPROW y[16],u[8],v[8]; - JSAMPARRAY data[3]; - - data[0] = y; - data[1] = u; - data[2] = v; - - WebRtc_UWord32 i, j; - - for (j = 0; j < height; j += 16) - { - for (i = 0; i < 16; i++) - { - y[i] = (JSAMPLE*)imgPtr + width * (i + j); - - if (i % 2 == 0) - { - u[i / 2] = (JSAMPLE*) imgPtr + width * height + - width / 2 * ((i + j) / 2); - v[i / 2] = (JSAMPLE*) imgPtr + width * height + - width * height / 4 + width / 2 * ((i + j) / 2); - } - } - jpeg_write_raw_data(_cinfo, data, 16); - } - - jpeg_finish_compress(_cinfo); - jpeg_destroy_compress(_cinfo); - - fclose(outFile); - - if (origImagePtr != NULL) - { - delete [] origImagePtr; - } - - return 0; -} - -JpegDecoder::JpegDecoder() -{ - _cinfo = new jpeg_decompress_struct; -} - -JpegDecoder::~JpegDecoder() -{ - if (_cinfo != NULL) - { - delete _cinfo; - _cinfo = NULL; - } -} - -WebRtc_Word32 -JpegDecoder::Decode(const EncodedImage& inputImage, - VideoFrame& outputImage) -{ - - WebRtc_UWord8* tmpBuffer = NULL; - // Set error handler - myErrorMgr jerr; - _cinfo->err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = MyErrorExit; - - // Establish the setjmp return context - if (setjmp(jerr.setjmp_buffer)) - { - if (_cinfo->is_decompressor) - { - jpeg_destroy_decompress(_cinfo); - } - if (tmpBuffer != NULL) - { - delete [] tmpBuffer; - } - return -1; - } - - _cinfo->out_color_space = JCS_YCbCr; - - // Create decompression object - jpeg_create_decompress(_cinfo); - - // Specify data source - jpegSetSrcBuffer(_cinfo, (JOCTET*) inputImage._buffer, inputImage._size); - - // Read header data - jpeg_read_header(_cinfo, TRUE); - - _cinfo->raw_data_out = TRUE; - jpeg_start_decompress(_cinfo); - - // Check header - if (_cinfo->num_components == 4) - { - return -2; // not supported - } - if (_cinfo->progressive_mode == 1) - { - return -2; // not supported - } - - - WebRtc_UWord32 height = _cinfo->image_height; - WebRtc_UWord32 width = _cinfo->image_width; - - // Making sure width and height are even - if (height % 2) - { - height++; - } - if (width % 2) - { - width++; - } - - WebRtc_UWord32 height16 = (height + 15) & ~15; - WebRtc_UWord32 stride = (width + 15) & ~15; - WebRtc_UWord32 uvStride = ((((stride + 1) >> 1) + 15) & ~15); - - WebRtc_UWord32 tmpRequiredSize = stride * height16 + - 2 * (uvStride * ((height16 + 1) >> 1)); - WebRtc_UWord32 requiredSize = width * height * 3 >> 1; - - // Verify sufficient buffer size. - outputImage.VerifyAndAllocate(requiredSize); - WebRtc_UWord8* outPtr = outputImage.Buffer(); - - if (tmpRequiredSize > requiredSize) - { - tmpBuffer = new WebRtc_UWord8[(int) (tmpRequiredSize)]; - outPtr = tmpBuffer; - } - - JSAMPROW y[16],u[8],v[8]; - JSAMPARRAY data[3]; - data[0] = y; - data[1] = u; - data[2] = v; - - WebRtc_UWord32 hInd, i; - WebRtc_UWord32 numScanLines = 16; - WebRtc_UWord32 numLinesProcessed = 0; - - while (_cinfo->output_scanline < _cinfo->output_height) - { - hInd = _cinfo->output_scanline; - for (i = 0; i < numScanLines; i++) - { - y[i] = outPtr + stride * (i + hInd); - - if (i % 2 == 0) - { - u[i / 2] = outPtr + stride * height16 + - stride / 2 * ((i + hInd) / 2); - v[i / 2] = outPtr + stride * height16 + - stride * height16 / 4 + - stride / 2 * ((i + hInd) / 2); - } - } - // Processes exactly one iMCU row per call - numLinesProcessed = jpeg_read_raw_data(_cinfo, data, numScanLines); - // Error in read - if (numLinesProcessed == 0) - { - jpeg_abort((j_common_ptr)_cinfo); - return -1; - } - } - - if (tmpRequiredSize > requiredSize) - { - WebRtc_UWord8* dstFramePtr = outputImage.Buffer(); - WebRtc_UWord8* tmpPtr = outPtr; - - for (WebRtc_UWord32 p = 0; p < 3; p++) - { - const WebRtc_UWord32 h = (p == 0) ? height : height >> 1; - const WebRtc_UWord32 h16 = (p == 0) ? height16 : height16 >> 1; - const WebRtc_UWord32 w = (p == 0) ? width : width >> 1; - const WebRtc_UWord32 s = (p == 0) ? stride : stride >> 1; - - for (WebRtc_UWord32 i = 0; i < h; i++) - { - memcpy(dstFramePtr, tmpPtr, w); - dstFramePtr += w; - tmpPtr += s; - } - tmpPtr += (h16 - h) * s; - } - } - - if (tmpBuffer != NULL) - { - delete [] tmpBuffer; - } - // Setting output Image parameter - outputImage.SetWidth(width); - outputImage.SetHeight(height); - outputImage.SetLength(requiredSize); - outputImage.SetTimeStamp(inputImage._timeStamp); - - jpeg_finish_decompress(_cinfo); - jpeg_destroy_decompress(_cinfo); - return 0; -} - - -}
diff --git a/src/common_video/jpeg/jpeg.gypi b/src/common_video/jpeg/jpeg.gypi deleted file mode 100644 index 80f3f62..0000000 --- a/src/common_video/jpeg/jpeg.gypi +++ /dev/null
@@ -1,81 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'variables': { - 'use_libjpeg_turbo%': '<(use_libjpeg_turbo)', - 'conditions': [ - ['use_libjpeg_turbo==1', { - 'libjpeg_include_dir%': [ '<(DEPTH)/third_party/libjpeg_turbo', ], - }, { - 'libjpeg_include_dir%': [ '<(DEPTH)/third_party/libjpeg', ], - }], - ], - }, - 'targets': [ - { - 'target_name': 'webrtc_jpeg', - 'type': '<(library)', - 'dependencies': [ - 'webrtc_libyuv', - ], - 'include_dirs': [ - 'include', - '<(webrtc_root)', - '<(webrtc_root)/common_video/interface', - '<(webrtc_root)/modules/interface/', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - '<(webrtc_root)/common_video/interface', - ], - }, - 'conditions': [ - ['build_libjpeg==1', { - 'dependencies': [ - '<(libjpeg_gyp_path):libjpeg', - ], - }, { - # Need to add a directory normally exported by libjpeg.gyp. - 'include_dirs': [ '<(libjpeg_include_dir)' ], - }], - ], - 'sources': [ - 'include/jpeg.h', - 'data_manager.cc', - 'data_manager.h', - 'jpeg.cc', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'jpeg_unittests', - 'type': 'executable', - 'dependencies': [ - 'webrtc_jpeg', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(webrtc_root)/test/test.gyp:test_support_main', - ], - 'sources': [ - 'jpeg_unittest.cc', - ], - }, - ] # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/common_video/jpeg/jpeg_unittest.cc b/src/common_video/jpeg/jpeg_unittest.cc deleted file mode 100644 index ee5d0b0..0000000 --- a/src/common_video/jpeg/jpeg_unittest.cc +++ /dev/null
@@ -1,126 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <cstdio> -#include <string> - -#include "common_video/jpeg/include/jpeg.h" -#include "common_video/interface/video_image.h" -#include "gtest/gtest.h" -#include "testsupport/fileutils.h" -#include "modules/interface/module_common_types.h" - -namespace webrtc { - -const unsigned int kImageWidth = 640; -const unsigned int kImageHeight = 480; - -class JpegTest: public testing::Test { - protected: - JpegTest() - : input_filename_(webrtc::test::ProjectRootPath() + - "data/common_video/jpeg/webrtc_logo.jpg"), - decoded_filename_(webrtc::test::OutputPath() + "TestJpegDec.yuv"), - encoded_filename_(webrtc::test::OutputPath() + "TestJpegEnc.jpg"), - encoded_buffer_(NULL) {} - virtual ~JpegTest() {} - - void SetUp() { - encoder_ = new JpegEncoder(); - decoder_ = new JpegDecoder(); - } - - void TearDown() { - if (encoded_buffer_ != NULL) { - if (encoded_buffer_->_buffer != NULL) { - delete [] encoded_buffer_->_buffer; - } - delete encoded_buffer_; - } - delete encoder_; - delete decoder_; - } - - // Reads an encoded image. Caller will have to deallocate the memory of this - // object and it's _buffer byte array. - EncodedImage* ReadEncodedImage(std::string input_filename) { - FILE* open_file = fopen(input_filename.c_str(), "rb"); - assert(open_file != NULL); - size_t length = webrtc::test::GetFileSize(input_filename); - EncodedImage* encoded_buffer = new EncodedImage(); - encoded_buffer->_buffer = new WebRtc_UWord8[length]; - encoded_buffer->_size = length; - encoded_buffer->_length = length; - if (fread(encoded_buffer->_buffer, 1, length, open_file) != length) { - ADD_FAILURE() << "Error reading file:" << input_filename; - } - fclose(open_file); - return encoded_buffer; - } - - std::string input_filename_; - std::string decoded_filename_; - std::string encoded_filename_; - EncodedImage* encoded_buffer_; - JpegEncoder* encoder_; - JpegDecoder* decoder_; -}; - -TEST_F(JpegTest, Decode) { - encoded_buffer_ = ReadEncodedImage(input_filename_); - VideoFrame image_buffer; - EXPECT_EQ(0, decoder_->Decode(*encoded_buffer_, image_buffer)); - EXPECT_GT(image_buffer.Length(), 0u); - EXPECT_EQ(kImageWidth, image_buffer.Width()); - EXPECT_EQ(kImageHeight, image_buffer.Height()); - image_buffer.Free(); -} - -TEST_F(JpegTest, EncodeInvalidInputs) { - VideoFrame empty; - empty.SetWidth(164); - empty.SetHeight(164); - EXPECT_EQ(-1, encoder_->SetFileName(0)); - EXPECT_EQ(-1, encoder_->Encode(empty)); - - empty.VerifyAndAllocate(0); - EXPECT_EQ(-1, encoder_->Encode(empty)); - - empty.VerifyAndAllocate(10); - empty.SetHeight(0); - EXPECT_EQ(-1, encoder_->Encode(empty)); - - empty.SetHeight(164); - empty.SetWidth(0); - EXPECT_EQ(-1, encoder_->Encode(empty)); - empty.Free(); -} - -TEST_F(JpegTest, Encode) { - // Decode our input image then encode it again to a new file: - encoded_buffer_ = ReadEncodedImage(input_filename_); - VideoFrame image_buffer; - EXPECT_EQ(0, decoder_->Decode(*encoded_buffer_, image_buffer)); - - EXPECT_EQ(0, encoder_->SetFileName(encoded_filename_.c_str())); - EXPECT_EQ(0, encoder_->Encode(image_buffer)); - - // Save decoded image to file. - FILE* save_file = fopen(decoded_filename_.c_str(), "wb"); - if (fwrite(image_buffer.Buffer(), 1, - image_buffer.Length(), save_file) != image_buffer.Length()) { - return; - } - fclose(save_file); - - image_buffer.Free(); -} - -} // namespace webrtc
diff --git a/src/common_video/libyuv/include/scaler.h b/src/common_video/libyuv/include/scaler.h deleted file mode 100644 index 40fa660..0000000 --- a/src/common_video/libyuv/include/scaler.h +++ /dev/null
@@ -1,71 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * Interface to the LibYuv scaling functionality - */ - -#ifndef WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_ -#define WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_ - -#include "common_video/libyuv/include/webrtc_libyuv.h" -#include "typedefs.h" - -namespace webrtc { - -// Supported scaling types -enum ScaleMethod { - kScalePoint, // no interpolation - kScaleBilinear, - kScaleBox -}; - -// TODO (mikhal): Have set return the expected value of the dst_frame, such -// that the user can allocate memory for Scale(). -class Scaler { - public: - Scaler(); - ~Scaler(); - - // Set interpolation properties: - // - // Return value: 0 - OK - // -1 - parameter error - int Set(int src_width, int src_height, - int dst_width, int dst_height, - VideoType src_video_type, VideoType dst_video_type, - ScaleMethod method); - - // Scale frame - // Memory is allocated by user. If dst_frame is not of sufficient size, - // the frame will be reallocated to the appropriate size. - // Return value: 0 - OK, - // -1 - parameter error - // -2 - scaler not set - int Scale(const uint8_t* src_frame, - uint8_t*& dst_frame, - int& dst_size); - - private: - // Determine if the VideoTypes are currently supported. - bool SupportedVideoType(VideoType src_video_type, - VideoType dst_video_type); - - ScaleMethod method_; - int src_width_; - int src_height_; - int dst_width_; - int dst_height_; - bool set_; -}; - -} // namespace webrtc - -#endif // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
diff --git a/src/common_video/libyuv/include/webrtc_libyuv.h b/src/common_video/libyuv/include/webrtc_libyuv.h deleted file mode 100644 index 87fbdb1..0000000 --- a/src/common_video/libyuv/include/webrtc_libyuv.h +++ /dev/null
@@ -1,150 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * WebRTC's wrapper to libyuv. - */ - -#ifndef WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_WEBRTC_LIBYUV_H_ -#define WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_WEBRTC_LIBYUV_H_ - -#include "common_types.h" // RawVideoTypes. -#include "typedefs.h" - -namespace webrtc { - -// TODO(mikhal): 1. Sync libyuv and WebRtc meaning of stride. -// 2. Reorder parameters for consistency. - -// Supported video types. -enum VideoType { - kUnknown, - kI420, - kIYUV, - kRGB24, - kABGR, - kARGB, - kARGB4444, - kRGB565, - kARGB1555, - kYUY2, - kYV12, - kUYVY, - kMJPG, - kNV21, - kNV12, - kBGRA, -}; - -// Conversion between the RawVideoType and the LibYuv videoType. -// TODO(wu): Consolidate types into one type throughout WebRtc. -VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type); - -// Supported rotation -// Direction of rotation - clockwise. -enum VideoRotationMode { - kRotateNone = 0, - kRotate90 = 90, - kRotate180 = 180, - kRotate270 = 270, -}; - -// Calculate the required buffer size. -// Input: -// - type - The type of the designated video frame. -// - width - frame width in pixels. -// - height - frame height in pixels. -// Return value: The required size in bytes to accommodate the specified -// video frame or -1 in case of an error . -int CalcBufferSize(VideoType type, int width, int height); - -// Convert To I420 -// Input: -// - src_video_type : Type of input video. -// - src_frame : Pointer to a source frame. -// - crop_x/crop_y : Starting positions for cropping (0 for no crop). -// - src/dst_width : src/dst width in pixels. -// - src/dst_height : src/dst height in pixels. -// - sample_size : Required only for the parsing of MJPG (set to 0 else). -// - dst_stride : Number of bytes in a row of the dst Y plane. -// - rotate : Rotation mode of output image. -// Output: -// - dst_frame : Pointer to a destination frame. -// Return value: 0 if OK, < 0 otherwise. - -int ConvertToI420(VideoType src_video_type, - const uint8_t* src_frame, - int crop_x, int crop_y, - int src_width, int src_height, - int sample_size, - int dst_width, int dst_height, int dst_stride, - VideoRotationMode rotation, - uint8_t* dst_frame); - -// Convert From I420 -// Input: -// - src_frame : Pointer to a source frame. -// - src_stride : Number of bytes in a row of the src Y plane. -// - dst_video_type : Type of output video. -// - dst_sample_size : Required only for the parsing of MJPG. -// - width : Width in pixels. -// - height : Height in pixels. -// - dst_frame : Pointer to a destination frame. -// Return value: 0 if OK, < 0 otherwise. -int ConvertFromI420(const uint8_t* src_frame, int src_stride, - VideoType dst_video_type, int dst_sample_size, - int width, int height, - uint8_t* dst_frame); -// ConvertFrom YV12. -// Interface - same as above. -int ConvertFromYV12(const uint8_t* src_frame, int src_stride, - VideoType dst_video_type, int dst_sample_size, - int width, int height, - uint8_t* dst_frame); - -// The following list describes designated conversion functions which -// are not covered by the previous general functions. -// Input and output descriptions mostly match the above descriptions, and are -// therefore omitted. -int ConvertRGB24ToARGB(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height, - int dst_stride); -int ConvertNV12ToRGB565(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); - -// Mirror functions -// The following 2 functions perform mirroring on a given image -// (LeftRight/UpDown). -// Input: -// - width : Image width in pixels. -// - height : Image height in pixels. -// - src_frame : Pointer to a source frame. -// - dst_frame : Pointer to a destination frame. -// Return value: 0 if OK, < 0 otherwise. -int MirrorI420LeftRight(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); -int MirrorI420UpDown(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height); - -// Compute PSNR for an I420 frame (all planes). -double I420PSNR(const uint8_t* ref_frame, - const uint8_t* test_frame, - int width, int height); -// Compute SSIM for an I420 frame (all planes). -double I420SSIM(const uint8_t* ref_frame, - const uint8_t* test_frame, - int width, int height); -} - -#endif // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_WEBRTC_LIBYUV_H_
diff --git a/src/common_video/libyuv/libyuv.gypi b/src/common_video/libyuv/libyuv.gypi deleted file mode 100644 index 77aba19..0000000 --- a/src/common_video/libyuv/libyuv.gypi +++ /dev/null
@@ -1,52 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'webrtc_libyuv', - 'type': '<(library)', - 'conditions': [ - ['build_libyuv==1', { - 'dependencies': [ - '<(DEPTH)/third_party/libyuv/libyuv.gyp:libyuv' - ], - }, { - # Need to add a directory normally exported by libyuv.gyp. - 'include_dirs': [ '<(libyuv_dir)/include', ], - }], - ], - 'sources': [ - 'include/webrtc_libyuv.h', - 'include/scaler.h', - 'webrtc_libyuv.cc', - 'scaler.cc', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'libyuv_unittests', - 'type': 'executable', - 'dependencies': [ - 'webrtc_libyuv', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', - '<(webrtc_root)/test/test.gyp:test_support_main', - ], - 'sources': [ - 'libyuv_unittest.cc', - 'scaler_unittest.cc', - ], - }, - ], # targets - }], # include_tests - ], # conditions -}
diff --git a/src/common_video/libyuv/libyuv_unittest.cc b/src/common_video/libyuv/libyuv_unittest.cc deleted file mode 100644 index 3e58314..0000000 --- a/src/common_video/libyuv/libyuv_unittest.cc +++ /dev/null
@@ -1,304 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <math.h> -#include <string.h> - -#include "common_video/libyuv/include/webrtc_libyuv.h" -#include "gtest/gtest.h" -#include "system_wrappers/interface/tick_util.h" -#include "testsupport/fileutils.h" - -namespace webrtc { - -int PrintFrame(const uint8_t* frame, int width, int height) { - if (frame == NULL) - return -1; - int k = 0; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - printf("%d ", frame[k++]); - } - printf(" \n"); - } - printf(" \n"); - return 0; -} - -int PrintFrame(const uint8_t* frame, int width, - int height, const char* str) { - if (frame == NULL) - return -1; - printf("%s %dx%d \n", str, width, height); - - const uint8_t* frame_y = frame; - const uint8_t* frame_u = frame_y + width * height; - const uint8_t* frame_v = frame_u + width * height / 4; - - int ret = 0; - ret += PrintFrame(frame_y, width, height); - ret += PrintFrame(frame_u, width / 2, height / 2); - ret += PrintFrame(frame_v, width / 2, height / 2); - - return ret; -} - -void CreateImage(int width, int height, - uint8_t* frame, int offset, - int height_factor, int width_factor) { - if (frame == NULL) - return; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - *frame = static_cast<uint8_t>((i + offset) * height_factor - + j * width_factor); - frame++; - } - } -} - -class TestLibYuv : public ::testing::Test { - protected: - TestLibYuv(); - virtual void SetUp(); - virtual void TearDown(); - - FILE* source_file_; - const int width_; - const int height_; - const int frame_length_; -}; - -// TODO (mikhal): Use scoped_ptr when handling buffers. -TestLibYuv::TestLibYuv() - : source_file_(NULL), - width_(352), - height_(288), - frame_length_(CalcBufferSize(kI420, 352, 288)) { -} - -void TestLibYuv::SetUp() { - const std::string input_file_name = webrtc::test::ProjectRootPath() + - "resources/foreman_cif.yuv"; - source_file_ = fopen(input_file_name.c_str(), "rb"); - ASSERT_TRUE(source_file_ != NULL) << "Cannot read file: "<< - input_file_name << "\n"; -} - -void TestLibYuv::TearDown() { - if (source_file_ != NULL) { - ASSERT_EQ(0, fclose(source_file_)); - } - source_file_ = NULL; -} - -TEST_F(TestLibYuv, ConvertSanityTest) { - // TODO(mikhal) -} - -TEST_F(TestLibYuv, ConvertTest) { - // Reading YUV frame - testing on the first frame of the foreman sequence - int j = 0; - std::string output_file_name = webrtc::test::OutputPath() + - "LibYuvTest_conversion.yuv"; - FILE* output_file = fopen(output_file_name.c_str(), "wb"); - ASSERT_TRUE(output_file != NULL); - - double psnr = 0; - - uint8_t* orig_buffer = new uint8_t[frame_length_]; - EXPECT_GT(fread(orig_buffer, 1, frame_length_, source_file_), 0U); - - // printf("\nConvert #%d I420 <-> RGB24\n", j); - uint8_t* res_rgb_buffer2 = new uint8_t[width_ * height_ * 3]; - uint8_t* res_i420_buffer = new uint8_t[frame_length_]; - - EXPECT_EQ(0, ConvertFromI420(orig_buffer, width_, kRGB24, 0, - width_, height_, res_rgb_buffer2)); - - EXPECT_EQ(0, ConvertToI420(kRGB24, res_rgb_buffer2, 0, 0, width_, height_, - 0, width_, height_, width_, kRotateNone, - res_i420_buffer)); - - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - // Optimization Speed- quality trade-off => 45 dB only (platform dependant). - EXPECT_GT(ceil(psnr), 44); - j++; - delete [] res_rgb_buffer2; - - // printf("\nConvert #%d I420 <-> UYVY\n", j); - uint8_t* out_uyvy_buffer = new uint8_t[width_ * height_ * 2]; - EXPECT_EQ(0, ConvertFromI420(orig_buffer, width_, - kUYVY, 0, width_, height_, out_uyvy_buffer)); - EXPECT_EQ(0, ConvertToI420(kUYVY, out_uyvy_buffer, 0, 0, width_, height_, - 0, width_, height_, width_,kRotateNone, res_i420_buffer)); - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - EXPECT_EQ(48.0, psnr); - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - - j++; - delete [] out_uyvy_buffer; - - // printf("\nConvert #%d I420 <-> I420 \n", j); - uint8_t* out_i420_buffer = new uint8_t[width_ * height_ * 3 / 2 ]; - EXPECT_EQ(0, ConvertToI420(kI420, orig_buffer, 0, 0, width_, height_, - 0, width_, height_, width_, - kRotateNone, out_i420_buffer)); - EXPECT_EQ(0, ConvertFromI420(out_i420_buffer, width_, kI420, 0, - width_, height_, res_i420_buffer)); - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - EXPECT_EQ(48.0, psnr); - j++; - delete [] out_i420_buffer; - - // printf("\nConvert #%d I420 <-> YV12\n", j); - uint8_t* outYV120Buffer = new uint8_t[frame_length_]; - - EXPECT_EQ(0, ConvertFromI420(orig_buffer, width_, kYV12, 0, - width_, height_, outYV120Buffer)); - EXPECT_EQ(0, ConvertFromYV12(outYV120Buffer, width_, - kI420, 0, - width_, height_, - res_i420_buffer)); - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - EXPECT_EQ(48.0, psnr); - j++; - delete [] outYV120Buffer; - - // printf("\nConvert #%d I420 <-> YUY2\n", j); - uint8_t* out_yuy2_buffer = new uint8_t[width_ * height_ * 2]; - EXPECT_EQ(0, ConvertFromI420(orig_buffer, width_, - kYUY2, 0, width_, height_, out_yuy2_buffer)); - - EXPECT_EQ(0, ConvertToI420(kYUY2, out_yuy2_buffer, 0, 0, width_, height_, - 0, width_, height_, width_, - kRotateNone, res_i420_buffer)); - - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - EXPECT_EQ(48.0, psnr); - - // printf("\nConvert #%d I420 <-> RGB565\n", j); - uint8_t* out_rgb565_buffer = new uint8_t[width_ * height_ * 2]; - EXPECT_EQ(0, ConvertFromI420(orig_buffer, width_, - kRGB565, 0, width_, height_, out_rgb565_buffer)); - - EXPECT_EQ(0, ConvertToI420(kRGB565, out_rgb565_buffer, 0, 0, width_, height_, - 0, width_, height_, width_, - kRotateNone, res_i420_buffer)); - - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - // TODO(leozwang) Investigate the right psnr should be set for I420ToRGB565, - // Another example is I420ToRGB24, the psnr is 44 - EXPECT_GT(ceil(psnr), 40); - - // printf("\nConvert #%d I420 <-> ARGB8888\n", j); - uint8_t* out_argb8888_buffer = new uint8_t[width_ * height_ * 4]; - EXPECT_EQ(0, ConvertFromI420(orig_buffer, width_, - kARGB, 0, width_, height_, out_argb8888_buffer)); - - EXPECT_EQ(0, ConvertToI420(kARGB, out_argb8888_buffer, 0, 0, width_, height_, - 0, width_, height_, width_, - kRotateNone, res_i420_buffer)); - - if (fwrite(res_i420_buffer, 1, frame_length_, - output_file) != static_cast<unsigned int>(frame_length_)) { - return; - } - psnr = I420PSNR(orig_buffer, res_i420_buffer, width_, height_); - // TODO(leozwang) Investigate the right psnr should be set for I420ToARGB8888, - EXPECT_GT(ceil(psnr), 42); - - ASSERT_EQ(0, fclose(output_file)); - - delete [] out_argb8888_buffer; - delete [] out_rgb565_buffer; - delete [] out_yuy2_buffer; - delete [] res_i420_buffer; - delete [] orig_buffer; -} - -// TODO(holmer): Disabled for now due to crashes on Linux 32 bit. The theory -// is that it crashes due to the fact that the buffers are not 16 bit aligned. -// See http://code.google.com/p/webrtc/issues/detail?id=335 for more info. -TEST_F(TestLibYuv, DISABLED_MirrorTest) { - // TODO (mikhal): Add an automated test to confirm output. - std::string str; - int width = 16; - int height = 8; - int factor_y = 1; - int factor_u = 1; - int factor_v = 1; - int start_buffer_offset = 10; - int length = webrtc::CalcBufferSize(kI420, width, height); - - uint8_t* test_frame = new uint8_t[length]; - memset(test_frame, 255, length); - - // Create input frame - uint8_t* in_frame = test_frame; - uint8_t* in_frame_cb = in_frame + width * height; - uint8_t* in_frame_cr = in_frame_cb + (width * height) / 4; - CreateImage(width, height, in_frame, 10, factor_y, 1); // Y - CreateImage(width / 2, height / 2, in_frame_cb, 100, factor_u, 1); // Cb - CreateImage(width / 2, height / 2, in_frame_cr, 200, factor_v, 1); // Cr - EXPECT_EQ(0, PrintFrame(test_frame, width, height, "InputFrame")); - - uint8_t* test_frame2 = new uint8_t[length + start_buffer_offset * 2]; - memset(test_frame2, 255, length + start_buffer_offset * 2); - uint8_t* out_frame = test_frame2; - - // LeftRight - std::cout << "Test Mirror function: LeftRight" << std::endl; - EXPECT_EQ(0, MirrorI420LeftRight(in_frame, out_frame, width, height)); - EXPECT_EQ(0, PrintFrame(test_frame2, width, height, "OutputFrame")); - EXPECT_EQ(0, MirrorI420LeftRight(out_frame, test_frame, width, height)); - - EXPECT_EQ(0, memcmp(in_frame, test_frame, length)); - - // UpDown - std::cout << "Test Mirror function: UpDown" << std::endl; - EXPECT_EQ(0, MirrorI420UpDown(in_frame, out_frame, width, height)); - EXPECT_EQ(0, PrintFrame(test_frame2, width, height, "OutputFrame")); - EXPECT_EQ(0, MirrorI420UpDown(out_frame, test_frame, width, height)); - - EXPECT_EQ(0, memcmp(in_frame, test_frame, length)); - - // TODO(mikhal): Write to a file, and ask to look at the file. - - std::cout << "Do the mirrored frames look correct?" << std::endl; - delete [] test_frame; - delete [] test_frame2; -} - -} // namespace
diff --git a/src/common_video/libyuv/scaler.cc b/src/common_video/libyuv/scaler.cc deleted file mode 100644 index b27c75c..0000000 --- a/src/common_video/libyuv/scaler.cc +++ /dev/null
@@ -1,106 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "common_video/libyuv/include/scaler.h" - -#include "libyuv.h" - -namespace webrtc { - -Scaler::Scaler() - : method_(kScaleBox), - src_width_(0), - src_height_(0), - dst_width_(0), - dst_height_(0), - set_(false) {} - -Scaler::~Scaler() {} - -int Scaler::Set(int src_width, int src_height, - int dst_width, int dst_height, - VideoType src_video_type, VideoType dst_video_type, - ScaleMethod method) { - set_ = false; - if (src_width < 1 || src_height < 1 || dst_width < 1 || dst_height < 1) - return -1; - - if (!SupportedVideoType(src_video_type, dst_video_type)) - return -1; - - src_width_ = src_width; - src_height_ = src_height; - dst_width_ = dst_width; - dst_height_ = dst_height; - method_ = method; - set_ = true; - return 0; -} - -int Scaler::Scale(const uint8_t* src_frame, - uint8_t*& dst_frame, - int& dst_size) { - if (src_frame == NULL) - return -1; - if (!set_) - return -2; - - // Making sure that destination frame is of sufficient size - int dst_half_width = (dst_width_ + 1) >> 1; - int dst_half_height = (dst_height_ + 1) >> 1; - int required_dst_size = dst_width_ * dst_height_ + 2 * (dst_half_width * - dst_half_height); - if (dst_frame && required_dst_size > dst_size) { - // allocated buffer is too small - delete [] dst_frame; - dst_frame = NULL; - } - if (dst_frame == NULL) { - // TODO(mikhal): align this buffer to 16 bytes. - dst_frame = new uint8_t[required_dst_size]; - dst_size = required_dst_size; - } - - int src_half_width = (src_width_ + 1) >> 1; - int src_half_height = (src_height_ + 1) >> 1; - // Converting to planes: - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + src_width_ * src_height_; - const uint8_t* src_vplane = src_uplane + src_half_width * src_half_height; - - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + dst_width_ * dst_height_; - uint8_t* dst_vplane = dst_uplane + dst_half_width * dst_half_height; - - return libyuv::I420Scale(src_yplane, src_width_, - src_uplane, src_half_width, - src_vplane, src_half_width, - src_width_, src_height_, - dst_yplane, dst_width_, - dst_uplane, dst_half_width, - dst_vplane, dst_half_width, - dst_width_, dst_height_, - libyuv::FilterMode(method_)); -} - -// TODO(mikhal): Add support for more types. -bool Scaler::SupportedVideoType(VideoType src_video_type, - VideoType dst_video_type) { - if (src_video_type != dst_video_type) - return false; - - if ((src_video_type == kI420) || (src_video_type == kIYUV) || - (src_video_type == kYV12)) - return true; - - return false; -} - -} // namespace webrtc
diff --git a/src/common_video/libyuv/scaler_unittest.cc b/src/common_video/libyuv/scaler_unittest.cc deleted file mode 100644 index f6ee15d..0000000 --- a/src/common_video/libyuv/scaler_unittest.cc +++ /dev/null
@@ -1,469 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <math.h> -#include <string.h> - -#include "common_video/libyuv/include/scaler.h" -#include "gtest/gtest.h" -#include "system_wrappers/interface/tick_util.h" -#include "testsupport/fileutils.h" - -namespace webrtc { - -class TestScaler : public ::testing::Test { - protected: - TestScaler(); - virtual void SetUp(); - virtual void TearDown(); - - void ScaleSequence(ScaleMethod method, - FILE* source_file, std::string out_name, - int src_width, int src_height, - int dst_width, int dst_height); - - // TODO(mikhal): add a sequence reader to libyuv. - - // Computes the sequence average PSNR between an input sequence in - // |input_file| and an output sequence with filename |out_name|. |width| and - // |height| are the frame sizes of both sequences. - double ComputeAvgSequencePSNR(FILE* input_file, std::string out_name, - int width, int height); - - Scaler test_scaler_; - FILE* source_file_; - uint8_t* test_buffer_; - const int width_; - const int height_; - const int frame_length_; -}; - - -// TODO (mikhal): Use scoped_ptr when handling buffers. -TestScaler::TestScaler() - : source_file_(NULL), - width_(352), - height_(288), - frame_length_(CalcBufferSize(kI420, 352, 288)) { -} - -void TestScaler::SetUp() { - const std::string input_file_name = - webrtc::test::ResourcePath("foreman_cif", "yuv"); - source_file_ = fopen(input_file_name.c_str(), "rb"); - ASSERT_TRUE(source_file_ != NULL) << "Cannot read file: "<< - input_file_name << "\n"; - test_buffer_ = new uint8_t[frame_length_]; -} - -void TestScaler::TearDown() { - if (source_file_ != NULL) { - ASSERT_EQ(0, fclose(source_file_)); - } - source_file_ = NULL; - delete [] test_buffer_; -} - -TEST_F(TestScaler, ScaleWithoutSettingValues) { - int size = 100; - EXPECT_EQ(-2, test_scaler_.Scale(test_buffer_, test_buffer_, size)); -} - -TEST_F(TestScaler, ScaleBadInitialValues) { - EXPECT_EQ(-1, test_scaler_.Set(0, 288, 352, 288, kI420, kI420, kScalePoint)); - EXPECT_EQ(-1, test_scaler_.Set(704, 0, 352, 288, kI420, kI420, kScaleBox)); - EXPECT_EQ(-1, test_scaler_.Set(704, 576, 352, 0, kI420, kI420, - kScaleBilinear)); - EXPECT_EQ(-1, test_scaler_.Set(704, 576, 0, 288, kI420, kI420, kScalePoint)); -} - -TEST_F(TestScaler, ScaleSendingNullSourcePointer) { - int size = 0; - EXPECT_EQ(-1, test_scaler_.Scale(NULL, test_buffer_, size)); -} - -TEST_F(TestScaler, ScaleSendingBufferTooSmall) { - // Sending a buffer which is too small (should reallocate and update size) - EXPECT_EQ(0, test_scaler_.Set(352, 288, 144, 288, kI420, kI420, kScalePoint)); - uint8_t* test_buffer2 = NULL; - int size = 0; - EXPECT_GT(fread(test_buffer_, 1, frame_length_, source_file_), 0U); - EXPECT_EQ(0, test_scaler_.Scale(test_buffer_, test_buffer2, size)); - EXPECT_EQ(144 * 288 * 3 / 2, size); - delete [] test_buffer2; -} - -//TODO (mikhal): Converge the test into one function that accepts the method. -TEST_F(TestScaler, PointScaleTest) { - double avg_psnr; - FILE* source_file2; - ScaleMethod method = kScalePoint; - std::string out_name = webrtc::test::OutputPath() + - "LibYuvTest_PointScale_176_144.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - width_ / 2, height_ / 2); - // Upsample back up and check PSNR. - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_352_288_" - "upfrom_176_144.yuv"; - ScaleSequence(method, - source_file2, out_name, - 176, 144, - 352, 288); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 176, 144, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 27.9); - ASSERT_EQ(0, fclose(source_file2)); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_320_240.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 320, 240); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_704_576.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - width_ * 2, height_ * 2); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_300_200.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 300, 200); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_400_300.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 400, 300); - // Dowsample to odd size frame and scale back up. - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_282_231.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 282, 231); - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_352_288_" - "upfrom_282_231.yuv"; - ScaleSequence(method, - source_file2, out_name, - 282, 231, - 352, 288); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 282, 231, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 27.8); - ASSERT_EQ(0, fclose(source_file2)); - // Upsample to odd size frame and scale back down. - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_699_531.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 699, 531); - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_PointScale_352_288_" - "downfrom_699_531.yuv"; - ScaleSequence(method, - source_file2, out_name, - 699, 531, - 352, 288); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 699, 531, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 37.8); - ASSERT_EQ(0, fclose(source_file2)); -} - -TEST_F(TestScaler, BiLinearScaleTest) { - double avg_psnr; - FILE* source_file2; - ScaleMethod method = kScaleBilinear; - std::string out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_176_144.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - width_ / 2, height_ / 2); - // Upsample back up and check PSNR. - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BilinearScale_352_288_" - "upfrom_176_144.yuv"; - ScaleSequence(method, - source_file2, out_name, - 176, 144, - 352, 288); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 176, 144, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 27.5); - ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - ASSERT_EQ(0, fclose(source_file2)); - out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_320_240.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 320, 240); - out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_704_576.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - width_ * 2, height_ * 2); - out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_300_200.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 300, 200); - out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_400_300.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 400, 300); - // Downsample to odd size frame and scale back up. - out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_282_231.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 282, 231); - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BilinearScale_352_288_" - "upfrom_282_231.yuv"; - ScaleSequence(method, - source_file2, out_name, - 282, 231, - width_, height_); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 282, 231, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 29.7); - ASSERT_EQ(0, fclose(source_file2)); - // Upsample to odd size frame and scale back down. - out_name = webrtc::test::OutputPath() + - "LibYuvTest_BilinearScale_699_531.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 699, 531); - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BilinearScale_352_288_" - "downfrom_699_531.yuv"; - ScaleSequence(method, - source_file2, out_name, - 699, 531, - width_, height_); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 699, 531, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 31.4); - ASSERT_EQ(0, fclose(source_file2)); -} - -TEST_F(TestScaler, BoxScaleTest) { - double avg_psnr; - FILE* source_file2; - ScaleMethod method = kScaleBox; - std::string out_name = webrtc::test::OutputPath() + - "LibYuvTest_BoxScale_176_144.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - width_ / 2, height_ / 2); - // Upsample back up and check PSNR. - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_352_288_" - "upfrom_176_144.yuv"; - ScaleSequence(method, - source_file2, out_name, - 176, 144, - 352, 288); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 176, 144, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 27.5); - ASSERT_EQ(0, fclose(source_file2)); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_320_240.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 320, 240); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_704_576.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - width_ * 2, height_ * 2); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_300_200.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 300, 200); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_400_300.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 400, 300); - // Downsample to odd size frame and scale back up. - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_282_231.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 282, 231); - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_352_288_" - "upfrom_282_231.yuv"; - ScaleSequence(method, - source_file2, out_name, - 282, 231, - width_, height_); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 282, 231, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 29.7); - ASSERT_EQ(0, fclose(source_file2)); - // Upsample to odd size frame and scale back down. - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_699_531.yuv"; - ScaleSequence(method, - source_file_, out_name, - width_, height_, - 699, 531); - source_file2 = fopen(out_name.c_str(), "rb"); - out_name = webrtc::test::OutputPath() + "LibYuvTest_BoxScale_352_288_" - "downfrom_699_531.yuv"; - ScaleSequence(method, - source_file2, out_name, - 699, 531, - width_, height_); - avg_psnr = ComputeAvgSequencePSNR(source_file_, out_name, width_, height_); - printf("PSNR for scaling from: %d %d, down/up to: %d %d, and back to " - "original size: %f \n", width_, height_, 699, 531, avg_psnr); - // Average PSNR for lower bound in assert is ~0.1dB lower than the actual - // average PSNR under same conditions. - ASSERT_GT(avg_psnr, 31.4); - ASSERT_EQ(0, fclose(source_file2)); -} - -double TestScaler::ComputeAvgSequencePSNR(FILE* input_file, - std::string out_name, - int width, int height) { - FILE* output_file; - output_file = fopen(out_name.c_str(), "rb"); - assert(output_file != NULL); - rewind(input_file); - rewind(output_file); - - int half_width = (width + 1) >> 1; - int half_height = (height + 1) >> 1; - int required_size = height * width + 2 * (half_width * half_height); - uint8_t* input_buffer = new uint8_t[required_size]; - uint8_t* output_buffer = new uint8_t[required_size]; - - int frame_count = 0; - double avg_psnr = 0; - while (feof(input_file) == 0) { - if ((size_t)required_size != - fread(input_buffer, 1, required_size, input_file)) { - break; - } - if ((size_t)required_size != - fread(output_buffer, 1, required_size, output_file)) { - break; - } - frame_count++; - double psnr = I420PSNR(input_buffer, output_buffer, width, height); - avg_psnr += psnr; - } - avg_psnr = avg_psnr / frame_count; - assert(0 == fclose(output_file)); - delete [] input_buffer; - delete [] output_buffer; - return avg_psnr; -} - -// TODO (mikhal): Move part to a separate scale test. -void TestScaler::ScaleSequence(ScaleMethod method, - FILE* source_file, std::string out_name, - int src_width, int src_height, - int dst_width, int dst_height) { - FILE* output_file; - EXPECT_EQ(0, test_scaler_.Set(src_width, src_height, - dst_width, dst_height, - kI420, kI420, method)); - - output_file = fopen(out_name.c_str(), "wb"); - ASSERT_TRUE(output_file != NULL); - - rewind(source_file); - - int src_half_width = (src_width + 1) >> 1; - int src_half_height = (src_height + 1) >> 1; - int dst_half_width = (dst_width + 1) >> 1; - int dst_half_height = (dst_height + 1) >> 1; - - int out_required_size = dst_width * dst_height + 2 * (dst_half_width * - dst_half_height); - int in_required_size = src_height * src_width + 2 * (src_half_width * - src_half_height); - - uint8_t* input_buffer = new uint8_t[in_required_size]; - uint8_t* output_buffer = new uint8_t[out_required_size]; - - int64_t start_clock, total_clock; - total_clock = 0; - int frame_count = 0; - - // Running through entire sequence - while (feof(source_file) == 0) { - if ((size_t)in_required_size != - fread(input_buffer, 1, in_required_size, source_file)) - break; - - start_clock = TickTime::MillisecondTimestamp(); - EXPECT_EQ(0, test_scaler_.Scale(input_buffer, output_buffer, - out_required_size)); - total_clock += TickTime::MillisecondTimestamp() - start_clock; - if (fwrite(output_buffer, 1, out_required_size, - output_file) != static_cast<unsigned int>(out_required_size)) { - return; - } - frame_count++; - } - - if (frame_count) { - printf("Scaling[%d %d] => [%d %d]: ", - src_width, src_height, dst_width, dst_height); - printf("Average time per frame[ms]: %.2lf\n", - (static_cast<double>(total_clock) / frame_count)); - } - ASSERT_EQ(0, fclose(output_file)); - delete [] input_buffer; - delete [] output_buffer; -} - -} // namespace webrtc
diff --git a/src/common_video/libyuv/webrtc_libyuv.cc b/src/common_video/libyuv/webrtc_libyuv.cc deleted file mode 100644 index 9c370f7..0000000 --- a/src/common_video/libyuv/webrtc_libyuv.cc +++ /dev/null
@@ -1,323 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "common_video/libyuv/include/webrtc_libyuv.h" - -#include <assert.h> - -#include "libyuv.h" - -namespace webrtc { - -VideoType RawVideoTypeToCommonVideoVideoType(RawVideoType type) { - switch (type) { - case kVideoI420: - return kI420; - case kVideoIYUV: - return kIYUV; - case kVideoRGB24: - return kRGB24; - case kVideoARGB: - return kARGB; - case kVideoARGB4444: - return kARGB4444; - case kVideoRGB565: - return kRGB565; - case kVideoARGB1555: - return kARGB1555; - case kVideoYUY2: - return kYUY2; - case kVideoYV12: - return kYV12; - case kVideoUYVY: - return kUYVY; - case kVideoNV21: - return kNV21; - case kVideoNV12: - return kNV12; - case kVideoBGRA: - return kBGRA; - case kVideoMJPEG: - return kMJPG; - default: - assert(false); - } - return kUnknown; -} - -int CalcBufferSize(VideoType type, int width, int height) { - int buffer_size = 0; - switch (type) { - case kI420: - case kNV12: - case kNV21: - case kIYUV: - case kYV12: { - int half_width = (width + 1) >> 1; - int half_height = (height + 1) >> 1; - buffer_size = width * height + half_width * half_height * 2; - break; - } - case kARGB4444: - case kRGB565: - case kARGB1555: - case kYUY2: - case kUYVY: - buffer_size = width * height * 2; - break; - case kRGB24: - buffer_size = width * height * 3; - break; - case kBGRA: - case kARGB: - buffer_size = width * height * 4; - break; - default: - assert(false); - return -1; - } - return buffer_size; -} - -int ConvertNV12ToRGB565(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - int abs_height = (height < 0) ? -height : height; - const uint8_t* yplane = src_frame; - const uint8_t* uvInterlaced = src_frame + (width * abs_height); - - return libyuv::NV12ToRGB565(yplane, width, - uvInterlaced, (width + 1) >> 1, - dst_frame, width, - width, height); -} - -int ConvertRGB24ToARGB(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height, int dst_stride) { - if (dst_stride == 0) - dst_stride = width; - return libyuv::RGB24ToARGB(src_frame, width, - dst_frame, dst_stride, - width, height); -} - -libyuv::RotationMode ConvertRotationMode(VideoRotationMode rotation) { - switch(rotation) { - case kRotateNone: - return libyuv::kRotate0; - case kRotate90: - return libyuv::kRotate90; - case kRotate180: - return libyuv::kRotate180; - case kRotate270: - return libyuv::kRotate270; - } - assert(false); - return libyuv::kRotate0; -} - -int ConvertVideoType(VideoType video_type) { - switch(video_type) { - case kUnknown: - return libyuv::FOURCC_ANY; - case kI420: - return libyuv::FOURCC_I420; - case kIYUV: // same as KYV12 - case kYV12: - return libyuv::FOURCC_YV12; - case kRGB24: - return libyuv::FOURCC_24BG; - case kABGR: - return libyuv::FOURCC_ABGR; - case kRGB565: - return libyuv::FOURCC_RGBP; - case kYUY2: - return libyuv::FOURCC_YUY2; - case kUYVY: - return libyuv::FOURCC_UYVY; - case kMJPG: - return libyuv::FOURCC_MJPG; - case kNV21: - return libyuv::FOURCC_NV21; - case kNV12: - return libyuv::FOURCC_NV12; - case kARGB: - return libyuv::FOURCC_ARGB; - case kBGRA: - return libyuv::FOURCC_BGRA; - case kARGB4444: - return libyuv::FOURCC_R444; - case kARGB1555: - return libyuv::FOURCC_RGBO; - } - assert(false); - return libyuv::FOURCC_ANY; -} - -int ConvertToI420(VideoType src_video_type, - const uint8_t* src_frame, - int crop_x, int crop_y, - int src_width, int src_height, - int sample_size, - int dst_width, int dst_height, int dst_stride, - VideoRotationMode rotation, - uint8_t* dst_frame) { - // All sanity tests are conducted within LibYuv. - int abs_dst_height = (dst_height < 0) ? -dst_height : dst_height; - int half_dst_width = (dst_width + 1) >> 1; - int half_dst_height = (abs_dst_height + 1) >> 1; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_yplane + dst_width * abs_dst_height; - uint8_t* dst_vplane = dst_uplane + half_dst_width * half_dst_height; - return libyuv::ConvertToI420(src_frame, sample_size, - dst_yplane, dst_stride, - dst_uplane, (dst_stride + 1) / 2, - dst_vplane, (dst_stride + 1) / 2, - crop_x, crop_y, - src_width, src_height, - dst_width, dst_height, - ConvertRotationMode(rotation), - ConvertVideoType(src_video_type)); -} - -int ConvertFromI420(const uint8_t* src_frame, int src_stride, - VideoType dst_video_type, int dst_sample_size, - int width, int height, - uint8_t* dst_frame) { - int abs_height = (height < 0) ? -height : height; - int half_width = (width + 1) >> 1; - int half_height = (abs_height + 1) >> 1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_yplane + width * abs_height; - const uint8_t* src_vplane = src_uplane + half_width * half_height; - return libyuv::ConvertFromI420(src_yplane, src_stride, - src_uplane, (src_stride + 1) / 2, - src_vplane, (src_stride + 1) / 2, - dst_frame, dst_sample_size, - width, height, - ConvertVideoType(dst_video_type)); -} - -int ConvertFromYV12(const uint8_t* src_frame, int src_stride, - VideoType dst_video_type, int dst_sample_size, - int width, int height, - uint8_t* dst_frame) { - int half_src_stride = (src_stride + 1) >> 1; - int abs_height = (height < 0) ? -height : height; - int half_height = (abs_height + 1) >> 1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_yplane + width * abs_height; - const uint8_t* src_vplane = src_uplane + half_src_stride * half_height; - // YV12 = Y, V, U - return libyuv::ConvertFromI420(src_yplane, src_stride, - src_vplane, half_src_stride, - src_uplane, half_src_stride, - dst_frame, dst_sample_size, - width, height, - ConvertVideoType(dst_video_type)); -} - -int MirrorI420LeftRight(const uint8_t* src_frame, - uint8_t* dst_frame, - int width, int height) { - int half_width = (width + 1) >> 1; - int half_height = (height + 1) >> 1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_yplane + width * height; - const uint8_t* src_vplane = src_uplane + half_width * half_height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_yplane + width * height; - uint8_t* dst_vplane = dst_uplane + half_width * half_height; - return libyuv::I420Mirror(src_yplane, width, - src_uplane, half_width, - src_vplane, half_width, - dst_yplane, width, - dst_uplane, half_width, - dst_vplane, half_width, - width, height); -} - -int MirrorI420UpDown(const uint8_t* src_frame, uint8_t* dst_frame, - int width, int height) { - int half_width = (width + 1) >> 1; - int half_height = (height + 1) >> 1; - const uint8_t* src_yplane = src_frame; - const uint8_t* src_uplane = src_frame + width * height; - const uint8_t* src_vplane = src_uplane + half_width * half_height; - uint8_t* dst_yplane = dst_frame; - uint8_t* dst_uplane = dst_frame + width * height; - uint8_t* dst_vplane = dst_uplane + half_width * half_height; - - // Inserting negative height flips the frame. - return libyuv::I420Copy(src_yplane, width, - src_uplane, half_width, - src_vplane, half_width, - dst_yplane, width, - dst_uplane, half_width, - dst_vplane, half_width, - width, -height); -} - -// Compute PSNR for an I420 frame (all planes) -double I420PSNR(const uint8_t* ref_frame, - const uint8_t* test_frame, - int width, int height) { - if (!ref_frame || !test_frame) - return -1; - else if (height < 0 || width < 0) - return -1; - int half_width = (width + 1) >> 1; - int half_height = (height + 1) >> 1; - const uint8_t* src_y_a = ref_frame; - const uint8_t* src_u_a = src_y_a + width * height; - const uint8_t* src_v_a = src_u_a + half_width * half_height; - const uint8_t* src_y_b = test_frame; - const uint8_t* src_u_b = src_y_b + width * height; - const uint8_t* src_v_b = src_u_b + half_width * half_height; - // In the following: stride is determined by width. - double psnr = libyuv::I420Psnr(src_y_a, width, - src_u_a, half_width, - src_v_a, half_width, - src_y_b, width, - src_u_b, half_width, - src_v_b, half_width, - width, height); - // LibYuv sets the max psnr value to 128, we restrict it to 48. - // In case of 0 mse in one frame, 128 can skew the results significantly. - return (psnr > 48.0) ? 48.0 : psnr; -} -// Compute SSIM for an I420 frame (all planes) -double I420SSIM(const uint8_t* ref_frame, - const uint8_t* test_frame, - int width, int height) { - if (!ref_frame || !test_frame) - return -1; - else if (height < 0 || width < 0) - return -1; - int half_width = (width + 1) >> 1; - int half_height = (height + 1) >> 1; - const uint8_t* src_y_a = ref_frame; - const uint8_t* src_u_a = src_y_a + width * height; - const uint8_t* src_v_a = src_u_a + half_width * half_height; - const uint8_t* src_y_b = test_frame; - const uint8_t* src_u_b = src_y_b + width * height; - const uint8_t* src_v_b = src_u_b + half_width * half_height; - int stride_y = width; - int stride_uv = half_width; - return libyuv::I420Ssim(src_y_a, stride_y, - src_u_a, stride_uv, - src_v_a, stride_uv, - src_y_b, stride_y, - src_u_b, stride_uv, - src_v_b, stride_uv, - width, height); -} - -} // namespace webrtc
diff --git a/src/engine_configurations.h b/src/engine_configurations.h deleted file mode 100644 index a1ed4a9..0000000 --- a/src/engine_configurations.h +++ /dev/null
@@ -1,151 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_ENGINE_CONFIGURATIONS_H_ -#define WEBRTC_ENGINE_CONFIGURATIONS_H_ - -// ============================================================================ -// Voice and Video -// ============================================================================ - -// Don't link in socket support in Chrome -#ifdef WEBRTC_CHROMIUM_BUILD -#define WEBRTC_EXTERNAL_TRANSPORT -#endif - -// Optional to enable stand-alone -// #define WEBRTC_EXTERNAL_TRANSPORT - -// ---------------------------------------------------------------------------- -// [Voice] Codec settings -// ---------------------------------------------------------------------------- - -#ifdef WEBRTC_ARCH_ARM -#define WEBRTC_CODEC_ISACFX // fix-point iSAC implementation -#else -#define WEBRTC_CODEC_ISAC // floating-point iSAC implementation (default) -#endif -#define WEBRTC_CODEC_AVT - -#ifndef WEBRTC_CHROMIUM_BUILD -#define WEBRTC_CODEC_ILBC -#define WEBRTC_CODEC_G722 -#define WEBRTC_CODEC_PCM16 -#define WEBRTC_CODEC_RED -#endif - -// ---------------------------------------------------------------------------- -// [Video] Codec settings -// ---------------------------------------------------------------------------- - -#define VIDEOCODEC_I420 -#define VIDEOCODEC_VP8 - -// ============================================================================ -// VoiceEngine -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Settings for VoiceEngine -// ---------------------------------------------------------------------------- - -#define WEBRTC_VOICE_ENGINE_AGC // Near-end AGC -#define WEBRTC_VOICE_ENGINE_ECHO // Near-end AEC -#define WEBRTC_VOICE_ENGINE_NR // Near-end NS -#define WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT - -#ifndef WEBRTC_CHROMIUM_BUILD -#define WEBRTC_VOICE_ENGINE_TYPING_DETECTION // Typing detection -#endif - -// ---------------------------------------------------------------------------- -// VoiceEngine sub-APIs -// ---------------------------------------------------------------------------- - -#define WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API -#define WEBRTC_VOICE_ENGINE_CODEC_API -#define WEBRTC_VOICE_ENGINE_DTMF_API -#define WEBRTC_VOICE_ENGINE_EXTERNAL_MEDIA_API -#define WEBRTC_VOICE_ENGINE_FILE_API -#define WEBRTC_VOICE_ENGINE_HARDWARE_API -#define WEBRTC_VOICE_ENGINE_NETEQ_STATS_API -#define WEBRTC_VOICE_ENGINE_NETWORK_API -#define WEBRTC_VOICE_ENGINE_RTP_RTCP_API -#define WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API -#define WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API - -#ifndef WEBRTC_CHROMIUM_BUILD -#define WEBRTC_VOICE_ENGINE_CALL_REPORT_API -#define WEBRTC_VOICE_ENGINE_ENCRYPTION_API -#endif - -// ============================================================================ -// VideoEngine -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Settings for special VideoEngine configurations -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// VideoEngine sub-API:s -// ---------------------------------------------------------------------------- - -#define WEBRTC_VIDEO_ENGINE_CAPTURE_API -#define WEBRTC_VIDEO_ENGINE_CODEC_API -#define WEBRTC_VIDEO_ENGINE_ENCRYPTION_API -#define WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API -#define WEBRTC_VIDEO_ENGINE_NETWORK_API -#define WEBRTC_VIDEO_ENGINE_RENDER_API -#define WEBRTC_VIDEO_ENGINE_RTP_RTCP_API -// #define WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - -// Now handled by gyp: -// WEBRTC_VIDEO_ENGINE_FILE_API - -// ============================================================================ -// Platform specific configurations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// VideoEngine Windows -// ---------------------------------------------------------------------------- - -#if defined(_WIN32) -// #define DIRECTDRAW_RENDERING -#define DIRECT3D9_RENDERING // Requires DirectX 9. -#endif - -// ---------------------------------------------------------------------------- -// VideoEngine MAC -// ---------------------------------------------------------------------------- - -#if defined(WEBRTC_MAC) && !defined(MAC_IPHONE) -// #define CARBON_RENDERING -#define COCOA_RENDERING -#endif - -// ---------------------------------------------------------------------------- -// VideoEngine Mobile iPhone -// ---------------------------------------------------------------------------- - -#if defined(MAC_IPHONE) -#define EAGL_RENDERING -#endif - -// ---------------------------------------------------------------------------- -// Deprecated -// ---------------------------------------------------------------------------- - -// #define WEBRTC_CODEC_G729 -// #define WEBRTC_DTMF_DETECTION -// #define WEBRTC_SRTP -// #define WEBRTC_SRTP_ALLOW_ROC_ITERATION - -#endif // WEBRTC_ENGINE_CONFIGURATIONS_H_
diff --git a/src/modules/audio_coding/codecs/OWNERS b/src/modules/audio_coding/codecs/OWNERS deleted file mode 100644 index e1e6256..0000000 --- a/src/modules/audio_coding/codecs/OWNERS +++ /dev/null
@@ -1,3 +0,0 @@ -tina.legrand@webrtc.org -turaj@webrtc.org -jan.skoglund@webrtc.org
diff --git a/src/modules/audio_coding/codecs/cng/cng.gypi b/src/modules/audio_coding/codecs/cng/cng.gypi deleted file mode 100644 index ce83e29..0000000 --- a/src/modules/audio_coding/codecs/cng/cng.gypi +++ /dev/null
@@ -1,57 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'CNG', - 'type': '<(library)', - 'dependencies': [ - '<(webrtc_root)/common_audio/common_audio.gyp:signal_processing', - ], - 'include_dirs': [ - 'include', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - ], - }, - 'sources': [ - 'include/webrtc_cng.h', - 'webrtc_cng.c', - 'cng_helpfuns.c', - 'cng_helpfuns.h', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'cng_unittests', - 'type': 'executable', - 'dependencies': [ - 'CNG', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(webrtc_root)/test/test.gyp:test_support_main', - ], - 'sources': [ - 'cng_unittest.cc', - ], - }, # CNG_unittests - ], # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/modules/audio_coding/codecs/cng/cng_helpfuns.c b/src/modules/audio_coding/codecs/cng/cng_helpfuns.c deleted file mode 100644 index 2e9029f..0000000 --- a/src/modules/audio_coding/codecs/cng/cng_helpfuns.c +++ /dev/null
@@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#include "webrtc_cng.h" -#include "signal_processing_library.h" -#include "typedefs.h" -#include "cng_helpfuns.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -void WebRtcCng_K2a16( - WebRtc_Word16 *k, /* Q15. */ - int useOrder, - WebRtc_Word16 *a /* Q12. */ -) -{ - WebRtc_Word16 any[WEBRTC_SPL_MAX_LPC_ORDER+1]; - WebRtc_Word16 *aptr, *aptr2, *anyptr; - G_CONST WebRtc_Word16 *kptr; - int m, i; - - kptr = k; - *a = 4096; /* i.e., (Word16_MAX >> 3)+1 */ - *any = *a; - a[1] = (*k+4) >> 3; - for( m=1; m<useOrder; m++ ) - { - kptr++; - aptr = a; - aptr++; - aptr2 = &a[m]; - anyptr = any; - anyptr++; - - any[m+1] = (*kptr+4) >> 3; - for( i=0; i<m; i++ ) { - *anyptr++ = (*aptr++) + (WebRtc_Word16)( (( (WebRtc_Word32)(*aptr2--) * (WebRtc_Word32)*kptr )+16384) >> 15); - } - - aptr = a; - anyptr = any; - for( i=0; i<(m+2); i++ ){ - *aptr++ = *anyptr++; - } - } -} - - -#ifdef __cplusplus -} -#endif -
diff --git a/src/modules/audio_coding/codecs/cng/cng_helpfuns.h b/src/modules/audio_coding/codecs/cng/cng_helpfuns.h deleted file mode 100644 index fd8d6dc..0000000 --- a/src/modules/audio_coding/codecs/cng/cng_helpfuns.h +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_SOURCE_CNG_HELPFUNS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_SOURCE_CNG_HELPFUNS_H_ - -extern WebRtc_Word32 lpc_lagwinTbl_fixw32[WEBRTC_CNG_MAX_LPC_ORDER + 1]; - -#ifdef __cplusplus -extern "C" { -#endif - - -void WebRtcCng_K2a16(WebRtc_Word16 *k, int useOrder, WebRtc_Word16 *a); - -#ifdef __cplusplus -} -#endif - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_SOURCE_CNG_HELPFUNS_H_
diff --git a/src/modules/audio_coding/codecs/cng/cng_unittest.cc b/src/modules/audio_coding/codecs/cng/cng_unittest.cc deleted file mode 100644 index 6a4edc0..0000000 --- a/src/modules/audio_coding/codecs/cng/cng_unittest.cc +++ /dev/null
@@ -1,17 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * Empty test just to get code coverage metrics for this dir. - */ -#include "webrtc_cng.h" -#include "gtest/gtest.h" - -TEST(CngTest, EmptyTestToGetCodeCoverage) {}
diff --git a/src/modules/audio_coding/codecs/cng/include/webrtc_cng.h b/src/modules/audio_coding/codecs/cng/include/webrtc_cng.h deleted file mode 100644 index d405e3a..0000000 --- a/src/modules/audio_coding/codecs/cng/include/webrtc_cng.h +++ /dev/null
@@ -1,236 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_ - -#include "typedefs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define WEBRTC_CNG_MAX_LPC_ORDER 12 -#define WEBRTC_CNG_MAX_OUTSIZE_ORDER 640 - -/* Define Error codes */ - -/* 6100 Encoder */ -#define CNG_ENCODER_MEMORY_ALLOCATION_FAILED 6110 -#define CNG_ENCODER_NOT_INITIATED 6120 -#define CNG_DISALLOWED_LPC_ORDER 6130 -#define CNG_DISALLOWED_FRAME_SIZE 6140 -#define CNG_DISALLOWED_SAMPLING_FREQUENCY 6150 -/* 6200 Decoder */ -#define CNG_DECODER_MEMORY_ALLOCATION_FAILED 6210 -#define CNG_DECODER_NOT_INITIATED 6220 - - -typedef struct WebRtcCngEncInst CNG_enc_inst; -typedef struct WebRtcCngDecInst CNG_dec_inst; - - -/**************************************************************************** - * WebRtcCng_Version(...) - * - * These functions returns the version name (string must be at least - * 500 characters long) - * - * Output: - * - version : Pointer to character string - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_Version(char *version); - -/**************************************************************************** - * WebRtcCng_AssignSizeEnc/Dec(...) - * - * These functions get the size needed for storing the instance for encoder - * and decoder, respectively - * - * Input/Output: - * - sizeinbytes : Pointer to integer where the size is returned - * - * Return value : 0 - */ - -WebRtc_Word16 WebRtcCng_AssignSizeEnc(int *sizeinbytes); -WebRtc_Word16 WebRtcCng_AssignSizeDec(int *sizeinbytes); - - -/**************************************************************************** - * WebRtcCng_AssignEnc/Dec(...) - * - * These functions Assignes memory for the instances. - * - * Input: - * - CNG_inst_Addr : Adress to where to assign memory - * Output: - * - inst : Pointer to the instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_AssignEnc(CNG_enc_inst **inst, void *CNG_inst_Addr); -WebRtc_Word16 WebRtcCng_AssignDec(CNG_dec_inst **inst, void *CNG_inst_Addr); - - -/**************************************************************************** - * WebRtcCng_CreateEnc/Dec(...) - * - * These functions create an instance to the specified structure - * - * Input: - * - XXX_inst : Pointer to created instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_CreateEnc(CNG_enc_inst **cng_inst); -WebRtc_Word16 WebRtcCng_CreateDec(CNG_dec_inst **cng_inst); - - -/**************************************************************************** - * WebRtcCng_InitEnc/Dec(...) - * - * This function initializes a instance - * - * Input: - * - cng_inst : Instance that should be initialized - * - * - fs : 8000 for narrowband and 16000 for wideband - * - interval : generate SID data every interval ms - * - quality : Number of refl. coefs, maximum allowed is 12 - * - * Output: - * - cng_inst : Initialized instance - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_InitEnc(CNG_enc_inst *cng_inst, - WebRtc_Word16 fs, - WebRtc_Word16 interval, - WebRtc_Word16 quality); -WebRtc_Word16 WebRtcCng_InitDec(CNG_dec_inst *cng_dec_inst); - - -/**************************************************************************** - * WebRtcCng_FreeEnc/Dec(...) - * - * These functions frees the dynamic memory of a specified instance - * - * Input: - * - cng_inst : Pointer to created instance that should be freed - * - * Return value : 0 - Ok - * -1 - Error - */ - - -WebRtc_Word16 WebRtcCng_FreeEnc(CNG_enc_inst *cng_inst); -WebRtc_Word16 WebRtcCng_FreeDec(CNG_dec_inst *cng_inst); - - - -/**************************************************************************** - * WebRtcCng_Encode(...) - * - * These functions analyzes background noise - * - * Input: - * - cng_inst : Pointer to created instance - * - speech : Signal to be analyzed - * - nrOfSamples : Size of speech vector - * - forceSID : not zero to force SID frame and reset - * - * Output: - * - bytesOut : Nr of bytes to transmit, might be 0 - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_Encode(CNG_enc_inst *cng_inst, - WebRtc_Word16 *speech, - WebRtc_Word16 nrOfSamples, - WebRtc_UWord8* SIDdata, - WebRtc_Word16 *bytesOut, - WebRtc_Word16 forceSID); - - -/**************************************************************************** - * WebRtcCng_UpdateSid(...) - * - * These functions updates the CN state, when a new SID packet arrives - * - * Input: - * - cng_inst : Pointer to created instance that should be freed - * - SID : SID packet, all headers removed - * - length : Length in bytes of SID packet - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcCng_UpdateSid(CNG_dec_inst *cng_inst, - WebRtc_UWord8 *SID, - WebRtc_Word16 length); - - -/**************************************************************************** - * WebRtcCng_Generate(...) - * - * These functions generates CN data when needed - * - * Input: - * - cng_inst : Pointer to created instance that should be freed - * - outData : pointer to area to write CN data - * - nrOfSamples : How much data to generate - * - new_period : >0 if a new period of CNG, will reset history - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcCng_Generate(CNG_dec_inst *cng_inst, - WebRtc_Word16 * outData, - WebRtc_Word16 nrOfSamples, - WebRtc_Word16 new_period); - - -/***************************************************************************** - * WebRtcCng_GetErrorCodeEnc/Dec(...) - * - * This functions can be used to check the error code of a CNG instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occurred in the - * specified instance. - * - * Input: - * - CNG_inst : CNG enc/dec instance - * - * Return value : Error code - */ - -WebRtc_Word16 WebRtcCng_GetErrorCodeEnc(CNG_enc_inst *cng_inst); -WebRtc_Word16 WebRtcCng_GetErrorCodeDec(CNG_dec_inst *cng_inst); - - -#ifdef __cplusplus -} -#endif - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_
diff --git a/src/modules/audio_coding/codecs/cng/test/CNG.cc b/src/modules/audio_coding/codecs/cng/test/CNG.cc deleted file mode 100644 index e3cabbb..0000000 --- a/src/modules/audio_coding/codecs/cng/test/CNG.cc +++ /dev/null
@@ -1,224 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * CNG.cpp : Defines the entry point for the console application. - */ - -#include <stdlib.h> -#include <string.h> -#include "stdafx.h" -#include "webrtc_cng.h" -#include "webrtc_vad.h" - -CNG_enc_inst *e_inst; -CNG_dec_inst *d_inst; - -VadInst *vinst; -//#define ASSIGN - -short anaSpeech[WEBRTC_CNG_MAX_OUTSIZE_ORDER], genSpeech[WEBRTC_CNG_MAX_OUTSIZE_ORDER], state[WEBRTC_CNG_MAX_OUTSIZE_ORDER]; -unsigned char SIDpkt[114]; - -int main(int argc, char* argv[]) -{ - FILE * infile, *outfile, *statefile; - short res=0,errtype; - /*float time=0.0;*/ - - WebRtcVad_Create(&vinst); - WebRtcVad_Init(vinst); - - short size; - int samps=0; - - if (argc < 5){ - printf("Usage:\n CNG.exe infile outfile samplingfreq(Hz) interval(ms) order\n\n"); - return(0); - } - - infile=fopen(argv[1],"rb"); - if (infile==NULL){ - printf("file %s does not exist\n",argv[1]); - return(0); - } - outfile=fopen(argv[2],"wb"); - statefile=fopen("CNGVAD.d","wb"); - if (outfile==NULL){ - printf("file %s could not be created\n",argv[2]); - return(0); - } - - unsigned int fs=16000; - short frameLen=fs/50; - -#ifndef ASSIGN - res=WebRtcCng_CreateEnc(&e_inst); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - res=WebRtcCng_CreateDec(&d_inst); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeDec(d_inst); - fprintf(stderr,"\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - -#else - - // Test the Assign-functions - int Esize, Dsize; - void *Eaddr, *Daddr; - - res=WebRtcCng_AssignSizeEnc(&Esize); - res=WebRtcCng_AssignSizeDec(&Dsize); - Eaddr=malloc(Esize); - Daddr=malloc(Dsize); - - res=WebRtcCng_AssignEnc(&e_inst, Eaddr); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - - res=WebRtcCng_AssignDec(&d_inst, Daddr); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeDec(d_inst); - fprintf(stderr,"\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - -#endif - - res=WebRtcCng_InitEnc(e_inst,atoi(argv[3]),atoi(argv[4]),atoi(argv[5])); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - - res=WebRtcCng_InitDec(d_inst); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeDec(d_inst); - fprintf(stderr,"\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - - static bool firstSilent=true; - - int numSamp=0; - int speech=0; - int silent=0; - long cnt=0; - - while(fread(anaSpeech,2,frameLen,infile)==frameLen){ - - cnt++; - if (cnt==60){ - cnt=60; - } - /* time+=(float)frameLen/fs; - numSamp+=frameLen; - float temp[640]; - for(unsigned int j=0;j<frameLen;j++) - temp[j]=(float)anaSpeech[j]; */ - - // if(!WebRtcVad_Process(vinst, fs, anaSpeech, frameLen)){ - - - if(1){ // Do CNG coding of entire file - - // if(!((anaSpeech[0]==0)&&(anaSpeech[1]==0)&&(anaSpeech[2]==0))){ - if(firstSilent){ - res = WebRtcCng_Encode(e_inst, anaSpeech, frameLen/2, SIDpkt,&size,1); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in encoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - - firstSilent=false; - - res=WebRtcCng_Encode(e_inst, &anaSpeech[frameLen/2], frameLen/2, SIDpkt,&size,1); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in encoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - - } - else{ - res=WebRtcCng_Encode(e_inst, anaSpeech, frameLen/2, SIDpkt,&size,0); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in encoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - res=WebRtcCng_Encode(e_inst, &anaSpeech[frameLen/2], frameLen/2, SIDpkt,&size,0); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeEnc(e_inst); - fprintf(stderr,"\n\n Error in encoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - } - - if(size>0){ - res=WebRtcCng_UpdateSid(d_inst,SIDpkt, size); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeDec(d_inst); - fprintf(stderr,"\n\n Error in decoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - } - res=WebRtcCng_Generate(d_inst,genSpeech, frameLen,0); - if (res < 0) { - /* exit if returned with error */ - errtype=WebRtcCng_GetErrorCodeDec(d_inst); - fprintf(stderr,"\n\n Error in decoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - memcpy(state,anaSpeech,2*frameLen); - } - else{ - firstSilent=true; - memcpy(genSpeech,anaSpeech,2*frameLen); - - memset(anaSpeech,0,frameLen*2); - memset(state,0,frameLen*2); - - } - if (fwrite(genSpeech, 2, frameLen, - outfile) != static_cast<size_t>(frameLen)) { - return -1; - } - if (fwrite(state, 2, frameLen, - statefile) != static_cast<size_t>(frameLen)) { - return -1; - } - } - fclose(infile); - fclose(outfile); - fclose(statefile); - return 0; -}
diff --git a/src/modules/audio_coding/codecs/cng/test/StdAfx.cc b/src/modules/audio_coding/codecs/cng/test/StdAfx.cc deleted file mode 100644 index 995e510..0000000 --- a/src/modules/audio_coding/codecs/cng/test/StdAfx.cc +++ /dev/null
@@ -1,18 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// stdafx.cpp : source file that includes just the standard includes -// CNG.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file
diff --git a/src/modules/audio_coding/codecs/cng/test/StdAfx.h b/src/modules/audio_coding/codecs/cng/test/StdAfx.h deleted file mode 100644 index dd6c445..0000000 --- a/src/modules/audio_coding/codecs/cng/test/StdAfx.h +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_TEST_STDAFX_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_TEST_STDAFX_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include <stdio.h> - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__DE2097A7_569B_42A0_A615_41BF352D6FFB__INCLUDED_)
diff --git a/src/modules/audio_coding/codecs/cng/webrtc_cng.c b/src/modules/audio_coding/codecs/cng/webrtc_cng.c deleted file mode 100644 index 6d95f11..0000000 --- a/src/modules/audio_coding/codecs/cng/webrtc_cng.c +++ /dev/null
@@ -1,732 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#include <string.h> -#include <stdlib.h> - -#include "webrtc_cng.h" -#include "signal_processing_library.h" -#include "cng_helpfuns.h" -#include "stdio.h" - - -typedef struct WebRtcCngDecInst_t_ { - - WebRtc_UWord32 dec_seed; - WebRtc_Word32 dec_target_energy; - WebRtc_Word32 dec_used_energy; - WebRtc_Word16 dec_target_reflCoefs[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 dec_used_reflCoefs[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 dec_filtstate[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 dec_filtstateLow[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 dec_Efiltstate[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 dec_EfiltstateLow[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 dec_order; - WebRtc_Word16 dec_target_scale_factor; /*Q29*/ - WebRtc_Word16 dec_used_scale_factor; /*Q29*/ - WebRtc_Word16 target_scale_factor; /* Q13 */ - WebRtc_Word16 errorcode; - WebRtc_Word16 initflag; - -} WebRtcCngDecInst_t; - - -typedef struct WebRtcCngEncInst_t_ { - - WebRtc_Word16 enc_nrOfCoefs; - WebRtc_Word16 enc_sampfreq; - WebRtc_Word16 enc_interval; - WebRtc_Word16 enc_msSinceSID; - WebRtc_Word32 enc_Energy; - WebRtc_Word16 enc_reflCoefs[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word32 enc_corrVector[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 enc_filtstate[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 enc_filtstateLow[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_UWord32 enc_seed; - WebRtc_Word16 errorcode; - WebRtc_Word16 initflag; - -} WebRtcCngEncInst_t; - -const WebRtc_Word32 WebRtcCng_kDbov[94]={ - 1081109975, 858756178, 682134279, 541838517, 430397633, 341876992, - 271562548, 215709799, 171344384, 136103682, 108110997, 85875618, - 68213428, 54183852, 43039763, 34187699, 27156255, 21570980, - 17134438, 13610368, 10811100, 8587562, 6821343, 5418385, - 4303976, 3418770, 2715625, 2157098, 1713444, 1361037, - 1081110, 858756, 682134, 541839, 430398, 341877, - 271563, 215710, 171344, 136104, 108111, 85876, - 68213, 54184, 43040, 34188, 27156, 21571, - 17134, 13610, 10811, 8588, 6821, 5418, - 4304, 3419, 2716, 2157, 1713, 1361, - 1081, 859, 682, 542, 430, 342, - 272, 216, 171, 136, 108, 86, - 68, 54, 43, 34, 27, 22, - 17, 14, 11, 9, 7, 5, - 4, 3, 3, 2, 2, 1, - 1, 1, 1, 1 -}; -const WebRtc_Word16 WebRtcCng_kCorrWindow[WEBRTC_CNG_MAX_LPC_ORDER] = { - 32702, 32636, 32570, 32505, 32439, 32374, - 32309, 32244, 32179, 32114, 32049, 31985 -}; - -/**************************************************************************** - * WebRtcCng_Version(...) - * - * These functions returns the version name (string must be at least - * 500 characters long) - * - * Output: - * - version : Pointer to character string - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_Version(char *version) -{ - strcpy((char*)version,(const char*)"1.2.0\n"); - return(0); -} - - -/**************************************************************************** - * WebRtcCng_AssignSizeEnc/Dec(...) - * - * These functions get the size needed for storing the instance for encoder - * and decoder, respectively - * - * Input/Output: - * - sizeinbytes : Pointer to integer where the size is returned - * - * Return value : 0 - */ - -WebRtc_Word16 WebRtcCng_AssignSizeEnc(int *sizeinbytes) -{ - *sizeinbytes=sizeof(WebRtcCngEncInst_t)*2/sizeof(WebRtc_Word16); - return(0); -} - -WebRtc_Word16 WebRtcCng_AssignSizeDec(int *sizeinbytes) -{ - *sizeinbytes=sizeof(WebRtcCngDecInst_t)*2/sizeof(WebRtc_Word16); - return(0); -} - - -/**************************************************************************** - * WebRtcCng_AssignEnc/Dec(...) - * - * These functions Assignes memory for the instances. - * - * Input: - * - CNG_inst_Addr : Adress to where to assign memory - * Output: - * - inst : Pointer to the instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_AssignEnc(CNG_enc_inst **inst, void *CNG_inst_Addr) -{ - if (CNG_inst_Addr!=NULL) { - *inst = (CNG_enc_inst*)CNG_inst_Addr; - (*(WebRtcCngEncInst_t**) inst)->errorcode = 0; - (*(WebRtcCngEncInst_t**) inst)->initflag = 0; - return(0); - } else { - /* The memory could not be allocated */ - return(-1); - } -} - -WebRtc_Word16 WebRtcCng_AssignDec(CNG_dec_inst **inst, void *CNG_inst_Addr) -{ - if (CNG_inst_Addr!=NULL) { - *inst = (CNG_dec_inst*)CNG_inst_Addr; - (*(WebRtcCngDecInst_t**) inst)->errorcode = 0; - (*(WebRtcCngDecInst_t**) inst)->initflag = 0; - return(0); - } else { - /* The memory could not be allocated */ - return(-1); - } -} - - -/**************************************************************************** - * WebRtcCng_CreateEnc/Dec(...) - * - * These functions create an instance to the specified structure - * - * Input: - * - XXX_inst : Pointer to created instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_CreateEnc(CNG_enc_inst **cng_inst) -{ - *cng_inst=(CNG_enc_inst*)malloc(sizeof(WebRtcCngEncInst_t)); - if(*cng_inst!=NULL) { - (*(WebRtcCngEncInst_t**) cng_inst)->errorcode = 0; - (*(WebRtcCngEncInst_t**) cng_inst)->initflag = 0; - return(0); - } - else { - /* The memory could not be allocated */ - return(-1); - } -} - -WebRtc_Word16 WebRtcCng_CreateDec(CNG_dec_inst **cng_inst) -{ - *cng_inst=(CNG_dec_inst*)malloc(sizeof(WebRtcCngDecInst_t)); - if(*cng_inst!=NULL) { - (*(WebRtcCngDecInst_t**) cng_inst)->errorcode = 0; - (*(WebRtcCngDecInst_t**) cng_inst)->initflag = 0; - return(0); - } - else { - /* The memory could not be allocated */ - return(-1); - } -} - - -/**************************************************************************** - * WebRtcCng_InitEnc/Dec(...) - * - * This function initializes a instance - * - * Input: - * - cng_inst : Instance that should be initialized - * - * - fs : 8000 for narrowband and 16000 for wideband - * - interval : generate SID data every interval ms - * - quality : TBD - * - * Output: - * - cng_inst : Initialized instance - * - * Return value : 0 - Ok - * -1 - Error - */ - - -WebRtc_Word16 WebRtcCng_InitEnc(CNG_enc_inst *cng_inst, - WebRtc_Word16 fs, - WebRtc_Word16 interval, - WebRtc_Word16 quality) -{ - int i; - - WebRtcCngEncInst_t* inst=(WebRtcCngEncInst_t*)cng_inst; - - memset(inst, 0, sizeof(WebRtcCngEncInst_t)); - - /* Check LPC order */ - - if (quality>WEBRTC_CNG_MAX_LPC_ORDER) { - inst->errorcode = CNG_DISALLOWED_LPC_ORDER; - return (-1); - } - - if (fs<=0) { - inst->errorcode = CNG_DISALLOWED_SAMPLING_FREQUENCY; - return (-1); - } - - inst->enc_sampfreq=fs; - inst->enc_interval=interval; - inst->enc_nrOfCoefs=quality; - inst->enc_msSinceSID=0; - inst->enc_seed=7777; /*For debugging only*/ - inst->enc_Energy=0; - for(i=0;i<(WEBRTC_CNG_MAX_LPC_ORDER+1);i++){ - inst->enc_reflCoefs[i]=0; - inst->enc_corrVector[i]=0; - } - inst->initflag=1; - - return(0); -} - -WebRtc_Word16 WebRtcCng_InitDec(CNG_dec_inst *cng_inst) -{ - int i; - - WebRtcCngDecInst_t* inst=(WebRtcCngDecInst_t*)cng_inst; - - memset(inst, 0, sizeof(WebRtcCngDecInst_t)); - inst->dec_seed=7777; /*For debugging only*/ - inst->dec_order=5; - inst->dec_target_scale_factor=0; - inst->dec_used_scale_factor=0; - for(i=0;i<(WEBRTC_CNG_MAX_LPC_ORDER+1);i++){ - inst->dec_filtstate[i]=0; - inst->dec_target_reflCoefs[i]=0; - inst->dec_used_reflCoefs[i]=0; - } - inst->dec_target_reflCoefs[0]=0; - inst->dec_used_reflCoefs[0]=0; - inst ->dec_used_energy=0; - inst->initflag=1; - - return(0); -} - -/**************************************************************************** - * WebRtcCng_FreeEnc/Dec(...) - * - * These functions frees the dynamic memory of a specified instance - * - * Input: - * - cng_inst : Pointer to created instance that should be freed - * - * Return value : 0 - Ok - * -1 - Error - */ - - -WebRtc_Word16 WebRtcCng_FreeEnc(CNG_enc_inst *cng_inst) -{ - free(cng_inst); - return(0); -} - -WebRtc_Word16 WebRtcCng_FreeDec(CNG_dec_inst *cng_inst) -{ - free(cng_inst); - return(0); -} - - - -/**************************************************************************** - * WebRtcCng_Encode(...) - * - * These functions analyzes background noise - * - * Input: - * - cng_inst : Pointer to created instance - * - speech : Signal (noise) to be analyzed - * - nrOfSamples : Size of speech vector - * - bytesOut : Nr of bytes to transmit, might be 0 - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcCng_Encode(CNG_enc_inst *cng_inst, - WebRtc_Word16 *speech, - WebRtc_Word16 nrOfSamples, - WebRtc_UWord8* SIDdata, - WebRtc_Word16* bytesOut, - WebRtc_Word16 forceSID) -{ - WebRtcCngEncInst_t* inst=(WebRtcCngEncInst_t*)cng_inst; - - WebRtc_Word16 arCoefs[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word32 corrVector[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 refCs[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 hanningW[WEBRTC_CNG_MAX_OUTSIZE_ORDER]; - WebRtc_Word16 ReflBeta=19661; /*0.6 in q15*/ - WebRtc_Word16 ReflBetaComp=13107; /*0.4 in q15*/ - WebRtc_Word32 outEnergy; - int outShifts; - int i, stab; - int acorrScale; - int index; - WebRtc_Word16 ind,factor; - WebRtc_Word32 *bptr, blo, bhi; - WebRtc_Word16 negate; - const WebRtc_Word16 *aptr; - - WebRtc_Word16 speechBuf[WEBRTC_CNG_MAX_OUTSIZE_ORDER]; - - - /* check if encoder initiated */ - if (inst->initflag != 1) { - inst->errorcode = CNG_ENCODER_NOT_INITIATED; - return (-1); - } - - - /* check framesize */ - if (nrOfSamples>WEBRTC_CNG_MAX_OUTSIZE_ORDER) { - inst->errorcode = CNG_DISALLOWED_FRAME_SIZE; - return (-1); - } - - - for(i=0;i<nrOfSamples;i++){ - speechBuf[i]=speech[i]; - } - - factor=nrOfSamples; - - /* Calculate energy and a coefficients */ - outEnergy =WebRtcSpl_Energy(speechBuf, nrOfSamples, &outShifts); - while(outShifts>0){ - if(outShifts>5){ /*We can only do 5 shifts without destroying accuracy in division factor*/ - outEnergy<<=(outShifts-5); - outShifts=5; - } - else{ - factor/=2; - outShifts--; - } - } - outEnergy=WebRtcSpl_DivW32W16(outEnergy,factor); - - if (outEnergy > 1){ - /* Create Hanning Window */ - WebRtcSpl_GetHanningWindow(hanningW, nrOfSamples/2); - for( i=0;i<(nrOfSamples/2);i++ ) - hanningW[nrOfSamples-i-1]=hanningW[i]; - - WebRtcSpl_ElementwiseVectorMult(speechBuf, hanningW, speechBuf, nrOfSamples, 14); - - WebRtcSpl_AutoCorrelation( speechBuf, nrOfSamples, inst->enc_nrOfCoefs, corrVector, &acorrScale ); - - if( *corrVector==0 ) - *corrVector = WEBRTC_SPL_WORD16_MAX; - - /* Adds the bandwidth expansion */ - aptr = WebRtcCng_kCorrWindow; - bptr = corrVector; - - // (zzz) lpc16_1 = 17+1+820+2+2 = 842 (ordo2=700) - for( ind=0; ind<inst->enc_nrOfCoefs; ind++ ) - { - // The below code multiplies the 16 b corrWindow values (Q15) with - // the 32 b corrvector (Q0) and shifts the result down 15 steps. - - negate = *bptr<0; - if( negate ) - *bptr = -*bptr; - - blo = (WebRtc_Word32)*aptr * (*bptr & 0xffff); - bhi = ((blo >> 16) & 0xffff) + ((WebRtc_Word32)(*aptr++) * ((*bptr >> 16) & 0xffff)); - blo = (blo & 0xffff) | ((bhi & 0xffff) << 16); - - *bptr = (( (bhi>>16) & 0x7fff) << 17) | ((WebRtc_UWord32)blo >> 15); - if( negate ) - *bptr = -*bptr; - bptr++; - } - - // end of bandwidth expansion - - stab=WebRtcSpl_LevinsonDurbin(corrVector, arCoefs, refCs, inst->enc_nrOfCoefs); - - if(!stab){ - // disregard from this frame - *bytesOut=0; - return(0); - } - - } - else { - for(i=0;i<inst->enc_nrOfCoefs; i++) - refCs[i]=0; - } - - if(forceSID){ - /*Read instantaneous values instead of averaged*/ - for(i=0;i<inst->enc_nrOfCoefs;i++) - inst->enc_reflCoefs[i]=refCs[i]; - inst->enc_Energy=outEnergy; - } - else{ - /*Average history with new values*/ - for(i=0;i<(inst->enc_nrOfCoefs);i++){ - inst->enc_reflCoefs[i]=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(inst->enc_reflCoefs[i],ReflBeta,15); - inst->enc_reflCoefs[i]+=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(refCs[i],ReflBetaComp,15); - } - inst->enc_Energy=(outEnergy>>2)+(inst->enc_Energy>>1)+(inst->enc_Energy>>2); - } - - - if(inst->enc_Energy<1){ - inst->enc_Energy=1; - } - - if((inst->enc_msSinceSID>(inst->enc_interval-1))||forceSID){ - - /* Search for best dbov value */ - index=0; - for(i=1;i<93;i++){ - /* Always round downwards */ - if((inst->enc_Energy-WebRtcCng_kDbov[i])>0){ - index=i; - break; - } - } - if((i==93)&&(index==0)) - index=94; - SIDdata[0]=index; - - - /* Quantize coefs with tweak for WebRtc implementation of RFC3389 */ - if(inst->enc_nrOfCoefs==WEBRTC_CNG_MAX_LPC_ORDER){ - for(i=0;i<inst->enc_nrOfCoefs;i++){ - SIDdata[i+1]=((inst->enc_reflCoefs[i]+128)>>8); /* Q15 to Q7*/ /* +127 */ - } - }else{ - for(i=0;i<inst->enc_nrOfCoefs;i++){ - SIDdata[i+1]=(127+((inst->enc_reflCoefs[i]+128)>>8)); /* Q15 to Q7*/ /* +127 */ - } - } - - inst->enc_msSinceSID=0; - *bytesOut=inst->enc_nrOfCoefs+1; - - inst->enc_msSinceSID+=(1000*nrOfSamples)/inst->enc_sampfreq; - return(inst->enc_nrOfCoefs+1); - }else{ - inst->enc_msSinceSID+=(1000*nrOfSamples)/inst->enc_sampfreq; - *bytesOut=0; - return(0); - } -} - - -/**************************************************************************** - * WebRtcCng_UpdateSid(...) - * - * These functions updates the CN state, when a new SID packet arrives - * - * Input: - * - cng_inst : Pointer to created instance that should be freed - * - SID : SID packet, all headers removed - * - length : Length in bytes of SID packet - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcCng_UpdateSid(CNG_dec_inst *cng_inst, - WebRtc_UWord8 *SID, - WebRtc_Word16 length) -{ - - WebRtcCngDecInst_t* inst=(WebRtcCngDecInst_t*)cng_inst; - WebRtc_Word16 refCs[WEBRTC_CNG_MAX_LPC_ORDER]; - WebRtc_Word32 targetEnergy; - int i; - - if (inst->initflag != 1) { - inst->errorcode = CNG_DECODER_NOT_INITIATED; - return (-1); - } - - /*Throw away reflection coefficients of higher order than we can handle*/ - if(length> (WEBRTC_CNG_MAX_LPC_ORDER+1)) - length=WEBRTC_CNG_MAX_LPC_ORDER+1; - - inst->dec_order=length-1; - - if(SID[0]>93) - SID[0]=93; - targetEnergy=WebRtcCng_kDbov[SID[0]]; - /* Take down target energy to 75% */ - targetEnergy=targetEnergy>>1; - targetEnergy+=targetEnergy>>2; - - inst->dec_target_energy=targetEnergy; - - /* Reconstruct coeffs with tweak for WebRtc implementation of RFC3389 */ - if(inst->dec_order==WEBRTC_CNG_MAX_LPC_ORDER){ - for(i=0;i<(inst->dec_order);i++){ - refCs[i]=SID[i+1]<<8; /* Q7 to Q15*/ - inst->dec_target_reflCoefs[i]=refCs[i]; - } - }else{ - for(i=0;i<(inst->dec_order);i++){ - refCs[i]=(SID[i+1]-127)<<8; /* Q7 to Q15*/ - inst->dec_target_reflCoefs[i]=refCs[i]; - } - } - - for(i=(inst->dec_order);i<WEBRTC_CNG_MAX_LPC_ORDER;i++){ - refCs[i]=0; - inst->dec_target_reflCoefs[i]=refCs[i]; - } - - return(0); -} - - -/**************************************************************************** - * WebRtcCng_Generate(...) - * - * These functions generates CN data when needed - * - * Input: - * - cng_inst : Pointer to created instance that should be freed - * - outData : pointer to area to write CN data - * - nrOfSamples : How much data to generate - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcCng_Generate(CNG_dec_inst *cng_inst, - WebRtc_Word16 *outData, - WebRtc_Word16 nrOfSamples, - WebRtc_Word16 new_period) -{ - WebRtcCngDecInst_t* inst=(WebRtcCngDecInst_t*)cng_inst; - - int i; - WebRtc_Word16 excitation[WEBRTC_CNG_MAX_OUTSIZE_ORDER]; - WebRtc_Word16 low[WEBRTC_CNG_MAX_OUTSIZE_ORDER]; - WebRtc_Word16 lpPoly[WEBRTC_CNG_MAX_LPC_ORDER+1]; - WebRtc_Word16 ReflBetaStd=26214; /*0.8 in q15*/ - WebRtc_Word16 ReflBetaCompStd=6553; /*0.2in q15*/ - WebRtc_Word16 ReflBetaNewP=19661; /*0.6 in q15*/ - WebRtc_Word16 ReflBetaCompNewP=13107; /*0.4 in q15*/ - WebRtc_Word16 Beta,BetaC, tmp1, tmp2, tmp3; - WebRtc_Word32 targetEnergy; - WebRtc_Word16 En; - WebRtc_Word16 temp16; - - if (nrOfSamples>WEBRTC_CNG_MAX_OUTSIZE_ORDER) { - inst->errorcode = CNG_DISALLOWED_FRAME_SIZE; - return (-1); - } - - - if (new_period) { - inst->dec_used_scale_factor=inst->dec_target_scale_factor; - Beta=ReflBetaNewP; - BetaC=ReflBetaCompNewP; - } else { - Beta=ReflBetaStd; - BetaC=ReflBetaCompStd; - } - - /*Here we use a 0.5 weighting, should possibly be modified to 0.6*/ - tmp1=inst->dec_used_scale_factor<<2; /* Q13->Q15 */ - tmp2=inst->dec_target_scale_factor<<2; /* Q13->Q15 */ - tmp3=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp1,Beta,15); - tmp3+=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp2,BetaC,15); - inst->dec_used_scale_factor=tmp3>>2; /* Q15->Q13 */ - - inst->dec_used_energy=inst->dec_used_energy>>1; - inst->dec_used_energy+=inst->dec_target_energy>>1; - - - /* Do the same for the reflection coeffs */ - for (i=0;i<WEBRTC_CNG_MAX_LPC_ORDER;i++) { - inst->dec_used_reflCoefs[i]=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(inst->dec_used_reflCoefs[i],Beta,15); - inst->dec_used_reflCoefs[i]+=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(inst->dec_target_reflCoefs[i],BetaC,15); - } - - /* Compute the polynomial coefficients */ - WebRtcCng_K2a16(inst->dec_used_reflCoefs, WEBRTC_CNG_MAX_LPC_ORDER, lpPoly); - - /***/ - - targetEnergy=inst->dec_used_energy; - - // Calculate scaling factor based on filter energy - En=8192; //1.0 in Q13 - for (i=0; i<(WEBRTC_CNG_MAX_LPC_ORDER); i++) { - - // Floating point value for reference - // E*=1.0-((float)inst->dec_used_reflCoefs[i]/32768.0)*((float)inst->dec_used_reflCoefs[i]/32768.0); - - // Same in fixed point - temp16=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(inst->dec_used_reflCoefs[i],inst->dec_used_reflCoefs[i],15); // K(i).^2 in Q15 - temp16=0x7fff - temp16; // 1 - K(i).^2 in Q15 - En=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(En,temp16,15); - - } - - //float scaling= sqrt(E*inst->dec_target_energy/((1<<24))); - - //Calculate sqrt(En*target_energy/exctiation energy) - - targetEnergy=WebRtcSpl_Sqrt(inst->dec_used_energy); - - En=(WebRtc_Word16)WebRtcSpl_Sqrt(En)<<6; //We are missing a factor sqrt(2) here - En=(En*3)>>1; //1.5 estimates sqrt(2) - - inst->dec_used_scale_factor=(WebRtc_Word16)((En*targetEnergy)>>12); - - - /***/ - - /*Generate excitation*/ - /*Excitation energy per sample is 2.^24 - Q13 N(0,1) */ - for(i=0;i<nrOfSamples;i++){ - excitation[i]=WebRtcSpl_RandN(&inst->dec_seed)>>1; - } - - /*Scale to correct energy*/ - WebRtcSpl_ScaleVector(excitation, excitation, inst->dec_used_scale_factor, nrOfSamples, 13); - - WebRtcSpl_FilterAR( - lpPoly, /* Coefficients in Q12 */ - WEBRTC_CNG_MAX_LPC_ORDER+1, - excitation, /* Speech samples */ - nrOfSamples, - inst->dec_filtstate, /* State preservation */ - WEBRTC_CNG_MAX_LPC_ORDER, - inst->dec_filtstateLow, /* State preservation */ - WEBRTC_CNG_MAX_LPC_ORDER, - outData, /* Filtered speech samples */ - low, - nrOfSamples - ); - - return(0); - -} - - - -/**************************************************************************** - * WebRtcCng_GetErrorCodeEnc/Dec(...) - * - * This functions can be used to check the error code of a CNG instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occured in the - * specified instance. - * - * Input: - * - CNG_inst : CNG enc/dec instance - * - * Return value : Error code - */ - -WebRtc_Word16 WebRtcCng_GetErrorCodeEnc(CNG_enc_inst *cng_inst) -{ - - /* typecast pointer to real structure */ - WebRtcCngEncInst_t* inst=(WebRtcCngEncInst_t*)cng_inst; - - return inst->errorcode; -} - -WebRtc_Word16 WebRtcCng_GetErrorCodeDec(CNG_dec_inst *cng_inst) -{ - - /* typecast pointer to real structure */ - WebRtcCngDecInst_t* inst=(WebRtcCngDecInst_t*)cng_inst; - - return inst->errorcode; -}
diff --git a/src/modules/audio_coding/codecs/g711/g711.c b/src/modules/audio_coding/codecs/g711/g711.c deleted file mode 100644 index 954f377..0000000 --- a/src/modules/audio_coding/codecs/g711/g711.c +++ /dev/null
@@ -1,83 +0,0 @@ -/* - * SpanDSP - a series of DSP components for telephony - * - * g711.c - A-law and u-law transcoding routines - * - * Written by Steve Underwood <steveu@coppice.org> - * - * Copyright (C) 2006 Steve Underwood - * - * Despite my general liking of the GPL, I place this code in the - * public domain for the benefit of all mankind - even the slimy - * ones who might try to proprietize my work and use it to my - * detriment. - * - * $Id: g711.c,v 1.1 2006/06/07 15:46:39 steveu Exp $ - * - * Modifications for WebRtc, 2011/04/28, by tlegrand: - * -Removed unused include files - * -Changed to use WebRtc types - * -Added option to run encoder bitexact with ITU-T reference implementation - */ - -/*! \file */ - -#include "g711.h" -#include "typedefs.h" - -/* Copied from the CCITT G.711 specification */ -static const WebRtc_UWord8 ulaw_to_alaw_table[256] = -{ - 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, - 58, 59, 56, 57, 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 26, - 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 106, - 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100, 101, 122, 120, - 126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117, 75, 73, 79, 77, - 66, 67, 64, 65, 70, 71, 68, 69, 90, 91, 88, 89, 94, 95, 92, 93, - 82, 82, 83, 83, 80, 80, 81, 81, 86, 86, 87, 87, 84, 84, 85, 85, - 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, - 186, 187, 184, 185, 190, 191, 188, 189, 178, 179, 176, 177, 182, 183, 180, 181, - 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 154, - 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, 234, - 232, 233, 238, 239, 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 248, - 254, 255, 252, 253, 242, 243, 240, 241, 246, 247, 244, 245, 203, 201, 207, 205, - 194, 195, 192, 193, 198, 199, 196, 197, 218, 219, 216, 217, 222, 223, 220, 221, - 210, 210, 211, 211, 208, 208, 209, 209, 214, 214, 215, 215, 212, 212, 213, 213 -}; - -/* These transcoding tables are copied from the CCITT G.711 specification. To achieve - optimal results, do not change them. */ - -static const WebRtc_UWord8 alaw_to_ulaw_table[256] = -{ - 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, - 57, 58, 55, 56, 61, 62, 59, 60, 49, 50, 47, 48, 53, 54, 51, 52, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5, - 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, - 98, 99, 96, 97, 102, 103, 100, 101, 93, 93, 92, 92, 95, 95, 94, 94, - 116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109, - 72, 73, 70, 71, 76, 77, 74, 75, 64, 65, 63, 63, 68, 69, 66, 67, - 86, 87, 84, 85, 90, 91, 88, 89, 79, 79, 78, 78, 82, 83, 80, 81, - 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, - 185, 186, 183, 184, 189, 190, 187, 188, 177, 178, 175, 176, 181, 182, 179, 180, - 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 133, - 154, 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, - 226, 227, 224, 225, 230, 231, 228, 229, 221, 221, 220, 220, 223, 223, 222, 222, - 244, 246, 240, 242, 252, 254, 248, 250, 234, 235, 232, 233, 238, 239, 236, 237, - 200, 201, 198, 199, 204, 205, 202, 203, 192, 193, 191, 191, 196, 197, 194, 195, - 214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209 -}; - -WebRtc_UWord8 alaw_to_ulaw(WebRtc_UWord8 alaw) -{ - return alaw_to_ulaw_table[alaw]; -} -/*- End of function --------------------------------------------------------*/ - -WebRtc_UWord8 ulaw_to_alaw(WebRtc_UWord8 ulaw) -{ - return ulaw_to_alaw_table[ulaw]; -} -/*- End of function --------------------------------------------------------*/ -/*- End of file ------------------------------------------------------------*/
diff --git a/src/modules/audio_coding/codecs/g711/g711.gypi b/src/modules/audio_coding/codecs/g711/g711.gypi deleted file mode 100644 index 66aa17a..0000000 --- a/src/modules/audio_coding/codecs/g711/g711.gypi +++ /dev/null
@@ -1,64 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'G711', - 'type': '<(library)', - 'include_dirs': [ - 'include', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - ], - }, - 'sources': [ - 'include/g711_interface.h', - 'g711_interface.c', - 'g711.c', - 'g711.h', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'g711_unittests', - 'type': 'executable', - 'dependencies': [ - 'G711', - '<(webrtc_root)/test/test.gyp:test_support_main', - '<(DEPTH)/testing/gtest.gyp:gtest', - ], - 'sources': [ - 'g711_unittest.cc', - ], - }, - { - 'target_name': 'g711_test', - 'type': 'executable', - 'dependencies': [ - 'G711', - ], - 'sources': [ - 'test/testG711.cc', - ], - }, - ], # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/modules/audio_coding/codecs/g711/g711.h b/src/modules/audio_coding/codecs/g711/g711.h deleted file mode 100644 index cd5e3d7..0000000 --- a/src/modules/audio_coding/codecs/g711/g711.h +++ /dev/null
@@ -1,382 +0,0 @@ -/* - * SpanDSP - a series of DSP components for telephony - * - * g711.h - In line A-law and u-law conversion routines - * - * Written by Steve Underwood <steveu@coppice.org> - * - * Copyright (C) 2001 Steve Underwood - * - * Despite my general liking of the GPL, I place this code in the - * public domain for the benefit of all mankind - even the slimy - * ones who might try to proprietize my work and use it to my - * detriment. - * - * $Id: g711.h,v 1.1 2006/06/07 15:46:39 steveu Exp $ - * - * Modifications for WebRtc, 2011/04/28, by tlegrand: - * -Changed to use WebRtc types - * -Changed __inline__ to __inline - * -Two changes to make implementation bitexact with ITU-T reference implementation - */ - -/*! \file */ - -/*! \page g711_page A-law and mu-law handling -Lookup tables for A-law and u-law look attractive, until you consider the impact -on the CPU cache. If it causes a substantial area of your processor cache to get -hit too often, cache sloshing will severely slow things down. The main reason -these routines are slow in C, is the lack of direct access to the CPU's "find -the first 1" instruction. A little in-line assembler fixes that, and the -conversion routines can be faster than lookup tables, in most real world usage. -A "find the first 1" instruction is available on most modern CPUs, and is a -much underused feature. - -If an assembly language method of bit searching is not available, these routines -revert to a method that can be a little slow, so the cache thrashing might not -seem so bad :( - -Feel free to submit patches to add fast "find the first 1" support for your own -favourite processor. - -Look up tables are used for transcoding between A-law and u-law, since it is -difficult to achieve the precise transcoding procedure laid down in the G.711 -specification by other means. -*/ - -#if !defined(_G711_H_) -#define _G711_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "typedefs.h" - -#if defined(__i386__) -/*! \brief Find the bit position of the highest set bit in a word - \param bits The word to be searched - \return The bit number of the highest set bit, or -1 if the word is zero. */ -static __inline__ int top_bit(unsigned int bits) -{ - int res; - - __asm__ __volatile__(" movl $-1,%%edx;\n" - " bsrl %%eax,%%edx;\n" - : "=d" (res) - : "a" (bits)); - return res; -} -/*- End of function --------------------------------------------------------*/ - -/*! \brief Find the bit position of the lowest set bit in a word - \param bits The word to be searched - \return The bit number of the lowest set bit, or -1 if the word is zero. */ -static __inline__ int bottom_bit(unsigned int bits) -{ - int res; - - __asm__ __volatile__(" movl $-1,%%edx;\n" - " bsfl %%eax,%%edx;\n" - : "=d" (res) - : "a" (bits)); - return res; -} -/*- End of function --------------------------------------------------------*/ -#elif defined(__x86_64__) -static __inline__ int top_bit(unsigned int bits) -{ - int res; - - __asm__ __volatile__(" movq $-1,%%rdx;\n" - " bsrq %%rax,%%rdx;\n" - : "=d" (res) - : "a" (bits)); - return res; -} -/*- End of function --------------------------------------------------------*/ - -static __inline__ int bottom_bit(unsigned int bits) -{ - int res; - - __asm__ __volatile__(" movq $-1,%%rdx;\n" - " bsfq %%rax,%%rdx;\n" - : "=d" (res) - : "a" (bits)); - return res; -} -/*- End of function --------------------------------------------------------*/ -#else -static __inline int top_bit(unsigned int bits) -{ - int i; - - if (bits == 0) - return -1; - i = 0; - if (bits & 0xFFFF0000) - { - bits &= 0xFFFF0000; - i += 16; - } - if (bits & 0xFF00FF00) - { - bits &= 0xFF00FF00; - i += 8; - } - if (bits & 0xF0F0F0F0) - { - bits &= 0xF0F0F0F0; - i += 4; - } - if (bits & 0xCCCCCCCC) - { - bits &= 0xCCCCCCCC; - i += 2; - } - if (bits & 0xAAAAAAAA) - { - bits &= 0xAAAAAAAA; - i += 1; - } - return i; -} -/*- End of function --------------------------------------------------------*/ - -static __inline int bottom_bit(unsigned int bits) -{ - int i; - - if (bits == 0) - return -1; - i = 32; - if (bits & 0x0000FFFF) - { - bits &= 0x0000FFFF; - i -= 16; - } - if (bits & 0x00FF00FF) - { - bits &= 0x00FF00FF; - i -= 8; - } - if (bits & 0x0F0F0F0F) - { - bits &= 0x0F0F0F0F; - i -= 4; - } - if (bits & 0x33333333) - { - bits &= 0x33333333; - i -= 2; - } - if (bits & 0x55555555) - { - bits &= 0x55555555; - i -= 1; - } - return i; -} -/*- End of function --------------------------------------------------------*/ -#endif - -/* N.B. It is tempting to use look-up tables for A-law and u-law conversion. - * However, you should consider the cache footprint. - * - * A 64K byte table for linear to x-law and a 512 byte table for x-law to - * linear sound like peanuts these days, and shouldn't an array lookup be - * real fast? No! When the cache sloshes as badly as this one will, a tight - * calculation may be better. The messiest part is normally finding the - * segment, but a little inline assembly can fix that on an i386, x86_64 and - * many other modern processors. - */ - -/* - * Mu-law is basically as follows: - * - * Biased Linear Input Code Compressed Code - * ------------------------ --------------- - * 00000001wxyza 000wxyz - * 0000001wxyzab 001wxyz - * 000001wxyzabc 010wxyz - * 00001wxyzabcd 011wxyz - * 0001wxyzabcde 100wxyz - * 001wxyzabcdef 101wxyz - * 01wxyzabcdefg 110wxyz - * 1wxyzabcdefgh 111wxyz - * - * Each biased linear code has a leading 1 which identifies the segment - * number. The value of the segment number is equal to 7 minus the number - * of leading 0's. The quantization interval is directly available as the - * four bits wxyz. * The trailing bits (a - h) are ignored. - * - * Ordinarily the complement of the resulting code word is used for - * transmission, and so the code word is complemented before it is returned. - * - * For further information see John C. Bellamy's Digital Telephony, 1982, - * John Wiley & Sons, pps 98-111 and 472-476. - */ - -//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */ -#define ULAW_BIAS 0x84 /* Bias for linear code. */ - -/*! \brief Encode a linear sample to u-law - \param linear The sample to encode. - \return The u-law value. -*/ -static __inline WebRtc_UWord8 linear_to_ulaw(int linear) -{ - WebRtc_UWord8 u_val; - int mask; - int seg; - - /* Get the sign and the magnitude of the value. */ - if (linear < 0) - { - /* WebRtc, tlegrand: -1 added to get bitexact to reference implementation */ - linear = ULAW_BIAS - linear - 1; - mask = 0x7F; - } - else - { - linear = ULAW_BIAS + linear; - mask = 0xFF; - } - - seg = top_bit(linear | 0xFF) - 7; - - /* - * Combine the sign, segment, quantization bits, - * and complement the code word. - */ - if (seg >= 8) - u_val = (WebRtc_UWord8) (0x7F ^ mask); - else - u_val = (WebRtc_UWord8) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask); -#ifdef ULAW_ZEROTRAP - /* Optional ITU trap */ - if (u_val == 0) - u_val = 0x02; -#endif - return u_val; -} -/*- End of function --------------------------------------------------------*/ - -/*! \brief Decode an u-law sample to a linear value. - \param ulaw The u-law sample to decode. - \return The linear value. -*/ -static __inline WebRtc_Word16 ulaw_to_linear(WebRtc_UWord8 ulaw) -{ - int t; - - /* Complement to obtain normal u-law value. */ - ulaw = ~ulaw; - /* - * Extract and bias the quantization bits. Then - * shift up by the segment number and subtract out the bias. - */ - t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4); - return (WebRtc_Word16) ((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS)); -} -/*- End of function --------------------------------------------------------*/ - -/* - * A-law is basically as follows: - * - * Linear Input Code Compressed Code - * ----------------- --------------- - * 0000000wxyza 000wxyz - * 0000001wxyza 001wxyz - * 000001wxyzab 010wxyz - * 00001wxyzabc 011wxyz - * 0001wxyzabcd 100wxyz - * 001wxyzabcde 101wxyz - * 01wxyzabcdef 110wxyz - * 1wxyzabcdefg 111wxyz - * - * For further information see John C. Bellamy's Digital Telephony, 1982, - * John Wiley & Sons, pps 98-111 and 472-476. - */ - -#define ALAW_AMI_MASK 0x55 - -/*! \brief Encode a linear sample to A-law - \param linear The sample to encode. - \return The A-law value. -*/ -static __inline WebRtc_UWord8 linear_to_alaw(int linear) -{ - int mask; - int seg; - - if (linear >= 0) - { - /* Sign (bit 7) bit = 1 */ - mask = ALAW_AMI_MASK | 0x80; - } - else - { - /* Sign (bit 7) bit = 0 */ - mask = ALAW_AMI_MASK; - /* WebRtc, tlegrand: Changed from -8 to -1 to get bitexact to reference - * implementation */ - linear = -linear - 1; - } - - /* Convert the scaled magnitude to segment number. */ - seg = top_bit(linear | 0xFF) - 7; - if (seg >= 8) - { - if (linear >= 0) - { - /* Out of range. Return maximum value. */ - return (WebRtc_UWord8) (0x7F ^ mask); - } - /* We must be just a tiny step below zero */ - return (WebRtc_UWord8) (0x00 ^ mask); - } - /* Combine the sign, segment, and quantization bits. */ - return (WebRtc_UWord8) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask); -} -/*- End of function --------------------------------------------------------*/ - -/*! \brief Decode an A-law sample to a linear value. - \param alaw The A-law sample to decode. - \return The linear value. -*/ -static __inline WebRtc_Word16 alaw_to_linear(WebRtc_UWord8 alaw) -{ - int i; - int seg; - - alaw ^= ALAW_AMI_MASK; - i = ((alaw & 0x0F) << 4); - seg = (((int) alaw & 0x70) >> 4); - if (seg) - i = (i + 0x108) << (seg - 1); - else - i += 8; - return (WebRtc_Word16) ((alaw & 0x80) ? i : -i); -} -/*- End of function --------------------------------------------------------*/ - -/*! \brief Transcode from A-law to u-law, using the procedure defined in G.711. - \param alaw The A-law sample to transcode. - \return The best matching u-law value. -*/ -WebRtc_UWord8 alaw_to_ulaw(WebRtc_UWord8 alaw); - -/*! \brief Transcode from u-law to A-law, using the procedure defined in G.711. - \param alaw The u-law sample to transcode. - \return The best matching A-law value. -*/ -WebRtc_UWord8 ulaw_to_alaw(WebRtc_UWord8 ulaw); - -#ifdef __cplusplus -} -#endif - -#endif -/*- End of file ------------------------------------------------------------*/
diff --git a/src/modules/audio_coding/codecs/g711/g711_interface.c b/src/modules/audio_coding/codecs/g711/g711_interface.c deleted file mode 100644 index a49abdb..0000000 --- a/src/modules/audio_coding/codecs/g711/g711_interface.c +++ /dev/null
@@ -1,171 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include <string.h> -#include "g711.h" -#include "g711_interface.h" -#include "typedefs.h" - -WebRtc_Word16 WebRtcG711_EncodeA(void *state, - WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded) -{ - int n; - WebRtc_UWord16 tempVal, tempVal2; - - // Set and discard to avoid getting warnings - (void)(state = NULL); - - // Sanity check of input length - if (len < 0) { - return (-1); - } - - // Loop over all samples - for (n = 0; n < len; n++) { - tempVal = (WebRtc_UWord16)linear_to_alaw(speechIn[n]); - -#ifdef WEBRTC_BIG_ENDIAN - if ((n & 0x1) == 1) { - encoded[n>>1]|=((WebRtc_UWord16)tempVal); - } else { - encoded[n>>1]=((WebRtc_UWord16)tempVal)<<8; - } -#else - if ((n & 0x1) == 1) { - tempVal2 |= ((WebRtc_UWord16) tempVal) << 8; - encoded[n >> 1] |= ((WebRtc_UWord16) tempVal) << 8; - } else { - tempVal2 = ((WebRtc_UWord16) tempVal); - encoded[n >> 1] = ((WebRtc_UWord16) tempVal); - } -#endif - } - return (len); -} - -WebRtc_Word16 WebRtcG711_EncodeU(void *state, - WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded) -{ - int n; - WebRtc_UWord16 tempVal; - - // Set and discard to avoid getting warnings - (void)(state = NULL); - - // Sanity check of input length - if (len < 0) { - return (-1); - } - - // Loop over all samples - for (n = 0; n < len; n++) { - tempVal = (WebRtc_UWord16)linear_to_ulaw(speechIn[n]); - - #ifdef WEBRTC_BIG_ENDIAN - if ((n & 0x1) == 1) { - encoded[n>>1]|=((WebRtc_UWord16)tempVal); - } else { - encoded[n>>1]=((WebRtc_UWord16)tempVal)<<8; - } - #else - if ((n & 0x1) == 1) { - encoded[n >> 1] |= ((WebRtc_UWord16) tempVal) << 8; - } else { - encoded[n >> 1] = ((WebRtc_UWord16) tempVal); - } - #endif - } - return (len); -} - -WebRtc_Word16 WebRtcG711_DecodeA(void *state, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - int n; - WebRtc_UWord16 tempVal; - - // Set and discard to avoid getting warnings - (void)(state = NULL); - - // Sanity check of input length - if (len < 0) { - return (-1); - } - - for (n = 0; n < len; n++) { - #ifdef WEBRTC_BIG_ENDIAN - if ((n & 0x1) == 1) { - tempVal=((WebRtc_UWord16)encoded[n>>1] & 0xFF); - } else { - tempVal=((WebRtc_UWord16)encoded[n>>1] >> 8); - } - #else - if ((n & 0x1) == 1) { - tempVal = (encoded[n >> 1] >> 8); - } else { - tempVal = (encoded[n >> 1] & 0xFF); - } - #endif - decoded[n] = (WebRtc_Word16) alaw_to_linear(tempVal); - } - - *speechType = 1; - return (len); -} - -WebRtc_Word16 WebRtcG711_DecodeU(void *state, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - int n; - WebRtc_UWord16 tempVal; - - // Set and discard to avoid getting warnings - (void)(state = NULL); - - // Sanity check of input length - if (len < 0) { - return (-1); - } - - for (n = 0; n < len; n++) { - #ifdef WEBRTC_BIG_ENDIAN - if ((n & 0x1) == 1) { - tempVal=((WebRtc_UWord16)encoded[n>>1] & 0xFF); - } else { - tempVal=((WebRtc_UWord16)encoded[n>>1] >> 8); - } - #else - if ((n & 0x1) == 1) { - tempVal = (encoded[n >> 1] >> 8); - } else { - tempVal = (encoded[n >> 1] & 0xFF); - } - #endif - decoded[n] = (WebRtc_Word16) ulaw_to_linear(tempVal); - } - - *speechType = 1; - return (len); -} - -WebRtc_Word16 WebRtcG711_Version(char* version, WebRtc_Word16 lenBytes) -{ - strncpy(version, "2.0.0", lenBytes); - return 0; -}
diff --git a/src/modules/audio_coding/codecs/g711/g711_unittest.cc b/src/modules/audio_coding/codecs/g711/g711_unittest.cc deleted file mode 100644 index c903bed..0000000 --- a/src/modules/audio_coding/codecs/g711/g711_unittest.cc +++ /dev/null
@@ -1,17 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * Empty test just to get code coverage metrics for this dir. - */ -#include "g711_interface.h" -#include "gtest/gtest.h" - -TEST(G711Test, EmptyTestToGetCodeCoverage) {}
diff --git a/src/modules/audio_coding/codecs/g711/include/g711_interface.h b/src/modules/audio_coding/codecs/g711/include/g711_interface.h deleted file mode 100644 index 25a9903..0000000 --- a/src/modules/audio_coding/codecs/g711/include/g711_interface.h +++ /dev/null
@@ -1,148 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_CODING_CODECS_G711_MAIN_INTERFACE_G711_INTERFACE_H_ -#define MODULES_AUDIO_CODING_CODECS_G711_MAIN_INTERFACE_G711_INTERFACE_H_ - -#include "typedefs.h" - -// Comfort noise constants -#define G711_WEBRTC_SPEECH 1 -#define G711_WEBRTC_CNG 2 - -#ifdef __cplusplus -extern "C" { -#endif - -/**************************************************************************** - * WebRtcG711_EncodeA(...) - * - * This function encodes a G711 A-law frame and inserts it into a packet. - * Input speech length has be of any length. - * - * Input: - * - state : Dummy state to make this codec look more like - * other codecs - * - speechIn : Input speech vector - * - len : Samples in speechIn - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - -WebRtc_Word16 WebRtcG711_EncodeA(void *state, - WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded); - -/**************************************************************************** - * WebRtcG711_EncodeU(...) - * - * This function encodes a G711 U-law frame and inserts it into a packet. - * Input speech length has be of any length. - * - * Input: - * - state : Dummy state to make this codec look more like - * other codecs - * - speechIn : Input speech vector - * - len : Samples in speechIn - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - -WebRtc_Word16 WebRtcG711_EncodeU(void *state, - WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded); - -/**************************************************************************** - * WebRtcG711_DecodeA(...) - * - * This function decodes a packet G711 A-law frame. - * - * Input: - * - state : Dummy state to make this codec look more like - * other codecs - * - encoded : Encoded data - * - len : Bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - speechType : 1 normal, 2 CNG (for G711 it should - * always return 1 since G711 does not have a - * built-in DTX/CNG scheme) - * - * Return value : >0 - Samples in decoded vector - * -1 - Error - */ - -WebRtc_Word16 WebRtcG711_DecodeA(void *state, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - -/**************************************************************************** - * WebRtcG711_DecodeU(...) - * - * This function decodes a packet G711 U-law frame. - * - * Input: - * - state : Dummy state to make this codec look more like - * other codecs - * - encoded : Encoded data - * - len : Bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - speechType : 1 normal, 2 CNG (for G711 it should - * always return 1 since G711 does not have a - * built-in DTX/CNG scheme) - * - * Return value : >0 - Samples in decoded vector - * -1 - Error - */ - -WebRtc_Word16 WebRtcG711_DecodeU(void *state, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - -/********************************************************************** -* WebRtcG711_Version(...) -* -* This function gives the version string of the G.711 codec. -* -* Input: -* - lenBytes: the size of Allocated space (in Bytes) where -* the version number is written to (in string format). -* -* Output: -* - version: Pointer to a buffer where the version number is -* written to. -* -*/ - -WebRtc_Word16 WebRtcG711_Version(char* version, WebRtc_Word16 lenBytes); - -#ifdef __cplusplus -} -#endif - - -#endif /* MODULES_AUDIO_CODING_CODECS_G711_MAIN_INTERFACE_G711_INTERFACE_H_ */
diff --git a/src/modules/audio_coding/codecs/g711/test/testG711.cc b/src/modules/audio_coding/codecs/g711/test/testG711.cc deleted file mode 100644 index fd54522..0000000 --- a/src/modules/audio_coding/codecs/g711/test/testG711.cc +++ /dev/null
@@ -1,178 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * testG711.cpp : Defines the entry point for the console application. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -/* include API */ -#include "g711_interface.h" - -/* Runtime statistics */ -#include <time.h> -#define CLOCKS_PER_SEC_G711 1000 - - -/* function for reading audio data from PCM file */ -int readframe(WebRtc_Word16 *data, FILE *inp, int length) { - - short k, rlen, status = 0; - - rlen = (short)fread(data, sizeof(WebRtc_Word16), length, inp); - if (rlen < length) { - for (k = rlen; k < length; k++) - data[k] = 0; - status = 1; - } - - return status; -} - -int main(int argc, char* argv[]) -{ - char inname[80], outname[40], bitname[40]; - FILE *inp, *outp, *bitp = NULL; - int framecnt, endfile; - - WebRtc_Word16 framelength = 80; - - int err; - - /* Runtime statistics */ - double starttime; - double runtime; - double length_file; - - WebRtc_Word16 stream_len = 0; - WebRtc_Word16 shortdata[480]; - WebRtc_Word16 decoded[480]; - WebRtc_Word16 streamdata[500]; - WebRtc_Word16 speechType[1]; - char law[2]; - char versionNumber[40]; - - /* handling wrong input arguments in the command line */ - if ((argc!=5) && (argc!=6)) { - printf("\n\nWrong number of arguments or flag values.\n\n"); - - printf("\n"); - printf("\nG.711 test application\n\n"); - printf("Usage:\n\n"); - printf("./testG711.exe framelength law infile outfile \n\n"); - printf("framelength: Framelength in samples.\n"); - printf("law : Coding law, A och u.\n"); - printf("infile : Normal speech input file\n"); - printf("outfile : Speech output file\n\n"); - printf("outbits : Output bitstream file [optional]\n\n"); - exit(0); - - } - - /* Get version and print */ - WebRtcG711_Version(versionNumber, 40); - - printf("-----------------------------------\n"); - printf("G.711 version: %s\n\n", versionNumber); - /* Get frame length */ - framelength = atoi(argv[1]); - - /* Get compression law */ - strcpy(law, argv[2]); - - /* Get Input and Output files */ - sscanf(argv[3], "%s", inname); - sscanf(argv[4], "%s", outname); - if (argc==6) { - sscanf(argv[5], "%s", bitname); - if ((bitp = fopen(bitname,"wb")) == NULL) { - printf(" G.711: Cannot read file %s.\n", bitname); - exit(1); - } - } - - if ((inp = fopen(inname,"rb")) == NULL) { - printf(" G.711: Cannot read file %s.\n", inname); - exit(1); - } - if ((outp = fopen(outname,"wb")) == NULL) { - printf(" G.711: Cannot write file %s.\n", outname); - exit(1); - } - printf("\nInput: %s\nOutput: %s\n", inname, outname); - if (argc==6) { - printf("\nBitfile: %s\n", bitname); - } - - starttime = clock()/(double)CLOCKS_PER_SEC_G711; /* Runtime statistics */ - - /* Initialize encoder and decoder */ - framecnt= 0; - endfile = 0; - while (endfile == 0) { - framecnt++; - /* Read speech block */ - endfile = readframe(shortdata, inp, framelength); - - /* G.711 encoding */ - if (!strcmp(law,"A")) { - /* A-law encoding */ - stream_len = WebRtcG711_EncodeA(NULL, shortdata, framelength, streamdata); - if (argc==6){ - /* Write bits to file */ - if (fwrite(streamdata, sizeof(unsigned char), stream_len, - bitp) != static_cast<size_t>(stream_len)) { - return -1; - } - } - err = WebRtcG711_DecodeA(NULL, streamdata, stream_len, decoded, speechType); - } else if (!strcmp(law,"u")){ - /* u-law encoding */ - stream_len = WebRtcG711_EncodeU(NULL, shortdata, framelength, streamdata); - if (argc==6){ - /* Write bits to file */ - if (fwrite(streamdata, sizeof(unsigned char), stream_len, - bitp) != static_cast<size_t>(stream_len)) { - return -1; - } - } - err = WebRtcG711_DecodeU(NULL, streamdata, stream_len, decoded, speechType); - } else { - printf("Wrong law mode\n"); - exit (1); - } - if (stream_len < 0 || err < 0) { - /* exit if returned with error */ - printf("Error in encoder/decoder\n"); - } else { - /* Write coded speech to file */ - if (fwrite(decoded, sizeof(short), framelength, - outp) != static_cast<size_t>(framelength)) { - return -1; - } - } - } - - - runtime = (double)(clock()/(double)CLOCKS_PER_SEC_G711-starttime); - length_file = ((double)framecnt*(double)framelength/8000); - printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file)); - printf("---------------------END----------------------\n"); - - fclose(inp); - fclose(outp); - - - return 0; -}
diff --git a/src/modules/audio_coding/codecs/g722/g722.gypi b/src/modules/audio_coding/codecs/g722/g722.gypi deleted file mode 100644 index 311b5a0..0000000 --- a/src/modules/audio_coding/codecs/g722/g722.gypi +++ /dev/null
@@ -1,64 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -{ - 'targets': [ - { - 'target_name': 'G722', - 'type': '<(library)', - 'include_dirs': [ - 'include', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - ], - }, - 'sources': [ - 'include/g722_interface.h', - 'g722_interface.c', - 'g722_encode.c', - 'g722_decode.c', - 'g722_enc_dec.h', - ], - }, - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'g722_unittests', - 'type': 'executable', - 'dependencies': [ - 'G722', - '<(webrtc_root)/test/test.gyp:test_support_main', - '<(DEPTH)/testing/gtest.gyp:gtest', - ], - 'sources': [ - 'g722_unittest.cc', - ], - }, - { - 'target_name': 'G722Test', - 'type': 'executable', - 'dependencies': [ - 'G722', - ], - 'sources': [ - 'test/testG722.cc', - ], - }, - ], # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/modules/audio_coding/codecs/g722/g722_decode.c b/src/modules/audio_coding/codecs/g722/g722_decode.c deleted file mode 100644 index 499cc8f..0000000 --- a/src/modules/audio_coding/codecs/g722/g722_decode.c +++ /dev/null
@@ -1,410 +0,0 @@ -/* - * SpanDSP - a series of DSP components for telephony - * - * g722_decode.c - The ITU G.722 codec, decode part. - * - * Written by Steve Underwood <steveu@coppice.org> - * - * Copyright (C) 2005 Steve Underwood - * - * Despite my general liking of the GPL, I place my own contributions - * to this code in the public domain for the benefit of all mankind - - * even the slimy ones who might try to proprietize my work and use it - * to my detriment. - * - * Based in part on a single channel G.722 codec which is: - * - * Copyright (c) CMU 1993 - * Computer Science, Speech Group - * Chengxiang Lu and Alex Hauptmann - * - * $Id: g722_decode.c,v 1.15 2006/07/07 16:37:49 steveu Exp $ - * - * Modifications for WebRtc, 2011/04/28, by tlegrand: - * -Removed usage of inttypes.h and tgmath.h - * -Changed to use WebRtc types - * -Changed __inline__ to __inline - * -Added saturation check on output - */ - -/*! \file */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <memory.h> -#include <stdlib.h> - -#include "typedefs.h" -#include "g722_enc_dec.h" - - -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - -static __inline WebRtc_Word16 saturate(WebRtc_Word32 amp) -{ - WebRtc_Word16 amp16; - - /* Hopefully this is optimised for the common case - not clipping */ - amp16 = (WebRtc_Word16) amp; - if (amp == amp16) - return amp16; - if (amp > WEBRTC_INT16_MAX) - return WEBRTC_INT16_MAX; - return WEBRTC_INT16_MIN; -} -/*- End of function --------------------------------------------------------*/ - -static void block4(g722_decode_state_t *s, int band, int d); - -static void block4(g722_decode_state_t *s, int band, int d) -{ - int wd1; - int wd2; - int wd3; - int i; - - /* Block 4, RECONS */ - s->band[band].d[0] = d; - s->band[band].r[0] = saturate(s->band[band].s + d); - - /* Block 4, PARREC */ - s->band[band].p[0] = saturate(s->band[band].sz + d); - - /* Block 4, UPPOL2 */ - for (i = 0; i < 3; i++) - s->band[band].sg[i] = s->band[band].p[i] >> 15; - wd1 = saturate(s->band[band].a[1] << 2); - - wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1; - if (wd2 > 32767) - wd2 = 32767; - wd3 = (s->band[band].sg[0] == s->band[band].sg[2]) ? 128 : -128; - wd3 += (wd2 >> 7); - wd3 += (s->band[band].a[2]*32512) >> 15; - if (wd3 > 12288) - wd3 = 12288; - else if (wd3 < -12288) - wd3 = -12288; - s->band[band].ap[2] = wd3; - - /* Block 4, UPPOL1 */ - s->band[band].sg[0] = s->band[band].p[0] >> 15; - s->band[band].sg[1] = s->band[band].p[1] >> 15; - wd1 = (s->band[band].sg[0] == s->band[band].sg[1]) ? 192 : -192; - wd2 = (s->band[band].a[1]*32640) >> 15; - - s->band[band].ap[1] = saturate(wd1 + wd2); - wd3 = saturate(15360 - s->band[band].ap[2]); - if (s->band[band].ap[1] > wd3) - s->band[band].ap[1] = wd3; - else if (s->band[band].ap[1] < -wd3) - s->band[band].ap[1] = -wd3; - - /* Block 4, UPZERO */ - wd1 = (d == 0) ? 0 : 128; - s->band[band].sg[0] = d >> 15; - for (i = 1; i < 7; i++) - { - s->band[band].sg[i] = s->band[band].d[i] >> 15; - wd2 = (s->band[band].sg[i] == s->band[band].sg[0]) ? wd1 : -wd1; - wd3 = (s->band[band].b[i]*32640) >> 15; - s->band[band].bp[i] = saturate(wd2 + wd3); - } - - /* Block 4, DELAYA */ - for (i = 6; i > 0; i--) - { - s->band[band].d[i] = s->band[band].d[i - 1]; - s->band[band].b[i] = s->band[band].bp[i]; - } - - for (i = 2; i > 0; i--) - { - s->band[band].r[i] = s->band[band].r[i - 1]; - s->band[band].p[i] = s->band[band].p[i - 1]; - s->band[band].a[i] = s->band[band].ap[i]; - } - - /* Block 4, FILTEP */ - wd1 = saturate(s->band[band].r[1] + s->band[band].r[1]); - wd1 = (s->band[band].a[1]*wd1) >> 15; - wd2 = saturate(s->band[band].r[2] + s->band[band].r[2]); - wd2 = (s->band[band].a[2]*wd2) >> 15; - s->band[band].sp = saturate(wd1 + wd2); - - /* Block 4, FILTEZ */ - s->band[band].sz = 0; - for (i = 6; i > 0; i--) - { - wd1 = saturate(s->band[band].d[i] + s->band[band].d[i]); - s->band[band].sz += (s->band[band].b[i]*wd1) >> 15; - } - s->band[band].sz = saturate(s->band[band].sz); - - /* Block 4, PREDIC */ - s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); -} -/*- End of function --------------------------------------------------------*/ - -g722_decode_state_t *WebRtc_g722_decode_init(g722_decode_state_t *s, - int rate, - int options) -{ - if (s == NULL) - { - if ((s = (g722_decode_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; - } - memset(s, 0, sizeof(*s)); - if (rate == 48000) - s->bits_per_sample = 6; - else if (rate == 56000) - s->bits_per_sample = 7; - else - s->bits_per_sample = 8; - if ((options & G722_SAMPLE_RATE_8000)) - s->eight_k = TRUE; - if ((options & G722_PACKED) && s->bits_per_sample != 8) - s->packed = TRUE; - else - s->packed = FALSE; - s->band[0].det = 32; - s->band[1].det = 8; - return s; -} -/*- End of function --------------------------------------------------------*/ - -int WebRtc_g722_decode_release(g722_decode_state_t *s) -{ - free(s); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -int WebRtc_g722_decode(g722_decode_state_t *s, WebRtc_Word16 amp[], - const WebRtc_UWord8 g722_data[], int len) -{ - static const int wl[8] = {-60, -30, 58, 172, 334, 538, 1198, 3042 }; - static const int rl42[16] = {0, 7, 6, 5, 4, 3, 2, 1, - 7, 6, 5, 4, 3, 2, 1, 0 }; - static const int ilb[32] = - { - 2048, 2093, 2139, 2186, 2233, 2282, 2332, - 2383, 2435, 2489, 2543, 2599, 2656, 2714, - 2774, 2834, 2896, 2960, 3025, 3091, 3158, - 3228, 3298, 3371, 3444, 3520, 3597, 3676, - 3756, 3838, 3922, 4008 - }; - static const int wh[3] = {0, -214, 798}; - static const int rh2[4] = {2, 1, 2, 1}; - static const int qm2[4] = {-7408, -1616, 7408, 1616}; - static const int qm4[16] = - { - 0, -20456, -12896, -8968, - -6288, -4240, -2584, -1200, - 20456, 12896, 8968, 6288, - 4240, 2584, 1200, 0 - }; - static const int qm5[32] = - { - -280, -280, -23352, -17560, - -14120, -11664, -9752, -8184, - -6864, -5712, -4696, -3784, - -2960, -2208, -1520, -880, - 23352, 17560, 14120, 11664, - 9752, 8184, 6864, 5712, - 4696, 3784, 2960, 2208, - 1520, 880, 280, -280 - }; - static const int qm6[64] = - { - -136, -136, -136, -136, - -24808, -21904, -19008, -16704, - -14984, -13512, -12280, -11192, - -10232, -9360, -8576, -7856, - -7192, -6576, -6000, -5456, - -4944, -4464, -4008, -3576, - -3168, -2776, -2400, -2032, - -1688, -1360, -1040, -728, - 24808, 21904, 19008, 16704, - 14984, 13512, 12280, 11192, - 10232, 9360, 8576, 7856, - 7192, 6576, 6000, 5456, - 4944, 4464, 4008, 3576, - 3168, 2776, 2400, 2032, - 1688, 1360, 1040, 728, - 432, 136, -432, -136 - }; - static const int qmf_coeffs[12] = - { - 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, - }; - - int dlowt; - int rlow; - int ihigh; - int dhigh; - int rhigh; - int xout1; - int xout2; - int wd1; - int wd2; - int wd3; - int code; - int outlen; - int i; - int j; - - outlen = 0; - rhigh = 0; - for (j = 0; j < len; ) - { - if (s->packed) - { - /* Unpack the code bits */ - if (s->in_bits < s->bits_per_sample) - { - s->in_buffer |= (g722_data[j++] << s->in_bits); - s->in_bits += 8; - } - code = s->in_buffer & ((1 << s->bits_per_sample) - 1); - s->in_buffer >>= s->bits_per_sample; - s->in_bits -= s->bits_per_sample; - } - else - { - code = g722_data[j++]; - } - - switch (s->bits_per_sample) - { - default: - case 8: - wd1 = code & 0x3F; - ihigh = (code >> 6) & 0x03; - wd2 = qm6[wd1]; - wd1 >>= 2; - break; - case 7: - wd1 = code & 0x1F; - ihigh = (code >> 5) & 0x03; - wd2 = qm5[wd1]; - wd1 >>= 1; - break; - case 6: - wd1 = code & 0x0F; - ihigh = (code >> 4) & 0x03; - wd2 = qm4[wd1]; - break; - } - /* Block 5L, LOW BAND INVQBL */ - wd2 = (s->band[0].det*wd2) >> 15; - /* Block 5L, RECONS */ - rlow = s->band[0].s + wd2; - /* Block 6L, LIMIT */ - if (rlow > 16383) - rlow = 16383; - else if (rlow < -16384) - rlow = -16384; - - /* Block 2L, INVQAL */ - wd2 = qm4[wd1]; - dlowt = (s->band[0].det*wd2) >> 15; - - /* Block 3L, LOGSCL */ - wd2 = rl42[wd1]; - wd1 = (s->band[0].nb*127) >> 7; - wd1 += wl[wd2]; - if (wd1 < 0) - wd1 = 0; - else if (wd1 > 18432) - wd1 = 18432; - s->band[0].nb = wd1; - - /* Block 3L, SCALEL */ - wd1 = (s->band[0].nb >> 6) & 31; - wd2 = 8 - (s->band[0].nb >> 11); - wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); - s->band[0].det = wd3 << 2; - - block4(s, 0, dlowt); - - if (!s->eight_k) - { - /* Block 2H, INVQAH */ - wd2 = qm2[ihigh]; - dhigh = (s->band[1].det*wd2) >> 15; - /* Block 5H, RECONS */ - rhigh = dhigh + s->band[1].s; - /* Block 6H, LIMIT */ - if (rhigh > 16383) - rhigh = 16383; - else if (rhigh < -16384) - rhigh = -16384; - - /* Block 2H, INVQAH */ - wd2 = rh2[ihigh]; - wd1 = (s->band[1].nb*127) >> 7; - wd1 += wh[wd2]; - if (wd1 < 0) - wd1 = 0; - else if (wd1 > 22528) - wd1 = 22528; - s->band[1].nb = wd1; - - /* Block 3H, SCALEH */ - wd1 = (s->band[1].nb >> 6) & 31; - wd2 = 10 - (s->band[1].nb >> 11); - wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); - s->band[1].det = wd3 << 2; - - block4(s, 1, dhigh); - } - - if (s->itu_test_mode) - { - amp[outlen++] = (WebRtc_Word16) (rlow << 1); - amp[outlen++] = (WebRtc_Word16) (rhigh << 1); - } - else - { - if (s->eight_k) - { - amp[outlen++] = (WebRtc_Word16) (rlow << 1); - } - else - { - /* Apply the receive QMF */ - for (i = 0; i < 22; i++) - s->x[i] = s->x[i + 2]; - s->x[22] = rlow + rhigh; - s->x[23] = rlow - rhigh; - - xout1 = 0; - xout2 = 0; - for (i = 0; i < 12; i++) - { - xout2 += s->x[2*i]*qmf_coeffs[i]; - xout1 += s->x[2*i + 1]*qmf_coeffs[11 - i]; - } - /* We shift by 12 to allow for the QMF filters (DC gain = 4096), less 1 - to allow for the 15 bit input to the G.722 algorithm. */ - /* WebRtc, tlegrand: added saturation */ - amp[outlen++] = saturate(xout1 >> 11); - amp[outlen++] = saturate(xout2 >> 11); - } - } - } - return outlen; -} -/*- End of function --------------------------------------------------------*/ -/*- End of file ------------------------------------------------------------*/
diff --git a/src/modules/audio_coding/codecs/g722/g722_enc_dec.h b/src/modules/audio_coding/codecs/g722/g722_enc_dec.h deleted file mode 100644 index d2d19b0..0000000 --- a/src/modules/audio_coding/codecs/g722/g722_enc_dec.h +++ /dev/null
@@ -1,158 +0,0 @@ -/* - * SpanDSP - a series of DSP components for telephony - * - * g722.h - The ITU G.722 codec. - * - * Written by Steve Underwood <steveu@coppice.org> - * - * Copyright (C) 2005 Steve Underwood - * - * Despite my general liking of the GPL, I place my own contributions - * to this code in the public domain for the benefit of all mankind - - * even the slimy ones who might try to proprietize my work and use it - * to my detriment. - * - * Based on a single channel G.722 codec which is: - * - ***** Copyright (c) CMU 1993 ***** - * Computer Science, Speech Group - * Chengxiang Lu and Alex Hauptmann - * - * $Id: g722.h,v 1.10 2006/06/16 12:45:53 steveu Exp $ - * - * Modifications for WebRtc, 2011/04/28, by tlegrand: - * -Changed to use WebRtc types - * -Added new defines for minimum and maximum values of short int - */ - - -/*! \file */ - -#if !defined(_G722_ENC_DEC_H_) -#define _G722_ENC_DEC_H_ - -/*! \page g722_page G.722 encoding and decoding -\section g722_page_sec_1 What does it do? -The G.722 module is a bit exact implementation of the ITU G.722 specification for all three -specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. - -To allow fast and flexible interworking with narrow band telephony, the encoder and decoder -support an option for the linear audio to be an 8k samples/second stream. In this mode the -codec is considerably faster, and still fully compatible with wideband terminals using G.722. - -\section g722_page_sec_2 How does it work? -???. -*/ - -#define WEBRTC_INT16_MAX 32767 -#define WEBRTC_INT16_MIN -32768 - -enum -{ - G722_SAMPLE_RATE_8000 = 0x0001, - G722_PACKED = 0x0002 -}; - -typedef struct -{ - /*! TRUE if the operating in the special ITU test mode, with the band split filters - disabled. */ - int itu_test_mode; - /*! TRUE if the G.722 data is packed */ - int packed; - /*! TRUE if encode from 8k samples/second */ - int eight_k; - /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ - int bits_per_sample; - - /*! Signal history for the QMF */ - int x[24]; - - struct - { - int s; - int sp; - int sz; - int r[3]; - int a[3]; - int ap[3]; - int p[3]; - int d[7]; - int b[7]; - int bp[7]; - int sg[7]; - int nb; - int det; - } band[2]; - - unsigned int in_buffer; - int in_bits; - unsigned int out_buffer; - int out_bits; -} g722_encode_state_t; - -typedef struct -{ - /*! TRUE if the operating in the special ITU test mode, with the band split filters - disabled. */ - int itu_test_mode; - /*! TRUE if the G.722 data is packed */ - int packed; - /*! TRUE if decode to 8k samples/second */ - int eight_k; - /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ - int bits_per_sample; - - /*! Signal history for the QMF */ - int x[24]; - - struct - { - int s; - int sp; - int sz; - int r[3]; - int a[3]; - int ap[3]; - int p[3]; - int d[7]; - int b[7]; - int bp[7]; - int sg[7]; - int nb; - int det; - } band[2]; - - unsigned int in_buffer; - int in_bits; - unsigned int out_buffer; - int out_bits; -} g722_decode_state_t; - -#ifdef __cplusplus -extern "C" { -#endif - -g722_encode_state_t *WebRtc_g722_encode_init(g722_encode_state_t *s, - int rate, - int options); -int WebRtc_g722_encode_release(g722_encode_state_t *s); -int WebRtc_g722_encode(g722_encode_state_t *s, - WebRtc_UWord8 g722_data[], - const WebRtc_Word16 amp[], - int len); - -g722_decode_state_t *WebRtc_g722_decode_init(g722_decode_state_t *s, - int rate, - int options); -int WebRtc_g722_decode_release(g722_decode_state_t *s); -int WebRtc_g722_decode(g722_decode_state_t *s, - WebRtc_Word16 amp[], - const WebRtc_UWord8 g722_data[], - int len); - -#ifdef __cplusplus -} -#endif - -#endif
diff --git a/src/modules/audio_coding/codecs/g722/g722_encode.c b/src/modules/audio_coding/codecs/g722/g722_encode.c deleted file mode 100644 index 7487b64..0000000 --- a/src/modules/audio_coding/codecs/g722/g722_encode.c +++ /dev/null
@@ -1,434 +0,0 @@ -/* - * SpanDSP - a series of DSP components for telephony - * - * g722_encode.c - The ITU G.722 codec, encode part. - * - * Written by Steve Underwood <steveu@coppice.org> - * - * Copyright (C) 2005 Steve Underwood - * - * All rights reserved. - * - * Despite my general liking of the GPL, I place my own contributions - * to this code in the public domain for the benefit of all mankind - - * even the slimy ones who might try to proprietize my work and use it - * to my detriment. - * - * Based on a single channel 64kbps only G.722 codec which is: - * - ***** Copyright (c) CMU 1993 ***** - * Computer Science, Speech Group - * Chengxiang Lu and Alex Hauptmann - * - * $Id: g722_encode.c,v 1.14 2006/07/07 16:37:49 steveu Exp $ - * - * Modifications for WebRtc, 2011/04/28, by tlegrand: - * -Removed usage of inttypes.h and tgmath.h - * -Changed to use WebRtc types - * -Added option to run encoder bitexact with ITU-T reference implementation - */ - -/*! \file */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <memory.h> -#include <stdlib.h> - -#include "typedefs.h" -#include "g722_enc_dec.h" - -#if !defined(FALSE) -#define FALSE 0 -#endif -#if !defined(TRUE) -#define TRUE (!FALSE) -#endif - -static __inline WebRtc_Word16 saturate(WebRtc_Word32 amp) -{ - WebRtc_Word16 amp16; - - /* Hopefully this is optimised for the common case - not clipping */ - amp16 = (WebRtc_Word16) amp; - if (amp == amp16) - return amp16; - if (amp > WEBRTC_INT16_MAX) - return WEBRTC_INT16_MAX; - return WEBRTC_INT16_MIN; -} -/*- End of function --------------------------------------------------------*/ - -static void block4(g722_encode_state_t *s, int band, int d) -{ - int wd1; - int wd2; - int wd3; - int i; - - /* Block 4, RECONS */ - s->band[band].d[0] = d; - s->band[band].r[0] = saturate(s->band[band].s + d); - - /* Block 4, PARREC */ - s->band[band].p[0] = saturate(s->band[band].sz + d); - - /* Block 4, UPPOL2 */ - for (i = 0; i < 3; i++) - s->band[band].sg[i] = s->band[band].p[i] >> 15; - wd1 = saturate(s->band[band].a[1] << 2); - - wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1; - if (wd2 > 32767) - wd2 = 32767; - wd3 = (wd2 >> 7) + ((s->band[band].sg[0] == s->band[band].sg[2]) ? 128 : -128); - wd3 += (s->band[band].a[2]*32512) >> 15; - if (wd3 > 12288) - wd3 = 12288; - else if (wd3 < -12288) - wd3 = -12288; - s->band[band].ap[2] = wd3; - - /* Block 4, UPPOL1 */ - s->band[band].sg[0] = s->band[band].p[0] >> 15; - s->band[band].sg[1] = s->band[band].p[1] >> 15; - wd1 = (s->band[band].sg[0] == s->band[band].sg[1]) ? 192 : -192; - wd2 = (s->band[band].a[1]*32640) >> 15; - - s->band[band].ap[1] = saturate(wd1 + wd2); - wd3 = saturate(15360 - s->band[band].ap[2]); - if (s->band[band].ap[1] > wd3) - s->band[band].ap[1] = wd3; - else if (s->band[band].ap[1] < -wd3) - s->band[band].ap[1] = -wd3; - - /* Block 4, UPZERO */ - wd1 = (d == 0) ? 0 : 128; - s->band[band].sg[0] = d >> 15; - for (i = 1; i < 7; i++) - { - s->band[band].sg[i] = s->band[band].d[i] >> 15; - wd2 = (s->band[band].sg[i] == s->band[band].sg[0]) ? wd1 : -wd1; - wd3 = (s->band[band].b[i]*32640) >> 15; - s->band[band].bp[i] = saturate(wd2 + wd3); - } - - /* Block 4, DELAYA */ - for (i = 6; i > 0; i--) - { - s->band[band].d[i] = s->band[band].d[i - 1]; - s->band[band].b[i] = s->band[band].bp[i]; - } - - for (i = 2; i > 0; i--) - { - s->band[band].r[i] = s->band[band].r[i - 1]; - s->band[band].p[i] = s->band[band].p[i - 1]; - s->band[band].a[i] = s->band[band].ap[i]; - } - - /* Block 4, FILTEP */ - wd1 = saturate(s->band[band].r[1] + s->band[band].r[1]); - wd1 = (s->band[band].a[1]*wd1) >> 15; - wd2 = saturate(s->band[band].r[2] + s->band[band].r[2]); - wd2 = (s->band[band].a[2]*wd2) >> 15; - s->band[band].sp = saturate(wd1 + wd2); - - /* Block 4, FILTEZ */ - s->band[band].sz = 0; - for (i = 6; i > 0; i--) - { - wd1 = saturate(s->band[band].d[i] + s->band[band].d[i]); - s->band[band].sz += (s->band[band].b[i]*wd1) >> 15; - } - s->band[band].sz = saturate(s->band[band].sz); - - /* Block 4, PREDIC */ - s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); -} -/*- End of function --------------------------------------------------------*/ - -g722_encode_state_t *WebRtc_g722_encode_init(g722_encode_state_t *s, - int rate, int options) -{ - if (s == NULL) - { - if ((s = (g722_encode_state_t *) malloc(sizeof(*s))) == NULL) - return NULL; - } - memset(s, 0, sizeof(*s)); - if (rate == 48000) - s->bits_per_sample = 6; - else if (rate == 56000) - s->bits_per_sample = 7; - else - s->bits_per_sample = 8; - if ((options & G722_SAMPLE_RATE_8000)) - s->eight_k = TRUE; - if ((options & G722_PACKED) && s->bits_per_sample != 8) - s->packed = TRUE; - else - s->packed = FALSE; - s->band[0].det = 32; - s->band[1].det = 8; - return s; -} -/*- End of function --------------------------------------------------------*/ - -int WebRtc_g722_encode_release(g722_encode_state_t *s) -{ - free(s); - return 0; -} -/*- End of function --------------------------------------------------------*/ - -/* WebRtc, tlegrand: - * Only define the following if bit-exactness with reference implementation - * is needed. Will only have any effect if input signal is saturated. - */ -//#define RUN_LIKE_REFERENCE_G722 -#ifdef RUN_LIKE_REFERENCE_G722 -WebRtc_Word16 limitValues (WebRtc_Word16 rl) -{ - - WebRtc_Word16 yl; - - yl = (rl > 16383) ? 16383 : ((rl < -16384) ? -16384 : rl); - - return (yl); -} -#endif - -int WebRtc_g722_encode(g722_encode_state_t *s, WebRtc_UWord8 g722_data[], - const WebRtc_Word16 amp[], int len) -{ - static const int q6[32] = - { - 0, 35, 72, 110, 150, 190, 233, 276, - 323, 370, 422, 473, 530, 587, 650, 714, - 786, 858, 940, 1023, 1121, 1219, 1339, 1458, - 1612, 1765, 1980, 2195, 2557, 2919, 0, 0 - }; - static const int iln[32] = - { - 0, 63, 62, 31, 30, 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, 0 - }; - static const int ilp[32] = - { - 0, 61, 60, 59, 58, 57, 56, 55, - 54, 53, 52, 51, 50, 49, 48, 47, - 46, 45, 44, 43, 42, 41, 40, 39, - 38, 37, 36, 35, 34, 33, 32, 0 - }; - static const int wl[8] = - { - -60, -30, 58, 172, 334, 538, 1198, 3042 - }; - static const int rl42[16] = - { - 0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 - }; - static const int ilb[32] = - { - 2048, 2093, 2139, 2186, 2233, 2282, 2332, - 2383, 2435, 2489, 2543, 2599, 2656, 2714, - 2774, 2834, 2896, 2960, 3025, 3091, 3158, - 3228, 3298, 3371, 3444, 3520, 3597, 3676, - 3756, 3838, 3922, 4008 - }; - static const int qm4[16] = - { - 0, -20456, -12896, -8968, - -6288, -4240, -2584, -1200, - 20456, 12896, 8968, 6288, - 4240, 2584, 1200, 0 - }; - static const int qm2[4] = - { - -7408, -1616, 7408, 1616 - }; - static const int qmf_coeffs[12] = - { - 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, - }; - static const int ihn[3] = {0, 1, 0}; - static const int ihp[3] = {0, 3, 2}; - static const int wh[3] = {0, -214, 798}; - static const int rh2[4] = {2, 1, 2, 1}; - - int dlow; - int dhigh; - int el; - int wd; - int wd1; - int ril; - int wd2; - int il4; - int ih2; - int wd3; - int eh; - int mih; - int i; - int j; - /* Low and high band PCM from the QMF */ - int xlow; - int xhigh; - int g722_bytes; - /* Even and odd tap accumulators */ - int sumeven; - int sumodd; - int ihigh; - int ilow; - int code; - - g722_bytes = 0; - xhigh = 0; - for (j = 0; j < len; ) - { - if (s->itu_test_mode) - { - xlow = - xhigh = amp[j++] >> 1; - } - else - { - if (s->eight_k) - { - /* We shift by 1 to allow for the 15 bit input to the G.722 algorithm. */ - xlow = amp[j++] >> 1; - } - else - { - /* Apply the transmit QMF */ - /* Shuffle the buffer down */ - for (i = 0; i < 22; i++) - s->x[i] = s->x[i + 2]; - s->x[22] = amp[j++]; - s->x[23] = amp[j++]; - - /* Discard every other QMF output */ - sumeven = 0; - sumodd = 0; - for (i = 0; i < 12; i++) - { - sumodd += s->x[2*i]*qmf_coeffs[i]; - sumeven += s->x[2*i + 1]*qmf_coeffs[11 - i]; - } - /* We shift by 12 to allow for the QMF filters (DC gain = 4096), plus 1 - to allow for us summing two filters, plus 1 to allow for the 15 bit - input to the G.722 algorithm. */ - xlow = (sumeven + sumodd) >> 14; - xhigh = (sumeven - sumodd) >> 14; - -#ifdef RUN_LIKE_REFERENCE_G722 - /* The following lines are only used to verify bit-exactness - * with reference implementation of G.722. Higher precision - * is achieved without limiting the values. - */ - xlow = limitValues(xlow); - xhigh = limitValues(xhigh); -#endif - } - } - /* Block 1L, SUBTRA */ - el = saturate(xlow - s->band[0].s); - - /* Block 1L, QUANTL */ - wd = (el >= 0) ? el : -(el + 1); - - for (i = 1; i < 30; i++) - { - wd1 = (q6[i]*s->band[0].det) >> 12; - if (wd < wd1) - break; - } - ilow = (el < 0) ? iln[i] : ilp[i]; - - /* Block 2L, INVQAL */ - ril = ilow >> 2; - wd2 = qm4[ril]; - dlow = (s->band[0].det*wd2) >> 15; - - /* Block 3L, LOGSCL */ - il4 = rl42[ril]; - wd = (s->band[0].nb*127) >> 7; - s->band[0].nb = wd + wl[il4]; - if (s->band[0].nb < 0) - s->band[0].nb = 0; - else if (s->band[0].nb > 18432) - s->band[0].nb = 18432; - - /* Block 3L, SCALEL */ - wd1 = (s->band[0].nb >> 6) & 31; - wd2 = 8 - (s->band[0].nb >> 11); - wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); - s->band[0].det = wd3 << 2; - - block4(s, 0, dlow); - - if (s->eight_k) - { - /* Just leave the high bits as zero */ - code = (0xC0 | ilow) >> (8 - s->bits_per_sample); - } - else - { - /* Block 1H, SUBTRA */ - eh = saturate(xhigh - s->band[1].s); - - /* Block 1H, QUANTH */ - wd = (eh >= 0) ? eh : -(eh + 1); - wd1 = (564*s->band[1].det) >> 12; - mih = (wd >= wd1) ? 2 : 1; - ihigh = (eh < 0) ? ihn[mih] : ihp[mih]; - - /* Block 2H, INVQAH */ - wd2 = qm2[ihigh]; - dhigh = (s->band[1].det*wd2) >> 15; - - /* Block 3H, LOGSCH */ - ih2 = rh2[ihigh]; - wd = (s->band[1].nb*127) >> 7; - s->band[1].nb = wd + wh[ih2]; - if (s->band[1].nb < 0) - s->band[1].nb = 0; - else if (s->band[1].nb > 22528) - s->band[1].nb = 22528; - - /* Block 3H, SCALEH */ - wd1 = (s->band[1].nb >> 6) & 31; - wd2 = 10 - (s->band[1].nb >> 11); - wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); - s->band[1].det = wd3 << 2; - - block4(s, 1, dhigh); - code = ((ihigh << 6) | ilow) >> (8 - s->bits_per_sample); - } - - if (s->packed) - { - /* Pack the code bits */ - s->out_buffer |= (code << s->out_bits); - s->out_bits += s->bits_per_sample; - if (s->out_bits >= 8) - { - g722_data[g722_bytes++] = (WebRtc_UWord8) (s->out_buffer & 0xFF); - s->out_bits -= 8; - s->out_buffer >>= 8; - } - } - else - { - g722_data[g722_bytes++] = (WebRtc_UWord8) code; - } - } - return g722_bytes; -} -/*- End of function --------------------------------------------------------*/ -/*- End of file ------------------------------------------------------------*/
diff --git a/src/modules/audio_coding/codecs/g722/g722_interface.c b/src/modules/audio_coding/codecs/g722/g722_interface.c deleted file mode 100644 index d559014..0000000 --- a/src/modules/audio_coding/codecs/g722/g722_interface.c +++ /dev/null
@@ -1,115 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - - -#include <stdlib.h> -#include <string.h> -#include "g722_interface.h" -#include "g722_enc_dec.h" -#include "typedefs.h" - - -WebRtc_Word16 WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst) -{ - *G722enc_inst=(G722EncInst*)malloc(sizeof(g722_encode_state_t)); - if (*G722enc_inst!=NULL) { - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcG722_EncoderInit(G722EncInst *G722enc_inst) -{ - // Create and/or reset the G.722 encoder - // Bitrate 64 kbps and wideband mode (2) - G722enc_inst = (G722EncInst *) WebRtc_g722_encode_init( - (g722_encode_state_t*) G722enc_inst, 64000, 2); - if (G722enc_inst == NULL) { - return -1; - } else { - return 0; - } -} - -WebRtc_Word16 WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst) -{ - // Free encoder memory - return WebRtc_g722_encode_release((g722_encode_state_t*) G722enc_inst); -} - -WebRtc_Word16 WebRtcG722_Encode(G722EncInst *G722enc_inst, - WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded) -{ - unsigned char *codechar = (unsigned char*) encoded; - // Encode the input speech vector - return WebRtc_g722_encode((g722_encode_state_t*) G722enc_inst, - codechar, speechIn, len); -} - -WebRtc_Word16 WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst) -{ - *G722dec_inst=(G722DecInst*)malloc(sizeof(g722_decode_state_t)); - if (*G722dec_inst!=NULL) { - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcG722_DecoderInit(G722DecInst *G722dec_inst) -{ - // Create and/or reset the G.722 decoder - // Bitrate 64 kbps and wideband mode (2) - G722dec_inst = (G722DecInst *) WebRtc_g722_decode_init( - (g722_decode_state_t*) G722dec_inst, 64000, 2); - if (G722dec_inst == NULL) { - return -1; - } else { - return 0; - } -} - -WebRtc_Word16 WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst) -{ - // Free encoder memory - return WebRtc_g722_decode_release((g722_decode_state_t*) G722dec_inst); -} - -WebRtc_Word16 WebRtcG722_Decode(G722DecInst *G722dec_inst, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - // Decode the G.722 encoder stream - *speechType=G722_WEBRTC_SPEECH; - return WebRtc_g722_decode((g722_decode_state_t*) G722dec_inst, - decoded, (WebRtc_UWord8*) encoded, len); -} - -WebRtc_Word16 WebRtcG722_Version(char *versionStr, short len) -{ - // Get version string - char version[30] = "2.0.0\n"; - if (strlen(version) < (unsigned int)len) - { - strcpy(versionStr, version); - return 0; - } - else - { - return -1; - } -} -
diff --git a/src/modules/audio_coding/codecs/g722/g722_unittest.cc b/src/modules/audio_coding/codecs/g722/g722_unittest.cc deleted file mode 100644 index a828edd..0000000 --- a/src/modules/audio_coding/codecs/g722/g722_unittest.cc +++ /dev/null
@@ -1,17 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * Empty test just to get code coverage metrics for this dir. - */ -#include "g722_interface.h" -#include "gtest/gtest.h" - -TEST(G722Test, EmptyTestToGetCodeCoverage) {}
diff --git a/src/modules/audio_coding/codecs/g722/include/g722_interface.h b/src/modules/audio_coding/codecs/g722/include/g722_interface.h deleted file mode 100644 index e50d66f..0000000 --- a/src/modules/audio_coding/codecs/g722/include/g722_interface.h +++ /dev/null
@@ -1,190 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef MODULES_AUDIO_CODING_CODECS_G722_MAIN_INTERFACE_G722_INTERFACE_H_ -#define MODULES_AUDIO_CODING_CODECS_G722_MAIN_INTERFACE_G722_INTERFACE_H_ - -#include "typedefs.h" - -/* - * Solution to support multiple instances - */ - -typedef struct WebRtcG722EncInst G722EncInst; -typedef struct WebRtcG722DecInst G722DecInst; - -/* - * Comfort noise constants - */ - -#define G722_WEBRTC_SPEECH 1 -#define G722_WEBRTC_CNG 2 - -#ifdef __cplusplus -extern "C" { -#endif - - -/**************************************************************************** - * WebRtcG722_CreateEncoder(...) - * - * Create memory used for G722 encoder - * - * Input: - * - G722enc_inst : G722 instance for encoder - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst); - - -/**************************************************************************** - * WebRtcG722_EncoderInit(...) - * - * This function initializes a G722 instance - * - * Input: - * - G722enc_inst : G722 instance, i.e. the user that should receive - * be initialized - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcG722_EncoderInit(G722EncInst *G722enc_inst); - - -/**************************************************************************** - * WebRtcG722_FreeEncoder(...) - * - * Free the memory used for G722 encoder - * - * Input: - * - G722enc_inst : G722 instance for encoder - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst); - - - -/**************************************************************************** - * WebRtcG722_Encode(...) - * - * This function encodes G722 encoded data. - * - * Input: - * - G722enc_inst : G722 instance, i.e. the user that should encode - * a packet - * - speechIn : Input speech vector - * - len : Samples in speechIn - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - -WebRtc_Word16 WebRtcG722_Encode(G722EncInst *G722enc_inst, - WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded); - - -/**************************************************************************** - * WebRtcG722_CreateDecoder(...) - * - * Create memory used for G722 encoder - * - * Input: - * - G722dec_inst : G722 instance for decoder - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst); - - -/**************************************************************************** - * WebRtcG722_DecoderInit(...) - * - * This function initializes a G729 instance - * - * Input: - * - G729_decinst_t : G729 instance, i.e. the user that should receive - * be initialized - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcG722_DecoderInit(G722DecInst *G722dec_inst); - - -/**************************************************************************** - * WebRtcG722_FreeDecoder(...) - * - * Free the memory used for G722 decoder - * - * Input: - * - G722dec_inst : G722 instance for decoder - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst); - - -/**************************************************************************** - * WebRtcG722_Decode(...) - * - * This function decodes a packet with G729 frame(s). Output speech length - * will be a multiple of 80 samples (80*frames/packet). - * - * Input: - * - G722dec_inst : G722 instance, i.e. the user that should decode - * a packet - * - encoded : Encoded G722 frame(s) - * - len : Bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - speechType : 1 normal, 2 CNG (Since G722 does not have its own - * DTX/CNG scheme it should always return 1) - * - * Return value : >0 - Samples in decoded vector - * -1 - Error - */ - -WebRtc_Word16 WebRtcG722_Decode(G722DecInst *G722dec_inst, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - -/**************************************************************************** - * WebRtcG722_Version(...) - * - * Get a string with the current version of the codec - */ - -WebRtc_Word16 WebRtcG722_Version(char *versionStr, short len); - - -#ifdef __cplusplus -} -#endif - - -#endif /* MODULES_AUDIO_CODING_CODECS_G722_MAIN_INTERFACE_G722_INTERFACE_H_ */
diff --git a/src/modules/audio_coding/codecs/g722/test/testG722.cc b/src/modules/audio_coding/codecs/g722/test/testG722.cc deleted file mode 100644 index d2fdca3..0000000 --- a/src/modules/audio_coding/codecs/g722/test/testG722.cc +++ /dev/null
@@ -1,162 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * testG722.cpp : Defines the entry point for the console application. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "typedefs.h" - -/* include API */ -#include "g722_interface.h" - -/* Runtime statistics */ -#include <time.h> -#define CLOCKS_PER_SEC_G722 100000 - -// Forward declaration -typedef struct WebRtcG722EncInst G722EncInst; -typedef struct WebRtcG722DecInst G722DecInst; - -/* function for reading audio data from PCM file */ -int readframe(WebRtc_Word16 *data, FILE *inp, int length) -{ - short k, rlen, status = 0; - - rlen = (short)fread(data, sizeof(WebRtc_Word16), length, inp); - if (rlen < length) { - for (k = rlen; k < length; k++) - data[k] = 0; - status = 1; - } - - return status; -} - -int main(int argc, char* argv[]) -{ - char inname[60], outbit[40], outname[40]; - FILE *inp, *outbitp, *outp; - - int framecnt, endfile; - WebRtc_Word16 framelength = 160; - G722EncInst *G722enc_inst; - G722DecInst *G722dec_inst; - int err; - - /* Runtime statistics */ - double starttime; - double runtime = 0; - double length_file; - - WebRtc_Word16 stream_len = 0; - WebRtc_Word16 shortdata[960]; - WebRtc_Word16 decoded[960]; - WebRtc_Word16 streamdata[80*3]; - WebRtc_Word16 speechType[1]; - - /* handling wrong input arguments in the command line */ - if (argc!=5) { - printf("\n\nWrong number of arguments or flag values.\n\n"); - - printf("\n"); - printf("Usage:\n\n"); - printf("./testG722.exe framelength infile outbitfile outspeechfile \n\n"); - printf("with:\n"); - printf("framelength : Framelength in samples.\n\n"); - printf("infile : Normal speech input file\n\n"); - printf("outbitfile : Bitstream output file\n\n"); - printf("outspeechfile: Speech output file\n\n"); - exit(0); - - } - - /* Get frame length */ - framelength = atoi(argv[1]); - - /* Get Input and Output files */ - sscanf(argv[2], "%s", inname); - sscanf(argv[3], "%s", outbit); - sscanf(argv[4], "%s", outname); - - if ((inp = fopen(inname,"rb")) == NULL) { - printf(" G.722: Cannot read file %s.\n", inname); - exit(1); - } - if ((outbitp = fopen(outbit,"wb")) == NULL) { - printf(" G.722: Cannot write file %s.\n", outbit); - exit(1); - } - if ((outp = fopen(outname,"wb")) == NULL) { - printf(" G.722: Cannot write file %s.\n", outname); - exit(1); - } - printf("\nInput:%s\nOutput bitstream:%s\nOutput:%s\n", inname, outbit, outname); - - /* Create and init */ - WebRtcG722_CreateEncoder((G722EncInst **)&G722enc_inst); - WebRtcG722_CreateDecoder((G722DecInst **)&G722dec_inst); - WebRtcG722_EncoderInit((G722EncInst *)G722enc_inst); - WebRtcG722_DecoderInit((G722DecInst *)G722dec_inst); - - - /* Initialize encoder and decoder */ - framecnt = 0; - endfile = 0; - while (endfile == 0) { - framecnt++; - - /* Read speech block */ - endfile = readframe(shortdata, inp, framelength); - - /* Start clock before call to encoder and decoder */ - starttime = clock()/(double)CLOCKS_PER_SEC_G722; - - /* G.722 encoding + decoding */ - stream_len = WebRtcG722_Encode((G722EncInst *)G722enc_inst, shortdata, framelength, streamdata); - err = WebRtcG722_Decode((G722DecInst *)G722dec_inst, streamdata, stream_len, decoded, speechType); - - /* Stop clock after call to encoder and decoder */ - runtime += (double)((clock()/(double)CLOCKS_PER_SEC_G722)-starttime); - - if (stream_len < 0 || err < 0) { - /* exit if returned with error */ - printf("Error in encoder/decoder\n"); - } else { - /* Write coded bits to file */ - if (fwrite(streamdata, sizeof(short), stream_len/2, - outbitp) != static_cast<size_t>(stream_len/2)) { - return -1; - } - /* Write coded speech to file */ - if (fwrite(decoded, sizeof(short), framelength, - outp) != static_cast<size_t>(framelength)) { - return -1; - } - } - } - - WebRtcG722_FreeEncoder((G722EncInst *)G722enc_inst); - WebRtcG722_FreeDecoder((G722DecInst *)G722dec_inst); - - length_file = ((double)framecnt*(double)framelength/16000); - printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run G.722: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file)); - printf("---------------------END----------------------\n"); - - fclose(inp); - fclose(outbitp); - fclose(outp); - - return 0; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/abs_quant.c b/src/modules/audio_coding/codecs/ilbc/abs_quant.c deleted file mode 100644 index 4a70c8b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/abs_quant.c +++ /dev/null
@@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuant.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "abs_quant_loop.h" - - -/*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for WebRtcIlbcfix_StateSearch) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AbsQuant( - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax - and idxVec, uses state_first as - input) */ - WebRtc_Word16 *in, /* (i) vector to encode */ - WebRtc_Word16 *weightDenum /* (i) denominator of synthesis filter */ - ) { - WebRtc_Word16 *syntOut; - WebRtc_Word16 quantLen[2]; - - /* Stack based */ - WebRtc_Word16 syntOutBuf[LPC_FILTERORDER+STATE_SHORT_LEN_30MS]; - WebRtc_Word16 in_weightedVec[STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - WebRtc_Word16 *in_weighted = &in_weightedVec[LPC_FILTERORDER]; - - /* Initialize the buffers */ - WebRtcSpl_MemSetW16(syntOutBuf, 0, LPC_FILTERORDER+STATE_SHORT_LEN_30MS); - syntOut = &syntOutBuf[LPC_FILTERORDER]; - /* Start with zero state */ - WebRtcSpl_MemSetW16(in_weightedVec, 0, LPC_FILTERORDER); - - /* Perform the quantization loop in two sections of length quantLen[i], - where the perceptual weighting filter is updated at the subframe - border */ - - if (iLBC_encbits->state_first) { - quantLen[0]=SUBL; - quantLen[1]=iLBCenc_inst->state_short_len-SUBL; - } else { - quantLen[0]=iLBCenc_inst->state_short_len-SUBL; - quantLen[1]=SUBL; - } - - /* Calculate the weighted residual, switch perceptual weighting - filter at the subframe border */ - WebRtcSpl_FilterARFastQ12( - in, in_weighted, - weightDenum, LPC_FILTERORDER+1, quantLen[0]); - WebRtcSpl_FilterARFastQ12( - &in[quantLen[0]], &in_weighted[quantLen[0]], - &weightDenum[LPC_FILTERORDER+1], LPC_FILTERORDER+1, quantLen[1]); - - WebRtcIlbcfix_AbsQuantLoop( - syntOut, - in_weighted, - weightDenum, - quantLen, - iLBC_encbits->idxVec); - -}
diff --git a/src/modules/audio_coding/codecs/ilbc/abs_quant.h b/src/modules/audio_coding/codecs/ilbc/abs_quant.h deleted file mode 100644 index fa59593..0000000 --- a/src/modules/audio_coding/codecs/ilbc/abs_quant.h +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuant.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for WebRtcIlbcfix_StateSearch) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AbsQuant( - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits (outputs idxForMax - and idxVec, uses state_first as - input) */ - WebRtc_Word16 *in, /* (i) vector to encode */ - WebRtc_Word16 *weightDenum /* (i) denominator of synthesis filter */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/abs_quant_loop.c b/src/modules/audio_coding/codecs/ilbc/abs_quant_loop.c deleted file mode 100644 index 4eebc3e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/abs_quant_loop.c +++ /dev/null
@@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuantLoop.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "sort_sq.h" - -void WebRtcIlbcfix_AbsQuantLoop( - WebRtc_Word16 *syntOutIN, - WebRtc_Word16 *in_weightedIN, - WebRtc_Word16 *weightDenumIN, - WebRtc_Word16 *quantLenIN, - WebRtc_Word16 *idxVecIN - ) -{ - int n, k1, k2; - WebRtc_Word16 index; - WebRtc_Word32 toQW32; - WebRtc_Word32 toQ32; - WebRtc_Word16 tmp16a; - WebRtc_Word16 xq; - - WebRtc_Word16 *syntOut = syntOutIN; - WebRtc_Word16 *in_weighted = in_weightedIN; - WebRtc_Word16 *weightDenum = weightDenumIN; - WebRtc_Word16 *quantLen = quantLenIN; - WebRtc_Word16 *idxVec = idxVecIN; - - n=0; - - for(k1=0;k1<2;k1++) { - for(k2=0;k2<quantLen[k1];k2++){ - - /* Filter to get the predicted value */ - WebRtcSpl_FilterARFastQ12( - syntOut, syntOut, - weightDenum, LPC_FILTERORDER+1, 1); - - /* the quantizer */ - toQW32 = (WebRtc_Word32)(*in_weighted) - (WebRtc_Word32)(*syntOut); - - toQ32 = (((WebRtc_Word32)toQW32)<<2); - - if (toQ32 > 32767) { - toQ32 = (WebRtc_Word32) 32767; - } else if (toQ32 < -32768) { - toQ32 = (WebRtc_Word32) -32768; - } - - /* Quantize the state */ - if (toQW32<(-7577)) { - /* To prevent negative overflow */ - index=0; - } else if (toQW32>8151) { - /* To prevent positive overflow */ - index=7; - } else { - /* Find the best quantization index - (state_sq3Tbl is in Q13 and toQ is in Q11) - */ - WebRtcIlbcfix_SortSq(&xq, &index, - (WebRtc_Word16)toQ32, - WebRtcIlbcfix_kStateSq3, 8); - } - - /* Store selected index */ - (*idxVec++) = index; - - /* Compute decoded sample and update of the prediction filter */ - tmp16a = ((WebRtcIlbcfix_kStateSq3[index] + 2 ) >> 2); - - *syntOut = (WebRtc_Word16) (tmp16a + (WebRtc_Word32)(*in_weighted) - toQW32); - - n++; - syntOut++; in_weighted++; - } - /* Update perceptual weighting filter at subframe border */ - weightDenum += 11; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/abs_quant_loop.h b/src/modules/audio_coding/codecs/ilbc/abs_quant_loop.h deleted file mode 100644 index f506e8e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/abs_quant_loop.h +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AbsQuantLoop.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_LOOP_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ABS_QUANT_LOOP_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * predictive noise shaping encoding of scaled start state - * (subrutine for WebRtcIlbcfix_StateSearch) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AbsQuantLoop( - WebRtc_Word16 *syntOutIN, - WebRtc_Word16 *in_weightedIN, - WebRtc_Word16 *weightDenumIN, - WebRtc_Word16 *quantLenIN, - WebRtc_Word16 *idxVecIN - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c b/src/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c deleted file mode 100644 index 6011e92..0000000 --- a/src/modules/audio_coding/codecs/ilbc/augmented_cb_corr.c +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AugmentedCbCorr.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "augmented_cb_corr.h" - -void WebRtcIlbcfix_AugmentedCbCorr( - WebRtc_Word16 *target, /* (i) Target vector */ - WebRtc_Word16 *buffer, /* (i) Memory buffer */ - WebRtc_Word16 *interpSamples, /* (i) buffer with - interpolated samples */ - WebRtc_Word32 *crossDot, /* (o) The cross correlation between - the target and the Augmented - vector */ - WebRtc_Word16 low, /* (i) Lag to start from (typically - 20) */ - WebRtc_Word16 high, /* (i) Lag to end at (typically 39) */ - WebRtc_Word16 scale) /* (i) Scale factor to use for - the crossDot */ -{ - int lagcount; - WebRtc_Word16 ilow; - WebRtc_Word16 *targetPtr; - WebRtc_Word32 *crossDotPtr; - WebRtc_Word16 *iSPtr=interpSamples; - - /* Calculate the correlation between the target and the - interpolated codebook. The correlation is calculated in - 3 sections with the interpolated part in the middle */ - crossDotPtr=crossDot; - for (lagcount=low; lagcount<=high; lagcount++) { - - ilow = (WebRtc_Word16) (lagcount-4); - - /* Compute dot product for the first (lagcount-4) samples */ - (*crossDotPtr) = WebRtcSpl_DotProductWithScale(target, buffer-lagcount, ilow, scale); - - /* Compute dot product on the interpolated samples */ - (*crossDotPtr) += WebRtcSpl_DotProductWithScale(target+ilow, iSPtr, 4, scale); - targetPtr = target + lagcount; - iSPtr += lagcount-ilow; - - /* Compute dot product for the remaining samples */ - (*crossDotPtr) += WebRtcSpl_DotProductWithScale(targetPtr, buffer-lagcount, SUBL-lagcount, scale); - crossDotPtr++; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h b/src/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h deleted file mode 100644 index 8e097fe..0000000 --- a/src/modules/audio_coding/codecs/ilbc/augmented_cb_corr.h +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_AugmentedCbCorr.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_AUGMENTED_CB_CORR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_AUGMENTED_CB_CORR_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Calculate correlation between target and Augmented codebooks - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_AugmentedCbCorr( - WebRtc_Word16 *target, /* (i) Target vector */ - WebRtc_Word16 *buffer, /* (i) Memory buffer */ - WebRtc_Word16 *interpSamples, /* (i) buffer with - interpolated samples */ - WebRtc_Word32 *crossDot, /* (o) The cross correlation between - the target and the Augmented - vector */ - WebRtc_Word16 low, /* (i) Lag to start from (typically - 20) */ - WebRtc_Word16 high, /* (i) Lag to end at (typically 39 */ - WebRtc_Word16 scale); /* (i) Scale factor to use for - the crossDot */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/bw_expand.c b/src/modules/audio_coding/codecs/ilbc/bw_expand.c deleted file mode 100644 index a2287aa..0000000 --- a/src/modules/audio_coding/codecs/ilbc/bw_expand.c +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_BwExpand.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lpc bandwidth expansion - *---------------------------------------------------------------*/ - -/* The output is in the same domain as the input */ -void WebRtcIlbcfix_BwExpand( - WebRtc_Word16 *out, /* (o) the bandwidth expanded lpc coefficients */ - WebRtc_Word16 *in, /* (i) the lpc coefficients before bandwidth - expansion */ - WebRtc_Word16 *coef, /* (i) the bandwidth expansion factor Q15 */ - WebRtc_Word16 length /* (i) the length of lpc coefficient vectors */ - ) { - int i; - - out[0] = in[0]; - for (i = 1; i < length; i++) { - /* out[i] = coef[i] * in[i] with rounding. - in[] and out[] are in Q12 and coef[] is in Q15 - */ - out[i] = (WebRtc_Word16)((WEBRTC_SPL_MUL_16_16(coef[i], in[i])+16384)>>15); - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/bw_expand.h b/src/modules/audio_coding/codecs/ilbc/bw_expand.h deleted file mode 100644 index c9f3fab..0000000 --- a/src/modules/audio_coding/codecs/ilbc/bw_expand.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_BwExpand.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_BW_EXPAND_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lpc bandwidth expansion - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_BwExpand( - WebRtc_Word16 *out, /* (o) the bandwidth expanded lpc coefficients */ - WebRtc_Word16 *in, /* (i) the lpc coefficients before bandwidth - expansion */ - WebRtc_Word16 *coef, /* (i) the bandwidth expansion factor Q15 */ - WebRtc_Word16 length /* (i) the length of lpc coefficient vectors */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_construct.c b/src/modules/audio_coding/codecs/ilbc/cb_construct.c deleted file mode 100644 index 094a7e4..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_construct.c +++ /dev/null
@@ -1,67 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbConstruct.c - -******************************************************************/ - -#include "defines.h" -#include "gain_dequant.h" -#include "get_cd_vec.h" - -/*----------------------------------------------------------------* - * Construct decoded vector from codebook and gains. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_CbConstruct( - WebRtc_Word16 *decvector, /* (o) Decoded vector */ - WebRtc_Word16 *index, /* (i) Codebook indices */ - WebRtc_Word16 *gain_index, /* (i) Gain quantization indices */ - WebRtc_Word16 *mem, /* (i) Buffer for codevector construction */ - WebRtc_Word16 lMem, /* (i) Length of buffer */ - WebRtc_Word16 veclen /* (i) Length of vector */ - ){ - int j; - WebRtc_Word16 gain[CB_NSTAGES]; - /* Stack based */ - WebRtc_Word16 cbvec0[SUBL]; - WebRtc_Word16 cbvec1[SUBL]; - WebRtc_Word16 cbvec2[SUBL]; - WebRtc_Word32 a32; - WebRtc_Word16 *gainPtr; - - /* gain de-quantization */ - - gain[0] = WebRtcIlbcfix_GainDequant(gain_index[0], 16384, 0); - gain[1] = WebRtcIlbcfix_GainDequant(gain_index[1], gain[0], 1); - gain[2] = WebRtcIlbcfix_GainDequant(gain_index[2], gain[1], 2); - - /* codebook vector construction and construction of total vector */ - - /* Stack based */ - WebRtcIlbcfix_GetCbVec(cbvec0, mem, index[0], lMem, veclen); - WebRtcIlbcfix_GetCbVec(cbvec1, mem, index[1], lMem, veclen); - WebRtcIlbcfix_GetCbVec(cbvec2, mem, index[2], lMem, veclen); - - gainPtr = &gain[0]; - for (j=0;j<veclen;j++) { - a32 = WEBRTC_SPL_MUL_16_16(*gainPtr++, cbvec0[j]); - a32 += WEBRTC_SPL_MUL_16_16(*gainPtr++, cbvec1[j]); - a32 += WEBRTC_SPL_MUL_16_16(*gainPtr, cbvec2[j]); - gainPtr -= 2; - decvector[j] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(a32 + 8192, 14); - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_construct.h b/src/modules/audio_coding/codecs/ilbc/cb_construct.h deleted file mode 100644 index bec759f..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_construct.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbConstruct.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_CONSTRUCT_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Construct decoded vector from codebook and gains. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_CbConstruct( - WebRtc_Word16 *decvector, /* (o) Decoded vector */ - WebRtc_Word16 *index, /* (i) Codebook indices */ - WebRtc_Word16 *gain_index, /* (i) Gain quantization indices */ - WebRtc_Word16 *mem, /* (i) Buffer for codevector construction */ - WebRtc_Word16 lMem, /* (i) Length of buffer */ - WebRtc_Word16 veclen /* (i) Length of vector */ - ); - - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy.c b/src/modules/audio_coding/codecs/ilbc/cb_mem_energy.c deleted file mode 100644 index 8613fa2..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy.c +++ /dev/null
@@ -1,79 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergy.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "cb_mem_energy_calc.h" - -/*----------------------------------------------------------------* - * Function WebRtcIlbcfix_CbMemEnergy computes the energy of all - * the vectors in the codebook memory that will be used in the - * following search for the best match. - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CbMemEnergy( - WebRtc_Word16 range, - WebRtc_Word16 *CB, /* (i) The CB memory (1:st section) */ - WebRtc_Word16 *filteredCB, /* (i) The filtered CB memory (2:nd section) */ - WebRtc_Word16 lMem, /* (i) Length of the CB memory */ - WebRtc_Word16 lTarget, /* (i) Length of the target vector */ - WebRtc_Word16 *energyW16, /* (o) Energy in the CB vectors */ - WebRtc_Word16 *energyShifts, /* (o) Shift value of the energy */ - WebRtc_Word16 scale, /* (i) The scaling of all energy values */ - WebRtc_Word16 base_size /* (i) Index to where the energy values should be stored */ - ) { - WebRtc_Word16 *ppi, *ppo, *pp; - WebRtc_Word32 energy, tmp32; - - /* Compute the energy and store it in a vector. Also the - * corresponding shift values are stored. The energy values - * are reused in all three stages. */ - - /* Calculate the energy in the first block of 'lTarget' sampels. */ - ppi = CB+lMem-lTarget-1; - ppo = CB+lMem-1; - - pp=CB+lMem-lTarget; - energy = WebRtcSpl_DotProductWithScale( pp, pp, lTarget, scale); - - /* Normalize the energy and store the number of shifts */ - energyShifts[0] = (WebRtc_Word16)WebRtcSpl_NormW32(energy); - tmp32 = WEBRTC_SPL_LSHIFT_W32(energy, energyShifts[0]); - energyW16[0] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32, 16); - - /* Compute the energy of the rest of the cb memory - * by step wise adding and subtracting the next - * sample and the last sample respectively. */ - WebRtcIlbcfix_CbMemEnergyCalc(energy, range, ppi, ppo, energyW16, energyShifts, scale, 0); - - /* Next, precompute the energy values for the filtered cb section */ - energy=0; - pp=filteredCB+lMem-lTarget; - - energy = WebRtcSpl_DotProductWithScale( pp, pp, lTarget, scale); - - /* Normalize the energy and store the number of shifts */ - energyShifts[base_size] = (WebRtc_Word16)WebRtcSpl_NormW32(energy); - tmp32 = WEBRTC_SPL_LSHIFT_W32(energy, energyShifts[base_size]); - energyW16[base_size] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32, 16); - - ppi = filteredCB + lMem - 1 - lTarget; - ppo = filteredCB + lMem - 1; - - WebRtcIlbcfix_CbMemEnergyCalc(energy, range, ppi, ppo, energyW16, energyShifts, scale, base_size); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy.h b/src/modules/audio_coding/codecs/ilbc/cb_mem_energy.h deleted file mode 100644 index 1aa2b7b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergy.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_H_ - -void WebRtcIlbcfix_CbMemEnergy( - WebRtc_Word16 range, - WebRtc_Word16 *CB, /* (i) The CB memory (1:st section) */ - WebRtc_Word16 *filteredCB, /* (i) The filtered CB memory (2:nd section) */ - WebRtc_Word16 lMem, /* (i) Length of the CB memory */ - WebRtc_Word16 lTarget, /* (i) Length of the target vector */ - WebRtc_Word16 *energyW16, /* (o) Energy in the CB vectors */ - WebRtc_Word16 *energyShifts, /* (o) Shift value of the energy */ - WebRtc_Word16 scale, /* (i) The scaling of all energy values */ - WebRtc_Word16 base_size /* (i) Index to where the energy values should be stored */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c b/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c deleted file mode 100644 index 0c6f479..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.c +++ /dev/null
@@ -1,67 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyAugmentation.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -void WebRtcIlbcfix_CbMemEnergyAugmentation( - WebRtc_Word16 *interpSamples, /* (i) The interpolated samples */ - WebRtc_Word16 *CBmem, /* (i) The CB memory */ - WebRtc_Word16 scale, /* (i) The scaling of all energy values */ - WebRtc_Word16 base_size, /* (i) Index to where the energy values should be stored */ - WebRtc_Word16 *energyW16, /* (o) Energy in the CB vectors */ - WebRtc_Word16 *energyShifts /* (o) Shift value of the energy */ - ){ - WebRtc_Word32 energy, tmp32; - WebRtc_Word16 *ppe, *pp, *interpSamplesPtr; - WebRtc_Word16 *CBmemPtr, lagcount; - WebRtc_Word16 *enPtr=&energyW16[base_size-20]; - WebRtc_Word16 *enShPtr=&energyShifts[base_size-20]; - WebRtc_Word32 nrjRecursive; - - CBmemPtr = CBmem+147; - interpSamplesPtr = interpSamples; - - /* Compute the energy for the first (low-5) noninterpolated samples */ - nrjRecursive = WebRtcSpl_DotProductWithScale( CBmemPtr-19, CBmemPtr-19, 15, scale); - ppe = CBmemPtr - 20; - - for (lagcount=20; lagcount<=39; lagcount++) { - - /* Update the energy recursively to save complexity */ - nrjRecursive = nrjRecursive + - WEBRTC_SPL_MUL_16_16_RSFT(*ppe, *ppe, scale); - ppe--; - energy = nrjRecursive; - - /* interpolation */ - energy += WebRtcSpl_DotProductWithScale(interpSamplesPtr, interpSamplesPtr, 4, scale); - interpSamplesPtr += 4; - - /* Compute energy for the remaining samples */ - pp = CBmemPtr - lagcount; - energy += WebRtcSpl_DotProductWithScale(pp, pp, SUBL-lagcount, scale); - - /* Normalize the energy and store the number of shifts */ - (*enShPtr) = (WebRtc_Word16)WebRtcSpl_NormW32(energy); - tmp32 = WEBRTC_SPL_LSHIFT_W32(energy, (*enShPtr)); - (*enPtr) = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32, 16); - enShPtr++; - enPtr++; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h b/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h deleted file mode 100644 index 938b87e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_augmentation.h +++ /dev/null
@@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyAugmentation.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_AUGMENTATION_H_ - -void WebRtcIlbcfix_CbMemEnergyAugmentation( - WebRtc_Word16 *interpSamples, /* (i) The interpolated samples */ - WebRtc_Word16 *CBmem, /* (i) The CB memory */ - WebRtc_Word16 scale, /* (i) The scaling of all energy values */ - WebRtc_Word16 base_size, /* (i) Index to where the energy values should be stored */ - WebRtc_Word16 *energyW16, /* (o) Energy in the CB vectors */ - WebRtc_Word16 *energyShifts /* (o) Shift value of the energy */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c b/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c deleted file mode 100644 index 40bb708..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyCalc.c - -******************************************************************/ - -#include "defines.h" - -/* Compute the energy of the rest of the cb memory - * by step wise adding and subtracting the next - * sample and the last sample respectively */ -void WebRtcIlbcfix_CbMemEnergyCalc( - WebRtc_Word32 energy, /* (i) input start energy */ - WebRtc_Word16 range, /* (i) number of iterations */ - WebRtc_Word16 *ppi, /* (i) input pointer 1 */ - WebRtc_Word16 *ppo, /* (i) input pointer 2 */ - WebRtc_Word16 *energyW16, /* (o) Energy in the CB vectors */ - WebRtc_Word16 *energyShifts, /* (o) Shift value of the energy */ - WebRtc_Word16 scale, /* (i) The scaling of all energy values */ - WebRtc_Word16 base_size /* (i) Index to where the energy values should be stored */ - ) -{ - WebRtc_Word16 j,shft; - WebRtc_Word32 tmp; - WebRtc_Word16 *eSh_ptr; - WebRtc_Word16 *eW16_ptr; - - - eSh_ptr = &energyShifts[1+base_size]; - eW16_ptr = &energyW16[1+base_size]; - - for(j=0;j<range-1;j++) { - - /* Calculate next energy by a +/- - operation on the edge samples */ - tmp = WEBRTC_SPL_MUL_16_16(*ppi, *ppi); - tmp -= WEBRTC_SPL_MUL_16_16(*ppo, *ppo); - energy += WEBRTC_SPL_RSHIFT_W32(tmp, scale); - energy = WEBRTC_SPL_MAX(energy, 0); - - ppi--; - ppo--; - - /* Normalize the energy into a WebRtc_Word16 and store - the number of shifts */ - - shft = (WebRtc_Word16)WebRtcSpl_NormW32(energy); - *eSh_ptr++ = shft; - - tmp = WEBRTC_SPL_LSHIFT_W32(energy, shft); - *eW16_ptr++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp, 16); - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h b/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h deleted file mode 100644 index ee2e285..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.h +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbMemEnergyCalc.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_MEM_ENERGY_CALC_H_ - -void WebRtcIlbcfix_CbMemEnergyCalc( - WebRtc_Word32 energy, /* (i) input start energy */ - WebRtc_Word16 range, /* (i) number of iterations */ - WebRtc_Word16 *ppi, /* (i) input pointer 1 */ - WebRtc_Word16 *ppo, /* (i) input pointer 2 */ - WebRtc_Word16 *energyW16, /* (o) Energy in the CB vectors */ - WebRtc_Word16 *energyShifts, /* (o) Shift value of the energy */ - WebRtc_Word16 scale, /* (i) The scaling of all energy values */ - WebRtc_Word16 base_size /* (i) Index to where the energy values should be stored */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_search.c b/src/modules/audio_coding/codecs/ilbc/cb_search.c deleted file mode 100644 index c51ccf7..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_search.c +++ /dev/null
@@ -1,396 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearch.c - -******************************************************************/ - -#include "defines.h" -#include "gain_quant.h" -#include "filtered_cb_vecs.h" -#include "constants.h" -#include "cb_mem_energy.h" -#include "interpolate_samples.h" -#include "cb_mem_energy_augmentation.h" -#include "cb_search_core.h" -#include "energy_inverse.h" -#include "augmented_cb_corr.h" -#include "cb_update_best_index.h" -#include "create_augmented_vec.h" - -/*----------------------------------------------------------------* - * Search routine for codebook encoding and gain quantization. - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CbSearch( - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i) the encoder state structure */ - WebRtc_Word16 *index, /* (o) Codebook indices */ - WebRtc_Word16 *gain_index, /* (o) Gain quantization indices */ - WebRtc_Word16 *intarget, /* (i) Target vector for encoding */ - WebRtc_Word16 *decResidual,/* (i) Decoded residual for codebook construction */ - WebRtc_Word16 lMem, /* (i) Length of buffer */ - WebRtc_Word16 lTarget, /* (i) Length of vector */ - WebRtc_Word16 *weightDenum,/* (i) weighting filter coefficients in Q12 */ - WebRtc_Word16 block /* (i) the subblock number */ - ) { - WebRtc_Word16 i, j, stage, range; - WebRtc_Word16 *pp, scale, tmp; - WebRtc_Word16 bits, temp1, temp2; - WebRtc_Word16 base_size; - WebRtc_Word32 codedEner, targetEner; - WebRtc_Word16 gains[CB_NSTAGES+1]; - WebRtc_Word16 *cb_vecPtr; - WebRtc_Word16 indexOffset, sInd, eInd; - WebRtc_Word32 CritMax=0; - WebRtc_Word16 shTotMax=WEBRTC_SPL_WORD16_MIN; - WebRtc_Word16 bestIndex=0; - WebRtc_Word16 bestGain=0; - WebRtc_Word16 indexNew, CritNewSh; - WebRtc_Word32 CritNew; - WebRtc_Word32 *cDotPtr; - WebRtc_Word16 noOfZeros; - WebRtc_Word16 *gainPtr; - WebRtc_Word32 t32, tmpW32; - WebRtc_Word16 *WebRtcIlbcfix_kGainSq5_ptr; - /* Stack based */ - WebRtc_Word16 CBbuf[CB_MEML+LPC_FILTERORDER+CB_HALFFILTERLEN]; - WebRtc_Word32 cDot[128]; - WebRtc_Word32 Crit[128]; - WebRtc_Word16 targetVec[SUBL+LPC_FILTERORDER]; - WebRtc_Word16 cbvectors[CB_MEML]; - WebRtc_Word16 codedVec[SUBL]; - WebRtc_Word16 interpSamples[20*4]; - WebRtc_Word16 interpSamplesFilt[20*4]; - WebRtc_Word16 energyW16[CB_EXPAND*128]; - WebRtc_Word16 energyShifts[CB_EXPAND*128]; - WebRtc_Word16 *inverseEnergy=energyW16; /* Reuse memory */ - WebRtc_Word16 *inverseEnergyShifts=energyShifts; /* Reuse memory */ - WebRtc_Word16 *buf = &CBbuf[LPC_FILTERORDER]; - WebRtc_Word16 *target = &targetVec[LPC_FILTERORDER]; - WebRtc_Word16 *aug_vec = (WebRtc_Word16*)cDot; /* length [SUBL], reuse memory */ - - /* Determine size of codebook sections */ - - base_size=lMem-lTarget+1; - if (lTarget==SUBL) { - base_size=lMem-19; - } - - /* weighting of the CB memory */ - noOfZeros=lMem-WebRtcIlbcfix_kFilterRange[block]; - WebRtcSpl_MemSetW16(&buf[-LPC_FILTERORDER], 0, noOfZeros+LPC_FILTERORDER); - WebRtcSpl_FilterARFastQ12( - decResidual+noOfZeros, buf+noOfZeros, - weightDenum, LPC_FILTERORDER+1, WebRtcIlbcfix_kFilterRange[block]); - - /* weighting of the target vector */ - WEBRTC_SPL_MEMCPY_W16(&target[-LPC_FILTERORDER], buf+noOfZeros+WebRtcIlbcfix_kFilterRange[block]-LPC_FILTERORDER, LPC_FILTERORDER); - WebRtcSpl_FilterARFastQ12( - intarget, target, - weightDenum, LPC_FILTERORDER+1, lTarget); - - /* Store target, towards the end codedVec is calculated as - the initial target minus the remaining target */ - WEBRTC_SPL_MEMCPY_W16(codedVec, target, lTarget); - - /* Find the highest absolute value to calculate proper - vector scale factor (so that it uses 12 bits) */ - temp1 = WebRtcSpl_MaxAbsValueW16(buf, (WebRtc_Word16)lMem); - temp2 = WebRtcSpl_MaxAbsValueW16(target, (WebRtc_Word16)lTarget); - - if ((temp1>0)&&(temp2>0)) { - temp1 = WEBRTC_SPL_MAX(temp1, temp2); - scale = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(temp1, temp1)); - } else { - /* temp1 or temp2 is negative (maximum was -32768) */ - scale = 30; - } - - /* Scale to so that a mul-add 40 times does not overflow */ - scale = scale - 25; - scale = WEBRTC_SPL_MAX(0, scale); - - /* Compute energy of the original target */ - targetEner = WebRtcSpl_DotProductWithScale(target, target, lTarget, scale); - - /* Prepare search over one more codebook section. This section - is created by filtering the original buffer with a filter. */ - WebRtcIlbcfix_FilteredCbVecs(cbvectors, buf, lMem, WebRtcIlbcfix_kFilterRange[block]); - - range = WebRtcIlbcfix_kSearchRange[block][0]; - - if(lTarget == SUBL) { - /* Create the interpolated samples and store them for use in all stages */ - - /* First section, non-filtered half of the cb */ - WebRtcIlbcfix_InterpolateSamples(interpSamples, buf, lMem); - - /* Second section, filtered half of the cb */ - WebRtcIlbcfix_InterpolateSamples(interpSamplesFilt, cbvectors, lMem); - - /* Compute the CB vectors' energies for the first cb section (non-filtered) */ - WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamples, buf, - scale, 20, energyW16, energyShifts); - - /* Compute the CB vectors' energies for the second cb section (filtered cb) */ - WebRtcIlbcfix_CbMemEnergyAugmentation(interpSamplesFilt, cbvectors, - scale, (WebRtc_Word16)(base_size+20), energyW16, energyShifts); - - /* Compute the CB vectors' energies and store them in the vector - * energyW16. Also the corresponding shift values are stored. The - * energy values are used in all three stages. */ - WebRtcIlbcfix_CbMemEnergy(range, buf, cbvectors, lMem, - lTarget, energyW16+20, energyShifts+20, scale, base_size); - - } else { - /* Compute the CB vectors' energies and store them in the vector - * energyW16. Also the corresponding shift values are stored. The - * energy values are used in all three stages. */ - WebRtcIlbcfix_CbMemEnergy(range, buf, cbvectors, lMem, - lTarget, energyW16, energyShifts, scale, base_size); - - /* Set the energy positions 58-63 and 122-127 to zero - (otherwise they are uninitialized) */ - WebRtcSpl_MemSetW16(energyW16+range, 0, (base_size-range)); - WebRtcSpl_MemSetW16(energyW16+range+base_size, 0, (base_size-range)); - } - - /* Calculate Inverse Energy (energyW16 is already normalized - and will contain the inverse energy in Q29 after this call */ - WebRtcIlbcfix_EnergyInverse(energyW16, base_size*CB_EXPAND); - - /* The gain value computed in the previous stage is used - * as an upper limit to what the next stage gain value - * is allowed to be. In stage 0, 16384 (1.0 in Q14) is used as - * the upper limit. */ - gains[0] = 16384; - - for (stage=0; stage<CB_NSTAGES; stage++) { - - /* Set up memories */ - range = WebRtcIlbcfix_kSearchRange[block][stage]; - - /* initialize search measures */ - CritMax=0; - shTotMax=-100; - bestIndex=0; - bestGain=0; - - /* loop over lags 40+ in the first codebook section, full search */ - cb_vecPtr = buf+lMem-lTarget; - - /* Calculate all the cross correlations (augmented part of CB) */ - if (lTarget==SUBL) { - WebRtcIlbcfix_AugmentedCbCorr(target, buf+lMem, - interpSamples, cDot, - 20, 39, scale); - cDotPtr=&cDot[20]; - } else { - cDotPtr=cDot; - } - /* Calculate all the cross correlations (main part of CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, range, scale, -1); - - /* Adjust the search range for the augmented vectors */ - if (lTarget==SUBL) { - range=WebRtcIlbcfix_kSearchRange[block][stage]+20; - } else { - range=WebRtcIlbcfix_kSearchRange[block][stage]; - } - - indexOffset=0; - - /* Search for best index in this part of the vector */ - WebRtcIlbcfix_CbSearchCore( - cDot, range, stage, inverseEnergy, - inverseEnergyShifts, Crit, - &indexNew, &CritNew, &CritNewSh); - - /* Update the global best index and the corresponding gain */ - WebRtcIlbcfix_CbUpdateBestIndex( - CritNew, CritNewSh, (WebRtc_Word16)(indexNew+indexOffset), cDot[indexNew+indexOffset], - inverseEnergy[indexNew+indexOffset], inverseEnergyShifts[indexNew+indexOffset], - &CritMax, &shTotMax, &bestIndex, &bestGain); - - sInd=bestIndex-(WebRtc_Word16)(CB_RESRANGE>>1); - eInd=sInd+CB_RESRANGE; - if (sInd<0) { - eInd-=sInd; - sInd=0; - } - if (eInd>=range) { - eInd=range-1; - sInd=eInd-CB_RESRANGE; - } - - range = WebRtcIlbcfix_kSearchRange[block][stage]; - - if (lTarget==SUBL) { - i=sInd; - if (sInd<20) { - WebRtcIlbcfix_AugmentedCbCorr(target, cbvectors+lMem, - interpSamplesFilt, cDot, - (WebRtc_Word16)(sInd+20), (WebRtc_Word16)(WEBRTC_SPL_MIN(39, (eInd+20))), scale); - i=20; - } - - cDotPtr=&cDot[WEBRTC_SPL_MAX(0,(20-sInd))]; - cb_vecPtr = cbvectors+lMem-20-i; - - /* Calculate the cross correlations (main part of the filtered CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, (WebRtc_Word16)(eInd-i+1), scale, -1); - - } else { - cDotPtr = cDot; - cb_vecPtr = cbvectors+lMem-lTarget-sInd; - - /* Calculate the cross correlations (main part of the filtered CB) */ - WebRtcSpl_CrossCorrelation(cDotPtr, target, cb_vecPtr, lTarget, (WebRtc_Word16)(eInd-sInd+1), scale, -1); - - } - - /* Adjust the search range for the augmented vectors */ - indexOffset=base_size+sInd; - - /* Search for best index in this part of the vector */ - WebRtcIlbcfix_CbSearchCore( - cDot, (WebRtc_Word16)(eInd-sInd+1), stage, inverseEnergy+indexOffset, - inverseEnergyShifts+indexOffset, Crit, - &indexNew, &CritNew, &CritNewSh); - - /* Update the global best index and the corresponding gain */ - WebRtcIlbcfix_CbUpdateBestIndex( - CritNew, CritNewSh, (WebRtc_Word16)(indexNew+indexOffset), cDot[indexNew], - inverseEnergy[indexNew+indexOffset], inverseEnergyShifts[indexNew+indexOffset], - &CritMax, &shTotMax, &bestIndex, &bestGain); - - index[stage] = bestIndex; - - - bestGain = WebRtcIlbcfix_GainQuant(bestGain, - (WebRtc_Word16)WEBRTC_SPL_ABS_W16(gains[stage]), stage, &gain_index[stage]); - - /* Extract the best (according to measure) codebook vector - Also adjust the index, so that the augmented vectors are last. - Above these vectors were first... - */ - - if(lTarget==(STATE_LEN-iLBCenc_inst->state_short_len)) { - - if(index[stage]<base_size) { - pp=buf+lMem-lTarget-index[stage]; - } else { - pp=cbvectors+lMem-lTarget- - index[stage]+base_size; - } - - } else { - - if (index[stage]<base_size) { - if (index[stage]>=20) { - /* Adjust index and extract vector */ - index[stage]-=20; - pp=buf+lMem-lTarget-index[stage]; - } else { - /* Adjust index and extract vector */ - index[stage]+=(base_size-20); - - WebRtcIlbcfix_CreateAugmentedVec((WebRtc_Word16)(index[stage]-base_size+40), - buf+lMem, aug_vec); - pp = aug_vec; - - } - } else { - - if ((index[stage] - base_size) >= 20) { - /* Adjust index and extract vector */ - index[stage]-=20; - pp=cbvectors+lMem-lTarget- - index[stage]+base_size; - } else { - /* Adjust index and extract vector */ - index[stage]+=(base_size-20); - WebRtcIlbcfix_CreateAugmentedVec((WebRtc_Word16)(index[stage]-2*base_size+40), - cbvectors+lMem, aug_vec); - pp = aug_vec; - } - } - } - - /* Subtract the best codebook vector, according - to measure, from the target vector */ - - WebRtcSpl_AddAffineVectorToVector(target, pp, (WebRtc_Word16)(-bestGain), (WebRtc_Word32)8192, (WebRtc_Word16)14, (int)lTarget); - - /* record quantized gain */ - gains[stage+1] = bestGain; - - } /* end of Main Loop. for (stage=0;... */ - - /* Calculte the coded vector (original target - what's left) */ - for (i=0;i<lTarget;i++) { - codedVec[i]-=target[i]; - } - - /* Gain adjustment for energy matching */ - codedEner = WebRtcSpl_DotProductWithScale(codedVec, codedVec, lTarget, scale); - - j=gain_index[0]; - - temp1 = (WebRtc_Word16)WebRtcSpl_NormW32(codedEner); - temp2 = (WebRtc_Word16)WebRtcSpl_NormW32(targetEner); - - if(temp1 < temp2) { - bits = 16 - temp1; - } else { - bits = 16 - temp2; - } - - tmp = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT(gains[1],gains[1], 14); - - targetEner = WEBRTC_SPL_MUL_16_16( - WEBRTC_SPL_SHIFT_W32(targetEner, -bits), tmp); - - tmpW32 = ((WebRtc_Word32)(gains[1]-1))<<1; - - /* Pointer to the table that contains - gain_sq5TblFIX * gain_sq5TblFIX in Q14 */ - gainPtr=(WebRtc_Word16*)WebRtcIlbcfix_kGainSq5Sq+gain_index[0]; - temp1 = (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(codedEner, -bits); - - WebRtcIlbcfix_kGainSq5_ptr = (WebRtc_Word16*)&WebRtcIlbcfix_kGainSq5[j]; - - /* targetEner and codedEner are in Q(-2*scale) */ - for (i=gain_index[0];i<32;i++) { - - /* Change the index if - (codedEnergy*gainTbl[i]*gainTbl[i])<(targetEn*gain[0]*gain[0]) AND - gainTbl[i] < 2*gain[0] - */ - - t32 = WEBRTC_SPL_MUL_16_16(temp1, (*gainPtr)); - t32 = t32 - targetEner; - if (t32 < 0) { - if ((*WebRtcIlbcfix_kGainSq5_ptr) < tmpW32) { - j=i; - WebRtcIlbcfix_kGainSq5_ptr = (WebRtc_Word16*)&WebRtcIlbcfix_kGainSq5[i]; - } - } - gainPtr++; - } - gain_index[0]=j; - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_search.h b/src/modules/audio_coding/codecs/ilbc/cb_search.h deleted file mode 100644 index e4ad4b5..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_search.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearch.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_H_ - -void WebRtcIlbcfix_CbSearch( - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i) the encoder state structure */ - WebRtc_Word16 *index, /* (o) Codebook indices */ - WebRtc_Word16 *gain_index, /* (o) Gain quantization indices */ - WebRtc_Word16 *intarget, /* (i) Target vector for encoding */ - WebRtc_Word16 *decResidual,/* (i) Decoded residual for codebook construction */ - WebRtc_Word16 lMem, /* (i) Length of buffer */ - WebRtc_Word16 lTarget, /* (i) Length of vector */ - WebRtc_Word16 *weightDenum,/* (i) weighting filter coefficients in Q12 */ - WebRtc_Word16 block /* (i) the subblock number */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_search_core.c b/src/modules/audio_coding/codecs/ilbc/cb_search_core.c deleted file mode 100644 index 711e2df..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_search_core.c +++ /dev/null
@@ -1,113 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearchCore.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -void WebRtcIlbcfix_CbSearchCore( - WebRtc_Word32 *cDot, /* (i) Cross Correlation */ - WebRtc_Word16 range, /* (i) Search range */ - WebRtc_Word16 stage, /* (i) Stage of this search */ - WebRtc_Word16 *inverseEnergy, /* (i) Inversed energy */ - WebRtc_Word16 *inverseEnergyShift, /* (i) Shifts of inversed energy - with the offset 2*16-29 */ - WebRtc_Word32 *Crit, /* (o) The criteria */ - WebRtc_Word16 *bestIndex, /* (o) Index that corresponds to - maximum criteria (in this - vector) */ - WebRtc_Word32 *bestCrit, /* (o) Value of critera for the - chosen index */ - WebRtc_Word16 *bestCritSh) /* (o) The domain of the chosen - criteria */ -{ - WebRtc_Word32 maxW32, tmp32; - WebRtc_Word16 max, sh, tmp16; - int i; - WebRtc_Word32 *cDotPtr; - WebRtc_Word16 cDotSqW16; - WebRtc_Word16 *inverseEnergyPtr; - WebRtc_Word32 *critPtr; - WebRtc_Word16 *inverseEnergyShiftPtr; - - /* Don't allow negative values for stage 0 */ - if (stage==0) { - cDotPtr=cDot; - for (i=0;i<range;i++) { - *cDotPtr=WEBRTC_SPL_MAX(0, (*cDotPtr)); - cDotPtr++; - } - } - - /* Normalize cDot to WebRtc_Word16, calculate the square of cDot and store the upper WebRtc_Word16 */ - maxW32 = WebRtcSpl_MaxAbsValueW32(cDot, range); - - sh = (WebRtc_Word16)WebRtcSpl_NormW32(maxW32); - cDotPtr = cDot; - inverseEnergyPtr = inverseEnergy; - critPtr = Crit; - inverseEnergyShiftPtr=inverseEnergyShift; - max=WEBRTC_SPL_WORD16_MIN; - - for (i=0;i<range;i++) { - /* Calculate cDot*cDot and put the result in a WebRtc_Word16 */ - tmp32 = WEBRTC_SPL_LSHIFT_W32(*cDotPtr,sh); - tmp16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32,16); - cDotSqW16 = (WebRtc_Word16)(((WebRtc_Word32)(tmp16)*(tmp16))>>16); - - /* Calculate the criteria (cDot*cDot/energy) */ - *critPtr=WEBRTC_SPL_MUL_16_16(cDotSqW16, (*inverseEnergyPtr)); - - /* Extract the maximum shift value under the constraint - that the criteria is not zero */ - if ((*critPtr)!=0) { - max = WEBRTC_SPL_MAX((*inverseEnergyShiftPtr), max); - } - - inverseEnergyPtr++; - inverseEnergyShiftPtr++; - critPtr++; - cDotPtr++; - } - - /* If no max shifts still at initialization value, set shift to zero */ - if (max==WEBRTC_SPL_WORD16_MIN) { - max = 0; - } - - /* Modify the criterias, so that all of them use the same Q domain */ - critPtr=Crit; - inverseEnergyShiftPtr=inverseEnergyShift; - for (i=0;i<range;i++) { - /* Guarantee that the shift value is less than 16 - in order to simplify for DSP's (and guard against >31) */ - tmp16 = WEBRTC_SPL_MIN(16, max-(*inverseEnergyShiftPtr)); - - (*critPtr)=WEBRTC_SPL_SHIFT_W32((*critPtr),-tmp16); - critPtr++; - inverseEnergyShiftPtr++; - } - - /* Find the index of the best value */ - *bestIndex = WebRtcSpl_MaxIndexW32(Crit, range); - *bestCrit = Crit[*bestIndex]; - - /* Calculate total shifts of this criteria */ - *bestCritSh = 32 - 2*sh + max; - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_search_core.h b/src/modules/audio_coding/codecs/ilbc/cb_search_core.h deleted file mode 100644 index e074c52..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_search_core.h +++ /dev/null
@@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbSearchCore.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_CORE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_SEARCH_CORE_H_ - -#include "defines.h" - -void WebRtcIlbcfix_CbSearchCore( - WebRtc_Word32 *cDot, /* (i) Cross Correlation */ - WebRtc_Word16 range, /* (i) Search range */ - WebRtc_Word16 stage, /* (i) Stage of this search */ - WebRtc_Word16 *inverseEnergy, /* (i) Inversed energy */ - WebRtc_Word16 *inverseEnergyShift, /* (i) Shifts of inversed energy - with the offset 2*16-29 */ - WebRtc_Word32 *Crit, /* (o) The criteria */ - WebRtc_Word16 *bestIndex, /* (o) Index that corresponds to - maximum criteria (in this - vector) */ - WebRtc_Word32 *bestCrit, /* (o) Value of critera for the - chosen index */ - WebRtc_Word16 *bestCritSh); /* (o) The domain of the chosen - criteria */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_update_best_index.c b/src/modules/audio_coding/codecs/ilbc/cb_update_best_index.c deleted file mode 100644 index bf85408..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_update_best_index.c +++ /dev/null
@@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbUpdateBestIndex.c - -******************************************************************/ - -#include "defines.h" -#include "cb_update_best_index.h" -#include "constants.h" - -void WebRtcIlbcfix_CbUpdateBestIndex( - WebRtc_Word32 CritNew, /* (i) New Potentially best Criteria */ - WebRtc_Word16 CritNewSh, /* (i) Shift value of above Criteria */ - WebRtc_Word16 IndexNew, /* (i) Index of new Criteria */ - WebRtc_Word32 cDotNew, /* (i) Cross dot of new index */ - WebRtc_Word16 invEnergyNew, /* (i) Inversed energy new index */ - WebRtc_Word16 energyShiftNew, /* (i) Energy shifts of new index */ - WebRtc_Word32 *CritMax, /* (i/o) Maximum Criteria (so far) */ - WebRtc_Word16 *shTotMax, /* (i/o) Shifts of maximum criteria */ - WebRtc_Word16 *bestIndex, /* (i/o) Index that corresponds to - maximum criteria */ - WebRtc_Word16 *bestGain) /* (i/o) Gain in Q14 that corresponds - to maximum criteria */ -{ - WebRtc_Word16 shOld, shNew, tmp16; - WebRtc_Word16 scaleTmp; - WebRtc_Word32 gainW32; - - /* Normalize the new and old Criteria to the same domain */ - if (CritNewSh>(*shTotMax)) { - shOld=WEBRTC_SPL_MIN(31,CritNewSh-(*shTotMax)); - shNew=0; - } else { - shOld=0; - shNew=WEBRTC_SPL_MIN(31,(*shTotMax)-CritNewSh); - } - - /* Compare the two criterias. If the new one is better, - calculate the gain and store this index as the new best one - */ - - if (WEBRTC_SPL_RSHIFT_W32(CritNew, shNew)> - WEBRTC_SPL_RSHIFT_W32((*CritMax),shOld)) { - - tmp16 = (WebRtc_Word16)WebRtcSpl_NormW32(cDotNew); - tmp16 = 16 - tmp16; - - /* Calculate the gain in Q14 - Compensate for inverseEnergyshift in Q29 and that the energy - value was stored in a WebRtc_Word16 (shifted down 16 steps) - => 29-14+16 = 31 */ - - scaleTmp = -energyShiftNew-tmp16+31; - scaleTmp = WEBRTC_SPL_MIN(31, scaleTmp); - - gainW32 = WEBRTC_SPL_MUL_16_16_RSFT( - ((WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(cDotNew, -tmp16)), invEnergyNew, scaleTmp); - - /* Check if criteria satisfies Gain criteria (max 1.3) - if it is larger set the gain to 1.3 - (slightly different from FLP version) - */ - if (gainW32>21299) { - *bestGain=21299; - } else if (gainW32<-21299) { - *bestGain=-21299; - } else { - *bestGain=(WebRtc_Word16)gainW32; - } - - *CritMax=CritNew; - *shTotMax=CritNewSh; - *bestIndex = IndexNew; - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/cb_update_best_index.h b/src/modules/audio_coding/codecs/ilbc/cb_update_best_index.h deleted file mode 100644 index 9015187..0000000 --- a/src/modules/audio_coding/codecs/ilbc/cb_update_best_index.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CbUpdateBestIndex.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_UPDATE_BEST_INDEX_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CB_UPDATE_BEST_INDEX_H_ - -#include "defines.h" - -void WebRtcIlbcfix_CbUpdateBestIndex( - WebRtc_Word32 CritNew, /* (i) New Potentially best Criteria */ - WebRtc_Word16 CritNewSh, /* (i) Shift value of above Criteria */ - WebRtc_Word16 IndexNew, /* (i) Index of new Criteria */ - WebRtc_Word32 cDotNew, /* (i) Cross dot of new index */ - WebRtc_Word16 invEnergyNew, /* (i) Inversed energy new index */ - WebRtc_Word16 energyShiftNew, /* (i) Energy shifts of new index */ - WebRtc_Word32 *CritMax, /* (i/o) Maximum Criteria (so far) */ - WebRtc_Word16 *shTotMax, /* (i/o) Shifts of maximum criteria */ - WebRtc_Word16 *bestIndex, /* (i/o) Index that corresponds to - maximum criteria */ - WebRtc_Word16 *bestGain); /* (i/o) Gain in Q14 that corresponds - to maximum criteria */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/chebyshev.c b/src/modules/audio_coding/codecs/ilbc/chebyshev.c deleted file mode 100644 index 90108ff..0000000 --- a/src/modules/audio_coding/codecs/ilbc/chebyshev.c +++ /dev/null
@@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Chebyshev.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*------------------------------------------------------------------* - * Calculate the Chevyshev polynomial series - * F(w) = 2*exp(-j5w)*C(x) - * C(x) = (T_0(x) + f(1)T_1(x) + ... + f(4)T_1(x) + f(5)/2) - * T_i(x) is the i:th order Chebyshev polynomial - *------------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_Chebyshev( - /* (o) Result of C(x) */ - WebRtc_Word16 x, /* (i) Value to the Chevyshev polynomial */ - WebRtc_Word16 *f /* (i) The coefficients in the polynomial */ - ) { - WebRtc_Word16 b1_high, b1_low; /* Use the high, low format to increase the accuracy */ - WebRtc_Word32 b2; - WebRtc_Word32 tmp1W32; - WebRtc_Word32 tmp2W32; - int i; - - b2 = (WebRtc_Word32)0x1000000; /* b2 = 1.0 (Q23) */ - /* Calculate b1 = 2*x + f[1] */ - tmp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)x, 10); - tmp1W32 += WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)f[1], 14); - - for (i = 2; i < 5; i++) { - tmp2W32 = tmp1W32; - - /* Split b1 (in tmp1W32) into a high and low part */ - b1_high = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp1W32, 16); - b1_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp1W32-WEBRTC_SPL_LSHIFT_W32(((WebRtc_Word32)b1_high),16), 1); - - /* Calculate 2*x*b1-b2+f[i] */ - tmp1W32 = WEBRTC_SPL_LSHIFT_W32( (WEBRTC_SPL_MUL_16_16(b1_high, x) + - WEBRTC_SPL_MUL_16_16_RSFT(b1_low, x, 15)), 2); - - tmp1W32 -= b2; - tmp1W32 += WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)f[i], 14); - - /* Update b2 for next round */ - b2 = tmp2W32; - } - - /* Split b1 (in tmp1W32) into a high and low part */ - b1_high = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp1W32, 16); - b1_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp1W32-WEBRTC_SPL_LSHIFT_W32(((WebRtc_Word32)b1_high),16), 1); - - /* tmp1W32 = x*b1 - b2 + f[i]/2 */ - tmp1W32 = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(b1_high, x), 1) + - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16_RSFT(b1_low, x, 15), 1); - - tmp1W32 -= b2; - tmp1W32 += WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)f[i], 13); - - /* Handle overflows and set to maximum or minimum WebRtc_Word16 instead */ - if (tmp1W32>((WebRtc_Word32)33553408)) { - return(WEBRTC_SPL_WORD16_MAX); - } else if (tmp1W32<((WebRtc_Word32)-33554432)) { - return(WEBRTC_SPL_WORD16_MIN); - } else { - return((WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp1W32, 10)); - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/chebyshev.h b/src/modules/audio_coding/codecs/ilbc/chebyshev.h deleted file mode 100644 index 57aab99..0000000 --- a/src/modules/audio_coding/codecs/ilbc/chebyshev.h +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Chebyshev.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CHEBYSHEV_H_ - -#include "defines.h" - -/*------------------------------------------------------------------* - * Calculate the Chevyshev polynomial series - * F(w) = 2*exp(-j5w)*C(x) - * C(x) = (T_0(x) + f(1)T_1(x) + ... + f(4)T_1(x) + f(5)/2) - * T_i(x) is the i:th order Chebyshev polynomial - *------------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_Chebyshev( - /* (o) Result of C(x) */ - WebRtc_Word16 x, /* (i) Value to the Chevyshev polynomial */ - WebRtc_Word16 *f /* (i) The coefficients in the polynomial */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/comp_corr.c b/src/modules/audio_coding/codecs/ilbc/comp_corr.c deleted file mode 100644 index 3d7f93e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/comp_corr.c +++ /dev/null
@@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CompCorr.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Compute cross correlation and pitch gain for pitch prediction - * of last subframe at given lag. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_CompCorr( - WebRtc_Word32 *corr, /* (o) cross correlation */ - WebRtc_Word32 *ener, /* (o) energy */ - WebRtc_Word16 *buffer, /* (i) signal buffer */ - WebRtc_Word16 lag, /* (i) pitch lag */ - WebRtc_Word16 bLen, /* (i) length of buffer */ - WebRtc_Word16 sRange, /* (i) correlation search length */ - WebRtc_Word16 scale /* (i) number of rightshifts to use */ - ){ - WebRtc_Word16 *w16ptr; - - w16ptr=&buffer[bLen-sRange-lag]; - - /* Calculate correlation and energy */ - (*corr)=WebRtcSpl_DotProductWithScale(&buffer[bLen-sRange], w16ptr, sRange, scale); - (*ener)=WebRtcSpl_DotProductWithScale(w16ptr, w16ptr, sRange, scale); - - /* For zero energy set the energy to 0 in order to avoid potential - problems for coming divisions */ - if (*ener == 0) { - *corr = 0; - *ener = 1; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/comp_corr.h b/src/modules/audio_coding/codecs/ilbc/comp_corr.h deleted file mode 100644 index cd46532..0000000 --- a/src/modules/audio_coding/codecs/ilbc/comp_corr.h +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CompCorr.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_COMP_CORR_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Compute cross correlation and pitch gain for pitch prediction - * of last subframe at given lag. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_CompCorr( - WebRtc_Word32 *corr, /* (o) cross correlation */ - WebRtc_Word32 *ener, /* (o) energy */ - WebRtc_Word16 *buffer, /* (i) signal buffer */ - WebRtc_Word16 lag, /* (i) pitch lag */ - WebRtc_Word16 bLen, /* (i) length of buffer */ - WebRtc_Word16 sRange, /* (i) correlation search length */ - WebRtc_Word16 scale /* (i) number of rightshifts to use */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/constants.c b/src/modules/audio_coding/codecs/ilbc/constants.c deleted file mode 100644 index 5ebe9be..0000000 --- a/src/modules/audio_coding/codecs/ilbc/constants.c +++ /dev/null
@@ -1,666 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - constants.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/* HP Filters {b[0] b[1] b[2] -a[1] -a[2]} */ - -const WebRtc_Word16 WebRtcIlbcfix_kHpInCoefs[5] = {3798, -7596, 3798, 7807, -3733}; -const WebRtc_Word16 WebRtcIlbcfix_kHpOutCoefs[5] = {3849, -7699, 3849, 7918, -3833}; - -/* Window in Q11 to window the energies of the 5 choises (3 for 20ms) in the choise for - the 80 sample start state -*/ -const WebRtc_Word16 WebRtcIlbcfix_kStartSequenceEnrgWin[NSUB_MAX-1]= { - 1638, 1843, 2048, 1843, 1638 -}; - -/* LP Filter coeffs used for downsampling */ -const WebRtc_Word16 WebRtcIlbcfix_kLpFiltCoefs[FILTERORDER_DS_PLUS1]= { - -273, 512, 1297, 1696, 1297, 512, -273 -}; - -/* Constants used in the LPC calculations */ - -/* Hanning LPC window (in Q15) */ -const WebRtc_Word16 WebRtcIlbcfix_kLpcWin[BLOCKL_MAX] = { - 6, 22, 50, 89, 139, 200, 272, 355, 449, 554, 669, 795, - 932, 1079, 1237, 1405, 1583, 1771, 1969, 2177, 2395, 2622, 2858, 3104, - 3359, 3622, 3894, 4175, 4464, 4761, 5066, 5379, 5699, 6026, 6361, 6702, - 7050, 7404, 7764, 8130, 8502, 8879, 9262, 9649, 10040, 10436, 10836, 11240, - 11647, 12058, 12471, 12887, 13306, 13726, 14148, 14572, 14997, 15423, 15850, 16277, - 16704, 17131, 17558, 17983, 18408, 18831, 19252, 19672, 20089, 20504, 20916, 21325, - 21730, 22132, 22530, 22924, 23314, 23698, 24078, 24452, 24821, 25185, 25542, 25893, - 26238, 26575, 26906, 27230, 27547, 27855, 28156, 28450, 28734, 29011, 29279, 29538, - 29788, 30029, 30261, 30483, 30696, 30899, 31092, 31275, 31448, 31611, 31764, 31906, - 32037, 32158, 32268, 32367, 32456, 32533, 32600, 32655, 32700, 32733, 32755, 32767, - 32767, 32755, 32733, 32700, 32655, 32600, 32533, 32456, 32367, 32268, 32158, 32037, - 31906, 31764, 31611, 31448, 31275, 31092, 30899, 30696, 30483, 30261, 30029, 29788, - 29538, 29279, 29011, 28734, 28450, 28156, 27855, 27547, 27230, 26906, 26575, 26238, - 25893, 25542, 25185, 24821, 24452, 24078, 23698, 23314, 22924, 22530, 22132, 21730, - 21325, 20916, 20504, 20089, 19672, 19252, 18831, 18408, 17983, 17558, 17131, 16704, - 16277, 15850, 15423, 14997, 14572, 14148, 13726, 13306, 12887, 12471, 12058, 11647, - 11240, 10836, 10436, 10040, 9649, 9262, 8879, 8502, 8130, 7764, 7404, 7050, - 6702, 6361, 6026, 5699, 5379, 5066, 4761, 4464, 4175, 3894, 3622, 3359, - 3104, 2858, 2622, 2395, 2177, 1969, 1771, 1583, 1405, 1237, 1079, 932, - 795, 669, 554, 449, 355, 272, 200, 139, 89, 50, 22, 6 -}; - -/* Asymmetric LPC window (in Q15)*/ -const WebRtc_Word16 WebRtcIlbcfix_kLpcAsymWin[BLOCKL_MAX] = { - 2, 7, 15, 27, 42, 60, 81, 106, 135, 166, 201, 239, - 280, 325, 373, 424, 478, 536, 597, 661, 728, 798, 872, 949, - 1028, 1111, 1197, 1287, 1379, 1474, 1572, 1674, 1778, 1885, 1995, 2108, - 2224, 2343, 2465, 2589, 2717, 2847, 2980, 3115, 3254, 3395, 3538, 3684, - 3833, 3984, 4138, 4295, 4453, 4615, 4778, 4944, 5112, 5283, 5456, 5631, - 5808, 5987, 6169, 6352, 6538, 6725, 6915, 7106, 7300, 7495, 7692, 7891, - 8091, 8293, 8497, 8702, 8909, 9118, 9328, 9539, 9752, 9966, 10182, 10398, - 10616, 10835, 11055, 11277, 11499, 11722, 11947, 12172, 12398, 12625, 12852, 13080, - 13309, 13539, 13769, 14000, 14231, 14463, 14695, 14927, 15160, 15393, 15626, 15859, - 16092, 16326, 16559, 16792, 17026, 17259, 17492, 17725, 17957, 18189, 18421, 18653, - 18884, 19114, 19344, 19573, 19802, 20030, 20257, 20483, 20709, 20934, 21157, 21380, - 21602, 21823, 22042, 22261, 22478, 22694, 22909, 23123, 23335, 23545, 23755, 23962, - 24168, 24373, 24576, 24777, 24977, 25175, 25371, 25565, 25758, 25948, 26137, 26323, - 26508, 26690, 26871, 27049, 27225, 27399, 27571, 27740, 27907, 28072, 28234, 28394, - 28552, 28707, 28860, 29010, 29157, 29302, 29444, 29584, 29721, 29855, 29987, 30115, - 30241, 30364, 30485, 30602, 30717, 30828, 30937, 31043, 31145, 31245, 31342, 31436, - 31526, 31614, 31699, 31780, 31858, 31933, 32005, 32074, 32140, 32202, 32261, 32317, - 32370, 32420, 32466, 32509, 32549, 32585, 32618, 32648, 32675, 32698, 32718, 32734, - 32748, 32758, 32764, 32767, 32767, 32667, 32365, 31863, 31164, 30274, 29197, 27939, - 26510, 24917, 23170, 21281, 19261, 17121, 14876, 12540, 10126, 7650, 5126, 2571 -}; - -/* Lag window for LPC (Q31) */ -const WebRtc_Word32 WebRtcIlbcfix_kLpcLagWin[LPC_FILTERORDER + 1]={ - 2147483647, 2144885453, 2137754373, 2125918626, 2109459810, - 2088483140, 2063130336, 2033564590, 1999977009, 1962580174, - 1921610283}; - -/* WebRtcIlbcfix_kLpcChirpSyntDenum vector in Q15 corresponding - * floating point vector {1 0.9025 0.9025^2 0.9025^3 ...} - */ -const WebRtc_Word16 WebRtcIlbcfix_kLpcChirpSyntDenum[LPC_FILTERORDER + 1] = { - 32767, 29573, 26690, 24087, - 21739, 19619, 17707, 15980, - 14422, 13016, 11747}; - -/* WebRtcIlbcfix_kLpcChirpWeightDenum in Q15 corresponding to - * floating point vector {1 0.4222 0.4222^2... } - */ -const WebRtc_Word16 WebRtcIlbcfix_kLpcChirpWeightDenum[LPC_FILTERORDER + 1] = { - 32767, 13835, 5841, 2466, 1041, 440, - 186, 78, 33, 14, 6}; - -/* LSF quantization Q13 domain */ -const WebRtc_Word16 WebRtcIlbcfix_kLsfCb[64 * 3 + 128 * 3 + 128 * 4] = { - 1273, 2238, 3696, - 3199, 5309, 8209, - 3606, 5671, 7829, - 2815, 5262, 8778, - 2608, 4027, 5493, - 1582, 3076, 5945, - 2983, 4181, 5396, - 2437, 4322, 6902, - 1861, 2998, 4613, - 2007, 3250, 5214, - 1388, 2459, 4262, - 2563, 3805, 5269, - 2036, 3522, 5129, - 1935, 4025, 6694, - 2744, 5121, 7338, - 2810, 4248, 5723, - 3054, 5405, 7745, - 1449, 2593, 4763, - 3411, 5128, 6596, - 2484, 4659, 7496, - 1668, 2879, 4818, - 1812, 3072, 5036, - 1638, 2649, 3900, - 2464, 3550, 4644, - 1853, 2900, 4158, - 2458, 4163, 5830, - 2556, 4036, 6254, - 2703, 4432, 6519, - 3062, 4953, 7609, - 1725, 3703, 6187, - 2221, 3877, 5427, - 2339, 3579, 5197, - 2021, 4633, 7037, - 2216, 3328, 4535, - 2961, 4739, 6667, - 2807, 3955, 5099, - 2788, 4501, 6088, - 1642, 2755, 4431, - 3341, 5282, 7333, - 2414, 3726, 5727, - 1582, 2822, 5269, - 2259, 3447, 4905, - 3117, 4986, 7054, - 1825, 3491, 5542, - 3338, 5736, 8627, - 1789, 3090, 5488, - 2566, 3720, 4923, - 2846, 4682, 7161, - 1950, 3321, 5976, - 1834, 3383, 6734, - 3238, 4769, 6094, - 2031, 3978, 5903, - 1877, 4068, 7436, - 2131, 4644, 8296, - 2764, 5010, 8013, - 2194, 3667, 6302, - 2053, 3127, 4342, - 3523, 6595, 10010, - 3134, 4457, 5748, - 3142, 5819, 9414, - 2223, 4334, 6353, - 2022, 3224, 4822, - 2186, 3458, 5544, - 2552, 4757, 6870, - 10905, 12917, 14578, - 9503, 11485, 14485, - 9518, 12494, 14052, - 6222, 7487, 9174, - 7759, 9186, 10506, - 8315, 12755, 14786, - 9609, 11486, 13866, - 8909, 12077, 13643, - 7369, 9054, 11520, - 9408, 12163, 14715, - 6436, 9911, 12843, - 7109, 9556, 11884, - 7557, 10075, 11640, - 6482, 9202, 11547, - 6463, 7914, 10980, - 8611, 10427, 12752, - 7101, 9676, 12606, - 7428, 11252, 13172, - 10197, 12955, 15842, - 7487, 10955, 12613, - 5575, 7858, 13621, - 7268, 11719, 14752, - 7476, 11744, 13795, - 7049, 8686, 11922, - 8234, 11314, 13983, - 6560, 11173, 14984, - 6405, 9211, 12337, - 8222, 12054, 13801, - 8039, 10728, 13255, - 10066, 12733, 14389, - 6016, 7338, 10040, - 6896, 8648, 10234, - 7538, 9170, 12175, - 7327, 12608, 14983, - 10516, 12643, 15223, - 5538, 7644, 12213, - 6728, 12221, 14253, - 7563, 9377, 12948, - 8661, 11023, 13401, - 7280, 8806, 11085, - 7723, 9793, 12333, - 12225, 14648, 16709, - 8768, 13389, 15245, - 10267, 12197, 13812, - 5301, 7078, 11484, - 7100, 10280, 11906, - 8716, 12555, 14183, - 9567, 12464, 15434, - 7832, 12305, 14300, - 7608, 10556, 12121, - 8913, 11311, 12868, - 7414, 9722, 11239, - 8666, 11641, 13250, - 9079, 10752, 12300, - 8024, 11608, 13306, - 10453, 13607, 16449, - 8135, 9573, 10909, - 6375, 7741, 10125, - 10025, 12217, 14874, - 6985, 11063, 14109, - 9296, 13051, 14642, - 8613, 10975, 12542, - 6583, 10414, 13534, - 6191, 9368, 13430, - 5742, 6859, 9260, - 7723, 9813, 13679, - 8137, 11291, 12833, - 6562, 8973, 10641, - 6062, 8462, 11335, - 6928, 8784, 12647, - 7501, 8784, 10031, - 8372, 10045, 12135, - 8191, 9864, 12746, - 5917, 7487, 10979, - 5516, 6848, 10318, - 6819, 9899, 11421, - 7882, 12912, 15670, - 9558, 11230, 12753, - 7752, 9327, 11472, - 8479, 9980, 11358, - 11418, 14072, 16386, - 7968, 10330, 14423, - 8423, 10555, 12162, - 6337, 10306, 14391, - 8850, 10879, 14276, - 6750, 11885, 15710, - 7037, 8328, 9764, - 6914, 9266, 13476, - 9746, 13949, 15519, - 11032, 14444, 16925, - 8032, 10271, 11810, - 10962, 13451, 15833, - 10021, 11667, 13324, - 6273, 8226, 12936, - 8543, 10397, 13496, - 7936, 10302, 12745, - 6769, 8138, 10446, - 6081, 7786, 11719, - 8637, 11795, 14975, - 8790, 10336, 11812, - 7040, 8490, 10771, - 7338, 10381, 13153, - 6598, 7888, 9358, - 6518, 8237, 12030, - 9055, 10763, 12983, - 6490, 10009, 12007, - 9589, 12023, 13632, - 6867, 9447, 10995, - 7930, 9816, 11397, - 10241, 13300, 14939, - 5830, 8670, 12387, - 9870, 11915, 14247, - 9318, 11647, 13272, - 6721, 10836, 12929, - 6543, 8233, 9944, - 8034, 10854, 12394, - 9112, 11787, 14218, - 9302, 11114, 13400, - 9022, 11366, 13816, - 6962, 10461, 12480, - 11288, 13333, 15222, - 7249, 8974, 10547, - 10566, 12336, 14390, - 6697, 11339, 13521, - 11851, 13944, 15826, - 6847, 8381, 11349, - 7509, 9331, 10939, - 8029, 9618, 11909, - 13973, 17644, 19647, 22474, - 14722, 16522, 20035, 22134, - 16305, 18179, 21106, 23048, - 15150, 17948, 21394, 23225, - 13582, 15191, 17687, 22333, - 11778, 15546, 18458, 21753, - 16619, 18410, 20827, 23559, - 14229, 15746, 17907, 22474, - 12465, 15327, 20700, 22831, - 15085, 16799, 20182, 23410, - 13026, 16935, 19890, 22892, - 14310, 16854, 19007, 22944, - 14210, 15897, 18891, 23154, - 14633, 18059, 20132, 22899, - 15246, 17781, 19780, 22640, - 16396, 18904, 20912, 23035, - 14618, 17401, 19510, 21672, - 15473, 17497, 19813, 23439, - 18851, 20736, 22323, 23864, - 15055, 16804, 18530, 20916, - 16490, 18196, 19990, 21939, - 11711, 15223, 21154, 23312, - 13294, 15546, 19393, 21472, - 12956, 16060, 20610, 22417, - 11628, 15843, 19617, 22501, - 14106, 16872, 19839, 22689, - 15655, 18192, 20161, 22452, - 12953, 15244, 20619, 23549, - 15322, 17193, 19926, 21762, - 16873, 18676, 20444, 22359, - 14874, 17871, 20083, 21959, - 11534, 14486, 19194, 21857, - 17766, 19617, 21338, 23178, - 13404, 15284, 19080, 23136, - 15392, 17527, 19470, 21953, - 14462, 16153, 17985, 21192, - 17734, 19750, 21903, 23783, - 16973, 19096, 21675, 23815, - 16597, 18936, 21257, 23461, - 15966, 17865, 20602, 22920, - 15416, 17456, 20301, 22972, - 18335, 20093, 21732, 23497, - 15548, 17217, 20679, 23594, - 15208, 16995, 20816, 22870, - 13890, 18015, 20531, 22468, - 13211, 15377, 19951, 22388, - 12852, 14635, 17978, 22680, - 16002, 17732, 20373, 23544, - 11373, 14134, 19534, 22707, - 17329, 19151, 21241, 23462, - 15612, 17296, 19362, 22850, - 15422, 19104, 21285, 23164, - 13792, 17111, 19349, 21370, - 15352, 17876, 20776, 22667, - 15253, 16961, 18921, 22123, - 14108, 17264, 20294, 23246, - 15785, 17897, 20010, 21822, - 17399, 19147, 20915, 22753, - 13010, 15659, 18127, 20840, - 16826, 19422, 22218, 24084, - 18108, 20641, 22695, 24237, - 18018, 20273, 22268, 23920, - 16057, 17821, 21365, 23665, - 16005, 17901, 19892, 23016, - 13232, 16683, 21107, 23221, - 13280, 16615, 19915, 21829, - 14950, 18575, 20599, 22511, - 16337, 18261, 20277, 23216, - 14306, 16477, 21203, 23158, - 12803, 17498, 20248, 22014, - 14327, 17068, 20160, 22006, - 14402, 17461, 21599, 23688, - 16968, 18834, 20896, 23055, - 15070, 17157, 20451, 22315, - 15419, 17107, 21601, 23946, - 16039, 17639, 19533, 21424, - 16326, 19261, 21745, 23673, - 16489, 18534, 21658, 23782, - 16594, 18471, 20549, 22807, - 18973, 21212, 22890, 24278, - 14264, 18674, 21123, 23071, - 15117, 16841, 19239, 23118, - 13762, 15782, 20478, 23230, - 14111, 15949, 20058, 22354, - 14990, 16738, 21139, 23492, - 13735, 16971, 19026, 22158, - 14676, 17314, 20232, 22807, - 16196, 18146, 20459, 22339, - 14747, 17258, 19315, 22437, - 14973, 17778, 20692, 23367, - 15715, 17472, 20385, 22349, - 15702, 18228, 20829, 23410, - 14428, 16188, 20541, 23630, - 16824, 19394, 21365, 23246, - 13069, 16392, 18900, 21121, - 12047, 16640, 19463, 21689, - 14757, 17433, 19659, 23125, - 15185, 16930, 19900, 22540, - 16026, 17725, 19618, 22399, - 16086, 18643, 21179, 23472, - 15462, 17248, 19102, 21196, - 17368, 20016, 22396, 24096, - 12340, 14475, 19665, 23362, - 13636, 16229, 19462, 22728, - 14096, 16211, 19591, 21635, - 12152, 14867, 19943, 22301, - 14492, 17503, 21002, 22728, - 14834, 16788, 19447, 21411, - 14650, 16433, 19326, 22308, - 14624, 16328, 19659, 23204, - 13888, 16572, 20665, 22488, - 12977, 16102, 18841, 22246, - 15523, 18431, 21757, 23738, - 14095, 16349, 18837, 20947, - 13266, 17809, 21088, 22839, - 15427, 18190, 20270, 23143, - 11859, 16753, 20935, 22486, - 12310, 17667, 21736, 23319, - 14021, 15926, 18702, 22002, - 12286, 15299, 19178, 21126, - 15703, 17491, 21039, 23151, - 12272, 14018, 18213, 22570, - 14817, 16364, 18485, 22598, - 17109, 19683, 21851, 23677, - 12657, 14903, 19039, 22061, - 14713, 16487, 20527, 22814, - 14635, 16726, 18763, 21715, - 15878, 18550, 20718, 22906 -}; - -const WebRtc_Word16 WebRtcIlbcfix_kLsfDimCb[LSF_NSPLIT] = {3, 3, 4}; -const WebRtc_Word16 WebRtcIlbcfix_kLsfSizeCb[LSF_NSPLIT] = {64,128,128}; - -const WebRtc_Word16 WebRtcIlbcfix_kLsfMean[LPC_FILTERORDER] = { - 2308, 3652, 5434, 7885, - 10255, 12559, 15160, 17513, - 20328, 22752}; - -const WebRtc_Word16 WebRtcIlbcfix_kLspMean[LPC_FILTERORDER] = { - 31476, 29565, 25819, 18725, 10276, - 1236, -9049, -17600, -25884, -30618 -}; - -/* Q14 */ -const WebRtc_Word16 WebRtcIlbcfix_kLsfWeight20ms[4] = {12288, 8192, 4096, 0}; -const WebRtc_Word16 WebRtcIlbcfix_kLsfWeight30ms[6] = {8192, 16384, 10923, 5461, 0, 0}; - -/* - cos(x) in Q15 - WebRtcIlbcfix_kCos[i] = cos(pi*i/64.0) - used in WebRtcIlbcfix_Lsp2Lsf() -*/ - -const WebRtc_Word16 WebRtcIlbcfix_kCos[64] = { - 32767, 32729, 32610, 32413, 32138, 31786, 31357, 30853, - 30274, 29622, 28899, 28106, 27246, 26320, 25330, 24279, - 23170, 22006, 20788, 19520, 18205, 16846, 15447, 14010, - 12540, 11039, 9512, 7962, 6393, 4808, 3212, 1608, - 0, -1608, -3212, -4808, -6393, -7962, -9512, -11039, - -12540, -14010, -15447, -16846, -18205, -19520, -20788, -22006, - -23170, -24279, -25330, -26320, -27246, -28106, -28899, -29622, - -30274, -30853, -31357, -31786, -32138, -32413, -32610, -32729 -}; - -/* - Derivative in Q19, used to interpolate between the - WebRtcIlbcfix_kCos[] values to get a more exact y = cos(x) -*/ -const WebRtc_Word16 WebRtcIlbcfix_kCosDerivative[64] = { - -632, -1893, -3150, -4399, -5638, -6863, -8072, -9261, - -10428, -11570, -12684, -13767, -14817, -15832, -16808, -17744, - -18637, -19486, -20287, -21039, -21741, -22390, -22986, -23526, - -24009, -24435, -24801, -25108, -25354, -25540, -25664, -25726, - -25726, -25664, -25540, -25354, -25108, -24801, -24435, -24009, - -23526, -22986, -22390, -21741, -21039, -20287, -19486, -18637, - -17744, -16808, -15832, -14817, -13767, -12684, -11570, -10428, - -9261, -8072, -6863, -5638, -4399, -3150, -1893, -632}; - -/* - Table in Q15, used for a2lsf conversion - WebRtcIlbcfix_kCosGrid[i] = cos((2*pi*i)/(float)(2*COS_GRID_POINTS)); -*/ - -const WebRtc_Word16 WebRtcIlbcfix_kCosGrid[COS_GRID_POINTS + 1] = { - 32760, 32723, 32588, 32364, 32051, 31651, 31164, 30591, - 29935, 29196, 28377, 27481, 26509, 25465, 24351, 23170, - 21926, 20621, 19260, 17846, 16384, 14876, 13327, 11743, - 10125, 8480, 6812, 5126, 3425, 1714, 0, -1714, -3425, - -5126, -6812, -8480, -10125, -11743, -13327, -14876, - -16384, -17846, -19260, -20621, -21926, -23170, -24351, - -25465, -26509, -27481, -28377, -29196, -29935, -30591, - -31164, -31651, -32051, -32364, -32588, -32723, -32760 -}; - -/* - Derivative of y = acos(x) in Q12 - used in WebRtcIlbcfix_Lsp2Lsf() -*/ - -const WebRtc_Word16 WebRtcIlbcfix_kAcosDerivative[64] = { - -26887, -8812, -5323, -3813, -2979, -2444, -2081, -1811, - -1608, -1450, -1322, -1219, -1132, -1059, -998, -946, - -901, -861, -827, -797, -772, -750, -730, -713, - -699, -687, -677, -668, -662, -657, -654, -652, - -652, -654, -657, -662, -668, -677, -687, -699, - -713, -730, -750, -772, -797, -827, -861, -901, - -946, -998, -1059, -1132, -1219, -1322, -1450, -1608, - -1811, -2081, -2444, -2979, -3813, -5323, -8812, -26887 -}; - - -/* Tables for quantization of start state */ - -/* State quantization tables */ -const WebRtc_Word16 WebRtcIlbcfix_kStateSq3[8] = { /* Values in Q13 */ - -30473, -17838, -9257, -2537, - 3639, 10893, 19958, 32636 -}; - -/* This table defines the limits for the selection of the freqg - less or equal than value 0 => index = 0 - less or equal than value k => index = k -*/ -const WebRtc_Word32 WebRtcIlbcfix_kChooseFrgQuant[64] = { - 118, 163, 222, 305, 425, 604, - 851, 1174, 1617, 2222, 3080, 4191, - 5525, 7215, 9193, 11540, 14397, 17604, - 21204, 25209, 29863, 35720, 42531, 50375, - 59162, 68845, 80108, 93754, 110326, 129488, - 150654, 174328, 201962, 233195, 267843, 308239, - 354503, 405988, 464251, 531550, 608652, 697516, - 802526, 928793, 1080145, 1258120, 1481106, 1760881, - 2111111, 2546619, 3078825, 3748642, 4563142, 5573115, - 6887601, 8582108, 10797296, 14014513, 18625760, 25529599, - 37302935, 58819185, 109782723, WEBRTC_SPL_WORD32_MAX -}; - -const WebRtc_Word16 WebRtcIlbcfix_kScale[64] = { - /* Values in Q16 */ - 29485, 25003, 21345, 18316, 15578, 13128, 10973, 9310, 7955, - 6762, 5789, 4877, 4255, 3699, 3258, 2904, 2595, 2328, - 2123, 1932, 1785, 1631, 1493, 1370, 1260, 1167, 1083, - /* Values in Q21 */ - 32081, 29611, 27262, 25229, 23432, 21803, 20226, 18883, 17609, - 16408, 15311, 14327, 13390, 12513, 11693, 10919, 10163, 9435, - 8739, 8100, 7424, 6813, 6192, 5648, 5122, 4639, 4207, 3798, - 3404, 3048, 2706, 2348, 2036, 1713, 1393, 1087, 747 -}; - -/*frgq in fixpoint, but already computed like this: - for(i=0; i<64; i++){ - a = (pow(10,frgq[i])/4.5); - WebRtcIlbcfix_kFrgQuantMod[i] = round(a); - } - - Value 0 :36 in Q8 - 37:58 in Q5 - 59:63 in Q3 -*/ -const WebRtc_Word16 WebRtcIlbcfix_kFrgQuantMod[64] = { - /* First 37 values in Q8 */ - 569, 671, 786, 916, 1077, 1278, - 1529, 1802, 2109, 2481, 2898, 3440, - 3943, 4535, 5149, 5778, 6464, 7208, - 7904, 8682, 9397, 10285, 11240, 12246, - 13313, 14382, 15492, 16735, 18131, 19693, - 21280, 22912, 24624, 26544, 28432, 30488, - 32720, - /* 22 values in Q5 */ - 4383, 4684, 5012, 5363, 5739, 6146, - 6603, 7113, 7679, 8285, 9040, 9850, - 10838, 11882, 13103, 14467, 15950, 17669, - 19712, 22016, 24800, 28576, - /* 5 values in Q3 */ - 8240, 9792, 12040, 15440, 22472 -}; - -/* Constants for codebook search and creation */ - -/* Expansion filter to get additional cb section. - * Q12 and reversed compared to flp - */ -const WebRtc_Word16 WebRtcIlbcfix_kCbFiltersRev[CB_FILTERLEN]={ - -140, 446, -755, 3302, 2922, -590, 343, -138}; - -/* Weighting coefficients for short lags. - * [0.2 0.4 0.6 0.8] in Q15 */ -const WebRtc_Word16 WebRtcIlbcfix_kAlpha[4]={ - 6554, 13107, 19661, 26214}; - -/* Ranges for search and filters at different subframes */ - -const WebRtc_Word16 WebRtcIlbcfix_kSearchRange[5][CB_NSTAGES]={ - {58,58,58}, {108,44,44}, {108,108,108}, {108,108,108}, {108,108,108}}; - -const WebRtc_Word16 WebRtcIlbcfix_kFilterRange[5]={63, 85, 125, 147, 147}; - -/* Gain Quantization for the codebook gains of the 3 stages */ - -/* Q14 (one extra value (max WebRtc_Word16) to simplify for the search) */ -const WebRtc_Word16 WebRtcIlbcfix_kGainSq3[9]={ - -16384, -10813, -5407, 0, 4096, 8192, - 12288, 16384, 32767}; - -/* Q14 (one extra value (max WebRtc_Word16) to simplify for the search) */ -const WebRtc_Word16 WebRtcIlbcfix_kGainSq4[17]={ - -17203, -14746, -12288, -9830, -7373, -4915, - -2458, 0, 2458, 4915, 7373, 9830, - 12288, 14746, 17203, 19661, 32767}; - -/* Q14 (one extra value (max WebRtc_Word16) to simplify for the search) */ -const WebRtc_Word16 WebRtcIlbcfix_kGainSq5[33]={ - 614, 1229, 1843, 2458, 3072, 3686, - 4301, 4915, 5530, 6144, 6758, 7373, - 7987, 8602, 9216, 9830, 10445, 11059, - 11674, 12288, 12902, 13517, 14131, 14746, - 15360, 15974, 16589, 17203, 17818, 18432, - 19046, 19661, 32767}; - -/* Q14 gain_sq5Tbl squared in Q14 */ -const WebRtc_Word16 WebRtcIlbcfix_kGainSq5Sq[32] = { - 23, 92, 207, 368, 576, 829, - 1129, 1474, 1866, 2304, 2787, 3317, - 3893, 4516, 5184, 5897, 6658, 7464, - 8318, 9216, 10160, 11151, 12187, 13271, - 14400, 15574, 16796, 18062, 19377, 20736, - 22140, 23593 -}; - -const WebRtc_Word16* const WebRtcIlbcfix_kGain[3] = -{WebRtcIlbcfix_kGainSq5, WebRtcIlbcfix_kGainSq4, WebRtcIlbcfix_kGainSq3}; - - -/* Tables for the Enhancer, using upsamling factor 4 (ENH_UPS0 = 4) */ - -const WebRtc_Word16 WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1]={ - {0, 0, 0, 4096, 0, 0, 0}, - {64, -315, 1181, 3531, -436, 77, -64}, - {97, -509, 2464, 2464, -509, 97, -97}, - {77, -436, 3531, 1181, -315, 64, -77} -}; - -const WebRtc_Word16 WebRtcIlbcfix_kEnhWt[3] = { - 4800, 16384, 27968 /* Q16 */ -}; - -const WebRtc_Word16 WebRtcIlbcfix_kEnhPlocs[ENH_NBLOCKS_TOT] = { - 160, 480, 800, 1120, 1440, 1760, 2080, 2400 /* Q(-2) */ -}; - -/* PLC table */ - -const WebRtc_Word16 WebRtcIlbcfix_kPlcPerSqr[6] = { /* Grid points for square of periodiciy in Q15 */ - 839, 1343, 2048, 2998, 4247, 5849 -}; - -const WebRtc_Word16 WebRtcIlbcfix_kPlcPitchFact[6] = { /* Value of y=(x^4-0.4)/(0.7-0.4) in grid points in Q15 */ - 0, 5462, 10922, 16384, 21846, 27306 -}; - -const WebRtc_Word16 WebRtcIlbcfix_kPlcPfSlope[6] = { /* Slope of y=(x^4-0.4)/(0.7-0.4) in Q11 */ - 26667, 18729, 13653, 10258, 7901, 6214 -};
diff --git a/src/modules/audio_coding/codecs/ilbc/constants.h b/src/modules/audio_coding/codecs/ilbc/constants.h deleted file mode 100644 index f787f74..0000000 --- a/src/modules/audio_coding/codecs/ilbc/constants.h +++ /dev/null
@@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - constants.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CONSTANTS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CONSTANTS_H_ - -#include "defines.h" -#include "typedefs.h" - -/* high pass filters */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kHpInCoefs[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kHpOutCoefs[]; - -/* Window for start state decision */ -extern const WebRtc_Word16 WebRtcIlbcfix_kStartSequenceEnrgWin[]; - -/* low pass filter used for downsampling */ -extern const WebRtc_Word16 WebRtcIlbcfix_kLpFiltCoefs[]; - -/* LPC analysis and quantization */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kLpcWin[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLpcAsymWin[]; -extern const WebRtc_Word32 WebRtcIlbcfix_kLpcLagWin[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLpcChirpSyntDenum[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLpcChirpWeightDenum[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLsfDimCb[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLsfSizeCb[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLsfCb[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLsfWeight20ms[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLsfWeight30ms[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLsfMean[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kLspMean[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kCos[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kCosDerivative[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kCosGrid[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kAcosDerivative[]; - -/* state quantization tables */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kStateSq3[]; -extern const WebRtc_Word32 WebRtcIlbcfix_kChooseFrgQuant[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kScale[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kFrgQuantMod[]; - -/* Ranges for search and filters at different subframes */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kSearchRange[5][CB_NSTAGES]; -extern const WebRtc_Word16 WebRtcIlbcfix_kFilterRange[]; - -/* gain quantization tables */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kGainSq3[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kGainSq4[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kGainSq5[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kGainSq5Sq[]; -extern const WebRtc_Word16* const WebRtcIlbcfix_kGain[]; - -/* adaptive codebook definitions */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kCbFiltersRev[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kAlpha[]; - -/* enhancer definitions */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kEnhPolyPhaser[ENH_UPS0][ENH_FLO_MULT2_PLUS1]; -extern const WebRtc_Word16 WebRtcIlbcfix_kEnhWt[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kEnhPlocs[]; - -/* PLC tables */ - -extern const WebRtc_Word16 WebRtcIlbcfix_kPlcPerSqr[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kPlcPitchFact[]; -extern const WebRtc_Word16 WebRtcIlbcfix_kPlcPfSlope[]; - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/create_augmented_vec.c b/src/modules/audio_coding/codecs/ilbc/create_augmented_vec.c deleted file mode 100644 index f021c4d..0000000 --- a/src/modules/audio_coding/codecs/ilbc/create_augmented_vec.c +++ /dev/null
@@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CreateAugmentedVec.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * Recreate a specific codebook vector from the augmented part. - * - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CreateAugmentedVec( - WebRtc_Word16 index, /* (i) Index for the augmented vector to be created */ - WebRtc_Word16 *buffer, /* (i) Pointer to the end of the codebook memory that - is used for creation of the augmented codebook */ - WebRtc_Word16 *cbVec /* (o) The construced codebook vector */ - ) { - WebRtc_Word16 ilow; - WebRtc_Word16 *ppo, *ppi; - WebRtc_Word16 cbVecTmp[4]; - - ilow = index-4; - - /* copy the first noninterpolated part */ - ppo = buffer-index; - WEBRTC_SPL_MEMCPY_W16(cbVec, ppo, index); - - /* interpolation */ - ppo = buffer - 4; - ppi = buffer - index - 4; - - /* perform cbVec[ilow+k] = ((ppi[k]*alphaTbl[k])>>15) + ((ppo[k]*alphaTbl[3-k])>>15); - for k = 0..3 - */ - WebRtcSpl_ElementwiseVectorMult(&cbVec[ilow], ppi, WebRtcIlbcfix_kAlpha, 4, 15); - WebRtcSpl_ReverseOrderMultArrayElements(cbVecTmp, ppo, &WebRtcIlbcfix_kAlpha[3], 4, 15); - WebRtcSpl_AddVectorsAndShift(&cbVec[ilow], &cbVec[ilow], cbVecTmp, 4, 0); - - /* copy the second noninterpolated part */ - ppo = buffer - index; - WEBRTC_SPL_MEMCPY_W16(cbVec+index,ppo,(SUBL-index)); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/create_augmented_vec.h b/src/modules/audio_coding/codecs/ilbc/create_augmented_vec.h deleted file mode 100644 index 970a9be..0000000 --- a/src/modules/audio_coding/codecs/ilbc/create_augmented_vec.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_CreateAugmentedVec.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CREATE_AUGMENTED_VEC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_CREATE_AUGMENTED_VEC_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Recreate a specific codebook vector from the augmented part. - * - *----------------------------------------------------------------*/ - -void WebRtcIlbcfix_CreateAugmentedVec( - WebRtc_Word16 index, /* (i) Index for the augmented vector to be created */ - WebRtc_Word16 *buffer, /* (i) Pointer to the end of the codebook memory that - is used for creation of the augmented codebook */ - WebRtc_Word16 *cbVec /* (o) The construced codebook vector */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/decode.c b/src/modules/audio_coding/codecs/ilbc/decode.c deleted file mode 100644 index 3bca764..0000000 --- a/src/modules/audio_coding/codecs/ilbc/decode.c +++ /dev/null
@@ -1,243 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Decode.c - -******************************************************************/ - -#include "defines.h" -#include "simple_lsf_dequant.h" -#include "decoder_interpolate_lsf.h" -#include "index_conv_dec.h" -#include "do_plc.h" -#include "constants.h" -#include "enhancer_interface.h" -#include "xcorr_coef.h" -#include "lsf_check.h" -#include "decode_residual.h" -#include "unpack_bits.h" -#include "hp_output.h" -#ifndef WEBRTC_BIG_ENDIAN -#include "swap_bytes.h" -#endif - -/*----------------------------------------------------------------* - * main decoder function - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecodeImpl( - WebRtc_Word16 *decblock, /* (o) decoded signal block */ - const WebRtc_UWord16 *bytes, /* (i) encoded signal bits */ - iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) the decoder state - structure */ - WebRtc_Word16 mode /* (i) 0: bad packet, PLC, - 1: normal */ - ) { - int i; - WebRtc_Word16 order_plus_one; - - WebRtc_Word16 last_bit; - WebRtc_Word16 *data; - /* Stack based */ - WebRtc_Word16 decresidual[BLOCKL_MAX]; - WebRtc_Word16 PLCresidual[BLOCKL_MAX + LPC_FILTERORDER]; - WebRtc_Word16 syntdenum[NSUB_MAX*(LPC_FILTERORDER+1)]; - WebRtc_Word16 PLClpc[LPC_FILTERORDER + 1]; -#ifndef WEBRTC_BIG_ENDIAN - WebRtc_UWord16 swapped[NO_OF_WORDS_30MS]; -#endif - iLBC_bits *iLBCbits_inst = (iLBC_bits*)PLCresidual; - - /* Reuse some buffers that are non overlapping in order to save stack memory */ - data = &PLCresidual[LPC_FILTERORDER]; - - if (mode) { /* the data are good */ - - /* decode data */ - - /* Unpacketize bits into parameters */ - -#ifndef WEBRTC_BIG_ENDIAN - WebRtcIlbcfix_SwapBytes(bytes, iLBCdec_inst->no_of_words, swapped); - last_bit = WebRtcIlbcfix_UnpackBits(swapped, iLBCbits_inst, iLBCdec_inst->mode); -#else - last_bit = WebRtcIlbcfix_UnpackBits(bytes, iLBCbits_inst, iLBCdec_inst->mode); -#endif - - /* Check for bit errors */ - if (iLBCbits_inst->startIdx<1) - mode = 0; - if ((iLBCdec_inst->mode==20) && (iLBCbits_inst->startIdx>3)) - mode = 0; - if ((iLBCdec_inst->mode==30) && (iLBCbits_inst->startIdx>5)) - mode = 0; - if (last_bit==1) - mode = 0; - - if (mode) { /* No bit errors was detected, continue decoding */ - /* Stack based */ - WebRtc_Word16 lsfdeq[LPC_FILTERORDER*LPC_N_MAX]; - WebRtc_Word16 weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; - - /* adjust index */ - WebRtcIlbcfix_IndexConvDec(iLBCbits_inst->cb_index); - - /* decode the lsf */ - WebRtcIlbcfix_SimpleLsfDeQ(lsfdeq, (WebRtc_Word16*)(iLBCbits_inst->lsf), iLBCdec_inst->lpc_n); - WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCdec_inst->lpc_n); - WebRtcIlbcfix_DecoderInterpolateLsp(syntdenum, weightdenum, - lsfdeq, LPC_FILTERORDER, iLBCdec_inst); - - /* Decode the residual using the cb and gain indexes */ - WebRtcIlbcfix_DecodeResidual(iLBCdec_inst, iLBCbits_inst, decresidual, syntdenum); - - /* preparing the plc for a future loss! */ - WebRtcIlbcfix_DoThePlc( PLCresidual, PLClpc, 0, - decresidual, syntdenum + (LPC_FILTERORDER + 1)*(iLBCdec_inst->nsub - 1), - (WebRtc_Word16)(iLBCdec_inst->last_lag), iLBCdec_inst); - - /* Use the output from doThePLC */ - WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); - } - - } - - if (mode == 0) { - /* the data is bad (either a PLC call - * was made or a bit error was detected) - */ - - /* packet loss conceal */ - - WebRtcIlbcfix_DoThePlc( PLCresidual, PLClpc, 1, - decresidual, syntdenum, (WebRtc_Word16)(iLBCdec_inst->last_lag), iLBCdec_inst); - - WEBRTC_SPL_MEMCPY_W16(decresidual, PLCresidual, iLBCdec_inst->blockl); - - order_plus_one = LPC_FILTERORDER + 1; - - for (i = 0; i < iLBCdec_inst->nsub; i++) { - WEBRTC_SPL_MEMCPY_W16(syntdenum+(i*order_plus_one), - PLClpc, order_plus_one); - } - } - - if ((*iLBCdec_inst).use_enhancer == 1) { /* Enhancer activated */ - - /* Update the filter and filter coefficients if there was a packet loss */ - if (iLBCdec_inst->prev_enh_pl==2) { - for (i=0;i<iLBCdec_inst->nsub;i++) { - WEBRTC_SPL_MEMCPY_W16(&(iLBCdec_inst->old_syntdenum[i*(LPC_FILTERORDER+1)]), - syntdenum, (LPC_FILTERORDER+1)); - } - } - - /* post filtering */ - (*iLBCdec_inst).last_lag = - WebRtcIlbcfix_EnhancerInterface(data, decresidual, iLBCdec_inst); - - /* synthesis filtering */ - - /* Set up the filter state */ - WEBRTC_SPL_MEMCPY_W16(&data[-LPC_FILTERORDER], iLBCdec_inst->syntMem, LPC_FILTERORDER); - - if (iLBCdec_inst->mode==20) { - /* Enhancer has 40 samples delay */ - i=0; - WebRtcSpl_FilterARFastQ12( - data, data, - iLBCdec_inst->old_syntdenum + (i+iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - - for (i=1; i < iLBCdec_inst->nsub; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - syntdenum+(i-1)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - - } else if (iLBCdec_inst->mode==30) { - /* Enhancer has 80 samples delay */ - for (i=0; i < 2; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - iLBCdec_inst->old_syntdenum + (i+4)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - for (i=2; i < iLBCdec_inst->nsub; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - syntdenum+(i-2)*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - } - - /* Save the filter state */ - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &data[iLBCdec_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); - - } else { /* Enhancer not activated */ - WebRtc_Word16 lag; - - /* Find last lag (since the enhancer is not called to give this info) */ - lag = 20; - if (iLBCdec_inst->mode==20) { - lag = (WebRtc_Word16)WebRtcIlbcfix_XcorrCoef( - &decresidual[iLBCdec_inst->blockl-60], - &decresidual[iLBCdec_inst->blockl-60-lag], - 60, - 80, lag, -1); - } else { - lag = (WebRtc_Word16)WebRtcIlbcfix_XcorrCoef( - &decresidual[iLBCdec_inst->blockl-ENH_BLOCKL], - &decresidual[iLBCdec_inst->blockl-ENH_BLOCKL-lag], - ENH_BLOCKL, - 100, lag, -1); - } - - /* Store lag (it is needed if next packet is lost) */ - (*iLBCdec_inst).last_lag = (int)lag; - - /* copy data and run synthesis filter */ - WEBRTC_SPL_MEMCPY_W16(data, decresidual, iLBCdec_inst->blockl); - - /* Set up the filter state */ - WEBRTC_SPL_MEMCPY_W16(&data[-LPC_FILTERORDER], iLBCdec_inst->syntMem, LPC_FILTERORDER); - - for (i=0; i < iLBCdec_inst->nsub; i++) { - WebRtcSpl_FilterARFastQ12( - data+i*SUBL, data+i*SUBL, - syntdenum + i*(LPC_FILTERORDER+1), - LPC_FILTERORDER+1, SUBL); - } - - /* Save the filter state */ - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &data[iLBCdec_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); - } - - WEBRTC_SPL_MEMCPY_W16(decblock,data,iLBCdec_inst->blockl); - - /* High pass filter the signal (with upscaling a factor 2 and saturation) */ - WebRtcIlbcfix_HpOutput(decblock, (WebRtc_Word16*)WebRtcIlbcfix_kHpOutCoefs, - iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, - iLBCdec_inst->blockl); - - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->old_syntdenum, - syntdenum, iLBCdec_inst->nsub*(LPC_FILTERORDER+1)); - - iLBCdec_inst->prev_enh_pl=0; - - if (mode==0) { /* PLC was used */ - iLBCdec_inst->prev_enh_pl=1; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/decode.h b/src/modules/audio_coding/codecs/ilbc/decode.h deleted file mode 100644 index 2c9b5a2..0000000 --- a/src/modules/audio_coding/codecs/ilbc/decode.h +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Decode.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * main decoder function - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecodeImpl( - WebRtc_Word16 *decblock, /* (o) decoded signal block */ - const WebRtc_UWord16 *bytes, /* (i) encoded signal bits */ - iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) the decoder state - structure */ - WebRtc_Word16 mode /* (i) 0: bad packet, PLC, - 1: normal */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/decode_residual.c b/src/modules/audio_coding/codecs/ilbc/decode_residual.c deleted file mode 100644 index 4bc1cd3..0000000 --- a/src/modules/audio_coding/codecs/ilbc/decode_residual.c +++ /dev/null
@@ -1,189 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecodeResidual.c - -******************************************************************/ - -#include "defines.h" -#include "state_construct.h" -#include "cb_construct.h" -#include "index_conv_dec.h" -#include "do_plc.h" -#include "constants.h" -#include "enhancer_interface.h" -#include "xcorr_coef.h" -#include "lsf_check.h" - - -/*----------------------------------------------------------------* - * frame residual decoder function (subrutine to iLBC_decode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecodeResidual( - iLBC_Dec_Inst_t *iLBCdec_inst, - /* (i/o) the decoder state structure */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits, which are used - for the decoding */ - WebRtc_Word16 *decresidual, /* (o) decoded residual frame */ - WebRtc_Word16 *syntdenum /* (i) the decoded synthesis filter - coefficients */ - ) { - WebRtc_Word16 meml_gotten, Nfor, Nback, diff, start_pos; - WebRtc_Word16 subcount, subframe; - WebRtc_Word16 *reverseDecresidual = iLBCdec_inst->enh_buf; /* Reversed decoded data, used for decoding backwards in time (reuse memory in state) */ - WebRtc_Word16 *memVec = iLBCdec_inst->prevResidual; /* Memory for codebook and filter state (reuse memory in state) */ - WebRtc_Word16 *mem = &memVec[CB_HALFFILTERLEN]; /* Memory for codebook */ - - diff = STATE_LEN - iLBCdec_inst->state_short_len; - - if (iLBC_encbits->state_first == 1) { - start_pos = (iLBC_encbits->startIdx-1)*SUBL; - } else { - start_pos = (iLBC_encbits->startIdx-1)*SUBL + diff; - } - - /* decode scalar part of start state */ - - WebRtcIlbcfix_StateConstruct(iLBC_encbits->idxForMax, - iLBC_encbits->idxVec, &syntdenum[(iLBC_encbits->startIdx-1)*(LPC_FILTERORDER+1)], - &decresidual[start_pos], iLBCdec_inst->state_short_len - ); - - if (iLBC_encbits->state_first) { /* put adaptive part in the end */ - - /* setup memory */ - - WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-iLBCdec_inst->state_short_len)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCdec_inst->state_short_len, decresidual+start_pos, - iLBCdec_inst->state_short_len); - - /* construct decoded vector */ - - WebRtcIlbcfix_CbConstruct( - &decresidual[start_pos+iLBCdec_inst->state_short_len], - iLBC_encbits->cb_index, iLBC_encbits->gain_index, - mem+CB_MEML-ST_MEM_L_TBL, - ST_MEM_L_TBL, (WebRtc_Word16)diff - ); - - } - else {/* put adaptive part in the beginning */ - - /* create reversed vectors for prediction */ - - WebRtcSpl_MemCpyReversedOrder(reverseDecresidual+diff, - &decresidual[(iLBC_encbits->startIdx+1)*SUBL-1-STATE_LEN], diff); - - /* setup memory */ - - meml_gotten = iLBCdec_inst->state_short_len; - WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, - decresidual+start_pos, meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-meml_gotten)); - - /* construct decoded vector */ - - WebRtcIlbcfix_CbConstruct( - reverseDecresidual, - iLBC_encbits->cb_index, iLBC_encbits->gain_index, - mem+CB_MEML-ST_MEM_L_TBL, - ST_MEM_L_TBL, diff - ); - - /* get decoded residual from reversed vector */ - - WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], - reverseDecresidual, diff); - } - - /* counter for predicted subframes */ - - subcount=1; - - /* forward prediction of subframes */ - - Nfor = iLBCdec_inst->nsub-iLBC_encbits->startIdx-1; - - if( Nfor > 0 ) { - - /* setup memory */ - WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, - decresidual+(iLBC_encbits->startIdx-1)*SUBL, STATE_LEN); - - /* loop over subframes to encode */ - - for (subframe=0; subframe<Nfor; subframe++) { - - /* construct decoded vector */ - WebRtcIlbcfix_CbConstruct( - &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], - iLBC_encbits->cb_index+subcount*CB_NSTAGES, - iLBC_encbits->gain_index+subcount*CB_NSTAGES, - mem, MEM_LF_TBL, SUBL - ); - - /* update memory */ - WEBRTC_SPL_MEMMOVE_W16(mem, mem+SUBL, CB_MEML-SUBL); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &decresidual[(iLBC_encbits->startIdx+1+subframe)*SUBL], SUBL); - - subcount++; - } - - } - - /* backward prediction of subframes */ - - Nback = iLBC_encbits->startIdx-1; - - if( Nback > 0 ){ - - /* setup memory */ - - meml_gotten = SUBL*(iLBCdec_inst->nsub+1-iLBC_encbits->startIdx); - if( meml_gotten > CB_MEML ) { - meml_gotten=CB_MEML; - } - - WebRtcSpl_MemCpyReversedOrder(mem+CB_MEML-1, - decresidual+(iLBC_encbits->startIdx-1)*SUBL, meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-meml_gotten)); - - /* loop over subframes to decode */ - - for (subframe=0; subframe<Nback; subframe++) { - - /* construct decoded vector */ - WebRtcIlbcfix_CbConstruct( - &reverseDecresidual[subframe*SUBL], - iLBC_encbits->cb_index+subcount*CB_NSTAGES, - iLBC_encbits->gain_index+subcount*CB_NSTAGES, - mem, MEM_LF_TBL, SUBL - ); - - /* update memory */ - WEBRTC_SPL_MEMMOVE_W16(mem, mem+SUBL, CB_MEML-SUBL); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &reverseDecresidual[subframe*SUBL], SUBL); - - subcount++; - } - - /* get decoded residual from reversed vector */ - WebRtcSpl_MemCpyReversedOrder(decresidual+SUBL*Nback-1, - reverseDecresidual, SUBL*Nback); - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/decode_residual.h b/src/modules/audio_coding/codecs/ilbc/decode_residual.h deleted file mode 100644 index ea7208a..0000000 --- a/src/modules/audio_coding/codecs/ilbc/decode_residual.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecodeResidual.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODE_RESIDUAL_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * frame residual decoder function (subrutine to iLBC_decode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecodeResidual( - iLBC_Dec_Inst_t *iLBCdec_inst, - /* (i/o) the decoder state structure */ - iLBC_bits *iLBC_encbits, /* (i/o) Encoded bits, which are used - for the decoding */ - WebRtc_Word16 *decresidual, /* (o) decoded residual frame */ - WebRtc_Word16 *syntdenum /* (i) the decoded synthesis filter - coefficients */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.c b/src/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.c deleted file mode 100644 index eee3105..0000000 --- a/src/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.c +++ /dev/null
@@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecoderInterpolateLsp.c - -******************************************************************/ - -#include "lsf_interpolate_to_poly_dec.h" -#include "bw_expand.h" -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * obtain synthesis and weighting filters form lsf coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecoderInterpolateLsp( - WebRtc_Word16 *syntdenum, /* (o) synthesis filter coefficients */ - WebRtc_Word16 *weightdenum, /* (o) weighting denumerator - coefficients */ - WebRtc_Word16 *lsfdeq, /* (i) dequantized lsf coefficients */ - WebRtc_Word16 length, /* (i) length of lsf coefficient vector */ - iLBC_Dec_Inst_t *iLBCdec_inst - /* (i) the decoder state structure */ - ){ - int i, pos, lp_length; - WebRtc_Word16 lp[LPC_FILTERORDER + 1], *lsfdeq2; - - lsfdeq2 = lsfdeq + length; - lp_length = length + 1; - - if (iLBCdec_inst->mode==30) { - /* subframe 1: Interpolation between old and first LSF */ - - WebRtcIlbcfix_LspInterpolate2PolyDec(lp, (*iLBCdec_inst).lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight30ms[0], length); - WEBRTC_SPL_MEMCPY_W16(syntdenum,lp,lp_length); - WebRtcIlbcfix_BwExpand(weightdenum, lp, (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpSyntDenum, (WebRtc_Word16)lp_length); - - /* subframes 2 to 6: interpolation between first and last LSF */ - - pos = lp_length; - for (i = 1; i < 6; i++) { - WebRtcIlbcfix_LspInterpolate2PolyDec(lp, lsfdeq, lsfdeq2, - WebRtcIlbcfix_kLsfWeight30ms[i], length); - WEBRTC_SPL_MEMCPY_W16(syntdenum + pos,lp,lp_length); - WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, - (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpSyntDenum, (WebRtc_Word16)lp_length); - pos += lp_length; - } - } else { /* iLBCdec_inst->mode=20 */ - /* subframes 1 to 4: interpolation between old and new LSF */ - pos = 0; - for (i = 0; i < iLBCdec_inst->nsub; i++) { - WebRtcIlbcfix_LspInterpolate2PolyDec(lp, iLBCdec_inst->lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight20ms[i], length); - WEBRTC_SPL_MEMCPY_W16(syntdenum+pos,lp,lp_length); - WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, - (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpSyntDenum, (WebRtc_Word16)lp_length); - pos += lp_length; - } - } - - /* update memory */ - - if (iLBCdec_inst->mode==30) { - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, lsfdeq2, length); - } else { - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, lsfdeq, length); - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h b/src/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h deleted file mode 100644 index 3896ca9..0000000 --- a/src/modules/audio_coding/codecs/ilbc/decoder_interpolate_lsf.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DecoderInterpolateLsp.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODER_INTERPOLATE_LSF_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DECODER_INTERPOLATE_LSF_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * obtain synthesis and weighting filters form lsf coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DecoderInterpolateLsp( - WebRtc_Word16 *syntdenum, /* (o) synthesis filter coefficients */ - WebRtc_Word16 *weightdenum, /* (o) weighting denumerator - coefficients */ - WebRtc_Word16 *lsfdeq, /* (i) dequantized lsf coefficients */ - WebRtc_Word16 length, /* (i) length of lsf coefficient vector */ - iLBC_Dec_Inst_t *iLBCdec_inst - /* (i) the decoder state structure */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/defines.h b/src/modules/audio_coding/codecs/ilbc/defines.h deleted file mode 100644 index bdeba01..0000000 --- a/src/modules/audio_coding/codecs/ilbc/defines.h +++ /dev/null
@@ -1,219 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - define.h - -******************************************************************/ -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DEFINES_H_ - -#include "typedefs.h" -#include "signal_processing_library.h" -#include <string.h> - -/* general codec settings */ - -#define FS 8000 -#define BLOCKL_20MS 160 -#define BLOCKL_30MS 240 -#define BLOCKL_MAX 240 -#define NSUB_20MS 4 -#define NSUB_30MS 6 -#define NSUB_MAX 6 -#define NASUB_20MS 2 -#define NASUB_30MS 4 -#define NASUB_MAX 4 -#define SUBL 40 -#define STATE_LEN 80 -#define STATE_SHORT_LEN_30MS 58 -#define STATE_SHORT_LEN_20MS 57 - -/* LPC settings */ - -#define LPC_FILTERORDER 10 -#define LPC_LOOKBACK 60 -#define LPC_N_20MS 1 -#define LPC_N_30MS 2 -#define LPC_N_MAX 2 -#define LPC_ASYMDIFF 20 -#define LSF_NSPLIT 3 -#define LSF_NUMBER_OF_STEPS 4 -#define LPC_HALFORDER 5 -#define COS_GRID_POINTS 60 - -/* cb settings */ - -#define CB_NSTAGES 3 -#define CB_EXPAND 2 -#define CB_MEML 147 -#define CB_FILTERLEN (2*4) -#define CB_HALFFILTERLEN 4 -#define CB_RESRANGE 34 -#define CB_MAXGAIN_FIXQ6 83 /* error = -0.24% */ -#define CB_MAXGAIN_FIXQ14 21299 - -/* enhancer */ - -#define ENH_BLOCKL 80 /* block length */ -#define ENH_BLOCKL_HALF (ENH_BLOCKL/2) -#define ENH_HL 3 /* 2*ENH_HL+1 is number blocks - in said second sequence */ -#define ENH_SLOP 2 /* max difference estimated and - correct pitch period */ -#define ENH_PLOCSL 8 /* pitch-estimates and - pitch-locations buffer length */ -#define ENH_OVERHANG 2 -#define ENH_UPS0 4 /* upsampling rate */ -#define ENH_FL0 3 /* 2*FLO+1 is the length of each filter */ -#define ENH_FLO_MULT2_PLUS1 7 -#define ENH_VECTL (ENH_BLOCKL+2*ENH_FL0) -#define ENH_CORRDIM (2*ENH_SLOP+1) -#define ENH_NBLOCKS (BLOCKL/ENH_BLOCKL) -#define ENH_NBLOCKS_EXTRA 5 -#define ENH_NBLOCKS_TOT 8 /* ENH_NBLOCKS+ENH_NBLOCKS_EXTRA */ -#define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL -#define ENH_BUFL_FILTEROVERHEAD 3 -#define ENH_A0 819 /* Q14 */ -#define ENH_A0_MINUS_A0A0DIV4 848256041 /* Q34 */ -#define ENH_A0DIV2 26843546 /* Q30 */ - -/* PLC */ - -/* Down sampling */ - -#define FILTERORDER_DS_PLUS1 7 -#define DELAY_DS 3 -#define FACTOR_DS 2 - -/* bit stream defs */ - -#define NO_OF_BYTES_20MS 38 -#define NO_OF_BYTES_30MS 50 -#define NO_OF_WORDS_20MS 19 -#define NO_OF_WORDS_30MS 25 -#define STATE_BITS 3 -#define BYTE_LEN 8 -#define ULP_CLASSES 3 - -/* help parameters */ - -#define TWO_PI_FIX 25736 /* Q12 */ - -/* Constants for codebook search and creation */ - -#define ST_MEM_L_TBL 85 -#define MEM_LF_TBL 147 - - -/* Struct for the bits */ -typedef struct iLBC_bits_t_ { - WebRtc_Word16 lsf[LSF_NSPLIT*LPC_N_MAX]; - WebRtc_Word16 cb_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB index */ - WebRtc_Word16 gain_index[CB_NSTAGES*(NASUB_MAX+1)]; /* First CB_NSTAGES values contains extra CB gain */ - WebRtc_Word16 idxForMax; - WebRtc_Word16 state_first; - WebRtc_Word16 idxVec[STATE_SHORT_LEN_30MS]; - WebRtc_Word16 firstbits; - WebRtc_Word16 startIdx; -} iLBC_bits; - -/* type definition encoder instance */ -typedef struct iLBC_Enc_Inst_t_ { - - /* flag for frame size mode */ - WebRtc_Word16 mode; - - /* basic parameters for different frame sizes */ - WebRtc_Word16 blockl; - WebRtc_Word16 nsub; - WebRtc_Word16 nasub; - WebRtc_Word16 no_of_bytes, no_of_words; - WebRtc_Word16 lpc_n; - WebRtc_Word16 state_short_len; - - /* analysis filter state */ - WebRtc_Word16 anaMem[LPC_FILTERORDER]; - - /* Fix-point old lsf parameters for interpolation */ - WebRtc_Word16 lsfold[LPC_FILTERORDER]; - WebRtc_Word16 lsfdeqold[LPC_FILTERORDER]; - - /* signal buffer for LP analysis */ - WebRtc_Word16 lpc_buffer[LPC_LOOKBACK + BLOCKL_MAX]; - - /* state of input HP filter */ - WebRtc_Word16 hpimemx[2]; - WebRtc_Word16 hpimemy[4]; - -#ifdef SPLIT_10MS - WebRtc_Word16 weightdenumbuf[66]; - WebRtc_Word16 past_samples[160]; - WebRtc_UWord16 bytes[25]; - WebRtc_Word16 section; - WebRtc_Word16 Nfor_flag; - WebRtc_Word16 Nback_flag; - WebRtc_Word16 start_pos; - WebRtc_Word16 diff; -#endif - -} iLBC_Enc_Inst_t; - -/* type definition decoder instance */ -typedef struct iLBC_Dec_Inst_t_ { - - /* flag for frame size mode */ - WebRtc_Word16 mode; - - /* basic parameters for different frame sizes */ - WebRtc_Word16 blockl; - WebRtc_Word16 nsub; - WebRtc_Word16 nasub; - WebRtc_Word16 no_of_bytes, no_of_words; - WebRtc_Word16 lpc_n; - WebRtc_Word16 state_short_len; - - /* synthesis filter state */ - WebRtc_Word16 syntMem[LPC_FILTERORDER]; - - /* old LSF for interpolation */ - WebRtc_Word16 lsfdeqold[LPC_FILTERORDER]; - - /* pitch lag estimated in enhancer and used in PLC */ - int last_lag; - - /* PLC state information */ - int consPLICount, prev_enh_pl; - WebRtc_Word16 perSquare; - - WebRtc_Word16 prevScale, prevPLI; - WebRtc_Word16 prevLag, prevLpc[LPC_FILTERORDER+1]; - WebRtc_Word16 prevResidual[NSUB_MAX*SUBL]; - WebRtc_Word16 seed; - - /* previous synthesis filter parameters */ - - WebRtc_Word16 old_syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; - - /* state of output HP filter */ - WebRtc_Word16 hpimemx[2]; - WebRtc_Word16 hpimemy[4]; - - /* enhancer state information */ - int use_enhancer; - WebRtc_Word16 enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD]; - WebRtc_Word16 enh_period[ENH_NBLOCKS_TOT]; - -} iLBC_Dec_Inst_t; - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/do_plc.c b/src/modules/audio_coding/codecs/ilbc/do_plc.c deleted file mode 100644 index 0dfae2b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/do_plc.c +++ /dev/null
@@ -1,308 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DoThePlc.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "comp_corr.h" -#include "bw_expand.h" - -/*----------------------------------------------------------------* - * Packet loss concealment routine. Conceals a residual signal - * and LP parameters. If no packet loss, update state. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DoThePlc( - WebRtc_Word16 *PLCresidual, /* (o) concealed residual */ - WebRtc_Word16 *PLClpc, /* (o) concealed LP parameters */ - WebRtc_Word16 PLI, /* (i) packet loss indicator - 0 - no PL, 1 = PL */ - WebRtc_Word16 *decresidual, /* (i) decoded residual */ - WebRtc_Word16 *lpc, /* (i) decoded LPC (only used for no PL) */ - WebRtc_Word16 inlag, /* (i) pitch lag */ - iLBC_Dec_Inst_t *iLBCdec_inst - /* (i/o) decoder instance */ - ){ - WebRtc_Word16 i, pick; - WebRtc_Word32 cross, ener, cross_comp, ener_comp = 0; - WebRtc_Word32 measure, maxMeasure, energy; - WebRtc_Word16 max, crossSquareMax, crossSquare; - WebRtc_Word16 j, lag, tmp1, tmp2, randlag; - WebRtc_Word16 shift1, shift2, shift3, shiftMax; - WebRtc_Word16 scale3; - WebRtc_Word16 corrLen; - WebRtc_Word32 tmpW32, tmp2W32; - WebRtc_Word16 use_gain; - WebRtc_Word16 tot_gain; - WebRtc_Word16 max_perSquare; - WebRtc_Word16 scale1, scale2; - WebRtc_Word16 totscale; - WebRtc_Word32 nom; - WebRtc_Word16 denom; - WebRtc_Word16 pitchfact; - WebRtc_Word16 use_lag; - int ind; - WebRtc_Word16 randvec[BLOCKL_MAX]; - - /* Packet Loss */ - if (PLI == 1) { - - (*iLBCdec_inst).consPLICount += 1; - - /* if previous frame not lost, - determine pitch pred. gain */ - - if (iLBCdec_inst->prevPLI != 1) { - - /* Maximum 60 samples are correlated, preserve as high accuracy - as possible without getting overflow */ - max = WebRtcSpl_MaxAbsValueW16((*iLBCdec_inst).prevResidual, (WebRtc_Word16)iLBCdec_inst->blockl); - scale3 = (WebRtcSpl_GetSizeInBits(max)<<1) - 25; - if (scale3 < 0) { - scale3 = 0; - } - - /* Store scale for use when interpolating between the - * concealment and the received packet */ - iLBCdec_inst->prevScale = scale3; - - /* Search around the previous lag +/-3 to find the - best pitch period */ - lag = inlag - 3; - - /* Guard against getting outside the frame */ - corrLen = WEBRTC_SPL_MIN(60, iLBCdec_inst->blockl-(inlag+3)); - - WebRtcIlbcfix_CompCorr( &cross, &ener, - iLBCdec_inst->prevResidual, lag, iLBCdec_inst->blockl, corrLen, scale3); - - /* Normalize and store cross^2 and the number of shifts */ - shiftMax = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(cross))-15; - crossSquareMax = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(WEBRTC_SPL_SHIFT_W32(cross, -shiftMax), - WEBRTC_SPL_SHIFT_W32(cross, -shiftMax), 15); - - for (j=inlag-2;j<=inlag+3;j++) { - WebRtcIlbcfix_CompCorr( &cross_comp, &ener_comp, - iLBCdec_inst->prevResidual, j, iLBCdec_inst->blockl, corrLen, scale3); - - /* Use the criteria (corr*corr)/energy to compare if - this lag is better or not. To avoid the division, - do a cross multiplication */ - shift1 = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(cross_comp))-15; - crossSquare = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1), - WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1), 15); - - shift2 = WebRtcSpl_GetSizeInBits(ener)-15; - measure = WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_SHIFT_W32(ener, -shift2), - crossSquare); - - shift3 = WebRtcSpl_GetSizeInBits(ener_comp)-15; - maxMeasure = WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_SHIFT_W32(ener_comp, -shift3), - crossSquareMax); - - /* Calculate shift value, so that the two measures can - be put in the same Q domain */ - if(((shiftMax<<1)+shift3) > ((shift1<<1)+shift2)) { - tmp1 = WEBRTC_SPL_MIN(31, (shiftMax<<1)+shift3-(shift1<<1)-shift2); - tmp2 = 0; - } else { - tmp1 = 0; - tmp2 = WEBRTC_SPL_MIN(31, (shift1<<1)+shift2-(shiftMax<<1)-shift3); - } - - if ((measure>>tmp1) > (maxMeasure>>tmp2)) { - /* New lag is better => record lag, measure and domain */ - lag = j; - crossSquareMax = crossSquare; - cross = cross_comp; - shiftMax = shift1; - ener = ener_comp; - } - } - - /* Calculate the periodicity for the lag with the maximum correlation. - - Definition of the periodicity: - abs(corr(vec1, vec2))/(sqrt(energy(vec1))*sqrt(energy(vec2))) - - Work in the Square domain to simplify the calculations - max_perSquare is less than 1 (in Q15) - */ - tmp2W32=WebRtcSpl_DotProductWithScale(&iLBCdec_inst->prevResidual[iLBCdec_inst->blockl-corrLen], - &iLBCdec_inst->prevResidual[iLBCdec_inst->blockl-corrLen], - corrLen, scale3); - - if ((tmp2W32>0)&&(ener_comp>0)) { - /* norm energies to WebRtc_Word16, compute the product of the energies and - use the upper WebRtc_Word16 as the denominator */ - - scale1=(WebRtc_Word16)WebRtcSpl_NormW32(tmp2W32)-16; - tmp1=(WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(tmp2W32, scale1); - - scale2=(WebRtc_Word16)WebRtcSpl_NormW32(ener)-16; - tmp2=(WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(ener, scale2); - denom=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp1, tmp2, 16); /* denom in Q(scale1+scale2-16) */ - - /* Square the cross correlation and norm it such that max_perSquare - will be in Q15 after the division */ - - totscale = scale1+scale2-1; - tmp1 = (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(cross, (totscale>>1)); - tmp2 = (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(cross, totscale-(totscale>>1)); - - nom = WEBRTC_SPL_MUL_16_16(tmp1, tmp2); - max_perSquare = (WebRtc_Word16)WebRtcSpl_DivW32W16(nom, denom); - - } else { - max_perSquare = 0; - } - } - - /* previous frame lost, use recorded lag and gain */ - - else { - lag = iLBCdec_inst->prevLag; - max_perSquare = iLBCdec_inst->perSquare; - } - - /* Attenuate signal and scale down pitch pred gain if - several frames lost consecutively */ - - use_gain = 32767; /* 1.0 in Q15 */ - - if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>320) { - use_gain = 29491; /* 0.9 in Q15 */ - } else if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>640) { - use_gain = 22938; /* 0.7 in Q15 */ - } else if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>960) { - use_gain = 16384; /* 0.5 in Q15 */ - } else if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>1280) { - use_gain = 0; /* 0.0 in Q15 */ - } - - /* Compute mixing factor of picth repeatition and noise: - for max_per>0.7 set periodicity to 1.0 - 0.4<max_per<0.7 set periodicity to (maxper-0.4)/0.7-0.4) - max_per<0.4 set periodicity to 0.0 - */ - - if (max_perSquare>7868) { /* periodicity > 0.7 (0.7^4=0.2401 in Q15) */ - pitchfact = 32767; - } else if (max_perSquare>839) { /* 0.4 < periodicity < 0.7 (0.4^4=0.0256 in Q15) */ - /* find best index and interpolate from that */ - ind = 5; - while ((max_perSquare<WebRtcIlbcfix_kPlcPerSqr[ind])&&(ind>0)) { - ind--; - } - /* pitch fact is approximated by first order */ - tmpW32 = (WebRtc_Word32)WebRtcIlbcfix_kPlcPitchFact[ind] + - WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIlbcfix_kPlcPfSlope[ind], (max_perSquare-WebRtcIlbcfix_kPlcPerSqr[ind]), 11); - - pitchfact = (WebRtc_Word16)WEBRTC_SPL_MIN(tmpW32, 32767); /* guard against overflow */ - - } else { /* periodicity < 0.4 */ - pitchfact = 0; - } - - /* avoid repetition of same pitch cycle (buzzyness) */ - use_lag = lag; - if (lag<80) { - use_lag = 2*lag; - } - - /* compute concealed residual */ - energy = 0; - - for (i=0; i<iLBCdec_inst->blockl; i++) { - - /* noise component - 52 < randlagFIX < 117 */ - iLBCdec_inst->seed = (WebRtc_Word16)(WEBRTC_SPL_MUL_16_16(iLBCdec_inst->seed, 31821)+(WebRtc_Word32)13849); - randlag = 53 + (WebRtc_Word16)(iLBCdec_inst->seed & 63); - - pick = i - randlag; - - if (pick < 0) { - randvec[i] = iLBCdec_inst->prevResidual[iLBCdec_inst->blockl+pick]; - } else { - randvec[i] = iLBCdec_inst->prevResidual[pick]; - } - - /* pitch repeatition component */ - pick = i - use_lag; - - if (pick < 0) { - PLCresidual[i] = iLBCdec_inst->prevResidual[iLBCdec_inst->blockl+pick]; - } else { - PLCresidual[i] = PLCresidual[pick]; - } - - /* Attinuate total gain for each 10 ms */ - if (i<80) { - tot_gain=use_gain; - } else if (i<160) { - tot_gain=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(31130, use_gain, 15); /* 0.95*use_gain */ - } else { - tot_gain=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(29491, use_gain, 15); /* 0.9*use_gain */ - } - - - /* mix noise and pitch repeatition */ - - PLCresidual[i] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tot_gain, - (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( (WEBRTC_SPL_MUL_16_16(pitchfact, PLCresidual[i]) + - WEBRTC_SPL_MUL_16_16((32767-pitchfact), randvec[i]) + 16384), - 15), - 15); - - /* Shifting down the result one step extra to ensure that no overflow - will occur */ - energy += WEBRTC_SPL_MUL_16_16_RSFT(PLCresidual[i], - PLCresidual[i], (iLBCdec_inst->prevScale+1)); - - } - - /* less than 30 dB, use only noise */ - if (energy < (WEBRTC_SPL_SHIFT_W32(((WebRtc_Word32)iLBCdec_inst->blockl*900),-(iLBCdec_inst->prevScale+1)))) { - energy = 0; - for (i=0; i<iLBCdec_inst->blockl; i++) { - PLCresidual[i] = randvec[i]; - } - } - - /* use the old LPC */ - WEBRTC_SPL_MEMCPY_W16(PLClpc, (*iLBCdec_inst).prevLpc, LPC_FILTERORDER+1); - - /* Update state in case there are multiple frame losses */ - iLBCdec_inst->prevLag = lag; - iLBCdec_inst->perSquare = max_perSquare; - } - - /* no packet loss, copy input */ - - else { - WEBRTC_SPL_MEMCPY_W16(PLCresidual, decresidual, iLBCdec_inst->blockl); - WEBRTC_SPL_MEMCPY_W16(PLClpc, lpc, (LPC_FILTERORDER+1)); - iLBCdec_inst->consPLICount = 0; - } - - /* update state */ - iLBCdec_inst->prevPLI = PLI; - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevLpc, PLClpc, (LPC_FILTERORDER+1)); - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->prevResidual, PLCresidual, iLBCdec_inst->blockl); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/do_plc.h b/src/modules/audio_coding/codecs/ilbc/do_plc.h deleted file mode 100644 index c5bcc52..0000000 --- a/src/modules/audio_coding/codecs/ilbc/do_plc.h +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_DoThePlc.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_DO_PLC_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Packet loss concealment routine. Conceals a residual signal - * and LP parameters. If no packet loss, update state. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_DoThePlc( - WebRtc_Word16 *PLCresidual, /* (o) concealed residual */ - WebRtc_Word16 *PLClpc, /* (o) concealed LP parameters */ - WebRtc_Word16 PLI, /* (i) packet loss indicator - 0 - no PL, 1 = PL */ - WebRtc_Word16 *decresidual, /* (i) decoded residual */ - WebRtc_Word16 *lpc, /* (i) decoded LPC (only used for no PL) */ - WebRtc_Word16 inlag, /* (i) pitch lag */ - iLBC_Dec_Inst_t *iLBCdec_inst - /* (i/o) decoder instance */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/encode.c b/src/modules/audio_coding/codecs/ilbc/encode.c deleted file mode 100644 index d3d3ba8..0000000 --- a/src/modules/audio_coding/codecs/ilbc/encode.c +++ /dev/null
@@ -1,518 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Encode.c - -******************************************************************/ - -#include "defines.h" -#include "lpc_encode.h" -#include "frame_classify.h" -#include "state_search.h" -#include "state_construct.h" -#include "constants.h" -#include "cb_search.h" -#include "cb_construct.h" -#include "index_conv_enc.h" -#include "pack_bits.h" -#include "hp_input.h" - -#ifdef SPLIT_10MS -#include "unpack_bits.h" -#include "index_conv_dec.h" -#endif -#ifndef WEBRTC_BIG_ENDIAN -#include "swap_bytes.h" -#endif - -/*----------------------------------------------------------------* - * main encoder function - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EncodeImpl( - WebRtc_UWord16 *bytes, /* (o) encoded data bits iLBC */ - const WebRtc_Word16 *block, /* (i) speech vector to encode */ - iLBC_Enc_Inst_t *iLBCenc_inst /* (i/o) the general encoder - state */ - ){ - int n, meml_gotten, Nfor, Nback; - WebRtc_Word16 diff, start_pos; - int index; - int subcount, subframe; - WebRtc_Word16 start_count, end_count; - WebRtc_Word16 *residual; - WebRtc_Word32 en1, en2; - WebRtc_Word16 scale, max; - WebRtc_Word16 *syntdenum; - WebRtc_Word16 *decresidual; - WebRtc_Word16 *reverseResidual; - WebRtc_Word16 *reverseDecresidual; - /* Stack based */ - WebRtc_Word16 weightdenum[(LPC_FILTERORDER + 1)*NSUB_MAX]; - WebRtc_Word16 dataVec[BLOCKL_MAX + LPC_FILTERORDER]; - WebRtc_Word16 memVec[CB_MEML+CB_FILTERLEN]; - WebRtc_Word16 bitsMemory[sizeof(iLBC_bits)/sizeof(WebRtc_Word16)]; - iLBC_bits *iLBCbits_inst = (iLBC_bits*)bitsMemory; - - -#ifdef SPLIT_10MS - WebRtc_Word16 *weightdenumbuf = iLBCenc_inst->weightdenumbuf; - WebRtc_Word16 last_bit; -#endif - - WebRtc_Word16 *data = &dataVec[LPC_FILTERORDER]; - WebRtc_Word16 *mem = &memVec[CB_HALFFILTERLEN]; - - /* Reuse som buffers to save stack memory */ - residual = &iLBCenc_inst->lpc_buffer[LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl]; - syntdenum = mem; /* syntdenum[(LPC_FILTERORDER + 1)*NSUB_MAX] and mem are used non overlapping in the code */ - decresidual = residual; /* Already encoded residual is overwritten by the decoded version */ - reverseResidual = data; /* data and reverseResidual are used non overlapping in the code */ - reverseDecresidual = reverseResidual; /* Already encoded residual is overwritten by the decoded version */ - -#ifdef SPLIT_10MS - - WebRtcSpl_MemSetW16 ( (WebRtc_Word16 *) iLBCbits_inst, 0, - (WebRtc_Word16) (sizeof(iLBC_bits) / sizeof(WebRtc_Word16)) ); - - start_pos = iLBCenc_inst->start_pos; - diff = iLBCenc_inst->diff; - - if (iLBCenc_inst->section != 0){ - WEBRTC_SPL_MEMCPY_W16 (weightdenum, weightdenumbuf, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - /* Un-Packetize the frame into parameters */ - last_bit = WebRtcIlbcfix_UnpackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - if (last_bit) - return; - /* adjust index */ - WebRtcIlbcfix_IndexConvDec (iLBCbits_inst->cb_index); - - if (iLBCenc_inst->section == 1){ - /* Save first 80 samples of a 160/240 sample frame for 20/30msec */ - WEBRTC_SPL_MEMCPY_W16 (iLBCenc_inst->past_samples, block, 80); - } - else{ // iLBCenc_inst->section == 2 AND mode = 30ms - /* Save second 80 samples of a 240 sample frame for 30msec */ - WEBRTC_SPL_MEMCPY_W16 (iLBCenc_inst->past_samples + 80, block, 80); - } - } - else{ // iLBCenc_inst->section == 0 - /* form a complete frame of 160/240 for 20msec/30msec mode */ - WEBRTC_SPL_MEMCPY_W16 (data + (iLBCenc_inst->mode * 8) - 80, block, 80); - WEBRTC_SPL_MEMCPY_W16 (data, iLBCenc_inst->past_samples, - (iLBCenc_inst->mode * 8) - 80); - iLBCenc_inst->Nfor_flag = 0; - iLBCenc_inst->Nback_flag = 0; -#else - /* copy input block to data*/ - WEBRTC_SPL_MEMCPY_W16(data,block,iLBCenc_inst->blockl); -#endif - - /* high pass filtering of input signal and scale down the residual (*0.5) */ - WebRtcIlbcfix_HpInput(data, (WebRtc_Word16*)WebRtcIlbcfix_kHpInCoefs, - iLBCenc_inst->hpimemy, iLBCenc_inst->hpimemx, - iLBCenc_inst->blockl); - - /* LPC of hp filtered input data */ - WebRtcIlbcfix_LpcEncode(syntdenum, weightdenum, iLBCbits_inst->lsf, data, - iLBCenc_inst); - - /* Set up state */ - WEBRTC_SPL_MEMCPY_W16(dataVec, iLBCenc_inst->anaMem, LPC_FILTERORDER); - - /* inverse filter to get residual */ - for (n=0; n<iLBCenc_inst->nsub; n++ ) { - WebRtcSpl_FilterMAFastQ12( - &data[n*SUBL], &residual[n*SUBL], - &syntdenum[n*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, SUBL); - } - - /* Copy the state for next frame */ - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->anaMem, &data[iLBCenc_inst->blockl-LPC_FILTERORDER], LPC_FILTERORDER); - - /* find state location */ - - iLBCbits_inst->startIdx = WebRtcIlbcfix_FrameClassify(iLBCenc_inst,residual); - - /* check if state should be in first or last part of the - two subframes */ - - index = (iLBCbits_inst->startIdx-1)*SUBL; - max=WebRtcSpl_MaxAbsValueW16(&residual[index], 2*SUBL); - scale=WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max,max)); - - /* Scale to maximum 25 bits so that the MAC won't cause overflow */ - scale = scale - 25; - if(scale < 0) { - scale = 0; - } - - diff = STATE_LEN - iLBCenc_inst->state_short_len; - en1=WebRtcSpl_DotProductWithScale(&residual[index], &residual[index], - iLBCenc_inst->state_short_len, scale); - index += diff; - en2=WebRtcSpl_DotProductWithScale(&residual[index], &residual[index], - iLBCenc_inst->state_short_len, scale); - if (en1 > en2) { - iLBCbits_inst->state_first = 1; - start_pos = (iLBCbits_inst->startIdx-1)*SUBL; - } else { - iLBCbits_inst->state_first = 0; - start_pos = (iLBCbits_inst->startIdx-1)*SUBL + diff; - } - - /* scalar quantization of state */ - - WebRtcIlbcfix_StateSearch(iLBCenc_inst, iLBCbits_inst, &residual[start_pos], - &syntdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], - &weightdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)]); - - WebRtcIlbcfix_StateConstruct(iLBCbits_inst->idxForMax, iLBCbits_inst->idxVec, - &syntdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], - &decresidual[start_pos], iLBCenc_inst->state_short_len - ); - - /* predictive quantization in state */ - - if (iLBCbits_inst->state_first) { /* put adaptive part in the end */ - - /* setup memory */ - - WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-iLBCenc_inst->state_short_len)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-iLBCenc_inst->state_short_len, - decresidual+start_pos, iLBCenc_inst->state_short_len); - - /* encode subframes */ - - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - &residual[start_pos+iLBCenc_inst->state_short_len], - mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff, - &weightdenum[iLBCbits_inst->startIdx*(LPC_FILTERORDER+1)], 0); - - /* construct decoded vector */ - - WebRtcIlbcfix_CbConstruct(&decresidual[start_pos+iLBCenc_inst->state_short_len], - iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, - diff - ); - - } - else { /* put adaptive part in the beginning */ - - /* create reversed vectors for prediction */ - - WebRtcSpl_MemCpyReversedOrder(&reverseResidual[diff-1], - &residual[(iLBCbits_inst->startIdx+1)*SUBL-STATE_LEN], diff); - - /* setup memory */ - - meml_gotten = iLBCenc_inst->state_short_len; - WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[start_pos], meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-iLBCenc_inst->state_short_len)); - - /* encode subframes */ - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - reverseResidual, mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, diff, - &weightdenum[(iLBCbits_inst->startIdx-1)*(LPC_FILTERORDER+1)], - 0); - - /* construct decoded vector */ - - WebRtcIlbcfix_CbConstruct(reverseDecresidual, - iLBCbits_inst->cb_index, iLBCbits_inst->gain_index, - mem+CB_MEML-ST_MEM_L_TBL, ST_MEM_L_TBL, - diff - ); - - /* get decoded residual from reversed vector */ - - WebRtcSpl_MemCpyReversedOrder(&decresidual[start_pos-1], reverseDecresidual, diff); - } - -#ifdef SPLIT_10MS - iLBCenc_inst->start_pos = start_pos; - iLBCenc_inst->diff = diff; - iLBCenc_inst->section++; - /* adjust index */ - WebRtcIlbcfix_IndexConvEnc (iLBCbits_inst->cb_index); - /* Packetize the parameters into the frame */ - WebRtcIlbcfix_PackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - return; - } -#endif - - /* forward prediction of subframes */ - - Nfor = iLBCenc_inst->nsub-iLBCbits_inst->startIdx-1; - - /* counter for predicted subframes */ -#ifdef SPLIT_10MS - if (iLBCenc_inst->mode == 20) - { - subcount = 1; - } - if (iLBCenc_inst->mode == 30) - { - if (iLBCenc_inst->section == 1) - { - subcount = 1; - } - if (iLBCenc_inst->section == 2) - { - subcount = 3; - } - } -#else - subcount=1; -#endif - - if( Nfor > 0 ){ - - /* setup memory */ - - WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-STATE_LEN, - decresidual+(iLBCbits_inst->startIdx-1)*SUBL, STATE_LEN); - -#ifdef SPLIT_10MS - if (iLBCenc_inst->Nfor_flag > 0) - { - for (subframe = 0; subframe < WEBRTC_SPL_MIN (Nfor, 2); subframe++) - { - /* update memory */ - WEBRTC_SPL_MEMCPY_W16 (mem, mem + SUBL, (CB_MEML - SUBL)); - WEBRTC_SPL_MEMCPY_W16 (mem + CB_MEML - SUBL, - &decresidual[(iLBCbits_inst->startIdx + 1 + - subframe) * SUBL], SUBL); - } - } - - iLBCenc_inst->Nfor_flag++; - - if (iLBCenc_inst->mode == 20) - { - start_count = 0; - end_count = Nfor; - } - if (iLBCenc_inst->mode == 30) - { - if (iLBCenc_inst->section == 1) - { - start_count = 0; - end_count = WEBRTC_SPL_MIN (Nfor, 2); - } - if (iLBCenc_inst->section == 2) - { - start_count = WEBRTC_SPL_MIN (Nfor, 2); - end_count = Nfor; - } - } -#else - start_count = 0; - end_count = (WebRtc_Word16)Nfor; -#endif - - /* loop over subframes to encode */ - - for (subframe = start_count; subframe < end_count; subframe++){ - - /* encode subframe */ - - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_NSTAGES, - iLBCbits_inst->gain_index+subcount*CB_NSTAGES, - &residual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], - mem, MEM_LF_TBL, SUBL, - &weightdenum[(iLBCbits_inst->startIdx+1+subframe)*(LPC_FILTERORDER+1)], - (WebRtc_Word16)subcount); - - /* construct decoded vector */ - - WebRtcIlbcfix_CbConstruct(&decresidual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], - iLBCbits_inst->cb_index+subcount*CB_NSTAGES, - iLBCbits_inst->gain_index+subcount*CB_NSTAGES, - mem, MEM_LF_TBL, - SUBL - ); - - /* update memory */ - - WEBRTC_SPL_MEMMOVE_W16(mem, mem+SUBL, (CB_MEML-SUBL)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &decresidual[(iLBCbits_inst->startIdx+1+subframe)*SUBL], SUBL); - - subcount++; - } - } - -#ifdef SPLIT_10MS - if ((iLBCenc_inst->section == 1) && - (iLBCenc_inst->mode == 30) && (Nfor > 0) && (end_count == 2)) - { - iLBCenc_inst->section++; - /* adjust index */ - WebRtcIlbcfix_IndexConvEnc (iLBCbits_inst->cb_index); - /* Packetize the parameters into the frame */ - WebRtcIlbcfix_PackBits (iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - return; - } -#endif - - /* backward prediction of subframes */ - - Nback = iLBCbits_inst->startIdx-1; - - if( Nback > 0 ){ - - /* create reverse order vectors - (The decresidual does not need to be copied since it is - contained in the same vector as the residual) - */ - - WebRtcSpl_MemCpyReversedOrder(&reverseResidual[Nback*SUBL-1], residual, Nback*SUBL); - - /* setup memory */ - - meml_gotten = SUBL*(iLBCenc_inst->nsub+1-iLBCbits_inst->startIdx); - if( meml_gotten > CB_MEML ) { - meml_gotten=CB_MEML; - } - - WebRtcSpl_MemCpyReversedOrder(&mem[CB_MEML-1], &decresidual[Nback*SUBL], meml_gotten); - WebRtcSpl_MemSetW16(mem, 0, (WebRtc_Word16)(CB_MEML-meml_gotten)); - -#ifdef SPLIT_10MS - if (iLBCenc_inst->Nback_flag > 0) - { - for (subframe = 0; subframe < WEBRTC_SPL_MAX (2 - Nfor, 0); subframe++) - { - /* update memory */ - WEBRTC_SPL_MEMCPY_W16 (mem, mem + SUBL, (CB_MEML - SUBL)); - WEBRTC_SPL_MEMCPY_W16 (mem + CB_MEML - SUBL, - &reverseDecresidual[subframe * SUBL], SUBL); - } - } - - iLBCenc_inst->Nback_flag++; - - - if (iLBCenc_inst->mode == 20) - { - start_count = 0; - end_count = Nback; - } - if (iLBCenc_inst->mode == 30) - { - if (iLBCenc_inst->section == 1) - { - start_count = 0; - end_count = WEBRTC_SPL_MAX (2 - Nfor, 0); - } - if (iLBCenc_inst->section == 2) - { - start_count = WEBRTC_SPL_MAX (2 - Nfor, 0); - end_count = Nback; - } - } -#else - start_count = 0; - end_count = (WebRtc_Word16)Nback; -#endif - - /* loop over subframes to encode */ - - for (subframe = start_count; subframe < end_count; subframe++){ - - /* encode subframe */ - - WebRtcIlbcfix_CbSearch(iLBCenc_inst, iLBCbits_inst->cb_index+subcount*CB_NSTAGES, - iLBCbits_inst->gain_index+subcount*CB_NSTAGES, &reverseResidual[subframe*SUBL], - mem, MEM_LF_TBL, SUBL, - &weightdenum[(iLBCbits_inst->startIdx-2-subframe)*(LPC_FILTERORDER+1)], - (WebRtc_Word16)subcount); - - /* construct decoded vector */ - - WebRtcIlbcfix_CbConstruct(&reverseDecresidual[subframe*SUBL], - iLBCbits_inst->cb_index+subcount*CB_NSTAGES, - iLBCbits_inst->gain_index+subcount*CB_NSTAGES, - mem, MEM_LF_TBL, SUBL - ); - - /* update memory */ - - WEBRTC_SPL_MEMMOVE_W16(mem, mem+SUBL, (CB_MEML-SUBL)); - WEBRTC_SPL_MEMCPY_W16(mem+CB_MEML-SUBL, - &reverseDecresidual[subframe*SUBL], SUBL); - - subcount++; - - } - - /* get decoded residual from reversed vector */ - - WebRtcSpl_MemCpyReversedOrder(&decresidual[SUBL*Nback-1], reverseDecresidual, SUBL*Nback); - } - /* end encoding part */ - - /* adjust index */ - - WebRtcIlbcfix_IndexConvEnc(iLBCbits_inst->cb_index); - - /* Packetize the parameters into the frame */ - -#ifdef SPLIT_10MS - if( (iLBCenc_inst->mode==30) && (iLBCenc_inst->section==1) ){ - WebRtcIlbcfix_PackBits(iLBCenc_inst->bytes, iLBCbits_inst, iLBCenc_inst->mode); - } - else{ - WebRtcIlbcfix_PackBits(bytes, iLBCbits_inst, iLBCenc_inst->mode); - } -#else - WebRtcIlbcfix_PackBits(bytes, iLBCbits_inst, iLBCenc_inst->mode); -#endif - -#ifndef WEBRTC_BIG_ENDIAN - /* Swap bytes for LITTLE ENDIAN since the packbits() - function assumes BIG_ENDIAN machine */ -#ifdef SPLIT_10MS - if (( (iLBCenc_inst->section == 1) && (iLBCenc_inst->mode == 20) ) || - ( (iLBCenc_inst->section == 2) && (iLBCenc_inst->mode == 30) )){ - WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); - } -#else - WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); -#endif -#endif - -#ifdef SPLIT_10MS - if (subcount == (iLBCenc_inst->nsub - 1)) - { - iLBCenc_inst->section = 0; - } - else - { - iLBCenc_inst->section++; - WEBRTC_SPL_MEMCPY_W16 (weightdenumbuf, weightdenum, - SCRATCH_ENCODE_DATAVEC - SCRATCH_ENCODE_WEIGHTDENUM); - } -#endif - -}
diff --git a/src/modules/audio_coding/codecs/ilbc/encode.h b/src/modules/audio_coding/codecs/ilbc/encode.h deleted file mode 100644 index b7d93d7..0000000 --- a/src/modules/audio_coding/codecs/ilbc/encode.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Encode.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENCODE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * main encoder function - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EncodeImpl( - WebRtc_UWord16 *bytes, /* (o) encoded data bits iLBC */ - const WebRtc_Word16 *block, /* (i) speech vector to encode */ - iLBC_Enc_Inst_t *iLBCenc_inst /* (i/o) the general encoder - state */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/energy_inverse.c b/src/modules/audio_coding/codecs/ilbc/energy_inverse.c deleted file mode 100644 index d56069b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/energy_inverse.c +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnergyInverse.c - -******************************************************************/ - -/* Inverses the in vector in into Q29 domain */ - -#include "energy_inverse.h" - -void WebRtcIlbcfix_EnergyInverse( - WebRtc_Word16 *energy, /* (i/o) Energy and inverse - energy (in Q29) */ - int noOfEnergies) /* (i) The length of the energy - vector */ -{ - WebRtc_Word32 Nom=(WebRtc_Word32)0x1FFFFFFF; - WebRtc_Word16 *energyPtr; - int i; - - /* Set the minimum energy value to 16384 to avoid overflow */ - energyPtr=energy; - for (i=0; i<noOfEnergies; i++) { - (*energyPtr)=WEBRTC_SPL_MAX((*energyPtr),16384); - energyPtr++; - } - - /* Calculate inverse energy in Q29 */ - energyPtr=energy; - for (i=0; i<noOfEnergies; i++) { - (*energyPtr) = (WebRtc_Word16)WebRtcSpl_DivW32W16(Nom, (*energyPtr)); - energyPtr++; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/energy_inverse.h b/src/modules/audio_coding/codecs/ilbc/energy_inverse.h deleted file mode 100644 index db13589..0000000 --- a/src/modules/audio_coding/codecs/ilbc/energy_inverse.h +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnergyInverse.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENERGY_INVERSE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENERGY_INVERSE_H_ - -#include "defines.h" - -/* Inverses the in vector in into Q29 domain */ - -void WebRtcIlbcfix_EnergyInverse( - WebRtc_Word16 *energy, /* (i/o) Energy and inverse - energy (in Q29) */ - int noOfEnergies); /* (i) The length of the energy - vector */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/enh_upsample.c b/src/modules/audio_coding/codecs/ilbc/enh_upsample.c deleted file mode 100644 index 3343816..0000000 --- a/src/modules/audio_coding/codecs/ilbc/enh_upsample.c +++ /dev/null
@@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnhUpsample.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * upsample finite array assuming zeros outside bounds - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EnhUpsample( - WebRtc_Word32 *useq1, /* (o) upsampled output sequence */ - WebRtc_Word16 *seq1 /* (i) unupsampled sequence */ - ){ - int j; - WebRtc_Word32 *pu1, *pu11; - WebRtc_Word16 *ps, *w16tmp; - const WebRtc_Word16 *pp; - - /* filtering: filter overhangs left side of sequence */ - pu1=useq1; - for (j=0;j<ENH_UPS0; j++) { - pu11=pu1; - /* i = 2 */ - pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; - ps=seq1+2; - (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - pu11+=ENH_UPS0; - /* i = 3 */ - pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; - ps=seq1+3; - (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - pu11+=ENH_UPS0; - /* i = 4 */ - pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; - ps=seq1+4; - (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); - pu1++; - } - - /* filtering: simple convolution=inner products - (not needed since the sequence is so short) - */ - - /* filtering: filter overhangs right side of sequence */ - - /* Code with loops, which is equivivalent to the expanded version below - - filterlength = 5; - hf1 = 2; - for(j=0;j<ENH_UPS0; j++){ - pu = useq1 + (filterlength-hfl)*ENH_UPS0 + j; - for(i=1; i<=hfl; i++){ - *pu=0; - pp = polyp[j]+i; - ps = seq1+dim1-1; - for(k=0;k<filterlength-i;k++) { - *pu += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - } - pu+=ENH_UPS0; - } - } - */ - pu1 = useq1 + 12; - w16tmp = seq1+4; - for (j=0;j<ENH_UPS0; j++) { - pu11 = pu1; - /* i = 1 */ - pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+2; - ps = w16tmp; - (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - pu11+=ENH_UPS0; - /* i = 2 */ - pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3; - ps = w16tmp; - (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); - pu11+=ENH_UPS0; - - pu1++; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/enh_upsample.h b/src/modules/audio_coding/codecs/ilbc/enh_upsample.h deleted file mode 100644 index 53534cc..0000000 --- a/src/modules/audio_coding/codecs/ilbc/enh_upsample.h +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnhUpsample.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENH_UPSAMPLE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENH_UPSAMPLE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * upsample finite array assuming zeros outside bounds - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_EnhUpsample( - WebRtc_Word32 *useq1, /* (o) upsampled output sequence */ - WebRtc_Word16 *seq1 /* (i) unupsampled sequence */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/enhancer.c b/src/modules/audio_coding/codecs/ilbc/enhancer.c deleted file mode 100644 index b8f3335..0000000 --- a/src/modules/audio_coding/codecs/ilbc/enhancer.c +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Enhancer.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "get_sync_seq.h" -#include "smooth.h" - -/*----------------------------------------------------------------* - * perform enhancement on idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Enhancer( - WebRtc_Word16 *odata, /* (o) smoothed block, dimension blockl */ - WebRtc_Word16 *idata, /* (i) data buffer used for enhancing */ - WebRtc_Word16 idatal, /* (i) dimension idata */ - WebRtc_Word16 centerStartPos, /* (i) first sample current block within idata */ - WebRtc_Word16 *period, /* (i) pitch period array (pitch bward-in time) */ - WebRtc_Word16 *plocs, /* (i) locations where period array values valid */ - WebRtc_Word16 periodl /* (i) dimension of period and plocs */ - ){ - /* Stack based */ - WebRtc_Word16 surround[ENH_BLOCKL]; - - WebRtcSpl_MemSetW16(surround, 0, ENH_BLOCKL); - - /* get said second sequence of segments */ - - WebRtcIlbcfix_GetSyncSeq(idata, idatal, centerStartPos, period, plocs, - periodl, ENH_HL, surround); - - /* compute the smoothed output from said second sequence */ - - WebRtcIlbcfix_Smooth(odata, idata+centerStartPos, surround); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/enhancer.h b/src/modules/audio_coding/codecs/ilbc/enhancer.h deleted file mode 100644 index e14f559..0000000 --- a/src/modules/audio_coding/codecs/ilbc/enhancer.h +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Enhancer.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * perform enhancement on idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Enhancer( - WebRtc_Word16 *odata, /* (o) smoothed block, dimension blockl */ - WebRtc_Word16 *idata, /* (i) data buffer used for enhancing */ - WebRtc_Word16 idatal, /* (i) dimension idata */ - WebRtc_Word16 centerStartPos, /* (i) first sample current block within idata */ - WebRtc_Word16 *period, /* (i) pitch period array (pitch bward-in time) */ - WebRtc_Word16 *plocs, /* (i) locations where period array values valid */ - WebRtc_Word16 periodl /* (i) dimension of period and plocs */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/src/modules/audio_coding/codecs/ilbc/enhancer_interface.c deleted file mode 100644 index 61b71d1..0000000 --- a/src/modules/audio_coding/codecs/ilbc/enhancer_interface.c +++ /dev/null
@@ -1,381 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnhancerInterface.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "xcorr_coef.h" -#include "enhancer.h" -#include "hp_output.h" - - - -/*----------------------------------------------------------------* - * interface for enhancer - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ - WebRtc_Word16 *out, /* (o) enhanced signal */ - WebRtc_Word16 *in, /* (i) unenhanced signal */ - iLBC_Dec_Inst_t *iLBCdec_inst /* (i) buffers etc */ - ){ - int iblock; - int lag=20, tlag=20; - int inLen=iLBCdec_inst->blockl+120; - WebRtc_Word16 scale, scale1, plc_blockl; - WebRtc_Word16 *enh_buf, *enh_period; - WebRtc_Word32 tmp1, tmp2, max, new_blocks; - WebRtc_Word16 *enh_bufPtr1; - int i, k; - WebRtc_Word16 EnChange; - WebRtc_Word16 SqrtEnChange; - WebRtc_Word16 inc; - WebRtc_Word16 win; - WebRtc_Word16 *tmpW16ptr; - WebRtc_Word16 startPos; - WebRtc_Word16 *plc_pred; - WebRtc_Word16 *target, *regressor; - WebRtc_Word16 max16; - int shifts; - WebRtc_Word32 ener; - WebRtc_Word16 enerSh; - WebRtc_Word16 corrSh; - WebRtc_Word16 ind, sh; - WebRtc_Word16 start, stop; - /* Stack based */ - WebRtc_Word16 totsh[3]; - WebRtc_Word16 downsampled[(BLOCKL_MAX+120)>>1]; /* length 180 */ - WebRtc_Word32 corr32[50]; - WebRtc_Word32 corrmax[3]; - WebRtc_Word16 corr16[3]; - WebRtc_Word16 en16[3]; - WebRtc_Word16 lagmax[3]; - - plc_pred = downsampled; /* Reuse memory since plc_pred[ENH_BLOCKL] and - downsampled are non overlapping */ - enh_buf=iLBCdec_inst->enh_buf; - enh_period=iLBCdec_inst->enh_period; - - /* Copy in the new data into the enhancer buffer */ - - WEBRTC_SPL_MEMMOVE_W16(enh_buf, &enh_buf[iLBCdec_inst->blockl], - ENH_BUFL-iLBCdec_inst->blockl); - - WEBRTC_SPL_MEMCPY_W16(&enh_buf[ENH_BUFL-iLBCdec_inst->blockl], in, - iLBCdec_inst->blockl); - - /* Set variables that are dependent on frame size */ - if (iLBCdec_inst->mode==30) { - plc_blockl=ENH_BLOCKL; - new_blocks=3; - startPos=320; /* Start position for enhancement - (640-new_blocks*ENH_BLOCKL-80) */ - } else { - plc_blockl=40; - new_blocks=2; - startPos=440; /* Start position for enhancement - (640-new_blocks*ENH_BLOCKL-40) */ - } - - /* Update the pitch prediction for each enhancer block, move the old ones */ - WEBRTC_SPL_MEMMOVE_W16(enh_period, &enh_period[new_blocks], - (ENH_NBLOCKS_TOT-new_blocks)); - - k=WebRtcSpl_DownsampleFast( - enh_buf+ENH_BUFL-inLen, /* Input samples */ - (WebRtc_Word16)(inLen+ENH_BUFL_FILTEROVERHEAD), - downsampled, - (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(inLen, 1), - (WebRtc_Word16*)WebRtcIlbcfix_kLpFiltCoefs, /* Coefficients in Q12 */ - FILTERORDER_DS_PLUS1, /* Length of filter (order-1) */ - FACTOR_DS, - DELAY_DS); - - /* Estimate the pitch in the down sampled domain. */ - for(iblock = 0; iblock<new_blocks; iblock++){ - - /* references */ - i=60+WEBRTC_SPL_MUL_16_16(iblock,ENH_BLOCKL_HALF); - target=downsampled+i; - regressor=downsampled+i-10; - - /* scaling */ - max16=WebRtcSpl_MaxAbsValueW16(®ressor[-50], - (WebRtc_Word16)(ENH_BLOCKL_HALF+50-1)); - shifts = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max16, max16)) - 25; - shifts = WEBRTC_SPL_MAX(0, shifts); - - /* compute cross correlation */ - WebRtcSpl_CrossCorrelation(corr32, target, regressor, - ENH_BLOCKL_HALF, 50, (WebRtc_Word16)shifts, -1); - - /* Find 3 highest correlations that should be compared for the - highest (corr*corr)/ener */ - - for (i=0;i<2;i++) { - lagmax[i] = WebRtcSpl_MaxIndexW32(corr32, 50); - corrmax[i] = corr32[lagmax[i]]; - start = lagmax[i] - 2; - stop = lagmax[i] + 2; - start = WEBRTC_SPL_MAX(0, start); - stop = WEBRTC_SPL_MIN(49, stop); - for (k=start; k<=stop; k++) { - corr32[k] = 0; - } - } - lagmax[2] = WebRtcSpl_MaxIndexW32(corr32, 50); - corrmax[2] = corr32[lagmax[2]]; - - /* Calculate normalized corr^2 and ener */ - for (i=0;i<3;i++) { - corrSh = 15-WebRtcSpl_GetSizeInBits(corrmax[i]); - ener = WebRtcSpl_DotProductWithScale(®ressor[-lagmax[i]], - ®ressor[-lagmax[i]], - ENH_BLOCKL_HALF, shifts); - enerSh = 15-WebRtcSpl_GetSizeInBits(ener); - corr16[i] = (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(corrmax[i], corrSh); - corr16[i] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(corr16[i], - corr16[i], 16); - en16[i] = (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(ener, enerSh); - totsh[i] = enerSh - WEBRTC_SPL_LSHIFT_W32(corrSh, 1); - } - - /* Compare lagmax[0..3] for the (corr^2)/ener criteria */ - ind = 0; - for (i=1; i<3; i++) { - if (totsh[ind] > totsh[i]) { - sh = WEBRTC_SPL_MIN(31, totsh[ind]-totsh[i]); - if ( WEBRTC_SPL_MUL_16_16(corr16[ind], en16[i]) < - WEBRTC_SPL_MUL_16_16_RSFT(corr16[i], en16[ind], sh)) { - ind = i; - } - } else { - sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]); - if (WEBRTC_SPL_MUL_16_16_RSFT(corr16[ind], en16[i], sh) < - WEBRTC_SPL_MUL_16_16(corr16[i], en16[ind])) { - ind = i; - } - } - } - - lag = lagmax[ind] + 10; - - /* Store the estimated lag in the non-downsampled domain */ - enh_period[ENH_NBLOCKS_TOT-new_blocks+iblock] = - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(lag, 8); - - /* Store the estimated lag for backward PLC */ - if (iLBCdec_inst->prev_enh_pl==1) { - if (!iblock) { - tlag = WEBRTC_SPL_MUL_16_16(lag, 2); - } - } else { - if (iblock==1) { - tlag = WEBRTC_SPL_MUL_16_16(lag, 2); - } - } - - lag = WEBRTC_SPL_MUL_16_16(lag, 2); - } - - if ((iLBCdec_inst->prev_enh_pl==1)||(iLBCdec_inst->prev_enh_pl==2)) { - - /* Calculate the best lag of the new frame - This is used to interpolate backwards and mix with the PLC'd data - */ - - /* references */ - target=in; - regressor=in+tlag-1; - - /* scaling */ - max16=WebRtcSpl_MaxAbsValueW16(regressor, (WebRtc_Word16)(plc_blockl+3-1)); - if (max16>5000) - shifts=2; - else - shifts=0; - - /* compute cross correlation */ - WebRtcSpl_CrossCorrelation(corr32, target, regressor, - plc_blockl, 3, (WebRtc_Word16)shifts, 1); - - /* find lag */ - lag=WebRtcSpl_MaxIndexW32(corr32, 3); - lag+=tlag-1; - - /* Copy the backward PLC to plc_pred */ - - if (iLBCdec_inst->prev_enh_pl==1) { - if (lag>plc_blockl) { - WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-plc_blockl], plc_blockl); - } else { - WEBRTC_SPL_MEMCPY_W16(&plc_pred[plc_blockl-lag], in, lag); - WEBRTC_SPL_MEMCPY_W16( - plc_pred, &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl+lag], - (plc_blockl-lag)); - } - } else { - int pos; - - pos = plc_blockl; - - while (lag<pos) { - WEBRTC_SPL_MEMCPY_W16(&plc_pred[pos-lag], in, lag); - pos = pos - lag; - } - WEBRTC_SPL_MEMCPY_W16(plc_pred, &in[lag-pos], pos); - - } - - if (iLBCdec_inst->prev_enh_pl==1) { - /* limit energy change - if energy in backward PLC is more than 4 times higher than the forward - PLC, then reduce the energy in the backward PLC vector: - sample 1...len-16 set energy of the to 4 times forward PLC - sample len-15..len interpolate between 4 times fw PLC and bw PLC energy - - Note: Compared to floating point code there is a slight change, - the window is 16 samples long instead of 10 samples to simplify the - calculations - */ - - max=WebRtcSpl_MaxAbsValueW16( - &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl], plc_blockl); - max16=WebRtcSpl_MaxAbsValueW16(plc_pred, plc_blockl); - max = WEBRTC_SPL_MAX(max, max16); - scale=22-(WebRtc_Word16)WebRtcSpl_NormW32(max); - scale=WEBRTC_SPL_MAX(scale,0); - - tmp2 = WebRtcSpl_DotProductWithScale( - &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl], - &enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl], - plc_blockl, scale); - tmp1 = WebRtcSpl_DotProductWithScale(plc_pred, plc_pred, - plc_blockl, scale); - - /* Check the energy difference */ - if ((tmp1>0)&&((tmp1>>2)>tmp2)) { - /* EnChange is now guaranteed to be <0.5 - Calculate EnChange=tmp2/tmp1 in Q16 - */ - - scale1=(WebRtc_Word16)WebRtcSpl_NormW32(tmp1); - tmp1=WEBRTC_SPL_SHIFT_W32(tmp1, (scale1-16)); /* using 15 bits */ - - tmp2=WEBRTC_SPL_SHIFT_W32(tmp2, (scale1)); - EnChange = (WebRtc_Word16)WebRtcSpl_DivW32W16(tmp2, - (WebRtc_Word16)tmp1); - - /* Calculate the Sqrt of the energy in Q15 ((14+16)/2) */ - SqrtEnChange = (WebRtc_Word16)WebRtcSpl_SqrtFloor( - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)EnChange, 14)); - - - /* Multiply first part of vector with 2*SqrtEnChange */ - WebRtcSpl_ScaleVector(plc_pred, plc_pred, SqrtEnChange, - (WebRtc_Word16)(plc_blockl-16), 14); - - /* Calculate increase parameter for window part (16 last samples) */ - /* (1-2*SqrtEnChange)/16 in Q15 */ - inc=(2048-WEBRTC_SPL_RSHIFT_W16(SqrtEnChange, 3)); - - win=0; - tmpW16ptr=&plc_pred[plc_blockl-16]; - - for (i=16;i>0;i--) { - (*tmpW16ptr)=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - (*tmpW16ptr), (SqrtEnChange+(win>>1)), 14); - /* multiply by (2.0*SqrtEnChange+win) */ - - win += inc; - tmpW16ptr++; - } - } - - /* Make the linear interpolation between the forward PLC'd data - and the backward PLC'd data (from the new frame) - */ - - if (plc_blockl==40) { - inc=400; /* 1/41 in Q14 */ - } else { /* plc_blockl==80 */ - inc=202; /* 1/81 in Q14 */ - } - win=0; - enh_bufPtr1=&enh_buf[ENH_BUFL-1-iLBCdec_inst->blockl]; - for (i=0; i<plc_blockl; i++) { - win+=inc; - *enh_bufPtr1 = - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT((*enh_bufPtr1), win, 14); - *enh_bufPtr1 += (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - (16384-win), plc_pred[plc_blockl-1-i], 14); - enh_bufPtr1--; - } - } else { - WebRtc_Word16 *synt = &downsampled[LPC_FILTERORDER]; - - enh_bufPtr1=&enh_buf[ENH_BUFL-iLBCdec_inst->blockl-plc_blockl]; - WEBRTC_SPL_MEMCPY_W16(enh_bufPtr1, plc_pred, plc_blockl); - - /* Clear fileter memory */ - WebRtcSpl_MemSetW16(iLBCdec_inst->syntMem, 0, LPC_FILTERORDER); - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemy, 0, 4); - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemx, 0, 2); - - /* Initialize filter memory by filtering through 2 lags */ - WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], iLBCdec_inst->syntMem, - LPC_FILTERORDER); - WebRtcSpl_FilterARFastQ12( - enh_bufPtr1, - synt, - &iLBCdec_inst->old_syntdenum[ - (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, (WebRtc_Word16)lag); - - WEBRTC_SPL_MEMCPY_W16(&synt[-LPC_FILTERORDER], &synt[lag-LPC_FILTERORDER], - LPC_FILTERORDER); - WebRtcIlbcfix_HpOutput(synt, (WebRtc_Word16*)WebRtcIlbcfix_kHpOutCoefs, - iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, - (WebRtc_Word16)lag); - WebRtcSpl_FilterARFastQ12( - enh_bufPtr1, synt, - &iLBCdec_inst->old_syntdenum[ - (iLBCdec_inst->nsub-1)*(LPC_FILTERORDER+1)], - LPC_FILTERORDER+1, (WebRtc_Word16)lag); - - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->syntMem, &synt[lag-LPC_FILTERORDER], - LPC_FILTERORDER); - WebRtcIlbcfix_HpOutput(synt, (WebRtc_Word16*)WebRtcIlbcfix_kHpOutCoefs, - iLBCdec_inst->hpimemy, iLBCdec_inst->hpimemx, - (WebRtc_Word16)lag); - } - } - - - /* Perform enhancement block by block */ - - for (iblock = 0; iblock<new_blocks; iblock++) { - WebRtcIlbcfix_Enhancer(out+WEBRTC_SPL_MUL_16_16(iblock, ENH_BLOCKL), - enh_buf, - ENH_BUFL, - (WebRtc_Word16)(WEBRTC_SPL_MUL_16_16(iblock, ENH_BLOCKL)+startPos), - enh_period, - (WebRtc_Word16*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT); - } - - return (lag); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/enhancer_interface.h b/src/modules/audio_coding/codecs/ilbc/enhancer_interface.h deleted file mode 100644 index 37b27e2..0000000 --- a/src/modules/audio_coding/codecs/ilbc/enhancer_interface.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_EnhancerInterface.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_INTERFACE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_ENHANCER_INTERFACE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * interface for enhancer - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */ - WebRtc_Word16 *out, /* (o) enhanced signal */ - WebRtc_Word16 *in, /* (i) unenhanced signal */ - iLBC_Dec_Inst_t *iLBCdec_inst /* (i) buffers etc */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c b/src/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c deleted file mode 100644 index 7cece26..0000000 --- a/src/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.c +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FilteredCbVecs.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * Construct an additional codebook vector by filtering the - * initial codebook buffer. This vector is then used to expand - * the codebook with an additional section. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_FilteredCbVecs( - WebRtc_Word16 *cbvectors, /* (o) Codebook vector for the higher section */ - WebRtc_Word16 *CBmem, /* (i) Codebook memory that is filtered to create a - second CB section */ - int lMem, /* (i) Length of codebook memory */ - WebRtc_Word16 samples /* (i) Number of samples to filter */ - ) { - - /* Set up the memory, start with zero state */ - WebRtcSpl_MemSetW16(CBmem+lMem, 0, CB_HALFFILTERLEN); - WebRtcSpl_MemSetW16(CBmem-CB_HALFFILTERLEN, 0, CB_HALFFILTERLEN); - WebRtcSpl_MemSetW16(cbvectors, 0, lMem-samples); - - /* Filter to obtain the filtered CB memory */ - - WebRtcSpl_FilterMAFastQ12( - CBmem+CB_HALFFILTERLEN+lMem-samples, cbvectors+lMem-samples, - (WebRtc_Word16*)WebRtcIlbcfix_kCbFiltersRev, CB_FILTERLEN, samples); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h b/src/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h deleted file mode 100644 index c502e8f..0000000 --- a/src/modules/audio_coding/codecs/ilbc/filtered_cb_vecs.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FilteredCbVecs.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FILTERED_CB_VECS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FILTERED_CB_VECS_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Construct an additional codebook vector by filtering the - * initial codebook buffer. This vector is then used to expand - * the codebook with an additional section. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_FilteredCbVecs( - WebRtc_Word16 *cbvectors, /* (o) Codebook vector for the higher section */ - WebRtc_Word16 *CBmem, /* (i) Codebook memory that is filtered to create a - second CB section */ - int lMem, /* (i) Length of codebook memory */ - WebRtc_Word16 samples /* (i) Number of samples to filter */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/frame_classify.c b/src/modules/audio_coding/codecs/ilbc/frame_classify.c deleted file mode 100644 index ea3675e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/frame_classify.c +++ /dev/null
@@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FrameClassify.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * Classification of subframes to localize start state - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_FrameClassify( - /* (o) Index to the max-energy sub frame */ - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i/o) the encoder state structure */ - WebRtc_Word16 *residualFIX /* (i) lpc residual signal */ - ){ - WebRtc_Word16 max, scale; - WebRtc_Word32 ssqEn[NSUB_MAX-1]; - WebRtc_Word16 *ssqPtr; - WebRtc_Word32 *seqEnPtr; - WebRtc_Word32 maxW32; - WebRtc_Word16 scale1; - WebRtc_Word16 pos; - int n; - - /* - Calculate the energy of each of the 80 sample blocks - in the draft the 4 first and last samples are windowed with 1/5...4/5 - and 4/5...1/5 respectively. To simplify for the fixpoint we have changed - this to 0 0 1 1 and 1 1 0 0 - */ - - max = WebRtcSpl_MaxAbsValueW16(residualFIX, iLBCenc_inst->blockl); - scale=WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max,max)); - - /* Scale to maximum 24 bits so that it won't overflow for 76 samples */ - scale = scale-24; - scale1 = WEBRTC_SPL_MAX(0, scale); - - /* Calculate energies */ - ssqPtr=residualFIX + 2; - seqEnPtr=ssqEn; - for (n=(iLBCenc_inst->nsub-1); n>0; n--) { - (*seqEnPtr) = WebRtcSpl_DotProductWithScale(ssqPtr, ssqPtr, 76, scale1); - ssqPtr += 40; - seqEnPtr++; - } - - /* Scale to maximum 20 bits in order to allow for the 11 bit window */ - maxW32 = WebRtcSpl_MaxValueW32(ssqEn, (WebRtc_Word16)(iLBCenc_inst->nsub-1)); - scale = WebRtcSpl_GetSizeInBits(maxW32) - 20; - scale1 = WEBRTC_SPL_MAX(0, scale); - - /* Window each 80 block with the ssqEn_winTbl window to give higher probability for - the blocks in the middle - */ - seqEnPtr=ssqEn; - if (iLBCenc_inst->mode==20) { - ssqPtr=(WebRtc_Word16*)WebRtcIlbcfix_kStartSequenceEnrgWin+1; - } else { - ssqPtr=(WebRtc_Word16*)WebRtcIlbcfix_kStartSequenceEnrgWin; - } - for (n=(iLBCenc_inst->nsub-1); n>0; n--) { - (*seqEnPtr)=WEBRTC_SPL_MUL(((*seqEnPtr)>>scale1), (*ssqPtr)); - seqEnPtr++; - ssqPtr++; - } - - /* Extract the best choise of start state */ - pos = WebRtcSpl_MaxIndexW32(ssqEn, (WebRtc_Word16)(iLBCenc_inst->nsub-1)) + 1; - - return(pos); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/frame_classify.h b/src/modules/audio_coding/codecs/ilbc/frame_classify.h deleted file mode 100644 index faf4666..0000000 --- a/src/modules/audio_coding/codecs/ilbc/frame_classify.h +++ /dev/null
@@ -1,29 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_FrameClassify.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FRAME_CLASSIFY_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_FRAME_CLASSIFY_H_ - -WebRtc_Word16 WebRtcIlbcfix_FrameClassify( - /* (o) Index to the max-energy sub frame */ - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i/o) the encoder state structure */ - WebRtc_Word16 *residualFIX /* (i) lpc residual signal */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/gain_dequant.c b/src/modules/audio_coding/codecs/ilbc/gain_dequant.c deleted file mode 100644 index 9450a80..0000000 --- a/src/modules/audio_coding/codecs/ilbc/gain_dequant.c +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainDequant.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * decoder for quantized gains in the gain-shape coding of - * residual - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_GainDequant( - /* (o) quantized gain value (Q14) */ - WebRtc_Word16 index, /* (i) quantization index */ - WebRtc_Word16 maxIn, /* (i) maximum of unquantized gain (Q14) */ - WebRtc_Word16 stage /* (i) The stage of the search */ - ){ - WebRtc_Word16 scale; - const WebRtc_Word16 *gain; - - /* obtain correct scale factor */ - - scale=WEBRTC_SPL_ABS_W16(maxIn); - scale = WEBRTC_SPL_MAX(1638, scale); /* if lower than 0.1, set it to 0.1 */ - - /* select the quantization table and return the decoded value */ - gain = WebRtcIlbcfix_kGain[stage]; - - return((WebRtc_Word16)((WEBRTC_SPL_MUL_16_16(scale, gain[index])+8192)>>14)); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/gain_dequant.h b/src/modules/audio_coding/codecs/ilbc/gain_dequant.h deleted file mode 100644 index 28f2ceb..0000000 --- a/src/modules/audio_coding/codecs/ilbc/gain_dequant.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainDequant.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_DEQUANT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_DEQUANT_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * decoder for quantized gains in the gain-shape coding of - * residual - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_GainDequant( - /* (o) quantized gain value (Q14) */ - WebRtc_Word16 index, /* (i) quantization index */ - WebRtc_Word16 maxIn, /* (i) maximum of unquantized gain (Q14) */ - WebRtc_Word16 stage /* (i) The stage of the search */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/gain_quant.c b/src/modules/audio_coding/codecs/ilbc/gain_quant.c deleted file mode 100644 index bdf88a5..0000000 --- a/src/modules/audio_coding/codecs/ilbc/gain_quant.c +++ /dev/null
@@ -1,106 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainQuant.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * quantizer for the gain in the gain-shape coding of residual - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ - WebRtc_Word16 gain, /* (i) gain value Q14 */ - WebRtc_Word16 maxIn, /* (i) maximum of gain value Q14 */ - WebRtc_Word16 stage, /* (i) The stage of the search */ - WebRtc_Word16 *index /* (o) quantization index */ - ) { - - WebRtc_Word16 scale, returnVal, cblen; - WebRtc_Word32 gainW32, measure1, measure2; - const WebRtc_Word16 *cbPtr, *cb; - int loc, noMoves, noChecks, i; - - /* ensure a lower bound (0.1) on the scaling factor */ - - scale = WEBRTC_SPL_MAX(1638, maxIn); - - /* select the quantization table and calculate - the length of the table and the number of - steps in the binary search that are needed */ - cb = WebRtcIlbcfix_kGain[stage]; - cblen = 32>>stage; - noChecks = 4-stage; - - /* Multiply the gain with 2^14 to make the comparison - easier and with higher precision */ - gainW32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)gain, 14); - - /* Do a binary search, starting in the middle of the CB - loc - defines the current position in the table - noMoves - defines the number of steps to move in the CB in order - to get next CB location - */ - - loc = cblen>>1; - noMoves = loc; - cbPtr = cb + loc; /* Centre of CB */ - - for (i=noChecks;i>0;i--) { - noMoves>>=1; - measure1=WEBRTC_SPL_MUL_16_16(scale, (*cbPtr)); - - /* Move up if gain is larger, otherwise move down in table */ - measure1 = measure1 - gainW32; - - if (0>measure1) { - cbPtr+=noMoves; - loc+=noMoves; - } else { - cbPtr-=noMoves; - loc-=noMoves; - } - } - - /* Check which value is the closest one: loc-1, loc or loc+1 */ - - measure1=WEBRTC_SPL_MUL_16_16(scale, (*cbPtr)); - if (gainW32>measure1) { - /* Check against value above loc */ - measure2=WEBRTC_SPL_MUL_16_16(scale, (*(cbPtr+1))); - if ((measure2-gainW32)<(gainW32-measure1)) { - loc+=1; - } - } else { - /* Check against value below loc */ - measure2=WEBRTC_SPL_MUL_16_16(scale, (*(cbPtr-1))); - if ((gainW32-measure2)<=(measure1-gainW32)) { - loc-=1; - } - } - - /* Guard against getting outside the table. The calculation above can give a location - which is one above the maximum value (in very rare cases) */ - loc=WEBRTC_SPL_MIN(loc, (cblen-1)); - *index=loc; - - /* Calculate the quantized gain value (in Q14) */ - returnVal=(WebRtc_Word16)((WEBRTC_SPL_MUL_16_16(scale, cb[loc])+8192)>>14); - - /* return the quantized value */ - return(returnVal); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/gain_quant.h b/src/modules/audio_coding/codecs/ilbc/gain_quant.h deleted file mode 100644 index a2f0596..0000000 --- a/src/modules/audio_coding/codecs/ilbc/gain_quant.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GainQuant.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_QUANT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GAIN_QUANT_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * quantizer for the gain in the gain-shape coding of residual - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */ - WebRtc_Word16 gain, /* (i) gain value Q14 */ - WebRtc_Word16 maxIn, /* (i) maximum of gain value Q14 */ - WebRtc_Word16 stage, /* (i) The stage of the search */ - WebRtc_Word16 *index /* (o) quantization index */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/get_cd_vec.c b/src/modules/audio_coding/codecs/ilbc/get_cd_vec.c deleted file mode 100644 index aba3e31..0000000 --- a/src/modules/audio_coding/codecs/ilbc/get_cd_vec.c +++ /dev/null
@@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetCbVec.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "create_augmented_vec.h" - -/*----------------------------------------------------------------* - * Construct codebook vector for given index. - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetCbVec( - WebRtc_Word16 *cbvec, /* (o) Constructed codebook vector */ - WebRtc_Word16 *mem, /* (i) Codebook buffer */ - WebRtc_Word16 index, /* (i) Codebook index */ - WebRtc_Word16 lMem, /* (i) Length of codebook buffer */ - WebRtc_Word16 cbveclen /* (i) Codebook vector length */ - ){ - WebRtc_Word16 k, base_size; - WebRtc_Word16 lag; - /* Stack based */ - WebRtc_Word16 tempbuff2[SUBL+5]; - - /* Determine size of codebook sections */ - - base_size=lMem-cbveclen+1; - - if (cbveclen==SUBL) { - base_size+=WEBRTC_SPL_RSHIFT_W16(cbveclen,1); - } - - /* No filter -> First codebook section */ - - if (index<lMem-cbveclen+1) { - - /* first non-interpolated vectors */ - - k=index+cbveclen; - /* get vector */ - WEBRTC_SPL_MEMCPY_W16(cbvec, mem+lMem-k, cbveclen); - - } else if (index < base_size) { - - /* Calculate lag */ - - k=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(2, (index-(lMem-cbveclen+1)))+cbveclen; - - lag=WEBRTC_SPL_RSHIFT_W16(k, 1); - - WebRtcIlbcfix_CreateAugmentedVec(lag, mem+lMem, cbvec); - - } - - /* Higher codebbok section based on filtering */ - - else { - - WebRtc_Word16 memIndTest; - - /* first non-interpolated vectors */ - - if (index-base_size<lMem-cbveclen+1) { - - /* Set up filter memory, stuff zeros outside memory buffer */ - - memIndTest = lMem-(index-base_size+cbveclen); - - WebRtcSpl_MemSetW16(mem-CB_HALFFILTERLEN, 0, CB_HALFFILTERLEN); - WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); - - /* do filtering to get the codebook vector */ - - WebRtcSpl_FilterMAFastQ12( - &mem[memIndTest+4], cbvec, (WebRtc_Word16*)WebRtcIlbcfix_kCbFiltersRev, - CB_FILTERLEN, cbveclen); - } - - /* interpolated vectors */ - - else { - /* Stuff zeros outside memory buffer */ - memIndTest = lMem-cbveclen-CB_FILTERLEN; - WebRtcSpl_MemSetW16(mem+lMem, 0, CB_HALFFILTERLEN); - - /* do filtering */ - WebRtcSpl_FilterMAFastQ12( - &mem[memIndTest+7], tempbuff2, (WebRtc_Word16*)WebRtcIlbcfix_kCbFiltersRev, - CB_FILTERLEN, (WebRtc_Word16)(cbveclen+5)); - - /* Calculate lag index */ - lag = (cbveclen<<1)-20+index-base_size-lMem-1; - - WebRtcIlbcfix_CreateAugmentedVec(lag, tempbuff2+SUBL+5, cbvec); - } - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/get_cd_vec.h b/src/modules/audio_coding/codecs/ilbc/get_cd_vec.h deleted file mode 100644 index 99b5d4e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/get_cd_vec.h +++ /dev/null
@@ -1,30 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetCbVec.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_CD_VEC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_CD_VEC_H_ - -void WebRtcIlbcfix_GetCbVec( - WebRtc_Word16 *cbvec, /* (o) Constructed codebook vector */ - WebRtc_Word16 *mem, /* (i) Codebook buffer */ - WebRtc_Word16 index, /* (i) Codebook index */ - WebRtc_Word16 lMem, /* (i) Length of codebook buffer */ - WebRtc_Word16 cbveclen /* (i) Codebook vector length */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/get_lsp_poly.c b/src/modules/audio_coding/codecs/ilbc/get_lsp_poly.c deleted file mode 100644 index c55e918..0000000 --- a/src/modules/audio_coding/codecs/ilbc/get_lsp_poly.c +++ /dev/null
@@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetLspPoly.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Construct the polynomials F1(z) and F2(z) from the LSP - * (Computations are done in Q24) - * - * The expansion is performed using the following recursion: - * - * f[0] = 1; - * tmp = -2.0 * lsp[0]; - * f[1] = tmp; - * for (i=2; i<=5; i++) { - * b = -2.0 * lsp[2*i-2]; - * f[i] = tmp*f[i-1] + 2.0*f[i-2]; - * for (j=i; j>=2; j--) { - * f[j] = f[j] + tmp*f[j-1] + f[j-2]; - * } - * f[i] = f[i] + tmp; - * } - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetLspPoly( - WebRtc_Word16 *lsp, /* (i) LSP in Q15 */ - WebRtc_Word32 *f) /* (o) polonymial in Q24 */ -{ - WebRtc_Word32 tmpW32; - int i, j; - WebRtc_Word16 high, low; - WebRtc_Word16 *lspPtr; - WebRtc_Word32 *fPtr; - - lspPtr = lsp; - fPtr = f; - /* f[0] = 1.0 (Q24) */ - (*fPtr) = (WebRtc_Word32)16777216; - fPtr++; - - (*fPtr) = WEBRTC_SPL_MUL((*lspPtr), -1024); - fPtr++; - lspPtr+=2; - - for(i=2; i<=5; i++) - { - (*fPtr) = fPtr[-2]; - - for(j=i; j>1; j--) - { - /* Compute f[j] = f[j] + tmp*f[j-1] + f[j-2]; */ - high = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(fPtr[-1], 16); - low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(fPtr[-1]-WEBRTC_SPL_LSHIFT_W32(((WebRtc_Word32)high),16), 1); - - tmpW32 = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(high, (*lspPtr)), 2) + - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16_RSFT(low, (*lspPtr), 15), 2); - - (*fPtr) += fPtr[-2]; - (*fPtr) -= tmpW32; - fPtr--; - } - (*fPtr) -= (WebRtc_Word32)WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)(*lspPtr), 10); - - fPtr+=i; - lspPtr+=2; - } - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/get_lsp_poly.h b/src/modules/audio_coding/codecs/ilbc/get_lsp_poly.h deleted file mode 100644 index b0520b4..0000000 --- a/src/modules/audio_coding/codecs/ilbc/get_lsp_poly.h +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetLspPoly.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_LSP_POLY_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_LSP_POLY_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Construct the polynomials F1(z) and F2(z) from the LSP - * (Computations are done in Q24) - * - * The expansion is performed using the following recursion: - * - * f[0] = 1; - * tmp = -2.0 * lsp[0]; - * f[1] = tmp; - * for (i=2; i<=5; i++) { - * b = -2.0 * lsp[2*i-2]; - * f[i] = tmp*f[i-1] + 2.0*f[i-2]; - * for (j=i; j>=2; j--) { - * f[j] = f[j] + tmp*f[j-1] + f[j-2]; - * } - * f[i] = f[i] + tmp; - * } - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetLspPoly( - WebRtc_Word16 *lsp, /* (i) LSP in Q15 */ - WebRtc_Word32 *f); /* (o) polonymial in Q24 */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/get_sync_seq.c b/src/modules/audio_coding/codecs/ilbc/get_sync_seq.c deleted file mode 100644 index ce72865..0000000 --- a/src/modules/audio_coding/codecs/ilbc/get_sync_seq.c +++ /dev/null
@@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetSyncSeq.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "refiner.h" -#include "nearest_neighbor.h" - -/*----------------------------------------------------------------* - * get the pitch-synchronous sample sequence - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetSyncSeq( - WebRtc_Word16 *idata, /* (i) original data */ - WebRtc_Word16 idatal, /* (i) dimension of data */ - WebRtc_Word16 centerStartPos, /* (i) where current block starts */ - WebRtc_Word16 *period, /* (i) rough-pitch-period array (Q-2) */ - WebRtc_Word16 *plocs, /* (i) where periods of period array are taken (Q-2) */ - WebRtc_Word16 periodl, /* (i) dimension period array */ - WebRtc_Word16 hl, /* (i) 2*hl+1 is the number of sequences */ - WebRtc_Word16 *surround /* (i/o) The contribution from this sequence - summed with earlier contributions */ - ){ - WebRtc_Word16 i,centerEndPos,q; - /* Stack based */ - WebRtc_Word16 lagBlock[2*ENH_HL+1]; - WebRtc_Word16 blockStartPos[2*ENH_HL+1]; /* Defines the position to search around (Q2) */ - WebRtc_Word16 plocs2[ENH_PLOCSL]; - - centerEndPos=centerStartPos+ENH_BLOCKL-1; - - /* present (find predicted lag from this position) */ - - WebRtcIlbcfix_NearestNeighbor(lagBlock+hl,plocs, - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(2, (centerStartPos+centerEndPos)), - periodl); - - blockStartPos[hl]=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(4, centerStartPos); - - /* past (find predicted position and perform a refined - search to find the best sequence) */ - - for(q=hl-1;q>=0;q--) { - blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]]; - - WebRtcIlbcfix_NearestNeighbor(lagBlock+q, plocs, - (WebRtc_Word16)(blockStartPos[q] + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(4, ENH_BLOCKL_HALF)-period[lagBlock[q+1]]), - periodl); - - if((blockStartPos[q]-(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(4, ENH_OVERHANG))>=0) { - - /* Find the best possible sequence in the 4 times upsampled - domain around blockStartPos+q */ - WebRtcIlbcfix_Refiner(blockStartPos+q,idata,idatal, - centerStartPos,blockStartPos[q],surround,WebRtcIlbcfix_kEnhWt[q]); - - } else { - /* Don't add anything since this sequence would - be outside the buffer */ - } - } - - /* future (find predicted position and perform a refined - search to find the best sequence) */ - - for(i=0;i<periodl;i++) { - plocs2[i]=(plocs[i]-period[i]); - } - - for(q=hl+1;q<=WEBRTC_SPL_MUL_16_16(2, hl);q++) { - - WebRtcIlbcfix_NearestNeighbor(lagBlock+q,plocs2, - (WebRtc_Word16)(blockStartPos[q-1]+ - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(4, ENH_BLOCKL_HALF)),periodl); - - blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]]; - - if( (blockStartPos[q]+(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(4, (ENH_BLOCKL+ENH_OVERHANG))) - < - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(4, idatal)) { - - /* Find the best possible sequence in the 4 times upsampled - domain around blockStartPos+q */ - WebRtcIlbcfix_Refiner(blockStartPos+q, idata, idatal, - centerStartPos,blockStartPos[q],surround,WebRtcIlbcfix_kEnhWt[2*hl-q]); - - } - else { - /* Don't add anything since this sequence would - be outside the buffer */ - } - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/get_sync_seq.h b/src/modules/audio_coding/codecs/ilbc/get_sync_seq.h deleted file mode 100644 index a0ffd39..0000000 --- a/src/modules/audio_coding/codecs/ilbc/get_sync_seq.h +++ /dev/null
@@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_GetSyncSeq.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_SYNC_SEQ_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_GET_SYNC_SEQ_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * get the pitch-synchronous sample sequence - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_GetSyncSeq( - WebRtc_Word16 *idata, /* (i) original data */ - WebRtc_Word16 idatal, /* (i) dimension of data */ - WebRtc_Word16 centerStartPos, /* (i) where current block starts */ - WebRtc_Word16 *period, /* (i) rough-pitch-period array (Q-2) */ - WebRtc_Word16 *plocs, /* (i) where periods of period array are taken (Q-2) */ - WebRtc_Word16 periodl, /* (i) dimension period array */ - WebRtc_Word16 hl, /* (i) 2*hl+1 is the number of sequences */ - WebRtc_Word16 *surround /* (i/o) The contribution from this sequence - summed with earlier contributions */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/hp_input.c b/src/modules/audio_coding/codecs/ilbc/hp_input.c deleted file mode 100644 index f202f62..0000000 --- a/src/modules/audio_coding/codecs/ilbc/hp_input.c +++ /dev/null
@@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpInput.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * high-pass filter of input with *0.5 and saturation - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_HpInput( - WebRtc_Word16 *signal, /* (i/o) signal vector */ - WebRtc_Word16 *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - WebRtc_Word16 *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - WebRtc_Word16 *x, /* (i/o) Filter state x[n-1] x[n-2] */ - WebRtc_Word16 len) /* (i) Number of samples to filter */ -{ - int i; - WebRtc_Word32 tmpW32; - WebRtc_Word32 tmpW32b; - - for (i=0; i<len; i++) { - - /* - y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] - + (-a[1])*y[i-1] + (-a[2])*y[i-2]; - */ - - tmpW32 = WEBRTC_SPL_MUL_16_16(y[1], ba[3]); /* (-a[1])*y[i-1] (low part) */ - tmpW32 += WEBRTC_SPL_MUL_16_16(y[3], ba[4]); /* (-a[2])*y[i-2] (low part) */ - tmpW32 = (tmpW32>>15); - tmpW32 += WEBRTC_SPL_MUL_16_16(y[0], ba[3]); /* (-a[1])*y[i-1] (high part) */ - tmpW32 += WEBRTC_SPL_MUL_16_16(y[2], ba[4]); /* (-a[2])*y[i-2] (high part) */ - tmpW32 = (tmpW32<<1); - - tmpW32 += WEBRTC_SPL_MUL_16_16(signal[i], ba[0]); /* b[0]*x[0] */ - tmpW32 += WEBRTC_SPL_MUL_16_16(x[0], ba[1]); /* b[1]*x[i-1] */ - tmpW32 += WEBRTC_SPL_MUL_16_16(x[1], ba[2]); /* b[2]*x[i-2] */ - - /* Update state (input part) */ - x[1] = x[0]; - x[0] = signal[i]; - - /* Rounding in Q(12+1), i.e. add 2^12 */ - tmpW32b = tmpW32 + 4096; - - /* Saturate (to 2^28) so that the HP filtered signal does not overflow */ - tmpW32b = WEBRTC_SPL_SAT((WebRtc_Word32)268435455, tmpW32b, (WebRtc_Word32)-268435456); - - /* Convert back to Q0 and multiply with 0.5 */ - signal[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32b, 13); - - /* Update state (filtered part) */ - y[2] = y[0]; - y[3] = y[1]; - - /* upshift tmpW32 by 3 with saturation */ - if (tmpW32>268435455) { - tmpW32 = WEBRTC_SPL_WORD32_MAX; - } else if (tmpW32<-268435456) { - tmpW32 = WEBRTC_SPL_WORD32_MIN; - } else { - tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3); - } - - y[0] = (WebRtc_Word16)(tmpW32 >> 16); - y[1] = (WebRtc_Word16)((tmpW32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)y[0], 16))>>1); - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/hp_input.h b/src/modules/audio_coding/codecs/ilbc/hp_input.h deleted file mode 100644 index f56c4f7..0000000 --- a/src/modules/audio_coding/codecs/ilbc/hp_input.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpInput.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_INPUT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_INPUT_H_ - -#include "defines.h" - -void WebRtcIlbcfix_HpInput( - WebRtc_Word16 *signal, /* (i/o) signal vector */ - WebRtc_Word16 *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - WebRtc_Word16 *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - WebRtc_Word16 *x, /* (i/o) Filter state x[n-1] x[n-2] */ - WebRtc_Word16 len); /* (i) Number of samples to filter */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/hp_output.c b/src/modules/audio_coding/codecs/ilbc/hp_output.c deleted file mode 100644 index 8e1c919..0000000 --- a/src/modules/audio_coding/codecs/ilbc/hp_output.c +++ /dev/null
@@ -1,89 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpOutput.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * high-pass filter of output and *2 with saturation - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_HpOutput( - WebRtc_Word16 *signal, /* (i/o) signal vector */ - WebRtc_Word16 *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - WebRtc_Word16 *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - WebRtc_Word16 *x, /* (i/o) Filter state x[n-1] x[n-2] */ - WebRtc_Word16 len) /* (i) Number of samples to filter */ -{ - int i; - WebRtc_Word32 tmpW32; - WebRtc_Word32 tmpW32b; - - for (i=0; i<len; i++) { - - /* - y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2] - + (-a[1])*y[i-1] + (-a[2])*y[i-2]; - */ - - tmpW32 = WEBRTC_SPL_MUL_16_16(y[1], ba[3]); /* (-a[1])*y[i-1] (low part) */ - tmpW32 += WEBRTC_SPL_MUL_16_16(y[3], ba[4]); /* (-a[2])*y[i-2] (low part) */ - tmpW32 = (tmpW32>>15); - tmpW32 += WEBRTC_SPL_MUL_16_16(y[0], ba[3]); /* (-a[1])*y[i-1] (high part) */ - tmpW32 += WEBRTC_SPL_MUL_16_16(y[2], ba[4]); /* (-a[2])*y[i-2] (high part) */ - tmpW32 = (tmpW32<<1); - - tmpW32 += WEBRTC_SPL_MUL_16_16(signal[i], ba[0]); /* b[0]*x[0] */ - tmpW32 += WEBRTC_SPL_MUL_16_16(x[0], ba[1]); /* b[1]*x[i-1] */ - tmpW32 += WEBRTC_SPL_MUL_16_16(x[1], ba[2]); /* b[2]*x[i-2] */ - - /* Update state (input part) */ - x[1] = x[0]; - x[0] = signal[i]; - - /* Rounding in Q(12-1), i.e. add 2^10 */ - tmpW32b = tmpW32 + 1024; - - /* Saturate (to 2^26) so that the HP filtered signal does not overflow */ - tmpW32b = WEBRTC_SPL_SAT((WebRtc_Word32)67108863, tmpW32b, (WebRtc_Word32)-67108864); - - /* Convert back to Q0 and multiply with 2 */ - signal[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32b, 11); - - /* Update state (filtered part) */ - y[2] = y[0]; - y[3] = y[1]; - - /* upshift tmpW32 by 3 with saturation */ - if (tmpW32>268435455) { - tmpW32 = WEBRTC_SPL_WORD32_MAX; - } else if (tmpW32<-268435456) { - tmpW32 = WEBRTC_SPL_WORD32_MIN; - } else { - tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3); - } - - y[0] = (WebRtc_Word16)(tmpW32 >> 16); - y[1] = (WebRtc_Word16)((tmpW32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)y[0], 16))>>1); - - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/hp_output.h b/src/modules/audio_coding/codecs/ilbc/hp_output.h deleted file mode 100644 index c9a7426..0000000 --- a/src/modules/audio_coding/codecs/ilbc/hp_output.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_HpOutput.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_OUTPUT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_HP_OUTPUT_H_ - -#include "defines.h" - -void WebRtcIlbcfix_HpOutput( - WebRtc_Word16 *signal, /* (i/o) signal vector */ - WebRtc_Word16 *ba, /* (i) B- and A-coefficients (2:nd order) - {b[0] b[1] b[2] -a[1] -a[2]} a[0] - is assumed to be 1.0 */ - WebRtc_Word16 *y, /* (i/o) Filter state yhi[n-1] ylow[n-1] - yhi[n-2] ylow[n-2] */ - WebRtc_Word16 *x, /* (i/o) Filter state x[n-1] x[n-2] */ - WebRtc_Word16 len); /* (i) Number of samples to filter */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/ilbc.c b/src/modules/audio_coding/codecs/ilbc/ilbc.c deleted file mode 100644 index dbd32d1..0000000 --- a/src/modules/audio_coding/codecs/ilbc/ilbc.c +++ /dev/null
@@ -1,255 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - iLBCInterface.c - -******************************************************************/ - -#include "ilbc.h" -#include "defines.h" -#include "init_encode.h" -#include "encode.h" -#include "init_decode.h" -#include "decode.h" -#include <stdlib.h> - - -WebRtc_Word16 WebRtcIlbcfix_EncoderAssign(iLBC_encinst_t **iLBC_encinst, WebRtc_Word16 *ILBCENC_inst_Addr, WebRtc_Word16 *size) { - *iLBC_encinst=(iLBC_encinst_t*)ILBCENC_inst_Addr; - *size=sizeof(iLBC_Enc_Inst_t)/sizeof(WebRtc_Word16); - if (*iLBC_encinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcIlbcfix_DecoderAssign(iLBC_decinst_t **iLBC_decinst, WebRtc_Word16 *ILBCDEC_inst_Addr, WebRtc_Word16 *size) { - *iLBC_decinst=(iLBC_decinst_t*)ILBCDEC_inst_Addr; - *size=sizeof(iLBC_Dec_Inst_t)/sizeof(WebRtc_Word16); - if (*iLBC_decinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcIlbcfix_EncoderCreate(iLBC_encinst_t **iLBC_encinst) { - *iLBC_encinst=(iLBC_encinst_t*)malloc(sizeof(iLBC_Enc_Inst_t)); - if (*iLBC_encinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcIlbcfix_DecoderCreate(iLBC_decinst_t **iLBC_decinst) { - *iLBC_decinst=(iLBC_decinst_t*)malloc(sizeof(iLBC_Dec_Inst_t)); - if (*iLBC_decinst!=NULL) { - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcIlbcfix_EncoderFree(iLBC_encinst_t *iLBC_encinst) { - free(iLBC_encinst); - return(0); -} - -WebRtc_Word16 WebRtcIlbcfix_DecoderFree(iLBC_decinst_t *iLBC_decinst) { - free(iLBC_decinst); - return(0); -} - - -WebRtc_Word16 WebRtcIlbcfix_EncoderInit(iLBC_encinst_t *iLBCenc_inst, WebRtc_Word16 mode) -{ - if ((mode==20)||(mode==30)) { - WebRtcIlbcfix_InitEncode((iLBC_Enc_Inst_t*) iLBCenc_inst, mode); - return(0); - } else { - return(-1); - } -} - -WebRtc_Word16 WebRtcIlbcfix_Encode(iLBC_encinst_t *iLBCenc_inst, const WebRtc_Word16 *speechIn, WebRtc_Word16 len, WebRtc_Word16 *encoded) { - - WebRtc_Word16 pos = 0; - WebRtc_Word16 encpos = 0; - - if ((len != ((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl) && -#ifdef SPLIT_10MS - (len != 80) && -#endif - (len != 2*((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl) && - (len != 3*((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl)) - { - /* A maximum of 3 frames/packet is allowed */ - return(-1); - } else { - - /* call encoder */ - while (pos<len) { - WebRtcIlbcfix_EncodeImpl((WebRtc_UWord16*) &encoded[encpos], &speechIn[pos], (iLBC_Enc_Inst_t*) iLBCenc_inst); -#ifdef SPLIT_10MS - pos += 80; - if(((iLBC_Enc_Inst_t*)iLBCenc_inst)->section == 0) -#else - pos += ((iLBC_Enc_Inst_t*)iLBCenc_inst)->blockl; -#endif - encpos += ((iLBC_Enc_Inst_t*)iLBCenc_inst)->no_of_words; - } - return (encpos*2); - } -} - -WebRtc_Word16 WebRtcIlbcfix_DecoderInit(iLBC_decinst_t *iLBCdec_inst, WebRtc_Word16 mode) { - if ((mode==20)||(mode==30)) { - WebRtcIlbcfix_InitDecode((iLBC_Dec_Inst_t*) iLBCdec_inst, mode, 1); - return(0); - } else { - return(-1); - } -} -WebRtc_Word16 WebRtcIlbcfix_DecoderInit20Ms(iLBC_decinst_t *iLBCdec_inst) { - WebRtcIlbcfix_InitDecode((iLBC_Dec_Inst_t*) iLBCdec_inst, 20, 1); - return(0); -} -WebRtc_Word16 WebRtcIlbcfix_Decoderinit30Ms(iLBC_decinst_t *iLBCdec_inst) { - WebRtcIlbcfix_InitDecode((iLBC_Dec_Inst_t*) iLBCdec_inst, 30, 1); - return(0); -} - - -WebRtc_Word16 WebRtcIlbcfix_Decode(iLBC_decinst_t *iLBCdec_inst, - const WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - int i=0; - /* Allow for automatic switching between the frame sizes - (although you do get some discontinuity) */ - if ((len==((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)|| - (len==2*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)|| - (len==3*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)) { - /* ok, do nothing */ - } else { - /* Test if the mode has changed */ - if (((iLBC_Dec_Inst_t*)iLBCdec_inst)->mode==20) { - if ((len==NO_OF_BYTES_30MS)|| - (len==2*NO_OF_BYTES_30MS)|| - (len==3*NO_OF_BYTES_30MS)) { - WebRtcIlbcfix_InitDecode(((iLBC_Dec_Inst_t*)iLBCdec_inst), 30, ((iLBC_Dec_Inst_t*)iLBCdec_inst)->use_enhancer); - } else { - /* Unsupported frame length */ - return(-1); - } - } else { - if ((len==NO_OF_BYTES_20MS)|| - (len==2*NO_OF_BYTES_20MS)|| - (len==3*NO_OF_BYTES_20MS)) { - WebRtcIlbcfix_InitDecode(((iLBC_Dec_Inst_t*)iLBCdec_inst), 20, ((iLBC_Dec_Inst_t*)iLBCdec_inst)->use_enhancer); - } else { - /* Unsupported frame length */ - return(-1); - } - } - } - - while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)<len) { - WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); - i++; - } - /* iLBC does not support VAD/CNG yet */ - *speechType=1; - return(i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl); -} - -WebRtc_Word16 WebRtcIlbcfix_Decode20Ms(iLBC_decinst_t *iLBCdec_inst, - const WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - int i=0; - if ((len==((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)|| - (len==2*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)|| - (len==3*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)) { - /* ok, do nothing */ - } else { - return(-1); - } - - while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)<len) { - WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); - i++; - } - /* iLBC does not support VAD/CNG yet */ - *speechType=1; - return(i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl); -} - -WebRtc_Word16 WebRtcIlbcfix_Decode30Ms(iLBC_decinst_t *iLBCdec_inst, - const WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - int i=0; - if ((len==((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)|| - (len==2*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)|| - (len==3*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)) { - /* ok, do nothing */ - } else { - return(-1); - } - - while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)<len) { - WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); - i++; - } - /* iLBC does not support VAD/CNG yet */ - *speechType=1; - return(i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl); -} - -WebRtc_Word16 WebRtcIlbcfix_DecodePlc(iLBC_decinst_t *iLBCdec_inst, WebRtc_Word16 *decoded, WebRtc_Word16 noOfLostFrames) { - int i; - WebRtc_UWord16 dummy; - - for (i=0;i<noOfLostFrames;i++) { - /* call decoder */ - WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], &dummy, (iLBC_Dec_Inst_t*) iLBCdec_inst, 0); - } - return (noOfLostFrames*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl); -} - -WebRtc_Word16 WebRtcIlbcfix_NetEqPlc(iLBC_decinst_t *iLBCdec_inst, WebRtc_Word16 *decoded, WebRtc_Word16 noOfLostFrames) { - - /* Two input parameters not used, but needed for function pointers in NetEQ */ - (void)(decoded = NULL); - (void)(noOfLostFrames = 0); - - WebRtcSpl_MemSetW16(((iLBC_Dec_Inst_t*)iLBCdec_inst)->enh_buf, 0, ENH_BUFL); - ((iLBC_Dec_Inst_t*)iLBCdec_inst)->prev_enh_pl = 2; - - return (0); -} - -void WebRtcIlbcfix_version(char *version) -{ - strcpy((char*)version, "1.1.1"); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/ilbc.gypi b/src/modules/audio_coding/codecs/ilbc/ilbc.gypi deleted file mode 100644 index 89ae27d..0000000 --- a/src/modules/audio_coding/codecs/ilbc/ilbc.gypi +++ /dev/null
@@ -1,190 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'iLBC', - 'type': '<(library)', - 'dependencies': [ - '<(webrtc_root)/common_audio/common_audio.gyp:signal_processing', - ], - 'include_dirs': [ - 'interface', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'interface', - ], - }, - 'sources': [ - 'interface/ilbc.h', - 'abs_quant.c', - 'abs_quant_loop.c', - 'augmented_cb_corr.c', - 'bw_expand.c', - 'cb_construct.c', - 'cb_mem_energy.c', - 'cb_mem_energy_augmentation.c', - 'cb_mem_energy_calc.c', - 'cb_search.c', - 'cb_search_core.c', - 'cb_update_best_index.c', - 'chebyshev.c', - 'comp_corr.c', - 'constants.c', - 'create_augmented_vec.c', - 'decode.c', - 'decode_residual.c', - 'decoder_interpolate_lsf.c', - 'do_plc.c', - 'encode.c', - 'energy_inverse.c', - 'enh_upsample.c', - 'enhancer.c', - 'enhancer_interface.c', - 'filtered_cb_vecs.c', - 'frame_classify.c', - 'gain_dequant.c', - 'gain_quant.c', - 'get_cd_vec.c', - 'get_lsp_poly.c', - 'get_sync_seq.c', - 'hp_input.c', - 'hp_output.c', - 'ilbc.c', - 'index_conv_dec.c', - 'index_conv_enc.c', - 'init_decode.c', - 'init_encode.c', - 'interpolate.c', - 'interpolate_samples.c', - 'lpc_encode.c', - 'lsf_check.c', - 'lsf_interpolate_to_poly_dec.c', - 'lsf_interpolate_to_poly_enc.c', - 'lsf_to_lsp.c', - 'lsf_to_poly.c', - 'lsp_to_lsf.c', - 'my_corr.c', - 'nearest_neighbor.c', - 'pack_bits.c', - 'poly_to_lsf.c', - 'poly_to_lsp.c', - 'refiner.c', - 'simple_interpolate_lsf.c', - 'simple_lpc_analysis.c', - 'simple_lsf_dequant.c', - 'simple_lsf_quant.c', - 'smooth.c', - 'smooth_out_data.c', - 'sort_sq.c', - 'split_vq.c', - 'state_construct.c', - 'state_search.c', - 'swap_bytes.c', - 'unpack_bits.c', - 'vq3.c', - 'vq4.c', - 'window32_w32.c', - 'xcorr_coef.c', - 'abs_quant.h', - 'abs_quant_loop.h', - 'augmented_cb_corr.h', - 'bw_expand.h', - 'cb_construct.h', - 'cb_mem_energy.h', - 'cb_mem_energy_augmentation.h', - 'cb_mem_energy_calc.h', - 'cb_search.h', - 'cb_search_core.h', - 'cb_update_best_index.h', - 'chebyshev.h', - 'comp_corr.h', - 'constants.h', - 'create_augmented_vec.h', - 'decode.h', - 'decode_residual.h', - 'decoder_interpolate_lsf.h', - 'do_plc.h', - 'encode.h', - 'energy_inverse.h', - 'enh_upsample.h', - 'enhancer.h', - 'enhancer_interface.h', - 'filtered_cb_vecs.h', - 'frame_classify.h', - 'gain_dequant.h', - 'gain_quant.h', - 'get_cd_vec.h', - 'get_lsp_poly.h', - 'get_sync_seq.h', - 'hp_input.h', - 'hp_output.h', - 'defines.h', - 'index_conv_dec.h', - 'index_conv_enc.h', - 'init_decode.h', - 'init_encode.h', - 'interpolate.h', - 'interpolate_samples.h', - 'lpc_encode.h', - 'lsf_check.h', - 'lsf_interpolate_to_poly_dec.h', - 'lsf_interpolate_to_poly_enc.h', - 'lsf_to_lsp.h', - 'lsf_to_poly.h', - 'lsp_to_lsf.h', - 'my_corr.h', - 'nearest_neighbor.h', - 'pack_bits.h', - 'poly_to_lsf.h', - 'poly_to_lsp.h', - 'refiner.h', - 'simple_interpolate_lsf.h', - 'simple_lpc_analysis.h', - 'simple_lsf_dequant.h', - 'simple_lsf_quant.h', - 'smooth.h', - 'smooth_out_data.h', - 'sort_sq.h', - 'split_vq.h', - 'state_construct.h', - 'state_search.h', - 'swap_bytes.h', - 'unpack_bits.h', - 'vq3.h', - 'vq4.h', - 'window32_w32.h', - 'xcorr_coef.h', - ], # sources - }, # iLBC - ], # targets - 'conditions': [ - ['include_tests==1', { - 'targets': [ - { - 'target_name': 'iLBCtest', - 'type': 'executable', - 'dependencies': [ - 'iLBC', - ], - 'sources': [ - 'test/iLBC_test.c', - ], - }, # iLBCtest - ], # targets - }], # include_tests - ], # conditions -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/modules/audio_coding/codecs/ilbc/index_conv_dec.c b/src/modules/audio_coding/codecs/ilbc/index_conv_dec.c deleted file mode 100644 index 0d6346a..0000000 --- a/src/modules/audio_coding/codecs/ilbc/index_conv_dec.c +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvDec.c - -******************************************************************/ - -#include "defines.h" - -void WebRtcIlbcfix_IndexConvDec( - WebRtc_Word16 *index /* (i/o) Codebook indexes */ - ){ - int k; - - for (k=4;k<6;k++) { - /* Readjust the second and third codebook index for the first 40 sample - so that they look the same as the first (in terms of lag) - */ - if ((index[k]>=44)&&(index[k]<108)) { - index[k]+=64; - } else if ((index[k]>=108)&&(index[k]<128)) { - index[k]+=128; - } else { - /* ERROR */ - } - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/index_conv_dec.h b/src/modules/audio_coding/codecs/ilbc/index_conv_dec.h deleted file mode 100644 index f29ee23..0000000 --- a/src/modules/audio_coding/codecs/ilbc/index_conv_dec.h +++ /dev/null
@@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvDec.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_DEC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_DEC_H_ - -#include "defines.h" - -void WebRtcIlbcfix_IndexConvDec( - WebRtc_Word16 *index /* (i/o) Codebook indexes */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/index_conv_enc.c b/src/modules/audio_coding/codecs/ilbc/index_conv_enc.c deleted file mode 100644 index cbc04b6..0000000 --- a/src/modules/audio_coding/codecs/ilbc/index_conv_enc.c +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - IiLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvEnc.c - -******************************************************************/ - -#include "defines.h" -/*----------------------------------------------------------------* - * Convert the codebook indexes to make the search easier - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_IndexConvEnc( - WebRtc_Word16 *index /* (i/o) Codebook indexes */ - ){ - int k; - - for (k=4;k<6;k++) { - /* Readjust the second and third codebook index so that it is - packetized into 7 bits (before it was put in lag-wise the same - way as for the first codebook which uses 8 bits) - */ - if ((index[k]>=108)&&(index[k]<172)) { - index[k]-=64; - } else if (index[k]>=236) { - index[k]-=128; - } else { - /* ERROR */ - } - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/index_conv_enc.h b/src/modules/audio_coding/codecs/ilbc/index_conv_enc.h deleted file mode 100644 index d28a6e2..0000000 --- a/src/modules/audio_coding/codecs/ilbc/index_conv_enc.h +++ /dev/null
@@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_IndexConvEnc.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_ENC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INDEX_CONV_ENC_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Convert the codebook indexes to make the search easier - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_IndexConvEnc( - WebRtc_Word16 *index /* (i/o) Codebook indexes */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/init_decode.c b/src/modules/audio_coding/codecs/ilbc/init_decode.c deleted file mode 100644 index b654f1e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/init_decode.c +++ /dev/null
@@ -1,98 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitDecode.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * Initiation of decoder instance. - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */ - iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) Decoder instance */ - WebRtc_Word16 mode, /* (i) frame size mode */ - int use_enhancer /* (i) 1 to use enhancer - 0 to run without enhancer */ - ) { - int i; - - iLBCdec_inst->mode = mode; - - /* Set all the variables that are dependent on the frame size mode */ - if (mode==30) { - iLBCdec_inst->blockl = BLOCKL_30MS; - iLBCdec_inst->nsub = NSUB_30MS; - iLBCdec_inst->nasub = NASUB_30MS; - iLBCdec_inst->lpc_n = LPC_N_30MS; - iLBCdec_inst->no_of_bytes = NO_OF_BYTES_30MS; - iLBCdec_inst->no_of_words = NO_OF_WORDS_30MS; - iLBCdec_inst->state_short_len=STATE_SHORT_LEN_30MS; - } - else if (mode==20) { - iLBCdec_inst->blockl = BLOCKL_20MS; - iLBCdec_inst->nsub = NSUB_20MS; - iLBCdec_inst->nasub = NASUB_20MS; - iLBCdec_inst->lpc_n = LPC_N_20MS; - iLBCdec_inst->no_of_bytes = NO_OF_BYTES_20MS; - iLBCdec_inst->no_of_words = NO_OF_WORDS_20MS; - iLBCdec_inst->state_short_len=STATE_SHORT_LEN_20MS; - } - else { - return(-1); - } - - /* Reset all the previous LSF to mean LSF */ - WEBRTC_SPL_MEMCPY_W16(iLBCdec_inst->lsfdeqold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER); - - /* Clear the synthesis filter memory */ - WebRtcSpl_MemSetW16(iLBCdec_inst->syntMem, 0, LPC_FILTERORDER); - - /* Set the old synthesis filter to {1.0 0.0 ... 0.0} */ - WebRtcSpl_MemSetW16(iLBCdec_inst->old_syntdenum, 0, ((LPC_FILTERORDER + 1)*NSUB_MAX)); - for (i=0; i<NSUB_MAX; i++) { - iLBCdec_inst->old_syntdenum[i*(LPC_FILTERORDER+1)] = 4096; - } - - /* Clear the variables that are used for the PLC */ - iLBCdec_inst->last_lag = 20; - iLBCdec_inst->consPLICount = 0; - iLBCdec_inst->prevPLI = 0; - iLBCdec_inst->perSquare = 0; - iLBCdec_inst->prevLag = 120; - iLBCdec_inst->prevLpc[0] = 4096; - WebRtcSpl_MemSetW16(iLBCdec_inst->prevLpc+1, 0, LPC_FILTERORDER); - WebRtcSpl_MemSetW16(iLBCdec_inst->prevResidual, 0, BLOCKL_MAX); - - /* Initialize the seed for the random number generator */ - iLBCdec_inst->seed = 777; - - /* Set the filter state of the HP filter to 0 */ - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemx, 0, 2); - WebRtcSpl_MemSetW16(iLBCdec_inst->hpimemy, 0, 4); - - /* Set the variables that are used in the ehnahcer */ - iLBCdec_inst->use_enhancer = use_enhancer; - WebRtcSpl_MemSetW16(iLBCdec_inst->enh_buf, 0, (ENH_BUFL+ENH_BUFL_FILTEROVERHEAD)); - for (i=0;i<ENH_NBLOCKS_TOT;i++) { - iLBCdec_inst->enh_period[i]=160; /* Q(-4) */ - } - - iLBCdec_inst->prev_enh_pl = 0; - - return (iLBCdec_inst->blockl); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/init_decode.h b/src/modules/audio_coding/codecs/ilbc/init_decode.h deleted file mode 100644 index 3452f34..0000000 --- a/src/modules/audio_coding/codecs/ilbc/init_decode.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitDecode.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_DECODE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_DECODE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Initiation of decoder instance. - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_InitDecode( /* (o) Number of decoded samples */ - iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) Decoder instance */ - WebRtc_Word16 mode, /* (i) frame size mode */ - int use_enhancer /* (i) 1 to use enhancer - 0 to run without enhancer */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/init_encode.c b/src/modules/audio_coding/codecs/ilbc/init_encode.c deleted file mode 100644 index e034bb0..0000000 --- a/src/modules/audio_coding/codecs/ilbc/init_encode.c +++ /dev/null
@@ -1,72 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitEncode.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * Initiation of encoder instance. - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */ - iLBC_Enc_Inst_t *iLBCenc_inst, /* (i/o) Encoder instance */ - WebRtc_Word16 mode /* (i) frame size mode */ - ){ - iLBCenc_inst->mode = mode; - - /* Set all the variables that are dependent on the frame size mode */ - if (mode==30) { - iLBCenc_inst->blockl = BLOCKL_30MS; - iLBCenc_inst->nsub = NSUB_30MS; - iLBCenc_inst->nasub = NASUB_30MS; - iLBCenc_inst->lpc_n = LPC_N_30MS; - iLBCenc_inst->no_of_bytes = NO_OF_BYTES_30MS; - iLBCenc_inst->no_of_words = NO_OF_WORDS_30MS; - iLBCenc_inst->state_short_len=STATE_SHORT_LEN_30MS; - } - else if (mode==20) { - iLBCenc_inst->blockl = BLOCKL_20MS; - iLBCenc_inst->nsub = NSUB_20MS; - iLBCenc_inst->nasub = NASUB_20MS; - iLBCenc_inst->lpc_n = LPC_N_20MS; - iLBCenc_inst->no_of_bytes = NO_OF_BYTES_20MS; - iLBCenc_inst->no_of_words = NO_OF_WORDS_20MS; - iLBCenc_inst->state_short_len=STATE_SHORT_LEN_20MS; - } - else { - return(-1); - } - - /* Clear the buffers and set the previous LSF and LSP to the mean value */ - WebRtcSpl_MemSetW16(iLBCenc_inst->anaMem, 0, LPC_FILTERORDER); - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER); - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lsfdeqold, WebRtcIlbcfix_kLsfMean, LPC_FILTERORDER); - WebRtcSpl_MemSetW16(iLBCenc_inst->lpc_buffer, 0, LPC_LOOKBACK + BLOCKL_MAX); - - /* Set the filter state of the HP filter to 0 */ - WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemx, 0, 2); - WebRtcSpl_MemSetW16(iLBCenc_inst->hpimemy, 0, 4); - -#ifdef SPLIT_10MS - /*Zeroing the past samples for 10msec Split*/ - WebRtcSpl_MemSetW16(iLBCenc_inst->past_samples,0,160); - iLBCenc_inst->section = 0; -#endif - - return (iLBCenc_inst->no_of_bytes); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/init_encode.h b/src/modules/audio_coding/codecs/ilbc/init_encode.h deleted file mode 100644 index f1d1858..0000000 --- a/src/modules/audio_coding/codecs/ilbc/init_encode.h +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InitEncode.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_ENCODE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INIT_ENCODE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Initiation of encoder instance. - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_InitEncode( /* (o) Number of bytes encoded */ - iLBC_Enc_Inst_t *iLBCenc_inst, /* (i/o) Encoder instance */ - WebRtc_Word16 mode /* (i) frame size mode */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h b/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h deleted file mode 100644 index 6208962..0000000 --- a/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h +++ /dev/null
@@ -1,259 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * ilbc.h - * - * This header file contains all of the API's for iLBC. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_INTERFACE_ILBC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_INTERFACE_ILBC_H_ - -/* - * Define the fixpoint numeric formats - */ - -#include "typedefs.h" - -/* - * Solution to support multiple instances - * Customer has to cast instance to proper type - */ - -typedef struct iLBC_encinst_t_ iLBC_encinst_t; - -typedef struct iLBC_decinst_t_ iLBC_decinst_t; - -/* - * Comfort noise constants - */ - -#define ILBC_SPEECH 1 -#define ILBC_CNG 2 - -#ifdef __cplusplus -extern "C" { -#endif - - /**************************************************************************** - * WebRtcIlbcfix_XxxAssign(...) - * - * These functions assigns the encoder/decoder instance to the specified - * memory location - * - * Input: - * - XXX_xxxinst : Pointer to created instance that should be - * assigned - * - ILBCXXX_inst_Addr : Pointer to the desired memory space - * - size : The size that this structure occupies (in Word16) - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_EncoderAssign(iLBC_encinst_t **iLBC_encinst, - WebRtc_Word16 *ILBCENC_inst_Addr, - WebRtc_Word16 *size); - WebRtc_Word16 WebRtcIlbcfix_DecoderAssign(iLBC_decinst_t **iLBC_decinst, - WebRtc_Word16 *ILBCDEC_inst_Addr, - WebRtc_Word16 *size); - - - /**************************************************************************** - * WebRtcIlbcfix_XxxAssign(...) - * - * These functions create a instance to the specified structure - * - * Input: - * - XXX_inst : Pointer to created instance that should be created - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_EncoderCreate(iLBC_encinst_t **iLBC_encinst); - WebRtc_Word16 WebRtcIlbcfix_DecoderCreate(iLBC_decinst_t **iLBC_decinst); - - /**************************************************************************** - * WebRtcIlbcfix_XxxFree(...) - * - * These functions frees the dynamic memory of a specified instance - * - * Input: - * - XXX_inst : Pointer to created instance that should be freed - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_EncoderFree(iLBC_encinst_t *iLBC_encinst); - WebRtc_Word16 WebRtcIlbcfix_DecoderFree(iLBC_decinst_t *iLBC_decinst); - - - /**************************************************************************** - * WebRtcIlbcfix_EncoderInit(...) - * - * This function initializes a iLBC instance - * - * Input: - * - iLBCenc_inst : iLBC instance, i.e. the user that should receive - * be initialized - * - frameLen : The frame length of the codec 20/30 (ms) - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_EncoderInit(iLBC_encinst_t *iLBCenc_inst, - WebRtc_Word16 frameLen); - - /**************************************************************************** - * WebRtcIlbcfix_Encode(...) - * - * This function encodes one iLBC frame. Input speech length has be a - * multiple of the frame length. - * - * Input: - * - iLBCenc_inst : iLBC instance, i.e. the user that should encode - * a package - * - speechIn : Input speech vector - * - len : Samples in speechIn (160, 240, 320 or 480) - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_Encode(iLBC_encinst_t *iLBCenc_inst, - const WebRtc_Word16 *speechIn, - WebRtc_Word16 len, - WebRtc_Word16 *encoded); - - /**************************************************************************** - * WebRtcIlbcfix_DecoderInit(...) - * - * This function initializes a iLBC instance with either 20 or 30 ms frames - * Alternatively the WebRtcIlbcfix_DecoderInit_XXms can be used. Then it's - * not needed to specify the frame length with a variable. - * - * Input: - * - iLBC_decinst_t : iLBC instance, i.e. the user that should receive - * be initialized - * - frameLen : The frame length of the codec 20/30 (ms) - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_DecoderInit(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 frameLen); - WebRtc_Word16 WebRtcIlbcfix_DecoderInit20Ms(iLBC_decinst_t *iLBCdec_inst); - WebRtc_Word16 WebRtcIlbcfix_Decoderinit30Ms(iLBC_decinst_t *iLBCdec_inst); - - /**************************************************************************** - * WebRtcIlbcfix_Decode(...) - * - * This function decodes a packet with iLBC frame(s). Output speech length - * will be a multiple of 160 or 240 samples ((160 or 240)*frames/packet). - * - * Input: - * - iLBCdec_inst : iLBC instance, i.e. the user that should decode - * a packet - * - encoded : Encoded iLBC frame(s) - * - len : Bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - speechType : 1 normal, 2 CNG - * - * Return value : >0 - Samples in decoded vector - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_Decode(iLBC_decinst_t *iLBCdec_inst, - const WebRtc_Word16* encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - WebRtc_Word16 WebRtcIlbcfix_Decode20Ms(iLBC_decinst_t *iLBCdec_inst, - const WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - WebRtc_Word16 WebRtcIlbcfix_Decode30Ms(iLBC_decinst_t *iLBCdec_inst, - const WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - - /**************************************************************************** - * WebRtcIlbcfix_DecodePlc(...) - * - * This function conducts PLC for iLBC frame(s). Output speech length - * will be a multiple of 160 or 240 samples. - * - * Input: - * - iLBCdec_inst : iLBC instance, i.e. the user that should perform - * a PLC - * - noOfLostFrames : Number of PLC frames to produce - * - * Output: - * - decoded : The "decoded" vector - * - * Return value : >0 - Samples in decoded PLC vector - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_DecodePlc(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *decoded, - WebRtc_Word16 noOfLostFrames); - - /**************************************************************************** - * WebRtcIlbcfix_NetEqPlc(...) - * - * This function updates the decoder when a packet loss has occured, but it - * does not produce any PLC data. Function can be used if another PLC method - * is used (i.e NetEq). - * - * Input: - * - iLBCdec_inst : iLBC instance that should be updated - * - noOfLostFrames : Number of lost frames - * - * Output: - * - decoded : The "decoded" vector (nothing in this case) - * - * Return value : >0 - Samples in decoded PLC vector - * -1 - Error - */ - - WebRtc_Word16 WebRtcIlbcfix_NetEqPlc(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *decoded, - WebRtc_Word16 noOfLostFrames); - - /**************************************************************************** - * WebRtcIlbcfix_version(...) - * - * This function returns the version number of iLBC - * - * Output: - * - version : Version number of iLBC (maximum 20 char) - */ - - void WebRtcIlbcfix_version(char *version); - -#ifdef __cplusplus -} -#endif - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/interpolate.c b/src/modules/audio_coding/codecs/ilbc/interpolate.c deleted file mode 100644 index 11cb33c..0000000 --- a/src/modules/audio_coding/codecs/ilbc/interpolate.c +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Interpolate.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * interpolation between vectors - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Interpolate( - WebRtc_Word16 *out, /* (o) output vector */ - WebRtc_Word16 *in1, /* (i) first input vector */ - WebRtc_Word16 *in2, /* (i) second input vector */ - WebRtc_Word16 coef, /* (i) weight coefficient in Q14 */ - WebRtc_Word16 length) /* (i) number of sample is vectors */ -{ - int i; - WebRtc_Word16 invcoef; - - /* - Performs the operation out[i] = in[i]*coef + (1-coef)*in2[i] (with rounding) - */ - - invcoef = 16384 - coef; /* 16384 = 1.0 (Q14)*/ - for (i = 0; i < length; i++) { - out[i] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32( - (WEBRTC_SPL_MUL_16_16(coef, in1[i]) + WEBRTC_SPL_MUL_16_16(invcoef, in2[i]))+8192, - 14); - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/interpolate.h b/src/modules/audio_coding/codecs/ilbc/interpolate.h deleted file mode 100644 index a12021c..0000000 --- a/src/modules/audio_coding/codecs/ilbc/interpolate.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Interpolate.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * interpolation between vectors - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Interpolate( - WebRtc_Word16 *out, /* (o) output vector */ - WebRtc_Word16 *in1, /* (i) first input vector */ - WebRtc_Word16 *in2, /* (i) second input vector */ - WebRtc_Word16 coef, /* (i) weight coefficient in Q14 */ - WebRtc_Word16 length); /* (i) number of sample is vectors */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/interpolate_samples.c b/src/modules/audio_coding/codecs/ilbc/interpolate_samples.c deleted file mode 100644 index 31eb52e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/interpolate_samples.c +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InterpolateSamples.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -void WebRtcIlbcfix_InterpolateSamples( - WebRtc_Word16 *interpSamples, /* (o) The interpolated samples */ - WebRtc_Word16 *CBmem, /* (i) The CB memory */ - WebRtc_Word16 lMem /* (i) Length of the CB memory */ - ) { - WebRtc_Word16 *ppi, *ppo, i, j, temp1, temp2; - WebRtc_Word16 *tmpPtr; - - /* Calculate the 20 vectors of interpolated samples (4 samples each) - that are used in the codebooks for lag 20 to 39 */ - tmpPtr = interpSamples; - for (j=0; j<20; j++) { - temp1 = 0; - temp2 = 3; - ppo = CBmem+lMem-4; - ppi = CBmem+lMem-j-24; - for (i=0; i<4; i++) { - - *tmpPtr++ = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIlbcfix_kAlpha[temp2],*ppo, 15) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIlbcfix_kAlpha[temp1], *ppi, 15); - - ppo++; - ppi++; - temp1++; - temp2--; - } - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/interpolate_samples.h b/src/modules/audio_coding/codecs/ilbc/interpolate_samples.h deleted file mode 100644 index 5c98aaf..0000000 --- a/src/modules/audio_coding/codecs/ilbc/interpolate_samples.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_InterpolateSamples.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_SAMPLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_INTERPOLATE_SAMPLES_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Construct the interpolated samples for the Augmented CB - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_InterpolateSamples( - WebRtc_Word16 *interpSamples, /* (o) The interpolated samples */ - WebRtc_Word16 *CBmem, /* (i) The CB memory */ - WebRtc_Word16 lMem /* (i) Length of the CB memory */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lpc_encode.c b/src/modules/audio_coding/codecs/ilbc/lpc_encode.c deleted file mode 100644 index 73d67a0..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lpc_encode.c +++ /dev/null
@@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LpcEncode.c - -******************************************************************/ - -#include "defines.h" -#include "simple_lpc_analysis.h" -#include "simple_interpolate_lsf.h" -#include "simple_lsf_quant.h" -#include "lsf_check.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * lpc encoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LpcEncode( - WebRtc_Word16 *syntdenum, /* (i/o) synthesis filter coefficients - before/after encoding */ - WebRtc_Word16 *weightdenum, /* (i/o) weighting denumerator coefficients - before/after encoding */ - WebRtc_Word16 *lsf_index, /* (o) lsf quantization index */ - WebRtc_Word16 *data, /* (i) Speech to do LPC analysis on */ - iLBC_Enc_Inst_t *iLBCenc_inst - /* (i/o) the encoder state structure */ - ) { - /* Stack based */ - WebRtc_Word16 lsf[LPC_FILTERORDER * LPC_N_MAX]; - WebRtc_Word16 lsfdeq[LPC_FILTERORDER * LPC_N_MAX]; - - /* Calculate LSF's from the input speech */ - WebRtcIlbcfix_SimpleLpcAnalysis(lsf, data, iLBCenc_inst); - - /* Quantize the LSF's */ - WebRtcIlbcfix_SimpleLsfQ(lsfdeq, lsf_index, lsf, iLBCenc_inst->lpc_n); - - /* Stableize the LSF's if needed */ - WebRtcIlbcfix_LsfCheck(lsfdeq, LPC_FILTERORDER, iLBCenc_inst->lpc_n); - - /* Calculate the synthesis and weighting filter coefficients from - the optimal LSF and the dequantized LSF */ - WebRtcIlbcfix_SimpleInterpolateLsf(syntdenum, weightdenum, - lsf, lsfdeq, iLBCenc_inst->lsfold, - iLBCenc_inst->lsfdeqold, LPC_FILTERORDER, iLBCenc_inst); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lpc_encode.h b/src/modules/audio_coding/codecs/ilbc/lpc_encode.h deleted file mode 100644 index 36967a3..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lpc_encode.h +++ /dev/null
@@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LpcEncode.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LPC_ENCODE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LPC_ENCODE_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lpc encoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LpcEncode( - WebRtc_Word16 *syntdenum, /* (i/o) synthesis filter coefficients - before/after encoding */ - WebRtc_Word16 *weightdenum, /* (i/o) weighting denumerator coefficients - before/after encoding */ - WebRtc_Word16 *lsf_index, /* (o) lsf quantization index */ - WebRtc_Word16 *data, /* (i) Speech to do LPC analysis on */ - iLBC_Enc_Inst_t *iLBCenc_inst - /* (i/o) the encoder state structure */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_check.c b/src/modules/audio_coding/codecs/ilbc/lsf_check.c deleted file mode 100644 index 7097d74..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_check.c +++ /dev/null
@@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfCheck.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * check for stability of lsf coefficients - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_LsfCheck( - WebRtc_Word16 *lsf, /* LSF parameters */ - int dim, /* dimension of LSF */ - int NoAn) /* No of analysis per frame */ -{ - int k,n,m, Nit=2, change=0,pos; - const WebRtc_Word16 eps=319; /* 0.039 in Q13 (50 Hz)*/ - const WebRtc_Word16 eps2=160; /* eps/2.0 in Q13;*/ - const WebRtc_Word16 maxlsf=25723; /* 3.14; (4000 Hz)*/ - const WebRtc_Word16 minlsf=82; /* 0.01; (0 Hz)*/ - - /* LSF separation check*/ - for (n=0;n<Nit;n++) { /* Run through a 2 times */ - for (m=0;m<NoAn;m++) { /* Number of analyses per frame */ - for (k=0;k<(dim-1);k++) { - pos=m*dim+k; - - /* Seperate coefficients with a safety margin of 50 Hz */ - if ((lsf[pos+1]-lsf[pos])<eps) { - - if (lsf[pos+1]<lsf[pos]) { - lsf[pos+1]= lsf[pos]+eps2; - lsf[pos]= lsf[pos+1]-eps2; - } else { - lsf[pos]-=eps2; - lsf[pos+1]+=eps2; - } - change=1; - } - - /* Limit minimum and maximum LSF */ - if (lsf[pos]<minlsf) { - lsf[pos]=minlsf; - change=1; - } - - if (lsf[pos]>maxlsf) { - lsf[pos]=maxlsf; - change=1; - } - } - } - } - - return change; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_check.h b/src/modules/audio_coding/codecs/ilbc/lsf_check.h deleted file mode 100644 index 830bbed..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_check.h +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfCheck.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_CHECK_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_CHECK_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * check for stability of lsf coefficients - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_LsfCheck( - WebRtc_Word16 *lsf, /* LSF parameters */ - int dim, /* dimension of LSF */ - int NoAn); /* No of analysis per frame */ - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c b/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c deleted file mode 100644 index 3bb23d0..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.c +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LspInterpolate2PolyDec.c - -******************************************************************/ - -#include "interpolate.h" -#include "lsf_to_poly.h" -#include "defines.h" - -/*----------------------------------------------------------------* - * interpolation of lsf coefficients for the decoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LspInterpolate2PolyDec( - WebRtc_Word16 *a, /* (o) lpc coefficients Q12 */ - WebRtc_Word16 *lsf1, /* (i) first set of lsf coefficients Q13 */ - WebRtc_Word16 *lsf2, /* (i) second set of lsf coefficients Q13 */ - WebRtc_Word16 coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - WebRtc_Word16 length /* (i) length of coefficient vectors */ - ){ - WebRtc_Word16 lsftmp[LPC_FILTERORDER]; - - /* interpolate LSF */ - WebRtcIlbcfix_Interpolate(lsftmp, lsf1, lsf2, coef, length); - - /* Compute the filter coefficients from the LSF */ - WebRtcIlbcfix_Lsf2Poly(a, lsftmp); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h b/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h deleted file mode 100644 index 23fe3a7..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_dec.h +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LspInterpolate2PolyDec.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_DEC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_DEC_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * interpolation of lsf coefficients for the decoder - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LspInterpolate2PolyDec( - WebRtc_Word16 *a, /* (o) lpc coefficients Q12 */ - WebRtc_Word16 *lsf1, /* (i) first set of lsf coefficients Q13 */ - WebRtc_Word16 *lsf2, /* (i) second set of lsf coefficients Q13 */ - WebRtc_Word16 coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - WebRtc_Word16 length /* (i) length of coefficient vectors */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c b/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c deleted file mode 100644 index 3b0a34d..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.c +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfInterpolate2PloyEnc.c - -******************************************************************/ - -#include "defines.h" -#include "interpolate.h" -#include "lsf_to_poly.h" - -/*----------------------------------------------------------------* - * lsf interpolator and conversion from lsf to a coefficients - * (subrutine to SimpleInterpolateLSF) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LsfInterpolate2PloyEnc( - WebRtc_Word16 *a, /* (o) lpc coefficients Q12 */ - WebRtc_Word16 *lsf1, /* (i) first set of lsf coefficients Q13 */ - WebRtc_Word16 *lsf2, /* (i) second set of lsf coefficients Q13 */ - WebRtc_Word16 coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - WebRtc_Word16 length /* (i) length of coefficient vectors */ - ) { - /* Stack based */ - WebRtc_Word16 lsftmp[LPC_FILTERORDER]; - - /* interpolate LSF */ - WebRtcIlbcfix_Interpolate(lsftmp, lsf1, lsf2, coef, length); - - /* Compute the filter coefficients from the LSF */ - WebRtcIlbcfix_Lsf2Poly(a, lsftmp); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h b/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h deleted file mode 100644 index 1bbbb80..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_interpolate_to_poly_enc.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_LsfInterpolate2PloyEnc.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_ENC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_INTERPOLATE_TO_POLY_ENC_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lsf interpolator and conversion from lsf to a coefficients - * (subrutine to SimpleInterpolateLSF) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_LsfInterpolate2PloyEnc( - WebRtc_Word16 *a, /* (o) lpc coefficients Q12 */ - WebRtc_Word16 *lsf1, /* (i) first set of lsf coefficients Q13 */ - WebRtc_Word16 *lsf2, /* (i) second set of lsf coefficients Q13 */ - WebRtc_Word16 coef, /* (i) weighting coefficient to use between - lsf1 and lsf2 Q14 */ - WebRtc_Word16 length /* (i) length of coefficient vectors */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c b/src/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c deleted file mode 100644 index 84278a4..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Lsp.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * conversion from lsf to lsp coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsf2Lsp( - WebRtc_Word16 *lsf, /* (i) lsf in Q13 values between 0 and pi */ - WebRtc_Word16 *lsp, /* (o) lsp in Q15 values between -1 and 1 */ - WebRtc_Word16 m /* (i) number of coefficients */ - ) { - WebRtc_Word16 i, k; - WebRtc_Word16 diff; /* difference, which is used for the - linear approximation (Q8) */ - WebRtc_Word16 freq; /* normalized frequency in Q15 (0..1) */ - WebRtc_Word32 tmpW32; - - for(i=0; i<m; i++) - { - freq = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(lsf[i], 20861, 15); - /* 20861: 1.0/(2.0*PI) in Q17 */ - /* - Upper 8 bits give the index k and - Lower 8 bits give the difference, which needs - to be approximated linearly - */ - k = WEBRTC_SPL_RSHIFT_W16(freq, 8); - diff = (freq&0x00ff); - - /* Guard against getting outside table */ - - if (k>63) { - k = 63; - } - - /* Calculate linear approximation */ - tmpW32 = WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kCosDerivative[k], diff); - lsp[i] = WebRtcIlbcfix_kCos[k]+(WebRtc_Word16)(WEBRTC_SPL_RSHIFT_W32(tmpW32, 12)); - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h b/src/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h deleted file mode 100644 index db6549b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_to_lsp.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Lsp.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_LSP_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_LSP_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * conversion from lsf to lsp coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsf2Lsp( - WebRtc_Word16 *lsf, /* (i) lsf in Q13 values between 0 and pi */ - WebRtc_Word16 *lsp, /* (o) lsp in Q15 values between -1 and 1 */ - WebRtc_Word16 m /* (i) number of coefficients */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_to_poly.c b/src/modules/audio_coding/codecs/ilbc/lsf_to_poly.c deleted file mode 100644 index f1c4a9e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_to_poly.c +++ /dev/null
@@ -1,86 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Poly.c - -******************************************************************/ - -#include "defines.h" -#include "lsf_to_lsp.h" -#include "get_lsp_poly.h" -#include "constants.h" - -void WebRtcIlbcfix_Lsf2Poly( - WebRtc_Word16 *a, /* (o) predictor coefficients (order = 10) in Q12 */ - WebRtc_Word16 *lsf /* (i) line spectral frequencies in Q13 */ - ) { - WebRtc_Word32 f[2][6]; /* f[0][] and f[1][] corresponds to - F1(z) and F2(z) respectivly */ - WebRtc_Word32 *f1ptr, *f2ptr; - WebRtc_Word16 *a1ptr, *a2ptr; - WebRtc_Word32 tmpW32; - WebRtc_Word16 lsp[10]; - int i; - - /* Convert lsf to lsp */ - WebRtcIlbcfix_Lsf2Lsp(lsf, lsp, LPC_FILTERORDER); - - /* Get F1(z) and F2(z) from the lsp */ - f1ptr=f[0]; - f2ptr=f[1]; - WebRtcIlbcfix_GetLspPoly(&lsp[0],f1ptr); - WebRtcIlbcfix_GetLspPoly(&lsp[1],f2ptr); - - /* for i = 5 down to 1 - Compute f1[i] += f1[i-1]; - and f2[i] += f2[i-1]; - */ - f1ptr=&f[0][5]; - f2ptr=&f[1][5]; - for (i=5; i>0; i--) - { - (*f1ptr) += (*(f1ptr-1)); - (*f2ptr) -= (*(f2ptr-1)); - f1ptr--; - f2ptr--; - } - - /* Get the A(z) coefficients - a[0] = 1.0 - for i = 1 to 5 - a[i] = (f1[i] + f2[i] + round)>>13; - for i = 1 to 5 - a[11-i] = (f1[i] - f2[i] + round)>>13; - */ - a[0]=4096; - a1ptr=&a[1]; - a2ptr=&a[10]; - f1ptr=&f[0][1]; - f2ptr=&f[1][1]; - for (i=5; i>0; i--) - { - tmpW32 = (*f1ptr) + (*f2ptr); - (*a1ptr) = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32+4096),13); - - tmpW32 = (*f1ptr) - (*f2ptr); - (*a2ptr) = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32+4096),13); - - a1ptr++; - a2ptr--; - f1ptr++; - f2ptr++; - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lsf_to_poly.h b/src/modules/audio_coding/codecs/ilbc/lsf_to_poly.h deleted file mode 100644 index a00693b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsf_to_poly.h +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsf2Poly.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_POLY_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSF_TO_POLY_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Convert from LSF coefficients to A coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsf2Poly( - WebRtc_Word16 *a, /* (o) predictor coefficients (order = 10) in Q12 */ - WebRtc_Word16 *lsf /* (i) line spectral frequencies in Q13 */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/lsp_to_lsf.c b/src/modules/audio_coding/codecs/ilbc/lsp_to_lsf.c deleted file mode 100644 index 134afbb..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsp_to_lsf.c +++ /dev/null
@@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsp2Lsf.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * conversion from LSP coefficients to LSF coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsp2Lsf( - WebRtc_Word16 *lsp, /* (i) lsp vector -1...+1 in Q15 */ - WebRtc_Word16 *lsf, /* (o) Lsf vector 0...Pi in Q13 - (ordered, so that lsf[i]<lsf[i+1]) */ - WebRtc_Word16 m /* (i) Number of coefficients */ - ) -{ - WebRtc_Word16 i, k; - WebRtc_Word16 diff; /* diff between table value and desired value (Q15) */ - WebRtc_Word16 freq; /* lsf/(2*pi) (Q16) */ - WebRtc_Word16 *lspPtr, *lsfPtr, *cosTblPtr; - WebRtc_Word16 tmp; - - /* set the index to maximum index value in WebRtcIlbcfix_kCos */ - k = 63; - - /* - Start with the highest LSP and then work the way down - For each LSP the lsf is calculated by first order approximation - of the acos(x) function - */ - lspPtr = &lsp[9]; - lsfPtr = &lsf[9]; - cosTblPtr=(WebRtc_Word16*)&WebRtcIlbcfix_kCos[k]; - for(i=m-1; i>=0; i--) - { - /* - locate value in the table, which is just above lsp[i], - basically an approximation to acos(x) - */ - while( (((WebRtc_Word32)(*cosTblPtr)-(*lspPtr)) < 0)&&(k>0) ) - { - k-=1; - cosTblPtr--; - } - - /* Calculate diff, which is used in the linear approximation of acos(x) */ - diff = (*lspPtr)-(*cosTblPtr); - - /* - The linear approximation of acos(lsp[i]) : - acos(lsp[i])= k*512 + (WebRtcIlbcfix_kAcosDerivative[ind]*offset >> 11) - */ - - /* tmp (linear offset) in Q16 */ - tmp = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIlbcfix_kAcosDerivative[k],diff, 11); - - /* freq in Q16 */ - freq = (WebRtc_Word16)WEBRTC_SPL_LSHIFT_W16(k,9)+tmp; - - /* lsf = freq*2*pi */ - (*lsfPtr) = (WebRtc_Word16)(((WebRtc_Word32)freq*25736)>>15); - - lsfPtr--; - lspPtr--; - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h b/src/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h deleted file mode 100644 index 97ba7e4..0000000 --- a/src/modules/audio_coding/codecs/ilbc/lsp_to_lsf.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Lsp2Lsf.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSP_TO_LSF_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_LSP_TO_LSF_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * conversion from LSP coefficients to LSF coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Lsp2Lsf( - WebRtc_Word16 *lsp, /* (i) lsp vector -1...+1 in Q15 */ - WebRtc_Word16 *lsf, /* (o) Lsf vector 0...Pi in Q13 - (ordered, so that lsf[i]<lsf[i+1]) */ - WebRtc_Word16 m /* (i) Number of coefficients */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/my_corr.c b/src/modules/audio_coding/codecs/ilbc/my_corr.c deleted file mode 100644 index 2162205..0000000 --- a/src/modules/audio_coding/codecs/ilbc/my_corr.c +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_MyCorr.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * compute cross correlation between sequences - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_MyCorr( - WebRtc_Word32 *corr, /* (o) correlation of seq1 and seq2 */ - WebRtc_Word16 *seq1, /* (i) first sequence */ - WebRtc_Word16 dim1, /* (i) dimension first seq1 */ - const WebRtc_Word16 *seq2, /* (i) second sequence */ - WebRtc_Word16 dim2 /* (i) dimension seq2 */ - ){ - WebRtc_Word16 max, scale, loops; - - /* Calculate correlation between the two sequences. Scale the - result of the multiplcication to maximum 26 bits in order - to avoid overflow */ - max=WebRtcSpl_MaxAbsValueW16(seq1, dim1); - scale=WebRtcSpl_GetSizeInBits(max); - - scale = (WebRtc_Word16)(WEBRTC_SPL_MUL_16_16(2,scale)-26); - if (scale<0) { - scale=0; - } - - loops=dim1-dim2+1; - - /* Calculate the cross correlations */ - WebRtcSpl_CrossCorrelation(corr, (WebRtc_Word16*)seq2, seq1, dim2, loops, scale, 1); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/my_corr.h b/src/modules/audio_coding/codecs/ilbc/my_corr.h deleted file mode 100644 index f588c53..0000000 --- a/src/modules/audio_coding/codecs/ilbc/my_corr.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_MyCorr.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_MY_CORR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_MY_CORR_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * compute cross correlation between sequences - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_MyCorr( - WebRtc_Word32 *corr, /* (o) correlation of seq1 and seq2 */ - WebRtc_Word16 *seq1, /* (i) first sequence */ - WebRtc_Word16 dim1, /* (i) dimension first seq1 */ - const WebRtc_Word16 *seq2, /* (i) second sequence */ - WebRtc_Word16 dim2 /* (i) dimension seq2 */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/nearest_neighbor.c b/src/modules/audio_coding/codecs/ilbc/nearest_neighbor.c deleted file mode 100644 index ea9e1eb..0000000 --- a/src/modules/audio_coding/codecs/ilbc/nearest_neighbor.c +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_NearestNeighbor.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Find index in array such that the array element with said - * index is the element of said array closest to "value" - * according to the squared-error criterion - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_NearestNeighbor( - WebRtc_Word16 *index, /* (o) index of array element closest to value */ - WebRtc_Word16 *array, /* (i) data array (Q2) */ - WebRtc_Word16 value, /* (i) value (Q2) */ - WebRtc_Word16 arlength /* (i) dimension of data array (==8) */ - ){ - int i; - WebRtc_Word16 diff; - /* Stack based */ - WebRtc_Word32 crit[8]; - - /* Calculate square distance */ - for(i=0;i<arlength;i++){ - diff=array[i]-value; - crit[i]=WEBRTC_SPL_MUL_16_16(diff, diff); - } - - /* Find the minimum square distance */ - *index=WebRtcSpl_MinIndexW32(crit, (WebRtc_Word16)arlength); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/nearest_neighbor.h b/src/modules/audio_coding/codecs/ilbc/nearest_neighbor.h deleted file mode 100644 index 705e17a..0000000 --- a/src/modules/audio_coding/codecs/ilbc/nearest_neighbor.h +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_NearestNeighbor.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_NEAREST_NEIGHBOR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_NEAREST_NEIGHBOR_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Find index in array such that the array element with said - * index is the element of said array closest to "value" - * according to the squared-error criterion - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_NearestNeighbor( - WebRtc_Word16 *index, /* (o) index of array element closest to value */ - WebRtc_Word16 *array, /* (i) data array (Q2) */ - WebRtc_Word16 value, /* (i) value (Q2) */ - WebRtc_Word16 arlength /* (i) dimension of data array (==8) */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/pack_bits.c b/src/modules/audio_coding/codecs/ilbc/pack_bits.c deleted file mode 100644 index 3990fbe..0000000 --- a/src/modules/audio_coding/codecs/ilbc/pack_bits.c +++ /dev/null
@@ -1,251 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_PackBits.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_PackBits( - WebRtc_UWord16 *bitstream, /* (o) The packetized bitstream */ - iLBC_bits *enc_bits, /* (i) Encoded bits */ - WebRtc_Word16 mode /* (i) Codec mode (20 or 30) */ - ){ - WebRtc_UWord16 *bitstreamPtr; - int i, k; - WebRtc_Word16 *tmpPtr; - - bitstreamPtr=bitstream; - - /* Class 1 bits of ULP */ - /* First WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)enc_bits->lsf[0])<<10; /* Bit 0..5 */ - (*bitstreamPtr) |= (enc_bits->lsf[1])<<3; /* Bit 6..12 */ - (*bitstreamPtr) |= (enc_bits->lsf[2]&0x70)>>4; /* Bit 13..15 */ - bitstreamPtr++; - /* Second WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)enc_bits->lsf[2]&0xF)<<12; /* Bit 0..3 */ - - if (mode==20) { - (*bitstreamPtr) |= (enc_bits->startIdx)<<10; /* Bit 4..5 */ - (*bitstreamPtr) |= (enc_bits->state_first)<<9; /* Bit 6 */ - (*bitstreamPtr) |= (enc_bits->idxForMax)<<3; /* Bit 7..12 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[0])&0x70)>>4; /* Bit 13..15 */ - bitstreamPtr++; - /* Third WebRtc_Word16 */ - (*bitstreamPtr) = ((enc_bits->cb_index[0])&0xE)<<12; /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[0])&0x18)<<8; /* Bit 3..4 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[1])&0x8)<<7; /* Bit 5 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[3])&0xFE)<<2; /* Bit 6..12 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[3])&0x10)>>2; /* Bit 13 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[4])&0x8)>>2; /* Bit 14 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[6])&0x10)>>4; /* Bit 15 */ - } else { /* mode==30 */ - (*bitstreamPtr) |= (enc_bits->lsf[3])<<6; /* Bit 4..9 */ - (*bitstreamPtr) |= (enc_bits->lsf[4]&0x7E)>>1; /* Bit 10..15 */ - bitstreamPtr++; - /* Third WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)enc_bits->lsf[4]&0x1)<<15; /* Bit 0 */ - (*bitstreamPtr) |= (enc_bits->lsf[5])<<8; /* Bit 1..7 */ - (*bitstreamPtr) |= (enc_bits->startIdx)<<5; /* Bit 8..10 */ - (*bitstreamPtr) |= (enc_bits->state_first)<<4; /* Bit 11 */ - (*bitstreamPtr) |= ((enc_bits->idxForMax)&0x3C)>>2; /* Bit 12..15 */ - bitstreamPtr++; - /* 4:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)enc_bits->idxForMax&0x3)<<14; /* Bit 0..1 */ - (*bitstreamPtr) |= (enc_bits->cb_index[0]&0x78)<<7; /* Bit 2..5 */ - (*bitstreamPtr) |= (enc_bits->gain_index[0]&0x10)<<5; /* Bit 6 */ - (*bitstreamPtr) |= (enc_bits->gain_index[1]&0x8)<<5; /* Bit 7 */ - (*bitstreamPtr) |= (enc_bits->cb_index[3]&0xFC); /* Bit 8..13 */ - (*bitstreamPtr) |= (enc_bits->gain_index[3]&0x10)>>3; /* Bit 14 */ - (*bitstreamPtr) |= (enc_bits->gain_index[4]&0x8)>>3; /* Bit 15 */ - } - /* Class 2 bits of ULP */ - /* 4:th to 6:th WebRtc_Word16 for 20 ms case - 5:th to 7:th WebRtc_Word16 for 30 ms case */ - bitstreamPtr++; - tmpPtr=enc_bits->idxVec; - for (k=0; k<3; k++) { - (*bitstreamPtr) = 0; - for (i=15; i>=0; i--) { - (*bitstreamPtr) |= ((WebRtc_UWord16)((*tmpPtr)&0x4)>>2)<<i; - /* Bit 15-i */ - tmpPtr++; - } - bitstreamPtr++; - } - - if (mode==20) { - /* 7:th WebRtc_Word16 */ - (*bitstreamPtr) = 0; - for (i=15; i>6; i--) { - (*bitstreamPtr) |= ((WebRtc_UWord16)((*tmpPtr)&0x4)>>2)<<i; - /* Bit 15-i */ - tmpPtr++; - } - (*bitstreamPtr) |= (enc_bits->gain_index[1]&0x4)<<4; /* Bit 9 */ - (*bitstreamPtr) |= (enc_bits->gain_index[3]&0xC)<<2; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[4]&0x4)<<1; /* Bit 12 */ - (*bitstreamPtr) |= (enc_bits->gain_index[6]&0x8)>>1; /* Bit 13 */ - (*bitstreamPtr) |= (enc_bits->gain_index[7]&0xC)>>2; /* Bit 14..15 */ - - } else { /* mode==30 */ - /* 8:th WebRtc_Word16 */ - (*bitstreamPtr) = 0; - for (i=15; i>5; i--) { - (*bitstreamPtr) |= ((WebRtc_UWord16)((*tmpPtr)&0x4)>>2)<<i; - /* Bit 15-i */ - tmpPtr++; - } - (*bitstreamPtr) |= (enc_bits->cb_index[0]&0x6)<<3; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[0]&0x8); /* Bit 12 */ - (*bitstreamPtr) |= (enc_bits->gain_index[1]&0x4); /* Bit 13 */ - (*bitstreamPtr) |= (enc_bits->cb_index[3]&0x2); /* Bit 14 */ - (*bitstreamPtr) |= (enc_bits->cb_index[6]&0x80)>>7; /* Bit 15 */ - bitstreamPtr++; - /* 9:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)enc_bits->cb_index[6]&0x7E)<<9;/* Bit 0..5 */ - (*bitstreamPtr) |= (enc_bits->cb_index[9]&0xFE)<<2; /* Bit 6..12 */ - (*bitstreamPtr) |= (enc_bits->cb_index[12]&0xE0)>>5; /* Bit 13..15 */ - bitstreamPtr++; - /* 10:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)enc_bits->cb_index[12]&0x1E)<<11;/* Bit 0..3 */ - (*bitstreamPtr) |= (enc_bits->gain_index[3]&0xC)<<8; /* Bit 4..5 */ - (*bitstreamPtr) |= (enc_bits->gain_index[4]&0x6)<<7; /* Bit 6..7 */ - (*bitstreamPtr) |= (enc_bits->gain_index[6]&0x18)<<3; /* Bit 8..9 */ - (*bitstreamPtr) |= (enc_bits->gain_index[7]&0xC)<<2; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[9]&0x10)>>1; /* Bit 12 */ - (*bitstreamPtr) |= (enc_bits->gain_index[10]&0x8)>>1; /* Bit 13 */ - (*bitstreamPtr) |= (enc_bits->gain_index[12]&0x10)>>3; /* Bit 14 */ - (*bitstreamPtr) |= (enc_bits->gain_index[13]&0x8)>>3; /* Bit 15 */ - } - bitstreamPtr++; - /* Class 3 bits of ULP */ - /* 8:th to 14:th WebRtc_Word16 for 20 ms case - 11:th to 17:th WebRtc_Word16 for 30 ms case */ - tmpPtr=enc_bits->idxVec; - for (k=0; k<7; k++) { - (*bitstreamPtr) = 0; - for (i=14; i>=0; i-=2) { - (*bitstreamPtr) |= ((WebRtc_UWord16)((*tmpPtr)&0x3))<<i; /* Bit 15-i..14-i*/ - tmpPtr++; - } - bitstreamPtr++; - } - - if (mode==20) { - /* 15:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)((enc_bits->idxVec[56])&0x3))<<14;/* Bit 0..1 */ - (*bitstreamPtr) |= (((enc_bits->cb_index[0])&1))<<13; /* Bit 2 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[1]))<<6; /* Bit 3..9 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[2])&0x7E)>>1; /* Bit 10..15 */ - bitstreamPtr++; - /* 16:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)((enc_bits->cb_index[2])&0x1))<<15; - /* Bit 0 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[0])&0x7)<<12; /* Bit 1..3 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[1])&0x3)<<10; /* Bit 4..5 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[2]))<<7; /* Bit 6..8 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[3])&0x1)<<6; /* Bit 9 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[4])&0x7E)>>1; /* Bit 10..15 */ - bitstreamPtr++; - /* 17:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)((enc_bits->cb_index[4])&0x1))<<15; - /* Bit 0 */ - (*bitstreamPtr) |= (enc_bits->cb_index[5])<<8; /* Bit 1..7 */ - (*bitstreamPtr) |= (enc_bits->cb_index[6]); /* Bit 8..15 */ - bitstreamPtr++; - /* 18:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->cb_index[7]))<<8; /* Bit 0..7 */ - (*bitstreamPtr) |= (enc_bits->cb_index[8]); /* Bit 8..15 */ - bitstreamPtr++; - /* 19:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)((enc_bits->gain_index[3])&0x3))<<14; - /* Bit 0..1 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[4])&0x3)<<12; /* Bit 2..3 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[5]))<<9; /* Bit 4..6 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[6])&0x7)<<6; /* Bit 7..9 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[7])&0x3)<<4; /* Bit 10..11 */ - (*bitstreamPtr) |= (enc_bits->gain_index[8])<<1; /* Bit 12..14 */ - } else { /* mode==30 */ - /* 18:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)((enc_bits->idxVec[56])&0x3))<<14;/* Bit 0..1 */ - (*bitstreamPtr) |= (((enc_bits->idxVec[57])&0x3))<<12; /* Bit 2..3 */ - (*bitstreamPtr) |= (((enc_bits->cb_index[0])&1))<<11; /* Bit 4 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[1]))<<4; /* Bit 5..11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[2])&0x78)>>3; /* Bit 12..15 */ - bitstreamPtr++; - /* 19:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->cb_index[2])&0x7)<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[0])&0x7)<<10; /* Bit 3..5 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[1])&0x3)<<8; /* Bit 6..7 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[2])&0x7)<<5; /* Bit 8..10 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[3])&0x1)<<4; /* Bit 11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[4])&0x78)>>3; /* Bit 12..15 */ - bitstreamPtr++; - /* 20:th WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->cb_index[4])&0x7)<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[5]))<<6; /* Bit 3..9 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[6])&0x1)<<5; /* Bit 10 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[7])&0xF8)>>3; /* Bit 11..15 */ - bitstreamPtr++; - /* 21:st WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->cb_index[7])&0x7)<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[8]))<<5; /* Bit 3..10 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[9])&0x1)<<4; /* Bit 11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[10])&0xF0)>>4; /* Bit 12..15 */ - bitstreamPtr++; - /* 22:nd WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->cb_index[10])&0xF)<<12; - /* Bit 0..3 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[11]))<<4; /* Bit 4..11 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[12])&0x1)<<3; /* Bit 12 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[13])&0xE0)>>5; /* Bit 13..15 */ - bitstreamPtr++; - /* 23:rd WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->cb_index[13])&0x1F)<<11; - /* Bit 0..4 */ - (*bitstreamPtr) |= ((enc_bits->cb_index[14]))<<3; /* Bit 5..12 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[3])&0x3)<<1; /* Bit 13..14 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[4])&0x1); /* Bit 15 */ - bitstreamPtr++; - /* 24:rd WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->gain_index[5]))<<13; - /* Bit 0..2 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[6])&0x7)<<10; /* Bit 3..5 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[7])&0x3)<<8; /* Bit 6..7 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[8]))<<5; /* Bit 8..10 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[9])&0xF)<<1; /* Bit 11..14 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[10])&0x4)>>2; /* Bit 15 */ - bitstreamPtr++; - /* 25:rd WebRtc_Word16 */ - (*bitstreamPtr) = ((WebRtc_UWord16)(enc_bits->gain_index[10])&0x3)<<14; - /* Bit 0..1 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[11]))<<11; /* Bit 2..4 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[12])&0xF)<<7; /* Bit 5..8 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[13])&0x7)<<4; /* Bit 9..11 */ - (*bitstreamPtr) |= ((enc_bits->gain_index[14]))<<1; /* Bit 12..14 */ - } - /* Last bit is automatically zero */ - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/pack_bits.h b/src/modules/audio_coding/codecs/ilbc/pack_bits.h deleted file mode 100644 index ed3f224..0000000 --- a/src/modules/audio_coding/codecs/ilbc/pack_bits.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_PackBits.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_PACK_BITS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_PACK_BITS_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_PackBits( - WebRtc_UWord16 *bitstream, /* (o) The packetized bitstream */ - iLBC_bits *enc_bits, /* (i) Encoded bits */ - WebRtc_Word16 mode /* (i) Codec mode (20 or 30) */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/poly_to_lsf.c b/src/modules/audio_coding/codecs/ilbc/poly_to_lsf.c deleted file mode 100644 index fe91851..0000000 --- a/src/modules/audio_coding/codecs/ilbc/poly_to_lsf.c +++ /dev/null
@@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsf.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "poly_to_lsp.h" -#include "lsp_to_lsf.h" - -void WebRtcIlbcfix_Poly2Lsf( - WebRtc_Word16 *lsf, /* (o) lsf coefficients (Q13) */ - WebRtc_Word16 *a /* (i) A coefficients (Q12) */ - ) { - WebRtc_Word16 lsp[10]; - WebRtcIlbcfix_Poly2Lsp(a, lsp, (WebRtc_Word16*)WebRtcIlbcfix_kLspMean); - WebRtcIlbcfix_Lsp2Lsf(lsp, lsf, 10); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/poly_to_lsf.h b/src/modules/audio_coding/codecs/ilbc/poly_to_lsf.h deleted file mode 100644 index 0ea595e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/poly_to_lsf.h +++ /dev/null
@@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsf.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSF_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSF_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * conversion from lpc coefficients to lsf coefficients - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Poly2Lsf( - WebRtc_Word16 *lsf, /* (o) lsf coefficients (Q13) */ - WebRtc_Word16 *a /* (i) A coefficients (Q12) */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/poly_to_lsp.c b/src/modules/audio_coding/codecs/ilbc/poly_to_lsp.c deleted file mode 100644 index 29b4213..0000000 --- a/src/modules/audio_coding/codecs/ilbc/poly_to_lsp.c +++ /dev/null
@@ -1,156 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsp.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "chebyshev.h" - -/*----------------------------------------------------------------* - * conversion from lpc coefficients to lsp coefficients - * function is only for 10:th order LPC - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Poly2Lsp( - WebRtc_Word16 *a, /* (o) A coefficients in Q12 */ - WebRtc_Word16 *lsp, /* (i) LSP coefficients in Q15 */ - WebRtc_Word16 *old_lsp /* (i) old LSP coefficients that are used if the new - coefficients turn out to be unstable */ - ) { - WebRtc_Word16 f[2][6]; /* f[0][] represents f1 and f[1][] represents f2 */ - WebRtc_Word16 *a_i_ptr, *a_10mi_ptr; - WebRtc_Word16 *f1ptr, *f2ptr; - WebRtc_Word32 tmpW32; - WebRtc_Word16 x, y, xlow, ylow, xmid, ymid, xhigh, yhigh, xint; - WebRtc_Word16 shifts, sign; - int i, j; - int foundFreqs; - int fi_select; - - /* - Calculate the two polynomials f1(z) and f2(z) - (the sum and the diff polynomial) - f1[0] = f2[0] = 1.0; - f1[i+1] = a[i+1] + a[10-i] - f1[i]; - f2[i+1] = a[i+1] - a[10-i] - f1[i]; - */ - - a_i_ptr = a + 1; - a_10mi_ptr = a + 10; - f1ptr = f[0]; - f2ptr = f[1]; - (*f1ptr) = 1024; /* 1.0 in Q10 */ - (*f2ptr) = 1024; /* 1.0 in Q10 */ - for (i = 0; i < 5; i++) { - (*(f1ptr+1)) = (WebRtc_Word16)(WEBRTC_SPL_RSHIFT_W32(((WebRtc_Word32)(*a_i_ptr)+(*a_10mi_ptr)), 2) - (*f1ptr)); - (*(f2ptr+1)) = (WebRtc_Word16)(WEBRTC_SPL_RSHIFT_W32(((WebRtc_Word32)(*a_i_ptr)-(*a_10mi_ptr)), 2) + (*f2ptr)); - a_i_ptr++; - a_10mi_ptr--; - f1ptr++; - f2ptr++; - } - - /* - find the LSPs using the Chebychev pol. evaluation - */ - - fi_select = 0; /* selector between f1 and f2, start with f1 */ - - foundFreqs = 0; - - xlow = WebRtcIlbcfix_kCosGrid[0]; - ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); - - /* - Iterate until all the 10 LSP's have been found or - all the grid points have been tried. If the 10 LSP's can - not be found, set the LSP vector to previous LSP - */ - - for (j = 1; j < COS_GRID_POINTS && foundFreqs < 10; j++) { - xhigh = xlow; - yhigh = ylow; - xlow = WebRtcIlbcfix_kCosGrid[j]; - ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); - - if (WEBRTC_SPL_MUL_16_16(ylow, yhigh) <= 0) { - /* Run 4 times to reduce the interval */ - for (i = 0; i < 4; i++) { - /* xmid =(xlow + xhigh)/2 */ - xmid = WEBRTC_SPL_RSHIFT_W16(xlow, 1) + WEBRTC_SPL_RSHIFT_W16(xhigh, 1); - ymid = WebRtcIlbcfix_Chebyshev(xmid, f[fi_select]); - - if (WEBRTC_SPL_MUL_16_16(ylow, ymid) <= 0) { - yhigh = ymid; - xhigh = xmid; - } else { - ylow = ymid; - xlow = xmid; - } - } - - /* - Calculater xint by linear interpolation: - xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow); - */ - - x = xhigh - xlow; - y = yhigh - ylow; - - if (y == 0) { - xint = xlow; - } else { - sign = y; - y = WEBRTC_SPL_ABS_W16(y); - shifts = (WebRtc_Word16)WebRtcSpl_NormW32(y)-16; - y = WEBRTC_SPL_LSHIFT_W16(y, shifts); - y = (WebRtc_Word16)WebRtcSpl_DivW32W16(536838144, y); /* 1/(yhigh-ylow) */ - - tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(x, y, (19-shifts)); - - /* y=(xhigh-xlow)/(yhigh-ylow) */ - y = (WebRtc_Word16)(tmpW32&0xFFFF); - - if (sign < 0) { - y = -y; - } - /* tmpW32 = ylow*(xhigh-xlow)/(yhigh-ylow) */ - tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(ylow, y, 10); - xint = xlow-(WebRtc_Word16)(tmpW32&0xFFFF); - } - - /* Store the calculated lsp */ - lsp[foundFreqs] = (WebRtc_Word16)xint; - foundFreqs++; - - /* if needed, set xlow and ylow for next recursion */ - if (foundFreqs<10) { - xlow = xint; - /* Swap between f1 and f2 (f[0][] and f[1][]) */ - fi_select = ((fi_select+1)&0x1); - - ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); - } - } - } - - /* Check if M roots found, if not then use the old LSP */ - if (foundFreqs < 10) { - WEBRTC_SPL_MEMCPY_W16(lsp, old_lsp, 10); - } - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/poly_to_lsp.h b/src/modules/audio_coding/codecs/ilbc/poly_to_lsp.h deleted file mode 100644 index 7eebb25..0000000 --- a/src/modules/audio_coding/codecs/ilbc/poly_to_lsp.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Poly2Lsp.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSP_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_POLY_TO_LSP_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * conversion from lpc coefficients to lsp coefficients - * function is only for 10:th order LPC - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Poly2Lsp( - WebRtc_Word16 *a, /* (o) A coefficients in Q12 */ - WebRtc_Word16 *lsp, /* (i) LSP coefficients in Q15 */ - WebRtc_Word16 *old_lsp /* (i) old LSP coefficients that are used if the new - coefficients turn out to be unstable */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/refiner.c b/src/modules/audio_coding/codecs/ilbc/refiner.c deleted file mode 100644 index 9210092..0000000 --- a/src/modules/audio_coding/codecs/ilbc/refiner.c +++ /dev/null
@@ -1,150 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Refiner.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "enh_upsample.h" -#include "my_corr.h" - -/*----------------------------------------------------------------* - * find segment starting near idata+estSegPos that has highest - * correlation with idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a - * resolution of ENH_UPSO times the original of the original - * sampling rate - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Refiner( - WebRtc_Word16 *updStartPos, /* (o) updated start point (Q-2) */ - WebRtc_Word16 *idata, /* (i) original data buffer */ - WebRtc_Word16 idatal, /* (i) dimension of idata */ - WebRtc_Word16 centerStartPos, /* (i) beginning center segment */ - WebRtc_Word16 estSegPos, /* (i) estimated beginning other segment (Q-2) */ - WebRtc_Word16 *surround, /* (i/o) The contribution from this sequence - summed with earlier contributions */ - WebRtc_Word16 gain /* (i) Gain to use for this sequence */ - ){ - WebRtc_Word16 estSegPosRounded,searchSegStartPos,searchSegEndPos,corrdim; - WebRtc_Word16 tloc,tloc2,i,st,en,fraction; - - WebRtc_Word32 maxtemp, scalefact; - WebRtc_Word16 *filtStatePtr, *polyPtr; - /* Stack based */ - WebRtc_Word16 filt[7]; - WebRtc_Word32 corrVecUps[ENH_CORRDIM*ENH_UPS0]; - WebRtc_Word32 corrVecTemp[ENH_CORRDIM]; - WebRtc_Word16 vect[ENH_VECTL]; - WebRtc_Word16 corrVec[ENH_CORRDIM]; - - /* defining array bounds */ - - estSegPosRounded=WEBRTC_SPL_RSHIFT_W16((estSegPos - 2),2); - - searchSegStartPos=estSegPosRounded-ENH_SLOP; - - if (searchSegStartPos<0) { - searchSegStartPos=0; - } - searchSegEndPos=estSegPosRounded+ENH_SLOP; - - if(searchSegEndPos+ENH_BLOCKL >= idatal) { - searchSegEndPos=idatal-ENH_BLOCKL-1; - } - corrdim=searchSegEndPos-searchSegStartPos+1; - - /* compute upsampled correlation and find - location of max */ - - WebRtcIlbcfix_MyCorr(corrVecTemp,idata+searchSegStartPos, - (WebRtc_Word16)(corrdim+ENH_BLOCKL-1),idata+centerStartPos,ENH_BLOCKL); - - /* Calculate the rescaling factor for the correlation in order to - put the correlation in a WebRtc_Word16 vector instead */ - maxtemp=WebRtcSpl_MaxAbsValueW32(corrVecTemp, (WebRtc_Word16)corrdim); - - scalefact=WebRtcSpl_GetSizeInBits(maxtemp)-15; - - if (scalefact>0) { - for (i=0;i<corrdim;i++) { - corrVec[i]=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(corrVecTemp[i], scalefact); - } - } else { - for (i=0;i<corrdim;i++) { - corrVec[i]=(WebRtc_Word16)corrVecTemp[i]; - } - } - /* In order to guarantee that all values are initialized */ - for (i=corrdim;i<ENH_CORRDIM;i++) { - corrVec[i]=0; - } - - /* Upsample the correlation */ - WebRtcIlbcfix_EnhUpsample(corrVecUps,corrVec); - - /* Find maximum */ - tloc=WebRtcSpl_MaxIndexW32(corrVecUps, (WebRtc_Word16) (ENH_UPS0*corrdim)); - - /* make vector can be upsampled without ever running outside - bounds */ - *updStartPos = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(searchSegStartPos,4) + tloc + 4; - - tloc2 = WEBRTC_SPL_RSHIFT_W16((tloc+3), 2); - - st=searchSegStartPos+tloc2-ENH_FL0; - - /* initialize the vector to be filtered, stuff with zeros - when data is outside idata buffer */ - if(st<0){ - WebRtcSpl_MemSetW16(vect, 0, (WebRtc_Word16)(-st)); - WEBRTC_SPL_MEMCPY_W16(&vect[-st], idata, (ENH_VECTL+st)); - } - else{ - en=st+ENH_VECTL; - - if(en>idatal){ - WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], - (ENH_VECTL-(en-idatal))); - WebRtcSpl_MemSetW16(&vect[ENH_VECTL-(en-idatal)], 0, - (WebRtc_Word16)(en-idatal)); - } - else { - WEBRTC_SPL_MEMCPY_W16(vect, &idata[st], ENH_VECTL); - } - } - /* Calculate which of the 4 fractions to use */ - fraction=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(tloc2,ENH_UPS0)-tloc; - - /* compute the segment (this is actually a convolution) */ - - filtStatePtr = filt + 6; - polyPtr = (WebRtc_Word16*)WebRtcIlbcfix_kEnhPolyPhaser[fraction]; - for (i=0;i<7;i++) { - *filtStatePtr-- = *polyPtr++; - } - - WebRtcSpl_FilterMAFastQ12( - &vect[6], vect, filt, - ENH_FLO_MULT2_PLUS1, ENH_BLOCKL); - - /* Add the contribution from this vector (scaled with gain) to the total surround vector */ - WebRtcSpl_AddAffineVectorToVector( - surround, vect, gain, - (WebRtc_Word32)32768, 16, ENH_BLOCKL); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/refiner.h b/src/modules/audio_coding/codecs/ilbc/refiner.h deleted file mode 100644 index 559555c..0000000 --- a/src/modules/audio_coding/codecs/ilbc/refiner.h +++ /dev/null
@@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Refiner.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_REFINER_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_REFINER_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * find segment starting near idata+estSegPos that has highest - * correlation with idata+centerStartPos through - * idata+centerStartPos+ENH_BLOCKL-1 segment is found at a - * resolution of ENH_UPSO times the original of the original - * sampling rate - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Refiner( - WebRtc_Word16 *updStartPos, /* (o) updated start point (Q-2) */ - WebRtc_Word16 *idata, /* (i) original data buffer */ - WebRtc_Word16 idatal, /* (i) dimension of idata */ - WebRtc_Word16 centerStartPos, /* (i) beginning center segment */ - WebRtc_Word16 estSegPos, /* (i) estimated beginning other segment (Q-2) */ - WebRtc_Word16 *surround, /* (i/o) The contribution from this sequence - summed with earlier contributions */ - WebRtc_Word16 gain /* (i) Gain to use for this sequence */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.c b/src/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.c deleted file mode 100644 index ee5e643..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.c +++ /dev/null
@@ -1,130 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleInterpolateLsf.c - -******************************************************************/ - -#include "defines.h" -#include "lsf_interpolate_to_poly_enc.h" -#include "bw_expand.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * lsf interpolator (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleInterpolateLsf( - WebRtc_Word16 *syntdenum, /* (o) the synthesis filter denominator - resulting from the quantized - interpolated lsf Q12 */ - WebRtc_Word16 *weightdenum, /* (o) the weighting filter denominator - resulting from the unquantized - interpolated lsf Q12 */ - WebRtc_Word16 *lsf, /* (i) the unquantized lsf coefficients Q13 */ - WebRtc_Word16 *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ - WebRtc_Word16 *lsfold, /* (i) the unquantized lsf coefficients of - the previous signal frame Q13 */ - WebRtc_Word16 *lsfdeqold, /* (i) the dequantized lsf coefficients of the - previous signal frame Q13 */ - WebRtc_Word16 length, /* (i) should equate FILTERORDER */ - iLBC_Enc_Inst_t *iLBCenc_inst - /* (i/o) the encoder state structure */ - ) { - int i, pos, lp_length; - - WebRtc_Word16 *lsf2, *lsfdeq2; - /* Stack based */ - WebRtc_Word16 lp[LPC_FILTERORDER + 1]; - - lsf2 = lsf + length; - lsfdeq2 = lsfdeq + length; - lp_length = length + 1; - - if (iLBCenc_inst->mode==30) { - /* subframe 1: Interpolation between old and first set of - lsf coefficients */ - - /* Calculate Analysis/Syntehsis filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight30ms[0], - length); - WEBRTC_SPL_MEMCPY_W16(syntdenum, lp, lp_length); - - /* Calculate Weighting filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, - WebRtcIlbcfix_kLsfWeight30ms[0], - length); - WebRtcIlbcfix_BwExpand(weightdenum, lp, - (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpWeightDenum, - (WebRtc_Word16)lp_length); - - /* subframe 2 to 6: Interpolation between first and second - set of lsf coefficients */ - - pos = lp_length; - for (i = 1; i < iLBCenc_inst->nsub; i++) { - - /* Calculate Analysis/Syntehsis filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeq, lsfdeq2, - WebRtcIlbcfix_kLsfWeight30ms[i], - length); - WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); - - /* Calculate Weighting filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsf, lsf2, - WebRtcIlbcfix_kLsfWeight30ms[i], - length); - WebRtcIlbcfix_BwExpand(weightdenum + pos, lp, - (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpWeightDenum, - (WebRtc_Word16)lp_length); - - pos += lp_length; - } - - /* update memory */ - - WEBRTC_SPL_MEMCPY_W16(lsfold, lsf2, length); - WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq2, length); - - } else { /* iLBCenc_inst->mode==20 */ - pos = 0; - for (i = 0; i < iLBCenc_inst->nsub; i++) { - - /* Calculate Analysis/Syntehsis filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfdeqold, lsfdeq, - WebRtcIlbcfix_kLsfWeight20ms[i], - length); - WEBRTC_SPL_MEMCPY_W16(syntdenum + pos, lp, lp_length); - - /* Calculate Weighting filter from quantized LSF */ - WebRtcIlbcfix_LsfInterpolate2PloyEnc(lp, lsfold, lsf, - WebRtcIlbcfix_kLsfWeight20ms[i], - length); - WebRtcIlbcfix_BwExpand(weightdenum+pos, lp, - (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpWeightDenum, - (WebRtc_Word16)lp_length); - - pos += lp_length; - } - - /* update memory */ - - WEBRTC_SPL_MEMCPY_W16(lsfold, lsf, length); - WEBRTC_SPL_MEMCPY_W16(lsfdeqold, lsfdeq, length); - - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h b/src/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h deleted file mode 100644 index 8cdd7da..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_interpolate_lsf.h +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleInterpolateLsf.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_INTERPOLATE_LSF_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_INTERPOLATE_LSF_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lsf interpolator (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleInterpolateLsf( - WebRtc_Word16 *syntdenum, /* (o) the synthesis filter denominator - resulting from the quantized - interpolated lsf Q12 */ - WebRtc_Word16 *weightdenum, /* (o) the weighting filter denominator - resulting from the unquantized - interpolated lsf Q12 */ - WebRtc_Word16 *lsf, /* (i) the unquantized lsf coefficients Q13 */ - WebRtc_Word16 *lsfdeq, /* (i) the dequantized lsf coefficients Q13 */ - WebRtc_Word16 *lsfold, /* (i) the unquantized lsf coefficients of - the previous signal frame Q13 */ - WebRtc_Word16 *lsfdeqold, /* (i) the dequantized lsf coefficients of the - previous signal frame Q13 */ - WebRtc_Word16 length, /* (i) should equate FILTERORDER */ - iLBC_Enc_Inst_t *iLBCenc_inst - /* (i/o) the encoder state structure */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.c b/src/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.c deleted file mode 100644 index 2d19edd..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.c +++ /dev/null
@@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLpcAnalysis.c - -******************************************************************/ - -#include "defines.h" -#include "window32_w32.h" -#include "bw_expand.h" -#include "poly_to_lsf.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * lpc analysis (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLpcAnalysis( - WebRtc_Word16 *lsf, /* (o) lsf coefficients */ - WebRtc_Word16 *data, /* (i) new block of speech */ - iLBC_Enc_Inst_t *iLBCenc_inst - /* (i/o) the encoder state structure */ - ) { - int k; - int scale; - WebRtc_Word16 is; - WebRtc_Word16 stability; - /* Stack based */ - WebRtc_Word16 A[LPC_FILTERORDER + 1]; - WebRtc_Word32 R[LPC_FILTERORDER + 1]; - WebRtc_Word16 windowedData[BLOCKL_MAX]; - WebRtc_Word16 rc[LPC_FILTERORDER]; - - is=LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl; - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lpc_buffer+is,data,iLBCenc_inst->blockl); - - /* No lookahead, last window is asymmetric */ - - for (k = 0; k < iLBCenc_inst->lpc_n; k++) { - - is = LPC_LOOKBACK; - - if (k < (iLBCenc_inst->lpc_n - 1)) { - - /* Hanning table WebRtcIlbcfix_kLpcWin[] is in Q15-domain so the output is right-shifted 15 */ - WebRtcSpl_ElementwiseVectorMult(windowedData, iLBCenc_inst->lpc_buffer, WebRtcIlbcfix_kLpcWin, BLOCKL_MAX, 15); - } else { - - /* Hanning table WebRtcIlbcfix_kLpcAsymWin[] is in Q15-domain so the output is right-shifted 15 */ - WebRtcSpl_ElementwiseVectorMult(windowedData, iLBCenc_inst->lpc_buffer+is, WebRtcIlbcfix_kLpcAsymWin, BLOCKL_MAX, 15); - } - - /* Compute autocorrelation */ - WebRtcSpl_AutoCorrelation(windowedData, BLOCKL_MAX, LPC_FILTERORDER, R, &scale); - - /* Window autocorrelation vector */ - WebRtcIlbcfix_Window32W32(R, R, WebRtcIlbcfix_kLpcLagWin, LPC_FILTERORDER + 1 ); - - /* Calculate the A coefficients from the Autocorrelation using Levinson Durbin algorithm */ - stability=WebRtcSpl_LevinsonDurbin(R, A, rc, LPC_FILTERORDER); - - /* - Set the filter to {1.0, 0.0, 0.0,...} if filter from Levinson Durbin algorithm is unstable - This should basically never happen... - */ - if (stability!=1) { - A[0]=4096; - WebRtcSpl_MemSetW16(&A[1], 0, LPC_FILTERORDER); - } - - /* Bandwidth expand the filter coefficients */ - WebRtcIlbcfix_BwExpand(A, A, (WebRtc_Word16*)WebRtcIlbcfix_kLpcChirpSyntDenum, LPC_FILTERORDER+1); - - /* Convert from A to LSF representation */ - WebRtcIlbcfix_Poly2Lsf(lsf + k*LPC_FILTERORDER, A); - } - - is=LPC_LOOKBACK+BLOCKL_MAX-iLBCenc_inst->blockl; - WEBRTC_SPL_MEMCPY_W16(iLBCenc_inst->lpc_buffer, - iLBCenc_inst->lpc_buffer+LPC_LOOKBACK+BLOCKL_MAX-is, is); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h b/src/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h deleted file mode 100644 index 83c1e5b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_lpc_analysis.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLpcAnalysis.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LPC_ANALYSIS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LPC_ANALYSIS_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lpc analysis (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLpcAnalysis( - WebRtc_Word16 *lsf, /* (o) lsf coefficients */ - WebRtc_Word16 *data, /* (i) new block of speech */ - iLBC_Enc_Inst_t *iLBCenc_inst - /* (i/o) the encoder state structure */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c b/src/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c deleted file mode 100644 index 7b5efa0..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c +++ /dev/null
@@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfDeQ.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * obtain dequantized lsf coefficients from quantization index - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfDeQ( - WebRtc_Word16 *lsfdeq, /* (o) dequantized lsf coefficients */ - WebRtc_Word16 *index, /* (i) quantization index */ - WebRtc_Word16 lpc_n /* (i) number of LPCs */ - ){ - int i, j, pos, cb_pos; - - /* decode first LSF */ - - pos = 0; - cb_pos = 0; - for (i = 0; i < LSF_NSPLIT; i++) { - for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { - lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + - WEBRTC_SPL_MUL_16_16(index[i], WebRtcIlbcfix_kLsfDimCb[i]) + j]; - } - pos += WebRtcIlbcfix_kLsfDimCb[i]; - cb_pos += WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kLsfSizeCb[i], WebRtcIlbcfix_kLsfDimCb[i]); - } - - if (lpc_n>1) { - /* decode last LSF */ - pos = 0; - cb_pos = 0; - for (i = 0; i < LSF_NSPLIT; i++) { - for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { - lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + - WEBRTC_SPL_MUL_16_16(index[LSF_NSPLIT + i], WebRtcIlbcfix_kLsfDimCb[i]) + j]; - } - pos += WebRtcIlbcfix_kLsfDimCb[i]; - cb_pos += WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kLsfSizeCb[i], WebRtcIlbcfix_kLsfDimCb[i]); - } - } - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h b/src/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h deleted file mode 100644 index efd3103..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfDeQ.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_DEQUANT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_DEQUANT_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * obtain dequantized lsf coefficients from quantization index - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfDeQ( - WebRtc_Word16 *lsfdeq, /* (o) dequantized lsf coefficients */ - WebRtc_Word16 *index, /* (i) quantization index */ - WebRtc_Word16 lpc_n /* (i) number of LPCs */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_lsf_quant.c b/src/modules/audio_coding/codecs/ilbc/simple_lsf_quant.c deleted file mode 100644 index aa27fb4..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_lsf_quant.c +++ /dev/null
@@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfQ.c - -******************************************************************/ - -#include "defines.h" -#include "split_vq.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * lsf quantizer (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfQ( - WebRtc_Word16 *lsfdeq, /* (o) dequantized lsf coefficients - (dimension FILTERORDER) Q13 */ - WebRtc_Word16 *index, /* (o) quantization index */ - WebRtc_Word16 *lsf, /* (i) the lsf coefficient vector to be - quantized (dimension FILTERORDER) Q13 */ - WebRtc_Word16 lpc_n /* (i) number of lsf sets to quantize */ - ){ - - /* Quantize first LSF with memoryless split VQ */ - WebRtcIlbcfix_SplitVq( lsfdeq, index, lsf, - (WebRtc_Word16*)WebRtcIlbcfix_kLsfCb, (WebRtc_Word16*)WebRtcIlbcfix_kLsfDimCb, (WebRtc_Word16*)WebRtcIlbcfix_kLsfSizeCb); - - if (lpc_n==2) { - /* Quantize second LSF with memoryless split VQ */ - WebRtcIlbcfix_SplitVq( lsfdeq + LPC_FILTERORDER, index + LSF_NSPLIT, - lsf + LPC_FILTERORDER, (WebRtc_Word16*)WebRtcIlbcfix_kLsfCb, - (WebRtc_Word16*)WebRtcIlbcfix_kLsfDimCb, (WebRtc_Word16*)WebRtcIlbcfix_kLsfSizeCb); - } - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h b/src/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h deleted file mode 100644 index fd17b2e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/simple_lsf_quant.h +++ /dev/null
@@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SimpleLsfQ.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_QUANT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SIMPLE_LSF_QUANT_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * lsf quantizer (subrutine to LPCencode) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SimpleLsfQ( - WebRtc_Word16 *lsfdeq, /* (o) dequantized lsf coefficients - (dimension FILTERORDER) Q13 */ - WebRtc_Word16 *index, /* (o) quantization index */ - WebRtc_Word16 *lsf, /* (i) the lsf coefficient vector to be - quantized (dimension FILTERORDER) Q13 */ - WebRtc_Word16 lpc_n /* (i) number of lsf sets to quantize */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/smooth.c b/src/modules/audio_coding/codecs/ilbc/smooth.c deleted file mode 100644 index b606077..0000000 --- a/src/modules/audio_coding/codecs/ilbc/smooth.c +++ /dev/null
@@ -1,211 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "smooth_out_data.h" - -/*----------------------------------------------------------------* - * find the smoothed output data - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Smooth( - WebRtc_Word16 *odata, /* (o) smoothed output */ - WebRtc_Word16 *current, /* (i) the un enhanced residual for - this block */ - WebRtc_Word16 *surround /* (i) The approximation from the - surrounding sequences */ - ) { - WebRtc_Word16 maxtot, scale, scale1, scale2; - WebRtc_Word16 A, B, C, denomW16; - WebRtc_Word32 B_W32, denom, num; - WebRtc_Word32 errs; - WebRtc_Word32 w00,w10,w11, endiff, crit; - WebRtc_Word32 w00prim, w10prim, w11_div_w00; - WebRtc_Word16 w11prim; - WebRtc_Word16 bitsw00, bitsw10, bitsw11; - WebRtc_Word32 w11w00, w10w10, w00w00; - WebRtc_Word16 max1, max2; - - /* compute some inner products (ensure no overflow by first calculating proper scale factor) */ - - w00 = w10 = w11 = 0; - - max1=WebRtcSpl_MaxAbsValueW16(current, ENH_BLOCKL); - max2=WebRtcSpl_MaxAbsValueW16(surround, ENH_BLOCKL); - maxtot=WEBRTC_SPL_MAX(max1, max2); - - scale=WebRtcSpl_GetSizeInBits(maxtot); - scale = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(2,scale)-26; - scale=WEBRTC_SPL_MAX(0, scale); - - w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale); - w11=WebRtcSpl_DotProductWithScale(surround,surround,ENH_BLOCKL,scale); - w10=WebRtcSpl_DotProductWithScale(surround,current,ENH_BLOCKL,scale); - - if (w00<0) w00 = WEBRTC_SPL_WORD32_MAX; - if (w11<0) w11 = WEBRTC_SPL_WORD32_MAX; - - /* Rescale w00 and w11 to w00prim and w11prim, so that w00prim/w11prim - is in Q16 */ - - bitsw00 = WebRtcSpl_GetSizeInBits(w00); - bitsw11 = WebRtcSpl_GetSizeInBits(w11); - bitsw10 = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_ABS_W32(w10)); - scale1 = 31 - bitsw00; - scale2 = 15 - bitsw11; - - if (scale2>(scale1-16)) { - scale2 = scale1 - 16; - } else { - scale1 = scale2 + 16; - } - - w00prim = WEBRTC_SPL_LSHIFT_W32(w00, scale1); - w11prim = (WebRtc_Word16) WEBRTC_SPL_SHIFT_W32(w11, scale2); - - /* Perform C = sqrt(w11/w00) (C is in Q11 since (16+6)/2=11) */ - if (w11prim>64) { - endiff = WEBRTC_SPL_LSHIFT_W32( - (WebRtc_Word32)WebRtcSpl_DivW32W16(w00prim, w11prim), 6); - C = (WebRtc_Word16)WebRtcSpl_SqrtFloor(endiff); /* C is in Q11 */ - } else { - C = 1; - } - - /* first try enhancement without power-constraint */ - - errs = WebRtcIlbcfix_Smooth_odata(odata, current, surround, C); - - - - /* if constraint violated by first try, add constraint */ - - if ( (6-scale+scale1) > 31) { - crit=0; - } else { - /* crit = 0.05 * w00 (Result in Q-6) */ - crit = WEBRTC_SPL_SHIFT_W32( - WEBRTC_SPL_MUL(ENH_A0, WEBRTC_SPL_RSHIFT_W32(w00prim, 14)), - -(6-scale+scale1)); - } - - if (errs > crit) { - - if( w00 < 1) { - w00=1; - } - - /* Calculate w11*w00, w10*w10 and w00*w00 in the same Q domain */ - - scale1 = bitsw00-15; - scale2 = bitsw11-15; - - if (scale2>scale1) { - scale = scale2; - } else { - scale = scale1; - } - - w11w00 = WEBRTC_SPL_MUL_16_16( - (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(w11, -scale), - (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(w00, -scale)); - - w10w10 = WEBRTC_SPL_MUL_16_16( - (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(w10, -scale), - (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(w10, -scale)); - - w00w00 = WEBRTC_SPL_MUL_16_16( - (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(w00, -scale), - (WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(w00, -scale)); - - /* Calculate (w11*w00-w10*w10)/(w00*w00) in Q16 */ - if (w00w00>65536) { - endiff = (w11w00-w10w10); - endiff = WEBRTC_SPL_MAX(0, endiff); - /* denom is in Q16 */ - denom = WebRtcSpl_DivW32W16(endiff, (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(w00w00, 16)); - } else { - denom = 65536; - } - - if( denom > 7){ /* eliminates numerical problems - for if smooth */ - - scale=WebRtcSpl_GetSizeInBits(denom)-15; - - if (scale>0) { - /* denomW16 is in Q(16+scale) */ - denomW16=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(denom, scale); - - /* num in Q(34-scale) */ - num=WEBRTC_SPL_RSHIFT_W32(ENH_A0_MINUS_A0A0DIV4, scale); - } else { - /* denomW16 is in Q16 */ - denomW16=(WebRtc_Word16)denom; - - /* num in Q34 */ - num=ENH_A0_MINUS_A0A0DIV4; - } - - /* A sqrt( (ENH_A0-(ENH_A0^2)/4)*(w00*w00)/(w11*w00 + w10*w10) ) in Q9 */ - A = (WebRtc_Word16)WebRtcSpl_SqrtFloor(WebRtcSpl_DivW32W16(num, denomW16)); - - /* B_W32 is in Q30 ( B = 1 - ENH_A0/2 - A * w10/w00 ) */ - scale1 = 31-bitsw10; - scale2 = 21-scale1; - w10prim = WEBRTC_SPL_LSHIFT_W32(w10, scale1); - w00prim = WEBRTC_SPL_SHIFT_W32(w00, -scale2); - scale = bitsw00-scale2-15; - - if (scale>0) { - w10prim=WEBRTC_SPL_RSHIFT_W32(w10prim, scale); - w00prim=WEBRTC_SPL_RSHIFT_W32(w00prim, scale); - } - - if ((w00prim>0)&&(w10prim>0)) { - w11_div_w00=WebRtcSpl_DivW32W16(w10prim, (WebRtc_Word16)w00prim); - - if (WebRtcSpl_GetSizeInBits(w11_div_w00)+WebRtcSpl_GetSizeInBits(A)>31) { - B_W32 = 0; - } else { - B_W32 = (WebRtc_Word32)1073741824 - (WebRtc_Word32)ENH_A0DIV2 - - WEBRTC_SPL_MUL(A, w11_div_w00); - } - B = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(B_W32, 16); /* B in Q14 */ - } else { - /* No smoothing */ - A = 0; - B = 16384; /* 1 in Q14 */ - } - } - else{ /* essentially no difference between cycles; - smoothing not needed */ - - A = 0; - B = 16384; /* 1 in Q14 */ - } - - /* create smoothed sequence */ - - WebRtcSpl_ScaleAndAddVectors(surround, A, 9, - current, B, 14, - odata, ENH_BLOCKL); - } - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/smooth.h b/src/modules/audio_coding/codecs/ilbc/smooth.h deleted file mode 100644 index 88ce805..0000000 --- a/src/modules/audio_coding/codecs/ilbc/smooth.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * find the smoothed output data - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Smooth( - WebRtc_Word16 *odata, /* (o) smoothed output */ - WebRtc_Word16 *current, /* (i) the un enhanced residual for - this block */ - WebRtc_Word16 *surround /* (i) The approximation from the - surrounding sequences */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/smooth_out_data.c b/src/modules/audio_coding/codecs/ilbc/smooth_out_data.c deleted file mode 100644 index 9bacd85..0000000 --- a/src/modules/audio_coding/codecs/ilbc/smooth_out_data.c +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth_odata.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -WebRtc_Word32 WebRtcIlbcfix_Smooth_odata( - WebRtc_Word16 *odata, - WebRtc_Word16 *psseq, - WebRtc_Word16 *surround, - WebRtc_Word16 C) -{ - int i; - - WebRtc_Word16 err; - WebRtc_Word32 errs; - - for(i=0;i<80;i++) { - odata[i]= (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (WEBRTC_SPL_MUL_16_16(C, surround[i])+1024), 11); - } - - errs=0; - for(i=0;i<80;i++) { - err=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16((psseq[i]-odata[i]), 3); - errs+=WEBRTC_SPL_MUL_16_16(err, err); /* errs in Q-6 */ - } - - return errs; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/smooth_out_data.h b/src/modules/audio_coding/codecs/ilbc/smooth_out_data.h deleted file mode 100644 index 6fbe694..0000000 --- a/src/modules/audio_coding/codecs/ilbc/smooth_out_data.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Smooth_odata.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_OUT_DATA_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SMOOTH_OUT_DATA_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * help function to WebRtcIlbcfix_Smooth() - *---------------------------------------------------------------*/ - -WebRtc_Word32 WebRtcIlbcfix_Smooth_odata( - WebRtc_Word16 *odata, - WebRtc_Word16 *psseq, - WebRtc_Word16 *surround, - WebRtc_Word16 C); - - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/sort_sq.c b/src/modules/audio_coding/codecs/ilbc/sort_sq.c deleted file mode 100644 index 9276a7b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/sort_sq.c +++ /dev/null
@@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SortSq.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * scalar quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SortSq( - WebRtc_Word16 *xq, /* (o) the quantized value */ - WebRtc_Word16 *index, /* (o) the quantization index */ - WebRtc_Word16 x, /* (i) the value to quantize */ - const WebRtc_Word16 *cb, /* (i) the quantization codebook */ - WebRtc_Word16 cb_size /* (i) the size of the quantization codebook */ - ){ - int i; - - if (x <= cb[0]) { - *index = 0; - *xq = cb[0]; - } else { - i = 0; - while ((x > cb[i]) && (i < (cb_size-1))) { - i++; - } - - if (x > WEBRTC_SPL_RSHIFT_W32(( (WebRtc_Word32)cb[i] + cb[i - 1] + 1),1)) { - *index = i; - *xq = cb[i]; - } else { - *index = i - 1; - *xq = cb[i - 1]; - } - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/sort_sq.h b/src/modules/audio_coding/codecs/ilbc/sort_sq.h deleted file mode 100644 index 2863dc5..0000000 --- a/src/modules/audio_coding/codecs/ilbc/sort_sq.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SortSq.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SORT_SQ_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SORT_SQ_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * scalar quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SortSq( - WebRtc_Word16 *xq, /* (o) the quantized value */ - WebRtc_Word16 *index, /* (o) the quantization index */ - WebRtc_Word16 x, /* (i) the value to quantize */ - const WebRtc_Word16 *cb, /* (i) the quantization codebook */ - WebRtc_Word16 cb_size /* (i) the size of the quantization codebook */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/split_vq.c b/src/modules/audio_coding/codecs/ilbc/split_vq.c deleted file mode 100644 index d908fa2..0000000 --- a/src/modules/audio_coding/codecs/ilbc/split_vq.c +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SplitVq.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "vq3.h" -#include "vq4.h" - -/*----------------------------------------------------------------* - * split vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SplitVq( - WebRtc_Word16 *qX, /* (o) the quantized vector in Q13 */ - WebRtc_Word16 *index, /* (o) a vector of indexes for all vector - codebooks in the split */ - WebRtc_Word16 *X, /* (i) the vector to quantize */ - WebRtc_Word16 *CB, /* (i) the quantizer codebook in Q13 */ - WebRtc_Word16 *dim, /* (i) the dimension of X and qX */ - WebRtc_Word16 *cbsize /* (i) the number of vectors in the codebook */ - ) { - - WebRtc_Word16 *qXPtr, *indexPtr, *CBPtr, *XPtr; - - /* Quantize X with the 3 vectror quantization tables */ - - qXPtr=qX; - indexPtr=index; - CBPtr=CB; - XPtr=X; - WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[0]); - - qXPtr+=3; - indexPtr+=1; - CBPtr+=(dim[0]*cbsize[0]); - XPtr+=3; - WebRtcIlbcfix_Vq3(qXPtr, indexPtr, CBPtr, XPtr, cbsize[1]); - - qXPtr+=3; - indexPtr+=1; - CBPtr+=(dim[1]*cbsize[1]); - XPtr+=3; - WebRtcIlbcfix_Vq4(qXPtr, indexPtr, CBPtr, XPtr, cbsize[2]); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/split_vq.h b/src/modules/audio_coding/codecs/ilbc/split_vq.h deleted file mode 100644 index 7264a21..0000000 --- a/src/modules/audio_coding/codecs/ilbc/split_vq.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SplitVq.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SPLIT_VQ_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SPLIT_VQ_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * split vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SplitVq( - WebRtc_Word16 *qX, /* (o) the quantized vector in Q13 */ - WebRtc_Word16 *index, /* (o) a vector of indexes for all vector - codebooks in the split */ - WebRtc_Word16 *X, /* (i) the vector to quantize */ - WebRtc_Word16 *CB, /* (i) the quantizer codebook in Q13 */ - WebRtc_Word16 *dim, /* (i) the dimension of X and qX */ - WebRtc_Word16 *cbsize /* (i) the number of vectors in the codebook */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/state_construct.c b/src/modules/audio_coding/codecs/ilbc/state_construct.c deleted file mode 100644 index 9d03cc3..0000000 --- a/src/modules/audio_coding/codecs/ilbc/state_construct.c +++ /dev/null
@@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateConstruct.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * decoding of the start state - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateConstruct( - WebRtc_Word16 idxForMax, /* (i) 6-bit index for the quantization of - max amplitude */ - WebRtc_Word16 *idxVec, /* (i) vector of quantization indexes */ - WebRtc_Word16 *syntDenum, /* (i) synthesis filter denumerator */ - WebRtc_Word16 *Out_fix, /* (o) the decoded state vector */ - WebRtc_Word16 len /* (i) length of a state vector */ - ) { - int k; - WebRtc_Word16 maxVal; - WebRtc_Word16 *tmp1, *tmp2, *tmp3; - /* Stack based */ - WebRtc_Word16 numerator[1+LPC_FILTERORDER]; - WebRtc_Word16 sampleValVec[2*STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - WebRtc_Word16 sampleMaVec[2*STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - WebRtc_Word16 *sampleVal = &sampleValVec[LPC_FILTERORDER]; - WebRtc_Word16 *sampleMa = &sampleMaVec[LPC_FILTERORDER]; - WebRtc_Word16 *sampleAr = &sampleValVec[LPC_FILTERORDER]; - - /* initialization of coefficients */ - - for (k=0; k<LPC_FILTERORDER+1; k++){ - numerator[k] = syntDenum[LPC_FILTERORDER-k]; - } - - /* decoding of the maximum value */ - - maxVal = WebRtcIlbcfix_kFrgQuantMod[idxForMax]; - - /* decoding of the sample values */ - tmp1 = sampleVal; - tmp2 = &idxVec[len-1]; - - if (idxForMax<37) { - for(k=0; k<len; k++){ - /*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 2097152 (= 0.5 << 22) - maxVal is in Q8 and result is in Q(-1) */ - (*tmp1) = (WebRtc_Word16) ((WEBRTC_SPL_MUL_16_16(maxVal,WebRtcIlbcfix_kStateSq3[(*tmp2)])+(WebRtc_Word32)2097152) >> 22); - tmp1++; - tmp2--; - } - } else if (idxForMax<59) { - for(k=0; k<len; k++){ - /*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 262144 (= 0.5 << 19) - maxVal is in Q5 and result is in Q(-1) */ - (*tmp1) = (WebRtc_Word16) ((WEBRTC_SPL_MUL_16_16(maxVal,WebRtcIlbcfix_kStateSq3[(*tmp2)])+(WebRtc_Word32)262144) >> 19); - tmp1++; - tmp2--; - } - } else { - for(k=0; k<len; k++){ - /*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 65536 (= 0.5 << 17) - maxVal is in Q3 and result is in Q(-1) */ - (*tmp1) = (WebRtc_Word16) ((WEBRTC_SPL_MUL_16_16(maxVal,WebRtcIlbcfix_kStateSq3[(*tmp2)])+(WebRtc_Word32)65536) >> 17); - tmp1++; - tmp2--; - } - } - - /* Set the rest of the data to zero */ - WebRtcSpl_MemSetW16(&sampleVal[len], 0, len); - - /* circular convolution with all-pass filter */ - - /* Set the state to zero */ - WebRtcSpl_MemSetW16(sampleValVec, 0, (LPC_FILTERORDER)); - - /* Run MA filter + AR filter */ - WebRtcSpl_FilterMAFastQ12( - sampleVal, sampleMa, - numerator, LPC_FILTERORDER+1, (WebRtc_Word16)(len + LPC_FILTERORDER)); - WebRtcSpl_MemSetW16(&sampleMa[len + LPC_FILTERORDER], 0, (len - LPC_FILTERORDER)); - WebRtcSpl_FilterARFastQ12( - sampleMa, sampleAr, - syntDenum, LPC_FILTERORDER+1, (WebRtc_Word16)(2*len)); - - tmp1 = &sampleAr[len-1]; - tmp2 = &sampleAr[2*len-1]; - tmp3 = Out_fix; - for(k=0;k<len;k++){ - (*tmp3) = (*tmp1) + (*tmp2); - tmp1--; - tmp2--; - tmp3++; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/state_construct.h b/src/modules/audio_coding/codecs/ilbc/state_construct.h deleted file mode 100644 index 465699b..0000000 --- a/src/modules/audio_coding/codecs/ilbc/state_construct.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateConstruct.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_CONSTRUCT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_CONSTRUCT_H_ - -/*----------------------------------------------------------------* - * Generate the start state from the quantized indexes - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateConstruct( - WebRtc_Word16 idxForMax, /* (i) 6-bit index for the quantization of - max amplitude */ - WebRtc_Word16 *idxVec, /* (i) vector of quantization indexes */ - WebRtc_Word16 *syntDenum, /* (i) synthesis filter denumerator */ - WebRtc_Word16 *Out_fix, /* (o) the decoded state vector */ - WebRtc_Word16 len /* (i) length of a state vector */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/state_search.c b/src/modules/audio_coding/codecs/ilbc/state_search.c deleted file mode 100644 index 824a0ba..0000000 --- a/src/modules/audio_coding/codecs/ilbc/state_search.c +++ /dev/null
@@ -1,119 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateSearch.c - -******************************************************************/ - -#include "defines.h" -#include "constants.h" -#include "abs_quant.h" - -/*----------------------------------------------------------------* - * encoding of start state - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateSearch( - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits,/* (i/o) Encoded bits (output idxForMax - and idxVec, input state_first) */ - WebRtc_Word16 *residual, /* (i) target residual vector */ - WebRtc_Word16 *syntDenum, /* (i) lpc synthesis filter */ - WebRtc_Word16 *weightDenum /* (i) weighting filter denuminator */ - ) { - WebRtc_Word16 k, index; - WebRtc_Word16 maxVal; - WebRtc_Word16 scale, shift; - WebRtc_Word32 maxValsq; - WebRtc_Word16 scaleRes; - WebRtc_Word16 max; - int i; - /* Stack based */ - WebRtc_Word16 numerator[1+LPC_FILTERORDER]; - WebRtc_Word16 residualLongVec[2*STATE_SHORT_LEN_30MS+LPC_FILTERORDER]; - WebRtc_Word16 sampleMa[2*STATE_SHORT_LEN_30MS]; - WebRtc_Word16 *residualLong = &residualLongVec[LPC_FILTERORDER]; - WebRtc_Word16 *sampleAr = residualLong; - - /* Scale to maximum 12 bits to avoid saturation in circular convolution filter */ - max = WebRtcSpl_MaxAbsValueW16(residual, iLBCenc_inst->state_short_len); - scaleRes = WebRtcSpl_GetSizeInBits(max)-12; - scaleRes = WEBRTC_SPL_MAX(0, scaleRes); - /* Set up the filter coefficients for the circular convolution */ - for (i=0; i<LPC_FILTERORDER+1; i++) { - numerator[i] = (syntDenum[LPC_FILTERORDER-i]>>scaleRes); - } - - /* Copy the residual to a temporary buffer that we can filter - * and set the remaining samples to zero. - */ - WEBRTC_SPL_MEMCPY_W16(residualLong, residual, iLBCenc_inst->state_short_len); - WebRtcSpl_MemSetW16(residualLong + iLBCenc_inst->state_short_len, 0, iLBCenc_inst->state_short_len); - - /* Run the Zero-Pole filter (Ciurcular convolution) */ - WebRtcSpl_MemSetW16(residualLongVec, 0, LPC_FILTERORDER); - WebRtcSpl_FilterMAFastQ12( - residualLong, sampleMa, - numerator, LPC_FILTERORDER+1, (WebRtc_Word16)(iLBCenc_inst->state_short_len + LPC_FILTERORDER)); - WebRtcSpl_MemSetW16(&sampleMa[iLBCenc_inst->state_short_len + LPC_FILTERORDER], 0, iLBCenc_inst->state_short_len - LPC_FILTERORDER); - - WebRtcSpl_FilterARFastQ12( - sampleMa, sampleAr, - syntDenum, LPC_FILTERORDER+1, (WebRtc_Word16)(2*iLBCenc_inst->state_short_len)); - - for(k=0;k<iLBCenc_inst->state_short_len;k++){ - sampleAr[k] += sampleAr[k+iLBCenc_inst->state_short_len]; - } - - /* Find maximum absolute value in the vector */ - maxVal=WebRtcSpl_MaxAbsValueW16(sampleAr, iLBCenc_inst->state_short_len); - - /* Find the best index */ - - if ((((WebRtc_Word32)maxVal)<<scaleRes)<23170) { - maxValsq=((WebRtc_Word32)maxVal*maxVal)<<(2+2*scaleRes); - } else { - maxValsq=(WebRtc_Word32)WEBRTC_SPL_WORD32_MAX; - } - - index=0; - for (i=0;i<63;i++) { - - if (maxValsq>=WebRtcIlbcfix_kChooseFrgQuant[i]) { - index=i+1; - } else { - i=63; - } - } - iLBC_encbits->idxForMax=index; - - /* Rescale the vector before quantization */ - scale=WebRtcIlbcfix_kScale[index]; - - if (index<27) { /* scale table is in Q16, fout[] is in Q(-1) and we want the result to be in Q11 */ - shift=4; - } else { /* scale table is in Q21, fout[] is in Q(-1) and we want the result to be in Q11 */ - shift=9; - } - - /* Set up vectors for AbsQuant and rescale it with the scale factor */ - WebRtcSpl_ScaleVectorWithSat(sampleAr, sampleAr, scale, - iLBCenc_inst->state_short_len, (WebRtc_Word16)(shift-scaleRes)); - - /* Quantize the values in fout[] */ - WebRtcIlbcfix_AbsQuant(iLBCenc_inst, iLBC_encbits, sampleAr, weightDenum); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/state_search.h b/src/modules/audio_coding/codecs/ilbc/state_search.h deleted file mode 100644 index 8b7f298..0000000 --- a/src/modules/audio_coding/codecs/ilbc/state_search.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_StateSearch.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_SEARCH_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_STATE_SEARCH_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * encoding of start state - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_StateSearch( - iLBC_Enc_Inst_t *iLBCenc_inst, - /* (i) Encoder instance */ - iLBC_bits *iLBC_encbits,/* (i/o) Encoded bits (output idxForMax - and idxVec, input state_first) */ - WebRtc_Word16 *residual, /* (i) target residual vector */ - WebRtc_Word16 *syntDenum, /* (i) lpc synthesis filter */ - WebRtc_Word16 *weightDenum /* (i) weighting filter denuminator */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/swap_bytes.c b/src/modules/audio_coding/codecs/ilbc/swap_bytes.c deleted file mode 100644 index a48a066..0000000 --- a/src/modules/audio_coding/codecs/ilbc/swap_bytes.c +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SwapBytes.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Swap bytes (to simplify operations on Little Endian machines) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SwapBytes( - const WebRtc_UWord16* input, /* (i) the sequence to swap */ - WebRtc_Word16 wordLength, /* (i) number or WebRtc_UWord16 to swap */ - WebRtc_UWord16* output /* (o) the swapped sequence */ - ) { - int k; - for (k = wordLength; k > 0; k--) { - *output++ = (*input >> 8)|(*input << 8); - input++; - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/swap_bytes.h b/src/modules/audio_coding/codecs/ilbc/swap_bytes.h deleted file mode 100644 index 1632311..0000000 --- a/src/modules/audio_coding/codecs/ilbc/swap_bytes.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_SwapBytes.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SWAP_BYTES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_SWAP_BYTES_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * Swap bytes (to simplify operations on Little Endian machines) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_SwapBytes( - const WebRtc_UWord16* input, /* (i) the sequence to swap */ - WebRtc_Word16 wordLength, /* (i) number or WebRtc_UWord16 to swap */ - WebRtc_UWord16* output /* (o) the swapped sequence */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/test/iLBC_test.c b/src/modules/audio_coding/codecs/ilbc/test/iLBC_test.c deleted file mode 100644 index 19569ac..0000000 --- a/src/modules/audio_coding/codecs/ilbc/test/iLBC_test.c +++ /dev/null
@@ -1,232 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - iLBC_test.c - -******************************************************************/ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include "ilbc.h" - -/*---------------------------------------------------------------* - * Main program to test iLBC encoding and decoding - * - * Usage: - * exefile_name.exe <infile> <bytefile> <outfile> <channel> - * - * <infile> : Input file, speech for encoder (16-bit pcm file) - * <bytefile> : Bit stream output from the encoder - * <outfile> : Output file, decoded speech (16-bit pcm file) - * <channel> : Bit error file, optional (16-bit) - * 1 - Packet received correctly - * 0 - Packet Lost - * - *--------------------------------------------------------------*/ - -#define BLOCKL_MAX 240 -#define ILBCNOOFWORDS_MAX 25 - - -int main(int argc, char* argv[]) -{ - - FILE *ifileid,*efileid,*ofileid, *cfileid; - WebRtc_Word16 data[BLOCKL_MAX]; - WebRtc_Word16 encoded_data[ILBCNOOFWORDS_MAX], decoded_data[BLOCKL_MAX]; - int len; - short pli, mode; - int blockcount = 0; - int packetlosscount = 0; - int frameLen; - WebRtc_Word16 speechType; - iLBC_encinst_t *Enc_Inst; - iLBC_decinst_t *Dec_Inst; - -#ifdef __ILBC_WITH_40BITACC - /* Doublecheck that long long exists */ - if (sizeof(long)>=sizeof(long long)) { - fprintf(stderr, "40-bit simulation is not be supported on this platform\n"); - exit(0); - } -#endif - - /* get arguments and open files */ - - if ((argc!=5) && (argc!=6)) { - fprintf(stderr, - "\n*-----------------------------------------------*\n"); - fprintf(stderr, - " %s <20,30> input encoded decoded (channel)\n\n", - argv[0]); - fprintf(stderr, - " mode : Frame size for the encoding/decoding\n"); - fprintf(stderr, - " 20 - 20 ms\n"); - fprintf(stderr, - " 30 - 30 ms\n"); - fprintf(stderr, - " input : Speech for encoder (16-bit pcm file)\n"); - fprintf(stderr, - " encoded : Encoded bit stream\n"); - fprintf(stderr, - " decoded : Decoded speech (16-bit pcm file)\n"); - fprintf(stderr, - " channel : Packet loss pattern, optional (16-bit)\n"); - fprintf(stderr, - " 1 - Packet received correctly\n"); - fprintf(stderr, - " 0 - Packet Lost\n"); - fprintf(stderr, - "*-----------------------------------------------*\n\n"); - exit(1); - } - mode=atoi(argv[1]); - if (mode != 20 && mode != 30) { - fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", - argv[1]); - exit(2); - } - if ( (ifileid=fopen(argv[2],"rb")) == NULL) { - fprintf(stderr,"Cannot open input file %s\n", argv[2]); - exit(2);} - if ( (efileid=fopen(argv[3],"wb")) == NULL) { - fprintf(stderr, "Cannot open encoded file file %s\n", - argv[3]); exit(1);} - if ( (ofileid=fopen(argv[4],"wb")) == NULL) { - fprintf(stderr, "Cannot open decoded file %s\n", - argv[4]); exit(1);} - if (argc==6) { - if( (cfileid=fopen(argv[5],"rb")) == NULL) { - fprintf(stderr, "Cannot open channel file %s\n", - argv[5]); - exit(1); - } - } else { - cfileid=NULL; - } - - /* print info */ - - fprintf(stderr, "\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* iLBC test program *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr,"\nMode : %2d ms\n", mode); - fprintf(stderr,"Input file : %s\n", argv[2]); - fprintf(stderr,"Encoded file : %s\n", argv[3]); - fprintf(stderr,"Output file : %s\n", argv[4]); - if (argc==6) { - fprintf(stderr,"Channel file : %s\n", argv[5]); - } - fprintf(stderr,"\n"); - - /* Create structs */ - WebRtcIlbcfix_EncoderCreate(&Enc_Inst); - WebRtcIlbcfix_DecoderCreate(&Dec_Inst); - - - /* Initialization */ - - WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); - WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); - frameLen = mode*8; - - /* loop over input blocks */ - - while (((WebRtc_Word16)fread(data,sizeof(WebRtc_Word16),frameLen,ifileid))== - frameLen) { - - blockcount++; - - /* encoding */ - - fprintf(stderr, "--- Encoding block %i --- ",blockcount); - len=WebRtcIlbcfix_Encode(Enc_Inst, data, (WebRtc_Word16)frameLen, encoded_data); - fprintf(stderr, "\r"); - - /* write byte file */ - - if (fwrite(encoded_data, sizeof(WebRtc_Word16), - ((len+1)/sizeof(WebRtc_Word16)), efileid) != - (size_t)(((len+1)/sizeof(WebRtc_Word16)))) { - return -1; - } - - /* get channel data if provided */ - if (argc==6) { - if (fread(&pli, sizeof(WebRtc_Word16), 1, cfileid)) { - if ((pli!=0)&&(pli!=1)) { - fprintf(stderr, "Error in channel file\n"); - exit(0); - } - if (pli==0) { - /* Packet loss -> remove info from frame */ - memset(encoded_data, 0, - sizeof(WebRtc_Word16)*ILBCNOOFWORDS_MAX); - packetlosscount++; - } - } else { - fprintf(stderr, "Error. Channel file too short\n"); - exit(0); - } - } else { - pli=1; - } - - /* decoding */ - - fprintf(stderr, "--- Decoding block %i --- ",blockcount); - if (pli==1) { - len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, - (WebRtc_Word16)len, decoded_data,&speechType); - } else { - len=WebRtcIlbcfix_DecodePlc(Dec_Inst, decoded_data, 1); - } - fprintf(stderr, "\r"); - - /* write output file */ - - if (fwrite(decoded_data, sizeof(WebRtc_Word16), len, - ofileid) != (size_t)len) { - return -1; - } - } - - /* close files */ - - fclose(ifileid); fclose(efileid); fclose(ofileid); - if (argc==6) { - fclose(cfileid); - } - - /* Free structs */ - WebRtcIlbcfix_EncoderFree(Enc_Inst); - WebRtcIlbcfix_DecoderFree(Dec_Inst); - - - printf("\nDone with simulation\n\n"); - - return(0); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c b/src/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c deleted file mode 100644 index ee5e484..0000000 --- a/src/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c +++ /dev/null
@@ -1,207 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - -iLBC Speech Coder ANSI-C Source Code - -iLBC_test.c - -******************************************************************/ - -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <time.h> -#include "ilbc.h" - -//#define JUNK_DATA -#ifdef JUNK_DATA -#define SEED_FILE "randseed.txt" -#endif - - -/*----------------------------------------------------------------* -* Main program to test iLBC encoding and decoding -* -* Usage: -* exefile_name.exe <infile> <bytefile> <outfile> -* -*---------------------------------------------------------------*/ - -int main(int argc, char* argv[]) -{ - FILE *ifileid,*efileid,*ofileid, *chfileid; - short encoded_data[55], data[240], speechType; - short len, mode, pli; - int blockcount = 0; - - iLBC_encinst_t *Enc_Inst; - iLBC_decinst_t *Dec_Inst; -#ifdef JUNK_DATA - int i; - FILE *seedfile; - unsigned int random_seed = (unsigned int) time(NULL);//1196764538 -#endif - - /* Create structs */ - WebRtcIlbcfix_EncoderCreate(&Enc_Inst); - WebRtcIlbcfix_DecoderCreate(&Dec_Inst); - - /* get arguments and open files */ - - if (argc != 6 ) { - fprintf(stderr, "%s mode inputfile bytefile outputfile channelfile\n", - argv[0]); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s <30,20> in.pcm byte.dat out.pcm T30.0.dat\n", argv[0]); - exit(1); - } - mode=atoi(argv[1]); - if (mode != 20 && mode != 30) { - fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", argv[1]); - exit(2); - } - if ( (ifileid=fopen(argv[2],"rb")) == NULL) { - fprintf(stderr,"Cannot open input file %s\n", argv[2]); - exit(2);} - if ( (efileid=fopen(argv[3],"wb")) == NULL) { - fprintf(stderr, "Cannot open channelfile file %s\n", - argv[3]); exit(3);} - if( (ofileid=fopen(argv[4],"wb")) == NULL) { - fprintf(stderr, "Cannot open output file %s\n", - argv[4]); exit(3);} - if ( (chfileid=fopen(argv[5],"rb")) == NULL) { - fprintf(stderr,"Cannot open channel file file %s\n", argv[5]); - exit(2); - } - /* print info */ - fprintf(stderr, "\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* iLBCtest *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); -#ifdef SPLIT_10MS - fprintf(stderr,"\n10ms split with raw mode: %2d ms\n", mode); -#else - fprintf(stderr,"\nMode : %2d ms\n", mode); -#endif - fprintf(stderr,"\nInput file : %s\n", argv[2]); - fprintf(stderr,"Coded file : %s\n", argv[3]); - fprintf(stderr,"Output file : %s\n\n", argv[4]); - fprintf(stderr,"Channel file : %s\n\n", argv[5]); - -#ifdef JUNK_DATA - srand(random_seed); - - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE); - } - else { - fprintf(seedfile, "%u\n", random_seed); - fclose(seedfile); - } -#endif - - /* Initialization */ - WebRtcIlbcfix_EncoderInit(Enc_Inst, mode); - WebRtcIlbcfix_DecoderInit(Dec_Inst, mode); - - /* loop over input blocks */ -#ifdef SPLIT_10MS - while(fread(data, sizeof(short), 80, ifileid) == 80) { -#else - while((short)fread(data,sizeof(short),(mode<<3),ifileid)==(mode<<3)) { -#endif - blockcount++; - - /* encoding */ - fprintf(stderr, "--- Encoding block %i --- ",blockcount); -#ifdef SPLIT_10MS - len=WebRtcIlbcfix_Encode(Enc_Inst, data, 80, encoded_data); -#else - len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data); -#endif - fprintf(stderr, "\r"); - -#ifdef JUNK_DATA - for ( i = 0; i < len; i++) { - encoded_data[i] = (short) (encoded_data[i] + (short) rand()); - } -#endif - /* write byte file */ - if(len != 0){ //len may be 0 in 10ms split case - fwrite(encoded_data,1,len,efileid); - } - - if(len != 0){ //len may be 0 in 10ms split case - /* get channel data if provided */ - if (argc==6) { - if (fread(&pli, sizeof(WebRtc_Word16), 1, chfileid)) { - if ((pli!=0)&&(pli!=1)) { - fprintf(stderr, "Error in channel file\n"); - exit(0); - } - if (pli==0) { - /* Packet loss -> remove info from frame */ - memset(encoded_data, 0, sizeof(WebRtc_Word16)*25); - } - } else { - fprintf(stderr, "Error. Channel file too short\n"); - exit(0); - } - } else { - pli=1; - } - - /* decoding */ - fprintf(stderr, "--- Decoding block %i --- ",blockcount); - if (pli==1) { - len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, len, data, &speechType); - } else { - len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1); - } - fprintf(stderr, "\r"); - - /* write output file */ - fwrite(data,sizeof(short),len,ofileid); - } - } - -#ifdef JUNK_DATA - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - fprintf(stderr, "Error: Could not open file %s\n", SEED_FILE); - } - else { - fprintf(seedfile, "ok\n\n"); - fclose(seedfile); - } -#endif - - /* free structs */ - WebRtcIlbcfix_EncoderFree(Enc_Inst); - WebRtcIlbcfix_DecoderFree(Dec_Inst); - - /* close files */ - fclose(ifileid); - fclose(efileid); - fclose(ofileid); - - return 0; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/test/iLBC_testprogram.c b/src/modules/audio_coding/codecs/ilbc/test/iLBC_testprogram.c deleted file mode 100644 index f67945e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/test/iLBC_testprogram.c +++ /dev/null
@@ -1,343 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - iLBC_test.c - -******************************************************************/ - -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "defines.h" -#include "nit_encode.h" -#include "encode.h" -#include "init_decode.h" -#include "decode.h" -#include "constants.h" -#include "ilbc.h" - -#define ILBCNOOFWORDS_MAX (NO_OF_BYTES_30MS)/2 - -/* Runtime statistics */ -#include <time.h> -/* #define CLOCKS_PER_SEC 1000 */ - -/*----------------------------------------------------------------* - * Encoder interface function - *---------------------------------------------------------------*/ - -short encode( /* (o) Number of bytes encoded */ - iLBC_Enc_Inst_t *iLBCenc_inst, /* (i/o) Encoder instance */ - WebRtc_Word16 *encoded_data, /* (o) The encoded bytes */ - WebRtc_Word16 *data /* (i) The signal block to encode */ - ){ - - /* do the actual encoding */ - WebRtcIlbcfix_Encode((WebRtc_UWord16 *)encoded_data, data, iLBCenc_inst); - - return (iLBCenc_inst->no_of_bytes); -} - -/*----------------------------------------------------------------* - * Decoder interface function - *---------------------------------------------------------------*/ - -short decode( /* (o) Number of decoded samples */ - iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) Decoder instance */ - short *decoded_data, /* (o) Decoded signal block */ - short *encoded_data, /* (i) Encoded bytes */ - short mode /* (i) 0=PL, 1=Normal */ - ){ - - /* check if mode is valid */ - - if (mode<0 || mode>1) { - printf("\nERROR - Wrong mode - 0, 1 allowed\n"); exit(3);} - - /* do actual decoding of block */ - - WebRtcIlbcfix_Decode(decoded_data, (WebRtc_UWord16 *)encoded_data, - iLBCdec_inst, mode); - - return (iLBCdec_inst->blockl); -} - -/*----------------------------------------------------------------* - * Main program to test iLBC encoding and decoding - * - * Usage: - * exefile_name.exe <infile> <bytefile> <outfile> <channelfile> - * - *---------------------------------------------------------------*/ - -#define MAXFRAMES 10000 -#define MAXFILELEN (BLOCKL_MAX*MAXFRAMES) - -int main(int argc, char* argv[]) -{ - - /* Runtime statistics */ - - float starttime1, starttime2; - float runtime1, runtime2; - float outtime; - - FILE *ifileid,*efileid,*ofileid, *chfileid; - short *inputdata, *encodeddata, *decodeddata; - short *channeldata; - int blockcount = 0, noOfBlocks=0, i, noOfLostBlocks=0; - short mode; - iLBC_Enc_Inst_t Enc_Inst; - iLBC_Dec_Inst_t Dec_Inst; - - short frameLen; - short count; -#ifdef SPLIT_10MS - short size; -#endif - - inputdata=(short*) malloc(MAXFILELEN*sizeof(short)); - if (inputdata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - exit(0); - } - encodeddata=(short*) malloc(ILBCNOOFWORDS_MAX*MAXFRAMES*sizeof(short)); - if (encodeddata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - free(inputdata); - exit(0); - } - decodeddata=(short*) malloc(MAXFILELEN*sizeof(short)); - if (decodeddata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - free(inputdata); - free(encodeddata); - exit(0); - } - channeldata=(short*) malloc(MAXFRAMES*sizeof(short)); - if (channeldata==NULL) { - fprintf(stderr,"Could not allocate memory for vector\n"); - free(inputdata); - free(encodeddata); - free(decodeddata); - exit(0); - } - - /* get arguments and open files */ - - if (argc != 6 ) { - fprintf(stderr, "%s mode inputfile bytefile outputfile channelfile\n", - argv[0]); - fprintf(stderr, "Example:\n"); - fprintf(stderr, "%s <30,20> in.pcm byte.dat out.pcm T30.0.dat\n", argv[0]); - exit(1); - } - mode=atoi(argv[1]); - if (mode != 20 && mode != 30) { - fprintf(stderr,"Wrong mode %s, must be 20, or 30\n", argv[1]); - exit(2); - } - if ( (ifileid=fopen(argv[2],"rb")) == NULL) { - fprintf(stderr,"Cannot open input file %s\n", argv[2]); - exit(2);} - if ( (efileid=fopen(argv[3],"wb")) == NULL) { - fprintf(stderr, "Cannot open channelfile file %s\n", - argv[3]); exit(3);} - if( (ofileid=fopen(argv[4],"wb")) == NULL) { - fprintf(stderr, "Cannot open output file %s\n", - argv[4]); exit(3);} - if ( (chfileid=fopen(argv[5],"rb")) == NULL) { - fprintf(stderr,"Cannot open channel file file %s\n", argv[5]); - exit(2);} - - - /* print info */ -#ifndef PRINT_MIPS - fprintf(stderr, "\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* iLBCtest *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "* *\n"); - fprintf(stderr, - "*---------------------------------------------------*\n"); -#ifdef SPLIT_10MS - fprintf(stderr,"\n10ms split with raw mode: %2d ms\n", mode); -#else - fprintf(stderr,"\nMode : %2d ms\n", mode); -#endif - fprintf(stderr,"\nInput file : %s\n", argv[2]); - fprintf(stderr,"Coded file : %s\n", argv[3]); - fprintf(stderr,"Output file : %s\n\n", argv[4]); - fprintf(stderr,"Channel file : %s\n\n", argv[5]); -#endif - - /* Initialization */ - - WebRtcIlbcfix_EncoderInit(&Enc_Inst, mode); - WebRtcIlbcfix_DecoderInit(&Dec_Inst, mode, 1); - - /* extract the input file and channel file */ - -#ifdef SPLIT_10MS - frameLen = (mode==20)? 80:160; - fread(Enc_Inst.past_samples, sizeof(short), frameLen, ifileid); - Enc_Inst.section = 0; - - while( fread(&inputdata[noOfBlocks*80], sizeof(short), - 80, ifileid) == 80 ) { - noOfBlocks++; - } - - noOfBlocks += frameLen/80; - frameLen = 80; -#else - frameLen = Enc_Inst.blockl; - - while( fread(&inputdata[noOfBlocks*Enc_Inst.blockl],sizeof(short), - Enc_Inst.blockl,ifileid)==(WebRtc_UWord16)Enc_Inst.blockl){ - noOfBlocks++; - } -#endif - - - while ((fread(&channeldata[blockcount],sizeof(short), 1,chfileid)==1) - && ( blockcount < noOfBlocks/(Enc_Inst.blockl/frameLen) )) { - blockcount++; - } - - if ( blockcount < noOfBlocks/(Enc_Inst.blockl/frameLen) ) { - fprintf(stderr,"Channel file %s is too short\n", argv[4]); - free(inputdata); - free(encodeddata); - free(decodeddata); - free(channeldata); - exit(0); - } - - count=0; - - /* Runtime statistics */ - - starttime1 = clock()/(float)CLOCKS_PER_SEC; - - /* Encoding loop */ -#ifdef PRINT_MIPS - printf("-1 -1\n"); -#endif - -#ifdef SPLIT_10MS - /* "Enc_Inst.section != 0" is to make sure we run through full - lengths of all vectors for 10ms split mode. - */ - // while( (count < noOfBlocks) || (Enc_Inst.section != 0) ) { - while( count < blockcount * (Enc_Inst.blockl/frameLen) ) { - - encode(&Enc_Inst, &encodeddata[Enc_Inst.no_of_words * - (count/(Enc_Inst.nsub/2))], - &inputdata[frameLen * count] ); -#else - while (count < noOfBlocks) { - encode( &Enc_Inst, &encodeddata[Enc_Inst.no_of_words * count], - &inputdata[frameLen * count] ); -#endif - -#ifdef PRINT_MIPS - printf("-1 -1\n"); -#endif - - count++; - } - - count=0; - - /* Runtime statistics */ - - starttime2=clock()/(float)CLOCKS_PER_SEC; - runtime1 = (float)(starttime2-starttime1); - - /* Decoding loop */ - - while (count < blockcount) { - if (channeldata[count]==1) { - /* Normal decoding */ - decode(&Dec_Inst, &decodeddata[count * Dec_Inst.blockl], - &encodeddata[Dec_Inst.no_of_words * count], 1); - } else if (channeldata[count]==0) { - /* PLC */ - short emptydata[ILBCNOOFWORDS_MAX]; - memset(emptydata, 0, Dec_Inst.no_of_words*sizeof(short)); - decode(&Dec_Inst, &decodeddata[count*Dec_Inst.blockl], - emptydata, 0); - noOfLostBlocks++; - } else { - printf("Error in channel file (values have to be either 1 or 0)\n"); - exit(0); - } -#ifdef PRINT_MIPS - printf("-1 -1\n"); -#endif - - count++; - } - - /* Runtime statistics */ - - runtime2 = (float)(clock()/(float)CLOCKS_PER_SEC-starttime2); - - outtime = (float)((float)blockcount* - (float)mode/1000.0); - -#ifndef PRINT_MIPS - printf("\nLength of speech file: %.1f s\n", outtime); - printf("Lost frames : %.1f%%\n\n", 100*(float)noOfLostBlocks/(float)blockcount); - - printf("Time to run iLBC_encode+iLBC_decode:"); - printf(" %.1f s (%.1f%% of realtime)\n", runtime1+runtime2, - (100*(runtime1+runtime2)/outtime)); - - printf("Time in iLBC_encode :"); - printf(" %.1f s (%.1f%% of total runtime)\n", - runtime1, 100.0*runtime1/(runtime1+runtime2)); - - printf("Time in iLBC_decode :"); - printf(" %.1f s (%.1f%% of total runtime)\n\n", - runtime2, 100.0*runtime2/(runtime1+runtime2)); -#endif - - /* Write data to files */ - for (i=0; i<blockcount; i++) { - fwrite(&encodeddata[i*Enc_Inst.no_of_words], sizeof(short), - Enc_Inst.no_of_words, efileid); - } - for (i=0;i<blockcount;i++) { - fwrite(&decodeddata[i*Enc_Inst.blockl],sizeof(short),Enc_Inst.blockl,ofileid); - } - - /* return memory and close files */ - - free(inputdata); - free(encodeddata); - free(decodeddata); - free(channeldata); - fclose(ifileid); fclose(efileid); fclose(ofileid); - return(0); - }
diff --git a/src/modules/audio_coding/codecs/ilbc/unpack_bits.c b/src/modules/audio_coding/codecs/ilbc/unpack_bits.c deleted file mode 100644 index 6ed9265..0000000 --- a/src/modules/audio_coding/codecs/ilbc/unpack_bits.c +++ /dev/null
@@ -1,239 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_UnpackBits.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_UnpackBits( /* (o) "Empty" frame indicator */ - const WebRtc_UWord16 *bitstream, /* (i) The packatized bitstream */ - iLBC_bits *enc_bits, /* (o) Paramerers from bitstream */ - WebRtc_Word16 mode /* (i) Codec mode (20 or 30) */ - ) { - const WebRtc_UWord16 *bitstreamPtr; - int i, k; - WebRtc_Word16 *tmpPtr; - - bitstreamPtr=bitstream; - - /* First WebRtc_Word16 */ - enc_bits->lsf[0] = (*bitstreamPtr)>>10; /* Bit 0..5 */ - enc_bits->lsf[1] = ((*bitstreamPtr)>>3)&0x7F; /* Bit 6..12 */ - enc_bits->lsf[2] = ((*bitstreamPtr)&0x7)<<4; /* Bit 13..15 */ - bitstreamPtr++; - /* Second WebRtc_Word16 */ - enc_bits->lsf[2] |= ((*bitstreamPtr)>>12)&0xF; /* Bit 0..3 */ - - if (mode==20) { - enc_bits->startIdx = ((*bitstreamPtr)>>10)&0x3; /* Bit 4..5 */ - enc_bits->state_first = ((*bitstreamPtr)>>9)&0x1; /* Bit 6 */ - enc_bits->idxForMax = ((*bitstreamPtr)>>3)&0x3F; /* Bit 7..12 */ - enc_bits->cb_index[0] = ((*bitstreamPtr)&0x7)<<4; /* Bit 13..15 */ - bitstreamPtr++; - /* Third WebRtc_Word16 */ - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>12)&0xE; /* Bit 0..2 */ - enc_bits->gain_index[0] = ((*bitstreamPtr)>>8)&0x18; /* Bit 3..4 */ - enc_bits->gain_index[1] = ((*bitstreamPtr)>>7)&0x8; /* Bit 5 */ - enc_bits->cb_index[3] = ((*bitstreamPtr)>>2)&0xFE; /* Bit 6..12 */ - enc_bits->gain_index[3] = ((*bitstreamPtr)<<2)&0x10; /* Bit 13 */ - enc_bits->gain_index[4] = ((*bitstreamPtr)<<2)&0x8; /* Bit 14 */ - enc_bits->gain_index[6] = ((*bitstreamPtr)<<4)&0x10; /* Bit 15 */ - } else { /* mode==30 */ - enc_bits->lsf[3] = ((*bitstreamPtr)>>6)&0x3F; /* Bit 4..9 */ - enc_bits->lsf[4] = ((*bitstreamPtr)<<1)&0x7E; /* Bit 10..15 */ - bitstreamPtr++; - /* Third WebRtc_Word16 */ - enc_bits->lsf[4] |= ((*bitstreamPtr)>>15)&0x1; /* Bit 0 */ - enc_bits->lsf[5] = ((*bitstreamPtr)>>8)&0x7F; /* Bit 1..7 */ - enc_bits->startIdx = ((*bitstreamPtr)>>5)&0x7; /* Bit 8..10 */ - enc_bits->state_first = ((*bitstreamPtr)>>4)&0x1; /* Bit 11 */ - enc_bits->idxForMax = ((*bitstreamPtr)<<2)&0x3C; /* Bit 12..15 */ - bitstreamPtr++; - /* 4:th WebRtc_Word16 */ - enc_bits->idxForMax |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->cb_index[0] = ((*bitstreamPtr)>>7)&0x78; /* Bit 2..5 */ - enc_bits->gain_index[0] = ((*bitstreamPtr)>>5)&0x10; /* Bit 6 */ - enc_bits->gain_index[1] = ((*bitstreamPtr)>>5)&0x8; /* Bit 7 */ - enc_bits->cb_index[3] = ((*bitstreamPtr))&0xFC; /* Bit 8..13 */ - enc_bits->gain_index[3] = ((*bitstreamPtr)<<3)&0x10; /* Bit 14 */ - enc_bits->gain_index[4] = ((*bitstreamPtr)<<3)&0x8; /* Bit 15 */ - } - /* Class 2 bits of ULP */ - /* 4:th to 6:th WebRtc_Word16 for 20 ms case - 5:th to 7:th WebRtc_Word16 for 30 ms case */ - bitstreamPtr++; - tmpPtr=enc_bits->idxVec; - for (k=0; k<3; k++) { - for (i=15; i>=0; i--) { - (*tmpPtr) = (((*bitstreamPtr)>>i)<<2)&0x4; - /* Bit 15-i */ - tmpPtr++; - } - bitstreamPtr++; - } - - if (mode==20) { - /* 7:th WebRtc_Word16 */ - for (i=15; i>6; i--) { - (*tmpPtr) = (((*bitstreamPtr)>>i)<<2)&0x4; - /* Bit 15-i */ - tmpPtr++; - } - enc_bits->gain_index[1] |= ((*bitstreamPtr)>>4)&0x4; /* Bit 9 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>2)&0xC; /* Bit 10..11 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)>>1)&0x4; /* Bit 12 */ - enc_bits->gain_index[6] |= ((*bitstreamPtr)<<1)&0x8; /* Bit 13 */ - enc_bits->gain_index[7] = ((*bitstreamPtr)<<2)&0xC; /* Bit 14..15 */ - - } else { /* mode==30 */ - /* 8:th WebRtc_Word16 */ - for (i=15; i>5; i--) { - (*tmpPtr) = (((*bitstreamPtr)>>i)<<2)&0x4; - /* Bit 15-i */ - tmpPtr++; - } - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>3)&0x6; /* Bit 10..11 */ - enc_bits->gain_index[0] |= ((*bitstreamPtr))&0x8; /* Bit 12 */ - enc_bits->gain_index[1] |= ((*bitstreamPtr))&0x4; /* Bit 13 */ - enc_bits->cb_index[3] |= ((*bitstreamPtr))&0x2; /* Bit 14 */ - enc_bits->cb_index[6] = ((*bitstreamPtr)<<7)&0x80; /* Bit 15 */ - bitstreamPtr++; - /* 9:th WebRtc_Word16 */ - enc_bits->cb_index[6] |= ((*bitstreamPtr)>>9)&0x7E; /* Bit 0..5 */ - enc_bits->cb_index[9] = ((*bitstreamPtr)>>2)&0xFE; /* Bit 6..12 */ - enc_bits->cb_index[12] = ((*bitstreamPtr)<<5)&0xE0; /* Bit 13..15 */ - bitstreamPtr++; - /* 10:th WebRtc_Word16 */ - enc_bits->cb_index[12] |= ((*bitstreamPtr)>>11)&0x1E;/* Bit 0..3 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>8)&0xC; /* Bit 4..5 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)>>7)&0x6; /* Bit 6..7 */ - enc_bits->gain_index[6] = ((*bitstreamPtr)>>3)&0x18; /* Bit 8..9 */ - enc_bits->gain_index[7] = ((*bitstreamPtr)>>2)&0xC; /* Bit 10..11 */ - enc_bits->gain_index[9] = ((*bitstreamPtr)<<1)&0x10; /* Bit 12 */ - enc_bits->gain_index[10] = ((*bitstreamPtr)<<1)&0x8; /* Bit 13 */ - enc_bits->gain_index[12] = ((*bitstreamPtr)<<3)&0x10; /* Bit 14 */ - enc_bits->gain_index[13] = ((*bitstreamPtr)<<3)&0x8; /* Bit 15 */ - } - bitstreamPtr++; - /* Class 3 bits of ULP */ - /* 8:th to 14:th WebRtc_Word16 for 20 ms case - 11:th to 17:th WebRtc_Word16 for 30 ms case */ - tmpPtr=enc_bits->idxVec; - for (k=0; k<7; k++) { - for (i=14; i>=0; i-=2) { - (*tmpPtr) |= ((*bitstreamPtr)>>i)&0x3; /* Bit 15-i..14-i*/ - tmpPtr++; - } - bitstreamPtr++; - } - - if (mode==20) { - /* 15:th WebRtc_Word16 */ - enc_bits->idxVec[56] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>13)&0x1; /* Bit 2 */ - enc_bits->cb_index[1] = ((*bitstreamPtr)>>6)&0x7F; /* Bit 3..9 */ - enc_bits->cb_index[2] = ((*bitstreamPtr)<<1)&0x7E; /* Bit 10..15 */ - bitstreamPtr++; - /* 16:th WebRtc_Word16 */ - enc_bits->cb_index[2] |= ((*bitstreamPtr)>>15)&0x1; /* Bit 0 */ - enc_bits->gain_index[0] |= ((*bitstreamPtr)>>12)&0x7; /* Bit 1..3 */ - enc_bits->gain_index[1] |= ((*bitstreamPtr)>>10)&0x3; /* Bit 4..5 */ - enc_bits->gain_index[2] = ((*bitstreamPtr)>>7)&0x7; /* Bit 6..8 */ - enc_bits->cb_index[3] |= ((*bitstreamPtr)>>6)&0x1; /* Bit 9 */ - enc_bits->cb_index[4] = ((*bitstreamPtr)<<1)&0x7E; /* Bit 10..15 */ - bitstreamPtr++; - /* 17:th WebRtc_Word16 */ - enc_bits->cb_index[4] |= ((*bitstreamPtr)>>15)&0x1; /* Bit 0 */ - enc_bits->cb_index[5] = ((*bitstreamPtr)>>8)&0x7F; /* Bit 1..7 */ - enc_bits->cb_index[6] = ((*bitstreamPtr))&0xFF; /* Bit 8..15 */ - bitstreamPtr++; - /* 18:th WebRtc_Word16 */ - enc_bits->cb_index[7] = (*bitstreamPtr)>>8; /* Bit 0..7 */ - enc_bits->cb_index[8] = (*bitstreamPtr)&0xFF; /* Bit 8..15 */ - bitstreamPtr++; - /* 19:th WebRtc_Word16 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)>>12)&0x3; /* Bit 2..3 */ - enc_bits->gain_index[5] = ((*bitstreamPtr)>>9)&0x7; /* Bit 4..6 */ - enc_bits->gain_index[6] |= ((*bitstreamPtr)>>6)&0x7; /* Bit 7..9 */ - enc_bits->gain_index[7] |= ((*bitstreamPtr)>>4)&0x3; /* Bit 10..11 */ - enc_bits->gain_index[8] = ((*bitstreamPtr)>>1)&0x7; /* Bit 12..14 */ - } else { /* mode==30 */ - /* 18:th WebRtc_Word16 */ - enc_bits->idxVec[56] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->idxVec[57] |= ((*bitstreamPtr)>>12)&0x3; /* Bit 2..3 */ - enc_bits->cb_index[0] |= ((*bitstreamPtr)>>11)&1; /* Bit 4 */ - enc_bits->cb_index[1] = ((*bitstreamPtr)>>4)&0x7F; /* Bit 5..11 */ - enc_bits->cb_index[2] = ((*bitstreamPtr)<<3)&0x78; /* Bit 12..15 */ - bitstreamPtr++; - /* 19:th WebRtc_Word16 */ - enc_bits->cb_index[2] |= ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->gain_index[0] |= ((*bitstreamPtr)>>10)&0x7; /* Bit 3..5 */ - enc_bits->gain_index[1] |= ((*bitstreamPtr)>>8)&0x3; /* Bit 6..7 */ - enc_bits->gain_index[2] = ((*bitstreamPtr)>>5)&0x7; /* Bit 8..10 */ - enc_bits->cb_index[3] |= ((*bitstreamPtr)>>4)&0x1; /* Bit 11 */ - enc_bits->cb_index[4] = ((*bitstreamPtr)<<3)&0x78; /* Bit 12..15 */ - bitstreamPtr++; - /* 20:th WebRtc_Word16 */ - enc_bits->cb_index[4] |= ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->cb_index[5] = ((*bitstreamPtr)>>6)&0x7F; /* Bit 3..9 */ - enc_bits->cb_index[6] |= ((*bitstreamPtr)>>5)&0x1; /* Bit 10 */ - enc_bits->cb_index[7] = ((*bitstreamPtr)<<3)&0xF8; /* Bit 11..15 */ - bitstreamPtr++; - /* 21:st WebRtc_Word16 */ - enc_bits->cb_index[7] |= ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->cb_index[8] = ((*bitstreamPtr)>>5)&0xFF; /* Bit 3..10 */ - enc_bits->cb_index[9] |= ((*bitstreamPtr)>>4)&0x1; /* Bit 11 */ - enc_bits->cb_index[10] = ((*bitstreamPtr)<<4)&0xF0; /* Bit 12..15 */ - bitstreamPtr++; - /* 22:nd WebRtc_Word16 */ - enc_bits->cb_index[10] |= ((*bitstreamPtr)>>12)&0xF; /* Bit 0..3 */ - enc_bits->cb_index[11] = ((*bitstreamPtr)>>4)&0xFF; /* Bit 4..11 */ - enc_bits->cb_index[12] |= ((*bitstreamPtr)>>3)&0x1; /* Bit 12 */ - enc_bits->cb_index[13] = ((*bitstreamPtr)<<5)&0xE0; /* Bit 13..15 */ - bitstreamPtr++; - /* 23:rd WebRtc_Word16 */ - enc_bits->cb_index[13] |= ((*bitstreamPtr)>>11)&0x1F;/* Bit 0..4 */ - enc_bits->cb_index[14] = ((*bitstreamPtr)>>3)&0xFF; /* Bit 5..12 */ - enc_bits->gain_index[3] |= ((*bitstreamPtr)>>1)&0x3; /* Bit 13..14 */ - enc_bits->gain_index[4] |= ((*bitstreamPtr)&0x1); /* Bit 15 */ - bitstreamPtr++; - /* 24:rd WebRtc_Word16 */ - enc_bits->gain_index[5] = ((*bitstreamPtr)>>13)&0x7; /* Bit 0..2 */ - enc_bits->gain_index[6] |= ((*bitstreamPtr)>>10)&0x7; /* Bit 3..5 */ - enc_bits->gain_index[7] |= ((*bitstreamPtr)>>8)&0x3; /* Bit 6..7 */ - enc_bits->gain_index[8] = ((*bitstreamPtr)>>5)&0x7; /* Bit 8..10 */ - enc_bits->gain_index[9] |= ((*bitstreamPtr)>>1)&0xF; /* Bit 11..14 */ - enc_bits->gain_index[10] |= ((*bitstreamPtr)<<2)&0x4; /* Bit 15 */ - bitstreamPtr++; - /* 25:rd WebRtc_Word16 */ - enc_bits->gain_index[10] |= ((*bitstreamPtr)>>14)&0x3; /* Bit 0..1 */ - enc_bits->gain_index[11] = ((*bitstreamPtr)>>11)&0x7; /* Bit 2..4 */ - enc_bits->gain_index[12] |= ((*bitstreamPtr)>>7)&0xF; /* Bit 5..8 */ - enc_bits->gain_index[13] |= ((*bitstreamPtr)>>4)&0x7; /* Bit 9..11 */ - enc_bits->gain_index[14] = ((*bitstreamPtr)>>1)&0x7; /* Bit 12..14 */ - } - /* Last bit should be zero, otherwise it's an "empty" frame */ - if (((*bitstreamPtr)&0x1) == 1) { - return(1); - } else { - return(0); - } -}
diff --git a/src/modules/audio_coding/codecs/ilbc/unpack_bits.h b/src/modules/audio_coding/codecs/ilbc/unpack_bits.h deleted file mode 100644 index 31c728e..0000000 --- a/src/modules/audio_coding/codecs/ilbc/unpack_bits.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_UnpackBits.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_UNPACK_BITS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_UNPACK_BITS_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * unpacking of bits from bitstream, i.e., vector of bytes - *---------------------------------------------------------------*/ - -WebRtc_Word16 WebRtcIlbcfix_UnpackBits( /* (o) "Empty" frame indicator */ - const WebRtc_UWord16 *bitstream, /* (i) The packatized bitstream */ - iLBC_bits *enc_bits, /* (o) Paramerers from bitstream */ - WebRtc_Word16 mode /* (i) Codec mode (20 or 30) */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/vq3.c b/src/modules/audio_coding/codecs/ilbc/vq3.c deleted file mode 100644 index 81d1bfa..0000000 --- a/src/modules/audio_coding/codecs/ilbc/vq3.c +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq3.c - -******************************************************************/ - -#include "vq3.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq3( - WebRtc_Word16 *Xq, /* quantized vector (Q13) */ - WebRtc_Word16 *index, - WebRtc_Word16 *CB, /* codebook in Q13 */ - WebRtc_Word16 *X, /* vector to quantize (Q13) */ - WebRtc_Word16 n_cb - ){ - WebRtc_Word16 i, j; - WebRtc_Word16 pos, minindex=0; - WebRtc_Word16 tmp; - WebRtc_Word32 dist, mindist; - - pos = 0; - mindist = WEBRTC_SPL_WORD32_MAX; /* start value */ - - /* Find the codebook with the lowest square distance */ - for (j = 0; j < n_cb; j++) { - tmp = X[0] - CB[pos]; - dist = WEBRTC_SPL_MUL_16_16(tmp, tmp); - for (i = 1; i < 3; i++) { - tmp = X[i] - CB[pos + i]; - dist += WEBRTC_SPL_MUL_16_16(tmp, tmp); - } - - if (dist < mindist) { - mindist = dist; - minindex = j; - } - pos += 3; - } - - /* Store the quantized codebook and the index */ - for (i = 0; i < 3; i++) { - Xq[i] = CB[minindex*3 + i]; - } - *index = minindex; - -}
diff --git a/src/modules/audio_coding/codecs/ilbc/vq3.h b/src/modules/audio_coding/codecs/ilbc/vq3.h deleted file mode 100644 index f2628e0..0000000 --- a/src/modules/audio_coding/codecs/ilbc/vq3.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq3.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ3_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ3_H_ - -#include "typedefs.h" - -/*----------------------------------------------------------------* - * Vector quantization of order 3 (based on MSE) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq3( - WebRtc_Word16 *Xq, /* (o) the quantized vector (Q13) */ - WebRtc_Word16 *index, /* (o) the quantization index */ - WebRtc_Word16 *CB, /* (i) the vector quantization codebook (Q13) */ - WebRtc_Word16 *X, /* (i) the vector to quantize (Q13) */ - WebRtc_Word16 n_cb /* (i) the number of vectors in the codebook */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/vq4.c b/src/modules/audio_coding/codecs/ilbc/vq4.c deleted file mode 100644 index 3d4c26d..0000000 --- a/src/modules/audio_coding/codecs/ilbc/vq4.c +++ /dev/null
@@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq4.c - -******************************************************************/ - -#include "vq4.h" -#include "constants.h" - -/*----------------------------------------------------------------* - * vector quantization - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq4( - WebRtc_Word16 *Xq, /* quantized vector (Q13) */ - WebRtc_Word16 *index, - WebRtc_Word16 *CB, /* codebook in Q13 */ - WebRtc_Word16 *X, /* vector to quantize (Q13) */ - WebRtc_Word16 n_cb - ){ - WebRtc_Word16 i, j; - WebRtc_Word16 pos, minindex=0; - WebRtc_Word16 tmp; - WebRtc_Word32 dist, mindist; - - pos = 0; - mindist = WEBRTC_SPL_WORD32_MAX; /* start value */ - - /* Find the codebook with the lowest square distance */ - for (j = 0; j < n_cb; j++) { - tmp = X[0] - CB[pos]; - dist = WEBRTC_SPL_MUL_16_16(tmp, tmp); - for (i = 1; i < 4; i++) { - tmp = X[i] - CB[pos + i]; - dist += WEBRTC_SPL_MUL_16_16(tmp, tmp); - } - - if (dist < mindist) { - mindist = dist; - minindex = j; - } - pos += 4; - } - - /* Store the quantized codebook and the index */ - for (i = 0; i < 4; i++) { - Xq[i] = CB[minindex*4 + i]; - } - *index = minindex; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/vq4.h b/src/modules/audio_coding/codecs/ilbc/vq4.h deleted file mode 100644 index 1b8cff2..0000000 --- a/src/modules/audio_coding/codecs/ilbc/vq4.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Vq4.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ4_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_VQ4_H_ - -#include "typedefs.h" - -/*----------------------------------------------------------------* - * Vector quantization of order 4 (based on MSE) - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Vq4( - WebRtc_Word16 *Xq, /* (o) the quantized vector (Q13) */ - WebRtc_Word16 *index, /* (o) the quantization index */ - WebRtc_Word16 *CB, /* (i) the vector quantization codebook (Q13) */ - WebRtc_Word16 *X, /* (i) the vector to quantize (Q13) */ - WebRtc_Word16 n_cb /* (i) the number of vectors in the codebook */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/window32_w32.c b/src/modules/audio_coding/codecs/ilbc/window32_w32.c deleted file mode 100644 index b0e8406..0000000 --- a/src/modules/audio_coding/codecs/ilbc/window32_w32.c +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Window32W32.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * window multiplication - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Window32W32( - WebRtc_Word32 *z, /* Output */ - WebRtc_Word32 *x, /* Input (same domain as Output)*/ - const WebRtc_Word32 *y, /* Q31 Window */ - WebRtc_Word16 N /* length to process */ - ) { - WebRtc_Word16 i; - WebRtc_Word16 x_low, x_hi, y_low, y_hi; - WebRtc_Word16 left_shifts; - WebRtc_Word32 temp; - - left_shifts = (WebRtc_Word16)WebRtcSpl_NormW32(x[0]); - WebRtcSpl_VectorBitShiftW32(x, N, x, (WebRtc_Word16)(-left_shifts)); - - - /* The double precision numbers use a special representation: - * w32 = hi<<16 + lo<<1 - */ - for (i = 0; i < N; i++) { - /* Extract higher bytes */ - x_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(x[i], 16); - y_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(y[i], 16); - - /* Extract lower bytes, defined as (w32 - hi<<16)>>1 */ - temp = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)x_hi, 16); - x_low = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32((x[i] - temp), 1); - - temp = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)y_hi, 16); - y_low = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32((y[i] - temp), 1); - - /* Calculate z by a 32 bit multiplication using both low and high from x and y */ - temp = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(x_hi, y_hi), 1); - temp = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_hi, y_low, 14))); - - z[i] = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_low, y_hi, 14))); - } - - WebRtcSpl_VectorBitShiftW32(z, N, z, left_shifts); - - return; -}
diff --git a/src/modules/audio_coding/codecs/ilbc/window32_w32.h b/src/modules/audio_coding/codecs/ilbc/window32_w32.h deleted file mode 100644 index 121188a..0000000 --- a/src/modules/audio_coding/codecs/ilbc/window32_w32.h +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_Window32W32.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_WINDOW32_W32_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_WINDOW32_W32_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * window multiplication - *---------------------------------------------------------------*/ - -void WebRtcIlbcfix_Window32W32( - WebRtc_Word32 *z, /* Output */ - WebRtc_Word32 *x, /* Input (same domain as Output)*/ - const WebRtc_Word32 *y, /* Q31 Window */ - WebRtc_Word16 N /* length to process */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/ilbc/xcorr_coef.c b/src/modules/audio_coding/codecs/ilbc/xcorr_coef.c deleted file mode 100644 index 04170ad..0000000 --- a/src/modules/audio_coding/codecs/ilbc/xcorr_coef.c +++ /dev/null
@@ -1,142 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_XcorrCoef.c - -******************************************************************/ - -#include "defines.h" - -/*----------------------------------------------------------------* - * cross correlation which finds the optimal lag for the - * crossCorr*crossCorr/(energy) criteria - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_XcorrCoef( - WebRtc_Word16 *target, /* (i) first array */ - WebRtc_Word16 *regressor, /* (i) second array */ - WebRtc_Word16 subl, /* (i) dimension arrays */ - WebRtc_Word16 searchLen, /* (i) the search lenght */ - WebRtc_Word16 offset, /* (i) samples offset between arrays */ - WebRtc_Word16 step /* (i) +1 or -1 */ - ){ - int k; - WebRtc_Word16 maxlag; - WebRtc_Word16 pos; - WebRtc_Word16 max; - WebRtc_Word16 crossCorrScale, Energyscale; - WebRtc_Word16 crossCorrSqMod, crossCorrSqMod_Max; - WebRtc_Word32 crossCorr, Energy; - WebRtc_Word16 crossCorrmod, EnergyMod, EnergyMod_Max; - WebRtc_Word16 *tp, *rp; - WebRtc_Word16 *rp_beg, *rp_end; - WebRtc_Word16 totscale, totscale_max; - WebRtc_Word16 scalediff; - WebRtc_Word32 newCrit, maxCrit; - int shifts; - - /* Initializations, to make sure that the first one is selected */ - crossCorrSqMod_Max=0; - EnergyMod_Max=WEBRTC_SPL_WORD16_MAX; - totscale_max=-500; - maxlag=0; - pos=0; - - /* Find scale value and start position */ - if (step==1) { - max=WebRtcSpl_MaxAbsValueW16(regressor, (WebRtc_Word16)(subl+searchLen-1)); - rp_beg = regressor; - rp_end = ®ressor[subl]; - } else { /* step==-1 */ - max=WebRtcSpl_MaxAbsValueW16(®ressor[-searchLen], (WebRtc_Word16)(subl+searchLen-1)); - rp_beg = ®ressor[-1]; - rp_end = ®ressor[subl-1]; - } - - /* Introduce a scale factor on the Energy in WebRtc_Word32 in - order to make sure that the calculation does not - overflow */ - - if (max>5000) { - shifts=2; - } else { - shifts=0; - } - - /* Calculate the first energy, then do a +/- to get the other energies */ - Energy=WebRtcSpl_DotProductWithScale(regressor, regressor, subl, shifts); - - for (k=0;k<searchLen;k++) { - tp = target; - rp = ®ressor[pos]; - - crossCorr=WebRtcSpl_DotProductWithScale(tp, rp, subl, shifts); - - if ((Energy>0)&&(crossCorr>0)) { - - /* Put cross correlation and energy on 16 bit word */ - crossCorrScale=(WebRtc_Word16)WebRtcSpl_NormW32(crossCorr)-16; - crossCorrmod=(WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(crossCorr, crossCorrScale); - Energyscale=(WebRtc_Word16)WebRtcSpl_NormW32(Energy)-16; - EnergyMod=(WebRtc_Word16)WEBRTC_SPL_SHIFT_W32(Energy, Energyscale); - - /* Square cross correlation and store upper WebRtc_Word16 */ - crossCorrSqMod=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(crossCorrmod, crossCorrmod, 16); - - /* Calculate the total number of (dynamic) right shifts that have - been performed on (crossCorr*crossCorr)/energy - */ - totscale=Energyscale-(crossCorrScale<<1); - - /* Calculate the shift difference in order to be able to compare the two - (crossCorr*crossCorr)/energy in the same domain - */ - scalediff=totscale-totscale_max; - scalediff=WEBRTC_SPL_MIN(scalediff,31); - scalediff=WEBRTC_SPL_MAX(scalediff,-31); - - /* Compute the cross multiplication between the old best criteria - and the new one to be able to compare them without using a - division */ - - if (scalediff<0) { - newCrit = ((WebRtc_Word32)crossCorrSqMod*EnergyMod_Max)>>(-scalediff); - maxCrit = ((WebRtc_Word32)crossCorrSqMod_Max*EnergyMod); - } else { - newCrit = ((WebRtc_Word32)crossCorrSqMod*EnergyMod_Max); - maxCrit = ((WebRtc_Word32)crossCorrSqMod_Max*EnergyMod)>>scalediff; - } - - /* Store the new lag value if the new criteria is larger - than previous largest criteria */ - - if (newCrit > maxCrit) { - crossCorrSqMod_Max = crossCorrSqMod; - EnergyMod_Max = EnergyMod; - totscale_max = totscale; - maxlag = k; - } - } - pos+=step; - - /* Do a +/- to get the next energy */ - Energy += step*(WEBRTC_SPL_RSHIFT_W32( - ((WebRtc_Word32)(*rp_end)*(*rp_end)) - ((WebRtc_Word32)(*rp_beg)*(*rp_beg)), - shifts)); - rp_beg+=step; - rp_end+=step; - } - - return(maxlag+offset); -}
diff --git a/src/modules/audio_coding/codecs/ilbc/xcorr_coef.h b/src/modules/audio_coding/codecs/ilbc/xcorr_coef.h deleted file mode 100644 index ac885c4..0000000 --- a/src/modules/audio_coding/codecs/ilbc/xcorr_coef.h +++ /dev/null
@@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - - iLBC Speech Coder ANSI-C Source Code - - WebRtcIlbcfix_XcorrCoef.h - -******************************************************************/ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_XCORR_COEF_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_MAIN_SOURCE_XCORR_COEF_H_ - -#include "defines.h" - -/*----------------------------------------------------------------* - * cross correlation which finds the optimal lag for the - * crossCorr*crossCorr/(energy) criteria - *---------------------------------------------------------------*/ - -int WebRtcIlbcfix_XcorrCoef( - WebRtc_Word16 *target, /* (i) first array */ - WebRtc_Word16 *regressor, /* (i) second array */ - WebRtc_Word16 subl, /* (i) dimension arrays */ - WebRtc_Word16 searchLen, /* (i) the search lenght */ - WebRtc_Word16 offset, /* (i) samples offset between arrays */ - WebRtc_Word16 step /* (i) +1 or -1 */ - ); - -#endif
diff --git a/src/modules/audio_coding/codecs/isac/fix/interface/isacfix.h b/src/modules/audio_coding/codecs/isac/fix/interface/isacfix.h deleted file mode 100644 index 28e9429..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/interface/isacfix.h +++ /dev/null
@@ -1,633 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INTERFACE_ISACFIX_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INTERFACE_ISACFIX_H_ - -/* - * Define the fixpoint numeric formats - */ -#include "typedefs.h" - - -typedef struct { - void *dummy; -} ISACFIX_MainStruct; - - -#if defined(__cplusplus) -extern "C" { -#endif - - - /************************************************************************** - * WebRtcIsacfix_AssignSize(...) - * - * Functions used when malloc is not allowed - * Output the number of bytes needed to allocate for iSAC struct. - * - */ - - WebRtc_Word16 WebRtcIsacfix_AssignSize(int *sizeinbytes); - - /************************************************************************** - * WebRtcIsacfix_Assign(...) - * - * Functions used when malloc is not allowed, it - * places a struct at the given address. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - ISACFIX_inst_Addr : address of the memory where a space is - * for iSAC structure. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_Assign(ISACFIX_MainStruct **inst, - void *ISACFIX_inst_Addr); - - /**************************************************************************** - * WebRtcIsacfix_Create(...) - * - * This function creates an ISAC instance, which will contain the state - * information for one coding/decoding channel. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_Create(ISACFIX_MainStruct **ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_Free(...) - * - * This function frees the ISAC instance created at the beginning. - * - * Input: - * - ISAC_main_inst : a ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_Free(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_EncoderInit(...) - * - * This function initializes an ISAC instance prior to the encoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - CodingMode : 0 - Bit rate and frame length are automatically - * adjusted to available bandwidth on - * transmission channel. - * 1 - User sets a frame length and a target bit - * rate which is taken as the maximum short-term - * average bit rate. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 CodingMode); - - - /**************************************************************************** - * WebRtcIsacfix_Encode(...) - * - * This function encodes 10ms frame(s) and inserts it into a package. - * Input speech length has to be 160 samples (10ms). The encoder buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_Word16 *speechIn, - WebRtc_Word16 *encoded); - - - - /**************************************************************************** - * WebRtcIsacfix_EncodeNb(...) - * - * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts - * it into a package. Input speech length has to be 80 samples (10ms). The encoder - * interpolates into wide-band (16 kHz sampling) buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 wide-band samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * -1 - Error - */ - - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtc_Word16 WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_Word16 *speechIn, - WebRtc_Word16 *encoded); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - - - - /**************************************************************************** - * WebRtcIsacfix_DecoderInit(...) - * - * This function initializes an ISAC instance prior to the decoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - * Return value - * : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_UpdateBwEstimate1(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 arr_ts); - - /**************************************************************************** - * WebRtcIsacfix_UpdateBwEstimate(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - send_ts : the send time of the packet from RTP header, - * in samples. - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts); - - /**************************************************************************** - * WebRtcIsacfix_Decode(...) - * - * This function decodes an ISAC frame. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the framesize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); - - - /**************************************************************************** - * WebRtcIsacfix_DecodeNb(...) - * - * This function decodes a ISAC frame in narrow-band (8 kHz sampling). - * Output speech length will be a multiple of 240 samples: 240 or 480 samples, - * depending on the framesize (30 or 60 ms). - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtc_Word16 WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - - - /**************************************************************************** - * WebRtcIsacfix_DecodePlcNb(...) - * - * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). - * Output speech length will be "240*noOfLostFrames" samples - * that equevalent of "30*noOfLostFrames" millisecond. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce - * NOTE! Maximum number is 2 (480 samples = 60ms) - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtc_Word16 WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 *decoded, - WebRtc_Word16 noOfLostFrames ); -#endif // WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - - - - - /**************************************************************************** - * WebRtcIsacfix_DecodePlc(...) - * - * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling). - * Output speech length will be "480*noOfLostFrames" samples - * that is equevalent of "30*noOfLostFrames" millisecond. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (480sample = 30ms) - * to produce - * NOTE! Maximum number is 2 (960 samples = 60ms) - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 *decoded, - WebRtc_Word16 noOfLostFrames ); - - - /**************************************************************************** - * WebRtcIsacfix_ReadFrameLen(...) - * - * This function returns the length of the frame represented in the packet. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - */ - - WebRtc_Word16 WebRtcIsacfix_ReadFrameLen(const WebRtc_Word16* encoded, - WebRtc_Word16* frameLength); - - /**************************************************************************** - * WebRtcIsacfix_Control(...) - * - * This function sets the limit on the short-term average bit rate and the - * frame length. Should be used only in Instantaneous mode. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rate : limit on the short-term average bit rate, - * in bits/second (between 10000 and 32000) - * - framesize : number of milliseconds per frame (30 or 60) - * - * Return value : 0 - ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 rate, - WebRtc_Word16 framesize); - - - - /**************************************************************************** - * WebRtcIsacfix_ControlBwe(...) - * - * This function sets the initial values of bottleneck and frame-size if - * iSAC is used in channel-adaptive mode. Through this API, users can - * enforce a frame-size for all values of bottleneck. Then iSAC will not - * automatically change the frame-size. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rateBPS : initial value of bottleneck in bits/second - * 10000 <= rateBPS <= 32000 is accepted - * - frameSizeMs : number of milliseconds per frame (30 or 60) - * - enforceFrameSize : 1 to enforce the given frame-size through out - * the adaptation process, 0 to let iSAC change - * the frame-size if required. - * - * Return value : 0 - ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 rateBPS, - WebRtc_Word16 frameSizeMs, - WebRtc_Word16 enforceFrameSize); - - - - /**************************************************************************** - * WebRtcIsacfix_version(...) - * - * This function returns the version number. - * - * Output: - * - version : Pointer to character string - * - */ - - void WebRtcIsacfix_version(char *version); - - - /**************************************************************************** - * WebRtcIsacfix_GetErrorCode(...) - * - * This function can be used to check the error code of an iSAC instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occured in the - * specified instance. - * - * Input: - * - ISAC_main_inst : ISAC instance - * - * Return value : Error code - */ - - WebRtc_Word16 WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_GetUplinkBw(...) - * - * This function return iSAC send bitrate - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : <0 Error code - * else bitrate - */ - - WebRtc_Word32 WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_SetMaxPayloadSize(...) - * - * This function sets a limit for the maximum payload size of iSAC. The same - * value is used both for 30 and 60 msec packets. - * The absolute max will be valid until next time the function is called. - * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate() - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxPayloadBytes : maximum size of the payload in bytes - * valid values are between 100 and 400 bytes - * - * - * Return value : 0 if sucessful - * -1 if error happens - */ - - WebRtc_Word16 WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 maxPayloadBytes); - - - /**************************************************************************** - * WebRtcIsacfix_SetMaxRate(...) - * - * This function sets the maximum rate which the codec may not exceed for a - * singel packet. The maximum rate is set in bits per second. - * The codec has an absolute maximum rate of 53400 bits per second (200 bytes - * per 30 msec). - * It is possible to set a maximum rate between 32000 and 53400 bits per second. - * - * The rate limit is valid until next time the function is called. - * - * NOTE! Packet size will never go above the value set if calling - * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxRateInBytes : maximum rate in bits per second, - * valid values are 32000 to 53400 bits - * - * Return value : 0 if sucessful - * -1 if error happens - */ - - WebRtc_Word16 WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word32 maxRate); - - /**************************************************************************** - * WebRtcIsacfix_CreateInternal(...) - * - * This function creates the memory that is used to store data in the encoder - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_FreeInternal(...) - * - * This function frees the internal memory for storing encoder data. - * - * Input: - * - ISAC_main_inst : an ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct *ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsacfix_GetNewBitStream(...) - * - * This function returns encoded data, with the recieved bwe-index in the - * stream. It should always return a complete packet, i.e. only called once - * even for 60 msec frames - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - bweIndex : index of bandwidth estimate to put in new bitstream - * - scale : factor for rate change (0.4 ~=> half the rate, 1 no change). - * - * Output: - * - encoded : the encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 bweIndex, - float scale, - WebRtc_Word16 *encoded); - - - /**************************************************************************** - * WebRtcIsacfix_GetDownLinkBwIndex(...) - * - * This function returns index representing the Bandwidth estimate from - * other side to this side. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - rateIndex : Bandwidth estimate to transmit to other side. - * - */ - - WebRtc_Word16 WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst, - WebRtc_Word16* rateIndex); - - - /**************************************************************************** - * WebRtcIsacfix_UpdateUplinkBw(...) - * - * This function takes an index representing the Bandwidth estimate from - * this side to other side and updates BWE. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - rateIndex : Bandwidth estimate from other side. - * - */ - - WebRtc_Word16 WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst, - WebRtc_Word16 rateIndex); - - - /**************************************************************************** - * WebRtcIsacfix_ReadBwIndex(...) - * - * This function returns the index of the Bandwidth estimate from the bitstream. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - rateIndex : Bandwidth estimate in bitstream - * - */ - - WebRtc_Word16 WebRtcIsacfix_ReadBwIndex(const WebRtc_Word16* encoded, - WebRtc_Word16* rateIndex); - - - /**************************************************************************** - * WebRtcIsacfix_GetNewFrameLen(...) - * - * This function return the next frame length (in samples) of iSAC. - * - * Input: - * -ISAC_main_inst : iSAC instance - * - * Return value : frame lenght in samples - */ - - WebRtc_Word16 WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct *ISAC_main_inst); - - -#if defined(__cplusplus) -} -#endif - - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_INTERFACE_ISACFIX_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/Android.mk b/src/modules/audio_coding/codecs/isac/fix/source/Android.mk deleted file mode 100644 index 0138888..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/Android.mk +++ /dev/null
@@ -1,124 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -############################# -# Build the non-neon library. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -include $(LOCAL_PATH)/../../../../../../../android-webrtc.mk - -LOCAL_ARM_MODE := arm -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libwebrtc_isacfix -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := \ - arith_routines.c \ - arith_routines_hist.c \ - arith_routines_logist.c \ - bandwidth_estimator.c \ - decode.c \ - decode_bwe.c \ - decode_plc.c \ - encode.c \ - entropy_coding.c \ - fft.c \ - filterbank_tables.c \ - filterbanks.c \ - filters.c \ - initialize.c \ - isacfix.c \ - lattice.c \ - lpc_masking_model.c \ - lpc_tables.c \ - pitch_estimator.c \ - pitch_filter.c \ - pitch_gain_tables.c \ - pitch_lag_tables.c \ - spectrum_ar_model_tables.c \ - transform.c - -# Using .S (instead of .s) extention is to include a C header file in assembly. -my_as_src := \ - lattice_armv7.S \ - pitch_filter_armv6.S -my_c_src := \ - lattice_c.c \ - pitch_filter_c.c -LOCAL_SRC_FILES_arm += $(my_as_src) -LOCAL_SRC_FILES_x86 += $(my_c_src) -LOCAL_SRC_FILES_mips += $(my_c_src) -LOCAL_SRC_FILES_arm64 += $(my_c_src) -LOCAL_SRC_FILES_x86_64 += $(my_c_src) -LOCAL_SRC_FILES_mips64 += $(my_c_src) - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := \ - $(MY_WEBRTC_COMMON_DEFS) - -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) -LOCAL_CFLAGS_x86 := $(MY_WEBRTC_COMMON_DEFS_x86) -LOCAL_CFLAGS_mips := $(MY_WEBRTC_COMMON_DEFS_mips) -LOCAL_CFLAGS_arm64 := $(MY_WEBRTC_COMMON_DEFS_arm64) -LOCAL_CFLAGS_x86_64 := $(MY_WEBRTC_COMMON_DEFS_x86_64) -LOCAL_CFLAGS_mips64 := $(MY_WEBRTC_COMMON_DEFS_mips64) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../interface \ - $(LOCAL_PATH)/../../../../../.. \ - $(LOCAL_PATH)/../../../../../../common_audio/signal_processing/include - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -endif - -include $(BUILD_STATIC_LIBRARY) - -######################### -# Build the neon library. -ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) - -include $(CLEAR_VARS) - -LOCAL_ARM_MODE := arm -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libwebrtc_isacfix_neon -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := \ - filters_neon.c \ - lattice_neon.S \ - lpc_masking_model_neon.S - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := \ - $(MY_WEBRTC_COMMON_DEFS) \ - -mfpu=neon \ - -mfloat-abi=softfp \ - -flax-vector-conversions - -LOCAL_MODULE_TARGET_ARCH := arm -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../interface \ - $(LOCAL_PATH)/../../../../../.. \ - $(LOCAL_PATH)/../../../../../../common_audio/signal_processing/include - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -endif - -include $(BUILD_STATIC_LIBRARY) - -endif # ifeq ($(WEBRTC_BUILD_NEON_LIBS),true)
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/arith_routines.c b/src/modules/audio_coding/codecs/isac/fix/source/arith_routines.c deleted file mode 100644 index ee62bad..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/arith_routines.c +++ /dev/null
@@ -1,124 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * arith_routins.c - * - * This C file contains a function for finalizing the bitstream - * after arithmetic coding. - * - */ - -#include "arith_routins.h" - - -/**************************************************************************** - * WebRtcIsacfix_EncTerminate(...) - * - * Final call to the arithmetic coder for an encoder call. This function - * terminates and return byte stream. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - * Return value : number of bytes in the stream - */ -WebRtc_Word16 WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData) -{ - WebRtc_UWord16 *streamPtr; - WebRtc_UWord16 negCarry; - - /* point to the right place in the stream buffer */ - streamPtr = streamData->stream + streamData->stream_index; - - /* find minimum length (determined by current interval width) */ - if ( streamData->W_upper > 0x01FFFFFF ) - { - streamData->streamval += 0x01000000; - - /* if result is less than the added value we must take care of the carry */ - if (streamData->streamval < 0x01000000) - { - /* propagate carry */ - if (streamData->full == 0) { - /* Add value to current value */ - negCarry = *streamPtr; - negCarry += 0x0100; - *streamPtr = negCarry; - - /* if value is too big, propagate carry to next byte, and so on */ - while (!(negCarry)) - { - negCarry = *--streamPtr; - negCarry++; - *streamPtr = negCarry; - } - } else { - /* propagate carry by adding one to the previous byte in the - * stream if that byte is 0xFFFF we need to propagate the carry - * furhter back in the stream */ - while ( !(++(*--streamPtr)) ); - } - - /* put pointer back to the old value */ - streamPtr = streamData->stream + streamData->stream_index; - } - /* write remaining data to bitstream, if "full == 0" first byte has data */ - if (streamData->full == 0) { - *streamPtr++ += (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24); - streamData->full = 1; - } else { - *streamPtr = (WebRtc_UWord16) WEBRTC_SPL_LSHIFT_W32( - WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24), 8); - streamData->full = 0; - } - } - else - { - streamData->streamval += 0x00010000; - - /* if result is less than the added value we must take care of the carry */ - if (streamData->streamval < 0x00010000) - { - /* propagate carry */ - if (streamData->full == 0) { - /* Add value to current value */ - negCarry = *streamPtr; - negCarry += 0x0100; - *streamPtr = negCarry; - - /* if value to big, propagate carry to next byte, and so on */ - while (!(negCarry)) - { - negCarry = *--streamPtr; - negCarry++; - *streamPtr = negCarry; - } - } else { - /* Add carry to previous byte */ - while ( !(++(*--streamPtr)) ); - } - - /* put pointer back to the old value */ - streamPtr = streamData->stream + streamData->stream_index; - } - /* write remaining data (2 bytes) to bitstream */ - if (streamData->full) { - *streamPtr++ = (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 16); - } else { - *streamPtr++ |= (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24); - *streamPtr = (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 8) - & 0xFF00; - } - } - - /* calculate stream length in bytes */ - return (((streamPtr - streamData->stream)<<1) + !(streamData->full)); -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c b/src/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c deleted file mode 100644 index 14f1add..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c +++ /dev/null
@@ -1,404 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * arith_routinshist.c - * - * This C file contains arithmetic encoding and decoding. - * - */ - -#include "arith_routins.h" - - -/**************************************************************************** - * WebRtcIsacfix_EncHistMulti(...) - * - * Encode the histogram interval - * - * Input: - * - streamData : in-/output struct containing bitstream - * - data : data vector - * - cdf : array of cdf arrays - * - lenData : data vector length - * - * Return value : 0 if ok - * <0 if error detected - */ -int WebRtcIsacfix_EncHistMulti(Bitstr_enc *streamData, - const WebRtc_Word16 *data, - const WebRtc_UWord16 **cdf, - const WebRtc_Word16 lenData) -{ - WebRtc_UWord32 W_lower; - WebRtc_UWord32 W_upper; - WebRtc_UWord32 W_upper_LSB; - WebRtc_UWord32 W_upper_MSB; - WebRtc_UWord16 *streamPtr; - WebRtc_UWord16 negCarry; - WebRtc_UWord16 *maxStreamPtr; - WebRtc_UWord16 *streamPtrCarry; - WebRtc_UWord32 cdfLo; - WebRtc_UWord32 cdfHi; - int k; - - - /* point to beginning of stream buffer - * and set maximum streamPtr value */ - streamPtr = streamData->stream + streamData->stream_index; - maxStreamPtr = streamData->stream + STREAM_MAXW16_60MS - 1; - - W_upper = streamData->W_upper; - - for (k = lenData; k > 0; k--) - { - /* fetch cdf_lower and cdf_upper from cdf tables */ - cdfLo = (WebRtc_UWord32) *(*cdf + (WebRtc_UWord32)*data); - cdfHi = (WebRtc_UWord32) *(*cdf++ + (WebRtc_UWord32)*data++ + 1); - - /* update interval */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = WEBRTC_SPL_RSHIFT_W32(W_upper, 16); - W_lower = WEBRTC_SPL_UMUL(W_upper_MSB, cdfLo); - W_lower += WEBRTC_SPL_UMUL_RSFT16(W_upper_LSB, cdfLo); - W_upper = WEBRTC_SPL_UMUL(W_upper_MSB, cdfHi); - W_upper += WEBRTC_SPL_UMUL_RSFT16(W_upper_LSB, cdfHi); - - /* shift interval such that it begins at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamData->streamval += W_lower; - - /* handle carry */ - if (streamData->streamval < W_lower) - { - /* propagate carry */ - streamPtrCarry = streamPtr; - if (streamData->full == 0) { - negCarry = *streamPtrCarry; - negCarry += 0x0100; - *streamPtrCarry = negCarry; - while (!(negCarry)) - { - negCarry = *--streamPtrCarry; - negCarry++; - *streamPtrCarry = negCarry; - } - } else { - while ( !(++(*--streamPtrCarry)) ); - } - } - - /* renormalize interval, store most significant byte of streamval and update streamval - * W_upper < 2^24 */ - while ( !(W_upper & 0xFF000000) ) - { - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); - if (streamData->full == 0) { - *streamPtr++ += (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24); - streamData->full = 1; - } else { - *streamPtr = (WebRtc_UWord16) WEBRTC_SPL_LSHIFT_W32( - WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24), 8); - streamData->full = 0; - } - - if( streamPtr > maxStreamPtr ) { - return -ISAC_DISALLOWED_BITSTREAM_LENGTH; - } - streamData->streamval = WEBRTC_SPL_LSHIFT_W32(streamData->streamval, 8); - } - } - - /* calculate new stream_index */ - streamData->stream_index = streamPtr - streamData->stream; - streamData->W_upper = W_upper; - - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_DecHistBisectMulti(...) - * - * Function to decode more symbols from the arithmetic bytestream, using - * method of bisection cdf tables should be of size 2^k-1 (which corresponds - * to an alphabet size of 2^k-2) - * - * Input: - * - streamData : in-/output struct containing bitstream - * - cdf : array of cdf arrays - * - cdfSize : array of cdf table sizes+1 (power of two: 2^k) - * - lenData : data vector length - * - * Output: - * - data : data vector - * - * Return value : number of bytes in the stream - * <0 if error detected - */ -WebRtc_Word16 WebRtcIsacfix_DecHistBisectMulti(WebRtc_Word16 *data, - Bitstr_dec *streamData, - const WebRtc_UWord16 **cdf, - const WebRtc_UWord16 *cdfSize, - const WebRtc_Word16 lenData) -{ - WebRtc_UWord32 W_lower = 0; - WebRtc_UWord32 W_upper; - WebRtc_UWord32 W_tmp; - WebRtc_UWord32 W_upper_LSB; - WebRtc_UWord32 W_upper_MSB; - WebRtc_UWord32 streamval; - const WebRtc_UWord16 *streamPtr; - const WebRtc_UWord16 *cdfPtr; - WebRtc_Word16 sizeTmp; - int k; - - - streamPtr = streamData->stream + streamData->stream_index; - W_upper = streamData->W_upper; - - /* Error check: should not be possible in normal operation */ - if (W_upper == 0) { - return -2; - } - - /* first time decoder is called for this stream */ - if (streamData->stream_index == 0) - { - /* read first word from bytestream */ - streamval = WEBRTC_SPL_LSHIFT_W32((WebRtc_UWord32)*streamPtr++, 16); - streamval |= *streamPtr++; - } else { - streamval = streamData->streamval; - } - - for (k = lenData; k > 0; k--) - { - /* find the integer *data for which streamval lies in [W_lower+1, W_upper] */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = WEBRTC_SPL_RSHIFT_W32(W_upper, 16); - - /* start halfway the cdf range */ - sizeTmp = WEBRTC_SPL_RSHIFT_W16(*cdfSize++, 1); - cdfPtr = *cdf + (sizeTmp - 1); - - /* method of bisection */ - for ( ;; ) - { - W_tmp = WEBRTC_SPL_UMUL_32_16(W_upper_MSB, *cdfPtr); - W_tmp += WEBRTC_SPL_UMUL_32_16_RSFT16(W_upper_LSB, *cdfPtr); - sizeTmp = WEBRTC_SPL_RSHIFT_W16(sizeTmp, 1); - if (sizeTmp == 0) { - break; - } - - if (streamval > W_tmp) - { - W_lower = W_tmp; - cdfPtr += sizeTmp; - } else { - W_upper = W_tmp; - cdfPtr -= sizeTmp; - } - } - if (streamval > W_tmp) - { - W_lower = W_tmp; - *data++ = cdfPtr - *cdf++; - } else { - W_upper = W_tmp; - *data++ = cdfPtr - *cdf++ - 1; - } - - /* shift interval to start at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamval -= W_lower; - - /* renormalize interval and update streamval */ - /* W_upper < 2^24 */ - while ( !(W_upper & 0xFF000000) ) - { - /* read next byte from stream */ - if (streamData->full == 0) { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | - (*streamPtr++ & 0x00FF); - streamData->full = 1; - } else { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | - WEBRTC_SPL_RSHIFT_W16(*streamPtr, 8); - streamData->full = 0; - } - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); - } - - - /* Error check: should not be possible in normal operation */ - if (W_upper == 0) { - return -2; - } - - } - - streamData->stream_index = streamPtr - streamData->stream; - streamData->W_upper = W_upper; - streamData->streamval = streamval; - - if ( W_upper > 0x01FFFFFF ) { - return (streamData->stream_index*2 - 3 + !streamData->full); - } else { - return (streamData->stream_index*2 - 2 + !streamData->full); - } -} - - -/**************************************************************************** - * WebRtcIsacfix_DecHistOneStepMulti(...) - * - * Function to decode more symbols from the arithmetic bytestream, taking - * single step up or down at a time. - * cdf tables can be of arbitrary size, but large tables may take a lot of - * iterations. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - cdf : array of cdf arrays - * - initIndex : vector of initial cdf table search entries - * - lenData : data vector length - * - * Output: - * - data : data vector - * - * Return value : number of bytes in original stream - * <0 if error detected - */ -WebRtc_Word16 WebRtcIsacfix_DecHistOneStepMulti(WebRtc_Word16 *data, - Bitstr_dec *streamData, - const WebRtc_UWord16 **cdf, - const WebRtc_UWord16 *initIndex, - const WebRtc_Word16 lenData) -{ - WebRtc_UWord32 W_lower; - WebRtc_UWord32 W_upper; - WebRtc_UWord32 W_tmp; - WebRtc_UWord32 W_upper_LSB; - WebRtc_UWord32 W_upper_MSB; - WebRtc_UWord32 streamval; - const WebRtc_UWord16 *streamPtr; - const WebRtc_UWord16 *cdfPtr; - int k; - - - streamPtr = streamData->stream + streamData->stream_index; - W_upper = streamData->W_upper; - /* Error check: Should not be possible in normal operation */ - if (W_upper == 0) { - return -2; - } - - /* Check if it is the first time decoder is called for this stream */ - if (streamData->stream_index == 0) - { - /* read first word from bytestream */ - streamval = WEBRTC_SPL_LSHIFT_U32(*streamPtr++, 16); - streamval |= *streamPtr++; - } else { - streamval = streamData->streamval; - } - - for (k = lenData; k > 0; k--) - { - /* find the integer *data for which streamval lies in [W_lower+1, W_upper] */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = WEBRTC_SPL_RSHIFT_U32(W_upper, 16); - - /* start at the specified table entry */ - cdfPtr = *cdf + (*initIndex++); - W_tmp = WEBRTC_SPL_UMUL_32_16(W_upper_MSB, *cdfPtr); - W_tmp += WEBRTC_SPL_UMUL_32_16_RSFT16(W_upper_LSB, *cdfPtr); - - if (streamval > W_tmp) - { - for ( ;; ) - { - W_lower = W_tmp; - - /* range check */ - if (cdfPtr[0] == 65535) { - return -3; - } - - W_tmp = WEBRTC_SPL_UMUL_32_16(W_upper_MSB, *++cdfPtr); - W_tmp += WEBRTC_SPL_UMUL_32_16_RSFT16(W_upper_LSB, *cdfPtr); - - if (streamval <= W_tmp) { - break; - } - } - W_upper = W_tmp; - *data++ = cdfPtr - *cdf++ - 1; - } else { - for ( ;; ) - { - W_upper = W_tmp; - --cdfPtr; - - /* range check */ - if (cdfPtr < *cdf) { - return -3; - } - - W_tmp = WEBRTC_SPL_UMUL_32_16(W_upper_MSB, *cdfPtr); - W_tmp += WEBRTC_SPL_UMUL_32_16_RSFT16(W_upper_LSB, *cdfPtr); - - if (streamval > W_tmp) { - break; - } - } - W_lower = W_tmp; - *data++ = cdfPtr - *cdf++; - } - - /* shift interval to start at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamval -= W_lower; - - /* renormalize interval and update streamval */ - /* W_upper < 2^24 */ - while ( !(W_upper & 0xFF000000) ) - { - /* read next byte from stream */ - if (streamData->full == 0) { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | (*streamPtr++ & 0x00FF); - streamData->full = 1; - } else { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | (*streamPtr >> 8); - streamData->full = 0; - } - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); - } - } - - streamData->stream_index = streamPtr - streamData->stream; - streamData->W_upper = W_upper; - streamData->streamval = streamval; - - /* find number of bytes in original stream (determined by current interval width) */ - if ( W_upper > 0x01FFFFFF ) { - return (streamData->stream_index*2 - 3 + !streamData->full); - } else { - return (streamData->stream_index*2 - 2 + !streamData->full); - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c b/src/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c deleted file mode 100644 index 39c437e..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c +++ /dev/null
@@ -1,404 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * arith_routinslogist.c - * - * This C file contains arithmetic encode and decode logistic - * - */ - -#include "arith_routins.h" - - -/* Tables for piecewise linear cdf functions: y = k*x */ - -/* x Points for function piecewise() in Q15 */ -static const WebRtc_Word32 kHistEdges[51] = { - -327680, -314573, -301466, -288359, -275252, -262144, -249037, -235930, -222823, -209716, - -196608, -183501, -170394, -157287, -144180, -131072, -117965, -104858, -91751, -78644, - -65536, -52429, -39322, -26215, -13108, 0, 13107, 26214, 39321, 52428, - 65536, 78643, 91750, 104857, 117964, 131072, 144179, 157286, 170393, 183500, - 196608, 209715, 222822, 235929, 249036, 262144, 275251, 288358, 301465, 314572, - 327680 -}; - - -/* k Points for function piecewise() in Q0 */ -static const WebRtc_UWord16 kCdfSlope[51] = { - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 13, 23, 47, 87, 154, 315, 700, 1088, - 2471, 6064, 14221, 21463, 36634, 36924, 19750, 13270, 5806, 2312, - 1095, 660, 316, 145, 86, 41, 32, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, - 0 -}; - -/* y Points for function piecewise() in Q0 */ -static const WebRtc_UWord16 kCdfLogistic[51] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, - 20, 22, 24, 29, 38, 57, 92, 153, 279, 559, - 994, 1983, 4408, 10097, 18682, 33336, 48105, 56005, 61313, 63636, - 64560, 64998, 65262, 65389, 65447, 65481, 65497, 65510, 65512, 65514, - 65516, 65518, 65520, 65522, 65524, 65526, 65528, 65530, 65532, 65534, - 65535 -}; - - -/**************************************************************************** - * WebRtcIsacfix_Piecewise(...) - * - * Piecewise linear function - * - * Input: - * - xinQ15 : input value x in Q15 - * - * Return value : korresponding y-value in Q0 - */ - - -static __inline WebRtc_UWord16 WebRtcIsacfix_Piecewise(WebRtc_Word32 xinQ15) { - WebRtc_Word32 ind; - WebRtc_Word32 qtmp1; - WebRtc_UWord16 qtmp2; - - /* Find index for x-value */ - qtmp1 = WEBRTC_SPL_SAT(kHistEdges[50],xinQ15,kHistEdges[0]); - ind = WEBRTC_SPL_MUL(5, qtmp1 - kHistEdges[0]); - ind = WEBRTC_SPL_RSHIFT_W32(ind, 16); - - /* Calculate corresponding y-value ans return*/ - qtmp1 = qtmp1 - kHistEdges[ind]; - qtmp2 = (WebRtc_UWord16)WEBRTC_SPL_RSHIFT_U32( - WEBRTC_SPL_UMUL_32_16(qtmp1,kCdfSlope[ind]), 15); - return (kCdfLogistic[ind] + qtmp2); -} - -/**************************************************************************** - * WebRtcIsacfix_EncLogisticMulti2(...) - * - * Arithmetic coding of spectrum. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - dataQ7 : data vector in Q7 - * - envQ8 : side info vector defining the width of the pdf - * in Q8 - * - lenData : data vector length - * - * Return value : 0 if ok, - * <0 otherwise. - */ -int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc *streamData, - WebRtc_Word16 *dataQ7, - const WebRtc_UWord16 *envQ8, - const WebRtc_Word16 lenData) -{ - WebRtc_UWord32 W_lower; - WebRtc_UWord32 W_upper; - WebRtc_UWord16 W_upper_LSB; - WebRtc_UWord16 W_upper_MSB; - WebRtc_UWord16 *streamPtr; - WebRtc_UWord16 *maxStreamPtr; - WebRtc_UWord16 *streamPtrCarry; - WebRtc_UWord16 negcarry; - WebRtc_UWord32 cdfLo; - WebRtc_UWord32 cdfHi; - int k; - - /* point to beginning of stream buffer - * and set maximum streamPtr value */ - streamPtr = streamData->stream + streamData->stream_index; - maxStreamPtr = streamData->stream + STREAM_MAXW16_60MS - 1; - W_upper = streamData->W_upper; - - for (k = 0; k < lenData; k++) - { - /* compute cdf_lower and cdf_upper by evaluating the - * WebRtcIsacfix_Piecewise linear cdf */ - cdfLo = WebRtcIsacfix_Piecewise(WEBRTC_SPL_MUL_16_U16(*dataQ7 - 64, *envQ8)); - cdfHi = WebRtcIsacfix_Piecewise(WEBRTC_SPL_MUL_16_U16(*dataQ7 + 64, *envQ8)); - - /* test and clip if probability gets too small */ - while ((cdfLo + 1) >= cdfHi) { - /* clip */ - if (*dataQ7 > 0) { - *dataQ7 -= 128; - cdfHi = cdfLo; - cdfLo = WebRtcIsacfix_Piecewise( - WEBRTC_SPL_MUL_16_U16(*dataQ7 - 64, *envQ8)); - } else { - *dataQ7 += 128; - cdfLo = cdfHi; - cdfHi = WebRtcIsacfix_Piecewise( - WEBRTC_SPL_MUL_16_U16(*dataQ7 + 64, *envQ8)); - } - } - - dataQ7++; - /* increment only once per 4 iterations */ - envQ8 += (k & 1) & (k >> 1); - - - /* update interval */ - W_upper_LSB = (WebRtc_UWord16)W_upper; - W_upper_MSB = (WebRtc_UWord16)WEBRTC_SPL_RSHIFT_U32(W_upper, 16); - W_lower = WEBRTC_SPL_UMUL_32_16(cdfLo, W_upper_MSB); - W_lower += WEBRTC_SPL_UMUL_32_16_RSFT16(cdfLo, W_upper_LSB); - W_upper = WEBRTC_SPL_UMUL_32_16(cdfHi, W_upper_MSB); - W_upper += WEBRTC_SPL_UMUL_32_16_RSFT16(cdfHi, W_upper_LSB); - - /* shift interval such that it begins at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamData->streamval += W_lower; - - /* handle carry */ - if (streamData->streamval < W_lower) - { - /* propagate carry */ - streamPtrCarry = streamPtr; - if (streamData->full == 0) { - negcarry = *streamPtrCarry; - negcarry += 0x0100; - *streamPtrCarry = negcarry; - while (!(negcarry)) - { - negcarry = *--streamPtrCarry; - negcarry++; - *streamPtrCarry = negcarry; - } - } else { - while (!(++(*--streamPtrCarry))); - } - } - - /* renormalize interval, store most significant byte of streamval and update streamval - * W_upper < 2^24 */ - while ( !(W_upper & 0xFF000000) ) - { - W_upper = WEBRTC_SPL_LSHIFT_U32(W_upper, 8); - if (streamData->full == 0) { - *streamPtr++ += (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_U32( - streamData->streamval, 24); - streamData->full = 1; - } else { - *streamPtr = (WebRtc_UWord16) WEBRTC_SPL_LSHIFT_U32( - WEBRTC_SPL_RSHIFT_U32(streamData->streamval, 24), 8); - streamData->full = 0; - } - - if( streamPtr > maxStreamPtr ) - return -ISAC_DISALLOWED_BITSTREAM_LENGTH; - - streamData->streamval = WEBRTC_SPL_LSHIFT_U32(streamData->streamval, 8); - } - } - - /* calculate new stream_index */ - streamData->stream_index = streamPtr - streamData->stream; - streamData->W_upper = W_upper; - - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_DecLogisticMulti2(...) - * - * Arithmetic decoding of spectrum. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - envQ8 : side info vector defining the width of the pdf - * in Q8 - * - lenData : data vector length - * - * Input/Output: - * - dataQ7 : input: dither vector, output: data vector - * - * Return value : number of bytes in the stream so far - * -1 if error detected - */ -WebRtc_Word16 WebRtcIsacfix_DecLogisticMulti2(WebRtc_Word16 *dataQ7, - Bitstr_dec *streamData, - const WebRtc_Word32 *envQ8, - const WebRtc_Word16 lenData) -{ - WebRtc_UWord32 W_lower; - WebRtc_UWord32 W_upper; - WebRtc_UWord32 W_tmp; - WebRtc_UWord16 W_upper_LSB; - WebRtc_UWord16 W_upper_MSB; - WebRtc_UWord32 streamVal; - WebRtc_UWord16 cdfTmp; - WebRtc_Word32 res; - WebRtc_Word32 inSqrt; - WebRtc_Word32 newRes; - const WebRtc_UWord16 *streamPtr; - WebRtc_Word16 candQ7; - WebRtc_Word16 envCount; - WebRtc_UWord16 tmpARSpecQ8 = 0; - int k, i; - - - /* point to beginning of stream buffer */ - streamPtr = streamData->stream + streamData->stream_index; - W_upper = streamData->W_upper; - - /* Check if it is first time decoder is called for this stream */ - if (streamData->stream_index == 0) - { - /* read first word from bytestream */ - streamVal = WEBRTC_SPL_LSHIFT_U32(*streamPtr++, 16); - streamVal |= *streamPtr++; - - } else { - streamVal = streamData->streamval; - } - - - res = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)1, - WEBRTC_SPL_RSHIFT_W16(WebRtcSpl_GetSizeInBits(envQ8[0]), 1)); - envCount = 0; - - /* code assumes lenData%4 == 0 */ - for (k = 0; k < lenData; k += 4) - { - int k4; - - /* convert to magnitude spectrum, by doing square-roots (modified from SPLIB) */ - inSqrt = envQ8[envCount]; - i = 10; - - /* For safty reasons */ - if (inSqrt < 0) - inSqrt=-inSqrt; - - newRes = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_DIV(inSqrt, res) + res, 1); - do - { - res = newRes; - newRes = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_DIV(inSqrt, res) + res, 1); - } while (newRes != res && i-- > 0); - - tmpARSpecQ8 = (WebRtc_UWord16)newRes; - - for(k4 = 0; k4 < 4; k4++) - { - /* find the integer *data for which streamVal lies in [W_lower+1, W_upper] */ - W_upper_LSB = (WebRtc_UWord16) (W_upper & 0x0000FFFF); - W_upper_MSB = (WebRtc_UWord16) WEBRTC_SPL_RSHIFT_U32(W_upper, 16); - - /* find first candidate by inverting the logistic cdf - * Input dither value collected from io-stream */ - candQ7 = - *dataQ7 + 64; - cdfTmp = WebRtcIsacfix_Piecewise(WEBRTC_SPL_MUL_16_U16(candQ7, tmpARSpecQ8)); - - W_tmp = WEBRTC_SPL_UMUL_16_16(cdfTmp, W_upper_MSB); - W_tmp += WEBRTC_SPL_UMUL_16_16_RSFT16(cdfTmp, W_upper_LSB); - - if (streamVal > W_tmp) - { - W_lower = W_tmp; - candQ7 += 128; - cdfTmp = WebRtcIsacfix_Piecewise(WEBRTC_SPL_MUL_16_U16(candQ7, tmpARSpecQ8)); - - W_tmp = WEBRTC_SPL_UMUL_16_16(cdfTmp, W_upper_MSB); - W_tmp += WEBRTC_SPL_UMUL_16_16_RSFT16(cdfTmp, W_upper_LSB); - - while (streamVal > W_tmp) - { - W_lower = W_tmp; - candQ7 += 128; - cdfTmp = WebRtcIsacfix_Piecewise( - WEBRTC_SPL_MUL_16_U16(candQ7, tmpARSpecQ8)); - - W_tmp = WEBRTC_SPL_UMUL_16_16(cdfTmp, W_upper_MSB); - W_tmp += WEBRTC_SPL_UMUL_16_16_RSFT16(cdfTmp, W_upper_LSB); - - /* error check */ - if (W_lower == W_tmp) { - return -1; - } - } - W_upper = W_tmp; - - /* Output value put in dataQ7: another sample decoded */ - *dataQ7 = candQ7 - 64; - } - else - { - W_upper = W_tmp; - candQ7 -= 128; - cdfTmp = WebRtcIsacfix_Piecewise(WEBRTC_SPL_MUL_16_U16(candQ7, tmpARSpecQ8)); - - W_tmp = WEBRTC_SPL_UMUL_16_16(cdfTmp, W_upper_MSB); - W_tmp += WEBRTC_SPL_UMUL_16_16_RSFT16(cdfTmp, W_upper_LSB); - - while ( !(streamVal > W_tmp) ) - { - W_upper = W_tmp; - candQ7 -= 128; - cdfTmp = WebRtcIsacfix_Piecewise( - WEBRTC_SPL_MUL_16_U16(candQ7, tmpARSpecQ8)); - - W_tmp = WEBRTC_SPL_UMUL_16_16(cdfTmp, W_upper_MSB); - W_tmp += WEBRTC_SPL_UMUL_16_16_RSFT16(cdfTmp, W_upper_LSB); - - /* error check */ - if (W_upper == W_tmp){ - return -1; - } - } - W_lower = W_tmp; - - /* Output value put in dataQ7: another sample decoded */ - *dataQ7 = candQ7 + 64; - } - - dataQ7++; - - /* shift interval to start at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamVal -= W_lower; - - /* renormalize interval and update streamVal - * W_upper < 2^24 */ - while ( !(W_upper & 0xFF000000) ) - { - /* read next byte from stream */ - if (streamData->full == 0) { - streamVal = WEBRTC_SPL_LSHIFT_W32(streamVal, 8) | (*streamPtr++ & 0x00FF); - streamData->full = 1; - } else { - streamVal = WEBRTC_SPL_LSHIFT_W32(streamVal, 8) | - WEBRTC_SPL_RSHIFT_U16(*streamPtr, 8); - streamData->full = 0; - } - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); - } - } - envCount++; - } - - streamData->stream_index = streamPtr - streamData->stream; - streamData->W_upper = W_upper; - streamData->streamval = streamVal; - - /* find number of bytes in original stream (determined by current interval width) */ - if ( W_upper > 0x01FFFFFF ) - return (streamData->stream_index*2 - 3 + !streamData->full); - else - return (streamData->stream_index*2 - 2 + !streamData->full); -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/arith_routins.h b/src/modules/audio_coding/codecs/isac/fix/source/arith_routins.h deleted file mode 100644 index 9aa49da..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/arith_routins.h +++ /dev/null
@@ -1,160 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * arith_routins.h - * - * Functions for arithmetic coding. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ - -#include "structs.h" - - -/**************************************************************************** - * WebRtcIsacfix_EncLogisticMulti2(...) - * - * Arithmetic coding of spectrum. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - dataQ7 : data vector in Q7 - * - envQ8 : side info vector defining the width of the pdf - * in Q8 - * - lenData : data vector length - * - * Return value : 0 if ok, - * <0 otherwise. - */ -int WebRtcIsacfix_EncLogisticMulti2( - Bitstr_enc *streamData, - WebRtc_Word16 *dataQ7, - const WebRtc_UWord16 *env, - const WebRtc_Word16 lenData); - - -/**************************************************************************** - * WebRtcIsacfix_EncTerminate(...) - * - * Final call to the arithmetic coder for an encoder call. This function - * terminates and return byte stream. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - * Return value : number of bytes in the stream - */ -WebRtc_Word16 WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData); - - -/**************************************************************************** - * WebRtcIsacfix_DecLogisticMulti2(...) - * - * Arithmetic decoding of spectrum. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - envQ8 : side info vector defining the width of the pdf - * in Q8 - * - lenData : data vector length - * - * Input/Output: - * - dataQ7 : input: dither vector, output: data vector, in Q7 - * - * Return value : number of bytes in the stream so far - * <0 if error detected - */ -WebRtc_Word16 WebRtcIsacfix_DecLogisticMulti2( - WebRtc_Word16 *data, - Bitstr_dec *streamData, - const WebRtc_Word32 *env, - const WebRtc_Word16 lenData); - - -/**************************************************************************** - * WebRtcIsacfix_EncHistMulti(...) - * - * Encode the histogram interval - * - * Input: - * - streamData : in-/output struct containing bitstream - * - data : data vector - * - cdf : array of cdf arrays - * - lenData : data vector length - * - * Return value : 0 if ok - * <0 if error detected - */ -int WebRtcIsacfix_EncHistMulti( - Bitstr_enc *streamData, - const WebRtc_Word16 *data, - const WebRtc_UWord16 **cdf, - const WebRtc_Word16 lenData); - - -/**************************************************************************** - * WebRtcIsacfix_DecHistBisectMulti(...) - * - * Function to decode more symbols from the arithmetic bytestream, using - * method of bisection. - * C df tables should be of size 2^k-1 (which corresponds to an - * alphabet size of 2^k-2) - * - * Input: - * - streamData : in-/output struct containing bitstream - * - cdf : array of cdf arrays - * - cdfSize : array of cdf table sizes+1 (power of two: 2^k) - * - lenData : data vector length - * - * Output: - * - data : data vector - * - * Return value : number of bytes in the stream - * <0 if error detected - */ -WebRtc_Word16 WebRtcIsacfix_DecHistBisectMulti( - WebRtc_Word16 *data, - Bitstr_dec *streamData, - const WebRtc_UWord16 **cdf, - const WebRtc_UWord16 *cdfSize, - const WebRtc_Word16 lenData); - - -/**************************************************************************** - * WebRtcIsacfix_DecHistOneStepMulti(...) - * - * Function to decode more symbols from the arithmetic bytestream, taking - * single step up or down at a time. - * cdf tables can be of arbitrary size, but large tables may take a lot of - * iterations. - * - * Input: - * - streamData : in-/output struct containing bitstream - * - cdf : array of cdf arrays - * - initIndex : vector of initial cdf table search entries - * - lenData : data vector length - * - * Output: - * - data : data vector - * - * Return value : number of bytes in original stream - * <0 if error detected - */ -WebRtc_Word16 WebRtcIsacfix_DecHistOneStepMulti( - WebRtc_Word16 *data, - Bitstr_dec *streamData, - const WebRtc_UWord16 **cdf, - const WebRtc_UWord16 *initIndex, - const WebRtc_Word16 lenData); - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ARITH_ROUTINS_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c b/src/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c deleted file mode 100644 index a274b66..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c +++ /dev/null
@@ -1,1022 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * bandwidth_estimator.c - * - * This file contains the code for the Bandwidth Estimator designed - * for iSAC. - * - * NOTE! Castings needed for C55, do not remove! - * - */ - -#include "bandwidth_estimator.h" -#include "settings.h" - - -/* array of quantization levels for bottle neck info; Matlab code: */ -/* sprintf('%4.1ff, ', logspace(log10(5000), log10(40000), 12)) */ -static const WebRtc_Word16 kQRateTable[12] = { - 10000, 11115, 12355, 13733, 15265, 16967, - 18860, 20963, 23301, 25900, 28789, 32000 -}; - -/* 0.1 times the values in the table kQRateTable */ -/* values are in Q16 */ -static const WebRtc_Word32 KQRate01[12] = { - 65536000, 72843264, 80969728, 90000589, 100040704, 111194931, - 123600896, 137383117, 152705434, 169738240, 188671590, 209715200 -}; - -/* Bits per Bytes Seconds - * 8 bits/byte * 1000 msec/sec * 1/framelength (in msec)->bits/byte*sec - * frame length will either be 30 or 60 msec. 8738 is 1/60 in Q19 and 1/30 in Q18 - * The following number is either in Q15 or Q14 depending on the current frame length */ -static const WebRtc_Word32 kBitsByteSec = 4369000; - -/* Received header rate. First value is for 30 ms packets and second for 60 ms */ -static const WebRtc_Word16 kRecHeaderRate[2] = { - 9333, 4666 -}; - -/* Inverted minimum and maximum bandwidth in Q30. - minBwInv 30 ms, maxBwInv 30 ms, - minBwInv 60 ms, maxBwInv 69 ms -*/ -static const WebRtc_Word32 kInvBandwidth[4] = { - 55539, 25978, - 73213, 29284 -}; - -/* Number of samples in 25 msec */ -static const WebRtc_Word32 kSamplesIn25msec = 400; - - -/**************************************************************************** - * WebRtcIsacfix_InitBandwidthEstimator(...) - * - * This function initializes the struct for the bandwidth estimator - * - * Input/Output: - * - bweStr : Struct containing bandwidth information. - * - * Return value : 0 - */ -WebRtc_Word32 WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bweStr) -{ - bweStr->prevFrameSizeMs = INIT_FRAME_LEN; - bweStr->prevRtpNumber = 0; - bweStr->prevSendTime = 0; - bweStr->prevArrivalTime = 0; - bweStr->prevRtpRate = 1; - bweStr->lastUpdate = 0; - bweStr->lastReduction = 0; - bweStr->countUpdates = -9; - - /* INIT_BN_EST = 20000 - * INIT_BN_EST_Q7 = 2560000 - * INIT_HDR_RATE = 4666 - * INIT_REC_BN_EST_Q5 = 789312 - * - * recBwInv = 1/(INIT_BN_EST + INIT_HDR_RATE) in Q30 - * recBwAvg = INIT_BN_EST + INIT_HDR_RATE in Q5 - */ - bweStr->recBwInv = 43531; - bweStr->recBw = INIT_BN_EST; - bweStr->recBwAvgQ = INIT_BN_EST_Q7; - bweStr->recBwAvg = INIT_REC_BN_EST_Q5; - bweStr->recJitter = (WebRtc_Word32) 327680; /* 10 in Q15 */ - bweStr->recJitterShortTerm = 0; - bweStr->recJitterShortTermAbs = (WebRtc_Word32) 40960; /* 5 in Q13 */ - bweStr->recMaxDelay = (WebRtc_Word32) 10; - bweStr->recMaxDelayAvgQ = (WebRtc_Word32) 5120; /* 10 in Q9 */ - bweStr->recHeaderRate = INIT_HDR_RATE; - bweStr->countRecPkts = 0; - bweStr->sendBwAvg = INIT_BN_EST_Q7; - bweStr->sendMaxDelayAvg = (WebRtc_Word32) 5120; /* 10 in Q9 */ - - bweStr->countHighSpeedRec = 0; - bweStr->highSpeedRec = 0; - bweStr->countHighSpeedSent = 0; - bweStr->highSpeedSend = 0; - bweStr->inWaitPeriod = 0; - - /* Find the inverse of the max bw and min bw in Q30 - * (1 / (MAX_ISAC_BW + INIT_HDR_RATE) in Q30 - * (1 / (MIN_ISAC_BW + INIT_HDR_RATE) in Q30 - */ - bweStr->maxBwInv = kInvBandwidth[3]; - bweStr->minBwInv = kInvBandwidth[2]; - - return 0; -} - -/**************************************************************************** - * WebRtcIsacfix_UpdateUplinkBwImpl(...) - * - * This function updates bottle neck rate received from other side in payload - * and calculates a new bottle neck to send to the other side. - * - * Input/Output: - * - bweStr : struct containing bandwidth information. - * - rtpNumber : value from RTP packet, from NetEq - * - frameSize : length of signal frame in ms, from iSAC decoder - * - sendTime : value in RTP header giving send time in samples - * - arrivalTime : value given by timeGetTime() time of arrival in - * samples of packet from NetEq - * - pksize : size of packet in bytes, from NetEq - * - Index : integer (range 0...23) indicating bottle neck & - * jitter as estimated by other side - * - * Return value : 0 if everything went fine, - * -1 otherwise - */ -WebRtc_Word32 WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr, - const WebRtc_UWord16 rtpNumber, - const WebRtc_Word16 frameSize, - const WebRtc_UWord32 sendTime, - const WebRtc_UWord32 arrivalTime, - const WebRtc_Word16 pksize, - const WebRtc_UWord16 Index) -{ - WebRtc_UWord16 weight = 0; - WebRtc_UWord32 currBwInv = 0; - WebRtc_UWord16 recRtpRate; - WebRtc_UWord32 arrTimeProj; - WebRtc_Word32 arrTimeDiff; - WebRtc_Word32 arrTimeNoise; - WebRtc_Word32 arrTimeNoiseAbs; - WebRtc_Word32 sendTimeDiff; - - WebRtc_Word32 delayCorrFactor = DELAY_CORRECTION_MED; - WebRtc_Word32 lateDiff = 0; - WebRtc_Word16 immediateSet = 0; - WebRtc_Word32 frameSizeSampl; - - WebRtc_Word32 temp; - WebRtc_Word32 msec; - WebRtc_UWord32 exponent; - WebRtc_UWord32 reductionFactor; - WebRtc_UWord32 numBytesInv; - WebRtc_Word32 sign; - - WebRtc_UWord32 byteSecondsPerBit; - WebRtc_UWord32 tempLower; - WebRtc_UWord32 tempUpper; - WebRtc_Word32 recBwAvgInv; - WebRtc_Word32 numPktsExpected; - - WebRtc_Word16 errCode; - - /* UPDATE ESTIMATES FROM OTHER SIDE */ - - /* The function also checks if Index has a valid value */ - errCode = WebRtcIsacfix_UpdateUplinkBwRec(bweStr, Index); - if (errCode <0) { - return(errCode); - } - - - /* UPDATE ESTIMATES ON THIS SIDE */ - - /* Bits per second per byte * 1/30 or 1/60 */ - if (frameSize == 60) { - /* If frameSize changed since last call, from 30 to 60, recalculate some values */ - if ( (frameSize != bweStr->prevFrameSizeMs) && (bweStr->countUpdates > 0)) { - bweStr->countUpdates = 10; - bweStr->recHeaderRate = kRecHeaderRate[1]; - - bweStr->maxBwInv = kInvBandwidth[3]; - bweStr->minBwInv = kInvBandwidth[2]; - bweStr->recBwInv = WEBRTC_SPL_UDIV(1073741824, (bweStr->recBw + bweStr->recHeaderRate)); - } - - /* kBitsByteSec is in Q15 */ - recRtpRate = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(kBitsByteSec, - (WebRtc_Word32)pksize), 15) + bweStr->recHeaderRate; - - } else { - /* If frameSize changed since last call, from 60 to 30, recalculate some values */ - if ( (frameSize != bweStr->prevFrameSizeMs) && (bweStr->countUpdates > 0)) { - bweStr->countUpdates = 10; - bweStr->recHeaderRate = kRecHeaderRate[0]; - - bweStr->maxBwInv = kInvBandwidth[1]; - bweStr->minBwInv = kInvBandwidth[0]; - bweStr->recBwInv = WEBRTC_SPL_UDIV(1073741824, (bweStr->recBw + bweStr->recHeaderRate)); - } - - /* kBitsByteSec is in Q14 */ - recRtpRate = (WebRtc_UWord16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(kBitsByteSec, - (WebRtc_Word32)pksize), 14) + bweStr->recHeaderRate; - } - - - /* Check for timer wrap-around */ - if (arrivalTime < bweStr->prevArrivalTime) { - bweStr->prevArrivalTime = arrivalTime; - bweStr->lastUpdate = arrivalTime; - bweStr->lastReduction = arrivalTime + FS3; - - bweStr->countRecPkts = 0; - - /* store frame size */ - bweStr->prevFrameSizeMs = frameSize; - - /* store far-side transmission rate */ - bweStr->prevRtpRate = recRtpRate; - - /* store far-side RTP time stamp */ - bweStr->prevRtpNumber = rtpNumber; - - return 0; - } - - bweStr->countRecPkts++; - - /* Calculate framesize in msec */ - frameSizeSampl = WEBRTC_SPL_MUL_16_16((WebRtc_Word16)SAMPLES_PER_MSEC, frameSize); - - /* Check that it's not one of the first 9 packets */ - if ( bweStr->countUpdates > 0 ) { - - /* Stay in Wait Period for 1.5 seconds (no updates in wait period) */ - if(bweStr->inWaitPeriod) { - if ((arrivalTime - bweStr->startWaitPeriod)> FS_1_HALF) { - bweStr->inWaitPeriod = 0; - } - } - - /* If not been updated for a long time, reduce the BN estimate */ - - /* Check send time difference between this packet and previous received */ - sendTimeDiff = sendTime - bweStr->prevSendTime; - if (sendTimeDiff <= WEBRTC_SPL_LSHIFT_W32(frameSizeSampl, 1)) { - - /* Only update if 3 seconds has past since last update */ - if ((arrivalTime - bweStr->lastUpdate) > FS3) { - - /* Calculate expected number of received packets since last update */ - numPktsExpected = WEBRTC_SPL_UDIV(arrivalTime - bweStr->lastUpdate, frameSizeSampl); - - /* If received number of packets is more than 90% of expected (922 = 0.9 in Q10): */ - /* do the update, else not */ - if(WEBRTC_SPL_LSHIFT_W32(bweStr->countRecPkts, 10) > WEBRTC_SPL_MUL_16_16(922, numPktsExpected)) { - /* Q4 chosen to approx dividing by 16 */ - msec = (arrivalTime - bweStr->lastReduction); - - /* the number below represents 13 seconds, highly unlikely - but to insure no overflow when reduction factor is multiplied by recBw inverse */ - if (msec > 208000) { - msec = 208000; - } - - /* Q20 2^(negative number: - 76/1048576) = .99995 - product is Q24 */ - exponent = WEBRTC_SPL_UMUL(0x0000004C, msec); - - /* do the approx with positive exponent so that value is actually rf^-1 - and multiply by bw inverse */ - reductionFactor = WEBRTC_SPL_RSHIFT_U32(0x01000000 | (exponent & 0x00FFFFFF), - WEBRTC_SPL_RSHIFT_U32(exponent, 24)); - - /* reductionFactor in Q13 */ - reductionFactor = WEBRTC_SPL_RSHIFT_U32(reductionFactor, 11); - - if ( reductionFactor != 0 ) { - bweStr->recBwInv = WEBRTC_SPL_MUL((WebRtc_Word32)bweStr->recBwInv, (WebRtc_Word32)reductionFactor); - bweStr->recBwInv = WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)bweStr->recBwInv, 13); - - } else { - /* recBwInv = 1 / (INIT_BN_EST + INIT_HDR_RATE) in Q26 (Q30??)*/ - bweStr->recBwInv = WEBRTC_SPL_DIV((1073741824 + - WEBRTC_SPL_LSHIFT_W32(((WebRtc_Word32)INIT_BN_EST + INIT_HDR_RATE), 1)), INIT_BN_EST + INIT_HDR_RATE); - } - - /* reset time-since-update counter */ - bweStr->lastReduction = arrivalTime; - } else { - /* Delay last reduction with 3 seconds */ - bweStr->lastReduction = arrivalTime + FS3; - bweStr->lastUpdate = arrivalTime; - bweStr->countRecPkts = 0; - } - } - } else { - bweStr->lastReduction = arrivalTime + FS3; - bweStr->lastUpdate = arrivalTime; - bweStr->countRecPkts = 0; - } - - - /* update only if previous packet was not lost */ - if ( rtpNumber == bweStr->prevRtpNumber + 1 ) { - arrTimeDiff = arrivalTime - bweStr->prevArrivalTime; - - if (!(bweStr->highSpeedSend && bweStr->highSpeedRec)) { - if (arrTimeDiff > frameSizeSampl) { - if (sendTimeDiff > 0) { - lateDiff = arrTimeDiff - sendTimeDiff - - WEBRTC_SPL_LSHIFT_W32(frameSizeSampl, 1); - } else { - lateDiff = arrTimeDiff - frameSizeSampl; - } - - /* 8000 is 1/2 second (in samples at FS) */ - if (lateDiff > 8000) { - delayCorrFactor = (WebRtc_Word32) DELAY_CORRECTION_MAX; - bweStr->inWaitPeriod = 1; - bweStr->startWaitPeriod = arrivalTime; - immediateSet = 1; - } else if (lateDiff > 5120) { - delayCorrFactor = (WebRtc_Word32) DELAY_CORRECTION_MED; - immediateSet = 1; - bweStr->inWaitPeriod = 1; - bweStr->startWaitPeriod = arrivalTime; - } - } - } - - if ((bweStr->prevRtpRate > WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32) bweStr->recBwAvg, 5)) && - (recRtpRate > WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)bweStr->recBwAvg, 5)) && - !bweStr->inWaitPeriod) { - - /* test if still in initiation period and increment counter */ - if (bweStr->countUpdates++ > 99) { - /* constant weight after initiation part, 0.01 in Q13 */ - weight = (WebRtc_UWord16) 82; - } else { - /* weight decreases with number of updates, 1/countUpdates in Q13 */ - weight = (WebRtc_UWord16) WebRtcSpl_DivW32W16( - (WebRtc_Word32)(8192 + WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32) bweStr->countUpdates, 1)), - (WebRtc_Word16)bweStr->countUpdates); - } - - /* Bottle Neck Estimation */ - - /* limit outliers, if more than 25 ms too much */ - if (arrTimeDiff > frameSizeSampl + kSamplesIn25msec) { - arrTimeDiff = frameSizeSampl + kSamplesIn25msec; - } - - /* don't allow it to be less than frame rate - 10 ms */ - if (arrTimeDiff < frameSizeSampl - FRAMESAMPLES_10ms) { - arrTimeDiff = frameSizeSampl - FRAMESAMPLES_10ms; - } - - /* compute inverse receiving rate for last packet, in Q19 */ - numBytesInv = (WebRtc_UWord16) WebRtcSpl_DivW32W16( - (WebRtc_Word32)(524288 + WEBRTC_SPL_RSHIFT_W32(((WebRtc_Word32)pksize + HEADER_SIZE), 1)), - (WebRtc_Word16)(pksize + HEADER_SIZE)); - - /* 8389 is ~ 1/128000 in Q30 */ - byteSecondsPerBit = WEBRTC_SPL_MUL_16_16(arrTimeDiff, 8389); - - /* get upper N bits */ - tempUpper = WEBRTC_SPL_RSHIFT_U32(byteSecondsPerBit, 15); - - /* get lower 15 bits */ - tempLower = byteSecondsPerBit & 0x00007FFF; - - tempUpper = WEBRTC_SPL_MUL(tempUpper, numBytesInv); - tempLower = WEBRTC_SPL_MUL(tempLower, numBytesInv); - tempLower = WEBRTC_SPL_RSHIFT_U32(tempLower, 15); - - currBwInv = tempUpper + tempLower; - currBwInv = WEBRTC_SPL_RSHIFT_U32(currBwInv, 4); - - /* Limit inv rate. Note that minBwInv > maxBwInv! */ - if(currBwInv < bweStr->maxBwInv) { - currBwInv = bweStr->maxBwInv; - } else if(currBwInv > bweStr->minBwInv) { - currBwInv = bweStr->minBwInv; - } - - /* update bottle neck rate estimate */ - bweStr->recBwInv = WEBRTC_SPL_UMUL(weight, currBwInv) + - WEBRTC_SPL_UMUL((WebRtc_UWord32) 8192 - weight, bweStr->recBwInv); - - /* Shift back to Q30 from Q40 (actual used bits shouldn't be more than 27 based on minBwInv) - up to 30 bits used with Q13 weight */ - bweStr->recBwInv = WEBRTC_SPL_RSHIFT_U32(bweStr->recBwInv, 13); - - /* reset time-since-update counter */ - bweStr->lastUpdate = arrivalTime; - bweStr->lastReduction = arrivalTime + FS3; - bweStr->countRecPkts = 0; - - /* to save resolution compute the inverse of recBwAvg in Q26 by left shifting numerator to 2^31 - and NOT right shifting recBwAvg 5 bits to an integer - At max 13 bits are used - shift to Q5 */ - recBwAvgInv = WEBRTC_SPL_UDIV((WebRtc_UWord32)(0x80000000 + WEBRTC_SPL_RSHIFT_U32(bweStr->recBwAvg, 1)), - bweStr->recBwAvg); - - /* Calculate Projected arrival time difference */ - - /* The numerator of the quotient can be 22 bits so right shift inv by 4 to avoid overflow - result in Q22 */ - arrTimeProj = WEBRTC_SPL_MUL((WebRtc_Word32)8000, recBwAvgInv); - /* shift to Q22 */ - arrTimeProj = WEBRTC_SPL_RSHIFT_U32(arrTimeProj, 4); - /* complete calulation */ - arrTimeProj = WEBRTC_SPL_MUL(((WebRtc_Word32)pksize + HEADER_SIZE), arrTimeProj); - /* shift to Q10 */ - arrTimeProj = WEBRTC_SPL_RSHIFT_U32(arrTimeProj, 12); - - /* difference between projected and actual arrival time differences */ - /* Q9 (only shift arrTimeDiff by 5 to simulate divide by 16 (need to revisit if change sampling rate) DH */ - if (WEBRTC_SPL_LSHIFT_W32(arrTimeDiff, 6) > (WebRtc_Word32)arrTimeProj) { - arrTimeNoise = WEBRTC_SPL_LSHIFT_W32(arrTimeDiff, 6) - arrTimeProj; - sign = 1; - } else { - arrTimeNoise = arrTimeProj - WEBRTC_SPL_LSHIFT_W32(arrTimeDiff, 6); - sign = -1; - } - - /* Q9 */ - arrTimeNoiseAbs = arrTimeNoise; - - /* long term averaged absolute jitter, Q15 */ - weight = WEBRTC_SPL_RSHIFT_W32(weight, 3); - bweStr->recJitter = WEBRTC_SPL_MUL(weight, WEBRTC_SPL_LSHIFT_W32(arrTimeNoiseAbs, 5)) - + WEBRTC_SPL_MUL(1024 - weight, bweStr->recJitter); - - /* remove the fractional portion */ - bweStr->recJitter = WEBRTC_SPL_RSHIFT_W32(bweStr->recJitter, 10); - - /* Maximum jitter is 10 msec in Q15 */ - if (bweStr->recJitter > (WebRtc_Word32)327680) { - bweStr->recJitter = (WebRtc_Word32)327680; - } - - /* short term averaged absolute jitter */ - /* Calculation in Q13 products in Q23 */ - bweStr->recJitterShortTermAbs = WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32(arrTimeNoiseAbs, 3)) + - WEBRTC_SPL_MUL(973, bweStr->recJitterShortTermAbs); - bweStr->recJitterShortTermAbs = WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTermAbs , 10); - - /* short term averaged jitter */ - /* Calculation in Q13 products in Q23 */ - bweStr->recJitterShortTerm = WEBRTC_SPL_MUL(205, WEBRTC_SPL_LSHIFT_W32(arrTimeNoise, 3)) * sign + - WEBRTC_SPL_MUL(3891, bweStr->recJitterShortTerm); - - if (bweStr->recJitterShortTerm < 0) { - temp = -bweStr->recJitterShortTerm; - temp = WEBRTC_SPL_RSHIFT_W32(temp, 12); - bweStr->recJitterShortTerm = -temp; - } else { - bweStr->recJitterShortTerm = WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTerm, 12); - } - } - } - } else { - /* reset time-since-update counter when receiving the first 9 packets */ - bweStr->lastUpdate = arrivalTime; - bweStr->lastReduction = arrivalTime + FS3; - bweStr->countRecPkts = 0; - bweStr->countUpdates++; - } - - /* Limit to minimum or maximum bottle neck rate (in Q30) */ - if (bweStr->recBwInv > bweStr->minBwInv) { - bweStr->recBwInv = bweStr->minBwInv; - } else if (bweStr->recBwInv < bweStr->maxBwInv) { - bweStr->recBwInv = bweStr->maxBwInv; - } - - - /* store frame length */ - bweStr->prevFrameSizeMs = frameSize; - - /* store far-side transmission rate */ - bweStr->prevRtpRate = recRtpRate; - - /* store far-side RTP time stamp */ - bweStr->prevRtpNumber = rtpNumber; - - /* Replace bweStr->recMaxDelay by the new value (atomic operation) */ - if (bweStr->prevArrivalTime != 0xffffffff) { - bweStr->recMaxDelay = WEBRTC_SPL_MUL(3, bweStr->recJitter); - } - - /* store arrival time stamp */ - bweStr->prevArrivalTime = arrivalTime; - bweStr->prevSendTime = sendTime; - - /* Replace bweStr->recBw by the new value */ - bweStr->recBw = WEBRTC_SPL_UDIV(1073741824, bweStr->recBwInv) - bweStr->recHeaderRate; - - if (immediateSet) { - /* delay correction factor is in Q10 */ - bweStr->recBw = WEBRTC_SPL_UMUL(delayCorrFactor, bweStr->recBw); - bweStr->recBw = WEBRTC_SPL_RSHIFT_U32(bweStr->recBw, 10); - - if (bweStr->recBw < (WebRtc_Word32) MIN_ISAC_BW) { - bweStr->recBw = (WebRtc_Word32) MIN_ISAC_BW; - } - - bweStr->recBwAvg = WEBRTC_SPL_LSHIFT_U32(bweStr->recBw + bweStr->recHeaderRate, 5); - - bweStr->recBwAvgQ = WEBRTC_SPL_LSHIFT_U32(bweStr->recBw, 7); - - bweStr->recJitterShortTerm = 0; - - bweStr->recBwInv = WEBRTC_SPL_UDIV(1073741824, bweStr->recBw + bweStr->recHeaderRate); - - immediateSet = 0; - } - - - return 0; -} - -/* This function updates the send bottle neck rate */ -/* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */ -/* returns 0 if everything went fine, -1 otherwise */ -WebRtc_Word16 WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr, - const WebRtc_Word16 Index) -{ - WebRtc_UWord16 RateInd; - - if ( (Index < 0) || (Index > 23) ) { - return -ISAC_RANGE_ERROR_BW_ESTIMATOR; - } - - /* UPDATE ESTIMATES FROM OTHER SIDE */ - - if ( Index > 11 ) { - RateInd = Index - 12; - /* compute the jitter estimate as decoded on the other side in Q9 */ - /* sendMaxDelayAvg = 0.9 * sendMaxDelayAvg + 0.1 * MAX_ISAC_MD */ - bweStr->sendMaxDelayAvg = WEBRTC_SPL_MUL(461, bweStr->sendMaxDelayAvg) + - WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)MAX_ISAC_MD, 9)); - bweStr->sendMaxDelayAvg = WEBRTC_SPL_RSHIFT_W32(bweStr->sendMaxDelayAvg, 9); - - } else { - RateInd = Index; - /* compute the jitter estimate as decoded on the other side in Q9 */ - /* sendMaxDelayAvg = 0.9 * sendMaxDelayAvg + 0.1 * MIN_ISAC_MD */ - bweStr->sendMaxDelayAvg = WEBRTC_SPL_MUL(461, bweStr->sendMaxDelayAvg) + - WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)MIN_ISAC_MD,9)); - bweStr->sendMaxDelayAvg = WEBRTC_SPL_RSHIFT_W32(bweStr->sendMaxDelayAvg, 9); - - } - - - /* compute the BN estimate as decoded on the other side */ - /* sendBwAvg = 0.9 * sendBwAvg + 0.1 * kQRateTable[RateInd]; */ - bweStr->sendBwAvg = WEBRTC_SPL_UMUL(461, bweStr->sendBwAvg) + - WEBRTC_SPL_UMUL(51, WEBRTC_SPL_LSHIFT_U32(kQRateTable[RateInd], 7)); - bweStr->sendBwAvg = WEBRTC_SPL_RSHIFT_U32(bweStr->sendBwAvg, 9); - - - if (WEBRTC_SPL_RSHIFT_U32(bweStr->sendBwAvg, 7) > 28000 && !bweStr->highSpeedSend) { - bweStr->countHighSpeedSent++; - - /* approx 2 seconds with 30ms frames */ - if (bweStr->countHighSpeedSent >= 66) { - bweStr->highSpeedSend = 1; - } - } else if (!bweStr->highSpeedSend) { - bweStr->countHighSpeedSent = 0; - } - - return 0; -} - -/**************************************************************************** - * WebRtcIsacfix_GetDownlinkBwIndexImpl(...) - * - * This function calculates and returns the bandwidth/jitter estimation code - * (integer 0...23) to put in the sending iSAC payload. - * - * Input: - * - bweStr : BWE struct - * - * Return: - * bandwith and jitter index (0..23) - */ -WebRtc_UWord16 WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr) -{ - WebRtc_Word32 rate; - WebRtc_Word32 maxDelay; - WebRtc_UWord16 rateInd; - WebRtc_UWord16 maxDelayBit; - WebRtc_Word32 tempTerm1; - WebRtc_Word32 tempTerm2; - WebRtc_Word32 tempTermX; - WebRtc_Word32 tempTermY; - WebRtc_Word32 tempMin; - WebRtc_Word32 tempMax; - - /* Get Rate Index */ - - /* Get unquantized rate. Always returns 10000 <= rate <= 32000 */ - rate = WebRtcIsacfix_GetDownlinkBandwidth(bweStr); - - /* Compute the averaged BN estimate on this side */ - - /* recBwAvg = 0.9 * recBwAvg + 0.1 * (rate + bweStr->recHeaderRate), 0.9 and 0.1 in Q9 */ - bweStr->recBwAvg = WEBRTC_SPL_UMUL(922, bweStr->recBwAvg) + - WEBRTC_SPL_UMUL(102, WEBRTC_SPL_LSHIFT_U32((WebRtc_UWord32)rate + bweStr->recHeaderRate, 5)); - bweStr->recBwAvg = WEBRTC_SPL_RSHIFT_U32(bweStr->recBwAvg, 10); - - /* find quantization index that gives the closest rate after averaging */ - for (rateInd = 1; rateInd < 12; rateInd++) { - if (rate <= kQRateTable[rateInd]){ - break; - } - } - - /* find closest quantization index, and update quantized average by taking: */ - /* 0.9*recBwAvgQ + 0.1*kQRateTable[rateInd] */ - - /* 0.9 times recBwAvgQ in Q16 */ - /* 461/512 - 25/65536 =0.900009 */ - tempTerm1 = WEBRTC_SPL_MUL(bweStr->recBwAvgQ, 25); - tempTerm1 = WEBRTC_SPL_RSHIFT_W32(tempTerm1, 7); - tempTermX = WEBRTC_SPL_UMUL(461, bweStr->recBwAvgQ) - tempTerm1; - - /* rate in Q16 */ - tempTermY = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)rate, 16); - - /* 0.1 * kQRateTable[rateInd] = KQRate01[rateInd] */ - tempTerm1 = tempTermX + KQRate01[rateInd] - tempTermY; - tempTerm2 = tempTermY - tempTermX - KQRate01[rateInd-1]; - - /* Compare (0.9 * recBwAvgQ + 0.1 * kQRateTable[rateInd] - rate) > - (rate - 0.9 * recBwAvgQ - 0.1 * kQRateTable[rateInd-1]) */ - if (tempTerm1 > tempTerm2) { - rateInd--; - } - - /* Update quantized average by taking: */ - /* 0.9*recBwAvgQ + 0.1*kQRateTable[rateInd] */ - - /* Add 0.1 times kQRateTable[rateInd], in Q16 */ - tempTermX += KQRate01[rateInd]; - - /* Shift back to Q7 */ - bweStr->recBwAvgQ = WEBRTC_SPL_RSHIFT_W32(tempTermX, 9); - - /* Count consecutive received bandwidth above 28000 kbps (28000 in Q7 = 3584000) */ - /* If 66 high estimates in a row, set highSpeedRec to one */ - /* 66 corresponds to ~2 seconds in 30 msec mode */ - if ((bweStr->recBwAvgQ > 3584000) && !bweStr->highSpeedRec) { - bweStr->countHighSpeedRec++; - if (bweStr->countHighSpeedRec >= 66) { - bweStr->highSpeedRec = 1; - } - } else if (!bweStr->highSpeedRec) { - bweStr->countHighSpeedRec = 0; - } - - /* Get Max Delay Bit */ - - /* get unquantized max delay */ - maxDelay = WebRtcIsacfix_GetDownlinkMaxDelay(bweStr); - - /* Update quantized max delay average */ - tempMax = 652800; /* MAX_ISAC_MD * 0.1 in Q18 */ - tempMin = 130560; /* MIN_ISAC_MD * 0.1 in Q18 */ - tempTermX = WEBRTC_SPL_MUL((WebRtc_Word32)bweStr->recMaxDelayAvgQ, (WebRtc_Word32)461); - tempTermY = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)maxDelay, 18); - - tempTerm1 = tempTermX + tempMax - tempTermY; - tempTerm2 = tempTermY - tempTermX - tempMin; - - if ( tempTerm1 > tempTerm2) { - maxDelayBit = 0; - tempTerm1 = tempTermX + tempMin; - - /* update quantized average, shift back to Q9 */ - bweStr->recMaxDelayAvgQ = WEBRTC_SPL_RSHIFT_W32(tempTerm1, 9); - } else { - maxDelayBit = 12; - tempTerm1 = tempTermX + tempMax; - - /* update quantized average, shift back to Q9 */ - bweStr->recMaxDelayAvgQ = WEBRTC_SPL_RSHIFT_W32(tempTerm1, 9); - } - - /* Return bandwitdh and jitter index (0..23) */ - return (WebRtc_UWord16)(rateInd + maxDelayBit); -} - -/* get the bottle neck rate from far side to here, as estimated on this side */ -WebRtc_UWord16 WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bweStr) -{ - WebRtc_UWord32 recBw; - WebRtc_Word32 jitter_sign; /* Q8 */ - WebRtc_Word32 bw_adjust; /* Q16 */ - WebRtc_Word32 rec_jitter_short_term_abs_inv; /* Q18 */ - WebRtc_Word32 temp; - - /* Q18 rec jitter short term abs is in Q13, multiply it by 2^13 to save precision - 2^18 then needs to be shifted 13 bits to 2^31 */ - rec_jitter_short_term_abs_inv = WEBRTC_SPL_UDIV(0x80000000, bweStr->recJitterShortTermAbs); - - /* Q27 = 9 + 18 */ - jitter_sign = WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTerm, 4), (WebRtc_Word32)rec_jitter_short_term_abs_inv); - - if (jitter_sign < 0) { - temp = -jitter_sign; - temp = WEBRTC_SPL_RSHIFT_W32(temp, 19); - jitter_sign = -temp; - } else { - jitter_sign = WEBRTC_SPL_RSHIFT_W32(jitter_sign, 19); - } - - /* adjust bw proportionally to negative average jitter sign */ - //bw_adjust = 1.0f - jitter_sign * (0.15f + 0.15f * jitter_sign * jitter_sign); - //Q8 -> Q16 .15 +.15 * jitter^2 first term is .15 in Q16 latter term is Q8*Q8*Q8 - //38 in Q8 ~.15 9830 in Q16 ~.15 - temp = 9830 + WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL(38, WEBRTC_SPL_MUL(jitter_sign, jitter_sign))), 8); - - if (jitter_sign < 0) { - temp = WEBRTC_SPL_MUL(jitter_sign, temp); - temp = -temp; - temp = WEBRTC_SPL_RSHIFT_W32(temp, 8); - bw_adjust = (WebRtc_UWord32)65536 + temp; /* (1 << 16) + temp; */ - } else { - bw_adjust = (WebRtc_UWord32)65536 - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(jitter_sign, temp), 8);/* (1 << 16) - ((jitter_sign * temp) >> 8); */ - } - - //make sure following multiplication won't overflow - //bw adjust now Q14 - bw_adjust = WEBRTC_SPL_RSHIFT_W32(bw_adjust, 2);//see if good resolution is maintained - - /* adjust Rate if jitter sign is mostly constant */ - recBw = WEBRTC_SPL_UMUL(bweStr->recBw, bw_adjust); - - recBw = WEBRTC_SPL_RSHIFT_W32(recBw, 14); - - /* limit range of bottle neck rate */ - if (recBw < MIN_ISAC_BW) { - recBw = MIN_ISAC_BW; - } else if (recBw > MAX_ISAC_BW) { - recBw = MAX_ISAC_BW; - } - - return (WebRtc_UWord16) recBw; -} - -/* Returns the mmax delay (in ms) */ -WebRtc_Word16 WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bweStr) -{ - WebRtc_Word16 recMaxDelay; - - recMaxDelay = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(bweStr->recMaxDelay, 15); - - /* limit range of jitter estimate */ - if (recMaxDelay < MIN_ISAC_MD) { - recMaxDelay = MIN_ISAC_MD; - } else if (recMaxDelay > MAX_ISAC_MD) { - recMaxDelay = MAX_ISAC_MD; - } - - return recMaxDelay; -} - -/* get the bottle neck rate from here to far side, as estimated by far side */ -WebRtc_Word16 WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr *bweStr) -{ - WebRtc_Word16 send_bw; - - send_bw = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_U32(bweStr->sendBwAvg, 7); - - /* limit range of bottle neck rate */ - if (send_bw < MIN_ISAC_BW) { - send_bw = MIN_ISAC_BW; - } else if (send_bw > MAX_ISAC_BW) { - send_bw = MAX_ISAC_BW; - } - - return send_bw; -} - - - -/* Returns the max delay value from the other side in ms */ -WebRtc_Word16 WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr *bweStr) -{ - WebRtc_Word16 send_max_delay; - - send_max_delay = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(bweStr->sendMaxDelayAvg, 9); - - /* limit range of jitter estimate */ - if (send_max_delay < MIN_ISAC_MD) { - send_max_delay = MIN_ISAC_MD; - } else if (send_max_delay > MAX_ISAC_MD) { - send_max_delay = MAX_ISAC_MD; - } - - return send_max_delay; -} - - - - -/* - * update long-term average bitrate and amount of data in buffer - * returns minimum payload size (bytes) - */ -WebRtc_UWord16 WebRtcIsacfix_GetMinBytes(RateModel *State, - WebRtc_Word16 StreamSize, /* bytes in bitstream */ - const WebRtc_Word16 FrameSamples, /* samples per frame */ - const WebRtc_Word16 BottleNeck, /* bottle neck rate; excl headers (bps) */ - const WebRtc_Word16 DelayBuildUp) /* max delay from bottle neck buffering (ms) */ -{ - WebRtc_Word32 MinRate = 0; - WebRtc_UWord16 MinBytes; - WebRtc_Word16 TransmissionTime; - WebRtc_Word32 inv_Q12; - WebRtc_Word32 den; - - - /* first 10 packets @ low rate, then INIT_BURST_LEN packets @ fixed rate of INIT_RATE bps */ - if (State->InitCounter > 0) { - if (State->InitCounter-- <= INIT_BURST_LEN) { - MinRate = INIT_RATE; - } else { - MinRate = 0; - } - } else { - /* handle burst */ - if (State->BurstCounter) { - if (State->StillBuffered < WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL((512 - WEBRTC_SPL_DIV(512, BURST_LEN)), DelayBuildUp), 9)) { - /* max bps derived from BottleNeck and DelayBuildUp values */ - inv_Q12 = WEBRTC_SPL_DIV(4096, WEBRTC_SPL_MUL(BURST_LEN, FrameSamples)); - MinRate = WEBRTC_SPL_MUL(512 + WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(DelayBuildUp, inv_Q12), 3)), BottleNeck); - } else { - /* max bps derived from StillBuffered and DelayBuildUp values */ - inv_Q12 = WEBRTC_SPL_DIV(4096, FrameSamples); - if (DelayBuildUp > State->StillBuffered) { - MinRate = WEBRTC_SPL_MUL(512 + WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(DelayBuildUp - State->StillBuffered, inv_Q12), 3)), BottleNeck); - } else if ((den = WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, (State->StillBuffered - DelayBuildUp))) >= FrameSamples) { - /* MinRate will be negative here */ - MinRate = 0; - } else { - MinRate = WEBRTC_SPL_MUL((512 - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(den, inv_Q12), 3)), BottleNeck); - } - //if (MinRate < 1.04 * BottleNeck) - // MinRate = 1.04 * BottleNeck; - //Q9 - if (MinRate < WEBRTC_SPL_MUL(532, BottleNeck)) { - MinRate += WEBRTC_SPL_MUL(22, BottleNeck); - } - } - - State->BurstCounter--; - } - } - - - /* convert rate from bits/second to bytes/packet */ - //round and shift before conversion - MinRate += 256; - MinRate = WEBRTC_SPL_RSHIFT_W32(MinRate, 9); - MinBytes = (WebRtc_UWord16)WEBRTC_SPL_UDIV(WEBRTC_SPL_MUL(MinRate, FrameSamples), FS8); - - /* StreamSize will be adjusted if less than MinBytes */ - if (StreamSize < MinBytes) { - StreamSize = MinBytes; - } - - /* keep track of when bottle neck was last exceeded by at least 1% */ - //517/512 ~ 1.01 - if (WEBRTC_SPL_DIV(WEBRTC_SPL_MUL(StreamSize, FS8), FrameSamples) > (WEBRTC_SPL_MUL(517, BottleNeck) >> 9)) { - if (State->PrevExceed) { - /* bottle_neck exceded twice in a row, decrease ExceedAgo */ - State->ExceedAgo -= WEBRTC_SPL_DIV(BURST_INTERVAL, BURST_LEN - 1); - if (State->ExceedAgo < 0) { - State->ExceedAgo = 0; - } - } else { - State->ExceedAgo += (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(FrameSamples, 4); /* ms */ - State->PrevExceed = 1; - } - } else { - State->PrevExceed = 0; - State->ExceedAgo += (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(FrameSamples, 4); /* ms */ - } - - /* set burst flag if bottle neck not exceeded for long time */ - if ((State->ExceedAgo > BURST_INTERVAL) && (State->BurstCounter == 0)) { - if (State->PrevExceed) { - State->BurstCounter = BURST_LEN - 1; - } else { - State->BurstCounter = BURST_LEN; - } - } - - - /* Update buffer delay */ - TransmissionTime = (WebRtc_Word16)WEBRTC_SPL_DIV(WEBRTC_SPL_MUL(StreamSize, 8000), BottleNeck); /* ms */ - State->StillBuffered += TransmissionTime; - State->StillBuffered -= (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(FrameSamples, 4); //>>4 = SAMPLES_PER_MSEC /* ms */ - if (State->StillBuffered < 0) { - State->StillBuffered = 0; - } - - if (State->StillBuffered > 2000) { - State->StillBuffered = 2000; - } - - return MinBytes; -} - - -/* - * update long-term average bitrate and amount of data in buffer - */ -void WebRtcIsacfix_UpdateRateModel(RateModel *State, - WebRtc_Word16 StreamSize, /* bytes in bitstream */ - const WebRtc_Word16 FrameSamples, /* samples per frame */ - const WebRtc_Word16 BottleNeck) /* bottle neck rate; excl headers (bps) */ -{ - WebRtc_Word16 TransmissionTime; - - /* avoid the initial "high-rate" burst */ - State->InitCounter = 0; - - /* Update buffer delay */ - TransmissionTime = (WebRtc_Word16)WEBRTC_SPL_DIV(WEBRTC_SPL_MUL(WEBRTC_SPL_MUL(StreamSize, 8), 1000), BottleNeck); /* ms */ - State->StillBuffered += TransmissionTime; - State->StillBuffered -= (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(FrameSamples, 4); /* ms */ - if (State->StillBuffered < 0) { - State->StillBuffered = 0; - } - -} - - -void WebRtcIsacfix_InitRateModel(RateModel *State) -{ - State->PrevExceed = 0; /* boolean */ - State->ExceedAgo = 0; /* ms */ - State->BurstCounter = 0; /* packets */ - State->InitCounter = INIT_BURST_LEN + 10; /* packets */ - State->StillBuffered = 1; /* ms */ -} - - - - - -WebRtc_Word16 WebRtcIsacfix_GetNewFrameLength(WebRtc_Word16 bottle_neck, WebRtc_Word16 current_framesamples) -{ - WebRtc_Word16 new_framesamples; - - new_framesamples = current_framesamples; - - /* find new framelength */ - switch(current_framesamples) { - case 480: - if (bottle_neck < Thld_30_60) { - new_framesamples = 960; - } - break; - case 960: - if (bottle_neck >= Thld_60_30) { - new_framesamples = 480; - } - break; - default: - new_framesamples = -1; /* Error */ - } - - return new_framesamples; -} - -WebRtc_Word16 WebRtcIsacfix_GetSnr(WebRtc_Word16 bottle_neck, WebRtc_Word16 framesamples) -{ - WebRtc_Word16 s2nr = 0; - - /* find new SNR value */ - //consider BottleNeck to be in Q10 ( * 1 in Q10) - switch(framesamples) { - case 480: - /*s2nr = -1*(a_30 << 10) + ((b_30 * bottle_neck) >> 10);*/ - s2nr = -22500 + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(500, bottle_neck, 10); //* 0.001; //+ c_30 * bottle_neck * bottle_neck * 0.000001; - break; - case 960: - /*s2nr = -1*(a_60 << 10) + ((b_60 * bottle_neck) >> 10);*/ - s2nr = -22500 + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(500, bottle_neck, 10); //* 0.001; //+ c_30 * bottle_neck * bottle_neck * 0.000001; - break; - default: - s2nr = -1; /* Error */ - } - - return s2nr; //return in Q10 - -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h b/src/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h deleted file mode 100644 index 76a50f8..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h +++ /dev/null
@@ -1,127 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * bandwidth_estimator.h - * - * This header file contains the API for the Bandwidth Estimator - * designed for iSAC. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ - -#include "structs.h" - - -/**************************************************************************** - * WebRtcIsacfix_InitBandwidthEstimator(...) - * - * This function initializes the struct for the bandwidth estimator - * - * Input/Output: - * - bwest_str : Struct containing bandwidth information. - * - * Return value : 0 - */ - -WebRtc_Word32 WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr *bwest_str); - - -/**************************************************************************** - * WebRtcIsacfix_UpdateUplinkBwImpl(...) - * - * This function updates bottle neck rate received from other side in payload - * and calculates a new bottle neck to send to the other side. - * - * Input/Output: - * - bweStr : struct containing bandwidth information. - * - rtpNumber : value from RTP packet, from NetEq - * - frameSize : length of signal frame in ms, from iSAC decoder - * - sendTime : value in RTP header giving send time in samples - * - arrivalTime : value given by timeGetTime() time of arrival in - * samples of packet from NetEq - * - pksize : size of packet in bytes, from NetEq - * - Index : integer (range 0...23) indicating bottle neck & - * jitter as estimated by other side - * - * Return value : 0 if everything went fine, - * -1 otherwise - */ - -WebRtc_Word32 WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bwest_str, - const WebRtc_UWord16 rtp_number, - const WebRtc_Word16 frameSize, - const WebRtc_UWord32 send_ts, - const WebRtc_UWord32 arr_ts, - const WebRtc_Word16 pksize, - const WebRtc_UWord16 Index); - -/* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */ -WebRtc_Word16 WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bwest_str, - const WebRtc_Word16 Index); - -/**************************************************************************** - * WebRtcIsacfix_GetDownlinkBwIndexImpl(...) - * - * This function calculates and returns the bandwidth/jitter estimation code - * (integer 0...23) to put in the sending iSAC payload. - * - * Input: - * - bweStr : BWE struct - * - * Return: - * bandwith and jitter index (0..23) - */ -WebRtc_UWord16 WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bwest_str); - -/* Returns the bandwidth estimation (in bps) */ -WebRtc_UWord16 WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bwest_str); - -/* Returns the bandwidth that iSAC should send with in bps */ -WebRtc_Word16 WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr *bwest_str); - -/* Returns the max delay (in ms) */ -WebRtc_Word16 WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str); - -/* Returns the max delay value from the other side in ms */ -WebRtc_Word16 WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr *bwest_str); - -/* - * update amount of data in bottle neck buffer and burst handling - * returns minimum payload size (bytes) - */ -WebRtc_UWord16 WebRtcIsacfix_GetMinBytes(RateModel *State, - WebRtc_Word16 StreamSize, /* bytes in bitstream */ - const WebRtc_Word16 FrameLen, /* ms per frame */ - const WebRtc_Word16 BottleNeck, /* bottle neck rate; excl headers (bps) */ - const WebRtc_Word16 DelayBuildUp); /* max delay from bottle neck buffering (ms) */ - -/* - * update long-term average bitrate and amount of data in buffer - */ -void WebRtcIsacfix_UpdateRateModel(RateModel *State, - WebRtc_Word16 StreamSize, /* bytes in bitstream */ - const WebRtc_Word16 FrameSamples, /* samples per frame */ - const WebRtc_Word16 BottleNeck); /* bottle neck rate; excl headers (bps) */ - - -void WebRtcIsacfix_InitRateModel(RateModel *State); - -/* Returns the new framelength value (input argument: bottle_neck) */ -WebRtc_Word16 WebRtcIsacfix_GetNewFrameLength(WebRtc_Word16 bottle_neck, WebRtc_Word16 current_framelength); - -/* Returns the new SNR value (input argument: bottle_neck) */ -//returns snr in Q10 -WebRtc_Word16 WebRtcIsacfix_GetSnr(WebRtc_Word16 bottle_neck, WebRtc_Word16 framesamples); - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/codec.h b/src/modules/audio_coding/codecs/isac/fix/source/codec.h deleted file mode 100644 index 1b4f987..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/codec.h +++ /dev/null
@@ -1,179 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * codec.h - * - * This header file contains the calls to the internal encoder - * and decoder functions. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_ - -#include "structs.h" - - -int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr *bwest_str, - Bitstr_dec *streamdata, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts); - -WebRtc_Word16 WebRtcIsacfix_DecodeImpl(WebRtc_Word16 *signal_out16, - ISACFIX_DecInst_t *ISACdec_obj, - WebRtc_Word16 *current_framesamples); - -WebRtc_Word16 WebRtcIsacfix_DecodePlcImpl(WebRtc_Word16 *decoded, - ISACFIX_DecInst_t *ISACdec_obj, - WebRtc_Word16 *current_framesample ); - -int WebRtcIsacfix_EncodeImpl(WebRtc_Word16 *in, - ISACFIX_EncInst_t *ISACenc_obj, - BwEstimatorstr *bw_estimatordata, - WebRtc_Word16 CodingMode); - -int WebRtcIsacfix_EncodeStoredData(ISACFIX_EncInst_t *ISACenc_obj, - int BWnumber, - float scale); - -/* initialization functions */ - -void WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc *maskdata); -void WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec *maskdata); - -void WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr *prefiltdata); - -void WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr *postfiltdata); - -void WebRtcIsacfix_InitPitchFilter(PitchFiltstr *pitchfiltdata); - -void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct *State); - -void WebRtcIsacfix_InitPlc( PLCstr *State ); - - -/* transform functions */ - -void WebRtcIsacfix_InitTransform(); - - -void WebRtcIsacfix_Time2Spec(WebRtc_Word16 *inre1Q9, - WebRtc_Word16 *inre2Q9, - WebRtc_Word16 *outre, - WebRtc_Word16 *outim); - - - -void WebRtcIsacfix_Spec2Time(WebRtc_Word16 *inreQ7, - WebRtc_Word16 *inimQ7, - WebRtc_Word32 *outre1Q16, - WebRtc_Word32 *outre2Q16); - - - - -/* filterbank functions */ - -void WebRtcIsacfix_SplitAndFilter1(WebRtc_Word16 *in, - WebRtc_Word16 *LP16, - WebRtc_Word16 *HP16, - PreFiltBankstr *prefiltdata); - -void WebRtcIsacfix_FilterAndCombine1(WebRtc_Word16 *tempin_ch1, - WebRtc_Word16 *tempin_ch2, - WebRtc_Word16 *out16, - PostFiltBankstr *postfiltdata); - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - -void WebRtcIsacfix_SplitAndFilter2(WebRtc_Word16 *in, - WebRtc_Word16 *LP16, - WebRtc_Word16 *HP16, - PreFiltBankstr *prefiltdata); - -void WebRtcIsacfix_FilterAndCombine2(WebRtc_Word16 *tempin_ch1, - WebRtc_Word16 *tempin_ch2, - WebRtc_Word16 *out16, - PostFiltBankstr *postfiltdata, - WebRtc_Word16 len); - -#endif - -/* normalized lattice filters */ - -void WebRtcIsacfix_NormLatticeFilterMa(WebRtc_Word16 orderCoef, - WebRtc_Word32 *stateGQ15, - WebRtc_Word16 *lat_inQ0, - WebRtc_Word16 *filt_coefQ15, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 lo_hi, - WebRtc_Word16 *lat_outQ9); - -void WebRtcIsacfix_NormLatticeFilterAr(WebRtc_Word16 orderCoef, - WebRtc_Word16 *stateGQ0, - WebRtc_Word32 *lat_inQ25, - WebRtc_Word16 *filt_coefQ15, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 lo_hi, - WebRtc_Word16 *lat_outQ0); - -/* TODO(kma): Remove the following functions into individual header files. */ - -/* Internal functions in both C and ARM Neon versions */ - -int WebRtcIsacfix_AutocorrC(WebRtc_Word32* __restrict r, - const WebRtc_Word16* __restrict x, - WebRtc_Word16 N, - WebRtc_Word16 order, - WebRtc_Word16* __restrict scale); - -void WebRtcIsacfix_FilterMaLoopC(int16_t input0, - int16_t input1, - int32_t input2, - int32_t* ptr0, - int32_t* ptr1, - int32_t* ptr2); - -#if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) -int WebRtcIsacfix_AutocorrNeon(WebRtc_Word32* __restrict r, - const WebRtc_Word16* __restrict x, - WebRtc_Word16 N, - WebRtc_Word16 order, - WebRtc_Word16* __restrict scale); - -void WebRtcIsacfix_FilterMaLoopNeon(int16_t input0, - int16_t input1, - int32_t input2, - int32_t* ptr0, - int32_t* ptr1, - int32_t* ptr2); -#endif - -/* Function pointers associated with the above functions. */ - -typedef int (*AutocorrFix)(WebRtc_Word32* __restrict r, - const WebRtc_Word16* __restrict x, - WebRtc_Word16 N, - WebRtc_Word16 order, - WebRtc_Word16* __restrict scale); -extern AutocorrFix WebRtcIsacfix_AutocorrFix; - -typedef void (*FilterMaLoopFix)(int16_t input0, - int16_t input1, - int32_t input2, - int32_t* ptr0, - int32_t* ptr1, - int32_t* ptr2); -extern FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/decode.c b/src/modules/audio_coding/codecs/isac/fix/source/decode.c deleted file mode 100644 index 2e15e7a..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/decode.c +++ /dev/null
@@ -1,217 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * decode.c - * - * This C file contains the internal decoding function. - * - */ - -#include <string.h> - -#include "bandwidth_estimator.h" -#include "codec.h" -#include "entropy_coding.h" -#include "pitch_estimator.h" -#include "settings.h" -#include "structs.h" - - - - -WebRtc_Word16 WebRtcIsacfix_DecodeImpl(WebRtc_Word16 *signal_out16, - ISACFIX_DecInst_t *ISACdec_obj, - WebRtc_Word16 *current_framesamples) -{ - int k; - int err; - WebRtc_Word16 BWno; - WebRtc_Word16 len = 0; - - WebRtc_Word16 model; - - - WebRtc_Word16 Vector_Word16_1[FRAMESAMPLES/2]; - WebRtc_Word16 Vector_Word16_2[FRAMESAMPLES/2]; - - WebRtc_Word32 Vector_Word32_1[FRAMESAMPLES/2]; - WebRtc_Word32 Vector_Word32_2[FRAMESAMPLES/2]; - - WebRtc_Word16 lofilt_coefQ15[ORDERLO*SUBFRAMES]; //refl. coeffs - WebRtc_Word16 hifilt_coefQ15[ORDERHI*SUBFRAMES]; //refl. coeffs - WebRtc_Word32 gain_lo_hiQ17[2*SUBFRAMES]; - - WebRtc_Word16 PitchLags_Q7[PITCH_SUBFRAMES]; - WebRtc_Word16 PitchGains_Q12[PITCH_SUBFRAMES]; - WebRtc_Word16 AvgPitchGain_Q12; - - WebRtc_Word16 tmp_1, tmp_2; - WebRtc_Word32 tmp32a, tmp32b; - WebRtc_Word16 gainQ13; - - - WebRtc_Word16 frame_nb; /* counter */ - WebRtc_Word16 frame_mode; /* 0 for 20ms and 30ms, 1 for 60ms */ - WebRtc_Word16 processed_samples; - - /* PLC */ - WebRtc_Word16 overlapWin[ 240 ]; - - (ISACdec_obj->bitstr_obj).W_upper = 0xFFFFFFFF; - (ISACdec_obj->bitstr_obj).streamval = 0; - (ISACdec_obj->bitstr_obj).stream_index = 0; - (ISACdec_obj->bitstr_obj).full = 1; - - - /* decode framelength and BW estimation - not used, only for stream pointer*/ - err = WebRtcIsacfix_DecodeFrameLen(&ISACdec_obj->bitstr_obj, current_framesamples); - if (err<0) // error check - return err; - - frame_mode = (WebRtc_Word16)WEBRTC_SPL_DIV(*current_framesamples, MAX_FRAMESAMPLES); /* 0, or 1 */ - processed_samples = (WebRtc_Word16)WEBRTC_SPL_DIV(*current_framesamples, frame_mode+1); /* either 320 (20ms) or 480 (30, 60 ms) */ - - err = WebRtcIsacfix_DecodeSendBandwidth(&ISACdec_obj->bitstr_obj, &BWno); - if (err<0) // error check - return err; - - /* one loop if it's one frame (20 or 30ms), 2 loops if 2 frames bundled together (60ms) */ - for (frame_nb = 0; frame_nb <= frame_mode; frame_nb++) { - - /* decode & dequantize pitch parameters */ - err = WebRtcIsacfix_DecodePitchGain(&(ISACdec_obj->bitstr_obj), PitchGains_Q12); - if (err<0) // error check - return err; - - err = WebRtcIsacfix_DecodePitchLag(&ISACdec_obj->bitstr_obj, PitchGains_Q12, PitchLags_Q7); - if (err<0) // error check - return err; - - AvgPitchGain_Q12 = (WebRtc_Word16)(((WebRtc_Word32)PitchGains_Q12[0] + PitchGains_Q12[1] + PitchGains_Q12[2] + PitchGains_Q12[3])>>2); - - /* decode & dequantize FiltCoef */ - err = WebRtcIsacfix_DecodeLpc(gain_lo_hiQ17, lofilt_coefQ15, hifilt_coefQ15, - &ISACdec_obj->bitstr_obj, &model); - - if (err<0) // error check - return err; - - /* decode & dequantize spectrum */ - len = WebRtcIsacfix_DecodeSpec(&ISACdec_obj->bitstr_obj, Vector_Word16_1, Vector_Word16_2, AvgPitchGain_Q12); - if (len < 0) // error check - return len; - - // Why does this need Q16 in and out? /JS - WebRtcIsacfix_Spec2Time(Vector_Word16_1, Vector_Word16_2, Vector_Word32_1, Vector_Word32_2); - - for (k=0; k<FRAMESAMPLES/2; k++) { - Vector_Word16_1[k] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(Vector_Word32_1[k]+64, 7); //Q16 -> Q9 - } - - /* ---- If this is recovery frame ---- */ - if( (ISACdec_obj->plcstr_obj).used == PLC_WAS_USED ) - { - (ISACdec_obj->plcstr_obj).used = PLC_NOT_USED; - if( (ISACdec_obj->plcstr_obj).B < 1000 ) - { - (ISACdec_obj->plcstr_obj).decayCoeffPriodic = 4000; - } - - ISACdec_obj->plcstr_obj.decayCoeffPriodic = WEBRTC_SPL_WORD16_MAX; /* DECAY_RATE is in Q15 */ - ISACdec_obj->plcstr_obj.decayCoeffNoise = WEBRTC_SPL_WORD16_MAX; /* DECAY_RATE is in Q15 */ - ISACdec_obj->plcstr_obj.pitchCycles = 0; - - PitchGains_Q12[0] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(PitchGains_Q12[0], 700, 10 ); - - /* ---- Add-overlap ---- */ - WebRtcSpl_GetHanningWindow( overlapWin, RECOVERY_OVERLAP ); - for( k = 0; k < RECOVERY_OVERLAP; k++ ) - Vector_Word16_1[k] = WEBRTC_SPL_ADD_SAT_W16( - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( (ISACdec_obj->plcstr_obj).overlapLP[k], overlapWin[RECOVERY_OVERLAP - k - 1], 14), - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( Vector_Word16_1[k], overlapWin[k], 14) ); - - - - } - - /* --- Store side info --- */ - if( frame_nb == frame_mode ) - { - /* --- LPC info */ - WEBRTC_SPL_MEMCPY_W16( (ISACdec_obj->plcstr_obj).lofilt_coefQ15, &lofilt_coefQ15[(SUBFRAMES-1)*ORDERLO], ORDERLO ); - WEBRTC_SPL_MEMCPY_W16( (ISACdec_obj->plcstr_obj).hifilt_coefQ15, &hifilt_coefQ15[(SUBFRAMES-1)*ORDERHI], ORDERHI ); - (ISACdec_obj->plcstr_obj).gain_lo_hiQ17[0] = gain_lo_hiQ17[(SUBFRAMES-1) * 2]; - (ISACdec_obj->plcstr_obj).gain_lo_hiQ17[1] = gain_lo_hiQ17[(SUBFRAMES-1) * 2 + 1]; - - /* --- LTP info */ - (ISACdec_obj->plcstr_obj).AvgPitchGain_Q12 = PitchGains_Q12[3]; - (ISACdec_obj->plcstr_obj).lastPitchGain_Q12 = PitchGains_Q12[3]; - (ISACdec_obj->plcstr_obj).lastPitchLag_Q7 = PitchLags_Q7[3]; - - if( PitchLags_Q7[3] < 3000 ) - (ISACdec_obj->plcstr_obj).lastPitchLag_Q7 += PitchLags_Q7[3]; - - WEBRTC_SPL_MEMCPY_W16( (ISACdec_obj->plcstr_obj).prevPitchInvIn, Vector_Word16_1, FRAMESAMPLES/2 ); - - } - /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - - /* inverse pitch filter */ - WebRtcIsacfix_PitchFilter(Vector_Word16_1, Vector_Word16_2, &ISACdec_obj->pitchfiltstr_obj, PitchLags_Q7, PitchGains_Q12, 4); - - if( frame_nb == frame_mode ) - { - WEBRTC_SPL_MEMCPY_W16( (ISACdec_obj->plcstr_obj).prevPitchInvOut, &(Vector_Word16_2[FRAMESAMPLES/2 - (PITCH_MAX_LAG + 10)]), PITCH_MAX_LAG ); - } - - - /* reduce gain to compensate for pitch enhancer */ - /* gain = 1.0f - 0.45f * AvgPitchGain; */ - tmp32a = WEBRTC_SPL_MUL_16_16_RSFT(AvgPitchGain_Q12, 29, 0); // Q18 - tmp32b = 262144 - tmp32a; // Q18 - gainQ13 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); // Q13 - - for (k = 0; k < FRAMESAMPLES/2; k++) - { - Vector_Word32_1[k] = (WebRtc_Word32) WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(Vector_Word16_2[k], gainQ13), 3); // Q25 - } - - - /* perceptual post-filtering (using normalized lattice filter) */ - WebRtcIsacfix_NormLatticeFilterAr(ORDERLO, (ISACdec_obj->maskfiltstr_obj).PostStateLoGQ0, - Vector_Word32_1, lofilt_coefQ15, gain_lo_hiQ17, 0, Vector_Word16_1); - - /* --- Store Highpass Residual --- */ - for (k = 0; k < FRAMESAMPLES/2; k++) - Vector_Word32_1[k] = WEBRTC_SPL_LSHIFT_W32(Vector_Word32_2[k], 9); // Q16 -> Q25 - - for( k = 0; k < PITCH_MAX_LAG + 10; k++ ) - (ISACdec_obj->plcstr_obj).prevHP[k] = Vector_Word32_1[FRAMESAMPLES/2 - (PITCH_MAX_LAG + 10) + k]; - - - WebRtcIsacfix_NormLatticeFilterAr(ORDERHI, (ISACdec_obj->maskfiltstr_obj).PostStateHiGQ0, - Vector_Word32_1, hifilt_coefQ15, gain_lo_hiQ17, 1, Vector_Word16_2); - - /* recombine the 2 bands */ - - /* Form the polyphase signals, and compensate for DC offset */ - for (k=0;k<FRAMESAMPLES/2;k++) { - tmp_1 = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(((WebRtc_Word32)Vector_Word16_1[k]+Vector_Word16_2[k] + 1)); /* Construct a new upper channel signal*/ - tmp_2 = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(((WebRtc_Word32)Vector_Word16_1[k]-Vector_Word16_2[k])); /* Construct a new lower channel signal*/ - Vector_Word16_1[k] = tmp_1; - Vector_Word16_2[k] = tmp_2; - } - - WebRtcIsacfix_FilterAndCombine1(Vector_Word16_1, Vector_Word16_2, signal_out16 + frame_nb * processed_samples, &ISACdec_obj->postfiltbankstr_obj); - - } - return len; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/decode_bwe.c b/src/modules/audio_coding/codecs/isac/fix/source/decode_bwe.c deleted file mode 100644 index 68c6003..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/decode_bwe.c +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * decode_bwe.c - * - * This C file contains the internal decode bandwidth estimate function. - * - */ - - -#include "bandwidth_estimator.h" -#include "codec.h" -#include "entropy_coding.h" -#include "structs.h" - - - - -int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr *bwest_str, - Bitstr_dec *streamdata, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts) -{ - WebRtc_Word16 index; - WebRtc_Word16 frame_samples; - int err; - - /* decode framelength */ - err = WebRtcIsacfix_DecodeFrameLen(streamdata, &frame_samples); - /* error check */ - if (err<0) { - return err; - } - - /* decode BW estimation */ - err = WebRtcIsacfix_DecodeSendBandwidth(streamdata, &index); - /* error check */ - if (err<0) { - return err; - } - - /* Update BWE with received data */ - err = WebRtcIsacfix_UpdateUplinkBwImpl( - bwest_str, - rtp_seq_number, - (WebRtc_UWord16)WEBRTC_SPL_UDIV(WEBRTC_SPL_UMUL(frame_samples,1000), FS), - send_ts, - arr_ts, - (WebRtc_Word16) packet_size, /* in bytes */ - index); - - /* error check */ - if (err<0) { - return err; - } - - /* Succesful */ - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/decode_plc.c b/src/modules/audio_coding/codecs/isac/fix/source/decode_plc.c deleted file mode 100644 index de51658..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/decode_plc.c +++ /dev/null
@@ -1,830 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * decode_plc.c - * - * Packet Loss Concealment. - * - */ - -#include <string.h> - -#include "settings.h" -#include "entropy_coding.h" -#include "pitch_estimator.h" -#include "bandwidth_estimator.h" -#include "structs.h" -#include "codec.h" - - -#define NO_OF_PRIMES 8 -#define NOISE_FILTER_LEN 30 - -/* - * function to decode the bitstream - * returns the total number of bytes in the stream - */ - -static WebRtc_Word16 plc_filterma_Fast( - WebRtc_Word16 *In, /* (i) Vector to be filtered. InOut[-orderCoef+1] - to InOut[-1] contains state */ - WebRtc_Word16 *Out, /* (o) Filtered vector */ - WebRtc_Word16 *B, /* (i) The filter coefficients (in Q0) */ - WebRtc_Word16 Blen, /* (i) Number of B coefficients */ - WebRtc_Word16 len, /* (i) Number of samples to be filtered */ - WebRtc_Word16 reduceDecay, - WebRtc_Word16 decay, - WebRtc_Word16 rshift ) -{ - int i, j; - WebRtc_Word32 o; - WebRtc_Word32 lim; - - lim = WEBRTC_SPL_LSHIFT_W32( (WebRtc_Word32)1, 15 + rshift )-1; - - for (i = 0; i < len; i++) - { - G_CONST WebRtc_Word16 *b_ptr = &B[0]; - G_CONST WebRtc_Word16 *x_ptr = &In[i]; - - o = (WebRtc_Word32)0; - - for (j = 0;j < Blen; j++) - { - o = WEBRTC_SPL_ADD_SAT_W32( o, WEBRTC_SPL_MUL_16_16( *b_ptr, *x_ptr) ); - b_ptr++; - x_ptr--; - } - - /* to round off correctly */ - o = WEBRTC_SPL_ADD_SAT_W32( o, WEBRTC_SPL_LSHIFT_W32( 1, (rshift-1) ) ); - - /* saturate according to the domain of the filter coefficients */ - o = WEBRTC_SPL_SAT((WebRtc_Word32)lim, o, (WebRtc_Word32)-lim); - - /* o should be in the range of WebRtc_Word16 */ - o = WEBRTC_SPL_RSHIFT_W32( o, rshift ); - - /* decay the output signal; this is specific to plc */ - *Out++ = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( (WebRtc_Word16)o, decay, 15); // ((o + (WebRtc_Word32)2048) >> 12); - - /* change the decay */ - decay -= reduceDecay; - if( decay < 0 ) - decay = 0; - } - return( decay ); -} - - - - - - - - -static __inline WebRtc_Word32 log2_Q8_T( WebRtc_UWord32 x ) { - - WebRtc_Word32 zeros, lg2; - WebRtc_Word16 frac; - - zeros=WebRtcSpl_NormU32(x); - frac=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(((WebRtc_UWord32)WEBRTC_SPL_LSHIFT_W32(x, zeros)&0x7FFFFFFF), 23); - /* log2(magn(i)) */ - - lg2= (WEBRTC_SPL_LSHIFT_W16((31-zeros), 8)+frac); - return lg2; - -} - -static __inline WebRtc_Word16 exp2_Q10_T(WebRtc_Word16 x) { // Both in and out in Q10 - - WebRtc_Word16 tmp16_1, tmp16_2; - - tmp16_2=(WebRtc_Word16)(0x0400|(x&0x03FF)); - tmp16_1=-(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(x,10); - if(tmp16_1>0) - return (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W16(tmp16_2, tmp16_1); - else - return (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1); - -} - - -/* - This is a fixed-point version of the above code with limLow = 700 and limHigh = 5000, - hard-coded. The values 700 and 5000 were experimentally obtained. - - The function implements membership values for two sets. The mebership functions are - of second orders corresponding to half-bell-shapped pulses. -*/ -static void MemshipValQ15( WebRtc_Word16 in, WebRtc_Word16 *A, WebRtc_Word16 *B ) -{ - WebRtc_Word16 x; - - in -= 700; /* translate the lowLim to 0, limHigh = 5000 - 700, M = 2150 */ - - if( in <= 2150 ) - { - if( in > 0 ) - { - /* b = in^2 / (2 * M^2), a = 1 - b in Q0. - We have to compute in Q15 */ - - /* x = in / 2150 {in Q15} = x * 15.2409 {in Q15} = - x*15 + (x*983)/(2^12); note that 983/2^12 = 0.23999 */ - - /* we are sure that x is in the range of WebRtc_Word16 */ - x = (WebRtc_Word16)( WEBRTC_SPL_MUL_16_16( in, 15 ) + - WEBRTC_SPL_MUL_16_16_RSFT( in, 983, 12) ); - /* b = x^2 / 2 {in Q15} so a shift of 16 is required to - be in correct domain and one more for the division by 2 */ - *B = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( WEBRTC_SPL_MUL_16_16( x, x ) + 0x00010000, 17 ); - *A = WEBRTC_SPL_WORD16_MAX - *B; - } - else - { - *B = 0; - *A = WEBRTC_SPL_WORD16_MAX; - } - } - else - { - if( in < 4300 ) - { - /* This is a mirror case of the above */ - in = 4300 - in; - x = (WebRtc_Word16)( WEBRTC_SPL_MUL_16_16( in, 15 ) + - WEBRTC_SPL_MUL_16_16_RSFT( in, 983, 12) ); - /* b = x^2 / 2 {in Q15} so a shift of 16 is required to - be in correct domain and one more for the division by 2 */ - *A = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( WEBRTC_SPL_MUL_16_16( x, x ) + 0x00010000, 17 ); - *B = WEBRTC_SPL_WORD16_MAX - *A; - - } - else - { - *A = 0; - *B = WEBRTC_SPL_WORD16_MAX; - } - } -} - - - - -static void LinearResampler( WebRtc_Word16 *in, WebRtc_Word16 *out, WebRtc_Word16 lenIn, WebRtc_Word16 lenOut ) -{ - WebRtc_Word32 n; - WebRtc_Word16 resOut, i, j, relativePos, diff; /* */ - WebRtc_UWord16 udiff; - - if( lenIn == lenOut ) - { - WEBRTC_SPL_MEMCPY_W16( out, in, lenIn ); - return; - } - - n = WEBRTC_SPL_MUL_16_16( (WebRtc_Word16)(lenIn-1), RESAMP_RES ); - resOut = WebRtcSpl_DivW32W16ResW16( n, (WebRtc_Word16)(lenOut-1) ); - - out[0] = in[0]; - for( i = 1, j = 0, relativePos = 0; i < lenOut; i++ ) - { - - relativePos += resOut; - while( relativePos > RESAMP_RES ) - { - j++; - relativePos -= RESAMP_RES; - } - - - /* an overflow may happen and the differce in sample values may - * require more than 16 bits. We like to avoid 32 bit arithmatic - * as much as possible */ - - if( (in[ j ] > 0) && (in[j + 1] < 0) ) - { - udiff = (WebRtc_UWord16)(in[ j ] - in[j + 1]); - out[ i ] = in[ j ] - (WebRtc_UWord16)( ((WebRtc_Word32)( udiff * relativePos )) >> RESAMP_RES_BIT); - } - else - { - if( (in[j] < 0) && (in[j+1] > 0) ) - { - udiff = (WebRtc_UWord16)( in[j + 1] - in[ j ] ); - out[ i ] = in[ j ] + (WebRtc_UWord16)( ((WebRtc_Word32)( udiff * relativePos )) >> RESAMP_RES_BIT); - } - else - { - diff = in[ j + 1 ] - in[ j ]; - out[ i ] = in[ j ] + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( diff, relativePos, RESAMP_RES_BIT ); - } - } - } -} - - - - - -WebRtc_Word16 WebRtcIsacfix_DecodePlcImpl(WebRtc_Word16 *signal_out16, - ISACFIX_DecInst_t *ISACdec_obj, - WebRtc_Word16 *current_framesamples ) -{ - int subframecnt; - WebRtc_Word16 len = 0; - - WebRtc_Word16* Vector_Word16_1; - WebRtc_Word16 Vector_Word16_Extended_1[FRAMESAMPLES_HALF + NOISE_FILTER_LEN]; - WebRtc_Word16* Vector_Word16_2; - WebRtc_Word16 Vector_Word16_Extended_2[FRAMESAMPLES_HALF + NOISE_FILTER_LEN]; - - WebRtc_Word32 Vector_Word32_1[FRAMESAMPLES_HALF]; - WebRtc_Word32 Vector_Word32_2[FRAMESAMPLES_HALF]; - - WebRtc_Word16 lofilt_coefQ15[ORDERLO*SUBFRAMES]; //refl. coeffs - WebRtc_Word16 hifilt_coefQ15[ORDERHI*SUBFRAMES]; //refl. coeffs - - WebRtc_Word16 pitchLags_Q7[PITCH_SUBFRAMES]; - WebRtc_Word16 pitchGains_Q12[PITCH_SUBFRAMES]; - - WebRtc_Word16 tmp_1, tmp_2; - WebRtc_Word32 tmp32a, tmp32b; - WebRtc_Word16 gainQ13; - - WebRtc_Word16 myDecayRate; - - /* ---------- PLC variables ------------ */ - WebRtc_Word16 lag0, i, k, noiseIndex; - WebRtc_Word16 stretchPitchLP[PITCH_MAX_LAG + 10], stretchPitchLP1[PITCH_MAX_LAG + 10]; - - WebRtc_Word32 gain_lo_hiQ17[2*SUBFRAMES]; - - WebRtc_Word16 nLP, pLP, wNoisyLP, wPriodicLP, tmp16, minIdx; - WebRtc_Word32 nHP, pHP, wNoisyHP, wPriodicHP, corr, minCorr, maxCoeff; - WebRtc_Word16 noise1, rshift; - - - WebRtc_Word16 ltpGain, pitchGain, myVoiceIndicator, myAbs, maxAbs; - WebRtc_Word32 varIn, varOut, logVarIn, logVarOut, Q, logMaxAbs; - int rightShiftIn, rightShiftOut; - - - /* ------------------------------------- */ - - - myDecayRate = (DECAY_RATE); - Vector_Word16_1 = &Vector_Word16_Extended_1[NOISE_FILTER_LEN]; - Vector_Word16_2 = &Vector_Word16_Extended_2[NOISE_FILTER_LEN]; - - - /* ----- Simply Copy Previous LPC parameters ------ */ - for( subframecnt = 0; subframecnt < SUBFRAMES; subframecnt++ ) - { - /* lower Band */ - WEBRTC_SPL_MEMCPY_W16(&lofilt_coefQ15[ subframecnt * ORDERLO ], - (ISACdec_obj->plcstr_obj).lofilt_coefQ15, ORDERLO); - gain_lo_hiQ17[2*subframecnt] = (ISACdec_obj->plcstr_obj).gain_lo_hiQ17[0]; - - /* Upper Band */ - WEBRTC_SPL_MEMCPY_W16(&hifilt_coefQ15[ subframecnt * ORDERHI ], - (ISACdec_obj->plcstr_obj).hifilt_coefQ15, ORDERHI); - gain_lo_hiQ17[2*subframecnt + 1] = (ISACdec_obj->plcstr_obj).gain_lo_hiQ17[1]; - } - - - - - lag0 = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).lastPitchLag_Q7 + 64, 7 ) + 1; - - - if( (ISACdec_obj->plcstr_obj).used != PLC_WAS_USED ) - { - (ISACdec_obj->plcstr_obj).pitchCycles = 0; - - (ISACdec_obj->plcstr_obj).lastPitchLP = - &((ISACdec_obj->plcstr_obj).prevPitchInvIn[FRAMESAMPLES_HALF - lag0]); - minCorr = WEBRTC_SPL_WORD32_MAX; - - if ( (FRAMESAMPLES_HALF - 2*lag0 - 10) > 0 ) - { - minIdx = 11; - for( i = 0; i < 21; i++ ) - { - corr = 0; - for( k = 0; k < lag0; k++ ) - { - corr = WEBRTC_SPL_ADD_SAT_W32( corr, WEBRTC_SPL_ABS_W32( - WEBRTC_SPL_SUB_SAT_W16( - (ISACdec_obj->plcstr_obj).lastPitchLP[k], - (ISACdec_obj->plcstr_obj).prevPitchInvIn[ - FRAMESAMPLES_HALF - 2*lag0 - 10 + i + k ] ) ) ); - } - if( corr < minCorr ) - { - minCorr = corr; - minIdx = i; - } - } - (ISACdec_obj->plcstr_obj).prevPitchLP = - &( (ISACdec_obj->plcstr_obj).prevPitchInvIn[ - FRAMESAMPLES_HALF - lag0*2 - 10 + minIdx] ); - } - else - { - (ISACdec_obj->plcstr_obj).prevPitchLP = - (ISACdec_obj->plcstr_obj).lastPitchLP; - } - pitchGain = (ISACdec_obj->plcstr_obj).lastPitchGain_Q12; - - WebRtcSpl_AutoCorrelation( - &(ISACdec_obj->plcstr_obj).prevPitchInvIn[FRAMESAMPLES_HALF - lag0], - lag0, 0, &varIn, &rightShiftIn); - WebRtcSpl_AutoCorrelation( - &(ISACdec_obj->plcstr_obj).prevPitchInvOut[PITCH_MAX_LAG + 10 - lag0], - lag0, 0, &varOut, &rightShiftOut); - - maxAbs = 0; - for( i = 0; i< lag0; i++) - { - myAbs = WEBRTC_SPL_ABS_W16( - (ISACdec_obj->plcstr_obj).prevPitchInvOut[ - PITCH_MAX_LAG + 10 - lag0 + i] ); - maxAbs = (myAbs > maxAbs)? myAbs:maxAbs; - } - logVarIn = log2_Q8_T( (WebRtc_UWord32)( varIn ) ) + - (WebRtc_Word32)(rightShiftIn << 8); - logVarOut = log2_Q8_T( (WebRtc_UWord32)( varOut ) ) + - (WebRtc_Word32)(rightShiftOut << 8); - logMaxAbs = log2_Q8_T( (WebRtc_UWord32)( maxAbs ) ); - - ltpGain = (WebRtc_Word16)(logVarOut - logVarIn); - Q = 2 * logMaxAbs - ( logVarOut - 1512 ); - - /* - * --- - * We are computing sqrt( (VarIn/lag0) / var( noise ) ) - * var( noise ) is almost 256. we have already computed log2( VarIn ) in Q8 - * so we actually compute 2^( 0.5*(log2( VarIn ) - log2( lag0 ) - log2( var(noise ) ) ). - * Note that put log function is in Q8 but the exponential function is in Q10. - * -- - */ - - logVarIn -= log2_Q8_T( (WebRtc_UWord32)( lag0 ) ); - tmp16 = (WebRtc_Word16)((logVarIn<<1) - (4<<10) ); - rightShiftIn = 0; - if( tmp16 > 4096 ) - { - tmp16 -= 4096; - tmp16 = exp2_Q10_T( tmp16 ); - tmp16 >>= 6; - } - else - tmp16 = exp2_Q10_T( tmp16 )>>10; - - (ISACdec_obj->plcstr_obj).std = tmp16 - 4; - - if( (ltpGain < 110) || (ltpGain > 230) ) - { - if( ltpGain < 100 && (pitchGain < 1800) ) - { - (ISACdec_obj->plcstr_obj).A = WEBRTC_SPL_WORD16_MAX; - } - else - { - (ISACdec_obj->plcstr_obj).A = ((ltpGain < 110) && (Q < 800) - )? WEBRTC_SPL_WORD16_MAX:0; - } - (ISACdec_obj->plcstr_obj).B = WEBRTC_SPL_WORD16_MAX - - (ISACdec_obj->plcstr_obj).A; - } - else - { - if( (pitchGain < 450) || (pitchGain > 1600) ) - { - (ISACdec_obj->plcstr_obj).A = ((pitchGain < 450) - )? WEBRTC_SPL_WORD16_MAX:0; - (ISACdec_obj->plcstr_obj).B = WEBRTC_SPL_WORD16_MAX - - (ISACdec_obj->plcstr_obj).A; - } - else - { - myVoiceIndicator = ltpGain * 2 + pitchGain; - MemshipValQ15( myVoiceIndicator, - &(ISACdec_obj->plcstr_obj).A, &(ISACdec_obj->plcstr_obj).B ); - } - } - - - - myVoiceIndicator = ltpGain * 16 + pitchGain * 2 + (pitchGain >> 8); - MemshipValQ15( myVoiceIndicator, - &(ISACdec_obj->plcstr_obj).A, &(ISACdec_obj->plcstr_obj).B ); - - - - (ISACdec_obj->plcstr_obj).stretchLag = lag0; - (ISACdec_obj->plcstr_obj).pitchIndex = 0; - - } - else - { - myDecayRate = (DECAY_RATE<<2); - } - - if( (ISACdec_obj->plcstr_obj).B < 1000 ) - { - myDecayRate += (DECAY_RATE<<3); - } - - /* ------------ reconstructing the residual signal ------------------ */ - - LinearResampler( (ISACdec_obj->plcstr_obj).lastPitchLP, - stretchPitchLP, lag0, (ISACdec_obj->plcstr_obj).stretchLag ); - /* inverse pitch filter */ - - pitchLags_Q7[0] = pitchLags_Q7[1] = pitchLags_Q7[2] = pitchLags_Q7[3] = - ((ISACdec_obj->plcstr_obj).stretchLag<<7); - pitchGains_Q12[3] = ( (ISACdec_obj->plcstr_obj).lastPitchGain_Q12); - pitchGains_Q12[2] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - pitchGains_Q12[3], 1010, 10 ); - pitchGains_Q12[1] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - pitchGains_Q12[2], 1010, 10 ); - pitchGains_Q12[0] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - pitchGains_Q12[1], 1010, 10 ); - - - /* most of the time either B or A are zero so seperating */ - if( (ISACdec_obj->plcstr_obj).B == 0 ) - { - for( i = 0; i < FRAMESAMPLES_HALF; i++ ) - { - /* --- Low Pass */ - (ISACdec_obj->plcstr_obj).seed = WEBRTC_SPL_RAND( - (ISACdec_obj->plcstr_obj).seed ); - Vector_Word16_1[i] = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).seed, 10 ) - 16; - - /* --- Highpass */ - (ISACdec_obj->plcstr_obj).seed = WEBRTC_SPL_RAND( - (ISACdec_obj->plcstr_obj).seed ); - Vector_Word16_2[i] = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).seed, 10 ) - 16; - - } - for( i = 1; i < NOISE_FILTER_LEN; i++ ) - { - (ISACdec_obj->plcstr_obj).seed = WEBRTC_SPL_RAND( - (ISACdec_obj->plcstr_obj).seed ); - Vector_Word16_Extended_1[ i ] = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).seed, 10 ) - 16; - - (ISACdec_obj->plcstr_obj).seed = WEBRTC_SPL_RAND( - (ISACdec_obj->plcstr_obj).seed ); - Vector_Word16_Extended_2[ i ] = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).seed, 10 ) - 16; - } - plc_filterma_Fast(Vector_Word16_1, Vector_Word16_Extended_1, - &(ISACdec_obj->plcstr_obj).prevPitchInvIn[FRAMESAMPLES_HALF - - NOISE_FILTER_LEN], (WebRtc_Word16) NOISE_FILTER_LEN, - (WebRtc_Word16) FRAMESAMPLES_HALF, (WebRtc_Word16)(5), - (ISACdec_obj->plcstr_obj).decayCoeffNoise, (WebRtc_Word16)(6)); - - maxCoeff = WebRtcSpl_MaxAbsValueW32( - &(ISACdec_obj->plcstr_obj).prevHP[ - PITCH_MAX_LAG + 10 - NOISE_FILTER_LEN], NOISE_FILTER_LEN ); - - rshift = 0; - while( maxCoeff > WEBRTC_SPL_WORD16_MAX ) - { - maxCoeff = WEBRTC_SPL_RSHIFT_W32(maxCoeff, 1); - rshift++; - } - for( i = 0; i < NOISE_FILTER_LEN; i++ ) { - Vector_Word16_1[ FRAMESAMPLES_HALF - NOISE_FILTER_LEN + i] = - (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( - (ISACdec_obj->plcstr_obj).prevHP[ - PITCH_MAX_LAG + 10 - NOISE_FILTER_LEN + i], rshift); - } - (ISACdec_obj->plcstr_obj).decayCoeffNoise = plc_filterma_Fast( - Vector_Word16_2, - Vector_Word16_Extended_2, - &Vector_Word16_1[FRAMESAMPLES_HALF - NOISE_FILTER_LEN], - (WebRtc_Word16) NOISE_FILTER_LEN, - (WebRtc_Word16) FRAMESAMPLES_HALF, - (WebRtc_Word16) (5), - (ISACdec_obj->plcstr_obj).decayCoeffNoise, - (WebRtc_Word16) (7) ); - - for( i = 0; i < FRAMESAMPLES_HALF; i++ ) - Vector_Word32_2[i] = WEBRTC_SPL_LSHIFT_W32( - (WebRtc_Word32)Vector_Word16_Extended_2[i], rshift ); - - Vector_Word16_1 = Vector_Word16_Extended_1; - } - else - { - if( (ISACdec_obj->plcstr_obj).A == 0 ) - { - /* ------ Periodic Vector --- */ - for( i = 0, noiseIndex = 0; i < FRAMESAMPLES_HALF; i++, noiseIndex++ ) - { - /* --- Lowpass */ - pLP = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - stretchPitchLP[(ISACdec_obj->plcstr_obj).pitchIndex], - (ISACdec_obj->plcstr_obj).decayCoeffPriodic, 15 ); - - /* --- Highpass */ - pHP = (WebRtc_Word32)WEBRTC_SPL_MUL_16_32_RSFT15( - (ISACdec_obj->plcstr_obj).decayCoeffPriodic, - (ISACdec_obj->plcstr_obj).prevHP[PITCH_MAX_LAG + 10 - - (ISACdec_obj->plcstr_obj).stretchLag + - (ISACdec_obj->plcstr_obj).pitchIndex] ); - - /* --- lower the muliplier (more decay at next sample) --- */ - (ISACdec_obj->plcstr_obj).decayCoeffPriodic -= (myDecayRate); - if( (ISACdec_obj->plcstr_obj).decayCoeffPriodic < 0 ) - (ISACdec_obj->plcstr_obj).decayCoeffPriodic = 0; - - (ISACdec_obj->plcstr_obj).pitchIndex++; - - if( (ISACdec_obj->plcstr_obj).pitchIndex == - (ISACdec_obj->plcstr_obj).stretchLag ) - { - (ISACdec_obj->plcstr_obj).pitchIndex = 0; - (ISACdec_obj->plcstr_obj).pitchCycles++; - - if( (ISACdec_obj->plcstr_obj).stretchLag != (lag0 + 1) ) - { - (ISACdec_obj->plcstr_obj).stretchLag = lag0 + 1; - } - else - { - (ISACdec_obj->plcstr_obj).stretchLag = lag0; - } - - (ISACdec_obj->plcstr_obj).stretchLag = ( - (ISACdec_obj->plcstr_obj).stretchLag > PITCH_MAX_LAG - )? (PITCH_MAX_LAG):(ISACdec_obj->plcstr_obj).stretchLag; - - LinearResampler( (ISACdec_obj->plcstr_obj).lastPitchLP, - stretchPitchLP, lag0, (ISACdec_obj->plcstr_obj).stretchLag ); - - LinearResampler( (ISACdec_obj->plcstr_obj).prevPitchLP, - stretchPitchLP1, lag0, (ISACdec_obj->plcstr_obj).stretchLag ); - - switch( (ISACdec_obj->plcstr_obj).pitchCycles ) - { - case 1: - { - for( k=0; k<(ISACdec_obj->plcstr_obj).stretchLag; k++ ) - { - stretchPitchLP[k] = (WebRtc_Word16)(( - (WebRtc_Word32)stretchPitchLP[k]* 3 + - (WebRtc_Word32)stretchPitchLP1[k])>>2); - } - break; - } - case 2: - { - for( k=0; k<(ISACdec_obj->plcstr_obj).stretchLag; k++ ) - { - stretchPitchLP[k] = (WebRtc_Word16)(( - (WebRtc_Word32)stretchPitchLP[k] + - (WebRtc_Word32)stretchPitchLP1[k] )>>1); - } - break; - } - case 3: - { - for( k=0; k<(ISACdec_obj->plcstr_obj).stretchLag; k++ ) - { - stretchPitchLP[k] = (WebRtc_Word16)((stretchPitchLP[k] + - (WebRtc_Word32)stretchPitchLP1[k]*3 )>>2); - } - break; - } - } - - if( (ISACdec_obj->plcstr_obj).pitchCycles == 3 ) - { - myDecayRate += 35; //(myDecayRate>>1); - (ISACdec_obj->plcstr_obj).pitchCycles = 0; - } - - } - - /* ------ Sum the noisy and periodic signals ------ */ - Vector_Word16_1[i] = pLP; - Vector_Word32_2[i] = pHP; - } - } - else - { - for( i = 0, noiseIndex = 0; i < FRAMESAMPLES_HALF; i++, noiseIndex++ ) - { - - (ISACdec_obj->plcstr_obj).seed = WEBRTC_SPL_RAND( - (ISACdec_obj->plcstr_obj).seed ); - - noise1 = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).seed, 10 ) - 16; - - nLP = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - (WebRtc_Word16)((noise1)*(ISACdec_obj->plcstr_obj).std), - (ISACdec_obj->plcstr_obj).decayCoeffNoise, 15 ); - - /* --- Highpass */ - (ISACdec_obj->plcstr_obj).seed = WEBRTC_SPL_RAND( - (ISACdec_obj->plcstr_obj).seed ); - noise1 = WEBRTC_SPL_RSHIFT_W16( - (ISACdec_obj->plcstr_obj).seed, 11 ) - 8; - - nHP = (WebRtc_Word32)WEBRTC_SPL_MUL_16_32_RSFT15( - (ISACdec_obj->plcstr_obj).decayCoeffNoise, - (WebRtc_Word32)(noise1*(ISACdec_obj->plcstr_obj).std) ); - - /* --- lower the muliplier (more decay at next sample) --- */ - (ISACdec_obj->plcstr_obj).decayCoeffNoise -= (myDecayRate); - if( (ISACdec_obj->plcstr_obj).decayCoeffNoise < 0 ) - (ISACdec_obj->plcstr_obj).decayCoeffNoise = 0; - - /* ------ Periodic Vector --- */ - /* --- Lowpass */ - pLP = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - stretchPitchLP[(ISACdec_obj->plcstr_obj).pitchIndex], - (ISACdec_obj->plcstr_obj).decayCoeffPriodic, 15 ); - - /* --- Highpass */ - pHP = (WebRtc_Word32)WEBRTC_SPL_MUL_16_32_RSFT15( - (ISACdec_obj->plcstr_obj).decayCoeffPriodic, - (ISACdec_obj->plcstr_obj).prevHP[PITCH_MAX_LAG + 10 - - (ISACdec_obj->plcstr_obj).stretchLag + - (ISACdec_obj->plcstr_obj).pitchIndex] ); - - /* --- lower the muliplier (more decay at next sample) --- */ - (ISACdec_obj->plcstr_obj).decayCoeffPriodic -= (myDecayRate); - if( (ISACdec_obj->plcstr_obj).decayCoeffPriodic < 0 ) - { - (ISACdec_obj->plcstr_obj).decayCoeffPriodic = 0; - } - - /* ------ Weighting the noisy and periodic vectors ------- */ - wNoisyLP = (WebRtc_Word16)(WEBRTC_SPL_MUL_16_16_RSFT( - (ISACdec_obj->plcstr_obj).A, nLP, 15 ) ); - wNoisyHP = (WebRtc_Word32)(WEBRTC_SPL_MUL_16_32_RSFT15( - (ISACdec_obj->plcstr_obj).A, (nHP) ) ); - - wPriodicLP = (WebRtc_Word16)(WEBRTC_SPL_MUL_16_16_RSFT( - (ISACdec_obj->plcstr_obj).B, pLP, 15)); - wPriodicHP = (WebRtc_Word32)(WEBRTC_SPL_MUL_16_32_RSFT15( - (ISACdec_obj->plcstr_obj).B, pHP)); - - (ISACdec_obj->plcstr_obj).pitchIndex++; - - if((ISACdec_obj->plcstr_obj).pitchIndex == - (ISACdec_obj->plcstr_obj).stretchLag) - { - (ISACdec_obj->plcstr_obj).pitchIndex = 0; - (ISACdec_obj->plcstr_obj).pitchCycles++; - - if( (ISACdec_obj->plcstr_obj).stretchLag != (lag0 + 1) ) - (ISACdec_obj->plcstr_obj).stretchLag = lag0 + 1; - else - (ISACdec_obj->plcstr_obj).stretchLag = lag0; - - (ISACdec_obj->plcstr_obj).stretchLag = ( - (ISACdec_obj->plcstr_obj).stretchLag > PITCH_MAX_LAG - )? (PITCH_MAX_LAG):(ISACdec_obj->plcstr_obj).stretchLag; - LinearResampler( - (ISACdec_obj->plcstr_obj).lastPitchLP, - stretchPitchLP, lag0, (ISACdec_obj->plcstr_obj).stretchLag ); - - LinearResampler((ISACdec_obj->plcstr_obj).prevPitchLP, - stretchPitchLP1, lag0, (ISACdec_obj->plcstr_obj).stretchLag ); - - switch((ISACdec_obj->plcstr_obj).pitchCycles) - { - case 1: - { - for( k=0; k<(ISACdec_obj->plcstr_obj).stretchLag; k++ ) - { - stretchPitchLP[k] = (WebRtc_Word16)(( - (WebRtc_Word32)stretchPitchLP[k]* 3 + - (WebRtc_Word32)stretchPitchLP1[k] )>>2); - } - break; - } - case 2: - { - for( k=0; k<(ISACdec_obj->plcstr_obj).stretchLag; k++ ) - { - stretchPitchLP[k] = (WebRtc_Word16)(( - (WebRtc_Word32)stretchPitchLP[k] + - (WebRtc_Word32)stretchPitchLP1[k])>>1); - } - break; - } - case 3: - { - for( k=0; k<(ISACdec_obj->plcstr_obj).stretchLag; k++ ) - { - stretchPitchLP[k] = (WebRtc_Word16)( - (stretchPitchLP[k] + - (WebRtc_Word32)stretchPitchLP1[k]*3 )>>2); - } - break; - } - } - - if( (ISACdec_obj->plcstr_obj).pitchCycles == 3 ) - { - myDecayRate += 55; //(myDecayRate>>1); - (ISACdec_obj->plcstr_obj).pitchCycles = 0; - } - } - - /* ------ Sum the noisy and periodic signals ------ */ - Vector_Word16_1[i] = (WebRtc_Word16)WEBRTC_SPL_ADD_SAT_W16( - wNoisyLP, wPriodicLP ); - Vector_Word32_2[i] = (WebRtc_Word32)WEBRTC_SPL_ADD_SAT_W32( - wNoisyHP, wPriodicHP ); - } - } - } - /* ----------------- residual signal is reconstructed ------------------ */ - - k = (ISACdec_obj->plcstr_obj).pitchIndex; - /* --- Write one pitch cycle for recovery block --- */ - - for( i = 0; i < RECOVERY_OVERLAP; i++ ) - { - (ISACdec_obj->plcstr_obj).overlapLP[i] = (WebRtc_Word16)( - WEBRTC_SPL_MUL_16_16_RSFT(stretchPitchLP[k], - (ISACdec_obj->plcstr_obj).decayCoeffPriodic, 15) ); - k = ( k < ((ISACdec_obj->plcstr_obj).stretchLag - 1) )? (k+1):0; - } - - (ISACdec_obj->plcstr_obj).lastPitchLag_Q7 = (ISACdec_obj->plcstr_obj).stretchLag << 7; - - - /* --- Inverse Pitch Filter --- */ - WebRtcIsacfix_PitchFilter(Vector_Word16_1, Vector_Word16_2, - &ISACdec_obj->pitchfiltstr_obj, pitchLags_Q7, pitchGains_Q12, 4); - - /* reduce gain to compensate for pitch enhancer */ - /* gain = 1.0f - 0.45f * AvgPitchGain; */ - tmp32a = WEBRTC_SPL_MUL_16_16_RSFT((ISACdec_obj->plcstr_obj).AvgPitchGain_Q12, - 29, 0); // Q18 - tmp32b = 262144 - tmp32a; // Q18 - gainQ13 = (WebRtc_Word16) (tmp32b >> 5); // Q13 - - /* perceptual post-filtering (using normalized lattice filter) */ - for (k = 0; k < FRAMESAMPLES_HALF; k++) - Vector_Word32_1[k] = (WebRtc_Word32) WEBRTC_SPL_MUL_16_16( - Vector_Word16_2[k], gainQ13) << 3; // Q25 - - - WebRtcIsacfix_NormLatticeFilterAr(ORDERLO, - (ISACdec_obj->maskfiltstr_obj).PostStateLoGQ0, - Vector_Word32_1, lofilt_coefQ15, gain_lo_hiQ17, 0, Vector_Word16_1); - - WebRtcIsacfix_NormLatticeFilterAr(ORDERHI, - (ISACdec_obj->maskfiltstr_obj).PostStateHiGQ0, - Vector_Word32_2, hifilt_coefQ15, gain_lo_hiQ17, 1, Vector_Word16_2); - - /* recombine the 2 bands */ - - /* Form the polyphase signals, and compensate for DC offset */ - for (k=0;k<FRAMESAMPLES_HALF;k++) - { - /* Construct a new upper channel signal*/ - tmp_1 = (WebRtc_Word16)WebRtcSpl_SatW32ToW16( - ((WebRtc_Word32)Vector_Word16_1[k]+Vector_Word16_2[k] + 1)); - /* Construct a new lower channel signal*/ - tmp_2 = (WebRtc_Word16)WebRtcSpl_SatW32ToW16( - ((WebRtc_Word32)Vector_Word16_1[k]-Vector_Word16_2[k])); - Vector_Word16_1[k] = tmp_1; - Vector_Word16_2[k] = tmp_2; - } - - - WebRtcIsacfix_FilterAndCombine1(Vector_Word16_1, - Vector_Word16_2, signal_out16, &ISACdec_obj->postfiltbankstr_obj); - - (ISACdec_obj->plcstr_obj).used = PLC_WAS_USED; - *current_framesamples = 480; - - return len; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/encode.c b/src/modules/audio_coding/codecs/isac/fix/source/encode.c deleted file mode 100644 index cb531e5..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/encode.c +++ /dev/null
@@ -1,626 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * encode.c - * - * Encoding function for the iSAC coder. - * - */ - -#include "arith_routins.h" -#include "bandwidth_estimator.h" -#include "codec.h" -#include "pitch_gain_tables.h" -#include "pitch_lag_tables.h" -#include "entropy_coding.h" -#include "lpc_tables.h" -#include "lpc_masking_model.h" -#include "pitch_estimator.h" -#include "structs.h" -#include <stdio.h> - - -int WebRtcIsacfix_EncodeImpl(WebRtc_Word16 *in, - ISACFIX_EncInst_t *ISACenc_obj, - BwEstimatorstr *bw_estimatordata, - WebRtc_Word16 CodingMode) -{ - WebRtc_Word16 stream_length = 0; - WebRtc_Word16 usefulstr_len = 0; - int k; - WebRtc_Word16 BWno; - - WebRtc_Word16 lofilt_coefQ15[(ORDERLO)*SUBFRAMES]; - WebRtc_Word16 hifilt_coefQ15[(ORDERHI)*SUBFRAMES]; - WebRtc_Word32 gain_lo_hiQ17[2*SUBFRAMES]; - - WebRtc_Word16 LPandHP[FRAMESAMPLES/2 + QLOOKAHEAD]; - WebRtc_Word16 LP16a[FRAMESAMPLES/2 + QLOOKAHEAD]; - WebRtc_Word16 HP16a[FRAMESAMPLES/2 + QLOOKAHEAD]; - - WebRtc_Word16 PitchLags_Q7[PITCH_SUBFRAMES]; - WebRtc_Word16 PitchGains_Q12[PITCH_SUBFRAMES]; - WebRtc_Word16 AvgPitchGain_Q12; - - WebRtc_Word16 frame_mode; /* 0 for 30ms, 1 for 60ms */ - WebRtc_Word16 processed_samples; - int status; - - WebRtc_Word32 bits_gainsQ11; - WebRtc_Word16 MinBytes; - WebRtc_Word16 bmodel; - - transcode_obj transcodingParam; - WebRtc_Word16 payloadLimitBytes; - WebRtc_Word16 arithLenBeforeEncodingDFT; - WebRtc_Word16 iterCntr; - - /* copy new frame length and bottle neck rate only for the first 10 ms data */ - if (ISACenc_obj->buffer_index == 0) { - /* set the framelength for the next packet */ - ISACenc_obj->current_framesamples = ISACenc_obj->new_framelength; - } - - frame_mode = ISACenc_obj->current_framesamples/MAX_FRAMESAMPLES; /* 0 (30 ms) or 1 (60 ms) */ - processed_samples = ISACenc_obj->current_framesamples/(frame_mode+1); /* 480 (30, 60 ms) */ - - /* buffer speech samples (by 10ms packet) until the framelength is reached (30 or 60 ms) */ - /**************************************************************************************/ - /* fill the buffer with 10ms input data */ - for(k=0; k<FRAMESAMPLES_10ms; k++) { - ISACenc_obj->data_buffer_fix[k + ISACenc_obj->buffer_index] = in[k]; - } - /* if buffersize is not equal to current framesize, and end of file is not reached yet, */ - /* increase index and go back to main to get more speech samples */ - if (ISACenc_obj->buffer_index + FRAMESAMPLES_10ms != processed_samples) { - ISACenc_obj->buffer_index = ISACenc_obj->buffer_index + FRAMESAMPLES_10ms; - return 0; - } - /* if buffer reached the right size, reset index and continue with encoding the frame */ - ISACenc_obj->buffer_index = 0; - - /* end of buffer function */ - /**************************/ - - /* encoding */ - /************/ - - if (frame_mode == 0 || ISACenc_obj->frame_nb == 0 ) - { - /* reset bitstream */ - ISACenc_obj->bitstr_obj.W_upper = 0xFFFFFFFF; - ISACenc_obj->bitstr_obj.streamval = 0; - ISACenc_obj->bitstr_obj.stream_index = 0; - ISACenc_obj->bitstr_obj.full = 1; - - if (CodingMode == 0) { - ISACenc_obj->BottleNeck = WebRtcIsacfix_GetUplinkBandwidth(bw_estimatordata); - ISACenc_obj->MaxDelay = WebRtcIsacfix_GetUplinkMaxDelay(bw_estimatordata); - } - if (CodingMode == 0 && frame_mode == 0 && (ISACenc_obj->enforceFrameSize == 0)) { - ISACenc_obj->new_framelength = WebRtcIsacfix_GetNewFrameLength(ISACenc_obj->BottleNeck, - ISACenc_obj->current_framesamples); - } - - // multiply the bottleneck by 0.88 before computing SNR, 0.88 is tuned by experimenting on TIMIT - // 901/1024 is 0.87988281250000 - ISACenc_obj->s2nr = WebRtcIsacfix_GetSnr((WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ISACenc_obj->BottleNeck, 901, 10), - ISACenc_obj->current_framesamples); - - /* encode frame length */ - status = WebRtcIsacfix_EncodeFrameLen(ISACenc_obj->current_framesamples, &ISACenc_obj->bitstr_obj); - if (status < 0) - { - /* Wrong frame size */ - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - - /* Save framelength for multiple packets memory */ - if (ISACenc_obj->SaveEnc_ptr != NULL) { - (ISACenc_obj->SaveEnc_ptr)->framelength=ISACenc_obj->current_framesamples; - } - - /* bandwidth estimation and coding */ - BWno = WebRtcIsacfix_GetDownlinkBwIndexImpl(bw_estimatordata); - status = WebRtcIsacfix_EncodeReceiveBandwidth(&BWno, &ISACenc_obj->bitstr_obj); - if (status < 0) - { - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - } - - /* split signal in two bands */ - WebRtcIsacfix_SplitAndFilter1(ISACenc_obj->data_buffer_fix, LP16a, HP16a, &ISACenc_obj->prefiltbankstr_obj ); - - /* estimate pitch parameters and pitch-filter lookahead signal */ - WebRtcIsacfix_PitchAnalysis(LP16a+QLOOKAHEAD, LPandHP, - &ISACenc_obj->pitchanalysisstr_obj, PitchLags_Q7, PitchGains_Q12); /* LPandHP = LP_lookahead_pfQ0, */ - - /* Set where to store data in multiple packets memory */ - if (ISACenc_obj->SaveEnc_ptr != NULL) { - if (frame_mode == 0 || ISACenc_obj->frame_nb == 0) - { - (ISACenc_obj->SaveEnc_ptr)->startIdx = 0; - } - else - { - (ISACenc_obj->SaveEnc_ptr)->startIdx = 1; - } - } - - /* quantize & encode pitch parameters */ - status = WebRtcIsacfix_EncodePitchGain(PitchGains_Q12, &ISACenc_obj->bitstr_obj, ISACenc_obj->SaveEnc_ptr); - if (status < 0) - { - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - status = WebRtcIsacfix_EncodePitchLag(PitchLags_Q7 , PitchGains_Q12, &ISACenc_obj->bitstr_obj, ISACenc_obj->SaveEnc_ptr); - if (status < 0) - { - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - AvgPitchGain_Q12 = WEBRTC_SPL_RSHIFT_W32(PitchGains_Q12[0] + PitchGains_Q12[1] + PitchGains_Q12[2] + PitchGains_Q12[3], 2); - - /* find coefficients for perceptual pre-filters */ - WebRtcIsacfix_GetLpcCoef(LPandHP, HP16a+QLOOKAHEAD, &ISACenc_obj->maskfiltstr_obj, - ISACenc_obj->s2nr, PitchGains_Q12, - gain_lo_hiQ17, lofilt_coefQ15, hifilt_coefQ15); /*LPandHP = LP_lookahead_pfQ0*/ - - // record LPC Gains for possible bit-rate reduction - for(k = 0; k < KLT_ORDER_GAIN; k++) - { - transcodingParam.lpcGains[k] = gain_lo_hiQ17[k]; - } - - /* code LPC model and shape - gains not quantized yet */ - status = WebRtcIsacfix_EncodeLpc(gain_lo_hiQ17, lofilt_coefQ15, hifilt_coefQ15, - &bmodel, &bits_gainsQ11, &ISACenc_obj->bitstr_obj, ISACenc_obj->SaveEnc_ptr, &transcodingParam); - if (status < 0) - { - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - arithLenBeforeEncodingDFT = (ISACenc_obj->bitstr_obj.stream_index << 1) + (1-ISACenc_obj->bitstr_obj.full); - - /* low-band filtering */ - WebRtcIsacfix_NormLatticeFilterMa(ORDERLO, ISACenc_obj->maskfiltstr_obj.PreStateLoGQ15, - LP16a, lofilt_coefQ15, gain_lo_hiQ17, 0, LPandHP);/* LPandHP = LP16b */ - - /* pitch filter */ - WebRtcIsacfix_PitchFilter(LPandHP, LP16a, &ISACenc_obj->pitchfiltstr_obj, PitchLags_Q7, PitchGains_Q12, 1);/* LPandHP = LP16b */ - - /* high-band filtering */ - WebRtcIsacfix_NormLatticeFilterMa(ORDERHI, ISACenc_obj->maskfiltstr_obj.PreStateHiGQ15, - HP16a, hifilt_coefQ15, gain_lo_hiQ17, 1, LPandHP);/*LPandHP = HP16b*/ - - /* transform */ - WebRtcIsacfix_Time2Spec(LP16a, LPandHP, LP16a, LPandHP); /*LPandHP = HP16b*/ - - /* Save data for multiple packets memory */ - if (ISACenc_obj->SaveEnc_ptr != NULL) { - for (k = 0; k < FRAMESAMPLES_HALF; k++) { - (ISACenc_obj->SaveEnc_ptr)->fre[k + (ISACenc_obj->SaveEnc_ptr)->startIdx*FRAMESAMPLES_HALF] = LP16a[k]; - (ISACenc_obj->SaveEnc_ptr)->fim[k + (ISACenc_obj->SaveEnc_ptr)->startIdx*FRAMESAMPLES_HALF] = LPandHP[k]; - } - (ISACenc_obj->SaveEnc_ptr)->AvgPitchGain[(ISACenc_obj->SaveEnc_ptr)->startIdx] = AvgPitchGain_Q12; - } - - /* quantization and lossless coding */ - status = WebRtcIsacfix_EncodeSpec(LP16a, LPandHP, &ISACenc_obj->bitstr_obj, AvgPitchGain_Q12); - if((status <= -1) && (status != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) /*LPandHP = HP16b*/ - { - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - - if((frame_mode == 1) && (ISACenc_obj->frame_nb == 0)) - { - // it is a 60ms and we are in the first 30ms - // then the limit at this point should be half of the assigned value - payloadLimitBytes = ISACenc_obj->payloadLimitBytes60 >> 1; - } - else if (frame_mode == 0) - { - // it is a 30ms frame - payloadLimitBytes = (ISACenc_obj->payloadLimitBytes30) - 3; - } - else - { - // this is the second half of a 60ms frame. - payloadLimitBytes = ISACenc_obj->payloadLimitBytes60 - 3; // subract 3 because termination process may add 3 bytes - } - - iterCntr = 0; - while((((ISACenc_obj->bitstr_obj.stream_index) << 1) > payloadLimitBytes) || - (status == -ISAC_DISALLOWED_BITSTREAM_LENGTH)) - { - WebRtc_Word16 arithLenDFTByte; - WebRtc_Word16 bytesLeftQ5; - WebRtc_Word16 ratioQ5[8] = {0, 6, 9, 12, 16, 19, 22, 25}; - - // According to experiments on TIMIT the following is proper for audio, but it is not agressive enough for tonal inputs - // such as DTMF, sweep-sine, ... - // - // (0.55 - (0.8 - ratio[i]/32) * 5 / 6) * 2^14 - // WebRtc_Word16 scaleQ14[8] = {0, 648, 1928, 3208, 4915, 6195, 7475, 8755}; - - - // This is a supper-agressive scaling passed the tests (tonal inputs) tone with one iteration for payload limit - // of 120 (32kbps bottleneck), number of frames needed a rate-reduction was 58403 - // - WebRtc_Word16 scaleQ14[8] = {0, 348, 828, 1408, 2015, 3195, 3500, 3500}; - WebRtc_Word16 idx; - - if(iterCntr >= MAX_PAYLOAD_LIMIT_ITERATION) - { - // We were not able to limit the payload size - - if((frame_mode == 1) && (ISACenc_obj->frame_nb == 0)) - { - // This was the first 30ms of a 60ms frame. Although the payload is larger than it - // should be but we let the second 30ms be encoded. Maybe togetehr we won't exceed - // the limit. - ISACenc_obj->frame_nb = 1; - return 0; - } - else if((frame_mode == 1) && (ISACenc_obj->frame_nb == 1)) - { - ISACenc_obj->frame_nb = 0; - } - - if(status != -ISAC_DISALLOWED_BITSTREAM_LENGTH) - { - return -ISAC_PAYLOAD_LARGER_THAN_LIMIT; - } - else - { - return status; - } - } - if(status != -ISAC_DISALLOWED_BITSTREAM_LENGTH) - { - arithLenDFTByte = (ISACenc_obj->bitstr_obj.stream_index << 1) + (1-ISACenc_obj->bitstr_obj.full) - arithLenBeforeEncodingDFT; - bytesLeftQ5 = (payloadLimitBytes - arithLenBeforeEncodingDFT) << 5; - - // bytesLeft / arithLenDFTBytes indicates how much scaling is required a rough estimate (agressive) - // scale = 0.55 - (0.8 - bytesLeft / arithLenDFTBytes) * 5 / 6 - // bytesLeft / arithLenDFTBytes below 0.2 will have a scale of zero and above 0.8 are treated as 0.8 - // to avoid division we do more simplification. - // - // values of (bytesLeft / arithLenDFTBytes)*32 between ratioQ5[i] and ratioQ5[i+1] are rounded to ratioQ5[i] - // and the corresponding scale is chosen - - // we compare bytesLeftQ5 with ratioQ5[]*arithLenDFTByte; - idx = 4; - idx += (bytesLeftQ5 >= WEBRTC_SPL_MUL_16_16(ratioQ5[idx], arithLenDFTByte))? 2:-2; - idx += (bytesLeftQ5 >= WEBRTC_SPL_MUL_16_16(ratioQ5[idx], arithLenDFTByte))? 1:-1; - idx += (bytesLeftQ5 >= WEBRTC_SPL_MUL_16_16(ratioQ5[idx], arithLenDFTByte))? 0:-1; - } - else - { - // we are here because the bit-stream did not fit into the buffer, in this case, the stream_index is not - // trustable, especially if the is the first 30ms of a packet. Thereforem, we will go for the most agressive - // case. - idx = 0; - } - // scale FFT coefficients to reduce the bit-rate - for(k = 0; k < FRAMESAMPLES_HALF; k++) - { - LP16a[k] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(LP16a[k], scaleQ14[idx], 14); - LPandHP[k] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(LPandHP[k], scaleQ14[idx], 14); - } - - // Save data for multiple packets memory - if (ISACenc_obj->SaveEnc_ptr != NULL) - { - for(k = 0; k < FRAMESAMPLES_HALF; k++) - { - (ISACenc_obj->SaveEnc_ptr)->fre[k + (ISACenc_obj->SaveEnc_ptr)->startIdx*FRAMESAMPLES_HALF] = LP16a[k]; - (ISACenc_obj->SaveEnc_ptr)->fim[k + (ISACenc_obj->SaveEnc_ptr)->startIdx*FRAMESAMPLES_HALF] = LPandHP[k]; - } - } - - // scale the unquantized LPC gains and save the scaled version for the future use - for(k = 0; k < KLT_ORDER_GAIN; k++) - { - gain_lo_hiQ17[k] = WEBRTC_SPL_MUL_16_32_RSFT14(scaleQ14[idx], transcodingParam.lpcGains[k]);//transcodingParam.lpcGains[k]; // - transcodingParam.lpcGains[k] = gain_lo_hiQ17[k]; - } - - // reset the bit-stream object to the state which it had before encoding LPC Gains - ISACenc_obj->bitstr_obj.full = transcodingParam.full; - ISACenc_obj->bitstr_obj.stream_index = transcodingParam.stream_index; - ISACenc_obj->bitstr_obj.streamval = transcodingParam.streamval; - ISACenc_obj->bitstr_obj.W_upper = transcodingParam.W_upper; - ISACenc_obj->bitstr_obj.stream[transcodingParam.stream_index-1] = transcodingParam.beforeLastWord; - ISACenc_obj->bitstr_obj.stream[transcodingParam.stream_index] = transcodingParam.lastWord; - - - // quantize and encode LPC gain - WebRtcIsacfix_EstCodeLpcGain(gain_lo_hiQ17, &ISACenc_obj->bitstr_obj, ISACenc_obj->SaveEnc_ptr); - arithLenBeforeEncodingDFT = (ISACenc_obj->bitstr_obj.stream_index << 1) + (1-ISACenc_obj->bitstr_obj.full); - status = WebRtcIsacfix_EncodeSpec(LP16a, LPandHP, &ISACenc_obj->bitstr_obj, AvgPitchGain_Q12); - if((status <= -1) && (status != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) /*LPandHP = HP16b*/ - { - if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - // If this is the second 30ms of a 60ms frame reset this such that in the next call - // encoder starts fresh. - ISACenc_obj->frame_nb = 0; - } - return status; - } - iterCntr++; - } - - if (frame_mode == 1 && ISACenc_obj->frame_nb == 0) - /* i.e. 60 ms framesize and just processed the first 30ms, */ - /* go back to main function to buffer the other 30ms speech frame */ - { - ISACenc_obj->frame_nb = 1; - return 0; - } - else if (frame_mode == 1 && ISACenc_obj->frame_nb == 1) - { - ISACenc_obj->frame_nb = 0; - /* also update the framelength for next packet, in Adaptive mode only */ - if (CodingMode == 0 && (ISACenc_obj->enforceFrameSize == 0)) { - ISACenc_obj->new_framelength = WebRtcIsacfix_GetNewFrameLength(ISACenc_obj->BottleNeck, - ISACenc_obj->current_framesamples); - } - } - - - /* complete arithmetic coding */ - stream_length = WebRtcIsacfix_EncTerminate(&ISACenc_obj->bitstr_obj); - /* can this be negative? */ - - if(CodingMode == 0) - { - - /* update rate model and get minimum number of bytes in this packet */ - MinBytes = WebRtcIsacfix_GetMinBytes(&ISACenc_obj->rate_data_obj, (WebRtc_Word16) stream_length, - ISACenc_obj->current_framesamples, ISACenc_obj->BottleNeck, ISACenc_obj->MaxDelay); - - /* if bitstream is too short, add garbage at the end */ - - /* Store length of coded data */ - usefulstr_len = stream_length; - - /* Make sure MinBytes does not exceed packet size limit */ - if ((ISACenc_obj->frame_nb == 0) && (MinBytes > ISACenc_obj->payloadLimitBytes30)) { - MinBytes = ISACenc_obj->payloadLimitBytes30; - } else if ((ISACenc_obj->frame_nb == 1) && (MinBytes > ISACenc_obj->payloadLimitBytes60)) { - MinBytes = ISACenc_obj->payloadLimitBytes60; - } - - /* Make sure we don't allow more than 255 bytes of garbage data. - We store the length of the garbage data in 8 bits in the bitstream, - 255 is the max garbage lenght we can signal using 8 bits. */ - if( MinBytes > usefulstr_len + 255 ) { - MinBytes = usefulstr_len + 255; - } - - /* Save data for creation of multiple bitstreams */ - if (ISACenc_obj->SaveEnc_ptr != NULL) { - (ISACenc_obj->SaveEnc_ptr)->minBytes = MinBytes; - } - - while (stream_length < MinBytes) - { - if (stream_length & 0x0001){ - ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed ); - ISACenc_obj->bitstr_obj.stream[ WEBRTC_SPL_RSHIFT_W16(stream_length, 1) ] |= (WebRtc_UWord16)(ISACenc_obj->bitstr_seed & 0xFF); - } else { - ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed ); - ISACenc_obj->bitstr_obj.stream[ WEBRTC_SPL_RSHIFT_W16(stream_length, 1) ] = WEBRTC_SPL_LSHIFT_U16(ISACenc_obj->bitstr_seed, 8); - } - stream_length++; - } - - /* to get the real stream_length, without garbage */ - if (usefulstr_len & 0x0001) { - ISACenc_obj->bitstr_obj.stream[usefulstr_len>>1] &= 0xFF00; - ISACenc_obj->bitstr_obj.stream[usefulstr_len>>1] += (MinBytes - usefulstr_len) & 0x00FF; - } - else { - ISACenc_obj->bitstr_obj.stream[usefulstr_len>>1] &= 0x00FF; - ISACenc_obj->bitstr_obj.stream[usefulstr_len>>1] += WEBRTC_SPL_LSHIFT_U16((MinBytes - usefulstr_len) & 0x00FF, 8); - } - } - else - { - /* update rate model */ - WebRtcIsacfix_UpdateRateModel(&ISACenc_obj->rate_data_obj, (WebRtc_Word16) stream_length, - ISACenc_obj->current_framesamples, ISACenc_obj->BottleNeck); - } - return stream_length; -} - -/* This function is used to create a new bitstream with new BWE. - The same data as previously encoded with the fucntion WebRtcIsacfix_EncodeImpl() - is used. The data needed is taken from the struct, where it was stored - when calling the encoder. */ -int WebRtcIsacfix_EncodeStoredData(ISACFIX_EncInst_t *ISACenc_obj, - int BWnumber, - float scale) -{ - int ii; - int status; - WebRtc_Word16 BWno = BWnumber; - int stream_length = 0; - - WebRtc_Word16 model; - const WebRtc_UWord16 *Q_PitchGain_cdf_ptr[1]; - const WebRtc_UWord16 **cdf; - const ISAC_SaveEncData_t *SaveEnc_str; - WebRtc_Word32 tmpLPCcoeffs_g[KLT_ORDER_GAIN<<1]; - WebRtc_Word16 tmpLPCindex_g[KLT_ORDER_GAIN<<1]; - WebRtc_Word16 tmp_fre[FRAMESAMPLES]; - WebRtc_Word16 tmp_fim[FRAMESAMPLES]; - - SaveEnc_str = ISACenc_obj->SaveEnc_ptr; - - /* Check if SaveEnc memory exists */ - if (SaveEnc_str == NULL) { - return (-1); - } - - /* Sanity Check - possible values for BWnumber is 0 - 23 */ - if ((BWnumber < 0) || (BWnumber > 23)) { - return -ISAC_RANGE_ERROR_BW_ESTIMATOR; - } - - /* reset bitstream */ - ISACenc_obj->bitstr_obj.W_upper = 0xFFFFFFFF; - ISACenc_obj->bitstr_obj.streamval = 0; - ISACenc_obj->bitstr_obj.stream_index = 0; - ISACenc_obj->bitstr_obj.full = 1; - - /* encode frame length */ - status = WebRtcIsacfix_EncodeFrameLen(SaveEnc_str->framelength, &ISACenc_obj->bitstr_obj); - if (status < 0) { - /* Wrong frame size */ - return status; - } - - /* encode bandwidth estimate */ - status = WebRtcIsacfix_EncodeReceiveBandwidth(&BWno, &ISACenc_obj->bitstr_obj); - if (status < 0) { - return status; - } - - /* Transcoding */ - /* If scale < 1, rescale data to produce lower bitrate signal */ - if ((0.0 < scale) && (scale < 1.0)) { - /* Compensate LPC gain */ - for (ii = 0; ii < (KLT_ORDER_GAIN*(1+SaveEnc_str->startIdx)); ii++) { - tmpLPCcoeffs_g[ii] = (WebRtc_Word32) ((scale) * (float) SaveEnc_str->LPCcoeffs_g[ii]); - } - - /* Scale DFT */ - for (ii = 0; ii < (FRAMESAMPLES_HALF*(1+SaveEnc_str->startIdx)); ii++) { - tmp_fre[ii] = (WebRtc_Word16) ((scale) * (float) SaveEnc_str->fre[ii]) ; - tmp_fim[ii] = (WebRtc_Word16) ((scale) * (float) SaveEnc_str->fim[ii]) ; - } - } else { - for (ii = 0; ii < (KLT_ORDER_GAIN*(1+SaveEnc_str->startIdx)); ii++) { - tmpLPCindex_g[ii] = SaveEnc_str->LPCindex_g[ii]; - } - - for (ii = 0; ii < (FRAMESAMPLES_HALF*(1+SaveEnc_str->startIdx)); ii++) { - tmp_fre[ii] = SaveEnc_str->fre[ii]; - tmp_fim[ii] = SaveEnc_str->fim[ii]; - } - } - - /* Loop over number of 30 msec */ - for (ii = 0; ii <= SaveEnc_str->startIdx; ii++) - { - - /* encode pitch gains */ - *Q_PitchGain_cdf_ptr = WebRtcIsacfix_kPitchGainCdf; - status = WebRtcIsacfix_EncHistMulti(&ISACenc_obj->bitstr_obj, &SaveEnc_str->pitchGain_index[ii], - Q_PitchGain_cdf_ptr, 1); - if (status < 0) { - return status; - } - - /* entropy coding of quantization pitch lags */ - /* voicing classificiation */ - if (SaveEnc_str->meanGain[ii] <= 819) { - cdf = WebRtcIsacfix_kPitchLagPtrLo; - } else if (SaveEnc_str->meanGain[ii] <= 1638) { - cdf = WebRtcIsacfix_kPitchLagPtrMid; - } else { - cdf = WebRtcIsacfix_kPitchLagPtrHi; - } - status = WebRtcIsacfix_EncHistMulti(&ISACenc_obj->bitstr_obj, - &SaveEnc_str->pitchIndex[PITCH_SUBFRAMES*ii], cdf, PITCH_SUBFRAMES); - if (status < 0) { - return status; - } - - /* LPC */ - /* entropy coding of model number */ - model = 0; - status = WebRtcIsacfix_EncHistMulti(&ISACenc_obj->bitstr_obj, &model, - WebRtcIsacfix_kModelCdfPtr, 1); - if (status < 0) { - return status; - } - - /* entropy coding of quantization indices - LPC shape only */ - status = WebRtcIsacfix_EncHistMulti(&ISACenc_obj->bitstr_obj, &SaveEnc_str->LPCindex_s[KLT_ORDER_SHAPE*ii], - WebRtcIsacfix_kCdfShapePtr[0], KLT_ORDER_SHAPE); - if (status < 0) { - return status; - } - - /* If transcoding, get new LPC gain indices */ - if (scale < 1.0) { - WebRtcIsacfix_TranscodeLpcCoef(&tmpLPCcoeffs_g[KLT_ORDER_GAIN*ii], &tmpLPCindex_g[KLT_ORDER_GAIN*ii]); - } - - /* entropy coding of quantization indices - LPC gain */ - status = WebRtcIsacfix_EncHistMulti(&ISACenc_obj->bitstr_obj, &tmpLPCindex_g[KLT_ORDER_GAIN*ii], - WebRtcIsacfix_kCdfGainPtr[0], KLT_ORDER_GAIN); - if (status < 0) { - return status; - } - - /* quantization and lossless coding */ - status = WebRtcIsacfix_EncodeSpec(&tmp_fre[ii*FRAMESAMPLES_HALF], &tmp_fim[ii*FRAMESAMPLES_HALF], - &ISACenc_obj->bitstr_obj, SaveEnc_str->AvgPitchGain[ii]); - if (status < 0) { - return status; - } - } - - /* complete arithmetic coding */ - stream_length = WebRtcIsacfix_EncTerminate(&ISACenc_obj->bitstr_obj); - - return stream_length; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c b/src/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c deleted file mode 100644 index 0b64d83..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c +++ /dev/null
@@ -1,2072 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * entropy_coding.c - * - * This file contains all functions used to arithmetically - * encode the iSAC bistream. - * - */ - -#include <stddef.h> - -#include "arith_routins.h" -#include "spectrum_ar_model_tables.h" -#include "pitch_gain_tables.h" -#include "pitch_lag_tables.h" -#include "entropy_coding.h" -#include "lpc_tables.h" -#include "settings.h" -#include "signal_processing_library.h" - - -/* - This function implements the fix-point correspondant function to lrint. - - FLP: (WebRtc_Word32)floor(flt+.499999999999) - FIP: (fixVal+roundVal)>>qDomain - - where roundVal = 2^(qDomain-1) = 1<<(qDomain-1) - -*/ -static __inline WebRtc_Word32 CalcLrIntQ(WebRtc_Word32 fixVal, WebRtc_Word16 qDomain) { - WebRtc_Word32 intgr; - WebRtc_Word32 roundVal; - - roundVal = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)1, qDomain-1); - intgr = WEBRTC_SPL_RSHIFT_W32(fixVal+roundVal, qDomain); - - return intgr; -} - -/* - __inline WebRtc_UWord32 stepwise(WebRtc_Word32 dinQ10) { - - WebRtc_Word32 ind, diQ10, dtQ10; - - diQ10 = dinQ10; - if (diQ10 < DPMIN_Q10) - diQ10 = DPMIN_Q10; - if (diQ10 >= DPMAX_Q10) - diQ10 = DPMAX_Q10 - 1; - - dtQ10 = diQ10 - DPMIN_Q10;*/ /* Q10 + Q10 = Q10 */ -/* ind = (dtQ10 * 5) >> 10; */ /* 2^10 / 5 = 0.2 in Q10 */ -/* Q10 -> Q0 */ - -/* return rpointsFIX_Q10[ind]; - - } -*/ - -/* logN(x) = logN(2)*log2(x) = 0.6931*log2(x). Output in Q8. */ -/* The input argument X to logN(X) is 2^17 times higher than the - input floating point argument Y to log(Y), since the X value - is a Q17 value. This can be compensated for after the call, by - subraction a value Z for each Q-step. One Q-step means that - X gets 2 thimes higher, i.e. Z = logN(2)*256 = 0.693147180559*256 = - 177.445678 should be subtracted (since logN() returns a Q8 value). - For a X value in Q17, the value 177.445678*17 = 3017 should be - subtracted */ -static WebRtc_Word16 CalcLogN(WebRtc_Word32 arg) { - WebRtc_Word16 zeros, log2, frac, logN; - - zeros=WebRtcSpl_NormU32(arg); - frac=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_U32(WEBRTC_SPL_LSHIFT_W32(arg, zeros)&0x7FFFFFFF, 23); - log2=(WebRtc_Word16)(WEBRTC_SPL_LSHIFT_W32(31-zeros, 8)+frac); // log2(x) in Q8 - logN=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(log2,22713,15); //Q8*Q15 log(2) = 0.693147 = 22713 in Q15 - logN=logN+11; //Scalar compensation which minimizes the (log(x)-logN(x))^2 error over all x. - - return logN; -} - - -/* - expN(x) = 2^(a*x), where a = log2(e) ~= 1.442695 - - Input: Q8 (WebRtc_Word16) - Output: Q17 (WebRtc_Word32) - - a = log2(e) = log2(exp(1)) ~= 1.442695 ==> a = 23637 in Q14 (1.442688) - To this value, 700 is added or subtracted in order to get an average error - nearer zero, instead of always same-sign. -*/ - -static WebRtc_Word32 CalcExpN(WebRtc_Word16 x) { - WebRtc_Word16 ax, axINT, axFRAC; - WebRtc_Word16 exp16; - WebRtc_Word32 exp; - - if (x>=0) { - // ax=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637-700, 14); //Q8 - ax=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637, 14); //Q8 - axINT = WEBRTC_SPL_RSHIFT_W16(ax, 8); //Q0 - axFRAC = ax&0x00FF; - exp16 = WEBRTC_SPL_LSHIFT_W32(1, axINT); //Q0 - axFRAC = axFRAC+256; //Q8 - exp = WEBRTC_SPL_MUL_16_16(exp16, axFRAC); // Q0*Q8 = Q8 - exp = WEBRTC_SPL_LSHIFT_W32(exp, 9); //Q17 - } else { - // ax=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637+700, 14); //Q8 - ax=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637, 14); //Q8 - ax = -ax; - axINT = 1 + WEBRTC_SPL_RSHIFT_W16(ax, 8); //Q0 - axFRAC = 0x00FF - (ax&0x00FF); - exp16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(32768, axINT); //Q15 - axFRAC = axFRAC+256; //Q8 - exp = WEBRTC_SPL_MUL_16_16(exp16, axFRAC); // Q15*Q8 = Q23 - exp = WEBRTC_SPL_RSHIFT_W32(exp, 6); //Q17 - } - - return exp; -} - - -/* compute correlation from power spectrum */ -static void CalcCorrelation(WebRtc_Word32 *PSpecQ12, WebRtc_Word32 *CorrQ7) -{ - WebRtc_Word32 summ[FRAMESAMPLES/8]; - WebRtc_Word32 diff[FRAMESAMPLES/8]; - WebRtc_Word32 sum; - int k, n; - - for (k = 0; k < FRAMESAMPLES/8; k++) { - summ[k] = WEBRTC_SPL_RSHIFT_W32(PSpecQ12[k] + PSpecQ12[FRAMESAMPLES/4-1 - k] + 16, 5); - diff[k] = WEBRTC_SPL_RSHIFT_W32(PSpecQ12[k] - PSpecQ12[FRAMESAMPLES/4-1 - k] + 16, 5); - } - - sum = 2; - for (n = 0; n < FRAMESAMPLES/8; n++) - sum += summ[n]; - CorrQ7[0] = sum; - - for (k = 0; k < AR_ORDER; k += 2) { - sum = 0; - for (n = 0; n < FRAMESAMPLES/8; n++) - sum += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WebRtcIsacfix_kCos[k][n], diff[n]) + 256, 9); - CorrQ7[k+1] = sum; - } - - for (k=1; k<AR_ORDER; k+=2) { - sum = 0; - for (n = 0; n < FRAMESAMPLES/8; n++) - sum += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WebRtcIsacfix_kCos[k][n], summ[n]) + 256, 9); - CorrQ7[k+1] = sum; - } -} - - -/* compute inverse AR power spectrum */ -static void CalcInvArSpec(const WebRtc_Word16 *ARCoefQ12, - const WebRtc_Word32 gainQ10, - WebRtc_Word32 *CurveQ16) -{ - WebRtc_Word32 CorrQ11[AR_ORDER+1]; - WebRtc_Word32 sum, tmpGain; - WebRtc_Word32 diffQ16[FRAMESAMPLES/8]; - const WebRtc_Word16 *CS_ptrQ9; - int k, n; - WebRtc_Word16 round, shftVal = 0, sh; - - sum = 0; - for (n = 0; n < AR_ORDER+1; n++) - sum += WEBRTC_SPL_MUL(ARCoefQ12[n], ARCoefQ12[n]); /* Q24 */ - sum = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(sum, 6), 65) + 32768, 16); /* result in Q8 */ - CorrQ11[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, gainQ10) + 256, 9); - - /* To avoid overflow, we shift down gainQ10 if it is large. We will not lose any precision */ - if(gainQ10>400000){ - tmpGain = WEBRTC_SPL_RSHIFT_W32(gainQ10, 3); - round = 32; - shftVal = 6; - } else { - tmpGain = gainQ10; - round = 256; - shftVal = 9; - } - - for (k = 1; k < AR_ORDER+1; k++) { - sum = 16384; - for (n = k; n < AR_ORDER+1; n++) - sum += WEBRTC_SPL_MUL(ARCoefQ12[n-k], ARCoefQ12[n]); /* Q24 */ - sum = WEBRTC_SPL_RSHIFT_W32(sum, 15); - CorrQ11[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, tmpGain) + round, shftVal); - } - sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7); - for (n = 0; n < FRAMESAMPLES/8; n++) - CurveQ16[n] = sum; - - for (k = 1; k < AR_ORDER; k += 2) { - for (n = 0; n < FRAMESAMPLES/8; n++) - CurveQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WebRtcIsacfix_kCos[k][n], CorrQ11[k+1]) + 2, 2); - } - - CS_ptrQ9 = WebRtcIsacfix_kCos[0]; - - /* If CorrQ11[1] too large we avoid getting overflow in the calculation by shifting */ - sh=WebRtcSpl_NormW32(CorrQ11[1]); - if (CorrQ11[1]==0) /* Use next correlation */ - sh=WebRtcSpl_NormW32(CorrQ11[2]); - - if (sh<9) - shftVal = 9 - sh; - else - shftVal = 0; - - for (n = 0; n < FRAMESAMPLES/8; n++) - diffQ16[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[1], shftVal)) + 2, 2); - for (k = 2; k < AR_ORDER; k += 2) { - CS_ptrQ9 = WebRtcIsacfix_kCos[k]; - for (n = 0; n < FRAMESAMPLES/8; n++) - diffQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[k+1], shftVal)) + 2, 2); - } - - for (k=0; k<FRAMESAMPLES/8; k++) { - CurveQ16[FRAMESAMPLES/4-1 - k] = CurveQ16[k] - WEBRTC_SPL_LSHIFT_W32(diffQ16[k], shftVal); - CurveQ16[k] += WEBRTC_SPL_LSHIFT_W32(diffQ16[k], shftVal); - } -} - -static void CalcRootInvArSpec(const WebRtc_Word16 *ARCoefQ12, - const WebRtc_Word32 gainQ10, - WebRtc_UWord16 *CurveQ8) -{ - WebRtc_Word32 CorrQ11[AR_ORDER+1]; - WebRtc_Word32 sum, tmpGain; - WebRtc_Word32 summQ16[FRAMESAMPLES/8]; - WebRtc_Word32 diffQ16[FRAMESAMPLES/8]; - - const WebRtc_Word16 *CS_ptrQ9; - int k, n, i; - WebRtc_Word16 round, shftVal = 0, sh; - WebRtc_Word32 res, in_sqrt, newRes; - - sum = 0; - for (n = 0; n < AR_ORDER+1; n++) - sum += WEBRTC_SPL_MUL(ARCoefQ12[n], ARCoefQ12[n]); /* Q24 */ - sum = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(sum, 6), 65) + 32768, 16); /* result in Q8 */ - CorrQ11[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, gainQ10) + 256, 9); - - /* To avoid overflow, we shift down gainQ10 if it is large. We will not lose any precision */ - if(gainQ10>400000){ - tmpGain = WEBRTC_SPL_RSHIFT_W32(gainQ10, 3); - round = 32; - shftVal = 6; - } else { - tmpGain = gainQ10; - round = 256; - shftVal = 9; - } - - for (k = 1; k < AR_ORDER+1; k++) { - sum = 16384; - for (n = k; n < AR_ORDER+1; n++) - sum += WEBRTC_SPL_MUL(ARCoefQ12[n-k], ARCoefQ12[n]); /* Q24 */ - sum = WEBRTC_SPL_RSHIFT_W32(sum, 15); - CorrQ11[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, tmpGain) + round, shftVal); - } - sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7); - for (n = 0; n < FRAMESAMPLES/8; n++) - summQ16[n] = sum; - - for (k = 1; k < (AR_ORDER); k += 2) { - for (n = 0; n < FRAMESAMPLES/8; n++) - summQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_32_16(CorrQ11[k+1],WebRtcIsacfix_kCos[k][n]) + 2, 2); - } - - CS_ptrQ9 = WebRtcIsacfix_kCos[0]; - - /* If CorrQ11[1] too large we avoid getting overflow in the calculation by shifting */ - sh=WebRtcSpl_NormW32(CorrQ11[1]); - if (CorrQ11[1]==0) /* Use next correlation */ - sh=WebRtcSpl_NormW32(CorrQ11[2]); - - if (sh<9) - shftVal = 9 - sh; - else - shftVal = 0; - - for (n = 0; n < FRAMESAMPLES/8; n++) - diffQ16[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[1], shftVal)) + 2, 2); - for (k = 2; k < AR_ORDER; k += 2) { - CS_ptrQ9 = WebRtcIsacfix_kCos[k]; - for (n = 0; n < FRAMESAMPLES/8; n++) - diffQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[k+1], shftVal)) + 2, 2); - } - - in_sqrt = summQ16[0] + WEBRTC_SPL_LSHIFT_W32(diffQ16[0], shftVal); - - /* convert to magnitude spectrum, by doing square-roots (modified from SPLIB) */ - res = WEBRTC_SPL_LSHIFT_W32(1, WEBRTC_SPL_RSHIFT_W16(WebRtcSpl_GetSizeInBits(in_sqrt), 1)); - - for (k = 0; k < FRAMESAMPLES/8; k++) - { - in_sqrt = summQ16[k] + WEBRTC_SPL_LSHIFT_W32(diffQ16[k], shftVal); - i = 10; - - /* make in_sqrt positive to prohibit sqrt of negative values */ - if(in_sqrt<0) - in_sqrt=-in_sqrt; - - newRes = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_DIV(in_sqrt, res) + res, 1); - do - { - res = newRes; - newRes = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_DIV(in_sqrt, res) + res, 1); - } while (newRes != res && i-- > 0); - - CurveQ8[k] = (WebRtc_Word16)newRes; - } - for (k = FRAMESAMPLES/8; k < FRAMESAMPLES/4; k++) { - - in_sqrt = summQ16[FRAMESAMPLES/4-1 - k] - WEBRTC_SPL_LSHIFT_W32(diffQ16[FRAMESAMPLES/4-1 - k], shftVal); - i = 10; - - /* make in_sqrt positive to prohibit sqrt of negative values */ - if(in_sqrt<0) - in_sqrt=-in_sqrt; - - newRes = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_DIV(in_sqrt, res) + res, 1); - do - { - res = newRes; - newRes = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_DIV(in_sqrt, res) + res, 1); - } while (newRes != res && i-- > 0); - - CurveQ8[k] = (WebRtc_Word16)newRes; - } - -} - - - -/* generate array of dither samples in Q7 */ -static void GenerateDitherQ7(WebRtc_Word16 *bufQ7, - WebRtc_UWord32 seed, - WebRtc_Word16 length, - WebRtc_Word16 AvgPitchGain_Q12) -{ - int k; - WebRtc_Word16 dither1_Q7, dither2_Q7, dither_gain_Q14, shft; - - if (AvgPitchGain_Q12 < 614) /* this threshold should be equal to that in decode_spec() */ - { - for (k = 0; k < length-2; k += 3) - { - /* new random unsigned WebRtc_Word32 */ - seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; - - /* fixed-point dither sample between -64 and 64 (Q7) */ - dither1_Q7 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)seed + 16777216, 25); // * 128/4294967295 - - /* new random unsigned WebRtc_Word32 */ - seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; - - /* fixed-point dither sample between -64 and 64 */ - dither2_Q7 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(seed + 16777216, 25); - - shft = (WebRtc_Word16)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 15); - if (shft < 5) - { - bufQ7[k] = dither1_Q7; - bufQ7[k+1] = dither2_Q7; - bufQ7[k+2] = 0; - } - else if (shft < 10) - { - bufQ7[k] = dither1_Q7; - bufQ7[k+1] = 0; - bufQ7[k+2] = dither2_Q7; - } - else - { - bufQ7[k] = 0; - bufQ7[k+1] = dither1_Q7; - bufQ7[k+2] = dither2_Q7; - } - } - } - else - { - dither_gain_Q14 = (WebRtc_Word16)(22528 - WEBRTC_SPL_MUL(10, AvgPitchGain_Q12)); - - /* dither on half of the coefficients */ - for (k = 0; k < length-1; k += 2) - { - /* new random unsigned WebRtc_Word32 */ - seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515; - - /* fixed-point dither sample between -64 and 64 */ - dither1_Q7 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)seed + 16777216, 25); - - /* dither sample is placed in either even or odd index */ - shft = (WebRtc_Word16)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 1); /* either 0 or 1 */ - - bufQ7[k + shft] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(dither_gain_Q14, dither1_Q7) + 8192, 14); - bufQ7[k + 1 - shft] = 0; - } - } -} - - - - -/* - * function to decode the complex spectrum from the bitstream - * returns the total number of bytes in the stream - */ -WebRtc_Word16 WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, - WebRtc_Word16 *frQ7, - WebRtc_Word16 *fiQ7, - WebRtc_Word16 AvgPitchGain_Q12) -{ - WebRtc_Word16 data[FRAMESAMPLES]; - WebRtc_Word32 invARSpec2_Q16[FRAMESAMPLES/4]; - WebRtc_Word16 ARCoefQ12[AR_ORDER+1]; - WebRtc_Word16 RCQ15[AR_ORDER]; - WebRtc_Word16 gainQ10; - WebRtc_Word32 gain2_Q10; - WebRtc_Word16 len; - int k; - - /* create dither signal */ - GenerateDitherQ7(data, streamdata->W_upper, FRAMESAMPLES, AvgPitchGain_Q12); /* Dither is output in vector 'Data' */ - - /* decode model parameters */ - if (WebRtcIsacfix_DecodeRcCoef(streamdata, RCQ15) < 0) - return -ISAC_RANGE_ERROR_DECODE_SPECTRUM; - - - WebRtcSpl_ReflCoefToLpc(RCQ15, AR_ORDER, ARCoefQ12); - - if (WebRtcIsacfix_DecodeGain2(streamdata, &gain2_Q10) < 0) - return -ISAC_RANGE_ERROR_DECODE_SPECTRUM; - - /* compute inverse AR power spectrum */ - CalcInvArSpec(ARCoefQ12, gain2_Q10, invARSpec2_Q16); - - /* arithmetic decoding of spectrum */ - /* 'data' input and output. Input = Dither */ - len = WebRtcIsacfix_DecLogisticMulti2(data, streamdata, invARSpec2_Q16, (WebRtc_Word16)FRAMESAMPLES); - - if (len<1) - return -ISAC_RANGE_ERROR_DECODE_SPECTRUM; - - /* subtract dither and scale down spectral samples with low SNR */ - if (AvgPitchGain_Q12 <= 614) - { - for (k = 0; k < FRAMESAMPLES; k += 4) - { - gainQ10 = WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)30, 10), - (WebRtc_Word16)WEBRTC_SPL_RSHIFT_U32(invARSpec2_Q16[k>>2] + (WebRtc_UWord32)2195456, 16)); - *frQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[ k ], gainQ10) + 512, 10); - *fiQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+1], gainQ10) + 512, 10); - *frQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+2], gainQ10) + 512, 10); - *fiQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+3], gainQ10) + 512, 10); - } - } - else - { - for (k = 0; k < FRAMESAMPLES; k += 4) - { - gainQ10 = WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)36, 10), - (WebRtc_Word16)WEBRTC_SPL_RSHIFT_U32(invARSpec2_Q16[k>>2] + (WebRtc_UWord32)2654208, 16)); - *frQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[ k ], gainQ10) + 512, 10); - *fiQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+1], gainQ10) + 512, 10); - *frQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+2], gainQ10) + 512, 10); - *fiQ7++ = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+3], gainQ10) + 512, 10); - } - } - - return len; -} - - -int WebRtcIsacfix_EncodeSpec(const WebRtc_Word16 *fr, - const WebRtc_Word16 *fi, - Bitstr_enc *streamdata, - WebRtc_Word16 AvgPitchGain_Q12) -{ - WebRtc_Word16 dataQ7[FRAMESAMPLES]; - WebRtc_Word32 PSpec[FRAMESAMPLES/4]; - WebRtc_UWord16 invARSpecQ8[FRAMESAMPLES/4]; - WebRtc_Word32 CorrQ7[AR_ORDER+1]; - WebRtc_Word32 CorrQ7_norm[AR_ORDER+1]; - WebRtc_Word16 RCQ15[AR_ORDER]; - WebRtc_Word16 ARCoefQ12[AR_ORDER+1]; - WebRtc_Word32 gain2_Q10; - WebRtc_Word16 val; - WebRtc_Word32 nrg; - WebRtc_UWord32 sum; - WebRtc_Word16 lft_shft; - WebRtc_Word16 status; - int k, n, j; - - - /* create dither_float signal */ - GenerateDitherQ7(dataQ7, streamdata->W_upper, FRAMESAMPLES, AvgPitchGain_Q12); - - /* add dither and quantize, and compute power spectrum */ - /* Vector dataQ7 contains Dither in Q7 */ - for (k = 0; k < FRAMESAMPLES; k += 4) - { - val = ((*fr++ + dataQ7[k] + 64) & 0xFF80) - dataQ7[k]; /* Data = Dither */ - dataQ7[k] = val; /* New value in Data */ - sum = WEBRTC_SPL_UMUL(val, val); - - val = ((*fi++ + dataQ7[k+1] + 64) & 0xFF80) - dataQ7[k+1]; /* Data = Dither */ - dataQ7[k+1] = val; /* New value in Data */ - sum += WEBRTC_SPL_UMUL(val, val); - - val = ((*fr++ + dataQ7[k+2] + 64) & 0xFF80) - dataQ7[k+2]; /* Data = Dither */ - dataQ7[k+2] = val; /* New value in Data */ - sum += WEBRTC_SPL_UMUL(val, val); - - val = ((*fi++ + dataQ7[k+3] + 64) & 0xFF80) - dataQ7[k+3]; /* Data = Dither */ - dataQ7[k+3] = val; /* New value in Data */ - sum += WEBRTC_SPL_UMUL(val, val); - - PSpec[k>>2] = WEBRTC_SPL_RSHIFT_U32(sum, 2); - } - - /* compute correlation from power spectrum */ - CalcCorrelation(PSpec, CorrQ7); - - - /* find AR coefficients */ - /* number of bit shifts to 14-bit normalize CorrQ7[0] (leaving room for sign) */ - lft_shft = WebRtcSpl_NormW32(CorrQ7[0]) - 18; - - if (lft_shft > 0) { - for (k=0; k<AR_ORDER+1; k++) - CorrQ7_norm[k] = WEBRTC_SPL_LSHIFT_W32(CorrQ7[k], lft_shft); - } else { - for (k=0; k<AR_ORDER+1; k++) - CorrQ7_norm[k] = WEBRTC_SPL_RSHIFT_W32(CorrQ7[k], -lft_shft); - } - - /* find RC coefficients */ - WebRtcSpl_AutoCorrToReflCoef(CorrQ7_norm, AR_ORDER, RCQ15); - - /* quantize & code RC Coef */ - status = WebRtcIsacfix_EncodeRcCoef(RCQ15, streamdata); - if (status < 0) { - return status; - } - - /* RC -> AR coefficients */ - WebRtcSpl_ReflCoefToLpc(RCQ15, AR_ORDER, ARCoefQ12); - - /* compute ARCoef' * Corr * ARCoef in Q19 */ - nrg = 0; - for (j = 0; j <= AR_ORDER; j++) { - for (n = 0; n <= j; n++) - nrg += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(ARCoefQ12[j], WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CorrQ7_norm[j-n], ARCoefQ12[n]) + 256, 9)) + 4, 3); - for (n = j+1; n <= AR_ORDER; n++) - nrg += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(ARCoefQ12[j], WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CorrQ7_norm[n-j], ARCoefQ12[n]) + 256, 9)) + 4, 3); - } - - if (lft_shft > 0) - nrg = WEBRTC_SPL_RSHIFT_W32(nrg, lft_shft); - else - nrg = WEBRTC_SPL_LSHIFT_W32(nrg, -lft_shft); - - if(nrg>131072) - gain2_Q10 = WebRtcSpl_DivResultInQ31(FRAMESAMPLES >> 2, nrg); /* also shifts 31 bits to the left! */ - else - gain2_Q10 = WEBRTC_SPL_RSHIFT_W32(FRAMESAMPLES, 2); - - /* quantize & code gain2_Q10 */ - if (WebRtcIsacfix_EncodeGain2(&gain2_Q10, streamdata)) - return -1; - - /* compute inverse AR magnitude spectrum */ - CalcRootInvArSpec(ARCoefQ12, gain2_Q10, invARSpecQ8); - - - /* arithmetic coding of spectrum */ - status = WebRtcIsacfix_EncLogisticMulti2(streamdata, dataQ7, invARSpecQ8, (WebRtc_Word16)FRAMESAMPLES); - if ( status ) - return( status ); - - return 0; -} - - -/* Matlab's LAR definition */ -static void Rc2LarFix(const WebRtc_Word16 *rcQ15, WebRtc_Word32 *larQ17, WebRtc_Word16 order) { - - /* - - This is a piece-wise implemenetation of a rc2lar-function (all values in the comment - are Q15 values and are based on [0 24956/32768 30000/32768 32500/32768], i.e. - [0.76159667968750 0.91552734375000 0.99182128906250] - - x0 x1 a k x0(again) b - ================================================================================== - 0.00 0.76: 0 2.625997508581 0 0 - 0.76 0.91: 2.000012018559 7.284502668663 0.761596679688 -3.547841027073 - 0.91 0.99: 3.121320351712 31.115835041229 0.915527343750 -25.366077452148 - 0.99 1.00: 5.495270168700 686.663805654056 0.991821289063 -675.552510708011 - - The implementation is y(x)= a + (x-x0)*k, but this can be simplified to - - y(x) = a-x0*k + x*k = b + x*k, where b = a-x0*k - - akx=[0 2.625997508581 0 - 2.000012018559 7.284502668663 0.761596679688 - 3.121320351712 31.115835041229 0.915527343750 - 5.495270168700 686.663805654056 0.991821289063]; - - b = akx(:,1) - akx(:,3).*akx(:,2) - - [ 0.0 - -3.547841027073 - -25.366077452148 - -675.552510708011] - - */ - - int k; - WebRtc_Word16 rc; - WebRtc_Word32 larAbsQ17; - - for (k = 0; k < order; k++) { - - rc = WEBRTC_SPL_ABS_W16(rcQ15[k]); //Q15 - - /* Calculate larAbsQ17 in Q17 from rc in Q15 */ - - if (rc<24956) { //0.7615966 in Q15 - // (Q15*Q13)>>11 = Q17 - larAbsQ17 = WEBRTC_SPL_MUL_16_16_RSFT(rc, 21512, 11); - } else if (rc<30000) { //0.91552734375 in Q15 - // Q17 + (Q15*Q12)>>10 = Q17 - larAbsQ17 = -465024 + WEBRTC_SPL_MUL_16_16_RSFT(rc, 29837, 10); - } else if (rc<32500) { //0.99182128906250 in Q15 - // Q17 + (Q15*Q10)>>8 = Q17 - larAbsQ17 = -3324784 + WEBRTC_SPL_MUL_16_16_RSFT(rc, 31863, 8); - } else { - // Q17 + (Q15*Q5)>>3 = Q17 - larAbsQ17 = -88546020 + WEBRTC_SPL_MUL_16_16_RSFT(rc, 21973, 3); - } - - if (rcQ15[k]>0) { - larQ17[k] = larAbsQ17; - } else { - larQ17[k] = -larAbsQ17; - } - } -} - - -static void Lar2RcFix(const WebRtc_Word32 *larQ17, WebRtc_Word16 *rcQ15, WebRtc_Word16 order) { - - /* - This is a piece-wise implemenetation of a lar2rc-function - See comment in Rc2LarFix() about details. - */ - - int k; - WebRtc_Word16 larAbsQ11; - WebRtc_Word32 rc; - - for (k = 0; k < order; k++) { - - larAbsQ11 = (WebRtc_Word16) WEBRTC_SPL_ABS_W32(WEBRTC_SPL_RSHIFT_W32(larQ17[k]+32,6)); //Q11 - - if (larAbsQ11<4097) { //2.000012018559 in Q11 - // Q11*Q16>>12 = Q15 - rc = WEBRTC_SPL_MUL_16_16_RSFT(larAbsQ11, 24957, 12); - } else if (larAbsQ11<6393) { //3.121320351712 in Q11 - // (Q11*Q17 + Q13)>>13 = Q15 - rc = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(larAbsQ11, 17993) + 130738688), 13); - } else if (larAbsQ11<11255) { //5.495270168700 in Q11 - // (Q11*Q19 + Q30)>>15 = Q15 - rc = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(larAbsQ11, 16850) + 875329820), 15); - } else { - // (Q11*Q24>>16 + Q19)>>4 = Q15 - rc = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16_RSFT(larAbsQ11, 24433, 16)) + 515804), 4); - } - - if (larQ17[k]<=0) { - rc = -rc; - } - - rcQ15[k] = (WebRtc_Word16) rc; // Q15 - } -} - -static void Poly2LarFix(WebRtc_Word16 *lowbandQ15, - WebRtc_Word16 orderLo, - WebRtc_Word16 *hibandQ15, - WebRtc_Word16 orderHi, - WebRtc_Word16 Nsub, - WebRtc_Word32 *larsQ17) { - - int k, n; - WebRtc_Word32 *outpQ17; - WebRtc_Word16 orderTot; - WebRtc_Word32 larQ17[MAX_ORDER]; // Size 7+6 is enough - - orderTot = (orderLo + orderHi); - outpQ17 = larsQ17; - for (k = 0; k < Nsub; k++) { - - Rc2LarFix(lowbandQ15, larQ17, orderLo); - - for (n = 0; n < orderLo; n++) - outpQ17[n] = larQ17[n]; //Q17 - - Rc2LarFix(hibandQ15, larQ17, orderHi); - - for (n = 0; n < orderHi; n++) - outpQ17[n + orderLo] = larQ17[n]; //Q17; - - outpQ17 += orderTot; - lowbandQ15 += orderLo; - hibandQ15 += orderHi; - } -} - - -static void Lar2polyFix(WebRtc_Word32 *larsQ17, - WebRtc_Word16 *lowbandQ15, - WebRtc_Word16 orderLo, - WebRtc_Word16 *hibandQ15, - WebRtc_Word16 orderHi, - WebRtc_Word16 Nsub) { - - int k, n; - WebRtc_Word16 orderTot; - WebRtc_Word16 *outplQ15, *outphQ15; - WebRtc_Word32 *inpQ17; - WebRtc_Word16 rcQ15[7+6]; - - orderTot = (orderLo + orderHi); - outplQ15 = lowbandQ15; - outphQ15 = hibandQ15; - inpQ17 = larsQ17; - for (k = 0; k < Nsub; k++) { - - /* gains not handled here as in the FLP version */ - - /* Low band */ - Lar2RcFix(&inpQ17[0], rcQ15, orderLo); - for (n = 0; n < orderLo; n++) - outplQ15[n] = rcQ15[n]; // Refl. coeffs - - /* High band */ - Lar2RcFix(&inpQ17[orderLo], rcQ15, orderHi); - for (n = 0; n < orderHi; n++) - outphQ15[n] = rcQ15[n]; // Refl. coeffs - - inpQ17 += orderTot; - outplQ15 += orderLo; - outphQ15 += orderHi; - } -} - -int WebRtcIsacfix_DecodeLpc(WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *LPCCoef_loQ15, - WebRtc_Word16 *LPCCoef_hiQ15, - Bitstr_dec *streamdata, - WebRtc_Word16 *outmodel) { - - WebRtc_Word32 larsQ17[KLT_ORDER_SHAPE]; // KLT_ORDER_GAIN+KLT_ORDER_SHAPE == (ORDERLO+ORDERHI)*SUBFRAMES - int err; - - err = WebRtcIsacfix_DecodeLpcCoef(streamdata, larsQ17, gain_lo_hiQ17, outmodel); - if (err<0) // error check - return -ISAC_RANGE_ERROR_DECODE_LPC; - - Lar2polyFix(larsQ17, LPCCoef_loQ15, ORDERLO, LPCCoef_hiQ15, ORDERHI, SUBFRAMES); - - return 0; -} - -/* decode & dequantize LPC Coef */ -int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata, - WebRtc_Word32 *LPCCoefQ17, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *outmodel) -{ - int j, k, n; - int err; - WebRtc_Word16 pos, pos2, posg, poss, offsg, offss, offs2; - WebRtc_Word16 gainpos; - WebRtc_Word16 model; - WebRtc_Word16 index_QQ[KLT_ORDER_SHAPE]; - WebRtc_Word32 tmpcoeffs_gQ17[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs2_gQ21[KLT_ORDER_GAIN]; - WebRtc_Word16 tmpcoeffs_sQ10[KLT_ORDER_SHAPE]; - WebRtc_Word32 tmpcoeffs_sQ17[KLT_ORDER_SHAPE]; - WebRtc_Word32 tmpcoeffs2_sQ18[KLT_ORDER_SHAPE]; - WebRtc_Word32 sumQQ; - WebRtc_Word16 sumQQ16; - WebRtc_Word32 tmp32; - - - - /* entropy decoding of model number */ - err = WebRtcIsacfix_DecHistOneStepMulti(&model, streamdata, WebRtcIsacfix_kModelCdfPtr, WebRtcIsacfix_kModelInitIndex, 1); - if (err<0) // error check - return err; - - /* entropy decoding of quantization indices */ - err = WebRtcIsacfix_DecHistOneStepMulti(index_QQ, streamdata, WebRtcIsacfix_kCdfShapePtr[model], WebRtcIsacfix_kInitIndexShape[model], KLT_ORDER_SHAPE); - if (err<0) // error check - return err; - /* find quantization levels for coefficients */ - for (k=0; k<KLT_ORDER_SHAPE; k++) { - tmpcoeffs_sQ10[WebRtcIsacfix_kSelIndShape[k]] = WebRtcIsacfix_kLevelsShapeQ10[WebRtcIsacfix_kOfLevelsShape[model]+WebRtcIsacfix_kOffsetShape[model][k] + index_QQ[k]]; - } - - err = WebRtcIsacfix_DecHistOneStepMulti(index_QQ, streamdata, WebRtcIsacfix_kCdfGainPtr[model], WebRtcIsacfix_kInitIndexGain[model], KLT_ORDER_GAIN); - if (err<0) // error check - return err; - /* find quantization levels for coefficients */ - for (k=0; k<KLT_ORDER_GAIN; k++) { - tmpcoeffs_gQ17[WebRtcIsacfix_kSelIndGain[k]] = WebRtcIsacfix_kLevelsGainQ17[WebRtcIsacfix_kOfLevelsGain[model]+ WebRtcIsacfix_kOffsetGain[model][k] + index_QQ[k]]; - } - - - /* inverse KLT */ - - /* left transform */ // Transpose matrix! - offsg = 0; - offss = 0; - posg = 0; - poss = 0; - for (j=0; j<SUBFRAMES; j++) { - offs2 = 0; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = offsg; - pos2 = offs2; - for (n=0; n<2; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1GainQ15[model][pos2], tmpcoeffs_gQ17[pos]<<5)); // (Q15*Q17)>>(16-5) = Q21 - pos++; - pos2++; - } - tmpcoeffs2_gQ21[posg] = sumQQ; //Q21 - posg++; - offs2 += 2; - } - offs2 = 0; - - for (k=0; k<LPC_SHAPE_ORDER; k++) { - sumQQ = 0; - pos = offss; - pos2 = offs2; - for (n=0; n<LPC_SHAPE_ORDER; n++) { - sumQQ += WEBRTC_SPL_MUL_16_16_RSFT(tmpcoeffs_sQ10[pos], WebRtcIsacfix_kT1ShapeQ15[model][pos2], 7); // (Q10*Q15)>>7 = Q18 - pos++; - pos2++; - } - tmpcoeffs2_sQ18[poss] = sumQQ; //Q18 - poss++; - offs2 += LPC_SHAPE_ORDER; - } - offsg += 2; - offss += LPC_SHAPE_ORDER; - } - - /* right transform */ // Transpose matrix - offsg = 0; - offss = 0; - posg = 0; - poss = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = k; - pos2 = j; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2GainQ15[model][pos2], tmpcoeffs2_gQ21[pos]), 1); // (Q15*Q21)>>(16-1) = Q21 - pos += 2; - pos2 += SUBFRAMES; - - } - tmpcoeffs_gQ17[posg] = WEBRTC_SPL_RSHIFT_W32(sumQQ, 4); - posg++; - } - poss = offss; - for (k=0; k<LPC_SHAPE_ORDER; k++) { - sumQQ = 0; - pos = k; - pos2 = j; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2ShapeQ15[model][pos2], tmpcoeffs2_sQ18[pos])); // (Q15*Q18)>>16 = Q17 - pos += LPC_SHAPE_ORDER; - pos2 += SUBFRAMES; - } - tmpcoeffs_sQ17[poss] = sumQQ; - poss++; - } - offsg += 2; - offss += LPC_SHAPE_ORDER; - } - - /* scaling, mean addition, and gain restoration */ - gainpos = 0; - posg = 0;poss = 0;pos=0; - for (k=0; k<SUBFRAMES; k++) { - - /* log gains */ - sumQQ16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmpcoeffs_gQ17[posg], 2+9); //Divide by 4 and get Q17 to Q8, i.e. shift 2+9 - sumQQ16 += WebRtcIsacfix_kMeansGainQ8[model][posg]; - sumQQ = CalcExpN(sumQQ16); // Q8 in and Q17 out - gain_lo_hiQ17[gainpos] = sumQQ; //Q17 - gainpos++; - posg++; - - sumQQ16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmpcoeffs_gQ17[posg], 2+9); //Divide by 4 and get Q17 to Q8, i.e. shift 2+9 - sumQQ16 += WebRtcIsacfix_kMeansGainQ8[model][posg]; - sumQQ = CalcExpN(sumQQ16); // Q8 in and Q17 out - gain_lo_hiQ17[gainpos] = sumQQ; //Q17 - gainpos++; - posg++; - - /* lo band LAR coeffs */ - for (n=0; n<ORDERLO; n++, pos++, poss++) { - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(31208, tmpcoeffs_sQ17[poss]); // (Q16*Q17)>>16 = Q17, with 1/2.1 = 0.47619047619 ~= 31208 in Q16 - tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[model][poss]; // Q17+Q17 = Q17 - LPCCoefQ17[pos] = tmp32; - } - - /* hi band LAR coeffs */ - for (n=0; n<ORDERHI; n++, pos++, poss++) { - tmp32 = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]), 3); // ((Q13*Q17)>>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 - tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[model][poss]; // Q17+Q17 = Q17 - LPCCoefQ17[pos] = tmp32; - } - } - - - *outmodel=model; - - return 0; -} - -/* estimate codel length of LPC Coef */ -static int EstCodeLpcCoef(WebRtc_Word32 *LPCCoefQ17, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *model, - WebRtc_Word32 *sizeQ11, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData, - transcode_obj *transcodingParam) { - int j, k, n; - WebRtc_Word16 posQQ, pos2QQ, gainpos; - WebRtc_Word16 pos, pos2, poss, posg, offsg, offss, offs2; - WebRtc_Word16 index_gQQ[KLT_ORDER_GAIN], index_sQQ[KLT_ORDER_SHAPE]; - WebRtc_Word16 index_ovr_gQQ[KLT_ORDER_GAIN], index_ovr_sQQ[KLT_ORDER_SHAPE]; - WebRtc_Word32 BitsQQ; - - WebRtc_Word16 tmpcoeffs_gQ6[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs_gQ17[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs_sQ17[KLT_ORDER_SHAPE]; - WebRtc_Word32 tmpcoeffs2_gQ21[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs2_sQ17[KLT_ORDER_SHAPE]; - WebRtc_Word32 sumQQ; - WebRtc_Word32 tmp32; - WebRtc_Word16 sumQQ16; - int status = 0; - - /* write LAR coefficients to statistics file */ - /* Save data for creation of multiple bitstreams (and transcoding) */ - if (encData != NULL) { - for (k=0; k<KLT_ORDER_GAIN; k++) { - encData->LPCcoeffs_g[KLT_ORDER_GAIN*encData->startIdx + k] = gain_lo_hiQ17[k]; - } - } - - /* log gains, mean removal and scaling */ - posg = 0;poss = 0;pos=0; gainpos=0; - - for (k=0; k<SUBFRAMES; k++) { - /* log gains */ - - /* The input argument X to logN(X) is 2^17 times higher than the - input floating point argument Y to log(Y), since the X value - is a Q17 value. This can be compensated for after the call, by - subraction a value Z for each Q-step. One Q-step means that - X gets 2 times higher, i.e. Z = logN(2)*256 = 0.693147180559*256 = - 177.445678 should be subtracted (since logN() returns a Q8 value). - For a X value in Q17, the value 177.445678*17 = 3017 should be - subtracted */ - tmpcoeffs_gQ6[posg] = CalcLogN(gain_lo_hiQ17[gainpos])-3017; //Q8 - tmpcoeffs_gQ6[posg] -= WebRtcIsacfix_kMeansGainQ8[0][posg]; //Q8, but Q6 after not-needed mult. by 4 - posg++; gainpos++; - - tmpcoeffs_gQ6[posg] = CalcLogN(gain_lo_hiQ17[gainpos])-3017; //Q8 - tmpcoeffs_gQ6[posg] -= WebRtcIsacfix_kMeansGainQ8[0][posg]; //Q8, but Q6 after not-needed mult. by 4 - posg++; gainpos++; - - /* lo band LAR coeffs */ - for (n=0; n<ORDERLO; n++, poss++, pos++) { - tmp32 = LPCCoefQ17[pos] - WebRtcIsacfix_kMeansShapeQ17[0][poss]; //Q17 - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(17203, tmp32<<3); // tmp32 = 2.1*tmp32 - tmpcoeffs_sQ17[poss] = tmp32; //Q17 - } - - /* hi band LAR coeffs */ - for (n=0; n<ORDERHI; n++, poss++, pos++) { - tmp32 = LPCCoefQ17[pos] - WebRtcIsacfix_kMeansShapeQ17[0][poss]; //Q17 - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(14746, tmp32<<1); // tmp32 = 0.45*tmp32 - tmpcoeffs_sQ17[poss] = tmp32; //Q17 - } - - } - - - /* KLT */ - - /* left transform */ - offsg = 0; - offss = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = offsg; - pos2 = k; - for (n=0; n<2; n++) { - sumQQ += WEBRTC_SPL_MUL_16_16(tmpcoeffs_gQ6[pos], WebRtcIsacfix_kT1GainQ15[0][pos2]); //Q21 = Q6*Q15 - pos++; - pos2 += 2; - } - tmpcoeffs2_gQ21[posg] = sumQQ; - posg++; - } - poss = offss; - for (k=0; k<LPC_SHAPE_ORDER; k++) { - sumQQ = 0; - pos = offss; - pos2 = k; - for (n=0; n<LPC_SHAPE_ORDER; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1ShapeQ15[0][pos2], tmpcoeffs_sQ17[pos]<<1)); // (Q15*Q17)>>(16-1) = Q17 - pos++; - pos2 += LPC_SHAPE_ORDER; - } - tmpcoeffs2_sQ17[poss] = sumQQ; //Q17 - poss++; - } - offsg += 2; - offss += LPC_SHAPE_ORDER; - } - - /* right transform */ - offsg = 0; - offss = 0; - offs2 = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = k; - pos2 = offs2; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2GainQ15[0][pos2], tmpcoeffs2_gQ21[pos]), 1); // (Q15*Q21)>>(16-1) = Q21 - pos += 2; - pos2++; - } - tmpcoeffs_gQ17[posg] = WEBRTC_SPL_RSHIFT_W32(sumQQ, 4); - posg++; - } - poss = offss; - for (k=0; k<LPC_SHAPE_ORDER; k++) { - sumQQ = 0; - pos = k; - pos2 = offs2; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2ShapeQ15[0][pos2], tmpcoeffs2_sQ17[pos]<<1)); // (Q15*Q17)>>(16-1) = Q17 - pos += LPC_SHAPE_ORDER; - pos2++; - } - tmpcoeffs_sQ17[poss] = sumQQ; - poss++; - } - offs2 += SUBFRAMES; - offsg += 2; - offss += LPC_SHAPE_ORDER; - } - - /* quantize coefficients */ - - BitsQQ = 0; - for (k=0; k<KLT_ORDER_GAIN; k++) //ATTN: ok? - { - posQQ = WebRtcIsacfix_kSelIndGain[k]; - pos2QQ= (WebRtc_Word16)CalcLrIntQ(tmpcoeffs_gQ17[posQQ], 17); - - index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok? - if (index_gQQ[k] < 0) { - index_gQQ[k] = 0; - } - else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) { - index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k]; - } - index_ovr_gQQ[k] = WebRtcIsacfix_kOffsetGain[0][k]+index_gQQ[k]; - posQQ = WebRtcIsacfix_kOfLevelsGain[0] + index_ovr_gQQ[k]; - - /* Save data for creation of multiple bitstreams */ - if (encData != NULL) { - encData->LPCindex_g[KLT_ORDER_GAIN*encData->startIdx + k] = index_gQQ[k]; - } - - /* determine number of bits */ - sumQQ = WebRtcIsacfix_kCodeLenGainQ11[posQQ]; //Q11 - BitsQQ += sumQQ; - } - - for (k=0; k<KLT_ORDER_SHAPE; k++) //ATTN: ok? - { - index_sQQ[k] = (WebRtc_Word16)(CalcLrIntQ(tmpcoeffs_sQ17[WebRtcIsacfix_kSelIndShape[k]], 17) + WebRtcIsacfix_kQuantMinShape[k]); //ATTN: ok? - - if (index_sQQ[k] < 0) - index_sQQ[k] = 0; - else if (index_sQQ[k] > WebRtcIsacfix_kMaxIndShape[k]) - index_sQQ[k] = WebRtcIsacfix_kMaxIndShape[k]; - index_ovr_sQQ[k] = WebRtcIsacfix_kOffsetShape[0][k]+index_sQQ[k]; - - posQQ = WebRtcIsacfix_kOfLevelsShape[0] + index_ovr_sQQ[k]; - sumQQ = WebRtcIsacfix_kCodeLenShapeQ11[posQQ]; //Q11 - BitsQQ += sumQQ; - } - - - - *model = 0; - *sizeQ11=BitsQQ; - - /* entropy coding of model number */ - status = WebRtcIsacfix_EncHistMulti(streamdata, model, WebRtcIsacfix_kModelCdfPtr, 1); - if (status < 0) { - return status; - } - - /* entropy coding of quantization indices - shape only */ - status = WebRtcIsacfix_EncHistMulti(streamdata, index_sQQ, WebRtcIsacfix_kCdfShapePtr[0], KLT_ORDER_SHAPE); - if (status < 0) { - return status; - } - - /* Save data for creation of multiple bitstreams */ - if (encData != NULL) { - for (k=0; k<KLT_ORDER_SHAPE; k++) - { - encData->LPCindex_s[KLT_ORDER_SHAPE*encData->startIdx + k] = index_sQQ[k]; - } - } - /* save the state of the bitstream object 'streamdata' for the possible bit-rate reduction */ - transcodingParam->full = streamdata->full; - transcodingParam->stream_index = streamdata->stream_index; - transcodingParam->streamval = streamdata->streamval; - transcodingParam->W_upper = streamdata->W_upper; - transcodingParam->beforeLastWord = streamdata->stream[streamdata->stream_index-1]; - transcodingParam->lastWord = streamdata->stream[streamdata->stream_index]; - - /* entropy coding of index */ - status = WebRtcIsacfix_EncHistMulti(streamdata, index_gQQ, WebRtcIsacfix_kCdfGainPtr[0], KLT_ORDER_GAIN); - if (status < 0) { - return status; - } - - /* find quantization levels for shape coefficients */ - for (k=0; k<KLT_ORDER_SHAPE; k++) { - tmpcoeffs_sQ17[WebRtcIsacfix_kSelIndShape[k]] = WEBRTC_SPL_MUL(128, WebRtcIsacfix_kLevelsShapeQ10[WebRtcIsacfix_kOfLevelsShape[0]+index_ovr_sQQ[k]]); - - } - /* inverse KLT */ - - /* left transform */ // Transpose matrix! - offss = 0; - poss = 0; - for (j=0; j<SUBFRAMES; j++) { - offs2 = 0; - for (k=0; k<LPC_SHAPE_ORDER; k++) { - sumQQ = 0; - pos = offss; - pos2 = offs2; - for (n=0; n<LPC_SHAPE_ORDER; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1ShapeQ15[0][pos2], tmpcoeffs_sQ17[pos]<<1)); // (Q15*Q17)>>(16-1) = Q17 - pos++; - pos2++; - } - tmpcoeffs2_sQ17[poss] = sumQQ; - - poss++; - offs2 += LPC_SHAPE_ORDER; - } - offss += LPC_SHAPE_ORDER; - } - - - /* right transform */ // Transpose matrix - offss = 0; - poss = 0; - for (j=0; j<SUBFRAMES; j++) { - poss = offss; - for (k=0; k<LPC_SHAPE_ORDER; k++) { - sumQQ = 0; - pos = k; - pos2 = j; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2ShapeQ15[0][pos2], tmpcoeffs2_sQ17[pos]<<1)); // (Q15*Q17)>>(16-1) = Q17 - pos += LPC_SHAPE_ORDER; - pos2 += SUBFRAMES; - } - tmpcoeffs_sQ17[poss] = sumQQ; - poss++; - } - offss += LPC_SHAPE_ORDER; - } - - /* scaling, mean addition, and gain restoration */ - poss = 0;pos=0; - for (k=0; k<SUBFRAMES; k++) { - - /* lo band LAR coeffs */ - for (n=0; n<ORDERLO; n++, pos++, poss++) { - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(31208, tmpcoeffs_sQ17[poss]); // (Q16*Q17)>>16 = Q17, with 1/2.1 = 0.47619047619 ~= 31208 in Q16 - tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[0][poss]; // Q17+Q17 = Q17 - LPCCoefQ17[pos] = tmp32; - } - - /* hi band LAR coeffs */ - for (n=0; n<ORDERHI; n++, pos++, poss++) { - tmp32 = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]), 3); // ((Q13*Q17)>>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 - tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[0][poss]; // Q17+Q17 = Q17 - LPCCoefQ17[pos] = tmp32; - } - - } - - //to update tmpcoeffs_gQ17 to the proper state - for (k=0; k<KLT_ORDER_GAIN; k++) { - tmpcoeffs_gQ17[WebRtcIsacfix_kSelIndGain[k]] = WebRtcIsacfix_kLevelsGainQ17[WebRtcIsacfix_kOfLevelsGain[0]+index_ovr_gQQ[k]]; - } - - - - /* find quantization levels for coefficients */ - - /* left transform */ - offsg = 0; - posg = 0; - for (j=0; j<SUBFRAMES; j++) { - offs2 = 0; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = offsg; - pos2 = offs2; - for (n=0; n<2; n++) { - sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1GainQ15[0][pos2], tmpcoeffs_gQ17[pos])<<1); // (Q15*Q17)>>(16-1) = Q17 - pos++; - pos2++; - } - tmpcoeffs2_gQ21[posg] = WEBRTC_SPL_LSHIFT_W32(sumQQ, 4); //Q17<<4 = Q21 - posg++; - offs2 += 2; - } - offsg += 2; - } - - /* right transform */ // Transpose matrix - offsg = 0; - posg = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = k; - pos2 = j; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2GainQ15[0][pos2], tmpcoeffs2_gQ21[pos]), 1); // (Q15*Q21)>>(16-1) = Q21 - pos += 2; - pos2 += SUBFRAMES; - } - tmpcoeffs_gQ17[posg] = WEBRTC_SPL_RSHIFT_W32(sumQQ, 4); - posg++; - } - offsg += 2; - } - - /* scaling, mean addition, and gain restoration */ - posg = 0; - gainpos = 0; - for (k=0; k<2*SUBFRAMES; k++) { - - sumQQ16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmpcoeffs_gQ17[posg], 2+9); //Divide by 4 and get Q17 to Q8, i.e. shift 2+9 - sumQQ16 += WebRtcIsacfix_kMeansGainQ8[0][posg]; - sumQQ = CalcExpN(sumQQ16); // Q8 in and Q17 out - gain_lo_hiQ17[gainpos] = sumQQ; //Q17 - - gainpos++; - pos++;posg++; - } - - return 0; -} - -int WebRtcIsacfix_EstCodeLpcGain(WebRtc_Word32 *gain_lo_hiQ17, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData) { - int j, k, n; - WebRtc_Word16 posQQ, pos2QQ, gainpos; - WebRtc_Word16 pos, pos2, posg, offsg, offs2; - WebRtc_Word16 index_gQQ[KLT_ORDER_GAIN]; - - WebRtc_Word16 tmpcoeffs_gQ6[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs_gQ17[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs2_gQ21[KLT_ORDER_GAIN]; - WebRtc_Word32 sumQQ; - int status = 0; - - /* write LAR coefficients to statistics file */ - /* Save data for creation of multiple bitstreams (and transcoding) */ - if (encData != NULL) { - for (k=0; k<KLT_ORDER_GAIN; k++) { - encData->LPCcoeffs_g[KLT_ORDER_GAIN*encData->startIdx + k] = gain_lo_hiQ17[k]; - } - } - - /* log gains, mean removal and scaling */ - posg = 0; pos = 0; gainpos = 0; - - for (k=0; k<SUBFRAMES; k++) { - /* log gains */ - - /* The input argument X to logN(X) is 2^17 times higher than the - input floating point argument Y to log(Y), since the X value - is a Q17 value. This can be compensated for after the call, by - subraction a value Z for each Q-step. One Q-step means that - X gets 2 times higher, i.e. Z = logN(2)*256 = 0.693147180559*256 = - 177.445678 should be subtracted (since logN() returns a Q8 value). - For a X value in Q17, the value 177.445678*17 = 3017 should be - subtracted */ - tmpcoeffs_gQ6[posg] = CalcLogN(gain_lo_hiQ17[gainpos])-3017; //Q8 - tmpcoeffs_gQ6[posg] -= WebRtcIsacfix_kMeansGainQ8[0][posg]; //Q8, but Q6 after not-needed mult. by 4 - posg++; gainpos++; - - tmpcoeffs_gQ6[posg] = CalcLogN(gain_lo_hiQ17[gainpos])-3017; //Q8 - tmpcoeffs_gQ6[posg] -= WebRtcIsacfix_kMeansGainQ8[0][posg]; //Q8, but Q6 after not-needed mult. by 4 - posg++; gainpos++; - } - - - /* KLT */ - - /* left transform */ - offsg = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = offsg; - pos2 = k; - for (n=0; n<2; n++) { - sumQQ += WEBRTC_SPL_MUL_16_16(tmpcoeffs_gQ6[pos], WebRtcIsacfix_kT1GainQ15[0][pos2]); //Q21 = Q6*Q15 - pos++; - pos2 += 2; - } - tmpcoeffs2_gQ21[posg] = sumQQ; - posg++; - } - offsg += 2; - } - - /* right transform */ - offsg = 0; - offs2 = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = k; - pos2 = offs2; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2GainQ15[0][pos2], tmpcoeffs2_gQ21[pos]), 1); // (Q15*Q21)>>(16-1) = Q21 - pos += 2; - pos2++; - } - tmpcoeffs_gQ17[posg] = WEBRTC_SPL_RSHIFT_W32(sumQQ, 4); - posg++; - } - offsg += 2; - offs2 += SUBFRAMES; - } - - /* quantize coefficients */ - - for (k=0; k<KLT_ORDER_GAIN; k++) //ATTN: ok? - { - posQQ = WebRtcIsacfix_kSelIndGain[k]; - pos2QQ= (WebRtc_Word16)CalcLrIntQ(tmpcoeffs_gQ17[posQQ], 17); - - index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok? - if (index_gQQ[k] < 0) { - index_gQQ[k] = 0; - } - else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) { - index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k]; - } - - /* Save data for creation of multiple bitstreams */ - if (encData != NULL) { - encData->LPCindex_g[KLT_ORDER_GAIN*encData->startIdx + k] = index_gQQ[k]; - } - } - - /* entropy coding of index */ - status = WebRtcIsacfix_EncHistMulti(streamdata, index_gQQ, WebRtcIsacfix_kCdfGainPtr[0], KLT_ORDER_GAIN); - if (status < 0) { - return status; - } - - return 0; -} - - -int WebRtcIsacfix_EncodeLpc(WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *LPCCoef_loQ15, - WebRtc_Word16 *LPCCoef_hiQ15, - WebRtc_Word16 *model, - WebRtc_Word32 *sizeQ11, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData, - transcode_obj *transcodeParam) -{ - int status = 0; - WebRtc_Word32 larsQ17[KLT_ORDER_SHAPE]; // KLT_ORDER_SHAPE == (ORDERLO+ORDERHI)*SUBFRAMES - // = (6+12)*6 == 108 - - Poly2LarFix(LPCCoef_loQ15, ORDERLO, LPCCoef_hiQ15, ORDERHI, SUBFRAMES, larsQ17); - - status = EstCodeLpcCoef(larsQ17, gain_lo_hiQ17, model, sizeQ11, streamdata, encData, transcodeParam); - if (status < 0) { - return (status); - } - - Lar2polyFix(larsQ17, LPCCoef_loQ15, ORDERLO, LPCCoef_hiQ15, ORDERHI, SUBFRAMES); - - return 0; -} - - -/* decode & dequantize RC */ -int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec *streamdata, WebRtc_Word16 *RCQ15) -{ - int k, err; - WebRtc_Word16 index[AR_ORDER]; - - /* entropy decoding of quantization indices */ - err = WebRtcIsacfix_DecHistOneStepMulti(index, streamdata, WebRtcIsacfix_kRcCdfPtr, WebRtcIsacfix_kRcInitInd, AR_ORDER); - if (err<0) // error check - return err; - - /* find quantization levels for reflection coefficients */ - for (k=0; k<AR_ORDER; k++) - { - RCQ15[k] = *(WebRtcIsacfix_kRcLevPtr[k] + index[k]); - } - - return 0; -} - - - -/* quantize & code RC */ -int WebRtcIsacfix_EncodeRcCoef(WebRtc_Word16 *RCQ15, Bitstr_enc *streamdata) -{ - int k; - WebRtc_Word16 index[AR_ORDER]; - int status; - - /* quantize reflection coefficients (add noise feedback?) */ - for (k=0; k<AR_ORDER; k++) - { - index[k] = WebRtcIsacfix_kRcInitInd[k]; - - if (RCQ15[k] > WebRtcIsacfix_kRcBound[index[k]]) - { - while (RCQ15[k] > WebRtcIsacfix_kRcBound[index[k] + 1]) - index[k]++; - } - else - { - while (RCQ15[k] < WebRtcIsacfix_kRcBound[--index[k]]) ; - } - - RCQ15[k] = *(WebRtcIsacfix_kRcLevPtr[k] + index[k]); - } - - - /* entropy coding of quantization indices */ - status = WebRtcIsacfix_EncHistMulti(streamdata, index, WebRtcIsacfix_kRcCdfPtr, AR_ORDER); - - /* If error in WebRtcIsacfix_EncHistMulti(), status will be negative, otherwise 0 */ - return status; -} - - -/* decode & dequantize squared Gain */ -int WebRtcIsacfix_DecodeGain2(Bitstr_dec *streamdata, WebRtc_Word32 *gainQ10) -{ - int err; - WebRtc_Word16 index; - - /* entropy decoding of quantization index */ - err = WebRtcIsacfix_DecHistOneStepMulti( - &index, - streamdata, - WebRtcIsacfix_kGainPtr, - WebRtcIsacfix_kGainInitInd, - 1); - /* error check */ - if (err<0) { - return err; - } - - /* find quantization level */ - *gainQ10 = WebRtcIsacfix_kGain2Lev[index]; - - return 0; -} - - - -/* quantize & code squared Gain */ -int WebRtcIsacfix_EncodeGain2(WebRtc_Word32 *gainQ10, Bitstr_enc *streamdata) -{ - WebRtc_Word16 index; - int status = 0; - - /* find quantization index */ - index = WebRtcIsacfix_kGainInitInd[0]; - if (*gainQ10 > WebRtcIsacfix_kGain2Bound[index]) - { - while (*gainQ10 > WebRtcIsacfix_kGain2Bound[index + 1]) - index++; - } - else - { - while (*gainQ10 < WebRtcIsacfix_kGain2Bound[--index]) ; - } - - /* dequantize */ - *gainQ10 = WebRtcIsacfix_kGain2Lev[index]; - - /* entropy coding of quantization index */ - status = WebRtcIsacfix_EncHistMulti(streamdata, &index, WebRtcIsacfix_kGainPtr, 1); - - /* If error in WebRtcIsacfix_EncHistMulti(), status will be negative, otherwise 0 */ - return status; -} - - -/* code and decode Pitch Gains and Lags functions */ - -/* decode & dequantize Pitch Gains */ -int WebRtcIsacfix_DecodePitchGain(Bitstr_dec *streamdata, WebRtc_Word16 *PitchGains_Q12) -{ - int err; - WebRtc_Word16 index_comb; - const WebRtc_UWord16 *pitch_gain_cdf_ptr[1]; - - /* entropy decoding of quantization indices */ - *pitch_gain_cdf_ptr = WebRtcIsacfix_kPitchGainCdf; - err = WebRtcIsacfix_DecHistBisectMulti(&index_comb, streamdata, pitch_gain_cdf_ptr, WebRtcIsacfix_kCdfTableSizeGain, 1); - /* error check, Q_mean_Gain.. tables are of size 144 */ - if ((err<0) || (index_comb<0) || (index_comb>144)) - return -ISAC_RANGE_ERROR_DECODE_PITCH_GAIN; - - /* unquantize back to pitch gains by table look-up */ - PitchGains_Q12[0] = WebRtcIsacfix_kPitchGain1[index_comb]; - PitchGains_Q12[1] = WebRtcIsacfix_kPitchGain2[index_comb]; - PitchGains_Q12[2] = WebRtcIsacfix_kPitchGain3[index_comb]; - PitchGains_Q12[3] = WebRtcIsacfix_kPitchGain4[index_comb]; - - return 0; -} - - -/* quantize & code Pitch Gains */ -int WebRtcIsacfix_EncodePitchGain(WebRtc_Word16 *PitchGains_Q12, Bitstr_enc *streamdata, ISAC_SaveEncData_t* encData) -{ - int k,j; - WebRtc_Word16 SQ15[PITCH_SUBFRAMES]; - WebRtc_Word16 index[3]; - WebRtc_Word16 index_comb; - const WebRtc_UWord16 *pitch_gain_cdf_ptr[1]; - WebRtc_Word32 CQ17; - int status = 0; - - - /* get the approximate arcsine (almost linear)*/ - for (k=0; k<PITCH_SUBFRAMES; k++) - SQ15[k] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT(PitchGains_Q12[k],33,2); //Q15 - - - /* find quantization index; only for the first three transform coefficients */ - for (k=0; k<3; k++) - { - /* transform */ - CQ17=0; - for (j=0; j<PITCH_SUBFRAMES; j++) { - CQ17 += WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIsacfix_kTransform[k][j], SQ15[j],10); // Q17 - } - - index[k] = (WebRtc_Word16)((CQ17 + 8192)>>14); // Rounding and scaling with stepsize (=1/0.125=8) - - /* check that the index is not outside the boundaries of the table */ - if (index[k] < WebRtcIsacfix_kLowerlimiGain[k]) index[k] = WebRtcIsacfix_kLowerlimiGain[k]; - else if (index[k] > WebRtcIsacfix_kUpperlimitGain[k]) index[k] = WebRtcIsacfix_kUpperlimitGain[k]; - index[k] -= WebRtcIsacfix_kLowerlimiGain[k]; - } - - /* calculate unique overall index */ - index_comb = (WebRtc_Word16)(WEBRTC_SPL_MUL(WebRtcIsacfix_kMultsGain[0], index[0]) + - WEBRTC_SPL_MUL(WebRtcIsacfix_kMultsGain[1], index[1]) + index[2]); - - /* unquantize back to pitch gains by table look-up */ - // (Y) - PitchGains_Q12[0] = WebRtcIsacfix_kPitchGain1[index_comb]; - PitchGains_Q12[1] = WebRtcIsacfix_kPitchGain2[index_comb]; - PitchGains_Q12[2] = WebRtcIsacfix_kPitchGain3[index_comb]; - PitchGains_Q12[3] = WebRtcIsacfix_kPitchGain4[index_comb]; - - - /* entropy coding of quantization pitch gains */ - *pitch_gain_cdf_ptr = WebRtcIsacfix_kPitchGainCdf; - status = WebRtcIsacfix_EncHistMulti(streamdata, &index_comb, pitch_gain_cdf_ptr, 1); - if (status < 0) { - return status; - } - - /* Save data for creation of multiple bitstreams */ - if (encData != NULL) { - encData->pitchGain_index[encData->startIdx] = index_comb; - } - - return 0; -} - - - -/* Pitch LAG */ - - -/* decode & dequantize Pitch Lags */ -int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata, - WebRtc_Word16 *PitchGain_Q12, - WebRtc_Word16 *PitchLags_Q7) -{ - int k, err; - WebRtc_Word16 index[PITCH_SUBFRAMES]; - const WebRtc_Word16 *mean_val2Q10, *mean_val4Q10; - - const WebRtc_Word16 *lower_limit; - const WebRtc_UWord16 *init_index; - const WebRtc_UWord16 *cdf_size; - const WebRtc_UWord16 **cdf; - - WebRtc_Word32 meangainQ12; - WebRtc_Word32 CQ11, CQ10,tmp32a,tmp32b; - WebRtc_Word16 shft,tmp16a,tmp16c; - - meangainQ12=0; - for (k = 0; k < 4; k++) - meangainQ12 += PitchGain_Q12[k]; - - meangainQ12 = WEBRTC_SPL_RSHIFT_W32(meangainQ12, 2); // Get average - - /* voicing classificiation */ - if (meangainQ12 <= 819) { // mean_gain < 0.2 - shft = -1; // StepSize=2.0; - cdf = WebRtcIsacfix_kPitchLagPtrLo; - cdf_size = WebRtcIsacfix_kPitchLagSizeLo; - mean_val2Q10 = WebRtcIsacfix_kMeanLag2Lo; - mean_val4Q10 = WebRtcIsacfix_kMeanLag4Lo; - lower_limit = WebRtcIsacfix_kLowerLimitLo; - init_index = WebRtcIsacfix_kInitIndLo; - } else if (meangainQ12 <= 1638) { // mean_gain < 0.4 - shft = 0; // StepSize=1.0; - cdf = WebRtcIsacfix_kPitchLagPtrMid; - cdf_size = WebRtcIsacfix_kPitchLagSizeMid; - mean_val2Q10 = WebRtcIsacfix_kMeanLag2Mid; - mean_val4Q10 = WebRtcIsacfix_kMeanLag4Mid; - lower_limit = WebRtcIsacfix_kLowerLimitMid; - init_index = WebRtcIsacfix_kInitIndMid; - } else { - shft = 1; // StepSize=0.5; - cdf = WebRtcIsacfix_kPitchLagPtrHi; - cdf_size = WebRtcIsacfix_kPitchLagSizeHi; - mean_val2Q10 = WebRtcIsacfix_kMeanLag2Hi; - mean_val4Q10 = WebRtcIsacfix_kMeanLag4Hi; - lower_limit = WebRtcIsacfix_kLowerLimitHi; - init_index = WebRtcIsacfix_kInitIndHi; - } - - /* entropy decoding of quantization indices */ - err = WebRtcIsacfix_DecHistBisectMulti(index, streamdata, cdf, cdf_size, 1); - if ((err<0) || (index[0]<0)) // error check - return -ISAC_RANGE_ERROR_DECODE_PITCH_LAG; - - err = WebRtcIsacfix_DecHistOneStepMulti(index+1, streamdata, cdf+1, init_index, 3); - if (err<0) // error check - return -ISAC_RANGE_ERROR_DECODE_PITCH_LAG; - - - /* unquantize back to transform coefficients and do the inverse transform: S = T'*C */ - CQ11 = ((WebRtc_Word32)index[0] + lower_limit[0]); // Q0 - CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11 - for (k=0; k<PITCH_SUBFRAMES; k++) { - tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11); - tmp16a = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32a, 5); - PitchLags_Q7[k] = tmp16a; - } - - CQ10 = mean_val2Q10[index[1]]; - for (k=0; k<PITCH_SUBFRAMES; k++) { - tmp32b = (WebRtc_Word32) WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) WebRtcIsacfix_kTransform[1][k], (WebRtc_Word16) CQ10,10); - tmp16c = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); - PitchLags_Q7[k] += tmp16c; - } - - CQ10 = mean_val4Q10[index[3]]; - for (k=0; k<PITCH_SUBFRAMES; k++) { - tmp32b = (WebRtc_Word32) WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) WebRtcIsacfix_kTransform[3][k], (WebRtc_Word16) CQ10,10); - tmp16c = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); - PitchLags_Q7[k] += tmp16c; - } - - return 0; -} - - - -/* quantize & code Pitch Lags */ -int WebRtcIsacfix_EncodePitchLag(WebRtc_Word16 *PitchLagsQ7,WebRtc_Word16 *PitchGain_Q12, - Bitstr_enc *streamdata, ISAC_SaveEncData_t* encData) -{ - int k, j; - WebRtc_Word16 index[PITCH_SUBFRAMES]; - WebRtc_Word32 meangainQ12, CQ17; - WebRtc_Word32 CQ11, CQ10,tmp32a; - - const WebRtc_Word16 *mean_val2Q10,*mean_val4Q10; - const WebRtc_Word16 *lower_limit, *upper_limit; - const WebRtc_UWord16 **cdf; - WebRtc_Word16 shft, tmp16a, tmp16b, tmp16c; - WebRtc_Word32 tmp32b; - int status = 0; - - /* compute mean pitch gain */ - meangainQ12=0; - for (k = 0; k < 4; k++) - meangainQ12 += PitchGain_Q12[k]; - - meangainQ12 = WEBRTC_SPL_RSHIFT_W32(meangainQ12, 2); - - /* Save data for creation of multiple bitstreams */ - if (encData != NULL) { - encData->meanGain[encData->startIdx] = meangainQ12; - } - - /* voicing classificiation */ - if (meangainQ12 <= 819) { // mean_gain < 0.2 - shft = -1; // StepSize=2.0; - cdf = WebRtcIsacfix_kPitchLagPtrLo; - mean_val2Q10 = WebRtcIsacfix_kMeanLag2Lo; - mean_val4Q10 = WebRtcIsacfix_kMeanLag4Lo; - lower_limit = WebRtcIsacfix_kLowerLimitLo; - upper_limit = WebRtcIsacfix_kUpperLimitLo; - } else if (meangainQ12 <= 1638) { // mean_gain < 0.4 - shft = 0; // StepSize=1.0; - cdf = WebRtcIsacfix_kPitchLagPtrMid; - mean_val2Q10 = WebRtcIsacfix_kMeanLag2Mid; - mean_val4Q10 = WebRtcIsacfix_kMeanLag4Mid; - lower_limit = WebRtcIsacfix_kLowerLimitMid; - upper_limit = WebRtcIsacfix_kUpperLimitMid; - } else { - shft = 1; // StepSize=0.5; - cdf = WebRtcIsacfix_kPitchLagPtrHi; - mean_val2Q10 = WebRtcIsacfix_kMeanLag2Hi; - mean_val4Q10 = WebRtcIsacfix_kMeanLag4Hi; - lower_limit = WebRtcIsacfix_kLowerLimitHi; - upper_limit = WebRtcIsacfix_kUpperLimitHi; - } - - /* find quantization index */ - for (k=0; k<4; k++) - { - /* transform */ - CQ17=0; - for (j=0; j<PITCH_SUBFRAMES; j++) - CQ17 += WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIsacfix_kTransform[k][j], PitchLagsQ7[j],2); // Q17 - - CQ17 = WEBRTC_SPL_SHIFT_W32(CQ17,shft); // Scale with StepSize - - /* quantize */ - tmp16b = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(CQ17 + 65536, 17 ); - index[k] = tmp16b; - - /* check that the index is not outside the boundaries of the table */ - if (index[k] < lower_limit[k]) index[k] = lower_limit[k]; - else if (index[k] > upper_limit[k]) index[k] = upper_limit[k]; - index[k] -= lower_limit[k]; - - /* Save data for creation of multiple bitstreams */ - if(encData != NULL) { - encData->pitchIndex[PITCH_SUBFRAMES*encData->startIdx + k] = index[k]; - } - } - - /* unquantize back to transform coefficients and do the inverse transform: S = T'*C */ - CQ11 = (index[0] + lower_limit[0]); // Q0 - CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11 - - for (k=0; k<PITCH_SUBFRAMES; k++) { - tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11); // Q12 - tmp16a = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32a, 5);// Q7 - PitchLagsQ7[k] = tmp16a; - } - - CQ10 = mean_val2Q10[index[1]]; - for (k=0; k<PITCH_SUBFRAMES; k++) { - tmp32b = (WebRtc_Word32) WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) WebRtcIsacfix_kTransform[1][k], (WebRtc_Word16) CQ10,10); - tmp16c = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); // Q7 - PitchLagsQ7[k] += tmp16c; - } - - CQ10 = mean_val4Q10[index[3]]; - for (k=0; k<PITCH_SUBFRAMES; k++) { - tmp32b = (WebRtc_Word32) WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) WebRtcIsacfix_kTransform[3][k], (WebRtc_Word16) CQ10,10); - tmp16c = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); // Q7 - PitchLagsQ7[k] += tmp16c; - } - - /* entropy coding of quantization pitch lags */ - status = WebRtcIsacfix_EncHistMulti(streamdata, index, cdf, PITCH_SUBFRAMES); - - /* If error in WebRtcIsacfix_EncHistMulti(), status will be negative, otherwise 0 */ - return status; -} - - - -/* Routines for inband signaling of bandwitdh estimation */ -/* Histograms based on uniform distribution of indices */ -/* Move global variables later! */ - - -/* cdf array for frame length indicator */ -const WebRtc_UWord16 kFrameLenCdf[4] = { - 0, 21845, 43690, 65535}; - -/* pointer to cdf array for frame length indicator */ -const WebRtc_UWord16 *kFrameLenCdfPtr[1] = {kFrameLenCdf}; - -/* initial cdf index for decoder of frame length indicator */ -const WebRtc_UWord16 kFrameLenInitIndex[1] = {1}; - - -int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata, - WebRtc_Word16 *framesamples) -{ - - int err; - WebRtc_Word16 frame_mode; - - err = 0; - /* entropy decoding of frame length [1:30ms,2:60ms] */ - err = WebRtcIsacfix_DecHistOneStepMulti(&frame_mode, streamdata, kFrameLenCdfPtr, kFrameLenInitIndex, 1); - if (err<0) // error check - return -ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH; - - switch(frame_mode) { - case 1: - *framesamples = 480; /* 30ms */ - break; - case 2: - *framesamples = 960; /* 60ms */ - break; - default: - err = -ISAC_DISALLOWED_FRAME_MODE_DECODER; - } - - return err; -} - - -int WebRtcIsacfix_EncodeFrameLen(WebRtc_Word16 framesamples, Bitstr_enc *streamdata) { - - int status; - WebRtc_Word16 frame_mode; - - status = 0; - frame_mode = 0; - /* entropy coding of frame length [1:480 samples,2:960 samples] */ - switch(framesamples) { - case 480: - frame_mode = 1; - break; - case 960: - frame_mode = 2; - break; - default: - status = - ISAC_DISALLOWED_FRAME_MODE_ENCODER; - } - - if (status < 0) - return status; - - status = WebRtcIsacfix_EncHistMulti(streamdata, &frame_mode, kFrameLenCdfPtr, 1); - - return status; -} - -/* cdf array for estimated bandwidth */ -const WebRtc_UWord16 kBwCdf[25] = { - 0, 2731, 5461, 8192, 10923, 13653, 16384, 19114, 21845, 24576, 27306, 30037, - 32768, 35498, 38229, 40959, 43690, 46421, 49151, 51882, 54613, 57343, 60074, - 62804, 65535}; - -/* pointer to cdf array for estimated bandwidth */ -const WebRtc_UWord16 *kBwCdfPtr[1] = {kBwCdf}; - -/* initial cdf index for decoder of estimated bandwidth*/ -const WebRtc_UWord16 kBwInitIndex[1] = {7}; - - -int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec *streamdata, WebRtc_Word16 *BWno) { - - int err; - WebRtc_Word16 BWno32; - - /* entropy decoding of sender's BW estimation [0..23] */ - err = WebRtcIsacfix_DecHistOneStepMulti(&BWno32, streamdata, kBwCdfPtr, kBwInitIndex, 1); - if (err<0) // error check - return -ISAC_RANGE_ERROR_DECODE_BANDWIDTH; - *BWno = (WebRtc_Word16)BWno32; - return err; - -} - - -int WebRtcIsacfix_EncodeReceiveBandwidth(WebRtc_Word16 *BWno, Bitstr_enc *streamdata) -{ - int status = 0; - /* entropy encoding of receiver's BW estimation [0..23] */ - status = WebRtcIsacfix_EncHistMulti(streamdata, BWno, kBwCdfPtr, 1); - - return status; -} - -/* estimate codel length of LPC Coef */ -void WebRtcIsacfix_TranscodeLpcCoef(WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *index_gQQ) { - int j, k, n; - WebRtc_Word16 posQQ, pos2QQ; - WebRtc_Word16 pos, pos2, posg, offsg, offs2, gainpos; - WebRtc_Word32 tmpcoeffs_gQ6[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs_gQ17[KLT_ORDER_GAIN]; - WebRtc_Word32 tmpcoeffs2_gQ21[KLT_ORDER_GAIN]; - WebRtc_Word32 sumQQ; - - - /* log gains, mean removal and scaling */ - posg = 0;pos=0; gainpos=0; - - for (k=0; k<SUBFRAMES; k++) { - /* log gains */ - - /* The input argument X to logN(X) is 2^17 times higher than the - input floating point argument Y to log(Y), since the X value - is a Q17 value. This can be compensated for after the call, by - subraction a value Z for each Q-step. One Q-step means that - X gets 2 times higher, i.e. Z = logN(2)*256 = 0.693147180559*256 = - 177.445678 should be subtracted (since logN() returns a Q8 value). - For a X value in Q17, the value 177.445678*17 = 3017 should be - subtracted */ - tmpcoeffs_gQ6[posg] = CalcLogN(gain_lo_hiQ17[gainpos])-3017; //Q8 - tmpcoeffs_gQ6[posg] -= WebRtcIsacfix_kMeansGainQ8[0][posg]; //Q8, but Q6 after not-needed mult. by 4 - posg++; gainpos++; - - tmpcoeffs_gQ6[posg] = CalcLogN(gain_lo_hiQ17[gainpos])-3017; //Q8 - tmpcoeffs_gQ6[posg] -= WebRtcIsacfix_kMeansGainQ8[0][posg]; //Q8, but Q6 after not-needed mult. by 4 - posg++; gainpos++; - - } - - - /* KLT */ - - /* left transform */ - offsg = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = offsg; - pos2 = k; - for (n=0; n<2; n++) { - sumQQ += WEBRTC_SPL_MUL_16_16(tmpcoeffs_gQ6[pos], WebRtcIsacfix_kT1GainQ15[0][pos2]); //Q21 = Q6*Q15 - pos++; - pos2 += 2; - } - tmpcoeffs2_gQ21[posg] = sumQQ; - posg++; - } - - offsg += 2; - } - - /* right transform */ - offsg = 0; - offs2 = 0; - for (j=0; j<SUBFRAMES; j++) { - posg = offsg; - for (k=0; k<2; k++) { - sumQQ = 0; - pos = k; - pos2 = offs2; - for (n=0; n<SUBFRAMES; n++) { - sumQQ += WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT2GainQ15[0][pos2], tmpcoeffs2_gQ21[pos]), 1); // (Q15*Q21)>>(16-1) = Q21 - pos += 2; - pos2++; - } - tmpcoeffs_gQ17[posg] = WEBRTC_SPL_RSHIFT_W32(sumQQ, 4); - posg++; - } - offsg += 2; - offs2 += SUBFRAMES; - } - - /* quantize coefficients */ - for (k=0; k<KLT_ORDER_GAIN; k++) //ATTN: ok? - { - posQQ = WebRtcIsacfix_kSelIndGain[k]; - pos2QQ= (WebRtc_Word16)CalcLrIntQ(tmpcoeffs_gQ17[posQQ], 17); - - index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok? - if (index_gQQ[k] < 0) { - index_gQQ[k] = 0; - } - else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) { - index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k]; - } - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h b/src/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h deleted file mode 100644 index 298ea22..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h +++ /dev/null
@@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * entropy_coding.h - * - * This header file contains all of the functions used to arithmetically - * encode the iSAC bistream - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ - -#include "structs.h" - -/* decode complex spectrum (return number of bytes in stream) */ -WebRtc_Word16 WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, - WebRtc_Word16 *frQ7, - WebRtc_Word16 *fiQ7, - WebRtc_Word16 AvgPitchGain_Q12); - -/* encode complex spectrum */ -int WebRtcIsacfix_EncodeSpec(const WebRtc_Word16 *fr, - const WebRtc_Word16 *fi, - Bitstr_enc *streamdata, - WebRtc_Word16 AvgPitchGain_Q12); - - -/* decode & dequantize LPC Coef */ -int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata, - WebRtc_Word32 *LPCCoefQ17, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *outmodel); - -int WebRtcIsacfix_DecodeLpc(WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *LPCCoef_loQ15, - WebRtc_Word16 *LPCCoef_hiQ15, - Bitstr_dec *streamdata, - WebRtc_Word16 *outmodel); - -/* quantize & code LPC Coef */ -int WebRtcIsacfix_EncodeLpc(WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *LPCCoef_loQ15, - WebRtc_Word16 *LPCCoef_hiQ15, - WebRtc_Word16 *model, - WebRtc_Word32 *sizeQ11, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData, - transcode_obj *transcodeParam); - -int WebRtcIsacfix_EstCodeLpcGain(WebRtc_Word32 *gain_lo_hiQ17, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData); -/* decode & dequantize RC */ -int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec *streamdata, - WebRtc_Word16 *RCQ15); - -/* quantize & code RC */ -int WebRtcIsacfix_EncodeRcCoef(WebRtc_Word16 *RCQ15, - Bitstr_enc *streamdata); - -/* decode & dequantize squared Gain */ -int WebRtcIsacfix_DecodeGain2(Bitstr_dec *streamdata, - WebRtc_Word32 *Gain2); - -/* quantize & code squared Gain (input is squared gain) */ -int WebRtcIsacfix_EncodeGain2(WebRtc_Word32 *gain2, - Bitstr_enc *streamdata); - -int WebRtcIsacfix_EncodePitchGain(WebRtc_Word16 *PitchGains_Q12, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData); - -int WebRtcIsacfix_EncodePitchLag(WebRtc_Word16 *PitchLagQ7, - WebRtc_Word16 *PitchGain_Q12, - Bitstr_enc *streamdata, - ISAC_SaveEncData_t* encData); - -int WebRtcIsacfix_DecodePitchGain(Bitstr_dec *streamdata, - WebRtc_Word16 *PitchGain_Q12); - -int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata, - WebRtc_Word16 *PitchGain_Q12, - WebRtc_Word16 *PitchLagQ7); - -int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata, - WebRtc_Word16 *framelength); - - -int WebRtcIsacfix_EncodeFrameLen(WebRtc_Word16 framelength, - Bitstr_enc *streamdata); - -int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec *streamdata, - WebRtc_Word16 *BWno); - - -int WebRtcIsacfix_EncodeReceiveBandwidth(WebRtc_Word16 *BWno, - Bitstr_enc *streamdata); - -void WebRtcIsacfix_TranscodeLpcCoef(WebRtc_Word32 *tmpcoeffs_gQ6, - WebRtc_Word16 *index_gQQ); - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/fft.c b/src/modules/audio_coding/codecs/isac/fix/source/fft.c deleted file mode 100644 index fff35c4..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/fft.c +++ /dev/null
@@ -1,415 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * fft.c - * - * Fast Fourier Transform - * - */ - - -#include "fft.h" - -const WebRtc_Word16 kSortTabFft[240] = { - 0, 60, 120, 180, 20, 80, 140, 200, 40, 100, 160, 220, - 4, 64, 124, 184, 24, 84, 144, 204, 44, 104, 164, 224, - 8, 68, 128, 188, 28, 88, 148, 208, 48, 108, 168, 228, - 12, 72, 132, 192, 32, 92, 152, 212, 52, 112, 172, 232, - 16, 76, 136, 196, 36, 96, 156, 216, 56, 116, 176, 236, - 1, 61, 121, 181, 21, 81, 141, 201, 41, 101, 161, 221, - 5, 65, 125, 185, 25, 85, 145, 205, 45, 105, 165, 225, - 9, 69, 129, 189, 29, 89, 149, 209, 49, 109, 169, 229, - 13, 73, 133, 193, 33, 93, 153, 213, 53, 113, 173, 233, - 17, 77, 137, 197, 37, 97, 157, 217, 57, 117, 177, 237, - 2, 62, 122, 182, 22, 82, 142, 202, 42, 102, 162, 222, - 6, 66, 126, 186, 26, 86, 146, 206, 46, 106, 166, 226, - 10, 70, 130, 190, 30, 90, 150, 210, 50, 110, 170, 230, - 14, 74, 134, 194, 34, 94, 154, 214, 54, 114, 174, 234, - 18, 78, 138, 198, 38, 98, 158, 218, 58, 118, 178, 238, - 3, 63, 123, 183, 23, 83, 143, 203, 43, 103, 163, 223, - 7, 67, 127, 187, 27, 87, 147, 207, 47, 107, 167, 227, - 11, 71, 131, 191, 31, 91, 151, 211, 51, 111, 171, 231, - 15, 75, 135, 195, 35, 95, 155, 215, 55, 115, 175, 235, - 19, 79, 139, 199, 39, 99, 159, 219, 59, 119, 179, 239 -}; - -/* Cosine table in Q14 */ -const WebRtc_Word16 kCosTabFfftQ14[240] = { - 16384, 16378, 16362, 16333, 16294, 16244, 16182, 16110, 16026, 15931, 15826, 15709, - 15582, 15444, 15296, 15137, 14968, 14788, 14598, 14399, 14189, 13970, 13741, 13502, - 13255, 12998, 12733, 12458, 12176, 11885, 11585, 11278, 10963, 10641, 10311, 9974, - 9630, 9280, 8923, 8561, 8192, 7818, 7438, 7053, 6664, 6270, 5872, 5469, - 5063, 4653, 4240, 3825, 3406, 2986, 2563, 2139, 1713, 1285, 857, 429, - 0, -429, -857, -1285, -1713, -2139, -2563, -2986, -3406, -3825, -4240, -4653, - -5063, -5469, -5872, -6270, -6664, -7053, -7438, -7818, -8192, -8561, -8923, -9280, - -9630, -9974, -10311, -10641, -10963, -11278, -11585, -11885, -12176, -12458, -12733, -12998, - -13255, -13502, -13741, -13970, -14189, -14399, -14598, -14788, -14968, -15137, -15296, -15444, - -15582, -15709, -15826, -15931, -16026, -16110, -16182, -16244, -16294, -16333, -16362, -16378, - -16384, -16378, -16362, -16333, -16294, -16244, -16182, -16110, -16026, -15931, -15826, -15709, - -15582, -15444, -15296, -15137, -14968, -14788, -14598, -14399, -14189, -13970, -13741, -13502, - -13255, -12998, -12733, -12458, -12176, -11885, -11585, -11278, -10963, -10641, -10311, -9974, - -9630, -9280, -8923, -8561, -8192, -7818, -7438, -7053, -6664, -6270, -5872, -5469, - -5063, -4653, -4240, -3825, -3406, -2986, -2563, -2139, -1713, -1285, -857, -429, - 0, 429, 857, 1285, 1713, 2139, 2563, 2986, 3406, 3825, 4240, 4653, - 5063, 5469, 5872, 6270, 6664, 7053, 7438, 7818, 8192, 8561, 8923, 9280, - 9630, 9974, 10311, 10641, 10963, 11278, 11585, 11885, 12176, 12458, 12733, 12998, - 13255, 13502, 13741, 13970, 14189, 14399, 14598, 14788, 14968, 15137, 15296, 15444, - 15582, 15709, 15826, 15931, 16026, 16110, 16182, 16244, 16294, 16333, 16362, 16378 -}; - - - -/* Uses 16x16 mul, without rounding, which is faster. Uses WEBRTC_SPL_MUL_16_16_RSFT */ -WebRtc_Word16 WebRtcIsacfix_FftRadix16Fastest(WebRtc_Word16 RexQx[], WebRtc_Word16 ImxQx[], WebRtc_Word16 iSign) { - - WebRtc_Word16 dd, ee, ff, gg, hh, ii; - WebRtc_Word16 k0, k1, k2, k3, k4, kk; - WebRtc_Word16 tmp116, tmp216; - - WebRtc_Word16 ccc1Q14, ccc2Q14, ccc3Q14, sss1Q14, sss2Q14, sss3Q14; - WebRtc_Word16 sss60Q14, ccc72Q14, sss72Q14; - WebRtc_Word16 aaQx, ajQx, akQx, ajmQx, ajpQx, akmQx, akpQx; - WebRtc_Word16 bbQx, bjQx, bkQx, bjmQx, bjpQx, bkmQx, bkpQx; - - WebRtc_Word16 ReDATAQx[240], ImDATAQx[240]; - - sss60Q14 = kCosTabFfftQ14[20]; - ccc72Q14 = kCosTabFfftQ14[48]; - sss72Q14 = kCosTabFfftQ14[12]; - - if (iSign < 0) { - sss72Q14 = -sss72Q14; - sss60Q14 = -sss60Q14; - } - /* Complexity is: 10 cycles */ - - /* compute fourier transform */ - - // transform for factor of 4 - for (kk=0; kk<60; kk++) { - k0 = kk; - k1 = k0 + 60; - k2 = k1 + 60; - k3 = k2 + 60; - - akpQx = RexQx[k0] + RexQx[k2]; - akmQx = RexQx[k0] - RexQx[k2]; - ajpQx = RexQx[k1] + RexQx[k3]; - ajmQx = RexQx[k1] - RexQx[k3]; - bkpQx = ImxQx[k0] + ImxQx[k2]; - bkmQx = ImxQx[k0] - ImxQx[k2]; - bjpQx = ImxQx[k1] + ImxQx[k3]; - bjmQx = ImxQx[k1] - ImxQx[k3]; - - RexQx[k0] = akpQx + ajpQx; - ImxQx[k0] = bkpQx + bjpQx; - ajpQx = akpQx - ajpQx; - bjpQx = bkpQx - bjpQx; - if (iSign < 0) { - akpQx = akmQx + bjmQx; - bkpQx = bkmQx - ajmQx; - akmQx -= bjmQx; - bkmQx += ajmQx; - } else { - akpQx = akmQx - bjmQx; - bkpQx = bkmQx + ajmQx; - akmQx += bjmQx; - bkmQx -= ajmQx; - } - - ccc1Q14 = kCosTabFfftQ14[kk]; - ccc2Q14 = kCosTabFfftQ14[WEBRTC_SPL_MUL_16_16(2, kk)]; - ccc3Q14 = kCosTabFfftQ14[WEBRTC_SPL_MUL_16_16(3, kk)]; - sss1Q14 = kCosTabFfftQ14[kk+60]; - sss2Q14 = kCosTabFfftQ14[WEBRTC_SPL_MUL_16_16(2, kk)+60]; - sss3Q14 = kCosTabFfftQ14[WEBRTC_SPL_MUL_16_16(3, kk)+60]; - if (iSign==1) { - sss1Q14 = -sss1Q14; - sss2Q14 = -sss2Q14; - sss3Q14 = -sss3Q14; - } - - //Do several multiplications like Q14*Q16>>14 = Q16 - // RexQ16[k1] = akpQ16 * ccc1Q14 - bkpQ16 * sss1Q14; - // RexQ16[k2] = ajpQ16 * ccc2Q14 - bjpQ16 * sss2Q14; - // RexQ16[k3] = akmQ16 * ccc3Q14 - bkmQ16 * sss3Q14; - // ImxQ16[k1] = akpQ16 * sss1Q14 + bkpQ16 * ccc1Q14; - // ImxQ16[k2] = ajpQ16 * sss2Q14 + bjpQ16 * ccc2Q14; - // ImxQ16[k3] = akmQ16 * sss3Q14 + bkmQ16 * ccc3Q14; - - RexQx[k1] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc1Q14, akpQx, 14) - - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss1Q14, bkpQx, 14); // 6 non-mul + 2 mul cycles, i.e. 8 cycles (6+2*7=20 cycles if 16x32mul) - RexQx[k2] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, ajpQx, 14) - - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, bjpQx, 14); - RexQx[k3] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc3Q14, akmQx, 14) - - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss3Q14, bkmQx, 14); - ImxQx[k1] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss1Q14, akpQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc1Q14, bkpQx, 14); - ImxQx[k2] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, ajpQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, bjpQx, 14); - ImxQx[k3] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss3Q14, akmQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc3Q14, bkmQx, 14); - //This mul segment needs 6*8 = 48 cycles for 16x16 muls, but 6*20 = 120 cycles for 16x32 muls - - - } - /* Complexity is: 51+48 = 99 cycles for 16x16 muls, but 51+120 = 171 cycles for 16x32 muls*/ - - // transform for factor of 3 - kk=0; - k1=20; - k2=40; - - for (hh=0; hh<4; hh++) { - for (ii=0; ii<20; ii++) { - akQx = RexQx[kk]; - bkQx = ImxQx[kk]; - ajQx = RexQx[k1] + RexQx[k2]; - bjQx = ImxQx[k1] + ImxQx[k2]; - RexQx[kk] = akQx + ajQx; - ImxQx[kk] = bkQx + bjQx; - tmp116 = WEBRTC_SPL_RSHIFT_W16(ajQx, 1); - tmp216 = WEBRTC_SPL_RSHIFT_W16(bjQx, 1); - akQx = akQx - tmp116; - bkQx = bkQx - tmp216; - tmp116 = RexQx[k1] - RexQx[k2]; - tmp216 = ImxQx[k1] - ImxQx[k2]; - - ajQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss60Q14, tmp116, 14); // Q14*Qx>>14 = Qx - bjQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss60Q14, tmp216, 14); // Q14*Qx>>14 = Qx - RexQx[k1] = akQx - bjQx; - RexQx[k2] = akQx + bjQx; - ImxQx[k1] = bkQx + ajQx; - ImxQx[k2] = bkQx - ajQx; - - kk++; - k1++; - k2++; - } - /* Complexity : (31+6)*20 = 740 cycles for 16x16 muls, but (31+18)*20 = 980 cycles for 16x32 muls*/ - kk=kk+40; - k1=k1+40; - k2=k2+40; - } - /* Complexity : 4*(740+3) = 2972 cycles for 16x16 muls, but 4*(980+3) = 3932 cycles for 16x32 muls*/ - - /* multiply by rotation factor for odd factor 3 or 5 (not for 4) - Same code (duplicated) for both ii=2 and ii=3 */ - kk = 1; - ee = 0; - ff = 0; - - for (gg=0; gg<19; gg++) { - kk += 20; - ff = ff+4; - for (hh=0; hh<2; hh++) { - ee = ff + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(hh, ff); - dd = ee + 60; - ccc2Q14 = kCosTabFfftQ14[ee]; - sss2Q14 = kCosTabFfftQ14[dd]; - if (iSign==1) { - sss2Q14 = -sss2Q14; - } - for (ii=0; ii<4; ii++) { - akQx = RexQx[kk]; - bkQx = ImxQx[kk]; - RexQx[kk] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, akQx, 14) - // Q14*Qx>>14 = Qx - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, bkQx, 14); - ImxQx[kk] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, akQx, 14) + // Q14*Qx>>14 = Qx - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, bkQx, 14); - - - kk += 60; - } - kk = kk - 220; - } - // Complexity: 2*(13+5+4*13+2) = 144 for 16x16 muls, but 2*(13+5+4*33+2) = 304 cycles for 16x32 muls - kk = kk - 59; - } - // Complexity: 19*144 = 2736 for 16x16 muls, but 19*304 = 5776 cycles for 16x32 muls - - // transform for factor of 5 - kk = 0; - ccc2Q14 = kCosTabFfftQ14[96]; - sss2Q14 = kCosTabFfftQ14[84]; - if (iSign==1) { - sss2Q14 = -sss2Q14; - } - - for (hh=0; hh<4; hh++) { - for (ii=0; ii<12; ii++) { - k1 = kk + 4; - k2 = k1 + 4; - k3 = k2 + 4; - k4 = k3 + 4; - - akpQx = RexQx[k1] + RexQx[k4]; - akmQx = RexQx[k1] - RexQx[k4]; - bkpQx = ImxQx[k1] + ImxQx[k4]; - bkmQx = ImxQx[k1] - ImxQx[k4]; - ajpQx = RexQx[k2] + RexQx[k3]; - ajmQx = RexQx[k2] - RexQx[k3]; - bjpQx = ImxQx[k2] + ImxQx[k3]; - bjmQx = ImxQx[k2] - ImxQx[k3]; - aaQx = RexQx[kk]; - bbQx = ImxQx[kk]; - RexQx[kk] = aaQx + akpQx + ajpQx; - ImxQx[kk] = bbQx + bkpQx + bjpQx; - - akQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc72Q14, akpQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, ajpQx, 14) + aaQx; - bkQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc72Q14, bkpQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, bjpQx, 14) + bbQx; - ajQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss72Q14, akmQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, ajmQx, 14); - bjQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss72Q14, bkmQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, bjmQx, 14); - // 32+4*8=64 or 32+4*20=112 - - RexQx[k1] = akQx - bjQx; - RexQx[k4] = akQx + bjQx; - ImxQx[k1] = bkQx + ajQx; - ImxQx[k4] = bkQx - ajQx; - - akQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, akpQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc72Q14, ajpQx, 14) + aaQx; - bkQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, bkpQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc72Q14, bjpQx, 14) + bbQx; - ajQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, akmQx, 14) - - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss72Q14, ajmQx, 14); - bjQx = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, bkmQx, 14) - - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss72Q14, bjmQx, 14); - // 8+4*8=40 or 8+4*20=88 - - RexQx[k2] = akQx - bjQx; - RexQx[k3] = akQx + bjQx; - ImxQx[k2] = bkQx + ajQx; - ImxQx[k3] = bkQx - ajQx; - - kk = k4 + 4; - } - // Complexity: 12*(64+40+10) = 1368 for 16x16 muls, but 12*(112+88+10) = 2520 cycles for 16x32 muls - kk -= 239; - } - // Complexity: 4*1368 = 5472 for 16x16 muls, but 4*2520 = 10080 cycles for 16x32 muls - - /* multiply by rotation factor for odd factor 3 or 5 (not for 4) - Same code (duplicated) for both ii=2 and ii=3 */ - kk = 1; - ee=0; - - for (gg=0; gg<3; gg++) { - kk += 4; - dd = 12 + (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(12, gg); - ff = 0; - for (hh=0; hh<4; hh++) { - ff = ff+dd; - ee = ff+60; - for (ii=0; ii<12; ii++) { - akQx = RexQx[kk]; - bkQx = ImxQx[kk]; - - ccc2Q14 = kCosTabFfftQ14[ff]; - sss2Q14 = kCosTabFfftQ14[ee]; - - if (iSign==1) { - sss2Q14 = -sss2Q14; - } - - RexQx[kk] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, akQx, 14) - - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, bkQx, 14); - ImxQx[kk] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(sss2Q14, akQx, 14) + - (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(ccc2Q14, bkQx, 14); - - kk += 20; - } - kk = kk - 236; - // Complexity: 12*(12+12) = 288 for 16x16 muls, but 12*(12+32) = 528 cycles for 16x32 muls - } - kk = kk - 19; - // Complexity: 4*288+6 for 16x16 muls, but 4*528+6 cycles for 16x32 muls - } - // Complexity: 3*4*288+6 = 3462 for 16x16 muls, but 3*4*528+6 = 6342 cycles for 16x32 muls - - - // last transform for factor of 4 */ - for (kk=0; kk<240; kk=kk+4) { - k1 = kk + 1; - k2 = k1 + 1; - k3 = k2 + 1; - - akpQx = RexQx[kk] + RexQx[k2]; - akmQx = RexQx[kk] - RexQx[k2]; - ajpQx = RexQx[k1] + RexQx[k3]; - ajmQx = RexQx[k1] - RexQx[k3]; - bkpQx = ImxQx[kk] + ImxQx[k2]; - bkmQx = ImxQx[kk] - ImxQx[k2]; - bjpQx = ImxQx[k1] + ImxQx[k3]; - bjmQx = ImxQx[k1] - ImxQx[k3]; - RexQx[kk] = akpQx + ajpQx; - ImxQx[kk] = bkpQx + bjpQx; - ajpQx = akpQx - ajpQx; - bjpQx = bkpQx - bjpQx; - if (iSign < 0) { - akpQx = akmQx + bjmQx; - bkpQx = bkmQx - ajmQx; - akmQx -= bjmQx; - bkmQx += ajmQx; - } else { - akpQx = akmQx - bjmQx; - bkpQx = bkmQx + ajmQx; - akmQx += bjmQx; - bkmQx -= ajmQx; - } - RexQx[k1] = akpQx; - RexQx[k2] = ajpQx; - RexQx[k3] = akmQx; - ImxQx[k1] = bkpQx; - ImxQx[k2] = bjpQx; - ImxQx[k3] = bkmQx; - } - // Complexity: 60*45 = 2700 for 16x16 muls, but 60*45 = 2700 cycles for 16x32 muls - - /* permute the results to normal order */ - for (ii=0; ii<240; ii++) { - ReDATAQx[ii]=RexQx[ii]; - ImDATAQx[ii]=ImxQx[ii]; - } - // Complexity: 240*2=480 cycles - - for (ii=0; ii<240; ii++) { - RexQx[ii]=ReDATAQx[kSortTabFft[ii]]; - ImxQx[ii]=ImDATAQx[kSortTabFft[ii]]; - } - // Complexity: 240*2*2=960 cycles - - // Total complexity: - // 16x16 16x32 - // Complexity: 10 10 - // Complexity: 99 171 - // Complexity: 2972 3932 - // Complexity: 2736 5776 - // Complexity: 5472 10080 - // Complexity: 3462 6342 - // Complexity: 2700 2700 - // Complexity: 480 480 - // Complexity: 960 960 - // ======================= - // 18891 30451 - // - // If this FFT is called 2 time each frame, i.e. 67 times per second, it will correspond to - // a C54 complexity of 67*18891/1000000 = 1.27 MIPS with 16x16-muls, and 67*30451/1000000 = - // = 2.04 MIPS with 16x32-muls. Note that this routine somtimes is called 6 times during the - // encoding of a frame, i.e. the max complexity would be 7/2*1.27 = 4.4 MIPS for the 16x16 mul case. - - - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/fft.h b/src/modules/audio_coding/codecs/isac/fix/source/fft.h deleted file mode 100644 index efa116e..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/fft.h +++ /dev/null
@@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/*--------------------------------*-C-*---------------------------------* - * File: - * fft.h - * ---------------------------------------------------------------------* - * Re[]: real value array - * Im[]: imaginary value array - * nTotal: total number of complex values - * nPass: number of elements involved in this pass of transform - * nSpan: nspan/nPass = number of bytes to increment pointer - * in Re[] and Im[] - * isign: exponent: +1 = forward -1 = reverse - * scaling: normalizing constant by which the final result is *divided* - * scaling == -1, normalize by total dimension of the transform - * scaling < -1, normalize by the square-root of the total dimension - * - * ---------------------------------------------------------------------- - * See the comments in the code for correct usage! - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FFT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FFT_H_ - - -#include "structs.h" - - -WebRtc_Word16 WebRtcIsacfix_FftRadix16Fastest(WebRtc_Word16 RexQx[], WebRtc_Word16 ImxQx[], WebRtc_Word16 iSign); - - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FFT_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h b/src/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h deleted file mode 100644 index d5d9efb..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h +++ /dev/null
@@ -1,36 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FILTERBANK_INTERNAL_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FILTERBANK_INTERNAL_H_ - -#include "typedefs.h" - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/* Arguments: - * io: Input/output, in Q0. - * len: Input, sample length. - * coefficient: Input. - * state: Input/output, filter state, in Q4. - */ -void WebRtcIsacfix_HighpassFilterFixDec32(int16_t *io, - int16_t len, - const int16_t *coefficient, - int32_t *state); - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif -/* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FILTERBANK_INTERNAL_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/filterbank_tables.h b/src/modules/audio_coding/codecs/isac/fix/source/filterbank_tables.h deleted file mode 100644 index 9a888e4..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/filterbank_tables.h +++ /dev/null
@@ -1,52 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * filterbank_tables.h - * - * Header file for variables that are defined in - * filterbank_tables.c. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FILTERBANK_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FILTERBANK_TABLES_H_ - -#include "typedefs.h" - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif - -/********************* Coefficient Tables ************************/ - -/* HPstcoeff_in_Q14 = {a1, a2, b1 - b0 * a1, b2 - b0 * a2}; */ -/* [Q30lo Q30hi Q30lo Q30hi Q35lo Q35hi Q35lo Q35hi] */ -extern const int16_t WebRtcIsacfix_kHpStCoeffInQ30[8]; - -/* HPstcoeff_out_1_Q14 = {a1, a2, b1 - b0 * a1, b2 - b0 * a2}; */ -/* [Q30lo Q30hi Q30lo Q30hi Q35lo Q35hi Q35lo Q35hi] */ -extern const int16_t WebRtcIsacfix_kHPStCoeffOut1Q30[8]; - -/* HPstcoeff_out_2_Q14 = {a1, a2, b1 - b0 * a1, b2 - b0 * a2}; */ -/* [Q30lo Q30hi Q30lo Q30hi Q35lo Q35hi Q35lo Q35hi] */ -extern const int16_t WebRtcIsacfix_kHPStCoeffOut2Q30[8]; - -/* The upper channel all-pass filter factors */ -extern const int16_t WebRtcIsacfix_kUpperApFactorsQ15[2]; - -/* The lower channel all-pass filter factors */ -extern const int16_t WebRtcIsacfix_kLowerApFactorsQ15[2]; - -#if defined(__cplusplus) || defined(c_plusplus) -} -#endif - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_FILTERBANK_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/filterbanks.c b/src/modules/audio_coding/codecs/isac/fix/source/filterbanks.c deleted file mode 100644 index 949e7cf..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/filterbanks.c +++ /dev/null
@@ -1,354 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * filterbanks.c - * - * This file contains function - * WebRtcIsacfix_SplitAndFilter, and WebRtcIsacfix_FilterAndCombine - * which implement filterbanks that produce decimated lowpass and - * highpass versions of a signal, and performs reconstruction. - * - */ - -#include "codec.h" -#include "filterbank_internal.h" -#include "filterbank_tables.h" -#include "settings.h" - - -static void AllpassFilter2FixDec16(WebRtc_Word16 *InOut16, //Q0 - const WebRtc_Word16 *APSectionFactors, //Q15 - WebRtc_Word16 lengthInOut, - WebRtc_Word16 NumberOfSections, - WebRtc_Word32 *FilterState) //Q16 -{ - int n, j; - WebRtc_Word32 a, b; - - for (j=0; j<NumberOfSections; j++) { - for (n=0;n<lengthInOut;n++) { - - - a = WEBRTC_SPL_MUL_16_16(APSectionFactors[j], InOut16[n]); //Q15*Q0=Q15 - a = WEBRTC_SPL_LSHIFT_W32(a, 1); // Q15 -> Q16 - b = WEBRTC_SPL_ADD_SAT_W32(a, FilterState[j]); //Q16+Q16=Q16 - a = WEBRTC_SPL_MUL_16_16_RSFT(-APSectionFactors[j], (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(b, 16), 0); //Q15*Q0=Q15 - FilterState[j] = WEBRTC_SPL_ADD_SAT_W32(WEBRTC_SPL_LSHIFT_W32(a,1), WEBRTC_SPL_LSHIFT_W32((WebRtc_UWord32)InOut16[n],16)); // Q15<<1 + Q0<<16 = Q16 + Q16 = Q16 - InOut16[n] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(b, 16); //Save as Q0 - - } - } - -} - - -void WebRtcIsacfix_HighpassFilterFixDec32(int16_t *io, - int16_t len, - const int16_t *coefficient, - int32_t *state) -{ - int k; - WebRtc_Word32 a1 = 0, b1 = 0, c = 0, in = 0; - WebRtc_Word32 a2 = 0, b2 = 0; - WebRtc_Word32 state0 = state[0]; - WebRtc_Word32 state1 = state[1]; - - for (k=0; k<len; k++) { - in = (WebRtc_Word32)io[k]; - -#ifdef WEBRTC_ARCH_ARM_V7 - { - int tmp_coeff0 = 0; - int tmp_coeff1 = 0; - __asm __volatile( - "ldr %[tmp_coeff0], [%[coeff]]\n\t" - "ldr %[tmp_coeff1], [%[coeff], #4]\n\t" - "smmulr %[a2], %[tmp_coeff0], %[state0]\n\t" - "smmulr %[b2], %[tmp_coeff1], %[state1]\n\t" - "ldr %[tmp_coeff0], [%[coeff], #8]\n\t" - "ldr %[tmp_coeff1], [%[coeff], #12]\n\t" - "smmulr %[a1], %[tmp_coeff0], %[state0]\n\t" - "smmulr %[b1], %[tmp_coeff1], %[state1]\n\t" - :[a2]"+r"(a2), - [b2]"+r"(b2), - [a1]"+r"(a1), - [b1]"+r"(b1), - [tmp_coeff0]"+r"(tmp_coeff0), - [tmp_coeff1]"+r"(tmp_coeff1) - :[coeff]"r"(coefficient), - [state0]"r"(state0), - [state1]"r"(state1) - ); - } -#else - /* Q35 * Q4 = Q39 ; shift 32 bit => Q7 */ - a1 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[5], coefficient[4], state0); - b1 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[7], coefficient[6], state1); - - /* Q30 * Q4 = Q34 ; shift 32 bit => Q2 */ - a2 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[1], coefficient[0], state0); - b2 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[3], coefficient[2], state1); -#endif - - c = ((WebRtc_Word32)in) + WEBRTC_SPL_RSHIFT_W32(a1+b1, 7); // Q0 - io[k] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(c); // Write output as Q0. - - c = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)in, 2) - a2 - b2; // In Q2. - c = (WebRtc_Word32)WEBRTC_SPL_SAT(536870911, c, -536870912); - - state1 = state0; - state0 = WEBRTC_SPL_LSHIFT_W32(c, 2); // Write state as Q4 - } - state[0] = state0; - state[1] = state1; -} - - -void WebRtcIsacfix_SplitAndFilter1(WebRtc_Word16 *pin, - WebRtc_Word16 *LP16, - WebRtc_Word16 *HP16, - PreFiltBankstr *prefiltdata) -{ - /* Function WebRtcIsacfix_SplitAndFilter */ - /* This function creates low-pass and high-pass decimated versions of part of - the input signal, and part of the signal in the input 'lookahead buffer'. */ - - int k; - - WebRtc_Word16 tempin_ch1[FRAMESAMPLES/2 + QLOOKAHEAD]; - WebRtc_Word16 tempin_ch2[FRAMESAMPLES/2 + QLOOKAHEAD]; - WebRtc_Word32 tmpState[WEBRTC_SPL_MUL_16_16(2,(QORDER-1))]; /* 4 */ - - - /* High pass filter */ - WebRtcIsacfix_HighpassFilterFixDec32(pin, FRAMESAMPLES, WebRtcIsacfix_kHpStCoeffInQ30, prefiltdata->HPstates_fix); - - - /* First Channel */ - for (k=0;k<FRAMESAMPLES/2;k++) { - tempin_ch1[QLOOKAHEAD + k] = pin[1+WEBRTC_SPL_MUL_16_16(2, k)]; - } - for (k=0;k<QLOOKAHEAD;k++) { - tempin_ch1[k]=prefiltdata->INLABUF1_fix[k]; - prefiltdata->INLABUF1_fix[k]=pin[FRAMESAMPLES+1-WEBRTC_SPL_MUL_16_16(2, QLOOKAHEAD)+WEBRTC_SPL_MUL_16_16(2, k)]; - } - - /* Second Channel. This is exactly like the first channel, except that the - even samples are now filtered instead (lower channel). */ - for (k=0;k<FRAMESAMPLES/2;k++) { - tempin_ch2[QLOOKAHEAD+k] = pin[WEBRTC_SPL_MUL_16_16(2, k)]; - } - for (k=0;k<QLOOKAHEAD;k++) { - tempin_ch2[k]=prefiltdata->INLABUF2_fix[k]; - prefiltdata->INLABUF2_fix[k]=pin[FRAMESAMPLES-WEBRTC_SPL_MUL_16_16(2, QLOOKAHEAD)+WEBRTC_SPL_MUL_16_16(2, k)]; - } - - - /*obtain polyphase components by forward all-pass filtering through each channel */ - /* The all pass filtering automatically updates the filter states which are exported in the - prefiltdata structure */ - AllpassFilter2FixDec16(tempin_ch1,WebRtcIsacfix_kUpperApFactorsQ15, FRAMESAMPLES/2 , NUMBEROFCHANNELAPSECTIONS, prefiltdata->INSTAT1_fix); - AllpassFilter2FixDec16(tempin_ch2,WebRtcIsacfix_kLowerApFactorsQ15, FRAMESAMPLES/2 , NUMBEROFCHANNELAPSECTIONS, prefiltdata->INSTAT2_fix); - - for (k=0;k<WEBRTC_SPL_MUL_16_16(2, (QORDER-1));k++) - tmpState[k] = prefiltdata->INSTAT1_fix[k]; - AllpassFilter2FixDec16(tempin_ch1 + FRAMESAMPLES/2,WebRtcIsacfix_kUpperApFactorsQ15, QLOOKAHEAD , NUMBEROFCHANNELAPSECTIONS, tmpState); - for (k=0;k<WEBRTC_SPL_MUL_16_16(2, (QORDER-1));k++) - tmpState[k] = prefiltdata->INSTAT2_fix[k]; - AllpassFilter2FixDec16(tempin_ch2 + FRAMESAMPLES/2,WebRtcIsacfix_kLowerApFactorsQ15, QLOOKAHEAD , NUMBEROFCHANNELAPSECTIONS, tmpState); - - - /* Now Construct low-pass and high-pass signals as combinations of polyphase components */ - for (k=0; k<FRAMESAMPLES/2 + QLOOKAHEAD; k++) { - WebRtc_Word32 tmp1, tmp2, tmp3; - tmp1 = (WebRtc_Word32)tempin_ch1[k]; // Q0 -> Q0 - tmp2 = (WebRtc_Word32)tempin_ch2[k]; // Q0 -> Q0 - tmp3 = (WebRtc_Word32)WEBRTC_SPL_RSHIFT_W32((tmp1 + tmp2), 1);/* low pass signal*/ - LP16[k] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp3); /*low pass */ - tmp3 = (WebRtc_Word32)WEBRTC_SPL_RSHIFT_W32((tmp1 - tmp2), 1);/* high pass signal*/ - HP16[k] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp3); /*high pass */ - } - -}/*end of WebRtcIsacfix_SplitAndFilter */ - - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - -/* Without lookahead */ -void WebRtcIsacfix_SplitAndFilter2(WebRtc_Word16 *pin, - WebRtc_Word16 *LP16, - WebRtc_Word16 *HP16, - PreFiltBankstr *prefiltdata) -{ - /* Function WebRtcIsacfix_SplitAndFilter2 */ - /* This function creates low-pass and high-pass decimated versions of part of - the input signal. */ - - int k; - - WebRtc_Word16 tempin_ch1[FRAMESAMPLES/2]; - WebRtc_Word16 tempin_ch2[FRAMESAMPLES/2]; - - - /* High pass filter */ - WebRtcIsacfix_HighpassFilterFixDec32(pin, FRAMESAMPLES, WebRtcIsacfix_kHpStCoeffInQ30, prefiltdata->HPstates_fix); - - - /* First Channel */ - for (k=0;k<FRAMESAMPLES/2;k++) { - tempin_ch1[k] = pin[1+WEBRTC_SPL_MUL_16_16(2, k)]; - } - - /* Second Channel. This is exactly like the first channel, except that the - even samples are now filtered instead (lower channel). */ - for (k=0;k<FRAMESAMPLES/2;k++) { - tempin_ch2[k] = pin[WEBRTC_SPL_MUL_16_16(2, k)]; - } - - - /*obtain polyphase components by forward all-pass filtering through each channel */ - /* The all pass filtering automatically updates the filter states which are exported in the - prefiltdata structure */ - AllpassFilter2FixDec16(tempin_ch1,WebRtcIsacfix_kUpperApFactorsQ15, FRAMESAMPLES/2 , NUMBEROFCHANNELAPSECTIONS, prefiltdata->INSTAT1_fix); - AllpassFilter2FixDec16(tempin_ch2,WebRtcIsacfix_kLowerApFactorsQ15, FRAMESAMPLES/2 , NUMBEROFCHANNELAPSECTIONS, prefiltdata->INSTAT2_fix); - - - /* Now Construct low-pass and high-pass signals as combinations of polyphase components */ - for (k=0; k<FRAMESAMPLES/2; k++) { - WebRtc_Word32 tmp1, tmp2, tmp3; - tmp1 = (WebRtc_Word32)tempin_ch1[k]; // Q0 -> Q0 - tmp2 = (WebRtc_Word32)tempin_ch2[k]; // Q0 -> Q0 - tmp3 = (WebRtc_Word32)WEBRTC_SPL_RSHIFT_W32((tmp1 + tmp2), 1);/* low pass signal*/ - LP16[k] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp3); /*low pass */ - tmp3 = (WebRtc_Word32)WEBRTC_SPL_RSHIFT_W32((tmp1 - tmp2), 1);/* high pass signal*/ - HP16[k] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp3); /*high pass */ - } - -}/*end of WebRtcIsacfix_SplitAndFilter */ - -#endif - - - -////////////////////////////////////////////////////////// -////////// Combining -/* Function WebRtcIsacfix_FilterAndCombine */ -/* This is a decoder function that takes the decimated - length FRAMESAMPLES/2 input low-pass and - high-pass signals and creates a reconstructed fullband - output signal of length FRAMESAMPLES. WebRtcIsacfix_FilterAndCombine - is the sibling function of WebRtcIsacfix_SplitAndFilter */ -/* INPUTS: - inLP: a length FRAMESAMPLES/2 array of input low-pass - samples. - inHP: a length FRAMESAMPLES/2 array of input high-pass - samples. - postfiltdata: input data structure containing the filterbank - states from the previous decoding iteration. - OUTPUTS: - Out: a length FRAMESAMPLES array of output reconstructed - samples (fullband) based on the input low-pass and - high-pass signals. - postfiltdata: the input data structure containing the filterbank - states is updated for the next decoding iteration */ -void WebRtcIsacfix_FilterAndCombine1(WebRtc_Word16 *tempin_ch1, - WebRtc_Word16 *tempin_ch2, - WebRtc_Word16 *out16, - PostFiltBankstr *postfiltdata) -{ - int k; - WebRtc_Word16 in[FRAMESAMPLES]; - - /* all-pass filter the new upper channel signal. HOWEVER, use the all-pass filter factors - that were used as a lower channel at the encoding side. So at the decoder, the - corresponding all-pass filter factors for each channel are swapped.*/ - - AllpassFilter2FixDec16(tempin_ch1, WebRtcIsacfix_kLowerApFactorsQ15, FRAMESAMPLES/2, NUMBEROFCHANNELAPSECTIONS,postfiltdata->STATE_0_UPPER_fix); - - /* Now, all-pass filter the new lower channel signal. But since all-pass filter factors - at the decoder are swapped from the ones at the encoder, the 'upper' channel - all-pass filter factors (kUpperApFactors) are used to filter this new lower channel signal */ - - AllpassFilter2FixDec16(tempin_ch2, WebRtcIsacfix_kUpperApFactorsQ15, FRAMESAMPLES/2, NUMBEROFCHANNELAPSECTIONS,postfiltdata->STATE_0_LOWER_fix); - - /* Merge outputs to form the full length output signal.*/ - for (k=0;k<FRAMESAMPLES/2;k++) { - in[WEBRTC_SPL_MUL_16_16(2, k)]=tempin_ch2[k]; - in[WEBRTC_SPL_MUL_16_16(2, k)+1]=tempin_ch1[k]; - } - - /* High pass filter */ - WebRtcIsacfix_HighpassFilterFixDec32(in, FRAMESAMPLES, WebRtcIsacfix_kHPStCoeffOut1Q30, postfiltdata->HPstates1_fix); - WebRtcIsacfix_HighpassFilterFixDec32(in, FRAMESAMPLES, WebRtcIsacfix_kHPStCoeffOut2Q30, postfiltdata->HPstates2_fix); - - for (k=0;k<FRAMESAMPLES;k++) { - out16[k] = in[k]; - } -} - - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -/* Function WebRtcIsacfix_FilterAndCombine */ -/* This is a decoder function that takes the decimated - length len/2 input low-pass and - high-pass signals and creates a reconstructed fullband - output signal of length len. WebRtcIsacfix_FilterAndCombine - is the sibling function of WebRtcIsacfix_SplitAndFilter */ -/* INPUTS: - inLP: a length len/2 array of input low-pass - samples. - inHP: a length len/2 array of input high-pass - samples. - postfiltdata: input data structure containing the filterbank - states from the previous decoding iteration. - OUTPUTS: - Out: a length len array of output reconstructed - samples (fullband) based on the input low-pass and - high-pass signals. - postfiltdata: the input data structure containing the filterbank - states is updated for the next decoding iteration */ -void WebRtcIsacfix_FilterAndCombine2(WebRtc_Word16 *tempin_ch1, - WebRtc_Word16 *tempin_ch2, - WebRtc_Word16 *out16, - PostFiltBankstr *postfiltdata, - WebRtc_Word16 len) -{ - int k; - WebRtc_Word16 in[FRAMESAMPLES]; - - /* all-pass filter the new upper channel signal. HOWEVER, use the all-pass filter factors - that were used as a lower channel at the encoding side. So at the decoder, the - corresponding all-pass filter factors for each channel are swapped.*/ - - AllpassFilter2FixDec16(tempin_ch1, WebRtcIsacfix_kLowerApFactorsQ15,(WebRtc_Word16) (len/2), NUMBEROFCHANNELAPSECTIONS,postfiltdata->STATE_0_UPPER_fix); - - /* Now, all-pass filter the new lower channel signal. But since all-pass filter factors - at the decoder are swapped from the ones at the encoder, the 'upper' channel - all-pass filter factors (kUpperApFactors) are used to filter this new lower channel signal */ - - AllpassFilter2FixDec16(tempin_ch2, WebRtcIsacfix_kUpperApFactorsQ15, (WebRtc_Word16) (len/2), NUMBEROFCHANNELAPSECTIONS,postfiltdata->STATE_0_LOWER_fix); - - /* Merge outputs to form the full length output signal.*/ - for (k=0;k<len/2;k++) { - in[WEBRTC_SPL_MUL_16_16(2, k)]=tempin_ch2[k]; - in[WEBRTC_SPL_MUL_16_16(2, k)+1]=tempin_ch1[k]; - } - - /* High pass filter */ - WebRtcIsacfix_HighpassFilterFixDec32(in, len, WebRtcIsacfix_kHPStCoeffOut1Q30, postfiltdata->HPstates1_fix); - WebRtcIsacfix_HighpassFilterFixDec32(in, len, WebRtcIsacfix_kHPStCoeffOut2Q30, postfiltdata->HPstates2_fix); - - for (k=0;k<len;k++) { - out16[k] = in[k]; - } -} - -#endif
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/filters.c b/src/modules/audio_coding/codecs/isac/fix/source/filters.c deleted file mode 100644 index 6ee0477..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/filters.c +++ /dev/null
@@ -1,122 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * filters.c - * - * This file contains function WebRtcIsacfix_AutocorrC, - * AllpassFilterForDec32, and WebRtcIsacfix_DecimateAllpass32 - * - */ - -#include <string.h> - -#include "pitch_estimator.h" -#include "lpc_masking_model.h" -#include "codec.h" - -// Autocorrelation function in fixed point. -// NOTE! Different from SPLIB-version in how it scales the signal. -int WebRtcIsacfix_AutocorrC(WebRtc_Word32* __restrict r, - const WebRtc_Word16* __restrict x, - WebRtc_Word16 N, - WebRtc_Word16 order, - WebRtc_Word16* __restrict scale) { - int i = 0; - int j = 0; - int16_t scaling = 0; - int32_t sum = 0; - uint32_t temp = 0; - int64_t prod = 0; - - // Calculate r[0]. - for (i = 0; i < N; i++) { - prod += WEBRTC_SPL_MUL_16_16(x[i], x[i]); - } - - // Calculate scaling (the value of shifting). - temp = (uint32_t)(prod >> 31); - if(temp == 0) { - scaling = 0; - } else { - scaling = 32 - WebRtcSpl_NormU32(temp); - } - r[0] = (int32_t)(prod >> scaling); - - // Perform the actual correlation calculation. - for (i = 1; i < order + 1; i++) { - prod = 0; - for (j = 0; j < N - i; j++) { - prod += WEBRTC_SPL_MUL_16_16(x[j], x[i + j]); - } - sum = (int32_t)(prod >> scaling); - r[i] = sum; - } - - *scale = scaling; - - return(order + 1); -} - -static const WebRtc_Word32 kApUpperQ15[ALLPASSSECTIONS] = { 1137, 12537 }; -static const WebRtc_Word32 kApLowerQ15[ALLPASSSECTIONS] = { 5059, 24379 }; - - -static void AllpassFilterForDec32(WebRtc_Word16 *InOut16, //Q0 - const WebRtc_Word32 *APSectionFactors, //Q15 - WebRtc_Word16 lengthInOut, - WebRtc_Word32 *FilterState) //Q16 -{ - int n, j; - WebRtc_Word32 a, b; - - for (j=0; j<ALLPASSSECTIONS; j++) { - for (n=0;n<lengthInOut;n+=2){ - a = WEBRTC_SPL_MUL_16_32_RSFT16(InOut16[n], APSectionFactors[j]); //Q0*Q31=Q31 shifted 16 gives Q15 - a = WEBRTC_SPL_LSHIFT_W32(a, 1); // Q15 -> Q16 - b = WEBRTC_SPL_ADD_SAT_W32(a, FilterState[j]); //Q16+Q16=Q16 - a = WEBRTC_SPL_MUL_16_32_RSFT16( - (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(b, 16), - -APSectionFactors[j]); //Q0*Q31=Q31 shifted 16 gives Q15 - FilterState[j] = WEBRTC_SPL_ADD_SAT_W32( - WEBRTC_SPL_LSHIFT_W32(a,1), - WEBRTC_SPL_LSHIFT_W32((WebRtc_UWord32)InOut16[n], 16)); // Q15<<1 + Q0<<16 = Q16 + Q16 = Q16 - InOut16[n] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(b, 16); //Save as Q0 - } - } -} - - - - -void WebRtcIsacfix_DecimateAllpass32(const WebRtc_Word16 *in, - WebRtc_Word32 *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */ - WebRtc_Word16 N, /* number of input samples */ - WebRtc_Word16 *out) /* array of size N/2 */ -{ - int n; - WebRtc_Word16 data_vec[PITCH_FRAME_LEN]; - - /* copy input */ - memcpy(data_vec+1, in, WEBRTC_SPL_MUL_16_16(sizeof(WebRtc_Word16), (N-1))); - - - data_vec[0] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(state_in[WEBRTC_SPL_MUL_16_16(2, ALLPASSSECTIONS)],16); //the z^(-1) state - state_in[WEBRTC_SPL_MUL_16_16(2, ALLPASSSECTIONS)] = WEBRTC_SPL_LSHIFT_W32((WebRtc_UWord32)in[N-1],16); - - - - AllpassFilterForDec32(data_vec+1, kApUpperQ15, N, state_in); - AllpassFilterForDec32(data_vec, kApLowerQ15, N, state_in+ALLPASSSECTIONS); - - for (n=0;n<N/2;n++) { - out[n]=WEBRTC_SPL_ADD_SAT_W16(data_vec[WEBRTC_SPL_MUL_16_16(2, n)], data_vec[WEBRTC_SPL_MUL_16_16(2, n)+1]); - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/filters_neon.c b/src/modules/audio_coding/codecs/isac/fix/source/filters_neon.c deleted file mode 100644 index 7e7d74d..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/filters_neon.c +++ /dev/null
@@ -1,167 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * filters_neon.c - * - * This file contains function WebRtcIsacfix_AutocorrNeon, optimized for - * ARM Neon platform. - * - */ - -#include <arm_neon.h> -#include <assert.h> - -#include "codec.h" - -// Autocorrelation function in fixed point. -// NOTE! Different from SPLIB-version in how it scales the signal. -int WebRtcIsacfix_AutocorrNeon( - WebRtc_Word32* __restrict r, - const WebRtc_Word16* __restrict x, - WebRtc_Word16 N, - WebRtc_Word16 order, - WebRtc_Word16* __restrict scale) { - - // The 1st for loop assumed N % 4 == 0. - assert(N % 4 == 0); - - int i = 0; - int zeros_low = 0; - int zeros_high = 0; - int16_t scaling = 0; - int32_t sum = 0; - - // Step 1, calculate r[0] and how much scaling is needed. - - int16x4_t reg16x4; - int64x1_t reg64x1a; - int64x1_t reg64x1b; - int32x4_t reg32x4; - int64x2_t reg64x2 = vdupq_n_s64(0); // zeros - - // Loop over the samples and do: - // sum += WEBRTC_SPL_MUL_16_16(x[i], x[i]); - for (i = 0; i < N; i += 4) { - reg16x4 = vld1_s16(&x[i]); - reg32x4 = vmull_s16(reg16x4, reg16x4); - reg64x2 = vpadalq_s32(reg64x2, reg32x4); - } - reg64x1a = vget_low_s64(reg64x2); - reg64x1b = vget_high_s64(reg64x2); - reg64x1a = vadd_s64(reg64x1a, reg64x1b); - - // Calculate the value of shifting (scaling). - __asm__ __volatile__( - "vmov %[z_l], %[z_h], %P[reg]\n\t" - "clz %[z_l], %[z_l]\n\t" - "clz %[z_h], %[z_h]\n\t" - :[z_l]"+r"(zeros_low), - [z_h]"+r"(zeros_high) - :[reg]"w"(reg64x1a) - ); - if (zeros_high != 32) { - scaling = (32 - zeros_high + 1); - } else if (zeros_low == 0) { - scaling = 1; - } - reg64x1b = (int64x1_t) (int64_t) -scaling; - reg64x1a = vshl_s64(reg64x1a, reg64x1b); - - // Record the result. - r[0] = (int32_t)vget_lane_s64(reg64x1a, 0); - - - // Step 2, perform the actual correlation calculation. - - /* Original C code (for the rest of the function): - for (i = 1; i < order + 1; i++) { - prod = 0; - for (j = 0; j < N - i; j++) { - prod += WEBRTC_SPL_MUL_16_16(x[j], x[i + j]); - } - sum = (int32_t)(prod >> scaling); - r[i] = sum; - } - */ - - for (i = 1; i < order + 1; i++) { - int32_t prod_lower = 0; - int32_t prod_upper = 0; - const int16_t* ptr0 = &x[0]; - const int16_t* ptr1 = &x[i]; - int32_t tmp = 0; - - // Initialize the sum (q9) to zero. - __asm__ __volatile__("vmov.i32 q9, #0\n\t":::"q9"); - - // Calculate the major block of the samples (a multiple of 8). - for (; ptr0 < &x[N - i - 7];) { - __asm__ __volatile__( - "vld1.16 {d20, d21}, [%[ptr0]]!\n\t" - "vld1.16 {d22, d23}, [%[ptr1]]!\n\t" - "vmull.s16 q12, d20, d22\n\t" - "vmull.s16 q13, d21, d23\n\t" - "vpadal.s32 q9, q12\n\t" - "vpadal.s32 q9, q13\n\t" - - // Specify constraints. - :[ptr0]"+r"(ptr0), - [ptr1]"+r"(ptr1) - : - :"d18", "d19", "d20", "d21", "d22", "d23", "d24", "d25", "d26", "d27" - ); - } - - // Calculate the rest of the samples. - for (; ptr0 < &x[N - i]; ptr0++, ptr1++) { - __asm__ __volatile__( - "smulbb %[tmp], %[ptr0], %[ptr1]\n\t" - "adds %[prod_lower], %[prod_lower], %[tmp]\n\t" - "adc %[prod_upper], %[prod_upper], %[tmp], asr #31\n\t" - - // Specify constraints. - :[prod_lower]"+r"(prod_lower), - [prod_upper]"+r"(prod_upper), - [tmp]"+r"(tmp) - :[ptr0]"r"(*ptr0), - [ptr1]"r"(*ptr1) - ); - } - - // Sum the results up, and do shift. - __asm__ __volatile__( - "vadd.i64 d18, d19\n\t" - "vmov.32 d17[0], %[prod_lower]\n\t" - "vmov.32 d17[1], %[prod_upper]\n\t" - "vadd.i64 d17, d18\n\t" - "mov %[tmp], %[scaling], asr #31\n\t" - "vmov d16, %[scaling], %[tmp]\n\t" - "vshl.s64 d17, d16\n\t" - "vmov.32 %[sum], d17[0]\n\t" - - // Specify constraints. - :[sum]"=r"(sum), - [tmp]"+r"(tmp) - :[prod_upper]"r"(prod_upper), - [prod_lower]"r"(prod_lower), - [scaling]"r"(-scaling) - :"d16", "d17", "d18", "d19" - ); - - // Record the result. - r[i] = sum; - } - - // Record the result. - *scale = scaling; - - return(order + 1); -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/initialize.c b/src/modules/audio_coding/codecs/isac/fix/source/initialize.c deleted file mode 100644 index 4d11af5..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/initialize.c +++ /dev/null
@@ -1,175 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * initialize.c - * - * Internal initfunctions - * - */ - -#include "codec.h" -#include "structs.h" -#include "pitch_estimator.h" - - -void WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc *maskdata) { - - int k; - - for (k = 0; k < WINLEN; k++) { - maskdata->DataBufferLoQ0[k] = (WebRtc_Word16) 0; - maskdata->DataBufferHiQ0[k] = (WebRtc_Word16) 0; - } - for (k = 0; k < ORDERLO+1; k++) { - maskdata->CorrBufLoQQ[k] = (WebRtc_Word32) 0; - maskdata->CorrBufLoQdom[k] = 0; - - maskdata->PreStateLoGQ15[k] = 0; - - } - for (k = 0; k < ORDERHI+1; k++) { - maskdata->CorrBufHiQQ[k] = (WebRtc_Word32) 0; - maskdata->CorrBufHiQdom[k] = 0; - maskdata->PreStateHiGQ15[k] = 0; - } - - maskdata->OldEnergy = 10; - - return; -} - -void WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec *maskdata) { - - int k; - - for (k = 0; k < ORDERLO+1; k++) - { - maskdata->PostStateLoGQ0[k] = 0; - } - for (k = 0; k < ORDERHI+1; k++) - { - maskdata->PostStateHiGQ0[k] = 0; - } - - maskdata->OldEnergy = 10; - - return; -} - - - - - - - -void WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr *prefiltdata) -{ - int k; - - for (k = 0; k < QLOOKAHEAD; k++) { - prefiltdata->INLABUF1_fix[k] = 0; - prefiltdata->INLABUF2_fix[k] = 0; - } - for (k = 0; k < WEBRTC_SPL_MUL_16_16(2,(QORDER-1)); k++) { - - prefiltdata->INSTAT1_fix[k] = 0; - prefiltdata->INSTAT2_fix[k] = 0; - } - - /* High pass filter states */ - prefiltdata->HPstates_fix[0] = 0; - prefiltdata->HPstates_fix[1] = 0; - - return; -} - -void WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr *postfiltdata) -{ - int k; - - for (k = 0; k < WEBRTC_SPL_MUL_16_16(2, POSTQORDER); k++) { - - postfiltdata->STATE_0_LOWER_fix[k] = 0; - postfiltdata->STATE_0_UPPER_fix[k] = 0; - } - - /* High pass filter states */ - - postfiltdata->HPstates1_fix[0] = 0; - postfiltdata->HPstates1_fix[1] = 0; - - postfiltdata->HPstates2_fix[0] = 0; - postfiltdata->HPstates2_fix[1] = 0; - - return; -} - - -void WebRtcIsacfix_InitPitchFilter(PitchFiltstr *pitchfiltdata) -{ - int k; - - for (k = 0; k < PITCH_BUFFSIZE; k++) - pitchfiltdata->ubufQQ[k] = 0; - for (k = 0; k < (PITCH_DAMPORDER); k++) - pitchfiltdata->ystateQQ[k] = 0; - - pitchfiltdata->oldlagQ7 = 6400; /* 50.0 in Q7 */ - pitchfiltdata->oldgainQ12 = 0; -} - -void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct *State) -{ - int k; - - for (k = 0; k < PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2; k++) { - State->dec_buffer16[k] = 0; - } - for (k = 0; k < WEBRTC_SPL_MUL_16_16(2, ALLPASSSECTIONS)+1; k++) { - State->decimator_state32[k] = 0; - } - - for (k = 0; k < QLOOKAHEAD; k++) - State->inbuf[k] = 0; - - WebRtcIsacfix_InitPitchFilter(&(State->PFstr_wght)); - - WebRtcIsacfix_InitPitchFilter(&(State->PFstr)); -} - - -void WebRtcIsacfix_InitPlc( PLCstr *State ) -{ - State->decayCoeffPriodic = WEBRTC_SPL_WORD16_MAX; - State->decayCoeffNoise = WEBRTC_SPL_WORD16_MAX; - - State->used = PLC_WAS_USED; - - WebRtcSpl_ZerosArrayW16(State->overlapLP, RECOVERY_OVERLAP); - WebRtcSpl_ZerosArrayW16(State->lofilt_coefQ15, ORDERLO); - WebRtcSpl_ZerosArrayW16(State->hifilt_coefQ15, ORDERHI ); - - State->AvgPitchGain_Q12 = 0; - State->lastPitchGain_Q12 = 0; - State->lastPitchLag_Q7 = 0; - State->gain_lo_hiQ17[0]=State->gain_lo_hiQ17[1] = 0; - WebRtcSpl_ZerosArrayW16(State->prevPitchInvIn, FRAMESAMPLES/2); - WebRtcSpl_ZerosArrayW16(State->prevPitchInvOut, PITCH_MAX_LAG + 10 ); - WebRtcSpl_ZerosArrayW32(State->prevHP, PITCH_MAX_LAG + 10 ); - State->pitchCycles = 0; - State->A = 0; - State->B = 0; - State->pitchIndex = 0; - State->stretchLag = 240; - State->seed = 4447; - - -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/isacfix.c b/src/modules/audio_coding/codecs/isac/fix/source/isacfix.c deleted file mode 100644 index 8786b12..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/isacfix.c +++ /dev/null
@@ -1,1551 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * isacfix.c - * - * This C file contains the functions for the ISAC API - * - */ - -#include "modules/audio_coding/codecs/isac/fix/interface/isacfix.h" - -#include <stdlib.h> - -#include "modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h" -#include "modules/audio_coding/codecs/isac/fix/source/codec.h" -#include "modules/audio_coding/codecs/isac/fix/source/entropy_coding.h" -#include "modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h" -#include "modules/audio_coding/codecs/isac/fix/source/structs.h" -#include "system_wrappers/interface/cpu_features_wrapper.h" - - -/************************************************************************** - * WebRtcIsacfix_AssignSize(...) - * - * Functions used when malloc is not allowed - * Returns number of bytes needed to allocate for iSAC struct. - * - */ - -WebRtc_Word16 WebRtcIsacfix_AssignSize(int *sizeinbytes) { - *sizeinbytes=sizeof(ISACFIX_SubStruct)*2/sizeof(WebRtc_Word16); - return(0); -} - -/*************************************************************************** - * WebRtcIsacfix_Assign(...) - * - * Functions used when malloc is not allowed - * Place struct at given address - * - * If successful, Return 0, else Return -1 - */ - -WebRtc_Word16 WebRtcIsacfix_Assign(ISACFIX_MainStruct **inst, void *ISACFIX_inst_Addr) { - if (ISACFIX_inst_Addr!=NULL) { - *inst = (ISACFIX_MainStruct*)ISACFIX_inst_Addr; - (*(ISACFIX_SubStruct**)inst)->errorcode = 0; - (*(ISACFIX_SubStruct**)inst)->initflag = 0; - (*(ISACFIX_SubStruct**)inst)->ISACenc_obj.SaveEnc_ptr = NULL; - return(0); - } else { - return(-1); - } -} - - -#ifndef ISACFIX_NO_DYNAMIC_MEM - -/**************************************************************************** - * WebRtcIsacfix_Create(...) - * - * This function creates a ISAC instance, which will contain the state - * information for one coding/decoding channel. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_Create(ISACFIX_MainStruct **ISAC_main_inst) -{ - ISACFIX_SubStruct *tempo; - tempo = malloc(1 * sizeof(ISACFIX_SubStruct)); - *ISAC_main_inst = (ISACFIX_MainStruct *)tempo; - if (*ISAC_main_inst!=NULL) { - (*(ISACFIX_SubStruct**)ISAC_main_inst)->errorcode = 0; - (*(ISACFIX_SubStruct**)ISAC_main_inst)->initflag = 0; - (*(ISACFIX_SubStruct**)ISAC_main_inst)->ISACenc_obj.SaveEnc_ptr = NULL; - return(0); - } else { - return(-1); - } -} - - -/**************************************************************************** - * WebRtcIsacfix_CreateInternal(...) - * - * This function creates the memory that is used to store data in the encoder - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_CreateInternal(ISACFIX_MainStruct *ISAC_main_inst) -{ - ISACFIX_SubStruct *ISAC_inst; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Allocate memory for storing encoder data */ - ISAC_inst->ISACenc_obj.SaveEnc_ptr = malloc(1 * sizeof(ISAC_SaveEncData_t)); - - if (ISAC_inst->ISACenc_obj.SaveEnc_ptr!=NULL) { - return(0); - } else { - return(-1); - } -} - - -#endif - - - -/**************************************************************************** - * WebRtcIsacfix_Free(...) - * - * This function frees the ISAC instance created at the beginning. - * - * Input: - * - ISAC_main_inst : a ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_Free(ISACFIX_MainStruct *ISAC_main_inst) -{ - free(ISAC_main_inst); - return(0); -} - -/**************************************************************************** - * WebRtcIsacfix_FreeInternal(...) - * - * This function frees the internal memory for storing encoder data. - * - * Input: - * - ISAC_main_inst : a ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct *ISAC_main_inst) -{ - ISACFIX_SubStruct *ISAC_inst; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Release memory */ - free(ISAC_inst->ISACenc_obj.SaveEnc_ptr); - - return(0); -} - -/**************************************************************************** - * WebRtcAecm_InitNeon(...) - * - * This function initializes function pointers for ARM Neon platform. - */ - -#if (defined WEBRTC_DETECT_ARM_NEON || defined WEBRTC_ARCH_ARM_NEON) -static void WebRtcIsacfix_InitNeon(void) { - WebRtcIsacfix_AutocorrFix = WebRtcIsacfix_AutocorrNeon; - WebRtcIsacfix_FilterMaLoopFix = WebRtcIsacfix_FilterMaLoopNeon; - WebRtcIsacfix_CalculateResidualEnergy = - WebRtcIsacfix_CalculateResidualEnergyNeon; -} -#endif - -/**************************************************************************** - * WebRtcIsacfix_EncoderInit(...) - * - * This function initializes a ISAC instance prior to the encoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - CodingMode : 0 -> Bit rate and frame length are automatically - * adjusted to available bandwidth on - * transmission channel. - * 1 -> User sets a frame length and a target bit - * rate which is taken as the maximum short-term - * average bit rate. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_EncoderInit(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 CodingMode) -{ - int k; - WebRtc_Word16 statusInit; - ISACFIX_SubStruct *ISAC_inst; - - statusInit = 0; - /* typecast pointer to rela structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* flag encoder init */ - ISAC_inst->initflag |= 2; - - if (CodingMode == 0) - /* Adaptive mode */ - ISAC_inst->ISACenc_obj.new_framelength = INITIAL_FRAMESAMPLES; - else if (CodingMode == 1) - /* Instantaneous mode */ - ISAC_inst->ISACenc_obj.new_framelength = 480; /* default for I-mode */ - else { - ISAC_inst->errorcode = ISAC_DISALLOWED_CODING_MODE; - statusInit = -1; - } - - ISAC_inst->CodingMode = CodingMode; - - WebRtcIsacfix_InitMaskingEnc(&ISAC_inst->ISACenc_obj.maskfiltstr_obj); - WebRtcIsacfix_InitPreFilterbank(&ISAC_inst->ISACenc_obj.prefiltbankstr_obj); - WebRtcIsacfix_InitPitchFilter(&ISAC_inst->ISACenc_obj.pitchfiltstr_obj); - WebRtcIsacfix_InitPitchAnalysis(&ISAC_inst->ISACenc_obj.pitchanalysisstr_obj); - - - WebRtcIsacfix_InitBandwidthEstimator(&ISAC_inst->bwestimator_obj); - WebRtcIsacfix_InitRateModel(&ISAC_inst->ISACenc_obj.rate_data_obj); - - - ISAC_inst->ISACenc_obj.buffer_index = 0; - ISAC_inst->ISACenc_obj.frame_nb = 0; - ISAC_inst->ISACenc_obj.BottleNeck = 32000; /* default for I-mode */ - ISAC_inst->ISACenc_obj.MaxDelay = 10; /* default for I-mode */ - ISAC_inst->ISACenc_obj.current_framesamples = 0; - ISAC_inst->ISACenc_obj.s2nr = 0; - ISAC_inst->ISACenc_obj.MaxBits = 0; - ISAC_inst->ISACenc_obj.bitstr_seed = 4447; - ISAC_inst->ISACenc_obj.payloadLimitBytes30 = STREAM_MAXW16_30MS << 1; - ISAC_inst->ISACenc_obj.payloadLimitBytes60 = STREAM_MAXW16_60MS << 1; - ISAC_inst->ISACenc_obj.maxPayloadBytes = STREAM_MAXW16_60MS << 1; - ISAC_inst->ISACenc_obj.maxRateInBytes = STREAM_MAXW16_30MS << 1; - ISAC_inst->ISACenc_obj.enforceFrameSize = 0; - - /* Init the bistream data area to zero */ - for (k=0; k<STREAM_MAXW16_60MS; k++){ - ISAC_inst->ISACenc_obj.bitstr_obj.stream[k] = 0; - } - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtcIsacfix_InitPostFilterbank(&ISAC_inst->ISACenc_obj.interpolatorstr_obj); -#endif - - // Initiaze function pointers. - WebRtcIsacfix_AutocorrFix = WebRtcIsacfix_AutocorrC; - WebRtcIsacfix_FilterMaLoopFix = WebRtcIsacfix_FilterMaLoopC; - WebRtcIsacfix_CalculateResidualEnergy = - WebRtcIsacfix_CalculateResidualEnergyC; - -#ifdef WEBRTC_DETECT_ARM_NEON - if ((WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) != 0) { - WebRtcIsacfix_InitNeon(); - } -#elif defined(WEBRTC_ARCH_ARM_NEON) - WebRtcIsacfix_InitNeon(); -#endif - - return statusInit; -} - -/**************************************************************************** - * WebRtcIsacfix_Encode(...) - * - * This function encodes 10ms frame(s) and inserts it into a package. - * Input speech length has to be 160 samples (10ms). The encoder buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * : -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_Word16 *speechIn, - WebRtc_Word16 *encoded) -{ - ISACFIX_SubStruct *ISAC_inst; - WebRtc_Word16 stream_len; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - - /* typecast pointer to rela structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - - /* check if encoder initiated */ - if ((ISAC_inst->initflag & 2) != 2) { - ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; - return (-1); - } - - stream_len = WebRtcIsacfix_EncodeImpl((WebRtc_Word16*)speechIn, - &ISAC_inst->ISACenc_obj, - &ISAC_inst->bwestimator_obj, - ISAC_inst->CodingMode); - if (stream_len<0) { - ISAC_inst->errorcode = - stream_len; - return -1; - } - - - /* convert from bytes to WebRtc_Word16 */ -#ifndef WEBRTC_BIG_ENDIAN - for (k=0;k<(stream_len+1)>>1;k++) { - encoded[k] = (WebRtc_Word16)( ( (WebRtc_UWord16)(ISAC_inst->ISACenc_obj.bitstr_obj).stream[k] >> 8 ) - | (((ISAC_inst->ISACenc_obj.bitstr_obj).stream[k] & 0x00FF) << 8)); - } - -#else - WEBRTC_SPL_MEMCPY_W16(encoded, (ISAC_inst->ISACenc_obj.bitstr_obj).stream, (stream_len + 1)>>1); -#endif - - - - return stream_len; - -} - - - - -/**************************************************************************** - * WebRtcIsacfix_EncodeNb(...) - * - * This function encodes 10ms narrow band (8 kHz sampling) frame(s) and inserts - * it into a package. Input speech length has to be 80 samples (10ms). The encoder - * interpolates into wide-band (16 kHz sampling) buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 wide-band samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : 0 - The buffer didn't reach the chosen framesize - * so it keeps buffering speech samples. - * : -1 - Error - */ -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -WebRtc_Word16 WebRtcIsacfix_EncodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_Word16 *speechIn, - WebRtc_Word16 *encoded) -{ - ISACFIX_SubStruct *ISAC_inst; - WebRtc_Word16 stream_len; - WebRtc_Word16 speechInWB[FRAMESAMPLES_10ms]; - WebRtc_Word16 Vector_Word16_1[FRAMESAMPLES_10ms/2]; - WebRtc_Word16 Vector_Word16_2[FRAMESAMPLES_10ms/2]; - - int k; - - - /* typecast pointer to rela structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - - /* check if encoder initiated */ - if ((ISAC_inst->initflag & 2) != 2) { - ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; - return (-1); - } - - - /* Oversample to WB */ - - /* Form polyphase signals, and compensate for DC offset */ - for (k=0;k<FRAMESAMPLES_10ms/2;k++) { - Vector_Word16_1[k] = speechIn[k] + 1; - Vector_Word16_2[k] = speechIn[k]; - } - WebRtcIsacfix_FilterAndCombine2(Vector_Word16_1, Vector_Word16_2, speechInWB, &ISAC_inst->ISACenc_obj.interpolatorstr_obj, FRAMESAMPLES_10ms); - - - /* Encode WB signal */ - stream_len = WebRtcIsacfix_EncodeImpl((WebRtc_Word16*)speechInWB, - &ISAC_inst->ISACenc_obj, - &ISAC_inst->bwestimator_obj, - ISAC_inst->CodingMode); - if (stream_len<0) { - ISAC_inst->errorcode = - stream_len; - return -1; - } - - - /* convert from bytes to WebRtc_Word16 */ -#ifndef WEBRTC_BIG_ENDIAN - for (k=0;k<(stream_len+1)>>1;k++) { - encoded[k] = (WebRtc_Word16)(((WebRtc_UWord16)(ISAC_inst->ISACenc_obj.bitstr_obj).stream[k] >> 8) - | (((ISAC_inst->ISACenc_obj.bitstr_obj).stream[k] & 0x00FF) << 8)); - } - -#else - WEBRTC_SPL_MEMCPY_W16(encoded, (ISAC_inst->ISACenc_obj.bitstr_obj).stream, (stream_len + 1)>>1); -#endif - - - - return stream_len; -} -#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ - - -/**************************************************************************** - * WebRtcIsacfix_GetNewBitStream(...) - * - * This function returns encoded data, with the recieved bwe-index in the - * stream. It should always return a complete packet, i.e. only called once - * even for 60 msec frames - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - bweIndex : index of bandwidth estimate to put in new bitstream - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_GetNewBitStream(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 bweIndex, - float scale, - WebRtc_Word16 *encoded) -{ - ISACFIX_SubStruct *ISAC_inst; - WebRtc_Word16 stream_len; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - - /* typecast pointer to rela structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - - /* check if encoder initiated */ - if ((ISAC_inst->initflag & 2) != 2) { - ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; - return (-1); - } - - stream_len = WebRtcIsacfix_EncodeStoredData(&ISAC_inst->ISACenc_obj, - bweIndex, - scale); - if (stream_len<0) { - ISAC_inst->errorcode = - stream_len; - return -1; - } - -#ifndef WEBRTC_BIG_ENDIAN - for (k=0;k<(stream_len+1)>>1;k++) { - encoded[k] = (WebRtc_Word16)( ( (WebRtc_UWord16)(ISAC_inst->ISACenc_obj.bitstr_obj).stream[k] >> 8 ) - | (((ISAC_inst->ISACenc_obj.bitstr_obj).stream[k] & 0x00FF) << 8)); - } - -#else - WEBRTC_SPL_MEMCPY_W16(encoded, (ISAC_inst->ISACenc_obj.bitstr_obj).stream, (stream_len + 1)>>1); -#endif - - return stream_len; - -} - - - -/**************************************************************************** - * WebRtcIsacfix_DecoderInit(...) - * - * This function initializes a ISAC instance prior to the decoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - * Return value - * : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst) -{ - ISACFIX_SubStruct *ISAC_inst; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* flag decoder init */ - ISAC_inst->initflag |= 1; - - - WebRtcIsacfix_InitMaskingDec(&ISAC_inst->ISACdec_obj.maskfiltstr_obj); - WebRtcIsacfix_InitPostFilterbank(&ISAC_inst->ISACdec_obj.postfiltbankstr_obj); - WebRtcIsacfix_InitPitchFilter(&ISAC_inst->ISACdec_obj.pitchfiltstr_obj); - - /* TS */ - WebRtcIsacfix_InitPlc( &ISAC_inst->ISACdec_obj.plcstr_obj ); - - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - WebRtcIsacfix_InitPreFilterbank(&ISAC_inst->ISACdec_obj.decimatorstr_obj); -#endif - - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_UpdateBwEstimate1(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 arr_ts) -{ - ISACFIX_SubStruct *ISAC_inst; - Bitstr_dec streamdata; - WebRtc_UWord16 partOfStream[5]; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - - /* Set stream pointer to point at partOfStream */ - streamdata.stream = (WebRtc_UWord16 *)partOfStream; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Sanity check of packet length */ - if (packet_size <= 0) { - /* return error code if the packet length is null or less */ - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } else if (packet_size > (STREAM_MAXW16<<1)) { - /* return error code if length of stream is too long */ - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - return -1; - } - - /* check if decoder initiated */ - if ((ISAC_inst->initflag & 1) != 1) { - ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; - return (-1); - } - - streamdata.W_upper = 0xFFFFFFFF; - streamdata.streamval = 0; - streamdata.stream_index = 0; - streamdata.full = 1; - -#ifndef WEBRTC_BIG_ENDIAN - for (k=0; k<5; k++) { - streamdata.stream[k] = (WebRtc_UWord16) (((WebRtc_UWord16)encoded[k] >> 8)|((encoded[k] & 0xFF)<<8)); - } -#else - memcpy(streamdata.stream, encoded, 5); -#endif - - if (packet_size == 0) - { - /* return error code if the packet length is null */ - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } - - err = WebRtcIsacfix_EstimateBandwidth(&ISAC_inst->bwestimator_obj, - &streamdata, - packet_size, - rtp_seq_number, - 0, - arr_ts); - - - if (err < 0) - { - /* return error code if something went wrong */ - ISAC_inst->errorcode = -err; - return -1; - } - - - return 0; -} - -/**************************************************************************** - * WebRtcIsacfix_UpdateBwEstimate(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - send_ts : Send Time Stamp from RTP header - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts) -{ - ISACFIX_SubStruct *ISAC_inst; - Bitstr_dec streamdata; - WebRtc_UWord16 partOfStream[5]; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - - /* Set stream pointer to point at partOfStream */ - streamdata.stream = (WebRtc_UWord16 *)partOfStream; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Sanity check of packet length */ - if (packet_size <= 0) { - /* return error code if the packet length is null or less */ - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } else if (packet_size > (STREAM_MAXW16<<1)) { - /* return error code if length of stream is too long */ - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - return -1; - } - - /* check if decoder initiated */ - if ((ISAC_inst->initflag & 1) != 1) { - ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; - return (-1); - } - - streamdata.W_upper = 0xFFFFFFFF; - streamdata.streamval = 0; - streamdata.stream_index = 0; - streamdata.full = 1; - -#ifndef WEBRTC_BIG_ENDIAN - for (k=0; k<5; k++) { - streamdata.stream[k] = (WebRtc_UWord16) ((encoded[k] >> 8)|((encoded[k] & 0xFF)<<8)); - } -#else - memcpy(streamdata.stream, encoded, 5); -#endif - - if (packet_size == 0) - { - /* return error code if the packet length is null */ - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } - - err = WebRtcIsacfix_EstimateBandwidth(&ISAC_inst->bwestimator_obj, - &streamdata, - packet_size, - rtp_seq_number, - send_ts, - arr_ts); - - if (err < 0) - { - /* return error code if something went wrong */ - ISAC_inst->errorcode = -err; - return -1; - } - - - return 0; -} - -/**************************************************************************** - * WebRtcIsacfix_Decode(...) - * - * This function decodes a ISAC frame. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the framesize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - - -WebRtc_Word16 WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - ISACFIX_SubStruct *ISAC_inst; - /* number of samples (480 or 960), output from decoder */ - /* that were actually used in the encoder/decoder (determined on the fly) */ - WebRtc_Word16 number_of_samples; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 declen = 0; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* check if decoder initiated */ - if ((ISAC_inst->initflag & 1) != 1) { - ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; - return (-1); - } - - /* Sanity check of packet length */ - if (len <= 0) { - /* return error code if the packet length is null or less */ - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } else if (len > (STREAM_MAXW16<<1)) { - /* return error code if length of stream is too long */ - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - return -1; - } - - (ISAC_inst->ISACdec_obj.bitstr_obj).stream = (WebRtc_UWord16 *)encoded; - - /* convert bitstream from WebRtc_Word16 to bytes */ -#ifndef WEBRTC_BIG_ENDIAN - for (k=0; k<(len>>1); k++) { - (ISAC_inst->ISACdec_obj.bitstr_obj).stream[k] = (WebRtc_UWord16) ((encoded[k] >> 8)|((encoded[k] & 0xFF)<<8)); - } - if (len & 0x0001) - (ISAC_inst->ISACdec_obj.bitstr_obj).stream[k] = (WebRtc_UWord16) ((encoded[k] & 0xFF)<<8); -#endif - - /* added for NetEq purposes (VAD/DTX related) */ - *speechType=1; - - declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_samples); - - if (declen < 0) { - /* Some error inside the decoder */ - ISAC_inst->errorcode = -declen; - memset(decoded, 0, sizeof(WebRtc_Word16) * MAX_FRAMESAMPLES); - return -1; - } - - /* error check */ - - if (declen & 0x0001) { - if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) & 0x00FF) ) { - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - memset(decoded, 0, sizeof(WebRtc_Word16) * number_of_samples); - return -1; - } - } else { - if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) >> 8) ) { - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - memset(decoded, 0, sizeof(WebRtc_Word16) * number_of_samples); - return -1; - } - } - - return number_of_samples; -} - - - - - -/**************************************************************************** - * WebRtcIsacfix_DecodeNb(...) - * - * This function decodes a ISAC frame in narrow-band (8 kHz sampling). - * Output speech length will be a multiple of 240 samples: 240 or 480 samples, - * depending on the framesize (30 or 60 ms). - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -WebRtc_Word16 WebRtcIsacfix_DecodeNb(ISACFIX_MainStruct *ISAC_main_inst, - const WebRtc_UWord16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType) -{ - ISACFIX_SubStruct *ISAC_inst; - /* twice the number of samples (480 or 960), output from decoder */ - /* that were actually used in the encoder/decoder (determined on the fly) */ - WebRtc_Word16 number_of_samples; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 declen = 0; - WebRtc_Word16 dummy[FRAMESAMPLES/2]; - - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* check if decoder initiated */ - if ((ISAC_inst->initflag & 1) != 1) { - ISAC_inst->errorcode = ISAC_DECODER_NOT_INITIATED; - return (-1); - } - - if (len == 0) - { /* return error code if the packet length is null */ - - ISAC_inst->errorcode = ISAC_EMPTY_PACKET; - return -1; - } - - (ISAC_inst->ISACdec_obj.bitstr_obj).stream = (WebRtc_UWord16 *)encoded; - - /* convert bitstream from WebRtc_Word16 to bytes */ -#ifndef WEBRTC_BIG_ENDIAN - for (k=0; k<(len>>1); k++) { - (ISAC_inst->ISACdec_obj.bitstr_obj).stream[k] = (WebRtc_UWord16) ((encoded[k] >> 8)|((encoded[k] & 0xFF)<<8)); - } - if (len & 0x0001) - (ISAC_inst->ISACdec_obj.bitstr_obj).stream[k] = (WebRtc_UWord16) ((encoded[k] & 0xFF)<<8); -#endif - - /* added for NetEq purposes (VAD/DTX related) */ - *speechType=1; - - declen = WebRtcIsacfix_DecodeImpl(decoded,&ISAC_inst->ISACdec_obj, &number_of_samples); - - if (declen < 0) { - /* Some error inside the decoder */ - ISAC_inst->errorcode = -declen; - memset(decoded, 0, sizeof(WebRtc_Word16) * FRAMESAMPLES); - return -1; - } - - /* error check */ - - if (declen & 0x0001) { - if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) & 0x00FF) ) { - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - memset(decoded, 0, sizeof(WebRtc_Word16) * number_of_samples); - return -1; - } - } else { - if (len != declen && len != declen + (((ISAC_inst->ISACdec_obj.bitstr_obj).stream[declen>>1]) >> 8) ) { - ISAC_inst->errorcode = ISAC_LENGTH_MISMATCH; - memset(decoded, 0, sizeof(WebRtc_Word16) * number_of_samples); - return -1; - } - } - - WebRtcIsacfix_SplitAndFilter2(decoded, decoded, dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); - - if (number_of_samples>FRAMESAMPLES) { - WebRtcIsacfix_SplitAndFilter2(decoded + FRAMESAMPLES, decoded + FRAMESAMPLES/2, - dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); - } - - return number_of_samples/2; -} -#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ - - -/**************************************************************************** - * WebRtcIsacfix_DecodePlcNb(...) - * - * This function conducts PLC for ISAC frame(s) in narrow-band (8kHz sampling). - * Output speech length will be "240*noOfLostFrames" samples - * that is equevalent of "30*noOfLostFrames" millisecond. - * - * The function is enabled if WEBRTC_ISAC_FIX_NB_CALLS_ENABLED is defined - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (240 sample=30ms) to produce - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED -WebRtc_Word16 WebRtcIsacfix_DecodePlcNb(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 *decoded, - WebRtc_Word16 noOfLostFrames ) -{ - WebRtc_Word16 no_of_samples, declen, k, ok; - WebRtc_Word16 outframeNB[FRAMESAMPLES]; - WebRtc_Word16 outframeWB[FRAMESAMPLES]; - WebRtc_Word16 dummy[FRAMESAMPLES/2]; - - - ISACFIX_SubStruct *ISAC_inst; - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors */ - if (noOfLostFrames > 2){ - noOfLostFrames = 2; - } - - k = 0; - declen = 0; - while( noOfLostFrames > 0 ) - { - ok = WebRtcIsacfix_DecodePlcImpl( outframeWB, &ISAC_inst->ISACdec_obj, &no_of_samples ); - if(ok) - return -1; - - WebRtcIsacfix_SplitAndFilter2(outframeWB, &(outframeNB[k*240]), dummy, &ISAC_inst->ISACdec_obj.decimatorstr_obj); - - declen += no_of_samples; - noOfLostFrames--; - k++; - } - - declen>>=1; - - for (k=0;k<declen;k++) { - decoded[k] = outframeNB[k]; - } - - return declen; -} -#endif /* WEBRTC_ISAC_FIX_NB_CALLS_ENABLED */ - - - - -/**************************************************************************** - * WebRtcIsacfix_DecodePlc(...) - * - * This function conducts PLC for ISAC frame(s) in wide-band (16kHz sampling). - * Output speech length will be "480*noOfLostFrames" samples - * that is equevalent of "30*noOfLostFrames" millisecond. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames (480sample = 30ms) - * to produce - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_DecodePlc(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 *decoded, - WebRtc_Word16 noOfLostFrames) -{ - - WebRtc_Word16 no_of_samples, declen, k, ok; - WebRtc_Word16 outframe16[MAX_FRAMESAMPLES]; - - ISACFIX_SubStruct *ISAC_inst; - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Limit number of frames to two = 60 msec. Otherwise we exceed data vectors */ - if (noOfLostFrames > 2) { - noOfLostFrames = 2; - } - k = 0; - declen = 0; - while( noOfLostFrames > 0 ) - { - ok = WebRtcIsacfix_DecodePlcImpl( &(outframe16[k*480]), &ISAC_inst->ISACdec_obj, &no_of_samples ); - if(ok) - return -1; - declen += no_of_samples; - noOfLostFrames--; - k++; - } - - for (k=0;k<declen;k++) { - decoded[k] = outframe16[k]; - } - - return declen; -} - - -/**************************************************************************** - * WebRtcIsacfix_Control(...) - * - * This function sets the limit on the short-term average bit rate and the - * frame length. Should be used only in Instantaneous mode. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rate : limit on the short-term average bit rate, - * in bits/second (between 10000 and 32000) - * - framesize : number of milliseconds per frame (30 or 60) - * - * Return value : 0 - ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 rate, - WebRtc_Word16 framesize) -{ - ISACFIX_SubStruct *ISAC_inst; - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - if (ISAC_inst->CodingMode == 0) - { - /* in adaptive mode */ - ISAC_inst->errorcode = ISAC_MODE_MISMATCH; - return -1; - } - - - if (rate >= 10000 && rate <= 32000) - ISAC_inst->ISACenc_obj.BottleNeck = rate; - else { - ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK; - return -1; - } - - - - if (framesize == 30 || framesize == 60) - ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * framesize; - else { - ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; - return -1; - } - - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_ControlBwe(...) - * - * This function sets the initial values of bottleneck and frame-size if - * iSAC is used in channel-adaptive mode. Through this API, users can - * enforce a frame-size for all values of bottleneck. Then iSAC will not - * automatically change the frame-size. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rateBPS : initial value of bottleneck in bits/second - * 10000 <= rateBPS <= 32000 is accepted - * For default bottleneck set rateBPS = 0 - * - frameSizeMs : number of milliseconds per frame (30 or 60) - * - enforceFrameSize : 1 to enforce the given frame-size through out - * the adaptation process, 0 to let iSAC change - * the frame-size if required. - * - * Return value : 0 - ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsacfix_ControlBwe(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 rateBPS, - WebRtc_Word16 frameSizeMs, - WebRtc_Word16 enforceFrameSize) -{ - ISACFIX_SubStruct *ISAC_inst; - /* Typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* check if encoder initiated */ - if ((ISAC_inst->initflag & 2) != 2) { - ISAC_inst->errorcode = ISAC_ENCODER_NOT_INITIATED; - return (-1); - } - - /* Check that we are in channel-adaptive mode, otherwise, return -1 */ - if (ISAC_inst->CodingMode != 0) { - ISAC_inst->errorcode = ISAC_MODE_MISMATCH; - return (-1); - } - - /* Set struct variable if enforceFrameSize is set. ISAC will then keep the */ - /* chosen frame size. */ - ISAC_inst->ISACenc_obj.enforceFrameSize = (enforceFrameSize != 0)? 1:0; - - /* Set initial rate, if value between 10000 and 32000, */ - /* if rateBPS is 0, keep the default initial bottleneck value (15000) */ - if ((rateBPS >= 10000) && (rateBPS <= 32000)) { - ISAC_inst->bwestimator_obj.sendBwAvg = (((WebRtc_UWord32)rateBPS) << 7); - } else if (rateBPS != 0) { - ISAC_inst->errorcode = ISAC_DISALLOWED_BOTTLENECK; - return -1; - } - - /* Set initial framesize. If enforceFrameSize is set the frame size will not change */ - if ((frameSizeMs == 30) || (frameSizeMs == 60)) { - ISAC_inst->ISACenc_obj.new_framelength = (FS/1000) * frameSizeMs; - } else { - ISAC_inst->errorcode = ISAC_DISALLOWED_FRAME_LENGTH; - return -1; - } - - return 0; -} - - - - - -/**************************************************************************** - * WebRtcIsacfix_GetDownLinkBwIndex(...) - * - * This function returns index representing the Bandwidth estimate from - * other side to this side. - * - * Input: - * - ISAC_main_inst: iSAC struct - * - * Output: - * - rateIndex : Bandwidth estimate to transmit to other side. - * - */ - -WebRtc_Word16 WebRtcIsacfix_GetDownLinkBwIndex(ISACFIX_MainStruct* ISAC_main_inst, - WebRtc_Word16* rateIndex) -{ - ISACFIX_SubStruct *ISAC_inst; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Call function to get Bandwidth Estimate */ - *rateIndex = WebRtcIsacfix_GetDownlinkBwIndexImpl(&ISAC_inst->bwestimator_obj); - - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_UpdateUplinkBw(...) - * - * This function takes an index representing the Bandwidth estimate from - * this side to other side and updates BWE. - * - * Input: - * - ISAC_main_inst: iSAC struct - * - rateIndex : Bandwidth estimate from other side. - * - */ - -WebRtc_Word16 WebRtcIsacfix_UpdateUplinkBw(ISACFIX_MainStruct* ISAC_main_inst, - WebRtc_Word16 rateIndex) -{ - WebRtc_Word16 err = 0; - ISACFIX_SubStruct *ISAC_inst; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - /* Call function to update BWE with received Bandwidth Estimate */ - err = WebRtcIsacfix_UpdateUplinkBwRec(&ISAC_inst->bwestimator_obj, rateIndex); - if (err < 0) { - ISAC_inst->errorcode = -err; - return (-1); - } - - return 0; -} - -/**************************************************************************** - * WebRtcIsacfix_ReadFrameLen(...) - * - * This function returns the length of the frame represented in the packet. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - */ - -WebRtc_Word16 WebRtcIsacfix_ReadFrameLen(const WebRtc_Word16* encoded, - WebRtc_Word16* frameLength) -{ - Bitstr_dec streamdata; - WebRtc_UWord16 partOfStream[5]; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - - /* Set stream pointer to point at partOfStream */ - streamdata.stream = (WebRtc_UWord16 *)partOfStream; - - streamdata.W_upper = 0xFFFFFFFF; - streamdata.streamval = 0; - streamdata.stream_index = 0; - streamdata.full = 1; - -#ifndef WEBRTC_BIG_ENDIAN - for (k=0; k<5; k++) { - streamdata.stream[k] = (WebRtc_UWord16) (((WebRtc_UWord16)encoded[k] >> 8)|((encoded[k] & 0xFF)<<8)); - } -#else - memcpy(streamdata.stream, encoded, 5); -#endif - - /* decode frame length */ - err = WebRtcIsacfix_DecodeFrameLen(&streamdata, frameLength); - if (err<0) // error check - return err; - - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_ReadBwIndex(...) - * - * This function returns the index of the Bandwidth estimate from the bitstream. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - rateIndex : Bandwidth estimate in bitstream - * - */ - -WebRtc_Word16 WebRtcIsacfix_ReadBwIndex(const WebRtc_Word16* encoded, - WebRtc_Word16* rateIndex) -{ - Bitstr_dec streamdata; - WebRtc_UWord16 partOfStream[5]; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - - /* Set stream pointer to point at partOfStream */ - streamdata.stream = (WebRtc_UWord16 *)partOfStream; - - streamdata.W_upper = 0xFFFFFFFF; - streamdata.streamval = 0; - streamdata.stream_index = 0; - streamdata.full = 1; - -#ifndef WEBRTC_BIG_ENDIAN - for (k=0; k<5; k++) { - streamdata.stream[k] = (WebRtc_UWord16) (((WebRtc_UWord16)encoded[k] >> 8)|((encoded[k] & 0xFF)<<8)); - } -#else - memcpy(streamdata.stream, encoded, 5); -#endif - - /* decode frame length, needed to get to the rateIndex in the bitstream */ - err = WebRtcIsacfix_DecodeFrameLen(&streamdata, rateIndex); - if (err<0) // error check - return err; - - /* decode BW estimation */ - err = WebRtcIsacfix_DecodeSendBandwidth(&streamdata, rateIndex); - if (err<0) // error check - return err; - - return 0; -} - - - - -/**************************************************************************** - * WebRtcIsacfix_GetErrorCode(...) - * - * This function can be used to check the error code of an iSAC instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occured in the - * specified instance. - * - * Input: - * - ISAC_main_inst : ISAC instance - * - * Return value : Error code - */ - -WebRtc_Word16 WebRtcIsacfix_GetErrorCode(ISACFIX_MainStruct *ISAC_main_inst) -{ - ISACFIX_SubStruct *ISAC_inst; - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - return ISAC_inst->errorcode; -} - - - -/**************************************************************************** - * WebRtcIsacfix_GetUplinkBw(...) - * - * This function returns the inst quantized iSAC send bitrate - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : bitrate - */ - -WebRtc_Word32 WebRtcIsacfix_GetUplinkBw(ISACFIX_MainStruct *ISAC_main_inst) -{ - ISACFIX_SubStruct *ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - BwEstimatorstr * bw = (BwEstimatorstr*)&(ISAC_inst->bwestimator_obj); - - return (WebRtc_Word32) WebRtcIsacfix_GetUplinkBandwidth(bw); -} - -/**************************************************************************** - * WebRtcIsacfix_GetNewFrameLen(...) - * - * This function return the next frame length (in samples) of iSAC. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : frame lenght in samples - */ - -WebRtc_Word16 WebRtcIsacfix_GetNewFrameLen(ISACFIX_MainStruct *ISAC_main_inst) -{ - ISACFIX_SubStruct *ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - return ISAC_inst->ISACenc_obj.new_framelength; -} - - -/**************************************************************************** - * WebRtcIsacfix_SetMaxPayloadSize(...) - * - * This function sets a limit for the maximum payload size of iSAC. The same - * value is used both for 30 and 60 msec packets. - * The absolute max will be valid until next time the function is called. - * NOTE! This function may override the function WebRtcIsacfix_SetMaxRate() - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxPayloadBytes : maximum size of the payload in bytes - * valid values are between 100 and 400 bytes - * - * - * Return value : 0 if sucessful - * -1 if error happens - */ - -WebRtc_Word16 WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word16 maxPayloadBytes) -{ - ISACFIX_SubStruct *ISAC_inst; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - if((maxPayloadBytes < 100) || (maxPayloadBytes > 400)) - { - /* maxPayloadBytes is out of valid range */ - return -1; - } - else - { - /* Set new absolute max, which will not change unless this function - is called again with a new value */ - ISAC_inst->ISACenc_obj.maxPayloadBytes = maxPayloadBytes; - - /* Set new maximum values for 30 and 60 msec packets */ - if (maxPayloadBytes < ISAC_inst->ISACenc_obj.maxRateInBytes) { - ISAC_inst->ISACenc_obj.payloadLimitBytes30 = maxPayloadBytes; - } else { - ISAC_inst->ISACenc_obj.payloadLimitBytes30 = ISAC_inst->ISACenc_obj.maxRateInBytes; - } - - if ( maxPayloadBytes < (ISAC_inst->ISACenc_obj.maxRateInBytes << 1)) { - ISAC_inst->ISACenc_obj.payloadLimitBytes60 = maxPayloadBytes; - } else { - ISAC_inst->ISACenc_obj.payloadLimitBytes60 = (ISAC_inst->ISACenc_obj.maxRateInBytes << 1); - } - } - return 0; -} - - -/**************************************************************************** - * WebRtcIsacfix_SetMaxRate(...) - * - * This function sets the maximum rate which the codec may not exceed for a - * singel packet. The maximum rate is set in bits per second. - * The codec has an absolute maximum rate of 53400 bits per second (200 bytes - * per 30 msec). - * It is possible to set a maximum rate between 32000 and 53400 bits per second. - * - * The rate limit is valid until next time the function is called. - * - * NOTE! Packet size will never go above the value set if calling - * WebRtcIsacfix_SetMaxPayloadSize() (default max packet size is 400 bytes). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxRateInBytes : maximum rate in bits per second, - * valid values are 32000 to 53400 bits - * - * Return value : 0 if sucessful - * -1 if error happens - */ - -WebRtc_Word16 WebRtcIsacfix_SetMaxRate(ISACFIX_MainStruct *ISAC_main_inst, - WebRtc_Word32 maxRate) -{ - ISACFIX_SubStruct *ISAC_inst; - WebRtc_Word16 maxRateInBytes; - - /* typecast pointer to real structure */ - ISAC_inst = (ISACFIX_SubStruct *)ISAC_main_inst; - - if((maxRate < 32000) || (maxRate > 53400)) - { - /* maxRate is out of valid range */ - return -1; - } - else - { - /* Calculate maximum number of bytes per 30 msec packets for the given - maximum rate. Multiply with 30/1000 to get number of bits per 30 msec, - divide by 8 to get number of bytes per 30 msec: - maxRateInBytes = floor((maxRate * 30/1000) / 8); */ - maxRateInBytes = (WebRtc_Word16)( WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_MUL(maxRate, 3), 800) ); - - /* Store the value for usage in the WebRtcIsacfix_SetMaxPayloadSize-function */ - ISAC_inst->ISACenc_obj.maxRateInBytes = maxRateInBytes; - - /* For 30 msec packets: if the new limit is below the maximum - payload size, set a new limit */ - if (maxRateInBytes < ISAC_inst->ISACenc_obj.maxPayloadBytes) { - ISAC_inst->ISACenc_obj.payloadLimitBytes30 = maxRateInBytes; - } else { - ISAC_inst->ISACenc_obj.payloadLimitBytes30 = ISAC_inst->ISACenc_obj.maxPayloadBytes; - } - - /* For 60 msec packets: if the new limit (times 2) is below the - maximum payload size, set a new limit */ - if ( (maxRateInBytes << 1) < ISAC_inst->ISACenc_obj.maxPayloadBytes) { - ISAC_inst->ISACenc_obj.payloadLimitBytes60 = (maxRateInBytes << 1); - } else { - ISAC_inst->ISACenc_obj.payloadLimitBytes60 = ISAC_inst->ISACenc_obj.maxPayloadBytes; - } - } - - return 0; -} - - - -/**************************************************************************** - * WebRtcIsacfix_version(...) - * - * This function returns the version number. - * - * Output: - * - version : Pointer to character string - * - */ - -void WebRtcIsacfix_version(char *version) -{ - strcpy(version, "3.6.0"); -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/isacfix.gypi b/src/modules/audio_coding/codecs/isac/fix/source/isacfix.gypi deleted file mode 100644 index 739b2e1..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/isacfix.gypi +++ /dev/null
@@ -1,108 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'iSACFix', - 'type': '<(library)', - 'dependencies': [ - '<(webrtc_root)/common_audio/common_audio.gyp:signal_processing', - '<(webrtc_root)/system_wrappers/source/system_wrappers.gyp:system_wrappers', - ], - 'include_dirs': [ - '../interface', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - '../interface', - ], - }, - 'sources': [ - '../interface/isacfix.h', - 'arith_routines.c', - 'arith_routines_hist.c', - 'arith_routines_logist.c', - 'bandwidth_estimator.c', - 'decode.c', - 'decode_bwe.c', - 'decode_plc.c', - 'encode.c', - 'entropy_coding.c', - 'fft.c', - 'filterbank_tables.c', - 'filterbanks.c', - 'filters.c', - 'initialize.c', - 'isacfix.c', - 'lattice.c', - 'lattice_c.c', - 'lpc_masking_model.c', - 'lpc_tables.c', - 'pitch_estimator.c', - 'pitch_filter.c', - 'pitch_filter_c.c', - 'pitch_gain_tables.c', - 'pitch_lag_tables.c', - 'spectrum_ar_model_tables.c', - 'transform.c', - 'arith_routins.h', - 'bandwidth_estimator.h', - 'codec.h', - 'entropy_coding.h', - 'fft.h', - 'filterbank_tables.h', - 'lpc_masking_model.h', - 'lpc_tables.h', - 'pitch_estimator.h', - 'pitch_gain_tables.h', - 'pitch_lag_tables.h', - 'settings.h', - 'spectrum_ar_model_tables.h', - 'structs.h', - ], - 'conditions': [ - ['OS!="win"', { - 'defines': [ - 'WEBRTC_LINUX', - ], - }], - ['target_arch=="arm" and armv7==1', { - 'dependencies': [ 'isac_neon', ], - 'sources': [ - 'lattice_armv7.S', - 'pitch_filter_armv6.S', - ], - 'sources!': [ - 'lattice_c.c', - 'pitch_filter_c.c', - ], - }], - ], - }, - ], - 'conditions': [ - ['target_arch=="arm" and armv7==1', { - 'targets': [ - { - 'target_name': 'isac_neon', - 'type': '<(library)', - 'includes': ['../../../../../../build/arm_neon.gypi',], - 'dependencies': [ - '<(webrtc_root)/common_audio/common_audio.gyp:signal_processing', - ], - 'sources': [ - 'filters_neon.c', - 'lattice_neon.S', - 'lpc_masking_model_neon.S', - ], - }, - ], - }], - ], -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lattice.c b/src/modules/audio_coding/codecs/isac/fix/source/lattice.c deleted file mode 100644 index 14588d0..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lattice.c +++ /dev/null
@@ -1,314 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lattice.c - * - * Contains the normalized lattice filter routines (MA and AR) for iSAC codec - * - */ - -#include "codec.h" -#include "settings.h" - -#define LATTICE_MUL_32_32_RSFT16(a32a, a32b, b32) \ - ((WebRtc_Word32)(WEBRTC_SPL_MUL(a32a, b32) + (WEBRTC_SPL_MUL_16_32_RSFT16(a32b, b32)))) -/* This macro is FORBIDDEN to use elsewhere than in a function in this file and - its corresponding neon version. It might give unpredictable results, since a - general WebRtc_Word32*WebRtc_Word32 multiplication results in a 64 bit value. - The result is then shifted just 16 steps to the right, giving need for 48 - bits, i.e. in the generel case, it will NOT fit in a WebRtc_Word32. In the - cases used in here, the WebRtc_Word32 will be enough, since (for a good - reason) the involved multiplicands aren't big enough to overflow a - WebRtc_Word32 after shifting right 16 bits. I have compared the result of a - multiplication between t32 and tmp32, done in two ways: - 1) Using (WebRtc_Word32) (((float)(tmp32))*((float)(tmp32b))/65536.0); - 2) Using LATTICE_MUL_32_32_RSFT16(t16a, t16b, tmp32b); - By running 25 files, I haven't found any bigger diff than 64 - this was in the - case when method 1) gave 650235648 and 2) gave 650235712. -*/ - -/* Function prototype: filtering ar_g_Q0[] and ar_f_Q0[] through an AR filter - with coefficients cth_Q15[] and sth_Q15[]. - Implemented for both generic and ARMv7 platforms. - */ -void WebRtcIsacfix_FilterArLoop(int16_t* ar_g_Q0, - int16_t* ar_f_Q0, - int16_t* cth_Q15, - int16_t* sth_Q15, - int16_t order_coef); - -/* Inner loop used for function WebRtcIsacfix_NormLatticeFilterMa(). It does: - for 0 <= n < HALF_SUBFRAMELEN - 1: - *ptr2 = input2 * (*ptr2) + input0 * (*ptr0)); - *ptr1 = input1 * (*ptr0) + input0 * (*ptr2); - Note, function WebRtcIsacfix_FilterMaLoopNeon and WebRtcIsacfix_FilterMaLoopC - are not bit-exact. The accuracy by the ARM Neon function is same or better. -*/ -void WebRtcIsacfix_FilterMaLoopC(int16_t input0, // Filter coefficient - int16_t input1, // Filter coefficient - int32_t input2, // Inverse coeff. (1/input1) - int32_t* ptr0, // Sample buffer - int32_t* ptr1, // Sample buffer - int32_t* ptr2) { // Sample buffer - int n = 0; - - // Separate the 32-bit variable input2 into two 16-bit integers (high 16 and - // low 16 bits), for using LATTICE_MUL_32_32_RSFT16 in the loop. - int16_t t16a = (int16_t)(input2 >> 16); - int16_t t16b = (int16_t)input2; - if (t16b < 0) t16a++; - - // The loop filtering the samples *ptr0, *ptr1, *ptr2 with filter coefficients - // input0, input1, and input2. - for(n = 0; n < HALF_SUBFRAMELEN - 1; n++, ptr0++, ptr1++, ptr2++) { - int32_t tmp32a = 0; - int32_t tmp32b = 0; - - // Calculate *ptr2 = input2 * (*ptr2 + input0 * (*ptr0)); - tmp32a = WEBRTC_SPL_MUL_16_32_RSFT15(input0, *ptr0); // Q15 * Q15 >> 15 = Q15 - tmp32b = *ptr2 + tmp32a; // Q15 + Q15 = Q15 - *ptr2 = LATTICE_MUL_32_32_RSFT16(t16a, t16b, tmp32b); - - // Calculate *ptr1 = input1 * (*ptr0) + input0 * (*ptr2); - tmp32a = WEBRTC_SPL_MUL_16_32_RSFT15(input1, *ptr0); // Q15*Q15>>15 = Q15 - tmp32b = WEBRTC_SPL_MUL_16_32_RSFT15(input0, *ptr2); // Q15*Q15>>15 = Q15 - *ptr1 = tmp32a + tmp32b; // Q15 + Q15 = Q15 - } -} - -// Declare a function pointer. -FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix; - -/* filter the signal using normalized lattice filter */ -/* MA filter */ -void WebRtcIsacfix_NormLatticeFilterMa(WebRtc_Word16 orderCoef, - WebRtc_Word32 *stateGQ15, - WebRtc_Word16 *lat_inQ0, - WebRtc_Word16 *filt_coefQ15, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 lo_hi, - WebRtc_Word16 *lat_outQ9) -{ - WebRtc_Word16 sthQ15[MAX_AR_MODEL_ORDER]; - WebRtc_Word16 cthQ15[MAX_AR_MODEL_ORDER]; - - int u, i, k, n; - WebRtc_Word16 temp2,temp3; - WebRtc_Word16 ord_1 = orderCoef+1; - WebRtc_Word32 inv_cthQ16[MAX_AR_MODEL_ORDER]; - - WebRtc_Word32 gain32, fQtmp; - WebRtc_Word16 gain16; - WebRtc_Word16 gain_sh; - - WebRtc_Word32 tmp32, tmp32b; - WebRtc_Word32 fQ15vec[HALF_SUBFRAMELEN]; - WebRtc_Word32 gQ15[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN]; - WebRtc_Word16 sh; - WebRtc_Word16 t16a; - WebRtc_Word16 t16b; - - for (u=0;u<SUBFRAMES;u++) - { - int32_t temp1 = WEBRTC_SPL_MUL_16_16(u, HALF_SUBFRAMELEN); - - /* set the Direct Form coefficients */ - temp2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(u, orderCoef); - temp3 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(2, u)+lo_hi; - - /* compute lattice filter coefficients */ - memcpy(sthQ15, &filt_coefQ15[temp2], orderCoef * sizeof(WebRtc_Word16)); - - WebRtcSpl_SqrtOfOneMinusXSquared(sthQ15, orderCoef, cthQ15); - - /* compute the gain */ - gain32 = gain_lo_hiQ17[temp3]; - gain_sh = WebRtcSpl_NormW32(gain32); - gain32 = WEBRTC_SPL_LSHIFT_W32(gain32, gain_sh); //Q(17+gain_sh) - - for (k=0;k<orderCoef;k++) - { - gain32 = WEBRTC_SPL_MUL_16_32_RSFT15(cthQ15[k], gain32); //Q15*Q(17+gain_sh)>>15 = Q(17+gain_sh) - inv_cthQ16[k] = WebRtcSpl_DivW32W16((WebRtc_Word32)2147483647, cthQ15[k]); // 1/cth[k] in Q31/Q15 = Q16 - } - gain16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(gain32, 16); //Q(1+gain_sh) - - /* normalized lattice filter */ - /*****************************/ - - /* initial conditions */ - for (i=0;i<HALF_SUBFRAMELEN;i++) - { - fQ15vec[i] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)lat_inQ0[i + temp1], 15); //Q15 - gQ15[0][i] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)lat_inQ0[i + temp1], 15); //Q15 - } - - - fQtmp = fQ15vec[0]; - - /* get the state of f&g for the first input, for all orders */ - for (i=1;i<ord_1;i++) - { - // Calculate f[i][0] = inv_cth[i-1]*(f[i-1][0] + sth[i-1]*stateG[i-1]); - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT15(sthQ15[i-1], stateGQ15[i-1]);//Q15*Q15>>15 = Q15 - tmp32b= fQtmp + tmp32; //Q15+Q15=Q15 - tmp32 = inv_cthQ16[i-1]; //Q16 - t16a = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32, 16); - t16b = (WebRtc_Word16) (tmp32-WEBRTC_SPL_LSHIFT_W32(((WebRtc_Word32)t16a), 16)); - if (t16b<0) t16a++; - tmp32 = LATTICE_MUL_32_32_RSFT16(t16a, t16b, tmp32b); - fQtmp = tmp32; // Q15 - - // Calculate g[i][0] = cth[i-1]*stateG[i-1] + sth[i-1]* f[i][0]; - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT15(cthQ15[i-1], stateGQ15[i-1]); //Q15*Q15>>15 = Q15 - tmp32b = WEBRTC_SPL_MUL_16_32_RSFT15(sthQ15[i-1], fQtmp); //Q15*Q15>>15 = Q15 - tmp32 = tmp32 + tmp32b;//Q15+Q15 = Q15 - gQ15[i][0] = tmp32; // Q15 - } - - /* filtering */ - /* save the states */ - for(k=0;k<orderCoef;k++) - { - // for 0 <= n < HALF_SUBFRAMELEN - 1: - // f[k+1][n+1] = inv_cth[k]*(f[k][n+1] + sth[k]*g[k][n]); - // g[k+1][n+1] = cth[k]*g[k][n] + sth[k]* f[k+1][n+1]; - WebRtcIsacfix_FilterMaLoopFix(sthQ15[k], cthQ15[k], inv_cthQ16[k], - &gQ15[k][0], &gQ15[k+1][1], &fQ15vec[1]); - } - - fQ15vec[0] = fQtmp; - - for(n=0;n<HALF_SUBFRAMELEN;n++) - { - //gain32 = WEBRTC_SPL_RSHIFT_W32(gain32, gain_sh); // Q(17+gain_sh) -> Q17 - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(gain16, fQ15vec[n]); //Q(1+gain_sh)*Q15>>16 = Q(gain_sh) - sh = 9-gain_sh; //number of needed shifts to reach Q9 - t16a = (WebRtc_Word16) WEBRTC_SPL_SHIFT_W32(tmp32, sh); - lat_outQ9[n + temp1] = t16a; - } - - /* save the states */ - for (i=0;i<ord_1;i++) - { - stateGQ15[i] = gQ15[i][HALF_SUBFRAMELEN-1]; - } - //process next frame - } - - return; -} - - - - - -/* ----------------AR filter-------------------------*/ -/* filter the signal using normalized lattice filter */ -void WebRtcIsacfix_NormLatticeFilterAr(WebRtc_Word16 orderCoef, - WebRtc_Word16 *stateGQ0, - WebRtc_Word32 *lat_inQ25, - WebRtc_Word16 *filt_coefQ15, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 lo_hi, - WebRtc_Word16 *lat_outQ0) -{ - int ii,n,k,i,u; - WebRtc_Word16 sthQ15[MAX_AR_MODEL_ORDER]; - WebRtc_Word16 cthQ15[MAX_AR_MODEL_ORDER]; - WebRtc_Word32 tmp32; - - - WebRtc_Word16 tmpAR; - WebRtc_Word16 ARfQ0vec[HALF_SUBFRAMELEN]; - WebRtc_Word16 ARgQ0vec[MAX_AR_MODEL_ORDER+1]; - - WebRtc_Word32 inv_gain32; - WebRtc_Word16 inv_gain16; - WebRtc_Word16 den16; - WebRtc_Word16 sh; - - WebRtc_Word16 temp2,temp3; - WebRtc_Word16 ord_1 = orderCoef+1; - - for (u=0;u<SUBFRAMES;u++) - { - int32_t temp1 = WEBRTC_SPL_MUL_16_16(u, HALF_SUBFRAMELEN); - - //set the denominator and numerator of the Direct Form - temp2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(u, orderCoef); - temp3 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(2, u) + lo_hi; - - for (ii=0; ii<orderCoef; ii++) { - sthQ15[ii] = filt_coefQ15[temp2+ii]; - } - - WebRtcSpl_SqrtOfOneMinusXSquared(sthQ15, orderCoef, cthQ15); - - /* Simulation of the 25 files shows that maximum value in - the vector gain_lo_hiQ17[] is 441344, which means that - it is log2((2^31)/441344) = 12.2 shifting bits from - saturation. Therefore, it should be safe to use Q27 instead - of Q17. */ - - tmp32 = WEBRTC_SPL_LSHIFT_W32(gain_lo_hiQ17[temp3], 10); // Q27 - - for (k=0;k<orderCoef;k++) { - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT15(cthQ15[k], tmp32); // Q15*Q27>>15 = Q27 - } - - sh = WebRtcSpl_NormW32(tmp32); // tmp32 is the gain - den16 = (WebRtc_Word16) WEBRTC_SPL_SHIFT_W32(tmp32, sh-16); //Q(27+sh-16) = Q(sh+11) (all 16 bits are value bits) - inv_gain32 = WebRtcSpl_DivW32W16((WebRtc_Word32)2147483647, den16); // 1/gain in Q31/Q(sh+11) = Q(20-sh) - - //initial conditions - inv_gain16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(inv_gain32, 2); // 1/gain in Q(20-sh-2) = Q(18-sh) - - for (i=0;i<HALF_SUBFRAMELEN;i++) - { - - tmp32 = WEBRTC_SPL_LSHIFT_W32(lat_inQ25[i + temp1], 1); //Q25->Q26 - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(inv_gain16, tmp32); //lat_in[]*inv_gain in (Q(18-sh)*Q26)>>16 = Q(28-sh) - tmp32 = WEBRTC_SPL_SHIFT_W32(tmp32, -(28-sh)); // lat_in[]*inv_gain in Q0 - - ARfQ0vec[i] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp32); // Q0 - } - - for (i=orderCoef-1;i>=0;i--) //get the state of f&g for the first input, for all orders - { - tmp32 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(cthQ15[i],ARfQ0vec[0])) - (WEBRTC_SPL_MUL_16_16(sthQ15[i],stateGQ0[i])) + 16384), 15); - tmpAR = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp32); // Q0 - - tmp32 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(sthQ15[i],ARfQ0vec[0])) + (WEBRTC_SPL_MUL_16_16(cthQ15[i], stateGQ0[i])) + 16384), 15); - ARgQ0vec[i+1] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp32); // Q0 - ARfQ0vec[0] = tmpAR; - } - ARgQ0vec[0] = ARfQ0vec[0]; - - // Filter ARgQ0vec[] and ARfQ0vec[] through coefficients cthQ15[] and sthQ15[]. - WebRtcIsacfix_FilterArLoop(ARgQ0vec, ARfQ0vec, cthQ15, sthQ15, orderCoef); - - for(n=0;n<HALF_SUBFRAMELEN;n++) - { - lat_outQ0[n + temp1] = ARfQ0vec[n]; - } - - - /* cannot use memcpy in the following */ - - for (i=0;i<ord_1;i++) - { - stateGQ0[i] = ARgQ0vec[i]; - } - } - - return; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S b/src/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S deleted file mode 100644 index 1cd3a76..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S +++ /dev/null
@@ -1,82 +0,0 @@ -@ -@ Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ Contains a function for the core loop in the normalized lattice AR -@ filter routine for iSAC codec, optimized for ARMv7 platforms. -@ -@ Output is bit-exact with the reference C code in lattic_c.c -@ -@ Register usage: -@ -@ r0: &ar_g_Q0 -@ r1: &ar_f_Q0 -@ r2: &cth_Q15 -@ r3: &sth_Q15 -@ r4: out loop counter -@ r5: tmpAR -@ r9: inner loop counter -@ r12: constant #16384 -@ r6, r7, r8, r10, r11: scratch - -#include "settings.h" - -.arch armv7-a -.global WebRtcIsacfix_FilterArLoop -.align 2 - -WebRtcIsacfix_FilterArLoop: -.fnstart - -.save {r4-r11} - push {r4-r11} - - add r1, #2 @ &ar_f_Q0[1] - mov r12, #16384 - mov r4, #HALF_SUBFRAMELEN - sub r4, #1 @ Outer loop counter = HALF_SUBFRAMELEN - 1 - -HALF_SUBFRAME_LOOP: @ for(n = 0; n < HALF_SUBFRAMELEN - 1; n++) - - ldr r9, [sp, #32] @ Restore the inner loop counter to order_coef - ldrh r5, [r1] @ tmpAR = ar_f_Q0[n+1] - add r0, r9, asl #1 @ Restore r0 to &ar_g_Q0[order_coef] - add r2, r9, asl #1 @ Restore r2 to &cth_Q15[order_coef] - add r3, r9, asl #1 @ Restore r3 to &sth_Q15[order_coef] - -ORDER_COEF_LOOP: @ for(k = order_coef - 1 ; k >= 0; k--) - - ldrh r7, [r3, #-2]! @ sth_Q15[k] - ldrh r6, [r2, #-2]! @ cth_Q15[k] - - ldrh r8, [r0, #-2] @ ar_g_Q0[k] - smlabb r11, r7, r5, r12 @ sth_Q15[k] * tmpAR + 16384 - smlabb r10, r6, r5, r12 @ cth_Q15[k] * tmpAR + 16384 - smulbb r7, r7, r8 @ sth_Q15[k] * ar_g_Q0[k] - smlabb r11, r6, r8, r11 @ cth_Q15[k]*ar_g_Q0[k]+(sth_Q15[k]*tmpAR+16384) - - sub r10, r10, r7 @ cth_Q15[k]*tmpAR+16384-(sth_Q15[k]*ar_g_Q0[k]) - ssat r11, #16, r11, asr #15 - ssat r5, #16, r10, asr #15 - strh r11, [r0], #-2 @ Output: ar_g_Q0[k+1] - - subs r9, #1 - bgt ORDER_COEF_LOOP - - strh r5, [r0] @ Output: ar_g_Q0[0] = tmpAR; - strh r5, [r1], #2 @ Output: ar_f_Q0[n+1] = tmpAR; - - subs r4, #1 - bne HALF_SUBFRAME_LOOP - - pop {r4-r11} - bx lr - -.fnend -
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lattice_c.c b/src/modules/audio_coding/codecs/isac/fix/source/lattice_c.c deleted file mode 100644 index 80ccf39..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lattice_c.c +++ /dev/null
@@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * Contains the core loop function for the lattice filter AR routine - * for iSAC codec. - * - */ - -#include "settings.h" -#include "signal_processing_library.h" -#include "typedefs.h" - -/* Filter ar_g_Q0[] and ar_f_Q0[] through an AR filter with coefficients - * cth_Q15[] and sth_Q15[]. - */ -void WebRtcIsacfix_FilterArLoop(int16_t* ar_g_Q0, // Input samples - int16_t* ar_f_Q0, // Input samples - int16_t* cth_Q15, // Filter coefficients - int16_t* sth_Q15, // Filter coefficients - int16_t order_coef) { // order of the filter - int n = 0; - - for (n = 0; n < HALF_SUBFRAMELEN - 1; n++) { - int k = 0; - int16_t tmpAR = 0; - int32_t tmp32 = 0; - int32_t tmp32_2 = 0; - - tmpAR = ar_f_Q0[n + 1]; - for (k = order_coef - 1; k >= 0; k--) { - tmp32 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(cth_Q15[k], tmpAR)) - - (WEBRTC_SPL_MUL_16_16(sth_Q15[k], ar_g_Q0[k])) + 16384), 15); - tmp32_2 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(sth_Q15[k], tmpAR)) - + (WEBRTC_SPL_MUL_16_16(cth_Q15[k], ar_g_Q0[k])) + 16384), 15); - tmpAR = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp32); - ar_g_Q0[k + 1] = (WebRtc_Word16)WebRtcSpl_SatW32ToW16(tmp32_2); - } - ar_f_Q0[n + 1] = tmpAR; - ar_g_Q0[0] = tmpAR; - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lattice_neon.S b/src/modules/audio_coding/codecs/isac/fix/source/lattice_neon.S deleted file mode 100644 index a59b6e3..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lattice_neon.S +++ /dev/null
@@ -1,155 +0,0 @@ -@ -@ Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ lattice_neon.s -@ -@ Contains a function for the core loop in the normalized lattice MA -@ filter routine for iSAC codec, optimized for ARM Neon platform. -@ void WebRtcIsacfix_FilterMaLoopNeon(int16_t input0, -@ int16_t input1, -@ int32_t input2, -@ int32_t* ptr0, -@ int32_t* ptr1, -@ int32_t* __restrict ptr2); -@ It calculates -@ *ptr2 = input2 * (*ptr2) + input0 * (*ptr0)); -@ *ptr1 = input1 * (*ptr0) + input0 * (*ptr2); -@ in Q15 domain. -@ -@ Reference code in lattice.c. -@ Output is not bit-exact with the reference C code, due to the replacement -@ of WEBRTC_SPL_MUL_16_32_RSFT15 and LATTICE_MUL_32_32_RSFT16 with Neon -@ instructions, smulwb, and smull. Speech quality was not degraded by -@ testing speech and tone vectors. - -.arch armv7-a -.fpu neon - -#include "settings.h" - -.global WebRtcIsacfix_FilterMaLoopNeon - -.align 2 - -WebRtcIsacfix_FilterMaLoopNeon: -.fnstart - -.save {r4-r8} - push {r4-r8} - - vdup.32 d28, r0 @ Initialize Neon register with input0 - vdup.32 d29, r1 @ Initialize Neon register with input1 - vdup.32 d30, r2 @ Initialize Neon register with input2 - ldr r4, [sp, #20] @ ptr1 - ldr r12, [sp, #24] @ ptr2 - - @ Number of loop iterations after unrolling: r5 = (HALF_SUBFRAMELEN - 1) >> 2 - @ Leftover samples after the loop, in r6: - @ r6 = (HALF_SUBFRAMELEN - 1) - (HALF_SUBFRAMELEN - 1) >> 2 << 2 - mov r6, #HALF_SUBFRAMELEN - sub r6, #1 - lsr r5, r6, #2 - sub r6, r5, lsl #2 - - @ First r5 iterations in a loop. - -LOOP: - vld1.32 {d0, d1}, [r3]! @ *ptr0 - - vmull.s32 q10, d0, d28 @ tmp32a = input0 * (*ptr0) - vmull.s32 q11, d1, d28 @ tmp32a = input0 * (*ptr0) - vmull.s32 q12, d0, d29 @ input1 * (*ptr0) - vmull.s32 q13, d1, d29 @ input1 * (*ptr0) - - vrshrn.i64 d4, q10, #15 - vrshrn.i64 d5, q11, #15 - - vld1.32 {d2, d3}, [r12] @ *ptr2 - vadd.i32 q3, q2, q1 @ tmp32b = *ptr2 + tmp32a - - vrshrn.i64 d0, q12, #15 - - vmull.s32 q10, d6, d30 @ input2 * (*ptr2 + tmp32b) - vmull.s32 q11, d7, d30 @ input2 * (*ptr2 + tmp32b) - - vrshrn.i64 d16, q10, #16 - vrshrn.i64 d17, q11, #16 - - vmull.s32 q10, d16, d28 @ input0 * (*ptr2) - vmull.s32 q11, d17, d28 @ input0 * (*ptr2) - - vrshrn.i64 d1, q13, #15 - vrshrn.i64 d18, q10, #15 - vrshrn.i64 d19, q11, #15 - - vst1.32 {d16, d17}, [r12]! @ *ptr2 - - vadd.i32 q9, q0, q9 - subs r5, #1 - vst1.32 {d18, d19}, [r4]! @ *ptr1 - - bgt LOOP - - @ Check how many samples still need to be processed. - subs r6, #2 - blt LAST_SAMPLE - - @ Process two more samples: - vld1.32 d0, [r3]! @ *ptr0 - - vmull.s32 q11, d0, d28 @ tmp32a = input0 * (*ptr0) - vmull.s32 q13, d0, d29 @ input1 * (*ptr0) - - vld1.32 d18, [r12] @ *ptr2 - vrshrn.i64 d4, q11, #15 - - vadd.i32 d7, d4, d18 @ tmp32b = *ptr2 + tmp32a - vmull.s32 q11, d7, d30 @ input2 * (*ptr2 + tmp32b) - vrshrn.i64 d16, q11, #16 - - vmull.s32 q11, d16, d28 @ input0 * (*ptr2) - vst1.32 d16, [r12]! @ *ptr2 - - vrshrn.i64 d0, q13, #15 - vrshrn.i64 d19, q11, #15 - vadd.i32 d19, d0, d19 - - vst1.32 d19, [r4]! @ *ptr1 - - @ If there's still one more sample, process it here. -LAST_SAMPLE: - cmp r6, #1 - bne END - - @ *ptr2 = input2 * (*ptr2 + input0 * (*ptr0)); - - ldr r7, [r3] @ *ptr0 - ldr r8, [r12] @ *ptr2 - - smulwb r5, r7, r0 @ tmp32a = *ptr0 * input0 >> 16 - add r8, r8, r5, lsl #1 @ tmp32b = *ptr2 + (tmp32a << 1) - smull r5, r6, r8, r2 @ tmp32b * input2, in 64 bits - lsl r6, #16 - add r6, r5, lsr #16 @ Only take the middle 32 bits - str r6, [r12] @ Output (*ptr2, as 32 bits) - - @ *ptr1 = input1 * (*ptr0) + input0 * (*ptr2); - - smulwb r5, r7, r1 @ tmp32a = *ptr0 * input1 >> 16 - smulwb r6, r6, r0 @ tmp32b = *ptr2 * input0 >> 16 - lsl r5, r5, #1 - add r5, r6, lsl #1 - str r5, [r4] @ Output (*ptr1) - -END: - pop {r4-r8} - bx lr - -.fnend
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c b/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c deleted file mode 100644 index 4be438e..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c +++ /dev/null
@@ -1,957 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_masking_model.c - * - * LPC analysis and filtering functions - * - */ - -#include "lpc_masking_model.h" - -#include <limits.h> /* For LLONG_MAX and LLONG_MIN. */ -#include "codec.h" -#include "entropy_coding.h" -#include "settings.h" - -/* The conversion is implemented by the step-down algorithm */ -void WebRtcSpl_AToK_JSK( - WebRtc_Word16 *a16, /* Q11 */ - WebRtc_Word16 useOrder, - WebRtc_Word16 *k16 /* Q15 */ - ) -{ - int m, k; - WebRtc_Word32 tmp32[MAX_AR_MODEL_ORDER]; - WebRtc_Word32 tmp32b; - WebRtc_Word32 tmp_inv_denum32; - WebRtc_Word16 tmp_inv_denum16; - - k16[useOrder-1]= WEBRTC_SPL_LSHIFT_W16(a16[useOrder], 4); //Q11<<4 => Q15 - - for (m=useOrder-1; m>0; m--) { - tmp_inv_denum32 = ((WebRtc_Word32) 1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); // (1 - k^2) in Q30 - tmp_inv_denum16 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp_inv_denum32, 15); // (1 - k^2) in Q15 - - for (k=1; k<=m; k++) { - tmp32b = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)a16[k], 16) - - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(k16[m], a16[m-k+1]), 1); - - tmp32[k] = WebRtcSpl_DivW32W16(tmp32b, tmp_inv_denum16); //Q27/Q15 = Q12 - } - - for (k=1; k<m; k++) { - a16[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmp32[k], 1); //Q12>>1 => Q11 - } - - tmp32[m] = WEBRTC_SPL_SAT(4092, tmp32[m], -4092); - k16[m-1] = (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W32(tmp32[m], 3); //Q12<<3 => Q15 - } - - return; -} - - - - - -WebRtc_Word16 WebRtcSpl_LevinsonW32_JSK( - WebRtc_Word32 *R, /* (i) Autocorrelation of length >= order+1 */ - WebRtc_Word16 *A, /* (o) A[0..order] LPC coefficients (Q11) */ - WebRtc_Word16 *K, /* (o) K[0...order-1] Reflection coefficients (Q15) */ - WebRtc_Word16 order /* (i) filter order */ - ) { - WebRtc_Word16 i, j; - WebRtc_Word16 R_hi[LEVINSON_MAX_ORDER+1], R_low[LEVINSON_MAX_ORDER+1]; - /* Aurocorr coefficients in high precision */ - WebRtc_Word16 A_hi[LEVINSON_MAX_ORDER+1], A_low[LEVINSON_MAX_ORDER+1]; - /* LPC coefficients in high precicion */ - WebRtc_Word16 A_upd_hi[LEVINSON_MAX_ORDER+1], A_upd_low[LEVINSON_MAX_ORDER+1]; - /* LPC coefficients for next iteration */ - WebRtc_Word16 K_hi, K_low; /* reflection coefficient in high precision */ - WebRtc_Word16 Alpha_hi, Alpha_low, Alpha_exp; /* Prediction gain Alpha in high precision - and with scale factor */ - WebRtc_Word16 tmp_hi, tmp_low; - WebRtc_Word32 temp1W32, temp2W32, temp3W32; - WebRtc_Word16 norm; - - /* Normalize the autocorrelation R[0]...R[order+1] */ - - norm = WebRtcSpl_NormW32(R[0]); - - for (i=order;i>=0;i--) { - temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm); - /* Put R in hi and low format */ - R_hi[i] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - R_low[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[i], 16)), 1); - } - - /* K = A[1] = -R[1] / R[0] */ - - temp2W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[1],16) + - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_low[1],1); /* R[1] in Q31 */ - temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); /* abs R[1] */ - temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); /* abs(R[1])/R[0] in Q31 */ - /* Put back the sign on R[1] */ - if (temp2W32 > 0) { - temp1W32 = -temp1W32; - } - - /* Put K in hi and low format */ - K_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - K_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)K_hi, 16)), 1); - - /* Store first reflection coefficient */ - K[0] = K_hi; - - temp1W32 = WEBRTC_SPL_RSHIFT_W32(temp1W32, 4); /* A[1] in Q27 */ - - /* Put A[1] in hi and low format */ - A_hi[1] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - A_low[1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[1], 16)), 1); - - /* Alpha = R[0] * (1-K^2) */ - - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_hi, K_low), 14) + - WEBRTC_SPL_MUL_16_16(K_hi, K_hi)), 1); /* temp1W32 = k^2 in Q31 */ - - temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); /* Guard against <0 */ - temp1W32 = (WebRtc_Word32)0x7fffffffL - temp1W32; /* temp1W32 = (1 - K[0]*K[0]) in Q31 */ - - /* Store temp1W32 = 1 - K[0]*K[0] on hi and low format */ - tmp_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - - /* Calculate Alpha in Q31 */ - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_hi) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_low), 15) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_low[0], tmp_hi), 15) ), 1); - - /* Normalize Alpha and put it in hi and low format */ - - Alpha_exp = WebRtcSpl_NormW32(temp1W32); - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, Alpha_exp); - Alpha_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - Alpha_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)Alpha_hi, 16)), 1); - - /* Perform the iterative calculations in the - Levinson Durbin algorithm */ - - for (i=2; i<=order; i++) - { - - /* ---- - \ - temp1W32 = R[i] + > R[j]*A[i-j] - / - ---- - j=1..i-1 - */ - - temp1W32 = 0; - - for(j=1; j<i; j++) { - /* temp1W32 is in Q31 */ - temp1W32 += (WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_hi[j], A_hi[i-j]), 1) + - WEBRTC_SPL_LSHIFT_W32(( WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_hi[j], A_low[i-j]), 15) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_low[j], A_hi[i-j]), 15) ), 1)); - } - - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4); - temp1W32 += (WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[i], 16) + - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_low[i], 1)); - - /* K = -temp1W32 / Alpha */ - temp2W32 = WEBRTC_SPL_ABS_W32(temp1W32); /* abs(temp1W32) */ - temp3W32 = WebRtcSpl_DivW32HiLow(temp2W32, Alpha_hi, Alpha_low); /* abs(temp1W32)/Alpha */ - - /* Put the sign of temp1W32 back again */ - if (temp1W32 > 0) { - temp3W32 = -temp3W32; - } - - /* Use the Alpha shifts from earlier to denormalize */ - norm = WebRtcSpl_NormW32(temp3W32); - if ((Alpha_exp <= norm)||(temp3W32==0)) { - temp3W32 = WEBRTC_SPL_LSHIFT_W32(temp3W32, Alpha_exp); - } else { - if (temp3W32 > 0) - { - temp3W32 = (WebRtc_Word32)0x7fffffffL; - } else - { - temp3W32 = (WebRtc_Word32)0x80000000L; - } - } - - /* Put K on hi and low format */ - K_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp3W32, 16); - K_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp3W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)K_hi, 16)), 1); - - /* Store Reflection coefficient in Q15 */ - K[i-1] = K_hi; - - /* Test for unstable filter. If unstable return 0 and let the - user decide what to do in that case - */ - - if ((WebRtc_Word32)WEBRTC_SPL_ABS_W16(K_hi) > (WebRtc_Word32)32740) { - return(-i); /* Unstable filter */ - } - - /* - Compute updated LPC coefficient: Anew[i] - Anew[j]= A[j] + K*A[i-j] for j=1..i-1 - Anew[i]= K - */ - - for(j=1; j<i; j++) - { - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[j],16) + - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_low[j],1); /* temp1W32 = A[j] in Q27 */ - - temp1W32 += WEBRTC_SPL_LSHIFT_W32(( WEBRTC_SPL_MUL_16_16(K_hi, A_hi[i-j]) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_hi, A_low[i-j]), 15) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_low, A_hi[i-j]), 15) ), 1); /* temp1W32 += K*A[i-j] in Q27 */ - - /* Put Anew in hi and low format */ - A_upd_hi[j] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - A_upd_low[j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_upd_hi[j], 16)), 1); - } - - temp3W32 = WEBRTC_SPL_RSHIFT_W32(temp3W32, 4); /* temp3W32 = K in Q27 (Convert from Q31 to Q27) */ - - /* Store Anew in hi and low format */ - A_upd_hi[i] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp3W32, 16); - A_upd_low[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp3W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_upd_hi[i], 16)), 1); - - /* Alpha = Alpha * (1-K^2) */ - - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_hi, K_low), 14) + - WEBRTC_SPL_MUL_16_16(K_hi, K_hi)), 1); /* K*K in Q31 */ - - temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); /* Guard against <0 */ - temp1W32 = (WebRtc_Word32)0x7fffffffL - temp1W32; /* 1 - K*K in Q31 */ - - /* Convert 1- K^2 in hi and low format */ - tmp_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - - /* Calculate Alpha = Alpha * (1-K^2) in Q31 */ - temp1W32 = WEBRTC_SPL_LSHIFT_W32(( WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_hi) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_low), 15) + - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(Alpha_low, tmp_hi), 15)), 1); - - /* Normalize Alpha and store it on hi and low format */ - - norm = WebRtcSpl_NormW32(temp1W32); - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, norm); - - Alpha_hi = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); - Alpha_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)Alpha_hi, 16)), 1); - - /* Update the total nomalization of Alpha */ - Alpha_exp = Alpha_exp + norm; - - /* Update A[] */ - - for(j=1; j<=i; j++) - { - A_hi[j] =A_upd_hi[j]; - A_low[j] =A_upd_low[j]; - } - } - - /* - Set A[0] to 1.0 and store the A[i] i=1...order in Q12 - (Convert from Q27 and use rounding) - */ - - A[0] = 2048; - - for(i=1; i<=order; i++) { - /* temp1W32 in Q27 */ - temp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[i], 16) + - WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_low[i], 1); - /* Round and store upper word */ - A[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32+(WebRtc_Word32)32768, 16); - } - return(1); /* Stable filters */ -} - - - - - -/* window */ -/* Matlab generation of floating point code: - * t = (1:256)/257; r = 1-(1-t).^.45; w = sin(r*pi).^3; w = w/sum(w); plot((1:256)/8, w); grid; - * for k=1:16, fprintf(1, '%.8f, ', w(k*16 + (-15:0))); fprintf(1, '\n'); end - * All values are multiplyed with 2^21 in fixed point code. - */ -static const WebRtc_Word16 kWindowAutocorr[WINLEN] = { - 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 5, 6, - 8, 10, 12, 14, 17, 20, 24, 28, 33, 38, 43, 49, - 56, 63, 71, 79, 88, 98, 108, 119, 131, 143, 157, 171, - 186, 202, 219, 237, 256, 275, 296, 318, 341, 365, 390, 416, - 444, 472, 502, 533, 566, 600, 635, 671, 709, 748, 789, 831, - 875, 920, 967, 1015, 1065, 1116, 1170, 1224, 1281, 1339, 1399, 1461, - 1525, 1590, 1657, 1726, 1797, 1870, 1945, 2021, 2100, 2181, 2263, 2348, - 2434, 2523, 2614, 2706, 2801, 2898, 2997, 3099, 3202, 3307, 3415, 3525, - 3637, 3751, 3867, 3986, 4106, 4229, 4354, 4481, 4611, 4742, 4876, 5012, - 5150, 5291, 5433, 5578, 5725, 5874, 6025, 6178, 6333, 6490, 6650, 6811, - 6974, 7140, 7307, 7476, 7647, 7820, 7995, 8171, 8349, 8529, 8711, 8894, - 9079, 9265, 9453, 9642, 9833, 10024, 10217, 10412, 10607, 10803, 11000, 11199, - 11398, 11597, 11797, 11998, 12200, 12401, 12603, 12805, 13008, 13210, 13412, 13614, - 13815, 14016, 14216, 14416, 14615, 14813, 15009, 15205, 15399, 15591, 15782, 15971, - 16157, 16342, 16524, 16704, 16881, 17056, 17227, 17395, 17559, 17720, 17877, 18030, - 18179, 18323, 18462, 18597, 18727, 18851, 18970, 19082, 19189, 19290, 19384, 19471, - 19551, 19623, 19689, 19746, 19795, 19835, 19867, 19890, 19904, 19908, 19902, 19886, - 19860, 19823, 19775, 19715, 19644, 19561, 19465, 19357, 19237, 19102, 18955, 18793, - 18618, 18428, 18223, 18004, 17769, 17518, 17252, 16970, 16672, 16357, 16025, 15677, - 15311, 14929, 14529, 14111, 13677, 13225, 12755, 12268, 11764, 11243, 10706, 10152, - 9583, 8998, 8399, 7787, 7162, 6527, 5883, 5231, 4576, 3919, 3265, 2620, - 1990, 1386, 825, 333 -}; - - -/* By using a hearing threshold level in dB of -28 dB (higher value gives more noise), - the H_T_H (in float) can be calculated as: - H_T_H = pow(10.0, 0.05 * (-28.0)) = 0.039810717055350 - In Q19, H_T_H becomes round(0.039810717055350*2^19) ~= 20872, i.e. - H_T_H = 20872/524288.0, and H_T_HQ19 = 20872; -*/ - - -/* The bandwidth expansion vectors are created from: - kPolyVecLo=[0.900000,0.810000,0.729000,0.656100,0.590490,0.531441,0.478297,0.430467,0.387420,0.348678,0.313811,0.282430]; - kPolyVecHi=[0.800000,0.640000,0.512000,0.409600,0.327680,0.262144]; - round(kPolyVecLo*32768) - round(kPolyVecHi*32768) -*/ -static const WebRtc_Word16 kPolyVecLo[12] = { - 29491, 26542, 23888, 21499, 19349, 17414, 15673, 14106, 12695, 11425, 10283, 9255 -}; -static const WebRtc_Word16 kPolyVecHi[6] = { - 26214, 20972, 16777, 13422, 10737, 8590 -}; - -static __inline WebRtc_Word32 log2_Q8_LPC( WebRtc_UWord32 x ) { - - WebRtc_Word32 zeros, lg2; - WebRtc_Word16 frac; - - zeros=WebRtcSpl_NormU32(x); - frac=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(((WebRtc_UWord32)WEBRTC_SPL_LSHIFT_W32(x, zeros)&0x7FFFFFFF), 23); - - /* log2(x) */ - - lg2= (WEBRTC_SPL_LSHIFT_W16((31-zeros), 8)+frac); - return lg2; - -} - -static const WebRtc_Word16 kMulPitchGain = -25; /* 200/256 in Q5 */ -static const WebRtc_Word16 kChngFactor = 3523; /* log10(2)*10/4*0.4/1.4=log10(2)/1.4= 0.2150 in Q14 */ -static const WebRtc_Word16 kExp2 = 11819; /* 1/log(2) */ -const int kShiftLowerBand = 11; /* Shift value for lower band in Q domain. */ -const int kShiftHigherBand = 12; /* Shift value for higher band in Q domain. */ - -void WebRtcIsacfix_GetVars(const WebRtc_Word16 *input, const WebRtc_Word16 *pitchGains_Q12, - WebRtc_UWord32 *oldEnergy, WebRtc_Word16 *varscale) -{ - int k; - WebRtc_UWord32 nrgQ[4]; - WebRtc_Word16 nrgQlog[4]; - WebRtc_Word16 tmp16, chng1, chng2, chng3, chng4, tmp, chngQ, oldNrgQlog, pgQ, pg3; - WebRtc_Word32 expPg32; - WebRtc_Word16 expPg, divVal; - WebRtc_Word16 tmp16_1, tmp16_2; - - /* Calculate energies of first and second frame halfs */ - nrgQ[0]=0; - for (k = QLOOKAHEAD/2; k < (FRAMESAMPLES/4 + QLOOKAHEAD) / 2; k++) { - nrgQ[0] +=WEBRTC_SPL_MUL_16_16(input[k],input[k]); - } - nrgQ[1]=0; - for ( ; k < (FRAMESAMPLES/2 + QLOOKAHEAD) / 2; k++) { - nrgQ[1] +=WEBRTC_SPL_MUL_16_16(input[k],input[k]); - } - nrgQ[2]=0; - for ( ; k < (WEBRTC_SPL_MUL_16_16(FRAMESAMPLES, 3)/4 + QLOOKAHEAD) / 2; k++) { - nrgQ[2] +=WEBRTC_SPL_MUL_16_16(input[k],input[k]); - } - nrgQ[3]=0; - for ( ; k < (FRAMESAMPLES + QLOOKAHEAD) / 2; k++) { - nrgQ[3] +=WEBRTC_SPL_MUL_16_16(input[k],input[k]); - } - - for ( k=0; k<4; k++) { - nrgQlog[k] = (WebRtc_Word16)log2_Q8_LPC(nrgQ[k]); /* log2(nrgQ) */ - } - oldNrgQlog = (WebRtc_Word16)log2_Q8_LPC(*oldEnergy); - - /* Calculate average level change */ - chng1 = WEBRTC_SPL_ABS_W16(nrgQlog[3]-nrgQlog[2]); - chng2 = WEBRTC_SPL_ABS_W16(nrgQlog[2]-nrgQlog[1]); - chng3 = WEBRTC_SPL_ABS_W16(nrgQlog[1]-nrgQlog[0]); - chng4 = WEBRTC_SPL_ABS_W16(nrgQlog[0]-oldNrgQlog); - tmp = chng1+chng2+chng3+chng4; - chngQ = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp, kChngFactor, 10); /* Q12 */ - chngQ += 2926; /* + 1.0/1.4 in Q12 */ - - /* Find average pitch gain */ - pgQ = 0; - for (k=0; k<4; k++) - { - pgQ += pitchGains_Q12[k]; - } - - pg3 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(pgQ, pgQ,11); /* pgQ in Q(12+2)=Q14. Q14*Q14>>11 => Q17 */ - pg3 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(pgQ, pg3,13); /* Q17*Q14>>13 =>Q18 */ - pg3 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(pg3, kMulPitchGain ,5); /* Q10 kMulPitchGain = -25 = -200 in Q-3. */ - - tmp16=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(kExp2,pg3,13);/* Q13*Q10>>13 => Q10*/ - if (tmp16<0) { - tmp16_2 = (0x0400 | (tmp16 & 0x03FF)); - tmp16_1 = (WEBRTC_SPL_RSHIFT_W16((WebRtc_UWord16)(tmp16 ^ 0xFFFF), 10)-3); /* Gives result in Q14 */ - if (tmp16_1<0) - expPg=(WebRtc_Word16) -WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1); - else - expPg=(WebRtc_Word16) -WEBRTC_SPL_RSHIFT_W16(tmp16_2, tmp16_1); - } else - expPg = (WebRtc_Word16) -16384; /* 1 in Q14, since 2^0=1 */ - - expPg32 = (WebRtc_Word32)WEBRTC_SPL_LSHIFT_W16((WebRtc_Word32)expPg, 8); /* Q22 */ - divVal = WebRtcSpl_DivW32W16ResW16(expPg32, chngQ); /* Q22/Q12=Q10 */ - - tmp16=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(kExp2,divVal,13);/* Q13*Q10>>13 => Q10*/ - if (tmp16<0) { - tmp16_2 = (0x0400 | (tmp16 & 0x03FF)); - tmp16_1 = (WEBRTC_SPL_RSHIFT_W16((WebRtc_UWord16)(tmp16 ^ 0xFFFF), 10)-3); /* Gives result in Q14 */ - if (tmp16_1<0) - expPg=(WebRtc_Word16) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1); - else - expPg=(WebRtc_Word16) WEBRTC_SPL_RSHIFT_W16(tmp16_2, tmp16_1); - } else - expPg = (WebRtc_Word16) 16384; /* 1 in Q14, since 2^0=1 */ - - *varscale = expPg-1; - *oldEnergy = nrgQ[3]; -} - - - -static __inline WebRtc_Word16 exp2_Q10_T(WebRtc_Word16 x) { // Both in and out in Q10 - - WebRtc_Word16 tmp16_1, tmp16_2; - - tmp16_2=(WebRtc_Word16)(0x0400|(x&0x03FF)); - tmp16_1=-(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(x,10); - if(tmp16_1>0) - return (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W16(tmp16_2, tmp16_1); - else - return (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1); - -} - - -// Declare function pointers. -AutocorrFix WebRtcIsacfix_AutocorrFix; -CalculateResidualEnergy WebRtcIsacfix_CalculateResidualEnergy; - -/* This routine calculates the residual energy for LPC. - * Formula as shown in comments inside. - */ -int32_t WebRtcIsacfix_CalculateResidualEnergyC(int lpc_order, - int32_t q_val_corr, - int q_val_polynomial, - int16_t* a_polynomial, - int32_t* corr_coeffs, - int* q_val_residual_energy) { - int i = 0, j = 0; - int shift_internal = 0, shift_norm = 0; - int32_t tmp32 = 0, word32_high = 0, word32_low = 0, residual_energy = 0; - int64_t sum64 = 0, sum64_tmp = 0; - - for (i = 0; i <= lpc_order; i++) { - for (j = i; j <= lpc_order; j++) { - /* For the case of i == 0: residual_energy += - * a_polynomial[j] * corr_coeffs[i] * a_polynomial[j - i]; - * For the case of i != 0: residual_energy += - * a_polynomial[j] * corr_coeffs[i] * a_polynomial[j - i] * 2; - */ - - tmp32 = WEBRTC_SPL_MUL_16_16(a_polynomial[j], a_polynomial[j - i]); - /* tmp32 in Q(q_val_polynomial * 2). */ - if (i != 0) { - tmp32 <<= 1; - } - sum64_tmp = (int64_t)tmp32 * (int64_t)corr_coeffs[i]; - sum64_tmp >>= shift_internal; - - /* Test overflow and sum the result. */ - if(((sum64_tmp > 0 && sum64 > 0) && (LLONG_MAX - sum64 < sum64_tmp)) || - ((sum64_tmp < 0 && sum64 < 0) && (LLONG_MIN - sum64 > sum64_tmp))) { - /* Shift right for overflow. */ - shift_internal += 1; - sum64 >>= 1; - sum64 += sum64_tmp >> 1; - } else { - sum64 += sum64_tmp; - } - } - } - - word32_high = (int32_t)(sum64 >> 32); - word32_low = (int32_t)sum64; - - // Calculate the value of shifting (shift_norm) for the 64-bit sum. - if(word32_high != 0) { - shift_norm = 32 - WebRtcSpl_NormW32(word32_high); - residual_energy = (int32_t)(sum64 >> shift_norm); - } else { - if((word32_low & 0x80000000) != 0) { - shift_norm = 1; - residual_energy = (uint32_t)word32_low >> 1; - } else { - shift_norm = WebRtcSpl_NormW32(word32_low); - residual_energy = word32_low << shift_norm; - shift_norm = -shift_norm; - } - } - - /* Q(q_val_polynomial * 2) * Q(q_val_corr) >> shift_internal >> shift_norm - * = Q(q_val_corr - shift_internal - shift_norm + q_val_polynomial * 2) - */ - *q_val_residual_energy = q_val_corr - shift_internal - shift_norm - + q_val_polynomial * 2; - - return residual_energy; -} - -void WebRtcIsacfix_GetLpcCoef(WebRtc_Word16 *inLoQ0, - WebRtc_Word16 *inHiQ0, - MaskFiltstr_enc *maskdata, - WebRtc_Word16 snrQ10, - const WebRtc_Word16 *pitchGains_Q12, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *lo_coeffQ15, - WebRtc_Word16 *hi_coeffQ15) -{ - int k, n, ii; - int pos1, pos2; - int sh_lo, sh_hi, sh, ssh, shMem; - WebRtc_Word16 varscaleQ14; - - WebRtc_Word16 tmpQQlo, tmpQQhi; - WebRtc_Word32 tmp32; - WebRtc_Word16 tmp16,tmp16b; - - WebRtc_Word16 polyHI[ORDERHI+1]; - WebRtc_Word16 rcQ15_lo[ORDERLO], rcQ15_hi[ORDERHI]; - - - WebRtc_Word16 DataLoQ6[WINLEN], DataHiQ6[WINLEN]; - WebRtc_Word32 corrloQQ[ORDERLO+2]; - WebRtc_Word32 corrhiQQ[ORDERHI+1]; - WebRtc_Word32 corrlo2QQ[ORDERLO+1]; - WebRtc_Word16 scale; - WebRtc_Word16 QdomLO, QdomHI, newQdomHI, newQdomLO; - - WebRtc_Word32 res_nrgQQ; - WebRtc_Word32 sqrt_nrg; - - /* less-noise-at-low-frequencies factor */ - WebRtc_Word16 aaQ14; - - /* Multiplication with 1/sqrt(12) ~= 0.28901734104046 can be done by convertion to - Q15, i.e. round(0.28901734104046*32768) = 9471, and use 9471/32768.0 ~= 0.289032 - */ - WebRtc_Word16 snrq; - int shft; - - WebRtc_Word16 tmp16a; - WebRtc_Word32 tmp32a, tmp32b, tmp32c; - - WebRtc_Word16 a_LOQ11[ORDERLO+1]; - WebRtc_Word16 k_vecloQ15[ORDERLO]; - WebRtc_Word16 a_HIQ12[ORDERHI+1]; - WebRtc_Word16 k_vechiQ15[ORDERHI]; - - WebRtc_Word16 stab; - - snrq=snrQ10; - - /* SNR= C * 2 ^ (D * snrq) ; C=0.289, D=0.05*log2(10)=0.166 (~=172 in Q10)*/ - tmp16 = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT(snrq, 172, 10); // Q10 - tmp16b = exp2_Q10_T(tmp16); // Q10 - snrq = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT(tmp16b, 285, 10); // Q10 - - /* change quallevel depending on pitch gains and level fluctuations */ - WebRtcIsacfix_GetVars(inLoQ0, pitchGains_Q12, &(maskdata->OldEnergy), &varscaleQ14); - - /* less-noise-at-low-frequencies factor */ - /* Calculation of 0.35 * (0.5 + 0.5 * varscale) in fixpoint: - With 0.35 in Q16 (0.35 ~= 22938/65536.0 = 0.3500061) and varscaleQ14 in Q14, - we get Q16*Q14>>16 = Q14 - */ - aaQ14 = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32( - (WEBRTC_SPL_MUL_16_16(22938, (8192 + WEBRTC_SPL_RSHIFT_W32(varscaleQ14, 1))) - + ((WebRtc_Word32)32768)), 16); - - /* Calculate tmp = (1.0 + aa*aa); in Q12 */ - tmp16 = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT(aaQ14, aaQ14, 15); //Q14*Q14>>15 = Q13 - tmpQQlo = 4096 + WEBRTC_SPL_RSHIFT_W16(tmp16, 1); // Q12 + Q13>>1 = Q12 - - /* Calculate tmp = (1.0+aa) * (1.0+aa); */ - tmp16 = 8192 + WEBRTC_SPL_RSHIFT_W16(aaQ14, 1); // 1+a in Q13 - tmpQQhi = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT(tmp16, tmp16, 14); //Q13*Q13>>14 = Q12 - - /* replace data in buffer by new look-ahead data */ - for (pos1 = 0; pos1 < QLOOKAHEAD; pos1++) { - maskdata->DataBufferLoQ0[pos1 + WINLEN - QLOOKAHEAD] = inLoQ0[pos1]; - } - - for (k = 0; k < SUBFRAMES; k++) { - - /* Update input buffer and multiply signal with window */ - for (pos1 = 0; pos1 < WINLEN - UPDATE/2; pos1++) { - maskdata->DataBufferLoQ0[pos1] = maskdata->DataBufferLoQ0[pos1 + UPDATE/2]; - maskdata->DataBufferHiQ0[pos1] = maskdata->DataBufferHiQ0[pos1 + UPDATE/2]; - DataLoQ6[pos1] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT( - maskdata->DataBufferLoQ0[pos1], kWindowAutocorr[pos1], 15); // Q0*Q21>>15 = Q6 - DataHiQ6[pos1] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT( - maskdata->DataBufferHiQ0[pos1], kWindowAutocorr[pos1], 15); // Q0*Q21>>15 = Q6 - } - pos2 = (WebRtc_Word16)(WEBRTC_SPL_MUL_16_16(k, UPDATE)/2); - for (n = 0; n < UPDATE/2; n++, pos1++) { - maskdata->DataBufferLoQ0[pos1] = inLoQ0[QLOOKAHEAD + pos2]; - maskdata->DataBufferHiQ0[pos1] = inHiQ0[pos2++]; - DataLoQ6[pos1] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT( - maskdata->DataBufferLoQ0[pos1], kWindowAutocorr[pos1], 15); // Q0*Q21>>15 = Q6 - DataHiQ6[pos1] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT( - maskdata->DataBufferHiQ0[pos1], kWindowAutocorr[pos1], 15); // Q0*Q21>>15 = Q6 - } - - /* Get correlation coefficients */ - /* The highest absolute value measured inside DataLo in the test set - For DataHi, corresponding value was 160. - - This means that it should be possible to represent the input values - to WebRtcSpl_AutoCorrelation() as Q6 values (since 307*2^6 = - 19648). Of course, Q0 will also work, but due to the low energy in - DataLo and DataHi, the outputted autocorrelation will be more accurate - and mimic the floating point code better, by being in an high as possible - Q-domain. - */ - - WebRtcIsacfix_AutocorrFix(corrloQQ,DataLoQ6,WINLEN, ORDERLO+1, &scale); - QdomLO = 12-scale; // QdomLO is the Q-domain of corrloQQ - sh_lo = WebRtcSpl_NormW32(corrloQQ[0]); - QdomLO += sh_lo; - for (ii=0; ii<ORDERLO+2; ii++) { - corrloQQ[ii] = WEBRTC_SPL_LSHIFT_W32(corrloQQ[ii], sh_lo); - } - /* It is investigated whether it was possible to use 16 bits for the - 32-bit vector corrloQQ, but it didn't work. */ - - WebRtcIsacfix_AutocorrFix(corrhiQQ,DataHiQ6,WINLEN, ORDERHI, &scale); - - QdomHI = 12-scale; // QdomHI is the Q-domain of corrhiQQ - sh_hi = WebRtcSpl_NormW32(corrhiQQ[0]); - QdomHI += sh_hi; - for (ii=0; ii<ORDERHI+1; ii++) { - corrhiQQ[ii] = WEBRTC_SPL_LSHIFT_W32(corrhiQQ[ii], sh_hi); - } - - /* less noise for lower frequencies, by filtering/scaling autocorrelation sequences */ - - /* Calculate corrlo2[0] = tmpQQlo * corrlo[0] - 2.0*tmpQQlo * corrlo[1];*/ - corrlo2QQ[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQlo, corrloQQ[0]), 1)- // Q(12+QdomLO-16)>>1 = Q(QdomLO-5) - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(aaQ14, corrloQQ[1]), 2); // 2*Q(14+QdomLO-16)>>3 = Q(QdomLO-2)>>2 = Q(QdomLO-5) - - /* Calculate corrlo2[n] = tmpQQlo * corrlo[n] - tmpQQlo * (corrlo[n-1] + corrlo[n+1]);*/ - for (n = 1; n <= ORDERLO; n++) { - - tmp32 = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n-1], 1) + WEBRTC_SPL_RSHIFT_W32(corrloQQ[n+1], 1); // Q(QdomLO-1) - corrlo2QQ[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQlo, corrloQQ[n]), 1)- // Q(12+QdomLO-16)>>1 = Q(QdomLO-5) - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(aaQ14, tmp32), 2); // Q(14+QdomLO-1-16)>>2 = Q(QdomLO-3)>>2 = Q(QdomLO-5) - - } - QdomLO -= 5; - - /* Calculate corrhi[n] = tmpQQhi * corrhi[n]; */ - for (n = 0; n <= ORDERHI; n++) { - corrhiQQ[n] = WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQhi, corrhiQQ[n]); // Q(12+QdomHI-16) = Q(QdomHI-4) - } - QdomHI -= 4; - - /* add white noise floor */ - /* corrlo2QQ is in Q(QdomLO) and corrhiQQ is in Q(QdomHI) */ - /* Calculate corrlo2[0] += 9.5367431640625e-7; and - corrhi[0] += 9.5367431640625e-7, where the constant is 1/2^20 */ - - tmp32 = WEBRTC_SPL_SHIFT_W32((WebRtc_Word32) 1, QdomLO-20); - corrlo2QQ[0] += tmp32; - tmp32 = WEBRTC_SPL_SHIFT_W32((WebRtc_Word32) 1, QdomHI-20); - corrhiQQ[0] += tmp32; - - /* corrlo2QQ is in Q(QdomLO) and corrhiQQ is in Q(QdomHI) before the following - code segment, where we want to make sure we get a 1-bit margin */ - for (n = 0; n <= ORDERLO; n++) { - corrlo2QQ[n] = WEBRTC_SPL_RSHIFT_W32(corrlo2QQ[n], 1); // Make sure we have a 1-bit margin - } - QdomLO -= 1; // Now, corrlo2QQ is in Q(QdomLO), with a 1-bit margin - - for (n = 0; n <= ORDERHI; n++) { - corrhiQQ[n] = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], 1); // Make sure we have a 1-bit margin - } - QdomHI -= 1; // Now, corrhiQQ is in Q(QdomHI), with a 1-bit margin - - - newQdomLO = QdomLO; - - for (n = 0; n <= ORDERLO; n++) { - WebRtc_Word32 tmp, tmpB, tmpCorr; - WebRtc_Word16 alpha=328; //0.01 in Q15 - WebRtc_Word16 beta=324; //(1-0.01)*0.01=0.0099 in Q15 - WebRtc_Word16 gamma=32440; //(1-0.01)=0.99 in Q15 - - if (maskdata->CorrBufLoQQ[n] != 0) { - shMem=WebRtcSpl_NormW32(maskdata->CorrBufLoQQ[n]); - sh = QdomLO - maskdata->CorrBufLoQdom[n]; - if (sh<=shMem) { - tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufLoQQ[n], sh); // Get CorrBufLoQQ to same domain as corrlo2 - tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha, tmp); - } else if ((sh-shMem)<7){ - tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufLoQQ[n], shMem); // Shift up CorrBufLoQQ as much as possible - tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, (sh-shMem)), tmp); // Shift alpha the number of times required to get tmp in QdomLO - } else { - tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufLoQQ[n], shMem); // Shift up CorrBufHiQQ as much as possible - tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, 6), tmp); // Shift alpha as much as possible without overflow the number of times required to get tmp in QdomHI - tmpCorr = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n], sh-shMem-6); - tmp = tmp + tmpCorr; - maskdata->CorrBufLoQQ[n] = tmp; - newQdomLO = QdomLO-(sh-shMem-6); - maskdata->CorrBufLoQdom[n] = newQdomLO; - } - } else - tmp = 0; - - tmp = tmp + corrlo2QQ[n]; - - maskdata->CorrBufLoQQ[n] = tmp; - maskdata->CorrBufLoQdom[n] = QdomLO; - - tmp=WEBRTC_SPL_MUL_16_32_RSFT15(beta, tmp); - tmpB=WEBRTC_SPL_MUL_16_32_RSFT15(gamma, corrlo2QQ[n]); - corrlo2QQ[n] = tmp + tmpB; - } - if( newQdomLO!=QdomLO) { - for (n = 0; n <= ORDERLO; n++) { - if (maskdata->CorrBufLoQdom[n] != newQdomLO) - corrloQQ[n] = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n], maskdata->CorrBufLoQdom[n]-newQdomLO); - } - QdomLO = newQdomLO; - } - - - newQdomHI = QdomHI; - - for (n = 0; n <= ORDERHI; n++) { - WebRtc_Word32 tmp, tmpB, tmpCorr; - WebRtc_Word16 alpha=328; //0.01 in Q15 - WebRtc_Word16 beta=324; //(1-0.01)*0.01=0.0099 in Q15 - WebRtc_Word16 gamma=32440; //(1-0.01)=0.99 in Q1 - if (maskdata->CorrBufHiQQ[n] != 0) { - shMem=WebRtcSpl_NormW32(maskdata->CorrBufHiQQ[n]); - sh = QdomHI - maskdata->CorrBufHiQdom[n]; - if (sh<=shMem) { - tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufHiQQ[n], sh); // Get CorrBufHiQQ to same domain as corrhi - tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha, tmp); - tmpCorr = corrhiQQ[n]; - tmp = tmp + tmpCorr; - maskdata->CorrBufHiQQ[n] = tmp; - maskdata->CorrBufHiQdom[n] = QdomHI; - } else if ((sh-shMem)<7) { - tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufHiQQ[n], shMem); // Shift up CorrBufHiQQ as much as possible - tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, (sh-shMem)), tmp); // Shift alpha the number of times required to get tmp in QdomHI - tmpCorr = corrhiQQ[n]; - tmp = tmp + tmpCorr; - maskdata->CorrBufHiQQ[n] = tmp; - maskdata->CorrBufHiQdom[n] = QdomHI; - } else { - tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufHiQQ[n], shMem); // Shift up CorrBufHiQQ as much as possible - tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, 6), tmp); // Shift alpha as much as possible without overflow the number of times required to get tmp in QdomHI - tmpCorr = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], sh-shMem-6); - tmp = tmp + tmpCorr; - maskdata->CorrBufHiQQ[n] = tmp; - newQdomHI = QdomHI-(sh-shMem-6); - maskdata->CorrBufHiQdom[n] = newQdomHI; - } - } else { - tmp = corrhiQQ[n]; - tmpCorr = tmp; - maskdata->CorrBufHiQQ[n] = tmp; - maskdata->CorrBufHiQdom[n] = QdomHI; - } - - tmp=WEBRTC_SPL_MUL_16_32_RSFT15(beta, tmp); - tmpB=WEBRTC_SPL_MUL_16_32_RSFT15(gamma, tmpCorr); - corrhiQQ[n] = tmp + tmpB; - } - - if( newQdomHI!=QdomHI) { - for (n = 0; n <= ORDERHI; n++) { - if (maskdata->CorrBufHiQdom[n] != newQdomHI) - corrhiQQ[n] = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], maskdata->CorrBufHiQdom[n]-newQdomHI); - } - QdomHI = newQdomHI; - } - - stab=WebRtcSpl_LevinsonW32_JSK(corrlo2QQ, a_LOQ11, k_vecloQ15, ORDERLO); - - if (stab<0) { // If unstable use lower order - a_LOQ11[0]=2048; - for (n = 1; n <= ORDERLO; n++) { - a_LOQ11[n]=0; - } - - stab=WebRtcSpl_LevinsonW32_JSK(corrlo2QQ, a_LOQ11, k_vecloQ15, 8); - } - - - WebRtcSpl_LevinsonDurbin(corrhiQQ, a_HIQ12, k_vechiQ15, ORDERHI); - - /* bandwidth expansion */ - for (n = 1; n <= ORDERLO; n++) { - a_LOQ11[n] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(kPolyVecLo[n-1], a_LOQ11[n]); - } - - - polyHI[0] = a_HIQ12[0]; - for (n = 1; n <= ORDERHI; n++) { - a_HIQ12[n] = (WebRtc_Word16) WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(kPolyVecHi[n-1], a_HIQ12[n]); - polyHI[n] = a_HIQ12[n]; - } - - /* Normalize the corrlo2 vector */ - sh = WebRtcSpl_NormW32(corrlo2QQ[0]); - for (n = 0; n <= ORDERLO; n++) { - corrlo2QQ[n] = WEBRTC_SPL_LSHIFT_W32(corrlo2QQ[n], sh); - } - QdomLO += sh; /* Now, corrlo2QQ is still in Q(QdomLO) */ - - - /* residual energy */ - - sh_lo = 31; - res_nrgQQ = WebRtcIsacfix_CalculateResidualEnergy(ORDERLO, QdomLO, - kShiftLowerBand, a_LOQ11, corrlo2QQ, &sh_lo); - - /* Convert to reflection coefficients */ - WebRtcSpl_AToK_JSK(a_LOQ11, ORDERLO, rcQ15_lo); - - if (sh_lo & 0x0001) { - res_nrgQQ=WEBRTC_SPL_RSHIFT_W32(res_nrgQQ, 1); - sh_lo-=1; - } - - - if( res_nrgQQ > 0 ) - { - sqrt_nrg=WebRtcSpl_Sqrt(res_nrgQQ); - - /* add hearing threshold and compute the gain */ - /* lo_coeff = varscale * S_N_R / (sqrt_nrg + varscale * H_T_H); */ - - - //tmp32a=WEBRTC_SPL_MUL_16_16_RSFT(varscaleQ14, H_T_HQ19, 17); // Q14 - tmp32a=WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32) varscaleQ14,1); // H_T_HQ19=65536 (16-17=-1) ssh= WEBRTC_SPL_RSHIFT_W16(sh_lo, 1); // sqrt_nrg is in Qssh - ssh= WEBRTC_SPL_RSHIFT_W16(sh_lo, 1); // sqrt_nrg is in Qssh - sh = ssh - 14; - tmp32b = WEBRTC_SPL_SHIFT_W32(tmp32a, sh); // Q14->Qssh - tmp32c = sqrt_nrg + tmp32b; // Qssh (denominator) - tmp32a = WEBRTC_SPL_MUL_16_16_RSFT(varscaleQ14, snrq, 0); //Q24 (numerator) - - sh = WebRtcSpl_NormW32(tmp32c); - shft = 16 - sh; - tmp16a = (WebRtc_Word16) WEBRTC_SPL_SHIFT_W32(tmp32c, -shft); // Q(ssh-shft) (denominator) - - tmp32b = WebRtcSpl_DivW32W16(tmp32a, tmp16a); // Q(24-ssh+shft) - sh = ssh-shft-7; - *gain_lo_hiQ17 = WEBRTC_SPL_SHIFT_W32(tmp32b, sh); // Gains in Q17 - } - else - { - *gain_lo_hiQ17 = 100; //(WebRtc_Word32)WEBRTC_SPL_LSHIFT_W32( (WebRtc_Word32)1, 17); // Gains in Q17 - } - gain_lo_hiQ17++; - - /* copy coefficients to output array */ - for (n = 0; n < ORDERLO; n++) { - *lo_coeffQ15 = (WebRtc_Word16) (rcQ15_lo[n]); - lo_coeffQ15++; - } - /* residual energy */ - sh_hi = 31; - res_nrgQQ = WebRtcIsacfix_CalculateResidualEnergy(ORDERHI, QdomHI, - kShiftHigherBand, a_HIQ12, corrhiQQ, &sh_hi); - - /* Convert to reflection coefficients */ - WebRtcSpl_LpcToReflCoef(polyHI, ORDERHI, rcQ15_hi); - - if (sh_hi & 0x0001) { - res_nrgQQ=WEBRTC_SPL_RSHIFT_W32(res_nrgQQ, 1); - sh_hi-=1; - } - - - if( res_nrgQQ > 0 ) - { - sqrt_nrg=WebRtcSpl_Sqrt(res_nrgQQ); - - - /* add hearing threshold and compute the gain */ - /* hi_coeff = varscale * S_N_R / (sqrt_nrg + varscale * H_T_H); */ - - //tmp32a=WEBRTC_SPL_MUL_16_16_RSFT(varscaleQ14, H_T_HQ19, 17); // Q14 - tmp32a=WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32) varscaleQ14,1); // H_T_HQ19=65536 (16-17=-1) - - ssh= WEBRTC_SPL_RSHIFT_W32(sh_hi, 1); // sqrt_nrg is in Qssh - sh = ssh - 14; - tmp32b = WEBRTC_SPL_SHIFT_W32(tmp32a, sh); // Q14->Qssh - tmp32c = sqrt_nrg + tmp32b; // Qssh (denominator) - tmp32a = WEBRTC_SPL_MUL_16_16_RSFT(varscaleQ14, snrq, 0); //Q24 (numerator) - - sh = WebRtcSpl_NormW32(tmp32c); - shft = 16 - sh; - tmp16a = (WebRtc_Word16) WEBRTC_SPL_SHIFT_W32(tmp32c, -shft); // Q(ssh-shft) (denominator) - - tmp32b = WebRtcSpl_DivW32W16(tmp32a, tmp16a); // Q(24-ssh+shft) - sh = ssh-shft-7; - *gain_lo_hiQ17 = WEBRTC_SPL_SHIFT_W32(tmp32b, sh); // Gains in Q17 - } - else - { - *gain_lo_hiQ17 = 100; //(WebRtc_Word32)WEBRTC_SPL_LSHIFT_W32( (WebRtc_Word32)1, 17); // Gains in Q17 - } - gain_lo_hiQ17++; - - - /* copy coefficients to output array */ - for (n = 0; n < ORDERHI; n++) { - *hi_coeffQ15 = rcQ15_hi[n]; - hi_coeffQ15++; - } - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h b/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h deleted file mode 100644 index e06a207..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_masking_model.h - * - * LPC functions - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_LPC_MASKING_MODEL_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_LPC_MASKING_MODEL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "structs.h" - -void WebRtcIsacfix_GetVars(const WebRtc_Word16 *input, - const WebRtc_Word16 *pitchGains_Q12, - WebRtc_UWord32 *oldEnergy, - WebRtc_Word16 *varscale); - -void WebRtcIsacfix_GetLpcCoef(WebRtc_Word16 *inLoQ0, - WebRtc_Word16 *inHiQ0, - MaskFiltstr_enc *maskdata, - WebRtc_Word16 snrQ10, - const WebRtc_Word16 *pitchGains_Q12, - WebRtc_Word32 *gain_lo_hiQ17, - WebRtc_Word16 *lo_coeffQ15, - WebRtc_Word16 *hi_coeffQ15); - -typedef int32_t (*CalculateResidualEnergy)(int lpc_order, - int32_t q_val_corr, - int q_val_polynomial, - int16_t* a_polynomial, - int32_t* corr_coeffs, - int* q_val_residual_energy); -extern CalculateResidualEnergy WebRtcIsacfix_CalculateResidualEnergy; - -int32_t WebRtcIsacfix_CalculateResidualEnergyC(int lpc_order, - int32_t q_val_corr, - int q_val_polynomial, - int16_t* a_polynomial, - int32_t* corr_coeffs, - int* q_val_residual_energy); - -#if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) -int32_t WebRtcIsacfix_CalculateResidualEnergyNeon(int lpc_order, - int32_t q_val_corr, - int q_val_polynomial, - int16_t* a_polynomial, - int32_t* corr_coeffs, - int* q_val_residual_energy); -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_LPC_MASKING_MODEL_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_neon.S b/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_neon.S deleted file mode 100644 index 20b60d0..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model_neon.S +++ /dev/null
@@ -1,177 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ Contains a function for WebRtcIsacfix_CalculateResidualEnergyNeon() in -@ iSAC codec, optimized for ARM Neon platform. Reference code in -@ lpc_masking_model.c. - -.arch armv7-a -.fpu neon -.global WebRtcIsacfix_CalculateResidualEnergyNeon -.align 2 - -@ int32_t WebRtcIsacfix_CalculateResidualEnergyNeon(int lpc_order, -@ int32_t q_val_corr, -@ int q_val_polynomial, -@ int16_t* a_polynomial, -@ int32_t* corr_coeffs, -@ int* q_val_residual_energy); - -WebRtcIsacfix_CalculateResidualEnergyNeon: -.fnstart -.save {r4-r11} - push {r4-r11} - - sub r13, r13, #16 - str r1, [r13, #8] - str r2, [r13, #12] - - mov r4, #1 - vmov.s64 q11, #0 @ Initialize shift_internal. - vmov.s64 q13, #0 @ Initialize sum64. - vmov.s64 q10, #0 - vmov.u8 d20[0], r4 @ Set q10 to 1. - - cmp r0, #0 - blt POST_LOOP_I - - add r9, r3, r0, asl #1 @ &a_polynomial[lpc_order] - mov r6, #0 @ Loop counter i. - ldr r11, [r13, #48] - sub r10, r0, #1 - mov r7, r3 @ &a_polynomial[0] - str r9, [r13, #4] - -LOOP_I: - ldr r2, [r11], #4 @ corr_coeffs[i] - vmov.s64 q15, #0 @ Initialize the sum64_tmp. - vdup.s32 d25, r2 - - cmp r0, r6 @ Compare lpc_order to i. - movle r2, r6 - ble POST_LOOP_J - - mov r1, r6 @ j = i; - mov r12, r7 @ &a_polynomial[i] - mov r4, r3 @ &a_polynomial[j - i] - -LOOP_J: - ldr r8, [r12], #4 - ldr r5, [r4], #4 - vmov.u32 d0[0], r8 - vmov.u32 d1[0], r5 - vmull.s16 q0, d0, d1 - vmull.s32 q0, d0, d25 - cmp r6, #0 @ i == 0? - vshl.s64 q0, q11 - beq SUM1 - vshl.s64 q0, #1 - -SUM1: - vqadd.s64 q14, q0, q15 @ Sum and test overflow. - add r1, r1, #2 - bvc MOV1 @ Skip the shift if there's no overflow. - vshr.s64 q0, #1 - vshr.s64 q15, #1 - vadd.s64 q14, q0, q15 - vsub.s64 q11, q10 - -MOV1: - cmp r0, r1 @ Compare lpc_order to j. - vmov.s64 q15, q14 - bgt LOOP_J - - bic r1, r10, #1 - add r2, r6, #2 - add r2, r1, r2 - -POST_LOOP_J: - vqadd.s64 q0, q13, q15 @ Sum and test overflow. - bvc MOV2 @ Skip the shift if there's no overflow. - vshr.s64 q13, #1 - vshr.s64 q15, #1 - vadd.s64 q0, q13, q15 - vsub.s64 q11, q10 - -MOV2: - vmov.s64 q13, q0 @ update sum64. - cmp r2, r0 - bne CHECK_LOOP_CONDITION - - @ Last sample in the inner loop. - ldr r4, [r13, #4] - ldrsh r8, [r4] - ldrsh r12, [r9] - mul r8, r8, r12 - vmov.s32 d0[0], r8 - vmull.s32 q0, d0, d25 - cmp r6, #0 @ i == 0? - vshl.s64 q0, q11 - beq SUM2 - vshl.s64 q0, #1 - -SUM2: - vqadd.s64 d1, d0, d26 @ Sum and test overflow. - bvc MOV3 @ Skip the shift if there's no overflow. - vshr.s64 q13, #1 - vshr.s64 d0, #1 - vadd.s64 d1, d0, d26 - vsub.s64 q11, q10 - -MOV3: - vmov.s64 d26, d1 @ update sum64. - -CHECK_LOOP_CONDITION: - add r6, r6, #1 - sub r9, r9, #2 - cmp r0, r6 @ Compare i to lpc_order. - sub r10, r10, #1 - add r7, r7, #2 - bge LOOP_I - -POST_LOOP_I: - mov r3, #0 - vqadd.s64 d0, d26, d27 @ Sum and test overflow. - bvc GET_SHIFT_NORM @ Skip the shift if there's no overflow. - vshr.s64 q13, #1 - vadd.s64 d0, d26, d27 - vsub.s64 q11, q10 - -GET_SHIFT_NORM: - vcls.s32 d1, d0 @ Count leading extra sign bits. - vmov.32 r2, d1[1] @ Store # of sign bits of only the 32 MSBs. - vmovl.s32 q1, d1 - vshl.s64 d0, d3 @ d3 contains # of sign bits of the 32 MSBs. - - vcls.s32 d1, d0 @ Count again the leading extra sign bits. - vmov.s32 r1, d1[1] @ Store # of sign bits of only the 32 MSBs. - vmovl.s32 q1, d1 - vshl.s64 d0, d3 @ d3 contains # of sign bits of the 32 MSBs. - - vmov.s32 r0, d0[1] @ residual_energy - vmov.s32 r3, d22[0] @ shift_internal - - @ Calculate the value for q_val_residual_energy. - ldr r4, [r13, #8] @ q_val_corr - ldr r5, [r13, #12] @ q_val_polynomial - sub r12, r4, #32 - add r12, r12, r5, asl #1 - add r1, r12, r1 @ add 1st part of shift_internal. - add r12, r1, r2 @ add 2nd part of shift_internal. - ldr r2, [r13, #52] - add r3, r12, r3 @ value for q_val_residual_energy. - str r3, [r2, #0] - - add r13, r13, #16 - pop {r4-r11} - bx r14 - -.fnend -
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lpc_tables.c b/src/modules/audio_coding/codecs/isac/fix/source/lpc_tables.c deleted file mode 100644 index 90cc9af..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lpc_tables.c +++ /dev/null
@@ -1,1280 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_tables.c - * - * Coding tables for the KLT coefficients - * - */ - - -#include "settings.h" -#include "lpc_tables.h" - -/* indices of KLT coefficients used */ -const WebRtc_UWord16 WebRtcIsacfix_kSelIndGain[12] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11}; - -const WebRtc_UWord16 WebRtcIsacfix_kSelIndShape[108] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107 -}; - -/* cdf array for model indicator */ -const WebRtc_UWord16 WebRtcIsacfix_kModelCdf[4] = { - 0, 15434, 37548, 65535 -}; - -/* pointer to cdf array for model indicator */ -const WebRtc_UWord16 *WebRtcIsacfix_kModelCdfPtr[1] = { - WebRtcIsacfix_kModelCdf -}; - -/* initial cdf index for decoder of model indicator */ -const WebRtc_UWord16 WebRtcIsacfix_kModelInitIndex[1] = { - 1 -}; - -/* offset to go from rounded value to quantization index */ -const WebRtc_Word16 WebRtcIsacfix_kQuantMinGain[12] ={ - 3, 6, 4, 6, 6, 9, 5, 16, 11, 34, 32, 47 -}; - -const WebRtc_Word16 WebRtcIsacfix_kQuantMinShape[108] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 2, 2, 2, 3, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 2, 2, 3, 0, 0, 0, 0, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 4, 3, 5, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 2, 1, 2, 2, 3, 4, - 4, 7, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 2, 3, 2, 3, 4, 4, 5, 7, 13, - 0, 1, 1, 2, 3, 2, 2, 2, 4, 4, - 5, 6, 7, 11, 9, 13, 12, 26 -}; - -/* maximum quantization index */ -const WebRtc_UWord16 WebRtcIsacfix_kMaxIndGain[12] = { - 6, 12, 8, 14, 10, 19, 12, 31, 22, 56, 52, 138 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kMaxIndShape[108] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 2, 2, 2, 2, 4, 4, 5, 6, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 2, 2, - 2, 2, 3, 4, 5, 7, 0, 0, 0, 0, - 2, 0, 2, 2, 2, 2, 3, 2, 2, 4, - 4, 6, 6, 9, 0, 0, 0, 0, 2, 2, - 2, 2, 2, 2, 3, 2, 4, 4, 7, 7, - 9, 13, 0, 0, 2, 2, 2, 2, 2, 2, - 3, 4, 5, 4, 6, 8, 8, 10, 16, 25, - 0, 2, 2, 4, 5, 4, 4, 4, 7, 8, - 9, 10, 13, 19, 17, 23, 25, 49 -}; - -/* index offset */ -const WebRtc_UWord16 WebRtcIsacfix_kOffsetGain[3][12] = { - { 0, 7, 20, 29, 44, 55, 75, 88, 120, 143, 200, 253}, - { 0, 7, 19, 27, 42, 53, 73, 86, 117, 140, 197, 249}, - { 0, 7, 20, 28, 44, 55, 75, 89, 121, 145, 202, 257} -}; - -const WebRtc_UWord16 WebRtcIsacfix_kOffsetShape[3][108] = { - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 11, 14, 17, 20, 23, 28, 33, 39, 46, 47, - 48, 49, 50, 52, 53, 54, 55, 56, 58, 61, - 64, 67, 70, 74, 79, 85, 93, 94, 95, 96, - 97, 100, 101, 104, 107, 110, 113, 117, 120, 123, - 128, 133, 140, 147, 157, 158, 159, 160, 161, 164, - 167, 170, 173, 176, 179, 183, 186, 191, 196, 204, - 212, 222, 236, 237, 238, 241, 244, 247, 250, 253, - 256, 260, 265, 271, 276, 283, 292, 301, 312, 329, - 355, 356, 359, 362, 367, 373, 378, 383, 388, 396, - 405, 415, 426, 440, 460, 478, 502, 528 - }, - { - 0, 1, 2, 3, 4, 6, 7, 8, 9, 11, - 13, 16, 19, 22, 26, 29, 34, 39, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 55, 57, 60, - 63, 66, 70, 73, 78, 84, 91, 92, 93, 94, - 95, 96, 97, 99, 102, 105, 108, 111, 114, 118, - 123, 128, 134, 141, 151, 152, 153, 154, 156, 159, - 162, 165, 168, 171, 174, 177, 181, 186, 194, 200, - 208, 218, 233, 234, 235, 236, 239, 242, 245, 248, - 251, 254, 258, 263, 270, 277, 288, 297, 308, 324, - 349, 351, 354, 357, 361, 366, 372, 378, 383, 390, - 398, 407, 420, 431, 450, 472, 496, 524 - }, - { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, - 14, 17, 20, 23, 26, 29, 34, 40, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 58, 61, 64, - 67, 70, 73, 77, 82, 88, 96, 97, 98, 99, - 101, 102, 104, 107, 110, 113, 116, 119, 122, 125, - 129, 134, 141, 150, 160, 161, 162, 163, 166, 168, - 171, 174, 177, 180, 183, 186, 190, 195, 201, 208, - 216, 226, 243, 244, 245, 248, 251, 254, 257, 260, - 263, 268, 273, 278, 284, 291, 299, 310, 323, 340, - 366, 368, 371, 374, 379, 383, 389, 394, 399, 406, - 414, 422, 433, 445, 461, 480, 505, 533 - } -}; - -/* initial cdf index for KLT coefficients */ -const WebRtc_UWord16 WebRtcIsacfix_kInitIndexGain[3][12] = { - { 3, 6, 4, 7, 5, 10, 6, 16, 11, 28, 26, 69}, - { 3, 6, 4, 7, 5, 10, 6, 15, 11, 28, 26, 69}, - { 3, 6, 4, 8, 5, 10, 7, 16, 12, 28, 27, 70} -}; - -const WebRtc_UWord16 WebRtcIsacfix_kInitIndexShape[3][108] = { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 2, 2, 3, 3, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 2, 2, 3, 4, 0, 0, 0, 0, - 1, 0, 1, 1, 1, 1, 2, 1, 1, 2, - 2, 3, 3, 5, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 2, 1, 2, 2, 4, 4, - 5, 7, 0, 0, 1, 1, 1, 1, 1, 1, - 2, 2, 3, 2, 3, 4, 4, 5, 8, 13, - 0, 1, 1, 2, 3, 2, 2, 2, 4, 4, - 5, 5, 7, 10, 9, 12, 13, 25 - }, - { - 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, - 1, 1, 1, 2, 1, 2, 2, 3, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 2, 1, 2, 3, 3, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 3, 3, 5, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 2, 4, 3, 4, - 5, 7, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 2, 2, 3, 3, 5, 4, 5, 8, 12, - 1, 1, 1, 2, 2, 3, 3, 2, 3, 4, - 4, 6, 5, 9, 11, 12, 14, 25 - }, - { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 1, 2, 3, 3, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 2, 2, 3, 4, 0, 0, 0, 1, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 3, 4, 5, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, - 5, 8, 0, 0, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 3, 3, 4, 5, 6, 8, 13, - 1, 1, 1, 2, 2, 3, 2, 2, 3, 4, - 4, 5, 6, 8, 9, 12, 14, 25 - } -}; - -/* offsets for quantizer representation levels*/ -const WebRtc_UWord16 WebRtcIsacfix_kOfLevelsGain[3] = { - 0, 392, 779 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kOfLevelsShape[3] = { - 0, 578, 1152 -}; - -/* quantizer representation levels */ - - - -const WebRtc_Word32 WebRtcIsacfix_kLevelsGainQ17[1176] = { - -364547,-231664,-102123,-573,104807,238257,368823,-758583,-640135,-510291 - ,-377662,-252785,-113177,2627,112906,248601,389461,522691,644517,763974 - ,-538963,-368179,-245823,-106095,-890,104299,241111,350730,493190,-800763 - ,-646230,-510239,-382115,-248623,-111829,-2983,113852,251105,388114,519757 - ,644048,774712,896334,1057931,-770009,-635310,-503690,-375087,-248106,-108525 - ,-105,108259,243472,377948,519271,-1160885,-1032044,-914636,-777593,-647891 - ,-518408,-388028,-254321,-115293,-598,117849,251296,385367,515510,652727 - ,777432,920363,1038625,1153637,1316836,-632287,-505430,-379430,-248458,-118013 - ,-888,118762,250266,381650,513327,652169,766471,932113,-2107480,-1971030 - ,-1827020,-1698263,-1558670,-1436314,-1305377,-1172252,-1047355,-914202,-779651,-651001 - ,-520999,-390394,-255761,-123490,-1893,126839,256703,385493,518607,651760 - ,782750,908693,1044131,1163865,1311066,1424177,1582628,1709823,1831740,1955391 - ,-1423044,-1288917,-1181281,-1043222,-911770,-780354,-646799,-522664,-386721,-258266 - ,-128060,-1101,128233,259996,390336,519590,649290,778701,908010,1040796 - ,1161235,1306889,1441882,-4446002,-4301031,-4194304,-4080591,-3947740,-3808975,-3686530 - ,-3567839,-3383251,-3287089,-3136577,-3017405,-2869860,-2751321,-2619984,-2482932,-2354790 - ,-2223147,-2090669,-1964135,-1831208,-1706697,-1570817,-1446008,-1305386,-1175773,-1046066 - ,-915356,-785120,-653614,-524331,-393767,-260442,-130187,-799,128841,261466 - ,393616,520542,652117,784613,914159,1045399,1181072,1308971,1442502,1570346 - ,1693912,1843986,1966014,2090474,2224869,2364593,2475934,2628403,2752512,2856640 - ,-4192441,-4063232,-3917821,-3799195,-3666233,-3519199,-3411021,-3269192,-3135684,-3008826 - ,-2880875,-2747342,-2620981,-2494872,-2354979,-2229718,-2098939,-1964971,-1835399,-1703452 - ,-1572806,-1440482,-1311794,-1179338,-1046521,-919823,-785914,-655335,-523416,-395507 - ,-264833,-132184,-2546,131698,256217,391372,522688,651248,789964,909618 - ,1035305,1179145,1313824,1436934,1552353,1693722,1815508,1972826,2096328,2228224 - ,2359296,2490368,2598848,-6160384,-6029312,-5881382,-5767168,-5636096,-5505024,-5373952 - ,-5228418,-5110384,-4954923,-4880576,-4710990,-4587364,-4471340,-4333905,-4211513,-4051293 - ,-3907927,-3800105,-3675961,-3538640,-3413663,-3271148,-3152105,-3019103,-2869647,-2744015 - ,-2620639,-2479385,-2364211,-2227611,-2095427,-1974497,-1834168,-1703561,-1568961,-1439826 - ,-1309192,-1174050,-1050191,-917836,-786015,-656943,-518934,-394831,-257708,-128041 - ,1610,128991,264442,393977,521383,653849,788164,918641,1049122,1181971 - ,1308934,1439505,1571808,1706305,1836318,1966235,2097269,2228990,2357005,2490292 - ,2617400,2749680,2881234,3014880,3145637,3276467,3409099,3536637,3671493,3802918 - ,3929740,4065036,4194143,4325999,4456126,4586857,4717194,4843923,4978676,5110913 - ,5245281,5371394,5499780,5633779,5762611,5897682,6028688,6167546,6296465,6421682 - ,6548882,6682074,6809432,6941956,7078143,7204509,7334296,7475137,7609896,7732044 - ,7861604,8002039,8131670,8259222,8390299,8522399,8650037,8782348,8908402,9037815 - ,9164594,9300338,9434679,9574500,9699702,9833934,9948152,10083972,10244937,10332822 - ,10485760,10600122,10760754,10892964,11010048,11111004,11272192,11403264,11525091,11624984 - ,11796480,11915146,-393216,-262144,-101702,-740,100568,262144,393216,-786432 - ,-655360,-524288,-383907,-243301,-94956,-156,95547,269629,416691,524288 - ,655360,-393216,-262144,-88448,-37,87318,262144,393216,524288,-917504 - ,-786432,-655360,-495894,-373308,-267503,-93211,4119,91308,250895,393216 - ,526138,655360,786432,917504,-786432,-655360,-524288,-393216,-262144,-83497 - ,222,86893,240922,393216,524288,-1048576,-917504,-790472,-655360,-508639 - ,-383609,-262016,-95550,-3775,96692,256797,364847,534906,655360,786432 - ,889679,1048576,1179648,1310720,1441792,-655360,-524288,-377684,-248408,-93690 - ,1261,95441,227519,393216,524288,655360,786432,917504,-2097152,-1966080 - ,-1809470,-1703936,-1572864,-1441792,-1314289,-1195149,-1056205,-917504,-809951,-657769 - ,-521072,-383788,-248747,-106350,-2944,105550,243408,388548,521064,628732 - ,786432,885456,1064548,1179648,1310720,1441792,1572864,1703936,1835008,-1441792 - ,-1310720,-1179648,-1037570,-888492,-767774,-646634,-519935,-373458,-248029,-111915 - ,760,111232,247735,379432,507672,672699,786432,917504,1048576,1179648 - ,1310720,1441792,-4456448,-4325376,-4194304,-4063232,-3932160,-3801088,-3670016,-3538944 - ,-3407872,-3276800,-3145728,-3014656,-2883584,-2752512,-2647002,-2490368,-2359296,-2228224 - ,-2097152,-1951753,-1835008,-1703936,-1594177,-1462001,-1289150,-1160774,-1025917,-924928 - ,-782509,-641294,-516191,-386630,-251910,-118886,5210,121226,253949,386008 - ,517973,649374,780064,917783,1052462,1183856,1290593,1419389,1556641,1699884 - ,1835008,1988314,2090470,2228224,2359296,2490368,2621440,2752512,2883584,-3801088 - ,-3643514,-3539937,-3409931,-3263294,-3145658,-3012952,-2879230,-2752359,-2622556,-2483471 - ,-2357556,-2226500,-2093112,-1965892,-1833664,-1701035,-1567767,-1440320,-1310556,-1178339 - ,-1049625,-916812,-786477,-655277,-525050,-393773,-264828,-130696,-480,132126 - ,260116,394197,527846,652294,785563,917183,1049511,1175958,1308161,1438759 - ,1572253,1698835,1828535,1967072,2089391,2212798,2348901,2461547,2621440,2752512 - ,2883584,-7309870,-7203780,-7062699,-6939106,-6790819,-6672036,-6553600,-6422317,-6288422 - ,-6164694,-6026456,-5901410,-5754168,-5621459,-5502710,-5369686,-5240454,-5120712,-4976140 - ,-4847970,-4723070,-4589083,-4450923,-4324680,-4189892,-4065551,-3931803,-3800209,-3668539 - ,-3539395,-3404801,-3277470,-3141389,-3016710,-2885724,-2752612,-2618541,-2486762,-2354153 - ,-2225059,-2094984,-1968194,-1830895,-1699508,-1575743,-1444516,-1308683,-1179714,-1053088 - ,-917981,-783707,-653900,-524980,-395409,-260309,-131948,-3452,132113,263241 - ,392185,522597,654134,788288,919810,1045795,1179210,1314201,1444235,1574447 - ,1705193,1834009,1967332,2098102,2229019,2359147,2489859,2619878,2754966,2879671 - ,3014438,3146143,3276733,3405958,3542196,3667493,3798815,3932961,4062458,4187125 - ,4322346,4454875,4587752,4716809,4848274,4975027,5111957,5242215,5373085,5501158 - ,5640140,5762918,5895358,6024008,6157906,6290628,6422713,6546339,6675888,6815606 - ,6955288,7077501,7211630,7337893,7473635,7607175,7728310,7866475,7999658,8127888 - ,8241758,8386483,8522550,8641582,8771915,8922139,9038632,9179385,9313426,9437184 - ,9568256,9699328,9830400,9952933,10120004,10223616,10354688,10474645,10616832,-393216 - ,-262144,-85425,-121,82533,262144,393216,-786432,-655360,-524288,-379928 - ,-222821,-95200,287,95541,227093,393216,493567,655360,786432,-393216 - ,-262144,-86805,510,86722,262144,393216,524288,-1048576,-917504,-786432 - ,-624456,-529951,-395071,-241627,-101168,81,99975,241605,393216,524288 - ,655360,786432,917504,-786432,-655360,-524288,-393216,-230359,-95619,-137 - ,94425,226222,393216,524288,-1179648,-1048576,-917504,-773841,-655360,-492258 - ,-379715,-244707,-103621,-434,104523,242680,381575,523659,650565,786432 - ,917504,1048576,1179648,1310720,-786432,-629344,-524288,-376757,-242858,-101932 - ,-2715,107155,239212,366480,514943,655360,786432,917504,-2228224,-2097152 - ,-1966080,-1835008,-1703936,-1572864,-1441792,-1284584,-1179648,-1048819,-934658,-777181 - ,-626371,-515660,-377493,-248975,-113036,436,113584,248354,379718,512475 - ,653932,796494,917504,1048576,1179648,1310720,1441792,1572864,1703936,1835008 - ,-1572864,-1441792,-1297608,-1161159,-1032316,-917092,-779770,-647384,-515529,-384269 - ,-250003,-119252,1053,118111,249512,380545,512039,648101,770656,907003 - ,1021725,1178082,1310720,1441792,-4587520,-4456448,-4325376,-4194304,-4063232,-3932160 - ,-3801088,-3670016,-3538944,-3407872,-3276800,-3145728,-2999335,-2883584,-2752512,-2621440 - ,-2490368,-2359296,-2228224,-2112691,-1966080,-1848781,-1709830,-1566109,-1438427,-1303530 - ,-1176124,-1040936,-913876,-784585,-652025,-518361,-385267,-256342,-127297,-2733 - ,125422,257792,389363,519911,651106,783805,909407,1044143,1174156,1309267 - ,1436173,1553771,1708958,1814083,1967036,2095386,2255169,2359296,2478303,2621440 - ,2752512,-4456448,-4325376,-4194304,-4063232,-3932160,-3797524,-3670016,-3560250,-3413217 - ,-3257719,-3166416,-2986626,-2878000,-2781144,-2625383,-2495465,-2346792,-2230930,-2077063 - ,-1949225,-1819274,-1697261,-1568664,-1443074,-1304302,-1175289,-1043794,-913423,-785561 - ,-652104,-522835,-392667,-260517,-130088,-2,129509,260990,391931,522470 - ,655770,784902,917093,1046445,1176951,1303121,1441362,1565401,1702022,1822856 - ,1952852,2090384,2214607,2338436,2457483,2621440,-8781824,-8650752,-8519680,-8388608 - ,-8260828,-8126464,-8003337,-7859030,-7750057,-7602176,-7471104,-7340032,-7193045,-7090588 - ,-6946816,-6843344,-6676635,-6557575,-6447804,-6277614,-6159736,-6035729,-5884723,-5739567 - ,-5634818,-5489867,-5372864,-5243300,-5098939,-4988639,-4856258,-4728494,-4591717,-4447428 - ,-4322409,-4192918,-4062638,-3934141,-3797545,-3673373,-3531587,-3407391,-3277404,-3147797 - ,-3013578,-2886548,-2749811,-2616428,-2490949,-2361301,-2228482,-2096883,-1964343,-1831754 - ,-1702201,-1572495,-1442012,-1309242,-1182451,-1048996,-916905,-786510,-657079,-524730 - ,-393672,-261313,-128743,166,130678,261334,393287,524155,655570,786839 - ,917353,1052167,1179013,1309360,1442634,1571153,1703961,1832027,1965014,2097912 - ,2224861,2355341,2490455,2623051,2753484,2877015,3015783,3144157,3273705,3405255 - ,3542006,3669580,3802417,3935413,4065088,4190896,4333521,4456355,4579781,4713832 - ,4845707,4978625,5113278,5243817,5382318,5500592,5638135,5761179,5900822,6029270 - ,6186398,6297816,6436435,6559163,6666389,6806548,6950461,7086078,7195777,7350973 - ,7480132,7614852,7743514,7847288,8014762,8126464,8257536,8388608,8519680,8650752 - ,8781824,8912896,9043968,9175040,9306112,9437184 -}; - - - -const WebRtc_Word16 WebRtcIsacfix_kLevelsShapeQ10[1735] = { - 0, 0, -1, 0, 0, 1, 0, 1, 0, -821 - , 1, -763, -1, 656, -620, 0, 633, -636, 4, 615 - , -630, 1, 649, -1773, -670, 5, 678, 1810, -1876, -676 - , 0, 691, 1843, -1806, -743, -1, 749, 1795, 2920, -2872 - , -1761, -772, -3, 790, 1763, 2942, 0, 0, 0, 0 - , -792, 2, 0, 0, 1, 0, -854, 0, -702, -1 - , 662, -624, -5, 638, -611, -6, 638, -647, 0, 651 - , -685, -4, 679, 2123, -1814, -693, 0, 664, 1791, -1735 - , -737, 0, 771, 1854, 2873, -2867, -1842, -793, -1, 821 - , 1826, 2805, 3922, 0, 0, 0, -1, -779, 1, 786 - , 1, -708, 0, 789, -799, 1, 797, -663, 2, 646 - , -600, 3, 609, -600, 1, 658, 1807, -627, -3, 612 - , -625, 3, 632, -1732, -674, 1, 672, 2048, -1768, -715 - , 0, 724, 1784, -3881, -3072, -1774, -719, -1, 730, 1811 - , -2963, -1829, -806, -1, 816, 1795, 3050, -5389, -3784, -2942 - , -1893, -865, -12, 867, 1885, 2945, 3928, -2, 1, 4 - , 0, -694, 2, 665, -598, 5, 587, -599, -1, 661 - , -656, -7, 611, -607, 5, 603, -618, -4, 620, -1794 - , -645, -2, 654, -655, -1, 658, -1801, -700, 5, 707 - , 1927, -1752, -745, -8, 752, 1843, -2838, -1781, -801, 11 - , 796, 1811, 2942, 3866, -3849, -3026, -1848, -819, 2, 827 - , 1825, 2963, -3873, -2904, -1869, -910, -6, 903, 1902, 2885 - , 3978, 5286, -7168, -6081, -4989, -3968, -2963, -1970, -943, -2 - , 953, 1951, 2968, 3974, 5009, 6032, -2, 3, -1024, 2 - , 1024, -637, 1, 669, -613, -7, 630, -603, 4, 612 - , -612, 0, 590, -645, -11, 627, -657, -2, 671, 1849 - , -1853, -694, 2, 702, 1838, -3304, -1780, -736, -8, 732 - , 1772, -1709, -755, -6, 760, 1780, -2994, -1780, -800, 8 - , 819, 1830, 2816, -4096, -2822, -1881, -851, -4, 855, 1872 - , 2840, 3899, -3908, -2904, -1878, -887, 6, 897, 1872, 2942 - , 4008, -4992, -3881, -2933, -1915, -928, 1, 937, 1919, 2900 - , 4009, 4881, -6848, -6157, -5065, -3981, -2983, -1972, -978, -1 - , 968, 1979, 2988, 4008, 5007, 6108, 7003, 8051, 9027,-13272 - ,-12012,-11228,-10213, -9261, -8084, -7133, -6075, -5052, -4050, -3036 - , -2014, -996, -4, 1007, 2031, 3038, 4049, 5074, 6134, 7069 - , 8094, 9069, 10212, 11049, 12104, 51, -1024, -13, 1024, -609 - , -107, 613, -2048, -687, -95, 667, 2048, -3072, -1724, -785 - , -34, 732, 1819, -2048, -703, -26, 681, 2048, -2048, -686 - , -9, 665, 2048, -2048, -702, 37, 748, 1723, -4096, -2786 - , -1844, -837, 37, 811, 1742, 3072, -4096, -2783, -1848, -881 - , 39, 898, 1843, 2792, 3764, -5120, -4096, -2923, -1833, -852 - , -14, 862, 1824, 2834, 4096, -6144, -5120, -3914, -2842, -1870 - , -886, -27, 888, 1929, 2931, 4051, -7168, -6144, -5120, -3866 - , -2933, -1915, -927, 64, 933, 1902, 2929, 3912, 5063, 6144 - ,-11264,-10240, -9216, -8192, -7086, -6144, -5039, -3972, -2943, -1929 - , -941, 3, 938, 1942, 2959, 3933, 4905, 6088, 6983, 8192 - , -9216, -8192, -7202, -6088, -4983, -4019, -2955, -1975, -966, 17 - , 997, 1981, 2967, 3990, 4948, 6022, 6967, 8192,-13312,-12288 - ,-11264,-10240, -9216, -8049, -6997, -6040, -5026, -4043, -3029, -2034 - , -1015, -23, 984, 1997, 3010, 4038, 5002, 6015, 6946, 8061 - , 9216, 10240,-12381,-11264,-10240, -9060, -8058, -7153, -6085, -5075 - , -4051, -3042, -2037, -1017, -5, 1007, 2028, 3035, 4050, 5088 - , 6111, 7160, 8156, 9215, 10095, 11229, 12202, 13016,-26624,-25600 - ,-24582,-23671,-22674,-21400,-20355,-19508,-18315,-17269,-16361,-15299 - ,-14363,-13294,-12262,-11237,-10203, -9227, -8165, -7156, -6116, -5122 - , -4076, -3056, -2043, -1020, -8, 1027, 2047, 3065, 4110, 5130 - , 6125, 7168, 8195, 9206, 10230, 11227, 12256, 13304, 14281, 15316 - , 16374, 17382, 18428, 19388, 20361, 21468, 22448, 23781, 0, 0 - , -1, 0, -2, 1024, 0, 0, 0, -1, 1024, -1024 - , 1, -1024, 4, 1024, -1024, 2, 1024, -1024, 2, 1024 - , -2048, -1024, -4, 1024, -1024, 2, 1024, -2048, -1024, -3 - , 1024, 2048, -2048, -1024, 4, 1024, 2048, -3072, -2048, -1024 - , -1, 662, 2048, 0, 1, 0, 0, 1, -2, -2 - , 0, 2, 1024, -1, 1024, -1024, 4, 1024, -1024, 1 - , 1024, -1024, 1, 1024, -2048, -781, -4, 844, -807, -5 - , 866, -2048, -726, -13, 777, 2048, -2048, -643, -4, 617 - , 2048, 3072, -3072, -2048, -629, 1, 630, 2048, 3072, 0 - , -1, 1, -2, 2, 1, -1024, 5, -1024, 6, 1024 - , -1024, 4, 1024, -1024, 1, 1024, -1024, -9, 1024, -673 - , -7, 655, -2048, -665, -15, 716, -2048, -647, 4, 640 - , 2048, -2048, -615, -1, 635, 2048, -2048, -613, 10, 637 - , 2048, 3072, -3072, -2048, -647, -3, 641, 2048, 3072, -5120 - , -4096, -3072, -2048, -681, 6, 685, 2048, 3072, 4096, 1 - , 1, 0, -1, 1024, -1024, -3, 1024, -1024, 6, 1024 - , -1024, -1, 769, -733, 0, 1024, -876, -2, 653, -1024 - , -4, 786, -596, -13, 595, -634, -2, 638, 2048, -2048 - , -620, -5, 620, 2048, -4096, -3072, -2048, -639, 11, 655 - , 2048, 3072, -3072, -2048, -659, 5, 663, 2048, -3072, -1823 - , -687, 22, 695, 2048, 3072, 4096, -4096, -3072, -1848, -715 - , -3, 727, 1816, 3072, 4096, 5120, -8192, -7168, -6144, -5120 - , -4096, -2884, -1771, -756, -14, 775, 1844, 3072, 4096, 5120 - , 6144, -1, 1, 0, -1024, 2, 815, -768, 2, 708 - , -1024, -3, 693, -661, -7, 607, -643, -5, 609, -624 - , 3, 631, -682, -3, 691, 2048, -2048, -640, 5, 650 - , 2048, -3072, -2048, -701, 9, 704, 2048, 3072, -3072, -2048 - , -670, 10, 674, 2048, 3072, -5120, -4096, -3072, -1749, -738 - , 0, 733, 1811, 3072, 4096, 5120, -4096, -3072, -1873, -753 - , 0, 756, 1874, 3072, 4096, -5120, -4096, -2900, -1838, -793 - , -6, 793, 1868, 2837, 4096, 5120, -7168, -6144, -5120, -4096 - , -2832, -1891, -828, 1, 828, 1901, 2823, 3912, 5120, 6144 - , 7168, 8192,-13312,-12288,-11264,-10240, -9216, -8192, -7168, -6144 - , -5120, -3976, -3004, -1911, -869, 7, 869, 1932, 3024, 3992 - , 5009, 6144, 7168, 8192, 9216, 10240, 11264, -4, 1024, -629 - , -22, 609, -623, 9, 640, -2048, -768, 1, 682, -2048 - , -741, 49, 722, 2048, -3072, -1706, -808, -20, 768, 1750 - , -1684, -727, -29, 788, 1840, 3033, -1758, -784, 0, 801 - , 1702, -3072, -1813, -814, 38, 820, 1884, 2927, -4096, -3241 - , -1839, -922, 25, 882, 1886, 2812, -4096, -2982, -1923, -894 - , 84, 912, 1869, 2778, 4096, -4928, -3965, -2902, -1920, -883 - , 3, 917, 1953, 2921, 3957, 4922, 6144, 7168, -5120, -3916 - , -2897, -1949, -930, 31, 959, 1934, 2901, 3851, 5120, -9216 - , -8192, -7046, -6029, -5030, -4034, -2980, -1969, -1013, -76, 963 - , 1963, 2901, 3929, 4893, 6270, 7168, 8192, 9216,-12288,-11264 - ,-10240, -9216, -8192, -6846, -6123, -5108, -4008, -3000, -1963, -954 - , -6, 958, 1992, 3009, 4020, 5085, 6097, 7168, 8192, 9216 - ,-11264,-10139, -9194, -8127, -7156, -6102, -5053, -4049, -3036, -2025 - , -1009, -34, 974, 1984, 3034, 4028, 5138, 6000, 7057, 8166 - , 9070, 10033, 11360, 12288,-13312,-12288,-10932,-10190, -9120, -8123 - , -7128, -6103, -5074, -4081, -3053, -2029, -989, -4, 1010, 2028 - , 3051, 4073, 5071, 6099, 7132, 8147, 9295, 10159, 11023, 12263 - , 13312, 14336,-25600,-24576,-23552,-22529,-21504,-20480,-19456,-18637 - ,-17425,-16165,-15316,-14327,-13606,-12135,-11182,-10107, -9153, -8144 - , -7146, -6160, -5129, -4095, -3064, -2038, -1025, 1, 1031, 2072 - , 3074, 4088, 5123, 6149, 7157, 8173, 9198, 10244, 11250, 12268 - , 13263, 14289, 15351, 16370, 17402, 18413, 19474, 20337, 21386, 22521 - , 23367, 24350, 0, 0, 0, 0, 0, 0, 0, 0 - , -1024, 0, 1024, -1024, 0, 1024, -1024, 0, 1024, -1024 - , 0, 1024, -1024, 0, 1024, -773, 0, 1024, -674, 0 - , 645, -2048, -745, 0, 628, 2048, -2048, -712, 0, 681 - , 2048, 3072, -3072, -2048, -673, 0, 682, 1964, 3257, 0 - , 0, 0, 0, 0, 0, 0, 0, -1024, 0, 1024 - , -1024, 0, 1024, -1024, 0, 1024, -705, 0, 623, -771 - , 0, 1024, -786, 0, 688, -631, 0, 652, 2048, -2048 - , -627, -1, 666, 2048, -3072, -1756, -694, 0, 674, 2048 - , -3098, -1879, -720, 5, 694, 1886, 2958, 4096, 0, 0 - , 0, 0, 1024, 0, 0, 1024, -769, 0, 1024, -1024 - , 0, 1024, -1024, 0, 1024, -817, 0, 734, -786, 0 - , 651, -638, 0, 637, -623, 0, 671, -652, 0, 619 - , 2048, -2048, -670, -1, 663, 2048, -1908, -680, 1, 686 - , 2048, 3072, 4096, -4096, -3072, -1833, -711, 0, 727, 1747 - , 3072, 4096, -4096, -2971, -1826, -762, 2, 766, 1832, 2852 - , 3928, 5079, 0, 0, 0, -1024, 0, 1024, -1024, 0 - , -656, 0, 1024, -599, 0, 620, -1024, 0, 1024, -603 - , 0, 622, -643, 0, 660, -599, 0, 611, -641, -1 - , 651, 2048, -2048, -648, -2, 647, 1798, -3072, -2048, -672 - , 2, 670, 2048, -3072, -1780, -694, -1, 706, 1751, 3072 - , -3072, -1862, -757, 7, 739, 1798, 3072, 4096, -5120, -4096 - , -3253, -1811, -787, 3, 782, 1887, 3123, 4096, -7252, -6144 - , -5354, -4060, -2864, -1863, -820, -11, 847, 1903, 2970, 3851 - , 4921, 5957, 7168, 8192, 9306, 0, 0, -1024, 0, 1024 - , -726, 0, 706, -692, 0, 593, -598, 0, 616, -624 - , 0, 616, -605, 0, 613, -2048, -652, 1, 635, 2048 - , -2048, -647, -1, 660, 2048, -1811, -668, -2, 685, 2048 - , -1796, -731, -2, 730, 1702, 3072, -3072, -1766, -747, -4 - , 756, 1770, 3072, -4096, -3024, -1762, -783, 4, 771, 1781 - , 3072, -5120, -4057, -2807, -1832, -822, 0, 816, 1804, 2851 - , 3949, 5120, -6144, -4899, -3927, -2920, -1893, -874, -2, 868 - , 1881, 2905, 3960, 4912, 6144, -9216, -8192, -7168, -6225, -4963 - , -3943, -2956, -1890, -902, 0, 897, 1914, 2916, 3984, 4990 - , 6050, 7168,-11264,-10217, -9114, -8132, -7035, -5988, -4984, -4000 - , -2980, -1962, -927, 7, 931, 1956, 2981, 4031, 4972, 6213 - , 7227, 8192, 9216, 10240, 11170, 12288, 13312, 14336, 0, 1024 - , -557, 1, 571, -606, -4, 612, -1676, -707, 10, 673 - , 2048, -2048, -727, 5, 686, -3072, -1772, -755, 12, 716 - , 1877, -1856, -786, 2, 786, 1712, -1685, -818, -16, 863 - , 1729, -3072, -1762, -857, 3, 866, 1838, 2841, -3862, -2816 - , -1864, -925, -2, 923, 1897, 2779, -2782, -1838, -920, -28 - , 931, 1951, 2835, 3804, -4815, -4001, -2940, -1934, -959, -22 - , 975, 1957, 2904, 3971, 4835, -5148, -3892, -2944, -1953, -986 - , -11, 989, 1968, 2939, 3949, 4947, 5902, -9216, -8192, -6915 - , -6004, -4965, -4013, -3009, -1977, -987, -1, 982, 1972, 3000 - , 3960, 4939, 5814, -8976, -7888, -7084, -5955, -5043, -4009, -2991 - , -2002, -1000, -8, 993, 2011, 3023, 4026, 5028, 6023, 7052 - , 8014, 9216,-11240,-10036, -9125, -8118, -7105, -6062, -5048, -4047 - , -3044, -2025, -1009, -1, 1011, 2023, 3042, 4074, 5085, 6108 - , 7119, 8142, 9152, 10114, 11141, 12250, 13307,-15360,-14099,-13284 - ,-12291,-11223,-10221, -9152, -8147, -7128, -6104, -5077, -4072, -3062 - , -2033, -1020, 7, 1018, 2038, 3059, 4081, 5084, 6109, 7102 - , 8128, 9134, 10125, 11239, 12080,-23552,-22528,-21504,-20480,-19456 - ,-18159,-17240,-16291,-15364,-14285,-13305,-12271,-11233,-10217, -9198 - , -8175, -7157, -6134, -5122, -4089, -3071, -2047, -1018, 3, 1026 - , 2041, 3077, 4090, 5108, 6131, 7150, 8172, 9175, 10196, 11272 - , 12303, 13273, 14328, 15332, 16334, 17381, 18409, 19423, 20423, 21451 - , 22679, 23391, 24568, 25600, 26589 -}; - -/* cdf tables for quantizer indices */ -const WebRtc_UWord16 WebRtcIsacfix_kCdfGain[1212] = { - 0, 13, 301, 3730, 61784, 65167, 65489, 65535, 0, 17, - 142, 314, 929, 2466, 7678, 56450, 63463, 64740, 65204, 65426, - 65527, 65535, 0, 8, 100, 724, 6301, 60105, 65125, 65510, - 65531, 65535, 0, 13, 117, 368, 1068, 3010, 11928, 53603, - 61177, 63404, 64505, 65108, 65422, 65502, 65531, 65535, 0, 4, - 17, 96, 410, 1859, 12125, 54361, 64103, 65305, 65497, 65535, - 0, 4, 88, 230, 469, 950, 1746, 3228, 6092, 16592, - 44756, 56848, 61256, 63308, 64325, 64920, 65309, 65460, 65502, 65522, - 65535, 0, 88, 352, 1675, 6339, 20749, 46686, 59284, 63525, - 64949, 65359, 65502, 65527, 65535, 0, 13, 38, 63, 117, - 234, 381, 641, 929, 1407, 2043, 2809, 4032, 5753, 8792, - 14407, 24308, 38941, 48947, 55403, 59293, 61411, 62688, 63630, 64329, - 64840, 65188, 65376, 65472, 65506, 65527, 65531, 65535, 0, 8, - 29, 75, 222, 615, 1327, 2801, 5623, 9931, 16094, 24966, - 34419, 43458, 50676, 56186, 60055, 62500, 63936, 64765, 65225, 65435, - 65514, 65535, 0, 8, 13, 15, 17, 21, 33, 59, - 71, 92, 151, 243, 360, 456, 674, 934, 1223, 1583, - 1989, 2504, 3031, 3617, 4354, 5154, 6163, 7411, 8780, 10747, - 12874, 15591, 18974, 23027, 27436, 32020, 36948, 41830, 46205, 49797, - 53042, 56094, 58418, 60360, 61763, 62818, 63559, 64103, 64509, 64798, - 65045, 65162, 65288, 65363, 65447, 65506, 65522, 65531, 65533, 65535, - 0, 4, 6, 25, 38, 71, 138, 264, 519, 808, - 1227, 1825, 2516, 3408, 4279, 5560, 7092, 9197, 11420, 14108, - 16947, 20300, 23926, 27459, 31164, 34827, 38575, 42178, 45540, 48747, - 51444, 54090, 56426, 58460, 60080, 61595, 62734, 63668, 64275, 64673, - 64936, 65112, 65217, 65334, 65426, 65464, 65477, 65489, 65518, 65527, - 65529, 65531, 65533, 65535, 0, 2, 4, 8, 10, 12, - 14, 16, 21, 33, 50, 71, 84, 92, 105, 138, - 180, 255, 318, 377, 435, 473, 511, 590, 682, 758, - 913, 1097, 1256, 1449, 1671, 1884, 2169, 2445, 2772, 3157, - 3563, 3944, 4375, 4848, 5334, 5820, 6448, 7101, 7716, 8378, - 9102, 9956, 10752, 11648, 12707, 13670, 14758, 15910, 17187, 18472, - 19627, 20649, 21951, 23169, 24283, 25552, 26862, 28227, 29391, 30764, - 31882, 33213, 34432, 35600, 36910, 38116, 39464, 40729, 41872, 43144, - 44371, 45514, 46762, 47813, 48968, 50069, 51032, 51974, 52908, 53737, - 54603, 55445, 56282, 56990, 57572, 58191, 58840, 59410, 59887, 60264, - 60607, 60946, 61269, 61516, 61771, 61960, 62198, 62408, 62558, 62776, - 62985, 63207, 63408, 63546, 63739, 63906, 64070, 64237, 64371, 64551, - 64677, 64836, 64999, 65095, 65213, 65284, 65338, 65380, 65426, 65447, - 65472, 65485, 65487, 65489, 65502, 65510, 65512, 65514, 65516, 65518, - 65522, 65531, 65533, 65535, 0, 2, 4, 6, 65528, 65531, - 65533, 65535, 0, 2, 4, 6, 8, 10, 222, 65321, - 65513, 65528, 65531, 65533, 65535, 0, 2, 4, 50, 65476, - 65529, 65531, 65533, 65535, 0, 2, 4, 6, 8, 12, - 38, 544, 64936, 65509, 65523, 65525, 65529, 65531, 65533, 65535, - 0, 2, 4, 6, 8, 10, 1055, 64508, 65528, 65531, - 65533, 65535, 0, 2, 4, 6, 8, 10, 12, 123, - 3956, 62999, 65372, 65495, 65515, 65521, 65523, 65525, 65527, 65529, - 65531, 65533, 65535, 0, 2, 4, 12, 53, 4707, 59445, - 65467, 65525, 65527, 65529, 65531, 65533, 65535, 0, 2, 4, - 6, 8, 10, 12, 14, 16, 38, 40, 50, 67, - 96, 234, 929, 14345, 55750, 64866, 65389, 65462, 65514, 65517, - 65519, 65521, 65523, 65525, 65527, 65529, 65531, 65533, 65535, 0, - 2, 4, 6, 8, 10, 15, 35, 91, 377, 1946, - 13618, 52565, 63714, 65184, 65465, 65520, 65523, 65525, 65527, 65529, - 65531, 65533, 65535, 0, 2, 4, 6, 8, 10, 12, - 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, - 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, - 54, 82, 149, 362, 751, 1701, 4239, 12893, 38627, 55072, - 60875, 63071, 64158, 64702, 65096, 65283, 65412, 65473, 65494, 65505, - 65508, 65517, 65519, 65521, 65523, 65525, 65527, 65529, 65531, 65533, - 65535, 0, 2, 15, 23, 53, 143, 260, 418, 698, - 988, 1353, 1812, 2411, 3144, 4015, 5143, 6401, 7611, 8999, - 10653, 12512, 14636, 16865, 19404, 22154, 24798, 27521, 30326, 33102, - 35790, 38603, 41415, 43968, 46771, 49435, 52152, 54715, 57143, 59481, - 61178, 62507, 63603, 64489, 64997, 65257, 65427, 65473, 65503, 65520, - 65529, 65531, 65533, 65535, 0, 3, 6, 9, 26, 32, - 44, 46, 64, 94, 111, 164, 205, 254, 327, 409, - 506, 608, 733, 885, 1093, 1292, 1482, 1742, 1993, 2329, - 2615, 3029, 3374, 3798, 4257, 4870, 5405, 5992, 6618, 7225, - 7816, 8418, 9051, 9761, 10532, 11380, 12113, 13010, 13788, 14594, - 15455, 16361, 17182, 18088, 18997, 20046, 20951, 21968, 22947, 24124, - 25296, 26547, 27712, 28775, 29807, 30835, 31709, 32469, 33201, 34014, - 34876, 35773, 36696, 37620, 38558, 39547, 40406, 41277, 42367, 43290, - 44445, 45443, 46510, 47684, 48973, 50157, 51187, 52242, 53209, 54083, - 55006, 55871, 56618, 57293, 57965, 58556, 59222, 59722, 60180, 60554, - 60902, 61250, 61554, 61837, 62100, 62372, 62631, 62856, 63078, 63324, - 63557, 63768, 63961, 64089, 64235, 64352, 64501, 64633, 64770, 64887, - 65001, 65059, 65121, 65188, 65246, 65302, 65346, 65390, 65428, 65463, - 65477, 65506, 65515, 65517, 65519, 65521, 65523, 65525, 65527, 65529, - 65531, 65533, 65535, 0, 2, 4, 109, 65332, 65531, 65533, - 65535, 0, 2, 4, 6, 8, 25, 1817, 63874, 65511, - 65527, 65529, 65531, 65533, 65535, 0, 2, 4, 907, 65014, - 65529, 65531, 65533, 65535, 0, 2, 4, 6, 8, 10, - 12, 132, 2743, 62708, 65430, 65525, 65527, 65529, 65531, 65533, - 65535, 0, 2, 4, 6, 8, 35, 3743, 61666, 65485, - 65531, 65533, 65535, 0, 2, 4, 6, 8, 10, 23, - 109, 683, 6905, 58417, 64911, 65398, 65497, 65518, 65525, 65527, - 65529, 65531, 65533, 65535, 0, 2, 4, 6, 53, 510, - 10209, 55212, 64573, 65441, 65522, 65529, 65531, 65533, 65535, 0, - 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, - 22, 32, 90, 266, 1037, 3349, 14468, 50488, 62394, 64685, - 65341, 65480, 65514, 65519, 65521, 65523, 65525, 65527, 65529, 65531, - 65533, 65535, 0, 2, 4, 6, 9, 16, 37, 106, - 296, 748, 1868, 5733, 18897, 45553, 60165, 63949, 64926, 65314, - 65441, 65508, 65524, 65529, 65531, 65533, 65535, 0, 2, 4, - 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, - 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, - 46, 48, 50, 83, 175, 344, 667, 1293, 2337, 4357, - 8033, 14988, 28600, 43244, 52011, 57042, 59980, 61779, 63065, 63869, - 64390, 64753, 64988, 65164, 65326, 65422, 65462, 65492, 65506, 65522, - 65524, 65526, 65531, 65533, 65535, 0, 2, 4, 6, 8, - 10, 12, 14, 16, 25, 39, 48, 55, 62, 65, - 85, 106, 139, 169, 194, 252, 323, 485, 688, 1074, - 1600, 2544, 3863, 5733, 8303, 11397, 15529, 20273, 25734, 31455, - 36853, 41891, 46410, 50306, 53702, 56503, 58673, 60479, 61880, 62989, - 63748, 64404, 64852, 65124, 65309, 65424, 65480, 65524, 65528, 65533, - 65535, 0, 2, 4, 6, 8, 10, 12, 14, 21, - 23, 25, 27, 29, 31, 39, 41, 43, 48, 60, - 72, 79, 106, 136, 166, 187, 224, 252, 323, 381, - 427, 478, 568, 660, 783, 912, 1046, 1175, 1365, 1567, - 1768, 2024, 2347, 2659, 3049, 3529, 4033, 4623, 5281, 5925, - 6726, 7526, 8417, 9468, 10783, 12141, 13571, 15222, 16916, 18659, - 20350, 22020, 23725, 25497, 27201, 29026, 30867, 32632, 34323, 36062, - 37829, 39466, 41144, 42654, 43981, 45343, 46579, 47759, 49013, 50171, - 51249, 52283, 53245, 54148, 54938, 55669, 56421, 57109, 57791, 58464, - 59092, 59674, 60105, 60653, 61083, 61407, 61757, 62095, 62388, 62649, - 62873, 63157, 63358, 63540, 63725, 63884, 64046, 64155, 64278, 64426, - 64548, 64654, 64806, 64906, 64994, 65077, 65137, 65215, 65277, 65324, - 65354, 65409, 65437, 65455, 65462, 65490, 65495, 65499, 65508, 65511, - 65513, 65515, 65517, 65519, 65521, 65523, 65525, 65527, 65529, 65531, - 65533, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kCdfShape[2059] = { - 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, - 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, 4, - 65535, 0, 8, 65514, 65535, 0, 29, 65481, 65535, 0, - 121, 65439, 65535, 0, 239, 65284, 65535, 0, 8, 779, - 64999, 65527, 65535, 0, 8, 888, 64693, 65522, 65535, 0, - 29, 2604, 62843, 65497, 65531, 65535, 0, 25, 176, 4576, - 61164, 65275, 65527, 65535, 0, 65535, 0, 65535, 0, 65535, - 0, 65535, 0, 4, 65535, 0, 65535, 0, 65535, 0, - 65535, 0, 65535, 0, 4, 65535, 0, 33, 65502, 65535, - 0, 54, 65481, 65535, 0, 251, 65309, 65535, 0, 611, - 65074, 65535, 0, 1273, 64292, 65527, 65535, 0, 4, 1809, - 63940, 65518, 65535, 0, 88, 4392, 60603, 65426, 65531, 65535, - 0, 25, 419, 7046, 57756, 64961, 65514, 65531, 65535, 0, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 4, 65531, - 65535, 0, 65535, 0, 8, 65531, 65535, 0, 4, 65527, - 65535, 0, 17, 65510, 65535, 0, 42, 65481, 65535, 0, - 197, 65342, 65531, 65535, 0, 385, 65154, 65535, 0, 1005, - 64522, 65535, 0, 8, 1985, 63469, 65533, 65535, 0, 38, - 3119, 61884, 65514, 65535, 0, 4, 6, 67, 4961, 60804, - 65472, 65535, 0, 17, 565, 9182, 56538, 65087, 65514, 65535, - 0, 8, 63, 327, 2118, 14490, 52774, 63839, 65376, 65522, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, - 17, 65522, 65535, 0, 59, 65489, 65535, 0, 50, 65522, - 65535, 0, 54, 65489, 65535, 0, 310, 65179, 65535, 0, - 615, 64836, 65535, 0, 4, 1503, 63965, 65535, 0, 2780, - 63383, 65535, 0, 21, 3919, 61051, 65527, 65535, 0, 84, - 6674, 59929, 65435, 65535, 0, 4, 255, 7976, 55784, 65150, - 65518, 65531, 65535, 0, 4, 8, 582, 10726, 53465, 64949, - 65518, 65535, 0, 29, 339, 3006, 17555, 49517, 62956, 65200, - 65497, 65531, 65535, 0, 2, 33, 138, 565, 2324, 7670, - 22089, 45966, 58949, 63479, 64966, 65380, 65518, 65535, 0, 65535, - 0, 65535, 0, 2, 65533, 65535, 0, 46, 65514, 65535, - 0, 414, 65091, 65535, 0, 540, 64911, 65535, 0, 419, - 65162, 65535, 0, 976, 64790, 65535, 0, 2977, 62495, 65531, - 65535, 0, 4, 3852, 61034, 65527, 65535, 0, 4, 29, - 6021, 60243, 65468, 65535, 0, 84, 6711, 58066, 65418, 65535, - 0, 13, 281, 9550, 54917, 65125, 65506, 65535, 0, 2, - 63, 984, 12108, 52644, 64342, 65435, 65527, 65535, 0, 29, - 251, 2014, 14871, 47553, 62881, 65229, 65518, 65535, 0, 13, - 142, 749, 4220, 18497, 45200, 60913, 64823, 65426, 65527, 65535, - 0, 13, 71, 264, 1176, 3789, 10500, 24480, 43488, 56324, - 62315, 64493, 65242, 65464, 65514, 65522, 65531, 65535, 0, 4, - 13, 38, 109, 205, 448, 850, 1708, 3429, 6276, 11371, - 19221, 29734, 40955, 49391, 55411, 59460, 62102, 63793, 64656, 65150, - 65401, 65485, 65522, 65531, 65535, 0, 65535, 0, 2, 65533, - 65535, 0, 1160, 65476, 65535, 0, 2, 6640, 64763, 65533, - 65535, 0, 2, 38, 9923, 61009, 65527, 65535, 0, 2, - 4949, 63092, 65533, 65535, 0, 2, 3090, 63398, 65533, 65535, - 0, 2, 2520, 58744, 65510, 65535, 0, 2, 13, 544, - 8784, 51403, 65148, 65533, 65535, 0, 2, 25, 1017, 10412, - 43550, 63651, 65489, 65527, 65535, 0, 2, 4, 29, 783, - 13377, 52462, 64524, 65495, 65533, 65535, 0, 2, 4, 6, - 100, 1817, 18451, 52590, 63559, 65376, 65531, 65535, 0, 2, - 4, 6, 46, 385, 2562, 11225, 37416, 60488, 65026, 65487, - 65529, 65533, 65535, 0, 2, 4, 6, 8, 10, 12, - 42, 222, 971, 5221, 19811, 45048, 60312, 64486, 65294, 65474, - 65525, 65529, 65533, 65535, 0, 2, 4, 8, 71, 167, - 666, 2533, 7875, 19622, 38082, 54359, 62108, 64633, 65290, 65495, - 65529, 65533, 65535, 0, 2, 4, 6, 8, 10, 13, - 109, 586, 1930, 4949, 11600, 22641, 36125, 48312, 56899, 61495, - 63927, 64932, 65389, 65489, 65518, 65531, 65533, 65535, 0, 4, - 6, 8, 67, 209, 712, 1838, 4195, 8432, 14432, 22834, - 31723, 40523, 48139, 53929, 57865, 60657, 62403, 63584, 64363, 64907, - 65167, 65372, 65472, 65514, 65535, 0, 2, 4, 13, 25, - 42, 46, 50, 75, 113, 147, 281, 448, 657, 909, - 1185, 1591, 1976, 2600, 3676, 5317, 7398, 9914, 12941, 16169, - 19477, 22885, 26464, 29851, 33360, 37228, 41139, 44802, 48654, 52058, - 55181, 57676, 59581, 61022, 62190, 63107, 63676, 64199, 64547, 64924, - 65158, 65313, 65430, 65481, 65518, 65535, 0, 65535, 0, 65535, - 0, 65535, 0, 65535, 0, 65533, 65535, 0, 65535, 0, - 65535, 0, 65535, 0, 65533, 65535, 0, 2, 65535, 0, - 2, 65533, 65535, 0, 2, 65533, 65535, 0, 2, 65533, - 65535, 0, 2, 4, 65533, 65535, 0, 2, 65533, 65535, - 0, 2, 4, 65531, 65533, 65535, 0, 2, 4, 65531, - 65533, 65535, 0, 2, 4, 6, 65524, 65533, 65535, 0, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, - 65535, 0, 65535, 0, 65535, 0, 65533, 65535, 0, 65533, - 65535, 0, 2, 65533, 65535, 0, 2, 65533, 65535, 0, - 2, 65533, 65535, 0, 2, 4, 65532, 65535, 0, 6, - 65523, 65535, 0, 2, 15, 65530, 65533, 65535, 0, 2, - 35, 65493, 65531, 65533, 65535, 0, 2, 4, 158, 65382, - 65531, 65533, 65535, 0, 65535, 0, 65535, 0, 65535, 0, - 65535, 0, 65535, 0, 65535, 0, 2, 65535, 0, 2, - 65533, 65535, 0, 2, 65533, 65535, 0, 2, 65533, 65535, - 0, 2, 65533, 65535, 0, 9, 65512, 65535, 0, 2, - 12, 65529, 65535, 0, 2, 73, 65434, 65533, 65535, 0, - 2, 240, 65343, 65533, 65535, 0, 2, 476, 65017, 65531, - 65533, 65535, 0, 2, 4, 1046, 64686, 65531, 65533, 65535, - 0, 2, 4, 6, 8, 1870, 63898, 65529, 65531, 65533, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65533, 65535, - 0, 2, 65533, 65535, 0, 2, 65533, 65535, 0, 2, - 65532, 65535, 0, 6, 65533, 65535, 0, 6, 65523, 65535, - 0, 2, 65532, 65535, 0, 137, 65439, 65535, 0, 576, - 64899, 65533, 65535, 0, 2, 289, 65299, 65533, 65535, 0, - 2, 4, 6, 880, 64134, 65531, 65533, 65535, 0, 2, - 4, 1853, 63347, 65533, 65535, 0, 2, 6, 2516, 61762, - 65529, 65531, 65533, 65535, 0, 2, 4, 9, 3980, 61380, - 65503, 65529, 65531, 65533, 65535, 0, 2, 4, 6, 8, - 10, 12, 61, 6393, 59859, 65466, 65527, 65529, 65531, 65533, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 2, 65532, - 65535, 0, 3, 65529, 65535, 0, 2, 65529, 65535, 0, - 61, 65453, 65535, 0, 234, 65313, 65535, 0, 503, 65138, - 65535, 0, 155, 65402, 65533, 65535, 0, 2, 1058, 64554, - 65533, 65535, 0, 2, 4, 3138, 62109, 65531, 65533, 65535, - 0, 2, 4, 2031, 63339, 65531, 65533, 65535, 0, 2, - 4, 6, 9, 4155, 60778, 65523, 65529, 65531, 65533, 65535, - 0, 2, 4, 41, 6189, 59269, 65490, 65531, 65533, 65535, - 0, 2, 4, 6, 210, 8789, 57043, 65400, 65528, 65531, - 65533, 65535, 0, 2, 4, 6, 8, 26, 453, 10086, - 55499, 64948, 65483, 65524, 65527, 65529, 65531, 65533, 65535, 0, - 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, - 114, 1014, 11202, 52670, 64226, 65356, 65503, 65514, 65523, 65525, - 65527, 65529, 65531, 65533, 65535, 0, 65533, 65535, 0, 15, - 65301, 65535, 0, 152, 64807, 65535, 0, 2, 3328, 63308, - 65535, 0, 2, 4050, 59730, 65533, 65535, 0, 2, 164, - 10564, 61894, 65529, 65535, 0, 15, 6712, 59831, 65076, 65532, - 65535, 0, 32, 7712, 57449, 65459, 65535, 0, 2, 210, - 7849, 53110, 65021, 65523, 65535, 0, 2, 12, 1081, 13883, - 48262, 62870, 65477, 65535, 0, 2, 88, 847, 6145, 37852, - 62012, 65454, 65533, 65535, 0, 9, 47, 207, 1823, 14522, - 45521, 61069, 64891, 65481, 65528, 65531, 65533, 65535, 0, 2, - 9, 488, 2881, 12758, 38703, 58412, 64420, 65410, 65533, 65535, - 0, 2, 4, 6, 61, 333, 1891, 6486, 19720, 43188, - 57547, 62472, 64796, 65421, 65497, 65523, 65529, 65531, 65533, 65535, - 0, 2, 4, 6, 8, 10, 12, 29, 117, 447, - 1528, 6138, 21242, 43133, 56495, 62432, 64746, 65362, 65500, 65529, - 65531, 65533, 65535, 0, 2, 18, 105, 301, 760, 1490, - 3472, 7568, 15002, 26424, 40330, 53029, 60048, 62964, 64274, 64890, - 65337, 65445, 65489, 65513, 65527, 65530, 65533, 65535, 0, 2, - 4, 6, 41, 102, 409, 853, 2031, 4316, 7302, 11328, - 16869, 24825, 34926, 43481, 50877, 56126, 59874, 62103, 63281, 63857, - 64166, 64675, 65382, 65522, 65531, 65533, 65535, 0, 2, 4, - 6, 8, 10, 12, 14, 16, 18, 29, 38, 53, - 58, 96, 181, 503, 1183, 2849, 5590, 8600, 11379, 13942, - 16478, 19453, 22638, 26039, 29411, 32921, 37596, 41433, 44998, 48560, - 51979, 55106, 57666, 59892, 61485, 62616, 63484, 64018, 64375, 64685, - 64924, 65076, 65278, 65395, 65471, 65509, 65529, 65535, 0, 65535, - 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, - 0, 65535, 0, 65535, 0, 2, 65533, 65535, 0, 2, - 65533, 65535, 0, 2, 65533, 65535, 0, 2, 65533, 65535, - 0, 2, 65533, 65535, 0, 2, 65533, 65535, 0, 7, - 65519, 65535, 0, 2, 14, 65491, 65533, 65535, 0, 2, - 81, 65427, 65531, 65533, 65535, 0, 2, 4, 312, 65293, - 65528, 65533, 65535, 0, 65535, 0, 65535, 0, 65535, 0, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, - 2, 65533, 65535, 0, 2, 65533, 65535, 0, 2, 65533, - 65535, 0, 5, 65523, 65535, 0, 2, 65533, 65535, 0, - 7, 65526, 65535, 0, 46, 65464, 65533, 65535, 0, 2, - 120, 65309, 65533, 65535, 0, 2, 5, 362, 65097, 65533, - 65535, 0, 2, 18, 1164, 64785, 65528, 65531, 65533, 65535, - 0, 65535, 0, 65535, 0, 65535, 0, 65533, 65535, 0, - 65535, 0, 65533, 65535, 0, 2, 65533, 65535, 0, 2, - 65533, 65535, 0, 2, 65533, 65535, 0, 2, 65530, 65535, - 0, 2, 65523, 65535, 0, 69, 65477, 65535, 0, 141, - 65459, 65535, 0, 194, 65325, 65533, 65535, 0, 2, 543, - 64912, 65533, 65535, 0, 5, 1270, 64301, 65529, 65531, 65533, - 65535, 0, 2, 4, 12, 2055, 63538, 65508, 65531, 65533, - 65535, 0, 2, 7, 102, 3775, 61970, 65429, 65526, 65528, - 65533, 65535, 0, 65535, 0, 65535, 0, 65535, 0, 2, - 65533, 65535, 0, 2, 65535, 0, 9, 65533, 65535, 0, - 25, 65512, 65535, 0, 2, 65533, 65535, 0, 44, 65480, - 65535, 0, 48, 65475, 65535, 0, 162, 65373, 65535, 0, - 637, 64806, 65533, 65535, 0, 2, 935, 64445, 65533, 65535, - 0, 2, 4, 1662, 64083, 65533, 65535, 0, 2, 12, - 3036, 62469, 65521, 65533, 65535, 0, 2, 120, 5405, 60468, - 65469, 65531, 65533, 65535, 0, 2, 4, 18, 254, 6663, - 58999, 65272, 65528, 65533, 65535, 0, 2, 4, 9, 12, - 67, 591, 8981, 56781, 64564, 65365, 65508, 65524, 65526, 65529, - 65531, 65533, 65535, 0, 65535, 0, 65535, 0, 2, 65533, - 65535, 0, 9, 65526, 65535, 0, 14, 65503, 65535, 0, - 127, 65390, 65535, 0, 517, 64990, 65535, 0, 178, 65330, - 65535, 0, 2, 1055, 64533, 65533, 65535, 0, 2, 1558, - 63942, 65533, 65535, 0, 2, 2205, 63173, 65533, 65535, 0, - 25, 4493, 60862, 65505, 65533, 65535, 0, 2, 48, 5890, - 59442, 65482, 65533, 65535, 0, 2, 4, 127, 7532, 58191, - 65394, 65533, 65535, 0, 2, 5, 32, 550, 10388, 54924, - 65046, 65510, 65531, 65533, 65535, 0, 2, 4, 30, 150, - 1685, 14340, 51375, 63619, 65288, 65503, 65528, 65533, 65535, 0, - 2, 4, 6, 8, 28, 97, 473, 2692, 15407, 50020, - 62880, 65064, 65445, 65508, 65531, 65533, 65535, 0, 2, 4, - 12, 32, 79, 150, 372, 907, 2184, 5868, 18207, 45431, - 59856, 64031, 65096, 65401, 65481, 65507, 65521, 65523, 65525, 65527, - 65529, 65531, 65533, 65535, 0, 65533, 65535, 0, 182, 65491, - 65535, 0, 877, 64286, 65535, 0, 9, 2708, 63612, 65533, - 65535, 0, 2, 6038, 59532, 65535, 0, 2, 92, 5500, - 60539, 65533, 65535, 0, 268, 8908, 56512, 65385, 65535, 0, - 129, 13110, 52742, 65036, 65535, 0, 2, 806, 14003, 51929, - 64732, 65523, 65535, 0, 7, 92, 2667, 18159, 47678, 62610, - 65355, 65535, 0, 32, 1836, 19676, 48237, 61677, 64960, 65526, - 65535, 0, 21, 159, 967, 5668, 22782, 44709, 58317, 64020, - 65406, 65528, 65535, 0, 7, 162, 1838, 8328, 23929, 43014, - 56394, 63374, 65216, 65484, 65521, 65535, 0, 2, 4, 6, - 28, 268, 1120, 3613, 10688, 24185, 40989, 54917, 61684, 64510, - 65403, 65530, 65535, 0, 2, 16, 44, 139, 492, 1739, - 5313, 13558, 26766, 41566, 52446, 58937, 62815, 64480, 65201, 65454, - 65524, 65533, 65535, 0, 7, 25, 76, 263, 612, 1466, - 3325, 6832, 12366, 20152, 29466, 39255, 47360, 53506, 57740, 60726, - 62845, 64131, 64882, 65260, 65459, 65521, 65528, 65530, 65535, 0, - 2, 4, 14, 48, 136, 312, 653, 1240, 2369, 4327, - 7028, 10759, 15449, 21235, 28027, 35386, 42938, 49562, 54990, 59119, - 62086, 63916, 64863, 65249, 65445, 65493, 65523, 65535, 0, 2, - 4, 6, 8, 10, 12, 21, 83, 208, 409, 723, - 1152, 1868, 2951, 4463, 6460, 8979, 11831, 15195, 18863, 22657, - 26762, 30881, 34963, 39098, 43054, 47069, 50620, 53871, 56821, 59386, - 61340, 62670, 63512, 64023, 64429, 64750, 64944, 65126, 65279, 65366, - 65413, 65445, 65473, 65505, 65510, 65521, 65528, 65530, 65535 -}; - -/* pointers to cdf tables for quantizer indices */ -const WebRtc_UWord16 *WebRtcIsacfix_kCdfGainPtr[3][12] = { - { WebRtcIsacfix_kCdfGain +0 +0, WebRtcIsacfix_kCdfGain +0 +8, WebRtcIsacfix_kCdfGain +0 +22, - WebRtcIsacfix_kCdfGain +0 +32, WebRtcIsacfix_kCdfGain +0 +48, WebRtcIsacfix_kCdfGain +0 +60, - WebRtcIsacfix_kCdfGain +0 +81, WebRtcIsacfix_kCdfGain +0 +95, WebRtcIsacfix_kCdfGain +0 +128, - WebRtcIsacfix_kCdfGain +0 +152, WebRtcIsacfix_kCdfGain +0 +210, WebRtcIsacfix_kCdfGain +0 +264 - }, - { WebRtcIsacfix_kCdfGain +404 +0, WebRtcIsacfix_kCdfGain +404 +8, WebRtcIsacfix_kCdfGain +404 +21, - WebRtcIsacfix_kCdfGain +404 +30, WebRtcIsacfix_kCdfGain +404 +46, WebRtcIsacfix_kCdfGain +404 +58, - WebRtcIsacfix_kCdfGain +404 +79, WebRtcIsacfix_kCdfGain +404 +93, WebRtcIsacfix_kCdfGain +404 +125, - WebRtcIsacfix_kCdfGain +404 +149, WebRtcIsacfix_kCdfGain +404 +207, WebRtcIsacfix_kCdfGain +404 +260 - }, - { WebRtcIsacfix_kCdfGain +803 +0, WebRtcIsacfix_kCdfGain +803 +8, WebRtcIsacfix_kCdfGain +803 +22, - WebRtcIsacfix_kCdfGain +803 +31, WebRtcIsacfix_kCdfGain +803 +48, WebRtcIsacfix_kCdfGain +803 +60, - WebRtcIsacfix_kCdfGain +803 +81, WebRtcIsacfix_kCdfGain +803 +96, WebRtcIsacfix_kCdfGain +803 +129, - WebRtcIsacfix_kCdfGain +803 +154, WebRtcIsacfix_kCdfGain +803 +212, WebRtcIsacfix_kCdfGain +803 +268 - } -}; - -const WebRtc_UWord16 *WebRtcIsacfix_kCdfShapePtr[3][108] = { - { WebRtcIsacfix_kCdfShape +0 +0, WebRtcIsacfix_kCdfShape +0 +2, WebRtcIsacfix_kCdfShape +0 +4, - WebRtcIsacfix_kCdfShape +0 +6, WebRtcIsacfix_kCdfShape +0 +8, WebRtcIsacfix_kCdfShape +0 +10, - WebRtcIsacfix_kCdfShape +0 +12, WebRtcIsacfix_kCdfShape +0 +14, WebRtcIsacfix_kCdfShape +0 +16, - WebRtcIsacfix_kCdfShape +0 +18, WebRtcIsacfix_kCdfShape +0 +21, WebRtcIsacfix_kCdfShape +0 +25, - WebRtcIsacfix_kCdfShape +0 +29, WebRtcIsacfix_kCdfShape +0 +33, WebRtcIsacfix_kCdfShape +0 +37, - WebRtcIsacfix_kCdfShape +0 +43, WebRtcIsacfix_kCdfShape +0 +49, WebRtcIsacfix_kCdfShape +0 +56, - WebRtcIsacfix_kCdfShape +0 +64, WebRtcIsacfix_kCdfShape +0 +66, WebRtcIsacfix_kCdfShape +0 +68, - WebRtcIsacfix_kCdfShape +0 +70, WebRtcIsacfix_kCdfShape +0 +72, WebRtcIsacfix_kCdfShape +0 +75, - WebRtcIsacfix_kCdfShape +0 +77, WebRtcIsacfix_kCdfShape +0 +79, WebRtcIsacfix_kCdfShape +0 +81, - WebRtcIsacfix_kCdfShape +0 +83, WebRtcIsacfix_kCdfShape +0 +86, WebRtcIsacfix_kCdfShape +0 +90, - WebRtcIsacfix_kCdfShape +0 +94, WebRtcIsacfix_kCdfShape +0 +98, WebRtcIsacfix_kCdfShape +0 +102, - WebRtcIsacfix_kCdfShape +0 +107, WebRtcIsacfix_kCdfShape +0 +113, WebRtcIsacfix_kCdfShape +0 +120, - WebRtcIsacfix_kCdfShape +0 +129, WebRtcIsacfix_kCdfShape +0 +131, WebRtcIsacfix_kCdfShape +0 +133, - WebRtcIsacfix_kCdfShape +0 +135, WebRtcIsacfix_kCdfShape +0 +137, WebRtcIsacfix_kCdfShape +0 +141, - WebRtcIsacfix_kCdfShape +0 +143, WebRtcIsacfix_kCdfShape +0 +147, WebRtcIsacfix_kCdfShape +0 +151, - WebRtcIsacfix_kCdfShape +0 +155, WebRtcIsacfix_kCdfShape +0 +159, WebRtcIsacfix_kCdfShape +0 +164, - WebRtcIsacfix_kCdfShape +0 +168, WebRtcIsacfix_kCdfShape +0 +172, WebRtcIsacfix_kCdfShape +0 +178, - WebRtcIsacfix_kCdfShape +0 +184, WebRtcIsacfix_kCdfShape +0 +192, WebRtcIsacfix_kCdfShape +0 +200, - WebRtcIsacfix_kCdfShape +0 +211, WebRtcIsacfix_kCdfShape +0 +213, WebRtcIsacfix_kCdfShape +0 +215, - WebRtcIsacfix_kCdfShape +0 +217, WebRtcIsacfix_kCdfShape +0 +219, WebRtcIsacfix_kCdfShape +0 +223, - WebRtcIsacfix_kCdfShape +0 +227, WebRtcIsacfix_kCdfShape +0 +231, WebRtcIsacfix_kCdfShape +0 +235, - WebRtcIsacfix_kCdfShape +0 +239, WebRtcIsacfix_kCdfShape +0 +243, WebRtcIsacfix_kCdfShape +0 +248, - WebRtcIsacfix_kCdfShape +0 +252, WebRtcIsacfix_kCdfShape +0 +258, WebRtcIsacfix_kCdfShape +0 +264, - WebRtcIsacfix_kCdfShape +0 +273, WebRtcIsacfix_kCdfShape +0 +282, WebRtcIsacfix_kCdfShape +0 +293, - WebRtcIsacfix_kCdfShape +0 +308, WebRtcIsacfix_kCdfShape +0 +310, WebRtcIsacfix_kCdfShape +0 +312, - WebRtcIsacfix_kCdfShape +0 +316, WebRtcIsacfix_kCdfShape +0 +320, WebRtcIsacfix_kCdfShape +0 +324, - WebRtcIsacfix_kCdfShape +0 +328, WebRtcIsacfix_kCdfShape +0 +332, WebRtcIsacfix_kCdfShape +0 +336, - WebRtcIsacfix_kCdfShape +0 +341, WebRtcIsacfix_kCdfShape +0 +347, WebRtcIsacfix_kCdfShape +0 +354, - WebRtcIsacfix_kCdfShape +0 +360, WebRtcIsacfix_kCdfShape +0 +368, WebRtcIsacfix_kCdfShape +0 +378, - WebRtcIsacfix_kCdfShape +0 +388, WebRtcIsacfix_kCdfShape +0 +400, WebRtcIsacfix_kCdfShape +0 +418, - WebRtcIsacfix_kCdfShape +0 +445, WebRtcIsacfix_kCdfShape +0 +447, WebRtcIsacfix_kCdfShape +0 +451, - WebRtcIsacfix_kCdfShape +0 +455, WebRtcIsacfix_kCdfShape +0 +461, WebRtcIsacfix_kCdfShape +0 +468, - WebRtcIsacfix_kCdfShape +0 +474, WebRtcIsacfix_kCdfShape +0 +480, WebRtcIsacfix_kCdfShape +0 +486, - WebRtcIsacfix_kCdfShape +0 +495, WebRtcIsacfix_kCdfShape +0 +505, WebRtcIsacfix_kCdfShape +0 +516, - WebRtcIsacfix_kCdfShape +0 +528, WebRtcIsacfix_kCdfShape +0 +543, WebRtcIsacfix_kCdfShape +0 +564, - WebRtcIsacfix_kCdfShape +0 +583, WebRtcIsacfix_kCdfShape +0 +608, WebRtcIsacfix_kCdfShape +0 +635 - }, - { WebRtcIsacfix_kCdfShape +686 +0, WebRtcIsacfix_kCdfShape +686 +2, WebRtcIsacfix_kCdfShape +686 +4, - WebRtcIsacfix_kCdfShape +686 +6, WebRtcIsacfix_kCdfShape +686 +8, WebRtcIsacfix_kCdfShape +686 +11, - WebRtcIsacfix_kCdfShape +686 +13, WebRtcIsacfix_kCdfShape +686 +15, WebRtcIsacfix_kCdfShape +686 +17, - WebRtcIsacfix_kCdfShape +686 +20, WebRtcIsacfix_kCdfShape +686 +23, WebRtcIsacfix_kCdfShape +686 +27, - WebRtcIsacfix_kCdfShape +686 +31, WebRtcIsacfix_kCdfShape +686 +35, WebRtcIsacfix_kCdfShape +686 +40, - WebRtcIsacfix_kCdfShape +686 +44, WebRtcIsacfix_kCdfShape +686 +50, WebRtcIsacfix_kCdfShape +686 +56, - WebRtcIsacfix_kCdfShape +686 +63, WebRtcIsacfix_kCdfShape +686 +65, WebRtcIsacfix_kCdfShape +686 +67, - WebRtcIsacfix_kCdfShape +686 +69, WebRtcIsacfix_kCdfShape +686 +71, WebRtcIsacfix_kCdfShape +686 +73, - WebRtcIsacfix_kCdfShape +686 +75, WebRtcIsacfix_kCdfShape +686 +77, WebRtcIsacfix_kCdfShape +686 +79, - WebRtcIsacfix_kCdfShape +686 +82, WebRtcIsacfix_kCdfShape +686 +85, WebRtcIsacfix_kCdfShape +686 +89, - WebRtcIsacfix_kCdfShape +686 +93, WebRtcIsacfix_kCdfShape +686 +97, WebRtcIsacfix_kCdfShape +686 +102, - WebRtcIsacfix_kCdfShape +686 +106, WebRtcIsacfix_kCdfShape +686 +112, WebRtcIsacfix_kCdfShape +686 +119, - WebRtcIsacfix_kCdfShape +686 +127, WebRtcIsacfix_kCdfShape +686 +129, WebRtcIsacfix_kCdfShape +686 +131, - WebRtcIsacfix_kCdfShape +686 +133, WebRtcIsacfix_kCdfShape +686 +135, WebRtcIsacfix_kCdfShape +686 +137, - WebRtcIsacfix_kCdfShape +686 +139, WebRtcIsacfix_kCdfShape +686 +142, WebRtcIsacfix_kCdfShape +686 +146, - WebRtcIsacfix_kCdfShape +686 +150, WebRtcIsacfix_kCdfShape +686 +154, WebRtcIsacfix_kCdfShape +686 +158, - WebRtcIsacfix_kCdfShape +686 +162, WebRtcIsacfix_kCdfShape +686 +167, WebRtcIsacfix_kCdfShape +686 +173, - WebRtcIsacfix_kCdfShape +686 +179, WebRtcIsacfix_kCdfShape +686 +186, WebRtcIsacfix_kCdfShape +686 +194, - WebRtcIsacfix_kCdfShape +686 +205, WebRtcIsacfix_kCdfShape +686 +207, WebRtcIsacfix_kCdfShape +686 +209, - WebRtcIsacfix_kCdfShape +686 +211, WebRtcIsacfix_kCdfShape +686 +214, WebRtcIsacfix_kCdfShape +686 +218, - WebRtcIsacfix_kCdfShape +686 +222, WebRtcIsacfix_kCdfShape +686 +226, WebRtcIsacfix_kCdfShape +686 +230, - WebRtcIsacfix_kCdfShape +686 +234, WebRtcIsacfix_kCdfShape +686 +238, WebRtcIsacfix_kCdfShape +686 +242, - WebRtcIsacfix_kCdfShape +686 +247, WebRtcIsacfix_kCdfShape +686 +253, WebRtcIsacfix_kCdfShape +686 +262, - WebRtcIsacfix_kCdfShape +686 +269, WebRtcIsacfix_kCdfShape +686 +278, WebRtcIsacfix_kCdfShape +686 +289, - WebRtcIsacfix_kCdfShape +686 +305, WebRtcIsacfix_kCdfShape +686 +307, WebRtcIsacfix_kCdfShape +686 +309, - WebRtcIsacfix_kCdfShape +686 +311, WebRtcIsacfix_kCdfShape +686 +315, WebRtcIsacfix_kCdfShape +686 +319, - WebRtcIsacfix_kCdfShape +686 +323, WebRtcIsacfix_kCdfShape +686 +327, WebRtcIsacfix_kCdfShape +686 +331, - WebRtcIsacfix_kCdfShape +686 +335, WebRtcIsacfix_kCdfShape +686 +340, WebRtcIsacfix_kCdfShape +686 +346, - WebRtcIsacfix_kCdfShape +686 +354, WebRtcIsacfix_kCdfShape +686 +362, WebRtcIsacfix_kCdfShape +686 +374, - WebRtcIsacfix_kCdfShape +686 +384, WebRtcIsacfix_kCdfShape +686 +396, WebRtcIsacfix_kCdfShape +686 +413, - WebRtcIsacfix_kCdfShape +686 +439, WebRtcIsacfix_kCdfShape +686 +442, WebRtcIsacfix_kCdfShape +686 +446, - WebRtcIsacfix_kCdfShape +686 +450, WebRtcIsacfix_kCdfShape +686 +455, WebRtcIsacfix_kCdfShape +686 +461, - WebRtcIsacfix_kCdfShape +686 +468, WebRtcIsacfix_kCdfShape +686 +475, WebRtcIsacfix_kCdfShape +686 +481, - WebRtcIsacfix_kCdfShape +686 +489, WebRtcIsacfix_kCdfShape +686 +498, WebRtcIsacfix_kCdfShape +686 +508, - WebRtcIsacfix_kCdfShape +686 +522, WebRtcIsacfix_kCdfShape +686 +534, WebRtcIsacfix_kCdfShape +686 +554, - WebRtcIsacfix_kCdfShape +686 +577, WebRtcIsacfix_kCdfShape +686 +602, WebRtcIsacfix_kCdfShape +686 +631 - }, - { WebRtcIsacfix_kCdfShape +1368 +0, WebRtcIsacfix_kCdfShape +1368 +2, WebRtcIsacfix_kCdfShape +1368 +4, - WebRtcIsacfix_kCdfShape +1368 +6, WebRtcIsacfix_kCdfShape +1368 +8, WebRtcIsacfix_kCdfShape +1368 +10, - WebRtcIsacfix_kCdfShape +1368 +12, WebRtcIsacfix_kCdfShape +1368 +14, WebRtcIsacfix_kCdfShape +1368 +16, - WebRtcIsacfix_kCdfShape +1368 +20, WebRtcIsacfix_kCdfShape +1368 +24, WebRtcIsacfix_kCdfShape +1368 +28, - WebRtcIsacfix_kCdfShape +1368 +32, WebRtcIsacfix_kCdfShape +1368 +36, WebRtcIsacfix_kCdfShape +1368 +40, - WebRtcIsacfix_kCdfShape +1368 +44, WebRtcIsacfix_kCdfShape +1368 +50, WebRtcIsacfix_kCdfShape +1368 +57, - WebRtcIsacfix_kCdfShape +1368 +65, WebRtcIsacfix_kCdfShape +1368 +67, WebRtcIsacfix_kCdfShape +1368 +69, - WebRtcIsacfix_kCdfShape +1368 +71, WebRtcIsacfix_kCdfShape +1368 +73, WebRtcIsacfix_kCdfShape +1368 +75, - WebRtcIsacfix_kCdfShape +1368 +77, WebRtcIsacfix_kCdfShape +1368 +79, WebRtcIsacfix_kCdfShape +1368 +81, - WebRtcIsacfix_kCdfShape +1368 +85, WebRtcIsacfix_kCdfShape +1368 +89, WebRtcIsacfix_kCdfShape +1368 +93, - WebRtcIsacfix_kCdfShape +1368 +97, WebRtcIsacfix_kCdfShape +1368 +101, WebRtcIsacfix_kCdfShape +1368 +105, - WebRtcIsacfix_kCdfShape +1368 +110, WebRtcIsacfix_kCdfShape +1368 +116, WebRtcIsacfix_kCdfShape +1368 +123, - WebRtcIsacfix_kCdfShape +1368 +132, WebRtcIsacfix_kCdfShape +1368 +134, WebRtcIsacfix_kCdfShape +1368 +136, - WebRtcIsacfix_kCdfShape +1368 +138, WebRtcIsacfix_kCdfShape +1368 +141, WebRtcIsacfix_kCdfShape +1368 +143, - WebRtcIsacfix_kCdfShape +1368 +146, WebRtcIsacfix_kCdfShape +1368 +150, WebRtcIsacfix_kCdfShape +1368 +154, - WebRtcIsacfix_kCdfShape +1368 +158, WebRtcIsacfix_kCdfShape +1368 +162, WebRtcIsacfix_kCdfShape +1368 +166, - WebRtcIsacfix_kCdfShape +1368 +170, WebRtcIsacfix_kCdfShape +1368 +174, WebRtcIsacfix_kCdfShape +1368 +179, - WebRtcIsacfix_kCdfShape +1368 +185, WebRtcIsacfix_kCdfShape +1368 +193, WebRtcIsacfix_kCdfShape +1368 +203, - WebRtcIsacfix_kCdfShape +1368 +214, WebRtcIsacfix_kCdfShape +1368 +216, WebRtcIsacfix_kCdfShape +1368 +218, - WebRtcIsacfix_kCdfShape +1368 +220, WebRtcIsacfix_kCdfShape +1368 +224, WebRtcIsacfix_kCdfShape +1368 +227, - WebRtcIsacfix_kCdfShape +1368 +231, WebRtcIsacfix_kCdfShape +1368 +235, WebRtcIsacfix_kCdfShape +1368 +239, - WebRtcIsacfix_kCdfShape +1368 +243, WebRtcIsacfix_kCdfShape +1368 +247, WebRtcIsacfix_kCdfShape +1368 +251, - WebRtcIsacfix_kCdfShape +1368 +256, WebRtcIsacfix_kCdfShape +1368 +262, WebRtcIsacfix_kCdfShape +1368 +269, - WebRtcIsacfix_kCdfShape +1368 +277, WebRtcIsacfix_kCdfShape +1368 +286, WebRtcIsacfix_kCdfShape +1368 +297, - WebRtcIsacfix_kCdfShape +1368 +315, WebRtcIsacfix_kCdfShape +1368 +317, WebRtcIsacfix_kCdfShape +1368 +319, - WebRtcIsacfix_kCdfShape +1368 +323, WebRtcIsacfix_kCdfShape +1368 +327, WebRtcIsacfix_kCdfShape +1368 +331, - WebRtcIsacfix_kCdfShape +1368 +335, WebRtcIsacfix_kCdfShape +1368 +339, WebRtcIsacfix_kCdfShape +1368 +343, - WebRtcIsacfix_kCdfShape +1368 +349, WebRtcIsacfix_kCdfShape +1368 +355, WebRtcIsacfix_kCdfShape +1368 +361, - WebRtcIsacfix_kCdfShape +1368 +368, WebRtcIsacfix_kCdfShape +1368 +376, WebRtcIsacfix_kCdfShape +1368 +385, - WebRtcIsacfix_kCdfShape +1368 +397, WebRtcIsacfix_kCdfShape +1368 +411, WebRtcIsacfix_kCdfShape +1368 +429, - WebRtcIsacfix_kCdfShape +1368 +456, WebRtcIsacfix_kCdfShape +1368 +459, WebRtcIsacfix_kCdfShape +1368 +463, - WebRtcIsacfix_kCdfShape +1368 +467, WebRtcIsacfix_kCdfShape +1368 +473, WebRtcIsacfix_kCdfShape +1368 +478, - WebRtcIsacfix_kCdfShape +1368 +485, WebRtcIsacfix_kCdfShape +1368 +491, WebRtcIsacfix_kCdfShape +1368 +497, - WebRtcIsacfix_kCdfShape +1368 +505, WebRtcIsacfix_kCdfShape +1368 +514, WebRtcIsacfix_kCdfShape +1368 +523, - WebRtcIsacfix_kCdfShape +1368 +535, WebRtcIsacfix_kCdfShape +1368 +548, WebRtcIsacfix_kCdfShape +1368 +565, - WebRtcIsacfix_kCdfShape +1368 +585, WebRtcIsacfix_kCdfShape +1368 +611, WebRtcIsacfix_kCdfShape +1368 +640 - } -}; - -/* code length for all coefficients using different models */ - -const WebRtc_Word16 WebRtcIsacfix_kCodeLenGainQ11[392] = { - 25189, 16036, 8717, 358, 8757, 15706, 21456, 24397, 18502, 17559 - , 13794, 11088, 7480, 873, 6603, 11636, 14627, 16805, 19132, 26624 - , 26624, 19408, 13751, 7280, 583, 7591, 15178, 23773, 28672, 25189 - , 19045, 16442, 13412, 10397, 5893, 1338, 6376, 9992, 12074, 13853 - , 15781, 19821, 22819, 28672, 28672, 25189, 19858, 15781, 11262, 5477 - , 1298, 5632, 11814, 17234, 22020, 28672, 19677, 18125, 16587, 14521 - , 13032, 11196, 9249, 5411, 2495, 4994, 7975, 10234, 12308, 13892 - , 15148, 17944, 21725, 23917, 25189, 19539, 16293, 11531, 7808, 4475 - , 2739, 4872, 8089, 11314, 14992, 18105, 23257, 26624, 25189, 23257 - , 23257, 20982, 18697, 18023, 16338, 16036, 14539, 13695, 13146, 11763 - , 10754, 9074, 7260, 5584, 4430, 5553, 6848, 8344, 10141, 11636 - , 12535, 13416, 14342, 15477, 17296, 19282, 22349, 23773, 28672, 28672 - , 26624, 23773, 21456, 18023, 15118, 13362, 11212, 9293, 8043, 6985 - , 5908, 5721, 5853, 6518, 7316, 8360, 9716, 11289, 12912, 14652 - , 16969, 19858, 23773, 26624, 28013, 30720, 30720, 28672, 25426, 23141 - , 25426, 23773, 20720, 19408, 18697, 19282, 16859, 16338, 16026, 15377 - , 15021, 14319, 14251, 13937, 13260, 13017, 12332, 11703, 11430, 10359 - , 10128, 9405, 8757, 8223, 7974, 7859, 7646, 7673, 7997, 8580 - , 8880, 9061, 9866, 10397, 11358, 12200, 13244, 14157, 15021, 16026 - , 16490, 18697, 18479, 20011, 19677, 20720, 24576, 26276, 30720, 30720 - , 28672, 30720, 24068, 25189, 22437, 20345, 18479, 16396, 16026, 14928 - , 13877, 13450, 12696, 12766, 11626, 11098, 10159, 9998, 9437, 9275 - , 8783, 8552, 8629, 8488, 8522, 8454, 8571, 8775, 8915, 9427 - , 9483, 9851, 10260, 10933, 11131, 11974, 12560, 13833, 15080, 16304 - , 17491, 19017, 18697, 19408, 22020, 25189, 25426, 22819, 26276, 30720 - , 30720, 30720, 30720, 30720, 30720, 28672, 30720, 30720, 30720, 30720 - , 28013, 25426, 24397, 23773, 25189, 26624, 25189, 22437, 21725, 20011 - , 20527, 20720, 20771, 22020, 22020, 19858, 19408, 19972, 17866, 17360 - , 17791, 17219, 16805, 16927, 16067, 16162, 15661, 15178, 15021, 15209 - , 14845, 14570, 14490, 14490, 13733, 13617, 13794, 13577, 13312, 12824 - , 13032, 12683, 12189, 12469, 12109, 11940, 11636, 11617, 11932, 12294 - , 11578, 11775, 12039, 11654, 11560, 11439, 11909, 11421, 12029, 11513 - , 11773, 11899, 11560, 11805, 11476, 11664, 11963, 11647, 11754, 11963 - , 11703, 12211, 11932, 12074, 12469, 12535, 12560, 12912, 12783, 12866 - , 12884, 13378, 13957, 13775, 13635, 14019, 14545, 15240, 15520, 15554 - , 15697, 16490, 16396, 17281, 16599, 16969, 17963, 16859, 16983, 16805 - , 17099, 18210, 17219, 17646, 17700, 17646, 18297, 17425, 18479, 17791 - , 17718, 19282, 18672, 20173, 20982, 21725, 21456, 23773, 23257, 25189 - , 30720, 30720, 25189, 26624, 30720, 30720, 30720, 30720, 28672, 26276 - , 30720, 30720 -}; - -const WebRtc_Word16 WebRtcIsacfix_kCodeLenShapeQ11[577] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 28672 - , 0, 26624, 1, 23773, 22819, 4, 20982, 18598, 10, 19282 - , 16587, 22, 16442, 26624, 13126, 60, 14245, 26624, 26624, 12736 - , 79, 12912, 25189, 22819, 9563, 249, 9474, 22349, 28672, 23257 - , 17944, 7980, 434, 8181, 16431, 26624, 0, 0, 0, 0 - , 28672, 0, 0, 0, 0, 0, 28672, 0, 22437, 3 - , 22437, 20982, 5, 20982, 16442, 22, 16752, 13814, 49, 14646 - , 11645, 116, 11734, 26624, 28672, 10613, 158, 11010, 24397, 19539 - , 8046, 453, 7709, 19017, 28672, 23257, 15110, 6770, 758, 6523 - , 14108, 24397, 28672, 0, 0, 0, 0, 28672, 0, 28672 - , 0, 26624, 1, 28672, 28672, 1, 26624, 24397, 2, 23257 - , 21725, 4, 20982, 17158, 18, 17281, 28672, 15178, 35, 15209 - , 12343, 92, 12320, 26624, 10344, 189, 10217, 30720, 22020, 9033 - , 322, 8549, 23773, 28672, 30720, 20622, 7666, 473, 7806, 20527 - , 24397, 14135, 5995, 960, 6018, 14872, 23773, 26624, 20928, 16293 - , 10636, 4926, 1588, 5256, 11088, 18043, 25189, 0, 0, 0 - , 0, 24397, 1, 25189, 20720, 5, 21456, 21209, 3, 25189 - , 20982, 5, 21456, 15818, 30, 15410, 13794, 60, 13416, 28672 - , 11162, 142, 11025, 9337, 231, 10094, 23773, 8338, 405, 7930 - , 26624, 19677, 6787, 613, 7318, 19161, 28672, 16442, 6319, 932 - , 5748, 15312, 25189, 28672, 28672, 28672, 13998, 5513, 1263, 5146 - , 14024, 24397, 22819, 15818, 9460, 4447, 2122, 4681, 9970, 15945 - , 22349, 28672, 30720, 22622, 19017, 14872, 10689, 7405, 4473, 2983 - , 4783, 7894, 11186, 14964, 18210, 24397, 0, 0, 30720, 0 - , 30720, 21456, 3, 23773, 14964, 39, 14757, 14179, 53, 13751 - , 14928, 36, 15272, 12430, 79, 13228, 9135, 285, 9077, 28672 - , 28672, 8377, 403, 7919, 26624, 28672, 23257, 7068, 560, 7473 - , 20345, 19677, 6770, 720, 6464, 18697, 25189, 16249, 5779, 1087 - , 5494, 15209, 22819, 30720, 20622, 12601, 5240, 1419, 5091, 12095 - , 19408, 26624, 22819, 16805, 10683, 4812, 2056, 4293, 9836, 16026 - , 24397, 25189, 18409, 13833, 8681, 4503, 2653, 4220, 8329, 13853 - , 19132, 26624, 25189, 20771, 17219, 12630, 9520, 6733, 4565, 3657 - , 4817, 7069, 10058, 13212, 16805, 21209, 26624, 26276, 28672, 28672 - , 26276, 23257, 20173, 19282, 16538, 15051, 12811, 10754, 9267, 7547 - , 6270, 5407, 5214, 6057, 7054, 8226, 9488, 10806, 12793, 14442 - , 16442, 19677, 22099, 26276, 28672, 0, 30720, 0, 30720, 11920 - , 56, 20720, 30720, 6766, 355, 13130, 30720, 30720, 22180, 5589 - , 736, 7902, 26624, 30720, 7634, 354, 9721, 30720, 30720, 9027 - , 246, 10117, 30720, 30720, 9630, 453, 6709, 23257, 30720, 25683 - , 14228, 6127, 1271, 4615, 15178, 30720, 30720, 23504, 12382, 5739 - , 2015, 3492, 10560, 22020, 26624, 30720, 30720, 23257, 13192, 4873 - , 1527, 5001, 12445, 22020, 30720, 30720, 30720, 30720, 19344, 10761 - , 4051, 1927, 5281, 10594, 17866, 28672, 30720, 30720, 30720, 21869 - , 15554, 10060, 5979, 2710, 3085, 7889, 14646, 21725, 28672, 30720 - , 30720, 30720, 30720, 30720, 30720, 30720, 22719, 17425, 13212, 8083 - , 4439, 2820, 4305, 8136, 12988, 17425, 21151, 28672, 28672, 30720 - , 30720, 30720, 28672, 20527, 19282, 14412, 10513, 7407, 5079, 3744 - , 4115, 6308, 9621, 13599, 17040, 22349, 28672, 30720, 30720, 30720 - , 30720, 30720, 30720, 29522, 19282, 14545, 11485, 9093, 6760, 5262 - , 4672, 4970, 6005, 7852, 9732, 12343, 14672, 19161, 22819, 25189 - , 30720, 30720, 28672, 30720, 30720, 20720, 18125, 14388, 12007, 9825 - , 8092, 7064, 6069, 5903, 5932, 6359, 7169, 8310, 9324, 10711 - , 11867, 13096, 14157, 16338, 17040, 19161, 21725, 23773, 30720, 30720 - , 26276, 25426, 24397, 28672, 28672, 23257, 22020, 22349, 18297, 17646 - , 16983, 16431, 16162, 15021, 15178, 13751, 12142, 10895, 10193, 9632 - , 9086, 8896, 8823, 8735, 8591, 8754, 8649, 8361, 8329, 8522 - , 8373, 8739, 8993, 9657, 10454, 11279, 11899, 12614, 14024, 14273 - , 15477, 15240, 16649, 17866, 18697, 21151, 22099 -}; - -/* left KLT transforms */ -const WebRtc_Word16 WebRtcIsacfix_kT1GainQ15[3][4] = { - { -26130, 19773, 19773, 26130 }, - { -26664, 19046, 19046, 26664 }, - { -23538, 22797, 22797, 23538 } -}; - - - -const WebRtc_Word16 WebRtcIsacfix_kT1ShapeQ15[3][324] = { - { 52,16,168,7,439,-138,-89,306,671,882, - 157,1301,291,1598,-3571,-1943,-1119,32404,96,-12, - 379,-64,-307,345,-836,539,1045,2541,-2865,-992, - 1683,-4717,5808,7427,30599,2319,183,-73,451,481, - 933,-198,781,-397,1244,-777,3690,-2414,149,-1356, - -2593,-31140,8289,-1737,-202,-14,-214,360,501,450, - -245,-7,797,3638,-2804,3042,-337,22137,-22103,2264, - 6838,-3381,305,172,263,-195,-355,351,179,513, - 2234,3343,5509,7531,19075,-17740,-16836,2244,-629,-1505, - -153,108,124,-324,2694,-124,1492,-850,5347,4285, - 7439,-10229,-22822,-12467,-12891,3645,822,-232,131,13, - 374,565,536,4681,1294,-1935,1926,-5734,-10643,26462, - -12480,-5589,-1038,-2468,964,-704,-247,-106,186,-558, - -4050,3760,2972,2141,-7393,6294,26740,11991,-3251,5461, - 5341,1574,2208,-51,-552,-297,-753,-154,2068,-5371, - 3578,4106,28043,-10533,8041,2353,2389,4609,3410,1906, - 351,-249,18,-15,1117,539,2870,9084,17585,-24528, - -366,-6490,2009,-3170,2942,1116,-232,1672,1065,606, - -399,-388,-518,38,3728,28948,-11936,4543,4104,-4441, - 1545,-4044,1485,622,-68,186,-473,135,-280,125, - -546,-1813,6989,6606,23711,19376,-2636,2870,-4553,-1687, - 878,-375,205,-208,-409,-108,-200,-45,-1670,-337, - 8213,-5524,-2334,5240,-12939,-26205,5937,-1582,-592,-959, - -5374,2449,3400,559,349,-492,668,12379,-27684,3419, - 5117,4415,-297,-8270,-1252,-3490,-1272,-1199,-3159,191, - 630,488,-797,-3071,12912,-27783,-10249,1047,647,619, - 111,-3722,-915,-1055,-502,5,-1384,-306,221,68, - 5219,13173,-26474,-11663,-5626,927,806,-1127,236,-589, - -522,-230,-312,-315,-428,-573,426,192,-11830,-26883, - -14121,-2785,-1429,-109,410,-832,-302,539,-459,104, - 1,-530,-202,-289,153,116,30082,-12944,-671,20, - 649,98,103,215,234,0,280,-51,-169,298, - 31,230,-73,-51 - }, - { -154,-7,-192,61,-739,-389,-947,-162,-60,94, - 511,-716,1520,-1428,4168,-2214,1816,32270,-123,-77, - -199,-99,-42,-588,203,-240,-930,-35,1580,234, - 3206,-5507,-1495,-10946,30000,-2667,-136,-176,-240,-175, - -204,-661,-1796,-1039,-1271,498,3143,734,2663,2699, - -8127,29333,10495,2356,-72,113,-91,118,-2840,-723, - -1733,-1158,-389,-2116,-3054,-3,-5179,8071,29546,6308, - 5657,-3178,-186,-294,-473,-635,1213,-983,-1437,-1715, - -1094,1280,-92,-9573,948,29576,-7060,-5921,2954,1349, - -337,-108,-1099,962,418,-413,-1149,-334,1241,3975, - -6825,26725,-14377,7051,-4772,-1707,2335,2008,-150,570, - 1371,42,-1649,-619,2039,3369,-1225,1583,-2755,-15207, - -27504,-4855,-4304,1495,2733,1324,15,-448,403,353, - 3016,-1242,2338,2673,2064,-7496,-30447,-3686,5833,-1301, - -2455,2122,1519,608,43,-653,773,-3072,912,-1537, - 4505,10284,30237,1549,3200,-691,205,1702,658,1014, - 1499,148,79,-322,-1162,-4639,-813,7536,3204,29109, - -10747,-26,1611,2286,2114,2561,1022,372,348,207, - 1062,-1088,-443,-9849,2381,5671,29097,-7612,-2927,3853, - 194,1155,275,1438,1438,1312,581,888,-784,906, - 112,-11103,25104,14438,-9311,-3068,1210,368,370,-940, - -2434,-1148,1925,392,657,258,-526,1475,-2281,-4265, - -1880,1534,2185,-1472,959,-30934,6306,3114,-4109,1768, - -2612,-703,45,644,2185,2033,5670,7211,19114,-22427, - 6432,5150,-4090,-2694,3860,1245,-596,293,1829,369, - -319,229,-3256,2170,-6374,-26216,-4570,-16053,-5766,-262, - -2006,2873,-1477,147,378,-1544,-344,-544,-985,-481, - 4210,4542,30757,-7291,-4863,1529,-2079,-628,-603,-783, - -408,1646,697,808,-620,-292,181,158,-13313,-29173, - 5984,-1262,859,-1776,-558,-24,-883,-1421,739,210, - -531,-285,131,-160,-246,-56,29345,-13706,-2859,-2966, - -300,-970,-2382,-268,-103,-636,-12,-62,-691,-253, - -147,-127,27,66 - }, - { 55,-212,-198,489,-274,81,682,399,328,-934, - -389,-37,1357,-3632,5276,6581,-9493,-29921,29,-45, - 2,190,172,-15,311,-130,-1085,-25,324,-684, - 3223,-6580,4485,-5280,-29521,9933,82,-320,-530,229, - -705,-533,-414,848,-1842,-4473,1390,-857,6717,-6692, - 4648,29397,576,8339,-68,-85,238,-330,264,-1012, - -381,-203,-3384,-3329,3906,6810,3790,-6250,28312,-8078, - 8089,1565,160,-569,-612,-613,-1063,-1928,-1125,3421, - -7481,-7484,4942,-6984,4330,-25591,-10574,-6982,5682,-1781, - -308,89,178,-1715,-420,-3530,-5776,1219,-8617,-7137, - 7015,4981,24875,12657,-5408,-3356,-785,-1972,326,-858, - -506,-3382,-986,-6258,-2259,4015,-8374,-10482,3127,23826, - -14126,-514,-5417,2178,-2912,-17,-587,80,67,-5881, - -1702,-5351,-4481,398,-10156,-225,20727,-15460,-11603,7752, - 3660,1714,-2001,-359,499,-527,-1225,-7820,-1297,-6326, - -8526,7900,-18328,13311,-17488,-2926,-196,-17,2281,873, - 480,-160,-624,471,780,-8729,1707,-14262,-20647,1721, - 18590,-2206,-1214,-1066,312,-2602,783,-412,-113,49, - -119,1305,-2371,-15132,-1833,-18252,20295,-8316,2227,341, - -2074,-702,3082,-262,-465,-198,430,30,-70,-788, - 2342,-25132,-4863,19783,-484,2137,2811,-1906,799,1586, - 962,-734,-191,-30,-129,-93,-1126,1729,5860,-2030, - 8953,603,-3338,-10869,-1144,22070,12130,10513,3191,-6881, - -3514,2090,711,-666,1843,-5997,-5681,2921,-17641,-2801, - 4969,18590,7169,12214,8587,4405,3008,-1074,-371,-77, - 253,331,-5611,5014,13152,-1985,18483,-1696,8043,20463, - 2381,-393,1688,-1205,618,1220,457,248,-83,176, - 7920,-13676,-22139,-3038,17402,2036,844,3258,994,719, - 2087,-44,426,494,12,-91,46,5,-14204,22912, - -18156,-361,442,2298,-829,2229,386,1433,1335,1323, - 55,-592,-139,49,-12,-57,27783,17134,350,-282, - 552,158,142,2488,465,329,1087,118,143,10, - 56,65,-15,-31 - } -}; - -/* right KLT transforms */ -const WebRtc_Word16 WebRtcIsacfix_kT2GainQ15[3][36] = { - { 4775, -14892, 20313, -17104, 10533, -3613, -6782, 16044, -8889, - -11019, 21330, -10720, 13193, -15678, -11101, 14461, 12250, -13096, - -16951, 2167, 16066, 15569, -702, -16754, -19195, -12823, -4321, - 5128, 13348, 17825, 13232, 13404, 13494, 13490, 13383, 13261 - }, - { -3725, 11408, -18493, 20031, -13097, 3865, 9344, -19294, 10740, - 8856, -18432, 8982, 13975, -14444, -11930, 11774, 14285, -13594, - -16323, -4, 16340, 15609, 359, -17220, -18401, -13471, -4643, - 5225, 13375, 18053, 13124, 13463, 13621, 13583, 13393, 13072 - }, - { -3513, 11402, -17883, 19504, -14399, 4885, 8702, -19513, 12046, - 8533, -18110, 8447, 12778, -14838, -12444, 13177, 14107, -12759, - -17268, 914, 15822, 15661, 838, -16686, -18907, -12936, -4820, - 4175, 12398, 18830, 12913, 13215, 13433, 13572, 13601, 13518 - } -}; - -const WebRtc_Word16 WebRtcIsacfix_kT2ShapeQ15[3][36] = { - { 4400, -11512, 17205, -19470, 14770, -5345, 9784, -19222, 11228, - 6842, -18371, 9909, 14191, -13496, -11563, 14015, 11827, -14839, - -15439, 948, 17802, 14827, -2053, -17132, 18723, 14516, 4135, - -6822, -13869, -16016, 12975, 13341, 13563, 13603, 13478, 13296 - }, - { 5420, -14215, 19060, -18073, 11709, -3911, 9645, -18335, 7717, - 10842, -19283, 9777, 14898, -12555, -13661, 11668, 13520, -13733, - -15936, -1358, 15671, 16728, 328, -17100, 17527, 13973, 5587, - -5194, -14165, -17677, 12970, 13446, 13693, 13660, 13462, 13015 - }, - { 4386, -12426, 18019, -18895, 13894, -5034, 9713, -19270, 10283, - 8692, -18439, 9317, 13992, -13454, -13241, 12850, 13366, -13336, - -16334, -498, 15976, 16213, -114, -16987, 18191, 13659, 4958, - -5116, -13444, -18021, 12911, 13424, 13718, 13674, 13464, 13054 - } -}; - -/* means of log gains and LAR coefficients*/ -const WebRtc_Word16 WebRtcIsacfix_kMeansGainQ8[3][12] = { - { -1758, -1370, -1758, -1373, -1757, -1375, - -1758, -1374, -1758, -1373, -1755, -1370 - }, - { -1569, -1224, -1569, -1225, -1569, -1227, - -1569, -1226, -1567, -1225, -1565, -1224 - }, - { -1452, -957, -1447, -951, -1438, -944, - -1431, -938, -1419, -931, -1406, -926 - } -}; - - -const WebRtc_Word32 WebRtcIsacfix_kMeansShapeQ17[3][108] = { - { -119581, 34418, -44193, 11112, -4428, 18906, 9222, 8068, 1953, 5425, - 1871, 1689, 109933, 33751, 10471, -2566, 1090, 2320, -119219, 33728, - -43759, 11450, -4870, 19117, 9174, 8037, 1972, 5331, 1872, 1843, - 109899, 34301, 10629, -2316, 1272, 2562, -118608, 32318, -44012, 11591, - -4914, 18932, 9456, 8088, 1900, 5419, 1723, 1853, 109963, 35059, - 10745, -2335, 1161, 2520, -119174, 32107, -44462, 11635, -4694, 18611, - 9757, 8108, 1969, 5486, 1673, 1777, 109636, 34907, 10643, -2406, - 1034, 2420, -118597, 32320, -44590, 10854, -4569, 18821, 9701, 7866, - 2003, 5577, 1732, 1626, 109913, 34448, 10714, -2752, 990, 2228, - -118138, 32996, -44352, 10334, -3772, 18488, 9464, 7865, 2208, 5540, - 1745, 1664, 109880, 33381, 10640, -2779, 980, 2054 - }, - { -146328, 46370, 1047, 26431, 10035, 13933, 6415, 14359, -2368, 6661, - 2269, 1764, 96623, 7802, 4163, 10742, 1643, 2954, -146871, 46561, 1127, - 26225, 10113, 14096, 6771, 14323, -2037, 6788, 2297, 1761, 96324, 8382, - 4309, 10450, 1695, 3016, -146502, 46475, 1580, 26118, 10487, 14179, 6622, - 14439, -2034, 6757, 2342, 1761, 95869, 8966, 4347, 10358, 1999, 2855, - -146958, 47717, 826, 25952, 10263, 14061, 5266, 13681, -2417, 6582, 2047, - 1608, 96257, 9107, 4452, 10301, 1792, 2676, -146992, 47123, 446, 25822, - 10405, 14292, 5140, 13804, -2403, 6496, 1834, 1735, 97489, 9253, 4414, - 10684, 1549, 2721, -145811, 46182, 901, 26482, 10241, 14524, 6075, 14514, - -2147, 6691, 2196, 1899, 97011, 8178, 4102, 10758, 1638, 2869 - }, - { -166617, 46969, -43908, 17726, 6330, 25615, 6913, 5450, -2301, 1984, - 507, 2883, 149998, 28709, 19333, 16703, 11093, 8965, -168254, 46604, - -44315, 17862, 6474, 25746, 7018, 5373, -2343, 1930, 513, 2819, 150391, - 28627, 19194, 16678, 10998, 8929, -169093, 46084, -44767, 17427, 6401, - 25674, 7147, 5472, -2336, 1820, 491, 2802, 149860, 28430, 19064, 16524, - 10898, 8875, -170205, 46189, -44877, 17403, 6190, 25209, 7035, 5673, -2173, - 1894, 574, 2756, 148830, 28230, 18819, 16418, 10789, 8811, -171263, 45045, - -44834, 16858, 6103, 24726, 7014, 5713, -2103, 1877, 518, 2729, 147073, - 27744, 18629, 16277, 10690, 8703, -171720, 44153, -45062, 15951, 5872, - 24429, 7044, 5585, -2082, 1807, 519, 2769, 144791, 27402, 18490, 16126, - 10548, 8635 - } -};
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h b/src/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h deleted file mode 100644 index 4f2e0e7..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h +++ /dev/null
@@ -1,98 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_tables.h - * - * header file for coding tables for the LPC coefficients - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_LPC_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_LPC_TABLES_H_ - -#include "typedefs.h" - - -/* indices of KLT coefficients used */ -extern const WebRtc_UWord16 WebRtcIsacfix_kSelIndGain[12]; - -extern const WebRtc_UWord16 WebRtcIsacfix_kSelIndShape[108]; - -/* cdf array for model indicator */ -extern const WebRtc_UWord16 WebRtcIsacfix_kModelCdf[KLT_NUM_MODELS+1]; - -/* pointer to cdf array for model indicator */ -extern const WebRtc_UWord16 *WebRtcIsacfix_kModelCdfPtr[1]; - -/* initial cdf index for decoder of model indicator */ -extern const WebRtc_UWord16 WebRtcIsacfix_kModelInitIndex[1]; - -/* offset to go from rounded value to quantization index */ -extern const WebRtc_Word16 WebRtcIsacfix_kQuantMinGain[12]; - -extern const WebRtc_Word16 WebRtcIsacfix_kQuantMinShape[108]; - -/* maximum quantization index */ -extern const WebRtc_UWord16 WebRtcIsacfix_kMaxIndGain[12]; - -extern const WebRtc_UWord16 WebRtcIsacfix_kMaxIndShape[108]; - -/* index offset */ -extern const WebRtc_UWord16 WebRtcIsacfix_kOffsetGain[KLT_NUM_MODELS][12]; - -extern const WebRtc_UWord16 WebRtcIsacfix_kOffsetShape[KLT_NUM_MODELS][108]; - -/* initial cdf index for KLT coefficients */ -extern const WebRtc_UWord16 WebRtcIsacfix_kInitIndexGain[KLT_NUM_MODELS][12]; - -extern const WebRtc_UWord16 WebRtcIsacfix_kInitIndexShape[KLT_NUM_MODELS][108]; - -/* offsets for quantizer representation levels */ -extern const WebRtc_UWord16 WebRtcIsacfix_kOfLevelsGain[3]; - -extern const WebRtc_UWord16 WebRtcIsacfix_kOfLevelsShape[3]; - -/* quantizer representation levels */ -extern const WebRtc_Word32 WebRtcIsacfix_kLevelsGainQ17[1176]; - -extern const WebRtc_Word16 WebRtcIsacfix_kLevelsShapeQ10[1735]; - -/* cdf tables for quantizer indices */ -extern const WebRtc_UWord16 WebRtcIsacfix_kCdfGain[1212]; - -extern const WebRtc_UWord16 WebRtcIsacfix_kCdfShape[2059]; - -/* pointers to cdf tables for quantizer indices */ -extern const WebRtc_UWord16 *WebRtcIsacfix_kCdfGainPtr[KLT_NUM_MODELS][12]; - -extern const WebRtc_UWord16 *WebRtcIsacfix_kCdfShapePtr[KLT_NUM_MODELS][108]; - -/* code length for all coefficients using different models */ -extern const WebRtc_Word16 WebRtcIsacfix_kCodeLenGainQ11[392]; - -extern const WebRtc_Word16 WebRtcIsacfix_kCodeLenShapeQ11[577]; - -/* left KLT transforms */ -extern const WebRtc_Word16 WebRtcIsacfix_kT1GainQ15[KLT_NUM_MODELS][4]; - -extern const WebRtc_Word16 WebRtcIsacfix_kT1ShapeQ15[KLT_NUM_MODELS][324]; - -/* right KLT transforms */ -extern const WebRtc_Word16 WebRtcIsacfix_kT2GainQ15[KLT_NUM_MODELS][36]; - -extern const WebRtc_Word16 WebRtcIsacfix_kT2ShapeQ15[KLT_NUM_MODELS][36]; - -/* means of log gains and LAR coefficients */ -extern const WebRtc_Word16 WebRtcIsacfix_kMeansGainQ8[KLT_NUM_MODELS][12]; - -extern const WebRtc_Word32 WebRtcIsacfix_kMeansShapeQ17[3][108]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_LPC_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.c b/src/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.c deleted file mode 100644 index 6af02d8..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.c +++ /dev/null
@@ -1,551 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_estimator.c - * - * Pitch filter functions - * - */ - -#ifdef WEBRTC_ARCH_ARM_NEON -#include <arm_neon.h> -#endif - -#include "pitch_estimator.h" -#include "signal_processing_library.h" -#include "system_wrappers/interface/compile_assert.h" - -/* log2[0.2, 0.5, 0.98] in Q8 */ -static const WebRtc_Word16 kLogLagWinQ8[3] = { - -594, -256, -7 -}; - -/* [1 -0.75 0.25] in Q12 */ -static const WebRtc_Word16 kACoefQ12[3] = { - 4096, -3072, 1024 -}; - - - -static __inline WebRtc_Word32 Log2Q8( WebRtc_UWord32 x ) { - - WebRtc_Word32 zeros, lg2; - WebRtc_Word16 frac; - - zeros=WebRtcSpl_NormU32(x); - frac=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(((WebRtc_UWord32)(WEBRTC_SPL_LSHIFT_W32(x, zeros))&0x7FFFFFFF), 23); - /* log2(magn(i)) */ - - lg2= (WEBRTC_SPL_LSHIFT_W32((31-zeros), 8)+frac); - return lg2; - -} - -static __inline WebRtc_Word16 Exp2Q10(WebRtc_Word16 x) { // Both in and out in Q10 - - WebRtc_Word16 tmp16_1, tmp16_2; - - tmp16_2=(WebRtc_Word16)(0x0400|(x&0x03FF)); - tmp16_1=-(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W16(x,10); - if(tmp16_1>0) - return (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W16(tmp16_2, tmp16_1); - else - return (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1); - -} - - - -/* 1D parabolic interpolation . All input and output values are in Q8 */ -static __inline void Intrp1DQ8(WebRtc_Word32 *x, WebRtc_Word32 *fx, WebRtc_Word32 *y, WebRtc_Word32 *fy) { - - WebRtc_Word16 sign1=1, sign2=1; - WebRtc_Word32 r32, q32, t32, nom32, den32; - WebRtc_Word16 t16, tmp16, tmp16_1; - - if ((fx[0]>0) && (fx[2]>0)) { - r32=fx[1]-fx[2]; - q32=fx[0]-fx[1]; - nom32=q32+r32; - den32=WEBRTC_SPL_MUL_32_16((q32-r32), 2); - if (nom32<0) - sign1=-1; - if (den32<0) - sign2=-1; - - /* t = (q32+r32)/(2*(q32-r32)) = (fx[0]-fx[1] + fx[1]-fx[2])/(2 * fx[0]-fx[1] - (fx[1]-fx[2]))*/ - /* (Signs are removed because WebRtcSpl_DivResultInQ31 can't handle negative numbers) */ - t32=WebRtcSpl_DivResultInQ31(WEBRTC_SPL_MUL_32_16(nom32, sign1),WEBRTC_SPL_MUL_32_16(den32, sign2)); /* t in Q31, without signs */ - - t16=(WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(t32, 23); /* Q8 */ - t16=t16*sign1*sign2; /* t in Q8 with signs */ - - *y = x[0]+t16; /* Q8 */ - // *y = x[1]+t16; /* Q8 */ - - /* The following code calculates fy in three steps */ - /* fy = 0.5 * t * (t-1) * fx[0] + (1-t*t) * fx[1] + 0.5 * t * (t+1) * fx[2]; */ - - /* Part I: 0.5 * t * (t-1) * fx[0] */ - tmp16_1=(WebRtc_Word16)WEBRTC_SPL_MUL_16_16(t16,t16); /* Q8*Q8=Q16 */ - tmp16_1 = WEBRTC_SPL_RSHIFT_W16(tmp16_1,2); /* Q16>>2 = Q14 */ - t16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(t16, 64); /* Q8<<6 = Q14 */ - tmp16 = tmp16_1-t16; - *fy = WEBRTC_SPL_MUL_16_32_RSFT15(tmp16, fx[0]); /* (Q14 * Q8 >>15)/2 = Q8 */ - - /* Part II: (1-t*t) * fx[1] */ - tmp16 = 16384-tmp16_1; /* 1 in Q14 - Q14 */ - *fy += WEBRTC_SPL_MUL_16_32_RSFT14(tmp16, fx[1]);/* Q14 * Q8 >> 14 = Q8 */ - - /* Part III: 0.5 * t * (t+1) * fx[2] */ - tmp16 = tmp16_1+t16; - *fy += WEBRTC_SPL_MUL_16_32_RSFT15(tmp16, fx[2]);/* (Q14 * Q8 >>15)/2 = Q8 */ - } else { - *y = x[0]; - *fy= fx[1]; - } -} - - -static void FindFour32(WebRtc_Word32 *in, WebRtc_Word16 length, WebRtc_Word16 *bestind) -{ - WebRtc_Word32 best[4]= {-100, -100, -100, -100}; - WebRtc_Word16 k; - - for (k=0; k<length; k++) { - if (in[k] > best[3]) { - if (in[k] > best[2]) { - if (in[k] > best[1]) { - if (in[k] > best[0]) { // The Best - best[3] = best[2]; - bestind[3] = bestind[2]; - best[2] = best[1]; - bestind[2] = bestind[1]; - best[1] = best[0]; - bestind[1] = bestind[0]; - best[0] = in[k]; - bestind[0] = k; - } else { // 2nd best - best[3] = best[2]; - bestind[3] = bestind[2]; - best[2] = best[1]; - bestind[2] = bestind[1]; - best[1] = in[k]; - bestind[1] = k; - } - } else { // 3rd best - best[3] = best[2]; - bestind[3] = bestind[2]; - best[2] = in[k]; - bestind[2] = k; - } - } else { // 4th best - best[3] = in[k]; - bestind[3] = k; - } - } - } -} - - - - - -static void PCorr2Q32(const WebRtc_Word16 *in, WebRtc_Word32 *logcorQ8) -{ - WebRtc_Word16 scaling,n,k; - WebRtc_Word32 ysum32,csum32, lys, lcs; - WebRtc_Word32 oneQ8; - - - const WebRtc_Word16 *x, *inptr; - - oneQ8 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)1, 8); // 1.00 in Q8 - - x = in + PITCH_MAX_LAG/2 + 2; - scaling = WebRtcSpl_GetScalingSquare ((WebRtc_Word16 *) in, PITCH_CORR_LEN2, PITCH_CORR_LEN2); - ysum32 = 1; - csum32 = 0; - x = in + PITCH_MAX_LAG/2 + 2; - for (n = 0; n < PITCH_CORR_LEN2; n++) { - ysum32 += WEBRTC_SPL_MUL_16_16_RSFT( (WebRtc_Word16) in[n],(WebRtc_Word16) in[n], scaling); // Q0 - csum32 += WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) x[n],(WebRtc_Word16) in[n], scaling); // Q0 - } - - logcorQ8 += PITCH_LAG_SPAN2 - 1; - - lys=Log2Q8((WebRtc_UWord32) ysum32); // Q8 - lys=WEBRTC_SPL_RSHIFT_W32(lys, 1); //sqrt(ysum); - - if (csum32>0) { - - lcs=Log2Q8((WebRtc_UWord32) csum32); // 2log(csum) in Q8 - - if (lcs>(lys + oneQ8) ){ // csum/sqrt(ysum) > 2 in Q8 - *logcorQ8 = lcs - lys; // log2(csum/sqrt(ysum)) - } else { - *logcorQ8 = oneQ8; // 1.00 - } - - } else { - *logcorQ8 = 0; - } - - - for (k = 1; k < PITCH_LAG_SPAN2; k++) { - inptr = &in[k]; - ysum32 -= WEBRTC_SPL_MUL_16_16_RSFT( (WebRtc_Word16) in[k-1],(WebRtc_Word16) in[k-1], scaling); - ysum32 += WEBRTC_SPL_MUL_16_16_RSFT( (WebRtc_Word16) in[PITCH_CORR_LEN2 + k - 1],(WebRtc_Word16) in[PITCH_CORR_LEN2 + k - 1], scaling); - -#ifdef WEBRTC_ARCH_ARM_NEON - { - int32_t vbuff[4]; - int32x4_t int_32x4_sum = vmovq_n_s32(0); - // Can't shift a Neon register to right with a non-constant shift value. - int32x4_t int_32x4_scale = vdupq_n_s32(-scaling); - // Assert a codition used in loop unrolling at compile-time. - COMPILE_ASSERT(PITCH_CORR_LEN2 %4 == 0); - - for (n = 0; n < PITCH_CORR_LEN2; n += 4) { - int16x4_t int_16x4_x = vld1_s16(&x[n]); - int16x4_t int_16x4_in = vld1_s16(&inptr[n]); - int32x4_t int_32x4 = vmull_s16(int_16x4_x, int_16x4_in); - int_32x4 = vshlq_s32(int_32x4, int_32x4_scale); - int_32x4_sum = vaddq_s32(int_32x4_sum, int_32x4); - } - - // Use vector store to avoid long stall from data trasferring - // from vector to general register. - vst1q_s32(vbuff, int_32x4_sum); - csum32 = vbuff[0] + vbuff[1]; - csum32 += vbuff[2]; - csum32 += vbuff[3]; - } -#else - csum32 = 0; - if(scaling == 0) { - for (n = 0; n < PITCH_CORR_LEN2; n++) { - csum32 += x[n] * inptr[n]; - } - } else { - for (n = 0; n < PITCH_CORR_LEN2; n++) { - csum32 += (x[n] * inptr[n]) >> scaling; - } - } -#endif - - logcorQ8--; - - lys=Log2Q8((WebRtc_UWord32)ysum32); // Q8 - lys=WEBRTC_SPL_RSHIFT_W32(lys, 1); //sqrt(ysum); - - if (csum32>0) { - - lcs=Log2Q8((WebRtc_UWord32) csum32); // 2log(csum) in Q8 - - if (lcs>(lys + oneQ8) ){ // csum/sqrt(ysum) > 2 - *logcorQ8 = lcs - lys; // log2(csum/sqrt(ysum)) - } else { - *logcorQ8 = oneQ8; // 1.00 - } - - } else { - *logcorQ8 = 0; - } - } -} - - - -void WebRtcIsacfix_InitialPitch(const WebRtc_Word16 *in, /* Q0 */ - PitchAnalysisStruct *State, - WebRtc_Word16 *lagsQ7 /* Q7 */ - ) -{ - WebRtc_Word16 buf_dec16[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2+2]; - WebRtc_Word32 *crrvecQ8_1,*crrvecQ8_2; - WebRtc_Word32 cv1q[PITCH_LAG_SPAN2+2],cv2q[PITCH_LAG_SPAN2+2], peakvq[PITCH_LAG_SPAN2+2]; - int k; - WebRtc_Word16 peaks_indq; - WebRtc_Word16 peakiq[PITCH_LAG_SPAN2]; - WebRtc_Word32 corr; - WebRtc_Word32 corr32, corr_max32, corr_max_o32; - WebRtc_Word16 npkq; - WebRtc_Word16 best4q[4]={0,0,0,0}; - WebRtc_Word32 xq[3],yq[1],fyq[1]; - WebRtc_Word32 *fxq; - WebRtc_Word32 best_lag1q, best_lag2q; - WebRtc_Word32 tmp32a,tmp32b,lag32,ratq; - WebRtc_Word16 start; - WebRtc_Word16 oldgQ12, tmp16a, tmp16b, gain_bias16,tmp16c, tmp16d, bias16; - WebRtc_Word32 tmp32c,tmp32d, tmp32e; - WebRtc_Word16 old_lagQ; - WebRtc_Word32 old_lagQ8; - WebRtc_Word32 lagsQ8[4]; - - old_lagQ = State->PFstr_wght.oldlagQ7; // Q7 - old_lagQ8= WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)old_lagQ,1); //Q8 - - oldgQ12= State->PFstr_wght.oldgainQ12; - - crrvecQ8_1=&cv1q[1]; - crrvecQ8_2=&cv2q[1]; - - - /* copy old values from state buffer */ - memcpy(buf_dec16, State->dec_buffer16, WEBRTC_SPL_MUL_16_16(sizeof(WebRtc_Word16), (PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2))); - - /* decimation; put result after the old values */ - WebRtcIsacfix_DecimateAllpass32(in, State->decimator_state32, PITCH_FRAME_LEN, - &buf_dec16[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2]); - - /* low-pass filtering */ - start= PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2; - WebRtcSpl_FilterARFastQ12(&buf_dec16[start],&buf_dec16[start],(WebRtc_Word16*)kACoefQ12,3, PITCH_FRAME_LEN/2); - - /* copy end part back into state buffer */ - for (k = 0; k < (PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2); k++) - State->dec_buffer16[k] = buf_dec16[k+PITCH_FRAME_LEN/2]; - - - /* compute correlation for first and second half of the frame */ - PCorr2Q32(buf_dec16, crrvecQ8_1); - PCorr2Q32(buf_dec16 + PITCH_CORR_STEP2, crrvecQ8_2); - - - /* bias towards pitch lag of previous frame */ - tmp32a = Log2Q8((WebRtc_UWord32) old_lagQ8) - 2304; // log2(0.5*oldlag) in Q8 - tmp32b = WEBRTC_SPL_MUL_16_16_RSFT(oldgQ12,oldgQ12, 10); //Q12 & * 4.0; - gain_bias16 = (WebRtc_Word16) tmp32b; //Q12 - if (gain_bias16 > 3276) gain_bias16 = 3276; // 0.8 in Q12 - - - for (k = 0; k < PITCH_LAG_SPAN2; k++) - { - if (crrvecQ8_1[k]>0) { - tmp32b = Log2Q8((WebRtc_UWord32) (k + (PITCH_MIN_LAG/2-2))); - tmp16a = (WebRtc_Word16) (tmp32b - tmp32a); // Q8 & fabs(ratio)<4 - tmp32c = WEBRTC_SPL_MUL_16_16_RSFT(tmp16a,tmp16a, 6); //Q10 - tmp16b = (WebRtc_Word16) tmp32c; // Q10 & <8 - tmp32d = WEBRTC_SPL_MUL_16_16_RSFT(tmp16b, 177 , 8); // mult with ln2 in Q8 - tmp16c = (WebRtc_Word16) tmp32d; // Q10 & <4 - tmp16d = Exp2Q10((WebRtc_Word16) -tmp16c); //Q10 - tmp32c = WEBRTC_SPL_MUL_16_16_RSFT(gain_bias16,tmp16d,13); // Q10 & * 0.5 - bias16 = (WebRtc_Word16) (1024 + tmp32c); // Q10 - tmp32b = Log2Q8((WebRtc_UWord32) bias16) - 2560; // Q10 in -> Q8 out with 10*2^8 offset - crrvecQ8_1[k] += tmp32b ; // -10*2^8 offset - } - } - - /* taper correlation functions */ - for (k = 0; k < 3; k++) { - crrvecQ8_1[k] += kLogLagWinQ8[k]; - crrvecQ8_2[k] += kLogLagWinQ8[k]; - - crrvecQ8_1[PITCH_LAG_SPAN2-1-k] += kLogLagWinQ8[k]; - crrvecQ8_2[PITCH_LAG_SPAN2-1-k] += kLogLagWinQ8[k]; - } - - - /* Make zeropadded corr vectors */ - cv1q[0]=0; - cv2q[0]=0; - cv1q[PITCH_LAG_SPAN2+1]=0; - cv2q[PITCH_LAG_SPAN2+1]=0; - corr_max32 = 0; - - for (k = 1; k <= PITCH_LAG_SPAN2; k++) - { - - - corr32=crrvecQ8_1[k-1]; - if (corr32 > corr_max32) - corr_max32 = corr32; - - corr32=crrvecQ8_2[k-1]; - corr32 += -4; // Compensate for later (log2(0.99)) - - if (corr32 > corr_max32) - corr_max32 = corr32; - - } - - /* threshold value to qualify as a peak */ - // corr_max32 += -726; // log(0.14)/log(2.0) in Q8 - corr_max32 += -1000; // log(0.14)/log(2.0) in Q8 - corr_max_o32 = corr_max32; - - - /* find peaks in corr1 */ - peaks_indq = 0; - for (k = 1; k <= PITCH_LAG_SPAN2; k++) - { - corr32=cv1q[k]; - if (corr32>corr_max32) { // Disregard small peaks - if ((corr32>=cv1q[k-1]) && (corr32>cv1q[k+1])) { // Peak? - peakvq[peaks_indq] = corr32; - peakiq[peaks_indq++] = k; - } - } - } - - - /* find highest interpolated peak */ - corr_max32=0; - best_lag1q =0; - if (peaks_indq > 0) { - FindFour32(peakvq, (WebRtc_Word16) peaks_indq, best4q); - npkq = WEBRTC_SPL_MIN(peaks_indq, 4); - - for (k=0;k<npkq;k++) { - - lag32 = peakiq[best4q[k]]; - fxq = &cv1q[peakiq[best4q[k]]-1]; - xq[0]= lag32; - xq[0] = WEBRTC_SPL_LSHIFT_W32(xq[0], 8); - Intrp1DQ8(xq, fxq, yq, fyq); - - tmp32a= Log2Q8((WebRtc_UWord32) *yq) - 2048; // offset 8*2^8 - /* Bias towards short lags */ - /* log(pow(0.8, log(2.0 * *y )))/log(2.0) */ - tmp32b= WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) tmp32a, -42, 8); - tmp32c= tmp32b + 256; - *fyq += tmp32c; - if (*fyq > corr_max32) { - corr_max32 = *fyq; - best_lag1q = *yq; - } - } - tmp32a = best_lag1q - OFFSET_Q8; - tmp32b = WEBRTC_SPL_LSHIFT_W32(tmp32a, 1); - lagsQ8[0] = tmp32b + PITCH_MIN_LAG_Q8; - lagsQ8[1] = lagsQ8[0]; - } else { - lagsQ8[0] = old_lagQ8; - lagsQ8[1] = lagsQ8[0]; - } - - /* Bias towards constant pitch */ - tmp32a = lagsQ8[0] - PITCH_MIN_LAG_Q8; - ratq = WEBRTC_SPL_RSHIFT_W32(tmp32a, 1) + OFFSET_Q8; - - for (k = 1; k <= PITCH_LAG_SPAN2; k++) - { - tmp32a = WEBRTC_SPL_LSHIFT_W32(k, 7); // 0.5*k Q8 - tmp32b = (WebRtc_Word32) (WEBRTC_SPL_LSHIFT_W32(tmp32a, 1)) - ratq; // Q8 - tmp32c = WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) tmp32b, (WebRtc_Word16) tmp32b, 8); // Q8 - - tmp32b = (WebRtc_Word32) tmp32c + (WebRtc_Word32) WEBRTC_SPL_RSHIFT_W32(ratq, 1); // (k-r)^2 + 0.5 * r Q8 - tmp32c = Log2Q8((WebRtc_UWord32) tmp32a) - 2048; // offset 8*2^8 , log2(0.5*k) Q8 - tmp32d = Log2Q8((WebRtc_UWord32) tmp32b) - 2048; // offset 8*2^8 , log2(0.5*k) Q8 - tmp32e = tmp32c -tmp32d; - - cv2q[k] += WEBRTC_SPL_RSHIFT_W32(tmp32e, 1); - - } - - /* find peaks in corr2 */ - corr_max32 = corr_max_o32; - peaks_indq = 0; - - for (k = 1; k <= PITCH_LAG_SPAN2; k++) - { - corr=cv2q[k]; - if (corr>corr_max32) { // Disregard small peaks - if ((corr>=cv2q[k-1]) && (corr>cv2q[k+1])) { // Peak? - peakvq[peaks_indq] = corr; - peakiq[peaks_indq++] = k; - } - } - } - - - - /* find highest interpolated peak */ - corr_max32 = 0; - best_lag2q =0; - if (peaks_indq > 0) { - - FindFour32(peakvq, (WebRtc_Word16) peaks_indq, best4q); - npkq = WEBRTC_SPL_MIN(peaks_indq, 4); - for (k=0;k<npkq;k++) { - - lag32 = peakiq[best4q[k]]; - fxq = &cv2q[peakiq[best4q[k]]-1]; - - xq[0]= lag32; - xq[0] = WEBRTC_SPL_LSHIFT_W32(xq[0], 8); - Intrp1DQ8(xq, fxq, yq, fyq); - - /* Bias towards short lags */ - /* log(pow(0.8, log(2.0f * *y )))/log(2.0f) */ - tmp32a= Log2Q8((WebRtc_UWord32) *yq) - 2048; // offset 8*2^8 - tmp32b= WEBRTC_SPL_MUL_16_16_RSFT((WebRtc_Word16) tmp32a, -82, 8); - tmp32c= tmp32b + 256; - *fyq += tmp32c; - if (*fyq > corr_max32) { - corr_max32 = *fyq; - best_lag2q = *yq; - } - } - - tmp32a = best_lag2q - OFFSET_Q8; - tmp32b = WEBRTC_SPL_LSHIFT_W32(tmp32a, 1); - lagsQ8[2] = tmp32b + PITCH_MIN_LAG_Q8; - lagsQ8[3] = lagsQ8[2]; - } else { - lagsQ8[2] = lagsQ8[0]; - lagsQ8[3] = lagsQ8[0]; - } - - lagsQ7[0]=(WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(lagsQ8[0], 1); - lagsQ7[1]=(WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(lagsQ8[1], 1); - lagsQ7[2]=(WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(lagsQ8[2], 1); - lagsQ7[3]=(WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(lagsQ8[3], 1); - - -} - - - -void WebRtcIsacfix_PitchAnalysis(const WebRtc_Word16 *inn, /* PITCH_FRAME_LEN samples */ - WebRtc_Word16 *outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ - PitchAnalysisStruct *State, - WebRtc_Word16 *PitchLags_Q7, - WebRtc_Word16 *PitchGains_Q12) -{ - WebRtc_Word16 inbufQ0[PITCH_FRAME_LEN + QLOOKAHEAD]; - WebRtc_Word16 k; - - /* inital pitch estimate */ - WebRtcIsacfix_InitialPitch(inn, State, PitchLags_Q7); - - - /* Calculate gain */ - WebRtcIsacfix_PitchFilterGains(inn, &(State->PFstr_wght), PitchLags_Q7, PitchGains_Q12); - - /* concatenate previous input's end and current input */ - for (k = 0; k < QLOOKAHEAD; k++) { - inbufQ0[k] = State->inbuf[k]; - } - for (k = 0; k < PITCH_FRAME_LEN; k++) { - inbufQ0[k+QLOOKAHEAD] = (WebRtc_Word16) inn[k]; - } - - /* lookahead pitch filtering for masking analysis */ - WebRtcIsacfix_PitchFilter(inbufQ0, outQ0, &(State->PFstr), PitchLags_Q7,PitchGains_Q12, 2); - - - /* store last part of input */ - for (k = 0; k < QLOOKAHEAD; k++) { - State->inbuf[k] = inbufQ0[k + PITCH_FRAME_LEN]; - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h b/src/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h deleted file mode 100644 index 6225256..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h +++ /dev/null
@@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_estimator.h - * - * Pitch functions - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_ESTIMATOR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_ESTIMATOR_H_ - -#include "structs.h" - -void WebRtcIsacfix_PitchAnalysis(const WebRtc_Word16 *in, /* PITCH_FRAME_LEN samples */ - WebRtc_Word16 *outQ0, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ - PitchAnalysisStruct *State, - WebRtc_Word16 *lagsQ7, - WebRtc_Word16 *PitchGains_Q12); - -void WebRtcIsacfix_InitialPitch(const WebRtc_Word16 *in, - PitchAnalysisStruct *State, - WebRtc_Word16 *qlags); - -void WebRtcIsacfix_PitchFilter(WebRtc_Word16 *indatFix, - WebRtc_Word16 *outdatQQ, - PitchFiltstr *pfp, - WebRtc_Word16 *lagsQ7, - WebRtc_Word16 *gainsQ12, - WebRtc_Word16 type); - -void WebRtcIsacfix_PitchFilterCore(int loopNumber, - WebRtc_Word16 gain, - int index, - WebRtc_Word16 sign, - WebRtc_Word16* inputState, - WebRtc_Word16* outputBuff2, - const WebRtc_Word16* coefficient, - WebRtc_Word16* inputBuf, - WebRtc_Word16* outputBuf, - int* index2); - -void WebRtcIsacfix_PitchFilterGains(const WebRtc_Word16 *indatQ0, - PitchFiltstr *pfp, - WebRtc_Word16 *lagsQ7, - WebRtc_Word16 *gainsQ12); - -void WebRtcIsacfix_DecimateAllpass32(const WebRtc_Word16 *in, - WebRtc_Word32 *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */ - WebRtc_Word16 N, /* number of input samples */ - WebRtc_Word16 *out); /* array of size N/2 */ - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_ESTIMATOR_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c b/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c deleted file mode 100644 index f30293e..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c +++ /dev/null
@@ -1,280 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_filter.c - * - * Pitch filter functions - * - */ - -#include "common_audio/signal_processing/include/signal_processing_library.h" -#include "modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h" -#include "modules/audio_coding/codecs/isac/fix/source/settings.h" -#include "modules/audio_coding/codecs/isac/fix/source/structs.h" -#include "system_wrappers/interface/compile_assert.h" - -// Number of segments in a pitch subframe. -static const int kSegments = 5; - -// A division factor of 1/5 in Q15. -static const WebRtc_Word16 kDivFactor = 6553; - -// Filter coefficicients in Q15. -static const WebRtc_Word16 kDampFilter[PITCH_DAMPORDER] = { - -2294, 8192, 20972, 8192, -2294 -}; - -// Interpolation coefficients; generated by design_pitch_filter.m. -// Coefficients are stored in Q14. -static const WebRtc_Word16 kIntrpCoef[PITCH_FRACS][PITCH_FRACORDER] = { - {-367, 1090, -2706, 9945, 10596, -3318, 1626, -781, 287}, - {-325, 953, -2292, 7301, 12963, -3320, 1570, -743, 271}, - {-240, 693, -1622, 4634, 14809, -2782, 1262, -587, 212}, - {-125, 358, -817, 2144, 15982, -1668, 721, -329, 118}, - { 0, 0, -1, 1, 16380, 1, -1, 0, 0}, - { 118, -329, 721, -1668, 15982, 2144, -817, 358, -125}, - { 212, -587, 1262, -2782, 14809, 4634, -1622, 693, -240}, - { 271, -743, 1570, -3320, 12963, 7301, -2292, 953, -325} -}; - -// Function prototype for pitch filtering. -// TODO(Turaj): Add descriptions of input and output parameters. -void WebRtcIsacfix_PitchFilterCore(int loopNumber, - WebRtc_Word16 gain, - int index, - WebRtc_Word16 sign, - WebRtc_Word16* inputState, - WebRtc_Word16* outputBuf2, - const WebRtc_Word16* coefficient, - WebRtc_Word16* inputBuf, - WebRtc_Word16* outputBuf, - int* index2); - -static __inline WebRtc_Word32 CalcLrIntQ(WebRtc_Word32 fixVal, - WebRtc_Word16 qDomain) { - WebRtc_Word32 intgr; - WebRtc_Word32 roundVal; - - roundVal = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)1, qDomain - 1); - intgr = WEBRTC_SPL_RSHIFT_W32(fixVal + roundVal, qDomain); - - return intgr; -} - -void WebRtcIsacfix_PitchFilter(WebRtc_Word16* indatQQ, // Q10 if type is 1 or 4, - // Q0 if type is 2. - WebRtc_Word16* outdatQQ, - PitchFiltstr* pfp, - WebRtc_Word16* lagsQ7, - WebRtc_Word16* gainsQ12, - WebRtc_Word16 type) { - int k, ind, cnt; - WebRtc_Word16 sign = 1; - WebRtc_Word16 inystateQQ[PITCH_DAMPORDER]; - WebRtc_Word16 ubufQQ[PITCH_INTBUFFSIZE + QLOOKAHEAD]; - const WebRtc_Word16 Gain = 21299; // 1.3 in Q14 - WebRtc_Word16 oldLagQ7; - WebRtc_Word16 oldGainQ12, lagdeltaQ7, curLagQ7, gaindeltaQ12, curGainQ12; - int indW32 = 0, frcQQ = 0; - WebRtc_Word32 tmpW32; - const WebRtc_Word16* fracoeffQQ = NULL; - - // Assumptions in ARM assembly for WebRtcIsacfix_PitchFilterCoreARM(). - COMPILE_ASSERT(PITCH_FRACORDER == 9); - COMPILE_ASSERT(PITCH_DAMPORDER == 5); - - // Set up buffer and states. - memcpy(ubufQQ, pfp->ubufQQ, sizeof(pfp->ubufQQ)); - memcpy(inystateQQ, pfp->ystateQQ, sizeof(inystateQQ)); - - // Get old lag and gain value from memory. - oldLagQ7 = pfp->oldlagQ7; - oldGainQ12 = pfp->oldgainQ12; - - if (type == 4) { - sign = -1; - - // Make output more periodic. - for (k = 0; k < PITCH_SUBFRAMES; k++) { - gainsQ12[k] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - gainsQ12[k], Gain, 14); - } - } - - // No interpolation if pitch lag step is big. - if ((WEBRTC_SPL_MUL_16_16_RSFT(lagsQ7[0], 3, 1) < oldLagQ7) || - (lagsQ7[0] > WEBRTC_SPL_MUL_16_16_RSFT(oldLagQ7, 3, 1))) { - oldLagQ7 = lagsQ7[0]; - oldGainQ12 = gainsQ12[0]; - } - - ind = 0; - - for (k = 0; k < PITCH_SUBFRAMES; k++) { - // Calculate interpolation steps. - lagdeltaQ7 = lagsQ7[k] - oldLagQ7; - lagdeltaQ7 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( - lagdeltaQ7, kDivFactor, 15); - curLagQ7 = oldLagQ7; - gaindeltaQ12 = gainsQ12[k] - oldGainQ12; - gaindeltaQ12 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT( - gaindeltaQ12, kDivFactor, 15); - - curGainQ12 = oldGainQ12; - oldLagQ7 = lagsQ7[k]; - oldGainQ12 = gainsQ12[k]; - - // Each frame has 4 60-sample pitch subframes, and each subframe has 5 - // 12-sample segments. Each segment need to be processed with - // newly-updated parameters, so we break the pitch filtering into - // two for-loops (5 x 12) below. It's also why kDivFactor = 0.2 (in Q15). - for (cnt = 0; cnt < kSegments; cnt++) { - // Update parameters for each segment. - curGainQ12 += gaindeltaQ12; - curLagQ7 += lagdeltaQ7; - indW32 = CalcLrIntQ(curLagQ7, 7); - tmpW32 = WEBRTC_SPL_LSHIFT_W32(indW32, 7); - tmpW32 -= curLagQ7; - frcQQ = WEBRTC_SPL_RSHIFT_W32(tmpW32, 4); - frcQQ += 4; - - if (frcQQ == PITCH_FRACS) { - frcQQ = 0; - } - fracoeffQQ = kIntrpCoef[frcQQ]; - - // Pitch filtering. - WebRtcIsacfix_PitchFilterCore(PITCH_SUBFRAME_LEN / kSegments, curGainQ12, - indW32, sign, inystateQQ, ubufQQ, fracoeffQQ, indatQQ, outdatQQ, &ind); - } - } - - // Export buffer and states. - memcpy(pfp->ubufQQ, ubufQQ + PITCH_FRAME_LEN, sizeof(pfp->ubufQQ)); - memcpy(pfp->ystateQQ, inystateQQ, sizeof(pfp->ystateQQ)); - - pfp->oldlagQ7 = oldLagQ7; - pfp->oldgainQ12 = oldGainQ12; - - if (type == 2) { - // Filter look-ahead segment. - WebRtcIsacfix_PitchFilterCore(QLOOKAHEAD, curGainQ12, indW32, 1, inystateQQ, - ubufQQ, fracoeffQQ, indatQQ, outdatQQ, &ind); - } -} - - -void WebRtcIsacfix_PitchFilterGains(const WebRtc_Word16* indatQ0, - PitchFiltstr* pfp, - WebRtc_Word16* lagsQ7, - WebRtc_Word16* gainsQ12) { - int k, n, m, ind, pos, pos3QQ; - - WebRtc_Word16 ubufQQ[PITCH_INTBUFFSIZE]; - WebRtc_Word16 oldLagQ7, lagdeltaQ7, curLagQ7; - const WebRtc_Word16* fracoeffQQ = NULL; - WebRtc_Word16 scale; - WebRtc_Word16 cnt = 0, frcQQ, indW16 = 0, tmpW16; - WebRtc_Word32 tmpW32, tmp2W32, csum1QQ, esumxQQ; - - // Set up buffer and states. - memcpy(ubufQQ, pfp->ubufQQ, sizeof(pfp->ubufQQ)); - oldLagQ7 = pfp->oldlagQ7; - - // No interpolation if pitch lag step is big. - if ((WEBRTC_SPL_MUL_16_16_RSFT(lagsQ7[0], 3, 1) < oldLagQ7) || - (lagsQ7[0] > WEBRTC_SPL_MUL_16_16_RSFT(oldLagQ7, 3, 1))) { - oldLagQ7 = lagsQ7[0]; - } - - ind = 0; - pos = ind + PITCH_BUFFSIZE; - scale = 0; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - - // Calculate interpolation steps. - lagdeltaQ7 = lagsQ7[k] - oldLagQ7; - lagdeltaQ7 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( - lagdeltaQ7, kDivFactor, 15); - curLagQ7 = oldLagQ7; - oldLagQ7 = lagsQ7[k]; - - csum1QQ = 1; - esumxQQ = 1; - - // Same as function WebRtcIsacfix_PitchFilter(), we break the pitch - // filtering into two for-loops (5 x 12) below. - for (cnt = 0; cnt < kSegments; cnt++) { - // Update parameters for each segment. - curLagQ7 += lagdeltaQ7; - indW16 = (WebRtc_Word16)CalcLrIntQ(curLagQ7, 7); - tmpW16 = WEBRTC_SPL_LSHIFT_W16(indW16, 7); - tmpW16 -= curLagQ7; - frcQQ = WEBRTC_SPL_RSHIFT_W16(tmpW16, 4); - frcQQ += 4; - - if (frcQQ == PITCH_FRACS) { - frcQQ = 0; - } - fracoeffQQ = kIntrpCoef[frcQQ]; - - pos3QQ = pos - (indW16 + 4); - - for (n = 0; n < PITCH_SUBFRAME_LEN / kSegments; n++) { - // Filter to get fractional pitch. - - tmpW32 = 0; - for (m = 0; m < PITCH_FRACORDER; m++) { - tmpW32 += WEBRTC_SPL_MUL_16_16(ubufQQ[pos3QQ + m], fracoeffQQ[m]); - } - - // Subtract from input and update buffer. - ubufQQ[pos] = indatQ0[ind]; - - tmp2W32 = WEBRTC_SPL_MUL_16_32_RSFT14(indatQ0[ind], tmpW32); - tmpW32 += 8192; - tmpW16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 14); - tmpW32 = WEBRTC_SPL_MUL_16_16(tmpW16, tmpW16); - - if ((tmp2W32 > 1073700000) || (csum1QQ > 1073700000) || - (tmpW32 > 1073700000) || (esumxQQ > 1073700000)) { // 2^30 - scale++; - csum1QQ = WEBRTC_SPL_RSHIFT_W32(csum1QQ, 1); - esumxQQ = WEBRTC_SPL_RSHIFT_W32(esumxQQ, 1); - } - tmp2W32 = WEBRTC_SPL_RSHIFT_W32(tmp2W32, scale); - csum1QQ += tmp2W32; - tmpW32 = WEBRTC_SPL_RSHIFT_W32(tmpW32, scale); - esumxQQ += tmpW32; - - ind++; - pos++; - pos3QQ++; - } - } - - if (csum1QQ < esumxQQ) { - tmp2W32 = WebRtcSpl_DivResultInQ31(csum1QQ, esumxQQ); - - // Gain should be half the correlation. - tmpW32 = WEBRTC_SPL_RSHIFT_W32(tmp2W32, 20); - } else { - tmpW32 = 4096; - } - gainsQ12[k] = (WebRtc_Word16)WEBRTC_SPL_SAT(PITCH_MAX_GAIN_Q12, tmpW32, 0); - } - - // Export buffer and states. - memcpy(pfp->ubufQQ, ubufQQ + PITCH_FRAME_LEN, sizeof(pfp->ubufQQ)); - pfp->oldlagQ7 = lagsQ7[PITCH_SUBFRAMES - 1]; - pfp->oldgainQ12 = gainsQ12[PITCH_SUBFRAMES - 1]; - -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter_armv6.S b/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter_armv6.S deleted file mode 100644 index 7ce3b6f..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter_armv6.S +++ /dev/null
@@ -1,147 +0,0 @@ -@ -@ Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -@ -@ Use of this source code is governed by a BSD-style license -@ that can be found in the LICENSE file in the root of the source -@ tree. An additional intellectual property rights grant can be found -@ in the file PATENTS. All contributing project authors may -@ be found in the AUTHORS file in the root of the source tree. -@ - -@ Contains the core loop routine for the pitch filter function in iSAC, -@ optimized for ARMv7 platforms. -@ -@ Output is bit-exact with the reference C code in pitch_filter.c. - -#include "settings.h" - -.arch armv6 -.align 2 -.global WebRtcIsacfix_PitchFilterCore - - -@ void WebRtcIsacfix_PitchFilterCore(int loopNumber, -@ WebRtc_Word16 gain, -@ int index, -@ WebRtc_Word16 sign, -@ WebRtc_Word16* inputState, -@ WebRtc_Word16* outputBuf2, -@ const WebRtc_Word16* coefficient, -@ WebRtc_Word16* inputBuf, -@ WebRtc_Word16* outputBuf, -@ int* index2) { - -WebRtcIsacfix_PitchFilterCore: -.fnstart - push {r4-r11} - sub sp, #8 - - str r0, [sp] @ loopNumber - str r3, [sp, #4] @ sign - ldr r3, [sp, #44] @ outputBuf2 - ldr r6, [sp, #60] @ index2 - ldr r7, [r6] @ *index2 - ldr r8, [sp, #52] @ inputBuf - ldr r12, [sp, #56] @ outputBuf - - add r4, r7, r0 - str r4, [r6] @ Store return value to index2. - - mov r10, r7, asl #1 - add r12, r10 @ &outputBuf[*index2] - add r8, r10 @ &inputBuf[*index2] - - add r4, r7, #PITCH_BUFFSIZE @ *index2 + PITCH_BUFFSIZE - add r6, r3, r4, lsl #1 @ &outputBuf2[*index2 + PITCH_BUFFSIZE] - sub r4, r2 @ r2: index - sub r4, #2 @ *index2 + PITCH_BUFFSIZE - index - 2 - add r3, r4, lsl #1 @ &ubufQQpos2[*index2] - ldr r9, [sp, #48] @ coefficient - -LOOP: -@ Usage of registers in the loop: -@ r0: loop counter -@ r1: gain -@ r2: tmpW32 -@ r3: &ubufQQpos2[] -@ r6: &outputBuf2[] -@ r8: &inputBuf[] -@ r9: &coefficient[] -@ r12: &outputBuf[] -@ r4, r5, r7, r10, r11: scratch - - @ Filter to get fractional pitch. - @ The pitch filter loop here is unrolled with 9 multipications. - pld [r3] - ldr r10, [r3], #4 @ ubufQQpos2[*index2 + 0, *index2 + 1] - ldr r4, [r9], #4 @ coefficient[0, 1] - ldr r11, [r3], #4 - ldr r5, [r9], #4 - smuad r2, r10, r4 - smlad r2, r11, r5, r2 - - ldr r10, [r3], #4 - ldr r4, [r9], #4 - ldr r11, [r3], #4 - ldr r5, [r9], #4 - smlad r2, r10, r4, r2 - ldrh r10, [r3], #-14 @ r3 back to &ubufQQpos2[*index2]. - ldrh r4, [r9], #-16 @ r9 back to &coefficient[0]. - smlad r2, r11, r5, r2 - smlabb r2, r10, r4, r2 - - @ Saturate to avoid overflow in tmpW16. - asr r2, #1 - add r4, r2, #0x1000 - ssat r7, #16, r4, asr #13 - - @ Shift low pass filter state, and excute the low pass filter. - @ The memmove() and the low pass filter loop are unrolled and mixed. - smulbb r5, r1, r7 - add r7, r5, #0x800 - asr r7, #12 @ Get the value for inputState[0]. - ldr r11, [sp, #40] @ inputState - pld [r11] - adr r10, kDampFilter - ldrsh r4, [r10], #2 @ kDampFilter[0] - mul r2, r7, r4 - ldr r4, [r11] @ inputState[0, 1], before shift. - strh r7, [r11] @ inputState[0], after shift. - ldr r5, [r11, #4] @ inputState[2, 3], before shift. - ldr r7, [r10], #4 @ kDampFilter[1, 2] - ldr r10, [r10] @ kDampFilter[3, 4] - str r4, [r11, #2] @ inputState[1, 2], after shift. - str r5, [r11, #6] @ inputState[3, 4], after shift. - smlad r2, r4, r7, r2 - smlad r2, r5, r10, r2 - - @ Saturate to avoid overflow. - @ First shift the sample to the range of [0xC0000000, 0x3FFFFFFF], - @ to avoid overflow in the next saturation step. - asr r2, #1 - add r10, r2, #0x2000 - ssat r10, #16, r10, asr #14 - - @ Subtract from input and update buffer. - ldr r11, [sp, #4] @ sign - ldrsh r4, [r8] - ldrsh r7, [r8], #2 @ inputBuf[*index2] - smulbb r5, r11, r10 - subs r0, #1 - sub r4, r5 - ssat r2, #16, r4 - strh r2, [r12], #2 @ outputBuf[*index2] - - add r2, r7 - ssat r2, #16, r2 - strh r2, [r6], #2 @ outputBuff2[*index2 + PITCH_BUFFSIZE] - bgt LOOP - - add sp, #8 - pop {r4-r11} - bx lr -.fnend - -.align 2 -kDampFilter: - .short -2294, 8192, 20972, 8192, -2294
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter_c.c b/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter_c.c deleted file mode 100644 index 29b4b6a..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_filter_c.c +++ /dev/null
@@ -1,74 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "common_audio/signal_processing/include/signal_processing_library.h" -#include "modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h" - -/* Filter coefficicients in Q15. */ -static const WebRtc_Word16 kDampFilter[PITCH_DAMPORDER] = { - -2294, 8192, 20972, 8192, -2294 -}; - -void WebRtcIsacfix_PitchFilterCore(int loopNumber, - WebRtc_Word16 gain, - int index, - WebRtc_Word16 sign, - WebRtc_Word16* inputState, - WebRtc_Word16* outputBuf2, - const WebRtc_Word16* coefficient, - WebRtc_Word16* inputBuf, - WebRtc_Word16* outputBuf, - int* index2) { - int i = 0, j = 0; /* Loop counters. */ - WebRtc_Word16* ubufQQpos2 = &outputBuf2[PITCH_BUFFSIZE - (index + 2)]; - WebRtc_Word16 tmpW16 = 0; - - for (i = 0; i < loopNumber; i++) { - WebRtc_Word32 tmpW32 = 0; - - /* Filter to get fractional pitch. */ - for (j = 0; j < PITCH_FRACORDER; j++) { - tmpW32 += WEBRTC_SPL_MUL_16_16(ubufQQpos2[*index2 + j], coefficient[j]); - } - - /* Saturate to avoid overflow in tmpW16. */ - tmpW32 = WEBRTC_SPL_SAT(536862719, tmpW32, -536879104); - tmpW32 += 8192; - tmpW16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 14); - - /* Shift low pass filter state. */ - memmove(&inputState[1], &inputState[0], - (PITCH_DAMPORDER - 1) * sizeof(WebRtc_Word16)); - inputState[0] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( - gain, tmpW16, 12); - - /* Low pass filter. */ - tmpW32 = 0; - /* TODO(kma): Define a static inline function WebRtcSpl_DotProduct() - in spl_inl.h to replace this and other similar loops. */ - for (j = 0; j < PITCH_DAMPORDER; j++) { - tmpW32 += WEBRTC_SPL_MUL_16_16(inputState[j], kDampFilter[j]); - } - - /* Saturate to avoid overflow in tmpW16. */ - tmpW32 = WEBRTC_SPL_SAT(1073725439, tmpW32, -1073758208); - tmpW32 += 16384; - tmpW16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 15); - - /* Subtract from input and update buffer. */ - tmpW32 = inputBuf[*index2] - WEBRTC_SPL_MUL_16_16(sign, tmpW16); - outputBuf[*index2] = WebRtcSpl_SatW32ToW16(tmpW32); - tmpW32 = inputBuf[*index2] + outputBuf[*index2]; - outputBuf2[*index2 + PITCH_BUFFSIZE] = WebRtcSpl_SatW32ToW16(tmpW32); - - (*index2)++; - } -} -
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.c b/src/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.c deleted file mode 100644 index 50ea658..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.c +++ /dev/null
@@ -1,149 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_gain_tables.c - * - * This file contains tables for the pitch filter side-info in the entropy coder. - * - */ - -#include "pitch_gain_tables.h" - - -/********************* Pitch Filter Gain Coefficient Tables ************************/ - -/* cdf for quantized pitch filter gains */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchGainCdf[255] = { - 0, 2, 4, 6, 64, 901, 903, 905, 16954, 16956, - 16961, 17360, 17362, 17364, 17366, 17368, 17370, 17372, 17374, 17411, - 17514, 17516, 17583, 18790, 18796, 18802, 20760, 20777, 20782, 21722, - 21724, 21728, 21738, 21740, 21742, 21744, 21746, 21748, 22224, 22227, - 22230, 23214, 23229, 23239, 25086, 25108, 25120, 26088, 26094, 26098, - 26175, 26177, 26179, 26181, 26183, 26185, 26484, 26507, 26522, 27705, - 27731, 27750, 29767, 29799, 29817, 30866, 30883, 30885, 31025, 31029, - 31031, 31033, 31035, 31037, 31114, 31126, 31134, 32687, 32722, 32767, - 35718, 35742, 35757, 36943, 36952, 36954, 37115, 37128, 37130, 37132, - 37134, 37136, 37143, 37145, 37152, 38843, 38863, 38897, 47458, 47467, - 47474, 49040, 49061, 49063, 49145, 49157, 49159, 49161, 49163, 49165, - 49167, 49169, 49171, 49757, 49770, 49782, 61333, 61344, 61346, 62860, - 62883, 62885, 62887, 62889, 62891, 62893, 62895, 62897, 62899, 62901, - 62903, 62905, 62907, 62909, 65496, 65498, 65500, 65521, 65523, 65525, - 65527, 65529, 65531, 65533, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535 -}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsacfix_kLowerlimiGain[3] = { - -7, -2, -1 -}; - -const WebRtc_Word16 WebRtcIsacfix_kUpperlimitGain[3] = { - 0, 3, 1 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kMultsGain[2] = { - 18, 3 -}; - -/* size of cdf table */ -const WebRtc_UWord16 WebRtcIsacfix_kCdfTableSizeGain[1] = { - 256 -}; - -/* mean values of pitch filter gains in FIXED point Q12 */ -const WebRtc_Word16 WebRtcIsacfix_kPitchGain1[144] = { - 843, 1092, 1336, 1222, 1405, 1656, 1500, 1815, 1843, 1838, 1839, - 1843, 1843, 1843, 1843, 1843, 1843, 1843, 814, 846, 1092, 1013, - 1174, 1383, 1391, 1511, 1584, 1734, 1753, 1843, 1843, 1843, 1843, - 1843, 1843, 1843, 524, 689, 777, 845, 947, 1069, 1090, 1263, - 1380, 1447, 1559, 1676, 1645, 1749, 1843, 1843, 1843, 1843, 81, - 477, 563, 611, 706, 806, 849, 1012, 1192, 1128, 1330, 1489, - 1425, 1576, 1826, 1741, 1843, 1843, 0, 290, 305, 356, 488, - 575, 602, 741, 890, 835, 1079, 1196, 1182, 1376, 1519, 1506, - 1680, 1843, 0, 47, 97, 69, 289, 381, 385, 474, 617, - 664, 803, 1079, 935, 1160, 1269, 1265, 1506, 1741, 0, 0, - 0, 0, 112, 120, 190, 283, 442, 343, 526, 809, 684, - 935, 1134, 1020, 1265, 1506, 0, 0, 0, 0, 0, 0, - 0, 111, 256, 87, 373, 597, 430, 684, 935, 770, 1020, - 1265 -}; - -const WebRtc_Word16 WebRtcIsacfix_kPitchGain2[144] = { - 1760, 1525, 1285, 1747, 1671, 1393, 1843, 1826, 1555, 1843, 1784, - 1606, 1843, 1843, 1711, 1843, 1843, 1814, 1389, 1275, 1040, 1564, - 1414, 1252, 1610, 1495, 1343, 1753, 1592, 1405, 1804, 1720, 1475, - 1843, 1814, 1581, 1208, 1061, 856, 1349, 1148, 994, 1390, 1253, - 1111, 1495, 1343, 1178, 1770, 1465, 1234, 1814, 1581, 1342, 1040, - 793, 713, 1053, 895, 737, 1128, 1003, 861, 1277, 1094, 981, - 1475, 1192, 1019, 1581, 1342, 1098, 855, 570, 483, 833, 648, - 540, 948, 744, 572, 1009, 844, 636, 1234, 934, 685, 1342, - 1217, 984, 537, 318, 124, 603, 423, 350, 687, 479, 322, - 791, 581, 430, 987, 671, 488, 1098, 849, 597, 283, 27, - 0, 397, 222, 38, 513, 271, 124, 624, 325, 157, 737, - 484, 233, 849, 597, 343, 27, 0, 0, 141, 0, 0, - 256, 69, 0, 370, 87, 0, 484, 229, 0, 597, 343, - 87 -}; - -const WebRtc_Word16 WebRtcIsacfix_kPitchGain3[144] = { - 1843, 1843, 1711, 1843, 1818, 1606, 1843, 1827, 1511, 1814, 1639, - 1393, 1760, 1525, 1285, 1656, 1419, 1176, 1835, 1718, 1475, 1841, - 1650, 1387, 1648, 1498, 1287, 1600, 1411, 1176, 1522, 1299, 1040, - 1419, 1176, 928, 1773, 1461, 1128, 1532, 1355, 1202, 1429, 1260, - 1115, 1398, 1151, 1025, 1172, 1080, 790, 1176, 928, 677, 1475, - 1147, 1019, 1276, 1096, 922, 1214, 1010, 901, 1057, 893, 800, - 1040, 796, 734, 928, 677, 424, 1137, 897, 753, 1120, 830, - 710, 875, 751, 601, 795, 642, 583, 790, 544, 475, 677, - 474, 140, 987, 750, 482, 697, 573, 450, 691, 487, 303, - 661, 394, 332, 537, 303, 220, 424, 168, 0, 737, 484, - 229, 624, 348, 153, 441, 261, 136, 397, 166, 51, 283, - 27, 0, 168, 0, 0, 484, 229, 0, 370, 57, 0, - 256, 43, 0, 141, 0, 0, 27, 0, 0, 0, 0, - 0 -}; - - -const WebRtc_Word16 WebRtcIsacfix_kPitchGain4[144] = { - 1843, 1843, 1843, 1843, 1841, 1843, 1500, 1821, 1843, 1222, 1434, - 1656, 843, 1092, 1336, 504, 757, 1007, 1843, 1843, 1843, 1838, - 1791, 1843, 1265, 1505, 1599, 965, 1219, 1425, 730, 821, 1092, - 249, 504, 757, 1783, 1819, 1843, 1351, 1567, 1727, 1096, 1268, - 1409, 805, 961, 1131, 444, 670, 843, 0, 249, 504, 1425, - 1655, 1743, 1096, 1324, 1448, 822, 1019, 1199, 490, 704, 867, - 81, 450, 555, 0, 0, 249, 1247, 1428, 1530, 881, 1073, - 1283, 610, 759, 939, 278, 464, 645, 0, 200, 270, 0, - 0, 0, 935, 1163, 1410, 528, 790, 1068, 377, 499, 717, - 173, 240, 274, 0, 43, 62, 0, 0, 0, 684, 935, - 1182, 343, 551, 735, 161, 262, 423, 0, 55, 27, 0, - 0, 0, 0, 0, 0, 430, 684, 935, 87, 377, 597, - 0, 46, 256, 0, 0, 0, 0, 0, 0, 0, 0, - 0 -}; - - - -/* transform matrix in Q12*/ -const WebRtc_Word16 WebRtcIsacfix_kTransform[4][4] = { - { -2048, -2048, -2048, -2048 }, - { 2748, 916, -916, -2748 }, - { 2048, -2048, -2048, 2048 }, - { 916, -2748, 2748, -916 } -};
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h b/src/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h deleted file mode 100644 index 788e553..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_gain_tables.h - * - * This file contains tables for the pitch filter side-info in the entropy coder. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_GAIN_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_GAIN_TABLES_H_ - -#include "typedefs.h" - - -/********************* Pitch Filter Gain Coefficient Tables ************************/ -/* cdf for quantized pitch filter gains */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchGainCdf[255]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsacfix_kLowerlimiGain[3]; -extern const WebRtc_Word16 WebRtcIsacfix_kUpperlimitGain[3]; -extern const WebRtc_UWord16 WebRtcIsacfix_kMultsGain[2]; - -/* mean values of pitch filter gains in Q12*/ -extern const WebRtc_Word16 WebRtcIsacfix_kPitchGain1[144]; -extern const WebRtc_Word16 WebRtcIsacfix_kPitchGain2[144]; -extern const WebRtc_Word16 WebRtcIsacfix_kPitchGain3[144]; -extern const WebRtc_Word16 WebRtcIsacfix_kPitchGain4[144]; - -/* size of cdf table */ -extern const WebRtc_UWord16 WebRtcIsacfix_kCdfTableSizeGain[1]; - -/* transform matrix */ -extern const WebRtc_Word16 WebRtcIsacfix_kTransform[4][4]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_GAIN_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.c b/src/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.c deleted file mode 100644 index 81700e4..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.c +++ /dev/null
@@ -1,306 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_lag_tables.c - * - * This file contains tables for the pitch filter side-info in the entropy coder. - * - */ - -#include "settings.h" -#include "pitch_lag_tables.h" - - -/********************* Pitch Filter Gain Coefficient Tables ************************/ - -/* tables for use with small pitch gain */ - -/* cdf for quantized pitch filter lags */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf1Lo[127] = { - 0, 134, 336, 549, 778, 998, 1264, 1512, 1777, 2070, - 2423, 2794, 3051, 3361, 3708, 3979, 4315, 4610, 4933, 5269, - 5575, 5896, 6155, 6480, 6816, 7129, 7477, 7764, 8061, 8358, - 8718, 9020, 9390, 9783, 10177, 10543, 10885, 11342, 11795, 12213, - 12680, 13096, 13524, 13919, 14436, 14903, 15349, 15795, 16267, 16734, - 17266, 17697, 18130, 18632, 19080, 19447, 19884, 20315, 20735, 21288, - 21764, 22264, 22723, 23193, 23680, 24111, 24557, 25022, 25537, 26082, - 26543, 27090, 27620, 28139, 28652, 29149, 29634, 30175, 30692, 31273, - 31866, 32506, 33059, 33650, 34296, 34955, 35629, 36295, 36967, 37726, - 38559, 39458, 40364, 41293, 42256, 43215, 44231, 45253, 46274, 47359, - 48482, 49678, 50810, 51853, 53016, 54148, 55235, 56263, 57282, 58363, - 59288, 60179, 61076, 61806, 62474, 63129, 63656, 64160, 64533, 64856, - 65152, 65535, 65535, 65535, 65535, 65535, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf2Lo[20] = { - 0, 429, 3558, 5861, 8558, 11639, 15210, 19502, 24773, 31983, - 42602, 48567, 52601, 55676, 58160, 60172, 61889, 63235, 65383, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf3Lo[2] = { - 0, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf4Lo[10] = { - 0, 2966, 6368, 11182, 19431, 37793, 48532, 55353, 60626, 65535 -}; - -const WebRtc_UWord16 *WebRtcIsacfix_kPitchLagPtrLo[4] = { - WebRtcIsacfix_kPitchLagCdf1Lo, - WebRtcIsacfix_kPitchLagCdf2Lo, - WebRtcIsacfix_kPitchLagCdf3Lo, - WebRtcIsacfix_kPitchLagCdf4Lo -}; - -/* size of first cdf table */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagSizeLo[1] = { - 128 -}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsacfix_kLowerLimitLo[4] = { - -140, -9, 0, -4 -}; - -const WebRtc_Word16 WebRtcIsacfix_kUpperLimitLo[4] = { - -20, 9, 0, 4 -}; - -/* initial index for arithmetic decoder */ -const WebRtc_UWord16 WebRtcIsacfix_kInitIndLo[3] = { - 10, 1, 5 -}; - -/* mean values of pitch filter lags in Q10 */ - -const WebRtc_Word16 WebRtcIsacfix_kMeanLag2Lo[19] = { - -17627, -16207, -14409, -12319, -10253, -8200, -6054, -3986, -1948, -19, - 1937, 3974, 6064, 8155, 10229, 12270, 14296, 16127, 17520 -}; - -const WebRtc_Word16 WebRtcIsacfix_kMeanLag4Lo[9] = { - -7949, -6063, -4036, -1941, 38, 1977, 4060, 6059 -}; - - - -/* tables for use with medium pitch gain */ - -/* cdf for quantized pitch filter lags */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf1Mid[255] = { - 0, 28, 61, 88, 121, 149, 233, 331, 475, 559, - 624, 661, 689, 712, 745, 791, 815, 843, 866, 922, - 959, 1024, 1061, 1117, 1178, 1238, 1280, 1350, 1453, 1513, - 1564, 1625, 1671, 1741, 1788, 1904, 2072, 2421, 2626, 2770, - 2840, 2900, 2942, 3012, 3068, 3115, 3147, 3194, 3254, 3319, - 3366, 3520, 3678, 3780, 3850, 3911, 3957, 4032, 4106, 4185, - 4292, 4474, 4683, 4842, 5019, 5191, 5321, 5428, 5540, 5675, - 5763, 5847, 5959, 6127, 6304, 6564, 6839, 7090, 7263, 7421, - 7556, 7728, 7872, 7984, 8142, 8361, 8580, 8743, 8938, 9227, - 9409, 9539, 9674, 9795, 9930, 10060, 10177, 10382, 10614, 10861, - 11038, 11271, 11415, 11629, 11792, 12044, 12193, 12416, 12574, 12821, - 13007, 13235, 13445, 13654, 13901, 14134, 14488, 15000, 15703, 16285, - 16504, 16797, 17086, 17328, 17579, 17807, 17998, 18268, 18538, 18836, - 19087, 19274, 19474, 19716, 19935, 20270, 20833, 21303, 21532, 21741, - 21978, 22207, 22523, 22770, 23054, 23613, 23943, 24204, 24399, 24651, - 24832, 25074, 25270, 25549, 25759, 26015, 26150, 26424, 26713, 27048, - 27342, 27504, 27681, 27854, 28021, 28207, 28412, 28664, 28859, 29064, - 29278, 29548, 29748, 30107, 30377, 30656, 30856, 31164, 31452, 31755, - 32011, 32328, 32626, 32919, 33319, 33789, 34329, 34925, 35396, 35973, - 36443, 36964, 37551, 38156, 38724, 39357, 40023, 40908, 41587, 42602, - 43924, 45037, 45810, 46597, 47421, 48291, 49092, 50051, 51448, 52719, - 53440, 54241, 54944, 55977, 56676, 57299, 57872, 58389, 59059, 59688, - 60237, 60782, 61094, 61573, 61890, 62290, 62658, 63030, 63217, 63454, - 63622, 63882, 64003, 64273, 64427, 64529, 64581, 64697, 64758, 64902, - 65414, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf2Mid[36] = { - 0, 71, 335, 581, 836, 1039, 1323, 1795, 2258, 2608, - 3005, 3591, 4243, 5344, 7163, 10583, 16848, 28078, 49448, 57007, - 60357, 61850, 62837, 63437, 63872, 64188, 64377, 64614, 64774, 64949, - 65039, 65115, 65223, 65360, 65474, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf3Mid[2] = { - 0, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf4Mid[20] = { - 0, 28, 246, 459, 667, 1045, 1523, 2337, 4337, 11347, - 44231, 56709, 60781, 62243, 63161, 63969, 64608, 65062, 65502, 65535 -}; - -const WebRtc_UWord16 *WebRtcIsacfix_kPitchLagPtrMid[4] = { - WebRtcIsacfix_kPitchLagCdf1Mid, - WebRtcIsacfix_kPitchLagCdf2Mid, - WebRtcIsacfix_kPitchLagCdf3Mid, - WebRtcIsacfix_kPitchLagCdf4Mid -}; - -/* size of first cdf table */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagSizeMid[1] = { - 256 -}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsacfix_kLowerLimitMid[4] = { - -280, -17, 0, -9 -}; - -const WebRtc_Word16 WebRtcIsacfix_kUpperLimitMid[4] = { - -40, 17, 0, 9 -}; - -/* initial index for arithmetic decoder */ -const WebRtc_UWord16 WebRtcIsacfix_kInitIndMid[3] = { - 18, 1, 10 -}; - -/* mean values of pitch filter lags in Q10 */ - -const WebRtc_Word16 WebRtcIsacfix_kMeanLag2Mid[35] = { - -17297, -16250, -15416, -14343, -13341, -12363, -11270, - -10355, -9122, -8217, -7172, -6083, -5102, -4004, -3060, - -1982, -952, -18, 935, 1976, 3040, 4032, - 5082, 6065, 7257, 8202, 9264, 10225, 11242, - 12234, 13337, 14336, 15374, 16187, 17347 -}; - - -const WebRtc_Word16 WebRtcIsacfix_kMeanLag4Mid[19] = { - -8811, -8081, -7203, -6003, -5057, -4025, -2983, -1964, - -891, 29, 921, 1920, 2988, 4064, 5187, 6079, 7173, 8074, 8849 -}; - - -/* tables for use with large pitch gain */ - -/* cdf for quantized pitch filter lags */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf1Hi[511] = { - 0, 7, 18, 33, 69, 105, 156, 228, 315, 612, - 680, 691, 709, 724, 735, 738, 742, 746, 749, 753, - 756, 760, 764, 774, 782, 785, 789, 796, 800, 803, - 807, 814, 818, 822, 829, 832, 847, 854, 858, 869, - 876, 883, 898, 908, 934, 977, 1010, 1050, 1060, 1064, - 1075, 1078, 1086, 1089, 1093, 1104, 1111, 1122, 1133, 1136, - 1151, 1162, 1183, 1209, 1252, 1281, 1339, 1364, 1386, 1401, - 1411, 1415, 1426, 1430, 1433, 1440, 1448, 1455, 1462, 1477, - 1487, 1495, 1502, 1506, 1509, 1516, 1524, 1531, 1535, 1542, - 1553, 1556, 1578, 1589, 1611, 1625, 1639, 1643, 1654, 1665, - 1672, 1687, 1694, 1705, 1708, 1719, 1730, 1744, 1752, 1759, - 1791, 1795, 1820, 1867, 1886, 1915, 1936, 1943, 1965, 1987, - 2041, 2099, 2161, 2175, 2200, 2211, 2226, 2233, 2244, 2251, - 2266, 2280, 2287, 2298, 2309, 2316, 2331, 2342, 2356, 2378, - 2403, 2418, 2447, 2497, 2544, 2602, 2863, 2895, 2903, 2935, - 2950, 2971, 3004, 3011, 3018, 3029, 3040, 3062, 3087, 3127, - 3152, 3170, 3199, 3243, 3293, 3322, 3340, 3377, 3402, 3427, - 3474, 3518, 3543, 3579, 3601, 3637, 3659, 3706, 3731, 3760, - 3818, 3847, 3869, 3901, 3920, 3952, 4068, 4169, 4220, 4271, - 4524, 4571, 4604, 4632, 4672, 4730, 4777, 4806, 4857, 4904, - 4951, 5002, 5031, 5060, 5107, 5150, 5212, 5266, 5331, 5382, - 5432, 5490, 5544, 5610, 5700, 5762, 5812, 5874, 5972, 6022, - 6091, 6163, 6232, 6305, 6402, 6540, 6685, 6880, 7090, 7271, - 7379, 7452, 7542, 7625, 7687, 7770, 7843, 7911, 7966, 8024, - 8096, 8190, 8252, 8320, 8411, 8501, 8585, 8639, 8751, 8842, - 8918, 8986, 9066, 9127, 9203, 9269, 9345, 9406, 9464, 9536, - 9612, 9667, 9735, 9844, 9931, 10036, 10119, 10199, 10260, 10358, - 10441, 10514, 10666, 10734, 10872, 10951, 11053, 11125, 11223, 11324, - 11516, 11664, 11737, 11816, 11892, 12008, 12120, 12200, 12280, 12392, - 12490, 12576, 12685, 12812, 12917, 13003, 13108, 13210, 13300, 13384, - 13470, 13579, 13673, 13771, 13879, 13999, 14136, 14201, 14368, 14614, - 14759, 14867, 14958, 15030, 15121, 15189, 15280, 15385, 15461, 15555, - 15653, 15768, 15884, 15971, 16069, 16145, 16210, 16279, 16380, 16463, - 16539, 16615, 16688, 16818, 16919, 17017, 18041, 18338, 18523, 18649, - 18790, 18917, 19047, 19167, 19315, 19460, 19601, 19731, 19858, 20068, - 20173, 20318, 20466, 20625, 20741, 20911, 21045, 21201, 21396, 21588, - 21816, 22022, 22305, 22547, 22786, 23072, 23322, 23600, 23879, 24168, - 24433, 24769, 25120, 25511, 25895, 26289, 26792, 27219, 27683, 28077, - 28566, 29094, 29546, 29977, 30491, 30991, 31573, 32105, 32594, 33173, - 33788, 34497, 35181, 35833, 36488, 37255, 37921, 38645, 39275, 39894, - 40505, 41167, 41790, 42431, 43096, 43723, 44385, 45134, 45858, 46607, - 47349, 48091, 48768, 49405, 49955, 50555, 51167, 51985, 52611, 53078, - 53494, 53965, 54435, 54996, 55601, 56125, 56563, 56838, 57244, 57566, - 57967, 58297, 58771, 59093, 59419, 59647, 59886, 60143, 60461, 60693, - 60917, 61170, 61416, 61634, 61891, 62122, 62310, 62455, 62632, 62839, - 63103, 63436, 63639, 63805, 63906, 64015, 64192, 64355, 64475, 64558, - 64663, 64742, 64811, 64865, 64916, 64956, 64981, 65025, 65068, 65115, - 65195, 65314, 65419, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf2Hi[68] = { - 0, 7, 11, 22, 37, 52, 56, 59, 81, 85, - 89, 96, 115, 130, 137, 152, 170, 181, 193, 200, - 207, 233, 237, 259, 289, 318, 363, 433, 592, 992, - 1607, 3062, 6149, 12206, 25522, 48368, 58223, 61918, 63640, 64584, - 64943, 65098, 65206, 65268, 65294, 65335, 65350, 65372, 65387, 65402, - 65413, 65420, 65428, 65435, 65439, 65450, 65454, 65468, 65472, 65476, - 65483, 65491, 65498, 65505, 65516, 65520, 65528, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf3Hi[2] = { - 0, 65535 -}; - -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf4Hi[35] = { - 0, 7, 19, 30, 41, 48, 63, 74, 82, 96, - 122, 152, 215, 330, 701, 2611, 10931, 48106, 61177, 64341, - 65112, 65238, 65309, 65338, 65364, 65379, 65401, 65427, 65453, - 65465, 65476, 65490, 65509, 65528, 65535 -}; - -const WebRtc_UWord16 *WebRtcIsacfix_kPitchLagPtrHi[4] = { - WebRtcIsacfix_kPitchLagCdf1Hi, - WebRtcIsacfix_kPitchLagCdf2Hi, - WebRtcIsacfix_kPitchLagCdf3Hi, - WebRtcIsacfix_kPitchLagCdf4Hi -}; - -/* size of first cdf table */ -const WebRtc_UWord16 WebRtcIsacfix_kPitchLagSizeHi[1] = { - 512 -}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsacfix_kLowerLimitHi[4] = { - -552, -34, 0, -16 -}; - -const WebRtc_Word16 WebRtcIsacfix_kUpperLimitHi[4] = { - -80, 32, 0, 17 -}; - -/* initial index for arithmetic decoder */ -const WebRtc_UWord16 WebRtcIsacfix_kInitIndHi[3] = { - 34, 1, 18 -}; - -/* mean values of pitch filter lags */ - -const WebRtc_Word16 WebRtcIsacfix_kMeanLag2Hi[67] = { - -17482, -16896, -16220, -15929, -15329, -14848, -14336, -13807, -13312, -12800, -12218, -11720, - -11307, -10649, -10396, -9742, -9148, -8668, -8297, -7718, -7155, -6656, -6231, -5600, -5129, - -4610, -4110, -3521, -3040, -2525, -2016, -1506, -995, -477, -5, 469, 991, 1510, 2025, 2526, 3079, - 3555, 4124, 4601, 5131, 5613, 6194, 6671, 7140, 7645, 8207, 8601, 9132, 9728, 10359, 10752, 11302, - 11776, 12288, 12687, 13204, 13759, 14295, 14810, 15360, 15764, 16350 -}; - - -const WebRtc_Word16 WebRtcIsacfix_kMeanLag4Hi[34] = { - -8175, -7659, -7205, -6684, -6215, -5651, -5180, -4566, -4087, -3536, -3096, - -2532, -1990, -1482, -959, -440, 11, 451, 954, 1492, 2020, 2562, 3059, - 3577, 4113, 4618, 5134, 5724, 6060, 6758, 7015, 7716, 8066, 8741 -};
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h b/src/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h deleted file mode 100644 index 9517c29..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h +++ /dev/null
@@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_lag_tables.h - * - * This file contains tables for the pitch filter side-info in the entropy coder. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_LAG_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_LAG_TABLES_H_ - - -#include "typedefs.h" - - -/********************* Pitch Filter Lag Coefficient Tables ************************/ - -/* tables for use with small pitch gain */ - -/* cdfs for quantized pitch lags */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf1Lo[127]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf2Lo[20]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf3Lo[2]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf4Lo[10]; - -extern const WebRtc_UWord16 *WebRtcIsacfix_kPitchLagPtrLo[4]; - -/* size of first cdf table */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagSizeLo[1]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsacfix_kLowerLimitLo[4]; -extern const WebRtc_Word16 WebRtcIsacfix_kUpperLimitLo[4]; - -/* initial index for arithmetic decoder */ -extern const WebRtc_UWord16 WebRtcIsacfix_kInitIndLo[3]; - -/* mean values of pitch filter lags */ -extern const WebRtc_Word16 WebRtcIsacfix_kMeanLag2Lo[19]; -extern const WebRtc_Word16 WebRtcIsacfix_kMeanLag4Lo[9]; - - - -/* tables for use with medium pitch gain */ - -/* cdfs for quantized pitch lags */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf1Mid[255]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf2Mid[36]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf3Mid[2]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf4Mid[20]; - -extern const WebRtc_UWord16 *WebRtcIsacfix_kPitchLagPtrMid[4]; - -/* size of first cdf table */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagSizeMid[1]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsacfix_kLowerLimitMid[4]; -extern const WebRtc_Word16 WebRtcIsacfix_kUpperLimitMid[4]; - -/* initial index for arithmetic decoder */ -extern const WebRtc_UWord16 WebRtcIsacfix_kInitIndMid[3]; - -/* mean values of pitch filter lags */ -extern const WebRtc_Word16 WebRtcIsacfix_kMeanLag2Mid[35]; -extern const WebRtc_Word16 WebRtcIsacfix_kMeanLag4Mid[19]; - - -/* tables for use with large pitch gain */ - -/* cdfs for quantized pitch lags */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf1Hi[511]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf2Hi[68]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf3Hi[2]; -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagCdf4Hi[35]; - -extern const WebRtc_UWord16 *WebRtcIsacfix_kPitchLagPtrHi[4]; - -/* size of first cdf table */ -extern const WebRtc_UWord16 WebRtcIsacfix_kPitchLagSizeHi[1]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsacfix_kLowerLimitHi[4]; -extern const WebRtc_Word16 WebRtcIsacfix_kUpperLimitHi[4]; - -/* initial index for arithmetic decoder */ -extern const WebRtc_UWord16 WebRtcIsacfix_kInitIndHi[3]; - -/* mean values of pitch filter lags */ -extern const WebRtc_Word16 WebRtcIsacfix_kMeanLag2Hi[67]; -extern const WebRtc_Word16 WebRtcIsacfix_kMeanLag4Hi[34]; - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_PITCH_LAG_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/settings.h b/src/modules/audio_coding/codecs/isac/fix/source/settings.h deleted file mode 100644 index da88ba2..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/settings.h +++ /dev/null
@@ -1,205 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * settings.h - * - * Declaration of #defines used in the iSAC codec - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ - - -/* sampling frequency (Hz) */ -#define FS 16000 -/* 1.5 times Sampling frequency */ -#define FS_1_HALF (WebRtc_UWord32) 24000 -/* Three times Sampling frequency */ -#define FS3 (WebRtc_UWord32) 48000 -/* Eight times Sampling frequency */ -#define FS8 (WebRtc_UWord32) 128000 - -/* number of samples per frame (either 480 (30ms) or 960 (60ms)) */ -#define INITIAL_FRAMESAMPLES 960 - -/* miliseconds */ -#define FRAMESIZE 30 -/* number of samples per frame processed in the encoder (30ms) */ -#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ -#define FRAMESAMPLES_HALF 240 -/* max number of samples per frame (= 60 ms frame) */ -#define MAX_FRAMESAMPLES 960 -/* number of samples per 10ms frame */ -#define FRAMESAMPLES_10ms 160 /* ((10*FS)/1000) */ -/* Number of samples per 1 ms */ -#define SAMPLES_PER_MSEC 16 -/* number of subframes */ -#define SUBFRAMES 6 -/* length of a subframe */ -#define UPDATE 80 -/* length of half a subframe (low/high band) */ -#define HALF_SUBFRAMELEN 40 /* (UPDATE/2) */ -/* samples of look ahead (in a half-band, so actually half the samples of look ahead @ FS) */ -#define QLOOKAHEAD 24 /* 3 ms */ - -/* order of AR model in spectral entropy coder */ -#define AR_ORDER 6 -#define MAX_ORDER 13 -#define LEVINSON_MAX_ORDER 12 - -/* window length (masking analysis) */ -#define WINLEN 256 -/* order of low-band pole filter used to approximate masking curve */ -#define ORDERLO 12 -/* order of hi-band pole filter used to approximate masking curve */ -#define ORDERHI 6 - -#define KLT_NUM_AVG_GAIN 0 -#define KLT_NUM_AVG_SHAPE 0 -#define KLT_NUM_MODELS 3 -#define LPC_SHAPE_ORDER 18 /* (ORDERLO + ORDERHI) */ - -#define KLT_ORDER_GAIN 12 /* (2 * SUBFRAMES) */ -#define KLT_ORDER_SHAPE 108 /* (LPC_SHAPE_ORDER * SUBFRAMES) */ - - - -/* order for post_filter_bank */ -#define POSTQORDER 3 -/* order for pre-filterbank */ -#define QORDER 3 -/* for decimator */ -#define ALLPASSSECTIONS 2 -/* The number of composite all-pass filter factors */ -#define NUMBEROFCOMPOSITEAPSECTIONS 4 - -/* The number of all-pass filter factors in an upper or lower channel*/ -#define NUMBEROFCHANNELAPSECTIONS 2 - - - -#define DPMIN_Q10 -10240 /* -10.00 in Q10 */ -#define DPMAX_Q10 10240 /* 10.00 in Q10 */ -#define MINBITS_Q10 10240 /* 10.0 in Q10 */ - - -/* array size for byte stream in number of Word16. */ -#define STREAM_MAXW16 300 /* The old maximum size still needed for the decoding */ -#define STREAM_MAXW16_30MS 100 /* 100 Word16 = 200 bytes = 53.4 kbit/s @ 30 ms.framelength */ -#define STREAM_MAXW16_60MS 200 /* 200 Word16 = 400 bytes = 53.4 kbit/s @ 60 ms.framelength */ - - -/* storage size for bit counts */ -//#define BIT_COUNTER_SIZE 30 -/* maximum order of any AR model or filter */ -#define MAX_AR_MODEL_ORDER 12 - -/* Maximum number of iterations allowed to limit payload size */ -#define MAX_PAYLOAD_LIMIT_ITERATION 1 - -/* Bandwidth estimator */ - -#define MIN_ISAC_BW 10000 /* Minimum bandwidth in bits per sec */ -#define MAX_ISAC_BW 32000 /* Maxmum bandwidth in bits per sec */ -#define MIN_ISAC_MD 5 /* Minimum Max Delay in ?? */ -#define MAX_ISAC_MD 25 /* Maxmum Max Delay in ?? */ -#define DELAY_CORRECTION_MAX 717 -#define DELAY_CORRECTION_MED 819 -#define Thld_30_60 18000 -#define Thld_60_30 27000 - -/* assumed header size; we don't know the exact number (header compression may be used) */ -#define HEADER_SIZE 35 /* bytes */ -#define INIT_FRAME_LEN 60 -#define INIT_BN_EST 20000 -#define INIT_BN_EST_Q7 2560000 /* 20 kbps in Q7 */ -#define INIT_REC_BN_EST_Q5 789312 /* INIT_BN_EST + INIT_HDR_RATE in Q5 */ - -/* 8738 in Q18 is ~ 1/30 */ -/* #define INIT_HDR_RATE (((HEADER_SIZE * 8 * 1000) * 8738) >> NUM_BITS_TO_SHIFT (INIT_FRAME_LEN)) */ -#define INIT_HDR_RATE 4666 -/* number of packets in a row for a high rate burst */ -#define BURST_LEN 3 -/* ms, max time between two full bursts */ -#define BURST_INTERVAL 800 -/* number of packets in a row for initial high rate burst */ -#define INIT_BURST_LEN 5 -/* bits/s, rate for the first BURST_LEN packets */ -#define INIT_RATE 10240000 /* INIT_BN_EST in Q9 */ - - -/* For pitch analysis */ -#define PITCH_FRAME_LEN 240 /* (FRAMESAMPLES/2) 30 ms */ -#define PITCH_MAX_LAG 140 /* 57 Hz */ -#define PITCH_MIN_LAG 20 /* 400 Hz */ -#define PITCH_MIN_LAG_Q8 5120 /* 256 * PITCH_MIN_LAG */ -#define OFFSET_Q8 768 /* 256 * 3 */ - -#define PITCH_MAX_GAIN_Q12 1843 /* 0.45 */ -#define PITCH_LAG_SPAN2 65 /* (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) */ -#define PITCH_CORR_LEN2 60 /* 15 ms */ -#define PITCH_CORR_STEP2 60 /* (PITCH_FRAME_LEN/4) */ -#define PITCH_SUBFRAMES 4 -#define PITCH_SUBFRAME_LEN 60 /* (PITCH_FRAME_LEN/PITCH_SUBFRAMES) */ - -/* For pitch filter */ -#define PITCH_BUFFSIZE 190 /* (PITCH_MAX_LAG + 50) Extra 50 for fraction and LP filters */ -#define PITCH_INTBUFFSIZE 430 /* (PITCH_FRAME_LEN+PITCH_BUFFSIZE) */ -#define PITCH_FRACS 8 -#define PITCH_FRACORDER 9 -#define PITCH_DAMPORDER 5 - - -/* Order of high pass filter */ -#define HPORDER 2 - - -/* PLC */ -#define DECAY_RATE 10 /* Q15, 20% of decay every lost frame apllied linearly sample by sample*/ -#define PLC_WAS_USED 1 -#define PLC_NOT_USED 3 -#define RECOVERY_OVERLAP 80 -#define RESAMP_RES 256 -#define RESAMP_RES_BIT 8 - - - -/* Define Error codes */ -/* 6000 General */ -#define ISAC_MEMORY_ALLOCATION_FAILED 6010 -#define ISAC_MODE_MISMATCH 6020 -#define ISAC_DISALLOWED_BOTTLENECK 6030 -#define ISAC_DISALLOWED_FRAME_LENGTH 6040 -/* 6200 Bandwidth estimator */ -#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 -/* 6400 Encoder */ -#define ISAC_ENCODER_NOT_INITIATED 6410 -#define ISAC_DISALLOWED_CODING_MODE 6420 -#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 -#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 -#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 -/* 6600 Decoder */ -#define ISAC_DECODER_NOT_INITIATED 6610 -#define ISAC_EMPTY_PACKET 6620 -#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 -#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 -#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 -#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 -#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 -#define ISAC_RANGE_ERROR_DECODE_LPC 6680 -#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 -#define ISAC_LENGTH_MISMATCH 6730 -/* 6800 Call setup formats */ -#define ISAC_INCOMPATIBLE_FORMATS 6810 - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SETTINGS_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.c b/src/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.c deleted file mode 100644 index 81b932f..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.c +++ /dev/null
@@ -1,193 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * spectrum_ar_model_tables.c - * - * This file contains tables with AR coefficients, Gain coefficients - * and cosine tables. - * - */ - -#include "spectrum_ar_model_tables.h" -#include "settings.h" - -/********************* AR Coefficient Tables ************************/ - -/* cdf for quantized reflection coefficient 1 */ -const WebRtc_UWord16 WebRtcIsacfix_kRc1Cdf[12] = { - 0, 2, 4, 129, 7707, 57485, 65495, 65527, 65529, 65531, - 65533, 65535 -}; - -/* cdf for quantized reflection coefficient 2 */ -const WebRtc_UWord16 WebRtcIsacfix_kRc2Cdf[12] = { - 0, 2, 4, 7, 531, 25298, 64525, 65526, 65529, 65531, - 65533, 65535 -}; - -/* cdf for quantized reflection coefficient 3 */ -const WebRtc_UWord16 WebRtcIsacfix_kRc3Cdf[12] = { - 0, 2, 4, 6, 620, 22898, 64843, 65527, 65529, 65531, - 65533, 65535 -}; - -/* cdf for quantized reflection coefficient 4 */ -const WebRtc_UWord16 WebRtcIsacfix_kRc4Cdf[12] = { - 0, 2, 4, 6, 35, 10034, 60733, 65506, 65529, 65531, - 65533, 65535 -}; - -/* cdf for quantized reflection coefficient 5 */ -const WebRtc_UWord16 WebRtcIsacfix_kRc5Cdf[12] = { - 0, 2, 4, 6, 36, 7567, 56727, 65385, 65529, 65531, - 65533, 65535 -}; - -/* cdf for quantized reflection coefficient 6 */ -const WebRtc_UWord16 WebRtcIsacfix_kRc6Cdf[12] = { - 0, 2, 4, 6, 14, 6579, 57360, 65409, 65529, 65531, - 65533, 65535 -}; - -/* representation levels for quantized reflection coefficient 1 */ -const WebRtc_Word16 WebRtcIsacfix_kRc1Levels[11] = { - -32104, -29007, -23202, -15496, -9279, -2577, 5934, 17535, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 2 */ -const WebRtc_Word16 WebRtcIsacfix_kRc2Levels[11] = { - -32104, -29503, -23494, -15261, -7309, -1399, 6158, 16381, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 3 */ -const WebRtc_Word16 WebRtcIsacfix_kRc3Levels[11] = { - -32104, -29503, -23157, -15186, -7347, -1359, 5829, 17535, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 4 */ -const WebRtc_Word16 WebRtcIsacfix_kRc4Levels[11] = { - -32104, -29503, -24512, -15362, -6665, -342, 6596, 14585, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 5 */ -const WebRtc_Word16 WebRtcIsacfix_kRc5Levels[11] = { - -32104, -29503, -24512, -15005, -6564, -106, 7123, 14920, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 6 */ -const WebRtc_Word16 WebRtcIsacfix_kRc6Levels[11] = { - -32104, -29503, -24512, -15096, -6656, -37, 7036, 14847, 24512, 29503, 32104 -}; - -/* quantization boundary levels for reflection coefficients */ -const WebRtc_Word16 WebRtcIsacfix_kRcBound[12] = { - -32768, -31441, -27566, -21458, -13612, -4663, - 4663, 13612, 21458, 27566, 31441, 32767 -}; - -/* initial index for AR reflection coefficient quantizer and cdf table search */ -const WebRtc_UWord16 WebRtcIsacfix_kRcInitInd[6] = { - 5, 5, 5, 5, 5, 5 -}; - -/* pointers to AR cdf tables */ -const WebRtc_UWord16 *WebRtcIsacfix_kRcCdfPtr[AR_ORDER] = { - WebRtcIsacfix_kRc1Cdf, - WebRtcIsacfix_kRc2Cdf, - WebRtcIsacfix_kRc3Cdf, - WebRtcIsacfix_kRc4Cdf, - WebRtcIsacfix_kRc5Cdf, - WebRtcIsacfix_kRc6Cdf -}; - -/* pointers to AR representation levels tables */ -const WebRtc_Word16 *WebRtcIsacfix_kRcLevPtr[AR_ORDER] = { - WebRtcIsacfix_kRc1Levels, - WebRtcIsacfix_kRc2Levels, - WebRtcIsacfix_kRc3Levels, - WebRtcIsacfix_kRc4Levels, - WebRtcIsacfix_kRc5Levels, - WebRtcIsacfix_kRc6Levels -}; - - -/******************** GAIN Coefficient Tables ***********************/ - -/* cdf for Gain coefficient */ -const WebRtc_UWord16 WebRtcIsacfix_kGainCdf[19] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 1172, - 11119, 29411, 51699, 64445, 65527, 65529, 65531, 65533, 65535 -}; - -/* representation levels for quantized squared Gain coefficient */ -const WebRtc_Word32 WebRtcIsacfix_kGain2Lev[18] = { - 128, 128, 128, 128, 128, 215, 364, 709, 1268, - 1960, 3405, 6078, 11286, 17827, 51918, 134498, 487432, 2048000 -}; - -/* quantization boundary levels for squared Gain coefficient */ -const WebRtc_Word32 WebRtcIsacfix_kGain2Bound[19] = { - 0, 21, 35, 59, 99, 166, 280, 475, 815, 1414, - 2495, 4505, 8397, 16405, 34431, 81359, 240497, 921600, 0x7FFFFFFF -}; - -/* pointers to Gain cdf table */ -const WebRtc_UWord16 *WebRtcIsacfix_kGainPtr[1] = { - WebRtcIsacfix_kGainCdf -}; - -/* gain initial index for gain quantizer and cdf table search */ -const WebRtc_UWord16 WebRtcIsacfix_kGainInitInd[1] = { - 11 -}; - - -/************************* Cosine Tables ****************************/ - -/* cosine table */ -const WebRtc_Word16 WebRtcIsacfix_kCos[6][60] = { - { 512, 512, 511, 510, 508, 507, 505, 502, 499, 496, - 493, 489, 485, 480, 476, 470, 465, 459, 453, 447, - 440, 433, 426, 418, 410, 402, 394, 385, 376, 367, - 357, 348, 338, 327, 317, 306, 295, 284, 273, 262, - 250, 238, 226, 214, 202, 190, 177, 165, 152, 139, - 126, 113, 100, 87, 73, 60, 47, 33, 20, 7 }, - { 512, 510, 508, 503, 498, 491, 483, 473, 462, 450, - 437, 422, 406, 389, 371, 352, 333, 312, 290, 268, - 244, 220, 196, 171, 145, 120, 93, 67, 40, 13, - -13, -40, -67, -93, -120, -145, -171, -196, -220, -244, - -268, -290, -312, -333, -352, -371, -389, -406, -422, -437, - -450, -462, -473, -483, -491, -498, -503, -508, -510, -512 }, - { 512, 508, 502, 493, 480, 465, 447, 426, 402, 376, - 348, 317, 284, 250, 214, 177, 139, 100, 60, 20, - -20, -60, -100, -139, -177, -214, -250, -284, -317, -348, - -376, -402, -426, -447, -465, -480, -493, -502, -508, -512, - -512, -508, -502, -493, -480, -465, -447, -426, -402, -376, - -348, -317, -284, -250, -214, -177, -139, -100, -60, -20 }, - { 511, 506, 495, 478, 456, 429, 398, 362, 322, 279, - 232, 183, 133, 80, 27, -27, -80, -133, -183, -232, - -279, -322, -362, -398, -429, -456, -478, -495, -506, -511, - -511, -506, -495, -478, -456, -429, -398, -362, -322, -279, - -232, -183, -133, -80, -27, 27, 80, 133, 183, 232, - 279, 322, 362, 398, 429, 456, 478, 495, 506, 511 }, - { 511, 502, 485, 459, 426, 385, 338, 284, 226, 165, - 100, 33, -33, -100, -165, -226, -284, -338, -385, -426, - -459, -485, -502, -511, -511, -502, -485, -459, -426, -385, - -338, -284, -226, -165, -100, -33, 33, 100, 165, 226, - 284, 338, 385, 426, 459, 485, 502, 511, 511, 502, - 485, 459, 426, 385, 338, 284, 226, 165, 100, 33 }, - { 510, 498, 473, 437, 389, 333, 268, 196, 120, 40, - -40, -120, -196, -268, -333, -389, -437, -473, -498, -510, - -510, -498, -473, -437, -389, -333, -268, -196, -120, -40, - 40, 120, 196, 268, 333, 389, 437, 473, 498, 510, - 510, 498, 473, 437, 389, 333, 268, 196, 120, 40, - -40, -120, -196, -268, -333, -389, -437, -473, -498, -510 } -};
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h b/src/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h deleted file mode 100644 index b506d0e..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/spectrum_ar_model_tables.h +++ /dev/null
@@ -1,96 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * spectrum_ar_model_tables.h - * - * This file contains definitions of tables with AR coefficients, - * Gain coefficients and cosine tables. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ - -#include "typedefs.h" -#include "settings.h" - - -/********************* AR Coefficient Tables ************************/ -/* cdf for quantized reflection coefficient 1 */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRc1Cdf[12]; - -/* cdf for quantized reflection coefficient 2 */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRc2Cdf[12]; - -/* cdf for quantized reflection coefficient 3 */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRc3Cdf[12]; - -/* cdf for quantized reflection coefficient 4 */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRc4Cdf[12]; - -/* cdf for quantized reflection coefficient 5 */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRc5Cdf[12]; - -/* cdf for quantized reflection coefficient 6 */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRc6Cdf[12]; - -/* representation levels for quantized reflection coefficient 1 */ -extern const WebRtc_Word16 WebRtcIsacfix_kRc1Levels[11]; - -/* representation levels for quantized reflection coefficient 2 */ -extern const WebRtc_Word16 WebRtcIsacfix_kRc2Levels[11]; - -/* representation levels for quantized reflection coefficient 3 */ -extern const WebRtc_Word16 WebRtcIsacfix_kRc3Levels[11]; - -/* representation levels for quantized reflection coefficient 4 */ -extern const WebRtc_Word16 WebRtcIsacfix_kRc4Levels[11]; - -/* representation levels for quantized reflection coefficient 5 */ -extern const WebRtc_Word16 WebRtcIsacfix_kRc5Levels[11]; - -/* representation levels for quantized reflection coefficient 6 */ -extern const WebRtc_Word16 WebRtcIsacfix_kRc6Levels[11]; - -/* quantization boundary levels for reflection coefficients */ -extern const WebRtc_Word16 WebRtcIsacfix_kRcBound[12]; - -/* initial indices for AR reflection coefficient quantizer and cdf table search */ -extern const WebRtc_UWord16 WebRtcIsacfix_kRcInitInd[AR_ORDER]; - -/* pointers to AR cdf tables */ -extern const WebRtc_UWord16 *WebRtcIsacfix_kRcCdfPtr[AR_ORDER]; - -/* pointers to AR representation levels tables */ -extern const WebRtc_Word16 *WebRtcIsacfix_kRcLevPtr[AR_ORDER]; - - -/******************** GAIN Coefficient Tables ***********************/ -/* cdf for Gain coefficient */ -extern const WebRtc_UWord16 WebRtcIsacfix_kGainCdf[19]; - -/* representation levels for quantized Gain coefficient */ -extern const WebRtc_Word32 WebRtcIsacfix_kGain2Lev[18]; - -/* squared quantization boundary levels for Gain coefficient */ -extern const WebRtc_Word32 WebRtcIsacfix_kGain2Bound[19]; - -/* pointer to Gain cdf table */ -extern const WebRtc_UWord16 *WebRtcIsacfix_kGainPtr[1]; - -/* Gain initial index for gain quantizer and cdf table search */ -extern const WebRtc_UWord16 WebRtcIsacfix_kGainInitInd[1]; - -/************************* Cosine Tables ****************************/ -/* Cosine table */ -extern const WebRtc_Word16 WebRtcIsacfix_kCos[6][60]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/structs.h b/src/modules/audio_coding/codecs/isac/fix/source/structs.h deleted file mode 100644 index c038a43..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/structs.h +++ /dev/null
@@ -1,382 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * structs.h - * - * This header file contains all the structs used in the ISAC codec - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ - - -#include "common_audio/signal_processing/include/signal_processing_library.h" -#include "modules/audio_coding/codecs/isac/fix/source/settings.h" -#include "typedefs.h" - -/* Bitstream struct for decoder */ -typedef struct Bitstreamstruct_dec { - - WebRtc_UWord16 *stream; /* Pointer to bytestream to decode */ - WebRtc_UWord32 W_upper; /* Upper boundary of interval W */ - WebRtc_UWord32 streamval; - WebRtc_UWord16 stream_index; /* Index to the current position in bytestream */ - WebRtc_Word16 full; /* 0 - first byte in memory filled, second empty*/ - /* 1 - both bytes are empty (we just filled the previous memory */ - -} Bitstr_dec; - -/* Bitstream struct for encoder */ -typedef struct Bitstreamstruct_enc { - - WebRtc_UWord16 stream[STREAM_MAXW16_60MS]; /* Vector for adding encoded bytestream */ - WebRtc_UWord32 W_upper; /* Upper boundary of interval W */ - WebRtc_UWord32 streamval; - WebRtc_UWord16 stream_index; /* Index to the current position in bytestream */ - WebRtc_Word16 full; /* 0 - first byte in memory filled, second empty*/ - /* 1 - both bytes are empty (we just filled the previous memory */ - -} Bitstr_enc; - - -typedef struct { - - WebRtc_Word16 DataBufferLoQ0[WINLEN]; - WebRtc_Word16 DataBufferHiQ0[WINLEN]; - - WebRtc_Word32 CorrBufLoQQ[ORDERLO+1]; - WebRtc_Word32 CorrBufHiQQ[ORDERHI+1]; - - WebRtc_Word16 CorrBufLoQdom[ORDERLO+1]; - WebRtc_Word16 CorrBufHiQdom[ORDERHI+1]; - - WebRtc_Word32 PreStateLoGQ15[ORDERLO+1]; - WebRtc_Word32 PreStateHiGQ15[ORDERHI+1]; - - WebRtc_UWord32 OldEnergy; - -} MaskFiltstr_enc; - - - -typedef struct { - - WebRtc_Word16 PostStateLoGQ0[ORDERLO+1]; - WebRtc_Word16 PostStateHiGQ0[ORDERHI+1]; - - WebRtc_UWord32 OldEnergy; - -} MaskFiltstr_dec; - - - - - - - - -typedef struct { - - //state vectors for each of the two analysis filters - - WebRtc_Word32 INSTAT1_fix[2*(QORDER-1)]; - WebRtc_Word32 INSTAT2_fix[2*(QORDER-1)]; - WebRtc_Word16 INLABUF1_fix[QLOOKAHEAD]; - WebRtc_Word16 INLABUF2_fix[QLOOKAHEAD]; - - /* High pass filter */ - WebRtc_Word32 HPstates_fix[HPORDER]; - -} PreFiltBankstr; - - -typedef struct { - - //state vectors for each of the two analysis filters - WebRtc_Word32 STATE_0_LOWER_fix[2*POSTQORDER]; - WebRtc_Word32 STATE_0_UPPER_fix[2*POSTQORDER]; - - /* High pass filter */ - - WebRtc_Word32 HPstates1_fix[HPORDER]; - WebRtc_Word32 HPstates2_fix[HPORDER]; - -} PostFiltBankstr; - -typedef struct { - - - /* data buffer for pitch filter */ - WebRtc_Word16 ubufQQ[PITCH_BUFFSIZE]; - - /* low pass state vector */ - WebRtc_Word16 ystateQQ[PITCH_DAMPORDER]; - - /* old lag and gain */ - WebRtc_Word16 oldlagQ7; - WebRtc_Word16 oldgainQ12; - -} PitchFiltstr; - - - -typedef struct { - - //for inital estimator - WebRtc_Word16 dec_buffer16[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2]; - WebRtc_Word32 decimator_state32[2*ALLPASSSECTIONS+1]; - WebRtc_Word16 inbuf[QLOOKAHEAD]; - - PitchFiltstr PFstr_wght; - PitchFiltstr PFstr; - - -} PitchAnalysisStruct; - - -typedef struct { - /* Parameters used in PLC to avoid re-computation */ - - /* --- residual signals --- */ - WebRtc_Word16 prevPitchInvIn[FRAMESAMPLES/2]; - WebRtc_Word16 prevPitchInvOut[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90 - WebRtc_Word32 prevHP[PITCH_MAX_LAG + 10]; // [FRAMESAMPLES/2]; save 90 - - - WebRtc_Word16 decayCoeffPriodic; /* how much to supress a sample */ - WebRtc_Word16 decayCoeffNoise; - WebRtc_Word16 used; /* if PLC is used */ - - - WebRtc_Word16 *lastPitchLP; // [FRAMESAMPLES/2]; saved 240; - - - /* --- LPC side info --- */ - WebRtc_Word16 lofilt_coefQ15[ ORDERLO ]; - WebRtc_Word16 hifilt_coefQ15[ ORDERHI ]; - WebRtc_Word32 gain_lo_hiQ17[2]; - - /* --- LTP side info --- */ - WebRtc_Word16 AvgPitchGain_Q12; - WebRtc_Word16 lastPitchGain_Q12; - WebRtc_Word16 lastPitchLag_Q7; - - /* --- Add-overlap in recovery packet --- */ - WebRtc_Word16 overlapLP[ RECOVERY_OVERLAP ]; // [FRAMESAMPLES/2]; saved 160 - - WebRtc_Word16 pitchCycles; - WebRtc_Word16 A; - WebRtc_Word16 B; - WebRtc_Word16 pitchIndex; - WebRtc_Word16 stretchLag; - WebRtc_Word16 *prevPitchLP; // [ FRAMESAMPLES/2 ]; saved 240 - WebRtc_Word16 seed; - - WebRtc_Word16 std; -} PLCstr; - - - -/* Have instance of struct together with other iSAC structs */ -typedef struct { - - WebRtc_Word16 prevFrameSizeMs; /* Previous frame size (in ms) */ - WebRtc_UWord16 prevRtpNumber; /* Previous RTP timestamp from received packet */ - /* (in samples relative beginning) */ - WebRtc_UWord32 prevSendTime; /* Send time for previous packet, from RTP header */ - WebRtc_UWord32 prevArrivalTime; /* Arrival time for previous packet (in ms using timeGetTime()) */ - WebRtc_UWord16 prevRtpRate; /* rate of previous packet, derived from RTP timestamps (in bits/s) */ - WebRtc_UWord32 lastUpdate; /* Time since the last update of the Bottle Neck estimate (in samples) */ - WebRtc_UWord32 lastReduction; /* Time sinse the last reduction (in samples) */ - WebRtc_Word32 countUpdates; /* How many times the estimate was update in the beginning */ - - /* The estimated bottle neck rate from there to here (in bits/s) */ - WebRtc_UWord32 recBw; - WebRtc_UWord32 recBwInv; - WebRtc_UWord32 recBwAvg; - WebRtc_UWord32 recBwAvgQ; - - WebRtc_UWord32 minBwInv; - WebRtc_UWord32 maxBwInv; - - /* The estimated mean absolute jitter value, as seen on this side (in ms) */ - WebRtc_Word32 recJitter; - WebRtc_Word32 recJitterShortTerm; - WebRtc_Word32 recJitterShortTermAbs; - WebRtc_Word32 recMaxDelay; - WebRtc_Word32 recMaxDelayAvgQ; - - - WebRtc_Word16 recHeaderRate; /* (assumed) bitrate for headers (bps) */ - - WebRtc_UWord32 sendBwAvg; /* The estimated bottle neck rate from here to there (in bits/s) */ - WebRtc_Word32 sendMaxDelayAvg; /* The estimated mean absolute jitter value, as seen on the other siee (in ms) */ - - - WebRtc_Word16 countRecPkts; /* number of packets received since last update */ - WebRtc_Word16 highSpeedRec; /* flag for marking that a high speed network has been detected downstream */ - - /* number of consecutive pkts sent during which the bwe estimate has - remained at a value greater than the downstream threshold for determining highspeed network */ - WebRtc_Word16 countHighSpeedRec; - - /* flag indicating bwe should not adjust down immediately for very late pckts */ - WebRtc_Word16 inWaitPeriod; - - /* variable holding the time of the start of a window of time when - bwe should not adjust down immediately for very late pckts */ - WebRtc_UWord32 startWaitPeriod; - - /* number of consecutive pkts sent during which the bwe estimate has - remained at a value greater than the upstream threshold for determining highspeed network */ - WebRtc_Word16 countHighSpeedSent; - - /* flag indicated the desired number of packets over threshold rate have been sent and - bwe will assume the connection is over broadband network */ - WebRtc_Word16 highSpeedSend; - - - - -} BwEstimatorstr; - - -typedef struct { - - /* boolean, flags if previous packet exceeded B.N. */ - WebRtc_Word16 PrevExceed; - /* ms */ - WebRtc_Word16 ExceedAgo; - /* packets left to send in current burst */ - WebRtc_Word16 BurstCounter; - /* packets */ - WebRtc_Word16 InitCounter; - /* ms remaining in buffer when next packet will be sent */ - WebRtc_Word16 StillBuffered; - -} RateModel; - -/* The following strutc is used to store data from encoding, to make it - fast and easy to construct a new bitstream with a different Bandwidth - estimate. All values (except framelength and minBytes) is double size to - handle 60 ms of data. -*/ -typedef struct { - - /* Used to keep track of if it is first or second part of 60 msec packet */ - int startIdx; - - /* Frame length in samples */ - WebRtc_Word16 framelength; - - /* Pitch Gain */ - WebRtc_Word16 pitchGain_index[2]; - - /* Pitch Lag */ - WebRtc_Word32 meanGain[2]; - WebRtc_Word16 pitchIndex[PITCH_SUBFRAMES*2]; - - /* LPC */ - WebRtc_Word32 LPCcoeffs_g[12*2]; /* KLT_ORDER_GAIN = 12 */ - WebRtc_Word16 LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */ - WebRtc_Word16 LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */ - - /* Encode Spec */ - WebRtc_Word16 fre[FRAMESAMPLES]; - WebRtc_Word16 fim[FRAMESAMPLES]; - WebRtc_Word16 AvgPitchGain[2]; - - /* Used in adaptive mode only */ - int minBytes; - -} ISAC_SaveEncData_t; - -typedef struct { - - Bitstr_enc bitstr_obj; - MaskFiltstr_enc maskfiltstr_obj; - PreFiltBankstr prefiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; - PitchAnalysisStruct pitchanalysisstr_obj; - RateModel rate_data_obj; - - WebRtc_Word16 buffer_index; - WebRtc_Word16 current_framesamples; - - WebRtc_Word16 data_buffer_fix[FRAMESAMPLES]; // the size was MAX_FRAMESAMPLES - - WebRtc_Word16 frame_nb; - WebRtc_Word16 BottleNeck; - WebRtc_Word16 MaxDelay; - WebRtc_Word16 new_framelength; - WebRtc_Word16 s2nr; - WebRtc_UWord16 MaxBits; - - WebRtc_Word16 bitstr_seed; -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - PostFiltBankstr interpolatorstr_obj; -#endif - - ISAC_SaveEncData_t *SaveEnc_ptr; - WebRtc_Word16 payloadLimitBytes30; /* Maximum allowed number of bits for a 30 msec packet */ - WebRtc_Word16 payloadLimitBytes60; /* Maximum allowed number of bits for a 30 msec packet */ - WebRtc_Word16 maxPayloadBytes; /* Maximum allowed number of bits for both 30 and 60 msec packet */ - WebRtc_Word16 maxRateInBytes; /* Maximum allowed rate in bytes per 30 msec packet */ - WebRtc_Word16 enforceFrameSize; /* If set iSAC will never change packet size */ - -} ISACFIX_EncInst_t; - - -typedef struct { - - Bitstr_dec bitstr_obj; - MaskFiltstr_dec maskfiltstr_obj; - PostFiltBankstr postfiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; - PLCstr plcstr_obj; /* TS; for packet loss concealment */ - -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - PreFiltBankstr decimatorstr_obj; -#endif - -} ISACFIX_DecInst_t; - - - -typedef struct { - - ISACFIX_EncInst_t ISACenc_obj; - ISACFIX_DecInst_t ISACdec_obj; - BwEstimatorstr bwestimator_obj; - WebRtc_Word16 CodingMode; /* 0 = adaptive; 1 = instantaneous */ - WebRtc_Word16 errorcode; - WebRtc_Word16 initflag; /* 0 = nothing initiated; 1 = encoder or decoder */ - /* not initiated; 2 = all initiated */ -} ISACFIX_SubStruct; - - -typedef struct { - WebRtc_Word32 lpcGains[12]; /* 6 lower-band & 6 upper-band we may need to double it for 60*/ - /* */ - WebRtc_UWord32 W_upper; /* Upper boundary of interval W */ - WebRtc_UWord32 streamval; - WebRtc_UWord16 stream_index; /* Index to the current position in bytestream */ - WebRtc_Word16 full; /* 0 - first byte in memory filled, second empty*/ - /* 1 - both bytes are empty (we just filled the previous memory */ - WebRtc_UWord16 beforeLastWord; - WebRtc_UWord16 lastWord; -} transcode_obj; - - -//Bitstr_enc myBitStr; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_STRUCTS_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/fix/source/transform.c b/src/modules/audio_coding/codecs/isac/fix/source/transform.c deleted file mode 100644 index 56ef9f2..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/source/transform.c +++ /dev/null
@@ -1,296 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * WebRtcIsacfix_kTransform.c - * - * Transform functions - * - */ - -#include "fft.h" -#include "codec.h" -#include "settings.h" - - -/* Cosine table 1 in Q14 */ -static const WebRtc_Word16 kCosTab1[FRAMESAMPLES/2] = { - 16384, 16383, 16378, 16371, 16362, 16349, 16333, 16315, 16294, 16270, - 16244, 16214, 16182, 16147, 16110, 16069, 16026, 15980, 15931, 15880, - 15826, 15769, 15709, 15647, 15582, 15515, 15444, 15371, 15296, 15218, - 15137, 15053, 14968, 14879, 14788, 14694, 14598, 14500, 14399, 14295, - 14189, 14081, 13970, 13856, 13741, 13623, 13502, 13380, 13255, 13128, - 12998, 12867, 12733, 12597, 12458, 12318, 12176, 12031, 11885, 11736, - 11585, 11433, 11278, 11121, 10963, 10803, 10641, 10477, 10311, 10143, - 9974, 9803, 9630, 9456, 9280, 9102, 8923, 8743, 8561, 8377, - 8192, 8006, 7818, 7629, 7438, 7246, 7053, 6859, 6664, 6467, - 6270, 6071, 5872, 5671, 5469, 5266, 5063, 4859, 4653, 4447, - 4240, 4033, 3825, 3616, 3406, 3196, 2986, 2775, 2563, 2351, - 2139, 1926, 1713, 1499, 1285, 1072, 857, 643, 429, 214, - 0, -214, -429, -643, -857, -1072, -1285, -1499, -1713, -1926, - -2139, -2351, -2563, -2775, -2986, -3196, -3406, -3616, -3825, -4033, - -4240, -4447, -4653, -4859, -5063, -5266, -5469, -5671, -5872, -6071, - -6270, -6467, -6664, -6859, -7053, -7246, -7438, -7629, -7818, -8006, - -8192, -8377, -8561, -8743, -8923, -9102, -9280, -9456, -9630, -9803, - -9974, -10143, -10311, -10477, -10641, -10803, -10963, -11121, -11278, -11433, - -11585, -11736, -11885, -12031, -12176, -12318, -12458, -12597, -12733, -12867, - -12998, -13128, -13255, -13380, -13502, -13623, -13741, -13856, -13970, -14081, - -14189, -14295, -14399, -14500, -14598, -14694, -14788, -14879, -14968, -15053, - -15137, -15218, -15296, -15371, -15444, -15515, -15582, -15647, -15709, -15769, - -15826, -15880, -15931, -15980, -16026, -16069, -16110, -16147, -16182, -16214, - -16244, -16270, -16294, -16315, -16333, -16349, -16362, -16371, -16378, -16383 -}; - - -/* Sine table 1 in Q14 */ -static const WebRtc_Word16 kSinTab1[FRAMESAMPLES/2] = { - 0, 214, 429, 643, 857, 1072, 1285, 1499, 1713, 1926, - 2139, 2351, 2563, 2775, 2986, 3196, 3406, 3616, 3825, 4033, - 4240, 4447, 4653, 4859, 5063, 5266, 5469, 5671, 5872, 6071, - 6270, 6467, 6664, 6859, 7053, 7246, 7438, 7629, 7818, 8006, - 8192, 8377, 8561, 8743, 8923, 9102, 9280, 9456, 9630, 9803, - 9974, 10143, 10311, 10477, 10641, 10803, 10963, 11121, 11278, 11433, - 11585, 11736, 11885, 12031, 12176, 12318, 12458, 12597, 12733, 12867, - 12998, 13128, 13255, 13380, 13502, 13623, 13741, 13856, 13970, 14081, - 14189, 14295, 14399, 14500, 14598, 14694, 14788, 14879, 14968, 15053, - 15137, 15218, 15296, 15371, 15444, 15515, 15582, 15647, 15709, 15769, - 15826, 15880, 15931, 15980, 16026, 16069, 16110, 16147, 16182, 16214, - 16244, 16270, 16294, 16315, 16333, 16349, 16362, 16371, 16378, 16383, - 16384, 16383, 16378, 16371, 16362, 16349, 16333, 16315, 16294, 16270, - 16244, 16214, 16182, 16147, 16110, 16069, 16026, 15980, 15931, 15880, - 15826, 15769, 15709, 15647, 15582, 15515, 15444, 15371, 15296, 15218, - 15137, 15053, 14968, 14879, 14788, 14694, 14598, 14500, 14399, 14295, - 14189, 14081, 13970, 13856, 13741, 13623, 13502, 13380, 13255, 13128, - 12998, 12867, 12733, 12597, 12458, 12318, 12176, 12031, 11885, 11736, - 11585, 11433, 11278, 11121, 10963, 10803, 10641, 10477, 10311, 10143, - 9974, 9803, 9630, 9456, 9280, 9102, 8923, 8743, 8561, 8377, - 8192, 8006, 7818, 7629, 7438, 7246, 7053, 6859, 6664, 6467, - 6270, 6071, 5872, 5671, 5469, 5266, 5063, 4859, 4653, 4447, - 4240, 4033, 3825, 3616, 3406, 3196, 2986, 2775, 2563, 2351, - 2139, 1926, 1713, 1499, 1285, 1072, 857, 643, 429, 214 -}; - - -/* Cosine table 2 in Q14 */ -static const WebRtc_Word16 kCosTab2[FRAMESAMPLES/4] = { - 107, -322, 536, -750, 965, -1179, 1392, -1606, 1819, -2032, - 2245, -2457, 2669, -2880, 3091, -3301, 3511, -3720, 3929, -4137, - 4344, -4550, 4756, -4961, 5165, -5368, 5570, -5771, 5971, -6171, - 6369, -6566, 6762, -6957, 7150, -7342, 7534, -7723, 7912, -8099, - 8285, -8469, 8652, -8833, 9013, -9191, 9368, -9543, 9717, -9889, - 10059, -10227, 10394, -10559, 10722, -10883, 11042, -11200, 11356, -11509, - 11661, -11810, 11958, -12104, 12247, -12389, 12528, -12665, 12800, -12933, - 13063, -13192, 13318, -13441, 13563, -13682, 13799, -13913, 14025, -14135, - 14242, -14347, 14449, -14549, 14647, -14741, 14834, -14924, 15011, -15095, - 15178, -15257, 15334, -15408, 15480, -15549, 15615, -15679, 15739, -15798, - 15853, -15906, 15956, -16003, 16048, -16090, 16129, -16165, 16199, -16229, - 16257, -16283, 16305, -16325, 16342, -16356, 16367, -16375, 16381, -16384 -}; - - -/* Sine table 2 in Q14 */ -static const WebRtc_Word16 kSinTab2[FRAMESAMPLES/4] = { - 16384, -16381, 16375, -16367, 16356, -16342, 16325, -16305, 16283, -16257, - 16229, -16199, 16165, -16129, 16090, -16048, 16003, -15956, 15906, -15853, - 15798, -15739, 15679, -15615, 15549, -15480, 15408, -15334, 15257, -15178, - 15095, -15011, 14924, -14834, 14741, -14647, 14549, -14449, 14347, -14242, - 14135, -14025, 13913, -13799, 13682, -13563, 13441, -13318, 13192, -13063, - 12933, -12800, 12665, -12528, 12389, -12247, 12104, -11958, 11810, -11661, - 11509, -11356, 11200, -11042, 10883, -10722, 10559, -10394, 10227, -10059, - 9889, -9717, 9543, -9368, 9191, -9013, 8833, -8652, 8469, -8285, - 8099, -7912, 7723, -7534, 7342, -7150, 6957, -6762, 6566, -6369, - 6171, -5971, 5771, -5570, 5368, -5165, 4961, -4756, 4550, -4344, - 4137, -3929, 3720, -3511, 3301, -3091, 2880, -2669, 2457, -2245, - 2032, -1819, 1606, -1392, 1179, -965, 750, -536, 322, -107 -}; - - - -void WebRtcIsacfix_Time2Spec(WebRtc_Word16 *inre1Q9, - WebRtc_Word16 *inre2Q9, - WebRtc_Word16 *outreQ7, - WebRtc_Word16 *outimQ7) -{ - - int k; - WebRtc_Word32 tmpreQ16[FRAMESAMPLES/2], tmpimQ16[FRAMESAMPLES/2]; - WebRtc_Word16 tmp1rQ14, tmp1iQ14; - WebRtc_Word32 xrQ16, xiQ16, yrQ16, yiQ16; - WebRtc_Word32 v1Q16, v2Q16; - WebRtc_Word16 factQ19, sh; - - /* Multiply with complex exponentials and combine into one complex vector */ - factQ19 = 16921; // 0.5/sqrt(240) in Q19 is round(.5/sqrt(240)*(2^19)) = 16921 - for (k = 0; k < FRAMESAMPLES/2; k++) { - tmp1rQ14 = kCosTab1[k]; - tmp1iQ14 = kSinTab1[k]; - xrQ16 = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(tmp1rQ14, inre1Q9[k]) + WEBRTC_SPL_MUL_16_16(tmp1iQ14, inre2Q9[k]), 7); - xiQ16 = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(tmp1rQ14, inre2Q9[k]) - WEBRTC_SPL_MUL_16_16(tmp1iQ14, inre1Q9[k]), 7); - tmpreQ16[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(factQ19, xrQ16)+4, 3); // (Q16*Q19>>16)>>3 = Q16 - tmpimQ16[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(factQ19, xiQ16)+4, 3); // (Q16*Q19>>16)>>3 = Q16 - } - - - xrQ16 = WebRtcSpl_MaxAbsValueW32(tmpreQ16, FRAMESAMPLES/2); - yrQ16 = WebRtcSpl_MaxAbsValueW32(tmpimQ16, FRAMESAMPLES/2); - if (yrQ16>xrQ16) { - xrQ16 = yrQ16; - } - - sh = WebRtcSpl_NormW32(xrQ16); - sh = sh-24; //if sh becomes >=0, then we should shift sh steps to the left, and the domain will become Q(16+sh) - //if sh becomes <0, then we should shift -sh steps to the right, and the domain will become Q(16+sh) - - //"Fastest" vectors - if (sh>=0) { - for (k=0; k<FRAMESAMPLES/2; k++) { - inre1Q9[k] = (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W32(tmpreQ16[k], sh); //Q(16+sh) - inre2Q9[k] = (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W32(tmpimQ16[k], sh); //Q(16+sh) - } - } else { - WebRtc_Word32 round = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)1, -sh-1); - for (k=0; k<FRAMESAMPLES/2; k++) { - inre1Q9[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmpreQ16[k]+round, -sh); //Q(16+sh) - inre2Q9[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(tmpimQ16[k]+round, -sh); //Q(16+sh) - } - } - - /* Get DFT */ - WebRtcIsacfix_FftRadix16Fastest(inre1Q9, inre2Q9, -1); // real call - - //"Fastest" vectors - if (sh>=0) { - for (k=0; k<FRAMESAMPLES/2; k++) { - tmpreQ16[k] = WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)inre1Q9[k], sh); //Q(16+sh) -> Q16 - tmpimQ16[k] = WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)inre2Q9[k], sh); //Q(16+sh) -> Q16 - } - } else { - for (k=0; k<FRAMESAMPLES/2; k++) { - tmpreQ16[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)inre1Q9[k], -sh); //Q(16+sh) -> Q16 - tmpimQ16[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)inre2Q9[k], -sh); //Q(16+sh) -> Q16 - } - } - - - /* Use symmetry to separate into two complex vectors and center frames in time around zero */ - for (k = 0; k < FRAMESAMPLES/4; k++) { - xrQ16 = tmpreQ16[k] + tmpreQ16[FRAMESAMPLES/2 - 1 - k]; - yiQ16 = -tmpreQ16[k] + tmpreQ16[FRAMESAMPLES/2 - 1 - k]; - xiQ16 = tmpimQ16[k] - tmpimQ16[FRAMESAMPLES/2 - 1 - k]; - yrQ16 = tmpimQ16[k] + tmpimQ16[FRAMESAMPLES/2 - 1 - k]; - tmp1rQ14 = kCosTab2[k]; - tmp1iQ14 = kSinTab2[k]; - v1Q16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, xrQ16) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, xiQ16); - v2Q16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, xrQ16) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, xiQ16); - outreQ7[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(v1Q16, 9); - outimQ7[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(v2Q16, 9); - v1Q16 = -WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, yrQ16) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, yiQ16); - v2Q16 = -WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, yrQ16) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, yiQ16); - outreQ7[FRAMESAMPLES/2 - 1 - k] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(v1Q16, 9); //CalcLrIntQ(v1Q16, 9); - outimQ7[FRAMESAMPLES/2 - 1 - k] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(v2Q16, 9); //CalcLrIntQ(v2Q16, 9); - - } -} - - -void WebRtcIsacfix_Spec2Time(WebRtc_Word16 *inreQ7, WebRtc_Word16 *inimQ7, WebRtc_Word32 *outre1Q16, WebRtc_Word32 *outre2Q16) -{ - - int k; - WebRtc_Word16 tmp1rQ14, tmp1iQ14; - WebRtc_Word32 xrQ16, xiQ16, yrQ16, yiQ16; - WebRtc_Word32 tmpInRe, tmpInIm, tmpInRe2, tmpInIm2; - WebRtc_Word16 factQ11; - WebRtc_Word16 sh; - - for (k = 0; k < FRAMESAMPLES/4; k++) { - /* Move zero in time to beginning of frames */ - tmp1rQ14 = kCosTab2[k]; - tmp1iQ14 = kSinTab2[k]; - - tmpInRe = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32) inreQ7[k], 9); // Q7 -> Q16 - tmpInIm = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32) inimQ7[k], 9); // Q7 -> Q16 - tmpInRe2 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32) inreQ7[FRAMESAMPLES/2 - 1 - k], 9); // Q7 -> Q16 - tmpInIm2 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32) inimQ7[FRAMESAMPLES/2 - 1 - k], 9); // Q7 -> Q16 - - xrQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInRe) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInIm); - xiQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInIm) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInRe); - yrQ16 = -WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInIm2) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInRe2); - yiQ16 = -WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInRe2) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInIm2); - - /* Combine into one vector, z = x + j * y */ - outre1Q16[k] = xrQ16 - yiQ16; - outre1Q16[FRAMESAMPLES/2 - 1 - k] = xrQ16 + yiQ16; - outre2Q16[k] = xiQ16 + yrQ16; - outre2Q16[FRAMESAMPLES/2 - 1 - k] = -xiQ16 + yrQ16; - } - - /* Get IDFT */ - tmpInRe = WebRtcSpl_MaxAbsValueW32(outre1Q16, 240); - tmpInIm = WebRtcSpl_MaxAbsValueW32(outre2Q16, 240); - if (tmpInIm>tmpInRe) { - tmpInRe = tmpInIm; - } - - sh = WebRtcSpl_NormW32(tmpInRe); - sh = sh-24; //if sh becomes >=0, then we should shift sh steps to the left, and the domain will become Q(16+sh) - //if sh becomes <0, then we should shift -sh steps to the right, and the domain will become Q(16+sh) - - //"Fastest" vectors - if (sh>=0) { - for (k=0; k<240; k++) { - inreQ7[k] = (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W32(outre1Q16[k], sh); //Q(16+sh) - inimQ7[k] = (WebRtc_Word16) WEBRTC_SPL_LSHIFT_W32(outre2Q16[k], sh); //Q(16+sh) - } - } else { - WebRtc_Word32 round = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)1, -sh-1); - for (k=0; k<240; k++) { - inreQ7[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(outre1Q16[k]+round, -sh); //Q(16+sh) - inimQ7[k] = (WebRtc_Word16) WEBRTC_SPL_RSHIFT_W32(outre2Q16[k]+round, -sh); //Q(16+sh) - } - } - - WebRtcIsacfix_FftRadix16Fastest(inreQ7, inimQ7, 1); // real call - - //"Fastest" vectors - if (sh>=0) { - for (k=0; k<240; k++) { - outre1Q16[k] = WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)inreQ7[k], sh); //Q(16+sh) -> Q16 - outre2Q16[k] = WEBRTC_SPL_RSHIFT_W32((WebRtc_Word32)inimQ7[k], sh); //Q(16+sh) -> Q16 - } - } else { - for (k=0; k<240; k++) { - outre1Q16[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)inreQ7[k], -sh); //Q(16+sh) -> Q16 - outre2Q16[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)inimQ7[k], -sh); //Q(16+sh) -> Q16 - } - } - - /* Divide through by the normalizing constant: */ - /* scale all values with 1/240, i.e. with 273 in Q16 */ - /* 273/65536 ~= 0.0041656 */ - /* 1/240 ~= 0.0041666 */ - for (k=0; k<240; k++) { - outre1Q16[k] = WEBRTC_SPL_MUL_16_32_RSFT16(273, outre1Q16[k]); - outre2Q16[k] = WEBRTC_SPL_MUL_16_32_RSFT16(273, outre2Q16[k]); - } - - /* Demodulate and separate */ - factQ11 = 31727; // sqrt(240) in Q11 is round(15.49193338482967*2048) = 31727 - for (k = 0; k < FRAMESAMPLES/2; k++) { - tmp1rQ14 = kCosTab1[k]; - tmp1iQ14 = kSinTab1[k]; - xrQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, outre1Q16[k]) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, outre2Q16[k]); - xiQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, outre2Q16[k]) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, outre1Q16[k]); - xrQ16 = WEBRTC_SPL_MUL_16_32_RSFT11(factQ11, xrQ16); - xiQ16 = WEBRTC_SPL_MUL_16_32_RSFT11(factQ11, xiQ16); - outre2Q16[k] = xiQ16; - outre1Q16[k] = xrQ16; - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/test/Android.mk b/src/modules/audio_coding/codecs/isac/fix/test/Android.mk deleted file mode 100644 index 066738a..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/test/Android.mk +++ /dev/null
@@ -1,63 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -########################### -# isac test app - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests -LOCAL_CPP_EXTENSION := .cc -LOCAL_SRC_FILES:= kenny.c - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := $(MY_WEBRTC_COMMON_DEFS) - -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) -LOCAL_CFLAGS_x86 := $(MY_WEBRTC_COMMON_DEFS_x86) -LOCAL_CFLAGS_mips := $(MY_WEBRTC_COMMON_DEFS_mips) -LOCAL_CFLAGS_arm64 := $(MY_WEBRTC_COMMON_DEFS_arm64) -LOCAL_CFLAGS_x86_64 := $(MY_WEBRTC_COMMON_DEFS_x86_64) -LOCAL_CFLAGS_mips64 := $(MY_WEBRTC_COMMON_DEFS_mips64) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../interface \ - $(LOCAL_PATH)/../../../../../.. - -MY_LIB_SUFFIX := -ifdef WEBRTC_STL -MY_LIB_SUFFIX := _$(WEBRTC_STL) -endif - -LOCAL_STATIC_LIBRARIES := \ - libwebrtc_isacfix$(MY_LIB_SUFFIX) \ - libwebrtc_spl$(MY_LIB_SUFFIX) \ - libwebrtc_system_wrappers$(MY_LIB_SUFFIX) - -ifeq ($(WEBRTC_BUILD_NEON_LIBS),true) -# We need to dup libwebrtc_isacfix$(MY_LIB_SUFFIX) because ibwebrtc_isacfix_neon$(MY_LIB_SUFFIX) -# has dependency on it. -LOCAL_STATIC_LIBRARIES_arm += \ - libwebrtc_isacfix$(MY_LIB_SUFFIX) \ - libwebrtc_isacfix_neon$(MY_LIB_SUFFIX) -endif - -LOCAL_SHARED_LIBRARIES := \ - libutils - -LOCAL_MODULE:= webrtc_isac_test - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -LOCAL_SHARED_LIBRARIES := -endif -include $(BUILD_NATIVE_TEST)
diff --git a/src/modules/audio_coding/codecs/isac/fix/test/ISACHist.cc b/src/modules/audio_coding/codecs/isac/fix/test/ISACHist.cc deleted file mode 100644 index 753acd7..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/test/ISACHist.cc +++ /dev/null
@@ -1,173 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -//#include "isac_codec.h" -//#include "isac_structs.h" -#include "isacfix.h" - - -#define NUM_CODECS 1 - -int main(int argc, char* argv[]) -{ - FILE *inFileList; - FILE *audioFile; - FILE *outFile; - char audioFileName[501]; - short audioBuff[960]; - short encoded[600]; - short startAudio; - short encodedLen; - ISACFIX_MainStruct *isac_struct; - unsigned long int hist[601]; - - // reset the histogram - for(short n=0; n < 601; n++) - { - hist[n] = 0; - } - - - inFileList = fopen(argv[1], "r"); - if(inFileList == NULL) - { - printf("Could not open the input file.\n"); - getchar(); - exit(-1); - } - outFile = fopen(argv[2], "w"); - if(outFile == NULL) - { - printf("Could not open the histogram file.\n"); - getchar(); - exit(-1); - } - - short frameSizeMsec = 30; - if(argc > 3) - { - frameSizeMsec = atoi(argv[3]); - } - - short audioOffset = 0; - if(argc > 4) - { - audioOffset = atoi(argv[4]); - } - int ok; - ok = WebRtcIsacfix_Create(&isac_struct); - // instantaneous mode - ok |= WebRtcIsacfix_EncoderInit(isac_struct, 1); - // is not used but initialize - ok |= WebRtcIsacfix_DecoderInit(isac_struct); - ok |= WebRtcIsacfix_Control(isac_struct, 32000, frameSizeMsec); - - if(ok != 0) - { - printf("\nProblem in seting up iSAC\n"); - exit(-1); - } - - while( fgets(audioFileName, 500, inFileList) != NULL ) - { - // remove trailing white-spaces and any Cntrl character - if(strlen(audioFileName) == 0) - { - continue; - } - short n = strlen(audioFileName) - 1; - while(isspace(audioFileName[n]) || iscntrl(audioFileName[n])) - { - audioFileName[n] = '\0'; - n--; - if(n < 0) - { - break; - } - } - - // remove leading spaces - if(strlen(audioFileName) == 0) - { - continue; - } - n = 0; - while((isspace(audioFileName[n]) || iscntrl(audioFileName[n])) && - (audioFileName[n] != '\0')) - { - n++; - } - memmove(audioFileName, &audioFileName[n], 500 - n); - if(strlen(audioFileName) == 0) - { - continue; - } - audioFile = fopen(audioFileName, "rb"); - if(audioFile == NULL) - { - printf("\nCannot open %s!!!!!\n", audioFileName); - exit(0); - } - - if(audioOffset > 0) - { - fseek(audioFile, (audioOffset<<1), SEEK_SET); - } - - while(fread(audioBuff, sizeof(short), (480*frameSizeMsec/30), audioFile) >= (480*frameSizeMsec/30)) - { - startAudio = 0; - do - { - encodedLen = WebRtcIsacfix_Encode(isac_struct, - &audioBuff[startAudio], encoded); - startAudio += 160; - } while(encodedLen == 0); - - if(encodedLen < 0) - { - printf("\nEncoding Error!!!\n"); - exit(0); - } - hist[encodedLen]++; - } - fclose(audioFile); - } - fclose(inFileList); - unsigned long totalFrames = 0; - for(short n=0; n < 601; n++) - { - totalFrames += hist[n]; - fprintf(outFile, "%10lu\n", hist[n]); - } - fclose(outFile); - - short topTenCntr = 0; - printf("\nTotal number of Frames %lu\n\n", totalFrames); - printf("Payload Len # occurences\n"); - printf("=========== ============\n"); - - for(short n = 600; (n >= 0) && (topTenCntr < 10); n--) - { - if(hist[n] > 0) - { - topTenCntr++; - printf(" %3d %3d\n", n, hist[n]); - } - } - WebRtcIsacfix_Free(isac_struct); - return 0; -} -
diff --git a/src/modules/audio_coding/codecs/isac/fix/test/Isac_test.cc b/src/modules/audio_coding/codecs/isac/fix/test/Isac_test.cc deleted file mode 100644 index 2791db4..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/test/Isac_test.cc +++ /dev/null
@@ -1,260 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/****************************************************************** - Stand Alone test application for ISACFIX and ISAC LC - -******************************************************************/ - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include "typedefs.h" - -#include "isacfix.h" -ISACFIX_MainStruct *ISACfix_inst; - -#define FS 16000 - - -typedef struct { - WebRtc_UWord32 arrival_time; /* samples */ - WebRtc_UWord32 sample_count; /* samples */ - WebRtc_UWord16 rtp_number; -} BottleNeckModel; - -void get_arrival_time(int current_framesamples, /* samples */ - int packet_size, /* bytes */ - int bottleneck, /* excluding headers; bits/s */ - BottleNeckModel *BN_data) -{ - const int HeaderSize = 35; - int HeaderRate; - - HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */ - - /* everything in samples */ - BN_data->sample_count = BN_data->sample_count + current_framesamples; - - BN_data->arrival_time += ((packet_size + HeaderSize) * 8 * FS) / (bottleneck + HeaderRate); - - if (BN_data->arrival_time < BN_data->sample_count) - BN_data->arrival_time = BN_data->sample_count; - - BN_data->rtp_number++; -} - -/* -#ifdef __cplusplus -extern "C" { -#endif -*/ -int main(int argc, char* argv[]){ - - /* Parameters */ - FILE *pInFile, *pOutFile, *pChcFile; - WebRtc_Word8 inFile[40]; - WebRtc_Word8 outFile[40]; - WebRtc_Word8 chcFile[40]; - WebRtc_Word8 codec[10]; - WebRtc_Word16 bitrt, spType, size; - WebRtc_UWord16 frameLen; - WebRtc_Word16 sigOut[1000], sigIn[1000]; - WebRtc_UWord16 bitStream[500]; /* double to 32 kbps for 60 ms */ - - WebRtc_Word16 chc, ok; - int noOfCalls, cdlen; - WebRtc_Word16 noOfLostFrames; - int err, errtype; - - BottleNeckModel BN_data; - - int totalbits =0; - int totalsmpls =0; - - /*End Parameters*/ - - - if ((argc==6)||(argc==7) ){ - - strcpy(codec,argv[5]); - - if(argc==7){ - if (!_stricmp("isac",codec)){ - bitrt = atoi(argv[6]); - if ( (bitrt<10000)&&(bitrt>32000)){ - printf("Error: Supported bit rate in the range 10000-32000 bps!\n"); - exit(-1); - } - - }else{ - printf("Error: Codec not recognized. Check spelling!\n"); - exit(-1); - } - - } else { - printf("Error: Codec not recognized. Check spelling!\n"); - exit(-1); - } - } else { - printf("Error: Wrong number of input parameter!\n\n"); - exit(-1); - } - - frameLen = atoi(argv[4]); - strcpy(chcFile,argv[3]); - strcpy(outFile,argv[2]); - strcpy(inFile,argv[1]); - - /* Open file streams */ - if( (pInFile = fopen(inFile,"rb")) == NULL ) { - printf( "Error: Did not find input file!\n" ); - exit(-1); - } - strcat(outFile,"_"); - strcat(outFile, argv[4]); - strcat(outFile,"_"); - strcat(outFile, codec); - - if (argc==7){ - strcat(outFile,"_"); - strcat(outFile, argv[6]); - } - if (_stricmp("none", chcFile)){ - strcat(outFile,"_"); - strcat(outFile, "plc"); - } - - strcat(outFile, ".otp"); - - if (_stricmp("none", chcFile)){ - if( (pChcFile = fopen(chcFile,"rb")) == NULL ) { - printf( "Error: Did not find channel file!\n" ); - exit(-1); - } - } - /******************************************************************/ - if (!_stricmp("isac", codec)){ /* ISAC */ - if ((frameLen!=480)&&(frameLen!=960)) { - printf("Error: ISAC only supports 480 and 960 samples per frame (not %d)\n", frameLen); - exit(-1); - } - if( (pOutFile = fopen(outFile,"wb")) == NULL ) { - printf( "Could not open output file!\n" ); - exit(-1); - } - ok=WebRtcIsacfix_Create(&ISACfix_inst); - if (ok!=0) { - printf("Couldn't allocate memory for iSAC fix instance\n"); - exit(-1); - } - - BN_data.arrival_time = 0; - BN_data.sample_count = 0; - BN_data.rtp_number = 0; - - WebRtcIsacfix_EncoderInit(ISACfix_inst,1); - WebRtcIsacfix_DecoderInit(ISACfix_inst); - err = WebRtcIsacfix_Control(ISACfix_inst, bitrt, (frameLen>>4)); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACfix_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - /* loop over frame */ - while (fread(sigIn,sizeof(WebRtc_Word16),frameLen,pInFile) == frameLen) { - - noOfCalls=0; - cdlen=0; - while (cdlen<=0) { - cdlen=WebRtcIsacfix_Encode(ISACfix_inst,&sigIn[noOfCalls*160],(WebRtc_Word16*)bitStream); - if(cdlen==-1){ - errtype=WebRtcIsacfix_GetErrorCode(ISACfix_inst); - printf("\n\nError in encoder: %d.\n\n", errtype); - exit(-1); - } - noOfCalls++; - } - - - if(_stricmp("none", chcFile)){ - if (fread(&chc,sizeof(WebRtc_Word16),1,pChcFile)!=1) /* packet may be lost */ - break; - } else { - chc = 1; /* packets never lost */ - } - - /* simulate packet handling through NetEq and the modem */ - get_arrival_time(frameLen, cdlen, bitrt, &BN_data); - - if (chc){ /* decode */ - - err = WebRtcIsacfix_UpdateBwEstimate1(ISACfix_inst, - bitStream, - cdlen, - BN_data.rtp_number, - BN_data.arrival_time); - - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACfix_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - size = WebRtcIsacfix_Decode(ISACfix_inst, bitStream, cdlen, sigOut, &spType); - if(size<=0){ - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACfix_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - exit(-1); - } - } else { /* PLC */ - if (frameLen == 480){ - noOfLostFrames = 1; - } else{ - noOfLostFrames = 2; - } - size = WebRtcIsacfix_DecodePlc(ISACfix_inst, sigOut, noOfLostFrames ); - if(size<=0){ - errtype=WebRtcIsacfix_GetErrorCode(ISACfix_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - exit(-1); - } - } - - /* Write decoded speech to file */ - fwrite(sigOut,sizeof(short),size,pOutFile); - - totalbits += 8 * cdlen; - totalsmpls += size; - - } - /******************************************************************/ - } - -// printf("\n\ntotal bits = %d bits", totalbits); - printf("\nmeasured average bitrate = %0.3f kbits/s", (double)totalbits * 16 / totalsmpls); - printf("\n"); - - - fclose(pInFile); - fclose(pOutFile); - if (_stricmp("none", chcFile)){ - fclose(pChcFile); - } - - if (!_stricmp("isac", codec)){ - WebRtcIsacfix_Free(ISACfix_inst); - } - - return 0; - -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/test/isacfix_unittest.cc b/src/modules/audio_coding/codecs/isac/fix/test/isacfix_unittest.cc deleted file mode 100644 index bef71e9..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/test/isacfix_unittest.cc +++ /dev/null
@@ -1,96 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include <typedefs.h> - -#include "gtest/gtest.h" -#include "modules/audio_coding/codecs/isac/fix/source/filterbank_internal.h" -#include "modules/audio_coding/codecs/isac/fix/source/filterbank_tables.h" -#include "modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h" -#include "system_wrappers/interface/cpu_features_wrapper.h" - -class IsacUnitTest : public testing::Test { - protected: - // Pass a function pointer to the Tester function. - void CalculateResidualEnergyTester(CalculateResidualEnergy - CalculateResidualEnergyFunction) { - const int kIntOrder = 10; - const int32_t kInt32QDomain = 5; - const int kIntShift = 11; - int16_t a[kIntOrder + 1] = {32760, 122, 7, 0, -32760, -3958, - -48, 18745, 498, 9, 23456}; - int32_t corr[kIntOrder + 1] = {11443647, -27495, 0, - 98745, -11443600, 1, 1, 498, 9, 888, 23456}; - int q_shift_residual = 0; - int32_t residual_energy = 0; - - // Test the code path where (residual_energy >= 0x10000). - residual_energy = CalculateResidualEnergyFunction(kIntOrder, - kInt32QDomain, kIntShift, a, corr, &q_shift_residual); - EXPECT_EQ(1789023310, residual_energy); - EXPECT_EQ(2, q_shift_residual); - - // Test the code path where (residual_energy < 0x10000) - // and ((energy & 0x8000) != 0). - for(int i = 0; i < kIntOrder + 1; i++) { - a[i] = 24575 >> i; - corr[i] = i; - } - residual_energy = CalculateResidualEnergyFunction(kIntOrder, - kInt32QDomain, kIntShift, a, corr, &q_shift_residual); - EXPECT_EQ(1595279092, residual_energy); - EXPECT_EQ(26, q_shift_residual); - - // Test the code path where (residual_energy <= 0x7fff). - for(int i = 0; i < kIntOrder + 1; i++) { - a[i] = 2457 >> i; - } - residual_energy = CalculateResidualEnergyFunction(kIntOrder, - kInt32QDomain, kIntShift, a, corr, &q_shift_residual); - EXPECT_EQ(2029266944, residual_energy); - EXPECT_EQ(33, q_shift_residual); - } -}; - -TEST_F(IsacUnitTest, CalculateResidualEnergyTest) { - CalculateResidualEnergyTester(WebRtcIsacfix_CalculateResidualEnergyC); -#ifdef WEBRTC_DETECT_ARM_NEON - if ((WebRtc_GetCPUFeaturesARM() & kCPUFeatureNEON) != 0) { - CalculateResidualEnergyTester(WebRtcIsacfix_CalculateResidualEnergyNeon); - } -#elif defined(WEBRTC_ARCH_ARM_NEON) - CalculateResidualEnergyTester(WebRtcIsacfix_CalculateResidualEnergyNeon); -#endif -} - -TEST_F(IsacUnitTest, HighpassFilterFixDec32Test) { - const int kSamples = 20; - int16_t in[kSamples]; - int32_t state[2] = {12345, 987654}; -#ifdef WEBRTC_ARCH_ARM_V7 - int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20018, 7917, - -1279, -8552, -14494, -7558, -23537, -27258, -30554, -32768, -3432, -32768, - 25215, -27536, 22436}; -#else - int32_t out[kSamples] = {-1040, -1035, -22875, -1397, -27604, 20017, 7915, - -1280, -8554, -14496, -7561, -23541, -27263, -30560, -32768, -3441, -32768, - 25203, -27550, 22419}; -#endif - - for(int i = 0; i < kSamples; i++) { - in[i] = WEBRTC_SPL_WORD32_MAX / (i + 1); - } - - WebRtcIsacfix_HighpassFilterFixDec32(in, kSamples, - WebRtcIsacfix_kHPStCoeffOut1Q30, state); - - for(int i = 0; i < kSamples; i++) { - EXPECT_EQ(out[i], in[i]); - } -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/test/kenny.c b/src/modules/audio_coding/codecs/isac/fix/test/kenny.c deleted file mode 100644 index ea6b09e..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/test/kenny.c +++ /dev/null
@@ -1,853 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* kenny.c - Main function for the iSAC coder */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> - -#include "isacfix.h" - - -/* Defines */ -#define SEED_FILE "randseed.txt" /* Used when running decoder on garbage data */ -#define MAX_FRAMESAMPLES 960 /* max number of samples per frame (= 60 ms frame) */ -#define FRAMESAMPLES_10ms 160 /* number of samples per 10ms frame */ -#define FS 16000 /* sampling frequency (Hz) */ - -/* Function for reading audio data from PCM file */ -int readframe(WebRtc_Word16 *data, FILE *inp, int length) { - - short k, rlen, status = 0; - - rlen = fread(data, sizeof(WebRtc_Word16), length, inp); - if (rlen < length) { - for (k = rlen; k < length; k++) - data[k] = 0; - status = 1; - } - - return status; -} - -/* Struct for bottleneck model */ -typedef struct { - WebRtc_UWord32 send_time; /* samples */ - WebRtc_UWord32 arrival_time; /* samples */ - WebRtc_UWord32 sample_count; /* samples */ - WebRtc_UWord16 rtp_number; -} BottleNeckModel; - -void get_arrival_time(int current_framesamples, /* samples */ - int packet_size, /* bytes */ - int bottleneck, /* excluding headers; bits/s */ - BottleNeckModel *BN_data) -{ - const int HeaderSize = 35; - int HeaderRate; - - HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */ - - /* everything in samples */ - BN_data->sample_count = BN_data->sample_count + current_framesamples; - - BN_data->arrival_time += ((packet_size + HeaderSize) * 8 * FS) / (bottleneck + HeaderRate); - BN_data->send_time += current_framesamples; - - if (BN_data->arrival_time < BN_data->sample_count) - BN_data->arrival_time = BN_data->sample_count; - - BN_data->rtp_number++; -} - -void get_arrival_time2(int current_framesamples, - int current_delay, - BottleNeckModel *BN_data) -{ - if (current_delay == -1) - //dropped packet - { - BN_data->arrival_time += current_framesamples; - } - else if (current_delay != -2) - { - // - BN_data->arrival_time += (current_framesamples + ((FS/1000) * current_delay)); - } - //else - //current packet has same timestamp as previous packet - - BN_data->rtp_number++; -} - -int main(int argc, char* argv[]) -{ - - char inname[100], outname[100], outbitsname[100], bottleneck_file[100]; - FILE *inp, *outp, *f_bn, *outbits; - int endfile; - - int i, errtype, h = 0, k, packetLossPercent = 0; - WebRtc_Word16 CodingMode; - WebRtc_Word16 bottleneck; - WebRtc_Word16 framesize = 30; /* ms */ - int cur_framesmpls, err = 0, lostPackets = 0; - - /* Runtime statistics */ - double starttime, runtime, length_file; - - WebRtc_Word16 stream_len = 0; - WebRtc_Word16 framecnt, declen = 0; - WebRtc_Word16 shortdata[FRAMESAMPLES_10ms]; - WebRtc_Word16 decoded[MAX_FRAMESAMPLES]; - WebRtc_UWord16 streamdata[500]; - WebRtc_Word16 speechType[1]; - WebRtc_Word16 prevFrameSize = 1; - WebRtc_Word16 rateBPS = 0; - WebRtc_Word16 fixedFL = 0; - WebRtc_Word16 payloadSize = 0; - WebRtc_Word32 payloadRate = 0; - int setControlBWE = 0; - int readLoss; - FILE *plFile = NULL; - - char version_number[20]; - char tmpBit[5] = ".bit"; - - double kbps; - int totalbits =0; - int totalsmpls =0; -#ifdef _DEBUG - FILE *fy; -#endif - WebRtc_Word16 testNum, testCE; - - FILE *fp_gns = NULL; - int gns = 0; - int cur_delay = 0; - char gns_file[100]; - - int nbTest = 0; - WebRtc_Word16 lostFrame; - float scale = (float)0.7; - /* only one structure used for ISAC encoder */ - ISACFIX_MainStruct *ISAC_main_inst; - - /* For fault test 10, garbage data */ - FILE *seedfile; - unsigned int random_seed = (unsigned int) time(NULL);//1196764538 - - BottleNeckModel BN_data; - f_bn = NULL; - -#ifdef _DEBUG - fy = fopen("bit_rate.dat", "w"); - fclose(fy); - fy = fopen("bytes_frames.dat", "w"); - fclose(fy); -#endif - - readLoss = 0; - packetLossPercent = 0; - - /* Handling wrong input arguments in the command line */ - if ((argc<3) || (argc>21)) { - printf("\n\nWrong number of arguments or flag values.\n\n"); - - printf("\n"); - WebRtcIsacfix_version(version_number); - printf("iSAC version %s \n\n", version_number); - - printf("Usage:\n\n"); - printf("./kenny.exe [-F num][-I] bottleneck_value infile outfile \n\n"); - printf("with:\n"); - printf("[-I] :if -I option is specified, the coder will use\n"); - printf(" an instantaneous Bottleneck value. If not, it\n"); - printf(" will be an adaptive Bottleneck value.\n\n"); - printf("bottleneck_value :the value of the bottleneck provided either\n"); - printf(" as a fixed value (e.g. 25000) or\n"); - printf(" read from a file (e.g. bottleneck.txt)\n\n"); - printf("[-INITRATE num] :Set a new value for initial rate. Note! Only used" - " in adaptive mode.\n\n"); - printf("[-FL num] :Set (initial) frame length in msec. Valid length" - " are 30 and 60 msec.\n\n"); - printf("[-FIXED_FL] :Frame length will be fixed to initial value.\n\n"); - printf("[-MAX num] :Set the limit for the payload size of iSAC" - " in bytes. \n"); - printf(" Minimum 100, maximum 400.\n\n"); - printf("[-MAXRATE num] :Set the maxrate for iSAC in bits per second. \n"); - printf(" Minimum 32000, maximum 53400.\n\n"); - printf("[-F num] :if -F option is specified, the test function\n"); - printf(" will run the iSAC API fault scenario specified" - " by the\n"); - printf(" supplied number.\n"); - printf(" F 1 - Call encoder prior to init encoder call\n"); - printf(" F 2 - Call decoder prior to init decoder call\n"); - printf(" F 3 - Call decoder prior to encoder call\n"); - printf(" F 4 - Call decoder with a too short coded" - " sequence\n"); - printf(" F 5 - Call decoder with a too long coded" - " sequence\n"); - printf(" F 6 - Call decoder with random bit stream\n"); - printf(" F 7 - Call init encoder/decoder at random" - " during a call\n"); - printf(" F 8 - Call encoder/decoder without having" - " allocated memory for \n"); - printf(" encoder/decoder instance\n"); - printf(" F 9 - Call decodeB without calling decodeA\n"); - printf(" F 10 - Call decodeB with garbage data\n"); - printf("[-PL num] : if -PL option is specified 0<num<100 will " - "specify the\n"); - printf(" percentage of packet loss\n\n"); - printf("[-G file] : if -G option is specified the file given is" - " a .gns file\n"); - printf(" that represents a network profile\n\n"); - printf("[-NB num] : if -NB option, use the narrowband interfaces\n"); - printf(" num=1 => encode with narrowband encoder" - " (infile is narrowband)\n"); - printf(" num=2 => decode with narrowband decoder" - " (outfile is narrowband)\n\n"); - printf("[-CE num] : Test of APIs used by Conference Engine.\n"); - printf(" CE 1 - createInternal, freeInternal," - " getNewBitstream \n"); - printf(" CE 2 - transcode, getBWE \n"); - printf(" CE 3 - getSendBWE, setSendBWE. \n\n"); - printf("[-RTP_INIT num] : if -RTP_INIT option is specified num will be" - " the initial\n"); - printf(" value of the rtp sequence number.\n\n"); - printf("infile : Normal speech input file\n\n"); - printf("outfile : Speech output file\n\n"); - printf("Example usage : \n\n"); - printf("./kenny.exe -I bottleneck.txt speechIn.pcm speechOut.pcm\n\n"); - exit(0); - - } - - /* Print version number */ - WebRtcIsacfix_version(version_number); - printf("iSAC version %s \n\n", version_number); - - /* Loop over all command line arguments */ - CodingMode = 0; - testNum = 0; - testCE = 0; - for (i = 1; i < argc-2;i++) { - /* Instantaneous mode */ - if (!strcmp ("-I", argv[i])) { - printf("\nInstantaneous BottleNeck\n"); - CodingMode = 1; - i++; - } - - /* Set (initial) bottleneck value */ - if (!strcmp ("-INITRATE", argv[i])) { - rateBPS = atoi(argv[i + 1]); - setControlBWE = 1; - if ((rateBPS < 10000) || (rateBPS > 32000)) { - printf("\n%d is not a initial rate. " - "Valid values are in the range 10000 to 32000.\n", rateBPS); - exit(0); - } - printf("\nNew initial rate: %d\n", rateBPS); - i++; - } - - /* Set (initial) framelength */ - if (!strcmp ("-FL", argv[i])) { - framesize = atoi(argv[i + 1]); - if ((framesize != 30) && (framesize != 60)) { - printf("\n%d is not a valid frame length. " - "Valid length are 30 and 60 msec.\n", framesize); - exit(0); - } - printf("\nFrame Length: %d\n", framesize); - i++; - } - - /* Fixed frame length */ - if (!strcmp ("-FIXED_FL", argv[i])) { - fixedFL = 1; - setControlBWE = 1; - } - - /* Set maximum allowed payload size in bytes */ - if (!strcmp ("-MAX", argv[i])) { - payloadSize = atoi(argv[i + 1]); - printf("Maximum Payload Size: %d\n", payloadSize); - i++; - } - - /* Set maximum rate in bytes */ - if (!strcmp ("-MAXRATE", argv[i])) { - payloadRate = atoi(argv[i + 1]); - printf("Maximum Rate in kbps: %d\n", payloadRate); - i++; - } - - /* Test of fault scenarious */ - if (!strcmp ("-F", argv[i])) { - testNum = atoi(argv[i + 1]); - printf("\nFault test: %d\n", testNum); - if (testNum < 1 || testNum > 10) { - printf("\n%d is not a valid Fault Scenario number." - " Valid Fault Scenarios are numbered 1-10.\n", testNum); - exit(0); - } - i++; - } - - /* Packet loss test */ - if (!strcmp ("-PL", argv[i])) { - if( isdigit( *argv[i+1] ) ) { - packetLossPercent = atoi( argv[i+1] ); - if( (packetLossPercent < 0) | (packetLossPercent > 100) ) { - printf( "\nInvalid packet loss perentage \n" ); - exit( 0 ); - } - if( packetLossPercent > 0 ) { - printf( "\nSimulating %d %% of independent packet loss\n", - packetLossPercent ); - } else { - printf( "\nNo Packet Loss Is Simulated \n" ); - } - readLoss = 0; - } else { - readLoss = 1; - plFile = fopen( argv[i+1], "rb" ); - if( plFile == NULL ) { - printf( "\n couldn't open the frameloss file: %s\n", argv[i+1] ); - exit( 0 ); - } - printf( "\nSimulating packet loss through the given " - "channel file: %s\n", argv[i+1] ); - } - i++; - } - - /* Random packetlosses */ - if (!strcmp ("-rnd", argv[i])) { - srand(time(NULL) ); - printf( "\n Random pattern in lossed packets \n" ); - } - - /* Use gns file */ - if (!strcmp ("-G", argv[i])) { - sscanf(argv[i + 1], "%s", gns_file); - fp_gns = fopen(gns_file, "rb"); - if (fp_gns == NULL) { - printf("Cannot read file %s.\n", gns_file); - exit(0); - } - gns = 1; - i++; - } - - /* Run Narrowband interfaces (either encoder or decoder) */ - if (!strcmp ("-NB", argv[i])) { - nbTest = atoi(argv[i + 1]); - i++; - } - - /* Run Conference Engine APIs */ - if (!strcmp ("-CE", argv[i])) { - testCE = atoi(argv[i + 1]); - if (testCE==1 || testCE==2) { - i++; - scale = (float)strtod( argv[i+1], NULL ); - } else if (testCE < 1 || testCE > 3) { - printf("\n%d is not a valid CE-test number, valid Fault " - "Scenarios are numbered 1-3\n", testCE); - exit(0); - } - i++; - } - - /* Set initial RTP number */ - if (!strcmp ("-RTP_INIT", argv[i])) { - i++; - } - } - - /* Get Bottleneck value */ - /* Gns files and bottleneck should not and can not be used simultaneously */ - bottleneck = atoi(argv[CodingMode+1]); - if (bottleneck == 0 && gns == 0) { - sscanf(argv[CodingMode+1], "%s", bottleneck_file); - f_bn = fopen(bottleneck_file, "rb"); - if (f_bn == NULL) { - printf("No value provided for BottleNeck and cannot read file %s\n", bottleneck_file); - exit(0); - } else { - int aux_var; - printf("reading bottleneck rates from file %s\n\n",bottleneck_file); - if (fscanf(f_bn, "%d", &aux_var) == EOF) { - /* Set pointer to beginning of file */ - fseek(f_bn, 0L, SEEK_SET); - if (fscanf(f_bn, "%d", &aux_var) == EOF) { - exit(0); - } - } - bottleneck = (WebRtc_Word16)aux_var; - /* Bottleneck is a cosine function - * Matlab code for writing the bottleneck file: - * BottleNeck_10ms = 20e3 + 10e3 * cos((0:5999)/5999*2*pi); - * fid = fopen('bottleneck.txt', 'wb'); - * fprintf(fid, '%d\n', BottleNeck_10ms); fclose(fid); - */ - } - } else { - f_bn = NULL; - printf("\nfixed bottleneck rate of %d bits/s\n\n", bottleneck); - } - - if (CodingMode == 0) { - printf("\nAdaptive BottleNeck\n"); - } - - /* Get Input and Output files */ - sscanf(argv[argc-2], "%s", inname); - sscanf(argv[argc-1], "%s", outname); - - /* Add '.bit' to output bitstream file */ - while ((int)outname[h] != 0) { - outbitsname[h] = outname[h]; - h++; - } - for (k=0; k<5; k++) { - outbitsname[h] = tmpBit[k]; - h++; - } - if ((inp = fopen(inname,"rb")) == NULL) { - printf(" iSAC: Cannot read file %s\n", inname); - exit(1); - } - if ((outp = fopen(outname,"wb")) == NULL) { - printf(" iSAC: Cannot write file %s\n", outname); - exit(1); - } - - if ((outbits = fopen(outbitsname,"wb")) == NULL) { - printf(" iSAC: Cannot write file %s\n", outbitsname); - exit(1); - } - printf("\nInput:%s\nOutput:%s\n\n", inname, outname); - - /* Error test number 10, garbage data */ - if (testNum == 10) { - /* Test to run decoder with garbage data */ - srand(random_seed); - - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - printf("Error: Could not open file %s\n", SEED_FILE); - } - else { - fprintf(seedfile, "%u\n", random_seed); - fclose(seedfile); - } - } - - /* Runtime statistics */ - starttime = clock()/(double)CLOCKS_PER_SEC; - - /* Initialize the ISAC and BN structs */ - if (testNum != 8) - { - if(1){ - err =WebRtcIsacfix_Create(&ISAC_main_inst); - }else{ - /* Test the Assign functions */ - int sss; - void *ppp; - err =WebRtcIsacfix_AssignSize(&sss); - ppp=malloc(sss); - err =WebRtcIsacfix_Assign(&ISAC_main_inst,ppp); - } - /* Error check */ - if (err < 0) { - printf("\n\n Error in create.\n\n"); - } - if (testCE == 1) { - err = WebRtcIsacfix_CreateInternal(ISAC_main_inst); - /* Error check */ - if (err < 0) { - printf("\n\n Error in createInternal.\n\n"); - } - } - } - - /* Init of bandwidth data */ - BN_data.send_time = 0; - BN_data.arrival_time = 0; - BN_data.sample_count = 0; - BN_data.rtp_number = 0; - - /* Initialize encoder and decoder */ - framecnt= 0; - endfile = 0; - if (testNum != 1) { - WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode); - } - if (testNum != 2) { - WebRtcIsacfix_DecoderInit(ISAC_main_inst); - } - - if (CodingMode == 1) { - err = WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in control: %d.\n\n", errtype); - } - } else if(setControlBWE == 1) { - err = WebRtcIsacfix_ControlBwe(ISAC_main_inst, rateBPS, framesize, fixedFL); - } - - if (payloadSize != 0) { - err = WebRtcIsacfix_SetMaxPayloadSize(ISAC_main_inst, payloadSize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in SetMaxPayloadSize: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - } - if (payloadRate != 0) { - err = WebRtcIsacfix_SetMaxRate(ISAC_main_inst, payloadRate); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in SetMaxRateInBytes: %d.\n\n", errtype); - exit(EXIT_FAILURE); - } - } - - *speechType = 1; - - - while (endfile == 0) { - - if(testNum == 7 && (rand()%2 == 0)) { - err = WebRtcIsacfix_EncoderInit(ISAC_main_inst, CodingMode); - /* Error check */ - if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in encoderinit: %d.\n\n", errtype); - } - - err = WebRtcIsacfix_DecoderInit(ISAC_main_inst); - /* Error check */ - if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in decoderinit: %d.\n\n", errtype); - } - } - - - cur_framesmpls = 0; - while (1) { - /* Read 10 ms speech block */ - if (nbTest != 1) { - endfile = readframe(shortdata, inp, FRAMESAMPLES_10ms); - } else { - endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms/2)); - } - - if (testNum == 7) { - srand(time(NULL)); - } - - /* iSAC encoding */ - if (!(testNum == 3 && framecnt == 0)) { - if (nbTest != 1) { - short bwe; - - /* Encode */ - stream_len = WebRtcIsacfix_Encode(ISAC_main_inst, - shortdata, - (WebRtc_Word16*)streamdata); - - /* If packet is ready, and CE testing, call the different API functions - from the internal API. */ - if (stream_len>0) { - if (testCE == 1) { - err = WebRtcIsacfix_ReadBwIndex((WebRtc_Word16*)streamdata, &bwe); - stream_len = WebRtcIsacfix_GetNewBitStream( - ISAC_main_inst, - bwe, - scale, - (WebRtc_Word16*)streamdata); - } else if (testCE == 2) { - /* transcode function not supported */ - } else if (testCE == 3) { - /* Only for Function testing. The functions should normally - not be used in this way */ - - err = WebRtcIsacfix_GetDownLinkBwIndex(ISAC_main_inst, &bwe); - /* Error Check */ - if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\nError in getSendBWE: %d.\n", errtype); - } - - err = WebRtcIsacfix_UpdateUplinkBw(ISAC_main_inst, bwe); - /* Error Check */ - if (err < 0) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\nError in setBWE: %d.\n", errtype); - } - - } - } - } else { -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - stream_len = WebRtcIsacfix_EncodeNb(ISAC_main_inst, - shortdata, - streamdata); -#else - stream_len = -1; -#endif - } - } - else - { - break; - } - - if (stream_len < 0 || err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\nError in encoder: %d.\n", errtype); - } else { - if (fwrite(streamdata, sizeof(char), - stream_len, outbits) != (size_t)stream_len) { - return -1; - } - } - - cur_framesmpls += FRAMESAMPLES_10ms; - - /* read next bottleneck rate */ - if (f_bn != NULL) { - int aux_var; - if (fscanf(f_bn, "%d", &aux_var) == EOF) { - /* Set pointer to beginning of file */ - fseek(f_bn, 0L, SEEK_SET); - if (fscanf(f_bn, "%d", &aux_var) == EOF) { - exit(0); - } - } - bottleneck = (WebRtc_Word16)aux_var; - if (CodingMode == 1) { - WebRtcIsacfix_Control(ISAC_main_inst, bottleneck, framesize); - } - } - - /* exit encoder loop if the encoder returned a bitstream */ - if (stream_len != 0) break; - } - - /* make coded sequence to short be inreasing */ - /* the length the decoder expects */ - if (testNum == 4) { - stream_len += 10; - } - - /* make coded sequence to long be decreasing */ - /* the length the decoder expects */ - if (testNum == 5) { - stream_len -= 10; - } - - if (testNum == 6) { - srand(time(NULL)); - for (i = 0; i < stream_len; i++ ) { - streamdata[i] = rand(); - } - } - - /* set pointer to beginning of file */ - if (fp_gns != NULL) { - if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { - fseek(fp_gns, 0L, SEEK_SET); - if (fscanf(fp_gns, "%d", &cur_delay) == EOF) { - exit(0); - } - } - } - - /* simulate packet handling through NetEq and the modem */ - if (!(testNum == 3 && framecnt == 0)) { - if (gns == 0) { - get_arrival_time(cur_framesmpls, stream_len, bottleneck, - &BN_data); - } else { - get_arrival_time2(cur_framesmpls, cur_delay, &BN_data); - } - } - - /* packet not dropped */ - if (cur_delay != -1) { - - /* Error test number 10, garbage data */ - if (testNum == 10) { - for ( i = 0; i < stream_len; i++) { - streamdata[i] = (short) (streamdata[i] + (short) rand()); - } - } - - if (testNum != 9) { - err = WebRtcIsacfix_UpdateBwEstimate(ISAC_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.send_time, - BN_data.arrival_time); - - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\nError in decoder: %d.\n", errtype); - } - } -#ifdef _DEBUG - fprintf(stderr," \rframe = %7d", framecnt); -#endif - - if( readLoss == 1 ) { - if( fread( &lostFrame, sizeof(WebRtc_Word16), 1, plFile ) != 1 ) { - rewind( plFile ); - } - lostFrame = !lostFrame; - } else { - lostFrame = (rand()%100 < packetLossPercent); - } - - - - /* iSAC decoding */ - if( lostFrame && framecnt > 0) { - if (nbTest !=2) { - declen = WebRtcIsacfix_DecodePlc(ISAC_main_inst, - decoded, prevFrameSize ); - } else { -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - declen = WebRtcIsacfix_DecodePlcNb(ISAC_main_inst, decoded, - prevFrameSize ); -#else - declen = -1; -#endif - } - lostPackets++; - } else { - if (nbTest !=2 ) { - short FL; - /* Call getFramelen, only used here for function test */ - err = WebRtcIsacfix_ReadFrameLen((WebRtc_Word16*)streamdata, &FL); - declen = WebRtcIsacfix_Decode( ISAC_main_inst, streamdata, stream_len, - decoded, speechType ); - /* Error check */ - if (err<0 || declen<0 || FL!=declen) { - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\nError in decode_B/or getFrameLen: %d.\n", errtype); - } - prevFrameSize = declen/480; - - } else { -#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED - declen = WebRtcIsacfix_DecodeNb( ISAC_main_inst, streamdata, - stream_len, decoded, speechType ); -#else - declen = -1; -#endif - prevFrameSize = declen/240; - } - } - - if (declen <= 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); - printf("\nError in decoder: %d.\n", errtype); - } - - /* Write decoded speech frame to file */ - if (fwrite(decoded, sizeof(WebRtc_Word16), - declen, outp) != (size_t)declen) { - return -1; - } - // fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/ - // ((double)FS) ) * 8 ); - } else { - lostPackets++; - } - framecnt++; - - totalsmpls += declen; - totalbits += 8 * stream_len; - kbps = ((double) FS) / ((double) cur_framesmpls) * 8.0 * - stream_len / 1000.0;// kbits/s - - /* Error test number 10, garbage data */ - if (testNum == 10) { - if ( (seedfile = fopen(SEED_FILE, "a+t") ) == NULL ) { - printf( "Error: Could not open file %s\n", SEED_FILE); - } - else { - fprintf(seedfile, "ok\n\n"); - fclose(seedfile); - } - } - -#ifdef _DEBUG - - fy = fopen("bit_rate.dat", "a"); - fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps); - fclose(fy); - -#endif /* _DEBUG */ - - } - printf("\nLost Frames %d ~ %4.1f%%\n", lostPackets, - (double)lostPackets/(double)framecnt*100.0 ); - printf("\n\ntotal bits = %d bits", totalbits); - printf("\nmeasured average bitrate = %0.3f kbits/s", - (double)totalbits *(FS/1000) / totalsmpls); - printf("\n"); - -#ifdef _DEBUG - /* fprintf(stderr,"\n\ntotal bits = %d bits", totalbits); - fprintf(stderr,"\nmeasured average bitrate = %0.3f kbits/s", - (double)totalbits *(FS/1000) / totalsmpls); - fprintf(stderr,"\n"); - */ -#endif /* _DEBUG */ - - /* Runtime statistics */ - - - runtime = (double)(((double)clock()/(double)CLOCKS_PER_SEC)-starttime); - length_file = ((double)framecnt*(double)declen/FS); - printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", - runtime, (100*runtime/length_file)); - printf("\n\n_______________________________________________\n"); - - fclose(inp); - fclose(outp); - fclose(outbits); - - if ( testCE == 1) { - WebRtcIsacfix_FreeInternal(ISAC_main_inst); - } - WebRtcIsacfix_Free(ISAC_main_inst); - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c b/src/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c deleted file mode 100644 index 57c30ca..0000000 --- a/src/modules/audio_coding/codecs/isac/fix/test/test_iSACfixfloat.c +++ /dev/null
@@ -1,693 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * test_iSACfixfloat.c - * - * Test compatibility and quality between floating- and fixed-point code - * */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -/* include API */ -#include "isac.h" -#include "isacfix.h" - - -/* max number of samples per frame (= 60 ms frame) */ -#define MAX_FRAMESAMPLES 960 -/* number of samples per 10ms frame */ -#define FRAMESAMPLES_10ms 160 -/* sampling frequency (Hz) */ -#define FS 16000 - - - -/* Runtime statistics */ -#include <time.h> -#define CLOCKS_PER_SEC 1000 - - - -// FILE *histfile, *ratefile; - - -/* function for reading audio data from PCM file */ -int readframe(WebRtc_Word16 *data, FILE *inp, int length) { - - short k, rlen, status = 0; - - rlen = fread(data, sizeof(WebRtc_Word16), length, inp); - if (rlen < length) { - for (k = rlen; k < length; k++) - data[k] = 0; - status = 1; - } - - return status; -} - -typedef struct { - WebRtc_UWord32 send_time; /* samples */ - WebRtc_UWord32 arrival_time; /* samples */ - WebRtc_UWord32 sample_count; /* samples */ - WebRtc_UWord16 rtp_number; -} BottleNeckModel; - -void get_arrival_time(int current_framesamples, /* samples */ - int packet_size, /* bytes */ - int bottleneck, /* excluding headers; bits/s */ - BottleNeckModel *BN_data) -{ - const int HeaderSize = 35; - int HeaderRate; - - HeaderRate = HeaderSize * 8 * FS / current_framesamples; /* bits/s */ - - /* everything in samples */ - BN_data->sample_count = BN_data->sample_count + current_framesamples; - - BN_data->arrival_time += ((packet_size + HeaderSize) * 8 * FS) / (bottleneck + HeaderRate); - BN_data->send_time += current_framesamples; - - if (BN_data->arrival_time < BN_data->sample_count) - BN_data->arrival_time = BN_data->sample_count; - - BN_data->rtp_number++; -} - - - -int main(int argc, char* argv[]) -{ - - char inname[50], outname[50], bottleneck_file[50], bitfilename[60], bitending[10]="_bits.pcm"; - FILE *inp, *outp, *f_bn, *bitsp; - int framecnt, endfile; - - - int i,j,errtype, plc=0; - WebRtc_Word16 CodingMode; - WebRtc_Word16 bottleneck; - - WebRtc_Word16 framesize = 30; /* ms */ - //WebRtc_Word16 framesize = 60; /* To invoke cisco complexity case at frame 2252 */ - - int cur_framesmpls, err; - - /* Runtime statistics */ - double starttime; - double runtime; - double length_file; - - WebRtc_Word16 stream_len = 0; - WebRtc_Word16 declen; - - WebRtc_Word16 shortdata[FRAMESAMPLES_10ms]; - WebRtc_Word16 decoded[MAX_FRAMESAMPLES]; - WebRtc_UWord16 streamdata[600]; - WebRtc_Word16 speechType[1]; - -// WebRtc_Word16 *iSACstruct; - - char version_number[20]; - int mode=-1, tmp, nbTest=0; /*,sss;*/ - -#ifdef _DEBUG - FILE *fy; - double kbps; - int totalbits =0; - int totalsmpls =0; -#endif /* _DEBUG */ - - - - - /* only one structure used for ISAC encoder */ - ISAC_MainStruct *ISAC_main_inst; - ISACFIX_MainStruct *ISACFIX_main_inst; - - BottleNeckModel BN_data; - f_bn = NULL; - -#ifdef _DEBUG - fy = fopen("bit_rate.dat", "w"); - fclose(fy); - fy = fopen("bytes_frames.dat", "w"); - fclose(fy); -#endif /* _DEBUG */ - - -//histfile = fopen("histo.dat", "ab"); -//ratefile = fopen("rates.dat", "ab"); - - /* handling wrong input arguments in the command line */ - if ((argc<6) || (argc>10)) { - printf("\n\nWrong number of arguments or flag values.\n\n"); - - printf("\n"); - WebRtcIsacfix_version(version_number); - printf("iSAC version %s \n\n", version_number); - - printf("Usage:\n\n"); - printf("./kenny.exe [-I] bottleneck_value infile outfile \n\n"); - printf("with:\n"); - - printf("[-I] : if -I option is specified, the coder will use\n"); - printf(" an instantaneous Bottleneck value. If not, it\n"); - printf(" will be an adaptive Bottleneck value.\n\n"); - printf("bottleneck_value : the value of the bottleneck provided either\n"); - printf(" as a fixed value (e.g. 25000) or\n"); - printf(" read from a file (e.g. bottleneck.txt)\n\n"); - printf("[-m] mode : Mode (encoder - decoder):\n"); - printf(" : 0 - float - float \n"); - printf(" : 1 - float - fix \n"); - printf(" : 2 - fix - float \n"); - printf(" : 3 - fix - fix \n"); - printf("[-PLC] : Test PLC packetlosses\n"); - printf("[-NB] num : Test NB interfaces, num=1 encNB, num=2 decNB\n"); - printf("infile : Normal speech input file\n\n"); - printf("outfile : Speech output file\n\n"); - printf("Example usage:\n\n"); - printf("./kenny.exe -I bottleneck.txt -m 1 speechIn.pcm speechOut.pcm\n\n"); - exit(0); - - } - - - printf("--------------------START---------------------\n\n"); - WebRtcIsac_version(version_number); - printf("iSAC FLOAT version %s \n", version_number); - WebRtcIsacfix_version(version_number); - printf("iSAC FIX version %s \n\n", version_number); - - CodingMode = 0; - tmp=1; - for (i = 1; i < argc;i++) - { - if (!strcmp ("-I", argv[i])) - { - printf("\nInstantaneous BottleNeck\n"); - CodingMode = 1; - i++; - tmp=0; - } - - if (!strcmp ("-m", argv[i])) { - mode=atoi(argv[i+1]); - i++; - } - - if (!strcmp ("-PLC", argv[i])) - { - plc=1; - } - - if (!strcmp ("-NB", argv[i])) - { - nbTest = atoi(argv[i + 1]); - i++; - } - - } - - if(mode<0) { - printf("\nError! Mode must be set: -m 0 \n"); - exit(0); - } - - if (CodingMode == 0) - { - printf("\nAdaptive BottleNeck\n"); - } - - - - /* Get Bottleneck value */ - bottleneck = atoi(argv[2-tmp]); - if (bottleneck == 0) - { - sscanf(argv[2-tmp], "%s", bottleneck_file); - f_bn = fopen(bottleneck_file, "rb"); - if (f_bn == NULL) - { - printf("No value provided for BottleNeck and cannot read file %s.\n", bottleneck_file); - exit(0); - } - else { - printf("reading bottleneck rates from file %s\n\n",bottleneck_file); - if (fscanf(f_bn, "%d", &bottleneck) == EOF) { - /* Set pointer to beginning of file */ - fseek(f_bn, 0L, SEEK_SET); - fscanf(f_bn, "%d", &bottleneck); - } - - /* Bottleneck is a cosine function - * Matlab code for writing the bottleneck file: - * BottleNeck_10ms = 20e3 + 10e3 * cos((0:5999)/5999*2*pi); - * fid = fopen('bottleneck.txt', 'wb'); - * fprintf(fid, '%d\n', BottleNeck_10ms); fclose(fid); - */ - } - } - else - { - printf("\nfixed bottleneck rate of %d bits/s\n\n", bottleneck); - } - - - - /* Get Input and Output files */ - sscanf(argv[argc-2], "%s", inname); - sscanf(argv[argc-1], "%s", outname); - - if ((inp = fopen(inname,"rb")) == NULL) { - printf(" iSAC: Cannot read file %s.\n", inname); - exit(1); - } - if ((outp = fopen(outname,"wb")) == NULL) { - printf(" iSAC: Cannot write file %s.\n", outname); - exit(1); - } - printf("\nInput:%s\nOutput:%s\n", inname, outname); - - i=0; - while (outname[i]!='\0') { - bitfilename[i]=outname[i]; - i++; - } - i-=4; - for (j=0;j<9;j++, i++) - bitfilename[i]=bitending[j]; - bitfilename[i]='\0'; - if ((bitsp = fopen(bitfilename,"wb")) == NULL) { - printf(" iSAC: Cannot read file %s.\n", bitfilename); - exit(1); - } - printf("Bitstream:%s\n\n", bitfilename); - - - - starttime = clock()/(double)CLOCKS_PER_SEC; /* Runtime statistics */ - - - /* Initialize the ISAC and BN structs */ - WebRtcIsac_create(&ISAC_main_inst); -/* WebRtcIsacfix_AssignSize(&sss); - iSACstruct=malloc(sss); - WebRtcIsacfix_Assign(&ISACFIX_main_inst,iSACstruct);*/ - WebRtcIsacfix_Create(&ISACFIX_main_inst); - - BN_data.send_time = 0; - BN_data.arrival_time = 0; - BN_data.sample_count = 0; - BN_data.rtp_number = 0; - - /* Initialize encoder and decoder */ - framecnt= 0; - endfile = 0; - - if (mode==0) { /* Encode using FLOAT, decode using FLOAT */ - - printf("Coding mode: Encode using FLOAT, decode using FLOAT \n\n"); - - /* Init iSAC FLOAT */ - WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode); - WebRtcIsac_DecoderInit(ISAC_main_inst); - if (CodingMode == 1) { - err = WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - // exit(EXIT_FAILURE); - } - } - - } else if (mode==1) { /* Encode using FLOAT, decode using FIX */ - - printf("Coding mode: Encode using FLOAT, decode using FIX \n\n"); - - /* Init iSAC FLOAT */ - WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode); - WebRtcIsac_DecoderInit(ISAC_main_inst); - if (CodingMode == 1) { - err = WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - // exit(EXIT_FAILURE); - } - } - - /* Init iSAC FIX */ - WebRtcIsacfix_EncoderInit(ISACFIX_main_inst, CodingMode); - WebRtcIsacfix_DecoderInit(ISACFIX_main_inst); - if (CodingMode == 1) { - err = WebRtcIsacfix_Control(ISACFIX_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } - } else if (mode==2) { /* Encode using FIX, decode using FLOAT */ - - printf("Coding mode: Encode using FIX, decode using FLOAT \n\n"); - - /* Init iSAC FLOAT */ - WebRtcIsac_EncoderInit(ISAC_main_inst, CodingMode); - WebRtcIsac_DecoderInit(ISAC_main_inst); - if (CodingMode == 1) { - err = WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } - - /* Init iSAC FIX */ - WebRtcIsacfix_EncoderInit(ISACFIX_main_inst, CodingMode); - WebRtcIsacfix_DecoderInit(ISACFIX_main_inst); - if (CodingMode == 1) { - err = WebRtcIsacfix_Control(ISACFIX_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } - } else if (mode==3) { - - printf("Coding mode: Encode using FIX, decode using FIX \n\n"); - - WebRtcIsacfix_EncoderInit(ISACFIX_main_inst, CodingMode); - WebRtcIsacfix_DecoderInit(ISACFIX_main_inst); - if (CodingMode == 1) { - err = WebRtcIsacfix_Control(ISACFIX_main_inst, bottleneck, framesize); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\n Error in initialization: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } - - } else - printf("Mode must be value between 0 and 3\n"); - *speechType = 1; - -//#define BI_TEST 1 -#ifdef BI_TEST - err = WebRtcIsacfix_SetMaxPayloadSize(ISACFIX_main_inst, 300); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\n Error in setMaxPayloadSize: %d.\n\n", errtype); - fclose(inp); - fclose(outp); - fclose(bitsp); - return(EXIT_FAILURE); - } -#endif - - - while (endfile == 0) { - - cur_framesmpls = 0; - while (1) { - /* Read 10 ms speech block */ - if (nbTest != 1) - endfile = readframe(shortdata, inp, FRAMESAMPLES_10ms); - else - endfile = readframe(shortdata, inp, (FRAMESAMPLES_10ms/2)); - - /* iSAC encoding */ - - if (mode==0 || mode ==1) { - stream_len = WebRtcIsac_Encode(ISAC_main_inst, shortdata, streamdata); - if (stream_len < 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\nError in encoder: %d.\n\n", errtype); - // exit(EXIT_FAILURE); - } - } else if (mode==2 || mode==3) { - /* iSAC encoding */ - if (nbTest != 1) - stream_len = WebRtcIsacfix_Encode(ISACFIX_main_inst, shortdata, streamdata); - else - stream_len = WebRtcIsacfix_EncodeNb(ISACFIX_main_inst, shortdata, streamdata); - - if (stream_len < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\nError in encoder: %d.\n\n", errtype); - // exit(EXIT_FAILURE); - } - } - - cur_framesmpls += FRAMESAMPLES_10ms; - - /* read next bottleneck rate */ - if (f_bn != NULL) { - if (fscanf(f_bn, "%d", &bottleneck) == EOF) { - /* Set pointer to beginning of file */ - fseek(f_bn, 0L, SEEK_SET); - fscanf(f_bn, "%d", &bottleneck); - } - if (CodingMode == 1) { - if (mode==0 || mode==1) - WebRtcIsac_Control(ISAC_main_inst, bottleneck, framesize); - else if (mode==2 || mode==3) - WebRtcIsacfix_Control(ISACFIX_main_inst, bottleneck, framesize); - } - } - - /* exit encoder loop if the encoder returned a bitstream */ - if (stream_len != 0) break; - } - - fwrite(streamdata, 1, stream_len, bitsp); /* NOTE! Writes bytes to file */ - - /* simulate packet handling through NetEq and the modem */ - get_arrival_time(cur_framesmpls, stream_len, bottleneck, - &BN_data); -//***************************** - if (1){ - if (mode==0) { - err = WebRtcIsac_UpdateBwEstimate(ISAC_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.arrival_time); - - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - /* iSAC decoding */ - declen = WebRtcIsac_Decode(ISAC_main_inst, - streamdata, - stream_len, - decoded, - speechType); - if (declen <= 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } else if (mode==1) { - - err = WebRtcIsac_UpdateBwEstimate(ISAC_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.arrival_time); - err = WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.arrival_time); - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - - declen = WebRtcIsac_Decode(ISAC_main_inst, - streamdata, - stream_len, - decoded, - speechType); - - /* iSAC decoding */ - if (plc && (framecnt+1)%10 == 0) { - if (nbTest !=2 ) - declen = WebRtcIsacfix_DecodePlc( ISACFIX_main_inst, decoded, 1 ); - else - declen = WebRtcIsacfix_DecodePlcNb( ISACFIX_main_inst, decoded, 1 ); - } else { - if (nbTest !=2 ) - declen = WebRtcIsacfix_Decode(ISACFIX_main_inst, - streamdata, - stream_len, - decoded, - speechType); - else - declen = WebRtcIsacfix_DecodeNb(ISACFIX_main_inst, - streamdata, - stream_len, - decoded, - speechType); - } - - if (declen <= 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } else if (mode==2) { - err = WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.arrival_time); - - err = WebRtcIsac_UpdateBwEstimate(ISAC_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.arrival_time); - - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - /* iSAC decoding */ - declen = WebRtcIsac_Decode(ISAC_main_inst, - streamdata, - stream_len, - decoded, - speechType); - if (declen <= 0) { - /* exit if returned with error */ - errtype=WebRtcIsac_GetErrorCode(ISAC_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } else if (mode==3) { - err = WebRtcIsacfix_UpdateBwEstimate(ISACFIX_main_inst, - streamdata, - stream_len, - BN_data.rtp_number, - BN_data.send_time, - BN_data.arrival_time); - - if (err < 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - /* iSAC decoding */ - - if (plc && (framecnt+1)%10 == 0) { - if (nbTest !=2 ) - declen = WebRtcIsacfix_DecodePlc( ISACFIX_main_inst, decoded, 1 ); - else - declen = WebRtcIsacfix_DecodePlcNb( ISACFIX_main_inst, decoded, 1 ); - } else { - if (nbTest !=2 ) - declen = WebRtcIsacfix_Decode(ISACFIX_main_inst, - streamdata, - stream_len, - decoded, - speechType); - else - declen = WebRtcIsacfix_DecodeNb(ISACFIX_main_inst, - streamdata, - stream_len, - decoded, - speechType); - } - if (declen <= 0) { - /* exit if returned with error */ - errtype=WebRtcIsacfix_GetErrorCode(ISACFIX_main_inst); - printf("\n\nError in decoder: %d.\n\n", errtype); - //exit(EXIT_FAILURE); - } - } - - /* Write decoded speech frame to file */ - fwrite(decoded, sizeof(WebRtc_Word16), declen, outp); - } - - fprintf(stderr," \rframe = %d", framecnt); - framecnt++; - - - -#ifdef _DEBUG - - totalsmpls += declen; - totalbits += 8 * stream_len; - kbps = ((double) FS) / ((double) cur_framesmpls) * 8.0 * stream_len / 1000.0;// kbits/s - fy = fopen("bit_rate.dat", "a"); - fprintf(fy, "Frame %i = %0.14f\n", framecnt, kbps); - fclose(fy); - -#endif /* _DEBUG */ - - } - -#ifdef _DEBUG - printf("\n\ntotal bits = %d bits", totalbits); - printf("\nmeasured average bitrate = %0.3f kbits/s", (double)totalbits *(FS/1000) / totalsmpls); - printf("\n"); -#endif /* _DEBUG */ - - /* Runtime statistics */ - runtime = (double)(clock()/(double)CLOCKS_PER_SEC-starttime); - length_file = ((double)framecnt*(double)declen/FS); - printf("\n\nLength of speech file: %.1f s\n", length_file); - printf("Time to run iSAC: %.2f s (%.2f %% of realtime)\n\n", runtime, (100*runtime/length_file)); - printf("---------------------END----------------------\n"); - - fclose(inp); - fclose(outp); - - WebRtcIsac_Free(ISAC_main_inst); - WebRtcIsacfix_Free(ISACFIX_main_inst); - - - -// fclose(histfile); -// fclose(ratefile); - - return 0; - -} - -
diff --git a/src/modules/audio_coding/codecs/isac/isac_test.gypi b/src/modules/audio_coding/codecs/isac/isac_test.gypi deleted file mode 100644 index abe2454..0000000 --- a/src/modules/audio_coding/codecs/isac/isac_test.gypi +++ /dev/null
@@ -1,71 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - # simple kenny - { - 'target_name': 'iSACtest', - 'type': 'executable', - 'dependencies': [ - 'iSAC', - ], - 'include_dirs': [ - './main/test', - './main/interface', - './main/util', - ], - 'sources': [ - './main/test/simpleKenny.c', - './main/util/utility.c', - ], - }, - # ReleaseTest-API - { - 'target_name': 'iSACAPITest', - 'type': 'executable', - 'dependencies': [ - 'iSAC', - ], - 'include_dirs': [ - './main/test', - './main/interface', - './main/util', - ], - 'sources': [ - './main/test/ReleaseTest-API/ReleaseTest-API.cc', - './main/util/utility.c', - ], - }, - # SwitchingSampRate - { - 'target_name': 'iSACSwitchSampRateTest', - 'type': 'executable', - 'dependencies': [ - 'iSAC', - ], - 'include_dirs': [ - './main/test', - './main/interface', - '../../../../common_audio/signal_processing/include', - './main/util', - ], - 'sources': [ - './main/test/SwitchingSampRate/SwitchingSampRate.cc', - './main/util/utility.c', - ], - }, - - ], -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/modules/audio_coding/codecs/isac/isacfix_test.gypi b/src/modules/audio_coding/codecs/isac/isacfix_test.gypi deleted file mode 100644 index a6c59d0..0000000 --- a/src/modules/audio_coding/codecs/isac/isacfix_test.gypi +++ /dev/null
@@ -1,41 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - # kenny - { - 'target_name': 'iSACFixtest', - 'type': 'executable', - 'dependencies': [ - 'iSACFix', - ], - 'include_dirs': [ - './fix/test', - './fix/interface', - ], - 'sources': [ - './fix/test/kenny.c', - ], - }, - { - 'target_name': 'isacfix_unittests', - 'type': 'executable', - 'dependencies': [ - 'iSACFix', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(webrtc_root)/test/test.gyp:test_support_main', - ], - 'sources': [ - 'fix/test/isacfix_unittest.cc', - ], - }, - ], -} - -# TODO(kma): Add bit-exact test for iSAC-fix.
diff --git a/src/modules/audio_coding/codecs/isac/main/interface/isac.h b/src/modules/audio_coding/codecs/isac/main/interface/isac.h deleted file mode 100644 index 03c260b..0000000 --- a/src/modules/audio_coding/codecs/isac/main/interface/isac.h +++ /dev/null
@@ -1,729 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_ - -/* - * Define the fixed-point numeric formats - */ -#include "typedefs.h" - -typedef struct WebRtcISACStruct ISACStruct; - -enum IsacSamplingRate {kIsacWideband = 16, kIsacSuperWideband = 32}; - - -#if defined(__cplusplus) -extern "C" { -#endif - - /****************************************************************************** - * WebRtcIsac_AssignSize(...) - * - * This function returns the size of the ISAC instance, so that the instance - * can be created outside iSAC. - * - * Input: - * - samplingRate : sampling rate of the input/output audio. - * - * Output: - * - sizeinbytes : number of bytes needed to allocate for the - * instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_AssignSize( - int* sizeinbytes); - - - /****************************************************************************** - * WebRtcIsac_Assign(...) - * - * This function assignes the memory already created to the ISAC instance. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - samplingRate : sampling rate of the input/output audio. - * - ISAC_inst_Addr : the already allocated memory, where we put the - * iSAC structure. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_Assign( - ISACStruct** ISAC_main_inst, - void* ISAC_inst_Addr); - - - /****************************************************************************** - * WebRtcIsac_Create(...) - * - * This function creates an ISAC instance, which will contain the state - * information for one coding/decoding channel. - * - * Input: - * - *ISAC_main_inst : a pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_Create( - ISACStruct** ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_Free(...) - * - * This function frees the ISAC instance created at the beginning. - * - * Input: - * - ISAC_main_inst : an ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_Free( - ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_EncoderInit(...) - * - * This function initializes an ISAC instance prior to the encoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - CodingMode : 0 -> Bit rate and frame length are - * automatically adjusted to available bandwidth - * on transmission channel, just valid if codec - * is created to work in wideband mode. - * 1 -> User sets a frame length and a target bit - * rate which is taken as the maximum - * short-term average bit rate. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_EncoderInit( - ISACStruct* ISAC_main_inst, - WebRtc_Word16 CodingMode); - - - /****************************************************************************** - * WebRtcIsac_Encode(...) - * - * This function encodes 10ms audio blocks and inserts it into a package. - * Input speech length has 160 samples if operating at 16 kHz sampling - * rate, or 320 if operating at 32 kHz sampling rate. The encoder buffers the - * input audio until the whole frame is buffered then proceeds with encoding. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : 0 - The buffer didn't reach the chosen - * frame-size so it keeps buffering speech - * samples. - * : -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_Encode( - ISACStruct* ISAC_main_inst, - const WebRtc_Word16* speechIn, - WebRtc_Word16* encoded); - - - /****************************************************************************** - * WebRtcIsac_DecoderInit(...) - * - * This function initializes an ISAC instance prior to the decoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - * Return value - * : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_DecoderInit( - ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_UpdateBwEstimate(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - send_ts : the RTP send timestamp, given in samples - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_UpdateBwEstimate( - ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts); - - - /****************************************************************************** - * WebRtcIsac_Decode(...) - * - * This function decodes an ISAC frame. At 16 kHz sampling rate, the length - * of the output audio could be either 480 or 960 samples, equivalent to - * 30 or 60 ms respectively. At 32 kHz sampling rate, the length of the - * output audio is 960 samples, which is 30 ms. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - len : bytes in encoded vector. - * - * Output: - * - decoded : The decoded vector. - * - * Return value : >0 - number of samples in decoded vector. - * -1 - Error. - */ - - WebRtc_Word16 WebRtcIsac_Decode( - ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word16 len, - WebRtc_Word16* decoded, - WebRtc_Word16* speechType); - - - /****************************************************************************** - * WebRtcIsac_DecodePlc(...) - * - * This function conducts PLC for ISAC frame(s). Output speech length - * will be a multiple of frames, i.e. multiples of 30 ms audio. Therefore, - * the output is multiple of 480 samples if operating at 16 kHz and multiple - * of 960 if operating at 32 kHz. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames to produce. - * - * Output: - * - decoded : The decoded vector. - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_DecodePlc( - ISACStruct* ISAC_main_inst, - WebRtc_Word16* decoded, - WebRtc_Word16 noOfLostFrames); - - - /****************************************************************************** - * WebRtcIsac_Control(...) - * - * This function sets the limit on the short-term average bit-rate and the - * frame length. Should be used only in Instantaneous mode. At 16 kHz sampling - * rate, an average bit-rate between 10000 to 32000 bps is valid and a - * frame-size of 30 or 60 ms is acceptable. At 32 kHz, an average bit-rate - * between 10000 to 56000 is acceptable, and the valid frame-size is 30 ms. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rate : limit on the short-term average bit rate, - * in bits/second. - * - framesize : frame-size in millisecond. - * - * Return value : 0 - ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_Control( - ISACStruct* ISAC_main_inst, - WebRtc_Word32 rate, - WebRtc_Word16 framesize); - - - /****************************************************************************** - * WebRtcIsac_ControlBwe(...) - * - * This function sets the initial values of bottleneck and frame-size if - * iSAC is used in channel-adaptive mode. Therefore, this API is not - * applicable if the codec is created to operate in super-wideband mode. - * - * Through this API, users can enforce a frame-size for all values of - * bottleneck. Then iSAC will not automatically change the frame-size. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rateBPS : initial value of bottleneck in bits/second - * 10000 <= rateBPS <= 56000 is accepted - * For default bottleneck set rateBPS = 0 - * - frameSizeMs : number of milliseconds per frame (30 or 60) - * - enforceFrameSize : 1 to enforce the given frame-size through - * out the adaptation process, 0 to let iSAC - * change the frame-size if required. - * - * Return value : 0 - ok - * -1 - Error - */ - - WebRtc_Word16 WebRtcIsac_ControlBwe( - ISACStruct* ISAC_main_inst, - WebRtc_Word32 rateBPS, - WebRtc_Word16 frameSizeMs, - WebRtc_Word16 enforceFrameSize); - - - /****************************************************************************** - * WebRtcIsac_ReadFrameLen(...) - * - * This function returns the length of the frame represented in the packet. - * - * Input: - * - encoded : Encoded bit-stream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - */ - - WebRtc_Word16 WebRtcIsac_ReadFrameLen( - ISACStruct* ISAC_main_inst, - const WebRtc_Word16* encoded, - WebRtc_Word16* frameLength); - - - /****************************************************************************** - * WebRtcIsac_version(...) - * - * This function returns the version number. - * - * Output: - * - version : Pointer to character string - * - */ - - void WebRtcIsac_version( - char *version); - - - /****************************************************************************** - * WebRtcIsac_GetErrorCode(...) - * - * This function can be used to check the error code of an iSAC instance. When - * a function returns -1 a error code will be set for that instance. The - * function below extract the code of the last error that occurred in the - * specified instance. - * - * Input: - * - ISAC_main_inst : ISAC instance - * - * Return value : Error code - */ - - WebRtc_Word16 WebRtcIsac_GetErrorCode( - ISACStruct* ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsac_GetUplinkBw(...) - * - * This function outputs the target bottleneck of the codec. In - * channel-adaptive mode, the target bottleneck is specified through in-band - * signalling retreived by bandwidth estimator. - * In channel-independent, also called instantaneous mode, the target - * bottleneck is provided to the encoder by calling xxx_control(...). If - * xxx_control is never called the default values is returned. The default - * value for bottleneck at 16 kHz encoder sampling rate is 32000 bits/sec, - * and it is 56000 bits/sec for 32 kHz sampling rate. - * Note that the output is the iSAC internal operating bottleneck which might - * differ slightly from the one provided through xxx_control(). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Output: - * - *bottleneck : bottleneck in bits/sec - * - * Return value : -1 if error happens - * 0 bit-rates computed correctly. - */ - - WebRtc_Word16 WebRtcIsac_GetUplinkBw( - ISACStruct* ISAC_main_inst, - WebRtc_Word32* bottleneck); - - - /****************************************************************************** - * WebRtcIsac_SetMaxPayloadSize(...) - * - * This function sets a limit for the maximum payload size of iSAC. The same - * value is used both for 30 and 60 ms packets. If the encoder sampling rate - * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the - * encoder sampling rate is 32 kHz the maximum payload size is between 120 - * and 600 bytes. - * - * If an out of range limit is used, the function returns -1, but the closest - * valid value will be applied. - * - * --------------- - * IMPORTANT NOTES - * --------------- - * The size of a packet is limited to the minimum of 'max-payload-size' and - * 'max-rate.' For instance, let's assume the max-payload-size is set to - * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps - * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms - * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, - * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to - * 170 bytes, i.e. min(170, 300). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxPayloadBytes : maximum size of the payload in bytes - * valid values are between 120 and 400 bytes - * if encoder sampling rate is 16 kHz. For - * 32 kHz encoder sampling rate valid values - * are between 120 and 600 bytes. - * - * Return value : 0 if successful - * -1 if error happens - */ - - WebRtc_Word16 WebRtcIsac_SetMaxPayloadSize( - ISACStruct* ISAC_main_inst, - WebRtc_Word16 maxPayloadBytes); - - - /****************************************************************************** - * WebRtcIsac_SetMaxRate(...) - * - * This function sets the maximum rate which the codec may not exceed for - * any signal packet. The maximum rate is defined and payload-size per - * frame-size in bits per second. - * - * The codec has a maximum rate of 53400 bits per second (200 bytes per 30 - * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms) - * if the encoder sampling rate is 32 kHz. - * - * It is possible to set a maximum rate between 32000 and 53400 bits/sec - * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode. - * - * If an out of range limit is used, the function returns -1, but the closest - * valid value will be applied. - * - * --------------- - * IMPORTANT NOTES - * --------------- - * The size of a packet is limited to the minimum of 'max-payload-size' and - * 'max-rate.' For instance, let's assume the max-payload-size is set to - * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps - * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms - * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, - * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to - * 170 bytes, min(170, 300). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxRate : maximum rate in bits per second, - * valid values are 32000 to 53400 bits/sec in - * wideband mode, and 32000 to 160000 bits/sec in - * super-wideband mode. - * - * Return value : 0 if successful - * -1 if error happens - */ - - WebRtc_Word16 WebRtcIsac_SetMaxRate( - ISACStruct* ISAC_main_inst, - WebRtc_Word32 maxRate); - - - /****************************************************************************** - * WebRtcIsac_DecSampRate() - * Return the sampling rate of the decoded audio. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : enumerator representing sampling frequency - * associated with the decoder, i.e. the - * sampling rate of the decoded audio. - * - */ - - enum IsacSamplingRate WebRtcIsac_DecSampRate( - ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_EncSampRate() - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : enumerator representing sampling frequency - * associated with the encoder, the input audio - * is expected to be sampled at this rate. - * - */ - - enum IsacSamplingRate WebRtcIsac_EncSampRate( - ISACStruct* ISAC_main_inst); - - - /****************************************************************************** - * WebRtcIsac_SetDecSampRate() - * Set the sampling rate of the decoder. Initialization of the decoder WILL - * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz - * which is set when the instance is created. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - sampRate : enumerator specifying the sampling rate. - * - * Return value : 0 if successful - * -1 if failed. - */ - - WebRtc_Word16 WebRtcIsac_SetDecSampRate( - ISACStruct* ISAC_main_inst, - enum IsacSamplingRate sampRate); - - - /****************************************************************************** - * WebRtcIsac_SetEncSampRate() - * Set the sampling rate of the encoder. Initialization of the encoder WILL - * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz - * which is set when the instance is created. The encoding-mode and the - * bottleneck remain unchanged by this call, however, the maximum rate and - * maximum payload-size will reset to their default value. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - sampRate : enumerator specifying the sampling rate. - * - * Return value : 0 if successful - * -1 if failed. - */ - - WebRtc_Word16 WebRtcIsac_SetEncSampRate( - ISACStruct* ISAC_main_inst, - enum IsacSamplingRate sampRate); - - - - /****************************************************************************** - * WebRtcIsac_GetNewBitStream(...) - * - * This function returns encoded data, with the recieved bwe-index in the - * stream. If the rate is set to a value less than bottleneck of codec - * the new bistream will be re-encoded with the given target rate. - * It should always return a complete packet, i.e. only called once - * even for 60 msec frames. - * - * NOTE 1! This function does not write in the ISACStruct, it is not allowed. - * NOTE 2! Currently not implemented for SWB mode. - * NOTE 3! Rates larger than the bottleneck of the codec will be limited - * to the current bottleneck. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - bweIndex : Index of bandwidth estimate to put in new - * bitstream - * - rate : target rate of the transcoder is bits/sec. - * Valid values are the accepted rate in iSAC, - * i.e. 10000 to 56000. - * - isRCU : if the new bit-stream is an RCU stream. - * Note that the rate parameter always indicates - * the target rate of the main paylaod, regardless - * of 'isRCU' value. - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error or called in SWB mode - * NOTE! No error code is written to - * the struct since it is only allowed to read - * the struct. - */ - WebRtc_Word16 WebRtcIsac_GetNewBitStream( - ISACStruct* ISAC_main_inst, - WebRtc_Word16 bweIndex, - WebRtc_Word16 jitterInfo, - WebRtc_Word32 rate, - WebRtc_Word16* encoded, - WebRtc_Word16 isRCU); - - - - /**************************************************************************** - * WebRtcIsac_GetDownLinkBwIndex(...) - * - * This function returns index representing the Bandwidth estimate from - * other side to this side. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - bweIndex : Bandwidth estimate to transmit to other side. - * - */ - - WebRtc_Word16 WebRtcIsac_GetDownLinkBwIndex( - ISACStruct* ISAC_main_inst, - WebRtc_Word16* bweIndex, - WebRtc_Word16* jitterInfo); - - - /**************************************************************************** - * WebRtcIsac_UpdateUplinkBw(...) - * - * This function takes an index representing the Bandwidth estimate from - * this side to other side and updates BWE. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - bweIndex : Bandwidth estimate from other side. - * - */ - - WebRtc_Word16 WebRtcIsac_UpdateUplinkBw( - ISACStruct* ISAC_main_inst, - WebRtc_Word16 bweIndex); - - - /**************************************************************************** - * WebRtcIsac_ReadBwIndex(...) - * - * This function returns the index of the Bandwidth estimate from the bitstream. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - bweIndex : Bandwidth estimate in bitstream - * - */ - - WebRtc_Word16 WebRtcIsac_ReadBwIndex( - const WebRtc_Word16* encoded, - WebRtc_Word16* bweIndex); - - - - /******************************************************************************* - * WebRtcIsac_GetNewFrameLen(...) - * - * returns the frame lenght (in samples) of the next packet. In the case of channel-adaptive - * mode, iSAC decides on its frame lenght based on the estimated bottleneck - * this allows a user to prepare for the next packet (at the encoder) - * - * The primary usage is in CE to make the iSAC works in channel-adaptive mode - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Return Value : frame lenght in samples - * - */ - - WebRtc_Word16 WebRtcIsac_GetNewFrameLen( - ISACStruct* ISAC_main_inst); - - - /**************************************************************************** - * WebRtcIsac_GetRedPayload(...) - * - * Populates "encoded" with the redundant payload of the recently encoded - * frame. This function has to be called once that WebRtcIsac_Encode(...) - * returns a positive value. Regardless of the frame-size this function will - * be called only once after encoding is completed. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - encoded : the encoded data vector - * - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : -1 - Error - * - * - */ - WebRtc_Word16 WebRtcIsac_GetRedPayload( - ISACStruct* ISAC_main_inst, - WebRtc_Word16* encoded); - - - /**************************************************************************** - * WebRtcIsac_DecodeRcu(...) - * - * This function decodes a redundant (RCU) iSAC frame. Function is called in - * NetEq with a stored RCU payload i case of packet loss. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the framesize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC RCU frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - WebRtc_Word16 WebRtcIsac_DecodeRcu( - ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word16 len, - WebRtc_Word16* decoded, - WebRtc_Word16* speechType); - - -#if defined(__cplusplus) -} -#endif - - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/Android.mk b/src/modules/audio_coding/codecs/isac/main/source/Android.mk deleted file mode 100644 index f8d7f76..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/Android.mk +++ /dev/null
@@ -1,75 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -include $(LOCAL_PATH)/../../../../../../../android-webrtc.mk - -LOCAL_ARM_MODE := arm -LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_MODULE := libwebrtc_isac -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := \ - arith_routines.c \ - arith_routines_hist.c \ - arith_routines_logist.c \ - bandwidth_estimator.c \ - crc.c \ - decode.c \ - decode_bwe.c \ - encode.c \ - encode_lpc_swb.c \ - entropy_coding.c \ - fft.c \ - filter_functions.c \ - filterbank_tables.c \ - intialize.c \ - isac.c \ - filterbanks.c \ - pitch_lag_tables.c \ - lattice.c \ - lpc_gain_swb_tables.c \ - lpc_analysis.c \ - lpc_shape_swb12_tables.c \ - lpc_shape_swb16_tables.c \ - lpc_tables.c \ - pitch_estimator.c \ - pitch_filter.c \ - pitch_gain_tables.c \ - spectrum_ar_model_tables.c \ - transform.c - -# Flags passed to both C and C++ files. -LOCAL_CFLAGS := \ - $(MY_WEBRTC_COMMON_DEFS) - -# fft.c: error: comparison of array 'fftstate->Tmp0' equal to a null pointer -LOCAL_CLANG_CFLAGS := \ - -Wno-tautological-pointer-compare - -LOCAL_CFLAGS_arm := $(MY_WEBRTC_COMMON_DEFS_arm) -LOCAL_CFLAGS_x86 := $(MY_WEBRTC_COMMON_DEFS_x86) -LOCAL_CFLAGS_mips := $(MY_WEBRTC_COMMON_DEFS_mips) -LOCAL_CFLAGS_arm64 := $(MY_WEBRTC_COMMON_DEFS_arm64) -LOCAL_CFLAGS_x86_64 := $(MY_WEBRTC_COMMON_DEFS_x86_64) -LOCAL_CFLAGS_mips64 := $(MY_WEBRTC_COMMON_DEFS_mips64) - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../interface \ - $(LOCAL_PATH)/../../../../../.. \ - $(LOCAL_PATH)/../../../../../../common_audio/signal_processing/include - -ifdef WEBRTC_STL -LOCAL_NDK_STL_VARIANT := $(WEBRTC_STL) -LOCAL_SDK_VERSION := 14 -LOCAL_MODULE := $(LOCAL_MODULE)_$(WEBRTC_STL) -endif - -include $(BUILD_STATIC_LIBRARY)
diff --git a/src/modules/audio_coding/codecs/isac/main/source/arith_routines.c b/src/modules/audio_coding/codecs/isac/main/source/arith_routines.c deleted file mode 100644 index 31c441a..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/arith_routines.c +++ /dev/null
@@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "arith_routines.h" -#include "settings.h" - - -/* - * terminate and return byte stream; - * returns the number of bytes in the stream - */ -int WebRtcIsac_EncTerminate(Bitstr *streamdata) /* in-/output struct containing bitstream */ -{ - WebRtc_UWord8 *stream_ptr; - - - /* point to the right place in the stream buffer */ - stream_ptr = streamdata->stream + streamdata->stream_index; - - /* find minimum length (determined by current interval width) */ - if ( streamdata->W_upper > 0x01FFFFFF ) - { - streamdata->streamval += 0x01000000; - /* add carry to buffer */ - if (streamdata->streamval < 0x01000000) - { - /* propagate carry */ - while ( !(++(*--stream_ptr)) ); - /* put pointer back to the old value */ - stream_ptr = streamdata->stream + streamdata->stream_index; - } - /* write remaining data to bitstream */ - *stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24); - } - else - { - streamdata->streamval += 0x00010000; - /* add carry to buffer */ - if (streamdata->streamval < 0x00010000) - { - /* propagate carry */ - while ( !(++(*--stream_ptr)) ); - /* put pointer back to the old value */ - stream_ptr = streamdata->stream + streamdata->stream_index; - } - /* write remaining data to bitstream */ - *stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24); - *stream_ptr++ = (WebRtc_UWord8) ((streamdata->streamval >> 16) & 0x00FF); - } - - /* calculate stream length */ - return (int)(stream_ptr - streamdata->stream); -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/arith_routines.h b/src/modules/audio_coding/codecs/isac/main/source/arith_routines.h deleted file mode 100644 index 8e5f496..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/arith_routines.h +++ /dev/null
@@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * arith_routines.h - * - * Functions for arithmetic coding. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ - -#include "structs.h" - - -int WebRtcIsac_EncLogisticMulti2( - Bitstr *streamdata, /* in-/output struct containing bitstream */ - WebRtc_Word16 *dataQ7, /* input: data vector */ - const WebRtc_UWord16 *env, /* input: side info vector defining the width of the pdf */ - const int N, /* input: data vector length */ - const WebRtc_Word16 isSWB12kHz); /* if the codec is working in 12kHz bandwidth */ - -/* returns the number of bytes in the stream */ -int WebRtcIsac_EncTerminate(Bitstr *streamdata); /* in-/output struct containing bitstream */ - -/* returns the number of bytes in the stream so far */ -int WebRtcIsac_DecLogisticMulti2( - WebRtc_Word16 *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const WebRtc_UWord16 *env, /* input: side info vector defining the width of the pdf */ - const WebRtc_Word16 *dither, /* input: dither vector */ - const int N, /* input: data vector length */ - const WebRtc_Word16 isSWB12kHz); /* if the codec is working in 12kHz bandwidth */ - -void WebRtcIsac_EncHistMulti( - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const int *data, /* input: data vector */ - const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */ - const int N); /* input: data vector length */ - -int WebRtcIsac_DecHistBisectMulti( - int *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */ - const WebRtc_UWord16 *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */ - const int N); /* input: data vector length */ - -int WebRtcIsac_DecHistOneStepMulti( - int *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */ - const WebRtc_UWord16 *init_index,/* input: vector of initial cdf table search entries */ - const int N); /* input: data vector length */ - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ARITH_ROUTINES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/arith_routines_hist.c b/src/modules/audio_coding/codecs/isac/main/source/arith_routines_hist.c deleted file mode 100644 index f4a13d6..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/arith_routines_hist.c +++ /dev/null
@@ -1,291 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "settings.h" -#include "arith_routines.h" - - -/* - * code symbols into arithmetic bytestream - */ -void WebRtcIsac_EncHistMulti(Bitstr *streamdata, /* in-/output struct containing bitstream */ - const int *data, /* input: data vector */ - const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */ - const int N) /* input: data vector length */ -{ - WebRtc_UWord32 W_lower, W_upper; - WebRtc_UWord32 W_upper_LSB, W_upper_MSB; - WebRtc_UWord8 *stream_ptr; - WebRtc_UWord8 *stream_ptr_carry; - WebRtc_UWord32 cdf_lo, cdf_hi; - int k; - - - /* point to beginning of stream buffer */ - stream_ptr = streamdata->stream + streamdata->stream_index; - W_upper = streamdata->W_upper; - - for (k=N; k>0; k--) - { - /* fetch cdf_lower and cdf_upper from cdf tables */ - cdf_lo = (WebRtc_UWord32) *(*cdf + *data); - cdf_hi = (WebRtc_UWord32) *(*cdf++ + *data++ + 1); - - /* update interval */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = W_upper >> 16; - W_lower = W_upper_MSB * cdf_lo; - W_lower += (W_upper_LSB * cdf_lo) >> 16; - W_upper = W_upper_MSB * cdf_hi; - W_upper += (W_upper_LSB * cdf_hi) >> 16; - - /* shift interval such that it begins at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamdata->streamval += W_lower; - - /* handle carry */ - if (streamdata->streamval < W_lower) - { - /* propagate carry */ - stream_ptr_carry = stream_ptr; - while (!(++(*--stream_ptr_carry))); - } - - /* renormalize interval, store most significant byte of streamval and update streamval */ - while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ - { - W_upper <<= 8; - *stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24); - streamdata->streamval <<= 8; - } - } - - /* calculate new stream_index */ - streamdata->stream_index = (int)(stream_ptr - streamdata->stream); - streamdata->W_upper = W_upper; - - return; -} - - - -/* - * function to decode more symbols from the arithmetic bytestream, using method of bisection - * cdf tables should be of size 2^k-1 (which corresponds to an alphabet size of 2^k-2) - */ -int WebRtcIsac_DecHistBisectMulti(int *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */ - const WebRtc_UWord16 *cdf_size, /* input: array of cdf table sizes+1 (power of two: 2^k) */ - const int N) /* input: data vector length */ -{ - WebRtc_UWord32 W_lower, W_upper; - WebRtc_UWord32 W_tmp; - WebRtc_UWord32 W_upper_LSB, W_upper_MSB; - WebRtc_UWord32 streamval; - const WebRtc_UWord8 *stream_ptr; - const WebRtc_UWord16 *cdf_ptr; - int size_tmp; - int k; - - W_lower = 0; //to remove warning -DH - stream_ptr = streamdata->stream + streamdata->stream_index; - W_upper = streamdata->W_upper; - if (W_upper == 0) - /* Should not be possible in normal operation */ - return -2; - - if (streamdata->stream_index == 0) /* first time decoder is called for this stream */ - { - /* read first word from bytestream */ - streamval = *stream_ptr << 24; - streamval |= *++stream_ptr << 16; - streamval |= *++stream_ptr << 8; - streamval |= *++stream_ptr; - } else { - streamval = streamdata->streamval; - } - - for (k=N; k>0; k--) - { - /* find the integer *data for which streamval lies in [W_lower+1, W_upper] */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = W_upper >> 16; - - /* start halfway the cdf range */ - size_tmp = *cdf_size++ >> 1; - cdf_ptr = *cdf + (size_tmp - 1); - - /* method of bisection */ - for ( ;; ) - { - W_tmp = W_upper_MSB * *cdf_ptr; - W_tmp += (W_upper_LSB * *cdf_ptr) >> 16; - size_tmp >>= 1; - if (size_tmp == 0) break; - if (streamval > W_tmp) - { - W_lower = W_tmp; - cdf_ptr += size_tmp; - } else { - W_upper = W_tmp; - cdf_ptr -= size_tmp; - } - } - if (streamval > W_tmp) - { - W_lower = W_tmp; - *data++ = (int)(cdf_ptr - *cdf++); - } else { - W_upper = W_tmp; - *data++ = (int)(cdf_ptr - *cdf++ - 1); - } - - /* shift interval to start at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamval -= W_lower; - - /* renormalize interval and update streamval */ - while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ - { - /* read next byte from stream */ - streamval = (streamval << 8) | *++stream_ptr; - W_upper <<= 8; - } - - if (W_upper == 0) - /* Should not be possible in normal operation */ - return -2; - - - } - - streamdata->stream_index = (int)(stream_ptr - streamdata->stream); - streamdata->W_upper = W_upper; - streamdata->streamval = streamval; - - - /* find number of bytes in original stream (determined by current interval width) */ - if ( W_upper > 0x01FFFFFF ) - return streamdata->stream_index - 2; - else - return streamdata->stream_index - 1; -} - - - -/* - * function to decode more symbols from the arithmetic bytestream, taking single step up or - * down at a time - * cdf tables can be of arbitrary size, but large tables may take a lot of iterations - */ -int WebRtcIsac_DecHistOneStepMulti(int *data, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const WebRtc_UWord16 **cdf, /* input: array of cdf arrays */ - const WebRtc_UWord16 *init_index, /* input: vector of initial cdf table search entries */ - const int N) /* input: data vector length */ -{ - WebRtc_UWord32 W_lower, W_upper; - WebRtc_UWord32 W_tmp; - WebRtc_UWord32 W_upper_LSB, W_upper_MSB; - WebRtc_UWord32 streamval; - const WebRtc_UWord8 *stream_ptr; - const WebRtc_UWord16 *cdf_ptr; - int k; - - - stream_ptr = streamdata->stream + streamdata->stream_index; - W_upper = streamdata->W_upper; - if (W_upper == 0) - /* Should not be possible in normal operation */ - return -2; - - if (streamdata->stream_index == 0) /* first time decoder is called for this stream */ - { - /* read first word from bytestream */ - streamval = *stream_ptr << 24; - streamval |= *++stream_ptr << 16; - streamval |= *++stream_ptr << 8; - streamval |= *++stream_ptr; - } else { - streamval = streamdata->streamval; - } - - - for (k=N; k>0; k--) - { - /* find the integer *data for which streamval lies in [W_lower+1, W_upper] */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = W_upper >> 16; - - /* start at the specified table entry */ - cdf_ptr = *cdf + (*init_index++); - W_tmp = W_upper_MSB * *cdf_ptr; - W_tmp += (W_upper_LSB * *cdf_ptr) >> 16; - if (streamval > W_tmp) - { - for ( ;; ) - { - W_lower = W_tmp; - if (cdf_ptr[0]==65535) - /* range check */ - return -3; - W_tmp = W_upper_MSB * *++cdf_ptr; - W_tmp += (W_upper_LSB * *cdf_ptr) >> 16; - if (streamval <= W_tmp) break; - } - W_upper = W_tmp; - *data++ = (int)(cdf_ptr - *cdf++ - 1); - } else { - for ( ;; ) - { - W_upper = W_tmp; - --cdf_ptr; - if (cdf_ptr<*cdf) { - /* range check */ - return -3; - } - W_tmp = W_upper_MSB * *cdf_ptr; - W_tmp += (W_upper_LSB * *cdf_ptr) >> 16; - if (streamval > W_tmp) break; - } - W_lower = W_tmp; - *data++ = (int)(cdf_ptr - *cdf++); - } - - /* shift interval to start at zero */ - W_upper -= ++W_lower; - /* add integer to bitstream */ - streamval -= W_lower; - - /* renormalize interval and update streamval */ - while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ - { - /* read next byte from stream */ - streamval = (streamval << 8) | *++stream_ptr; - W_upper <<= 8; - } - } - - streamdata->stream_index = (int)(stream_ptr - streamdata->stream); - streamdata->W_upper = W_upper; - streamdata->streamval = streamval; - - - /* find number of bytes in original stream (determined by current interval width) */ - if ( W_upper > 0x01FFFFFF ) - return streamdata->stream_index - 2; - else - return streamdata->stream_index - 1; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/arith_routines_logist.c b/src/modules/audio_coding/codecs/isac/main/source/arith_routines_logist.c deleted file mode 100644 index 422855a..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/arith_routines_logist.c +++ /dev/null
@@ -1,294 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * arith_routines.h - * - * This file contains functions for arithmatically encoding and - * decoding DFT coefficients. - * - */ - - -#include "arith_routines.h" - - - -static const WebRtc_Word32 kHistEdgesQ15[51] = { - -327680, -314573, -301466, -288359, -275252, -262144, -249037, -235930, -222823, -209716, - -196608, -183501, -170394, -157287, -144180, -131072, -117965, -104858, -91751, -78644, - -65536, -52429, -39322, -26215, -13108, 0, 13107, 26214, 39321, 52428, - 65536, 78643, 91750, 104857, 117964, 131072, 144179, 157286, 170393, 183500, - 196608, 209715, 222822, 235929, 249036, 262144, 275251, 288358, 301465, 314572, - 327680}; - - -static const int kCdfSlopeQ0[51] = { /* Q0 */ - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 13, 23, 47, 87, 154, 315, 700, 1088, - 2471, 6064, 14221, 21463, 36634, 36924, 19750, 13270, 5806, 2312, - 1095, 660, 316, 145, 86, 41, 32, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 0}; - - -static const int kCdfQ16[51] = { /* Q16 */ - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, - 20, 22, 24, 29, 38, 57, 92, 153, 279, 559, - 994, 1983, 4408, 10097, 18682, 33336, 48105, 56005, 61313, 63636, - 64560, 64998, 65262, 65389, 65447, 65481, 65497, 65510, 65512, 65514, - 65516, 65518, 65520, 65522, 65524, 65526, 65528, 65530, 65532, 65534, - 65535}; - - - -/* function to be converted to fixed point */ -static __inline WebRtc_UWord32 piecewise(WebRtc_Word32 xinQ15) { - - WebRtc_Word32 ind, qtmp1, qtmp2, qtmp3; - WebRtc_UWord32 tmpUW32; - - - qtmp2 = xinQ15; - - if (qtmp2 < kHistEdgesQ15[0]) { - qtmp2 = kHistEdgesQ15[0]; - } - if (qtmp2 > kHistEdgesQ15[50]) { - qtmp2 = kHistEdgesQ15[50]; - } - - qtmp1 = qtmp2 - kHistEdgesQ15[0]; /* Q15 - Q15 = Q15 */ - ind = (qtmp1 * 5) >> 16; /* 2^16 / 5 = 0.4 in Q15 */ - /* Q15 -> Q0 */ - qtmp1 = qtmp2 - kHistEdgesQ15[ind]; /* Q15 - Q15 = Q15 */ - qtmp2 = kCdfSlopeQ0[ind] * qtmp1; /* Q0 * Q15 = Q15 */ - qtmp3 = qtmp2>>15; /* Q15 -> Q0 */ - - tmpUW32 = kCdfQ16[ind] + qtmp3; /* Q0 + Q0 = Q0 */ - return tmpUW32; -} - - - -int WebRtcIsac_EncLogisticMulti2( - Bitstr *streamdata, /* in-/output struct containing bitstream */ - WebRtc_Word16 *dataQ7, /* input: data vector */ - const WebRtc_UWord16 *envQ8, /* input: side info vector defining the width of the pdf */ - const int N, /* input: data vector length / 2 */ - const WebRtc_Word16 isSWB12kHz) -{ - WebRtc_UWord32 W_lower, W_upper; - WebRtc_UWord32 W_upper_LSB, W_upper_MSB; - WebRtc_UWord8 *stream_ptr; - WebRtc_UWord8 *maxStreamPtr; - WebRtc_UWord8 *stream_ptr_carry; - WebRtc_UWord32 cdf_lo, cdf_hi; - int k; - - /* point to beginning of stream buffer */ - stream_ptr = streamdata->stream + streamdata->stream_index; - W_upper = streamdata->W_upper; - - maxStreamPtr = streamdata->stream + STREAM_SIZE_MAX_60 - 1; - for (k = 0; k < N; k++) - { - /* compute cdf_lower and cdf_upper by evaluating the piecewise linear cdf */ - cdf_lo = piecewise((*dataQ7 - 64) * *envQ8); - cdf_hi = piecewise((*dataQ7 + 64) * *envQ8); - - /* test and clip if probability gets too small */ - while (cdf_lo+1 >= cdf_hi) { - /* clip */ - if (*dataQ7 > 0) { - *dataQ7 -= 128; - cdf_hi = cdf_lo; - cdf_lo = piecewise((*dataQ7 - 64) * *envQ8); - } else { - *dataQ7 += 128; - cdf_lo = cdf_hi; - cdf_hi = piecewise((*dataQ7 + 64) * *envQ8); - } - } - - dataQ7++; - // increment only once per 4 iterations for SWB-16kHz or WB - // increment only once per 2 iterations for SWB-12kHz - envQ8 += (isSWB12kHz)? (k & 1):((k & 1) & (k >> 1)); - - - /* update interval */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = W_upper >> 16; - W_lower = W_upper_MSB * cdf_lo; - W_lower += (W_upper_LSB * cdf_lo) >> 16; - W_upper = W_upper_MSB * cdf_hi; - W_upper += (W_upper_LSB * cdf_hi) >> 16; - - /* shift interval such that it begins at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamdata->streamval += W_lower; - - /* handle carry */ - if (streamdata->streamval < W_lower) - { - /* propagate carry */ - stream_ptr_carry = stream_ptr; - while (!(++(*--stream_ptr_carry))); - } - - /* renormalize interval, store most significant byte of streamval and update streamval */ - while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ - { - W_upper <<= 8; - *stream_ptr++ = (WebRtc_UWord8) (streamdata->streamval >> 24); - - if(stream_ptr > maxStreamPtr) - { - return -ISAC_DISALLOWED_BITSTREAM_LENGTH; - } - streamdata->streamval <<= 8; - } - } - - /* calculate new stream_index */ - streamdata->stream_index = (int)(stream_ptr - streamdata->stream); - streamdata->W_upper = W_upper; - - return 0; -} - - - -int WebRtcIsac_DecLogisticMulti2( - WebRtc_Word16 *dataQ7, /* output: data vector */ - Bitstr *streamdata, /* in-/output struct containing bitstream */ - const WebRtc_UWord16 *envQ8, /* input: side info vector defining the width of the pdf */ - const WebRtc_Word16 *ditherQ7,/* input: dither vector */ - const int N, /* input: data vector length */ - const WebRtc_Word16 isSWB12kHz) -{ - WebRtc_UWord32 W_lower, W_upper; - WebRtc_UWord32 W_tmp; - WebRtc_UWord32 W_upper_LSB, W_upper_MSB; - WebRtc_UWord32 streamval; - const WebRtc_UWord8 *stream_ptr; - WebRtc_UWord32 cdf_tmp; - WebRtc_Word16 candQ7; - int k; - - stream_ptr = streamdata->stream + streamdata->stream_index; - W_upper = streamdata->W_upper; - if (streamdata->stream_index == 0) /* first time decoder is called for this stream */ - { - /* read first word from bytestream */ - streamval = *stream_ptr << 24; - streamval |= *++stream_ptr << 16; - streamval |= *++stream_ptr << 8; - streamval |= *++stream_ptr; - } else { - streamval = streamdata->streamval; - } - - - for (k = 0; k < N; k++) - { - /* find the integer *data for which streamval lies in [W_lower+1, W_upper] */ - W_upper_LSB = W_upper & 0x0000FFFF; - W_upper_MSB = W_upper >> 16; - - /* find first candidate by inverting the logistic cdf */ - candQ7 = - *ditherQ7 + 64; - cdf_tmp = piecewise(candQ7 * *envQ8); - - W_tmp = W_upper_MSB * cdf_tmp; - W_tmp += (W_upper_LSB * cdf_tmp) >> 16; - if (streamval > W_tmp) - { - W_lower = W_tmp; - candQ7 += 128; - cdf_tmp = piecewise(candQ7 * *envQ8); - - W_tmp = W_upper_MSB * cdf_tmp; - W_tmp += (W_upper_LSB * cdf_tmp) >> 16; - while (streamval > W_tmp) - { - W_lower = W_tmp; - candQ7 += 128; - cdf_tmp = piecewise(candQ7 * *envQ8); - - W_tmp = W_upper_MSB * cdf_tmp; - W_tmp += (W_upper_LSB * cdf_tmp) >> 16; - - /* error check */ - if (W_lower == W_tmp) return -1; - } - W_upper = W_tmp; - - /* another sample decoded */ - *dataQ7 = candQ7 - 64; - } - else - { - W_upper = W_tmp; - candQ7 -= 128; - cdf_tmp = piecewise(candQ7 * *envQ8); - - W_tmp = W_upper_MSB * cdf_tmp; - W_tmp += (W_upper_LSB * cdf_tmp) >> 16; - while ( !(streamval > W_tmp) ) - { - W_upper = W_tmp; - candQ7 -= 128; - cdf_tmp = piecewise(candQ7 * *envQ8); - - W_tmp = W_upper_MSB * cdf_tmp; - W_tmp += (W_upper_LSB * cdf_tmp) >> 16; - - /* error check */ - if (W_upper == W_tmp) return -1; - } - W_lower = W_tmp; - - /* another sample decoded */ - *dataQ7 = candQ7 + 64; - } - ditherQ7++; - dataQ7++; - // increment only once per 4 iterations for SWB-16kHz or WB - // increment only once per 2 iterations for SWB-12kHz - envQ8 += (isSWB12kHz)? (k & 1):((k & 1) & (k >> 1)); - - /* shift interval to start at zero */ - W_upper -= ++W_lower; - - /* add integer to bitstream */ - streamval -= W_lower; - - /* renormalize interval and update streamval */ - while ( !(W_upper & 0xFF000000) ) /* W_upper < 2^24 */ - { - /* read next byte from stream */ - streamval = (streamval << 8) | *++stream_ptr; - W_upper <<= 8; - } - } - - streamdata->stream_index = (int)(stream_ptr - streamdata->stream); - streamdata->W_upper = W_upper; - streamdata->streamval = streamval; - - /* find number of bytes in original stream (determined by current interval width) */ - if ( W_upper > 0x01FFFFFF ) - return streamdata->stream_index - 2; - else - return streamdata->stream_index - 1; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c b/src/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c deleted file mode 100644 index d0a50c5..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c +++ /dev/null
@@ -1,1020 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * BwEstimator.c - * - * This file contains the code for the Bandwidth Estimator designed - * for iSAC. - * - */ - -#include "bandwidth_estimator.h" -#include "settings.h" -#include "isac.h" - -#include <math.h> - -/* array of quantization levels for bottle neck info; Matlab code: */ -/* sprintf('%4.1ff, ', logspace(log10(5000), log10(40000), 12)) */ -static const float kQRateTableWb[12] = -{ - 10000.0f, 11115.3f, 12355.1f, 13733.1f, 15264.8f, 16967.3f, - 18859.8f, 20963.3f, 23301.4f, 25900.3f, 28789.0f, 32000.0f}; - - -static const float kQRateTableSwb[24] = -{ - 10000.0f, 11115.3f, 12355.1f, 13733.1f, 15264.8f, 16967.3f, - 18859.8f, 20963.3f, 23153.1f, 25342.9f, 27532.7f, 29722.5f, - 31912.3f, 34102.1f, 36291.9f, 38481.7f, 40671.4f, 42861.2f, - 45051.0f, 47240.8f, 49430.6f, 51620.4f, 53810.2f, 56000.0f, -}; - - - - -WebRtc_Word32 WebRtcIsac_InitBandwidthEstimator( - BwEstimatorstr* bwest_str, - enum IsacSamplingRate encoderSampRate, - enum IsacSamplingRate decoderSampRate) -{ - switch(encoderSampRate) - { - case kIsacWideband: - { - bwest_str->send_bw_avg = INIT_BN_EST_WB; - break; - } - case kIsacSuperWideband: - { - bwest_str->send_bw_avg = INIT_BN_EST_SWB; - break; - } - } - - switch(decoderSampRate) - { - case kIsacWideband: - { - bwest_str->prev_frame_length = INIT_FRAME_LEN_WB; - bwest_str->rec_bw_inv = 1.0f / - (INIT_BN_EST_WB + INIT_HDR_RATE_WB); - bwest_str->rec_bw = (WebRtc_Word32)INIT_BN_EST_WB; - bwest_str->rec_bw_avg_Q = INIT_BN_EST_WB; - bwest_str->rec_bw_avg = INIT_BN_EST_WB + INIT_HDR_RATE_WB; - bwest_str->rec_header_rate = INIT_HDR_RATE_WB; - break; - } - case kIsacSuperWideband: - { - bwest_str->prev_frame_length = INIT_FRAME_LEN_SWB; - bwest_str->rec_bw_inv = 1.0f / - (INIT_BN_EST_SWB + INIT_HDR_RATE_SWB); - bwest_str->rec_bw = (WebRtc_Word32)INIT_BN_EST_SWB; - bwest_str->rec_bw_avg_Q = INIT_BN_EST_SWB; - bwest_str->rec_bw_avg = INIT_BN_EST_SWB + INIT_HDR_RATE_SWB; - bwest_str->rec_header_rate = INIT_HDR_RATE_SWB; - break; - } - } - - bwest_str->prev_rec_rtp_number = 0; - bwest_str->prev_rec_arr_ts = 0; - bwest_str->prev_rec_send_ts = 0; - bwest_str->prev_rec_rtp_rate = 1.0f; - bwest_str->last_update_ts = 0; - bwest_str->last_reduction_ts = 0; - bwest_str->count_tot_updates_rec = -9; - bwest_str->rec_jitter = 10.0f; - bwest_str->rec_jitter_short_term = 0.0f; - bwest_str->rec_jitter_short_term_abs = 5.0f; - bwest_str->rec_max_delay = 10.0f; - bwest_str->rec_max_delay_avg_Q = 10.0f; - bwest_str->num_pkts_rec = 0; - - bwest_str->send_max_delay_avg = 10.0f; - - bwest_str->hsn_detect_rec = 0; - - bwest_str->num_consec_rec_pkts_over_30k = 0; - - bwest_str->hsn_detect_snd = 0; - - bwest_str->num_consec_snt_pkts_over_30k = 0; - - bwest_str->in_wait_period = 0; - - bwest_str->change_to_WB = 0; - - bwest_str->numConsecLatePkts = 0; - bwest_str->consecLatency = 0; - bwest_str->inWaitLatePkts = 0; - bwest_str->senderTimestamp = 0; - bwest_str->receiverTimestamp = 0; - return 0; -} - -/* This function updates both bottle neck rates */ -/* Parameters: */ -/* rtp_number - value from RTP packet, from NetEq */ -/* frame length - length of signal frame in ms, from iSAC decoder */ -/* send_ts - value in RTP header giving send time in samples */ -/* arr_ts - value given by timeGetTime() time of arrival in samples of packet from NetEq */ -/* pksize - size of packet in bytes, from NetEq */ -/* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */ -/* returns 0 if everything went fine, -1 otherwise */ -WebRtc_Word16 WebRtcIsac_UpdateBandwidthEstimator( - BwEstimatorstr *bwest_str, - const WebRtc_UWord16 rtp_number, - const WebRtc_Word32 frame_length, - const WebRtc_UWord32 send_ts, - const WebRtc_UWord32 arr_ts, - const WebRtc_Word32 pksize - /*, const WebRtc_UWord16 Index*/) -{ - float weight = 0.0f; - float curr_bw_inv = 0.0f; - float rec_rtp_rate; - float t_diff_proj; - float arr_ts_diff; - float send_ts_diff; - float arr_time_noise; - float arr_time_noise_abs; - - float delay_correction_factor = 1; - float late_diff = 0.0f; - int immediate_set = 0; - int num_pkts_expected; - - - // We have to adjust the header-rate if the first packet has a - // frame-size different than the initialized value. - if ( frame_length != bwest_str->prev_frame_length ) - { - bwest_str->rec_header_rate = (float)HEADER_SIZE * 8.0f * - 1000.0f / (float)frame_length; /* bits/s */ - } - - /* UPDATE ESTIMATES ON THIS SIDE */ - /* compute far-side transmission rate */ - rec_rtp_rate = ((float)pksize * 8.0f * 1000.0f / (float)frame_length) + - bwest_str->rec_header_rate; - // rec_rtp_rate packet bits/s + header bits/s - - /* check for timer wrap-around */ - if (arr_ts < bwest_str->prev_rec_arr_ts) - { - bwest_str->prev_rec_arr_ts = arr_ts; - bwest_str->last_update_ts = arr_ts; - bwest_str->last_reduction_ts = arr_ts + 3*FS; - bwest_str->num_pkts_rec = 0; - - /* store frame length */ - bwest_str->prev_frame_length = frame_length; - - /* store far-side transmission rate */ - bwest_str->prev_rec_rtp_rate = rec_rtp_rate; - - /* store far-side RTP time stamp */ - bwest_str->prev_rec_rtp_number = rtp_number; - - return 0; - } - - bwest_str->num_pkts_rec++; - - /* check that it's not one of the first 9 packets */ - if ( bwest_str->count_tot_updates_rec > 0 ) - { - if(bwest_str->in_wait_period > 0 ) - { - bwest_str->in_wait_period--; - } - - bwest_str->inWaitLatePkts -= ((bwest_str->inWaitLatePkts > 0)? 1:0); - send_ts_diff = (float)(send_ts - bwest_str->prev_rec_send_ts); - - if (send_ts_diff <= (16 * frame_length)*2) - //doesn't allow for a dropped packet, not sure necessary to be - // that strict -DH - { - /* if not been updated for a long time, reduce the BN estimate */ - if((WebRtc_UWord32)(arr_ts - bwest_str->last_update_ts) * - 1000.0f / FS > 3000) - { - //how many frames should have been received since the last - // update if too many have been dropped or there have been - // big delays won't allow this reduction may no longer need - // the send_ts_diff here - num_pkts_expected = (int)(((float)(arr_ts - - bwest_str->last_update_ts) * 1000.0f /(float) FS) / - (float)frame_length); - - if(((float)bwest_str->num_pkts_rec/(float)num_pkts_expected) > - 0.9) - { - float inv_bitrate = (float) pow( 0.99995, - (double)((WebRtc_UWord32)(arr_ts - - bwest_str->last_reduction_ts)*1000.0f/FS) ); - - if ( inv_bitrate ) - { - bwest_str->rec_bw_inv /= inv_bitrate; - - //precautionary, likely never necessary - if (bwest_str->hsn_detect_snd && - bwest_str->hsn_detect_rec) - { - if (bwest_str->rec_bw_inv > 0.000066f) - { - bwest_str->rec_bw_inv = 0.000066f; - } - } - } - else - { - bwest_str->rec_bw_inv = 1.0f / - (INIT_BN_EST_WB + INIT_HDR_RATE_WB); - } - /* reset time-since-update counter */ - bwest_str->last_reduction_ts = arr_ts; - } - else - //reset here? - { - bwest_str->last_reduction_ts = arr_ts + 3*FS; - bwest_str->last_update_ts = arr_ts; - bwest_str->num_pkts_rec = 0; - } - } - } - else - { - bwest_str->last_reduction_ts = arr_ts + 3*FS; - bwest_str->last_update_ts = arr_ts; - bwest_str->num_pkts_rec = 0; - } - - - /* temporarily speed up adaptation if frame length has changed */ - if ( frame_length != bwest_str->prev_frame_length ) - { - bwest_str->count_tot_updates_rec = 10; - bwest_str->rec_header_rate = (float)HEADER_SIZE * 8.0f * - 1000.0f / (float)frame_length; /* bits/s */ - - bwest_str->rec_bw_inv = 1.0f /((float)bwest_str->rec_bw + - bwest_str->rec_header_rate); - } - - //////////////////////// - arr_ts_diff = (float)(arr_ts - bwest_str->prev_rec_arr_ts); - - if (send_ts_diff > 0 ) - { - late_diff = arr_ts_diff - send_ts_diff; - } - else - { - late_diff = arr_ts_diff - (float)(16 * frame_length); - } - - if((late_diff > 0) && !bwest_str->inWaitLatePkts) - { - bwest_str->numConsecLatePkts++; - bwest_str->consecLatency += late_diff; - } - else - { - bwest_str->numConsecLatePkts = 0; - bwest_str->consecLatency = 0; - } - if(bwest_str->numConsecLatePkts > 50) - { - float latencyMs = bwest_str->consecLatency/(FS/1000); - float averageLatencyMs = latencyMs / bwest_str->numConsecLatePkts; - delay_correction_factor = frame_length / (frame_length + averageLatencyMs); - immediate_set = 1; - bwest_str->inWaitLatePkts = (WebRtc_Word16)((bwest_str->consecLatency/(FS/1000)) / 30);// + 150; - bwest_str->start_wait_period = arr_ts; - } - /////////////////////////////////////////////// - - - - /* update only if previous packet was not lost */ - if ( rtp_number == bwest_str->prev_rec_rtp_number + 1 ) - { - - - if (!(bwest_str->hsn_detect_snd && bwest_str->hsn_detect_rec)) - { - if ((arr_ts_diff > (float)(16 * frame_length))) - { - //1/2 second - if ((late_diff > 8000.0f) && !bwest_str->in_wait_period) - { - delay_correction_factor = 0.7f; - bwest_str->in_wait_period = 55; - bwest_str->start_wait_period = arr_ts; - immediate_set = 1; - } - //320 ms - else if (late_diff > 5120.0f && !bwest_str->in_wait_period) - { - delay_correction_factor = 0.8f; - immediate_set = 1; - bwest_str->in_wait_period = 44; - bwest_str->start_wait_period = arr_ts; - } - } - } - - - if ((bwest_str->prev_rec_rtp_rate > bwest_str->rec_bw_avg) && - (rec_rtp_rate > bwest_str->rec_bw_avg) && - !bwest_str->in_wait_period) - { - /* test if still in initiation period and increment counter */ - if (bwest_str->count_tot_updates_rec++ > 99) - { - /* constant weight after initiation part */ - weight = 0.01f; - } - else - { - /* weight decreases with number of updates */ - weight = 1.0f / (float) bwest_str->count_tot_updates_rec; - } - /* Bottle Neck Estimation */ - - /* limit outliers */ - /* if more than 25 ms too much */ - if (arr_ts_diff > frame_length * FS/1000 + 400.0f) - { - // in samples, why 25ms?? - arr_ts_diff = frame_length * FS/1000 + 400.0f; - } - if(arr_ts_diff < (frame_length * FS/1000) - 160.0f) - { - /* don't allow it to be less than frame rate - 10 ms */ - arr_ts_diff = (float)frame_length * FS/1000 - 160.0f; - } - - /* compute inverse receiving rate for last packet */ - curr_bw_inv = arr_ts_diff / ((float)(pksize + HEADER_SIZE) * - 8.0f * FS); // (180+35)*8*16000 = 27.5 Mbit.... - - - if(curr_bw_inv < - (1.0f / (MAX_ISAC_BW + bwest_str->rec_header_rate))) - { - // don't allow inv rate to be larger than MAX - curr_bw_inv = (1.0f / - (MAX_ISAC_BW + bwest_str->rec_header_rate)); - } - - /* update bottle neck rate estimate */ - bwest_str->rec_bw_inv = weight * curr_bw_inv + - (1.0f - weight) * bwest_str->rec_bw_inv; - - /* reset time-since-update counter */ - bwest_str->last_update_ts = arr_ts; - bwest_str->last_reduction_ts = arr_ts + 3 * FS; - bwest_str->num_pkts_rec = 0; - - /* Jitter Estimation */ - /* projected difference between arrival times */ - t_diff_proj = ((float)(pksize + HEADER_SIZE) * 8.0f * - 1000.0f) / bwest_str->rec_bw_avg; - - - // difference between projected and actual - // arrival time differences - arr_time_noise = (float)(arr_ts_diff*1000.0f/FS) - - t_diff_proj; - arr_time_noise_abs = (float) fabs( arr_time_noise ); - - /* long term averaged absolute jitter */ - bwest_str->rec_jitter = weight * arr_time_noise_abs + - (1.0f - weight) * bwest_str->rec_jitter; - if (bwest_str->rec_jitter > 10.0f) - { - bwest_str->rec_jitter = 10.0f; - } - /* short term averaged absolute jitter */ - bwest_str->rec_jitter_short_term_abs = 0.05f * - arr_time_noise_abs + 0.95f * - bwest_str->rec_jitter_short_term_abs; - - /* short term averaged jitter */ - bwest_str->rec_jitter_short_term = 0.05f * arr_time_noise + - 0.95f * bwest_str->rec_jitter_short_term; - } - } - } - else - { - // reset time-since-update counter when - // receiving the first 9 packets - bwest_str->last_update_ts = arr_ts; - bwest_str->last_reduction_ts = arr_ts + 3*FS; - bwest_str->num_pkts_rec = 0; - - bwest_str->count_tot_updates_rec++; - } - - /* limit minimum bottle neck rate */ - if (bwest_str->rec_bw_inv > 1.0f / ((float)MIN_ISAC_BW + - bwest_str->rec_header_rate)) - { - bwest_str->rec_bw_inv = 1.0f / ((float)MIN_ISAC_BW + - bwest_str->rec_header_rate); - } - - // limit maximum bitrate - if (bwest_str->rec_bw_inv < 1.0f / ((float)MAX_ISAC_BW + - bwest_str->rec_header_rate)) - { - bwest_str->rec_bw_inv = 1.0f / ((float)MAX_ISAC_BW + - bwest_str->rec_header_rate); - } - - /* store frame length */ - bwest_str->prev_frame_length = frame_length; - - /* store far-side transmission rate */ - bwest_str->prev_rec_rtp_rate = rec_rtp_rate; - - /* store far-side RTP time stamp */ - bwest_str->prev_rec_rtp_number = rtp_number; - - // Replace bwest_str->rec_max_delay by the new - // value (atomic operation) - bwest_str->rec_max_delay = 3.0f * bwest_str->rec_jitter; - - /* store send and arrival time stamp */ - bwest_str->prev_rec_arr_ts = arr_ts ; - bwest_str->prev_rec_send_ts = send_ts; - - /* Replace bwest_str->rec_bw by the new value (atomic operation) */ - bwest_str->rec_bw = (WebRtc_Word32)(1.0f / bwest_str->rec_bw_inv - - bwest_str->rec_header_rate); - - if (immediate_set) - { - bwest_str->rec_bw = (WebRtc_Word32) (delay_correction_factor * - (float) bwest_str->rec_bw); - - if (bwest_str->rec_bw < (WebRtc_Word32) MIN_ISAC_BW) - { - bwest_str->rec_bw = (WebRtc_Word32) MIN_ISAC_BW; - } - - bwest_str->rec_bw_avg = bwest_str->rec_bw + - bwest_str->rec_header_rate; - - bwest_str->rec_bw_avg_Q = (float) bwest_str->rec_bw; - - bwest_str->rec_jitter_short_term = 0.0f; - - bwest_str->rec_bw_inv = 1.0f / (bwest_str->rec_bw + - bwest_str->rec_header_rate); - - bwest_str->count_tot_updates_rec = 1; - - immediate_set = 0; - bwest_str->consecLatency = 0; - bwest_str->numConsecLatePkts = 0; - } - - return 0; -} - - -/* This function updates the send bottle neck rate */ -/* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */ -/* returns 0 if everything went fine, -1 otherwise */ -WebRtc_Word16 WebRtcIsac_UpdateUplinkBwImpl( - BwEstimatorstr* bwest_str, - WebRtc_Word16 index, - enum IsacSamplingRate encoderSamplingFreq) -{ - if((index < 0) || (index > 23)) - { - return -ISAC_RANGE_ERROR_BW_ESTIMATOR; - } - - /* UPDATE ESTIMATES FROM OTHER SIDE */ - if(encoderSamplingFreq == kIsacWideband) - { - if(index > 11) - { - index -= 12; - /* compute the jitter estimate as decoded on the other side */ - bwest_str->send_max_delay_avg = 0.9f * bwest_str->send_max_delay_avg + - 0.1f * (float)MAX_ISAC_MD; - } - else - { - /* compute the jitter estimate as decoded on the other side */ - bwest_str->send_max_delay_avg = 0.9f * bwest_str->send_max_delay_avg + - 0.1f * (float)MIN_ISAC_MD; - } - - /* compute the BN estimate as decoded on the other side */ - bwest_str->send_bw_avg = 0.9f * bwest_str->send_bw_avg + - 0.1f * kQRateTableWb[index]; - } - else - { - /* compute the BN estimate as decoded on the other side */ - bwest_str->send_bw_avg = 0.9f * bwest_str->send_bw_avg + - 0.1f * kQRateTableSwb[index]; - } - - if (bwest_str->send_bw_avg > (float) 28000 && !bwest_str->hsn_detect_snd) - { - bwest_str->num_consec_snt_pkts_over_30k++; - - if (bwest_str->num_consec_snt_pkts_over_30k >= 66) - { - //approx 2 seconds with 30ms frames - bwest_str->hsn_detect_snd = 1; - } - } - else if (!bwest_str->hsn_detect_snd) - { - bwest_str->num_consec_snt_pkts_over_30k = 0; - } - return 0; -} - -// called when there is upper-band bit-stream to update jitter -// statistics. -WebRtc_Word16 WebRtcIsac_UpdateUplinkJitter( - BwEstimatorstr* bwest_str, - WebRtc_Word32 index) -{ - if((index < 0) || (index > 23)) - { - return -ISAC_RANGE_ERROR_BW_ESTIMATOR; - } - - if(index > 0) - { - /* compute the jitter estimate as decoded on the other side */ - bwest_str->send_max_delay_avg = 0.9f * bwest_str->send_max_delay_avg + - 0.1f * (float)MAX_ISAC_MD; - } - else - { - /* compute the jitter estimate as decoded on the other side */ - bwest_str->send_max_delay_avg = 0.9f * bwest_str->send_max_delay_avg + - 0.1f * (float)MIN_ISAC_MD; - } - - return 0; -} - - - -// Returns the bandwidth/jitter estimation code (integer 0...23) -// to put in the sending iSAC payload -WebRtc_UWord16 -WebRtcIsac_GetDownlinkBwJitIndexImpl( - BwEstimatorstr* bwest_str, - WebRtc_Word16* bottleneckIndex, - WebRtc_Word16* jitterInfo, - enum IsacSamplingRate decoderSamplingFreq) -{ - float MaxDelay; - //WebRtc_UWord16 MaxDelayBit; - - float rate; - float r; - float e1, e2; - const float weight = 0.1f; - const float* ptrQuantizationTable; - WebRtc_Word16 addJitterInfo; - WebRtc_Word16 minInd; - WebRtc_Word16 maxInd; - WebRtc_Word16 midInd; - - /* Get Max Delay Bit */ - /* get unquantized max delay */ - MaxDelay = (float)WebRtcIsac_GetDownlinkMaxDelay(bwest_str); - - if ( ((1.f - weight) * bwest_str->rec_max_delay_avg_Q + weight * - MAX_ISAC_MD - MaxDelay) > (MaxDelay - (1.f-weight) * - bwest_str->rec_max_delay_avg_Q - weight * MIN_ISAC_MD) ) - { - jitterInfo[0] = 0; - /* update quantized average */ - bwest_str->rec_max_delay_avg_Q = - (1.f - weight) * bwest_str->rec_max_delay_avg_Q + weight * - (float)MIN_ISAC_MD; - } - else - { - jitterInfo[0] = 1; - /* update quantized average */ - bwest_str->rec_max_delay_avg_Q = - (1.f-weight) * bwest_str->rec_max_delay_avg_Q + weight * - (float)MAX_ISAC_MD; - } - - // Get unquantized rate. - rate = (float)WebRtcIsac_GetDownlinkBandwidth(bwest_str); - - /* Get Rate Index */ - if(decoderSamplingFreq == kIsacWideband) - { - ptrQuantizationTable = kQRateTableWb; - addJitterInfo = 1; - maxInd = 11; - } - else - { - ptrQuantizationTable = kQRateTableSwb; - addJitterInfo = 0; - maxInd = 23; - } - - minInd = 0; - while(maxInd > minInd + 1) - { - midInd = (maxInd + minInd) >> 1; - if(rate > ptrQuantizationTable[midInd]) - { - minInd = midInd; - } - else - { - maxInd = midInd; - } - } - // Chose the index which gives results an average which is closest - // to rate - r = (1 - weight) * bwest_str->rec_bw_avg_Q - rate; - e1 = weight * ptrQuantizationTable[minInd] + r; - e2 = weight * ptrQuantizationTable[maxInd] + r; - e1 = (e1 > 0)? e1:-e1; - e2 = (e2 > 0)? e2:-e2; - if(e1 < e2) - { - bottleneckIndex[0] = minInd; - } - else - { - bottleneckIndex[0] = maxInd; - } - - bwest_str->rec_bw_avg_Q = (1 - weight) * bwest_str->rec_bw_avg_Q + - weight * ptrQuantizationTable[bottleneckIndex[0]]; - bottleneckIndex[0] += jitterInfo[0] * 12 * addJitterInfo; - - bwest_str->rec_bw_avg = (1 - weight) * bwest_str->rec_bw_avg + weight * - (rate + bwest_str->rec_header_rate); - - return 0; -} - - - -/* get the bottle neck rate from far side to here, as estimated on this side */ -WebRtc_Word32 WebRtcIsac_GetDownlinkBandwidth( const BwEstimatorstr *bwest_str) -{ - WebRtc_Word32 rec_bw; - float jitter_sign; - float bw_adjust; - - /* create a value between -1.0 and 1.0 indicating "average sign" of jitter */ - jitter_sign = bwest_str->rec_jitter_short_term / - bwest_str->rec_jitter_short_term_abs; - - /* adjust bw proportionally to negative average jitter sign */ - bw_adjust = 1.0f - jitter_sign * (0.15f + 0.15f * jitter_sign * jitter_sign); - - /* adjust Rate if jitter sign is mostly constant */ - rec_bw = (WebRtc_Word32)(bwest_str->rec_bw * bw_adjust); - - /* limit range of bottle neck rate */ - if (rec_bw < MIN_ISAC_BW) - { - rec_bw = MIN_ISAC_BW; - } - else if (rec_bw > MAX_ISAC_BW) - { - rec_bw = MAX_ISAC_BW; - } - return rec_bw; -} - -/* Returns the max delay (in ms) */ -WebRtc_Word32 -WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str) -{ - WebRtc_Word32 rec_max_delay; - - rec_max_delay = (WebRtc_Word32)(bwest_str->rec_max_delay); - - /* limit range of jitter estimate */ - if (rec_max_delay < MIN_ISAC_MD) - { - rec_max_delay = MIN_ISAC_MD; - } - else if (rec_max_delay > MAX_ISAC_MD) - { - rec_max_delay = MAX_ISAC_MD; - } - return rec_max_delay; -} - -/* get the bottle neck rate from here to far side, as estimated by far side */ -void -WebRtcIsac_GetUplinkBandwidth( - const BwEstimatorstr* bwest_str, - WebRtc_Word32* bitRate) -{ - /* limit range of bottle neck rate */ - if (bwest_str->send_bw_avg < MIN_ISAC_BW) - { - *bitRate = MIN_ISAC_BW; - } - else if (bwest_str->send_bw_avg > MAX_ISAC_BW) - { - *bitRate = MAX_ISAC_BW; - } - else - { - *bitRate = (WebRtc_Word32)(bwest_str->send_bw_avg); - } - return; -} - -/* Returns the max delay value from the other side in ms */ -WebRtc_Word32 -WebRtcIsac_GetUplinkMaxDelay(const BwEstimatorstr *bwest_str) -{ - WebRtc_Word32 send_max_delay; - - send_max_delay = (WebRtc_Word32)(bwest_str->send_max_delay_avg); - - /* limit range of jitter estimate */ - if (send_max_delay < MIN_ISAC_MD) - { - send_max_delay = MIN_ISAC_MD; - } - else if (send_max_delay > MAX_ISAC_MD) - { - send_max_delay = MAX_ISAC_MD; - } - return send_max_delay; -} - - -/* - * update long-term average bitrate and amount of data in buffer - * returns minimum payload size (bytes) - */ -int WebRtcIsac_GetMinBytes( - RateModel* State, - int StreamSize, /* bytes in bitstream */ - const int FrameSamples, /* samples per frame */ - const double BottleNeck, /* bottle neck rate; excl headers (bps) */ - const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */ - enum ISACBandwidth bandwidth - /*,WebRtc_Word16 frequentLargePackets*/) -{ - double MinRate = 0.0; - int MinBytes; - double TransmissionTime; - int burstInterval = BURST_INTERVAL; - - // first 10 packets @ low rate, then INIT_BURST_LEN packets @ - // fixed rate of INIT_RATE bps - if (State->InitCounter > 0) - { - if (State->InitCounter-- <= INIT_BURST_LEN) - { - if(bandwidth == isac8kHz) - { - MinRate = INIT_RATE_WB; - } - else - { - MinRate = INIT_RATE_SWB; - } - } - else - { - MinRate = 0; - } - } - else - { - /* handle burst */ - if (State->BurstCounter) - { - if (State->StillBuffered < (1.0 - 1.0/BURST_LEN) * DelayBuildUp) - { - /* max bps derived from BottleNeck and DelayBuildUp values */ - MinRate = (1.0 + (FS/1000) * DelayBuildUp / - (double)(BURST_LEN * FrameSamples)) * BottleNeck; - } - else - { - // max bps derived from StillBuffered and DelayBuildUp - // values - MinRate = (1.0 + (FS/1000) * (DelayBuildUp - - State->StillBuffered) / (double)FrameSamples) * BottleNeck; - if (MinRate < 1.04 * BottleNeck) - { - MinRate = 1.04 * BottleNeck; - } - } - State->BurstCounter--; - } - } - - - /* convert rate from bits/second to bytes/packet */ - MinBytes = (int) (MinRate * FrameSamples / (8.0 * FS)); - - /* StreamSize will be adjusted if less than MinBytes */ - if (StreamSize < MinBytes) - { - StreamSize = MinBytes; - } - - /* keep track of when bottle neck was last exceeded by at least 1% */ - if (StreamSize * 8.0 * FS / FrameSamples > 1.01 * BottleNeck) { - if (State->PrevExceed) { - /* bottle_neck exceded twice in a row, decrease ExceedAgo */ - State->ExceedAgo -= /*BURST_INTERVAL*/ burstInterval / (BURST_LEN - 1); - if (State->ExceedAgo < 0) - State->ExceedAgo = 0; - } - else - { - State->ExceedAgo += (FrameSamples * 1000) / FS; /* ms */ - State->PrevExceed = 1; - } - } - else - { - State->PrevExceed = 0; - State->ExceedAgo += (FrameSamples * 1000) / FS; /* ms */ - } - - /* set burst flag if bottle neck not exceeded for long time */ - if ((State->ExceedAgo > burstInterval) && - (State->BurstCounter == 0)) - { - if (State->PrevExceed) - { - State->BurstCounter = BURST_LEN - 1; - } - else - { - State->BurstCounter = BURST_LEN; - } - } - - - /* Update buffer delay */ - TransmissionTime = StreamSize * 8.0 * 1000.0 / BottleNeck; /* ms */ - State->StillBuffered += TransmissionTime; - State->StillBuffered -= (FrameSamples * 1000) / FS; /* ms */ - if (State->StillBuffered < 0.0) - { - State->StillBuffered = 0.0; - } - - return MinBytes; -} - - -/* - * update long-term average bitrate and amount of data in buffer - */ -void WebRtcIsac_UpdateRateModel( - RateModel *State, - int StreamSize, /* bytes in bitstream */ - const int FrameSamples, /* samples per frame */ - const double BottleNeck) /* bottle neck rate; excl headers (bps) */ -{ - double TransmissionTime; - - /* avoid the initial "high-rate" burst */ - State->InitCounter = 0; - - /* Update buffer delay */ - TransmissionTime = StreamSize * 8.0 * 1000.0 / BottleNeck; /* ms */ - State->StillBuffered += TransmissionTime; - State->StillBuffered -= (FrameSamples * 1000) / FS; /* ms */ - if (State->StillBuffered < 0.0) - State->StillBuffered = 0.0; - -} - - -void WebRtcIsac_InitRateModel( - RateModel *State) -{ - State->PrevExceed = 0; /* boolean */ - State->ExceedAgo = 0; /* ms */ - State->BurstCounter = 0; /* packets */ - State->InitCounter = INIT_BURST_LEN + 10; /* packets */ - State->StillBuffered = 1.0; /* ms */ -} - -int WebRtcIsac_GetNewFrameLength( - double bottle_neck, - int current_framesamples) -{ - int new_framesamples; - - const int Thld_20_30 = 20000; - - //const int Thld_30_20 = 30000; - const int Thld_30_20 = 1000000; // disable 20 ms frames - - const int Thld_30_60 = 18000; - //const int Thld_30_60 = 0; // disable 60 ms frames - - const int Thld_60_30 = 27000; - - - new_framesamples = current_framesamples; - - /* find new framelength */ - switch(current_framesamples) { - case 320: - if (bottle_neck < Thld_20_30) - new_framesamples = 480; - break; - case 480: - if (bottle_neck < Thld_30_60) - new_framesamples = 960; - else if (bottle_neck > Thld_30_20) - new_framesamples = 320; - break; - case 960: - if (bottle_neck >= Thld_60_30) - new_framesamples = 480; - break; - } - - return new_framesamples; -} - -double WebRtcIsac_GetSnr( - double bottle_neck, - int framesamples) -{ - double s2nr; - - const double a_20 = -30.0; - const double b_20 = 0.8; - const double c_20 = 0.0; - - const double a_30 = -23.0; - const double b_30 = 0.48; - const double c_30 = 0.0; - - const double a_60 = -23.0; - const double b_60 = 0.53; - const double c_60 = 0.0; - - - /* find new SNR value */ - switch(framesamples) { - case 320: - s2nr = a_20 + b_20 * bottle_neck * 0.001 + c_20 * bottle_neck * - bottle_neck * 0.000001; - break; - case 480: - s2nr = a_30 + b_30 * bottle_neck * 0.001 + c_30 * bottle_neck * - bottle_neck * 0.000001; - break; - case 960: - s2nr = a_60 + b_60 * bottle_neck * 0.001 + c_60 * bottle_neck * - bottle_neck * 0.000001; - break; - default: - s2nr = 0; - } - - return s2nr; - -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h b/src/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h deleted file mode 100644 index 5604d7b..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h +++ /dev/null
@@ -1,177 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * bandwidth_estimator.h - * - * This header file contains the API for the Bandwidth Estimator - * designed for iSAC. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ - -#include "structs.h" -#include "settings.h" - - -#define MIN_ISAC_BW 10000 -#define MIN_ISAC_BW_LB 10000 -#define MIN_ISAC_BW_UB 25000 - -#define MAX_ISAC_BW 56000 -#define MAX_ISAC_BW_UB 32000 -#define MAX_ISAC_BW_LB 32000 - -#define MIN_ISAC_MD 5 -#define MAX_ISAC_MD 25 - -// assumed header size, in bytes; we don't know the exact number -// (header compression may be used) -#define HEADER_SIZE 35 - -// Initial Frame-Size, in ms, for Wideband & Super-Wideband Mode -#define INIT_FRAME_LEN_WB 60 -#define INIT_FRAME_LEN_SWB 30 - -// Initial Bottleneck Estimate, in bits/sec, for -// Wideband & Super-wideband mode -#define INIT_BN_EST_WB 20e3f -#define INIT_BN_EST_SWB 56e3f - -// Initial Header rate (header rate depends on frame-size), -// in bits/sec, for Wideband & Super-Wideband mode. -#define INIT_HDR_RATE_WB \ - ((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_WB) -#define INIT_HDR_RATE_SWB \ - ((float)HEADER_SIZE * 8.0f * 1000.0f / (float)INIT_FRAME_LEN_SWB) - -// number of packets in a row for a high rate burst -#define BURST_LEN 3 - -// ms, max time between two full bursts -#define BURST_INTERVAL 500 - -// number of packets in a row for initial high rate burst -#define INIT_BURST_LEN 5 - -// bits/s, rate for the first BURST_LEN packets -#define INIT_RATE_WB INIT_BN_EST_WB -#define INIT_RATE_SWB INIT_BN_EST_SWB - - -#if defined(__cplusplus) -extern "C" { -#endif - - /* This function initializes the struct */ - /* to be called before using the struct for anything else */ - /* returns 0 if everything went fine, -1 otherwise */ - WebRtc_Word32 WebRtcIsac_InitBandwidthEstimator( - BwEstimatorstr* bwest_str, - enum IsacSamplingRate encoderSampRate, - enum IsacSamplingRate decoderSampRate); - - /* This function updates the receiving estimate */ - /* Parameters: */ - /* rtp_number - value from RTP packet, from NetEq */ - /* frame length - length of signal frame in ms, from iSAC decoder */ - /* send_ts - value in RTP header giving send time in samples */ - /* arr_ts - value given by timeGetTime() time of arrival in samples of packet from NetEq */ - /* pksize - size of packet in bytes, from NetEq */ - /* Index - integer (range 0...23) indicating bottle neck & jitter as estimated by other side */ - /* returns 0 if everything went fine, -1 otherwise */ - WebRtc_Word16 WebRtcIsac_UpdateBandwidthEstimator( - BwEstimatorstr* bwest_str, - const WebRtc_UWord16 rtp_number, - const WebRtc_Word32 frame_length, - const WebRtc_UWord32 send_ts, - const WebRtc_UWord32 arr_ts, - const WebRtc_Word32 pksize); - - /* Update receiving estimates. Used when we only receive BWE index, no iSAC data packet. */ - WebRtc_Word16 WebRtcIsac_UpdateUplinkBwImpl( - BwEstimatorstr* bwest_str, - WebRtc_Word16 Index, - enum IsacSamplingRate encoderSamplingFreq); - - /* Returns the bandwidth/jitter estimation code (integer 0...23) to put in the sending iSAC payload */ - WebRtc_UWord16 WebRtcIsac_GetDownlinkBwJitIndexImpl( - BwEstimatorstr* bwest_str, - WebRtc_Word16* bottleneckIndex, - WebRtc_Word16* jitterInfo, - enum IsacSamplingRate decoderSamplingFreq); - - /* Returns the bandwidth estimation (in bps) */ - WebRtc_Word32 WebRtcIsac_GetDownlinkBandwidth( - const BwEstimatorstr *bwest_str); - - /* Returns the max delay (in ms) */ - WebRtc_Word32 WebRtcIsac_GetDownlinkMaxDelay( - const BwEstimatorstr *bwest_str); - - /* Returns the bandwidth that iSAC should send with in bps */ - void WebRtcIsac_GetUplinkBandwidth( - const BwEstimatorstr* bwest_str, - WebRtc_Word32* bitRate); - - /* Returns the max delay value from the other side in ms */ - WebRtc_Word32 WebRtcIsac_GetUplinkMaxDelay( - const BwEstimatorstr *bwest_str); - - - /* - * update amount of data in bottle neck buffer and burst handling - * returns minimum payload size (bytes) - */ - int WebRtcIsac_GetMinBytes( - RateModel* State, - int StreamSize, /* bytes in bitstream */ - const int FrameLen, /* ms per frame */ - const double BottleNeck, /* bottle neck rate; excl headers (bps) */ - const double DelayBuildUp, /* max delay from bottleneck buffering (ms) */ - enum ISACBandwidth bandwidth - /*,WebRtc_Word16 frequentLargePackets*/); - - /* - * update long-term average bitrate and amount of data in buffer - */ - void WebRtcIsac_UpdateRateModel( - RateModel* State, - int StreamSize, /* bytes in bitstream */ - const int FrameSamples, /* samples per frame */ - const double BottleNeck); /* bottle neck rate; excl headers (bps) */ - - - void WebRtcIsac_InitRateModel( - RateModel *State); - - /* Returns the new framelength value (input argument: bottle_neck) */ - int WebRtcIsac_GetNewFrameLength( - double bottle_neck, - int current_framelength); - - /* Returns the new SNR value (input argument: bottle_neck) */ - double WebRtcIsac_GetSnr( - double bottle_neck, - int new_framelength); - - - WebRtc_Word16 WebRtcIsac_UpdateUplinkJitter( - BwEstimatorstr* bwest_str, - WebRtc_Word32 index); - -#if defined(__cplusplus) -} -#endif - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_BANDWIDTH_ESTIMATOR_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/codec.h b/src/modules/audio_coding/codecs/isac/main/source/codec.h deleted file mode 100644 index 0b4d862..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/codec.h +++ /dev/null
@@ -1,217 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * codec.h - * - * This header file contains the calls to the internal encoder - * and decoder functions. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CODEC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CODEC_H_ - -#include "structs.h" - - -void WebRtcIsac_ResetBitstream(Bitstr* bit_stream); - -int WebRtcIsac_EstimateBandwidth(BwEstimatorstr* bwest_str, Bitstr* streamdata, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, WebRtc_UWord32 arr_ts, - enum IsacSamplingRate encoderSampRate, - enum IsacSamplingRate decoderSampRate); - -int WebRtcIsac_DecodeLb(float* signal_out, ISACLBDecStruct* ISACdec_obj, - WebRtc_Word16* current_framesamples, - WebRtc_Word16 isRCUPayload); - -int WebRtcIsac_DecodeRcuLb(float* signal_out, ISACLBDecStruct* ISACdec_obj, - WebRtc_Word16* current_framesamples); - -int WebRtcIsac_EncodeLb(float* in, ISACLBEncStruct* ISACencLB_obj, - WebRtc_Word16 codingMode, WebRtc_Word16 - bottleneckIndex); - -int WebRtcIsac_EncodeStoredDataLb(const ISAC_SaveEncData_t* ISACSavedEnc_obj, - Bitstr* ISACBitStr_obj, int BWnumber, - float scale); - -int WebRtcIsac_EncodeStoredDataUb( - const ISACUBSaveEncDataStruct* ISACSavedEnc_obj, Bitstr* bitStream, - WebRtc_Word32 jitterInfo, float scale, enum ISACBandwidth bandwidth); - -WebRtc_Word16 WebRtcIsac_GetRedPayloadUb( - const ISACUBSaveEncDataStruct* ISACSavedEncObj, Bitstr* bitStreamObj, - enum ISACBandwidth bandwidth); - -/****************************************************************************** - * WebRtcIsac_RateAllocation() - * Internal function to perform a rate-allocation for upper and lower-band, - * given a total rate. - * - * Input: - * - inRateBitPerSec : a total bit-rate in bits/sec. - * - * Output: - * - rateLBBitPerSec : a bit-rate allocated to the lower-band - * in bits/sec. - * - rateUBBitPerSec : a bit-rate allocated to the upper-band - * in bits/sec. - * - * Return value : 0 if rate allocation has been successful. - * -1 if failed to allocate rates. - */ - -WebRtc_Word16 WebRtcIsac_RateAllocation(WebRtc_Word32 inRateBitPerSec, - double* rateLBBitPerSec, - double* rateUBBitPerSec, - enum ISACBandwidth* bandwidthKHz); - - -/****************************************************************************** - * WebRtcIsac_DecodeUb16() - * - * Decode the upper-band if the codec is in 0-16 kHz mode. - * - * Input/Output: - * -ISACdec_obj : pointer to the upper-band decoder object. The - * bit-stream is stored inside the decoder object. - * - * Output: - * -signal_out : decoded audio, 480 samples 30 ms. - * - * Return value : >0 number of decoded bytes. - * <0 if an error occurred. - */ -int WebRtcIsac_DecodeUb16(float* signal_out, ISACUBDecStruct* ISACdec_obj, - WebRtc_Word16 isRCUPayload); - - -/****************************************************************************** - * WebRtcIsac_DecodeUb12() - * - * Decode the upper-band if the codec is in 0-12 kHz mode. - * - * Input/Output: - * -ISACdec_obj : pointer to the upper-band decoder object. The - * bit-stream is stored inside the decoder object. - * - * Output: - * -signal_out : decoded audio, 480 samples 30 ms. - * - * Return value : >0 number of decoded bytes. - * <0 if an error occurred. - */ -int WebRtcIsac_DecodeUb12(float* signal_out, ISACUBDecStruct* ISACdec_obj, - WebRtc_Word16 isRCUPayload); - - -/****************************************************************************** - * WebRtcIsac_EncodeUb16() - * - * Encode the upper-band if the codec is in 0-16 kHz mode. - * - * Input: - * -in : upper-band audio, 160 samples (10 ms). - * - * Input/Output: - * -ISACdec_obj : pointer to the upper-band encoder object. The - * bit-stream is stored inside the encoder object. - * - * Return value : >0 number of encoded bytes. - * <0 if an error occurred. - */ -int WebRtcIsac_EncodeUb16(float* in, ISACUBEncStruct* ISACenc_obj, - WebRtc_Word32 jitterInfo); - - -/****************************************************************************** - * WebRtcIsac_EncodeUb12() - * - * Encode the upper-band if the codec is in 0-12 kHz mode. - * - * Input: - * -in : upper-band audio, 160 samples (10 ms). - * - * Input/Output: - * -ISACdec_obj : pointer to the upper-band encoder object. The - * bit-stream is stored inside the encoder object. - * - * Return value : >0 number of encoded bytes. - * <0 if an error occurred. - */ -int WebRtcIsac_EncodeUb12(float* in, ISACUBEncStruct* ISACenc_obj, - WebRtc_Word32 jitterInfo); - -/************************** initialization functions *************************/ - -void WebRtcIsac_InitMasking(MaskFiltstr* maskdata); - -void WebRtcIsac_InitPreFilterbank(PreFiltBankstr* prefiltdata); - -void WebRtcIsac_InitPostFilterbank(PostFiltBankstr* postfiltdata); - -void WebRtcIsac_InitPitchFilter(PitchFiltstr* pitchfiltdata); - -void WebRtcIsac_InitPitchAnalysis(PitchAnalysisStruct* State); - - -/**************************** transform functions ****************************/ - -void WebRtcIsac_InitTransform(); - -void WebRtcIsac_Time2Spec(double* inre1, double* inre2, WebRtc_Word16* outre, - WebRtc_Word16* outim, FFTstr* fftstr_obj); - -void WebRtcIsac_Spec2time(double* inre, double* inim, double* outre1, - double* outre2, FFTstr* fftstr_obj); - - -/******************************* filter functions ****************************/ - -void WebRtcIsac_AllPoleFilter(double* InOut, double* Coef, int lengthInOut, - int orderCoef); - -void WebRtcIsac_AllZeroFilter(double* In, double* Coef, int lengthInOut, - int orderCoef, double* Out); - -void WebRtcIsac_ZeroPoleFilter(double* In, double* ZeroCoef, double* PoleCoef, - int lengthInOut, int orderCoef, double* Out); - - -/***************************** filterbank functions **************************/ - -void WebRtcIsac_SplitAndFilterFloat(float* in, float* LP, float* HP, - double* LP_la, double* HP_la, - PreFiltBankstr* prefiltdata); - - -void WebRtcIsac_FilterAndCombineFloat(float* InLP, float* InHP, float* Out, - PostFiltBankstr* postfiltdata); - - -/************************* normalized lattice filters ************************/ - -void WebRtcIsac_NormLatticeFilterMa(int orderCoef, float* stateF, float* stateG, - float* lat_in, double* filtcoeflo, - double* lat_out); - -void WebRtcIsac_NormLatticeFilterAr(int orderCoef, float* stateF, float* stateG, - double* lat_in, double* lo_filt_coef, - float* lat_out); - -void WebRtcIsac_Dir2Lat(double* a, int orderCoef, float* sth, float* cth); - -void WebRtcIsac_AutoCorr(double* r, const double* x, int N, int order); - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CODEC_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/crc.c b/src/modules/audio_coding/codecs/isac/main/source/crc.c deleted file mode 100644 index 098e4b7..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/crc.c +++ /dev/null
@@ -1,110 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "crc.h" -#include <stdlib.h> -#include "signal_processing_library.h" - -#define POLYNOMIAL 0x04c11db7L - - -static const WebRtc_UWord32 kCrcTable[256] = { - 0, 0x4c11db7, 0x9823b6e, 0xd4326d9, 0x130476dc, 0x17c56b6b, - 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, - 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, - 0x709f7b7a, 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58, 0xbaea46ef, - 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, - 0xceb42022, 0xca753d95, 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0, - 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x18aeb13, 0x54bf6a4, - 0x808d07d, 0xcc9cdca, 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, - 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, - 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, 0xe0b41de7, 0xe4750050, - 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, - 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, 0x4f040d56, 0x4bc510e1, - 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, - 0x3f9b762c, 0x3b5a6b9b, 0x315d626, 0x7d4cb91, 0xa97ed48, 0xe56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e, 0xf5ee4bb9, - 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, - 0xcda1f604, 0xc960ebb3, 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71, - 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, - 0x470cdd2b, 0x43cdc09c, 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, - 0x18197087, 0x1cd86d30, 0x29f3d35, 0x65e2082, 0xb1d065b, 0xfdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, - 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, 0xe3a1cbc1, 0xe760d676, - 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, - 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 -}; - - - - -/**************************************************************************** - * WebRtcIsac_GetCrc(...) - * - * This function returns a 32 bit CRC checksum of a bit stream - * - * Input: - * - bitstream : payload bitstream - * - len_bitstream_in_bytes : number of 8-bit words in the bit stream - * - * Output: - * - crc : checksum - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsac_GetCrc(const WebRtc_Word16* bitstream, - WebRtc_Word16 len_bitstream_in_bytes, - WebRtc_UWord32* crc) -{ - WebRtc_UWord8* bitstream_ptr_uw8; - WebRtc_UWord32 crc_state; - int byte_cntr; - int crc_tbl_indx; - - /* Sanity Check. */ - if (bitstream == NULL) { - return -1; - } - /* cast to UWord8 pointer */ - bitstream_ptr_uw8 = (WebRtc_UWord8 *)bitstream; - - /* initialize */ - crc_state = 0xFFFFFFFF; - - for (byte_cntr = 0; byte_cntr < len_bitstream_in_bytes; byte_cntr++) { - crc_tbl_indx = (WEBRTC_SPL_RSHIFT_U32(crc_state, 24) ^ - bitstream_ptr_uw8[byte_cntr]) & 0xFF; - crc_state = WEBRTC_SPL_LSHIFT_U32(crc_state, 8) ^ kCrcTable[crc_tbl_indx]; - } - - *crc = ~crc_state; - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/crc.h b/src/modules/audio_coding/codecs/isac/main/source/crc.h deleted file mode 100644 index 0151278..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/crc.h +++ /dev/null
@@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * crc.h - * - * Checksum functions - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ - -#include "typedefs.h" - -/**************************************************************************** - * WebRtcIsac_GetCrc(...) - * - * This function returns a 32 bit CRC checksum of a bit stream - * - * Input: - * - encoded : payload bit stream - * - no_of_word8s : number of 8-bit words in the bit stream - * - * Output: - * - crc : checksum - * - * Return value : 0 - Ok - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsac_GetCrc( - const WebRtc_Word16* encoded, - WebRtc_Word16 no_of_word8s, - WebRtc_UWord32* crc); - - - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_CRC_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/decode.c b/src/modules/audio_coding/codecs/isac/main/source/decode.c deleted file mode 100644 index 2b06cd0..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/decode.c +++ /dev/null
@@ -1,299 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * decode_B.c - * - * This file contains definition of funtions for decoding. - * Decoding of lower-band, including normal-decoding and RCU decoding. - * Decoding of upper-band, including 8-12 kHz, when the bandwidth is - * 0-12 kHz, and 8-16 kHz, when the bandwidth is 0-16 kHz. - * - */ - - -#include "codec.h" -#include "entropy_coding.h" -#include "pitch_estimator.h" -#include "bandwidth_estimator.h" -#include "structs.h" -#include "settings.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - - -/* - * function to decode the bitstream - * returns the total number of bytes in the stream - */ -int WebRtcIsac_DecodeLb(float* signal_out, ISACLBDecStruct* ISACdecLB_obj, - WebRtc_Word16* current_framesamples, - WebRtc_Word16 isRCUPayload) { - int k; - int len, err; - WebRtc_Word16 bandwidthInd; - - float LP_dec_float[FRAMESAMPLES_HALF]; - float HP_dec_float[FRAMESAMPLES_HALF]; - - double LPw[FRAMESAMPLES_HALF]; - double HPw[FRAMESAMPLES_HALF]; - double LPw_pf[FRAMESAMPLES_HALF]; - - double lo_filt_coef[(ORDERLO + 1)*SUBFRAMES]; - double hi_filt_coef[(ORDERHI + 1)*SUBFRAMES]; - - double real_f[FRAMESAMPLES_HALF]; - double imag_f[FRAMESAMPLES_HALF]; - - double PitchLags[4]; - double PitchGains[4]; - double AvgPitchGain; - WebRtc_Word16 PitchGains_Q12[4]; - WebRtc_Word16 AvgPitchGain_Q12; - - float gain; - - int frame_nb; /* counter */ - int frame_mode; /* 0 30ms, 1 for 60ms */ - /* Processed_samples: 480 (30, 60 ms). Cannot take other values. */ - - WebRtcIsac_ResetBitstream(&(ISACdecLB_obj->bitstr_obj)); - - len = 0; - - /* Decode framelength and BW estimation - not used, - only for stream pointer*/ - err = WebRtcIsac_DecodeFrameLen(&ISACdecLB_obj->bitstr_obj, - current_framesamples); - if (err < 0) { - return err; - } - - /* Frame_mode: - * 0: indicates 30 ms frame (480 samples) - * 1: indicates 60 ms frame (960 samples) */ - frame_mode = *current_framesamples / MAX_FRAMESAMPLES; - - err = WebRtcIsac_DecodeSendBW(&ISACdecLB_obj->bitstr_obj, &bandwidthInd); - if (err < 0) { - return err; - } - - /* One loop if it's one frame (20 or 30ms), 2 loops if 2 frames - bundled together (60ms). */ - for (frame_nb = 0; frame_nb <= frame_mode; frame_nb++) { - /* Decode & de-quantize pitch parameters */ - err = WebRtcIsac_DecodePitchGain(&ISACdecLB_obj->bitstr_obj, - PitchGains_Q12); - if (err < 0) { - return err; - } - - err = WebRtcIsac_DecodePitchLag(&ISACdecLB_obj->bitstr_obj, PitchGains_Q12, - PitchLags); - if (err < 0) { - return err; - } - - AvgPitchGain_Q12 = (PitchGains_Q12[0] + PitchGains_Q12[1] + - PitchGains_Q12[2] + PitchGains_Q12[3]) >> 2; - - /* Decode & de-quantize filter coefficients. */ - err = WebRtcIsac_DecodeLpc(&ISACdecLB_obj->bitstr_obj, lo_filt_coef, - hi_filt_coef); - if (err < 0) { - return err; - } - /* Decode & de-quantize spectrum. */ - len = WebRtcIsac_DecodeSpec(&ISACdecLB_obj->bitstr_obj, AvgPitchGain_Q12, - kIsacLowerBand, real_f, imag_f); - if (len < 0) { - return len; - } - - /* Inverse transform. */ - WebRtcIsac_Spec2time(real_f, imag_f, LPw, HPw, - &ISACdecLB_obj->fftstr_obj); - - /* Convert PitchGains back to float for pitchfilter_post */ - for (k = 0; k < 4; k++) { - PitchGains[k] = ((float)PitchGains_Q12[k]) / 4096; - } - if (isRCUPayload) { - for (k = 0; k < 240; k++) { - LPw[k] *= RCU_TRANSCODING_SCALE_INVERSE; - HPw[k] *= RCU_TRANSCODING_SCALE_INVERSE; - } - } - - /* Inverse pitch filter. */ - WebRtcIsac_PitchfilterPost(LPw, LPw_pf, &ISACdecLB_obj->pitchfiltstr_obj, - PitchLags, PitchGains); - /* Convert AvgPitchGain back to float for computation of gain. */ - AvgPitchGain = ((float)AvgPitchGain_Q12) / 4096; - gain = 1.0f - 0.45f * (float)AvgPitchGain; - - for (k = 0; k < FRAMESAMPLES_HALF; k++) { - /* Reduce gain to compensate for pitch enhancer. */ - LPw_pf[k] *= gain; - } - - if (isRCUPayload) { - for (k = 0; k < FRAMESAMPLES_HALF; k++) { - /* Compensation for transcoding gain changes. */ - LPw_pf[k] *= RCU_TRANSCODING_SCALE; - HPw[k] *= RCU_TRANSCODING_SCALE; - } - } - /* Perceptual post-filtering (using normalized lattice filter). */ - WebRtcIsac_NormLatticeFilterAr( - ORDERLO, ISACdecLB_obj->maskfiltstr_obj.PostStateLoF, - (ISACdecLB_obj->maskfiltstr_obj).PostStateLoG, LPw_pf, lo_filt_coef, - LP_dec_float); - WebRtcIsac_NormLatticeFilterAr( - ORDERHI, ISACdecLB_obj->maskfiltstr_obj.PostStateHiF, - (ISACdecLB_obj->maskfiltstr_obj).PostStateHiG, HPw, hi_filt_coef, - HP_dec_float); - - /* Recombine the 2 bands. */ - WebRtcIsac_FilterAndCombineFloat(LP_dec_float, HP_dec_float, - signal_out + frame_nb * FRAMESAMPLES, - &ISACdecLB_obj->postfiltbankstr_obj); - } - return len; -} - - -/* - * This decode function is called when the codec is operating in 16 kHz - * bandwidth to decode the upperband, i.e. 8-16 kHz. - * - * Contrary to lower-band, the upper-band (8-16 kHz) is not split in - * frequency, but split to 12 sub-frames, i.e. twice as lower-band. - */ -int WebRtcIsac_DecodeUb16(float* signal_out, ISACUBDecStruct* ISACdecUB_obj, - WebRtc_Word16 isRCUPayload) { - int len, err; - - double halfFrameFirst[FRAMESAMPLES_HALF]; - double halfFrameSecond[FRAMESAMPLES_HALF]; - - double percepFilterParam[(UB_LPC_ORDER + 1) * (SUBFRAMES << 1) + - (UB_LPC_ORDER + 1)]; - - double real_f[FRAMESAMPLES_HALF]; - double imag_f[FRAMESAMPLES_HALF]; - const WebRtc_Word16 kAveragePitchGain = 0; /* No pitch-gain for upper-band. */ - len = 0; - - /* Decode & de-quantize filter coefficients. */ - memset(percepFilterParam, 0, sizeof(percepFilterParam)); - err = WebRtcIsac_DecodeInterpolLpcUb(&ISACdecUB_obj->bitstr_obj, - percepFilterParam, isac16kHz); - if (err < 0) { - return err; - } - - /* Decode & de-quantize spectrum. */ - len = WebRtcIsac_DecodeSpec(&ISACdecUB_obj->bitstr_obj, kAveragePitchGain, - kIsacUpperBand16, real_f, imag_f); - if (len < 0) { - return len; - } - if (isRCUPayload) { - int n; - for (n = 0; n < 240; n++) { - real_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; - imag_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; - } - } - /* Inverse transform. */ - WebRtcIsac_Spec2time(real_f, imag_f, halfFrameFirst, halfFrameSecond, - &ISACdecUB_obj->fftstr_obj); - - /* Perceptual post-filtering (using normalized lattice filter). */ - WebRtcIsac_NormLatticeFilterAr( - UB_LPC_ORDER, ISACdecUB_obj->maskfiltstr_obj.PostStateLoF, - (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, halfFrameFirst, - &percepFilterParam[(UB_LPC_ORDER + 1)], signal_out); - - WebRtcIsac_NormLatticeFilterAr( - UB_LPC_ORDER, ISACdecUB_obj->maskfiltstr_obj.PostStateLoF, - (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, halfFrameSecond, - &percepFilterParam[(UB_LPC_ORDER + 1) * SUBFRAMES + (UB_LPC_ORDER + 1)], - &signal_out[FRAMESAMPLES_HALF]); - - return len; -} - -/* - * This decode function is called when the codec operates at 0-12 kHz - * bandwidth to decode the upperband, i.e. 8-12 kHz. - * - * At the encoder the upper-band is split into two band, 8-12 kHz & 12-16 - * kHz, and only 8-12 kHz is encoded. At the decoder, 8-12 kHz band is - * reconstructed and 12-16 kHz replaced with zeros. Then two bands - * are combined, to reconstruct the upperband 8-16 kHz. - */ -int WebRtcIsac_DecodeUb12(float* signal_out, ISACUBDecStruct* ISACdecUB_obj, - WebRtc_Word16 isRCUPayload) { - int len, err; - - float LP_dec_float[FRAMESAMPLES_HALF]; - float HP_dec_float[FRAMESAMPLES_HALF]; - - double LPw[FRAMESAMPLES_HALF]; - double HPw[FRAMESAMPLES_HALF]; - - double percepFilterParam[(UB_LPC_ORDER + 1)*SUBFRAMES]; - - double real_f[FRAMESAMPLES_HALF]; - double imag_f[FRAMESAMPLES_HALF]; - const WebRtc_Word16 kAveragePitchGain = 0; /* No pitch-gain for upper-band. */ - len = 0; - - /* Decode & dequantize filter coefficients. */ - err = WebRtcIsac_DecodeInterpolLpcUb(&ISACdecUB_obj->bitstr_obj, - percepFilterParam, isac12kHz); - if (err < 0) { - return err; - } - - /* Decode & de-quantize spectrum. */ - len = WebRtcIsac_DecodeSpec(&ISACdecUB_obj->bitstr_obj, kAveragePitchGain, - kIsacUpperBand12, real_f, imag_f); - if (len < 0) { - return len; - } - - if (isRCUPayload) { - int n; - for (n = 0; n < 240; n++) { - real_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; - imag_f[n] *= RCU_TRANSCODING_SCALE_UB_INVERSE; - } - } - /* Inverse transform. */ - WebRtcIsac_Spec2time(real_f, imag_f, LPw, HPw, &ISACdecUB_obj->fftstr_obj); - /* perceptual post-filtering (using normalized lattice filter) */ - WebRtcIsac_NormLatticeFilterAr(UB_LPC_ORDER, - ISACdecUB_obj->maskfiltstr_obj.PostStateLoF, - (ISACdecUB_obj->maskfiltstr_obj).PostStateLoG, - LPw, percepFilterParam, LP_dec_float); - /* Zero for 12-16 kHz. */ - memset(HP_dec_float, 0, sizeof(float) * (FRAMESAMPLES_HALF)); - /* Recombine the 2 bands. */ - WebRtcIsac_FilterAndCombineFloat(HP_dec_float, LP_dec_float, signal_out, - &ISACdecUB_obj->postfiltbankstr_obj); - return len; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/decode_bwe.c b/src/modules/audio_coding/codecs/isac/main/source/decode_bwe.c deleted file mode 100644 index cdac7fa..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/decode_bwe.c +++ /dev/null
@@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "structs.h" -#include "bandwidth_estimator.h" -#include "entropy_coding.h" -#include "codec.h" - - -int -WebRtcIsac_EstimateBandwidth( - BwEstimatorstr* bwest_str, - Bitstr* streamdata, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts, - enum IsacSamplingRate encoderSampRate, - enum IsacSamplingRate decoderSampRate) -{ - WebRtc_Word16 index; - WebRtc_Word16 frame_samples; - WebRtc_UWord32 sendTimestampIn16kHz; - WebRtc_UWord32 arrivalTimestampIn16kHz; - WebRtc_UWord32 diffSendTime; - WebRtc_UWord32 diffArrivalTime; - int err; - - /* decode framelength and BW estimation */ - err = WebRtcIsac_DecodeFrameLen(streamdata, &frame_samples); - if(err < 0) // error check - { - return err; - } - err = WebRtcIsac_DecodeSendBW(streamdata, &index); - if(err < 0) // error check - { - return err; - } - - /* UPDATE ESTIMATES FROM OTHER SIDE */ - err = WebRtcIsac_UpdateUplinkBwImpl(bwest_str, index, encoderSampRate); - if(err < 0) - { - return err; - } - - // We like BWE to work at 16 kHz sampling rate, - // therefore, we have to change the timestamps accordingly. - // translate the send timestamp if required - diffSendTime = (WebRtc_UWord32)((WebRtc_UWord32)send_ts - - (WebRtc_UWord32)bwest_str->senderTimestamp); - bwest_str->senderTimestamp = send_ts; - - diffArrivalTime = (WebRtc_UWord32)((WebRtc_UWord32)arr_ts - - (WebRtc_UWord32)bwest_str->receiverTimestamp); - bwest_str->receiverTimestamp = arr_ts; - - if(decoderSampRate == kIsacSuperWideband) - { - diffArrivalTime = (WebRtc_UWord32)diffArrivalTime >> 1; - diffSendTime = (WebRtc_UWord32)diffSendTime >> 1; - } - // arrival timestamp in 16 kHz - arrivalTimestampIn16kHz = (WebRtc_UWord32)((WebRtc_UWord32) - bwest_str->prev_rec_arr_ts + (WebRtc_UWord32)diffArrivalTime); - // send timestamp in 16 kHz - sendTimestampIn16kHz = (WebRtc_UWord32)((WebRtc_UWord32) - bwest_str->prev_rec_send_ts + (WebRtc_UWord32)diffSendTime); - - err = WebRtcIsac_UpdateBandwidthEstimator(bwest_str, rtp_seq_number, - (frame_samples * 1000) / FS, sendTimestampIn16kHz, - arrivalTimestampIn16kHz, packet_size); - // error check - if(err < 0) - { - return err; - } - - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/encode.c b/src/modules/audio_coding/codecs/isac/main/source/encode.c deleted file mode 100644 index f6bdc17..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/encode.c +++ /dev/null
@@ -1,1252 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * encode.c - * - * This file contains definition of funtions for encoding. - * Decoding of upper-band, including 8-12 kHz, when the bandwidth is - * 0-12 kHz, and 8-16 kHz, when the bandwidth is 0-16 kHz. - * - */ - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> - -#include "structs.h" -#include "codec.h" -#include "pitch_estimator.h" -#include "entropy_coding.h" -#include "arith_routines.h" -#include "pitch_gain_tables.h" -#include "pitch_lag_tables.h" -#include "spectrum_ar_model_tables.h" -#include "lpc_tables.h" -#include "lpc_analysis.h" -#include "bandwidth_estimator.h" -#include "lpc_shape_swb12_tables.h" -#include "lpc_shape_swb16_tables.h" -#include "lpc_gain_swb_tables.h" - - -#define UB_LOOKAHEAD 24 - - -/* - Rate allocation tables of lower and upper-band bottleneck for - 12kHz & 16kHz bandwidth. - - 12 kHz bandwidth - ----------------- - The overall bottleneck of the coder is between 38 kbps and 45 kbps. We have - considered 7 enteries, uniformly distributed in this interval, i.e. 38, - 39.17, 40.33, 41.5, 42.67, 43.83 and 45. For every entery, the lower-band - and the upper-band bottlenecks are specified in - 'kLowerBandBitRate12' and 'kUpperBandBitRate12' - tables, respectively. E.g. the overall rate of 41.5 kbps corresponts to a - bottleneck of 31 kbps for lower-band and 27 kbps for upper-band. Given an - overall bottleneck of the codec, we use linear interpolation to get - lower-band and upper-band bottlenecks. - - 16 kHz bandwidth - ----------------- - The overall bottleneck of the coder is between 50 kbps and 56 kbps. We have - considered 7 enteries, uniformly distributed in this interval, i.e. 50, 51.2, - 52.4, 53.6, 54.8 and 56. For every entery, the lower-band and the upper-band - bottlenecks are specified in 'kLowerBandBitRate16' and - 'kUpperBandBitRate16' tables, respectively. E.g. the overall rate - of 53.6 kbps corresponts to a bottleneck of 32 kbps for lower-band and 30 - kbps for upper-band. Given an overall bottleneck of the codec, we use linear - interpolation to get lower-band and upper-band bottlenecks. - - */ - -/* 38 39.17 40.33 41.5 42.67 43.83 45 */ -static const WebRtc_Word16 kLowerBandBitRate12[7] = { - 29000, 30000, 30000, 31000, 31000, 32000, 32000 }; -static const WebRtc_Word16 kUpperBandBitRate12[7] = { - 25000, 25000, 27000, 27000, 29000, 29000, 32000 }; - -/* 50 51.2 52.4 53.6 54.8 56 */ -static const WebRtc_Word16 kLowerBandBitRate16[6] = { - 31000, 31000, 32000, 32000, 32000, 32000 }; -static const WebRtc_Word16 kUpperBandBitRate16[6] = { - 28000, 29000, 29000, 30000, 31000, 32000 }; - -/****************************************************************************** - * WebRtcIsac_RateAllocation() - * Internal function to perform a rate-allocation for upper and lower-band, - * given a total rate. - * - * Input: - * - inRateBitPerSec : a total bottleneck in bits/sec. - * - * Output: - * - rateLBBitPerSec : a bottleneck allocated to the lower-band - * in bits/sec. - * - rateUBBitPerSec : a bottleneck allocated to the upper-band - * in bits/sec. - * - * Return value : 0 if rate allocation has been successful. - * -1 if failed to allocate rates. - */ - -WebRtc_Word16 WebRtcIsac_RateAllocation(WebRtc_Word32 inRateBitPerSec, - double* rateLBBitPerSec, - double* rateUBBitPerSec, - enum ISACBandwidth* bandwidthKHz) { - WebRtc_Word16 idx; - double idxD; - double idxErr; - if (inRateBitPerSec < 38000) { - /* If the given overall bottleneck is less than 38000 then - * then codec has to operate in wideband mode, i.e. 8 kHz - * bandwidth. */ - *rateLBBitPerSec = (WebRtc_Word16)((inRateBitPerSec > 32000) ? - 32000 : inRateBitPerSec); - *rateUBBitPerSec = 0; - *bandwidthKHz = isac8kHz; - } else if ((inRateBitPerSec >= 38000) && (inRateBitPerSec < 50000)) { - /* At a bottleneck between 38 and 50 kbps the codec is operating - * at 12 kHz bandwidth. Using xxxBandBitRate12[] to calculates - * upper/lower bottleneck */ - - /* Find the bottlenecks by linear interpolation, - * step is (45000 - 38000)/6.0 we use the inverse of it. */ - const double stepSizeInv = 8.5714286e-4; - idxD = (inRateBitPerSec - 38000) * stepSizeInv; - idx = (idxD >= 6) ? 6 : ((WebRtc_Word16)idxD); - idxErr = idxD - idx; - *rateLBBitPerSec = kLowerBandBitRate12[idx]; - *rateUBBitPerSec = kUpperBandBitRate12[idx]; - - if (idx < 6) { - *rateLBBitPerSec += (WebRtc_Word16)( - idxErr * (kLowerBandBitRate12[idx + 1] - kLowerBandBitRate12[idx])); - *rateUBBitPerSec += (WebRtc_Word16)( - idxErr * (kUpperBandBitRate12[idx + 1] - kUpperBandBitRate12[idx])); - } - *bandwidthKHz = isac12kHz; - } else if ((inRateBitPerSec >= 50000) && (inRateBitPerSec <= 56000)) { - /* A bottleneck between 50 and 56 kbps corresponds to bandwidth - * of 16 kHz. Using xxxBandBitRate16[] to calculates - * upper/lower bottleneck. */ - - /* Find the bottlenecks by linear interpolation - * step is (56000 - 50000)/5 we use the inverse of it. */ - const double stepSizeInv = 8.3333333e-4; - idxD = (inRateBitPerSec - 50000) * stepSizeInv; - idx = (idxD >= 5) ? 5 : ((WebRtc_Word16)idxD); - idxErr = idxD - idx; - *rateLBBitPerSec = kLowerBandBitRate16[idx]; - *rateUBBitPerSec = kUpperBandBitRate16[idx]; - - if (idx < 5) { - *rateLBBitPerSec += (WebRtc_Word16)(idxErr * - (kLowerBandBitRate16[idx + 1] - - kLowerBandBitRate16[idx])); - - *rateUBBitPerSec += (WebRtc_Word16)(idxErr * - (kUpperBandBitRate16[idx + 1] - - kUpperBandBitRate16[idx])); - } - *bandwidthKHz = isac16kHz; - } else { - /* Out-of-range botlteneck value. */ - return -1; - } - - /* limit the values. */ - *rateLBBitPerSec = (*rateLBBitPerSec > 32000) ? 32000 : *rateLBBitPerSec; - *rateUBBitPerSec = (*rateUBBitPerSec > 32000) ? 32000 : *rateUBBitPerSec; - return 0; -} - - -void WebRtcIsac_ResetBitstream(Bitstr* bit_stream) { - bit_stream->W_upper = 0xFFFFFFFF; - bit_stream->stream_index = 0; - bit_stream->streamval = 0; -} - -int WebRtcIsac_EncodeLb(float* in, ISACLBEncStruct* ISACencLB_obj, - WebRtc_Word16 codingMode, - WebRtc_Word16 bottleneckIndex) { - int stream_length = 0; - int err; - int k; - int iterCntr; - - double lofilt_coef[(ORDERLO + 1)*SUBFRAMES]; - double hifilt_coef[(ORDERHI + 1)*SUBFRAMES]; - float LP[FRAMESAMPLES_HALF]; - float HP[FRAMESAMPLES_HALF]; - - double LP_lookahead[FRAMESAMPLES_HALF]; - double HP_lookahead[FRAMESAMPLES_HALF]; - double LP_lookahead_pf[FRAMESAMPLES_HALF + QLOOKAHEAD]; - double LPw[FRAMESAMPLES_HALF]; - - double HPw[FRAMESAMPLES_HALF]; - double LPw_pf[FRAMESAMPLES_HALF]; - WebRtc_Word16 fre[FRAMESAMPLES_HALF]; /* Q7 */ - WebRtc_Word16 fim[FRAMESAMPLES_HALF]; /* Q7 */ - - double PitchLags[4]; - double PitchGains[4]; - WebRtc_Word16 PitchGains_Q12[4]; - WebRtc_Word16 AvgPitchGain_Q12; - - int frame_mode; /* 0 for 30ms, 1 for 60ms */ - int status = 0; - int my_index; - transcode_obj transcodingParam; - double bytesLeftSpecCoding; - WebRtc_UWord16 payloadLimitBytes; - - /* Copy new frame-length and bottleneck rate only for the first 10 ms data */ - if (ISACencLB_obj->buffer_index == 0) { - /* Set the framelength for the next packet. */ - ISACencLB_obj->current_framesamples = ISACencLB_obj->new_framelength; - } - /* 'frame_mode' is 0 (30 ms) or 1 (60 ms). */ - frame_mode = ISACencLB_obj->current_framesamples / MAX_FRAMESAMPLES; - - /* buffer speech samples (by 10ms packet) until the frame-length */ - /* is reached (30 or 60 ms). */ - /*****************************************************************/ - - /* fill the buffer with 10ms input data */ - for (k = 0; k < FRAMESAMPLES_10ms; k++) { - ISACencLB_obj->data_buffer_float[k + ISACencLB_obj->buffer_index] = in[k]; - } - - /* If buffersize is not equal to current framesize then increase index - * and return. We do no encoding untill we have enough audio. */ - if (ISACencLB_obj->buffer_index + FRAMESAMPLES_10ms != FRAMESAMPLES) { - ISACencLB_obj->buffer_index += FRAMESAMPLES_10ms; - return 0; - } - /* If buffer reached the right size, reset index and continue with - * encoding the frame. */ - ISACencLB_obj->buffer_index = 0; - - /* End of buffer function. */ - /**************************/ - - /* Encoding */ - /************/ - - if (frame_mode == 0 || ISACencLB_obj->frame_nb == 0) { - /* This is to avoid Linux warnings until we change 'int' to 'Word32' - * at all places. */ - int intVar; - /* reset bitstream */ - WebRtcIsac_ResetBitstream(&(ISACencLB_obj->bitstr_obj)); - - if ((codingMode == 0) && (frame_mode == 0) && - (ISACencLB_obj->enforceFrameSize == 0)) { - ISACencLB_obj->new_framelength = WebRtcIsac_GetNewFrameLength( - ISACencLB_obj->bottleneck, ISACencLB_obj->current_framesamples); - } - - ISACencLB_obj->s2nr = WebRtcIsac_GetSnr( - ISACencLB_obj->bottleneck, ISACencLB_obj->current_framesamples); - - /* Encode frame length. */ - status = WebRtcIsac_EncodeFrameLen( - ISACencLB_obj->current_framesamples, &ISACencLB_obj->bitstr_obj); - if (status < 0) { - /* Wrong frame size. */ - return status; - } - /* Save framelength for multiple packets memory. */ - ISACencLB_obj->SaveEnc_obj.framelength = - ISACencLB_obj->current_framesamples; - - /* To be used for Redundant Coding. */ - ISACencLB_obj->lastBWIdx = bottleneckIndex; - intVar = (int)bottleneckIndex; - WebRtcIsac_EncodeReceiveBw(&intVar, &ISACencLB_obj->bitstr_obj); - } - - /* Split signal in two bands. */ - WebRtcIsac_SplitAndFilterFloat(ISACencLB_obj->data_buffer_float, LP, HP, - LP_lookahead, HP_lookahead, - &ISACencLB_obj->prefiltbankstr_obj); - - /* estimate pitch parameters and pitch-filter lookahead signal */ - WebRtcIsac_PitchAnalysis(LP_lookahead, LP_lookahead_pf, - &ISACencLB_obj->pitchanalysisstr_obj, PitchLags, - PitchGains); - - /* Encode in FIX Q12. */ - - /* Convert PitchGain to Fixed point. */ - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchGains_Q12[k] = (WebRtc_Word16)(PitchGains[k] * 4096.0); - } - - /* Set where to store data in multiple packets memory. */ - if (frame_mode == 0 || ISACencLB_obj->frame_nb == 0) { - ISACencLB_obj->SaveEnc_obj.startIdx = 0; - } else { - ISACencLB_obj->SaveEnc_obj.startIdx = 1; - } - - /* Quantize & encode pitch parameters. */ - WebRtcIsac_EncodePitchGain(PitchGains_Q12, &ISACencLB_obj->bitstr_obj, - &ISACencLB_obj->SaveEnc_obj); - WebRtcIsac_EncodePitchLag(PitchLags, PitchGains_Q12, - &ISACencLB_obj->bitstr_obj, - &ISACencLB_obj->SaveEnc_obj); - - AvgPitchGain_Q12 = (PitchGains_Q12[0] + PitchGains_Q12[1] + - PitchGains_Q12[2] + PitchGains_Q12[3]) >> 2; - - /* Find coefficients for perceptual pre-filters. */ - WebRtcIsac_GetLpcCoefLb(LP_lookahead_pf, HP_lookahead, - &ISACencLB_obj->maskfiltstr_obj, ISACencLB_obj->s2nr, - PitchGains_Q12, lofilt_coef, hifilt_coef); - - /* Code LPC model and shape - gains not quantized yet. */ - WebRtcIsac_EncodeLpcLb(lofilt_coef, hifilt_coef, &ISACencLB_obj->bitstr_obj, - &ISACencLB_obj->SaveEnc_obj); - - /* Convert PitchGains back to FLOAT for pitchfilter_pre. */ - for (k = 0; k < 4; k++) { - PitchGains[k] = ((float)PitchGains_Q12[k]) / 4096; - } - - /* Store the state of arithmetic coder before coding LPC gains. */ - transcodingParam.W_upper = ISACencLB_obj->bitstr_obj.W_upper; - transcodingParam.stream_index = ISACencLB_obj->bitstr_obj.stream_index; - transcodingParam.streamval = ISACencLB_obj->bitstr_obj.streamval; - transcodingParam.stream[0] = - ISACencLB_obj->bitstr_obj.stream[ISACencLB_obj->bitstr_obj.stream_index - - 2]; - transcodingParam.stream[1] = - ISACencLB_obj->bitstr_obj.stream[ISACencLB_obj->bitstr_obj.stream_index - - 1]; - transcodingParam.stream[2] = - ISACencLB_obj->bitstr_obj.stream[ISACencLB_obj->bitstr_obj.stream_index]; - - /* Store LPC Gains before encoding them. */ - for (k = 0; k < SUBFRAMES; k++) { - transcodingParam.loFiltGain[k] = lofilt_coef[(LPC_LOBAND_ORDER + 1) * k]; - transcodingParam.hiFiltGain[k] = hifilt_coef[(LPC_HIBAND_ORDER + 1) * k]; - } - - /* Code gains */ - WebRtcIsac_EncodeLpcGainLb(lofilt_coef, hifilt_coef, - &ISACencLB_obj->bitstr_obj, - &ISACencLB_obj->SaveEnc_obj); - - /* Get the correct value for the payload limit and calculate the - * number of bytes left for coding the spectrum. */ - if ((frame_mode == 1) && (ISACencLB_obj->frame_nb == 0)) { - /* It is a 60ms and we are in the first 30ms then the limit at - * this point should be half of the assigned value. */ - payloadLimitBytes = ISACencLB_obj->payloadLimitBytes60 >> 1; - } else if (frame_mode == 0) { - /* It is a 30ms frame */ - /* Subract 3 because termination process may add 3 bytes. */ - payloadLimitBytes = ISACencLB_obj->payloadLimitBytes30 - 3; - } else { - /* This is the second half of a 60ms frame. */ - /* Subract 3 because termination process may add 3 bytes. */ - payloadLimitBytes = ISACencLB_obj->payloadLimitBytes60 - 3; - } - bytesLeftSpecCoding = payloadLimitBytes - transcodingParam.stream_index; - - /* Perceptual pre-filtering (using normalized lattice filter). */ - /* Low-band filtering. */ - WebRtcIsac_NormLatticeFilterMa(ORDERLO, - ISACencLB_obj->maskfiltstr_obj.PreStateLoF, - ISACencLB_obj->maskfiltstr_obj.PreStateLoG, - LP, lofilt_coef, LPw); - /* High-band filtering. */ - WebRtcIsac_NormLatticeFilterMa(ORDERHI, - ISACencLB_obj->maskfiltstr_obj.PreStateHiF, - ISACencLB_obj->maskfiltstr_obj.PreStateHiG, - HP, hifilt_coef, HPw); - /* Pitch filter. */ - WebRtcIsac_PitchfilterPre(LPw, LPw_pf, &ISACencLB_obj->pitchfiltstr_obj, - PitchLags, PitchGains); - /* Transform */ - WebRtcIsac_Time2Spec(LPw_pf, HPw, fre, fim, &ISACencLB_obj->fftstr_obj); - - /* Save data for multiple packets memory. */ - my_index = ISACencLB_obj->SaveEnc_obj.startIdx * FRAMESAMPLES_HALF; - memcpy(&ISACencLB_obj->SaveEnc_obj.fre[my_index], fre, sizeof(fre)); - memcpy(&ISACencLB_obj->SaveEnc_obj.fim[my_index], fim, sizeof(fim)); - - ISACencLB_obj->SaveEnc_obj.AvgPitchGain[ISACencLB_obj->SaveEnc_obj.startIdx] = - AvgPitchGain_Q12; - - /* Quantization and loss-less coding. */ - err = WebRtcIsac_EncodeSpec(fre, fim, AvgPitchGain_Q12, kIsacLowerBand, - &ISACencLB_obj->bitstr_obj); - if ((err < 0) && (err != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - /* There has been an error but it was not too large payload - (we can cure too large payload). */ - if (frame_mode == 1 && ISACencLB_obj->frame_nb == 1) { - /* If this is the second 30ms of a 60ms frame reset - this such that in the next call encoder starts fresh. */ - ISACencLB_obj->frame_nb = 0; - } - return err; - } - iterCntr = 0; - while ((ISACencLB_obj->bitstr_obj.stream_index > payloadLimitBytes) || - (err == -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - double bytesSpecCoderUsed; - double transcodeScale; - - if (iterCntr >= MAX_PAYLOAD_LIMIT_ITERATION) { - /* We were not able to limit the payload size */ - if ((frame_mode == 1) && (ISACencLB_obj->frame_nb == 0)) { - /* This was the first 30ms of a 60ms frame. Although - the payload is larger than it should be but we let - the second 30ms be encoded. Maybe together we - won't exceed the limit. */ - ISACencLB_obj->frame_nb = 1; - return 0; - } else if ((frame_mode == 1) && (ISACencLB_obj->frame_nb == 1)) { - ISACencLB_obj->frame_nb = 0; - } - - if (err != -ISAC_DISALLOWED_BITSTREAM_LENGTH) { - return -ISAC_PAYLOAD_LARGER_THAN_LIMIT; - } else { - return status; - } - } - - if (err == -ISAC_DISALLOWED_BITSTREAM_LENGTH) { - bytesSpecCoderUsed = STREAM_SIZE_MAX; - /* Being conservative */ - transcodeScale = bytesLeftSpecCoding / bytesSpecCoderUsed * 0.5; - } else { - bytesSpecCoderUsed = ISACencLB_obj->bitstr_obj.stream_index - - transcodingParam.stream_index; - transcodeScale = bytesLeftSpecCoding / bytesSpecCoderUsed; - } - - /* To be safe, we reduce the scale depending on - the number of iterations. */ - transcodeScale *= (1.0 - (0.9 * (double)iterCntr / - (double)MAX_PAYLOAD_LIMIT_ITERATION)); - - /* Scale the LPC Gains. */ - for (k = 0; k < SUBFRAMES; k++) { - lofilt_coef[(LPC_LOBAND_ORDER + 1) * k] = - transcodingParam.loFiltGain[k] * transcodeScale; - hifilt_coef[(LPC_HIBAND_ORDER + 1) * k] = - transcodingParam.hiFiltGain[k] * transcodeScale; - transcodingParam.loFiltGain[k] = lofilt_coef[(LPC_LOBAND_ORDER + 1) * k]; - transcodingParam.hiFiltGain[k] = hifilt_coef[(LPC_HIBAND_ORDER + 1) * k]; - } - - /* Scale DFT coefficients. */ - for (k = 0; k < FRAMESAMPLES_HALF; k++) { - fre[k] = (WebRtc_Word16)(fre[k] * transcodeScale); - fim[k] = (WebRtc_Word16)(fim[k] * transcodeScale); - } - - /* Save data for multiple packets memory. */ - my_index = ISACencLB_obj->SaveEnc_obj.startIdx * FRAMESAMPLES_HALF; - memcpy(&ISACencLB_obj->SaveEnc_obj.fre[my_index], fre, sizeof(fre)); - memcpy(&ISACencLB_obj->SaveEnc_obj.fim[my_index], fim, sizeof(fim)); - - /* Re-store the state of arithmetic coder before coding LPC gains. */ - ISACencLB_obj->bitstr_obj.W_upper = transcodingParam.W_upper; - ISACencLB_obj->bitstr_obj.stream_index = transcodingParam.stream_index; - ISACencLB_obj->bitstr_obj.streamval = transcodingParam.streamval; - ISACencLB_obj->bitstr_obj.stream[transcodingParam.stream_index - 2] = - transcodingParam.stream[0]; - ISACencLB_obj->bitstr_obj.stream[transcodingParam.stream_index - 1] = - transcodingParam.stream[1]; - ISACencLB_obj->bitstr_obj.stream[transcodingParam.stream_index] = - transcodingParam.stream[2]; - - /* Code gains. */ - WebRtcIsac_EncodeLpcGainLb(lofilt_coef, hifilt_coef, - &ISACencLB_obj->bitstr_obj, - &ISACencLB_obj->SaveEnc_obj); - - /* Update the number of bytes left for encoding the spectrum. */ - bytesLeftSpecCoding = payloadLimitBytes - transcodingParam.stream_index; - - /* Encode the spectrum. */ - err = WebRtcIsac_EncodeSpec(fre, fim, AvgPitchGain_Q12, kIsacLowerBand, - &ISACencLB_obj->bitstr_obj); - - if ((err < 0) && (err != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - /* There has been an error but it was not too large - payload (we can cure too large payload). */ - if (frame_mode == 1 && ISACencLB_obj->frame_nb == 1) { - /* If this is the second 30 ms of a 60 ms frame reset - this such that in the next call encoder starts fresh. */ - ISACencLB_obj->frame_nb = 0; - } - return err; - } - iterCntr++; - } - - /* If 60 ms frame-size and just processed the first 30 ms, */ - /* go back to main function to buffer the other 30 ms speech frame. */ - if (frame_mode == 1) { - if (ISACencLB_obj->frame_nb == 0) { - ISACencLB_obj->frame_nb = 1; - return 0; - } else if (ISACencLB_obj->frame_nb == 1) { - ISACencLB_obj->frame_nb = 0; - /* Also update the frame-length for next packet, - in Adaptive mode only. */ - if (codingMode == 0 && (ISACencLB_obj->enforceFrameSize == 0)) { - ISACencLB_obj->new_framelength = - WebRtcIsac_GetNewFrameLength(ISACencLB_obj->bottleneck, - ISACencLB_obj->current_framesamples); - } - } - } else { - ISACencLB_obj->frame_nb = 0; - } - - /* Complete arithmetic coding. */ - stream_length = WebRtcIsac_EncTerminate(&ISACencLB_obj->bitstr_obj); - return stream_length; -} - - - -static int LimitPayloadUb(ISACUBEncStruct* ISACencUB_obj, - WebRtc_UWord16 payloadLimitBytes, - double bytesLeftSpecCoding, - transcode_obj* transcodingParam, - WebRtc_Word16* fre, WebRtc_Word16* fim, - double* lpcGains, enum ISACBand band, int status) { - - int iterCntr = 0; - int k; - double bytesSpecCoderUsed; - double transcodeScale; - const WebRtc_Word16 kAveragePitchGain = 0.0; - - do { - if (iterCntr >= MAX_PAYLOAD_LIMIT_ITERATION) { - /* We were not able to limit the payload size. */ - return -ISAC_PAYLOAD_LARGER_THAN_LIMIT; - } - - if (status == -ISAC_DISALLOWED_BITSTREAM_LENGTH) { - bytesSpecCoderUsed = STREAM_SIZE_MAX; - /* Being conservative. */ - transcodeScale = bytesLeftSpecCoding / bytesSpecCoderUsed * 0.5; - } else { - bytesSpecCoderUsed = ISACencUB_obj->bitstr_obj.stream_index - - transcodingParam->stream_index; - transcodeScale = bytesLeftSpecCoding / bytesSpecCoderUsed; - } - - /* To be safe, we reduce the scale depending on the - number of iterations. */ - transcodeScale *= (1.0 - (0.9 * (double)iterCntr / - (double)MAX_PAYLOAD_LIMIT_ITERATION)); - - /* Scale the LPC Gains. */ - if (band == kIsacUpperBand16) { - /* Two sets of coefficients if 16 kHz. */ - for (k = 0; k < SUBFRAMES; k++) { - transcodingParam->loFiltGain[k] *= transcodeScale; - transcodingParam->hiFiltGain[k] *= transcodeScale; - } - } else { - /* One sets of coefficients if 12 kHz. */ - for (k = 0; k < SUBFRAMES; k++) { - transcodingParam->loFiltGain[k] *= transcodeScale; - } - } - - /* Scale DFT coefficients. */ - for (k = 0; k < FRAMESAMPLES_HALF; k++) { - fre[k] = (WebRtc_Word16)(fre[k] * transcodeScale + 0.5); - fim[k] = (WebRtc_Word16)(fim[k] * transcodeScale + 0.5); - } - /* Store FFT coefficients for multiple encoding. */ - memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre, - sizeof(ISACencUB_obj->SaveEnc_obj.realFFT)); - memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim, - sizeof(ISACencUB_obj->SaveEnc_obj.imagFFT)); - - /* Store the state of arithmetic coder before coding LPC gains */ - ISACencUB_obj->bitstr_obj.W_upper = transcodingParam->W_upper; - ISACencUB_obj->bitstr_obj.stream_index = transcodingParam->stream_index; - ISACencUB_obj->bitstr_obj.streamval = transcodingParam->streamval; - ISACencUB_obj->bitstr_obj.stream[transcodingParam->stream_index - 2] = - transcodingParam->stream[0]; - ISACencUB_obj->bitstr_obj.stream[transcodingParam->stream_index - 1] = - transcodingParam->stream[1]; - ISACencUB_obj->bitstr_obj.stream[transcodingParam->stream_index] = - transcodingParam->stream[2]; - - /* Store the gains for multiple encoding. */ - memcpy(ISACencUB_obj->SaveEnc_obj.lpcGain, lpcGains, - SUBFRAMES * sizeof(double)); - /* Entropy Code lpc-gains, indices are stored for a later use.*/ - WebRtcIsac_EncodeLpcGainUb(transcodingParam->loFiltGain, - &ISACencUB_obj->bitstr_obj, - ISACencUB_obj->SaveEnc_obj.lpcGainIndex); - - /* If 16kHz should do one more set. */ - if (band == kIsacUpperBand16) { - /* Store the gains for multiple encoding. */ - memcpy(&ISACencUB_obj->SaveEnc_obj.lpcGain[SUBFRAMES], - &lpcGains[SUBFRAMES], SUBFRAMES * sizeof(double)); - /* Entropy Code lpc-gains, indices are stored for a later use.*/ - WebRtcIsac_EncodeLpcGainUb( - transcodingParam->hiFiltGain, &ISACencUB_obj->bitstr_obj, - &ISACencUB_obj->SaveEnc_obj.lpcGainIndex[SUBFRAMES]); - } - - /* Update the number of bytes left for encoding the spectrum. */ - bytesLeftSpecCoding = payloadLimitBytes - - ISACencUB_obj->bitstr_obj.stream_index; - - /* Save the bit-stream object at this point for FEC. */ - memcpy(&ISACencUB_obj->SaveEnc_obj.bitStreamObj, - &ISACencUB_obj->bitstr_obj, sizeof(Bitstr)); - - /* Encode the spectrum. */ - status = WebRtcIsac_EncodeSpec(fre, fim, kAveragePitchGain, - band, &ISACencUB_obj->bitstr_obj); - if ((status < 0) && (status != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - /* There has been an error but it was not too large payload - (we can cure too large payload). */ - return status; - } - iterCntr++; - } while ((ISACencUB_obj->bitstr_obj.stream_index > payloadLimitBytes) || - (status == -ISAC_DISALLOWED_BITSTREAM_LENGTH)); - return 0; -} - -int WebRtcIsac_EncodeUb16(float* in, ISACUBEncStruct* ISACencUB_obj, - WebRtc_Word32 jitterInfo) { - int err; - int k; - - double lpcVecs[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - double percepFilterParams[(1 + UB_LPC_ORDER) * (SUBFRAMES << 1) + - (1 + UB_LPC_ORDER)]; - - double LP_lookahead[FRAMESAMPLES]; - WebRtc_Word16 fre[FRAMESAMPLES_HALF]; /* Q7 */ - WebRtc_Word16 fim[FRAMESAMPLES_HALF]; /* Q7 */ - - int status = 0; - - double varscale[2]; - double corr[SUBFRAMES << 1][UB_LPC_ORDER + 1]; - double lpcGains[SUBFRAMES << 1]; - transcode_obj transcodingParam; - WebRtc_UWord16 payloadLimitBytes; - double s2nr; - const WebRtc_Word16 kAveragePitchGain = 0.0; - int bytesLeftSpecCoding; - - /* Buffer speech samples (by 10ms packet) until the frame-length is */ - /* reached (30 ms). */ - /*********************************************************************/ - - /* fill the buffer with 10ms input data */ - memcpy(&ISACencUB_obj->data_buffer_float[ISACencUB_obj->buffer_index], in, - FRAMESAMPLES_10ms * sizeof(float)); - - /* If buffer size is not equal to current frame-size, and end of file is - * not reached yet, we don't do encoding unless we have the whole frame. */ - if (ISACencUB_obj->buffer_index + FRAMESAMPLES_10ms < FRAMESAMPLES) { - ISACencUB_obj->buffer_index += FRAMESAMPLES_10ms; - return 0; - } - - /* End of buffer function. */ - /**************************/ - - /* Encoding */ - /************/ - - /* Reset bit-stream */ - WebRtcIsac_ResetBitstream(&(ISACencUB_obj->bitstr_obj)); - - /* Encoding of bandwidth information. */ - WebRtcIsac_EncodeJitterInfo(jitterInfo, &ISACencUB_obj->bitstr_obj); - - status = WebRtcIsac_EncodeBandwidth(isac16kHz, &ISACencUB_obj->bitstr_obj); - if (status < 0) { - return status; - } - - s2nr = WebRtcIsac_GetSnr(ISACencUB_obj->bottleneck, FRAMESAMPLES); - - memcpy(lpcVecs, ISACencUB_obj->lastLPCVec, UB_LPC_ORDER * sizeof(double)); - - for (k = 0; k < FRAMESAMPLES; k++) { - LP_lookahead[k] = ISACencUB_obj->data_buffer_float[UB_LOOKAHEAD + k]; - } - - /* Find coefficients for perceptual pre-filters. */ - WebRtcIsac_GetLpcCoefUb(LP_lookahead, &ISACencUB_obj->maskfiltstr_obj, - &lpcVecs[UB_LPC_ORDER], corr, varscale, isac16kHz); - - memcpy(ISACencUB_obj->lastLPCVec, - &lpcVecs[(UB16_LPC_VEC_PER_FRAME - 1) * (UB_LPC_ORDER)], - sizeof(double) * UB_LPC_ORDER); - - /* Code LPC model and shape - gains not quantized yet. */ - WebRtcIsac_EncodeLpcUB(lpcVecs, &ISACencUB_obj->bitstr_obj, - percepFilterParams, isac16kHz, - &ISACencUB_obj->SaveEnc_obj); - - /* the first set of lpc parameters are from the last sub-frame of - * the previous frame. so we don't care about them. */ - WebRtcIsac_GetLpcGain(s2nr, &percepFilterParams[UB_LPC_ORDER + 1], - (SUBFRAMES << 1), lpcGains, corr, varscale); - - /* Store the state of arithmetic coder before coding LPC gains */ - transcodingParam.stream_index = ISACencUB_obj->bitstr_obj.stream_index; - transcodingParam.W_upper = ISACencUB_obj->bitstr_obj.W_upper; - transcodingParam.streamval = ISACencUB_obj->bitstr_obj.streamval; - transcodingParam.stream[0] = - ISACencUB_obj->bitstr_obj.stream[ISACencUB_obj->bitstr_obj.stream_index - - 2]; - transcodingParam.stream[1] = - ISACencUB_obj->bitstr_obj.stream[ISACencUB_obj->bitstr_obj.stream_index - - 1]; - transcodingParam.stream[2] = - ISACencUB_obj->bitstr_obj.stream[ISACencUB_obj->bitstr_obj.stream_index]; - - /* Store LPC Gains before encoding them. */ - for (k = 0; k < SUBFRAMES; k++) { - transcodingParam.loFiltGain[k] = lpcGains[k]; - transcodingParam.hiFiltGain[k] = lpcGains[SUBFRAMES + k]; - } - - /* Store the gains for multiple encoding. */ - memcpy(ISACencUB_obj->SaveEnc_obj.lpcGain, lpcGains, - (SUBFRAMES << 1) * sizeof(double)); - - WebRtcIsac_EncodeLpcGainUb(lpcGains, &ISACencUB_obj->bitstr_obj, - ISACencUB_obj->SaveEnc_obj.lpcGainIndex); - WebRtcIsac_EncodeLpcGainUb( - &lpcGains[SUBFRAMES], &ISACencUB_obj->bitstr_obj, - &ISACencUB_obj->SaveEnc_obj.lpcGainIndex[SUBFRAMES]); - - /* Get the correct value for the payload limit and calculate the number of - bytes left for coding the spectrum. It is a 30ms frame - Subract 3 because termination process may add 3 bytes */ - payloadLimitBytes = ISACencUB_obj->maxPayloadSizeBytes - - ISACencUB_obj->numBytesUsed - 3; - bytesLeftSpecCoding = payloadLimitBytes - - ISACencUB_obj->bitstr_obj.stream_index; - - for (k = 0; k < (SUBFRAMES << 1); k++) { - percepFilterParams[k * (UB_LPC_ORDER + 1) + (UB_LPC_ORDER + 1)] = - lpcGains[k]; - } - - /* LPC filtering (using normalized lattice filter), */ - /* first half-frame. */ - WebRtcIsac_NormLatticeFilterMa(UB_LPC_ORDER, - ISACencUB_obj->maskfiltstr_obj.PreStateLoF, - ISACencUB_obj->maskfiltstr_obj.PreStateLoG, - &ISACencUB_obj->data_buffer_float[0], - &percepFilterParams[UB_LPC_ORDER + 1], - &LP_lookahead[0]); - - /* Second half-frame filtering. */ - WebRtcIsac_NormLatticeFilterMa( - UB_LPC_ORDER, ISACencUB_obj->maskfiltstr_obj.PreStateLoF, - ISACencUB_obj->maskfiltstr_obj.PreStateLoG, - &ISACencUB_obj->data_buffer_float[FRAMESAMPLES_HALF], - &percepFilterParams[(UB_LPC_ORDER + 1) + SUBFRAMES * (UB_LPC_ORDER + 1)], - &LP_lookahead[FRAMESAMPLES_HALF]); - - WebRtcIsac_Time2Spec(&LP_lookahead[0], &LP_lookahead[FRAMESAMPLES_HALF], - fre, fim, &ISACencUB_obj->fftstr_obj); - - /* Store FFT coefficients for multiple encoding. */ - memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre, sizeof(fre)); - memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim, sizeof(fim)); - - /* Prepare the audio buffer for the next packet - * move the last 3 ms to the beginning of the buffer. */ - memcpy(ISACencUB_obj->data_buffer_float, - &ISACencUB_obj->data_buffer_float[FRAMESAMPLES], - LB_TOTAL_DELAY_SAMPLES * sizeof(float)); - /* start writing with 3 ms delay to compensate for the delay - * of the lower-band. */ - ISACencUB_obj->buffer_index = LB_TOTAL_DELAY_SAMPLES; - - /* Save the bit-stream object at this point for FEC. */ - memcpy(&ISACencUB_obj->SaveEnc_obj.bitStreamObj, &ISACencUB_obj->bitstr_obj, - sizeof(Bitstr)); - - /* Qantization and lossless coding */ - /* Note that there is no pitch-gain for this band so kAveragePitchGain = 0 - * is passed to the function. In fact, the function ignores the 3rd parameter - * for this band. */ - err = WebRtcIsac_EncodeSpec(fre, fim, kAveragePitchGain, kIsacUpperBand16, - &ISACencUB_obj->bitstr_obj); - if ((err < 0) && (err != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - return err; - } - - if ((ISACencUB_obj->bitstr_obj.stream_index > payloadLimitBytes) || - (err == -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - err = LimitPayloadUb(ISACencUB_obj, payloadLimitBytes, bytesLeftSpecCoding, - &transcodingParam, fre, fim, lpcGains, - kIsacUpperBand16, err); - } - if (err < 0) { - return err; - } - /* Complete arithmetic coding. */ - return WebRtcIsac_EncTerminate(&ISACencUB_obj->bitstr_obj); -} - - -int WebRtcIsac_EncodeUb12(float* in, ISACUBEncStruct* ISACencUB_obj, - WebRtc_Word32 jitterInfo) { - int err; - int k; - - double lpcVecs[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; - - double percepFilterParams[(1 + UB_LPC_ORDER) * SUBFRAMES]; - float LP[FRAMESAMPLES_HALF]; - float HP[FRAMESAMPLES_HALF]; - - double LP_lookahead[FRAMESAMPLES_HALF]; - double HP_lookahead[FRAMESAMPLES_HALF]; - double LPw[FRAMESAMPLES_HALF]; - - double HPw[FRAMESAMPLES_HALF]; - WebRtc_Word16 fre[FRAMESAMPLES_HALF]; /* Q7 */ - WebRtc_Word16 fim[FRAMESAMPLES_HALF]; /* Q7 */ - - int status = 0; - - double varscale[1]; - - double corr[UB_LPC_GAIN_DIM][UB_LPC_ORDER + 1]; - double lpcGains[SUBFRAMES]; - transcode_obj transcodingParam; - WebRtc_UWord16 payloadLimitBytes; - double s2nr; - const WebRtc_Word16 kAveragePitchGain = 0.0; - double bytesLeftSpecCoding; - - /* Buffer speech samples (by 10ms packet) until the framelength is */ - /* reached (30 ms). */ - /********************************************************************/ - - /* Fill the buffer with 10ms input data. */ - memcpy(&ISACencUB_obj->data_buffer_float[ISACencUB_obj->buffer_index], in, - FRAMESAMPLES_10ms * sizeof(float)); - - /* if buffer-size is not equal to current frame-size then increase the - index and return. We do the encoding when we have enough audio. */ - if (ISACencUB_obj->buffer_index + FRAMESAMPLES_10ms < FRAMESAMPLES) { - ISACencUB_obj->buffer_index += FRAMESAMPLES_10ms; - return 0; - } - /* If buffer reached the right size, reset index and continue - with encoding the frame */ - ISACencUB_obj->buffer_index = 0; - - /* End of buffer function */ - /**************************/ - - /* Encoding */ - /************/ - - /* Reset bit-stream. */ - WebRtcIsac_ResetBitstream(&(ISACencUB_obj->bitstr_obj)); - - /* Encoding bandwidth information. */ - WebRtcIsac_EncodeJitterInfo(jitterInfo, &ISACencUB_obj->bitstr_obj); - status = WebRtcIsac_EncodeBandwidth(isac12kHz, &ISACencUB_obj->bitstr_obj); - if (status < 0) { - return status; - } - - s2nr = WebRtcIsac_GetSnr(ISACencUB_obj->bottleneck, FRAMESAMPLES); - - /* Split signal in two bands. */ - WebRtcIsac_SplitAndFilterFloat(ISACencUB_obj->data_buffer_float, HP, LP, - HP_lookahead, LP_lookahead, - &ISACencUB_obj->prefiltbankstr_obj); - - /* Find coefficients for perceptual pre-filters. */ - WebRtcIsac_GetLpcCoefUb(LP_lookahead, &ISACencUB_obj->maskfiltstr_obj, - lpcVecs, corr, varscale, isac12kHz); - - /* Code LPC model and shape - gains not quantized yet. */ - WebRtcIsac_EncodeLpcUB(lpcVecs, &ISACencUB_obj->bitstr_obj, - percepFilterParams, isac12kHz, - &ISACencUB_obj->SaveEnc_obj); - - WebRtcIsac_GetLpcGain(s2nr, percepFilterParams, SUBFRAMES, lpcGains, corr, - varscale); - - /* Store the state of arithmetic coder before coding LPC gains. */ - transcodingParam.W_upper = ISACencUB_obj->bitstr_obj.W_upper; - transcodingParam.stream_index = ISACencUB_obj->bitstr_obj.stream_index; - transcodingParam.streamval = ISACencUB_obj->bitstr_obj.streamval; - transcodingParam.stream[0] = - ISACencUB_obj->bitstr_obj.stream[ISACencUB_obj->bitstr_obj.stream_index - - 2]; - transcodingParam.stream[1] = - ISACencUB_obj->bitstr_obj.stream[ISACencUB_obj->bitstr_obj.stream_index - - 1]; - transcodingParam.stream[2] = - ISACencUB_obj->bitstr_obj.stream[ISACencUB_obj->bitstr_obj.stream_index]; - - /* Store LPC Gains before encoding them. */ - for (k = 0; k < SUBFRAMES; k++) { - transcodingParam.loFiltGain[k] = lpcGains[k]; - } - - /* Store the gains for multiple encoding. */ - memcpy(ISACencUB_obj->SaveEnc_obj.lpcGain, lpcGains, SUBFRAMES * - sizeof(double)); - - WebRtcIsac_EncodeLpcGainUb(lpcGains, &ISACencUB_obj->bitstr_obj, - ISACencUB_obj->SaveEnc_obj.lpcGainIndex); - - for (k = 0; k < SUBFRAMES; k++) { - percepFilterParams[k * (UB_LPC_ORDER + 1)] = lpcGains[k]; - } - - /* perceptual pre-filtering (using normalized lattice filter) */ - /* low-band filtering */ - WebRtcIsac_NormLatticeFilterMa(UB_LPC_ORDER, - ISACencUB_obj->maskfiltstr_obj.PreStateLoF, - ISACencUB_obj->maskfiltstr_obj.PreStateLoG, LP, - percepFilterParams, LPw); - - /* Get the correct value for the payload limit and calculate the number - of bytes left for coding the spectrum. It is a 30ms frame Subract 3 - because termination process may add 3 bytes */ - payloadLimitBytes = ISACencUB_obj->maxPayloadSizeBytes - - ISACencUB_obj->numBytesUsed - 3; - bytesLeftSpecCoding = payloadLimitBytes - - ISACencUB_obj->bitstr_obj.stream_index; - - memset(HPw, 0, sizeof(HPw)); - - /* Transform */ - WebRtcIsac_Time2Spec(LPw, HPw, fre, fim, &ISACencUB_obj->fftstr_obj); - - /* Store FFT coefficients for multiple encoding. */ - memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre, - sizeof(ISACencUB_obj->SaveEnc_obj.realFFT)); - memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim, - sizeof(ISACencUB_obj->SaveEnc_obj.imagFFT)); - - /* Save the bit-stream object at this point for FEC. */ - memcpy(&ISACencUB_obj->SaveEnc_obj.bitStreamObj, - &ISACencUB_obj->bitstr_obj, sizeof(Bitstr)); - - /* Quantization and loss-less coding */ - /* The 4th parameter to this function is pitch-gain, which is only used - * when encoding 0-8 kHz band, and irrelevant in this function, therefore, - * we insert zero here. */ - err = WebRtcIsac_EncodeSpec(fre, fim, kAveragePitchGain, kIsacUpperBand12, - &ISACencUB_obj->bitstr_obj); - if ((err < 0) && (err != -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - /* There has been an error but it was not too large - payload (we can cure too large payload) */ - return err; - } - - if ((ISACencUB_obj->bitstr_obj.stream_index > payloadLimitBytes) || - (err == -ISAC_DISALLOWED_BITSTREAM_LENGTH)) { - err = LimitPayloadUb(ISACencUB_obj, payloadLimitBytes, bytesLeftSpecCoding, - &transcodingParam, fre, fim, lpcGains, - kIsacUpperBand12, err); - } - if (err < 0) { - return err; - } - /* Complete arithmetic coding. */ - return WebRtcIsac_EncTerminate(&ISACencUB_obj->bitstr_obj); -} - - - - - - -/* This function is used to create a new bit-stream with new BWE. - The same data as previously encoded with the function WebRtcIsac_Encoder(). - The data needed is taken from the structure, where it was stored - when calling the encoder. */ - -int WebRtcIsac_EncodeStoredDataLb(const ISAC_SaveEncData_t* ISACSavedEnc_obj, - Bitstr* ISACBitStr_obj, int BWnumber, - float scale) { - int ii; - int status; - int BWno = BWnumber; - - const WebRtc_UWord16* WebRtcIsac_kQPitchGainCdf_ptr[1]; - const WebRtc_UWord16** cdf; - - double tmpLPCcoeffs_lo[(ORDERLO + 1)*SUBFRAMES * 2]; - double tmpLPCcoeffs_hi[(ORDERHI + 1)*SUBFRAMES * 2]; - int tmpLPCindex_g[12 * 2]; - WebRtc_Word16 tmp_fre[FRAMESAMPLES], tmp_fim[FRAMESAMPLES]; - const int kModel = 0; - - /* Sanity Check - possible values for BWnumber is 0 - 23. */ - if ((BWnumber < 0) || (BWnumber > 23)) { - return -ISAC_RANGE_ERROR_BW_ESTIMATOR; - } - - /* Reset bit-stream. */ - WebRtcIsac_ResetBitstream(ISACBitStr_obj); - - /* Encode frame length */ - status = WebRtcIsac_EncodeFrameLen(ISACSavedEnc_obj->framelength, - ISACBitStr_obj); - if (status < 0) { - /* Wrong frame size. */ - return status; - } - - /* Transcoding */ - if ((scale > 0.0) && (scale < 1.0)) { - /* Compensate LPC gain. */ - for (ii = 0; - ii < ((ORDERLO + 1)* SUBFRAMES * (1 + ISACSavedEnc_obj->startIdx)); - ii++) { - tmpLPCcoeffs_lo[ii] = scale * ISACSavedEnc_obj->LPCcoeffs_lo[ii]; - } - for (ii = 0; - ii < ((ORDERHI + 1) * SUBFRAMES * (1 + ISACSavedEnc_obj->startIdx)); - ii++) { - tmpLPCcoeffs_hi[ii] = scale * ISACSavedEnc_obj->LPCcoeffs_hi[ii]; - } - /* Scale DFT. */ - for (ii = 0; - ii < (FRAMESAMPLES_HALF * (1 + ISACSavedEnc_obj->startIdx)); - ii++) { - tmp_fre[ii] = (WebRtc_Word16)((scale) * (float)ISACSavedEnc_obj->fre[ii]); - tmp_fim[ii] = (WebRtc_Word16)((scale) * (float)ISACSavedEnc_obj->fim[ii]); - } - } else { - for (ii = 0; - ii < (KLT_ORDER_GAIN * (1 + ISACSavedEnc_obj->startIdx)); - ii++) { - tmpLPCindex_g[ii] = ISACSavedEnc_obj->LPCindex_g[ii]; - } - for (ii = 0; - ii < (FRAMESAMPLES_HALF * (1 + ISACSavedEnc_obj->startIdx)); - ii++) { - tmp_fre[ii] = ISACSavedEnc_obj->fre[ii]; - tmp_fim[ii] = ISACSavedEnc_obj->fim[ii]; - } - } - - /* Encode bandwidth estimate. */ - WebRtcIsac_EncodeReceiveBw(&BWno, ISACBitStr_obj); - - /* Loop over number of 30 msec */ - for (ii = 0; ii <= ISACSavedEnc_obj->startIdx; ii++) { - /* Encode pitch gains. */ - *WebRtcIsac_kQPitchGainCdf_ptr = WebRtcIsac_kQPitchGainCdf; - WebRtcIsac_EncHistMulti(ISACBitStr_obj, - &ISACSavedEnc_obj->pitchGain_index[ii], - WebRtcIsac_kQPitchGainCdf_ptr, 1); - - /* Entropy coding of quantization pitch lags */ - /* Voicing classification. */ - if (ISACSavedEnc_obj->meanGain[ii] < 0.2) { - cdf = WebRtcIsac_kQPitchLagCdfPtrLo; - } else if (ISACSavedEnc_obj->meanGain[ii] < 0.4) { - cdf = WebRtcIsac_kQPitchLagCdfPtrMid; - } else { - cdf = WebRtcIsac_kQPitchLagCdfPtrHi; - } - WebRtcIsac_EncHistMulti(ISACBitStr_obj, - &ISACSavedEnc_obj->pitchIndex[PITCH_SUBFRAMES * ii], - cdf, PITCH_SUBFRAMES); - - /* LPC */ - /* Only one model exists. The entropy coding is done only for backward - * compatibility. */ - WebRtcIsac_EncHistMulti(ISACBitStr_obj, &kModel, - WebRtcIsac_kQKltModelCdfPtr, 1); - /* Entropy coding of quantization indices - LPC shape only. */ - WebRtcIsac_EncHistMulti(ISACBitStr_obj, - &ISACSavedEnc_obj->LPCindex_s[KLT_ORDER_SHAPE * ii], - WebRtcIsac_kQKltCdfPtrShape, - KLT_ORDER_SHAPE); - - /* If transcoding, get new LPC gain indices */ - if (scale < 1.0) { - WebRtcIsac_TranscodeLPCCoef( - &tmpLPCcoeffs_lo[(ORDERLO + 1) * SUBFRAMES * ii], - &tmpLPCcoeffs_hi[(ORDERHI + 1)*SUBFRAMES * ii], - &tmpLPCindex_g[KLT_ORDER_GAIN * ii]); - } - - /* Entropy coding of quantization indices - LPC gain. */ - WebRtcIsac_EncHistMulti(ISACBitStr_obj, &tmpLPCindex_g[KLT_ORDER_GAIN * ii], - WebRtcIsac_kQKltCdfPtrGain, KLT_ORDER_GAIN); - - /* Quantization and loss-less coding. */ - status = WebRtcIsac_EncodeSpec(&tmp_fre[ii * FRAMESAMPLES_HALF], - &tmp_fim[ii * FRAMESAMPLES_HALF], - ISACSavedEnc_obj->AvgPitchGain[ii], - kIsacLowerBand, ISACBitStr_obj); - if (status < 0) { - return status; - } - } - /* Complete arithmetic coding. */ - return WebRtcIsac_EncTerminate(ISACBitStr_obj); -} - - -int WebRtcIsac_EncodeStoredDataUb( - const ISACUBSaveEncDataStruct* ISACSavedEnc_obj, - Bitstr* bitStream, - WebRtc_Word32 jitterInfo, - float scale, - enum ISACBandwidth bandwidth) { - int n; - int err; - double lpcGain[SUBFRAMES]; - WebRtc_Word16 realFFT[FRAMESAMPLES_HALF]; - WebRtc_Word16 imagFFT[FRAMESAMPLES_HALF]; - const WebRtc_UWord16** shape_cdf; - int shape_len; - const WebRtc_Word16 kAveragePitchGain = 0.0; - enum ISACBand band; - /* Reset bitstream. */ - WebRtcIsac_ResetBitstream(bitStream); - - /* Encode jitter index. */ - WebRtcIsac_EncodeJitterInfo(jitterInfo, bitStream); - - err = WebRtcIsac_EncodeBandwidth(bandwidth, bitStream); - if (err < 0) { - return err; - } - - /* Encode LPC-shape. */ - if (bandwidth == isac12kHz) { - shape_cdf = WebRtcIsac_kLpcShapeCdfMatUb12; - shape_len = UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME; - band = kIsacUpperBand12; - } else { - shape_cdf = WebRtcIsac_kLpcShapeCdfMatUb16; - shape_len = UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME; - band = kIsacUpperBand16; - } - WebRtcIsac_EncHistMulti(bitStream, ISACSavedEnc_obj->indexLPCShape, - shape_cdf, shape_len); - - if ((scale <= 0.0) || (scale >= 1.0)) { - /* We only consider scales between zero and one. */ - WebRtcIsac_EncHistMulti(bitStream, ISACSavedEnc_obj->lpcGainIndex, - WebRtcIsac_kLpcGainCdfMat, UB_LPC_GAIN_DIM); - if (bandwidth == isac16kHz) { - /* Store gain indices of the second half. */ - WebRtcIsac_EncHistMulti(bitStream, - &ISACSavedEnc_obj->lpcGainIndex[SUBFRAMES], - WebRtcIsac_kLpcGainCdfMat, UB_LPC_GAIN_DIM); - } - /* Store FFT coefficients. */ - err = WebRtcIsac_EncodeSpec(ISACSavedEnc_obj->realFFT, - ISACSavedEnc_obj->imagFFT, kAveragePitchGain, - band, bitStream); - } else { - /* Scale LPC gain and FFT coefficients. */ - for (n = 0; n < SUBFRAMES; n++) { - lpcGain[n] = scale * ISACSavedEnc_obj->lpcGain[n]; - } - /* Store LPC gains. */ - WebRtcIsac_StoreLpcGainUb(lpcGain, bitStream); - - if (bandwidth == isac16kHz) { - /* Scale and code the gains of the second half of the frame, if 16kHz. */ - for (n = 0; n < SUBFRAMES; n++) { - lpcGain[n] = scale * ISACSavedEnc_obj->lpcGain[n + SUBFRAMES]; - } - WebRtcIsac_StoreLpcGainUb(lpcGain, bitStream); - } - - for (n = 0; n < FRAMESAMPLES_HALF; n++) { - realFFT[n] = (WebRtc_Word16)(scale * (float)ISACSavedEnc_obj->realFFT[n] + - 0.5f); - imagFFT[n] = (WebRtc_Word16)(scale * (float)ISACSavedEnc_obj->imagFFT[n] + - 0.5f); - } - /* Store FFT coefficients. */ - err = WebRtcIsac_EncodeSpec(realFFT, imagFFT, kAveragePitchGain, - band, bitStream); - } - if (err < 0) { - /* Error happened while encoding FFT coefficients. */ - return err; - } - - /* Complete arithmetic coding. */ - return WebRtcIsac_EncTerminate(bitStream); -} - -WebRtc_Word16 WebRtcIsac_GetRedPayloadUb( - const ISACUBSaveEncDataStruct* ISACSavedEncObj, - Bitstr* bitStreamObj, - enum ISACBandwidth bandwidth) { - int n; - WebRtc_Word16 status; - WebRtc_Word16 realFFT[FRAMESAMPLES_HALF]; - WebRtc_Word16 imagFFT[FRAMESAMPLES_HALF]; - enum ISACBand band; - const WebRtc_Word16 kAveragePitchGain = 0.0; - /* Store bit-stream object. */ - memcpy(bitStreamObj, &ISACSavedEncObj->bitStreamObj, sizeof(Bitstr)); - - /* Scale FFT coefficients. */ - for (n = 0; n < FRAMESAMPLES_HALF; n++) { - realFFT[n] = (WebRtc_Word16)((float)ISACSavedEncObj->realFFT[n] * - RCU_TRANSCODING_SCALE_UB + 0.5); - imagFFT[n] = (WebRtc_Word16)((float)ISACSavedEncObj->imagFFT[n] * - RCU_TRANSCODING_SCALE_UB + 0.5); - } - - band = (bandwidth == isac12kHz) ? kIsacUpperBand12 : kIsacUpperBand16; - status = WebRtcIsac_EncodeSpec(realFFT, imagFFT, kAveragePitchGain, band, - bitStreamObj); - if (status < 0) { - return status; - } else { - /* Terminate entropy coding */ - return WebRtcIsac_EncTerminate(bitStreamObj); - } -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.c b/src/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.c deleted file mode 100644 index 2bf4c36..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.c +++ /dev/null
@@ -1,708 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * code_LPC_UB.c - * - * This file contains definition of functions used to - * encode LPC parameters (Shape & gain) of the upper band. - * - */ - -#include "encode_lpc_swb.h" -#include "typedefs.h" -#include "settings.h" - -#include "lpc_shape_swb12_tables.h" -#include "lpc_shape_swb16_tables.h" -#include "lpc_gain_swb_tables.h" - -#include <stdio.h> -#include <string.h> -#include <math.h> - -/****************************************************************************** - * WebRtcIsac_RemoveLarMean() - * - * Remove the means from LAR coefficients. - * - * Input: - * -lar : pointer to lar vectors. LAR vectors are - * concatenated. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -lar : pointer to mean-removed LAR:s. - * - * - */ -WebRtc_Word16 -WebRtcIsac_RemoveLarMean( - double* lar, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 coeffCntr; - WebRtc_Word16 vecCntr; - WebRtc_Word16 numVec; - const double* meanLAR; - switch(bandwidth) - { - case isac12kHz: - { - numVec = UB_LPC_VEC_PER_FRAME; - meanLAR = WebRtcIsac_kMeanLarUb12; - break; - } - case isac16kHz: - { - numVec = UB16_LPC_VEC_PER_FRAME; - meanLAR = WebRtcIsac_kMeanLarUb16; - break; - } - default: - return -1; - } - - for(vecCntr = 0; vecCntr < numVec; vecCntr++) - { - for(coeffCntr = 0; coeffCntr < UB_LPC_ORDER; coeffCntr++) - { - // REMOVE MEAN - *lar++ -= meanLAR[coeffCntr]; - } - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_DecorrelateIntraVec() - * - * Remove the correlation amonge the components of LAR vectors. If LAR vectors - * of one frame are put in a matrix where each column is a LAR vector of a - * sub-frame, then this is equivalent to multiplying the LAR matrix with - * a decorrelting mtrix from left. - * - * Input: - * -inLar : pointer to mean-removed LAR vecrtors. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : decorrelated LAR vectors. - */ -WebRtc_Word16 -WebRtcIsac_DecorrelateIntraVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth) -{ - const double* ptrData; - const double* ptrRow; - WebRtc_Word16 rowCntr; - WebRtc_Word16 colCntr; - WebRtc_Word16 larVecCntr; - WebRtc_Word16 numVec; - const double* decorrMat; - switch(bandwidth) - { - case isac12kHz: - { - decorrMat = &WebRtcIsac_kIntraVecDecorrMatUb12[0][0]; - numVec = UB_LPC_VEC_PER_FRAME; - break; - } - case isac16kHz: - { - decorrMat = &WebRtcIsac_kIintraVecDecorrMatUb16[0][0]; - numVec = UB16_LPC_VEC_PER_FRAME; - break; - } - default: - return -1; - } - - // - // decorrMat * data - // - // data is assumed to contain 'numVec' of LAR - // vectors (mean removed) each of dimension 'UB_LPC_ORDER' - // concatenated one after the other. - // - - ptrData = data; - for(larVecCntr = 0; larVecCntr < numVec; larVecCntr++) - { - for(rowCntr = 0; rowCntr < UB_LPC_ORDER; rowCntr++) - { - ptrRow = &decorrMat[rowCntr * UB_LPC_ORDER]; - *out = 0; - for(colCntr = 0; colCntr < UB_LPC_ORDER; colCntr++) - { - *out += ptrData[colCntr] * ptrRow[colCntr]; - } - out++; - } - ptrData += UB_LPC_ORDER; - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_DecorrelateInterVec() - * - * Remover the correlation among mean-removed LAR vectors. If LAR vectors - * of one frame are put in a matrix where each column is a LAR vector of a - * sub-frame, then this is equivalent to multiplying the LAR matrix with - * a decorrelting mtrix from right. - * - * Input: - * -data : pointer to matrix of LAR vectors. The matrix - * is stored column-wise. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : decorrelated LAR vectors. - */ -WebRtc_Word16 -WebRtcIsac_DecorrelateInterVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 coeffCntr; - WebRtc_Word16 rowCntr; - WebRtc_Word16 colCntr; - const double* decorrMat; - WebRtc_Word16 interVecDim; - - switch(bandwidth) - { - case isac12kHz: - { - decorrMat = &WebRtcIsac_kInterVecDecorrMatUb12[0][0]; - interVecDim = UB_LPC_VEC_PER_FRAME; - break; - } - case isac16kHz: - { - decorrMat = &WebRtcIsac_kInterVecDecorrMatUb16[0][0]; - interVecDim = UB16_LPC_VEC_PER_FRAME; - break; - } - default: - return -1; - } - - // - // data * decorrMat - // - // data is of size 'interVecDim' * 'UB_LPC_ORDER' - // That is 'interVecDim' of LAR vectors (mean removed) - // in columns each of dimension 'UB_LPC_ORDER'. - // matrix is stored column-wise. - // - - for(coeffCntr = 0; coeffCntr < UB_LPC_ORDER; coeffCntr++) - { - for(colCntr = 0; colCntr < interVecDim; colCntr++) - { - out[coeffCntr + colCntr * UB_LPC_ORDER] = 0; - for(rowCntr = 0; rowCntr < interVecDim; rowCntr++) - { - out[coeffCntr + colCntr * UB_LPC_ORDER] += - data[coeffCntr + rowCntr * UB_LPC_ORDER] * - decorrMat[rowCntr * interVecDim + colCntr]; - } - } - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_QuantizeUncorrLar() - * - * Quantize the uncorrelated parameters. - * - * Input: - * -data : uncorrelated LAR vectors. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -data : quantized version of the input. - * -idx : pointer to quantization indices. - */ -double -WebRtcIsac_QuantizeUncorrLar( - double* data, - int* recIdx, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 cntr; - WebRtc_Word32 idx; - WebRtc_Word16 interVecDim; - const double* leftRecPoint; - double quantizationStepSize; - const WebRtc_Word16* numQuantCell; - switch(bandwidth) - { - case isac12kHz: - { - leftRecPoint = WebRtcIsac_kLpcShapeLeftRecPointUb12; - quantizationStepSize = WebRtcIsac_kLpcShapeQStepSizeUb12; - numQuantCell = WebRtcIsac_kLpcShapeNumRecPointUb12; - interVecDim = UB_LPC_VEC_PER_FRAME; - break; - } - case isac16kHz: - { - leftRecPoint = WebRtcIsac_kLpcShapeLeftRecPointUb16; - quantizationStepSize = WebRtcIsac_kLpcShapeQStepSizeUb16; - numQuantCell = WebRtcIsac_kLpcShapeNumRecPointUb16; - interVecDim = UB16_LPC_VEC_PER_FRAME; - break; - } - default: - return -1; - } - - // - // Quantize the parametrs. - // - for(cntr = 0; cntr < UB_LPC_ORDER * interVecDim; cntr++) - { - idx = (WebRtc_Word32)floor((*data - leftRecPoint[cntr]) / - quantizationStepSize + 0.5); - if(idx < 0) - { - idx = 0; - } - else if(idx >= numQuantCell[cntr]) - { - idx = numQuantCell[cntr] - 1; - } - - *data++ = leftRecPoint[cntr] + idx * quantizationStepSize; - *recIdx++ = idx; - } - return 0; -} - - -/****************************************************************************** - * WebRtcIsac_DequantizeLpcParam() - * - * Get the quantized value of uncorrelated LARs given the quantization indices. - * - * Input: - * -idx : pointer to quantiztion indices. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : pointer to quantized values. - */ -WebRtc_Word16 -WebRtcIsac_DequantizeLpcParam( - const int* idx, - double* out, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 cntr; - WebRtc_Word16 interVecDim; - const double* leftRecPoint; - double quantizationStepSize; - - switch(bandwidth) - { - case isac12kHz: - { - leftRecPoint = WebRtcIsac_kLpcShapeLeftRecPointUb12; - quantizationStepSize = WebRtcIsac_kLpcShapeQStepSizeUb12; - interVecDim = UB_LPC_VEC_PER_FRAME; - break; - } - case isac16kHz: - { - leftRecPoint = WebRtcIsac_kLpcShapeLeftRecPointUb16; - quantizationStepSize = WebRtcIsac_kLpcShapeQStepSizeUb16; - interVecDim = UB16_LPC_VEC_PER_FRAME; - break; - } - default: - return -1; - } - - // - // Dequantize given the quantization indices - // - - for(cntr = 0; cntr < UB_LPC_ORDER * interVecDim; cntr++) - { - *out++ = leftRecPoint[cntr] + *idx++ * quantizationStepSize; - } - return 0; -} - - -/****************************************************************************** - * WebRtcIsac_CorrelateIntraVec() - * - * This is the inverse of WebRtcIsac_DecorrelateIntraVec(). - * - * Input: - * -data : uncorrelated parameters. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : correlated parametrs. - */ -WebRtc_Word16 -WebRtcIsac_CorrelateIntraVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 vecCntr; - WebRtc_Word16 rowCntr; - WebRtc_Word16 colCntr; - WebRtc_Word16 numVec; - const double* ptrData; - const double* intraVecDecorrMat; - - switch(bandwidth) - { - case isac12kHz: - { - numVec = UB_LPC_VEC_PER_FRAME; - intraVecDecorrMat = &WebRtcIsac_kIntraVecDecorrMatUb12[0][0]; - break; - } - case isac16kHz: - { - numVec = UB16_LPC_VEC_PER_FRAME; - intraVecDecorrMat = &WebRtcIsac_kIintraVecDecorrMatUb16[0][0]; - break; - } - default: - return -1; - } - - - ptrData = data; - for(vecCntr = 0; vecCntr < numVec; vecCntr++) - { - for(colCntr = 0; colCntr < UB_LPC_ORDER; colCntr++) - { - *out = 0; - for(rowCntr = 0; rowCntr < UB_LPC_ORDER; rowCntr++) - { - *out += ptrData[rowCntr] * - intraVecDecorrMat[rowCntr * UB_LPC_ORDER + colCntr]; - } - out++; - } - ptrData += UB_LPC_ORDER; - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_CorrelateInterVec() - * - * This is the inverse of WebRtcIsac_DecorrelateInterVec(). - * - * Input: - * -data - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : correlated parametrs. - */ -WebRtc_Word16 -WebRtcIsac_CorrelateInterVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 coeffCntr; - WebRtc_Word16 rowCntr; - WebRtc_Word16 colCntr; - WebRtc_Word16 interVecDim; - double myVec[UB16_LPC_VEC_PER_FRAME]; - const double* interVecDecorrMat; - - switch(bandwidth) - { - case isac12kHz: - { - interVecDim = UB_LPC_VEC_PER_FRAME; - interVecDecorrMat = &WebRtcIsac_kInterVecDecorrMatUb12[0][0]; - break; - } - case isac16kHz: - { - interVecDim = UB16_LPC_VEC_PER_FRAME; - interVecDecorrMat = &WebRtcIsac_kInterVecDecorrMatUb16[0][0]; - break; - } - default: - return -1; - } - - for(coeffCntr = 0; coeffCntr < UB_LPC_ORDER; coeffCntr++) - { - for(rowCntr = 0; rowCntr < interVecDim; rowCntr++) - { - myVec[rowCntr] = 0; - for(colCntr = 0; colCntr < interVecDim; colCntr++) - { - myVec[rowCntr] += data[coeffCntr + colCntr * UB_LPC_ORDER] * //*ptrData * - interVecDecorrMat[rowCntr * interVecDim + colCntr]; - //ptrData += UB_LPC_ORDER; - } - } - - for(rowCntr = 0; rowCntr < interVecDim; rowCntr++) - { - out[coeffCntr + rowCntr * UB_LPC_ORDER] = myVec[rowCntr]; - } - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_AddLarMean() - * - * This is the inverse of WebRtcIsac_RemoveLarMean() - * - * Input: - * -data : pointer to mean-removed LAR:s. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -data : pointer to LARs. - */ -WebRtc_Word16 -WebRtcIsac_AddLarMean( - double* data, - WebRtc_Word16 bandwidth) -{ - WebRtc_Word16 coeffCntr; - WebRtc_Word16 vecCntr; - WebRtc_Word16 numVec; - const double* meanLAR; - - switch(bandwidth) - { - case isac12kHz: - { - numVec = UB_LPC_VEC_PER_FRAME; - meanLAR = WebRtcIsac_kMeanLarUb12; - break; - } - case isac16kHz: - { - numVec = UB16_LPC_VEC_PER_FRAME; - meanLAR = WebRtcIsac_kMeanLarUb16; - break; - } - default: - return -1; - } - - for(vecCntr = 0; vecCntr < numVec; vecCntr++) - { - for(coeffCntr = 0; coeffCntr < UB_LPC_ORDER; coeffCntr++) - { - *data++ += meanLAR[coeffCntr]; - } - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_ToLogDomainRemoveMean() - * - * Transform the LPC gain to log domain then remove the mean value. - * - * Input: - * -lpcGain : pointer to LPC Gain, expecting 6 LPC gains - * - * Output: - * -lpcGain : mean-removed in log domain. - */ -WebRtc_Word16 -WebRtcIsac_ToLogDomainRemoveMean( - double* data) -{ - WebRtc_Word16 coeffCntr; - for(coeffCntr = 0; coeffCntr < UB_LPC_GAIN_DIM; coeffCntr++) - { - data[coeffCntr] = log(data[coeffCntr]) - WebRtcIsac_kMeanLpcGain; - } - return 0; -} - - -/****************************************************************************** - * WebRtcIsac_DecorrelateLPGain() - * - * Decorrelate LPC gains. There are 6 LPC Gains per frame. This is like - * multiplying gain vector with decorrelating matrix. - * - * Input: - * -data : LPC gain in log-domain with mean removed. - * - * Output: - * -out : decorrelated parameters. - */ -WebRtc_Word16 WebRtcIsac_DecorrelateLPGain( - const double* data, - double* out) -{ - WebRtc_Word16 rowCntr; - WebRtc_Word16 colCntr; - - for(colCntr = 0; colCntr < UB_LPC_GAIN_DIM; colCntr++) - { - *out = 0; - for(rowCntr = 0; rowCntr < UB_LPC_GAIN_DIM; rowCntr++) - { - *out += data[rowCntr] * WebRtcIsac_kLpcGainDecorrMat[rowCntr][colCntr]; - } - out++; - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_QuantizeLpcGain() - * - * Quantize the decorrelated log-domain gains. - * - * Input: - * -lpcGain : uncorrelated LPC gains. - * - * Output: - * -idx : quantization indices - * -lpcGain : quantized value of the inpt. - */ -double WebRtcIsac_QuantizeLpcGain( - double* data, - int* idx) -{ - WebRtc_Word16 coeffCntr; - for(coeffCntr = 0; coeffCntr < UB_LPC_GAIN_DIM; coeffCntr++) - { - *idx = (int)floor((*data - WebRtcIsac_kLeftRecPointLpcGain[coeffCntr]) / - WebRtcIsac_kQSizeLpcGain + 0.5); - - if(*idx < 0) - { - *idx = 0; - } - else if(*idx >= WebRtcIsac_kNumQCellLpcGain[coeffCntr]) - { - *idx = WebRtcIsac_kNumQCellLpcGain[coeffCntr] - 1; - } - *data = WebRtcIsac_kLeftRecPointLpcGain[coeffCntr] + *idx * - WebRtcIsac_kQSizeLpcGain; - - data++; - idx++; - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_DequantizeLpcGain() - * - * Get the quantized values given the quantization indices. - * - * Input: - * -idx : pointer to quantization indices. - * - * Output: - * -lpcGains : quantized values of the given parametes. - */ -WebRtc_Word16 WebRtcIsac_DequantizeLpcGain( - const int* idx, - double* out) -{ - WebRtc_Word16 coeffCntr; - for(coeffCntr = 0; coeffCntr < UB_LPC_GAIN_DIM; coeffCntr++) - { - *out = WebRtcIsac_kLeftRecPointLpcGain[coeffCntr] + *idx * - WebRtcIsac_kQSizeLpcGain; - out++; - idx++; - } - return 0; -} - -/****************************************************************************** - * WebRtcIsac_CorrelateLpcGain() - * - * This is the inverse of WebRtcIsac_DecorrelateLPGain(). - * - * Input: - * -data : decorrelated parameters. - * - * Output: - * -out : correlated parameters. - */ -WebRtc_Word16 WebRtcIsac_CorrelateLpcGain( - const double* data, - double* out) -{ - WebRtc_Word16 rowCntr; - WebRtc_Word16 colCntr; - - for(rowCntr = 0; rowCntr < UB_LPC_GAIN_DIM; rowCntr++) - { - *out = 0; - for(colCntr = 0; colCntr < UB_LPC_GAIN_DIM; colCntr++) - { - *out += WebRtcIsac_kLpcGainDecorrMat[rowCntr][colCntr] * data[colCntr]; - } - out++; - } - - return 0; -} - - -/****************************************************************************** - * WebRtcIsac_AddMeanToLinearDomain() - * - * This is the inverse of WebRtcIsac_ToLogDomainRemoveMean(). - * - * Input: - * -lpcGain : LPC gain in log-domain & mean removed - * - * Output: - * -lpcGain : LPC gain in normal domain. - */ -WebRtc_Word16 WebRtcIsac_AddMeanToLinearDomain( - double* lpcGains) -{ - WebRtc_Word16 coeffCntr; - for(coeffCntr = 0; coeffCntr < UB_LPC_GAIN_DIM; coeffCntr++) - { - lpcGains[coeffCntr] = exp(lpcGains[coeffCntr] + WebRtcIsac_kMeanLpcGain); - } - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h b/src/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h deleted file mode 100644 index e7f1a76..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.h +++ /dev/null
@@ -1,283 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * encode_lpc_swb.h - * - * This file contains declaration of functions used to - * encode LPC parameters (Shape & gain) of the upper band. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_ - -#include "typedefs.h" -#include "settings.h" -#include "structs.h" - - -/****************************************************************************** - * WebRtcIsac_RemoveLarMean() - * - * Remove the means from LAR coefficients. - * - * Input: - * -lar : pointer to lar vectors. LAR vectors are - * concatenated. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -lar : pointer to mean-removed LAR:s. - * - * - */ -WebRtc_Word16 WebRtcIsac_RemoveLarMean( - double* lar, - WebRtc_Word16 bandwidth); - -/****************************************************************************** - * WebRtcIsac_DecorrelateIntraVec() - * - * Remove the correlation amonge the components of LAR vectors. If LAR vectors - * of one frame are put in a matrix where each column is a LAR vector of a - * sub-frame, then this is equivalent to multiplying the LAR matrix with - * a decorrelting mtrix from left. - * - * Input: - * -inLar : pointer to mean-removed LAR vecrtors. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : decorrelated LAR vectors. - */ -WebRtc_Word16 WebRtcIsac_DecorrelateIntraVec( - const double* inLAR, - double* out, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_DecorrelateInterVec() - * - * Remover the correlation among mean-removed LAR vectors. If LAR vectors - * of one frame are put in a matrix where each column is a LAR vector of a - * sub-frame, then this is equivalent to multiplying the LAR matrix with - * a decorrelting mtrix from right. - * - * Input: - * -data : pointer to matrix of LAR vectors. The matrix - * is stored column-wise. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : decorrelated LAR vectors. - */ -WebRtc_Word16 WebRtcIsac_DecorrelateInterVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_QuantizeUncorrLar() - * - * Quantize the uncorrelated parameters. - * - * Input: - * -data : uncorrelated LAR vectors. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -data : quantized version of the input. - * -idx : pointer to quantization indices. - */ -double WebRtcIsac_QuantizeUncorrLar( - double* data, - int* idx, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_CorrelateIntraVec() - * - * This is the inverse of WebRtcIsac_DecorrelateIntraVec(). - * - * Input: - * -data : uncorrelated parameters. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : correlated parametrs. - */ -WebRtc_Word16 WebRtcIsac_CorrelateIntraVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_CorrelateInterVec() - * - * This is the inverse of WebRtcIsac_DecorrelateInterVec(). - * - * Input: - * -data - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : correlated parametrs. - */ -WebRtc_Word16 WebRtcIsac_CorrelateInterVec( - const double* data, - double* out, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_AddLarMean() - * - * This is the inverse of WebRtcIsac_RemoveLarMean() - * - * Input: - * -data : pointer to mean-removed LAR:s. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -data : pointer to LARs. - */ -WebRtc_Word16 WebRtcIsac_AddLarMean( - double* data, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_DequantizeLpcParam() - * - * Get the quantized value of uncorrelated LARs given the quantization indices. - * - * Input: - * -idx : pointer to quantiztion indices. - * -bandwidth : indicates if the given LAR vectors belong - * to SWB-12kHz or SWB-16kHz. - * - * Output: - * -out : pointer to quantized values. - */ -WebRtc_Word16 WebRtcIsac_DequantizeLpcParam( - const int* idx, - double* out, - WebRtc_Word16 bandwidth); - - -/****************************************************************************** - * WebRtcIsac_ToLogDomainRemoveMean() - * - * Transform the LPC gain to log domain then remove the mean value. - * - * Input: - * -lpcGain : pointer to LPC Gain, expecting 6 LPC gains - * - * Output: - * -lpcGain : mean-removed in log domain. - */ -WebRtc_Word16 WebRtcIsac_ToLogDomainRemoveMean( - double* lpGains); - - -/****************************************************************************** - * WebRtcIsac_DecorrelateLPGain() - * - * Decorrelate LPC gains. There are 6 LPC Gains per frame. This is like - * multiplying gain vector with decorrelating matrix. - * - * Input: - * -data : LPC gain in log-domain with mean removed. - * - * Output: - * -out : decorrelated parameters. - */ -WebRtc_Word16 WebRtcIsac_DecorrelateLPGain( - const double* data, - double* out); - - -/****************************************************************************** - * WebRtcIsac_QuantizeLpcGain() - * - * Quantize the decorrelated log-domain gains. - * - * Input: - * -lpcGain : uncorrelated LPC gains. - * - * Output: - * -idx : quantization indices - * -lpcGain : quantized value of the inpt. - */ -double WebRtcIsac_QuantizeLpcGain( - double* lpGains, - int* idx); - - -/****************************************************************************** - * WebRtcIsac_DequantizeLpcGain() - * - * Get the quantized values given the quantization indices. - * - * Input: - * -idx : pointer to quantization indices. - * - * Output: - * -lpcGains : quantized values of the given parametes. - */ -WebRtc_Word16 WebRtcIsac_DequantizeLpcGain( - const int* idx, - double* lpGains); - - -/****************************************************************************** - * WebRtcIsac_CorrelateLpcGain() - * - * This is the inverse of WebRtcIsac_DecorrelateLPGain(). - * - * Input: - * -data : decorrelated parameters. - * - * Output: - * -out : correlated parameters. - */ -WebRtc_Word16 WebRtcIsac_CorrelateLpcGain( - const double* data, - double* out); - - -/****************************************************************************** - * WebRtcIsac_AddMeanToLinearDomain() - * - * This is the inverse of WebRtcIsac_ToLogDomainRemoveMean(). - * - * Input: - * -lpcGain : LPC gain in log-domain & mean removed - * - * Output: - * -lpcGain : LPC gain in normal domain. - */ -WebRtc_Word16 WebRtcIsac_AddMeanToLinearDomain( - double* lpcGains); - - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_
diff --git a/src/modules/audio_coding/codecs/isac/main/source/entropy_coding.c b/src/modules/audio_coding/codecs/isac/main/source/entropy_coding.c deleted file mode 100644 index 49c695c..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/entropy_coding.c +++ /dev/null
@@ -1,2066 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * entropy_coding.c - * - * This header file defines all of the functions used to arithmetically - * encode the iSAC bistream - * - */ - - -#include "entropy_coding.h" -#include "settings.h" -#include "arith_routines.h" -#include "signal_processing_library.h" -#include "spectrum_ar_model_tables.h" -#include "lpc_tables.h" -#include "pitch_gain_tables.h" -#include "pitch_lag_tables.h" -#include "encode_lpc_swb.h" -#include "lpc_shape_swb12_tables.h" -#include "lpc_shape_swb16_tables.h" -#include "lpc_gain_swb_tables.h" -#include "os_specific_inline.h" - -#include <math.h> -#include <string.h> - -static const WebRtc_UWord16 kLpcVecPerSegmentUb12 = 5; -static const WebRtc_UWord16 kLpcVecPerSegmentUb16 = 4; - -/* CDF array for encoder bandwidth (12 vs 16 kHz) indicator. */ -static const WebRtc_UWord16 kOneBitEqualProbCdf[3] = { - 0, 32768, 65535 }; - -/* Pointer to cdf array for encoder bandwidth (12 vs 16 kHz) indicator. */ -static const WebRtc_UWord16* kOneBitEqualProbCdf_ptr[1] = { - kOneBitEqualProbCdf }; - -/* - * Initial cdf index for decoder of encoded bandwidth - * (12 vs 16 kHz) indicator. - */ -static const WebRtc_UWord16 kOneBitEqualProbInitIndex[1] = { 1 }; - - -static const int kIsSWB12 = 1; - -/* compute correlation from power spectrum */ -static void FindCorrelation(WebRtc_Word32* PSpecQ12, WebRtc_Word32* CorrQ7) { - WebRtc_Word32 summ[FRAMESAMPLES / 8]; - WebRtc_Word32 diff[FRAMESAMPLES / 8]; - const WebRtc_Word16* CS_ptrQ9; - WebRtc_Word32 sum; - int k, n; - - for (k = 0; k < FRAMESAMPLES / 8; k++) { - summ[k] = (PSpecQ12[k] + PSpecQ12[FRAMESAMPLES_QUARTER - 1 - k] + 16) >> 5; - diff[k] = (PSpecQ12[k] - PSpecQ12[FRAMESAMPLES_QUARTER - 1 - k] + 16) >> 5; - } - - sum = 2; - for (n = 0; n < FRAMESAMPLES / 8; n++) { - sum += summ[n]; - } - CorrQ7[0] = sum; - - for (k = 0; k < AR_ORDER; k += 2) { - sum = 0; - CS_ptrQ9 = WebRtcIsac_kCos[k]; - for (n = 0; n < FRAMESAMPLES / 8; n++) - sum += (CS_ptrQ9[n] * diff[n] + 256) >> 9; - CorrQ7[k + 1] = sum; - } - - for (k = 1; k < AR_ORDER; k += 2) { - sum = 0; - CS_ptrQ9 = WebRtcIsac_kCos[k]; - for (n = 0; n < FRAMESAMPLES / 8; n++) - sum += (CS_ptrQ9[n] * summ[n] + 256) >> 9; - CorrQ7[k + 1] = sum; - } -} - -/* compute inverse AR power spectrum */ -/* Changed to the function used in iSAC FIX for compatibility reasons */ -static void FindInvArSpec(const WebRtc_Word16* ARCoefQ12, - const WebRtc_Word32 gainQ10, - WebRtc_Word32* CurveQ16) { - WebRtc_Word32 CorrQ11[AR_ORDER + 1]; - WebRtc_Word32 sum, tmpGain; - WebRtc_Word32 diffQ16[FRAMESAMPLES / 8]; - const WebRtc_Word16* CS_ptrQ9; - int k, n; - WebRtc_Word16 round, shftVal = 0, sh; - - sum = 0; - for (n = 0; n < AR_ORDER + 1; n++) { - sum += WEBRTC_SPL_MUL(ARCoefQ12[n], ARCoefQ12[n]); /* Q24 */ - } - sum = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(sum, 6), - 65) + 32768, 16); /* Q8 */ - CorrQ11[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, gainQ10) + 256, 9); - - /* To avoid overflow, we shift down gainQ10 if it is large. - * We will not lose any precision */ - if (gainQ10 > 400000) { - tmpGain = WEBRTC_SPL_RSHIFT_W32(gainQ10, 3); - round = 32; - shftVal = 6; - } else { - tmpGain = gainQ10; - round = 256; - shftVal = 9; - } - - for (k = 1; k < AR_ORDER + 1; k++) { - sum = 16384; - for (n = k; n < AR_ORDER + 1; n++) - sum += WEBRTC_SPL_MUL(ARCoefQ12[n - k], ARCoefQ12[n]); /* Q24 */ - sum = WEBRTC_SPL_RSHIFT_W32(sum, 15); - CorrQ11[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, tmpGain) + round, - shftVal); - } - sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7); - for (n = 0; n < FRAMESAMPLES / 8; n++) { - CurveQ16[n] = sum; - } - for (k = 1; k < AR_ORDER; k += 2) { - for (n = 0; n < FRAMESAMPLES / 8; n++) { - CurveQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL( - WebRtcIsac_kCos[k][n], CorrQ11[k + 1]) + 2, 2); - } - } - - CS_ptrQ9 = WebRtcIsac_kCos[0]; - - /* If CorrQ11[1] too large we avoid getting overflow in the - * calculation by shifting */ - sh = WebRtcSpl_NormW32(CorrQ11[1]); - if (CorrQ11[1] == 0) { /* Use next correlation */ - sh = WebRtcSpl_NormW32(CorrQ11[2]); - } - if (sh < 9) { - shftVal = 9 - sh; - } else { - shftVal = 0; - } - for (n = 0; n < FRAMESAMPLES / 8; n++) { - diffQ16[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL( - CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[1], shftVal)) + 2, 2); - } - for (k = 2; k < AR_ORDER; k += 2) { - CS_ptrQ9 = WebRtcIsac_kCos[k]; - for (n = 0; n < FRAMESAMPLES / 8; n++) { - diffQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL( - CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[k + 1], shftVal)) + 2, 2); - } - } - - for (k = 0; k < FRAMESAMPLES / 8; k++) { - CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] - - WEBRTC_SPL_LSHIFT_W32(diffQ16[k], shftVal); - CurveQ16[k] += WEBRTC_SPL_LSHIFT_W32(diffQ16[k], shftVal); - } -} - -/* Generate array of dither samples in Q7. */ -static void GenerateDitherQ7Lb(WebRtc_Word16* bufQ7, WebRtc_UWord32 seed, - int length, WebRtc_Word16 AvgPitchGain_Q12) { - int k, shft; - WebRtc_Word16 dither1_Q7, dither2_Q7, dither_gain_Q14; - - /* This threshold should be equal to that in decode_spec(). */ - if (AvgPitchGain_Q12 < 614) { - for (k = 0; k < length - 2; k += 3) { - /* New random unsigned int. */ - seed = (seed * 196314165) + 907633515; - - /* Fixed-point dither sample between -64 and 64 (Q7). */ - /* dither = seed * 128 / 4294967295 */ - dither1_Q7 = (WebRtc_Word16)(((int)seed + 16777216) >> 25); - - /* New random unsigned int. */ - seed = (seed * 196314165) + 907633515; - - /* Fixed-point dither sample between -64 and 64. */ - dither2_Q7 = (WebRtc_Word16)(((int)seed + 16777216) >> 25); - - shft = (seed >> 25) & 15; - if (shft < 5) { - bufQ7[k] = dither1_Q7; - bufQ7[k + 1] = dither2_Q7; - bufQ7[k + 2] = 0; - } else if (shft < 10) { - bufQ7[k] = dither1_Q7; - bufQ7[k + 1] = 0; - bufQ7[k + 2] = dither2_Q7; - } else { - bufQ7[k] = 0; - bufQ7[k + 1] = dither1_Q7; - bufQ7[k + 2] = dither2_Q7; - } - } - } else { - dither_gain_Q14 = (WebRtc_Word16)(22528 - 10 * AvgPitchGain_Q12); - - /* Dither on half of the coefficients. */ - for (k = 0; k < length - 1; k += 2) { - /* New random unsigned int */ - seed = (seed * 196314165) + 907633515; - - /* Fixed-point dither sample between -64 and 64. */ - dither1_Q7 = (WebRtc_Word16)(((int)seed + 16777216) >> 25); - - /* Dither sample is placed in either even or odd index. */ - shft = (seed >> 25) & 1; /* Either 0 or 1 */ - - bufQ7[k + shft] = (((dither_gain_Q14 * dither1_Q7) + 8192) >> 14); - bufQ7[k + 1 - shft] = 0; - } - } -} - - - -/****************************************************************************** - * GenerateDitherQ7LbUB() - * - * generate array of dither samples in Q7 There are less zeros in dither - * vector compared to GenerateDitherQ7Lb. - * - * A uniform random number generator with the range of [-64 64] is employed - * but the generated dithers are scaled by 0.35, a heuristic scaling. - * - * Input: - * -seed : the initial seed for the random number generator. - * -length : the number of dither values to be generated. - * - * Output: - * -bufQ7 : pointer to a buffer where dithers are written to. - */ -static void GenerateDitherQ7LbUB( - WebRtc_Word16* bufQ7, - WebRtc_UWord32 seed, - int length) { - int k; - for (k = 0; k < length; k++) { - /* new random unsigned int */ - seed = (seed * 196314165) + 907633515; - - /* Fixed-point dither sample between -64 and 64 (Q7). */ - /* bufQ7 = seed * 128 / 4294967295 */ - bufQ7[k] = (WebRtc_Word16)(((int)seed + 16777216) >> 25); - - /* Scale by 0.35. */ - bufQ7[k] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(bufQ7[k], 2048, 13); - } -} - -/* - * Function to decode the complex spectrum from the bit stream - * returns the total number of bytes in the stream. - */ -int WebRtcIsac_DecodeSpec(Bitstr* streamdata, WebRtc_Word16 AvgPitchGain_Q12, - enum ISACBand band, double* fr, double* fi) { - WebRtc_Word16 DitherQ7[FRAMESAMPLES]; - WebRtc_Word16 data[FRAMESAMPLES]; - WebRtc_Word32 invARSpec2_Q16[FRAMESAMPLES_QUARTER]; - WebRtc_UWord16 invARSpecQ8[FRAMESAMPLES_QUARTER]; - WebRtc_Word16 ARCoefQ12[AR_ORDER + 1]; - WebRtc_Word16 RCQ15[AR_ORDER]; - WebRtc_Word16 gainQ10; - WebRtc_Word32 gain2_Q10, res; - WebRtc_Word32 in_sqrt; - WebRtc_Word32 newRes; - int k, len, i; - int is_12khz = !kIsSWB12; - int num_dft_coeff = FRAMESAMPLES; - /* Create dither signal. */ - if (band == kIsacLowerBand) { - GenerateDitherQ7Lb(DitherQ7, streamdata->W_upper, FRAMESAMPLES, - AvgPitchGain_Q12); - } else { - GenerateDitherQ7LbUB(DitherQ7, streamdata->W_upper, FRAMESAMPLES); - if (band == kIsacUpperBand12) { - is_12khz = kIsSWB12; - num_dft_coeff = FRAMESAMPLES_HALF; - } - } - - /* Decode model parameters. */ - if (WebRtcIsac_DecodeRc(streamdata, RCQ15) < 0) - return -ISAC_RANGE_ERROR_DECODE_SPECTRUM; - - WebRtcSpl_ReflCoefToLpc(RCQ15, AR_ORDER, ARCoefQ12); - - if (WebRtcIsac_DecodeGain2(streamdata, &gain2_Q10) < 0) - return -ISAC_RANGE_ERROR_DECODE_SPECTRUM; - - /* Compute inverse AR power spectrum. */ - FindInvArSpec(ARCoefQ12, gain2_Q10, invARSpec2_Q16); - - /* Convert to magnitude spectrum, - * by doing square-roots (modified from SPLIB). */ - res = 1 << (WebRtcSpl_GetSizeInBits(invARSpec2_Q16[0]) >> 1); - for (k = 0; k < FRAMESAMPLES_QUARTER; k++) { - in_sqrt = invARSpec2_Q16[k]; - i = 10; - - /* Negative values make no sense for a real sqrt-function. */ - if (in_sqrt < 0) - in_sqrt = -in_sqrt; - - newRes = (in_sqrt / res + res) >> 1; - do { - res = newRes; - newRes = (in_sqrt / res + res) >> 1; - } while (newRes != res && i-- > 0); - - invARSpecQ8[k] = (WebRtc_Word16)newRes; - } - - len = WebRtcIsac_DecLogisticMulti2(data, streamdata, invARSpecQ8, DitherQ7, - num_dft_coeff, is_12khz); - /* Arithmetic decoding of spectrum. */ - if (len < 1) { - return -ISAC_RANGE_ERROR_DECODE_SPECTRUM; - } - - switch (band) { - case kIsacLowerBand: { - /* Scale down spectral samples with low SNR. */ - WebRtc_Word32 p1; - WebRtc_Word32 p2; - if (AvgPitchGain_Q12 <= 614) { - p1 = 30 << 10; - p2 = 32768 + (33 << 16); - } else { - p1 = 36 << 10; - p2 = 32768 + (40 << 16); - } - for (k = 0; k < FRAMESAMPLES; k += 4) { - gainQ10 = WebRtcSpl_DivW32W16ResW16(p1, (WebRtc_Word16)( - (invARSpec2_Q16[k >> 2] + p2) >> 16)); - *fr++ = (double)((data[ k ] * gainQ10 + 512) >> 10) / 128.0; - *fi++ = (double)((data[k + 1] * gainQ10 + 512) >> 10) / 128.0; - *fr++ = (double)((data[k + 2] * gainQ10 + 512) >> 10) / 128.0; - *fi++ = (double)((data[k + 3] * gainQ10 + 512) >> 10) / 128.0; - } - break; - } - case kIsacUpperBand12: { - for (k = 0, i = 0; k < FRAMESAMPLES_HALF; k += 4) { - fr[i] = (double)data[ k ] / 128.0; - fi[i] = (double)data[k + 1] / 128.0; - i++; - fr[i] = (double)data[k + 2] / 128.0; - fi[i] = (double)data[k + 3] / 128.0; - i++; - } - /* The second half of real and imaginary coefficients is zero. This is - * due to using the old FFT module which requires two signals as input - * while in 0-12 kHz mode we only have 8-12 kHz band, and the second - * signal is set to zero. */ - memset(&fr[FRAMESAMPLES_QUARTER], 0, FRAMESAMPLES_QUARTER * - sizeof(double)); - memset(&fi[FRAMESAMPLES_QUARTER], 0, FRAMESAMPLES_QUARTER * - sizeof(double)); - break; - } - case kIsacUpperBand16: { - for (i = 0, k = 0; k < FRAMESAMPLES; k += 4, i++) { - fr[i] = (double)data[ k ] / 128.0; - fi[i] = (double)data[k + 1] / 128.0; - fr[(FRAMESAMPLES_HALF) - 1 - i] = (double)data[k + 2] / 128.0; - fi[(FRAMESAMPLES_HALF) - 1 - i] = (double)data[k + 3] / 128.0; - } - break; - } - } - return len; -} - - -int WebRtcIsac_EncodeSpec(const WebRtc_Word16* fr, const WebRtc_Word16* fi, - WebRtc_Word16 AvgPitchGain_Q12, enum ISACBand band, - Bitstr* streamdata) { - WebRtc_Word16 ditherQ7[FRAMESAMPLES]; - WebRtc_Word16 dataQ7[FRAMESAMPLES]; - WebRtc_Word32 PSpec[FRAMESAMPLES_QUARTER]; - WebRtc_Word32 invARSpec2_Q16[FRAMESAMPLES_QUARTER]; - WebRtc_UWord16 invARSpecQ8[FRAMESAMPLES_QUARTER]; - WebRtc_Word32 CorrQ7[AR_ORDER + 1]; - WebRtc_Word32 CorrQ7_norm[AR_ORDER + 1]; - WebRtc_Word16 RCQ15[AR_ORDER]; - WebRtc_Word16 ARCoefQ12[AR_ORDER + 1]; - WebRtc_Word32 gain2_Q10; - WebRtc_Word16 val; - WebRtc_Word32 nrg, res; - WebRtc_UWord32 sum; - WebRtc_Word32 in_sqrt; - WebRtc_Word32 newRes; - WebRtc_Word16 err; - WebRtc_UWord32 nrg_u32; - int shift_var; - int k, n, j, i; - int is_12khz = !kIsSWB12; - int num_dft_coeff = FRAMESAMPLES; - - /* Create dither signal. */ - if (band == kIsacLowerBand) { - GenerateDitherQ7Lb(ditherQ7, streamdata->W_upper, FRAMESAMPLES, - AvgPitchGain_Q12); - } else { - GenerateDitherQ7LbUB(ditherQ7, streamdata->W_upper, FRAMESAMPLES); - if (band == kIsacUpperBand12) { - is_12khz = kIsSWB12; - num_dft_coeff = FRAMESAMPLES_HALF; - } - } - - /* add dither and quantize, and compute power spectrum */ - switch (band) { - case kIsacLowerBand: { - for (k = 0; k < FRAMESAMPLES; k += 4) { - val = ((*fr++ + ditherQ7[k] + 64) & 0xFF80) - ditherQ7[k]; - dataQ7[k] = val; - sum = val * val; - - val = ((*fi++ + ditherQ7[k + 1] + 64) & 0xFF80) - ditherQ7[k + 1]; - dataQ7[k + 1] = val; - sum += val * val; - - val = ((*fr++ + ditherQ7[k + 2] + 64) & 0xFF80) - ditherQ7[k + 2]; - dataQ7[k + 2] = val; - sum += val * val; - - val = ((*fi++ + ditherQ7[k + 3] + 64) & 0xFF80) - ditherQ7[k + 3]; - dataQ7[k + 3] = val; - sum += val * val; - - PSpec[k >> 2] = sum >> 2; - } - break; - } - case kIsacUpperBand12: { - for (k = 0, j = 0; k < FRAMESAMPLES_HALF; k += 4) { - val = ((*fr++ + ditherQ7[k] + 64) & 0xFF80) - ditherQ7[k]; - dataQ7[k] = val; - sum = val * val; - - val = ((*fi++ + ditherQ7[k + 1] + 64) & 0xFF80) - ditherQ7[k + 1]; - dataQ7[k + 1] = val; - sum += val * val; - - PSpec[j++] = sum >> 1; - - val = ((*fr++ + ditherQ7[k + 2] + 64) & 0xFF80) - ditherQ7[k + 2]; - dataQ7[k + 2] = val; - sum = val * val; - - val = ((*fi++ + ditherQ7[k + 3] + 64) & 0xFF80) - ditherQ7[k + 3]; - dataQ7[k + 3] = val; - sum += val * val; - - PSpec[j++] = sum >> 1; - } - break; - } - case kIsacUpperBand16: { - for (j = 0, k = 0; k < FRAMESAMPLES; k += 4, j++) { - val = ((fr[j] + ditherQ7[k] + 64) & 0xFF80) - ditherQ7[k]; - dataQ7[k] = val; - sum = val * val; - - val = ((fi[j] + ditherQ7[k + 1] + 64) & 0xFF80) - ditherQ7[k + 1]; - dataQ7[k + 1] = val; - sum += val * val; - - val = ((fr[(FRAMESAMPLES_HALF) - 1 - j] + ditherQ7[k + 2] + 64) & - 0xFF80) - ditherQ7[k + 2]; - dataQ7[k + 2] = val; - sum += val * val; - - val = ((fi[(FRAMESAMPLES_HALF) - 1 - j] + ditherQ7[k + 3] + 64) & - 0xFF80) - ditherQ7[k + 3]; - dataQ7[k + 3] = val; - sum += val * val; - - PSpec[k >> 2] = sum >> 2; - } - break; - } - } - - /* compute correlation from power spectrum */ - FindCorrelation(PSpec, CorrQ7); - - /* Find AR coefficients */ - /* Aumber of bit shifts to 14-bit normalize CorrQ7[0] - * (leaving room for sign) */ - shift_var = WebRtcSpl_NormW32(CorrQ7[0]) - 18; - - if (shift_var > 0) { - for (k = 0; k < AR_ORDER + 1; k++) { - CorrQ7_norm[k] = CorrQ7[k] << shift_var; - } - } else { - for (k = 0; k < AR_ORDER + 1; k++) { - CorrQ7_norm[k] = CorrQ7[k] >> (-shift_var); - } - } - - /* Find RC coefficients. */ - WebRtcSpl_AutoCorrToReflCoef(CorrQ7_norm, AR_ORDER, RCQ15); - - /* Quantize & code RC Coefficient. */ - WebRtcIsac_EncodeRc(RCQ15, streamdata); - - /* RC -> AR coefficients */ - WebRtcSpl_ReflCoefToLpc(RCQ15, AR_ORDER, ARCoefQ12); - - /* Compute ARCoef' * Corr * ARCoef in Q19. */ - nrg = 0; - for (j = 0; j <= AR_ORDER; j++) { - for (n = 0; n <= j; n++) { - nrg += (ARCoefQ12[j] * ((CorrQ7_norm[j - n] * ARCoefQ12[n] + 256) >> 9) + - 4) >> 3; - } - for (n = j + 1; n <= AR_ORDER; n++) { - nrg += (ARCoefQ12[j] * ((CorrQ7_norm[n - j] * ARCoefQ12[n] + 256) >> 9) + - 4) >> 3; - } - } - - nrg_u32 = (WebRtc_UWord32)nrg; - if (shift_var > 0) { - nrg_u32 = nrg_u32 >> shift_var; - } else { - nrg_u32 = nrg_u32 << (-shift_var); - } - if (nrg_u32 > 0x7FFFFFFF) { - nrg = 0x7FFFFFFF; - } else { - nrg = (WebRtc_Word32)nrg_u32; - } - /* Also shifts 31 bits to the left! */ - gain2_Q10 = WebRtcSpl_DivResultInQ31(FRAMESAMPLES_QUARTER, nrg); - - /* Quantize & code gain2_Q10. */ - if (WebRtcIsac_EncodeGain2(&gain2_Q10, streamdata)) { - return -1; - } - - /* Compute inverse AR power spectrum. */ - FindInvArSpec(ARCoefQ12, gain2_Q10, invARSpec2_Q16); - /* Convert to magnitude spectrum, by doing square-roots - * (modified from SPLIB). */ - res = 1 << (WebRtcSpl_GetSizeInBits(invARSpec2_Q16[0]) >> 1); - for (k = 0; k < FRAMESAMPLES_QUARTER; k++) { - in_sqrt = invARSpec2_Q16[k]; - i = 10; - /* Negative values make no sense for a real sqrt-function. */ - if (in_sqrt < 0) { - in_sqrt = -in_sqrt; - } - newRes = (in_sqrt / res + res) >> 1; - do { - res = newRes; - newRes = (in_sqrt / res + res) >> 1; - } while (newRes != res && i-- > 0); - - invARSpecQ8[k] = (WebRtc_Word16)newRes; - } - /* arithmetic coding of spectrum */ - err = WebRtcIsac_EncLogisticMulti2(streamdata, dataQ7, invARSpecQ8, - num_dft_coeff, is_12khz); - if (err < 0) { - return (err); - } - return 0; -} - - -/* step-up */ -void WebRtcIsac_Rc2Poly(double* RC, int N, double* a) { - int m, k; - double tmp[MAX_AR_MODEL_ORDER]; - - a[0] = 1.0; - tmp[0] = 1.0; - for (m = 1; m <= N; m++) { - /* copy */ - memcpy(&tmp[1], &a[1], (m - 1) * sizeof(double)); - a[m] = RC[m - 1]; - for (k = 1; k < m; k++) { - a[k] += RC[m - 1] * tmp[m - k]; - } - } - return; -} - -/* step-down */ -void WebRtcIsac_Poly2Rc(double* a, int N, double* RC) { - int m, k; - double tmp[MAX_AR_MODEL_ORDER]; - double tmp_inv; - - RC[N - 1] = a[N]; - for (m = N - 1; m > 0; m--) { - tmp_inv = 1.0 / (1.0 - RC[m] * RC[m]); - for (k = 1; k <= m; k++) { - tmp[k] = (a[k] - RC[m] * a[m - k + 1]) * tmp_inv; - } - - memcpy(&a[1], &tmp[1], (m - 1) * sizeof(double)); - RC[m - 1] = tmp[m]; - } - return; -} - - -#define MAX_ORDER 100 - -/* Matlab's LAR definition */ -void WebRtcIsac_Rc2Lar(const double* refc, double* lar, int order) { - int k; - for (k = 0; k < order; k++) { - lar[k] = log((1 + refc[k]) / (1 - refc[k])); - } -} - - -void WebRtcIsac_Lar2Rc(const double* lar, double* refc, int order) { - int k; - double tmp; - - for (k = 0; k < order; k++) { - tmp = exp(lar[k]); - refc[k] = (tmp - 1) / (tmp + 1); - } -} - -void WebRtcIsac_Poly2Lar(double* lowband, int orderLo, double* hiband, - int orderHi, int Nsub, double* lars) { - int k; - double rc[MAX_ORDER], *inpl, *inph, *outp; - - inpl = lowband; - inph = hiband; - outp = lars; - for (k = 0; k < Nsub; k++) { - /* gains */ - outp[0] = inpl[0]; - outp[1] = inph[0]; - outp += 2; - - /* Low band */ - inpl[0] = 1.0; - WebRtcIsac_Poly2Rc(inpl, orderLo, rc); - WebRtcIsac_Rc2Lar(rc, outp, orderLo); - outp += orderLo; - - /* High band */ - inph[0] = 1.0; - WebRtcIsac_Poly2Rc(inph, orderHi, rc); - WebRtcIsac_Rc2Lar(rc, outp, orderHi); - outp += orderHi; - - inpl += orderLo + 1; - inph += orderHi + 1; - } -} - - -WebRtc_Word16 WebRtcIsac_Poly2LarUB(double* lpcVecs, WebRtc_Word16 bandwidth) { - double poly[MAX_ORDER]; - double rc[MAX_ORDER]; - double* ptrIO; - WebRtc_Word16 vecCntr; - WebRtc_Word16 vecSize; - WebRtc_Word16 numVec; - - vecSize = UB_LPC_ORDER; - switch (bandwidth) { - case isac12kHz: { - numVec = UB_LPC_VEC_PER_FRAME; - break; - } - case isac16kHz: { - numVec = UB16_LPC_VEC_PER_FRAME; - break; - } - default: - return -1; - } - - ptrIO = lpcVecs; - poly[0] = 1.0; - for (vecCntr = 0; vecCntr < numVec; vecCntr++) { - memcpy(&poly[1], ptrIO, sizeof(double) * vecSize); - WebRtcIsac_Poly2Rc(poly, vecSize, rc); - WebRtcIsac_Rc2Lar(rc, ptrIO, vecSize); - ptrIO += vecSize; - } - return 0; -} - - -void WebRtcIsac_Lar2Poly(double* lars, double* lowband, int orderLo, - double* hiband, int orderHi, int Nsub) { - int k, orderTot; - double rc[MAX_ORDER], *outpl, *outph, *inp; - - orderTot = (orderLo + orderHi + 2); - outpl = lowband; - outph = hiband; - /* First two elements of 'inp' store gains*/ - inp = lars; - for (k = 0; k < Nsub; k++) { - /* Low band */ - WebRtcIsac_Lar2Rc(&inp[2], rc, orderLo); - WebRtcIsac_Rc2Poly(rc, orderLo, outpl); - - /* High band */ - WebRtcIsac_Lar2Rc(&inp[orderLo + 2], rc, orderHi); - WebRtcIsac_Rc2Poly(rc, orderHi, outph); - - /* gains */ - outpl[0] = inp[0]; - outph[0] = inp[1]; - - outpl += orderLo + 1; - outph += orderHi + 1; - inp += orderTot; - } -} - -/* - * assumes 2 LAR vectors interpolates to 'numPolyVec' A-polynomials - * Note: 'numPolyVecs' includes the first and the last point of the interval - */ -void WebRtcIsac_Lar2PolyInterpolUB(double* larVecs, double* percepFilterParams, - int numPolyVecs) { - int polyCntr, coeffCntr; - double larInterpol[UB_LPC_ORDER]; - double rc[UB_LPC_ORDER]; - double delta[UB_LPC_ORDER]; - - /* calculate the step-size for linear interpolation coefficients */ - for (coeffCntr = 0; coeffCntr < UB_LPC_ORDER; coeffCntr++) { - delta[coeffCntr] = (larVecs[UB_LPC_ORDER + coeffCntr] - - larVecs[coeffCntr]) / (numPolyVecs - 1); - } - - for (polyCntr = 0; polyCntr < numPolyVecs; polyCntr++) { - for (coeffCntr = 0; coeffCntr < UB_LPC_ORDER; coeffCntr++) { - larInterpol[coeffCntr] = larVecs[coeffCntr] + - delta[coeffCntr] * polyCntr; - } - WebRtcIsac_Lar2Rc(larInterpol, rc, UB_LPC_ORDER); - - /* convert to A-polynomial, the following function returns A[0] = 1; - * which is written where gains had to be written. Then we write the - * gain (outside this function). This way we say a memcpy. */ - WebRtcIsac_Rc2Poly(rc, UB_LPC_ORDER, percepFilterParams); - percepFilterParams += (UB_LPC_ORDER + 1); - } -} - -int WebRtcIsac_DecodeLpc(Bitstr* streamdata, double* LPCCoef_lo, - double* LPCCoef_hi) { - double lars[KLT_ORDER_GAIN + KLT_ORDER_SHAPE]; - int err; - - err = WebRtcIsac_DecodeLpcCoef(streamdata, lars); - if (err < 0) { - return -ISAC_RANGE_ERROR_DECODE_LPC; - } - WebRtcIsac_Lar2Poly(lars, LPCCoef_lo, ORDERLO, LPCCoef_hi, ORDERHI, - SUBFRAMES); - return 0; -} - -WebRtc_Word16 WebRtcIsac_DecodeInterpolLpcUb(Bitstr* streamdata, - double* percepFilterParams, - WebRtc_Word16 bandwidth) { - double lpcCoeff[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - int err; - int interpolCntr; - int subframeCntr; - WebRtc_Word16 numSegments; - WebRtc_Word16 numVecPerSegment; - WebRtc_Word16 numGains; - - double percepFilterGains[SUBFRAMES << 1]; - double* ptrOutParam = percepFilterParams; - - err = WebRtcIsac_DecodeLpcCoefUB(streamdata, lpcCoeff, percepFilterGains, - bandwidth); - if (err < 0) { - return -ISAC_RANGE_ERROR_DECODE_LPC; - } - - switch (bandwidth) { - case isac12kHz: { - numGains = SUBFRAMES; - numSegments = UB_LPC_VEC_PER_FRAME - 1; - numVecPerSegment = kLpcVecPerSegmentUb12; - break; - } - case isac16kHz: { - numGains = SUBFRAMES << 1; - numSegments = UB16_LPC_VEC_PER_FRAME - 1; - numVecPerSegment = kLpcVecPerSegmentUb16; - break; - } - default: - return -1; - } - - for (interpolCntr = 0; interpolCntr < numSegments; interpolCntr++) { - WebRtcIsac_Lar2PolyInterpolUB(&lpcCoeff[interpolCntr * UB_LPC_ORDER], - ptrOutParam, numVecPerSegment + 1); - ptrOutParam += (numVecPerSegment * (UB_LPC_ORDER + 1)); - } - - ptrOutParam = percepFilterParams; - - if (bandwidth == isac16kHz) { - ptrOutParam += (1 + UB_LPC_ORDER); - } - - for (subframeCntr = 0; subframeCntr < numGains; subframeCntr++) { - *ptrOutParam = percepFilterGains[subframeCntr]; - ptrOutParam += (1 + UB_LPC_ORDER); - } - return 0; -} - - -/* decode & dequantize LPC Coef */ -int WebRtcIsac_DecodeLpcCoef(Bitstr* streamdata, double* LPCCoef) { - int j, k, n, pos, pos2, posg, poss, offsg, offss, offs2; - int index_g[KLT_ORDER_GAIN], index_s[KLT_ORDER_SHAPE]; - double tmpcoeffs_g[KLT_ORDER_GAIN], tmpcoeffs_s[KLT_ORDER_SHAPE]; - double tmpcoeffs2_g[KLT_ORDER_GAIN], tmpcoeffs2_s[KLT_ORDER_SHAPE]; - double sum; - int err; - int model = 1; - - /* entropy decoding of model number */ - /* We are keeping this for backward compatibility of bit-streams. */ - err = WebRtcIsac_DecHistOneStepMulti(&model, streamdata, - WebRtcIsac_kQKltModelCdfPtr, - WebRtcIsac_kQKltModelInitIndex, 1); - if (err < 0) { - return err; - } - /* Only accepted value of model is 0. It is kept in bit-stream for backward - * compatibility. */ - if (model != 0) { - return -ISAC_DISALLOWED_LPC_MODEL; - } - - /* entropy decoding of quantization indices */ - err = WebRtcIsac_DecHistOneStepMulti( - index_s, streamdata, WebRtcIsac_kQKltCdfPtrShape, - WebRtcIsac_kQKltInitIndexShape, KLT_ORDER_SHAPE); - if (err < 0) { - return err; - } - err = WebRtcIsac_DecHistOneStepMulti( - index_g, streamdata, WebRtcIsac_kQKltCdfPtrGain, - WebRtcIsac_kQKltInitIndexGain, KLT_ORDER_GAIN); - if (err < 0) { - return err; - } - - /* find quantization levels for coefficients */ - for (k = 0; k < KLT_ORDER_SHAPE; k++) { - tmpcoeffs_s[k] = - WebRtcIsac_kQKltLevelsShape[WebRtcIsac_kQKltOffsetShape[k] + - index_s[k]]; - } - for (k = 0; k < KLT_ORDER_GAIN; k++) { - tmpcoeffs_g[k] = WebRtcIsac_kQKltLevelsGain[WebRtcIsac_kQKltOffsetGain[k] + - index_g[k]]; - } - - /* Inverse KLT */ - - /* Left transform, transpose matrix! */ - offsg = 0; - offss = 0; - posg = 0; - poss = 0; - for (j = 0; j < SUBFRAMES; j++) { - offs2 = 0; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = offsg; - pos2 = offs2; - for (n = 0; n < LPC_GAIN_ORDER; n++) { - sum += tmpcoeffs_g[pos++] * WebRtcIsac_kKltT1Gain[pos2++]; - } - tmpcoeffs2_g[posg++] = sum; - offs2 += LPC_GAIN_ORDER; - } - offs2 = 0; - for (k = 0; k < LPC_SHAPE_ORDER; k++) { - sum = 0; - pos = offss; - pos2 = offs2; - for (n = 0; n < LPC_SHAPE_ORDER; n++) { - sum += tmpcoeffs_s[pos++] * WebRtcIsac_kKltT1Shape[pos2++]; - } - tmpcoeffs2_s[poss++] = sum; - offs2 += LPC_SHAPE_ORDER; - } - offsg += LPC_GAIN_ORDER; - offss += LPC_SHAPE_ORDER; - } - - /* Right transform, transpose matrix */ - offsg = 0; - offss = 0; - posg = 0; - poss = 0; - for (j = 0; j < SUBFRAMES; j++) { - posg = offsg; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = k; - pos2 = j; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_g[pos] * WebRtcIsac_kKltT2Gain[pos2]; - pos += LPC_GAIN_ORDER; - pos2 += SUBFRAMES; - - } - tmpcoeffs_g[posg++] = sum; - } - poss = offss; - for (k = 0; k < LPC_SHAPE_ORDER; k++) { - sum = 0; - pos = k; - pos2 = j; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_s[pos] * WebRtcIsac_kKltT2Shape[pos2]; - pos += LPC_SHAPE_ORDER; - pos2 += SUBFRAMES; - } - tmpcoeffs_s[poss++] = sum; - } - offsg += LPC_GAIN_ORDER; - offss += LPC_SHAPE_ORDER; - } - - /* scaling, mean addition, and gain restoration */ - posg = 0; - poss = 0; - pos = 0; - for (k = 0; k < SUBFRAMES; k++) { - /* log gains */ - LPCCoef[pos] = tmpcoeffs_g[posg] / LPC_GAIN_SCALE; - LPCCoef[pos] += WebRtcIsac_kLpcMeansGain[posg]; - LPCCoef[pos] = exp(LPCCoef[pos]); - pos++; - posg++; - LPCCoef[pos] = tmpcoeffs_g[posg] / LPC_GAIN_SCALE; - LPCCoef[pos] += WebRtcIsac_kLpcMeansGain[posg]; - LPCCoef[pos] = exp(LPCCoef[pos]); - pos++; - posg++; - - /* Low-band LAR coefficients. */ - for (n = 0; n < LPC_LOBAND_ORDER; n++, pos++, poss++) { - LPCCoef[pos] = tmpcoeffs_s[poss] / LPC_LOBAND_SCALE; - LPCCoef[pos] += WebRtcIsac_kLpcMeansShape[poss]; - } - - /* High-band LAR coefficients. */ - for (n = 0; n < LPC_HIBAND_ORDER; n++, pos++, poss++) { - LPCCoef[pos] = tmpcoeffs_s[poss] / LPC_HIBAND_SCALE; - LPCCoef[pos] += WebRtcIsac_kLpcMeansShape[poss]; - } - } - return 0; -} - -/* Encode LPC in LAR domain. */ -void WebRtcIsac_EncodeLar(double* LPCCoef, Bitstr* streamdata, - ISAC_SaveEncData_t* encData) { - int j, k, n, pos, pos2, poss, offss, offs2; - int index_s[KLT_ORDER_SHAPE]; - int index_ovr_s[KLT_ORDER_SHAPE]; - double tmpcoeffs_s[KLT_ORDER_SHAPE]; - double tmpcoeffs2_s[KLT_ORDER_SHAPE]; - double sum; - const int kModel = 0; - - /* Mean removal and scaling. */ - poss = 0; - pos = 0; - for (k = 0; k < SUBFRAMES; k++) { - /* First two element are gains, move over them. */ - pos += 2; - - /* Low-band LAR coefficients. */ - for (n = 0; n < LPC_LOBAND_ORDER; n++, poss++, pos++) { - tmpcoeffs_s[poss] = LPCCoef[pos] - WebRtcIsac_kLpcMeansShape[poss]; - tmpcoeffs_s[poss] *= LPC_LOBAND_SCALE; - } - - /* High-band LAR coefficients. */ - for (n = 0; n < LPC_HIBAND_ORDER; n++, poss++, pos++) { - tmpcoeffs_s[poss] = LPCCoef[pos] - WebRtcIsac_kLpcMeansShape[poss]; - tmpcoeffs_s[poss] *= LPC_HIBAND_SCALE; - } - } - - /* KLT */ - - /* Left transform. */ - offss = 0; - for (j = 0; j < SUBFRAMES; j++) { - poss = offss; - for (k = 0; k < LPC_SHAPE_ORDER; k++) { - sum = 0; - pos = offss; - pos2 = k; - for (n = 0; n < LPC_SHAPE_ORDER; n++) { - sum += tmpcoeffs_s[pos++] * WebRtcIsac_kKltT1Shape[pos2]; - pos2 += LPC_SHAPE_ORDER; - } - tmpcoeffs2_s[poss++] = sum; - } - offss += LPC_SHAPE_ORDER; - } - - /* Right transform. */ - offss = 0; - offs2 = 0; - for (j = 0; j < SUBFRAMES; j++) { - poss = offss; - for (k = 0; k < LPC_SHAPE_ORDER; k++) { - sum = 0; - pos = k; - pos2 = offs2; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_s[pos] * WebRtcIsac_kKltT2Shape[pos2++]; - pos += LPC_SHAPE_ORDER; - } - tmpcoeffs_s[poss++] = sum; - } - offs2 += SUBFRAMES; - offss += LPC_SHAPE_ORDER; - } - - /* Quantize coefficients. */ - for (k = 0; k < KLT_ORDER_SHAPE; k++) { - index_s[k] = (WebRtcIsac_lrint(tmpcoeffs_s[k] / KLT_STEPSIZE)) + - WebRtcIsac_kQKltQuantMinShape[k]; - if (index_s[k] < 0) { - index_s[k] = 0; - } else if (index_s[k] > WebRtcIsac_kQKltMaxIndShape[k]) { - index_s[k] = WebRtcIsac_kQKltMaxIndShape[k]; - } - index_ovr_s[k] = WebRtcIsac_kQKltOffsetShape[k] + index_s[k]; - } - - - /* Only one model remains in this version of the code, kModel = 0. We - * are keeping for bit-streams to be backward compatible. */ - /* entropy coding of model number */ - WebRtcIsac_EncHistMulti(streamdata, &kModel, WebRtcIsac_kQKltModelCdfPtr, 1); - - /* Save data for creation of multiple bit streams */ - /* Entropy coding of quantization indices - shape only. */ - WebRtcIsac_EncHistMulti(streamdata, index_s, WebRtcIsac_kQKltCdfPtrShape, - KLT_ORDER_SHAPE); - - /* Save data for creation of multiple bit streams. */ - for (k = 0; k < KLT_ORDER_SHAPE; k++) { - encData->LPCindex_s[KLT_ORDER_SHAPE * encData->startIdx + k] = index_s[k]; - } - - /* Find quantization levels for shape coefficients. */ - for (k = 0; k < KLT_ORDER_SHAPE; k++) { - tmpcoeffs_s[k] = WebRtcIsac_kQKltLevelsShape[index_ovr_s[k]]; - } - /* Inverse KLT. */ - /* Left transform, transpose matrix.! */ - offss = 0; - poss = 0; - for (j = 0; j < SUBFRAMES; j++) { - offs2 = 0; - for (k = 0; k < LPC_SHAPE_ORDER; k++) { - sum = 0; - pos = offss; - pos2 = offs2; - for (n = 0; n < LPC_SHAPE_ORDER; n++) { - sum += tmpcoeffs_s[pos++] * WebRtcIsac_kKltT1Shape[pos2++]; - } - tmpcoeffs2_s[poss++] = sum; - offs2 += LPC_SHAPE_ORDER; - } - offss += LPC_SHAPE_ORDER; - } - - /* Right transform, Transpose matrix */ - offss = 0; - poss = 0; - for (j = 0; j < SUBFRAMES; j++) { - poss = offss; - for (k = 0; k < LPC_SHAPE_ORDER; k++) { - sum = 0; - pos = k; - pos2 = j; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_s[pos] * WebRtcIsac_kKltT2Shape[pos2]; - pos += LPC_SHAPE_ORDER; - pos2 += SUBFRAMES; - } - tmpcoeffs_s[poss++] = sum; - } - offss += LPC_SHAPE_ORDER; - } - - /* Scaling, mean addition, and gain restoration. */ - poss = 0; - pos = 0; - for (k = 0; k < SUBFRAMES; k++) { - /* Ignore gains. */ - pos += 2; - - /* Low band LAR coefficients. */ - for (n = 0; n < LPC_LOBAND_ORDER; n++, pos++, poss++) { - LPCCoef[pos] = tmpcoeffs_s[poss] / LPC_LOBAND_SCALE; - LPCCoef[pos] += WebRtcIsac_kLpcMeansShape[poss]; - } - - /* High band LAR coefficients. */ - for (n = 0; n < LPC_HIBAND_ORDER; n++, pos++, poss++) { - LPCCoef[pos] = tmpcoeffs_s[poss] / LPC_HIBAND_SCALE; - LPCCoef[pos] += WebRtcIsac_kLpcMeansShape[poss]; - } - } -} - - -void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo, double* LPCCoef_hi, - Bitstr* streamdata, ISAC_SaveEncData_t* encData) { - double lars[KLT_ORDER_GAIN + KLT_ORDER_SHAPE]; - int k; - - WebRtcIsac_Poly2Lar(LPCCoef_lo, ORDERLO, LPCCoef_hi, ORDERHI, SUBFRAMES, - lars); - WebRtcIsac_EncodeLar(lars, streamdata, encData); - WebRtcIsac_Lar2Poly(lars, LPCCoef_lo, ORDERLO, LPCCoef_hi, ORDERHI, - SUBFRAMES); - /* Save data for creation of multiple bit streams (and transcoding). */ - for (k = 0; k < (ORDERLO + 1)*SUBFRAMES; k++) { - encData->LPCcoeffs_lo[(ORDERLO + 1)*SUBFRAMES * encData->startIdx + k] = - LPCCoef_lo[k]; - } - for (k = 0; k < (ORDERHI + 1)*SUBFRAMES; k++) { - encData->LPCcoeffs_hi[(ORDERHI + 1)*SUBFRAMES * encData->startIdx + k] = - LPCCoef_hi[k]; - } -} - - -WebRtc_Word16 WebRtcIsac_EncodeLpcUB(double* lpcVecs, Bitstr* streamdata, - double* interpolLPCCoeff, - WebRtc_Word16 bandwidth, - ISACUBSaveEncDataStruct* encData) { - double U[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - int idx[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - int interpolCntr; - - WebRtcIsac_Poly2LarUB(lpcVecs, bandwidth); - WebRtcIsac_RemoveLarMean(lpcVecs, bandwidth); - WebRtcIsac_DecorrelateIntraVec(lpcVecs, U, bandwidth); - WebRtcIsac_DecorrelateInterVec(U, lpcVecs, bandwidth); - WebRtcIsac_QuantizeUncorrLar(lpcVecs, idx, bandwidth); - - WebRtcIsac_CorrelateInterVec(lpcVecs, U, bandwidth); - WebRtcIsac_CorrelateIntraVec(U, lpcVecs, bandwidth); - WebRtcIsac_AddLarMean(lpcVecs, bandwidth); - - switch (bandwidth) { - case isac12kHz: { - /* Store the indices to be used for multiple encoding. */ - memcpy(encData->indexLPCShape, idx, UB_LPC_ORDER * - UB_LPC_VEC_PER_FRAME * sizeof(int)); - WebRtcIsac_EncHistMulti(streamdata, idx, WebRtcIsac_kLpcShapeCdfMatUb12, - UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME); - for (interpolCntr = 0; interpolCntr < UB_INTERPOL_SEGMENTS; - interpolCntr++) { - WebRtcIsac_Lar2PolyInterpolUB(lpcVecs, interpolLPCCoeff, - kLpcVecPerSegmentUb12 + 1); - lpcVecs += UB_LPC_ORDER; - interpolLPCCoeff += (kLpcVecPerSegmentUb12 * (UB_LPC_ORDER + 1)); - } - break; - } - case isac16kHz: { - /* Store the indices to be used for multiple encoding. */ - memcpy(encData->indexLPCShape, idx, UB_LPC_ORDER * - UB16_LPC_VEC_PER_FRAME * sizeof(int)); - WebRtcIsac_EncHistMulti(streamdata, idx, WebRtcIsac_kLpcShapeCdfMatUb16, - UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME); - for (interpolCntr = 0; interpolCntr < UB16_INTERPOL_SEGMENTS; - interpolCntr++) { - WebRtcIsac_Lar2PolyInterpolUB(lpcVecs, interpolLPCCoeff, - kLpcVecPerSegmentUb16 + 1); - lpcVecs += UB_LPC_ORDER; - interpolLPCCoeff += (kLpcVecPerSegmentUb16 * (UB_LPC_ORDER + 1)); - } - break; - } - default: - return -1; - } - return 0; -} - -void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi, - Bitstr* streamdata, - ISAC_SaveEncData_t* encData) { - int j, k, n, pos, pos2, posg, offsg, offs2; - int index_g[KLT_ORDER_GAIN]; - int index_ovr_g[KLT_ORDER_GAIN]; - double tmpcoeffs_g[KLT_ORDER_GAIN]; - double tmpcoeffs2_g[KLT_ORDER_GAIN]; - double sum; - /* log gains, mean removal and scaling */ - posg = 0; - for (k = 0; k < SUBFRAMES; k++) { - tmpcoeffs_g[posg] = log(LPCCoef_lo[(LPC_LOBAND_ORDER + 1) * k]); - tmpcoeffs_g[posg] -= WebRtcIsac_kLpcMeansGain[posg]; - tmpcoeffs_g[posg] *= LPC_GAIN_SCALE; - posg++; - tmpcoeffs_g[posg] = log(LPCCoef_hi[(LPC_HIBAND_ORDER + 1) * k]); - tmpcoeffs_g[posg] -= WebRtcIsac_kLpcMeansGain[posg]; - tmpcoeffs_g[posg] *= LPC_GAIN_SCALE; - posg++; - } - - /* KLT */ - - /* Left transform. */ - offsg = 0; - for (j = 0; j < SUBFRAMES; j++) { - posg = offsg; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = offsg; - pos2 = k; - for (n = 0; n < LPC_GAIN_ORDER; n++) { - sum += tmpcoeffs_g[pos++] * WebRtcIsac_kKltT1Gain[pos2]; - pos2 += LPC_GAIN_ORDER; - } - tmpcoeffs2_g[posg++] = sum; - } - offsg += LPC_GAIN_ORDER; - } - - /* Right transform. */ - offsg = 0; - offs2 = 0; - for (j = 0; j < SUBFRAMES; j++) { - posg = offsg; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = k; - pos2 = offs2; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_g[pos] * WebRtcIsac_kKltT2Gain[pos2++]; - pos += LPC_GAIN_ORDER; - } - tmpcoeffs_g[posg++] = sum; - } - offs2 += SUBFRAMES; - offsg += LPC_GAIN_ORDER; - } - - /* Quantize coefficients. */ - for (k = 0; k < KLT_ORDER_GAIN; k++) { - /* Get index. */ - pos2 = WebRtcIsac_lrint(tmpcoeffs_g[k] / KLT_STEPSIZE); - index_g[k] = (pos2) + WebRtcIsac_kQKltQuantMinGain[k]; - if (index_g[k] < 0) { - index_g[k] = 0; - } else if (index_g[k] > WebRtcIsac_kQKltMaxIndGain[k]) { - index_g[k] = WebRtcIsac_kQKltMaxIndGain[k]; - } - index_ovr_g[k] = WebRtcIsac_kQKltOffsetGain[k] + index_g[k]; - - /* Find quantization levels for coefficients. */ - tmpcoeffs_g[k] = WebRtcIsac_kQKltLevelsGain[index_ovr_g[k]]; - - /* Save data for creation of multiple bit streams. */ - encData->LPCindex_g[KLT_ORDER_GAIN * encData->startIdx + k] = index_g[k]; - } - - /* Entropy coding of quantization indices - gain. */ - WebRtcIsac_EncHistMulti(streamdata, index_g, WebRtcIsac_kQKltCdfPtrGain, - KLT_ORDER_GAIN); - - /* Find quantization levels for coefficients. */ - /* Left transform. */ - offsg = 0; - posg = 0; - for (j = 0; j < SUBFRAMES; j++) { - offs2 = 0; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = offsg; - pos2 = offs2; - for (n = 0; n < LPC_GAIN_ORDER; n++) - sum += tmpcoeffs_g[pos++] * WebRtcIsac_kKltT1Gain[pos2++]; - tmpcoeffs2_g[posg++] = sum; - offs2 += LPC_GAIN_ORDER; - } - offsg += LPC_GAIN_ORDER; - } - - /* Right transform, transpose matrix. */ - offsg = 0; - posg = 0; - for (j = 0; j < SUBFRAMES; j++) { - posg = offsg; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = k; - pos2 = j; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_g[pos] * WebRtcIsac_kKltT2Gain[pos2]; - pos += LPC_GAIN_ORDER; - pos2 += SUBFRAMES; - } - tmpcoeffs_g[posg++] = sum; - } - offsg += LPC_GAIN_ORDER; - } - - - /* Scaling, mean addition, and gain restoration. */ - posg = 0; - for (k = 0; k < SUBFRAMES; k++) { - sum = tmpcoeffs_g[posg] / LPC_GAIN_SCALE; - sum += WebRtcIsac_kLpcMeansGain[posg]; - LPCCoef_lo[k * (LPC_LOBAND_ORDER + 1)] = exp(sum); - pos++; - posg++; - sum = tmpcoeffs_g[posg] / LPC_GAIN_SCALE; - sum += WebRtcIsac_kLpcMeansGain[posg]; - LPCCoef_hi[k * (LPC_HIBAND_ORDER + 1)] = exp(sum); - pos++; - posg++; - } - -} - -void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata, - int* lpcGainIndex) { - double U[UB_LPC_GAIN_DIM]; - int idx[UB_LPC_GAIN_DIM]; - WebRtcIsac_ToLogDomainRemoveMean(lpGains); - WebRtcIsac_DecorrelateLPGain(lpGains, U); - WebRtcIsac_QuantizeLpcGain(U, idx); - /* Store the index for re-encoding for FEC. */ - memcpy(lpcGainIndex, idx, UB_LPC_GAIN_DIM * sizeof(int)); - WebRtcIsac_CorrelateLpcGain(U, lpGains); - WebRtcIsac_AddMeanToLinearDomain(lpGains); - WebRtcIsac_EncHistMulti(streamdata, idx, WebRtcIsac_kLpcGainCdfMat, - UB_LPC_GAIN_DIM); -} - - -void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata) { - double U[UB_LPC_GAIN_DIM]; - int idx[UB_LPC_GAIN_DIM]; - WebRtcIsac_ToLogDomainRemoveMean(lpGains); - WebRtcIsac_DecorrelateLPGain(lpGains, U); - WebRtcIsac_QuantizeLpcGain(U, idx); - WebRtcIsac_EncHistMulti(streamdata, idx, WebRtcIsac_kLpcGainCdfMat, - UB_LPC_GAIN_DIM); -} - - - -WebRtc_Word16 WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata) { - double U[UB_LPC_GAIN_DIM]; - int idx[UB_LPC_GAIN_DIM]; - int err; - err = WebRtcIsac_DecHistOneStepMulti(idx, streamdata, - WebRtcIsac_kLpcGainCdfMat, - WebRtcIsac_kLpcGainEntropySearch, - UB_LPC_GAIN_DIM); - if (err < 0) { - return -1; - } - WebRtcIsac_DequantizeLpcGain(idx, U); - WebRtcIsac_CorrelateLpcGain(U, lpGains); - WebRtcIsac_AddMeanToLinearDomain(lpGains); - return 0; -} - - - -/* decode & dequantize RC */ -int WebRtcIsac_DecodeRc(Bitstr* streamdata, WebRtc_Word16* RCQ15) { - int k, err; - int index[AR_ORDER]; - - /* entropy decoding of quantization indices */ - err = WebRtcIsac_DecHistOneStepMulti(index, streamdata, - WebRtcIsac_kQArRcCdfPtr, - WebRtcIsac_kQArRcInitIndex, AR_ORDER); - if (err < 0) - return err; - - /* find quantization levels for reflection coefficients */ - for (k = 0; k < AR_ORDER; k++) { - RCQ15[k] = *(WebRtcIsac_kQArRcLevelsPtr[k] + index[k]); - } - return 0; -} - - -/* quantize & code RC */ -void WebRtcIsac_EncodeRc(WebRtc_Word16* RCQ15, Bitstr* streamdata) { - int k; - int index[AR_ORDER]; - - /* quantize reflection coefficients (add noise feedback?) */ - for (k = 0; k < AR_ORDER; k++) { - index[k] = WebRtcIsac_kQArRcInitIndex[k]; - - if (RCQ15[k] > WebRtcIsac_kQArBoundaryLevels[index[k]]) { - while (RCQ15[k] > WebRtcIsac_kQArBoundaryLevels[index[k] + 1]) { - index[k]++; - } - } else { - while (RCQ15[k] < WebRtcIsac_kQArBoundaryLevels[--index[k]]) ; - } - RCQ15[k] = *(WebRtcIsac_kQArRcLevelsPtr[k] + index[k]); - } - - /* entropy coding of quantization indices */ - WebRtcIsac_EncHistMulti(streamdata, index, WebRtcIsac_kQArRcCdfPtr, AR_ORDER); -} - - -/* decode & dequantize squared Gain */ -int WebRtcIsac_DecodeGain2(Bitstr* streamdata, WebRtc_Word32* gainQ10) { - int index, err; - - /* entropy decoding of quantization index */ - err = WebRtcIsac_DecHistOneStepMulti(&index, streamdata, - WebRtcIsac_kQGainCdf_ptr, - WebRtcIsac_kQGainInitIndex, 1); - if (err < 0) { - return err; - } - /* find quantization level */ - *gainQ10 = WebRtcIsac_kQGain2Levels[index]; - return 0; -} - - -/* quantize & code squared Gain */ -int WebRtcIsac_EncodeGain2(WebRtc_Word32* gainQ10, Bitstr* streamdata) { - int index; - - /* find quantization index */ - index = WebRtcIsac_kQGainInitIndex[0]; - if (*gainQ10 > WebRtcIsac_kQGain2BoundaryLevels[index]) { - while (*gainQ10 > WebRtcIsac_kQGain2BoundaryLevels[index + 1]) { - index++; - } - } else { - while (*gainQ10 < WebRtcIsac_kQGain2BoundaryLevels[--index]) ; - } - /* De-quantize */ - *gainQ10 = WebRtcIsac_kQGain2Levels[index]; - - /* entropy coding of quantization index */ - WebRtcIsac_EncHistMulti(streamdata, &index, WebRtcIsac_kQGainCdf_ptr, 1); - return 0; -} - - -/* code and decode Pitch Gains and Lags functions */ - -/* decode & dequantize Pitch Gains */ -int WebRtcIsac_DecodePitchGain(Bitstr* streamdata, - WebRtc_Word16* PitchGains_Q12) { - int index_comb, err; - const WebRtc_UWord16* WebRtcIsac_kQPitchGainCdf_ptr[1]; - - /* Entropy decoding of quantization indices */ - *WebRtcIsac_kQPitchGainCdf_ptr = WebRtcIsac_kQPitchGainCdf; - err = WebRtcIsac_DecHistBisectMulti(&index_comb, streamdata, - WebRtcIsac_kQPitchGainCdf_ptr, - WebRtcIsac_kQCdfTableSizeGain, 1); - /* Error check, Q_mean_Gain.. tables are of size 144 */ - if ((err < 0) || (index_comb < 0) || (index_comb > 144)) { - return -ISAC_RANGE_ERROR_DECODE_PITCH_GAIN; - } - /* De-quantize back to pitch gains by table look-up. */ - PitchGains_Q12[0] = WebRtcIsac_kQMeanGain1Q12[index_comb]; - PitchGains_Q12[1] = WebRtcIsac_kQMeanGain2Q12[index_comb]; - PitchGains_Q12[2] = WebRtcIsac_kQMeanGain3Q12[index_comb]; - PitchGains_Q12[3] = WebRtcIsac_kQMeanGain4Q12[index_comb]; - return 0; -} - - -/* Quantize & code Pitch Gains. */ -void WebRtcIsac_EncodePitchGain(WebRtc_Word16* PitchGains_Q12, - Bitstr* streamdata, - ISAC_SaveEncData_t* encData) { - int k, j; - double C; - double S[PITCH_SUBFRAMES]; - int index[3]; - int index_comb; - const WebRtc_UWord16* WebRtcIsac_kQPitchGainCdf_ptr[1]; - double PitchGains[PITCH_SUBFRAMES] = {0, 0, 0, 0}; - - /* Take the asin. */ - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchGains[k] = ((float)PitchGains_Q12[k]) / 4096; - S[k] = asin(PitchGains[k]); - } - - /* Find quantization index; only for the first three - * transform coefficients. */ - for (k = 0; k < 3; k++) { - /* transform */ - C = 0.0; - for (j = 0; j < PITCH_SUBFRAMES; j++) { - C += WebRtcIsac_kTransform[k][j] * S[j]; - } - /* Quantize */ - index[k] = WebRtcIsac_lrint(C / PITCH_GAIN_STEPSIZE); - - /* Check that the index is not outside the boundaries of the table. */ - if (index[k] < WebRtcIsac_kIndexLowerLimitGain[k]) { - index[k] = WebRtcIsac_kIndexLowerLimitGain[k]; - } else if (index[k] > WebRtcIsac_kIndexUpperLimitGain[k]) { - index[k] = WebRtcIsac_kIndexUpperLimitGain[k]; - } - index[k] -= WebRtcIsac_kIndexLowerLimitGain[k]; - } - - /* Calculate unique overall index. */ - index_comb = WebRtcIsac_kIndexMultsGain[0] * index[0] + - WebRtcIsac_kIndexMultsGain[1] * index[1] + index[2]; - - /* unquantize back to pitch gains by table look-up */ - PitchGains_Q12[0] = WebRtcIsac_kQMeanGain1Q12[index_comb]; - PitchGains_Q12[1] = WebRtcIsac_kQMeanGain2Q12[index_comb]; - PitchGains_Q12[2] = WebRtcIsac_kQMeanGain3Q12[index_comb]; - PitchGains_Q12[3] = WebRtcIsac_kQMeanGain4Q12[index_comb]; - - /* entropy coding of quantization pitch gains */ - *WebRtcIsac_kQPitchGainCdf_ptr = WebRtcIsac_kQPitchGainCdf; - WebRtcIsac_EncHistMulti(streamdata, &index_comb, - WebRtcIsac_kQPitchGainCdf_ptr, 1); - encData->pitchGain_index[encData->startIdx] = index_comb; -} - - - -/* Pitch LAG */ -/* Decode & de-quantize Pitch Lags. */ -int WebRtcIsac_DecodePitchLag(Bitstr* streamdata, WebRtc_Word16* PitchGain_Q12, - double* PitchLags) { - int k, err; - double StepSize; - double C; - int index[PITCH_SUBFRAMES]; - double mean_gain; - const double* mean_val2, *mean_val3, *mean_val4; - const WebRtc_Word16* lower_limit; - const WebRtc_UWord16* init_index; - const WebRtc_UWord16* cdf_size; - const WebRtc_UWord16** cdf; - double PitchGain[4] = {0, 0, 0, 0}; - - /* compute mean pitch gain */ - mean_gain = 0.0; - for (k = 0; k < 4; k++) { - PitchGain[k] = ((float)PitchGain_Q12[k]) / 4096; - mean_gain += PitchGain[k]; - } - mean_gain /= 4.0; - - /* voicing classification. */ - if (mean_gain < 0.2) { - StepSize = WebRtcIsac_kQPitchLagStepsizeLo; - cdf = WebRtcIsac_kQPitchLagCdfPtrLo; - cdf_size = WebRtcIsac_kQPitchLagCdfSizeLo; - mean_val2 = WebRtcIsac_kQMeanLag2Lo; - mean_val3 = WebRtcIsac_kQMeanLag3Lo; - mean_val4 = WebRtcIsac_kQMeanLag4Lo; - lower_limit = WebRtcIsac_kQIndexLowerLimitLagLo; - init_index = WebRtcIsac_kQInitIndexLagLo; - } else if (mean_gain < 0.4) { - StepSize = WebRtcIsac_kQPitchLagStepsizeMid; - cdf = WebRtcIsac_kQPitchLagCdfPtrMid; - cdf_size = WebRtcIsac_kQPitchLagCdfSizeMid; - mean_val2 = WebRtcIsac_kQMeanLag2Mid; - mean_val3 = WebRtcIsac_kQMeanLag3Mid; - mean_val4 = WebRtcIsac_kQMeanLag4Mid; - lower_limit = WebRtcIsac_kQIndexLowerLimitLagMid; - init_index = WebRtcIsac_kQInitIndexLagMid; - } else { - StepSize = WebRtcIsac_kQPitchLagStepsizeHi; - cdf = WebRtcIsac_kQPitchLagCdfPtrHi; - cdf_size = WebRtcIsac_kQPitchLagCdfSizeHi; - mean_val2 = WebRtcIsac_kQMeanLag2Hi; - mean_val3 = WebRtcIsac_kQMeanLag3Hi; - mean_val4 = WebRtcIsac_kQMeanLag4Hi; - lower_limit = WebRtcIsac_kQindexLowerLimitLagHi; - init_index = WebRtcIsac_kQInitIndexLagHi; - } - - /* Entropy decoding of quantization indices. */ - err = WebRtcIsac_DecHistBisectMulti(index, streamdata, cdf, cdf_size, 1); - if ((err < 0) || (index[0] < 0)) { - return -ISAC_RANGE_ERROR_DECODE_PITCH_LAG; - } - err = WebRtcIsac_DecHistOneStepMulti(index + 1, streamdata, cdf + 1, - init_index, 3); - if (err < 0) { - return -ISAC_RANGE_ERROR_DECODE_PITCH_LAG; - } - - /* Unquantize back to transform coefficients and do the inverse transform: - * S = T'*C. */ - C = (index[0] + lower_limit[0]) * StepSize; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] = WebRtcIsac_kTransformTranspose[k][0] * C; - } - C = mean_val2[index[1]]; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] += WebRtcIsac_kTransformTranspose[k][1] * C; - } - C = mean_val3[index[2]]; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] += WebRtcIsac_kTransformTranspose[k][2] * C; - } - C = mean_val4[index[3]]; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] += WebRtcIsac_kTransformTranspose[k][3] * C; - } - return 0; -} - - - -/* Quantize & code pitch lags. */ -void WebRtcIsac_EncodePitchLag(double* PitchLags, WebRtc_Word16* PitchGain_Q12, - Bitstr* streamdata, - ISAC_SaveEncData_t* encData) { - int k, j; - double StepSize; - double C; - int index[PITCH_SUBFRAMES]; - double mean_gain; - const double* mean_val2, *mean_val3, *mean_val4; - const WebRtc_Word16* lower_limit, *upper_limit; - const WebRtc_UWord16** cdf; - double PitchGain[4] = {0, 0, 0, 0}; - - /* compute mean pitch gain */ - mean_gain = 0.0; - for (k = 0; k < 4; k++) { - PitchGain[k] = ((float)PitchGain_Q12[k]) / 4096; - mean_gain += PitchGain[k]; - } - mean_gain /= 4.0; - - /* Save data for creation of multiple bit streams */ - encData->meanGain[encData->startIdx] = mean_gain; - - /* Voicing classification. */ - if (mean_gain < 0.2) { - StepSize = WebRtcIsac_kQPitchLagStepsizeLo; - cdf = WebRtcIsac_kQPitchLagCdfPtrLo; - mean_val2 = WebRtcIsac_kQMeanLag2Lo; - mean_val3 = WebRtcIsac_kQMeanLag3Lo; - mean_val4 = WebRtcIsac_kQMeanLag4Lo; - lower_limit = WebRtcIsac_kQIndexLowerLimitLagLo; - upper_limit = WebRtcIsac_kQIndexUpperLimitLagLo; - } else if (mean_gain < 0.4) { - StepSize = WebRtcIsac_kQPitchLagStepsizeMid; - cdf = WebRtcIsac_kQPitchLagCdfPtrMid; - mean_val2 = WebRtcIsac_kQMeanLag2Mid; - mean_val3 = WebRtcIsac_kQMeanLag3Mid; - mean_val4 = WebRtcIsac_kQMeanLag4Mid; - lower_limit = WebRtcIsac_kQIndexLowerLimitLagMid; - upper_limit = WebRtcIsac_kQIndexUpperLimitLagMid; - } else { - StepSize = WebRtcIsac_kQPitchLagStepsizeHi; - cdf = WebRtcIsac_kQPitchLagCdfPtrHi; - mean_val2 = WebRtcIsac_kQMeanLag2Hi; - mean_val3 = WebRtcIsac_kQMeanLag3Hi; - mean_val4 = WebRtcIsac_kQMeanLag4Hi; - lower_limit = WebRtcIsac_kQindexLowerLimitLagHi; - upper_limit = WebRtcIsac_kQindexUpperLimitLagHi; - } - - /* find quantization index */ - for (k = 0; k < 4; k++) { - /* transform */ - C = 0.0; - for (j = 0; j < PITCH_SUBFRAMES; j++) { - C += WebRtcIsac_kTransform[k][j] * PitchLags[j]; - } - /* quantize */ - index[k] = WebRtcIsac_lrint(C / StepSize); - - /* check that the index is not outside the boundaries of the table */ - if (index[k] < lower_limit[k]) { - index[k] = lower_limit[k]; - } else if (index[k] > upper_limit[k]) index[k] = upper_limit[k]; { - index[k] -= lower_limit[k]; - } - /* Save data for creation of multiple bit streams */ - encData->pitchIndex[PITCH_SUBFRAMES * encData->startIdx + k] = index[k]; - } - - /* Un-quantize back to transform coefficients and do the inverse transform: - * S = T'*C */ - C = (index[0] + lower_limit[0]) * StepSize; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] = WebRtcIsac_kTransformTranspose[k][0] * C; - } - C = mean_val2[index[1]]; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] += WebRtcIsac_kTransformTranspose[k][1] * C; - } - C = mean_val3[index[2]]; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] += WebRtcIsac_kTransformTranspose[k][2] * C; - } - C = mean_val4[index[3]]; - for (k = 0; k < PITCH_SUBFRAMES; k++) { - PitchLags[k] += WebRtcIsac_kTransformTranspose[k][3] * C; - } - /* entropy coding of quantization pitch lags */ - WebRtcIsac_EncHistMulti(streamdata, index, cdf, PITCH_SUBFRAMES); -} - - - -/* Routines for in-band signaling of bandwidth estimation */ -/* Histograms based on uniform distribution of indices */ -/* Move global variables later! */ - - -/* cdf array for frame length indicator */ -const WebRtc_UWord16 WebRtcIsac_kFrameLengthCdf[4] = { - 0, 21845, 43690, 65535 }; - -/* pointer to cdf array for frame length indicator */ -const WebRtc_UWord16* WebRtcIsac_kFrameLengthCdf_ptr[1] = { - WebRtcIsac_kFrameLengthCdf }; - -/* initial cdf index for decoder of frame length indicator */ -const WebRtc_UWord16 WebRtcIsac_kFrameLengthInitIndex[1] = { 1 }; - - -int WebRtcIsac_DecodeFrameLen(Bitstr* streamdata, WebRtc_Word16* framesamples) { - int frame_mode, err; - err = 0; - /* entropy decoding of frame length [1:30ms,2:60ms] */ - err = WebRtcIsac_DecHistOneStepMulti(&frame_mode, streamdata, - WebRtcIsac_kFrameLengthCdf_ptr, - WebRtcIsac_kFrameLengthInitIndex, 1); - if (err < 0) - return -ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH; - - switch (frame_mode) { - case 1: - *framesamples = 480; /* 30ms */ - break; - case 2: - *framesamples = 960; /* 60ms */ - break; - default: - err = -ISAC_DISALLOWED_FRAME_MODE_DECODER; - } - return err; -} - -int WebRtcIsac_EncodeFrameLen(WebRtc_Word16 framesamples, Bitstr* streamdata) { - int frame_mode, status; - - status = 0; - frame_mode = 0; - /* entropy coding of frame length [1:480 samples,2:960 samples] */ - switch (framesamples) { - case 480: - frame_mode = 1; - break; - case 960: - frame_mode = 2; - break; - default: - status = - ISAC_DISALLOWED_FRAME_MODE_ENCODER; - } - - if (status < 0) - return status; - - WebRtcIsac_EncHistMulti(streamdata, &frame_mode, - WebRtcIsac_kFrameLengthCdf_ptr, 1); - return status; -} - -/* cdf array for estimated bandwidth */ -static const WebRtc_UWord16 kBwCdf[25] = { - 0, 2731, 5461, 8192, 10923, 13653, 16384, 19114, 21845, 24576, 27306, 30037, - 32768, 35498, 38229, 40959, 43690, 46421, 49151, 51882, 54613, 57343, 60074, - 62804, 65535 }; - -/* pointer to cdf array for estimated bandwidth */ -static const WebRtc_UWord16* kBwCdfPtr[1] = { kBwCdf }; - -/* initial cdf index for decoder of estimated bandwidth*/ -static const WebRtc_UWord16 kBwInitIndex[1] = { 7 }; - - -int WebRtcIsac_DecodeSendBW(Bitstr* streamdata, WebRtc_Word16* BWno) { - int BWno32, err; - - /* entropy decoding of sender's BW estimation [0..23] */ - err = WebRtcIsac_DecHistOneStepMulti(&BWno32, streamdata, kBwCdfPtr, - kBwInitIndex, 1); - if (err < 0) { - return -ISAC_RANGE_ERROR_DECODE_BANDWIDTH; - } - *BWno = (WebRtc_Word16)BWno32; - return err; -} - -void WebRtcIsac_EncodeReceiveBw(int* BWno, Bitstr* streamdata) { - /* entropy encoding of receiver's BW estimation [0..23] */ - WebRtcIsac_EncHistMulti(streamdata, BWno, kBwCdfPtr, 1); -} - - -/* estimate code length of LPC Coef */ -void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi, - int* index_g) { - int j, k, n, pos, pos2, posg, offsg, offs2; - int index_ovr_g[KLT_ORDER_GAIN]; - double tmpcoeffs_g[KLT_ORDER_GAIN]; - double tmpcoeffs2_g[KLT_ORDER_GAIN]; - double sum; - - /* log gains, mean removal and scaling */ - posg = 0; - for (k = 0; k < SUBFRAMES; k++) { - tmpcoeffs_g[posg] = log(LPCCoef_lo[(LPC_LOBAND_ORDER + 1) * k]); - tmpcoeffs_g[posg] -= WebRtcIsac_kLpcMeansGain[posg]; - tmpcoeffs_g[posg] *= LPC_GAIN_SCALE; - posg++; - tmpcoeffs_g[posg] = log(LPCCoef_hi[(LPC_HIBAND_ORDER + 1) * k]); - tmpcoeffs_g[posg] -= WebRtcIsac_kLpcMeansGain[posg]; - tmpcoeffs_g[posg] *= LPC_GAIN_SCALE; - posg++; - } - - /* KLT */ - - /* Left transform. */ - offsg = 0; - for (j = 0; j < SUBFRAMES; j++) { - posg = offsg; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = offsg; - pos2 = k; - for (n = 0; n < LPC_GAIN_ORDER; n++) { - sum += tmpcoeffs_g[pos++] * WebRtcIsac_kKltT1Gain[pos2]; - pos2 += LPC_GAIN_ORDER; - } - tmpcoeffs2_g[posg++] = sum; - } - offsg += LPC_GAIN_ORDER; - } - - /* Right transform. */ - offsg = 0; - offs2 = 0; - for (j = 0; j < SUBFRAMES; j++) { - posg = offsg; - for (k = 0; k < LPC_GAIN_ORDER; k++) { - sum = 0; - pos = k; - pos2 = offs2; - for (n = 0; n < SUBFRAMES; n++) { - sum += tmpcoeffs2_g[pos] * WebRtcIsac_kKltT2Gain[pos2++]; - pos += LPC_GAIN_ORDER; - } - tmpcoeffs_g[posg++] = sum; - } - offs2 += SUBFRAMES; - offsg += LPC_GAIN_ORDER; - } - - - /* quantize coefficients */ - for (k = 0; k < KLT_ORDER_GAIN; k++) { - /* Get index. */ - pos2 = WebRtcIsac_lrint(tmpcoeffs_g[k] / KLT_STEPSIZE); - index_g[k] = (pos2) + WebRtcIsac_kQKltQuantMinGain[k]; - if (index_g[k] < 0) { - index_g[k] = 0; - } else if (index_g[k] > WebRtcIsac_kQKltMaxIndGain[k]) { - index_g[k] = WebRtcIsac_kQKltMaxIndGain[k]; - } - index_ovr_g[k] = WebRtcIsac_kQKltOffsetGain[k] + index_g[k]; - - /* find quantization levels for coefficients */ - tmpcoeffs_g[k] = WebRtcIsac_kQKltLevelsGain[index_ovr_g[k]]; - } -} - - -/* Decode & de-quantize LPC Coefficients. */ -int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata, double* lpcVecs, - double* percepFilterGains, - WebRtc_Word16 bandwidth) { - int index_s[KLT_ORDER_SHAPE]; - - double U[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - int err; - - /* Entropy decoding of quantization indices. */ - switch (bandwidth) { - case isac12kHz: { - err = WebRtcIsac_DecHistOneStepMulti( - index_s, streamdata, WebRtcIsac_kLpcShapeCdfMatUb12, - WebRtcIsac_kLpcShapeEntropySearchUb12, UB_LPC_ORDER * - UB_LPC_VEC_PER_FRAME); - break; - } - case isac16kHz: { - err = WebRtcIsac_DecHistOneStepMulti( - index_s, streamdata, WebRtcIsac_kLpcShapeCdfMatUb16, - WebRtcIsac_kLpcShapeEntropySearchUb16, UB_LPC_ORDER * - UB16_LPC_VEC_PER_FRAME); - break; - } - default: - return -1; - } - - if (err < 0) { - return err; - } - - WebRtcIsac_DequantizeLpcParam(index_s, lpcVecs, bandwidth); - WebRtcIsac_CorrelateInterVec(lpcVecs, U, bandwidth); - WebRtcIsac_CorrelateIntraVec(U, lpcVecs, bandwidth); - WebRtcIsac_AddLarMean(lpcVecs, bandwidth); - WebRtcIsac_DecodeLpcGainUb(percepFilterGains, streamdata); - - if (bandwidth == isac16kHz) { - /* Decode another set of Gains. */ - WebRtcIsac_DecodeLpcGainUb(&percepFilterGains[SUBFRAMES], streamdata); - } - return 0; -} - -WebRtc_Word16 WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth, - Bitstr* streamData) { - int bandwidthMode; - switch (bandwidth) { - case isac12kHz: { - bandwidthMode = 0; - break; - } - case isac16kHz: { - bandwidthMode = 1; - break; - } - default: - return -ISAC_DISALLOWED_ENCODER_BANDWIDTH; - } - WebRtcIsac_EncHistMulti(streamData, &bandwidthMode, kOneBitEqualProbCdf_ptr, - 1); - return 0; -} - -WebRtc_Word16 WebRtcIsac_DecodeBandwidth(Bitstr* streamData, - enum ISACBandwidth* bandwidth) { - int bandwidthMode; - if (WebRtcIsac_DecHistOneStepMulti(&bandwidthMode, streamData, - kOneBitEqualProbCdf_ptr, - kOneBitEqualProbInitIndex, 1) < 0) { - return -ISAC_RANGE_ERROR_DECODE_BANDWITH; - } - switch (bandwidthMode) { - case 0: { - *bandwidth = isac12kHz; - break; - } - case 1: { - *bandwidth = isac16kHz; - break; - } - default: - return -ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER; - } - return 0; -} - -WebRtc_Word16 WebRtcIsac_EncodeJitterInfo(WebRtc_Word32 jitterIndex, - Bitstr* streamData) { - /* This is to avoid LINUX warning until we change 'int' to 'Word32'. */ - int intVar; - - if ((jitterIndex < 0) || (jitterIndex > 1)) { - return -1; - } - intVar = (int)(jitterIndex); - /* Use the same CDF table as for bandwidth - * both take two values with equal probability.*/ - WebRtcIsac_EncHistMulti(streamData, &intVar, kOneBitEqualProbCdf_ptr, 1); - return 0; -} - -WebRtc_Word16 WebRtcIsac_DecodeJitterInfo(Bitstr* streamData, - WebRtc_Word32* jitterInfo) { - int intVar; - /* Use the same CDF table as for bandwidth - * both take two values with equal probability. */ - if (WebRtcIsac_DecHistOneStepMulti(&intVar, streamData, - kOneBitEqualProbCdf_ptr, - kOneBitEqualProbInitIndex, 1) < 0) { - return -ISAC_RANGE_ERROR_DECODE_BANDWITH; - } - *jitterInfo = (WebRtc_Word16)(intVar); - return 0; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/entropy_coding.h b/src/modules/audio_coding/codecs/isac/main/source/entropy_coding.h deleted file mode 100644 index 1a46953..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/entropy_coding.h +++ /dev/null
@@ -1,341 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * entropy_coding.h - * - * This header file declares all of the functions used to arithmetically - * encode the iSAC bistream - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENTROPY_CODING_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENTROPY_CODING_H_ - -#include "settings.h" -#include "structs.h" - -/****************************************************************************** - * WebRtcIsac_DecodeSpec() - * Decode real and imaginary part of the DFT coefficients, given a bit-stream. - * The decoded DFT coefficient can be transformed to time domain by - * WebRtcIsac_Time2Spec(). - * - * Input: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - AvgPitchGain_Q12 : average pitch-gain of the frame. This is only - * relevant for 0-4 kHz band, and the input value is - * not used in other bands. - * - band : specifies which band's DFT should be decoded. - * - * Output: - * - *fr : pointer to a buffer where the real part of DFT - * coefficients are written to. - * - *fi : pointer to a buffer where the imaginary part - * of DFT coefficients are written to. - * - * Return value : < 0 if an error occures - * 0 if succeeded. - */ -int WebRtcIsac_DecodeSpec(Bitstr* streamdata, WebRtc_Word16 AvgPitchGain_Q12, - enum ISACBand band, double* fr, double* fi); - -/****************************************************************************** - * WebRtcIsac_EncodeSpec() - * Encode real and imaginary part of the DFT coefficients into the given - * bit-stream. - * - * Input: - * - *fr : pointer to a buffer where the real part of DFT - * coefficients are written to. - * - *fi : pointer to a buffer where the imaginary part - * of DFT coefficients are written to. - * - AvgPitchGain_Q12 : average pitch-gain of the frame. This is only - * relevant for 0-4 kHz band, and the input value is - * not used in other bands. - * - band : specifies which band's DFT should be decoded. - * - * Output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Return value : < 0 if an error occures - * 0 if succeeded. - */ -int WebRtcIsac_EncodeSpec(const WebRtc_Word16* fr, const WebRtc_Word16* fi, - WebRtc_Word16 AvgPitchGain_Q12, enum ISACBand band, - Bitstr* streamdata); - -/* decode & dequantize LPC Coef */ -int WebRtcIsac_DecodeLpcCoef(Bitstr* streamdata, double* LPCCoef); -int WebRtcIsac_DecodeLpcCoefUB(Bitstr* streamdata, double* lpcVecs, - double* percepFilterGains, - WebRtc_Word16 bandwidth); - -int WebRtcIsac_DecodeLpc(Bitstr* streamdata, double* LPCCoef_lo, - double* LPCCoef_hi); - -/* quantize & code LPC Coef */ -void WebRtcIsac_EncodeLpcLb(double* LPCCoef_lo, double* LPCCoef_hi, - Bitstr* streamdata, ISAC_SaveEncData_t* encData); - -void WebRtcIsac_EncodeLpcGainLb(double* LPCCoef_lo, double* LPCCoef_hi, - Bitstr* streamdata, - ISAC_SaveEncData_t* encData); - -/****************************************************************************** - * WebRtcIsac_EncodeLpcUB() - * Encode LPC parameters, given as A-polynomial, of upper-band. The encoding - * is performed in LAR domain. - * For the upper-band, we compute and encode LPC of some sub-frames, LPC of - * other sub-frames are computed by linear interpolation, in LAR domain. This - * function performs the interpolation and returns the LPC of all sub-frames. - * - * Inputs: - * - lpcCoef : a buffer containing A-polynomials of sub-frames - * (excluding first coefficient that is 1). - * - bandwidth : specifies if the codec is operating at 0-12 kHz - * or 0-16 kHz mode. - * - * Input/output: - * - streamdata : pointer to a structure containing the encoded - * data and the parameters needed for entropy - * coding. - * - * Output: - * - interpolLPCCoeff : Decoded and interpolated LPC (A-polynomial) - * of all sub-frames. - * If LP analysis is of order K, and there are N - * sub-frames then this is a buffer of size - * (k + 1) * N, each vector starts with the LPC gain - * of the corresponding sub-frame. The LPC gains - * are encoded and inserted after this function is - * called. The first A-coefficient which is 1 is not - * included. - * - * Return value : 0 if encoding is successful, - * <0 if failed to encode. - */ -WebRtc_Word16 WebRtcIsac_EncodeLpcUB(double* lpcCoeff, Bitstr* streamdata, - double* interpolLPCCoeff, - WebRtc_Word16 bandwidth, - ISACUBSaveEncDataStruct* encData); - -/****************************************************************************** - * WebRtcIsac_DecodeInterpolLpcUb() - * Decode LPC coefficients and interpolate to get the coefficients fo all - * sub-frmaes. - * - * Inputs: - * - bandwidth : spepecifies if the codec is in 0-12 kHz or - * 0-16 kHz mode. - * - * Input/output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Output: - * - percepFilterParam : Decoded and interpolated LPC (A-polynomial) of - * all sub-frames. - * If LP analysis is of order K, and there are N - * sub-frames then this is a buffer of size - * (k + 1) * N, each vector starts with the LPC gain - * of the corresponding sub-frame. The LPC gains - * are encoded and inserted after this function is - * called. The first A-coefficient which is 1 is not - * included. - * - * Return value : 0 if encoding is successful, - * <0 if failed to encode. - */ -WebRtc_Word16 WebRtcIsac_DecodeInterpolLpcUb(Bitstr* streamdata, - double* percepFilterParam, - WebRtc_Word16 bandwidth); - -/* Decode & dequantize RC */ -int WebRtcIsac_DecodeRc(Bitstr* streamdata, WebRtc_Word16* RCQ15); - -/* Quantize & code RC */ -void WebRtcIsac_EncodeRc(WebRtc_Word16* RCQ15, Bitstr* streamdata); - -/* Decode & dequantize squared Gain */ -int WebRtcIsac_DecodeGain2(Bitstr* streamdata, WebRtc_Word32* Gain2); - -/* Quantize & code squared Gain (input is squared gain) */ -int WebRtcIsac_EncodeGain2(WebRtc_Word32* gain2, Bitstr* streamdata); - -void WebRtcIsac_EncodePitchGain(WebRtc_Word16* PitchGains_Q12, - Bitstr* streamdata, - ISAC_SaveEncData_t* encData); - -void WebRtcIsac_EncodePitchLag(double* PitchLags, WebRtc_Word16* PitchGain_Q12, - Bitstr* streamdata, ISAC_SaveEncData_t* encData); - -int WebRtcIsac_DecodePitchGain(Bitstr* streamdata, - WebRtc_Word16* PitchGain_Q12); -int WebRtcIsac_DecodePitchLag(Bitstr* streamdata, WebRtc_Word16* PitchGain_Q12, - double* PitchLag); - -int WebRtcIsac_DecodeFrameLen(Bitstr* streamdata, WebRtc_Word16* framelength); -int WebRtcIsac_EncodeFrameLen(WebRtc_Word16 framelength, Bitstr* streamdata); -int WebRtcIsac_DecodeSendBW(Bitstr* streamdata, WebRtc_Word16* BWno); -void WebRtcIsac_EncodeReceiveBw(int* BWno, Bitstr* streamdata); - -/* Step-down */ -void WebRtcIsac_Poly2Rc(double* a, int N, double* RC); - -/* Step-up */ -void WebRtcIsac_Rc2Poly(double* RC, int N, double* a); - -void WebRtcIsac_TranscodeLPCCoef(double* LPCCoef_lo, double* LPCCoef_hi, - int* index_g); - - -/****************************************************************************** - * WebRtcIsac_EncodeLpcGainUb() - * Encode LPC gains of sub-Frames. - * - * Input/outputs: - * - lpGains : a buffer which contains 'SUBFRAME' number of - * LP gains to be encoded. The input values are - * overwritten by the quantized values. - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Output: - * - lpcGainIndex : quantization indices for lpc gains, these will - * be stored to be used for FEC. - */ -void WebRtcIsac_EncodeLpcGainUb(double* lpGains, Bitstr* streamdata, - int* lpcGainIndex); - - -/****************************************************************************** - * WebRtcIsac_EncodeLpcGainUb() - * Store LPC gains of sub-Frames in 'streamdata'. - * - * Input: - * - lpGains : a buffer which contains 'SUBFRAME' number of - * LP gains to be encoded. - * Input/outputs: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - */ -void WebRtcIsac_StoreLpcGainUb(double* lpGains, Bitstr* streamdata); - - -/****************************************************************************** - * WebRtcIsac_DecodeLpcGainUb() - * Decode the LPC gain of sub-frames. - * - * Input/output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Output: - * - lpGains : a buffer where decoded LPC gians will be stored. - * - * Return value : 0 if succeeded. - * <0 if failed. - */ -WebRtc_Word16 WebRtcIsac_DecodeLpcGainUb(double* lpGains, Bitstr* streamdata); - - -/****************************************************************************** - * WebRtcIsac_EncodeBandwidth() - * Encode if the bandwidth of encoded audio is 0-12 kHz or 0-16 kHz. - * - * Input: - * - bandwidth : an enumerator specifying if the codec in is - * 0-12 kHz or 0-16 kHz mode. - * - * Input/output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Return value : 0 if succeeded. - * <0 if failed. - */ -WebRtc_Word16 WebRtcIsac_EncodeBandwidth(enum ISACBandwidth bandwidth, - Bitstr* streamData); - - -/****************************************************************************** - * WebRtcIsac_DecodeBandwidth() - * Decode the bandwidth of the encoded audio, i.e. if the bandwidth is 0-12 kHz - * or 0-16 kHz. - * - * Input/output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Output: - * - bandwidth : an enumerator specifying if the codec is in - * 0-12 kHz or 0-16 kHz mode. - * - * Return value : 0 if succeeded. - * <0 if failed. - */ -WebRtc_Word16 WebRtcIsac_DecodeBandwidth(Bitstr* streamData, - enum ISACBandwidth* bandwidth); - - -/****************************************************************************** - * WebRtcIsac_EncodeJitterInfo() - * Decode the jitter information. - * - * Input/output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Input: - * - jitterInfo : one bit of info specifying if the channel is - * in high/low jitter. Zero indicates low jitter - * and one indicates high jitter. - * - * Return value : 0 if succeeded. - * <0 if failed. - */ -WebRtc_Word16 WebRtcIsac_EncodeJitterInfo(WebRtc_Word32 jitterIndex, - Bitstr* streamData); - - -/****************************************************************************** - * WebRtcIsac_DecodeJitterInfo() - * Decode the jitter information. - * - * Input/output: - * - streamdata : pointer to a stucture containg the encoded - * data and theparameters needed for entropy - * coding. - * - * Output: - * - jitterInfo : one bit of info specifying if the channel is - * in high/low jitter. Zero indicates low jitter - * and one indicates high jitter. - * - * Return value : 0 if succeeded. - * <0 if failed. - */ -WebRtc_Word16 WebRtcIsac_DecodeJitterInfo(Bitstr* streamData, - WebRtc_Word32* jitterInfo); - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENTROPY_CODING_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/fft.c b/src/modules/audio_coding/codecs/isac/main/source/fft.c deleted file mode 100644 index c824798..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/fft.c +++ /dev/null
@@ -1,947 +0,0 @@ -/* - * Copyright(c)1995,97 Mark Olesen <olesen@me.QueensU.CA> - * Queen's Univ at Kingston (Canada) - * - * Permission to use, copy, modify, and distribute this software for - * any purpose without fee is hereby granted, provided that this - * entire notice is included in all copies of any software which is - * or includes a copy or modification of this software and in all - * copies of the supporting documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR QUEEN'S - * UNIVERSITY AT KINGSTON MAKES ANY REPRESENTATION OR WARRANTY OF ANY - * KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS - * FITNESS FOR ANY PARTICULAR PURPOSE. - * - * All of which is to say that you can do what you like with this - * source code provided you don't try to sell it as your own and you - * include an unaltered copy of this message (including the - * copyright). - * - * It is also implicitly understood that bug fixes and improvements - * should make their way back to the general Internet community so - * that everyone benefits. - * - * Changes: - * Trivial type modifications by the WebRTC authors. - */ - - -/* - * File: - * WebRtcIsac_Fftn.c - * - * Public: - * WebRtcIsac_Fftn / fftnf (); - * - * Private: - * WebRtcIsac_Fftradix / fftradixf (); - * - * Descript: - * multivariate complex Fourier transform, computed in place - * using mixed-radix Fast Fourier Transform algorithm. - * - * Fortran code by: - * RC Singleton, Stanford Research Institute, Sept. 1968 - * - * translated by f2c (version 19950721). - * - * int WebRtcIsac_Fftn (int ndim, const int dims[], REAL Re[], REAL Im[], - * int iSign, double scaling); - * - * NDIM = the total number dimensions - * DIMS = a vector of array sizes - * if NDIM is zero then DIMS must be zero-terminated - * - * RE and IM hold the real and imaginary components of the data, and return - * the resulting real and imaginary Fourier coefficients. Multidimensional - * data *must* be allocated contiguously. There is no limit on the number - * of dimensions. - * - * ISIGN = the sign of the complex exponential (ie, forward or inverse FFT) - * the magnitude of ISIGN (normally 1) is used to determine the - * correct indexing increment (see below). - * - * SCALING = normalizing constant by which the final result is *divided* - * if SCALING == -1, normalize by total dimension of the transform - * if SCALING < -1, normalize by the square-root of the total dimension - * - * example: - * tri-variate transform with Re[n1][n2][n3], Im[n1][n2][n3] - * - * int dims[3] = {n1,n2,n3} - * WebRtcIsac_Fftn (3, dims, Re, Im, 1, scaling); - * - *-----------------------------------------------------------------------* - * int WebRtcIsac_Fftradix (REAL Re[], REAL Im[], size_t nTotal, size_t nPass, - * size_t nSpan, int iSign, size_t max_factors, - * size_t max_perm); - * - * RE, IM - see above documentation - * - * Although there is no limit on the number of dimensions, WebRtcIsac_Fftradix() must - * be called once for each dimension, but the calls may be in any order. - * - * NTOTAL = the total number of complex data values - * NPASS = the dimension of the current variable - * NSPAN/NPASS = the spacing of consecutive data values while indexing the - * current variable - * ISIGN - see above documentation - * - * example: - * tri-variate transform with Re[n1][n2][n3], Im[n1][n2][n3] - * - * WebRtcIsac_Fftradix (Re, Im, n1*n2*n3, n1, n1, 1, maxf, maxp); - * WebRtcIsac_Fftradix (Re, Im, n1*n2*n3, n2, n1*n2, 1, maxf, maxp); - * WebRtcIsac_Fftradix (Re, Im, n1*n2*n3, n3, n1*n2*n3, 1, maxf, maxp); - * - * single-variate transform, - * NTOTAL = N = NSPAN = (number of complex data values), - * - * WebRtcIsac_Fftradix (Re, Im, n, n, n, 1, maxf, maxp); - * - * The data can also be stored in a single array with alternating real and - * imaginary parts, the magnitude of ISIGN is changed to 2 to give correct - * indexing increment, and data [0] and data [1] used to pass the initial - * addresses for the sequences of real and imaginary values, - * - * example: - * REAL data [2*NTOTAL]; - * WebRtcIsac_Fftradix ( &data[0], &data[1], NTOTAL, nPass, nSpan, 2, maxf, maxp); - * - * for temporary allocation: - * - * MAX_FACTORS >= the maximum prime factor of NPASS - * MAX_PERM >= the number of prime factors of NPASS. In addition, - * if the square-free portion K of NPASS has two or more prime - * factors, then MAX_PERM >= (K-1) - * - * storage in FACTOR for a maximum of 15 prime factors of NPASS. if NPASS - * has more than one square-free factor, the product of the square-free - * factors must be <= 210 array storage for maximum prime factor of 23 the - * following two constants should agree with the array dimensions. - * - *----------------------------------------------------------------------*/ -#include "fft.h" - -#include <stdlib.h> -#include <math.h> - - - -/* double precision routine */ -static int -WebRtcIsac_Fftradix (double Re[], double Im[], - size_t nTotal, size_t nPass, size_t nSpan, int isign, - int max_factors, unsigned int max_perm, - FFTstr *fftstate); - - - -#ifndef M_PI -# define M_PI 3.14159265358979323846264338327950288 -#endif - -#ifndef SIN60 -# define SIN60 0.86602540378443865 /* sin(60 deg) */ -# define COS72 0.30901699437494742 /* cos(72 deg) */ -# define SIN72 0.95105651629515357 /* sin(72 deg) */ -#endif - -# define REAL double -# define FFTN WebRtcIsac_Fftn -# define FFTNS "fftn" -# define FFTRADIX WebRtcIsac_Fftradix -# define FFTRADIXS "fftradix" - - -int WebRtcIsac_Fftns(unsigned int ndim, const int dims[], - double Re[], - double Im[], - int iSign, - double scaling, - FFTstr *fftstate) -{ - - size_t nSpan, nPass, nTotal; - unsigned int i; - int ret, max_factors, max_perm; - - /* - * tally the number of elements in the data array - * and determine the number of dimensions - */ - nTotal = 1; - if (ndim && dims [0]) - { - for (i = 0; i < ndim; i++) - { - if (dims [i] <= 0) - { - return -1; - } - nTotal *= dims [i]; - } - } - else - { - ndim = 0; - for (i = 0; dims [i]; i++) - { - if (dims [i] <= 0) - { - return -1; - } - nTotal *= dims [i]; - ndim++; - } - } - - /* determine maximum number of factors and permuations */ -#if 1 - /* - * follow John Beale's example, just use the largest dimension and don't - * worry about excess allocation. May be someone else will do it? - */ - max_factors = max_perm = 1; - for (i = 0; i < ndim; i++) - { - nSpan = dims [i]; - if ((int)nSpan > max_factors) - { - max_factors = (int)nSpan; - } - if ((int)nSpan > max_perm) - { - max_perm = (int)nSpan; - } - } -#else - /* use the constants used in the original Fortran code */ - max_factors = 23; - max_perm = 209; -#endif - /* loop over the dimensions: */ - nPass = 1; - for (i = 0; i < ndim; i++) - { - nSpan = dims [i]; - nPass *= nSpan; - ret = FFTRADIX (Re, Im, nTotal, nSpan, nPass, iSign, - max_factors, max_perm, fftstate); - /* exit, clean-up already done */ - if (ret) - return ret; - } - - /* Divide through by the normalizing constant: */ - if (scaling && scaling != 1.0) - { - if (iSign < 0) iSign = -iSign; - if (scaling < 0.0) - { - scaling = (double)nTotal; - if (scaling < -1.0) - scaling = sqrt (scaling); - } - scaling = 1.0 / scaling; /* multiply is often faster */ - for (i = 0; i < nTotal; i += iSign) - { - Re [i] *= scaling; - Im [i] *= scaling; - } - } - return 0; -} - -/* - * singleton's mixed radix routine - * - * could move allocation out to WebRtcIsac_Fftn(), but leave it here so that it's - * possible to make this a standalone function - */ - -static int FFTRADIX (REAL Re[], - REAL Im[], - size_t nTotal, - size_t nPass, - size_t nSpan, - int iSign, - int max_factors, - unsigned int max_perm, - FFTstr *fftstate) -{ - int ii, mfactor, kspan, ispan, inc; - int j, jc, jf, jj, k, k1, k2, k3, k4, kk, kt, nn, ns, nt; - - - REAL radf; - REAL c1, c2, c3, cd, aa, aj, ak, ajm, ajp, akm, akp; - REAL s1, s2, s3, sd, bb, bj, bk, bjm, bjp, bkm, bkp; - - REAL *Rtmp = NULL; /* temp space for real part*/ - REAL *Itmp = NULL; /* temp space for imaginary part */ - REAL *Cos = NULL; /* Cosine values */ - REAL *Sin = NULL; /* Sine values */ - - REAL s60 = SIN60; /* sin(60 deg) */ - REAL c72 = COS72; /* cos(72 deg) */ - REAL s72 = SIN72; /* sin(72 deg) */ - REAL pi2 = M_PI; /* use PI first, 2 PI later */ - - - fftstate->SpaceAlloced = 0; - fftstate->MaxPermAlloced = 0; - - - // initialize to avoid warnings - k3 = c2 = c3 = s2 = s3 = 0.0; - - if (nPass < 2) - return 0; - - /* allocate storage */ - if (fftstate->SpaceAlloced < max_factors * sizeof (REAL)) - { -#ifdef SUN_BROKEN_REALLOC - if (!fftstate->SpaceAlloced) /* first time */ - { - fftstate->SpaceAlloced = max_factors * sizeof (REAL); - } - else - { -#endif - fftstate->SpaceAlloced = max_factors * sizeof (REAL); -#ifdef SUN_BROKEN_REALLOC - } -#endif - } - else - { - /* allow full use of alloc'd space */ - max_factors = fftstate->SpaceAlloced / sizeof (REAL); - } - if (fftstate->MaxPermAlloced < max_perm) - { -#ifdef SUN_BROKEN_REALLOC - if (!fftstate->MaxPermAlloced) /* first time */ - else -#endif - fftstate->MaxPermAlloced = max_perm; - } - else - { - /* allow full use of alloc'd space */ - max_perm = fftstate->MaxPermAlloced; - } - if (fftstate->Tmp0 == NULL || fftstate->Tmp1 == NULL || fftstate->Tmp2 == NULL || fftstate->Tmp3 == NULL - || fftstate->Perm == NULL) { - return -1; - } - - /* assign pointers */ - Rtmp = (REAL *) fftstate->Tmp0; - Itmp = (REAL *) fftstate->Tmp1; - Cos = (REAL *) fftstate->Tmp2; - Sin = (REAL *) fftstate->Tmp3; - - /* - * Function Body - */ - inc = iSign; - if (iSign < 0) { - s72 = -s72; - s60 = -s60; - pi2 = -pi2; - inc = -inc; /* absolute value */ - } - - /* adjust for strange increments */ - nt = inc * (int)nTotal; - ns = inc * (int)nSpan; - kspan = ns; - - nn = nt - inc; - jc = ns / (int)nPass; - radf = pi2 * (double) jc; - pi2 *= 2.0; /* use 2 PI from here on */ - - ii = 0; - jf = 0; - /* determine the factors of n */ - mfactor = 0; - k = (int)nPass; - while (k % 16 == 0) { - mfactor++; - fftstate->factor [mfactor - 1] = 4; - k /= 16; - } - j = 3; - jj = 9; - do { - while (k % jj == 0) { - mfactor++; - fftstate->factor [mfactor - 1] = j; - k /= jj; - } - j += 2; - jj = j * j; - } while (jj <= k); - if (k <= 4) { - kt = mfactor; - fftstate->factor [mfactor] = k; - if (k != 1) - mfactor++; - } else { - if (k - (k / 4 << 2) == 0) { - mfactor++; - fftstate->factor [mfactor - 1] = 2; - k /= 4; - } - kt = mfactor; - j = 2; - do { - if (k % j == 0) { - mfactor++; - fftstate->factor [mfactor - 1] = j; - k /= j; - } - j = ((j + 1) / 2 << 1) + 1; - } while (j <= k); - } - if (kt) { - j = kt; - do { - mfactor++; - fftstate->factor [mfactor - 1] = fftstate->factor [j - 1]; - j--; - } while (j); - } - - /* test that mfactors is in range */ - if (mfactor > NFACTOR) - { - return -1; - } - - /* compute fourier transform */ - for (;;) { - sd = radf / (double) kspan; - cd = sin(sd); - cd = 2.0 * cd * cd; - sd = sin(sd + sd); - kk = 0; - ii++; - - switch (fftstate->factor [ii - 1]) { - case 2: - /* transform for factor of 2 (including rotation factor) */ - kspan /= 2; - k1 = kspan + 2; - do { - do { - k2 = kk + kspan; - ak = Re [k2]; - bk = Im [k2]; - Re [k2] = Re [kk] - ak; - Im [k2] = Im [kk] - bk; - Re [kk] += ak; - Im [kk] += bk; - kk = k2 + kspan; - } while (kk < nn); - kk -= nn; - } while (kk < jc); - if (kk >= kspan) - goto Permute_Results_Label; /* exit infinite loop */ - do { - c1 = 1.0 - cd; - s1 = sd; - do { - do { - do { - k2 = kk + kspan; - ak = Re [kk] - Re [k2]; - bk = Im [kk] - Im [k2]; - Re [kk] += Re [k2]; - Im [kk] += Im [k2]; - Re [k2] = c1 * ak - s1 * bk; - Im [k2] = s1 * ak + c1 * bk; - kk = k2 + kspan; - } while (kk < (nt-1)); - k2 = kk - nt; - c1 = -c1; - kk = k1 - k2; - } while (kk > k2); - ak = c1 - (cd * c1 + sd * s1); - s1 = sd * c1 - cd * s1 + s1; - c1 = 2.0 - (ak * ak + s1 * s1); - s1 *= c1; - c1 *= ak; - kk += jc; - } while (kk < k2); - k1 += inc + inc; - kk = (k1 - kspan + 1) / 2 + jc - 1; - } while (kk < (jc + jc)); - break; - - case 4: /* transform for factor of 4 */ - ispan = kspan; - kspan /= 4; - - do { - c1 = 1.0; - s1 = 0.0; - do { - do { - k1 = kk + kspan; - k2 = k1 + kspan; - k3 = k2 + kspan; - akp = Re [kk] + Re [k2]; - akm = Re [kk] - Re [k2]; - ajp = Re [k1] + Re [k3]; - ajm = Re [k1] - Re [k3]; - bkp = Im [kk] + Im [k2]; - bkm = Im [kk] - Im [k2]; - bjp = Im [k1] + Im [k3]; - bjm = Im [k1] - Im [k3]; - Re [kk] = akp + ajp; - Im [kk] = bkp + bjp; - ajp = akp - ajp; - bjp = bkp - bjp; - if (iSign < 0) { - akp = akm + bjm; - bkp = bkm - ajm; - akm -= bjm; - bkm += ajm; - } else { - akp = akm - bjm; - bkp = bkm + ajm; - akm += bjm; - bkm -= ajm; - } - /* avoid useless multiplies */ - if (s1 == 0.0) { - Re [k1] = akp; - Re [k2] = ajp; - Re [k3] = akm; - Im [k1] = bkp; - Im [k2] = bjp; - Im [k3] = bkm; - } else { - Re [k1] = akp * c1 - bkp * s1; - Re [k2] = ajp * c2 - bjp * s2; - Re [k3] = akm * c3 - bkm * s3; - Im [k1] = akp * s1 + bkp * c1; - Im [k2] = ajp * s2 + bjp * c2; - Im [k3] = akm * s3 + bkm * c3; - } - kk = k3 + kspan; - } while (kk < nt); - - c2 = c1 - (cd * c1 + sd * s1); - s1 = sd * c1 - cd * s1 + s1; - c1 = 2.0 - (c2 * c2 + s1 * s1); - s1 *= c1; - c1 *= c2; - /* values of c2, c3, s2, s3 that will get used next time */ - c2 = c1 * c1 - s1 * s1; - s2 = 2.0 * c1 * s1; - c3 = c2 * c1 - s2 * s1; - s3 = c2 * s1 + s2 * c1; - kk = kk - nt + jc; - } while (kk < kspan); - kk = kk - kspan + inc; - } while (kk < jc); - if (kspan == jc) - goto Permute_Results_Label; /* exit infinite loop */ - break; - - default: - /* transform for odd factors */ -#ifdef FFT_RADIX4 - return -1; - break; -#else /* FFT_RADIX4 */ - k = fftstate->factor [ii - 1]; - ispan = kspan; - kspan /= k; - - switch (k) { - case 3: /* transform for factor of 3 (optional code) */ - do { - do { - k1 = kk + kspan; - k2 = k1 + kspan; - ak = Re [kk]; - bk = Im [kk]; - aj = Re [k1] + Re [k2]; - bj = Im [k1] + Im [k2]; - Re [kk] = ak + aj; - Im [kk] = bk + bj; - ak -= 0.5 * aj; - bk -= 0.5 * bj; - aj = (Re [k1] - Re [k2]) * s60; - bj = (Im [k1] - Im [k2]) * s60; - Re [k1] = ak - bj; - Re [k2] = ak + bj; - Im [k1] = bk + aj; - Im [k2] = bk - aj; - kk = k2 + kspan; - } while (kk < (nn - 1)); - kk -= nn; - } while (kk < kspan); - break; - - case 5: /* transform for factor of 5 (optional code) */ - c2 = c72 * c72 - s72 * s72; - s2 = 2.0 * c72 * s72; - do { - do { - k1 = kk + kspan; - k2 = k1 + kspan; - k3 = k2 + kspan; - k4 = k3 + kspan; - akp = Re [k1] + Re [k4]; - akm = Re [k1] - Re [k4]; - bkp = Im [k1] + Im [k4]; - bkm = Im [k1] - Im [k4]; - ajp = Re [k2] + Re [k3]; - ajm = Re [k2] - Re [k3]; - bjp = Im [k2] + Im [k3]; - bjm = Im [k2] - Im [k3]; - aa = Re [kk]; - bb = Im [kk]; - Re [kk] = aa + akp + ajp; - Im [kk] = bb + bkp + bjp; - ak = akp * c72 + ajp * c2 + aa; - bk = bkp * c72 + bjp * c2 + bb; - aj = akm * s72 + ajm * s2; - bj = bkm * s72 + bjm * s2; - Re [k1] = ak - bj; - Re [k4] = ak + bj; - Im [k1] = bk + aj; - Im [k4] = bk - aj; - ak = akp * c2 + ajp * c72 + aa; - bk = bkp * c2 + bjp * c72 + bb; - aj = akm * s2 - ajm * s72; - bj = bkm * s2 - bjm * s72; - Re [k2] = ak - bj; - Re [k3] = ak + bj; - Im [k2] = bk + aj; - Im [k3] = bk - aj; - kk = k4 + kspan; - } while (kk < (nn-1)); - kk -= nn; - } while (kk < kspan); - break; - - default: - if (k != jf) { - jf = k; - s1 = pi2 / (double) k; - c1 = cos(s1); - s1 = sin(s1); - if (jf > max_factors){ - return -1; - } - Cos [jf - 1] = 1.0; - Sin [jf - 1] = 0.0; - j = 1; - do { - Cos [j - 1] = Cos [k - 1] * c1 + Sin [k - 1] * s1; - Sin [j - 1] = Cos [k - 1] * s1 - Sin [k - 1] * c1; - k--; - Cos [k - 1] = Cos [j - 1]; - Sin [k - 1] = -Sin [j - 1]; - j++; - } while (j < k); - } - do { - do { - k1 = kk; - k2 = kk + ispan; - ak = aa = Re [kk]; - bk = bb = Im [kk]; - j = 1; - k1 += kspan; - do { - k2 -= kspan; - j++; - Rtmp [j - 1] = Re [k1] + Re [k2]; - ak += Rtmp [j - 1]; - Itmp [j - 1] = Im [k1] + Im [k2]; - bk += Itmp [j - 1]; - j++; - Rtmp [j - 1] = Re [k1] - Re [k2]; - Itmp [j - 1] = Im [k1] - Im [k2]; - k1 += kspan; - } while (k1 < k2); - Re [kk] = ak; - Im [kk] = bk; - k1 = kk; - k2 = kk + ispan; - j = 1; - do { - k1 += kspan; - k2 -= kspan; - jj = j; - ak = aa; - bk = bb; - aj = 0.0; - bj = 0.0; - k = 1; - do { - k++; - ak += Rtmp [k - 1] * Cos [jj - 1]; - bk += Itmp [k - 1] * Cos [jj - 1]; - k++; - aj += Rtmp [k - 1] * Sin [jj - 1]; - bj += Itmp [k - 1] * Sin [jj - 1]; - jj += j; - if (jj > jf) { - jj -= jf; - } - } while (k < jf); - k = jf - j; - Re [k1] = ak - bj; - Im [k1] = bk + aj; - Re [k2] = ak + bj; - Im [k2] = bk - aj; - j++; - } while (j < k); - kk += ispan; - } while (kk < nn); - kk -= nn; - } while (kk < kspan); - break; - } - - /* multiply by rotation factor (except for factors of 2 and 4) */ - if (ii == mfactor) - goto Permute_Results_Label; /* exit infinite loop */ - kk = jc; - do { - c2 = 1.0 - cd; - s1 = sd; - do { - c1 = c2; - s2 = s1; - kk += kspan; - do { - do { - ak = Re [kk]; - Re [kk] = c2 * ak - s2 * Im [kk]; - Im [kk] = s2 * ak + c2 * Im [kk]; - kk += ispan; - } while (kk < nt); - ak = s1 * s2; - s2 = s1 * c2 + c1 * s2; - c2 = c1 * c2 - ak; - kk = kk - nt + kspan; - } while (kk < ispan); - c2 = c1 - (cd * c1 + sd * s1); - s1 += sd * c1 - cd * s1; - c1 = 2.0 - (c2 * c2 + s1 * s1); - s1 *= c1; - c2 *= c1; - kk = kk - ispan + jc; - } while (kk < kspan); - kk = kk - kspan + jc + inc; - } while (kk < (jc + jc)); - break; -#endif /* FFT_RADIX4 */ - } - } - - /* permute the results to normal order---done in two stages */ - /* permutation for square factors of n */ -Permute_Results_Label: - fftstate->Perm [0] = ns; - if (kt) { - k = kt + kt + 1; - if (mfactor < k) - k--; - j = 1; - fftstate->Perm [k] = jc; - do { - fftstate->Perm [j] = fftstate->Perm [j - 1] / fftstate->factor [j - 1]; - fftstate->Perm [k - 1] = fftstate->Perm [k] * fftstate->factor [j - 1]; - j++; - k--; - } while (j < k); - k3 = fftstate->Perm [k]; - kspan = fftstate->Perm [1]; - kk = jc; - k2 = kspan; - j = 1; - if (nPass != nTotal) { - /* permutation for multivariate transform */ - Permute_Multi_Label: - do { - do { - k = kk + jc; - do { - /* swap Re [kk] <> Re [k2], Im [kk] <> Im [k2] */ - ak = Re [kk]; Re [kk] = Re [k2]; Re [k2] = ak; - bk = Im [kk]; Im [kk] = Im [k2]; Im [k2] = bk; - kk += inc; - k2 += inc; - } while (kk < (k-1)); - kk += ns - jc; - k2 += ns - jc; - } while (kk < (nt-1)); - k2 = k2 - nt + kspan; - kk = kk - nt + jc; - } while (k2 < (ns-1)); - do { - do { - k2 -= fftstate->Perm [j - 1]; - j++; - k2 = fftstate->Perm [j] + k2; - } while (k2 > fftstate->Perm [j - 1]); - j = 1; - do { - if (kk < (k2-1)) - goto Permute_Multi_Label; - kk += jc; - k2 += kspan; - } while (k2 < (ns-1)); - } while (kk < (ns-1)); - } else { - /* permutation for single-variate transform (optional code) */ - Permute_Single_Label: - do { - /* swap Re [kk] <> Re [k2], Im [kk] <> Im [k2] */ - ak = Re [kk]; Re [kk] = Re [k2]; Re [k2] = ak; - bk = Im [kk]; Im [kk] = Im [k2]; Im [k2] = bk; - kk += inc; - k2 += kspan; - } while (k2 < (ns-1)); - do { - do { - k2 -= fftstate->Perm [j - 1]; - j++; - k2 = fftstate->Perm [j] + k2; - } while (k2 >= fftstate->Perm [j - 1]); - j = 1; - do { - if (kk < k2) - goto Permute_Single_Label; - kk += inc; - k2 += kspan; - } while (k2 < (ns-1)); - } while (kk < (ns-1)); - } - jc = k3; - } - - if ((kt << 1) + 1 >= mfactor) - return 0; - ispan = fftstate->Perm [kt]; - /* permutation for square-free factors of n */ - j = mfactor - kt; - fftstate->factor [j] = 1; - do { - fftstate->factor [j - 1] *= fftstate->factor [j]; - j--; - } while (j != kt); - kt++; - nn = fftstate->factor [kt - 1] - 1; - if (nn > (int) max_perm) { - return -1; - } - j = jj = 0; - for (;;) { - k = kt + 1; - k2 = fftstate->factor [kt - 1]; - kk = fftstate->factor [k - 1]; - j++; - if (j > nn) - break; /* exit infinite loop */ - jj += kk; - while (jj >= k2) { - jj -= k2; - k2 = kk; - k++; - kk = fftstate->factor [k - 1]; - jj += kk; - } - fftstate->Perm [j - 1] = jj; - } - /* determine the permutation cycles of length greater than 1 */ - j = 0; - for (;;) { - do { - j++; - kk = fftstate->Perm [j - 1]; - } while (kk < 0); - if (kk != j) { - do { - k = kk; - kk = fftstate->Perm [k - 1]; - fftstate->Perm [k - 1] = -kk; - } while (kk != j); - k3 = kk; - } else { - fftstate->Perm [j - 1] = -j; - if (j == nn) - break; /* exit infinite loop */ - } - } - max_factors *= inc; - /* reorder a and b, following the permutation cycles */ - for (;;) { - j = k3 + 1; - nt -= ispan; - ii = nt - inc + 1; - if (nt < 0) - break; /* exit infinite loop */ - do { - do { - j--; - } while (fftstate->Perm [j - 1] < 0); - jj = jc; - do { - kspan = jj; - if (jj > max_factors) { - kspan = max_factors; - } - jj -= kspan; - k = fftstate->Perm [j - 1]; - kk = jc * k + ii + jj; - k1 = kk + kspan - 1; - k2 = 0; - do { - k2++; - Rtmp [k2 - 1] = Re [k1]; - Itmp [k2 - 1] = Im [k1]; - k1 -= inc; - } while (k1 != (kk-1)); - do { - k1 = kk + kspan - 1; - k2 = k1 - jc * (k + fftstate->Perm [k - 1]); - k = -fftstate->Perm [k - 1]; - do { - Re [k1] = Re [k2]; - Im [k1] = Im [k2]; - k1 -= inc; - k2 -= inc; - } while (k1 != (kk-1)); - kk = k2 + 1; - } while (k != j); - k1 = kk + kspan - 1; - k2 = 0; - do { - k2++; - Re [k1] = Rtmp [k2 - 1]; - Im [k1] = Itmp [k2 - 1]; - k1 -= inc; - } while (k1 != (kk-1)); - } while (jj); - } while (j != 1); - } - return 0; /* exit point here */ -} -/* ---------------------- end-of-file (c source) ---------------------- */ -
diff --git a/src/modules/audio_coding/codecs/isac/main/source/filter_functions.c b/src/modules/audio_coding/codecs/isac/main/source/filter_functions.c deleted file mode 100644 index 33024a3..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/filter_functions.c +++ /dev/null
@@ -1,271 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <memory.h> -#ifdef WEBRTC_ANDROID -#include <stdlib.h> -#endif -#include "pitch_estimator.h" -#include "lpc_analysis.h" -#include "codec.h" - - - -void WebRtcIsac_AllPoleFilter(double *InOut, double *Coef, int lengthInOut, int orderCoef){ - - /* the state of filter is assumed to be in InOut[-1] to InOut[-orderCoef] */ - double scal; - double sum; - int n,k; - - //if (fabs(Coef[0]-1.0)<0.001) { - if ( (Coef[0] > 0.9999) && (Coef[0] < 1.0001) ) - { - for(n = 0; n < lengthInOut; n++) - { - sum = Coef[1] * InOut[-1]; - for(k = 2; k <= orderCoef; k++){ - sum += Coef[k] * InOut[-k]; - } - *InOut++ -= sum; - } - } - else - { - scal = 1.0 / Coef[0]; - for(n=0;n<lengthInOut;n++) - { - *InOut *= scal; - for(k=1;k<=orderCoef;k++){ - *InOut -= scal*Coef[k]*InOut[-k]; - } - InOut++; - } - } -} - - -void WebRtcIsac_AllZeroFilter(double *In, double *Coef, int lengthInOut, int orderCoef, double *Out){ - - /* the state of filter is assumed to be in In[-1] to In[-orderCoef] */ - - int n, k; - double tmp; - - for(n = 0; n < lengthInOut; n++) - { - tmp = In[0] * Coef[0]; - - for(k = 1; k <= orderCoef; k++){ - tmp += Coef[k] * In[-k]; - } - - *Out++ = tmp; - In++; - } -} - - - -void WebRtcIsac_ZeroPoleFilter(double *In, double *ZeroCoef, double *PoleCoef, int lengthInOut, int orderCoef, double *Out){ - - /* the state of the zero section is assumed to be in In[-1] to In[-orderCoef] */ - /* the state of the pole section is assumed to be in Out[-1] to Out[-orderCoef] */ - - WebRtcIsac_AllZeroFilter(In,ZeroCoef,lengthInOut,orderCoef,Out); - WebRtcIsac_AllPoleFilter(Out,PoleCoef,lengthInOut,orderCoef); -} - - -void WebRtcIsac_AutoCorr( - double *r, - const double *x, - int N, - int order - ) -{ - int lag, n; - double sum, prod; - const double *x_lag; - - for (lag = 0; lag <= order; lag++) - { - sum = 0.0f; - x_lag = &x[lag]; - prod = x[0] * x_lag[0]; - for (n = 1; n < N - lag; n++) { - sum += prod; - prod = x[n] * x_lag[n]; - } - sum += prod; - r[lag] = sum; - } - -} - - -void WebRtcIsac_BwExpand(double *out, double *in, double coef, short length) { - int i; - double chirp; - - chirp = coef; - - out[0] = in[0]; - for (i = 1; i < length; i++) { - out[i] = chirp * in[i]; - chirp *= coef; - } -} - -void WebRtcIsac_WeightingFilter(const double *in, double *weiout, double *whiout, WeightFiltstr *wfdata) { - - double tmpbuffer[PITCH_FRAME_LEN + PITCH_WLPCBUFLEN]; - double corr[PITCH_WLPCORDER+1], rc[PITCH_WLPCORDER+1]; - double apol[PITCH_WLPCORDER+1], apolr[PITCH_WLPCORDER+1]; - double rho=0.9, *inp, *dp, *dp2; - double whoutbuf[PITCH_WLPCBUFLEN + PITCH_WLPCORDER]; - double weoutbuf[PITCH_WLPCBUFLEN + PITCH_WLPCORDER]; - double *weo, *who, opol[PITCH_WLPCORDER+1], ext[PITCH_WLPCWINLEN]; - int k, n, endpos, start; - - /* Set up buffer and states */ - memcpy(tmpbuffer, wfdata->buffer, sizeof(double) * PITCH_WLPCBUFLEN); - memcpy(tmpbuffer+PITCH_WLPCBUFLEN, in, sizeof(double) * PITCH_FRAME_LEN); - memcpy(wfdata->buffer, tmpbuffer+PITCH_FRAME_LEN, sizeof(double) * PITCH_WLPCBUFLEN); - - dp=weoutbuf; - dp2=whoutbuf; - for (k=0;k<PITCH_WLPCORDER;k++) { - *dp++ = wfdata->weostate[k]; - *dp2++ = wfdata->whostate[k]; - opol[k]=0.0; - } - opol[0]=1.0; - opol[PITCH_WLPCORDER]=0.0; - weo=dp; - who=dp2; - - endpos=PITCH_WLPCBUFLEN + PITCH_SUBFRAME_LEN; - inp=tmpbuffer + PITCH_WLPCBUFLEN; - - for (n=0; n<PITCH_SUBFRAMES; n++) { - /* Windowing */ - start=endpos-PITCH_WLPCWINLEN; - for (k=0; k<PITCH_WLPCWINLEN; k++) { - ext[k]=wfdata->window[k]*tmpbuffer[start+k]; - } - - /* Get LPC polynomial */ - WebRtcIsac_AutoCorr(corr, ext, PITCH_WLPCWINLEN, PITCH_WLPCORDER); - corr[0]=1.01*corr[0]+1.0; /* White noise correction */ - WebRtcIsac_LevDurb(apol, rc, corr, PITCH_WLPCORDER); - WebRtcIsac_BwExpand(apolr, apol, rho, PITCH_WLPCORDER+1); - - /* Filtering */ - WebRtcIsac_ZeroPoleFilter(inp, apol, apolr, PITCH_SUBFRAME_LEN, PITCH_WLPCORDER, weo); - WebRtcIsac_ZeroPoleFilter(inp, apolr, opol, PITCH_SUBFRAME_LEN, PITCH_WLPCORDER, who); - - inp+=PITCH_SUBFRAME_LEN; - endpos+=PITCH_SUBFRAME_LEN; - weo+=PITCH_SUBFRAME_LEN; - who+=PITCH_SUBFRAME_LEN; - } - - /* Export filter states */ - for (k=0;k<PITCH_WLPCORDER;k++) { - wfdata->weostate[k]=weoutbuf[PITCH_FRAME_LEN+k]; - wfdata->whostate[k]=whoutbuf[PITCH_FRAME_LEN+k]; - } - - /* Export output data */ - memcpy(weiout, weoutbuf+PITCH_WLPCORDER, sizeof(double) * PITCH_FRAME_LEN); - memcpy(whiout, whoutbuf+PITCH_WLPCORDER, sizeof(double) * PITCH_FRAME_LEN); -} - - -static const double APupper[ALLPASSSECTIONS] = {0.0347, 0.3826}; -static const double APlower[ALLPASSSECTIONS] = {0.1544, 0.744}; - - - -void WebRtcIsac_AllpassFilterForDec(double *InOut, - const double *APSectionFactors, - int lengthInOut, - double *FilterState) -{ - //This performs all-pass filtering--a series of first order all-pass sections are used - //to filter the input in a cascade manner. - int n,j; - double temp; - for (j=0; j<ALLPASSSECTIONS; j++){ - for (n=0;n<lengthInOut;n+=2){ - temp = InOut[n]; //store input - InOut[n] = FilterState[j] + APSectionFactors[j]*temp; - FilterState[j] = -APSectionFactors[j]*InOut[n] + temp; - } - } -} - -void WebRtcIsac_DecimateAllpass(const double *in, - double *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */ - int N, /* number of input samples */ - double *out) /* array of size N/2 */ -{ - int n; - double data_vec[PITCH_FRAME_LEN]; - - /* copy input */ - memcpy(data_vec+1, in, sizeof(double) * (N-1)); - - data_vec[0] = state_in[2*ALLPASSSECTIONS]; //the z^(-1) state - state_in[2*ALLPASSSECTIONS] = in[N-1]; - - WebRtcIsac_AllpassFilterForDec(data_vec+1, APupper, N, state_in); - WebRtcIsac_AllpassFilterForDec(data_vec, APlower, N, state_in+ALLPASSSECTIONS); - - for (n=0;n<N/2;n++) - out[n] = data_vec[2*n] + data_vec[2*n+1]; - -} - - - -/* create high-pass filter ocefficients - * z = 0.998 * exp(j*2*pi*35/8000); - * p = 0.94 * exp(j*2*pi*140/8000); - * HP_b = [1, -2*real(z), abs(z)^2]; - * HP_a = [1, -2*real(p), abs(p)^2]; */ -static const double a_coef[2] = { 1.86864659625574, -0.88360000000000}; -static const double b_coef[2] = {-1.99524591718270, 0.99600400000000}; -static const float a_coef_float[2] = { 1.86864659625574f, -0.88360000000000f}; -static const float b_coef_float[2] = {-1.99524591718270f, 0.99600400000000f}; - -/* second order high-pass filter */ -void WebRtcIsac_Highpass(const double *in, double *out, double *state, int N) -{ - int k; - - for (k=0; k<N; k++) { - *out = *in + state[1]; - state[1] = state[0] + b_coef[0] * *in + a_coef[0] * *out; - state[0] = b_coef[1] * *in++ + a_coef[1] * *out++; - } -} - -void WebRtcIsac_Highpass_float(const float *in, double *out, double *state, int N) -{ - int k; - - for (k=0; k<N; k++) { - *out = (double)*in + state[1]; - state[1] = state[0] + b_coef_float[0] * *in + a_coef_float[0] * *out; - state[0] = b_coef_float[1] * (double)*in++ + a_coef_float[1] * *out++; - } -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/intialize.c b/src/modules/audio_coding/codecs/isac/main/source/intialize.c deleted file mode 100644 index 6df034d..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/intialize.c +++ /dev/null
@@ -1,175 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* encode.c - Encoding function for the iSAC coder */ - -#include "structs.h" -#include "codec.h" -#include "pitch_estimator.h" - -#include <math.h> - -void WebRtcIsac_InitMasking(MaskFiltstr *maskdata) { - - int k; - - for (k = 0; k < WINLEN; k++) { - maskdata->DataBufferLo[k] = 0.0; - maskdata->DataBufferHi[k] = 0.0; - } - for (k = 0; k < ORDERLO+1; k++) { - maskdata->CorrBufLo[k] = 0.0; - maskdata->PreStateLoF[k] = 0.0; - maskdata->PreStateLoG[k] = 0.0; - maskdata->PostStateLoF[k] = 0.0; - maskdata->PostStateLoG[k] = 0.0; - } - for (k = 0; k < ORDERHI+1; k++) { - maskdata->CorrBufHi[k] = 0.0; - maskdata->PreStateHiF[k] = 0.0; - maskdata->PreStateHiG[k] = 0.0; - maskdata->PostStateHiF[k] = 0.0; - maskdata->PostStateHiG[k] = 0.0; - } - - maskdata->OldEnergy = 10.0; - - /* fill tables for transforms */ - WebRtcIsac_InitTransform(); - - return; -} - -void WebRtcIsac_InitPreFilterbank(PreFiltBankstr *prefiltdata) -{ - int k; - - for (k = 0; k < QLOOKAHEAD; k++) { - prefiltdata->INLABUF1[k] = 0; - prefiltdata->INLABUF2[k] = 0; - - prefiltdata->INLABUF1_float[k] = 0; - prefiltdata->INLABUF2_float[k] = 0; - } - for (k = 0; k < 2*(QORDER-1); k++) { - prefiltdata->INSTAT1[k] = 0; - prefiltdata->INSTAT2[k] = 0; - prefiltdata->INSTATLA1[k] = 0; - prefiltdata->INSTATLA2[k] = 0; - - prefiltdata->INSTAT1_float[k] = 0; - prefiltdata->INSTAT2_float[k] = 0; - prefiltdata->INSTATLA1_float[k] = 0; - prefiltdata->INSTATLA2_float[k] = 0; - } - - /* High pass filter states */ - prefiltdata->HPstates[0] = 0.0; - prefiltdata->HPstates[1] = 0.0; - - prefiltdata->HPstates_float[0] = 0.0f; - prefiltdata->HPstates_float[1] = 0.0f; - - return; -} - -void WebRtcIsac_InitPostFilterbank(PostFiltBankstr *postfiltdata) -{ - int k; - - for (k = 0; k < 2*POSTQORDER; k++) { - postfiltdata->STATE_0_LOWER[k] = 0; - postfiltdata->STATE_0_UPPER[k] = 0; - - postfiltdata->STATE_0_LOWER_float[k] = 0; - postfiltdata->STATE_0_UPPER_float[k] = 0; - } - - /* High pass filter states */ - postfiltdata->HPstates1[0] = 0.0; - postfiltdata->HPstates1[1] = 0.0; - - postfiltdata->HPstates2[0] = 0.0; - postfiltdata->HPstates2[1] = 0.0; - - postfiltdata->HPstates1_float[0] = 0.0f; - postfiltdata->HPstates1_float[1] = 0.0f; - - postfiltdata->HPstates2_float[0] = 0.0f; - postfiltdata->HPstates2_float[1] = 0.0f; - - return; -} - - -void WebRtcIsac_InitPitchFilter(PitchFiltstr *pitchfiltdata) -{ - int k; - - for (k = 0; k < PITCH_BUFFSIZE; k++) { - pitchfiltdata->ubuf[k] = 0.0; - } - pitchfiltdata->ystate[0] = 0.0; - for (k = 1; k < (PITCH_DAMPORDER); k++) { - pitchfiltdata->ystate[k] = 0.0; - } - pitchfiltdata->oldlagp[0] = 50.0; - pitchfiltdata->oldgainp[0] = 0.0; -} - -void WebRtcIsac_InitWeightingFilter(WeightFiltstr *wfdata) -{ - int k; - double t, dtmp, dtmp2, denum, denum2; - - for (k=0;k<PITCH_WLPCBUFLEN;k++) - wfdata->buffer[k]=0.0; - - for (k=0;k<PITCH_WLPCORDER;k++) { - wfdata->istate[k]=0.0; - wfdata->weostate[k]=0.0; - wfdata->whostate[k]=0.0; - } - - /* next part should be in Matlab, writing to a global table */ - t = 0.5; - denum = 1.0 / ((double) PITCH_WLPCWINLEN); - denum2 = denum * denum; - for (k=0;k<PITCH_WLPCWINLEN;k++) { - dtmp = PITCH_WLPCASYM * t * denum + (1-PITCH_WLPCASYM) * t * t * denum2; - dtmp *= 3.14159265; - dtmp2 = sin(dtmp); - wfdata->window[k] = dtmp2 * dtmp2; - t++; - } -} - -/* clear all buffers */ -void WebRtcIsac_InitPitchAnalysis(PitchAnalysisStruct *State) -{ - int k; - - for (k = 0; k < PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2; k++) - State->dec_buffer[k] = 0.0; - for (k = 0; k < 2*ALLPASSSECTIONS+1; k++) - State->decimator_state[k] = 0.0; - for (k = 0; k < 2; k++) - State->hp_state[k] = 0.0; - for (k = 0; k < QLOOKAHEAD; k++) - State->whitened_buf[k] = 0.0; - for (k = 0; k < QLOOKAHEAD; k++) - State->inbuf[k] = 0.0; - - WebRtcIsac_InitPitchFilter(&(State->PFstr_wght)); - - WebRtcIsac_InitPitchFilter(&(State->PFstr)); - - WebRtcIsac_InitWeightingFilter(&(State->Wghtstr)); -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/isac.c b/src/modules/audio_coding/codecs/isac/main/source/isac.c deleted file mode 100644 index 7c90334..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/isac.c +++ /dev/null
@@ -1,2313 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * isac.c - * - * This C file contains the functions for the ISAC API - * - */ - -#include "isac.h" -#include "bandwidth_estimator.h" -#include "crc.h" -#include "entropy_coding.h" -#include "codec.h" -#include "structs.h" -#include "signal_processing_library.h" -#include "lpc_shape_swb16_tables.h" -#include "os_specific_inline.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <math.h> - -#define BIT_MASK_DEC_INIT 0x0001 -#define BIT_MASK_ENC_INIT 0x0002 - -#define LEN_CHECK_SUM_WORD8 4 -#define MAX_NUM_LAYERS 10 - - -/**************************************************************************** - * UpdatePayloadSizeLimit(...) - * - * Call this function to update the limit on the payload size. The limit on - * payload size might change i) if a user ''directly changes the limit by - * calling xxx_setMaxPayloadSize() or xxx_setMaxRate(), or ii) indirectly - * when bandwidth is changing. The latter might be the result of bandwidth - * adaptation, or direct change of the bottleneck in instantaneous mode. - * - * This function takes the current overall limit on payload, and translates it - * to the limits on lower and upper-band. If the codec is in wideband mode, - * then the overall limit and the limit on the lower-band is the same. - * Otherwise, a fraction of the limit should be allocated to lower-band - * leaving some room for the upper-band bit-stream. That is why an update - * of limit is required every time that the bandwidth is changing. - * - */ -static void UpdatePayloadSizeLimit(ISACMainStruct* instISAC) { - WebRtc_Word16 lim30MsPayloadBytes = WEBRTC_SPL_MIN( - (instISAC->maxPayloadSizeBytes), - (instISAC->maxRateBytesPer30Ms)); - WebRtc_Word16 lim60MsPayloadBytes = WEBRTC_SPL_MIN( - (instISAC->maxPayloadSizeBytes), - (instISAC->maxRateBytesPer30Ms << 1)); - - /* The only time that iSAC will have 60 ms - * frame-size is when operating in wideband, so - * there is no upper-band bit-stream. */ - - if (instISAC->bandwidthKHz == isac8kHz) { - /* At 8 kHz there is no upper-band bit-stream, - * therefore, the lower-band limit is the overall limit. */ - instISAC->instLB.ISACencLB_obj.payloadLimitBytes60 = - lim60MsPayloadBytes; - instISAC->instLB.ISACencLB_obj.payloadLimitBytes30 = - lim30MsPayloadBytes; - } else { - /* When in super-wideband, we only have 30 ms frames. - * Do a rate allocation for the given limit. */ - if (lim30MsPayloadBytes > 250) { - /* 4/5 to lower-band the rest for upper-band. */ - instISAC->instLB.ISACencLB_obj.payloadLimitBytes30 = - (lim30MsPayloadBytes << 2) / 5; - } else if (lim30MsPayloadBytes > 200) { - /* For the interval of 200 to 250 the share of - * upper-band linearly grows from 20 to 50. */ - instISAC->instLB.ISACencLB_obj.payloadLimitBytes30 = - (lim30MsPayloadBytes << 1) / 5 + 100; - } else { - /* Allocate only 20 for upper-band. */ - instISAC->instLB.ISACencLB_obj.payloadLimitBytes30 = - lim30MsPayloadBytes - 20; - } - instISAC->instUB.ISACencUB_obj.maxPayloadSizeBytes = - lim30MsPayloadBytes; - } -} - - -/**************************************************************************** - * UpdateBottleneck(...) - * - * This function updates the bottleneck only if the codec is operating in - * channel-adaptive mode. Furthermore, as the update of bottleneck might - * result in an update of bandwidth, therefore, the bottlenech should be - * updated just right before the first 10ms of a frame is pushed into encoder. - * - */ -static void UpdateBottleneck(ISACMainStruct* instISAC) { - /* Read the bottleneck from bandwidth estimator for the - * first 10 ms audio. This way, if there is a change - * in bandwidth, upper and lower-band will be in sync. */ - if ((instISAC->codingMode == 0) && - (instISAC->instLB.ISACencLB_obj.buffer_index == 0) && - (instISAC->instLB.ISACencLB_obj.frame_nb == 0)) { - WebRtc_Word32 bottleneck; - WebRtcIsac_GetUplinkBandwidth(&(instISAC->bwestimator_obj), - &bottleneck); - - /* Adding hysteresis when increasing signal bandwidth. */ - if ((instISAC->bandwidthKHz == isac8kHz) - && (bottleneck > 37000) - && (bottleneck < 41000)) { - bottleneck = 37000; - } - - /* Switching from 12 kHz to 16 kHz is not allowed at this revision. - * If we let this happen, we have to take care of buffer_index and - * the last LPC vector. */ - if ((instISAC->bandwidthKHz != isac16kHz) && - (bottleneck > 46000)) { - bottleneck = 46000; - } - - /* We might need a rate allocation. */ - if (instISAC->encoderSamplingRateKHz == kIsacWideband) { - /* Wideband is the only choice we have here. */ - instISAC->instLB.ISACencLB_obj.bottleneck = - (bottleneck > 32000) ? 32000 : bottleneck; - instISAC->bandwidthKHz = isac8kHz; - } else { - /* Do the rate-allocation and get the new bandwidth. */ - enum ISACBandwidth bandwidth; - WebRtcIsac_RateAllocation(bottleneck, - &(instISAC->instLB.ISACencLB_obj.bottleneck), - &(instISAC->instUB.ISACencUB_obj.bottleneck), - &bandwidth); - if (bandwidth != isac8kHz) { - instISAC->instLB.ISACencLB_obj.new_framelength = 480; - } - if (bandwidth != instISAC->bandwidthKHz) { - /* Bandwidth is changing. */ - instISAC->bandwidthKHz = bandwidth; - UpdatePayloadSizeLimit(instISAC); - if (bandwidth == isac12kHz) { - instISAC->instLB.ISACencLB_obj.buffer_index = 0; - } - /* Currently we don't let the bandwidth to switch to 16 kHz - * if in adaptive mode. If we let this happen, we have to take - * care of buffer_index and the last LPC vector. */ - } - } - } -} - - -/**************************************************************************** - * GetSendBandwidthInfo(...) - * - * This is called to get the bandwidth info. This info is the bandwidth and - * the jitter of 'there-to-here' channel, estimated 'here.' These info - * is signaled in an in-band fashion to the other side. - * - * The call to the bandwidth estimator triggers a recursive averaging which - * has to be synchronized between encoder & decoder, therefore, the call to - * BWE should be once per packet. As the BWE info is inserted into bit-stream - * We need a valid info right before the encodeLB function is going to - * generate a bit-stream. That is when lower-band buffer has already 20ms - * of audio, and the 3rd block of 10ms is going to be injected into encoder. - * - * Inputs: - * - instISAC : iSAC instance. - * - * Outputs: - * - bandwidthIndex : an index which has to be encoded in - * lower-band bit-stream, indicating the - * bandwidth of there-to-here channel. - * - jitterInfo : this indicates if the jitter is high - * or low and it is encoded in upper-band - * bit-stream. - * - */ -static void GetSendBandwidthInfo(ISACMainStruct* instISAC, - WebRtc_Word16* bandwidthIndex, - WebRtc_Word16* jitterInfo) { - if ((instISAC->instLB.ISACencLB_obj.buffer_index == - (FRAMESAMPLES_10ms << 1)) && - (instISAC->instLB.ISACencLB_obj.frame_nb == 0)) { - /* Bandwidth estimation and coding. */ - WebRtcIsac_GetDownlinkBwJitIndexImpl(&(instISAC->bwestimator_obj), - bandwidthIndex, jitterInfo, - instISAC->decoderSamplingRateKHz); - } -} - - -/**************************************************************************** - * WebRtcIsac_AssignSize(...) - * - * This function returns the size of the ISAC instance, so that the instance - * can be created out side iSAC. - * - * Output: - * - sizeinbytes : number of bytes needed to allocate for the - * instance. - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_AssignSize(int* sizeInBytes) { - *sizeInBytes = sizeof(ISACMainStruct) * 2 / sizeof(WebRtc_Word16); - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_Assign(...) - * - * This function assigns the memory already created to the ISAC instance. - * - * Input: - * - ISAC_main_inst : address of the pointer to the coder instance. - * - instISAC_Addr : the already allocated memory, where we put the - * iSAC structure. - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_Assign(ISACStruct** ISAC_main_inst, - void* instISAC_Addr) { - if (instISAC_Addr != NULL) { - ISACMainStruct* instISAC = (ISACMainStruct*)instISAC_Addr; - instISAC->errorCode = 0; - instISAC->initFlag = 0; - - /* Assign the address. */ - *ISAC_main_inst = (ISACStruct*)instISAC_Addr; - - /* Default is wideband. */ - instISAC->encoderSamplingRateKHz = kIsacWideband; - instISAC->decoderSamplingRateKHz = kIsacWideband; - instISAC->bandwidthKHz = isac8kHz; - return 0; - } else { - return -1; - } -} - - -/**************************************************************************** - * WebRtcIsac_Create(...) - * - * This function creates an ISAC instance, which will contain the state - * information for one coding/decoding channel. - * - * Input: - * - ISAC_main_inst : address of the pointer to the coder instance. - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_Create(ISACStruct** ISAC_main_inst) { - ISACMainStruct* instISAC; - - instISAC = (ISACMainStruct*)WEBRTC_SPL_VNEW(ISACMainStruct, 1); - *ISAC_main_inst = (ISACStruct*)instISAC; - if (*ISAC_main_inst != NULL) { - instISAC->errorCode = 0; - instISAC->initFlag = 0; - /* Default is wideband. */ - instISAC->bandwidthKHz = isac8kHz; - instISAC->encoderSamplingRateKHz = kIsacWideband; - instISAC->decoderSamplingRateKHz = kIsacWideband; - return 0; - } else { - return -1; - } -} - - -/**************************************************************************** - * WebRtcIsac_Free(...) - * - * This function frees the ISAC instance created at the beginning. - * - * Input: - * - ISAC_main_inst : a ISAC instance. - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_Free(ISACStruct* ISAC_main_inst) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - WEBRTC_SPL_FREE(instISAC); - return 0; -} - - -/**************************************************************************** - * EncoderInitLb(...) - internal function for initialization of - * Lower Band - * EncoderInitUb(...) - internal function for initialization of - * Upper Band - * WebRtcIsac_EncoderInit(...) - API function - * - * This function initializes a ISAC instance prior to the encoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - CodingMode : 0 -> Bit rate and frame length are automatically - * adjusted to available bandwidth on - * transmission channel, applicable just to - * wideband mode. - * 1 -> User sets a frame length and a target bit - * rate which is taken as the maximum - * short-term average bit rate. - * - * Return value : 0 - Ok - * -1 - Error - */ -static WebRtc_Word16 EncoderInitLb(ISACLBStruct* instLB, - WebRtc_Word16 codingMode, - enum IsacSamplingRate sampRate) { - WebRtc_Word16 statusInit = 0; - int k; - - /* Init stream vector to zero */ - for (k = 0; k < STREAM_SIZE_MAX_60; k++) { - instLB->ISACencLB_obj.bitstr_obj.stream[k] = 0; - } - - if ((codingMode == 1) || (sampRate == kIsacSuperWideband)) { - /* 30 ms frame-size if either in super-wideband or - * instantaneous mode (I-mode). */ - instLB->ISACencLB_obj.new_framelength = 480; - } else { - instLB->ISACencLB_obj.new_framelength = INITIAL_FRAMESAMPLES; - } - - WebRtcIsac_InitMasking(&instLB->ISACencLB_obj.maskfiltstr_obj); - WebRtcIsac_InitPreFilterbank(&instLB->ISACencLB_obj.prefiltbankstr_obj); - WebRtcIsac_InitPitchFilter(&instLB->ISACencLB_obj.pitchfiltstr_obj); - WebRtcIsac_InitPitchAnalysis( - &instLB->ISACencLB_obj.pitchanalysisstr_obj); - - instLB->ISACencLB_obj.buffer_index = 0; - instLB->ISACencLB_obj.frame_nb = 0; - /* Default for I-mode. */ - instLB->ISACencLB_obj.bottleneck = 32000; - instLB->ISACencLB_obj.current_framesamples = 0; - instLB->ISACencLB_obj.s2nr = 0; - instLB->ISACencLB_obj.payloadLimitBytes30 = STREAM_SIZE_MAX_30; - instLB->ISACencLB_obj.payloadLimitBytes60 = STREAM_SIZE_MAX_60; - instLB->ISACencLB_obj.maxPayloadBytes = STREAM_SIZE_MAX_60; - instLB->ISACencLB_obj.maxRateInBytes = STREAM_SIZE_MAX_30; - instLB->ISACencLB_obj.enforceFrameSize = 0; - /* Invalid value prevents getRedPayload to - run before encoder is called. */ - instLB->ISACencLB_obj.lastBWIdx = -1; - return statusInit; -} - -static WebRtc_Word16 EncoderInitUb(ISACUBStruct* instUB, - WebRtc_Word16 bandwidth) { - WebRtc_Word16 statusInit = 0; - int k; - - /* Init stream vector to zero. */ - for (k = 0; k < STREAM_SIZE_MAX_60; k++) { - instUB->ISACencUB_obj.bitstr_obj.stream[k] = 0; - } - - WebRtcIsac_InitMasking(&instUB->ISACencUB_obj.maskfiltstr_obj); - WebRtcIsac_InitPreFilterbank(&instUB->ISACencUB_obj.prefiltbankstr_obj); - - if (bandwidth == isac16kHz) { - instUB->ISACencUB_obj.buffer_index = LB_TOTAL_DELAY_SAMPLES; - } else { - instUB->ISACencUB_obj.buffer_index = 0; - } - /* Default for I-mode. */ - instUB->ISACencUB_obj.bottleneck = 32000; - /* These store the limits for the wideband + super-wideband bit-stream. */ - instUB->ISACencUB_obj.maxPayloadSizeBytes = STREAM_SIZE_MAX_30 << 1; - /* This has to be updated after each lower-band encoding to guarantee - * a correct payload-limitation. */ - instUB->ISACencUB_obj.numBytesUsed = 0; - memset(instUB->ISACencUB_obj.data_buffer_float, 0, - (MAX_FRAMESAMPLES + LB_TOTAL_DELAY_SAMPLES) * sizeof(float)); - - memcpy(&(instUB->ISACencUB_obj.lastLPCVec), - WebRtcIsac_kMeanLarUb16, sizeof(double) * UB_LPC_ORDER); - - return statusInit; -} - - -WebRtc_Word16 WebRtcIsac_EncoderInit(ISACStruct* ISAC_main_inst, - WebRtc_Word16 codingMode) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - WebRtc_Word16 status; - - if ((codingMode != 0) && (codingMode != 1)) { - instISAC->errorCode = ISAC_DISALLOWED_CODING_MODE; - return -1; - } - /* Default bottleneck. */ - instISAC->bottleneck = MAX_ISAC_BW; - - if (instISAC->encoderSamplingRateKHz == kIsacWideband) { - instISAC->bandwidthKHz = isac8kHz; - instISAC->maxPayloadSizeBytes = STREAM_SIZE_MAX_60; - instISAC->maxRateBytesPer30Ms = STREAM_SIZE_MAX_30; - } else { - instISAC->bandwidthKHz = isac16kHz; - instISAC->maxPayloadSizeBytes = STREAM_SIZE_MAX; - instISAC->maxRateBytesPer30Ms = STREAM_SIZE_MAX; - } - - /* Channel-adaptive = 0; Instantaneous (Channel-independent) = 1. */ - instISAC->codingMode = codingMode; - - WebRtcIsac_InitBandwidthEstimator(&instISAC->bwestimator_obj, - instISAC->encoderSamplingRateKHz, - instISAC->decoderSamplingRateKHz); - - WebRtcIsac_InitRateModel(&instISAC->rate_data_obj); - /* Default for I-mode. */ - instISAC->MaxDelay = 10.0; - - status = EncoderInitLb(&instISAC->instLB, codingMode, - instISAC->encoderSamplingRateKHz); - if (status < 0) { - instISAC->errorCode = -status; - return -1; - } - - if (instISAC->encoderSamplingRateKHz == kIsacSuperWideband) { - /* Initialize encoder filter-bank. */ - memset(instISAC->analysisFBState1, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - memset(instISAC->analysisFBState2, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - - status = EncoderInitUb(&(instISAC->instUB), - instISAC->bandwidthKHz); - if (status < 0) { - instISAC->errorCode = -status; - return -1; - } - } - /* Initialization is successful, set the flag. */ - instISAC->initFlag |= BIT_MASK_ENC_INIT; - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_Encode(...) - * - * This function encodes 10ms frame(s) and inserts it into a package. - * Input speech length has to be 160 samples (10ms). The encoder buffers those - * 10ms frames until it reaches the chosen Framesize (480 or 960 samples - * corresponding to 30 or 60 ms frames), and then proceeds to the encoding. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - speechIn : input speech vector. - * - * Output: - * - encoded : the encoded data vector - * - * Return value: - * : >0 - Length (in bytes) of coded data - * : 0 - The buffer didn't reach the chosen - * frameSize so it keeps buffering speech - * samples. - * : -1 - Error - */ -WebRtc_Word16 WebRtcIsac_Encode(ISACStruct* ISAC_main_inst, - const WebRtc_Word16* speechIn, - WebRtc_Word16* encoded) { - float inFrame[FRAMESAMPLES_10ms]; - WebRtc_Word16 speechInLB[FRAMESAMPLES_10ms]; - WebRtc_Word16 speechInUB[FRAMESAMPLES_10ms]; - WebRtc_Word16 streamLenLB = 0; - WebRtc_Word16 streamLenUB = 0; - WebRtc_Word16 streamLen = 0; - WebRtc_Word16 k = 0; - WebRtc_UWord8* ptrEncodedUW8 = (WebRtc_UWord8*)encoded; - int garbageLen = 0; - WebRtc_Word32 bottleneck = 0; - WebRtc_Word16 bottleneckIdx = 0; - WebRtc_Word16 jitterInfo = 0; - - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - ISACLBStruct* instLB = &(instISAC->instLB); - ISACUBStruct* instUB = &(instISAC->instUB); - - /* Check if encoder initiated. */ - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - - if (instISAC->encoderSamplingRateKHz == kIsacSuperWideband) { - WebRtcSpl_AnalysisQMF(speechIn, speechInLB, speechInUB, - instISAC->analysisFBState1, - instISAC->analysisFBState2); - - /* Convert from fixed to floating point. */ - for (k = 0; k < FRAMESAMPLES_10ms; k++) { - inFrame[k] = (float)speechInLB[k]; - } - } else { - for (k = 0; k < FRAMESAMPLES_10ms; k++) { - inFrame[k] = (float) speechIn[k]; - } - } - - /* Add some noise to avoid denormal numbers. */ - inFrame[0] += (float)1.23455334e-3; - inFrame[1] -= (float)2.04324239e-3; - inFrame[2] += (float)1.90854954e-3; - inFrame[9] += (float)1.84854878e-3; - - /* This function will update the bottleneck if required. */ - UpdateBottleneck(instISAC); - - /* Get the bandwith information which has to be sent to the other side. */ - GetSendBandwidthInfo(instISAC, &bottleneckIdx, &jitterInfo); - - /* Encode lower-band. */ - streamLenLB = WebRtcIsac_EncodeLb(inFrame, &instLB->ISACencLB_obj, - instISAC->codingMode, bottleneckIdx); - if (streamLenLB < 0) { - return -1; - } - - if (instISAC->encoderSamplingRateKHz == kIsacSuperWideband) { - instUB = &(instISAC->instUB); - - /* Convert to float. */ - for (k = 0; k < FRAMESAMPLES_10ms; k++) { - inFrame[k] = (float) speechInUB[k]; - } - - /* Add some noise to avoid denormal numbers. */ - inFrame[0] += (float)1.23455334e-3; - inFrame[1] -= (float)2.04324239e-3; - inFrame[2] += (float)1.90854954e-3; - inFrame[9] += (float)1.84854878e-3; - - /* Tell to upper-band the number of bytes used so far. - * This is for payload limitation. */ - instUB->ISACencUB_obj.numBytesUsed = streamLenLB + 1 + - LEN_CHECK_SUM_WORD8; - /* Encode upper-band. */ - switch (instISAC->bandwidthKHz) { - case isac12kHz: { - streamLenUB = WebRtcIsac_EncodeUb12(inFrame, &instUB->ISACencUB_obj, - jitterInfo); - break; - } - case isac16kHz: { - streamLenUB = WebRtcIsac_EncodeUb16(inFrame, &instUB->ISACencUB_obj, - jitterInfo); - break; - } - case isac8kHz: { - streamLenUB = 0; - break; - } - } - - if ((streamLenUB < 0) && (streamLenUB != -ISAC_PAYLOAD_LARGER_THAN_LIMIT)) { - /* An error has happened but this is not the error due to a - * bit-stream larger than the limit. */ - return -1; - } - - if (streamLenLB == 0) { - return 0; - } - - /* One byte is allocated for the length. According to older decoders - so the length bit-stream plus one byte for size and - LEN_CHECK_SUM_WORD8 for the checksum should be less than or equal - to 255. */ - if ((streamLenUB > (255 - (LEN_CHECK_SUM_WORD8 + 1))) || - (streamLenUB == -ISAC_PAYLOAD_LARGER_THAN_LIMIT)) { - /* We have got a too long bit-stream we skip the upper-band - * bit-stream for this frame. */ - streamLenUB = 0; - } - - memcpy(ptrEncodedUW8, instLB->ISACencLB_obj.bitstr_obj.stream, streamLenLB); - streamLen = streamLenLB; - if (streamLenUB > 0) { - ptrEncodedUW8[streamLenLB] = (WebRtc_UWord8)(streamLenUB + 1 + - LEN_CHECK_SUM_WORD8); - memcpy(&ptrEncodedUW8[streamLenLB + 1], - instUB->ISACencUB_obj.bitstr_obj.stream, streamLenUB); - streamLen += ptrEncodedUW8[streamLenLB]; - } else { - ptrEncodedUW8[streamLenLB] = 0; - } - } else { - if (streamLenLB == 0) { - return 0; - } - memcpy(ptrEncodedUW8, instLB->ISACencLB_obj.bitstr_obj.stream, - streamLenLB); - streamLenUB = 0; - streamLen = streamLenLB; - } - - /* Add Garbage if required. */ - WebRtcIsac_GetUplinkBandwidth(&instISAC->bwestimator_obj, &bottleneck); - if (instISAC->codingMode == 0) { - int minBytes; - int limit; - WebRtc_UWord8* ptrGarbage; - - instISAC->MaxDelay = (double)WebRtcIsac_GetUplinkMaxDelay( - &instISAC->bwestimator_obj); - - /* Update rate model and get minimum number of bytes in this packet. */ - minBytes = WebRtcIsac_GetMinBytes( - &(instISAC->rate_data_obj), streamLen, - instISAC->instLB.ISACencLB_obj.current_framesamples, bottleneck, - instISAC->MaxDelay, instISAC->bandwidthKHz); - - /* Make sure MinBytes does not exceed packet size limit. */ - if (instISAC->bandwidthKHz == isac8kHz) { - if (instLB->ISACencLB_obj.current_framesamples == FRAMESAMPLES) { - limit = instLB->ISACencLB_obj.payloadLimitBytes30; - } else { - limit = instLB->ISACencLB_obj.payloadLimitBytes60; - } - } else { - limit = instUB->ISACencUB_obj.maxPayloadSizeBytes; - } - minBytes = (minBytes > limit) ? limit : minBytes; - - /* Make sure we don't allow more than 255 bytes of garbage data. - * We store the length of the garbage data in 8 bits in the bitstream, - * 255 is the max garbage length we can signal using 8 bits. */ - if ((instISAC->bandwidthKHz == isac8kHz) || - (streamLenUB == 0)) { - ptrGarbage = &ptrEncodedUW8[streamLenLB]; - limit = streamLen + 255; - } else { - ptrGarbage = &ptrEncodedUW8[streamLenLB + 1 + streamLenUB]; - limit = streamLen + (255 - ptrEncodedUW8[streamLenLB]); - } - minBytes = (minBytes > limit) ? limit : minBytes; - - garbageLen = (minBytes > streamLen) ? (minBytes - streamLen) : 0; - - /* Save data for creation of multiple bit-streams. */ - /* If bit-stream too short then add garbage at the end. */ - if (garbageLen > 0) { - for (k = 0; k < garbageLen; k++) { - ptrGarbage[k] = (WebRtc_UWord8)(rand() & 0xFF); - } - /* For a correct length of the upper-band bit-stream together - * with the garbage. Garbage is embeded in upper-band bit-stream. - * That is the only way to preserve backward compatibility. */ - if ((instISAC->bandwidthKHz == isac8kHz) || - (streamLenUB == 0)) { - ptrEncodedUW8[streamLenLB] = (WebRtc_UWord8)garbageLen; - } else { - ptrEncodedUW8[streamLenLB] += (WebRtc_UWord8)garbageLen; - /* Write the length of the garbage at the end of the upper-band - * bit-stream, if exists. This helps for sanity check. */ - ptrEncodedUW8[streamLenLB + 1 + streamLenUB] = - (WebRtc_UWord8)garbageLen; - - } - streamLen += garbageLen; - } - } else { - /* update rate model */ - WebRtcIsac_UpdateRateModel( - &instISAC->rate_data_obj, streamLen, - instISAC->instLB.ISACencLB_obj.current_framesamples, bottleneck); - garbageLen = 0; - } - - /* Generate CRC if required. */ - if ((instISAC->bandwidthKHz != isac8kHz) && (streamLenUB > 0)) { - WebRtc_UWord32 crc; - - WebRtcIsac_GetCrc((WebRtc_Word16*)(&(ptrEncodedUW8[streamLenLB + 1])), - streamLenUB + garbageLen, &crc); -#ifndef WEBRTC_BIG_ENDIAN - for (k = 0; k < LEN_CHECK_SUM_WORD8; k++) { - ptrEncodedUW8[streamLen - LEN_CHECK_SUM_WORD8 + k] = - (WebRtc_UWord8)((crc >> (24 - k * 8)) & 0xFF); - } -#else - memcpy(&ptrEncodedUW8[streamLenLB + streamLenUB + 1], &crc, - LEN_CHECK_SUM_WORD8); -#endif - } - return streamLen; -} - - -/****************************************************************************** - * WebRtcIsac_GetNewBitStream(...) - * - * This function returns encoded data, with the recieved bwe-index in the - * stream. If the rate is set to a value less than bottleneck of codec - * the new bistream will be re-encoded with the given target rate. - * It should always return a complete packet, i.e. only called once - * even for 60 msec frames. - * - * NOTE 1! This function does not write in the ISACStruct, it is not allowed. - * NOTE 3! Rates larger than the bottleneck of the codec will be limited - * to the current bottleneck. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - bweIndex : Index of bandwidth estimate to put in new - * bitstream - * - rate : target rate of the transcoder is bits/sec. - * Valid values are the accepted rate in iSAC, - * i.e. 10000 to 56000. - * - * Output: - * - encoded : The encoded data vector - * - * Return value : >0 - Length (in bytes) of coded data - * -1 - Error or called in SWB mode - * NOTE! No error code is written to - * the struct since it is only allowed to read - * the struct. - */ -WebRtc_Word16 WebRtcIsac_GetNewBitStream(ISACStruct* ISAC_main_inst, - WebRtc_Word16 bweIndex, - WebRtc_Word16 jitterInfo, - WebRtc_Word32 rate, - WebRtc_Word16* encoded, - WebRtc_Word16 isRCU) { - Bitstr iSACBitStreamInst; /* Local struct for bitstream handling */ - WebRtc_Word16 streamLenLB; - WebRtc_Word16 streamLenUB; - WebRtc_Word16 totalStreamLen; - double gain2; - double gain1; - float scale; - enum ISACBandwidth bandwidthKHz; - double rateLB; - double rateUB; - WebRtc_Word32 currentBN; - WebRtc_UWord8* encodedPtrUW8 = (WebRtc_UWord8*)encoded; - WebRtc_UWord32 crc; -#ifndef WEBRTC_BIG_ENDIAN - WebRtc_Word16 k; -#endif - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - return -1; - } - - /* Get the bottleneck of this iSAC and limit the - * given rate to the current bottleneck. */ - WebRtcIsac_GetUplinkBw(ISAC_main_inst, ¤tBN); - if (rate > currentBN) { - rate = currentBN; - } - - if (WebRtcIsac_RateAllocation(rate, &rateLB, &rateUB, &bandwidthKHz) < 0) { - return -1; - } - - /* Cannot transcode from 16 kHz to 12 kHz. */ - if ((bandwidthKHz == isac12kHz) && - (instISAC->bandwidthKHz == isac16kHz)) { - return -1; - } - - /* A gain [dB] for the given rate. */ - gain1 = WebRtcIsac_GetSnr( - rateLB, instISAC->instLB.ISACencLB_obj.current_framesamples); - /* The gain [dB] of this iSAC. */ - gain2 = WebRtcIsac_GetSnr( - instISAC->instLB.ISACencLB_obj.bottleneck, - instISAC->instLB.ISACencLB_obj.current_framesamples); - - /* Scale is the ratio of two gains in normal domain. */ - scale = (float)pow(10, (gain1 - gain2) / 20.0); - /* Change the scale if this is a RCU bit-stream. */ - scale = (isRCU) ? (scale * RCU_TRANSCODING_SCALE) : scale; - - streamLenLB = WebRtcIsac_EncodeStoredDataLb( - &instISAC->instLB.ISACencLB_obj.SaveEnc_obj, - &iSACBitStreamInst, bweIndex, scale); - - if (streamLenLB < 0) { - return -1; - } - - /* Convert from bytes to WebRtc_Word16. */ - memcpy(encoded, iSACBitStreamInst.stream, streamLenLB); - - if (bandwidthKHz == isac8kHz) { - return streamLenLB; - } - - totalStreamLen = streamLenLB; - /* super-wideband is always at 30ms. - * These gains are in dB. - * Gain for the given rate. */ - gain1 = WebRtcIsac_GetSnr(rateUB, FRAMESAMPLES); - /* Gain of this iSAC */ - gain2 = WebRtcIsac_GetSnr(instISAC->instUB.ISACencUB_obj.bottleneck, - FRAMESAMPLES); - - /* Scale is the ratio of two gains in normal domain. */ - scale = (float)pow(10, (gain1 - gain2) / 20.0); - - /* Change the scale if this is a RCU bit-stream. */ - scale = (isRCU)? (scale * RCU_TRANSCODING_SCALE_UB) : scale; - - streamLenUB = WebRtcIsac_EncodeStoredDataUb( - &(instISAC->instUB.ISACencUB_obj.SaveEnc_obj), - &iSACBitStreamInst, jitterInfo, scale, - instISAC->bandwidthKHz); - - if (streamLenUB < 0) { - return -1; - } - - if (streamLenUB + 1 + LEN_CHECK_SUM_WORD8 > 255) { - return streamLenLB; - } - - totalStreamLen = streamLenLB + streamLenUB + 1 + LEN_CHECK_SUM_WORD8; - encodedPtrUW8[streamLenLB] = streamLenUB + 1 + LEN_CHECK_SUM_WORD8; - - memcpy(&encodedPtrUW8[streamLenLB + 1], iSACBitStreamInst.stream, - streamLenUB); - - WebRtcIsac_GetCrc((WebRtc_Word16*)(&(encodedPtrUW8[streamLenLB + 1])), - streamLenUB, &crc); -#ifndef WEBRTC_BIG_ENDIAN - for (k = 0; k < LEN_CHECK_SUM_WORD8; k++) { - encodedPtrUW8[totalStreamLen - LEN_CHECK_SUM_WORD8 + k] = - (WebRtc_UWord8)((crc >> (24 - k * 8)) & 0xFF); - } -#else - memcpy(&encodedPtrUW8[streamLenLB + streamLenUB + 1], &crc, - LEN_CHECK_SUM_WORD8); -#endif - return totalStreamLen; -} - - -/**************************************************************************** - * DecoderInitLb(...) - internal function for initialization of - * Lower Band - * DecoderInitUb(...) - internal function for initialization of - * Upper Band - * WebRtcIsac_DecoderInit(...) - API function - * - * This function initializes a ISAC instance prior to the decoder calls. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - * Return value - * : 0 - Ok - * -1 - Error - */ -static WebRtc_Word16 DecoderInitLb(ISACLBStruct* instISAC) { - int i; - /* Initialize stream vector to zero. */ - for (i = 0; i < STREAM_SIZE_MAX_60; i++) { - instISAC->ISACdecLB_obj.bitstr_obj.stream[i] = 0; - } - - WebRtcIsac_InitMasking(&instISAC->ISACdecLB_obj.maskfiltstr_obj); - WebRtcIsac_InitPostFilterbank( - &instISAC->ISACdecLB_obj.postfiltbankstr_obj); - WebRtcIsac_InitPitchFilter(&instISAC->ISACdecLB_obj.pitchfiltstr_obj); - return 0; -} - -static WebRtc_Word16 DecoderInitUb(ISACUBStruct* instISAC) { - int i; - /* Init stream vector to zero */ - for (i = 0; i < STREAM_SIZE_MAX_60; i++) { - instISAC->ISACdecUB_obj.bitstr_obj.stream[i] = 0; - } - - WebRtcIsac_InitMasking(&instISAC->ISACdecUB_obj.maskfiltstr_obj); - WebRtcIsac_InitPostFilterbank( - &instISAC->ISACdecUB_obj.postfiltbankstr_obj); - return (0); -} - -WebRtc_Word16 WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - if (DecoderInitLb(&instISAC->instLB) < 0) { - return -1; - } - if (instISAC->decoderSamplingRateKHz == kIsacSuperWideband) { - memset(instISAC->synthesisFBState1, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - memset(instISAC->synthesisFBState2, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - - if (DecoderInitUb(&(instISAC->instUB)) < 0) { - return -1; - } - } - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != BIT_MASK_ENC_INIT) { - WebRtcIsac_InitBandwidthEstimator(&instISAC->bwestimator_obj, - instISAC->encoderSamplingRateKHz, - instISAC->decoderSamplingRateKHz); - } - instISAC->initFlag |= BIT_MASK_DEC_INIT; - instISAC->resetFlag_8kHz = 0; - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_UpdateBwEstimate(...) - * - * This function updates the estimate of the bandwidth. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s). - * - packet_size : size of the packet. - * - rtp_seq_number : the RTP number of the packet. - * - arr_ts : the arrival time of the packet (from NetEq) - * in samples. - * - * Return value : 0 - Ok - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word32 packet_size, - WebRtc_UWord16 rtp_seq_number, - WebRtc_UWord32 send_ts, - WebRtc_UWord32 arr_ts) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - Bitstr streamdata; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - - /* Check if decoder initiated. */ - if ((instISAC->initFlag & BIT_MASK_DEC_INIT) != BIT_MASK_DEC_INIT) { - instISAC->errorCode = ISAC_DECODER_NOT_INITIATED; - return -1; - } - - if (packet_size <= 0) { - /* Return error code if the packet length is null. */ - instISAC->errorCode = ISAC_EMPTY_PACKET; - return -1; - } - - WebRtcIsac_ResetBitstream(&(streamdata)); - -#ifndef WEBRTC_BIG_ENDIAN - for (k = 0; k < 10; k++) { - streamdata.stream[k] = (WebRtc_UWord8)((encoded[k >> 1] >> - ((k & 1) << 3)) & 0xFF); - } -#else - memcpy(streamdata.stream, encoded, 10); -#endif - - err = WebRtcIsac_EstimateBandwidth(&instISAC->bwestimator_obj, &streamdata, - packet_size, rtp_seq_number, send_ts, - arr_ts, instISAC->encoderSamplingRateKHz, - instISAC->decoderSamplingRateKHz); - if (err < 0) { - /* Return error code if something went wrong. */ - instISAC->errorCode = -err; - return -1; - } - return 0; -} - -static WebRtc_Word16 Decode(ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word16 lenEncodedBytes, - WebRtc_Word16* decoded, - WebRtc_Word16* speechType, - WebRtc_Word16 isRCUPayload) { - /* Number of samples (480 or 960), output from decoder - that were actually used in the encoder/decoder - (determined on the fly). */ - WebRtc_Word16 numSamplesLB; - WebRtc_Word16 numSamplesUB; - WebRtc_Word16 speechIdx; - float outFrame[MAX_FRAMESAMPLES]; - WebRtc_Word16 outFrameLB[MAX_FRAMESAMPLES]; - WebRtc_Word16 outFrameUB[MAX_FRAMESAMPLES]; - WebRtc_Word16 numDecodedBytesLB; - WebRtc_Word16 numDecodedBytesUB; - WebRtc_Word16 lenEncodedLBBytes; - WebRtc_Word16 validChecksum = 1; - WebRtc_Word16 k; - WebRtc_UWord8* ptrEncodedUW8 = (WebRtc_UWord8*)encoded; - WebRtc_UWord16 numLayer; - WebRtc_Word16 totSizeBytes; - WebRtc_Word16 err; - - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - ISACUBDecStruct* decInstUB = &(instISAC->instUB.ISACdecUB_obj); - ISACLBDecStruct* decInstLB = &(instISAC->instLB.ISACdecLB_obj); - - /* Check if decoder initiated. */ - if ((instISAC->initFlag & BIT_MASK_DEC_INIT) != - BIT_MASK_DEC_INIT) { - instISAC->errorCode = ISAC_DECODER_NOT_INITIATED; - return -1; - } - - if (lenEncodedBytes <= 0) { - /* return error code if the packet length is null. */ - instISAC->errorCode = ISAC_EMPTY_PACKET; - return -1; - } - - /* The size of the encoded lower-band is bounded by - * STREAM_SIZE_MAX. If a payload with the size larger than STREAM_SIZE_MAX - * is received, it is not considered erroneous. */ - lenEncodedLBBytes = (lenEncodedBytes > STREAM_SIZE_MAX) ? - STREAM_SIZE_MAX : lenEncodedBytes; - - /* Copy to lower-band bit-stream structure. */ - memcpy(instISAC->instLB.ISACdecLB_obj.bitstr_obj.stream, ptrEncodedUW8, - lenEncodedLBBytes); - - /* Regardless of that the current codec is setup to work in - * wideband or super-wideband, the decoding of the lower-band - * has to be performed. */ - numDecodedBytesLB = WebRtcIsac_DecodeLb(outFrame, decInstLB, - &numSamplesLB, isRCUPayload); - - if ((numDecodedBytesLB < 0) || (numDecodedBytesLB > lenEncodedLBBytes) || - (numSamplesLB > MAX_FRAMESAMPLES)) { - instISAC->errorCode = ISAC_LENGTH_MISMATCH; - return -1; - } - - /* Error Check, we accept multi-layer bit-stream This will limit number - * of iterations of the while loop. Even without this the number - * of iterations is limited. */ - numLayer = 1; - totSizeBytes = numDecodedBytesLB; - while (totSizeBytes != lenEncodedBytes) { - if ((totSizeBytes > lenEncodedBytes) || - (ptrEncodedUW8[totSizeBytes] == 0) || - (numLayer > MAX_NUM_LAYERS)) { - instISAC->errorCode = ISAC_LENGTH_MISMATCH; - return -1; - } - totSizeBytes += ptrEncodedUW8[totSizeBytes]; - numLayer++; - } - - if (instISAC->decoderSamplingRateKHz == kIsacWideband) { - for (k = 0; k < numSamplesLB; k++) { - if (outFrame[k] > 32767) { - decoded[k] = 32767; - } else if (outFrame[k] < -32768) { - decoded[k] = -32768; - } else { - decoded[k] = (WebRtc_Word16)WebRtcIsac_lrint(outFrame[k]); - } - } - numSamplesUB = 0; - } else { - WebRtc_UWord32 crc; - /* We don't accept larger than 30ms (480 samples at lower-band) - * frame-size. */ - for (k = 0; k < numSamplesLB; k++) { - if (outFrame[k] > 32767) { - outFrameLB[k] = 32767; - } else if (outFrame[k] < -32768) { - outFrameLB[k] = -32768; - } else { - outFrameLB[k] = (WebRtc_Word16)WebRtcIsac_lrint(outFrame[k]); - } - } - - /* Check for possible error, and if upper-band stream exists. */ - if (numDecodedBytesLB == lenEncodedBytes) { - /* Decoding was successful. No super-wideband bit-stream exists. */ - numSamplesUB = numSamplesLB; - memset(outFrameUB, 0, sizeof(WebRtc_Word16) * numSamplesUB); - - /* Prepare for the potential increase of signal bandwidth. */ - instISAC->resetFlag_8kHz = 2; - } else { - /* This includes the checksum and the bytes that stores the length. */ - WebRtc_Word16 lenNextStream = ptrEncodedUW8[numDecodedBytesLB]; - - /* Is this garbage or valid super-wideband bit-stream? - * Check if checksum is valid. */ - if (lenNextStream <= (LEN_CHECK_SUM_WORD8 + 1)) { - /* Such a small second layer cannot be super-wideband layer. - * It must be a short garbage. */ - validChecksum = 0; - } else { - /* Run CRC to see if the checksum match. */ - WebRtcIsac_GetCrc((WebRtc_Word16*)( - &ptrEncodedUW8[numDecodedBytesLB + 1]), - lenNextStream - LEN_CHECK_SUM_WORD8 - 1, &crc); - - validChecksum = 1; - for (k = 0; k < LEN_CHECK_SUM_WORD8; k++) { - validChecksum &= (((crc >> (24 - k * 8)) & 0xFF) == - ptrEncodedUW8[numDecodedBytesLB + lenNextStream - - LEN_CHECK_SUM_WORD8 + k]); - } - } - - if (!validChecksum) { - /* This is a garbage, we have received a wideband - * bit-stream with garbage. */ - numSamplesUB = numSamplesLB; - memset(outFrameUB, 0, sizeof(WebRtc_Word16) * numSamplesUB); - } else { - /* A valid super-wideband biststream exists. */ - enum ISACBandwidth bandwidthKHz; - WebRtc_Word32 maxDelayBit; - - /* If we have super-wideband bit-stream, we cannot - * have 60 ms frame-size. */ - if (numSamplesLB > FRAMESAMPLES) { - instISAC->errorCode = ISAC_LENGTH_MISMATCH; - return -1; - } - - /* The rest of the bit-stream contains the upper-band - * bit-stream curently this is the only thing there, - * however, we might add more layers. */ - - /* Have to exclude one byte where the length is stored - * and last 'LEN_CHECK_SUM_WORD8' bytes where the - * checksum is stored. */ - lenNextStream -= (LEN_CHECK_SUM_WORD8 + 1); - - memcpy(decInstUB->bitstr_obj.stream, - &ptrEncodedUW8[numDecodedBytesLB + 1], lenNextStream); - - /* Reset bit-stream object, this is the first decoding. */ - WebRtcIsac_ResetBitstream(&(decInstUB->bitstr_obj)); - - /* Decode jitter information. */ - err = WebRtcIsac_DecodeJitterInfo(&decInstUB->bitstr_obj, &maxDelayBit); - if (err < 0) { - instISAC->errorCode = -err; - return -1; - } - - /* Update jitter info which is in the upper-band bit-stream - * only if the encoder is in super-wideband. Otherwise, - * the jitter info is already embedded in bandwidth index - * and has been updated. */ - if (instISAC->encoderSamplingRateKHz == kIsacSuperWideband) { - err = WebRtcIsac_UpdateUplinkJitter( - &(instISAC->bwestimator_obj), maxDelayBit); - if (err < 0) { - instISAC->errorCode = -err; - return -1; - } - } - - /* Decode bandwidth information. */ - err = WebRtcIsac_DecodeBandwidth(&decInstUB->bitstr_obj, - &bandwidthKHz); - if (err < 0) { - instISAC->errorCode = -err; - return -1; - } - - switch (bandwidthKHz) { - case isac12kHz: { - numDecodedBytesUB = WebRtcIsac_DecodeUb12(outFrame, decInstUB, - isRCUPayload); - - /* Hang-over for transient alleviation - - * wait two frames to add the upper band going up from 8 kHz. */ - if (instISAC->resetFlag_8kHz > 0) { - if (instISAC->resetFlag_8kHz == 2) { - /* Silence first and a half frame. */ - memset(outFrame, 0, MAX_FRAMESAMPLES * - sizeof(float)); - } else { - const float rampStep = 2.0f / MAX_FRAMESAMPLES; - float rampVal = 0; - memset(outFrame, 0, (MAX_FRAMESAMPLES >> 1) * - sizeof(float)); - - /* Ramp up second half of second frame. */ - for (k = MAX_FRAMESAMPLES / 2; k < MAX_FRAMESAMPLES; k++) { - outFrame[k] *= rampVal; - rampVal += rampStep; - } - } - instISAC->resetFlag_8kHz -= 1; - } - - break; - } - case isac16kHz: { - numDecodedBytesUB = WebRtcIsac_DecodeUb16(outFrame, decInstUB, - isRCUPayload); - break; - } - default: - return -1; - } - - /* It might be less due to garbage. */ - if ((numDecodedBytesUB != lenNextStream) && - (numDecodedBytesUB != (lenNextStream - - ptrEncodedUW8[numDecodedBytesLB + 1 + numDecodedBytesUB]))) { - instISAC->errorCode = ISAC_LENGTH_MISMATCH; - return -1; - } - - /* If there is no error Upper-band always decodes - * 30 ms (480 samples). */ - numSamplesUB = FRAMESAMPLES; - - /* Convert to W16. */ - for (k = 0; k < numSamplesUB; k++) { - if (outFrame[k] > 32767) { - outFrameUB[k] = 32767; - } else if (outFrame[k] < -32768) { - outFrameUB[k] = -32768; - } else { - outFrameUB[k] = (WebRtc_Word16)WebRtcIsac_lrint( - outFrame[k]); - } - } - } - } - - speechIdx = 0; - while (speechIdx < numSamplesLB) { - WebRtcSpl_SynthesisQMF(&outFrameLB[speechIdx], &outFrameUB[speechIdx], - &decoded[(speechIdx << 1)], - instISAC->synthesisFBState1, - instISAC->synthesisFBState2); - - speechIdx += FRAMESAMPLES_10ms; - } - } - *speechType = 0; - return (numSamplesLB + numSamplesUB); -} - - - - - - - -/**************************************************************************** - * WebRtcIsac_Decode(...) - * - * This function decodes a ISAC frame. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the frameSize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - -WebRtc_Word16 WebRtcIsac_Decode(ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word16 lenEncodedBytes, - WebRtc_Word16* decoded, - WebRtc_Word16* speechType) { - WebRtc_Word16 isRCUPayload = 0; - return Decode(ISAC_main_inst, encoded, lenEncodedBytes, decoded, - speechType, isRCUPayload); -} - -/**************************************************************************** - * WebRtcIsac_DecodeRcu(...) - * - * This function decodes a redundant (RCU) iSAC frame. Function is called in - * NetEq with a stored RCU payload in case of packet loss. Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the framesize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - encoded : encoded ISAC RCU frame(s) - * - len : bytes in encoded vector - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded vector - * -1 - Error - */ - - - -WebRtc_Word16 WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst, - const WebRtc_UWord16* encoded, - WebRtc_Word16 lenEncodedBytes, - WebRtc_Word16* decoded, - WebRtc_Word16* speechType) { - WebRtc_Word16 isRCUPayload = 1; - return Decode(ISAC_main_inst, encoded, lenEncodedBytes, decoded, - speechType, isRCUPayload); -} - - -/**************************************************************************** - * WebRtcIsac_DecodePlc(...) - * - * This function conducts PLC for ISAC frame(s). Output speech length - * will be a multiple of 480 samples: 480 or 960 samples, - * depending on the frameSize (30 or 60 ms). - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - noOfLostFrames : Number of PLC frames to produce - * - * Output: - * - decoded : The decoded vector - * - * Return value : >0 - number of samples in decoded PLC vector - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_DecodePlc(ISACStruct* ISAC_main_inst, - WebRtc_Word16* decoded, - WebRtc_Word16 noOfLostFrames) { - WebRtc_Word16 numSamples = 0; - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - /* Limit number of frames to two = 60 millisecond. - * Otherwise we exceed data vectors. */ - if (noOfLostFrames > 2) { - noOfLostFrames = 2; - } - - /* Get the number of samples per frame */ - switch (instISAC->decoderSamplingRateKHz) { - case kIsacWideband: { - numSamples = 480 * noOfLostFrames; - break; - } - case kIsacSuperWideband: { - numSamples = 960 * noOfLostFrames; - break; - } - } - - /* Set output samples to zero. */ - memset(decoded, 0, numSamples * sizeof(WebRtc_Word16)); - return numSamples; -} - - -/**************************************************************************** - * ControlLb(...) - Internal function for controlling Lower Band - * ControlUb(...) - Internal function for controlling Upper Band - * WebRtcIsac_Control(...) - API function - * - * This function sets the limit on the short-term average bit rate and the - * frame length. Should be used only in Instantaneous mode. - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rate : limit on the short-term average bit rate, - * in bits/second (between 10000 and 32000) - * - frameSize : number of milliseconds per frame (30 or 60) - * - * Return value : 0 - ok - * -1 - Error - */ -static WebRtc_Word16 ControlLb(ISACLBStruct* instISAC, double rate, - WebRtc_Word16 frameSize) { - if ((rate >= 10000) && (rate <= 32000)) { - instISAC->ISACencLB_obj.bottleneck = rate; - } else { - return -ISAC_DISALLOWED_BOTTLENECK; - } - - if ((frameSize == 30) || (frameSize == 60)) { - instISAC->ISACencLB_obj.new_framelength = (FS / 1000) * frameSize; - } else { - return -ISAC_DISALLOWED_FRAME_LENGTH; - } - - return 0; -} - -static WebRtc_Word16 ControlUb(ISACUBStruct* instISAC, double rate) { - if ((rate >= 10000) && (rate <= 32000)) { - instISAC->ISACencUB_obj.bottleneck = rate; - } else { - return -ISAC_DISALLOWED_BOTTLENECK; - } - return 0; -} - -WebRtc_Word16 WebRtcIsac_Control(ISACStruct* ISAC_main_inst, - WebRtc_Word32 bottleneckBPS, - WebRtc_Word16 frameSize) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - WebRtc_Word16 status; - double rateLB; - double rateUB; - enum ISACBandwidth bandwidthKHz; - - if (instISAC->codingMode == 0) { - /* In adaptive mode. */ - instISAC->errorCode = ISAC_MODE_MISMATCH; - return -1; - } - - /* Check if encoder initiated */ - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - - if (instISAC->encoderSamplingRateKHz == kIsacWideband) { - /* If the sampling rate is 16kHz then bandwith should be 8kHz, - * regardless of bottleneck. */ - bandwidthKHz = isac8kHz; - rateLB = (bottleneckBPS > 32000) ? 32000 : bottleneckBPS; - rateUB = 0; - } else { - if (WebRtcIsac_RateAllocation(bottleneckBPS, &rateLB, &rateUB, - &bandwidthKHz) < 0) { - return -1; - } - } - - if ((instISAC->encoderSamplingRateKHz == kIsacSuperWideband) && - (frameSize != 30) && - (bandwidthKHz != isac8kHz)) { - /* Cannot have 60 ms in super-wideband. */ - instISAC->errorCode = ISAC_DISALLOWED_FRAME_LENGTH; - return -1; - } - - status = ControlLb(&instISAC->instLB, rateLB, frameSize); - if (status < 0) { - instISAC->errorCode = -status; - return -1; - } - if (bandwidthKHz != isac8kHz) { - status = ControlUb(&(instISAC->instUB), rateUB); - if (status < 0) { - instISAC->errorCode = -status; - return -1; - } - } - - - /* Check if bandwidth is changing from wideband to super-wideband - * then we have to synch data buffer of lower & upper-band. Also - * clean up the upper-band data buffer. */ - - if ((instISAC->bandwidthKHz == isac8kHz) && (bandwidthKHz != isac8kHz)) { - memset(instISAC->instUB.ISACencUB_obj.data_buffer_float, 0, - sizeof(float) * (MAX_FRAMESAMPLES + LB_TOTAL_DELAY_SAMPLES)); - - if (bandwidthKHz == isac12kHz) { - instISAC->instUB.ISACencUB_obj.buffer_index = - instISAC->instLB.ISACencLB_obj.buffer_index; - } else { - instISAC->instUB.ISACencUB_obj.buffer_index = - LB_TOTAL_DELAY_SAMPLES + instISAC->instLB.ISACencLB_obj.buffer_index; - - memcpy(&(instISAC->instUB.ISACencUB_obj.lastLPCVec), - WebRtcIsac_kMeanLarUb16, sizeof(double) * UB_LPC_ORDER); - } - } - - /* Update the payload limit if the bandwidth is changing. */ - if (instISAC->bandwidthKHz != bandwidthKHz) { - instISAC->bandwidthKHz = bandwidthKHz; - UpdatePayloadSizeLimit(instISAC); - } - instISAC->bottleneck = bottleneckBPS; - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_ControlBwe(...) - * - * This function sets the initial values of bottleneck and frame-size if - * iSAC is used in channel-adaptive mode. Through this API, users can - * enforce a frame-size for all values of bottleneck. Then iSAC will not - * automatically change the frame-size. - * - * - * Input: - * - ISAC_main_inst : ISAC instance. - * - rateBPS : initial value of bottleneck in bits/second - * 10000 <= rateBPS <= 32000 is accepted - * For default bottleneck set rateBPS = 0 - * - frameSizeMs : number of milliseconds per frame (30 or 60) - * - enforceFrameSize : 1 to enforce the given frame-size through out - * the adaptation process, 0 to let iSAC change - * the frame-size if required. - * - * Return value : 0 - ok - * -1 - Error - */ -WebRtc_Word16 WebRtcIsac_ControlBwe(ISACStruct* ISAC_main_inst, - WebRtc_Word32 bottleneckBPS, - WebRtc_Word16 frameSizeMs, - WebRtc_Word16 enforceFrameSize) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - enum ISACBandwidth bandwidth; - - /* Check if encoder initiated */ - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - - /* Check that we are in channel-adaptive mode, otherwise, return (-1) */ - if (instISAC->codingMode != 0) { - instISAC->errorCode = ISAC_MODE_MISMATCH; - return -1; - } - if ((frameSizeMs != 30) && - (instISAC->encoderSamplingRateKHz == kIsacSuperWideband)) { - return -1; - } - - /* Set structure variable if enforceFrameSize is set. ISAC will then - * keep the chosen frame size. */ - if (enforceFrameSize != 0) { - instISAC->instLB.ISACencLB_obj.enforceFrameSize = 1; - } else { - instISAC->instLB.ISACencLB_obj.enforceFrameSize = 0; - } - - /* Set the initial rate. If the input value is zero then the default intial - * rate is used. Otehrwise, values between 10 to 32 kbps are accepted. */ - if (bottleneckBPS != 0) { - double rateLB; - double rateUB; - if (WebRtcIsac_RateAllocation(bottleneckBPS, &rateLB, &rateUB, - &bandwidth) < 0) { - return -1; - } - instISAC->bwestimator_obj.send_bw_avg = (float)bottleneckBPS; - instISAC->bandwidthKHz = bandwidth; - } - - /* Set the initial frame-size. If 'enforceFrameSize' is set, the frame-size - * will not change */ - if (frameSizeMs != 0) { - if ((frameSizeMs == 30) || (frameSizeMs == 60)) { - instISAC->instLB.ISACencLB_obj.new_framelength = (FS / 1000) * - frameSizeMs; - } else { - instISAC->errorCode = ISAC_DISALLOWED_FRAME_LENGTH; - return -1; - } - } - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_GetDownLinkBwIndex(...) - * - * This function returns index representing the Bandwidth estimate from - * the other side to this side. - * - * Input: - * - ISAC_main_inst : iSAC structure - * - * Output: - * - bweIndex : Bandwidth estimate to transmit to other side. - * - */ -WebRtc_Word16 WebRtcIsac_GetDownLinkBwIndex(ISACStruct* ISAC_main_inst, - WebRtc_Word16* bweIndex, - WebRtc_Word16* jitterInfo) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - /* Check if encoder initialized. */ - if ((instISAC->initFlag & BIT_MASK_DEC_INIT) != - BIT_MASK_DEC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - - /* Call function to get Bandwidth Estimate. */ - WebRtcIsac_GetDownlinkBwJitIndexImpl(&(instISAC->bwestimator_obj), bweIndex, - jitterInfo, - instISAC->decoderSamplingRateKHz); - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_UpdateUplinkBw(...) - * - * This function takes an index representing the Bandwidth estimate from - * this side to other side and updates BWE. - * - * Input: - * - ISAC_main_inst : iSAC structure - * - rateIndex : Bandwidth estimate from other side. - * - * Return value : 0 - ok - * -1 - index out of range - */ -WebRtc_Word16 WebRtcIsac_UpdateUplinkBw(ISACStruct* ISAC_main_inst, - WebRtc_Word16 bweIndex) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - WebRtc_Word16 returnVal; - - /* Check if encoder initiated. */ - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - - /* Call function to get Bandwidth Estimate. */ - returnVal = WebRtcIsac_UpdateUplinkBwImpl( - &(instISAC->bwestimator_obj), bweIndex, - instISAC->encoderSamplingRateKHz); - - if (returnVal < 0) { - instISAC->errorCode = -returnVal; - return -1; - } else { - return 0; - } -} - - -/**************************************************************************** - * WebRtcIsac_ReadBwIndex(...) - * - * This function returns the index of the Bandwidth estimate from the - * bit-stream. - * - * Input: - * - encoded : Encoded bit-stream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - bweIndex : Bandwidth estimate in bit-stream - * - */ -WebRtc_Word16 WebRtcIsac_ReadBwIndex(const WebRtc_Word16* encoded, - WebRtc_Word16* bweIndex) { - Bitstr streamdata; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - - WebRtcIsac_ResetBitstream(&(streamdata)); - -#ifndef WEBRTC_BIG_ENDIAN - for (k = 0; k < 10; k++) { - streamdata.stream[k] = (WebRtc_UWord8)((encoded[k >> 1] >> - ((k & 1) << 3)) & 0xFF); - } -#else - memcpy(streamdata.stream, encoded, 10); -#endif - - /* Decode frame length. */ - err = WebRtcIsac_DecodeFrameLen(&streamdata, bweIndex); - if (err < 0) { - return err; - } - - /* Decode BW estimation. */ - err = WebRtcIsac_DecodeSendBW(&streamdata, bweIndex); - if (err < 0) { - return err; - } - - return 0; -} - - -/**************************************************************************** - * WebRtcIsac_ReadFrameLen(...) - * - * This function returns the length of the frame represented in the packet. - * - * Input: - * - encoded : Encoded bitstream - * - * Output: - * - frameLength : Length of frame in packet (in samples) - * - */ -WebRtc_Word16 WebRtcIsac_ReadFrameLen(ISACStruct* ISAC_main_inst, - const WebRtc_Word16* encoded, - WebRtc_Word16* frameLength) { - Bitstr streamdata; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - WebRtc_Word16 err; - ISACMainStruct* instISAC; - - WebRtcIsac_ResetBitstream(&(streamdata)); - -#ifndef WEBRTC_BIG_ENDIAN - for (k = 0; k < 10; k++) { - streamdata.stream[k] = (WebRtc_UWord8)((encoded[k >> 1] >> - ((k & 1) << 3)) & 0xFF); - } -#else - memcpy(streamdata.stream, encoded, 10); -#endif - - /* Decode frame length. */ - err = WebRtcIsac_DecodeFrameLen(&streamdata, frameLength); - if (err < 0) { - return -1; - } - instISAC = (ISACMainStruct*)ISAC_main_inst; - - if (instISAC->decoderSamplingRateKHz == kIsacSuperWideband) { - /* The decoded frame length indicates the number of samples in - * lower-band in this case, multiply by 2 to get the total number - * of samples. */ - *frameLength <<= 1; - } - return 0; -} - - -/******************************************************************************* - * WebRtcIsac_GetNewFrameLen(...) - * - * This function returns the frame length (in samples) of the next packet. - * In the case of channel-adaptive mode, iSAC decides on its frame length based - * on the estimated bottleneck, this AOI allows a user to prepare for the next - * packet (at the encoder). - * - * The primary usage is in CE to make the iSAC works in channel-adaptive mode - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Return Value : frame lenght in samples - * - */ -WebRtc_Word16 WebRtcIsac_GetNewFrameLen(ISACStruct* ISAC_main_inst) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - /* Return new frame length. */ - if (instISAC->encoderSamplingRateKHz == kIsacWideband) { - return (instISAC->instLB.ISACencLB_obj.new_framelength); - } else { - return ((instISAC->instLB.ISACencLB_obj.new_framelength) << 1); - } -} - - -/**************************************************************************** - * WebRtcIsac_GetErrorCode(...) - * - * This function can be used to check the error code of an iSAC instance. - * When a function returns -1 an error code will be set for that instance. - * The function below extracts the code of the last error that occurred in - * the specified instance. - * - * Input: - * - ISAC_main_inst : ISAC instance - * - * Return value : Error code - */ -WebRtc_Word16 WebRtcIsac_GetErrorCode(ISACStruct* ISAC_main_inst) { - return ((ISACMainStruct*)ISAC_main_inst)->errorCode; -} - - -/**************************************************************************** - * WebRtcIsac_GetUplinkBw(...) - * - * This function outputs the target bottleneck of the codec. In - * channel-adaptive mode, the target bottleneck is specified through an in-band - * signalling retrieved by bandwidth estimator. - * In channel-independent, also called instantaneous mode, the target - * bottleneck is provided to the encoder by calling xxx_control(...) (if - * xxx_control is never called, the default values are used.). - * Note that the output is the iSAC internal operating bottleneck which might - * differ slightly from the one provided through xxx_control(). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Output: - * - *bottleneck : bottleneck in bits/sec - * - * Return value : -1 if error happens - * 0 bit-rates computed correctly. - */ -WebRtc_Word16 WebRtcIsac_GetUplinkBw(ISACStruct* ISAC_main_inst, - WebRtc_Word32* bottleneck) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - if (instISAC->codingMode == 0) { - /* We are in adaptive mode then get the bottleneck from BWE. */ - *bottleneck = (WebRtc_Word32)instISAC->bwestimator_obj.send_bw_avg; - } else { - *bottleneck = instISAC->bottleneck; - } - - if ((*bottleneck > 32000) && (*bottleneck < 38000)) { - *bottleneck = 32000; - } else if ((*bottleneck > 45000) && (*bottleneck < 50000)) { - *bottleneck = 45000; - } else if (*bottleneck > 56000) { - *bottleneck = 56000; - } - return 0; -} - - -/****************************************************************************** - * WebRtcIsac_SetMaxPayloadSize(...) - * - * This function sets a limit for the maximum payload size of iSAC. The same - * value is used both for 30 and 60 ms packets. If the encoder sampling rate - * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the - * encoder sampling rate is 32 kHz the maximum payload size is between 120 - * and 600 bytes. - * - * --------------- - * IMPORTANT NOTES - * --------------- - * The size of a packet is limited to the minimum of 'max-payload-size' and - * 'max-rate.' For instance, let's assume the max-payload-size is set to - * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps - * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms - * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, - * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to - * 170 bytes, i.e. min(170, 300). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxPayloadBytes : maximum size of the payload in bytes - * valid values are between 100 and 400 bytes - * if encoder sampling rate is 16 kHz. For - * 32 kHz encoder sampling rate valid values - * are between 100 and 600 bytes. - * - * Return value : 0 if successful - * -1 if error happens - */ -WebRtc_Word16 WebRtcIsac_SetMaxPayloadSize(ISACStruct* ISAC_main_inst, - WebRtc_Word16 maxPayloadBytes) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - WebRtc_Word16 status = 0; - - /* Check if encoder initiated */ - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - - if (instISAC->encoderSamplingRateKHz == kIsacSuperWideband) { - /* Sanity check. */ - if (maxPayloadBytes < 120) { - /* 'maxRate' is out of valid range - * set to the acceptable value and return -1. */ - maxPayloadBytes = 120; - status = -1; - } - - /* sanity check */ - if (maxPayloadBytes > STREAM_SIZE_MAX) { - /* maxRate is out of valid range, - * set to the acceptable value and return -1. */ - maxPayloadBytes = STREAM_SIZE_MAX; - status = -1; - } - } else { - if (maxPayloadBytes < 120) { - /* Max payload-size is out of valid range - * set to the acceptable value and return -1. */ - maxPayloadBytes = 120; - status = -1; - } - if (maxPayloadBytes > STREAM_SIZE_MAX_60) { - /* Max payload-size is out of valid range - * set to the acceptable value and return -1. */ - maxPayloadBytes = STREAM_SIZE_MAX_60; - status = -1; - } - } - instISAC->maxPayloadSizeBytes = maxPayloadBytes; - UpdatePayloadSizeLimit(instISAC); - return status; -} - - -/****************************************************************************** - * WebRtcIsac_SetMaxRate(...) - * - * This function sets the maximum rate which the codec may not exceed for - * any signal packet. The maximum rate is defined and payload-size per - * frame-size in bits per second. - * - * The codec has a maximum rate of 53400 bits per second (200 bytes per 30 - * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms) - * if the encoder sampling rate is 32 kHz. - * - * It is possible to set a maximum rate between 32000 and 53400 bits/sec - * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode. - * - * --------------- - * IMPORTANT NOTES - * --------------- - * The size of a packet is limited to the minimum of 'max-payload-size' and - * 'max-rate.' For instance, let's assume the max-payload-size is set to - * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps - * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms - * frame-size. Then a packet with a frame-size of 30 ms is limited to 150, - * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to - * 170 bytes, min(170, 300). - * - * Input: - * - ISAC_main_inst : iSAC instance - * - maxRate : maximum rate in bits per second, - * valid values are 32000 to 53400 bits/sec in - * wideband mode, and 32000 to 160000 bits/sec in - * super-wideband mode. - * - * Return value : 0 if successful - * -1 if error happens - */ -WebRtc_Word16 WebRtcIsac_SetMaxRate(ISACStruct* ISAC_main_inst, - WebRtc_Word32 maxRate) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - WebRtc_Word16 maxRateInBytesPer30Ms; - WebRtc_Word16 status = 0; - - /* check if encoder initiated */ - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - return -1; - } - /* Calculate maximum number of bytes per 30 msec packets for the - given maximum rate. Multiply with 30/1000 to get number of - bits per 30 ms, divide by 8 to get number of bytes per 30 ms: - maxRateInBytes = floor((maxRate * 30/1000) / 8); */ - maxRateInBytesPer30Ms = (WebRtc_Word16)(maxRate * 3 / 800); - - if (instISAC->encoderSamplingRateKHz == kIsacWideband) { - if (maxRate < 32000) { - /* 'maxRate' is out of valid range. - * Set to the acceptable value and return -1. */ - maxRateInBytesPer30Ms = 120; - status = -1; - } - - if (maxRate > 53400) { - /* 'maxRate' is out of valid range. - * Set to the acceptable value and return -1. */ - maxRateInBytesPer30Ms = 200; - status = -1; - } - } else { - if (maxRateInBytesPer30Ms < 120) { - /* 'maxRate' is out of valid range - * Sset to the acceptable value and return -1. */ - maxRateInBytesPer30Ms = 120; - status = -1; - } - - if (maxRateInBytesPer30Ms > STREAM_SIZE_MAX) { - /* 'maxRate' is out of valid range. - * Set to the acceptable value and return -1. */ - maxRateInBytesPer30Ms = STREAM_SIZE_MAX; - status = -1; - } - } - instISAC->maxRateBytesPer30Ms = maxRateInBytesPer30Ms; - UpdatePayloadSizeLimit(instISAC); - return status; -} - - -/**************************************************************************** - * WebRtcIsac_GetRedPayload(...) - * - * This function populates "encoded" with the redundant payload of the recently - * encodedframe. This function has to be called once that WebRtcIsac_Encode(...) - * returns a positive value. Regardless of the frame-size this function will - * be called only once after encoding is completed. The bit-stream is - * targeted for 16000 bit/sec. - * - * Input: - * - ISAC_main_inst : iSAC struct - * - * Output: - * - encoded : the encoded data vector - * - * - * Return value : >0 - Length (in bytes) of coded data - * : -1 - Error - */ -WebRtc_Word16 WebRtcIsac_GetRedPayload(ISACStruct* ISAC_main_inst, - WebRtc_Word16* encoded) { - Bitstr iSACBitStreamInst; - WebRtc_Word16 streamLenLB; - WebRtc_Word16 streamLenUB; - WebRtc_Word16 streamLen; - WebRtc_Word16 totalLenUB; - WebRtc_UWord8* ptrEncodedUW8 = (WebRtc_UWord8*)encoded; - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; -#ifndef WEBRTC_BIG_ENDIAN - int k; -#endif - - if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - instISAC->errorCode = ISAC_ENCODER_NOT_INITIATED; - } - - WebRtcIsac_ResetBitstream(&(iSACBitStreamInst)); - - streamLenLB = WebRtcIsac_EncodeStoredDataLb( - &instISAC->instLB.ISACencLB_obj.SaveEnc_obj, - &iSACBitStreamInst, - instISAC->instLB.ISACencLB_obj.lastBWIdx, - RCU_TRANSCODING_SCALE); - if (streamLenLB < 0) { - return -1; - } - - /* convert from bytes to WebRtc_Word16. */ - memcpy(ptrEncodedUW8, iSACBitStreamInst.stream, streamLenLB); - streamLen = streamLenLB; - if (instISAC->bandwidthKHz == isac8kHz) { - return streamLenLB; - } - - streamLenUB = WebRtcIsac_GetRedPayloadUb( - &instISAC->instUB.ISACencUB_obj.SaveEnc_obj, - &iSACBitStreamInst, instISAC->bandwidthKHz); - if (streamLenUB < 0) { - /* An error has happened but this is not the error due to a - * bit-stream larger than the limit. */ - return -1; - } - - /* We have one byte to write the total length of the upper-band. - * The length includes the bit-stream length, check-sum and the - * single byte where the length is written to. This is according to - * iSAC wideband and how the "garbage" is dealt. */ - totalLenUB = streamLenUB + 1 + LEN_CHECK_SUM_WORD8; - if (totalLenUB > 255) { - streamLenUB = 0; - } - - /* Generate CRC if required. */ - if ((instISAC->bandwidthKHz != isac8kHz) && - (streamLenUB > 0)) { - WebRtc_UWord32 crc; - streamLen += totalLenUB; - ptrEncodedUW8[streamLenLB] = (WebRtc_UWord8)totalLenUB; - memcpy(&ptrEncodedUW8[streamLenLB + 1], iSACBitStreamInst.stream, - streamLenUB); - - WebRtcIsac_GetCrc((WebRtc_Word16*)(&(ptrEncodedUW8[streamLenLB + 1])), - streamLenUB, &crc); -#ifndef WEBRTC_BIG_ENDIAN - for (k = 0; k < LEN_CHECK_SUM_WORD8; k++) { - ptrEncodedUW8[streamLen - LEN_CHECK_SUM_WORD8 + k] = - (WebRtc_UWord8)((crc >> (24 - k * 8)) & 0xFF); - } -#else - memcpy(&ptrEncodedUW8[streamLenLB + streamLenUB + 1], &crc, - LEN_CHECK_SUM_WORD8); -#endif - } - return streamLen; -} - - -/**************************************************************************** - * WebRtcIsac_version(...) - * - * This function returns the version number. - * - * Output: - * - version : Pointer to character string - * - */ -void WebRtcIsac_version(char* version) { - strcpy(version, "4.3.0"); -} - - -/****************************************************************************** - * WebRtcIsac_SetEncSampRate() - * This function sets the sampling rate of the encoder. Initialization of the - * encoder WILL NOT overwrite the sampling rate of the encoder. The default - * value is 16 kHz which is set when the instance is created. The encoding-mode - * and the bottleneck remain unchanged by this call, however, the maximum rate - * and maximum payload-size will be reset to their default values. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - sampRate : enumerator specifying the sampling rate. - * - * Return value : 0 if successful - * -1 if failed. - */ -WebRtc_Word16 WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst, - enum IsacSamplingRate sampRate) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - if ((sampRate != kIsacWideband) && - (sampRate != kIsacSuperWideband)) { - /* Sampling Frequency is not supported. */ - instISAC->errorCode = ISAC_UNSUPPORTED_SAMPLING_FREQUENCY; - return -1; - } else if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != - BIT_MASK_ENC_INIT) { - if (sampRate == kIsacWideband) { - instISAC->bandwidthKHz = isac8kHz; - } else { - instISAC->bandwidthKHz = isac16kHz; - } - instISAC->encoderSamplingRateKHz = sampRate; - return 0; - } else { - ISACUBStruct* instUB = &(instISAC->instUB); - ISACLBStruct* instLB = &(instISAC->instLB); - double bottleneckLB; - double bottleneckUB; - WebRtc_Word32 bottleneck = instISAC->bottleneck; - WebRtc_Word16 codingMode = instISAC->codingMode; - WebRtc_Word16 frameSizeMs = instLB->ISACencLB_obj.new_framelength / - (FS / 1000); - - if ((sampRate == kIsacWideband) && - (instISAC->encoderSamplingRateKHz == kIsacSuperWideband)) { - /* Changing from super-wideband to wideband. - * we don't need to re-initialize the encoder of the lower-band. */ - instISAC->bandwidthKHz = isac8kHz; - if (codingMode == 1) { - ControlLb(instLB, - (bottleneck > 32000) ? 32000 : bottleneck, FRAMESIZE); - } - instISAC->maxPayloadSizeBytes = STREAM_SIZE_MAX_60; - instISAC->maxRateBytesPer30Ms = STREAM_SIZE_MAX_30; - } else if ((sampRate == kIsacSuperWideband) && - (instISAC->encoderSamplingRateKHz == kIsacWideband)) { - if (codingMode == 1) { - WebRtcIsac_RateAllocation(bottleneck, &bottleneckLB, &bottleneckUB, - &(instISAC->bandwidthKHz)); - } - - instISAC->bandwidthKHz = isac16kHz; - instISAC->maxPayloadSizeBytes = STREAM_SIZE_MAX; - instISAC->maxRateBytesPer30Ms = STREAM_SIZE_MAX; - - EncoderInitLb(instLB, codingMode, sampRate); - EncoderInitUb(instUB, instISAC->bandwidthKHz); - - memset(instISAC->analysisFBState1, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - memset(instISAC->analysisFBState2, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - - if (codingMode == 1) { - instISAC->bottleneck = bottleneck; - ControlLb(instLB, bottleneckLB, - (instISAC->bandwidthKHz == isac8kHz) ? frameSizeMs:FRAMESIZE); - if (instISAC->bandwidthKHz > isac8kHz) { - ControlUb(instUB, bottleneckUB); - } - } else { - instLB->ISACencLB_obj.enforceFrameSize = 0; - instLB->ISACencLB_obj.new_framelength = FRAMESAMPLES; - } - } - instISAC->encoderSamplingRateKHz = sampRate; - return 0; - } -} - - -/****************************************************************************** - * WebRtcIsac_SetDecSampRate() - * This function sets the sampling rate of the decoder. Initialization of the - * decoder WILL NOT overwrite the sampling rate of the encoder. The default - * value is 16 kHz which is set when the instance is created. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - sampRate : enumerator specifying the sampling rate. - * - * Return value : 0 if successful - * -1 if failed. - */ -WebRtc_Word16 WebRtcIsac_SetDecSampRate(ISACStruct* ISAC_main_inst, - enum IsacSamplingRate sampRate) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - - if ((sampRate != kIsacWideband) && - (sampRate != kIsacSuperWideband)) { - /* Sampling Frequency is not supported. */ - instISAC->errorCode = ISAC_UNSUPPORTED_SAMPLING_FREQUENCY; - return -1; - } else { - if ((instISAC->decoderSamplingRateKHz == kIsacWideband) && - (sampRate == kIsacSuperWideband)) { - /* Switching from wideband to super-wideband at the decoder - * we need to reset the filter-bank and initialize upper-band decoder. */ - memset(instISAC->synthesisFBState1, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - memset(instISAC->synthesisFBState2, 0, - FB_STATE_SIZE_WORD32 * sizeof(WebRtc_Word32)); - - if (DecoderInitUb(&(instISAC->instUB)) < 0) { - return -1; - } - } - instISAC->decoderSamplingRateKHz = sampRate; - return 0; - } -} - - -/****************************************************************************** - * WebRtcIsac_EncSampRate() - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : enumerator representing sampling frequency - * associated with the encoder, the input audio - * is expected to be sampled at this rate. - * - */ -enum IsacSamplingRate WebRtcIsac_EncSampRate(ISACStruct* ISAC_main_inst) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - return instISAC->encoderSamplingRateKHz; -} - - -/****************************************************************************** - * WebRtcIsac_DecSampRate() - * Return the sampling rate of the decoded audio. - * - * Input: - * - ISAC_main_inst : iSAC instance - * - * Return value : enumerator representing sampling frequency - * associated with the decoder, i.e. the - * sampling rate of the decoded audio. - * - */ -enum IsacSamplingRate WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst) { - ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; - return instISAC->decoderSamplingRateKHz; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/isac.gypi b/src/modules/audio_coding/codecs/isac/main/source/isac.gypi deleted file mode 100644 index d30be55..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/isac.gypi +++ /dev/null
@@ -1,91 +0,0 @@ -# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'iSAC', - 'type': '<(library)', - 'dependencies': [ - '<(webrtc_root)/common_audio/common_audio.gyp:signal_processing', - ], - 'include_dirs': [ - '../interface', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - '../interface', - ], - }, - 'sources': [ - '../interface/isac.h', - 'arith_routines.c', - 'arith_routines_hist.c', - 'arith_routines_logist.c', - 'bandwidth_estimator.c', - 'crc.c', - 'decode.c', - 'decode_bwe.c', - 'encode.c', - 'encode_lpc_swb.c', - 'entropy_coding.c', - 'fft.c', - 'filter_functions.c', - 'filterbank_tables.c', - 'intialize.c', - 'isac.c', - 'filterbanks.c', - 'pitch_lag_tables.c', - 'lattice.c', - 'lpc_gain_swb_tables.c', - 'lpc_analysis.c', - 'lpc_shape_swb12_tables.c', - 'lpc_shape_swb16_tables.c', - 'lpc_tables.c', - 'pitch_estimator.c', - 'pitch_filter.c', - 'pitch_gain_tables.c', - 'spectrum_ar_model_tables.c', - 'transform.c', - 'arith_routines.h', - 'bandwidth_estimator.h', - 'codec.h', - 'crc.h', - 'encode_lpc_swb.h', - 'entropy_coding.h', - 'fft.h', - 'filterbank_tables.h', - 'lpc_gain_swb_tables.h', - 'lpc_analysis.h', - 'lpc_shape_swb12_tables.h', - 'lpc_shape_swb16_tables.h', - 'lpc_tables.h', - 'pitch_estimator.h', - 'pitch_gain_tables.h', - 'pitch_lag_tables.h', - 'settings.h', - 'spectrum_ar_model_tables.h', - 'structs.h', - 'os_specific_inline.h', - ], - 'conditions': [ - ['OS!="win"', { - 'defines': [ - 'WEBRTC_LINUX', - ], - }], - ], - }, - ], -} - -# Local Variables: -# tab-width:2 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lattice.c b/src/modules/audio_coding/codecs/isac/main/source/lattice.c deleted file mode 100644 index a46135a..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lattice.c +++ /dev/null
@@ -1,217 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lattice.c - * - * contains the normalized lattice filter routines (MA and AR) for iSAC codec - * - */ -#include "settings.h" -#include "codec.h" - -#include <math.h> -#include <memory.h> -#ifdef WEBRTC_ANDROID -#include <stdlib.h> -#endif - -/* filter the signal using normalized lattice filter */ -/* MA filter */ -void WebRtcIsac_NormLatticeFilterMa(int orderCoef, - float *stateF, - float *stateG, - float *lat_in, - double *filtcoeflo, - double *lat_out) -{ - int n,k,i,u,temp1; - int ord_1 = orderCoef+1; - float sth[MAX_AR_MODEL_ORDER]; - float cth[MAX_AR_MODEL_ORDER]; - float inv_cth[MAX_AR_MODEL_ORDER]; - double a[MAX_AR_MODEL_ORDER+1]; - float f[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN], g[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN]; - float gain1; - - for (u=0;u<SUBFRAMES;u++) - { - /* set the Direct Form coefficients */ - temp1 = u*ord_1; - a[0] = 1; - memcpy(a+1, filtcoeflo+temp1+1, sizeof(double) * (ord_1-1)); - - /* compute lattice filter coefficients */ - WebRtcIsac_Dir2Lat(a,orderCoef,sth,cth); - - /* compute the gain */ - gain1 = (float)filtcoeflo[temp1]; - for (k=0;k<orderCoef;k++) - { - gain1 *= cth[k]; - inv_cth[k] = 1/cth[k]; - } - - /* normalized lattice filter */ - /*****************************/ - - /* initial conditions */ - for (i=0;i<HALF_SUBFRAMELEN;i++) - { - f[0][i] = lat_in[i + u * HALF_SUBFRAMELEN]; - g[0][i] = lat_in[i + u * HALF_SUBFRAMELEN]; - } - - /* get the state of f&g for the first input, for all orders */ - for (i=1;i<ord_1;i++) - { - f[i][0] = inv_cth[i-1]*(f[i-1][0] + sth[i-1]*stateG[i-1]); - g[i][0] = cth[i-1]*stateG[i-1] + sth[i-1]* f[i][0]; - } - - /* filtering */ - for(k=0;k<orderCoef;k++) - { - for(n=0;n<(HALF_SUBFRAMELEN-1);n++) - { - f[k+1][n+1] = inv_cth[k]*(f[k][n+1] + sth[k]*g[k][n]); - g[k+1][n+1] = cth[k]*g[k][n] + sth[k]* f[k+1][n+1]; - } - } - - for(n=0;n<HALF_SUBFRAMELEN;n++) - { - lat_out[n + u * HALF_SUBFRAMELEN] = gain1 * f[orderCoef][n]; - } - - /* save the states */ - for (i=0;i<ord_1;i++) - { - stateF[i] = f[i][HALF_SUBFRAMELEN-1]; - stateG[i] = g[i][HALF_SUBFRAMELEN-1]; - } - /* process next frame */ - } - - return; -} - - -/*///////////////////AR filter ///////////////////////////////*/ -/* filter the signal using normalized lattice filter */ -void WebRtcIsac_NormLatticeFilterAr(int orderCoef, - float *stateF, - float *stateG, - double *lat_in, - double *lo_filt_coef, - float *lat_out) -{ - int n,k,i,u,temp1; - int ord_1 = orderCoef+1; - float sth[MAX_AR_MODEL_ORDER]; - float cth[MAX_AR_MODEL_ORDER]; - double a[MAX_AR_MODEL_ORDER+1]; - float ARf[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN], ARg[MAX_AR_MODEL_ORDER+1][HALF_SUBFRAMELEN]; - float gain1,inv_gain1; - - for (u=0;u<SUBFRAMES;u++) - { - /* set the denominator and numerator of the Direct Form */ - temp1 = u*ord_1; - a[0] = 1; - - memcpy(a+1, lo_filt_coef+temp1+1, sizeof(double) * (ord_1-1)); - - WebRtcIsac_Dir2Lat(a,orderCoef,sth,cth); - - gain1 = (float)lo_filt_coef[temp1]; - for (k=0;k<orderCoef;k++) - { - gain1 = cth[k]*gain1; - } - - /* initial conditions */ - inv_gain1 = 1/gain1; - for (i=0;i<HALF_SUBFRAMELEN;i++) - { - ARf[orderCoef][i] = (float)lat_in[i + u * HALF_SUBFRAMELEN]*inv_gain1; - } - - - for (i=orderCoef-1;i>=0;i--) //get the state of f&g for the first input, for all orders - { - ARf[i][0] = cth[i]*ARf[i+1][0] - sth[i]*stateG[i]; - ARg[i+1][0] = sth[i]*ARf[i+1][0] + cth[i]* stateG[i]; - } - ARg[0][0] = ARf[0][0]; - - for(n=0;n<(HALF_SUBFRAMELEN-1);n++) - { - for(k=orderCoef-1;k>=0;k--) - { - ARf[k][n+1] = cth[k]*ARf[k+1][n+1] - sth[k]*ARg[k][n]; - ARg[k+1][n+1] = sth[k]*ARf[k+1][n+1] + cth[k]* ARg[k][n]; - } - ARg[0][n+1] = ARf[0][n+1]; - } - - memcpy(lat_out+u * HALF_SUBFRAMELEN, &(ARf[0][0]), sizeof(float) * HALF_SUBFRAMELEN); - - /* cannot use memcpy in the following */ - for (i=0;i<ord_1;i++) - { - stateF[i] = ARf[i][HALF_SUBFRAMELEN-1]; - stateG[i] = ARg[i][HALF_SUBFRAMELEN-1]; - } - - } - - return; -} - - -/* compute the reflection coefficients using the step-down procedure*/ -/* converts the direct form parameters to lattice form.*/ -/* a and b are vectors which contain the direct form coefficients, - according to - A(z) = a(1) + a(2)*z + a(3)*z^2 + ... + a(M+1)*z^M - B(z) = b(1) + b(2)*z + b(3)*z^2 + ... + b(M+1)*z^M -*/ - -void WebRtcIsac_Dir2Lat(double *a, - int orderCoef, - float *sth, - float *cth) -{ - int m, k; - float tmp[MAX_AR_MODEL_ORDER]; - float tmp_inv, cth2; - - sth[orderCoef-1] = (float)a[orderCoef]; - cth2 = 1.0f - sth[orderCoef-1] * sth[orderCoef-1]; - cth[orderCoef-1] = (float)sqrt(cth2); - for (m=orderCoef-1; m>0; m--) - { - tmp_inv = 1.0f / cth2; - for (k=1; k<=m; k++) - { - tmp[k] = ((float)a[k] - sth[m] * (float)a[m-k+1]) * tmp_inv; - } - - for (k=1; k<m; k++) - { - a[k] = tmp[k]; - } - - sth[m-1] = tmp[m]; - cth2 = 1 - sth[m-1] * sth[m-1]; - cth[m-1] = (float)sqrt(cth2); - } -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c b/src/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c deleted file mode 100644 index 854b2d7..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c +++ /dev/null
@@ -1,535 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "lpc_analysis.h" -#include "settings.h" -#include "codec.h" -#include "entropy_coding.h" - -#include <math.h> -#include <string.h> - -#define LEVINSON_EPS 1.0e-10 - - -/* window */ -/* Matlab generation code: - * t = (1:256)/257; r = 1-(1-t).^.45; w = sin(r*pi).^3; w = w/sum(w); plot((1:256)/8, w); grid; - * for k=1:16, fprintf(1, '%.8f, ', w(k*16 + (-15:0))); fprintf(1, '\n'); end - */ -static const double kLpcCorrWindow[WINLEN] = { - 0.00000000, 0.00000001, 0.00000004, 0.00000010, 0.00000020, - 0.00000035, 0.00000055, 0.00000083, 0.00000118, 0.00000163, - 0.00000218, 0.00000283, 0.00000361, 0.00000453, 0.00000558, 0.00000679, - 0.00000817, 0.00000973, 0.00001147, 0.00001342, 0.00001558, - 0.00001796, 0.00002058, 0.00002344, 0.00002657, 0.00002997, - 0.00003365, 0.00003762, 0.00004190, 0.00004651, 0.00005144, 0.00005673, - 0.00006236, 0.00006837, 0.00007476, 0.00008155, 0.00008875, - 0.00009636, 0.00010441, 0.00011290, 0.00012186, 0.00013128, - 0.00014119, 0.00015160, 0.00016252, 0.00017396, 0.00018594, 0.00019846, - 0.00021155, 0.00022521, 0.00023946, 0.00025432, 0.00026978, - 0.00028587, 0.00030260, 0.00031998, 0.00033802, 0.00035674, - 0.00037615, 0.00039626, 0.00041708, 0.00043863, 0.00046092, 0.00048396, - 0.00050775, 0.00053233, 0.00055768, 0.00058384, 0.00061080, - 0.00063858, 0.00066720, 0.00069665, 0.00072696, 0.00075813, - 0.00079017, 0.00082310, 0.00085692, 0.00089164, 0.00092728, 0.00096384, - 0.00100133, 0.00103976, 0.00107914, 0.00111947, 0.00116077, - 0.00120304, 0.00124630, 0.00129053, 0.00133577, 0.00138200, - 0.00142924, 0.00147749, 0.00152676, 0.00157705, 0.00162836, 0.00168070, - 0.00173408, 0.00178850, 0.00184395, 0.00190045, 0.00195799, - 0.00201658, 0.00207621, 0.00213688, 0.00219860, 0.00226137, - 0.00232518, 0.00239003, 0.00245591, 0.00252284, 0.00259079, 0.00265977, - 0.00272977, 0.00280078, 0.00287280, 0.00294582, 0.00301984, - 0.00309484, 0.00317081, 0.00324774, 0.00332563, 0.00340446, - 0.00348421, 0.00356488, 0.00364644, 0.00372889, 0.00381220, 0.00389636, - 0.00398135, 0.00406715, 0.00415374, 0.00424109, 0.00432920, - 0.00441802, 0.00450754, 0.00459773, 0.00468857, 0.00478001, - 0.00487205, 0.00496464, 0.00505775, 0.00515136, 0.00524542, 0.00533990, - 0.00543476, 0.00552997, 0.00562548, 0.00572125, 0.00581725, - 0.00591342, 0.00600973, 0.00610612, 0.00620254, 0.00629895, - 0.00639530, 0.00649153, 0.00658758, 0.00668341, 0.00677894, 0.00687413, - 0.00696891, 0.00706322, 0.00715699, 0.00725016, 0.00734266, - 0.00743441, 0.00752535, 0.00761540, 0.00770449, 0.00779254, - 0.00787947, 0.00796519, 0.00804963, 0.00813270, 0.00821431, 0.00829437, - 0.00837280, 0.00844949, 0.00852436, 0.00859730, 0.00866822, - 0.00873701, 0.00880358, 0.00886781, 0.00892960, 0.00898884, - 0.00904542, 0.00909923, 0.00915014, 0.00919805, 0.00924283, 0.00928436, - 0.00932252, 0.00935718, 0.00938821, 0.00941550, 0.00943890, - 0.00945828, 0.00947351, 0.00948446, 0.00949098, 0.00949294, - 0.00949020, 0.00948262, 0.00947005, 0.00945235, 0.00942938, 0.00940099, - 0.00936704, 0.00932738, 0.00928186, 0.00923034, 0.00917268, - 0.00910872, 0.00903832, 0.00896134, 0.00887763, 0.00878706, - 0.00868949, 0.00858478, 0.00847280, 0.00835343, 0.00822653, 0.00809199, - 0.00794970, 0.00779956, 0.00764145, 0.00747530, 0.00730103, - 0.00711857, 0.00692787, 0.00672888, 0.00652158, 0.00630597, - 0.00608208, 0.00584994, 0.00560962, 0.00536124, 0.00510493, 0.00484089, - 0.00456935, 0.00429062, 0.00400505, 0.00371310, 0.00341532, - 0.00311238, 0.00280511, 0.00249452, 0.00218184, 0.00186864, - 0.00155690, 0.00124918, 0.00094895, 0.00066112, 0.00039320, 0.00015881 -}; - -double WebRtcIsac_LevDurb(double *a, double *k, double *r, int order) -{ - - double sum, alpha; - int m, m_h, i; - alpha = 0; //warning -DH - a[0] = 1.0; - if (r[0] < LEVINSON_EPS) { /* if r[0] <= 0, set LPC coeff. to zero */ - for (i = 0; i < order; i++) { - k[i] = 0; - a[i+1] = 0; - } - } else { - a[1] = k[0] = -r[1]/r[0]; - alpha = r[0] + r[1] * k[0]; - for (m = 1; m < order; m++){ - sum = r[m + 1]; - for (i = 0; i < m; i++){ - sum += a[i+1] * r[m - i]; - } - k[m] = -sum / alpha; - alpha += k[m] * sum; - m_h = (m + 1) >> 1; - for (i = 0; i < m_h; i++){ - sum = a[i+1] + k[m] * a[m - i]; - a[m - i] += k[m] * a[i+1]; - a[i+1] = sum; - } - a[m+1] = k[m]; - } - } - return alpha; -} - - -//was static before, but didn't work with MEX file -void WebRtcIsac_GetVars(const double *input, const WebRtc_Word16 *pitchGains_Q12, - double *oldEnergy, double *varscale) -{ - double nrg[4], chng, pg; - int k; - - double pitchGains[4]={0,0,0,0};; - - /* Calculate energies of first and second frame halfs */ - nrg[0] = 0.0001; - for (k = QLOOKAHEAD/2; k < (FRAMESAMPLES_QUARTER + QLOOKAHEAD) / 2; k++) { - nrg[0] += input[k]*input[k]; - } - nrg[1] = 0.0001; - for ( ; k < (FRAMESAMPLES_HALF + QLOOKAHEAD) / 2; k++) { - nrg[1] += input[k]*input[k]; - } - nrg[2] = 0.0001; - for ( ; k < (FRAMESAMPLES*3/4 + QLOOKAHEAD) / 2; k++) { - nrg[2] += input[k]*input[k]; - } - nrg[3] = 0.0001; - for ( ; k < (FRAMESAMPLES + QLOOKAHEAD) / 2; k++) { - nrg[3] += input[k]*input[k]; - } - - /* Calculate average level change */ - chng = 0.25 * (fabs(10.0 * log10(nrg[3] / nrg[2])) + - fabs(10.0 * log10(nrg[2] / nrg[1])) + - fabs(10.0 * log10(nrg[1] / nrg[0])) + - fabs(10.0 * log10(nrg[0] / *oldEnergy))); - - - /* Find average pitch gain */ - pg = 0.0; - for (k=0; k<4; k++) - { - pitchGains[k] = ((float)pitchGains_Q12[k])/4096; - pg += pitchGains[k]; - } - pg *= 0.25; - - /* If pitch gain is low and energy constant - increase noise level*/ - /* Matlab code: - pg = 0:.01:.45; plot(pg, 0.0 + 1.0 * exp( -1.0 * exp(-200.0 * pg.*pg.*pg) / (1.0 + 0.4 * 0) )) - */ - *varscale = 0.0 + 1.0 * exp( -1.4 * exp(-200.0 * pg*pg*pg) / (1.0 + 0.4 * chng) ); - - *oldEnergy = nrg[3]; -} - -void -WebRtcIsac_GetVarsUB( - const double* input, - double* oldEnergy, - double* varscale) -{ - double nrg[4], chng; - int k; - - /* Calculate energies of first and second frame halfs */ - nrg[0] = 0.0001; - for (k = 0; k < (FRAMESAMPLES_QUARTER) / 2; k++) { - nrg[0] += input[k]*input[k]; - } - nrg[1] = 0.0001; - for ( ; k < (FRAMESAMPLES_HALF) / 2; k++) { - nrg[1] += input[k]*input[k]; - } - nrg[2] = 0.0001; - for ( ; k < (FRAMESAMPLES*3/4) / 2; k++) { - nrg[2] += input[k]*input[k]; - } - nrg[3] = 0.0001; - for ( ; k < (FRAMESAMPLES) / 2; k++) { - nrg[3] += input[k]*input[k]; - } - - /* Calculate average level change */ - chng = 0.25 * (fabs(10.0 * log10(nrg[3] / nrg[2])) + - fabs(10.0 * log10(nrg[2] / nrg[1])) + - fabs(10.0 * log10(nrg[1] / nrg[0])) + - fabs(10.0 * log10(nrg[0] / *oldEnergy))); - - - /* If pitch gain is low and energy constant - increase noise level*/ - /* Matlab code: - pg = 0:.01:.45; plot(pg, 0.0 + 1.0 * exp( -1.0 * exp(-200.0 * pg.*pg.*pg) / (1.0 + 0.4 * 0) )) - */ - *varscale = exp( -1.4 / (1.0 + 0.4 * chng) ); - - *oldEnergy = nrg[3]; -} - -void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata, - double signal_noise_ratio, const WebRtc_Word16 *pitchGains_Q12, - double *lo_coeff, double *hi_coeff) -{ - int k, n, j, pos1, pos2; - double varscale; - - double DataLo[WINLEN], DataHi[WINLEN]; - double corrlo[ORDERLO+2], corrlo2[ORDERLO+1]; - double corrhi[ORDERHI+1]; - double k_veclo[ORDERLO], k_vechi[ORDERHI]; - - double a_LO[ORDERLO+1], a_HI[ORDERHI+1]; - double tmp, res_nrg; - - double FwdA, FwdB; - - /* hearing threshold level in dB; higher value gives more noise */ - const double HearThresOffset = -28.0; - - /* bandwdith expansion factors for low- and high band */ - const double gammaLo = 0.9; - const double gammaHi = 0.8; - - /* less-noise-at-low-frequencies factor */ - double aa; - - - /* convert from dB to signal level */ - const double H_T_H = pow(10.0, 0.05 * HearThresOffset); - double S_N_R = pow(10.0, 0.05 * signal_noise_ratio) / 3.46; /* divide by sqrt(12) */ - - /* change quallevel depending on pitch gains and level fluctuations */ - WebRtcIsac_GetVars(inLo, pitchGains_Q12, &(maskdata->OldEnergy), &varscale); - - /* less-noise-at-low-frequencies factor */ - aa = 0.35 * (0.5 + 0.5 * varscale); - - /* replace data in buffer by new look-ahead data */ - for (pos1 = 0; pos1 < QLOOKAHEAD; pos1++) - maskdata->DataBufferLo[pos1 + WINLEN - QLOOKAHEAD] = inLo[pos1]; - - for (k = 0; k < SUBFRAMES; k++) { - - /* Update input buffer and multiply signal with window */ - for (pos1 = 0; pos1 < WINLEN - UPDATE/2; pos1++) { - maskdata->DataBufferLo[pos1] = maskdata->DataBufferLo[pos1 + UPDATE/2]; - maskdata->DataBufferHi[pos1] = maskdata->DataBufferHi[pos1 + UPDATE/2]; - DataLo[pos1] = maskdata->DataBufferLo[pos1] * kLpcCorrWindow[pos1]; - DataHi[pos1] = maskdata->DataBufferHi[pos1] * kLpcCorrWindow[pos1]; - } - pos2 = k * UPDATE/2; - for (n = 0; n < UPDATE/2; n++, pos1++) { - maskdata->DataBufferLo[pos1] = inLo[QLOOKAHEAD + pos2]; - maskdata->DataBufferHi[pos1] = inHi[pos2++]; - DataLo[pos1] = maskdata->DataBufferLo[pos1] * kLpcCorrWindow[pos1]; - DataHi[pos1] = maskdata->DataBufferHi[pos1] * kLpcCorrWindow[pos1]; - } - - /* Get correlation coefficients */ - WebRtcIsac_AutoCorr(corrlo, DataLo, WINLEN, ORDERLO+1); /* computing autocorrelation */ - WebRtcIsac_AutoCorr(corrhi, DataHi, WINLEN, ORDERHI); - - - /* less noise for lower frequencies, by filtering/scaling autocorrelation sequences */ - corrlo2[0] = (1.0+aa*aa) * corrlo[0] - 2.0*aa * corrlo[1]; - tmp = (1.0 + aa*aa); - for (n = 1; n <= ORDERLO; n++) { - corrlo2[n] = tmp * corrlo[n] - aa * (corrlo[n-1] + corrlo[n+1]); - } - tmp = (1.0+aa) * (1.0+aa); - for (n = 0; n <= ORDERHI; n++) { - corrhi[n] = tmp * corrhi[n]; - } - - /* add white noise floor */ - corrlo2[0] += 1e-6; - corrhi[0] += 1e-6; - - - FwdA = 0.01; - FwdB = 0.01; - - /* recursive filtering of correlation over subframes */ - for (n = 0; n <= ORDERLO; n++) { - maskdata->CorrBufLo[n] = FwdA * maskdata->CorrBufLo[n] + corrlo2[n]; - corrlo2[n] = ((1.0-FwdA)*FwdB) * maskdata->CorrBufLo[n] + (1.0-FwdB) * corrlo2[n]; - } - for (n = 0; n <= ORDERHI; n++) { - maskdata->CorrBufHi[n] = FwdA * maskdata->CorrBufHi[n] + corrhi[n]; - corrhi[n] = ((1.0-FwdA)*FwdB) * maskdata->CorrBufHi[n] + (1.0-FwdB) * corrhi[n]; - } - - /* compute prediction coefficients */ - WebRtcIsac_LevDurb(a_LO, k_veclo, corrlo2, ORDERLO); - WebRtcIsac_LevDurb(a_HI, k_vechi, corrhi, ORDERHI); - - /* bandwidth expansion */ - tmp = gammaLo; - for (n = 1; n <= ORDERLO; n++) { - a_LO[n] *= tmp; - tmp *= gammaLo; - } - - /* residual energy */ - res_nrg = 0.0; - for (j = 0; j <= ORDERLO; j++) { - for (n = 0; n <= j; n++) { - res_nrg += a_LO[j] * corrlo2[j-n] * a_LO[n]; - } - for (n = j+1; n <= ORDERLO; n++) { - res_nrg += a_LO[j] * corrlo2[n-j] * a_LO[n]; - } - } - - /* add hearing threshold and compute the gain */ - *lo_coeff++ = S_N_R / (sqrt(res_nrg) / varscale + H_T_H); - - /* copy coefficients to output array */ - for (n = 1; n <= ORDERLO; n++) { - *lo_coeff++ = a_LO[n]; - } - - - /* bandwidth expansion */ - tmp = gammaHi; - for (n = 1; n <= ORDERHI; n++) { - a_HI[n] *= tmp; - tmp *= gammaHi; - } - - /* residual energy */ - res_nrg = 0.0; - for (j = 0; j <= ORDERHI; j++) { - for (n = 0; n <= j; n++) { - res_nrg += a_HI[j] * corrhi[j-n] * a_HI[n]; - } - for (n = j+1; n <= ORDERHI; n++) { - res_nrg += a_HI[j] * corrhi[n-j] * a_HI[n]; - } - } - - /* add hearing threshold and compute of the gain */ - *hi_coeff++ = S_N_R / (sqrt(res_nrg) / varscale + H_T_H); - - /* copy coefficients to output array */ - for (n = 1; n <= ORDERHI; n++) { - *hi_coeff++ = a_HI[n]; - } - } -} - - - -/****************************************************************************** - * WebRtcIsac_GetLpcCoefUb() - * - * Compute LP coefficients and correlation coefficients. At 12 kHz LP - * coefficients of the first and the last sub-frame is computed. At 16 kHz - * LP coefficients of 4th, 8th and 12th sub-frames are computed. We always - * compute correlation coefficients of all sub-frames. - * - * Inputs: - * -inSignal : Input signal - * -maskdata : a structure keeping signal from previous frame. - * -bandwidth : specifies if the codec is in 0-16 kHz mode or - * 0-12 kHz mode. - * - * Outputs: - * -lpCoeff : pointer to a buffer where A-polynomials are - * written to (first coeff is 1 and it is not - * written) - * -corrMat : a matrix where correlation coefficients of each - * sub-frame are written to one row. - * -varscale : a scale used to compute LPC gains. - */ -void -WebRtcIsac_GetLpcCoefUb( - double* inSignal, - MaskFiltstr* maskdata, - double* lpCoeff, - double corrMat[][UB_LPC_ORDER + 1], - double* varscale, - WebRtc_Word16 bandwidth) -{ - int frameCntr, activeFrameCntr, n, pos1, pos2; - WebRtc_Word16 criterion1; - WebRtc_Word16 criterion2; - WebRtc_Word16 numSubFrames = SUBFRAMES * (1 + (bandwidth == isac16kHz)); - double data[WINLEN]; - double corrSubFrame[UB_LPC_ORDER+2]; - double reflecCoeff[UB_LPC_ORDER]; - - double aPolynom[UB_LPC_ORDER+1]; - double tmp; - - /* bandwdith expansion factors */ - const double gamma = 0.9; - - /* change quallevel depending on pitch gains and level fluctuations */ - WebRtcIsac_GetVarsUB(inSignal, &(maskdata->OldEnergy), varscale); - - /* replace data in buffer by new look-ahead data */ - for(frameCntr = 0, activeFrameCntr = 0; frameCntr < numSubFrames; - frameCntr++) - { - if(frameCntr == SUBFRAMES) - { - // we are in 16 kHz - varscale++; - WebRtcIsac_GetVarsUB(&inSignal[FRAMESAMPLES_HALF], - &(maskdata->OldEnergy), varscale); - } - /* Update input buffer and multiply signal with window */ - for(pos1 = 0; pos1 < WINLEN - UPDATE/2; pos1++) - { - maskdata->DataBufferLo[pos1] = maskdata->DataBufferLo[pos1 + - UPDATE/2]; - data[pos1] = maskdata->DataBufferLo[pos1] * kLpcCorrWindow[pos1]; - } - pos2 = frameCntr * UPDATE/2; - for(n = 0; n < UPDATE/2; n++, pos1++, pos2++) - { - maskdata->DataBufferLo[pos1] = inSignal[pos2]; - data[pos1] = maskdata->DataBufferLo[pos1] * kLpcCorrWindow[pos1]; - } - - /* Get correlation coefficients */ - /* computing autocorrelation */ - WebRtcIsac_AutoCorr(corrSubFrame, data, WINLEN, UB_LPC_ORDER+1); - memcpy(corrMat[frameCntr], corrSubFrame, - (UB_LPC_ORDER+1)*sizeof(double)); - - criterion1 = ((frameCntr == 0) || (frameCntr == (SUBFRAMES - 1))) && - (bandwidth == isac12kHz); - criterion2 = (((frameCntr+1) % 4) == 0) && - (bandwidth == isac16kHz); - if(criterion1 || criterion2) - { - /* add noise */ - corrSubFrame[0] += 1e-6; - /* compute prediction coefficients */ - WebRtcIsac_LevDurb(aPolynom, reflecCoeff, corrSubFrame, - UB_LPC_ORDER); - - /* bandwidth expansion */ - tmp = gamma; - for (n = 1; n <= UB_LPC_ORDER; n++) - { - *lpCoeff++ = aPolynom[n] * tmp; - tmp *= gamma; - } - activeFrameCntr++; - } - } -} - - - -/****************************************************************************** - * WebRtcIsac_GetLpcGain() - * - * Compute the LPC gains for each sub-frame, given the LPC of each sub-frame - * and the corresponding correlation coefficients. - * - * Inputs: - * -signal_noise_ratio : the desired SNR in dB. - * -numVecs : number of sub-frames - * -corrMat : a matrix of correlation coefficients where - * each row is a set of correlation coefficients of - * one sub-frame. - * -varscale : a scale computed when WebRtcIsac_GetLpcCoefUb() - * is called. - * - * Outputs: - * -gain : pointer to a buffer where LP gains are written. - * - */ -void -WebRtcIsac_GetLpcGain( - double signal_noise_ratio, - const double* filtCoeffVecs, - int numVecs, - double* gain, - double corrMat[][UB_LPC_ORDER + 1], - const double* varscale) -{ - WebRtc_Word16 j, n; - WebRtc_Word16 subFrameCntr; - double aPolynom[ORDERLO + 1]; - double res_nrg; - - const double HearThresOffset = -28.0; - const double H_T_H = pow(10.0, 0.05 * HearThresOffset); - /* divide by sqrt(12) = 3.46 */ - const double S_N_R = pow(10.0, 0.05 * signal_noise_ratio) / 3.46; - - aPolynom[0] = 1; - for(subFrameCntr = 0; subFrameCntr < numVecs; subFrameCntr++) - { - if(subFrameCntr == SUBFRAMES) - { - // we are in second half of a SWB frame. use new varscale - varscale++; - } - memcpy(&aPolynom[1], &filtCoeffVecs[(subFrameCntr * (UB_LPC_ORDER + 1)) + - 1], sizeof(double) * UB_LPC_ORDER); - - /* residual energy */ - res_nrg = 0.0; - for(j = 0; j <= UB_LPC_ORDER; j++) - { - for(n = 0; n <= j; n++) - { - res_nrg += aPolynom[j] * corrMat[subFrameCntr][j-n] * - aPolynom[n]; - } - for(n = j+1; n <= UB_LPC_ORDER; n++) - { - res_nrg += aPolynom[j] * corrMat[subFrameCntr][n-j] * - aPolynom[n]; - } - } - - /* add hearing threshold and compute the gain */ - gain[subFrameCntr] = S_N_R / (sqrt(res_nrg) / *varscale + H_T_H); - } -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h b/src/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h deleted file mode 100644 index 4eafeac..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_analysis.h +++ /dev/null
@@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_analysis.h - * - * LPC functions - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYSIS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYSIS_H_ - -#include "settings.h" -#include "structs.h" - -double WebRtcIsac_LevDurb(double *a, double *k, double *r, int order); - -void WebRtcIsac_GetVars(const double *input, const WebRtc_Word16 *pitchGains_Q12, - double *oldEnergy, double *varscale); - -void WebRtcIsac_GetLpcCoefLb(double *inLo, double *inHi, MaskFiltstr *maskdata, - double signal_noise_ratio, const WebRtc_Word16 *pitchGains_Q12, - double *lo_coeff, double *hi_coeff); - - -void WebRtcIsac_GetLpcGain( - double signal_noise_ratio, - const double* filtCoeffVecs, - int numVecs, - double* gain, - double corrLo[][UB_LPC_ORDER + 1], - const double* varscale); - -void WebRtcIsac_GetLpcCoefUb( - double* inSignal, - MaskFiltstr* maskdata, - double* lpCoeff, - double corr[][UB_LPC_ORDER + 1], - double* varscale, - WebRtc_Word16 bandwidth); - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_ANALYIS_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.c b/src/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.c deleted file mode 100644 index 25c69cb..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.c +++ /dev/null
@@ -1,137 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * SWB_KLT_Tables_LPCGain.c - * - * This file defines tables used for entropy coding of LPC Gain - * of upper-band. - * - */ - -#include "lpc_gain_swb_tables.h" -#include "settings.h" -#include "typedefs.h" - -const double WebRtcIsac_kQSizeLpcGain = 0.100000; - -const double WebRtcIsac_kMeanLpcGain = -3.3822; - -/* -* The smallest reconstruction points for quantiztion of -* LPC gains. -*/ -const double WebRtcIsac_kLeftRecPointLpcGain[SUBFRAMES] = -{ - -0.800000, -1.000000, -1.200000, -2.200000, -3.000000, -12.700000 -}; - -/* -* Number of reconstruction points of quantizers for LPC Gains. -*/ -const WebRtc_Word16 WebRtcIsac_kNumQCellLpcGain[SUBFRAMES] = -{ - 17, 20, 25, 45, 77, 170 -}; -/* -* Starting index for entropy decoder to search for the right interval, -* one entry per LAR coefficient -*/ -const WebRtc_UWord16 WebRtcIsac_kLpcGainEntropySearch[SUBFRAMES] = -{ - 8, 10, 12, 22, 38, 85 -}; - -/* -* The following 6 vectors define CDF of 6 decorrelated LPC -* gains. -*/ -const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec0[18] = -{ - 0, 10, 27, 83, 234, 568, 1601, 4683, 16830, 57534, 63437, - 64767, 65229, 65408, 65483, 65514, 65527, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec1[21] = -{ - 0, 15, 33, 84, 185, 385, 807, 1619, 3529, 7850, 19488, - 51365, 62437, 64548, 65088, 65304, 65409, 65484, 65507, 65522, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec2[26] = -{ - 0, 15, 29, 54, 89, 145, 228, 380, 652, 1493, 4260, - 12359, 34133, 50749, 57224, 60814, 62927, 64078, 64742, 65103, 65311, 65418, - 65473, 65509, 65521, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec3[46] = -{ - 0, 8, 12, 16, 26, 42, 56, 76, 111, 164, 247, - 366, 508, 693, 1000, 1442, 2155, 3188, 4854, 7387, 11249, 17617, - 30079, 46711, 56291, 60127, 62140, 63258, 63954, 64384, 64690, 64891, 65031, - 65139, 65227, 65293, 65351, 65399, 65438, 65467, 65492, 65504, 65510, 65518, - 65523, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec4[78] = -{ - 0, 17, 29, 39, 51, 70, 104, 154, 234, 324, 443, - 590, 760, 971, 1202, 1494, 1845, 2274, 2797, 3366, 4088, 4905, - 5899, 7142, 8683, 10625, 12983, 16095, 20637, 28216, 38859, 47237, 51537, - 54150, 56066, 57583, 58756, 59685, 60458, 61103, 61659, 62144, 62550, 62886, - 63186, 63480, 63743, 63954, 64148, 64320, 64467, 64600, 64719, 64837, 64939, - 65014, 65098, 65160, 65211, 65250, 65290, 65325, 65344, 65366, 65391, 65410, - 65430, 65447, 65460, 65474, 65487, 65494, 65501, 65509, 65513, 65518, 65520, - 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec5[171] = -{ - 0, 10, 12, 14, 16, 18, 23, 29, 35, 42, 51, - 58, 65, 72, 78, 87, 96, 103, 111, 122, 134, 150, - 167, 184, 202, 223, 244, 265, 289, 315, 346, 379, 414, - 450, 491, 532, 572, 613, 656, 700, 751, 802, 853, 905, - 957, 1021, 1098, 1174, 1250, 1331, 1413, 1490, 1565, 1647, 1730, - 1821, 1913, 2004, 2100, 2207, 2314, 2420, 2532, 2652, 2783, 2921, - 3056, 3189, 3327, 3468, 3640, 3817, 3993, 4171, 4362, 4554, 4751, - 4948, 5142, 5346, 5566, 5799, 6044, 6301, 6565, 6852, 7150, 7470, - 7797, 8143, 8492, 8835, 9181, 9547, 9919, 10315, 10718, 11136, 11566, - 12015, 12482, 12967, 13458, 13953, 14432, 14903, 15416, 15936, 16452, 16967, - 17492, 18024, 18600, 19173, 19736, 20311, 20911, 21490, 22041, 22597, 23157, - 23768, 24405, 25034, 25660, 26280, 26899, 27614, 28331, 29015, 29702, 30403, - 31107, 31817, 32566, 33381, 34224, 35099, 36112, 37222, 38375, 39549, 40801, - 42074, 43350, 44626, 45982, 47354, 48860, 50361, 51845, 53312, 54739, 56026, - 57116, 58104, 58996, 59842, 60658, 61488, 62324, 63057, 63769, 64285, 64779, - 65076, 65344, 65430, 65500, 65517, 65535 -}; - -/* -* An array of pointers to CDFs of decorrelated LPC Gains -*/ -const WebRtc_UWord16* WebRtcIsac_kLpcGainCdfMat[SUBFRAMES] = -{ - WebRtcIsac_kLpcGainCdfVec0, WebRtcIsac_kLpcGainCdfVec1, - WebRtcIsac_kLpcGainCdfVec2, WebRtcIsac_kLpcGainCdfVec3, - WebRtcIsac_kLpcGainCdfVec4, WebRtcIsac_kLpcGainCdfVec5 -}; - -/* -* A matrix to decorrellate LPC gains of subframes. -*/ -const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES] = -{ - {-0.150860, 0.327872, 0.367220, 0.504613, 0.559270, 0.409234}, - { 0.457128, -0.613591, -0.289283, -0.029734, 0.393760, 0.418240}, - {-0.626043, 0.136489, -0.439118, -0.448323, 0.135987, 0.420869}, - { 0.526617, 0.480187, 0.242552, -0.488754, -0.158713, 0.411331}, - {-0.302587, -0.494953, 0.588112, -0.063035, -0.404290, 0.387510}, - { 0.086378, 0.147714, -0.428875, 0.548300, -0.570121, 0.401391} -};
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h b/src/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h deleted file mode 100644 index 1eba97c..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.h +++ /dev/null
@@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * SWB_KLT_Tables_LPCGain.h - * - * This file declares tables used for entropy coding of LPC Gain - * of upper-band. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_ - -#include "settings.h" -#include "typedefs.h" - -extern const double WebRtcIsac_kQSizeLpcGain; - -extern const double WebRtcIsac_kLeftRecPointLpcGain[SUBFRAMES]; - -extern const WebRtc_Word16 WebRtcIsac_kNumQCellLpcGain[SUBFRAMES]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainEntropySearch[SUBFRAMES]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec0[18]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec1[21]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec2[26]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec3[46]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec4[78]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcGainCdfVec5[171]; - -extern const WebRtc_UWord16* WebRtcIsac_kLpcGainCdfMat[SUBFRAMES]; - -extern const double WebRtcIsac_kLpcGainDecorrMat[SUBFRAMES][SUBFRAMES]; - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_GAIN_SWB_TABLES_H_
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.c b/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.c deleted file mode 100644 index 695d583..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.c +++ /dev/null
@@ -1,159 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * SWB_KLT_Tables.c - * - * This file defines tables used for entropy coding of LPC shape of - * upper-band signal if the bandwidth is 12 kHz. - * - */ - -#include "lpc_shape_swb12_tables.h" -#include "settings.h" -#include "typedefs.h" - -/* -* Mean value of LAR -*/ -const double WebRtcIsac_kMeanLarUb12[UB_LPC_ORDER] = -{ - 0.03748928306641, 0.09453441192543, -0.01112522344398, 0.03800237516842 -}; - -/* -* A rotation matrix to decorrelate intra-vector correlation, -* i.e. correlation among components of LAR vector. -*/ -const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER] = -{ - {-0.00075365493856, -0.05809964887743, -0.23397966154116, 0.97050367376411}, - { 0.00625021257734, -0.17299965610679, 0.95977735920651, 0.22104179375008}, - { 0.20543384258374, -0.96202143495696, -0.15301870801552, -0.09432375099565}, - {-0.97865075648479, -0.20300322280841, -0.02581111653779, -0.01913568980258} -}; - -/* -* A rotation matrix to remove correlation among LAR coefficients -* of different LAR vectors. One might guess that decorrelation matrix -* for the first component should differ from the second component -* but we haven't observed a significant benefit of having different -* decorrelation matrices for different components. -*/ -const double WebRtcIsac_kInterVecDecorrMatUb12 -[UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME] = -{ - { 0.70650597970460, -0.70770707262373}, - {-0.70770707262373, -0.70650597970460} -}; - -/* -* LAR quantization step-size. -*/ -const double WebRtcIsac_kLpcShapeQStepSizeUb12 = 0.150000; - -/* -* The smallest reconstruction points for quantiztion of LAR coefficients. -*/ -const double WebRtcIsac_kLpcShapeLeftRecPointUb12 -[UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME] = -{ - -0.900000, -1.050000, -1.350000, -1.800000, -1.350000, -1.650000, - -2.250000, -3.450000 -}; - -/* -* Number of reconstruction points of quantizers for LAR coefficients. -*/ -const WebRtc_Word16 WebRtcIsac_kLpcShapeNumRecPointUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME] = -{ - 13, 15, 19, 27, 19, 24, 32, 48 -}; - -/* -* Starting index for entropy decoder to search for the right interval, -* one entry per LAR coefficient -*/ -const WebRtc_UWord16 WebRtcIsac_kLpcShapeEntropySearchUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME] = -{ - 6, 7, 9, 13, 9, 12, 16, 24 -}; - -/* -* The following 8 vectors define CDF of 8 decorrelated LAR -* coefficients. -*/ -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec0Ub12[14] = -{ - 0, 13, 95, 418, 1687, 6498, 21317, 44200, 59029, 63849, 65147, - 65449, 65525, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec1Ub12[16] = -{ - 0, 10, 59, 255, 858, 2667, 8200, 22609, 42988, 57202, 62947, - 64743, 65308, 65476, 65522, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec2Ub12[20] = -{ - 0, 18, 40, 118, 332, 857, 2017, 4822, 11321, 24330, 41279, - 54342, 60637, 63394, 64659, 65184, 65398, 65482, 65518, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec3Ub12[28] = -{ - 0, 21, 38, 90, 196, 398, 770, 1400, 2589, 4650, 8211, - 14933, 26044, 39592, 50814, 57452, 60971, 62884, 63995, 64621, 65019, 65273, - 65410, 65480, 65514, 65522, 65531, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec4Ub12[20] = -{ - 0, 7, 46, 141, 403, 969, 2132, 4649, 10633, 24902, 43254, - 54665, 59928, 62674, 64173, 64938, 65293, 65464, 65523, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec5Ub12[25] = -{ - 0, 7, 22, 72, 174, 411, 854, 1737, 3545, 6774, 13165, - 25221, 40980, 52821, 58714, 61706, 63472, 64437, 64989, 65287, 65430, 65503, - 65525, 65529, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec6Ub12[33] = -{ - 0, 11, 21, 36, 65, 128, 228, 401, 707, 1241, 2126, - 3589, 6060, 10517, 18853, 31114, 42477, 49770, 54271, 57467, 59838, 61569, - 62831, 63772, 64433, 64833, 65123, 65306, 65419, 65466, 65499, 65519, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec7Ub12[49] = -{ - 0, 14, 34, 67, 107, 167, 245, 326, 449, 645, 861, - 1155, 1508, 2003, 2669, 3544, 4592, 5961, 7583, 9887, 13256, 18765, - 26519, 34077, 40034, 44349, 47795, 50663, 53262, 55473, 57458, 59122, 60592, - 61742, 62690, 63391, 63997, 64463, 64794, 65045, 65207, 65309, 65394, 65443, - 65478, 65504, 65514, 65523, 65535 -}; - -/* -* An array of pointers to CDFs of decorrelated LARs -*/ -const WebRtc_UWord16* WebRtcIsac_kLpcShapeCdfMatUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME] = -{ - WebRtcIsac_kLpcShapeCdfVec0Ub12, WebRtcIsac_kLpcShapeCdfVec1Ub12, - WebRtcIsac_kLpcShapeCdfVec2Ub12, WebRtcIsac_kLpcShapeCdfVec3Ub12, - WebRtcIsac_kLpcShapeCdfVec4Ub12, WebRtcIsac_kLpcShapeCdfVec5Ub12, - WebRtcIsac_kLpcShapeCdfVec6Ub12, WebRtcIsac_kLpcShapeCdfVec7Ub12 -};
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h b/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h deleted file mode 100644 index 1e93847..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.h +++ /dev/null
@@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_shape_swb12_tables.h - * - * This file declares tables used for entropy coding of LPC shape of - * upper-band signal if the bandwidth is 12 kHz. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_ - -#include "settings.h" -#include "typedefs.h" - -extern const double WebRtcIsac_kMeanLarUb12[UB_LPC_ORDER]; - -extern const double WebRtcIsac_kMeanLpcGain; - -extern const double WebRtcIsac_kIntraVecDecorrMatUb12[UB_LPC_ORDER][UB_LPC_ORDER]; - -extern const double WebRtcIsac_kInterVecDecorrMatUb12 -[UB_LPC_VEC_PER_FRAME][UB_LPC_VEC_PER_FRAME]; - -extern const double WebRtcIsac_kLpcShapeQStepSizeUb12; - -extern const double WebRtcIsac_kLpcShapeLeftRecPointUb12 -[UB_LPC_ORDER*UB_LPC_VEC_PER_FRAME]; - - -extern const WebRtc_Word16 WebRtcIsac_kLpcShapeNumRecPointUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeEntropySearchUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec0Ub12[14]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec1Ub12[16]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec2Ub12[20]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec3Ub12[28]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec4Ub12[20]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec5Ub12[25]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec6Ub12[33]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec7Ub12[49]; - -extern const WebRtc_UWord16* WebRtcIsac_kLpcShapeCdfMatUb12 -[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB12_TABLES_H_
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.c b/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.c deleted file mode 100644 index 89f4523..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.c +++ /dev/null
@@ -1,248 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * SWB16_KLT_Tables.c - * - * This file defines tables used for entropy coding of LPC shape of - * upper-band signal if the bandwidth is 16 kHz. - * - */ - -#include "lpc_shape_swb16_tables.h" -#include "settings.h" -#include "typedefs.h" - -/* -* Mean value of LAR -*/ -const double WebRtcIsac_kMeanLarUb16[UB_LPC_ORDER] = -{ -0.454978, 0.364747, 0.102999, 0.104523 -}; - -/* -* A rotation matrix to decorrelate intra-vector correlation, -* i.e. correlation among components of LAR vector. -*/ -const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER][UB_LPC_ORDER] = -{ - {-0.020528, -0.085858, -0.002431, 0.996093}, - {-0.033155, 0.036102, 0.998786, 0.004866}, - { 0.202627, 0.974853, -0.028940, 0.088132}, - {-0.978479, 0.202454, -0.039785, -0.002811} -}; - -/* -* A rotation matrix to remove correlation among LAR coefficients -* of different LAR vectors. One might guess that decorrelation matrix -* for the first component should differ from the second component -* but we haven't observed a significant benefit of having different -* decorrelation matrices for different components. -*/ -const double WebRtcIsac_kInterVecDecorrMatUb16 -[UB16_LPC_VEC_PER_FRAME][UB16_LPC_VEC_PER_FRAME] = -{ - { 0.291675, -0.515786, 0.644927, 0.482658}, - {-0.647220, 0.479712, 0.289556, 0.516856}, - { 0.643084, 0.485489, -0.289307, 0.516763}, - {-0.287185, -0.517823, -0.645389, 0.482553} -}; - -/* -* The following 16 vectors define CDF of 16 decorrelated LAR -* coefficients. -*/ -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub16[14] = -{ - 0, 2, 20, 159, 1034, 5688, 20892, 44653, - 59849, 64485, 65383, 65518, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec1Ub16[16] = -{ - 0, 1, 7, 43, 276, 1496, 6681, 21653, - 43891, 58859, 64022, 65248, 65489, 65529, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec2Ub16[18] = -{ - 0, 1, 9, 54, 238, 933, 3192, 9461, - 23226, 42146, 56138, 62413, 64623, 65300, 65473, 65521, - 65533, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec3Ub16[30] = -{ - 0, 2, 4, 8, 17, 36, 75, 155, - 329, 683, 1376, 2662, 5047, 9508, 17526, 29027, - 40363, 48997, 55096, 59180, 61789, 63407, 64400, 64967, - 65273, 65429, 65497, 65526, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec4Ub16[16] = -{ - 0, 1, 10, 63, 361, 1785, 7407, 22242, - 43337, 58125, 63729, 65181, 65472, 65527, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec5Ub16[17] = -{ - 0, 1, 7, 29, 134, 599, 2443, 8590, - 22962, 42635, 56911, 63060, 64940, 65408, 65513, 65531, - 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec6Ub16[21] = -{ - 0, 1, 5, 16, 57, 191, 611, 1808, - 4847, 11755, 24612, 40910, 53789, 60698, 63729, 64924, - 65346, 65486, 65523, 65532, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec7Ub16[36] = -{ - 0, 1, 4, 12, 25, 55, 104, 184, - 314, 539, 926, 1550, 2479, 3861, 5892, 8845, - 13281, 20018, 29019, 38029, 45581, 51557, 56057, 59284, - 61517, 63047, 64030, 64648, 65031, 65261, 65402, 65480, - 65518, 65530, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec8Ub16[21] = -{ - 0, 1, 2, 7, 26, 103, 351, 1149, - 3583, 10204, 23846, 41711, 55361, 61917, 64382, 65186, - 65433, 65506, 65528, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub160[21] = -{ - 0, 6, 19, 63, 205, 638, 1799, 4784, - 11721, 24494, 40803, 53805, 60886, 63822, 64931, 65333, - 65472, 65517, 65530, 65533, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub161[28] = -{ - 0, 1, 3, 11, 31, 86, 221, 506, - 1101, 2296, 4486, 8477, 15356, 26079, 38941, 49952, - 57165, 61257, 63426, 64549, 65097, 65351, 65463, 65510, - 65526, 65532, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub162[55] = -{ - 0, 3, 12, 23, 42, 65, 89, 115, - 150, 195, 248, 327, 430, 580, 784, 1099, - 1586, 2358, 3651, 5899, 9568, 14312, 19158, 23776, - 28267, 32663, 36991, 41153, 45098, 48680, 51870, 54729, - 57141, 59158, 60772, 62029, 63000, 63761, 64322, 64728, - 65000, 65192, 65321, 65411, 65463, 65496, 65514, 65523, - 65527, 65529, 65531, 65532, 65533, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub163[26] = -{ - 0, 2, 4, 10, 21, 48, 114, 280, - 701, 1765, 4555, 11270, 24267, 41213, 54285, 61003, - 63767, 64840, 65254, 65421, 65489, 65514, 65526, 65532, - 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub164[28] = -{ - 0, 1, 3, 6, 15, 36, 82, 196, - 453, 1087, 2557, 5923, 13016, 25366, 40449, 52582, - 59539, 62896, 64389, 65033, 65316, 65442, 65494, 65519, - 65529, 65533, 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub165[34] = -{ - 0, 2, 4, 8, 18, 35, 73, 146, - 279, 524, 980, 1789, 3235, 5784, 10040, 16998, - 27070, 38543, 48499, 55421, 59712, 62257, 63748, 64591, - 65041, 65278, 65410, 65474, 65508, 65522, 65530, 65533, - 65534, 65535 -}; - -const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub166[71] = -{ - 0, 1, 2, 6, 13, 26, 55, 92, - 141, 191, 242, 296, 355, 429, 522, 636, - 777, 947, 1162, 1428, 1753, 2137, 2605, 3140, - 3743, 4409, 5164, 6016, 6982, 8118, 9451, 10993, - 12754, 14810, 17130, 19780, 22864, 26424, 30547, 35222, - 40140, 44716, 48698, 52056, 54850, 57162, 59068, 60643, - 61877, 62827, 63561, 64113, 64519, 64807, 65019, 65167, - 65272, 65343, 65399, 65440, 65471, 65487, 65500, 65509, - 65518, 65524, 65527, 65531, 65533, 65534, 65535 -}; - -/* -* An array of pointers to CDFs of decorrelated LARs -*/ -const WebRtc_UWord16* WebRtcIsac_kLpcShapeCdfMatUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME] = { - WebRtcIsac_kLpcShapeCdfVec01Ub16, - WebRtcIsac_kLpcShapeCdfVec1Ub16, - WebRtcIsac_kLpcShapeCdfVec2Ub16, - WebRtcIsac_kLpcShapeCdfVec3Ub16, - WebRtcIsac_kLpcShapeCdfVec4Ub16, - WebRtcIsac_kLpcShapeCdfVec5Ub16, - WebRtcIsac_kLpcShapeCdfVec6Ub16, - WebRtcIsac_kLpcShapeCdfVec7Ub16, - WebRtcIsac_kLpcShapeCdfVec8Ub16, - WebRtcIsac_kLpcShapeCdfVec01Ub160, - WebRtcIsac_kLpcShapeCdfVec01Ub161, - WebRtcIsac_kLpcShapeCdfVec01Ub162, - WebRtcIsac_kLpcShapeCdfVec01Ub163, - WebRtcIsac_kLpcShapeCdfVec01Ub164, - WebRtcIsac_kLpcShapeCdfVec01Ub165, - WebRtcIsac_kLpcShapeCdfVec01Ub166 -}; - -/* -* The smallest reconstruction points for quantiztion of LAR coefficients. -*/ -const double WebRtcIsac_kLpcShapeLeftRecPointUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME] = -{ - -0.8250, -0.9750, -1.1250, -2.1750, -0.9750, -1.1250, -1.4250, - -2.6250, -1.4250, -1.2750, -1.8750, -3.6750, -1.7250, -1.8750, - -2.3250, -5.4750 -}; - -/* -* Number of reconstruction points of quantizers for LAR coefficients. -*/ -const WebRtc_Word16 WebRtcIsac_kLpcShapeNumRecPointUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME] = -{ - 13, 15, 17, 29, 15, 16, 20, 35, 20, - 20, 27, 54, 25, 27, 33, 70 -}; - -/* -* Starting index for entropy decoder to search for the right interval, -* one entry per LAR coefficient -*/ -const WebRtc_UWord16 WebRtcIsac_kLpcShapeEntropySearchUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME] = -{ - 6, 7, 8, 14, 7, 8, 10, 17, 10, - 10, 13, 27, 12, 13, 16, 35 -}; - -/* -* LAR quantization step-size. -*/ -const double WebRtcIsac_kLpcShapeQStepSizeUb16 = 0.150000;
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h b/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h deleted file mode 100644 index 68d08b2..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.h +++ /dev/null
@@ -1,79 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_shape_swb16_tables.h - * - * This file declares tables used for entropy coding of LPC shape of - * upper-band signal if the bandwidth is 16 kHz. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_ - -#include "settings.h" -#include "typedefs.h" - - -extern const double WebRtcIsac_kMeanLarUb16[UB_LPC_ORDER]; - -extern const double WebRtcIsac_kIintraVecDecorrMatUb16[UB_LPC_ORDER][UB_LPC_ORDER]; - -extern const double WebRtcIsac_kInterVecDecorrMatUb16 -[UB16_LPC_VEC_PER_FRAME][UB16_LPC_VEC_PER_FRAME]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub16[14]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec1Ub16[16]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec2Ub16[18]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec3Ub16[30]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec4Ub16[16]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec5Ub16[17]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec6Ub16[21]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec7Ub16[36]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec8Ub16[21]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub160[21]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub161[28]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub162[55]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub163[26]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub164[28]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub165[34]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeCdfVec01Ub166[71]; - -extern const WebRtc_UWord16* WebRtcIsac_kLpcShapeCdfMatUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - -extern const double WebRtcIsac_kLpcShapeLeftRecPointUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - -extern const WebRtc_Word16 WebRtcIsac_kLpcShapeNumRecPointUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - -extern const WebRtc_UWord16 WebRtcIsac_kLpcShapeEntropySearchUb16 -[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - -extern const double WebRtcIsac_kLpcShapeQStepSizeUb16; - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_SHAPE_SWB16_TABLES_H_
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_tables.c b/src/modules/audio_coding/codecs/isac/main/source/lpc_tables.c deleted file mode 100644 index 985e43c..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_tables.c +++ /dev/null
@@ -1,601 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* coding tables for the KLT coefficients */ - -#include "lpc_tables.h" -#include "settings.h" - -/* cdf array for model indicator */ -const WebRtc_UWord16 WebRtcIsac_kQKltModelCdf[4] = { - 0, 15434, 37548, 65535 }; - -/* pointer to cdf array for model indicator */ -const WebRtc_UWord16 *WebRtcIsac_kQKltModelCdfPtr[1] = { - WebRtcIsac_kQKltModelCdf }; - -/* initial cdf index for decoder of model indicator */ -const WebRtc_UWord16 WebRtcIsac_kQKltModelInitIndex[1] = { 1 }; - -/* offset to go from rounded value to quantization index */ -const short WebRtcIsac_kQKltQuantMinGain[12] = { - 3, 6, 4, 6, 6, 9, 5, 16, 11, 34, 32, 47 }; - - -const short WebRtcIsac_kQKltQuantMinShape[108] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 2, 2, 2, 3, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 2, 2, 3, 0, 0, 0, 0, - 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 4, 3, 5, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 2, 1, 2, 2, 3, 4, - 4, 7, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 2, 3, 2, 3, 4, 4, 5, 7, 13, - 0, 1, 1, 2, 3, 2, 2, 2, 4, 4, - 5, 6, 7, 11, 9, 13, 12, 26 }; - -/* maximum quantization index */ -const WebRtc_UWord16 WebRtcIsac_kQKltMaxIndGain[12] = { - 6, 12, 8, 14, 10, 19, 12, 31, 22, 56, 52, 138 }; - -const WebRtc_UWord16 WebRtcIsac_kQKltMaxIndShape[108] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 2, 2, 2, 2, 4, 4, 5, 6, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 2, 2, - 2, 2, 3, 4, 5, 7, 0, 0, 0, 0, - 2, 0, 2, 2, 2, 2, 3, 2, 2, 4, - 4, 6, 6, 9, 0, 0, 0, 0, 2, 2, - 2, 2, 2, 2, 3, 2, 4, 4, 7, 7, - 9, 13, 0, 0, 2, 2, 2, 2, 2, 2, - 3, 4, 5, 4, 6, 8, 8, 10, 16, 25, - 0, 2, 2, 4, 5, 4, 4, 4, 7, 8, - 9, 10, 13, 19, 17, 23, 25, 49 }; - -/* index offset */ -const WebRtc_UWord16 WebRtcIsac_kQKltOffsetGain[12] = { - 0, 7, 20, 29, 44, 55, 75, 88, 120, 143, 200, 253 }; - -const WebRtc_UWord16 WebRtcIsac_kQKltOffsetShape[108] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 11, 14, 17, 20, 23, 28, 33, 39, 46, 47, - 48, 49, 50, 52, 53, 54, 55, 56, 58, 61, - 64, 67, 70, 74, 79, 85, 93, 94, 95, 96, - 97, 100, 101, 104, 107, 110, 113, 117, 120, 123, - 128, 133, 140, 147, 157, 158, 159, 160, 161, 164, - 167, 170, 173, 176, 179, 183, 186, 191, 196, 204, - 212, 222, 236, 237, 238, 241, 244, 247, 250, 253, - 256, 260, 265, 271, 276, 283, 292, 301, 312, 329, - 355, 356, 359, 362, 367, 373, 378, 383, 388, 396, - 405, 415, 426, 440, 460, 478, 502, 528 }; - -/* initial cdf index for KLT coefficients */ -const WebRtc_UWord16 WebRtcIsac_kQKltInitIndexGain[12] = { - 3, 6, 4, 7, 5, 10, 6, 16, 11, 28, 26, 69}; - -const WebRtc_UWord16 WebRtcIsac_kQKltInitIndexShape[108] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 2, 2, 3, 3, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 2, 2, 3, 4, 0, 0, 0, 0, - 1, 0, 1, 1, 1, 1, 2, 1, 1, 2, - 2, 3, 3, 5, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 1, 2, 1, 2, 2, 4, 4, - 5, 7, 0, 0, 1, 1, 1, 1, 1, 1, - 2, 2, 3, 2, 3, 4, 4, 5, 8, 13, - 0, 1, 1, 2, 3, 2, 2, 2, 4, 4, - 5, 5, 7, 10, 9, 12, 13, 25 }; - - -/* quantizer representation levels */ -const double WebRtcIsac_kQKltLevelsGain[392] = { - -2.78127126, -1.76745590, -0.77913790, -0.00437329, 0.79961206, - 1.81775776, 2.81389782, -5.78753143, -4.88384084, -3.89320940, - -2.88133610, -1.92859977, -0.86347396, 0.02003888, 0.86140400, - 1.89667156, 2.97134967, 3.98781964, 4.91727277, 5.82865898, - -4.11195874, -2.80898424, -1.87547977, -0.80943825, -0.00679084, - 0.79573851, 1.83953397, 2.67586037, 3.76274082, -6.10933968, - -4.93034581, -3.89281296, -2.91530625, -1.89684163, -0.85319130, - -0.02275767, 0.86862017, 1.91578276, 2.96107339, 3.96543056, - 4.91369908, 5.91058154, 6.83848343, 8.07136925, -5.87470395, - -4.84703049, -3.84284597, -2.86168446, -1.89290192, -0.82798145, - -0.00080013, 0.82594974, 1.85754329, 2.88351798, 3.96172628, - -8.85684885, -7.87387461, -6.97811862, -5.93256270, -4.94301439, - -3.95513701, -2.96041544, -1.94031192, -0.87961478, -0.00456201, - 0.89911505, 1.91723376, 2.94011511, 3.93302540, 4.97990967, - 5.93133404, 7.02181199, 7.92407762, 8.80155440, 10.04665814, - -4.82396678, -3.85612158, -2.89482244, -1.89558408, -0.90036978, - -0.00677823, 0.90607989, 1.90937981, 2.91175777, 3.91637730, - 4.97565723, 5.84771228, 7.11145863, -16.07879840, -15.03776309, - -13.93905670, -12.95671800, -11.89171202, -10.95820934, -9.95923714, - -8.94357334, -7.99068299, -6.97481009, -5.94826231, -4.96673988, - -3.97490466, -2.97846970, -1.95130435, -0.94215262, -0.01444043, - 0.96770704, 1.95848598, 2.94107862, 3.95666119, 4.97253085, - 5.97191122, 6.93277360, 7.96608727, 8.87958779, 10.00264269, - 10.86560820, 12.07449071, 13.04491775, 13.97507061, 14.91845261, - -10.85696295, -9.83365357, -9.01245635, -7.95915145, -6.95625003, - -5.95362618, -4.93468444, -3.98760978, -2.95044407, -1.97041277, - -0.97701799, -0.00840234, 0.97834289, 1.98361415, 2.97802439, - 3.96415871, 4.95369042, 5.94101770, 6.92756798, 7.94063998, - 8.85951828, 9.97077022, 11.00068503, -33.92030406, -32.81426422, - -32.00000000, -31.13243639, -30.11886909, -29.06017570, -28.12598824, - -27.22045482, -25.81215858, -25.07849962, -23.93018013, -23.02097643, - -21.89529725, -20.99091085, -19.98889048, -18.94327044, -17.96562071, - -16.96126218, -15.95054062, -14.98516200, -13.97101012, -13.02106500, - -11.98438006, -11.03216748, -9.95930286, -8.97043946, -7.98085082, - -6.98360995, -5.98998802, -4.98668173, -4.00032906, -3.00420619, - -1.98701132, -0.99324682, -0.00609324, 0.98297834, 1.99483076, - 3.00305044, 3.97142097, 4.97525759, 5.98612258, 6.97448236, - 7.97575900, 9.01086211, 9.98665542, 11.00541438, 11.98078628, - 12.92352471, 14.06849675, 14.99949430, 15.94904834, 16.97440321, - 18.04040916, 18.88987609, 20.05312391, 21.00000000, 21.79443341, - -31.98578825, -31.00000000, -29.89060567, -28.98555686, -27.97114102, - -26.84935410, -26.02402230, -24.94195278, -23.92336849, -22.95552382, - -21.97932836, -20.96055470, -19.99649553, -19.03436122, -17.96706525, - -17.01139515, -16.01363516, -14.99154248, -14.00298333, -12.99630613, - -11.99955519, -10.99000421, -10.00819092, -8.99763648, -7.98431793, - -7.01769025, -5.99604690, -4.99980697, -3.99334671, -3.01748192, - -2.02051217, -1.00848371, -0.01942358, 1.00477757, 1.95477872, - 2.98593031, 3.98779079, 4.96862849, 6.02694771, 6.93983733, - 7.89874717, 8.99615862, 10.02367921, 10.96293452, 11.84351528, - 12.92207187, 13.85122329, 15.05146877, 15.99371264, 17.00000000, - 18.00000000, 19.00000000, 19.82763573, -47.00000000, -46.00000000, - -44.87138498, -44.00000000, -43.00000000, -42.00000000, -41.00000000, - -39.88966612, -38.98913239, -37.80306486, -37.23584325, -35.94200288, - -34.99881301, -34.11361858, -33.06507360, -32.13129135, -30.90891364, - -29.81511907, -28.99250380, -28.04535391, -26.99767800, -26.04418164, - -24.95687851, -24.04865595, -23.03392645, -21.89366707, -20.93517364, - -19.99388660, -18.91620943, -18.03749683, -16.99532379, -15.98683813, - -15.06421479, -13.99359211, -12.99714098, -11.97022520, -10.98500279, - -9.98834422, -8.95729330, -8.01232284, -7.00253661, -5.99681626, - -5.01207817, -3.95914904, -3.01232178, -1.96615919, -0.97687670, - 0.01228030, 0.98412288, 2.01753544, 3.00580570, 3.97783510, - 4.98846894, 6.01321400, 7.00867732, 8.00416375, 9.01771966, - 9.98637729, 10.98255180, 11.99194163, 13.01807333, 14.00999545, - 15.00118556, 16.00089224, 17.00584148, 17.98251763, 18.99942091, - 19.96917690, 20.97839265, 21.98207297, 23.00171271, 23.99930737, - 24.99746061, 26.00936304, 26.98240132, 28.01126868, 29.01395915, - 29.98153507, 31.01376711, 31.99876818, 33.00475317, 33.99753994, - 34.99493913, 35.98933585, 36.95620160, 37.98428461, 38.99317544, - 40.01832073, 40.98048133, 41.95999283, 42.98232091, 43.96523612, - 44.99574268, 45.99524194, 47.05464025, 48.03821548, 48.99354366, - 49.96400411, 50.98017973, 51.95184408, 52.96291806, 54.00194392, - 54.96603783, 55.95623778, 57.03076595, 58.05889901, 58.99081551, - 59.97928121, 61.05071612, 62.03971580, 63.01286038, 64.01290338, - 65.02074503, 65.99454594, 67.00399425, 67.96571257, 68.95305727, - 69.92030664, 70.95594862, 71.98088567, 73.04764124, 74.00285480, - 75.02696330, 75.89837673, 76.93459997, 78.16266309, 78.83317543, - 80.00000000, 80.87251574, 82.09803524, 83.10671664, 84.00000000, - 84.77023523, 86.00000000, 87.00000000, 87.92946897, 88.69159118, - 90.00000000, 90.90535270 }; - -const double WebRtcIsac_kQKltLevelsShape[578] = { - 0.00032397, 0.00008053, -0.00061202, -0.00012620, 0.00030437, - 0.00054764, -0.00027902, 0.00069360, 0.00029449, -0.80219239, - 0.00091089, -0.74514927, -0.00094283, 0.64030631, -0.60509119, - 0.00035575, 0.61851665, -0.62129957, 0.00375219, 0.60054900, - -0.61554359, 0.00054977, 0.63362016, -1.73118727, -0.65422341, - 0.00524568, 0.66165298, 1.76785515, -1.83182018, -0.65997434, - -0.00011887, 0.67524299, 1.79933938, -1.76344480, -0.72547708, - -0.00133017, 0.73104704, 1.75305377, 2.85164534, -2.80423916, - -1.71959639, -0.75419722, -0.00329945, 0.77196760, 1.72211069, - 2.87339653, 0.00031089, -0.00015311, 0.00018201, -0.00035035, - -0.77357251, 0.00154647, -0.00047625, -0.00045299, 0.00086590, - 0.00044762, -0.83383829, 0.00024787, -0.68526258, -0.00122472, - 0.64643255, -0.60904942, -0.00448987, 0.62309184, -0.59626442, - -0.00574132, 0.62296546, -0.63222115, 0.00013441, 0.63609545, - -0.66911055, -0.00369971, 0.66346095, 2.07281301, -1.77184694, - -0.67640425, -0.00010145, 0.64818392, 1.74948973, -1.69420224, - -0.71943894, -0.00004680, 0.75303493, 1.81075983, 2.80610041, - -2.80005755, -1.79866753, -0.77409777, -0.00084220, 0.80141293, - 1.78291081, 2.73954236, 3.82994169, 0.00015140, -0.00012766, - -0.00034241, -0.00119125, -0.76113497, 0.00069246, 0.76722027, - 0.00132862, -0.69107530, 0.00010656, 0.77061578, -0.78012970, - 0.00095947, 0.77828502, -0.64787758, 0.00217168, 0.63050167, - -0.58601125, 0.00306596, 0.59466308, -0.58603410, 0.00059779, - 0.64257970, 1.76512766, -0.61193600, -0.00259517, 0.59767574, - -0.61026273, 0.00315811, 0.61725479, -1.69169719, -0.65816029, - 0.00067575, 0.65576890, 2.00000000, -1.72689193, -0.69780808, - -0.00040990, 0.70668487, 1.74198458, -3.79028154, -3.00000000, - -1.73194459, -0.70179341, -0.00106695, 0.71302629, 1.76849782, - -2.89332364, -1.78585007, -0.78731491, -0.00132610, 0.79692976, - 1.75247009, 2.97828682, -5.26238694, -3.69559829, -2.87286122, - -1.84908818, -0.84434577, -0.01167975, 0.84641753, 1.84087672, - 2.87628156, 3.83556679, -0.00190204, 0.00092642, 0.00354385, - -0.00012982, -0.67742785, 0.00229509, 0.64935672, -0.58444751, - 0.00470733, 0.57299534, -0.58456202, -0.00097715, 0.64593607, - -0.64060330, -0.00638534, 0.59680157, -0.59287537, 0.00490772, - 0.58919707, -0.60306173, -0.00417464, 0.60562100, -1.75218757, - -0.63018569, -0.00225922, 0.63863300, -0.63949939, -0.00126421, - 0.64268914, -1.75851182, -0.68318060, 0.00510418, 0.69049211, - 1.88178506, -1.71136148, -0.72710534, -0.00815559, 0.73412917, - 1.79996711, -2.77111145, -1.73940498, -0.78212945, 0.01074476, - 0.77688916, 1.76873972, 2.87281379, 3.77554698, -3.75832725, - -2.95463235, -1.80451491, -0.80017226, 0.00149902, 0.80729206, - 1.78265046, 2.89391793, -3.78236148, -2.83640598, -1.82532067, - -0.88844327, -0.00620952, 0.88208030, 1.85757631, 2.81712391, - 3.88430176, 5.16179367, -7.00000000, -5.93805408, -4.87172597, - -3.87524433, -2.89399744, -1.92359563, -0.92136341, -0.00172725, - 0.93087018, 1.90528280, 2.89809686, 3.88085708, 4.89147740, - 5.89078692, -0.00239502, 0.00312564, -1.00000000, 0.00178325, - 1.00000000, -0.62198029, 0.00143254, 0.65344051, -0.59851220, - -0.00676987, 0.61510140, -0.58894151, 0.00385055, 0.59794203, - -0.59808568, -0.00038214, 0.57625703, -0.63009713, -0.01107985, - 0.61278758, -0.64206758, -0.00154369, 0.65480598, 1.80604162, - -1.80909286, -0.67810514, 0.00205762, 0.68571097, 1.79453891, - -3.22682422, -1.73808453, -0.71870305, -0.00738594, 0.71486172, - 1.73005326, -1.66891897, -0.73689615, -0.00616203, 0.74262409, - 1.73807899, -2.92417482, -1.73866741, -0.78133871, 0.00764425, - 0.80027264, 1.78668732, 2.74992588, -4.00000000, -2.75578740, - -1.83697516, -0.83117035, -0.00355191, 0.83527172, 1.82814700, - 2.77377675, 3.80718693, -3.81667698, -2.83575471, -1.83372350, - -0.86579471, 0.00547578, 0.87582281, 1.82858793, 2.87265007, - 3.91405377, -4.87521600, -3.78999094, -2.86437014, -1.86964365, - -0.90618018, 0.00128243, 0.91497811, 1.87374952, 2.83199819, - 3.91519130, 4.76632822, -6.68713448, -6.01252467, -4.94587936, - -3.88795368, -2.91299088, -1.92592211, -0.95504570, -0.00089980, - 0.94565200, 1.93239633, 2.91832808, 3.91363475, 4.88920034, - 5.96471415, 6.83905252, 7.86195009, 8.81571018,-12.96141759, - -11.73039516,-10.96459719, -9.97382433, -9.04414433, -7.89460619, - -6.96628608, -5.93236595, -4.93337924, -3.95479990, -2.96451499, - -1.96635876, -0.97271229, -0.00402238, 0.98343930, 1.98348291, - 2.96641164, 3.95456471, 4.95517089, 5.98975714, 6.90322073, - 7.90468849, 8.85639467, 9.97255498, 10.79006309, 11.81988596, - 0.04950500, -1.00000000, -0.01226628, 1.00000000, -0.59479469, - -0.10438305, 0.59822144, -2.00000000, -0.67109149, -0.09256692, - 0.65171621, 2.00000000, -3.00000000, -1.68391999, -0.76681039, - -0.03354151, 0.71509146, 1.77615472, -2.00000000, -0.68661511, - -0.02497881, 0.66478398, 2.00000000, -2.00000000, -0.67032784, - -0.00920582, 0.64892756, 2.00000000, -2.00000000, -0.68561894, - 0.03641869, 0.73021611, 1.68293863, -4.00000000, -2.72024184, - -1.80096059, -0.81696185, 0.03604685, 0.79232033, 1.70070730, - 3.00000000, -4.00000000, -2.71795670, -1.80482986, -0.86001162, - 0.03764903, 0.87723968, 1.79970771, 2.72685932, 3.67589143, - -5.00000000, -4.00000000, -2.85492548, -1.78996365, -0.83250358, - -0.01376828, 0.84195506, 1.78161105, 2.76754458, 4.00000000, - -6.00000000, -5.00000000, -3.82268811, -2.77563624, -1.82608163, - -0.86486114, -0.02671886, 0.86693165, 1.88422879, 2.86248347, - 3.95632216, -7.00000000, -6.00000000, -5.00000000, -3.77533988, - -2.86391432, -1.87052039, -0.90513658, 0.06271236, 0.91083620, - 1.85734756, 2.86031688, 3.82019418, 4.94420394, 6.00000000, - -11.00000000,-10.00000000, -9.00000000, -8.00000000, -6.91952415, - -6.00000000, -4.92044374, -3.87845165, -2.87392362, -1.88413020, - -0.91915740, 0.00318517, 0.91602800, 1.89664838, 2.88925058, - 3.84123856, 4.78988651, 5.94526812, 6.81953917, 8.00000000, - -9.00000000, -8.00000000, -7.03319143, -5.94530963, -4.86669720, - -3.92438007, -2.88620396, -1.92848070, -0.94365985, 0.01671855, - 0.97349410, 1.93419878, 2.89740109, 3.89662823, 4.83235583, - 5.88106535, 6.80328232, 8.00000000,-13.00000000,-12.00000000, - -11.00000000,-10.00000000, -9.00000000, -7.86033489, -6.83344055, - -5.89844215, -4.90811454, -3.94841298, -2.95820490, -1.98627966, - -0.99161468, -0.02286136, 0.96055651, 1.95052433, 2.93969396, - 3.94304346, 4.88522624, 5.87434241, 6.78309433, 7.87244101, - 9.00000000, 10.00000000,-12.09117356,-11.00000000,-10.00000000, - -8.84766108, -7.86934236, -6.98544896, -5.94233429, -4.95583292, - -3.95575986, -2.97085529, -1.98955811, -0.99359873, -0.00485413, - 0.98298870, 1.98093258, 2.96430203, 3.95540216, 4.96915010, - 5.96775124, 6.99236918, 7.96503302, 8.99864542, 9.85857723, - 10.96541926, 11.91647197, 12.71060069,-26.00000000,-25.00000000, - -24.00585596,-23.11642573,-22.14271284,-20.89800711,-19.87815799, - -19.05036354,-17.88555651,-16.86471209,-15.97711073,-14.94012359, - -14.02661226,-12.98243228,-11.97489256,-10.97402777, -9.96425624, - -9.01085220, -7.97372506, -6.98795002, -5.97271328, -5.00191694, - -3.98055849, -2.98458048, -1.99470442, -0.99656768, -0.00825666, - 1.00272004, 1.99922218, 2.99357669, 4.01407905, 5.01003897, - 5.98115528, 7.00018958, 8.00338125, 8.98981046, 9.98990318, - 10.96341479, 11.96866930, 12.99175139, 13.94580443, 14.95745083, - 15.98992869, 16.97484646, 17.99630043, 18.93396897, 19.88347741, - 20.96532482, 21.92191032, 23.22314702 }; - - -/* cdf tables for quantizer indices */ -const WebRtc_UWord16 WebRtcIsac_kQKltCdfGain[404] = { - 0, 13, 301, 3730, 61784, 65167, 65489, 65535, 0, 17, - 142, 314, 929, 2466, 7678, 56450, 63463, 64740, 65204, 65426, - 65527, 65535, 0, 8, 100, 724, 6301, 60105, 65125, 65510, - 65531, 65535, 0, 13, 117, 368, 1068, 3010, 11928, 53603, - 61177, 63404, 64505, 65108, 65422, 65502, 65531, 65535, 0, 4, - 17, 96, 410, 1859, 12125, 54361, 64103, 65305, 65497, 65535, - 0, 4, 88, 230, 469, 950, 1746, 3228, 6092, 16592, - 44756, 56848, 61256, 63308, 64325, 64920, 65309, 65460, 65502, - 65522, 65535, 0, 88, 352, 1675, 6339, 20749, 46686, 59284, 63525, - 64949, 65359, 65502, 65527, 65535, 0, 13, 38, 63, 117, - 234, 381, 641, 929, 1407, 2043, 2809, 4032, 5753, 8792, - 14407, 24308, 38941, 48947, 55403, 59293, 61411, 62688, 63630, - 64329, 64840, 65188, 65376, 65472, 65506, 65527, 65531, 65535, - 0, 8, 29, 75, 222, 615, 1327, 2801, 5623, 9931, 16094, 24966, - 34419, 43458, 50676, 56186, 60055, 62500, 63936, 64765, 65225, - 65435, 65514, 65535, 0, 8, 13, 15, 17, 21, 33, 59, - 71, 92, 151, 243, 360, 456, 674, 934, 1223, 1583, - 1989, 2504, 3031, 3617, 4354, 5154, 6163, 7411, 8780, 10747, - 12874, 15591, 18974, 23027, 27436, 32020, 36948, 41830, 46205, - 49797, 53042, 56094, 58418, 60360, 61763, 62818, 63559, 64103, - 64509, 64798, 65045, 65162, 65288, 65363, 65447, 65506, 65522, - 65531, 65533, 65535, 0, 4, 6, 25, 38, 71, 138, 264, 519, 808, - 1227, 1825, 2516, 3408, 4279, 5560, 7092, 9197, 11420, 14108, - 16947, 20300, 23926, 27459, 31164, 34827, 38575, 42178, 45540, - 48747, 51444, 54090, 56426, 58460, 60080, 61595, 62734, 63668, - 64275, 64673, 64936, 65112, 65217, 65334, 65426, 65464, 65477, - 65489, 65518, 65527, 65529, 65531, 65533, 65535, 0, 2, 4, 8, 10, - 12, 14, 16, 21, 33, 50, 71, 84, 92, 105, 138, 180, 255, 318, - 377, 435, 473, 511, 590, 682, 758, 913, 1097, 1256, 1449, 1671, - 1884, 2169, 2445, 2772, 3157, 3563, 3944, 4375, 4848, 5334, 5820, - 6448, 7101, 7716, 8378, 9102, 9956, 10752, 11648, 12707, 13670, - 14758, 15910, 17187, 18472, 19627, 20649, 21951, 23169, 24283, - 25552, 26862, 28227, 29391, 30764, 31882, 33213, 34432, 35600, - 36910, 38116, 39464, 40729, 41872, 43144, 44371, 45514, 46762, - 47813, 48968, 50069, 51032, 51974, 52908, 53737, 54603, 55445, - 56282, 56990, 57572, 58191, 58840, 59410, 59887, 60264, 60607, - 60946, 61269, 61516, 61771, 61960, 62198, 62408, 62558, 62776, - 62985, 63207, 63408, 63546, 63739, 63906, 64070, 64237, 64371, - 64551, 64677, 64836, 64999, 65095, 65213, 65284, 65338, 65380, - 65426, 65447, 65472, 65485, 65487, 65489, 65502, 65510, 65512, - 65514, 65516, 65518, 65522, 65531, 65533, 65535 }; - - -const WebRtc_UWord16 WebRtcIsac_kQKltCdfShape[686] = { - 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, - 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, 4, - 65535, 0, 8, 65514, 65535, 0, 29, 65481, 65535, 0, - 121, 65439, 65535, 0, 239, 65284, 65535, 0, 8, 779, - 64999, 65527, 65535, 0, 8, 888, 64693, 65522, 65535, 0, - 29, 2604, 62843, 65497, 65531, 65535, 0, 25, 176, 4576, - 61164, 65275, 65527, 65535, 0, 65535, 0, 65535, 0, 65535, - 0, 65535, 0, 4, 65535, 0, 65535, 0, 65535, 0, - 65535, 0, 65535, 0, 4, 65535, 0, 33, 65502, 65535, - 0, 54, 65481, 65535, 0, 251, 65309, 65535, 0, 611, - 65074, 65535, 0, 1273, 64292, 65527, 65535, 0, 4, 1809, - 63940, 65518, 65535, 0, 88, 4392, 60603, 65426, 65531, 65535, - 0, 25, 419, 7046, 57756, 64961, 65514, 65531, 65535, 0, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 4, 65531, - 65535, 0, 65535, 0, 8, 65531, 65535, 0, 4, 65527, - 65535, 0, 17, 65510, 65535, 0, 42, 65481, 65535, 0, - 197, 65342, 65531, 65535, 0, 385, 65154, 65535, 0, 1005, - 64522, 65535, 0, 8, 1985, 63469, 65533, 65535, 0, 38, - 3119, 61884, 65514, 65535, 0, 4, 6, 67, 4961, 60804, - 65472, 65535, 0, 17, 565, 9182, 56538, 65087, 65514, 65535, - 0, 8, 63, 327, 2118, 14490, 52774, 63839, 65376, 65522, - 65535, 0, 65535, 0, 65535, 0, 65535, 0, 65535, 0, - 17, 65522, 65535, 0, 59, 65489, 65535, 0, 50, 65522, - 65535, 0, 54, 65489, 65535, 0, 310, 65179, 65535, 0, - 615, 64836, 65535, 0, 4, 1503, 63965, 65535, 0, 2780, - 63383, 65535, 0, 21, 3919, 61051, 65527, 65535, 0, 84, - 6674, 59929, 65435, 65535, 0, 4, 255, 7976, 55784, 65150, - 65518, 65531, 65535, 0, 4, 8, 582, 10726, 53465, 64949, - 65518, 65535, 0, 29, 339, 3006, 17555, 49517, 62956, 65200, - 65497, 65531, 65535, 0, 2, 33, 138, 565, 2324, 7670, - 22089, 45966, 58949, 63479, 64966, 65380, 65518, 65535, 0, 65535, - 0, 65535, 0, 2, 65533, 65535, 0, 46, 65514, 65535, - 0, 414, 65091, 65535, 0, 540, 64911, 65535, 0, 419, - 65162, 65535, 0, 976, 64790, 65535, 0, 2977, 62495, 65531, - 65535, 0, 4, 3852, 61034, 65527, 65535, 0, 4, 29, - 6021, 60243, 65468, 65535, 0, 84, 6711, 58066, 65418, 65535, - 0, 13, 281, 9550, 54917, 65125, 65506, 65535, 0, 2, - 63, 984, 12108, 52644, 64342, 65435, 65527, 65535, 0, 29, - 251, 2014, 14871, 47553, 62881, 65229, 65518, 65535, 0, 13, - 142, 749, 4220, 18497, 45200, 60913, 64823, 65426, 65527, 65535, - 0, 13, 71, 264, 1176, 3789, 10500, 24480, 43488, 56324, - 62315, 64493, 65242, 65464, 65514, 65522, 65531, 65535, 0, 4, - 13, 38, 109, 205, 448, 850, 1708, 3429, 6276, 11371, - 19221, 29734, 40955, 49391, 55411, 59460, 62102, 63793, 64656, - 65150, 65401, 65485, 65522, 65531, 65535, 0, 65535, 0, 2, 65533, - 65535, 0, 1160, 65476, 65535, 0, 2, 6640, 64763, 65533, - 65535, 0, 2, 38, 9923, 61009, 65527, 65535, 0, 2, - 4949, 63092, 65533, 65535, 0, 2, 3090, 63398, 65533, 65535, - 0, 2, 2520, 58744, 65510, 65535, 0, 2, 13, 544, - 8784, 51403, 65148, 65533, 65535, 0, 2, 25, 1017, 10412, - 43550, 63651, 65489, 65527, 65535, 0, 2, 4, 29, 783, - 13377, 52462, 64524, 65495, 65533, 65535, 0, 2, 4, 6, - 100, 1817, 18451, 52590, 63559, 65376, 65531, 65535, 0, 2, - 4, 6, 46, 385, 2562, 11225, 37416, 60488, 65026, 65487, - 65529, 65533, 65535, 0, 2, 4, 6, 8, 10, 12, - 42, 222, 971, 5221, 19811, 45048, 60312, 64486, 65294, 65474, - 65525, 65529, 65533, 65535, 0, 2, 4, 8, 71, 167, - 666, 2533, 7875, 19622, 38082, 54359, 62108, 64633, 65290, 65495, - 65529, 65533, 65535, 0, 2, 4, 6, 8, 10, 13, - 109, 586, 1930, 4949, 11600, 22641, 36125, 48312, 56899, 61495, - 63927, 64932, 65389, 65489, 65518, 65531, 65533, 65535, 0, 4, - 6, 8, 67, 209, 712, 1838, 4195, 8432, 14432, 22834, - 31723, 40523, 48139, 53929, 57865, 60657, 62403, 63584, 64363, - 64907, 65167, 65372, 65472, 65514, 65535, 0, 2, 4, 13, 25, - 42, 46, 50, 75, 113, 147, 281, 448, 657, 909, - 1185, 1591, 1976, 2600, 3676, 5317, 7398, 9914, 12941, 16169, - 19477, 22885, 26464, 29851, 33360, 37228, 41139, 44802, 48654, - 52058, 55181, 57676, 59581, 61022, 62190, 63107, 63676, 64199, - 64547, 64924, 65158, 65313, 65430, 65481, 65518, 65535 }; - - -/* pointers to cdf tables for quantizer indices */ -const WebRtc_UWord16 *WebRtcIsac_kQKltCdfPtrGain[12] = { - WebRtcIsac_kQKltCdfGain +0 +0, WebRtcIsac_kQKltCdfGain +0 +8, - WebRtcIsac_kQKltCdfGain +0 +22, WebRtcIsac_kQKltCdfGain +0 +32, - WebRtcIsac_kQKltCdfGain +0 +48, WebRtcIsac_kQKltCdfGain +0 +60, - WebRtcIsac_kQKltCdfGain +0 +81, WebRtcIsac_kQKltCdfGain +0 +95, - WebRtcIsac_kQKltCdfGain +0 +128, WebRtcIsac_kQKltCdfGain +0 +152, - WebRtcIsac_kQKltCdfGain +0 +210, WebRtcIsac_kQKltCdfGain +0 +264 }; - -const WebRtc_UWord16 *WebRtcIsac_kQKltCdfPtrShape[108] = { - WebRtcIsac_kQKltCdfShape +0 +0, WebRtcIsac_kQKltCdfShape +0 +2, - WebRtcIsac_kQKltCdfShape +0 +4, WebRtcIsac_kQKltCdfShape +0 +6, - WebRtcIsac_kQKltCdfShape +0 +8, WebRtcIsac_kQKltCdfShape +0 +10, - WebRtcIsac_kQKltCdfShape +0 +12, WebRtcIsac_kQKltCdfShape +0 +14, - WebRtcIsac_kQKltCdfShape +0 +16, WebRtcIsac_kQKltCdfShape +0 +18, - WebRtcIsac_kQKltCdfShape +0 +21, WebRtcIsac_kQKltCdfShape +0 +25, - WebRtcIsac_kQKltCdfShape +0 +29, WebRtcIsac_kQKltCdfShape +0 +33, - WebRtcIsac_kQKltCdfShape +0 +37, WebRtcIsac_kQKltCdfShape +0 +43, - WebRtcIsac_kQKltCdfShape +0 +49, WebRtcIsac_kQKltCdfShape +0 +56, - WebRtcIsac_kQKltCdfShape +0 +64, WebRtcIsac_kQKltCdfShape +0 +66, - WebRtcIsac_kQKltCdfShape +0 +68, WebRtcIsac_kQKltCdfShape +0 +70, - WebRtcIsac_kQKltCdfShape +0 +72, WebRtcIsac_kQKltCdfShape +0 +75, - WebRtcIsac_kQKltCdfShape +0 +77, WebRtcIsac_kQKltCdfShape +0 +79, - WebRtcIsac_kQKltCdfShape +0 +81, WebRtcIsac_kQKltCdfShape +0 +83, - WebRtcIsac_kQKltCdfShape +0 +86, WebRtcIsac_kQKltCdfShape +0 +90, - WebRtcIsac_kQKltCdfShape +0 +94, WebRtcIsac_kQKltCdfShape +0 +98, - WebRtcIsac_kQKltCdfShape +0 +102, WebRtcIsac_kQKltCdfShape +0 +107, - WebRtcIsac_kQKltCdfShape +0 +113, WebRtcIsac_kQKltCdfShape +0 +120, - WebRtcIsac_kQKltCdfShape +0 +129, WebRtcIsac_kQKltCdfShape +0 +131, - WebRtcIsac_kQKltCdfShape +0 +133, WebRtcIsac_kQKltCdfShape +0 +135, - WebRtcIsac_kQKltCdfShape +0 +137, WebRtcIsac_kQKltCdfShape +0 +141, - WebRtcIsac_kQKltCdfShape +0 +143, WebRtcIsac_kQKltCdfShape +0 +147, - WebRtcIsac_kQKltCdfShape +0 +151, WebRtcIsac_kQKltCdfShape +0 +155, - WebRtcIsac_kQKltCdfShape +0 +159, WebRtcIsac_kQKltCdfShape +0 +164, - WebRtcIsac_kQKltCdfShape +0 +168, WebRtcIsac_kQKltCdfShape +0 +172, - WebRtcIsac_kQKltCdfShape +0 +178, WebRtcIsac_kQKltCdfShape +0 +184, - WebRtcIsac_kQKltCdfShape +0 +192, WebRtcIsac_kQKltCdfShape +0 +200, - WebRtcIsac_kQKltCdfShape +0 +211, WebRtcIsac_kQKltCdfShape +0 +213, - WebRtcIsac_kQKltCdfShape +0 +215, WebRtcIsac_kQKltCdfShape +0 +217, - WebRtcIsac_kQKltCdfShape +0 +219, WebRtcIsac_kQKltCdfShape +0 +223, - WebRtcIsac_kQKltCdfShape +0 +227, WebRtcIsac_kQKltCdfShape +0 +231, - WebRtcIsac_kQKltCdfShape +0 +235, WebRtcIsac_kQKltCdfShape +0 +239, - WebRtcIsac_kQKltCdfShape +0 +243, WebRtcIsac_kQKltCdfShape +0 +248, - WebRtcIsac_kQKltCdfShape +0 +252, WebRtcIsac_kQKltCdfShape +0 +258, - WebRtcIsac_kQKltCdfShape +0 +264, WebRtcIsac_kQKltCdfShape +0 +273, - WebRtcIsac_kQKltCdfShape +0 +282, WebRtcIsac_kQKltCdfShape +0 +293, - WebRtcIsac_kQKltCdfShape +0 +308, WebRtcIsac_kQKltCdfShape +0 +310, - WebRtcIsac_kQKltCdfShape +0 +312, WebRtcIsac_kQKltCdfShape +0 +316, - WebRtcIsac_kQKltCdfShape +0 +320, WebRtcIsac_kQKltCdfShape +0 +324, - WebRtcIsac_kQKltCdfShape +0 +328, WebRtcIsac_kQKltCdfShape +0 +332, - WebRtcIsac_kQKltCdfShape +0 +336, WebRtcIsac_kQKltCdfShape +0 +341, - WebRtcIsac_kQKltCdfShape +0 +347, WebRtcIsac_kQKltCdfShape +0 +354, - WebRtcIsac_kQKltCdfShape +0 +360, WebRtcIsac_kQKltCdfShape +0 +368, - WebRtcIsac_kQKltCdfShape +0 +378, WebRtcIsac_kQKltCdfShape +0 +388, - WebRtcIsac_kQKltCdfShape +0 +400, WebRtcIsac_kQKltCdfShape +0 +418, - WebRtcIsac_kQKltCdfShape +0 +445, WebRtcIsac_kQKltCdfShape +0 +447, - WebRtcIsac_kQKltCdfShape +0 +451, WebRtcIsac_kQKltCdfShape +0 +455, - WebRtcIsac_kQKltCdfShape +0 +461, WebRtcIsac_kQKltCdfShape +0 +468, - WebRtcIsac_kQKltCdfShape +0 +474, WebRtcIsac_kQKltCdfShape +0 +480, - WebRtcIsac_kQKltCdfShape +0 +486, WebRtcIsac_kQKltCdfShape +0 +495, - WebRtcIsac_kQKltCdfShape +0 +505, WebRtcIsac_kQKltCdfShape +0 +516, - WebRtcIsac_kQKltCdfShape +0 +528, WebRtcIsac_kQKltCdfShape +0 +543, - WebRtcIsac_kQKltCdfShape +0 +564, WebRtcIsac_kQKltCdfShape +0 +583, - WebRtcIsac_kQKltCdfShape +0 +608, WebRtcIsac_kQKltCdfShape +0 +635 }; - - -/* left KLT transforms */ -const double WebRtcIsac_kKltT1Gain[4] = { - -0.79742827, 0.60341375, 0.60341375, 0.79742827 }; - -const double WebRtcIsac_kKltT1Shape[324] = { - 0.00159597, 0.00049320, 0.00513821, 0.00021066, 0.01338581, - -0.00422367, -0.00272072, 0.00935107, 0.02047622, 0.02691189, - 0.00478236, 0.03969702, 0.00886698, 0.04877604, -0.10898362, - -0.05930891, -0.03415047, 0.98889721, 0.00293558, -0.00035282, - 0.01156321, -0.00195341, -0.00937631, 0.01052213, -0.02551163, - 0.01644059, 0.03189927, 0.07754773, -0.08742313, -0.03026338, - 0.05136248, -0.14395974, 0.17725040, 0.22664856, 0.93380230, - 0.07076411, 0.00557890, -0.00222834, 0.01377569, 0.01466808, - 0.02847361, -0.00603178, 0.02382480, -0.01210452, 0.03797267, - -0.02371480, 0.11260335, -0.07366682, 0.00453436, -0.04136941, - -0.07912843, -0.95031418, 0.25295337, -0.05302216, -0.00617554, - -0.00044040, -0.00653778, 0.01097838, 0.01529174, 0.01374431, - -0.00748512, -0.00020034, 0.02432713, 0.11101570, -0.08556891, - 0.09282249, -0.01029446, 0.67556443, -0.67454300, 0.06910063, - 0.20866865, -0.10318050, 0.00932175, 0.00524058, 0.00803610, - -0.00594676, -0.01082578, 0.01069906, 0.00546768, 0.01565291, - 0.06816200, 0.10201227, 0.16812734, 0.22984074, 0.58213170, - -0.54138651, -0.51379962, 0.06847390, -0.01920037, -0.04592324, - -0.00467394, 0.00328858, 0.00377424, -0.00987448, 0.08222096, - -0.00377301, 0.04551941, -0.02592517, 0.16317082, 0.13077530, - 0.22702921, -0.31215289, -0.69645962, -0.38047101, -0.39339411, - 0.11124777, 0.02508035, -0.00708074, 0.00400344, 0.00040331, - 0.01142402, 0.01725406, 0.01635170, 0.14285366, 0.03949233, - -0.05905676, 0.05877154, -0.17497577, -0.32479440, 0.80754464, - -0.38085603, -0.17055430, -0.03168622, -0.07531451, 0.02942002, - -0.02148095, -0.00754114, -0.00322372, 0.00567812, -0.01701521, - -0.12358320, 0.11473564, 0.09070136, 0.06533068, -0.22560802, - 0.19209022, 0.81605094, 0.36592275, -0.09919829, 0.16667122, - 0.16300725, 0.04803807, 0.06739263, -0.00156752, -0.01685302, - -0.00905240, -0.02297836, -0.00469939, 0.06310613, -0.16391930, - 0.10919511, 0.12529293, 0.85581322, -0.32145522, 0.24539076, - 0.07181839, 0.07289591, 0.14066759, 0.10406711, 0.05815518, - 0.01072680, -0.00759339, 0.00053486, -0.00044865, 0.03407361, - 0.01645348, 0.08758579, 0.27722240, 0.53665485, -0.74853376, - -0.01118192, -0.19805430, 0.06130619, -0.09675299, 0.08978480, - 0.03405255, -0.00706867, 0.05102045, 0.03250746, 0.01849966, - -0.01216314, -0.01184187, -0.01579288, 0.00114807, 0.11376166, - 0.88342114, -0.36425379, 0.13863190, 0.12524180, -0.13553892, - 0.04715856, -0.12341103, 0.04531568, 0.01899360, -0.00206897, - 0.00567768, -0.01444163, 0.00411946, -0.00855896, 0.00381663, - -0.01664861, -0.05534280, 0.21328278, 0.20161162, 0.72360394, - 0.59130708, -0.08043791, 0.08757349, -0.13893918, -0.05147377, - 0.02680690, -0.01144070, 0.00625162, -0.00634215, -0.01248947, - -0.00329455, -0.00609625, -0.00136305, -0.05097048, -0.01029851, - 0.25065384, -0.16856837, -0.07123372, 0.15992623, -0.39487617, - -0.79972301, 0.18118185, -0.04826639, -0.01805578, -0.02927253, - -0.16400618, 0.07472763, 0.10376449, 0.01705406, 0.01065801, - -0.01500498, 0.02039914, 0.37776349, -0.84484186, 0.10434286, - 0.15616990, 0.13474456, -0.00906238, -0.25238368, -0.03820885, - -0.10650905, -0.03880833, -0.03660028, -0.09640894, 0.00583314, - 0.01922097, 0.01489911, -0.02431117, -0.09372217, 0.39404721, - -0.84786223, -0.31277121, 0.03193850, 0.01974060, 0.01887901, - 0.00337911, -0.11359599, -0.02792521, -0.03220184, -0.01533311, - 0.00015962, -0.04225043, -0.00933965, 0.00675311, 0.00206060, - 0.15926771, 0.40199829, -0.80792558, -0.35591604, -0.17169764, - 0.02830436, 0.02459982, -0.03438589, 0.00718705, -0.01798329, - -0.01594508, -0.00702430, -0.00952419, -0.00962701, -0.01307212, - -0.01749740, 0.01299602, 0.00587270, -0.36103108, -0.82039266, - -0.43092844, -0.08500097, -0.04361674, -0.00333482, 0.01250434, - -0.02538295, -0.00921797, 0.01645071, -0.01400872, 0.00317607, - 0.00003277, -0.01617646, -0.00616863, -0.00882661, 0.00466157, - 0.00353237, 0.91803104, -0.39503305, -0.02048964, 0.00060125, - 0.01980634, 0.00300109, 0.00313880, 0.00657337, 0.00715163, - 0.00000261, 0.00854276, -0.00154825, -0.00516128, 0.00909527, - 0.00095609, 0.00701196, -0.00221867, -0.00156741 }; - -/* right KLT transforms */ -const double WebRtcIsac_kKltT2Gain[36] = { - 0.14572837, -0.45446306, 0.61990621, -0.52197033, 0.32145074, - -0.11026900, -0.20698282, 0.48962182, -0.27127933, -0.33627476, - 0.65094037, -0.32715751, 0.40262573, -0.47844405, -0.33876075, - 0.44130653, 0.37383966, -0.39964662, -0.51730480, 0.06611973, - 0.49030187, 0.47512886, -0.02141226, -0.51129451, -0.58578569, - -0.39132064, -0.13187771, 0.15649421, 0.40735596, 0.54396897, - 0.40381276, 0.40904942, 0.41179766, 0.41167576, 0.40840251, - 0.40468132 }; - -const double WebRtcIsac_kKltT2Shape[36] = { - 0.13427386, -0.35132558, 0.52506528, -0.59419077, 0.45075085, - -0.16312057, 0.29857439, -0.58660147, 0.34265431, 0.20879510, - -0.56063262, 0.30238345, 0.43308283, -0.41186999, -0.35288681, - 0.42768996, 0.36094634, -0.45284910, -0.47116680, 0.02893449, - 0.54326135, 0.45249040, -0.06264420, -0.52283830, 0.57137758, - 0.44298139, 0.12617554, -0.20819946, -0.42324603, -0.48876443, - 0.39597050, 0.40713935, 0.41389880, 0.41512486, 0.41130400, - 0.40575001 }; - -/* means of log gains and LAR coefficients*/ -const double WebRtcIsac_kLpcMeansGain[12] = { - -6.86881911, -5.35075273, -6.86792680, -5.36200897, -6.86401538, - -5.36921533, -6.86802969, -5.36893966, -6.86538097, -5.36315063, - -6.85535304, -5.35155315 }; - -const double WebRtcIsac_kLpcMeansShape[108] = { - -0.91232981, 0.26258634, -0.33716701, 0.08477430, -0.03378426, - 0.14423909, 0.07036185, 0.06155019, 0.01490385, 0.04138740, - 0.01427317, 0.01288970, 0.83872106, 0.25750199, 0.07988929, - -0.01957923, 0.00831390, 0.01770300, -0.90957164, 0.25732216, - -0.33385344, 0.08735740, -0.03715332, 0.14584917, 0.06998990, - 0.06131968, 0.01504379, 0.04067339, 0.01428039, 0.01406460, - 0.83846243, 0.26169862, 0.08109025, -0.01767055, 0.00970539, - 0.01954310, -0.90490803, 0.24656405, -0.33578607, 0.08843286, - -0.03749139, 0.14443959, 0.07214669, 0.06170993, 0.01449947, - 0.04134309, 0.01314762, 0.01413471, 0.83895203, 0.26748062, - 0.08197507, -0.01781298, 0.00885967, 0.01922394, -0.90922472, - 0.24495889, -0.33921540, 0.08877169, -0.03581332, 0.14199172, - 0.07444032, 0.06185940, 0.01502054, 0.04185113, 0.01276579, - 0.01355457, 0.83645358, 0.26631720, 0.08119697, -0.01835449, - 0.00788512, 0.01846446, -0.90482253, 0.24658310, -0.34019734, - 0.08281090, -0.03486038, 0.14359248, 0.07401336, 0.06001471, - 0.01528421, 0.04254560, 0.01321472, 0.01240799, 0.83857127, - 0.26281654, 0.08174380, -0.02099842, 0.00755176, 0.01699448, - -0.90132307, 0.25174308, -0.33838268, 0.07883863, -0.02877906, - 0.14105407, 0.07220290, 0.06000352, 0.01684879, 0.04226844, - 0.01331331, 0.01269244, 0.83832138, 0.25467485, 0.08118028, - -0.02120528, 0.00747832, 0.01567212 };
diff --git a/src/modules/audio_coding/codecs/isac/main/source/lpc_tables.h b/src/modules/audio_coding/codecs/isac/main/source/lpc_tables.h deleted file mode 100644 index c217804..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/lpc_tables.h +++ /dev/null
@@ -1,100 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * lpc_tables.h - * - * header file for coding tables for the LPC coefficients - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_TABLES_H_ - -#include "structs.h" - -#include "settings.h" - -#define KLT_STEPSIZE 1.00000000 -#define KLT_NUM_AVG_GAIN 0 -#define KLT_NUM_AVG_SHAPE 0 -#define KLT_NUM_MODELS 3 -#define LPC_GAIN_SCALE 4.000f -#define LPC_LOBAND_SCALE 2.100f -#define LPC_LOBAND_ORDER ORDERLO -#define LPC_HIBAND_SCALE 0.450f -#define LPC_HIBAND_ORDER ORDERHI -#define LPC_GAIN_ORDER 2 - -#define LPC_SHAPE_ORDER (LPC_LOBAND_ORDER + LPC_HIBAND_ORDER) - -#define KLT_ORDER_GAIN (LPC_GAIN_ORDER * SUBFRAMES) -#define KLT_ORDER_SHAPE (LPC_SHAPE_ORDER * SUBFRAMES) - -/* cdf array for model indicator */ -extern const WebRtc_UWord16 WebRtcIsac_kQKltModelCdf[KLT_NUM_MODELS+1]; - -/* pointer to cdf array for model indicator */ -extern const WebRtc_UWord16 *WebRtcIsac_kQKltModelCdfPtr[1]; - -/* initial cdf index for decoder of model indicator */ -extern const WebRtc_UWord16 WebRtcIsac_kQKltModelInitIndex[1]; - -/* offset to go from rounded value to quantization index */ -extern const short WebRtcIsac_kQKltQuantMinGain[12]; - -extern const short WebRtcIsac_kQKltQuantMinShape[108]; - -/* maximum quantization index */ -extern const WebRtc_UWord16 WebRtcIsac_kQKltMaxIndGain[12]; - -extern const WebRtc_UWord16 WebRtcIsac_kQKltMaxIndShape[108]; - -/* index offset */ -extern const WebRtc_UWord16 WebRtcIsac_kQKltOffsetGain[12]; - -extern const WebRtc_UWord16 WebRtcIsac_kQKltOffsetShape[108]; - -/* initial cdf index for KLT coefficients */ -extern const WebRtc_UWord16 WebRtcIsac_kQKltInitIndexGain[12]; - -extern const WebRtc_UWord16 WebRtcIsac_kQKltInitIndexShape[108]; - -/* quantizer representation levels */ -extern const double WebRtcIsac_kQKltLevelsGain[392]; - -extern const double WebRtcIsac_kQKltLevelsShape[578]; - -/* cdf tables for quantizer indices */ -extern const WebRtc_UWord16 WebRtcIsac_kQKltCdfGain[404]; - -extern const WebRtc_UWord16 WebRtcIsac_kQKltCdfShape[686]; - -/* pointers to cdf tables for quantizer indices */ -extern const WebRtc_UWord16 *WebRtcIsac_kQKltCdfPtrGain[12]; - -extern const WebRtc_UWord16 *WebRtcIsac_kQKltCdfPtrShape[108]; - -/* left KLT transforms */ -extern const double WebRtcIsac_kKltT1Gain[4]; - -extern const double WebRtcIsac_kKltT1Shape[324]; - -/* right KLT transforms */ -extern const double WebRtcIsac_kKltT2Gain[36]; - -extern const double WebRtcIsac_kKltT2Shape[36]; - -/* means of log gains and LAR coefficients */ -extern const double WebRtcIsac_kLpcMeansGain[12]; - -extern const double WebRtcIsac_kLpcMeansShape[108]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_LPC_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h b/src/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h deleted file mode 100644 index c469c2e..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/os_specific_inline.h +++ /dev/null
@@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_ - -#include <math.h> -#include "typedefs.h" - -// TODO(turaj): switch to WEBRTC_POSIX when available -#if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) -#define WebRtcIsac_lrint lrint -#elif (defined(WEBRTC_ARCH_X86) && defined(WIN32)) -static __inline long int WebRtcIsac_lrint(double x_dbl) { - long int x_int; - - __asm { - fld x_dbl - fistp x_int - }; - - return x_int; -} -#else // Do a slow but correct implementation of lrint - -static __inline long int WebRtcIsac_lrint(double x_dbl) { - long int x_int; - x_int = (long int)floor(x_dbl + 0.499999999999); - return x_int; -} - -#endif - -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_OS_SPECIFIC_INLINE_H_
diff --git a/src/modules/audio_coding/codecs/isac/main/source/pitch_estimator.c b/src/modules/audio_coding/codecs/isac/main/source/pitch_estimator.c deleted file mode 100644 index 75525f6..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/pitch_estimator.c +++ /dev/null
@@ -1,622 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "pitch_estimator.h" - -#include <math.h> -#include <memory.h> -#ifdef WEBRTC_ANDROID -#include <stdlib.h> -#endif - -static const double kInterpolWin[8] = {-0.00067556028640, 0.02184247643159, -0.12203175715679, 0.60086484101160, - 0.60086484101160, -0.12203175715679, 0.02184247643159, -0.00067556028640}; - -/* interpolation filter */ -__inline static void IntrepolFilter(double *data_ptr, double *intrp) -{ - *intrp = kInterpolWin[0] * data_ptr[-3]; - *intrp += kInterpolWin[1] * data_ptr[-2]; - *intrp += kInterpolWin[2] * data_ptr[-1]; - *intrp += kInterpolWin[3] * data_ptr[0]; - *intrp += kInterpolWin[4] * data_ptr[1]; - *intrp += kInterpolWin[5] * data_ptr[2]; - *intrp += kInterpolWin[6] * data_ptr[3]; - *intrp += kInterpolWin[7] * data_ptr[4]; -} - - -/* 2D parabolic interpolation */ -/* probably some 0.5 factors can be eliminated, and the square-roots can be removed from the Cholesky fact. */ -__inline static void Intrpol2D(double T[3][3], double *x, double *y, double *peak_val) -{ - double c, b[2], A[2][2]; - double t1, t2, d; - double delta1, delta2; - - - // double T[3][3] = {{-1.25, -.25,-.25}, {-.25, .75, .75}, {-.25, .75, .75}}; - // should result in: delta1 = 0.5; delta2 = 0.0; peak_val = 1.0 - - c = T[1][1]; - b[0] = 0.5 * (T[1][2] + T[2][1] - T[0][1] - T[1][0]); - b[1] = 0.5 * (T[1][0] + T[2][1] - T[0][1] - T[1][2]); - A[0][1] = -0.5 * (T[0][1] + T[2][1] - T[1][0] - T[1][2]); - t1 = 0.5 * (T[0][0] + T[2][2]) - c; - t2 = 0.5 * (T[2][0] + T[0][2]) - c; - d = (T[0][1] + T[1][2] + T[1][0] + T[2][1]) - 4.0 * c - t1 - t2; - A[0][0] = -t1 - 0.5 * d; - A[1][1] = -t2 - 0.5 * d; - - /* deal with singularities or ill-conditioned cases */ - if ( (A[0][0] < 1e-7) || ((A[0][0] * A[1][1] - A[0][1] * A[0][1]) < 1e-7) ) { - *peak_val = T[1][1]; - return; - } - - /* Cholesky decomposition: replace A by upper-triangular factor */ - A[0][0] = sqrt(A[0][0]); - A[0][1] = A[0][1] / A[0][0]; - A[1][1] = sqrt(A[1][1] - A[0][1] * A[0][1]); - - /* compute [x; y] = -0.5 * inv(A) * b */ - t1 = b[0] / A[0][0]; - t2 = (b[1] - t1 * A[0][1]) / A[1][1]; - delta2 = t2 / A[1][1]; - delta1 = 0.5 * (t1 - delta2 * A[0][1]) / A[0][0]; - delta2 *= 0.5; - - /* limit norm */ - t1 = delta1 * delta1 + delta2 * delta2; - if (t1 > 1.0) { - delta1 /= t1; - delta2 /= t1; - } - - *peak_val = 0.5 * (b[0] * delta1 + b[1] * delta2) + c; - - *x += delta1; - *y += delta2; -} - - -static void PCorr(const double *in, double *outcorr) -{ - double sum, ysum, prod; - const double *x, *inptr; - int k, n; - - //ysum = 1e-6; /* use this with float (i.s.o. double)! */ - ysum = 1e-13; - sum = 0.0; - x = in + PITCH_MAX_LAG/2 + 2; - for (n = 0; n < PITCH_CORR_LEN2; n++) { - ysum += in[n] * in[n]; - sum += x[n] * in[n]; - } - - outcorr += PITCH_LAG_SPAN2 - 1; /* index of last element in array */ - *outcorr = sum / sqrt(ysum); - - for (k = 1; k < PITCH_LAG_SPAN2; k++) { - ysum -= in[k-1] * in[k-1]; - ysum += in[PITCH_CORR_LEN2 + k - 1] * in[PITCH_CORR_LEN2 + k - 1]; - sum = 0.0; - inptr = &in[k]; - prod = x[0] * inptr[0]; - for (n = 1; n < PITCH_CORR_LEN2; n++) { - sum += prod; - prod = x[n] * inptr[n]; - } - sum += prod; - outcorr--; - *outcorr = sum / sqrt(ysum); - } -} - - -void WebRtcIsac_InitializePitch(const double *in, - const double old_lag, - const double old_gain, - PitchAnalysisStruct *State, - double *lags) -{ - double buf_dec[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2+2]; - double ratio, log_lag, gain_bias; - double bias; - double corrvec1[PITCH_LAG_SPAN2]; - double corrvec2[PITCH_LAG_SPAN2]; - int m, k; - // Allocating 10 extra entries at the begining of the CorrSurf - double corrSurfBuff[10 + (2*PITCH_BW+3)*(PITCH_LAG_SPAN2+4)]; - double* CorrSurf[2*PITCH_BW+3]; - double *CorrSurfPtr1, *CorrSurfPtr2; - double LagWin[3] = {0.2, 0.5, 0.98}; - int ind1, ind2, peaks_ind, peak, max_ind; - int peaks[PITCH_MAX_NUM_PEAKS]; - double adj, gain_tmp; - double corr, corr_max; - double intrp_a, intrp_b, intrp_c, intrp_d; - double peak_vals[PITCH_MAX_NUM_PEAKS]; - double lags1[PITCH_MAX_NUM_PEAKS]; - double lags2[PITCH_MAX_NUM_PEAKS]; - double T[3][3]; - int row; - - for(k = 0; k < 2*PITCH_BW+3; k++) - { - CorrSurf[k] = &corrSurfBuff[10 + k * (PITCH_LAG_SPAN2+4)]; - } - /* reset CorrSurf matrix */ - memset(corrSurfBuff, 0, sizeof(double) * (10 + (2*PITCH_BW+3) * (PITCH_LAG_SPAN2+4))); - - //warnings -DH - max_ind = 0; - peak = 0; - - /* copy old values from state buffer */ - memcpy(buf_dec, State->dec_buffer, sizeof(double) * (PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2)); - - /* decimation; put result after the old values */ - WebRtcIsac_DecimateAllpass(in, State->decimator_state, PITCH_FRAME_LEN, - &buf_dec[PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2]); - - /* low-pass filtering */ - for (k = PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2; k < PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2+2; k++) - buf_dec[k] += 0.75 * buf_dec[k-1] - 0.25 * buf_dec[k-2]; - - /* copy end part back into state buffer */ - memcpy(State->dec_buffer, buf_dec+PITCH_FRAME_LEN/2, sizeof(double) * (PITCH_CORR_LEN2+PITCH_CORR_STEP2+PITCH_MAX_LAG/2-PITCH_FRAME_LEN/2+2)); - - /* compute correlation for first and second half of the frame */ - PCorr(buf_dec, corrvec1); - PCorr(buf_dec + PITCH_CORR_STEP2, corrvec2); - - /* bias towards pitch lag of previous frame */ - log_lag = log(0.5 * old_lag); - gain_bias = 4.0 * old_gain * old_gain; - if (gain_bias > 0.8) gain_bias = 0.8; - for (k = 0; k < PITCH_LAG_SPAN2; k++) - { - ratio = log((double) (k + (PITCH_MIN_LAG/2-2))) - log_lag; - bias = 1.0 + gain_bias * exp(-5.0 * ratio * ratio); - corrvec1[k] *= bias; - } - - /* taper correlation functions */ - for (k = 0; k < 3; k++) { - gain_tmp = LagWin[k]; - corrvec1[k] *= gain_tmp; - corrvec2[k] *= gain_tmp; - corrvec1[PITCH_LAG_SPAN2-1-k] *= gain_tmp; - corrvec2[PITCH_LAG_SPAN2-1-k] *= gain_tmp; - } - - corr_max = 0.0; - /* fill middle row of correlation surface */ - ind1 = 0; - ind2 = 0; - CorrSurfPtr1 = &CorrSurf[PITCH_BW][2]; - for (k = 0; k < PITCH_LAG_SPAN2; k++) { - corr = corrvec1[ind1++] + corrvec2[ind2++]; - CorrSurfPtr1[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr1[k] - &CorrSurf[0][0]); - } - } - /* fill first and last rows of correlation surface */ - ind1 = 0; - ind2 = PITCH_BW; - CorrSurfPtr1 = &CorrSurf[0][2]; - CorrSurfPtr2 = &CorrSurf[2*PITCH_BW][PITCH_BW+2]; - for (k = 0; k < PITCH_LAG_SPAN2-PITCH_BW; k++) { - ratio = ((double) (ind1 + 12)) / ((double) (ind2 + 12)); - adj = 0.2 * ratio * (2.0 - ratio); /* adjustment factor; inverse parabola as a function of ratio */ - corr = adj * (corrvec1[ind1] + corrvec2[ind2]); - CorrSurfPtr1[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr1[k] - &CorrSurf[0][0]); - } - corr = adj * (corrvec1[ind2++] + corrvec2[ind1++]); - CorrSurfPtr2[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr2[k] - &CorrSurf[0][0]); - } - } - /* fill second and next to last rows of correlation surface */ - ind1 = 0; - ind2 = PITCH_BW-1; - CorrSurfPtr1 = &CorrSurf[1][2]; - CorrSurfPtr2 = &CorrSurf[2*PITCH_BW-1][PITCH_BW+1]; - for (k = 0; k < PITCH_LAG_SPAN2-PITCH_BW+1; k++) { - ratio = ((double) (ind1 + 12)) / ((double) (ind2 + 12)); - adj = 0.9 * ratio * (2.0 - ratio); /* adjustment factor; inverse parabola as a function of ratio */ - corr = adj * (corrvec1[ind1] + corrvec2[ind2]); - CorrSurfPtr1[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr1[k] - &CorrSurf[0][0]); - } - corr = adj * (corrvec1[ind2++] + corrvec2[ind1++]); - CorrSurfPtr2[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr2[k] - &CorrSurf[0][0]); - } - } - /* fill remainder of correlation surface */ - for (m = 2; m < PITCH_BW; m++) { - ind1 = 0; - ind2 = PITCH_BW - m; /* always larger than ind1 */ - CorrSurfPtr1 = &CorrSurf[m][2]; - CorrSurfPtr2 = &CorrSurf[2*PITCH_BW-m][PITCH_BW+2-m]; - for (k = 0; k < PITCH_LAG_SPAN2-PITCH_BW+m; k++) { - ratio = ((double) (ind1 + 12)) / ((double) (ind2 + 12)); - adj = ratio * (2.0 - ratio); /* adjustment factor; inverse parabola as a function of ratio */ - corr = adj * (corrvec1[ind1] + corrvec2[ind2]); - CorrSurfPtr1[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr1[k] - &CorrSurf[0][0]); - } - corr = adj * (corrvec1[ind2++] + corrvec2[ind1++]); - CorrSurfPtr2[k] = corr; - if (corr > corr_max) { - corr_max = corr; /* update maximum */ - max_ind = (int)(&CorrSurfPtr2[k] - &CorrSurf[0][0]); - } - } - } - - /* threshold value to qualify as a peak */ - corr_max *= 0.6; - - peaks_ind = 0; - /* find peaks */ - for (m = 1; m < PITCH_BW+1; m++) { - if (peaks_ind == PITCH_MAX_NUM_PEAKS) break; - CorrSurfPtr1 = &CorrSurf[m][2]; - for (k = 2; k < PITCH_LAG_SPAN2-PITCH_BW-2+m; k++) { - corr = CorrSurfPtr1[k]; - if (corr > corr_max) { - if ( (corr > CorrSurfPtr1[k - (PITCH_LAG_SPAN2+5)]) && (corr > CorrSurfPtr1[k - (PITCH_LAG_SPAN2+4)]) ) { - if ( (corr > CorrSurfPtr1[k + (PITCH_LAG_SPAN2+4)]) && (corr > CorrSurfPtr1[k + (PITCH_LAG_SPAN2+5)]) ) { - /* found a peak; store index into matrix */ - peaks[peaks_ind++] = (int)(&CorrSurfPtr1[k] - &CorrSurf[0][0]); - if (peaks_ind == PITCH_MAX_NUM_PEAKS) break; - } - } - } - } - } - for (m = PITCH_BW+1; m < 2*PITCH_BW; m++) { - if (peaks_ind == PITCH_MAX_NUM_PEAKS) break; - CorrSurfPtr1 = &CorrSurf[m][2]; - for (k = 2+m-PITCH_BW; k < PITCH_LAG_SPAN2-2; k++) { - corr = CorrSurfPtr1[k]; - if (corr > corr_max) { - if ( (corr > CorrSurfPtr1[k - (PITCH_LAG_SPAN2+5)]) && (corr > CorrSurfPtr1[k - (PITCH_LAG_SPAN2+4)]) ) { - if ( (corr > CorrSurfPtr1[k + (PITCH_LAG_SPAN2+4)]) && (corr > CorrSurfPtr1[k + (PITCH_LAG_SPAN2+5)]) ) { - /* found a peak; store index into matrix */ - peaks[peaks_ind++] = (int)(&CorrSurfPtr1[k] - &CorrSurf[0][0]); - if (peaks_ind == PITCH_MAX_NUM_PEAKS) break; - } - } - } - } - } - - if (peaks_ind > 0) { - /* examine each peak */ - CorrSurfPtr1 = &CorrSurf[0][0]; - for (k = 0; k < peaks_ind; k++) { - peak = peaks[k]; - - /* compute four interpolated values around current peak */ - IntrepolFilter(&CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+5)], &intrp_a); - IntrepolFilter(&CorrSurfPtr1[peak - 1 ], &intrp_b); - IntrepolFilter(&CorrSurfPtr1[peak ], &intrp_c); - IntrepolFilter(&CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+4)], &intrp_d); - - /* determine maximum of the interpolated values */ - corr = CorrSurfPtr1[peak]; - corr_max = intrp_a; - if (intrp_b > corr_max) corr_max = intrp_b; - if (intrp_c > corr_max) corr_max = intrp_c; - if (intrp_d > corr_max) corr_max = intrp_d; - - /* determine where the peak sits and fill a 3x3 matrix around it */ - row = peak / (PITCH_LAG_SPAN2+4); - lags1[k] = (double) ((peak - row * (PITCH_LAG_SPAN2+4)) + PITCH_MIN_LAG/2 - 4); - lags2[k] = (double) (lags1[k] + PITCH_BW - row); - if ( corr > corr_max ) { - T[0][0] = CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+5)]; - T[2][0] = CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+4)]; - T[1][1] = corr; - T[0][2] = CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+4)]; - T[2][2] = CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+5)]; - T[1][0] = intrp_a; - T[0][1] = intrp_b; - T[2][1] = intrp_c; - T[1][2] = intrp_d; - } else { - if (intrp_a == corr_max) { - lags1[k] -= 0.5; - lags2[k] += 0.5; - IntrepolFilter(&CorrSurfPtr1[peak - 2*(PITCH_LAG_SPAN2+5)], &T[0][0]); - IntrepolFilter(&CorrSurfPtr1[peak - (2*PITCH_LAG_SPAN2+9)], &T[2][0]); - T[1][1] = intrp_a; - T[0][2] = intrp_b; - T[2][2] = intrp_c; - T[1][0] = CorrSurfPtr1[peak - (2*PITCH_LAG_SPAN2+9)]; - T[0][1] = CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+5)]; - T[2][1] = CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+4)]; - T[1][2] = corr; - } else if (intrp_b == corr_max) { - lags1[k] -= 0.5; - lags2[k] -= 0.5; - IntrepolFilter(&CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+6)], &T[0][0]); - T[2][0] = intrp_a; - T[1][1] = intrp_b; - IntrepolFilter(&CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+3)], &T[0][2]); - T[2][2] = intrp_d; - T[1][0] = CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+5)]; - T[0][1] = CorrSurfPtr1[peak - 1]; - T[2][1] = corr; - T[1][2] = CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+4)]; - } else if (intrp_c == corr_max) { - lags1[k] += 0.5; - lags2[k] += 0.5; - T[0][0] = intrp_a; - IntrepolFilter(&CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+4)], &T[2][0]); - T[1][1] = intrp_c; - T[0][2] = intrp_d; - IntrepolFilter(&CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+5)], &T[2][2]); - T[1][0] = CorrSurfPtr1[peak - (PITCH_LAG_SPAN2+4)]; - T[0][1] = corr; - T[2][1] = CorrSurfPtr1[peak + 1]; - T[1][2] = CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+5)]; - } else { - lags1[k] += 0.5; - lags2[k] -= 0.5; - T[0][0] = intrp_b; - T[2][0] = intrp_c; - T[1][1] = intrp_d; - IntrepolFilter(&CorrSurfPtr1[peak + 2*(PITCH_LAG_SPAN2+4)], &T[0][2]); - IntrepolFilter(&CorrSurfPtr1[peak + (2*PITCH_LAG_SPAN2+9)], &T[2][2]); - T[1][0] = corr; - T[0][1] = CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+4)]; - T[2][1] = CorrSurfPtr1[peak + (PITCH_LAG_SPAN2+5)]; - T[1][2] = CorrSurfPtr1[peak + (2*PITCH_LAG_SPAN2+9)]; - } - } - - /* 2D parabolic interpolation gives more accurate lags and peak value */ - Intrpol2D(T, &lags1[k], &lags2[k], &peak_vals[k]); - } - - /* determine the highest peak, after applying a bias towards short lags */ - corr_max = 0.0; - for (k = 0; k < peaks_ind; k++) { - corr = peak_vals[k] * pow(PITCH_PEAK_DECAY, log(lags1[k] + lags2[k])); - if (corr > corr_max) { - corr_max = corr; - peak = k; - } - } - - lags1[peak] *= 2.0; - lags2[peak] *= 2.0; - - if (lags1[peak] < (double) PITCH_MIN_LAG) lags1[peak] = (double) PITCH_MIN_LAG; - if (lags2[peak] < (double) PITCH_MIN_LAG) lags2[peak] = (double) PITCH_MIN_LAG; - if (lags1[peak] > (double) PITCH_MAX_LAG) lags1[peak] = (double) PITCH_MAX_LAG; - if (lags2[peak] > (double) PITCH_MAX_LAG) lags2[peak] = (double) PITCH_MAX_LAG; - - /* store lags of highest peak in output array */ - lags[0] = lags1[peak]; - lags[1] = lags1[peak]; - lags[2] = lags2[peak]; - lags[3] = lags2[peak]; - } - else - { - row = max_ind / (PITCH_LAG_SPAN2+4); - lags1[0] = (double) ((max_ind - row * (PITCH_LAG_SPAN2+4)) + PITCH_MIN_LAG/2 - 4); - lags2[0] = (double) (lags1[0] + PITCH_BW - row); - - if (lags1[0] < (double) PITCH_MIN_LAG) lags1[0] = (double) PITCH_MIN_LAG; - if (lags2[0] < (double) PITCH_MIN_LAG) lags2[0] = (double) PITCH_MIN_LAG; - if (lags1[0] > (double) PITCH_MAX_LAG) lags1[0] = (double) PITCH_MAX_LAG; - if (lags2[0] > (double) PITCH_MAX_LAG) lags2[0] = (double) PITCH_MAX_LAG; - - /* store lags of highest peak in output array */ - lags[0] = lags1[0]; - lags[1] = lags1[0]; - lags[2] = lags2[0]; - lags[3] = lags2[0]; - } -} - - - -/* create weighting matrix by orthogonalizing a basis of polynomials of increasing order - * t = (0:4)'; - * A = [t.^0, t.^1, t.^2, t.^3, t.^4]; - * [Q, dummy] = qr(A); - * P.Weight = Q * diag([0, .1, .5, 1, 1]) * Q'; */ -static const double kWeight[5][5] = { - { 0.29714285714286, -0.30857142857143, -0.05714285714286, 0.05142857142857, 0.01714285714286}, - {-0.30857142857143, 0.67428571428571, -0.27142857142857, -0.14571428571429, 0.05142857142857}, - {-0.05714285714286, -0.27142857142857, 0.65714285714286, -0.27142857142857, -0.05714285714286}, - { 0.05142857142857, -0.14571428571429, -0.27142857142857, 0.67428571428571, -0.30857142857143}, - { 0.01714285714286, 0.05142857142857, -0.05714285714286, -0.30857142857143, 0.29714285714286} -}; - - -void WebRtcIsac_PitchAnalysis(const double *in, /* PITCH_FRAME_LEN samples */ - double *out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ - PitchAnalysisStruct *State, - double *lags, - double *gains) -{ - double HPin[PITCH_FRAME_LEN]; - double Weighted[PITCH_FRAME_LEN]; - double Whitened[PITCH_FRAME_LEN + QLOOKAHEAD]; - double inbuf[PITCH_FRAME_LEN + QLOOKAHEAD]; - double out_G[PITCH_FRAME_LEN + QLOOKAHEAD]; // could be removed by using out instead - double out_dG[4][PITCH_FRAME_LEN + QLOOKAHEAD]; - double old_lag, old_gain; - double nrg_wht, tmp; - double Wnrg, Wfluct, Wgain; - double H[4][4]; - double grad[4]; - double dG[4]; - int k, m, n, iter; - - /* high pass filtering using second order pole-zero filter */ - WebRtcIsac_Highpass(in, HPin, State->hp_state, PITCH_FRAME_LEN); - - /* copy from state into buffer */ - memcpy(Whitened, State->whitened_buf, sizeof(double) * QLOOKAHEAD); - - /* compute weighted and whitened signals */ - WebRtcIsac_WeightingFilter(HPin, &Weighted[0], &Whitened[QLOOKAHEAD], &(State->Wghtstr)); - - /* copy from buffer into state */ - memcpy(State->whitened_buf, Whitened+PITCH_FRAME_LEN, sizeof(double) * QLOOKAHEAD); - - old_lag = State->PFstr_wght.oldlagp[0]; - old_gain = State->PFstr_wght.oldgainp[0]; - - /* inital pitch estimate */ - WebRtcIsac_InitializePitch(Weighted, old_lag, old_gain, State, lags); - - - /* Iterative optimization of lags - to be done */ - - /* compute energy of whitened signal */ - nrg_wht = 0.0; - for (k = 0; k < PITCH_FRAME_LEN + QLOOKAHEAD; k++) - nrg_wht += Whitened[k] * Whitened[k]; - - - /* Iterative optimization of gains */ - - /* set weights for energy, gain fluctiation, and spectral gain penalty functions */ - Wnrg = 1.0 / nrg_wht; - Wgain = 0.005; - Wfluct = 3.0; - - /* set initial gains */ - for (k = 0; k < 4; k++) - gains[k] = PITCH_MAX_GAIN_06; - - /* two iterations should be enough */ - for (iter = 0; iter < 2; iter++) { - /* compute Jacobian of pre-filter output towards gains */ - WebRtcIsac_PitchfilterPre_gains(Whitened, out_G, out_dG, &(State->PFstr_wght), lags, gains); - - /* gradient and approximate Hessian (lower triangle) for minimizing the filter's output power */ - for (k = 0; k < 4; k++) { - tmp = 0.0; - for (n = 0; n < PITCH_FRAME_LEN + QLOOKAHEAD; n++) - tmp += out_G[n] * out_dG[k][n]; - grad[k] = tmp * Wnrg; - } - for (k = 0; k < 4; k++) { - for (m = 0; m <= k; m++) { - tmp = 0.0; - for (n = 0; n < PITCH_FRAME_LEN + QLOOKAHEAD; n++) - tmp += out_dG[m][n] * out_dG[k][n]; - H[k][m] = tmp * Wnrg; - } - } - - /* add gradient and Hessian (lower triangle) for dampening fast gain changes */ - for (k = 0; k < 4; k++) { - tmp = kWeight[k+1][0] * old_gain; - for (m = 0; m < 4; m++) - tmp += kWeight[k+1][m+1] * gains[m]; - grad[k] += tmp * Wfluct; - } - for (k = 0; k < 4; k++) { - for (m = 0; m <= k; m++) { - H[k][m] += kWeight[k+1][m+1] * Wfluct; - } - } - - /* add gradient and Hessian for dampening gain */ - for (k = 0; k < 3; k++) { - tmp = 1.0 / (1 - gains[k]); - grad[k] += tmp * tmp * Wgain; - H[k][k] += 2.0 * tmp * (tmp * tmp * Wgain); - } - tmp = 1.0 / (1 - gains[3]); - grad[3] += 1.33 * (tmp * tmp * Wgain); - H[3][3] += 2.66 * tmp * (tmp * tmp * Wgain); - - - /* compute Cholesky factorization of Hessian - * by overwritting the upper triangle; scale factors on diagonal - * (for non pc-platforms store the inverse of the diagonals seperately to minimize divisions) */ - H[0][1] = H[1][0] / H[0][0]; - H[0][2] = H[2][0] / H[0][0]; - H[0][3] = H[3][0] / H[0][0]; - H[1][1] -= H[0][0] * H[0][1] * H[0][1]; - H[1][2] = (H[2][1] - H[0][1] * H[2][0]) / H[1][1]; - H[1][3] = (H[3][1] - H[0][1] * H[3][0]) / H[1][1]; - H[2][2] -= H[0][0] * H[0][2] * H[0][2] + H[1][1] * H[1][2] * H[1][2]; - H[2][3] = (H[3][2] - H[0][2] * H[3][0] - H[1][2] * H[1][1] * H[1][3]) / H[2][2]; - H[3][3] -= H[0][0] * H[0][3] * H[0][3] + H[1][1] * H[1][3] * H[1][3] + H[2][2] * H[2][3] * H[2][3]; - - /* Compute update as delta_gains = -inv(H) * grad */ - /* copy and negate */ - for (k = 0; k < 4; k++) - dG[k] = -grad[k]; - /* back substitution */ - dG[1] -= dG[0] * H[0][1]; - dG[2] -= dG[0] * H[0][2] + dG[1] * H[1][2]; - dG[3] -= dG[0] * H[0][3] + dG[1] * H[1][3] + dG[2] * H[2][3]; - /* scale */ - for (k = 0; k < 4; k++) - dG[k] /= H[k][k]; - /* back substitution */ - dG[2] -= dG[3] * H[2][3]; - dG[1] -= dG[3] * H[1][3] + dG[2] * H[1][2]; - dG[0] -= dG[3] * H[0][3] + dG[2] * H[0][2] + dG[1] * H[0][1]; - - /* update gains and check range */ - for (k = 0; k < 4; k++) { - gains[k] += dG[k]; - if (gains[k] > PITCH_MAX_GAIN) - gains[k] = PITCH_MAX_GAIN; - else if (gains[k] < 0.0) - gains[k] = 0.0; - } - } - - /* update state for next frame */ - WebRtcIsac_PitchfilterPre(Whitened, out, &(State->PFstr_wght), lags, gains); - - /* concatenate previous input's end and current input */ - memcpy(inbuf, State->inbuf, sizeof(double) * QLOOKAHEAD); - memcpy(inbuf+QLOOKAHEAD, in, sizeof(double) * PITCH_FRAME_LEN); - - /* lookahead pitch filtering for masking analysis */ - WebRtcIsac_PitchfilterPre_la(inbuf, out, &(State->PFstr), lags, gains); - - /* store last part of input */ - for (k = 0; k < QLOOKAHEAD; k++) - State->inbuf[k] = inbuf[k + PITCH_FRAME_LEN]; -}
diff --git a/src/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h b/src/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h deleted file mode 100644 index f5d9356..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/pitch_estimator.h +++ /dev/null
@@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_estimator.h - * - * Pitch functions - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ - -#include "structs.h" - - - -void WebRtcIsac_PitchAnalysis(const double *in, /* PITCH_FRAME_LEN samples */ - double *out, /* PITCH_FRAME_LEN+QLOOKAHEAD samples */ - PitchAnalysisStruct *State, - double *lags, - double *gains); - -void WebRtcIsac_InitializePitch(const double *in, - const double old_lag, - const double old_gain, - PitchAnalysisStruct *State, - double *lags); - -void WebRtcIsac_PitchfilterPre(double *indat, - double *outdat, - PitchFiltstr *pfp, - double *lags, - double *gains); - -void WebRtcIsac_PitchfilterPost(double *indat, - double *outdat, - PitchFiltstr *pfp, - double *lags, - double *gains); - -void WebRtcIsac_PitchfilterPre_la(double *indat, - double *outdat, - PitchFiltstr *pfp, - double *lags, - double *gains); - -void WebRtcIsac_PitchfilterPre_gains(double *indat, - double *outdat, - double out_dG[][PITCH_FRAME_LEN + QLOOKAHEAD], - PitchFiltstr *pfp, - double *lags, - double *gains); - -void WebRtcIsac_WeightingFilter(const double *in, double *weiout, double *whiout, WeightFiltstr *wfdata); - -void WebRtcIsac_Highpass(const double *in, double *out, double *state, int N); - -void WebRtcIsac_DecimateAllpass(const double *in, - double *state_in, /* array of size: 2*ALLPASSSECTIONS+1 */ - int N, /* number of input samples */ - double *out); /* array of size N/2 */ - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_ESTIMATOR_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.c b/src/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.c deleted file mode 100644 index 5d998a2..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.c +++ /dev/null
@@ -1,105 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "pitch_gain_tables.h" - -#include "settings.h" - -/* header file for coding tables for the pitch filter side-info in the entropy coder */ -/********************* Pitch Filter Gain Coefficient Tables ************************/ -/* cdf for quantized pitch filter gains */ -const WebRtc_UWord16 WebRtcIsac_kQPitchGainCdf[255] = { - 0, 2, 4, 6, 64, 901, 903, 905, 16954, 16956, - 16961, 17360, 17362, 17364, 17366, 17368, 17370, 17372, 17374, 17411, - 17514, 17516, 17583, 18790, 18796, 18802, 20760, 20777, 20782, 21722, - 21724, 21728, 21738, 21740, 21742, 21744, 21746, 21748, 22224, 22227, - 22230, 23214, 23229, 23239, 25086, 25108, 25120, 26088, 26094, 26098, - 26175, 26177, 26179, 26181, 26183, 26185, 26484, 26507, 26522, 27705, - 27731, 27750, 29767, 29799, 29817, 30866, 30883, 30885, 31025, 31029, - 31031, 31033, 31035, 31037, 31114, 31126, 31134, 32687, 32722, 32767, - 35718, 35742, 35757, 36943, 36952, 36954, 37115, 37128, 37130, 37132, - 37134, 37136, 37143, 37145, 37152, 38843, 38863, 38897, 47458, 47467, - 47474, 49040, 49061, 49063, 49145, 49157, 49159, 49161, 49163, 49165, - 49167, 49169, 49171, 49757, 49770, 49782, 61333, 61344, 61346, 62860, - 62883, 62885, 62887, 62889, 62891, 62893, 62895, 62897, 62899, 62901, - 62903, 62905, 62907, 62909, 65496, 65498, 65500, 65521, 65523, 65525, - 65527, 65529, 65531, 65533, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsac_kIndexLowerLimitGain[3] = { - -7, -2, -1}; - -const WebRtc_Word16 WebRtcIsac_kIndexUpperLimitGain[3] = { - 0, 3, 1}; - -const WebRtc_UWord16 WebRtcIsac_kIndexMultsGain[2] = { - 18, 3}; - -/* size of cdf table */ -const WebRtc_UWord16 WebRtcIsac_kQCdfTableSizeGain[1] = { - 256}; - -///////////////////////////FIXED POINT -/* mean values of pitch filter gains in FIXED point */ -const WebRtc_Word16 WebRtcIsac_kQMeanGain1Q12[144] = { - 843, 1092, 1336, 1222, 1405, 1656, 1500, 1815, 1843, 1838, 1839, 1843, 1843, 1843, 1843, 1843, - 1843, 1843, 814, 846, 1092, 1013, 1174, 1383, 1391, 1511, 1584, 1734, 1753, 1843, 1843, 1843, - 1843, 1843, 1843, 1843, 524, 689, 777, 845, 947, 1069, 1090, 1263, 1380, 1447, 1559, 1676, - 1645, 1749, 1843, 1843, 1843, 1843, 81, 477, 563, 611, 706, 806, 849, 1012, 1192, 1128, - 1330, 1489, 1425, 1576, 1826, 1741, 1843, 1843, 0, 290, 305, 356, 488, 575, 602, 741, - 890, 835, 1079, 1196, 1182, 1376, 1519, 1506, 1680, 1843, 0, 47, 97, 69, 289, 381, - 385, 474, 617, 664, 803, 1079, 935, 1160, 1269, 1265, 1506, 1741, 0, 0, 0, 0, - 112, 120, 190, 283, 442, 343, 526, 809, 684, 935, 1134, 1020, 1265, 1506, 0, 0, - 0, 0, 0, 0, 0, 111, 256, 87, 373, 597, 430, 684, 935, 770, 1020, 1265}; - -const WebRtc_Word16 WebRtcIsac_kQMeanGain2Q12[144] = { - 1760, 1525, 1285, 1747, 1671, 1393, 1843, 1826, 1555, 1843, 1784, 1606, 1843, 1843, 1711, 1843, - 1843, 1814, 1389, 1275, 1040, 1564, 1414, 1252, 1610, 1495, 1343, 1753, 1592, 1405, 1804, 1720, - 1475, 1843, 1814, 1581, 1208, 1061, 856, 1349, 1148, 994, 1390, 1253, 1111, 1495, 1343, 1178, - 1770, 1465, 1234, 1814, 1581, 1342, 1040, 793, 713, 1053, 895, 737, 1128, 1003, 861, 1277, - 1094, 981, 1475, 1192, 1019, 1581, 1342, 1098, 855, 570, 483, 833, 648, 540, 948, 744, - 572, 1009, 844, 636, 1234, 934, 685, 1342, 1217, 984, 537, 318, 124, 603, 423, 350, - 687, 479, 322, 791, 581, 430, 987, 671, 488, 1098, 849, 597, 283, 27, 0, 397, - 222, 38, 513, 271, 124, 624, 325, 157, 737, 484, 233, 849, 597, 343, 27, 0, - 0, 141, 0, 0, 256, 69, 0, 370, 87, 0, 484, 229, 0, 597, 343, 87}; - -const WebRtc_Word16 WebRtcIsac_kQMeanGain3Q12[144] = { - 1843, 1843, 1711, 1843, 1818, 1606, 1843, 1827, 1511, 1814, 1639, 1393, 1760, 1525, 1285, 1656, - 1419, 1176, 1835, 1718, 1475, 1841, 1650, 1387, 1648, 1498, 1287, 1600, 1411, 1176, 1522, 1299, - 1040, 1419, 1176, 928, 1773, 1461, 1128, 1532, 1355, 1202, 1429, 1260, 1115, 1398, 1151, 1025, - 1172, 1080, 790, 1176, 928, 677, 1475, 1147, 1019, 1276, 1096, 922, 1214, 1010, 901, 1057, - 893, 800, 1040, 796, 734, 928, 677, 424, 1137, 897, 753, 1120, 830, 710, 875, 751, - 601, 795, 642, 583, 790, 544, 475, 677, 474, 140, 987, 750, 482, 697, 573, 450, - 691, 487, 303, 661, 394, 332, 537, 303, 220, 424, 168, 0, 737, 484, 229, 624, - 348, 153, 441, 261, 136, 397, 166, 51, 283, 27, 0, 168, 0, 0, 484, 229, - 0, 370, 57, 0, 256, 43, 0, 141, 0, 0, 27, 0, 0, 0, 0, 0}; - - -const WebRtc_Word16 WebRtcIsac_kQMeanGain4Q12[144] = { - 1843, 1843, 1843, 1843, 1841, 1843, 1500, 1821, 1843, 1222, 1434, 1656, 843, 1092, 1336, 504, - 757, 1007, 1843, 1843, 1843, 1838, 1791, 1843, 1265, 1505, 1599, 965, 1219, 1425, 730, 821, - 1092, 249, 504, 757, 1783, 1819, 1843, 1351, 1567, 1727, 1096, 1268, 1409, 805, 961, 1131, - 444, 670, 843, 0, 249, 504, 1425, 1655, 1743, 1096, 1324, 1448, 822, 1019, 1199, 490, - 704, 867, 81, 450, 555, 0, 0, 249, 1247, 1428, 1530, 881, 1073, 1283, 610, 759, - 939, 278, 464, 645, 0, 200, 270, 0, 0, 0, 935, 1163, 1410, 528, 790, 1068, - 377, 499, 717, 173, 240, 274, 0, 43, 62, 0, 0, 0, 684, 935, 1182, 343, - 551, 735, 161, 262, 423, 0, 55, 27, 0, 0, 0, 0, 0, 0, 430, 684, - 935, 87, 377, 597, 0, 46, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0};
diff --git a/src/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h b/src/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h deleted file mode 100644 index f958f5d..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.h +++ /dev/null
@@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_gain_tables.h - * - * This file contains tables for the pitch filter side-info in the entropy coder. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_GAIN_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_GAIN_TABLES_H_ - -#include "typedefs.h" - -/* header file for coding tables for the pitch filter side-info in the entropy coder */ -/********************* Pitch Filter Gain Coefficient Tables ************************/ -/* cdf for quantized pitch filter gains */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchGainCdf[255]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsac_kIndexLowerLimitGain[3]; - -extern const WebRtc_Word16 WebRtcIsac_kIndexUpperLimitGain[3]; -extern const WebRtc_UWord16 WebRtcIsac_kIndexMultsGain[2]; - -/* mean values of pitch filter gains */ -//(Y) -extern const WebRtc_Word16 WebRtcIsac_kQMeanGain1Q12[144]; -extern const WebRtc_Word16 WebRtcIsac_kQMeanGain2Q12[144]; -extern const WebRtc_Word16 WebRtcIsac_kQMeanGain3Q12[144]; -extern const WebRtc_Word16 WebRtcIsac_kQMeanGain4Q12[144]; -//(Y) - -/* size of cdf table */ -extern const WebRtc_UWord16 WebRtcIsac_kQCdfTableSizeGain[1]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_GAIN_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.c b/src/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.c deleted file mode 100644 index 72a031e..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.c +++ /dev/null
@@ -1,277 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "pitch_lag_tables.h" -#include "settings.h" - -/* header file for coding tables for the pitch filter side-info in the entropy coder */ -/********************* Pitch Filter Gain Coefficient Tables ************************/ - -/* tables for use with small pitch gain */ - -/* cdf for quantized pitch filter lags */ -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf1Lo[127] = { - 0, 134, 336, 549, 778, 998, 1264, 1512, 1777, 2070, - 2423, 2794, 3051, 3361, 3708, 3979, 4315, 4610, 4933, 5269, - 5575, 5896, 6155, 6480, 6816, 7129, 7477, 7764, 8061, 8358, - 8718, 9020, 9390, 9783, 10177, 10543, 10885, 11342, 11795, 12213, - 12680, 13096, 13524, 13919, 14436, 14903, 15349, 15795, 16267, 16734, - 17266, 17697, 18130, 18632, 19080, 19447, 19884, 20315, 20735, 21288, - 21764, 22264, 22723, 23193, 23680, 24111, 24557, 25022, 25537, 26082, - 26543, 27090, 27620, 28139, 28652, 29149, 29634, 30175, 30692, 31273, - 31866, 32506, 33059, 33650, 34296, 34955, 35629, 36295, 36967, 37726, - 38559, 39458, 40364, 41293, 42256, 43215, 44231, 45253, 46274, 47359, - 48482, 49678, 50810, 51853, 53016, 54148, 55235, 56263, 57282, 58363, - 59288, 60179, 61076, 61806, 62474, 63129, 63656, 64160, 64533, 64856, - 65152, 65535, 65535, 65535, 65535, 65535, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf2Lo[20] = { - 0, 429, 3558, 5861, 8558, 11639, 15210, 19502, 24773, 31983, - 42602, 48567, 52601, 55676, 58160, 60172, 61889, 63235, 65383, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf3Lo[2] = { - 0, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf4Lo[10] = { - 0, 2966, 6368, 11182, 19431, 37793, 48532, 55353, 60626, 65535}; - -const WebRtc_UWord16 *WebRtcIsac_kQPitchLagCdfPtrLo[4] = {WebRtcIsac_kQPitchLagCdf1Lo, WebRtcIsac_kQPitchLagCdf2Lo, WebRtcIsac_kQPitchLagCdf3Lo, WebRtcIsac_kQPitchLagCdf4Lo}; - -/* size of first cdf table */ -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdfSizeLo[1] = {128}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsac_kQIndexLowerLimitLagLo[4] = { --140, -9, 0, -4}; - -const WebRtc_Word16 WebRtcIsac_kQIndexUpperLimitLagLo[4] = { --20, 9, 0, 4}; - -/* initial index for arithmetic decoder */ -const WebRtc_UWord16 WebRtcIsac_kQInitIndexLagLo[3] = { - 10, 1, 5}; - -/* mean values of pitch filter lags */ -const double WebRtcIsac_kQMeanLag2Lo[19] = { --17.21385070, -15.82678944, -14.07123081, -12.03003877, -10.01311864, -8.00794627, -5.91162987, -3.89231876, -1.90220980, -0.01879275, - 1.89144232, 3.88123171, 5.92146992, 7.96435361, 9.98923648, 11.98266347, 13.96101002, 15.74855713, 17.10976611}; - -const double WebRtcIsac_kQMeanLag3Lo[1] = { - 0.00000000}; - -const double WebRtcIsac_kQMeanLag4Lo[9] = { --7.76246496, -5.92083980, -3.94095226, -1.89502305, 0.03724681, 1.93054221, 3.96443467, 5.91726366, 7.78434291}; - -const double WebRtcIsac_kQPitchLagStepsizeLo = 2.000000; - - -/* tables for use with medium pitch gain */ - -/* cdf for quantized pitch filter lags */ -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf1Mid[255] = { - 0, 28, 61, 88, 121, 149, 233, 331, 475, 559, - 624, 661, 689, 712, 745, 791, 815, 843, 866, 922, - 959, 1024, 1061, 1117, 1178, 1238, 1280, 1350, 1453, 1513, - 1564, 1625, 1671, 1741, 1788, 1904, 2072, 2421, 2626, 2770, - 2840, 2900, 2942, 3012, 3068, 3115, 3147, 3194, 3254, 3319, - 3366, 3520, 3678, 3780, 3850, 3911, 3957, 4032, 4106, 4185, - 4292, 4474, 4683, 4842, 5019, 5191, 5321, 5428, 5540, 5675, - 5763, 5847, 5959, 6127, 6304, 6564, 6839, 7090, 7263, 7421, - 7556, 7728, 7872, 7984, 8142, 8361, 8580, 8743, 8938, 9227, - 9409, 9539, 9674, 9795, 9930, 10060, 10177, 10382, 10614, 10861, - 11038, 11271, 11415, 11629, 11792, 12044, 12193, 12416, 12574, 12821, - 13007, 13235, 13445, 13654, 13901, 14134, 14488, 15000, 15703, 16285, - 16504, 16797, 17086, 17328, 17579, 17807, 17998, 18268, 18538, 18836, - 19087, 19274, 19474, 19716, 19935, 20270, 20833, 21303, 21532, 21741, - 21978, 22207, 22523, 22770, 23054, 23613, 23943, 24204, 24399, 24651, - 24832, 25074, 25270, 25549, 25759, 26015, 26150, 26424, 26713, 27048, - 27342, 27504, 27681, 27854, 28021, 28207, 28412, 28664, 28859, 29064, - 29278, 29548, 29748, 30107, 30377, 30656, 30856, 31164, 31452, 31755, - 32011, 32328, 32626, 32919, 33319, 33789, 34329, 34925, 35396, 35973, - 36443, 36964, 37551, 38156, 38724, 39357, 40023, 40908, 41587, 42602, - 43924, 45037, 45810, 46597, 47421, 48291, 49092, 50051, 51448, 52719, - 53440, 54241, 54944, 55977, 56676, 57299, 57872, 58389, 59059, 59688, - 60237, 60782, 61094, 61573, 61890, 62290, 62658, 63030, 63217, 63454, - 63622, 63882, 64003, 64273, 64427, 64529, 64581, 64697, 64758, 64902, - 65414, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf2Mid[36] = { - 0, 71, 335, 581, 836, 1039, 1323, 1795, 2258, 2608, - 3005, 3591, 4243, 5344, 7163, 10583, 16848, 28078, 49448, 57007, - 60357, 61850, 62837, 63437, 63872, 64188, 64377, 64614, 64774, 64949, - 65039, 65115, 65223, 65360, 65474, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf3Mid[2] = { - 0, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf4Mid[20] = { - 0, 28, 246, 459, 667, 1045, 1523, 2337, 4337, 11347, - 44231, 56709, 60781, 62243, 63161, 63969, 64608, 65062, 65502, 65535}; - -const WebRtc_UWord16 *WebRtcIsac_kQPitchLagCdfPtrMid[4] = {WebRtcIsac_kQPitchLagCdf1Mid, WebRtcIsac_kQPitchLagCdf2Mid, WebRtcIsac_kQPitchLagCdf3Mid, WebRtcIsac_kQPitchLagCdf4Mid}; - -/* size of first cdf table */ -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdfSizeMid[1] = {256}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsac_kQIndexLowerLimitLagMid[4] = { --280, -17, 0, -9}; - -const WebRtc_Word16 WebRtcIsac_kQIndexUpperLimitLagMid[4] = { --40, 17, 0, 9}; - -/* initial index for arithmetic decoder */ -const WebRtc_UWord16 WebRtcIsac_kQInitIndexLagMid[3] = { - 18, 1, 10}; - -/* mean values of pitch filter lags */ -const double WebRtcIsac_kQMeanLag2Mid[35] = { --16.89183900, -15.86949778, -15.05476653, -14.00664348, -13.02793036, -12.07324237, -11.00542532, -10.11250602, -8.90792971, -8.02474753, --7.00426767, -5.94055287, -4.98251338, -3.91053158, -2.98820425, -1.93524245, -0.92978085, -0.01722509, 0.91317387, 1.92973955, - 2.96908851, 3.93728974, 4.96308471, 5.92244151, 7.08673497, 8.00993708, 9.04656316, 9.98538742, 10.97851694, 11.94772884, - 13.02426166, 14.00039951, 15.01347042, 15.80758023, 16.94086895}; - -const double WebRtcIsac_kQMeanLag3Mid[1] = { - 0.00000000}; - -const double WebRtcIsac_kQMeanLag4Mid[19] = { --8.60409403, -7.89198395, -7.03450280, -5.86260421, -4.93822322, -3.93078706, -2.91302322, -1.91824007, -0.87003282, 0.02822649, - 0.89951758, 1.87495484, 2.91802604, 3.96874074, 5.06571703, 5.93618227, 7.00520185, 7.88497726, 8.64160364}; - -const double WebRtcIsac_kQPitchLagStepsizeMid = 1.000000; - - -/* tables for use with large pitch gain */ - -/* cdf for quantized pitch filter lags */ -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf1Hi[511] = { - 0, 7, 18, 33, 69, 105, 156, 228, 315, 612, - 680, 691, 709, 724, 735, 738, 742, 746, 749, 753, - 756, 760, 764, 774, 782, 785, 789, 796, 800, 803, - 807, 814, 818, 822, 829, 832, 847, 854, 858, 869, - 876, 883, 898, 908, 934, 977, 1010, 1050, 1060, 1064, - 1075, 1078, 1086, 1089, 1093, 1104, 1111, 1122, 1133, 1136, - 1151, 1162, 1183, 1209, 1252, 1281, 1339, 1364, 1386, 1401, - 1411, 1415, 1426, 1430, 1433, 1440, 1448, 1455, 1462, 1477, - 1487, 1495, 1502, 1506, 1509, 1516, 1524, 1531, 1535, 1542, - 1553, 1556, 1578, 1589, 1611, 1625, 1639, 1643, 1654, 1665, - 1672, 1687, 1694, 1705, 1708, 1719, 1730, 1744, 1752, 1759, - 1791, 1795, 1820, 1867, 1886, 1915, 1936, 1943, 1965, 1987, - 2041, 2099, 2161, 2175, 2200, 2211, 2226, 2233, 2244, 2251, - 2266, 2280, 2287, 2298, 2309, 2316, 2331, 2342, 2356, 2378, - 2403, 2418, 2447, 2497, 2544, 2602, 2863, 2895, 2903, 2935, - 2950, 2971, 3004, 3011, 3018, 3029, 3040, 3062, 3087, 3127, - 3152, 3170, 3199, 3243, 3293, 3322, 3340, 3377, 3402, 3427, - 3474, 3518, 3543, 3579, 3601, 3637, 3659, 3706, 3731, 3760, - 3818, 3847, 3869, 3901, 3920, 3952, 4068, 4169, 4220, 4271, - 4524, 4571, 4604, 4632, 4672, 4730, 4777, 4806, 4857, 4904, - 4951, 5002, 5031, 5060, 5107, 5150, 5212, 5266, 5331, 5382, - 5432, 5490, 5544, 5610, 5700, 5762, 5812, 5874, 5972, 6022, - 6091, 6163, 6232, 6305, 6402, 6540, 6685, 6880, 7090, 7271, - 7379, 7452, 7542, 7625, 7687, 7770, 7843, 7911, 7966, 8024, - 8096, 8190, 8252, 8320, 8411, 8501, 8585, 8639, 8751, 8842, - 8918, 8986, 9066, 9127, 9203, 9269, 9345, 9406, 9464, 9536, - 9612, 9667, 9735, 9844, 9931, 10036, 10119, 10199, 10260, 10358, - 10441, 10514, 10666, 10734, 10872, 10951, 11053, 11125, 11223, 11324, - 11516, 11664, 11737, 11816, 11892, 12008, 12120, 12200, 12280, 12392, - 12490, 12576, 12685, 12812, 12917, 13003, 13108, 13210, 13300, 13384, - 13470, 13579, 13673, 13771, 13879, 13999, 14136, 14201, 14368, 14614, - 14759, 14867, 14958, 15030, 15121, 15189, 15280, 15385, 15461, 15555, - 15653, 15768, 15884, 15971, 16069, 16145, 16210, 16279, 16380, 16463, - 16539, 16615, 16688, 16818, 16919, 17017, 18041, 18338, 18523, 18649, - 18790, 18917, 19047, 19167, 19315, 19460, 19601, 19731, 19858, 20068, - 20173, 20318, 20466, 20625, 20741, 20911, 21045, 21201, 21396, 21588, - 21816, 22022, 22305, 22547, 22786, 23072, 23322, 23600, 23879, 24168, - 24433, 24769, 25120, 25511, 25895, 26289, 26792, 27219, 27683, 28077, - 28566, 29094, 29546, 29977, 30491, 30991, 31573, 32105, 32594, 33173, - 33788, 34497, 35181, 35833, 36488, 37255, 37921, 38645, 39275, 39894, - 40505, 41167, 41790, 42431, 43096, 43723, 44385, 45134, 45858, 46607, - 47349, 48091, 48768, 49405, 49955, 50555, 51167, 51985, 52611, 53078, - 53494, 53965, 54435, 54996, 55601, 56125, 56563, 56838, 57244, 57566, - 57967, 58297, 58771, 59093, 59419, 59647, 59886, 60143, 60461, 60693, - 60917, 61170, 61416, 61634, 61891, 62122, 62310, 62455, 62632, 62839, - 63103, 63436, 63639, 63805, 63906, 64015, 64192, 64355, 64475, 64558, - 64663, 64742, 64811, 64865, 64916, 64956, 64981, 65025, 65068, 65115, - 65195, 65314, 65419, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, - 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf2Hi[68] = { - 0, 7, 11, 22, 37, 52, 56, 59, 81, 85, - 89, 96, 115, 130, 137, 152, 170, 181, 193, 200, - 207, 233, 237, 259, 289, 318, 363, 433, 592, 992, - 1607, 3062, 6149, 12206, 25522, 48368, 58223, 61918, 63640, 64584, - 64943, 65098, 65206, 65268, 65294, 65335, 65350, 65372, 65387, 65402, - 65413, 65420, 65428, 65435, 65439, 65450, 65454, 65468, 65472, 65476, - 65483, 65491, 65498, 65505, 65516, 65520, 65528, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf3Hi[2] = { - 0, 65535}; - -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf4Hi[35] = { - 0, 7, 19, 30, 41, 48, 63, 74, 82, 96, - 122, 152, 215, 330, 701, 2611, 10931, 48106, 61177, 64341, - 65112, 65238, 65309, 65338, 65364, 65379, 65401, 65427, 65453, 65465, - 65476, 65490, 65509, 65528, 65535}; - -const WebRtc_UWord16 *WebRtcIsac_kQPitchLagCdfPtrHi[4] = {WebRtcIsac_kQPitchLagCdf1Hi, WebRtcIsac_kQPitchLagCdf2Hi, WebRtcIsac_kQPitchLagCdf3Hi, WebRtcIsac_kQPitchLagCdf4Hi}; - -/* size of first cdf table */ -const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdfSizeHi[1] = {512}; - -/* index limits and ranges */ -const WebRtc_Word16 WebRtcIsac_kQindexLowerLimitLagHi[4] = { --552, -34, 0, -16}; - -const WebRtc_Word16 WebRtcIsac_kQindexUpperLimitLagHi[4] = { --80, 32, 0, 17}; - -/* initial index for arithmetic decoder */ -const WebRtc_UWord16 WebRtcIsac_kQInitIndexLagHi[3] = { - 34, 1, 18}; - -/* mean values of pitch filter lags */ -const double WebRtcIsac_kQMeanLag2Hi[67] = { --17.07263295, -16.50000000, -15.83966081, -15.55613708, -14.96948007, -14.50000000, -14.00000000, -13.48377986, -13.00000000, -12.50000000, --11.93199636, -11.44530414, -11.04197641, -10.39910301, -10.15202337, -9.51322461, -8.93357741, -8.46456632, -8.10270672, -7.53751847, --6.98686404, -6.50000000, -6.08463150, -5.46872991, -5.00864717, -4.50163760, -4.01382410, -3.43856708, -2.96898001, -2.46554810, --1.96861004, -1.47106701, -0.97197237, -0.46561654, -0.00531409, 0.45767857, 0.96777907, 1.47507903, 1.97740425, 2.46695420, - 3.00695774, 3.47167185, 4.02712538, 4.49280007, 5.01087640, 5.48191963, 6.04916550, 6.51511058, 6.97297819, 7.46565499, - 8.01489405, 8.39912001, 8.91819757, 9.50000000, 10.11654065, 10.50000000, 11.03712583, 11.50000000, 12.00000000, 12.38964346, - 12.89466127, 13.43657881, 13.96013840, 14.46279912, 15.00000000, 15.39412269, 15.96662441}; - -const double WebRtcIsac_kQMeanLag3Hi[1] = { - 0.00000000}; - -const double WebRtcIsac_kQMeanLag4Hi[34] = { --7.98331221, -7.47988769, -7.03626557, -6.52708003, -6.06982173, -5.51856292, -5.05827033, -4.45909878, -3.99125864, -3.45308135, --3.02328139, -2.47297273, -1.94341995, -1.44699056, -0.93612243, -0.43012406, 0.01120357, 0.44054812, 0.93199883, 1.45669587, - 1.97218322, 2.50187419, 2.98748690, 3.49343202, 4.01660147, 4.50984306, 5.01402683, 5.58936797, 5.91787793, 6.59998900, - 6.85034315, 7.53503316, 7.87711194, 8.53631648}; - -const double WebRtcIsac_kQPitchLagStepsizeHi = 0.500000; - -/* transform matrix */ -const double WebRtcIsac_kTransform[4][4] = { -{-0.50000000, -0.50000000, -0.50000000, -0.50000000}, -{ 0.67082039, 0.22360680, -0.22360680, -0.67082039}, -{ 0.50000000, -0.50000000, -0.50000000, 0.50000000}, -{ 0.22360680, -0.67082039, 0.67082039, -0.22360680}}; - -/* transpose transform matrix */ -const double WebRtcIsac_kTransformTranspose[4][4] = { -{-0.50000000, 0.67082039, 0.50000000, 0.22360680}, -{-0.50000000, 0.22360680, -0.50000000, -0.67082039}, -{-0.50000000, -0.22360680, -0.50000000, 0.67082039}, -{-0.50000000, -0.67082039, 0.50000000, -0.22360680}}; -
diff --git a/src/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h b/src/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h deleted file mode 100644 index 67b02e5..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.h +++ /dev/null
@@ -1,114 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * pitch_lag_tables.h - * - * This file contains tables for the pitch filter side-info in the entropy coder. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_LAG_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_LAG_TABLES_H_ - -#include "typedefs.h" -/* header file for coding tables for the pitch filter side-info in the entropy coder */ -/********************* Pitch Filter Lag Coefficient Tables ************************/ - -/* tables for use with small pitch gain */ - -/* cdfs for quantized pitch lags */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf1Lo[127]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf2Lo[20]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf3Lo[2]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf4Lo[10]; - -extern const WebRtc_UWord16 *WebRtcIsac_kQPitchLagCdfPtrLo[4]; - -/* size of first cdf table */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdfSizeLo[1]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsac_kQIndexLowerLimitLagLo[4]; -extern const WebRtc_Word16 WebRtcIsac_kQIndexUpperLimitLagLo[4]; - -/* initial index for arithmetic decoder */ -extern const WebRtc_UWord16 WebRtcIsac_kQInitIndexLagLo[3]; - -/* mean values of pitch filter lags */ -extern const double WebRtcIsac_kQMeanLag2Lo[19]; -extern const double WebRtcIsac_kQMeanLag3Lo[1]; -extern const double WebRtcIsac_kQMeanLag4Lo[9]; - -extern const double WebRtcIsac_kQPitchLagStepsizeLo; - - -/* tables for use with medium pitch gain */ - -/* cdfs for quantized pitch lags */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf1Mid[255]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf2Mid[36]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf3Mid[2]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf4Mid[20]; - -extern const WebRtc_UWord16 *WebRtcIsac_kQPitchLagCdfPtrMid[4]; - -/* size of first cdf table */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdfSizeMid[1]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsac_kQIndexLowerLimitLagMid[4]; -extern const WebRtc_Word16 WebRtcIsac_kQIndexUpperLimitLagMid[4]; - -/* initial index for arithmetic decoder */ -extern const WebRtc_UWord16 WebRtcIsac_kQInitIndexLagMid[3]; - -/* mean values of pitch filter lags */ -extern const double WebRtcIsac_kQMeanLag2Mid[35]; -extern const double WebRtcIsac_kQMeanLag3Mid[1]; -extern const double WebRtcIsac_kQMeanLag4Mid[19]; - -extern const double WebRtcIsac_kQPitchLagStepsizeMid; - - -/* tables for use with large pitch gain */ - -/* cdfs for quantized pitch lags */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf1Hi[511]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf2Hi[68]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf3Hi[2]; -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdf4Hi[35]; - -extern const WebRtc_UWord16 *WebRtcIsac_kQPitchLagCdfPtrHi[4]; - -/* size of first cdf table */ -extern const WebRtc_UWord16 WebRtcIsac_kQPitchLagCdfSizeHi[1]; - -/* index limits and ranges */ -extern const WebRtc_Word16 WebRtcIsac_kQindexLowerLimitLagHi[4]; -extern const WebRtc_Word16 WebRtcIsac_kQindexUpperLimitLagHi[4]; - -/* initial index for arithmetic decoder */ -extern const WebRtc_UWord16 WebRtcIsac_kQInitIndexLagHi[3]; - -/* mean values of pitch filter lags */ -extern const double WebRtcIsac_kQMeanLag2Hi[67]; -extern const double WebRtcIsac_kQMeanLag3Hi[1]; -extern const double WebRtcIsac_kQMeanLag4Hi[34]; - -extern const double WebRtcIsac_kQPitchLagStepsizeHi; - -/* transform matrix */ -extern const double WebRtcIsac_kTransform[4][4]; - -/* transpose transform matrix */ -extern const double WebRtcIsac_kTransformTranspose[4][4]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_PITCH_LAG_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/settings.h b/src/modules/audio_coding/codecs/isac/main/source/settings.h deleted file mode 100644 index 9c1ec1e..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/settings.h +++ /dev/null
@@ -1,205 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * settings.h - * - * Declaration of #defines used in the iSAC codec - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ - -/* sampling frequency (Hz) */ -#define FS 16000 - -/* number of samples per frame (either 320 (20ms), 480 (30ms) or 960 (60ms)) */ -#define INITIAL_FRAMESAMPLES 960 - - -#define MAXFFTSIZE 2048 -#define NFACTOR 11 - - - -/* do not modify the following; this will have to be modified if we - * have a 20ms framesize option */ -/**********************************************************************/ -/* miliseconds */ -#define FRAMESIZE 30 -/* number of samples per frame processed in the encoder, 480 */ -#define FRAMESAMPLES 480 /* ((FRAMESIZE*FS)/1000) */ -#define FRAMESAMPLES_HALF 240 -#define FRAMESAMPLES_QUARTER 120 -/**********************************************************************/ - - - -/* max number of samples per frame (= 60 ms frame) */ -#define MAX_FRAMESAMPLES 960 -#define MAX_SWBFRAMESAMPLES (MAX_FRAMESAMPLES * 2) -/* number of samples per 10ms frame */ -#define FRAMESAMPLES_10ms ((10*FS)/1000) -#define SWBFRAMESAMPLES_10ms (FRAMESAMPLES_10ms * 2) -/* number of samples in 30 ms frame */ -#define FRAMESAMPLES_30ms 480 -/* number of subframes */ -#define SUBFRAMES 6 -/* length of a subframe */ -#define UPDATE 80 -/* length of half a subframe (low/high band) */ -#define HALF_SUBFRAMELEN (UPDATE/2) -/* samples of look ahead (in a half-band, so actually - * half the samples of look ahead @ FS) */ -#define QLOOKAHEAD 24 /* 3 ms */ -/* order of AR model in spectral entropy coder */ -#define AR_ORDER 6 -/* order of LP model in spectral entropy coder */ -#define LP_ORDER 0 - -/* window length (masking analysis) */ -#define WINLEN 256 -/* order of low-band pole filter used to approximate masking curve */ -#define ORDERLO 12 -/* order of hi-band pole filter used to approximate masking curve */ -#define ORDERHI 6 - -#define UB_LPC_ORDER 4 -#define UB_LPC_VEC_PER_FRAME 2 -#define UB16_LPC_VEC_PER_FRAME 4 -#define UB_ACTIVE_SUBFRAMES 2 -#define UB_MAX_LPC_ORDER 6 -#define UB_INTERPOL_SEGMENTS 1 -#define UB16_INTERPOL_SEGMENTS 3 -#define LB_TOTAL_DELAY_SAMPLES 48 -enum ISACBandwidth {isac8kHz = 8, isac12kHz = 12, isac16kHz = 16}; -enum ISACBand {kIsacLowerBand = 0, kIsacUpperBand12 = 1, kIsacUpperBand16 = 2}; -#define UB_LPC_GAIN_DIM SUBFRAMES -#define FB_STATE_SIZE_WORD32 6 - - -/* order for post_filter_bank */ -#define POSTQORDER 3 -/* order for pre-filterbank */ -#define QORDER 3 -/* another order */ -#define QORDER_ALL (POSTQORDER+QORDER-1) -/* for decimator */ -#define ALLPASSSECTIONS 2 - - -/* array size for byte stream in number of bytes. */ -/* The old maximum size still needed for the decoding */ -#define STREAM_SIZE_MAX 600 -#define STREAM_SIZE_MAX_30 200 /* 200 bytes=53.4 kbps @ 30 ms.framelength */ -#define STREAM_SIZE_MAX_60 400 /* 400 bytes=53.4 kbps @ 60 ms.framelength */ - -/* storage size for bit counts */ -#define BIT_COUNTER_SIZE 30 -/* maximum order of any AR model or filter */ -#define MAX_AR_MODEL_ORDER 12//50 - - -/* For pitch analysis */ -#define PITCH_FRAME_LEN (FRAMESAMPLES_HALF) /* 30 ms */ -#define PITCH_MAX_LAG 140 /* 57 Hz */ -#define PITCH_MIN_LAG 20 /* 400 Hz */ -#define PITCH_MAX_GAIN 0.45 -#define PITCH_MAX_GAIN_06 0.27 /* PITCH_MAX_GAIN*0.6 */ -#define PITCH_MAX_GAIN_Q12 1843 -#define PITCH_LAG_SPAN2 (PITCH_MAX_LAG/2-PITCH_MIN_LAG/2+5) -#define PITCH_CORR_LEN2 60 /* 15 ms */ -#define PITCH_CORR_STEP2 (PITCH_FRAME_LEN/4) -#define PITCH_BW 11 /* half the band width of correlation surface */ -#define PITCH_SUBFRAMES 4 -#define PITCH_GRAN_PER_SUBFRAME 5 -#define PITCH_SUBFRAME_LEN (PITCH_FRAME_LEN/PITCH_SUBFRAMES) -#define PITCH_UPDATE (PITCH_SUBFRAME_LEN/PITCH_GRAN_PER_SUBFRAME) -/* maximum number of peaks to be examined in correlation surface */ -#define PITCH_MAX_NUM_PEAKS 10 -#define PITCH_PEAK_DECAY 0.85 -/* For weighting filter */ -#define PITCH_WLPCORDER 6 -#define PITCH_WLPCWINLEN PITCH_FRAME_LEN -#define PITCH_WLPCASYM 0.3 /* asymmetry parameter */ -#define PITCH_WLPCBUFLEN PITCH_WLPCWINLEN -/* For pitch filter */ -/* Extra 50 for fraction and LP filters */ -#define PITCH_BUFFSIZE (PITCH_MAX_LAG + 50) -#define PITCH_INTBUFFSIZE (PITCH_FRAME_LEN+PITCH_BUFFSIZE) -/* Max rel. step for interpolation */ -#define PITCH_UPSTEP 1.5 -/* Max rel. step for interpolation */ -#define PITCH_DOWNSTEP 0.67 -#define PITCH_FRACS 8 -#define PITCH_FRACORDER 9 -#define PITCH_DAMPORDER 5 -#define PITCH_FILTDELAY 1.5f -/* stepsize for quantization of the pitch Gain */ -#define PITCH_GAIN_STEPSIZE 0.125 - - - -/* Order of high pass filter */ -#define HPORDER 2 - -/* some mathematical constants */ -/* log2(exp) */ -#define LOG2EXP 1.44269504088896 -#define PI 3.14159265358979 - -/* Maximum number of iterations allowed to limit payload size */ -#define MAX_PAYLOAD_LIMIT_ITERATION 5 - -/* Redundant Coding */ -#define RCU_BOTTLENECK_BPS 16000 -#define RCU_TRANSCODING_SCALE 0.40f -#define RCU_TRANSCODING_SCALE_INVERSE 2.5f - -#define RCU_TRANSCODING_SCALE_UB 0.50f -#define RCU_TRANSCODING_SCALE_UB_INVERSE 2.0f - - -/* Define Error codes */ -/* 6000 General */ -#define ISAC_MEMORY_ALLOCATION_FAILED 6010 -#define ISAC_MODE_MISMATCH 6020 -#define ISAC_DISALLOWED_BOTTLENECK 6030 -#define ISAC_DISALLOWED_FRAME_LENGTH 6040 -#define ISAC_UNSUPPORTED_SAMPLING_FREQUENCY 6050 - -/* 6200 Bandwidth estimator */ -#define ISAC_RANGE_ERROR_BW_ESTIMATOR 6240 -/* 6400 Encoder */ -#define ISAC_ENCODER_NOT_INITIATED 6410 -#define ISAC_DISALLOWED_CODING_MODE 6420 -#define ISAC_DISALLOWED_FRAME_MODE_ENCODER 6430 -#define ISAC_DISALLOWED_BITSTREAM_LENGTH 6440 -#define ISAC_PAYLOAD_LARGER_THAN_LIMIT 6450 -#define ISAC_DISALLOWED_ENCODER_BANDWIDTH 6460 -/* 6600 Decoder */ -#define ISAC_DECODER_NOT_INITIATED 6610 -#define ISAC_EMPTY_PACKET 6620 -#define ISAC_DISALLOWED_FRAME_MODE_DECODER 6630 -#define ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH 6640 -#define ISAC_RANGE_ERROR_DECODE_BANDWIDTH 6650 -#define ISAC_RANGE_ERROR_DECODE_PITCH_GAIN 6660 -#define ISAC_RANGE_ERROR_DECODE_PITCH_LAG 6670 -#define ISAC_RANGE_ERROR_DECODE_LPC 6680 -#define ISAC_RANGE_ERROR_DECODE_SPECTRUM 6690 -#define ISAC_LENGTH_MISMATCH 6730 -#define ISAC_RANGE_ERROR_DECODE_BANDWITH 6740 -#define ISAC_DISALLOWED_BANDWIDTH_MODE_DECODER 6750 -#define ISAC_DISALLOWED_LPC_MODEL 6760 -/* 6800 Call setup formats */ -#define ISAC_INCOMPATIBLE_FORMATS 6810 - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SETTINGS_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.c b/src/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.c deleted file mode 100644 index 92b9c4d..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.c +++ /dev/null
@@ -1,138 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "spectrum_ar_model_tables.h" -#include "settings.h" - -/********************* AR Coefficient Tables ************************/ -/* cdf for quantized reflection coefficient 1 */ -const WebRtc_UWord16 WebRtcIsac_kQArRc1Cdf[12] = { - 0, 2, 4, 129, 7707, 57485, 65495, 65527, 65529, 65531, - 65533, 65535}; - -/* cdf for quantized reflection coefficient 2 */ -const WebRtc_UWord16 WebRtcIsac_kQArRc2Cdf[12] = { - 0, 2, 4, 7, 531, 25298, 64525, 65526, 65529, 65531, - 65533, 65535}; - -/* cdf for quantized reflection coefficient 3 */ -const WebRtc_UWord16 WebRtcIsac_kQArRc3Cdf[12] = { - 0, 2, 4, 6, 620, 22898, 64843, 65527, 65529, 65531, - 65533, 65535}; - -/* cdf for quantized reflection coefficient 4 */ -const WebRtc_UWord16 WebRtcIsac_kQArRc4Cdf[12] = { - 0, 2, 4, 6, 35, 10034, 60733, 65506, 65529, 65531, - 65533, 65535}; - -/* cdf for quantized reflection coefficient 5 */ -const WebRtc_UWord16 WebRtcIsac_kQArRc5Cdf[12] = { - 0, 2, 4, 6, 36, 7567, 56727, 65385, 65529, 65531, - 65533, 65535}; - -/* cdf for quantized reflection coefficient 6 */ -const WebRtc_UWord16 WebRtcIsac_kQArRc6Cdf[12] = { - 0, 2, 4, 6, 14, 6579, 57360, 65409, 65529, 65531, - 65533, 65535}; - -/* representation levels for quantized reflection coefficient 1 */ -const WebRtc_Word16 WebRtcIsac_kQArRc1Levels[11] = { - -32104, -29007, -23202, -15496, -9279, -2577, 5934, 17535, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 2 */ -const WebRtc_Word16 WebRtcIsac_kQArRc2Levels[11] = { - -32104, -29503, -23494, -15261, -7309, -1399, 6158, 16381, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 3 */ -const WebRtc_Word16 WebRtcIsac_kQArRc3Levels[11] = { --32104, -29503, -23157, -15186, -7347, -1359, 5829, 17535, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 4 */ -const WebRtc_Word16 WebRtcIsac_kQArRc4Levels[11] = { --32104, -29503, -24512, -15362, -6665, -342, 6596, 14585, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 5 */ -const WebRtc_Word16 WebRtcIsac_kQArRc5Levels[11] = { --32104, -29503, -24512, -15005, -6564, -106, 7123, 14920, 24512, 29503, 32104 -}; - -/* representation levels for quantized reflection coefficient 6 */ -const WebRtc_Word16 WebRtcIsac_kQArRc6Levels[11] = { --32104, -29503, -24512, -15096, -6656, -37, 7036, 14847, 24512, 29503, 32104 -}; - -/* quantization boundary levels for reflection coefficients */ -const WebRtc_Word16 WebRtcIsac_kQArBoundaryLevels[12] = { --32768, -31441, -27566, -21458, -13612, -4663, 4663, 13612, 21458, 27566, 31441, 32767 -}; - -/* initial index for AR reflection coefficient quantizer and cdf table search */ -const WebRtc_UWord16 WebRtcIsac_kQArRcInitIndex[6] = { - 5, 5, 5, 5, 5, 5}; - -/* pointers to AR cdf tables */ -const WebRtc_UWord16 *WebRtcIsac_kQArRcCdfPtr[AR_ORDER] = { - WebRtcIsac_kQArRc1Cdf, WebRtcIsac_kQArRc2Cdf, WebRtcIsac_kQArRc3Cdf, - WebRtcIsac_kQArRc4Cdf, WebRtcIsac_kQArRc5Cdf, WebRtcIsac_kQArRc6Cdf -}; - -/* pointers to AR representation levels tables */ -const WebRtc_Word16 *WebRtcIsac_kQArRcLevelsPtr[AR_ORDER] = { - WebRtcIsac_kQArRc1Levels, WebRtcIsac_kQArRc2Levels, WebRtcIsac_kQArRc3Levels, - WebRtcIsac_kQArRc4Levels, WebRtcIsac_kQArRc5Levels, WebRtcIsac_kQArRc6Levels -}; - - -/******************** GAIN Coefficient Tables ***********************/ -/* cdf for Gain coefficient */ -const WebRtc_UWord16 WebRtcIsac_kQGainCdf[19] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 1172, - 11119, 29411, 51699, 64445, 65527, 65529, 65531, 65533, 65535}; - -/* representation levels for quantized squared Gain coefficient */ -const WebRtc_Word32 WebRtcIsac_kQGain2Levels[18] = { -// 17, 28, 46, 76, 128, 215, 364, 709, 1268, 1960, 3405, 6078, 11286, 17827, 51918, 134498, 487432, 2048000}; - 128, 128, 128, 128, 128, 215, 364, 709, 1268, 1960, 3405, 6078, 11286, 17827, 51918, 134498, 487432, 2048000}; -/* quantization boundary levels for squared Gain coefficient */ -const WebRtc_Word32 WebRtcIsac_kQGain2BoundaryLevels[19] = { -0, 21, 35, 59, 99, 166, 280, 475, 815, 1414, 2495, 4505, 8397, 16405, 34431, 81359, 240497, 921600, 0x7FFFFFFF}; - -/* pointers to Gain cdf table */ -const WebRtc_UWord16 *WebRtcIsac_kQGainCdf_ptr[1] = {WebRtcIsac_kQGainCdf}; - -/* Gain initial index for gain quantizer and cdf table search */ -const WebRtc_UWord16 WebRtcIsac_kQGainInitIndex[1] = {11}; - -/************************* Cosine Tables ****************************/ -/* Cosine table */ -const WebRtc_Word16 WebRtcIsac_kCos[6][60] = { -{512, 512, 511, 510, 508, 507, 505, 502, 499, 496, 493, 489, 485, 480, 476, 470, 465, 459, 453, 447, -440, 433, 426, 418, 410, 402, 394, 385, 376, 367, 357, 348, 338, 327, 317, 306, 295, 284, 273, 262, -250, 238, 226, 214, 202, 190, 177, 165, 152, 139, 126, 113, 100, 87, 73, 60, 47, 33, 20, 7}, -{512, 510, 508, 503, 498, 491, 483, 473, 462, 450, 437, 422, 406, 389, 371, 352, 333, 312, 290, 268, -244, 220, 196, 171, 145, 120, 93, 67, 40, 13, -13, -40, -67, -93, -120, -145, -171, -196, -220, -244, --268, -290, -312, -333, -352, -371, -389, -406, -422, -437, -450, -462, -473, -483, -491, -498, -503, -508, -510, -512}, -{512, 508, 502, 493, 480, 465, 447, 426, 402, 376, 348, 317, 284, 250, 214, 177, 139, 100, 60, 20, --20, -60, -100, -139, -177, -214, -250, -284, -317, -348, -376, -402, -426, -447, -465, -480, -493, -502, -508, -512, --512, -508, -502, -493, -480, -465, -447, -426, -402, -376, -348, -317, -284, -250, -214, -177, -139, -100, -60, -20}, -{511, 506, 495, 478, 456, 429, 398, 362, 322, 279, 232, 183, 133, 80, 27, -27, -80, -133, -183, -232, --279, -322, -362, -398, -429, -456, -478, -495, -506, -511, -511, -506, -495, -478, -456, -429, -398, -362, -322, -279, --232, -183, -133, -80, -27, 27, 80, 133, 183, 232, 279, 322, 362, 398, 429, 456, 478, 495, 506, 511}, -{511, 502, 485, 459, 426, 385, 338, 284, 226, 165, 100, 33, -33, -100, -165, -226, -284, -338, -385, -426, --459, -485, -502, -511, -511, -502, -485, -459, -426, -385, -338, -284, -226, -165, -100, -33, 33, 100, 165, 226, -284, 338, 385, 426, 459, 485, 502, 511, 511, 502, 485, 459, 426, 385, 338, 284, 226, 165, 100, 33}, -{510, 498, 473, 437, 389, 333, 268, 196, 120, 40, -40, -120, -196, -268, -333, -389, -437, -473, -498, -510, --510, -498, -473, -437, -389, -333, -268, -196, -120, -40, 40, 120, 196, 268, 333, 389, 437, 473, 498, 510, -510, 498, 473, 437, 389, 333, 268, 196, 120, 40, -40, -120, -196, -268, -333, -389, -437, -473, -498, -510} -};
diff --git a/src/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h b/src/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h deleted file mode 100644 index 159245b..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.h +++ /dev/null
@@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * spectrum_ar_model_tables.h - * - * This file contains definitions of tables with AR coefficients, - * Gain coefficients and cosine tables. - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ - -#include "structs.h" - -/********************* AR Coefficient Tables ************************/ -/* cdf for quantized reflection coefficient 1 */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRc1Cdf[12]; - -/* cdf for quantized reflection coefficient 2 */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRc2Cdf[12]; - -/* cdf for quantized reflection coefficient 3 */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRc3Cdf[12]; - -/* cdf for quantized reflection coefficient 4 */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRc4Cdf[12]; - -/* cdf for quantized reflection coefficient 5 */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRc5Cdf[12]; - -/* cdf for quantized reflection coefficient 6 */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRc6Cdf[12]; - -/* quantization boundary levels for reflection coefficients */ -extern const WebRtc_Word16 WebRtcIsac_kQArBoundaryLevels[12]; - -/* initial indices for AR reflection coefficient quantizer and cdf table search */ -extern const WebRtc_UWord16 WebRtcIsac_kQArRcInitIndex[AR_ORDER]; - -/* pointers to AR cdf tables */ -extern const WebRtc_UWord16 *WebRtcIsac_kQArRcCdfPtr[AR_ORDER]; - -/* pointers to AR representation levels tables */ -extern const WebRtc_Word16 *WebRtcIsac_kQArRcLevelsPtr[AR_ORDER]; - - -/******************** GAIN Coefficient Tables ***********************/ -/* cdf for Gain coefficient */ -extern const WebRtc_UWord16 WebRtcIsac_kQGainCdf[19]; - -/* representation levels for quantized Gain coefficient */ -extern const WebRtc_Word32 WebRtcIsac_kQGain2Levels[18]; - -/* squared quantization boundary levels for Gain coefficient */ -extern const WebRtc_Word32 WebRtcIsac_kQGain2BoundaryLevels[19]; - -/* pointer to Gain cdf table */ -extern const WebRtc_UWord16 *WebRtcIsac_kQGainCdf_ptr[1]; - -/* Gain initial index for gain quantizer and cdf table search */ -extern const WebRtc_UWord16 WebRtcIsac_kQGainInitIndex[1]; - -/************************* Cosine Tables ****************************/ -/* Cosine table */ -extern const WebRtc_Word16 WebRtcIsac_kCos[6][60]; - -#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_SPECTRUM_AR_MODEL_TABLES_H_ */
diff --git a/src/modules/audio_coding/codecs/isac/main/source/structs.h b/src/modules/audio_coding/codecs/isac/main/source/structs.h deleted file mode 100644 index 96cef30..0000000 --- a/src/modules/audio_coding/codecs/isac/main/source/structs.h +++ /dev/null
@@ -1,477 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * structs.h - * - * This header file contains all the structs used in the ISAC codec - * - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_STRUCTS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_STRUCTS_H_ - - -#include "typedefs.h" -#include "settings.h" -#include "isac.h" - -typedef struct Bitstreamstruct { - - WebRtc_UWord8 stream[STREAM_SIZE_MAX]; - WebRtc_UWord32 W_upper; - WebRtc_UWord32 streamval; - WebRtc_UWord32 stream_index; - -} Bitstr; - -typedef struct { - - double DataBufferLo[WINLEN]; - double DataBufferHi[WINLEN]; - - double CorrBufLo[ORDERLO+1]; - double CorrBufHi[ORDERHI+1]; - - float PreStateLoF[ORDERLO+1]; - float PreStateLoG[ORDERLO+1]; - float PreStateHiF[ORDERHI+1]; - float PreStateHiG[ORDERHI+1]; - float PostStateLoF[ORDERLO+1]; - float PostStateLoG[ORDERLO+1]; - float PostStateHiF[ORDERHI+1]; - float PostStateHiG[ORDERHI+1]; - - double OldEnergy; - -} MaskFiltstr; - - -typedef struct { - - //state vectors for each of the two analysis filters - double INSTAT1[2*(QORDER-1)]; - double INSTAT2[2*(QORDER-1)]; - double INSTATLA1[2*(QORDER-1)]; - double INSTATLA2[2*(QORDER-1)]; - double INLABUF1[QLOOKAHEAD]; - double INLABUF2[QLOOKAHEAD]; - - float INSTAT1_float[2*(QORDER-1)]; - float INSTAT2_float[2*(QORDER-1)]; - float INSTATLA1_float[2*(QORDER-1)]; - float INSTATLA2_float[2*(QORDER-1)]; - float INLABUF1_float[QLOOKAHEAD]; - float INLABUF2_float[QLOOKAHEAD]; - - /* High pass filter */ - double HPstates[HPORDER]; - float HPstates_float[HPORDER]; - -} PreFiltBankstr; - - -typedef struct { - - //state vectors for each of the two analysis filters - double STATE_0_LOWER[2*POSTQORDER]; - double STATE_0_UPPER[2*POSTQORDER]; - - /* High pass filter */ - double HPstates1[HPORDER]; - double HPstates2[HPORDER]; - - float STATE_0_LOWER_float[2*POSTQORDER]; - float STATE_0_UPPER_float[2*POSTQORDER]; - - float HPstates1_float[HPORDER]; - float HPstates2_float[HPORDER]; - -} PostFiltBankstr; - -typedef struct { - - //data buffer for pitch filter - double ubuf[PITCH_BUFFSIZE]; - - //low pass state vector - double ystate[PITCH_DAMPORDER]; - - //old lag and gain - double oldlagp[1]; - double oldgainp[1]; - -} PitchFiltstr; - -typedef struct { - - //data buffer - double buffer[PITCH_WLPCBUFLEN]; - - //state vectors - double istate[PITCH_WLPCORDER]; - double weostate[PITCH_WLPCORDER]; - double whostate[PITCH_WLPCORDER]; - - //LPC window -> should be a global array because constant - double window[PITCH_WLPCWINLEN]; - -} WeightFiltstr; - -typedef struct { - - //for inital estimator - double dec_buffer[PITCH_CORR_LEN2 + PITCH_CORR_STEP2 + - PITCH_MAX_LAG/2 - PITCH_FRAME_LEN/2+2]; - double decimator_state[2*ALLPASSSECTIONS+1]; - double hp_state[2]; - - double whitened_buf[QLOOKAHEAD]; - - double inbuf[QLOOKAHEAD]; - - PitchFiltstr PFstr_wght; - PitchFiltstr PFstr; - WeightFiltstr Wghtstr; - -} PitchAnalysisStruct; - - - -/* Have instance of struct together with other iSAC structs */ -typedef struct { - - /* Previous frame length (in ms) */ - WebRtc_Word32 prev_frame_length; - - /* Previous RTP timestamp from received - packet (in samples relative beginning) */ - WebRtc_Word32 prev_rec_rtp_number; - - /* Send timestamp for previous packet (in ms using timeGetTime()) */ - WebRtc_UWord32 prev_rec_send_ts; - - /* Arrival time for previous packet (in ms using timeGetTime()) */ - WebRtc_UWord32 prev_rec_arr_ts; - - /* rate of previous packet, derived from RTP timestamps (in bits/s) */ - float prev_rec_rtp_rate; - - /* Time sinse the last update of the BN estimate (in ms) */ - WebRtc_UWord32 last_update_ts; - - /* Time sinse the last reduction (in ms) */ - WebRtc_UWord32 last_reduction_ts; - - /* How many times the estimate was update in the beginning */ - WebRtc_Word32 count_tot_updates_rec; - - /* The estimated bottle neck rate from there to here (in bits/s) */ - WebRtc_Word32 rec_bw; - float rec_bw_inv; - float rec_bw_avg; - float rec_bw_avg_Q; - - /* The estimated mean absolute jitter value, - as seen on this side (in ms) */ - float rec_jitter; - float rec_jitter_short_term; - float rec_jitter_short_term_abs; - float rec_max_delay; - float rec_max_delay_avg_Q; - - /* (assumed) bitrate for headers (bps) */ - float rec_header_rate; - - /* The estimated bottle neck rate from here to there (in bits/s) */ - float send_bw_avg; - - /* The estimated mean absolute jitter value, as seen on - the other siee (in ms) */ - float send_max_delay_avg; - - // number of packets received since last update - int num_pkts_rec; - - int num_consec_rec_pkts_over_30k; - - // flag for marking that a high speed network has been - // detected downstream - int hsn_detect_rec; - - int num_consec_snt_pkts_over_30k; - - // flag for marking that a high speed network has - // been detected upstream - int hsn_detect_snd; - - WebRtc_UWord32 start_wait_period; - - int in_wait_period; - - int change_to_WB; - - WebRtc_UWord32 senderTimestamp; - WebRtc_UWord32 receiverTimestamp; - //enum IsacSamplingRate incomingStreamSampFreq; - WebRtc_UWord16 numConsecLatePkts; - float consecLatency; - WebRtc_Word16 inWaitLatePkts; -} BwEstimatorstr; - - -typedef struct { - - /* boolean, flags if previous packet exceeded B.N. */ - int PrevExceed; - /* ms */ - int ExceedAgo; - /* packets left to send in current burst */ - int BurstCounter; - /* packets */ - int InitCounter; - /* ms remaining in buffer when next packet will be sent */ - double StillBuffered; - -} RateModel; - - -typedef struct { - - unsigned int SpaceAlloced; - unsigned int MaxPermAlloced; - double Tmp0[MAXFFTSIZE]; - double Tmp1[MAXFFTSIZE]; - double Tmp2[MAXFFTSIZE]; - double Tmp3[MAXFFTSIZE]; - int Perm[MAXFFTSIZE]; - int factor [NFACTOR]; - -} FFTstr; - - -/* The following strutc is used to store data from encoding, to make it - fast and easy to construct a new bitstream with a different Bandwidth - estimate. All values (except framelength and minBytes) is double size to - handle 60 ms of data. -*/ -typedef struct { - - /* Used to keep track of if it is first or second part of 60 msec packet */ - int startIdx; - - /* Frame length in samples */ - WebRtc_Word16 framelength; - - /* Pitch Gain */ - int pitchGain_index[2]; - - /* Pitch Lag */ - double meanGain[2]; - int pitchIndex[PITCH_SUBFRAMES*2]; - - /* LPC */ - int LPCindex_s[108*2]; /* KLT_ORDER_SHAPE = 108 */ - int LPCindex_g[12*2]; /* KLT_ORDER_GAIN = 12 */ - double LPCcoeffs_lo[(ORDERLO+1)*SUBFRAMES*2]; - double LPCcoeffs_hi[(ORDERHI+1)*SUBFRAMES*2]; - - /* Encode Spec */ - WebRtc_Word16 fre[FRAMESAMPLES]; - WebRtc_Word16 fim[FRAMESAMPLES]; - WebRtc_Word16 AvgPitchGain[2]; - - /* Used in adaptive mode only */ - int minBytes; - -} ISAC_SaveEncData_t; - - -typedef struct { - - int indexLPCShape[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; - double lpcGain[SUBFRAMES<<1]; - int lpcGainIndex[SUBFRAMES<<1]; - - Bitstr bitStreamObj; - - WebRtc_Word16 realFFT[FRAMESAMPLES_HALF]; - WebRtc_Word16 imagFFT[FRAMESAMPLES_HALF]; -} ISACUBSaveEncDataStruct; - - - -typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; - PreFiltBankstr prefiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; - PitchAnalysisStruct pitchanalysisstr_obj; - FFTstr fftstr_obj; - ISAC_SaveEncData_t SaveEnc_obj; - - int buffer_index; - WebRtc_Word16 current_framesamples; - - float data_buffer_float[FRAMESAMPLES_30ms]; - - int frame_nb; - double bottleneck; - WebRtc_Word16 new_framelength; - double s2nr; - - /* Maximum allowed number of bits for a 30 msec packet */ - WebRtc_Word16 payloadLimitBytes30; - /* Maximum allowed number of bits for a 30 msec packet */ - WebRtc_Word16 payloadLimitBytes60; - /* Maximum allowed number of bits for both 30 and 60 msec packet */ - WebRtc_Word16 maxPayloadBytes; - /* Maximum allowed rate in bytes per 30 msec packet */ - WebRtc_Word16 maxRateInBytes; - - /*--- - If set to 1 iSAC will not addapt the frame-size, if used in - channel-adaptive mode. The initial value will be used for all rates. - ---*/ - WebRtc_Word16 enforceFrameSize; - - /*----- - This records the BWE index the encoder injected into the bit-stream. - It will be used in RCU. The same BWE index of main paylaod will be in - the redundant payload. We can not retrive it from BWE because it is - a recursive procedure (WebRtcIsac_GetDownlinkBwJitIndexImpl) and has to be - called only once per each encode. - -----*/ - WebRtc_Word16 lastBWIdx; -} ISACLBEncStruct; - -typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; - PreFiltBankstr prefiltbankstr_obj; - FFTstr fftstr_obj; - ISACUBSaveEncDataStruct SaveEnc_obj; - - int buffer_index; - float data_buffer_float[MAX_FRAMESAMPLES + - LB_TOTAL_DELAY_SAMPLES]; - double bottleneck; - /* Maximum allowed number of bits for a 30 msec packet */ - //WebRtc_Word16 payloadLimitBytes30; - /* Maximum allowed number of bits for both 30 and 60 msec packet */ - //WebRtc_Word16 maxPayloadBytes; - WebRtc_Word16 maxPayloadSizeBytes; - - double lastLPCVec[UB_LPC_ORDER]; - WebRtc_Word16 numBytesUsed; - WebRtc_Word16 lastJitterInfo; -} ISACUBEncStruct; - - - -typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; - PostFiltBankstr postfiltbankstr_obj; - PitchFiltstr pitchfiltstr_obj; - FFTstr fftstr_obj; - -} ISACLBDecStruct; - -typedef struct { - - Bitstr bitstr_obj; - MaskFiltstr maskfiltstr_obj; - PostFiltBankstr postfiltbankstr_obj; - FFTstr fftstr_obj; - -} ISACUBDecStruct; - - - -typedef struct { - - ISACLBEncStruct ISACencLB_obj; - ISACLBDecStruct ISACdecLB_obj; -} ISACLBStruct; - - -typedef struct { - - ISACUBEncStruct ISACencUB_obj; - ISACUBDecStruct ISACdecUB_obj; -} ISACUBStruct; - -/* - This struct is used to take a snapshot of the entropy coder and LPC gains - right before encoding LPC gains. This allows us to go back to that state - if we like to limit the payload size. -*/ -typedef struct { - /* 6 lower-band & 6 upper-band */ - double loFiltGain[SUBFRAMES]; - double hiFiltGain[SUBFRAMES]; - /* Upper boundary of interval W */ - WebRtc_UWord32 W_upper; - WebRtc_UWord32 streamval; - /* Index to the current position in bytestream */ - WebRtc_UWord32 stream_index; - WebRtc_UWord8 stream[3]; -} transcode_obj; - - -typedef struct { - // lower-band codec instance - ISACLBStruct instLB; - // upper-band codec instance - ISACUBStruct instUB; - - // Bandwidth Estimator and model for the rate. - BwEstimatorstr bwestimator_obj; - RateModel rate_data_obj; - double MaxDelay; - - /* 0 = adaptive; 1 = instantaneous */ - WebRtc_Word16 codingMode; - - // overall bottleneck of the codec - WebRtc_Word32 bottleneck; - - // QMF Filter state - WebRtc_Word32 analysisFBState1[FB_STATE_SIZE_WORD32]; - WebRtc_Word32 analysisFBState2[FB_STATE_SIZE_WORD32]; - WebRtc_Word32 synthesisFBState1[FB_STATE_SIZE_WORD32]; - WebRtc_Word32 synthesisFBState2[FB_STATE_SIZE_WORD32]; - - // Error Code - WebRtc_Word16 errorCode; - - // bandwidth of the encoded audio 8, 12 or 16 kHz - enum ISACBandwidth bandwidthKHz; - // Sampl