Commit 39198c63 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

update scripts from LC3plus v.1.6.1 update MR

parent 686954ce
Loading
Loading
Loading
Loading
Loading
+26 −34
Original line number Diff line number Diff line
@@ -3,24 +3,15 @@
# This script shall only be used by automated continuous integration systems

printf "Cleaning old version of LC3plus\n"
rm -rf lib_lc3plus
rm -rf lib_lc3plus/*

printf "Downloading LC3plus code\n"
if false; then
    # Waiting for official ETSI release.
    # TODO: add new URL, remove `if false` when package goes public
    curl -o ./lc3plus_sources.zip NEW_URL_HERE
    unzip lc3plus_sources.zip -d .

curl -o ./lc3plus_sources.zip https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.06.01_60/ts_103634v010601p0.zip
unzip -o lc3plus_sources.zip -d . -x "__MACOSX/*" "package.info"
rm lc3plus_sources.zip
    cp -r "ETSI_Release/<package name here>/src/floating_point" lib_lc3plus
    rm -r ETSI_Release
else
    # Temp solution for downloading WIP ETSI package
    # LC3_ETSI_REPO_URL must be define before running the script
    git clone "$LC3_ETSI_REPO_URL"
    cp -r lc3_etsi_release/src/floating_point lib_lc3plus
    rm -rf lc3_etsi_release
fi
cp -r LC3plus_ETSI_src_v527e88bdddb_20251022/src/floating_point/* lib_lc3plus
rm -r LC3plus_ETSI_src_v527e88bdddb_20251022

# Remove unneeded files
printf "Removing unneeded files\n"
@@ -33,13 +24,13 @@ rm lib_lc3plus/tinywaveout_c.h # Only used for executable

# Limit file permissions
printf "Limiting file permissions\n"
find lib_lc3plus -type f -print0 | \
find lib_lc3plus -type f -print0 |
    xargs -0 -I {} \
        chmod -x {}

# include options.h in all C files
printf "Including options.h and wmc_auto.h in C files\n"
find lib_lc3plus -name '*.[ch]' -type f -print0 | \
find lib_lc3plus -name '*.[ch]' -type f -print0 |
    xargs -0 -I {} \
        sed -i '
# range: from 1st line to first match
@@ -53,17 +44,18 @@ sed -i '

# Remove whitespace from preprocessor commands
printf "Removing whitespace from preprocessor commands\n"
find lib_lc3plus -name '*.[ch]' -type f -print0 | \
xargs -0 -I {} \
sed -i 's/^#[[:space:]]\+/#/' {}
find lib_lc3plus -name '*.[ch]' -type f -print0 |
    xargs -0 -I {} sh -c '
        sed -i "s/^#[[:space:]]\+/#/" "$1"
        sed -i "s/^#\(define\|undef\|ifdef\|ifndef\|endif\|if\|else\|elif\|include\)[[:space:]]\+/#\1 /" "$1"
    ' _ {}

# fix for sanitizer issues
sed -i 's/st->low << 8/(LC3_INT)((LC3_UINT32)st->low << 8)/' lib_lc3plus/ari_codec.c
sed -i 's/~3/(uintptr_t)(~3)/' lib_lc3plus/lc3.c
# delete define of NPRM_RESQ - not used anywhere in LC3plus but conflicts with IVAS
sed -i '/^\/\* RESIDUAL CODING \*\/$/d; /^#define NPRM_RESQ 5 \* MAX_LEN$/d' lib_lc3plus/defines.h

# Add .clang-format file to lib_lc3plus to disable formatting there
printf "Disabling clang-format in lib_lc3plus directory\n"
printf '
DisableFormat: true
SortIncludes: Never
' >> lib_lc3plus/.clang-format
' >lib_lc3plus/.clang-format
+174 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

# This script shall only be used by automated continuous integration systems

set -ux

printf "Cleaning old version of LC3plus\n"
rm -rf lib_lc3plus/*

printf "Downloading LC3plus code\n"

curl -o ./lc3plus_sources.zip https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.06.01_60/ts_103634v010601p0.zip
unzip -o lc3plus_sources.zip -d . -x "__MACOSX/*" "package.info"
rm lc3plus_sources.zip
cp -r LC3plus_ETSI_src_v527e88bdddb_20251022/src/fixed_point/* lib_lc3plus
rm -r LC3plus_ETSI_src_v527e88bdddb_20251022

cd lib_lc3plus

printf "Updating LC3plus code for IVAS BASOP compatibility\n"

# rename files
mv basic_op/dynmem.[ch] .
mv basop_mpy.c basop_mpy_lc3plus.c
mv basop_mpy.h basop_mpy_lc3plus.h
mv basop_util.c basop_util_lc3plus.c
mv basop_util.h basop_util_lc3plus.h
mv fft.c fft_lc3plus.c
mv rom_basop_util.c rom_basop_util_lc3plus.c
mv rom_basop_util.h rom_basop_util_lc3plus.h

# remove unneeded files
rm makefile
rm codec_exe.c
rm ccConvert.c
rm tinywavein_c.h
rm tinywaveout_c.h
rm -r basic_op
rm -r msvc
rm -r msvc_ccc

# update header include guards to avoid conflict
sed -i 's|__BASOP_UTIL_H__|__BASOP_UTIL_LC3PLUS_H__|g' basop_util_lc3plus.h
sed -i 's|__BASOP_UTIL_ROM_H__|__BASOP_UTIL_ROM_LC3PLUS_H__|g' rom_basop_util_lc3plus.h

# update includes for renamed files
sed -i 's|#include "basop_mpy.h"|#include "basop_mpy_lc3plus.h"|g' *.[ch]
sed -i 's|#include "basop_util.h"|#include "basop_util_lc3plus.h"|g' *.[ch]
sed -i 's|#include "rom_basop_util.h"|#include "rom_basop_util_lc3plus.h"|g' *.[ch]

# deactivate DYNMEM_COUNT, conflicts with WMC tool
sed -i 's|#define DYNMEM_COUNT|// #define DYNMEM_COUNT /* conflicts with WMC tool */|g' defines.h

