Skip to content

Commit

Permalink
Move all DRED encoding/decoding files to dnn/ dir (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-signal committed Feb 29, 2024
1 parent a6bb622 commit aaf0bf5
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 7 deletions.
6 changes: 3 additions & 3 deletions opus_ng/opus/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ static_library("opus") {
"src/dnn/dred_rdovae_dec.c",
"src/dnn/dred_rdovae_dec_data.c",
"src/dnn/dred_rdovae_stats_data.c",
"src/silk/dred_encoder.c",
"src/silk/dred_coding.c",
"src/silk/dred_decoder.c",
"src/dnn/dred_encoder.c",
"src/dnn/dred_coding.c",
"src/dnn/dred_decoder.c",
"src/dnn/nnet_arch.h",
"src/dnn/nnet_default.c",
"src/dnn/pitchdnn_data.c",
Expand Down
2 changes: 1 addition & 1 deletion opus_ng/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd ./src/opus_ng/opus
rm -rf src
git clone -b main https://gitlab.xiph.org/xiph/opus.git src
cd ./src
git reset --hard 57901a6758c3bdc7481d61669812bde13d2085b8
git reset --hard dcce2fd455b1f407bf4e1347ce5358a6d0096bd2
./dnn/download_model.sh "735117b"
popd
rm -rf ./src/third_party/opus
Expand Down
101 changes: 98 additions & 3 deletions ringrtc/opus/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
import("//build/config/arm.gni")
import("//testing/test.gni")

declare_args() {
opus_codec_support_dred = false
}

# If ARM optimizations shall be used to accelerate performance.
use_opus_arm_optimization =
current_cpu == "arm" ||
(current_cpu == "arm64" && (is_fuchsia || is_ios || is_win))
(current_cpu == "arm64" && (is_fuchsia || is_ios || is_win || is_mac))

# NaCl, unlike Chrome, doesn't target SSE2 minimum, so skip optimizations for
# the sake of simplicity.
Expand All @@ -30,6 +34,7 @@ config("opus_private_config") {
"OPUS_BUILD",
"OPUS_EXPORT=",
"ENABLE_HARDENING",
"DISABLE_DEBUG_FLOAT",

# Prefer alloca() over variable length arrays which are often inefficient;
# the opus code will automatically handle this correctly per-platform.
Expand All @@ -40,13 +45,21 @@ config("opus_private_config") {
include_dirs = [
"src",
"src/celt",
"src/dnn",
"src/silk",
"src/silk/fixed",
"src/silk/float",
]

cflags = []

if (opus_codec_support_dred) {
defines += [
"ENABLE_DEEP_PLC",
"ENABLE_DRED",
]
}

if (is_win) {
defines += [ "inline=__inline" ]

Expand Down Expand Up @@ -76,6 +89,7 @@ config("opus_private_config") {
# Run Time CPU Detections (RTCD) is always enabled for x86.
"OPUS_HAVE_RTCD",
"CPU_INFO_BY_ASM",
"FLOAT_APPROX",

# Chrome always targets SSE2+.
"OPUS_X86_MAY_HAVE_SSE",
Expand All @@ -88,7 +102,7 @@ config("opus_private_config") {

# At present libopus has no AVX functions so no sources are add for this,
# if you see linker errors on AVX code the this flag is why.
"OPUS_X86_MAY_HAVE_AVX",
"OPUS_X86_MAY_HAVE_AVX2",
]
}

Expand Down Expand Up @@ -179,6 +193,11 @@ if (use_opus_x86_optimization) {
"src/silk/x86/VAD_sse4_1.c",
"src/silk/x86/VQ_WMat_EC_sse4_1.c",
]
if (opus_codec_support_dred) {
sources += [
"src/dnn/x86/nnet_sse4_1.c",
]
}

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
Expand All @@ -187,11 +206,44 @@ if (use_opus_x86_optimization) {
":opus_config",
]

if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}

if (!is_win || is_clang) {
cflags = [ "-msse4.1" ]
}
}
# TODO(dalecurtis): If libopus ever adds AVX support, add an opus_avx block.

source_set("opus_avx2") {
sources = [
"src/celt/x86/pitch_avx.c",
"src/silk/x86/NSQ_del_dec_avx2.c",
"src/silk/float/x86/inner_product_FLP_avx2.c",
]
if (opus_codec_support_dred) {
sources += [
"src/dnn/x86/nnet_avx2.c",
]
}

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [
":opus_private_config",
":opus_config",
]

if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_speed" ]
}

if (!is_win || is_clang) {
cflags = [ "-mavx", "-mfma", "-mavx2" ]
}
}
}

# Note: Do not add any defines or include_dirs to this target, those should all
Expand Down Expand Up @@ -350,6 +402,7 @@ static_library("opus") {
"src/silk/typedef.h",
"src/src/analysis.c",
"src/src/analysis.h",
"src/src/extensions.c",
"src/src/mapping_matrix.c",
"src/src/mapping_matrix.h",
"src/src/mlp.c",
Expand Down Expand Up @@ -402,6 +455,34 @@ static_library("opus") {
"src/silk/float/warped_autocorrelation_FLP.c",
"src/silk/float/wrappers_FLP.c",
]

if (opus_codec_support_dred) {
sources += [
"src/dnn/burg.c",
"src/dnn/freq.c",
"src/dnn/fargan.c",
"src/dnn/fargan_data.c",
"src/dnn/lpcnet_enc.c",
"src/dnn/lpcnet_plc.c",
"src/dnn/lpcnet_tables.c",
"src/dnn/nnet.c",
"src/dnn/plc_data.c",
"src/dnn/parse_lpcnet_weights.c",
"src/dnn/pitchdnn.c",
"src/dnn/dred_rdovae_enc.c",
"src/dnn/dred_rdovae_enc_data.c",
"src/dnn/dred_rdovae_dec.c",
"src/dnn/dred_rdovae_dec_data.c",
"src/dnn/dred_rdovae_stats_data.c",
"src/dnn/dred_encoder.c",
"src/dnn/dred_coding.c",
"src/dnn/dred_decoder.c",
"src/dnn/nnet_arch.h",
"src/dnn/nnet_default.c",
"src/dnn/pitchdnn_data.c",
"src/dnn/pitchdnn_data.h",
]
}

configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
Expand Down Expand Up @@ -436,7 +517,14 @@ static_library("opus") {
"src/silk/x86/main_sse.h",
"src/silk/x86/x86_silk_map.c",
]
if (opus_codec_support_dred) {
sources += [
"src/dnn/x86/x86_dnn_map.c",
"src/dnn/x86/nnet_sse2.c",
]
}
deps += [ ":opus_sse41" ]
deps += [ ":opus_avx2" ]
}

if (use_opus_arm_optimization) {
Expand Down Expand Up @@ -482,6 +570,13 @@ static_library("opus") {
"src/silk/arm/biquad_alt_arm.h",
"src/silk/arm/biquad_alt_neon_intr.c",
]
if (opus_codec_support_dred) {
sources += [
"src/dnn/arm/arm_dnn_map.c",
"src/dnn/arm/nnet_dotprod.c",
"src/dnn/arm/nnet_neon.c",
]
}
}
}
}
Expand Down

0 comments on commit aaf0bf5

Please sign in to comment.