# change BASOP_sub_start/end to push/pop_wmops wrapped in #ifdef WMOPS
sed -E -i 's|BASOP(_sub){1,2}_start|push_wmops|g' *.[ch]
sed -E -i 's|BASOP(_sub){1,2}_end|pop_wmops|g' *.[ch]
sed -E -i 's|^(.*p[uo][sp]h?_wmops.*)$|#ifdef WMOPS\n\1\n#endif|g' *.[ch]

# rename conflicting BASOPs
sed -i 's|Isqrt|Isqrt_lc3plus|g' *.[ch]
sed -i 's|\bMpy_32_16(|Mpy_32_16_lc3plus(|g' *.[ch]
sed -i 's|\bMpy_32_32(|Mpy_32_32_lc3plus(|g' *.[ch]

# suppress #pragma message()
sed -i 's/\#pragma message(/\/\/ \#pragma message(/g' lc3plus.c

# add ENABLE_HR_MODE to lc3plus.h
sed -i '/\#define LC3PLUS_H/a\#define ENABLE_HR_MODE' lc3plus.h

# add macros missing from IVAS at the bottom of the file
sed -i '/\#endif \/\* __BASOP_UTIL_LC3PLUS_H__ \*\//i\
/* Macros missing from IVAS BASOP, used only in LC3plus */\
#define L_shl_pos(x, y) (L_shl((x), (y)))\
#define L_shr_pos(x, y) (L_shr((x), (y)))\
#define L_shr_pos_pos(x, y) (L_shr((x), (y)))\
\
#define L_shr_r_pos(x, shift) (L_shr_r(x, shift))\
\
#define shl_pos(x, y) (shl((x), (y)))\
#define shr_pos(x, y) (shr((x), (y)))\
#define shr_pos_pos(x, y) (shr((x), (y)))\
\
#define lshl_pos(x, y) (lshl(x, y))\
#define UL_lshr_pos(x, y) (UL_lshr(x, y))\
#define UL_lshl_pos(x, y) (UL_lshl(x, y))' basop_util_lc3plus.h

# locally redefine duplicate symbols
sed -i '/\#endif \/\* DEFINES_H \*\//i\
#define FIX_IVAS_LC3PLUS_DUPLICATES\
#ifdef FIX_IVAS_LC3PLUS_DUPLICATES\
#define abs_s_sat abs_s\
#define BASOP_cfft BASOP_cfft_lc3plus\
#define BASOP_getTables BASOP_getTables_lc3plus\
#define BASOP_Util_Add_Mant32Exp BASOP_Util_Add_Mant32Exp_lc3plus\
#define BASOP_Util_Cmp_Mant32Exp BASOP_Util_Cmp_Mant32Exp_lc3plus\
#define BASOP_Util_Divide1616_Scale BASOP_Util_Divide1616_Scale_lc3plus\
#define BASOP_Util_Divide3216_Scale BASOP_Util_Divide3216_Scale_lc3plus\
#define BASOP_Util_InvLog2 BASOP_Util_InvLog2_lc3plus\
#define BASOP_Util_Log2 BASOP_Util_Log2_lc3plus\
#define Copy_Scale_sig Copy_Scale_sig_lc3plus\
#define exp2_tab_long exp2_tab_long_lc3plus\
#define exp2w_tab_long exp2w_tab_long_lc3plus\
#define exp2x_tab_long exp2x_tab_long_lc3plus\
#define get_size_mpvq_calc_offset_fx get_size_mpvq_calc_offset_fx_lc3plus\
#define getScaleFactor16 getScaleFactor16_lc3plus\
#define getScaleFactor32 getScaleFactor32_lc3plus\
#define i_mult DEPR_i_mult\
#define Inv16 Inv16_lc3plus\
#define InvDiffTable InvDiffTable_lc3plus\
#define InvIntTable InvIntTable_lc3plus\
#define InvTable InvTable_lc3plus\
#define ISqrt16 ISqrt16_lc3plus\
#define ISqrtDiffTable ISqrtDiffTable_lc3plus\
#define ISqrtTable ISqrtTable_lc3plus\
#define L_abs_sat L_abs\
#define ldCoeff ldCoeff_lc3plus\
#define Norm32Norm Norm32Norm_lc3plus\
#define POW_ATT_TABLE0 POW_ATT_TABLE0_lc3plus\
#define POW_ATT_TABLE1 POW_ATT_TABLE1_lc3plus\
#define RotVector_320 RotVector_320_lc3plus\
#define RotVector_480 RotVector_480_lc3plus\
#define Scale_sig Scale_sig_lc3plus\
#define SineTable320 SineTable320_lc3plus\
#define SineWindow120 SineWindow120_lc3plus\
#define SineWindow160 SineWindow160_lc3plus\
#define SineWindow180 SineWindow180_lc3plus\
#define SineWindow20 SineWindow20_lc3plus\
#define SineWindow30 SineWindow30_lc3plus\
#define SineWindow320 SineWindow320_lc3plus\
#define SineWindow40 SineWindow40_lc3plus\
#define SineWindow60 SineWindow60_lc3plus\
#define SineWindow80 SineWindow80_lc3plus\
#define Sqrt16 Sqrt16_lc3plus\
#define SqrtDiffTable SqrtDiffTable_lc3plus\
#define SqrtTable SqrtTable_lc3plus\
#define Tab_esc_nb Tab_esc_nb_lc3plus\
#define tnsAcfWindow tnsAcfWindow_lc3plus\
#endif /* FIX_IVAS_LC3PLUS_DUPLICATES */' defines.h

cd -

# Limit file permissions
printf "Limiting file permissions\n"
find lib_lc3plus -type f -print0 |
	xargs -0 -I {} \
		chmod -x {}

# include options.h and wmc_auto.h in all C files
printf "Including options.h and wmc_auto.h in C files\n"
find lib_lc3plus -name '*.[ch]' -type f -print0 |
	xargs -0 -I {} \
		sed -i '
# range: from 1st line to first match
1,/^#include/ {
    # insert lines before first match
    /^#include/ i\
#include "options.h"\
#include "wmc_auto.h"
}
' {}

# Remove whitespace from preprocessor commands
printf "Removing whitespace from preprocessor commands\n"
find lib_lc3plus -name '*.[ch]' -type f -print0 |
    xargs -0 -I {} sh -c '
        sed -i "s/^#[[:space:]]\+/#/" "$1"
        sed -i "s/^#\(define\|undef\|ifdef\|ifndef\|endif\|if\|else\|elif\|include\)[[:space:]]\+/#\1 /" "$1"
    ' _ {}

# Add .clang-format file to lib_lc3plus to disable formatting there
printf "Disabling clang-format in lib_lc3plus directory\n"
printf 'DisableFormat: true
SortIncludes: Never
' >lib_lc3plus/.clang-format
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ if [ $ISAR -eq 1 ]; then
        echo "
        #define ENABLE_HR_MODE
        //#define DYNMEM_COUNT
        #define CR10_A_ATTENUATION_CURVE_SELECTOR
        //#define USE_LC3_OPERATORS
        #define SUBSET_NB
        #define SUBSET_WB
        #define SUBSET_SSWB
+28 −28

File changed.

Contains only whitespace changes.

+19 −19

File changed.

Contains only whitespace changes.