mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-10 09:23:27 +00:00
Support for Signal calls.
Merge in RedPhone // FREEBIE
This commit is contained in:
@@ -0,0 +1,433 @@
|
||||
#!/bin/bash
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # force bash to ignore \r character
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "x64" ] || [ "$2" = "x64" ] || [ "$#" -eq 0 ]
|
||||
then
|
||||
PLATFORM=_X64
|
||||
ISAC=../x64/Release/ReleaseTest-API_2005.exe
|
||||
elif [ "$1" = "LINUX" ] || [ "$2" = "LINUX" ]
|
||||
then
|
||||
PLATFORM=_linux
|
||||
ISAC=../ReleaseTest-API/isacswtest
|
||||
else
|
||||
PLATFORM=_2005
|
||||
ISAC=../win32/Release/ReleaseTest-API_2005.exe
|
||||
fi
|
||||
|
||||
if [ "$#" -eq 0 ] || [ "$1" = "all" ] || [ "$1" = "wb" ]
|
||||
then
|
||||
LOGFILE=logNormal"$PLATFORM".txt
|
||||
echo "START ISAC WB TEST" > $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
|
||||
INFILES=$(cat InputFiles.txt)
|
||||
SUBSET=$(cat InputFilesFew.txt)
|
||||
CHANNELFILES=$(cat ChannelFiles.txt)
|
||||
CHANNELLIST=($(cat ChannelFiles.txt))
|
||||
INDIR=../data/orig
|
||||
OUTDIR=../dataqa"$PLATFORM"
|
||||
mkdir -p $OUTDIR
|
||||
rm -f $OUTDIR/*
|
||||
|
||||
idx=0
|
||||
RATE=10000
|
||||
FRAMESIZE=30
|
||||
|
||||
|
||||
for file in $INFILES # loop over all input files
|
||||
do
|
||||
|
||||
echo "Input file: " $file
|
||||
echo "-----------------------------------"
|
||||
echo "Instantaneous with RATE " $RATE ", and Frame-size " $FRAMESIZE
|
||||
$ISAC -I -B $RATE -FL $FRAMESIZE -FS 16 $INDIR/"$file" $OUTDIR/i_"$FRAMESIZE"_"$RATE"_"$file" >> $LOGFILE
|
||||
echo
|
||||
|
||||
name="${CHANNELLIST[$idx]}"
|
||||
echo "Adaptive with channel file: " $name
|
||||
|
||||
$ISAC -B $INDIR/${CHANNELLIST[$idx]} -FS 16 $INDIR/"$file" $OUTDIR/a_${name%.*}_"$file" >> $LOGFILE
|
||||
|
||||
echo
|
||||
echo
|
||||
|
||||
# alternate between 30 & 60 ms.
|
||||
if [ $FRAMESIZE -eq 30 ]
|
||||
then
|
||||
FRAMESIZE=60
|
||||
else
|
||||
FRAMESIZE=30
|
||||
fi
|
||||
|
||||
# rate between 10000 to 32000 bits/sec
|
||||
if [ $RATE -le 30000 ]
|
||||
then
|
||||
let "RATE=RATE+2000"
|
||||
else
|
||||
let "RATE=10000"
|
||||
fi
|
||||
|
||||
# there are only three channel file
|
||||
if [ $idx -ge 2 ]; then
|
||||
idx=0
|
||||
else
|
||||
let "idx=idx+1"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
idx=0
|
||||
|
||||
# loop over the subset of input files
|
||||
for file in $SUBSET
|
||||
do
|
||||
|
||||
if [ $idx -eq 0 ]; then
|
||||
$ISAC -B $INDIR/${CHANNELLIST[0]} -FL 30 -FIXED_FL -FS 16 $INDIR/"$file" $OUTDIR/a30_"$file" >> $LOGFILE
|
||||
idx=1
|
||||
else
|
||||
$ISAC -B $INDIR/${CHANNELLIST[0]} -FL 60 -FIXED_FL -FS 16 $INDIR/"$file" $OUTDIR/a60_"$file" >> $LOGFILE
|
||||
idx=0
|
||||
fi
|
||||
done
|
||||
|
||||
$ISAC -B $INDIR/${CHANNELLIST[0]} -INITRATE 25000 -FL 30 -FS 16 $INDIR/"$file" $OUTDIR/a60_Init25kbps_"$file" >> $LOGFILE
|
||||
|
||||
echo
|
||||
echo WIDEBAND DONE!
|
||||
echo
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ "$#" -eq 0 ] || [ "$1" = "all" ] || [ "$1" = "swb" ]
|
||||
then
|
||||
|
||||
LOGFILE=logNormal_SWB"$PLATFORM".txt
|
||||
echo "START ISAC SWB TEST" > $LOGFILE
|
||||
echo >> $LOGFILE
|
||||
|
||||
echo STARTING TO TEST SUPER-WIDEBAND
|
||||
|
||||
INFILES=$(cat InputFilesSWB.txt)
|
||||
INDIR=../data/origswb
|
||||
OUTDIR=../dataqaswb"$PLATFORM"
|
||||
mkdir -p $OUTDIR
|
||||
rm -f $OUTDIR/*
|
||||
|
||||
for file in $INFILES
|
||||
do
|
||||
echo
|
||||
echo "Input file: " $file
|
||||
echo "--------------------------------"
|
||||
for RATE in 12000 20000 32000 38000 45000 50000 56000
|
||||
do
|
||||
|
||||
echo "Rate " $RATE
|
||||
$ISAC -I -B $RATE -FL 30 -FS 32 $INDIR/"$file" $OUTDIR/swb_"$RATE"_"$file" >> $LOGFILE
|
||||
echo
|
||||
|
||||
done
|
||||
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$#" -eq 0 ] || [ "$1" = "all" ] || [ "$1" = "API" ]
|
||||
then
|
||||
|
||||
LOGFILE_API=logNormal_API"$PLATFORM".txt
|
||||
echo
|
||||
echo
|
||||
echo "START ISAC API TEST" > $LOGFILE_API
|
||||
echo >> $LOGFILE_API
|
||||
idx=1
|
||||
echo " Test Enforcement of frame-size"
|
||||
echo "========================================================================================"
|
||||
mkdir -p ../FrameSizeLim"$PLATFORM"
|
||||
rm -f ../FrameSizeLim"$PLATFORM"/*
|
||||
echo
|
||||
echo "-- No enforcement; BN 10000"
|
||||
echo
|
||||
$ISAC -B 10000 -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../FrameSizeLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Now Enforce 30 ms frame size with the same bottleneck"
|
||||
echo "There should not be any 60 ms frame"
|
||||
echo
|
||||
$ISAC -B 10000 -FL 30 -FIXED_FL -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../FrameSizeLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- No enforcement; BN 32000"
|
||||
echo
|
||||
$ISAC -B 32000 -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../FrameSizeLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Now Enforce 60 ms frame size with the same bottleneck"
|
||||
echo "There should not be any 30 ms frame"
|
||||
echo
|
||||
$ISAC -B 32000 -FL 60 -FIXED_FL -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../FrameSizeLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
|
||||
echo " Test Limiting of Payload Size and Rate"
|
||||
echo "========================================================================================"
|
||||
mkdir -p ../PayloadLim"$PLATFORM"
|
||||
rm -f ../PayloadLim"$PLATFORM"/*
|
||||
echo
|
||||
echo
|
||||
echo "-- No Limit, frame-size 60 ms, WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 60 -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Payload-size limit of 250, frame-size 60 ms, WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 60 -FS 16 -MAX 250 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Rate limit of 33 kbps for 60 ms frame-size"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 60 -FS 16 -MAXRATE 33000 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- No Limit, frame-size 30 ms, WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 30 -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Payload-size limit of 130, frame-size 30 ms, WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 30 -FS 16 -MAX 130 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Rate limit of 33 kbps for 30 ms frame-size, wideband"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 30 -FS 16 -MAXRATE 33000 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- No limit for 32 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 30 -FS 32 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Payload limit of 130 bytes for 32 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 30 -FS 32 -MAX 130 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- No limit, Rate 45 kbps, 30 ms, SUPER-WIDEBAND, 12 kHz"
|
||||
echo
|
||||
$ISAC -I -B 45000 -FL 30 -FS 32 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Rate limit of 46 kbps for 42 kbps, 30 ms, SUPER-WIDEBAND, 12 kHz"
|
||||
echo
|
||||
$ISAC -I -B 45000 -FL 30 -FS 32 -MAXRATE 46000 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Payload limit of 170 bytes for 45 kbps, 30 ms, SUPER-WIDEBAND, 12 kHz"
|
||||
echo
|
||||
$ISAC -I -B 45000 -FL 30 -FS 32 -MAX 170 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- No limit for 56 kbps, 30 ms, SUPER-WIDEBAND, 16 kHz"
|
||||
echo
|
||||
$ISAC -I -B 56000 -FL 30 -FS 32 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Payload limit of 200 bytes for 56 kbps 30 ms, SUPER-WIDEBAND, 16 kHz"
|
||||
echo
|
||||
$ISAC -I -B 56000 -FL 30 -FS 32 -MAX 200 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
echo "-- Rate limit of 57 kbps for 56 kbps 30 ms, SUPER-WIDEBAND, 16 kHz"
|
||||
echo
|
||||
$ISAC -I -B 56000 -FL 30 -FS 32 -MAXRATE 57000 ../data/origswb/jstest_32.pcm \
|
||||
../PayloadLim"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
|
||||
echo " Test Trans-Coding"
|
||||
echo "========================================================================================"
|
||||
mkdir -p ../Transcoding"$PLATFORM"
|
||||
rm -f ../Transcoding"$PLATFORM"/*
|
||||
echo
|
||||
echo
|
||||
echo "-- 20 kbps, 30 ms, WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 20000 -FL 30 -FS 16 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../Transcoding"$PLATFORM"/APITest_refTrans20WB.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 32 kbps trans-coding to 20 kbps, 30 ms, WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 32000 -FL 30 -FS 16 -T 20000 ../Transcoding"$PLATFORM"/APITest_32T20.pcm \
|
||||
../data/orig/speech_and_misc_WB.pcm ../Transcoding"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
|
||||
echo
|
||||
echo
|
||||
echo "-- 38 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 38000 -FL 30 -FS 32 ../data/origswb/jstest_32.pcm \
|
||||
../Transcoding"$PLATFORM"/APITest_refTrans38.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 45 kbps trans-coding to 38 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 45000 -FL 30 -FS 32 -T 38000 ../Transcoding"$PLATFORM"/APITest_45T38.pcm \
|
||||
../data/origswb/jstest_32.pcm ../Transcoding"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
|
||||
echo
|
||||
echo
|
||||
echo "-- 20 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 20000 -FL 30 -FS 32 ../data/origswb/jstest_32.pcm \
|
||||
../Transcoding"$PLATFORM"/APITest_refTrans20SWB.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 45 kbps trans-coding to 20 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 45000 -FL 30 -FS 32 -T 20000 ../Transcoding"$PLATFORM"/APITest_45T20.pcm \
|
||||
../data/origswb/jstest_32.pcm ../Transcoding"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
echo "-- 50 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 50000 -FL 30 -FS 32 ../data/origswb/jstest_32.pcm \
|
||||
../Transcoding"$PLATFORM"/APITest_refTrans50.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 56 kbps trans-coding to 50 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 56000 -FL 30 -FS 32 -T 50000 ../Transcoding"$PLATFORM"/APITest_56T50.pcm \
|
||||
../data/origswb/jstest_32.pcm ../Transcoding"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 56 kbps trans-coding to 20 kbps, 30 ms, SUPER-WIDEBAND"
|
||||
echo
|
||||
$ISAC -I -B 56000 -FL 30 -FS 32 -T 20000 ../Transcoding"$PLATFORM"/APITest_56T20.pcm \
|
||||
../data/origswb/jstest_32.pcm ../Transcoding"$PLATFORM"/APITest_"$idx".pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo "________________________________________________________"
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
|
||||
echo " Test FEC"
|
||||
echo "========================================================================================"
|
||||
mkdir -p ../FEC"$PLATFORM"
|
||||
rm -f ../FEC"$PLATFORM"/*
|
||||
echo
|
||||
echo
|
||||
echo "-- 32 kbps with transcoding to 20kbps, 30 ms, WIDEBAND, 10% packet loss"
|
||||
$ISAC -I -B 32000 -FL 30 -FS 16 -PL 10 -T 20000 ../FEC"$PLATFORM"/APITest_PL10_WB30_T20.pcm \
|
||||
../data/orig/speech_and_misc_WB.pcm ../FEC"$PLATFORM"/APITest_PL10_WB30.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 32 kbps, 60 ms, WIDEBAND, 10% packet loss"
|
||||
$ISAC -I -B 32000 -FL 60 -FS 16 -PL 10 ../data/orig/speech_and_misc_WB.pcm \
|
||||
../FEC"$PLATFORM"/APITest_PL10_WB60.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 32 kbps with transcoding to 20 kbps, 30 ms, SUPER-WIDEBAND, 10% packet loss"
|
||||
$ISAC -I -B 32000 -FL 30 -FS 32 -PL 10 -T 20000 ../FEC"$PLATFORM"/APITest_PL10_SWB_8kHz_T20.pcm \
|
||||
../data/origswb/jstest_32.pcm ../FEC"$PLATFORM"/APITest_PL10_SWB_8kHz.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 45 kbps with Trascoding to 38 kbps, 30 ms, SUPER-WIDEBAND, 10% packet loss"
|
||||
$ISAC -I -B 45000 -FL 30 -FS 32 -PL 10 -T 38000 ../FEC"$PLATFORM"/APITest_PL10_SWB_12kHz_T38.pcm \
|
||||
../data/origswb/jstest_32.pcm ../FEC"$PLATFORM"/APITest_PL10_SWB_12kHz.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
|
||||
echo "-- 56 kbps with transcoding to 50 kbps, 30 ms, SUPER-WIDEBAND, 10% packet loss"
|
||||
$ISAC -I -B 56000 -FL 30 -FS 32 -PL 10 -T 50000 ../FEC"$PLATFORM"/APITest_PL10_SWB_16kHz_T50.pcm \
|
||||
../data/origswb/jstest_32.pcm ../FEC"$PLATFORM"/APITest_PL10_SWB_16kHz.pcm >> $LOGFILE_API
|
||||
let "idx=idx+1"
|
||||
echo
|
||||
echo
|
||||
fi
|
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # force bash to ignore \r character????? ??????
|
||||
if [ "$1" = "x64" ] || [ "$#" -eq 0 ]
|
||||
then
|
||||
PLATFORM=_X64
|
||||
ISAC=../x64/Release/ReleaseTest-API_2005.exe
|
||||
elif [ "$1" = "2005" ]
|
||||
then
|
||||
PLATFORM=_2005
|
||||
ISAC=../win32/Release/ReleaseTest-API_2005.exe
|
||||
elif [ "$1" == "LINUX" ]
|
||||
then
|
||||
PLATFORM=_linux
|
||||
ISAC=../ReleaseTest-API/isacswtest
|
||||
else
|
||||
echo Unknown Platform
|
||||
exit 2
|
||||
fi
|
||||
|
||||
LOGFILE=logfault$PLATFORM.txt
|
||||
echo "START FAULT TEST" > $LOGFILE
|
||||
|
||||
|
||||
INFILES=$(cat InputFiles.txt)
|
||||
SUBSET=$(cat InputFilesFew.txt)
|
||||
CHANNELFILES=$(cat ChannelFiles.txt)
|
||||
CHANNELLIST=($(cat ChannelFiles.txt))
|
||||
INDIR=../data/orig
|
||||
INDIRSWB=../data/origswb
|
||||
OUTDIR=../dataqaft$PLATFORM
|
||||
mkdir -p $OUTDIR
|
||||
|
||||
#maximum Target rate for different bandwidth
|
||||
TARGETRATE=( 32000 32000 44000 56000 )
|
||||
SAMPFREQ=( 16 32 32 32 )
|
||||
FAULTTEST=(1 2 3 4 5 6 7 9)
|
||||
|
||||
index1=0
|
||||
|
||||
file_wb=../data/orig/16kHz.pcm
|
||||
file_swb=../data/origswb/32kHz.pcm
|
||||
|
||||
for idx in 0 1 2 3
|
||||
do
|
||||
# Fault test
|
||||
echo
|
||||
echo "Sampling Frequency " ${SAMPFREQ[idx]} "kHz, Rate " ${TARGETRATE[idx]} "bps."
|
||||
echo "---------------------------------------------------"
|
||||
if [ ${SAMPFREQ[idx]} -eq 16 ]; then
|
||||
file=$file_wb
|
||||
else
|
||||
file=$file_swb
|
||||
fi
|
||||
|
||||
for testnr in ${FAULTTEST[*]}
|
||||
do
|
||||
echo "Running Fault Test " $testnr
|
||||
$ISAC -I -B "${TARGETRATE[idx]}" -F $testnr -FS "${SAMPFREQ[idx]}" "$file" \
|
||||
$OUTDIR/ft"$testnr"_"${TARGETRATE[idx]}"_"${SAMPFREQ[idx]}".pcm >> LOGFILE
|
||||
echo
|
||||
|
||||
done
|
||||
|
||||
# Fault test number 10, error in bitstream
|
||||
echo "Running Fault Test 10"
|
||||
$ISAC -I -B "${TARGETRATE[idx]}" -F 10 -FS "${SAMPFREQ[idx]}" "$file" \
|
||||
$OUTDIR/ft10_"${TARGETRATE[idx]}"_"${SAMPFREQ[idx]}".pcm >> LOGFILE
|
||||
echo
|
||||
echo "Running Fault Test 10 with packetloss"
|
||||
$ISAC -I -B "${TARGETRATE[idx]}" -F 10 -PL 10 -FS "${SAMPFREQ[idx]}" "$file" \
|
||||
$OUTDIR/ft10plc_"${TARGETRATE[idx]}"_"${SAMPFREQ[idx]}".pcm >> LOGFILE
|
||||
echo
|
||||
done
|
||||
|
||||
echo
|
||||
echo
|
||||
echo DONE!
|
||||
|
||||
|
||||
|
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
(set -o igncr) 2>/dev/null && set -o igncr; # force bash to ignore \r character
|
||||
|
||||
LOGFILE=logfxfl.txt
|
||||
echo "START FIX-FLOAT TEST" > $LOGFILE
|
||||
|
||||
|
||||
ISACFIXFLOAT=../../../fix/test/testFixFloat.exe
|
||||
|
||||
INFILES=$(cat InputFiles.txt)
|
||||
SUBSET=$(cat InputFilesFew.txt)
|
||||
CHANNELFILES=$(cat ChannelFiles.txt)
|
||||
CHANNELLIST=($(cat ChannelFiles.txt))
|
||||
INDIR=../data/orig
|
||||
OUTDIR=../dataqafxfl
|
||||
mkdir -p $OUTDIR
|
||||
|
||||
index1=0
|
||||
|
||||
for file in $INFILES # loop over all input files
|
||||
do
|
||||
|
||||
for channel in $CHANNELFILES
|
||||
do
|
||||
let "index1=index1+1"
|
||||
|
||||
$ISACFIXFLOAT $INDIR/$channel -m 1 -PLC $INDIR/"$file" $OUTDIR/flfx$index1"$file" >> $LOGFILE
|
||||
$ISACFIXFLOAT $INDIR/$channel -m 2 -PLC $INDIR/"$file" $OUTDIR/fxfl$index1"$file" >> $LOGFILE
|
||||
done
|
||||
|
||||
done
|
||||
|
||||
index1=0
|
||||
|
||||
for file in $SUBSET # loop over the subset of input files
|
||||
do
|
||||
let "index1=index1+1"
|
||||
$ISACFIXFLOAT $INDIR/$channel -m 1 -NB 1 $INDIR/"$file" $OUTDIR/flfxnb1_$index1"$file" >> $LOGFILE
|
||||
$ISACFIXFLOAT $INDIR/$channel -m 2 -NB 1 $INDIR/"$file" $OUTDIR/fxflnb1_$index1"$file" >> $LOGFILE
|
||||
$ISACFIXFLOAT $INDIR/$channel -m 1 -NB 2 -PLC $INDIR/"$file" $OUTDIR/flfxnb2_$index1"$file" >> $LOGFILE
|
||||
$ISACFIXFLOAT $INDIR/$channel -m 2 -NB 2 -PLC $INDIR/"$file" $OUTDIR/fxflnb2_$index1"$file" >> $LOGFILE
|
||||
done
|
||||
|
||||
echo DONE!
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// SwitchingSampRate.cpp : Defines the entry point for the console
|
||||
// application.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "isac.h"
|
||||
#include "utility.h"
|
||||
#include "signal_processing_library.h"
|
||||
|
||||
#define MAX_FILE_NAME 500
|
||||
#define MAX_NUM_CLIENTS 2
|
||||
|
||||
|
||||
#define NUM_CLIENTS 2
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char fileNameWB[MAX_FILE_NAME];
|
||||
char fileNameSWB[MAX_FILE_NAME];
|
||||
|
||||
char outFileName[MAX_NUM_CLIENTS][MAX_FILE_NAME];
|
||||
|
||||
FILE* inFile[MAX_NUM_CLIENTS];
|
||||
FILE* outFile[MAX_NUM_CLIENTS];
|
||||
|
||||
ISACStruct* codecInstance[MAX_NUM_CLIENTS];
|
||||
int32_t resamplerState[MAX_NUM_CLIENTS][8];
|
||||
|
||||
int encoderSampRate[MAX_NUM_CLIENTS];
|
||||
|
||||
int minBn = 16000;
|
||||
int maxBn = 56000;
|
||||
|
||||
int bnWB = 32000;
|
||||
int bnSWB = 56000;
|
||||
|
||||
strcpy(outFileName[0], "switchSampRate_out1.pcm");
|
||||
strcpy(outFileName[1], "switchSampRate_out2.pcm");
|
||||
|
||||
short clientCntr;
|
||||
|
||||
unsigned int lenEncodedInBytes[MAX_NUM_CLIENTS];
|
||||
unsigned int lenAudioIn10ms[MAX_NUM_CLIENTS];
|
||||
unsigned int lenEncodedInBytesTmp[MAX_NUM_CLIENTS];
|
||||
unsigned int lenAudioIn10msTmp[MAX_NUM_CLIENTS];
|
||||
BottleNeckModel* packetData[MAX_NUM_CLIENTS];
|
||||
|
||||
char versionNumber[100];
|
||||
short samplesIn10ms[MAX_NUM_CLIENTS];
|
||||
int bottleneck[MAX_NUM_CLIENTS];
|
||||
|
||||
printf("\n\n");
|
||||
printf("____________________________________________\n\n");
|
||||
WebRtcIsac_version(versionNumber);
|
||||
printf(" iSAC-swb version %s\n", versionNumber);
|
||||
printf("____________________________________________\n");
|
||||
|
||||
|
||||
fileNameWB[0] = '\0';
|
||||
fileNameSWB[0] = '\0';
|
||||
|
||||
char myFlag[20];
|
||||
strcpy(myFlag, "-wb");
|
||||
// READ THE WIDEBAND AND SUPER-WIDEBAND FILE NAMES
|
||||
if(readParamString(argc, argv, myFlag, fileNameWB, MAX_FILE_NAME) <= 0)
|
||||
{
|
||||
printf("No wideband file is specified");
|
||||
}
|
||||
|
||||
strcpy(myFlag, "-swb");
|
||||
if(readParamString(argc, argv, myFlag, fileNameSWB, MAX_FILE_NAME) <= 0)
|
||||
{
|
||||
printf("No super-wideband file is specified");
|
||||
}
|
||||
|
||||
// THE FIRST CLIENT STARTS IN WIDEBAND
|
||||
encoderSampRate[0] = 16000;
|
||||
OPEN_FILE_RB(inFile[0], fileNameWB);
|
||||
|
||||
// THE SECOND CLIENT STARTS IN SUPER-WIDEBAND
|
||||
encoderSampRate[1] = 32000;
|
||||
OPEN_FILE_RB(inFile[1], fileNameSWB);
|
||||
|
||||
strcpy(myFlag, "-I");
|
||||
short codingMode = readSwitch(argc, argv, myFlag);
|
||||
|
||||
for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
|
||||
{
|
||||
codecInstance[clientCntr] = NULL;
|
||||
|
||||
printf("\n");
|
||||
printf("Client %d\n", clientCntr + 1);
|
||||
printf("---------\n");
|
||||
printf("Starting %s",
|
||||
(encoderSampRate[clientCntr] == 16000)
|
||||
? "wideband":"super-wideband");
|
||||
|
||||
// Open output File Name
|
||||
OPEN_FILE_WB(outFile[clientCntr], outFileName[clientCntr]);
|
||||
printf("Output File...................... %s\n", outFileName[clientCntr]);
|
||||
|
||||
samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10;
|
||||
|
||||
if(codingMode == 1)
|
||||
{
|
||||
bottleneck[clientCntr] = (clientCntr)? bnSWB:bnWB;
|
||||
}
|
||||
else
|
||||
{
|
||||
bottleneck[clientCntr] = (clientCntr)? minBn:maxBn;
|
||||
}
|
||||
|
||||
printf("Bottleneck....................... %0.3f kbits/sec \n",
|
||||
bottleneck[clientCntr] / 1000.0);
|
||||
|
||||
// coding-mode
|
||||
printf("Encoding Mode.................... %s\n",
|
||||
(codingMode == 1)? "Channel-Independent (Instantaneous)":"Adaptive");
|
||||
|
||||
lenEncodedInBytes[clientCntr] = 0;
|
||||
lenAudioIn10ms[clientCntr] = 0;
|
||||
lenEncodedInBytesTmp[clientCntr] = 0;
|
||||
lenAudioIn10msTmp[clientCntr] = 0;
|
||||
|
||||
packetData[clientCntr] = (BottleNeckModel*)new(BottleNeckModel);
|
||||
if(packetData[clientCntr] == NULL)
|
||||
{
|
||||
printf("Could not allocate memory for packetData \n");
|
||||
return -1;
|
||||
}
|
||||
memset(packetData[clientCntr], 0, sizeof(BottleNeckModel));
|
||||
memset(resamplerState[clientCntr], 0, sizeof(int32_t) * 8);
|
||||
}
|
||||
|
||||
for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
|
||||
{
|
||||
// Create
|
||||
if(WebRtcIsac_Create(&codecInstance[clientCntr]))
|
||||
{
|
||||
printf("Could not creat client %d\n", clientCntr + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtcIsac_SetEncSampRate(codecInstance[clientCntr], encoderSampRate[clientCntr]);
|
||||
|
||||
WebRtcIsac_SetDecSampRate(codecInstance[clientCntr],
|
||||
encoderSampRate[clientCntr + (1 - ((clientCntr & 1)<<1))]);
|
||||
|
||||
// Initialize Encoder
|
||||
if(WebRtcIsac_EncoderInit(codecInstance[clientCntr],
|
||||
codingMode) < 0)
|
||||
{
|
||||
printf("Could not initialize client, %d\n", clientCntr + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Initialize Decoder
|
||||
if(WebRtcIsac_DecoderInit(codecInstance[clientCntr]) < 0)
|
||||
{
|
||||
printf("Could not initialize decoder of client %d\n",
|
||||
clientCntr + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// setup Rate if in Instantaneous mode
|
||||
if(codingMode != 0)
|
||||
{
|
||||
// ONLY Clients who are not in Adaptive mode
|
||||
if(WebRtcIsac_Control(codecInstance[clientCntr],
|
||||
bottleneck[clientCntr], 30) < 0)
|
||||
{
|
||||
printf("Could not setup bottleneck and frame-size for client %d\n",
|
||||
clientCntr + 1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
short streamLen;
|
||||
short numSamplesRead;
|
||||
short lenDecodedAudio;
|
||||
short senderIdx;
|
||||
short receiverIdx;
|
||||
|
||||
printf("\n");
|
||||
short num10ms[MAX_NUM_CLIENTS];
|
||||
memset(num10ms, 0, sizeof(short)*MAX_NUM_CLIENTS);
|
||||
FILE* arrivalTimeFile1 = fopen("arrivalTime1.dat", "wb");
|
||||
FILE* arrivalTimeFile2 = fopen("arrivalTime2.dat", "wb");
|
||||
short numPrint[MAX_NUM_CLIENTS];
|
||||
memset(numPrint, 0, sizeof(short) * MAX_NUM_CLIENTS);
|
||||
|
||||
// Audio Buffers
|
||||
short silence10ms[10 * 32];
|
||||
memset(silence10ms, 0, 320 * sizeof(short));
|
||||
short audioBuff10ms[10 * 32];
|
||||
short audioBuff60ms[60 * 32];
|
||||
short resampledAudio60ms[60 * 32];
|
||||
|
||||
unsigned short bitStream[600+600];
|
||||
short speechType[1];
|
||||
|
||||
short numSampFreqChanged = 0;
|
||||
while(numSampFreqChanged < 10)
|
||||
{
|
||||
for(clientCntr = 0; clientCntr < NUM_CLIENTS; clientCntr++)
|
||||
{
|
||||
// Encoding/decoding for this pair of clients, if there is
|
||||
// audio for any of them
|
||||
//if(audioLeft[clientCntr] || audioLeft[clientCntr + 1])
|
||||
//{
|
||||
//for(pairCntr = 0; pairCntr < 2; pairCntr++)
|
||||
//{
|
||||
senderIdx = clientCntr; // + pairCntr;
|
||||
receiverIdx = 1 - clientCntr;// + (1 - pairCntr);
|
||||
|
||||
//if(num10ms[senderIdx] > 6)
|
||||
//{
|
||||
// printf("Too many frames read for client %d",
|
||||
// senderIdx + 1);
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
numSamplesRead = (short)fread(audioBuff10ms, sizeof(short),
|
||||
samplesIn10ms[senderIdx], inFile[senderIdx]);
|
||||
if(numSamplesRead != samplesIn10ms[senderIdx])
|
||||
{
|
||||
// file finished switch encoder sampling frequency.
|
||||
printf("Changing Encoder Sampling frequency in client %d to ", senderIdx+1);
|
||||
fclose(inFile[senderIdx]);
|
||||
numSampFreqChanged++;
|
||||
if(encoderSampRate[senderIdx] == 16000)
|
||||
{
|
||||
printf("super-wideband.\n");
|
||||
OPEN_FILE_RB(inFile[senderIdx], fileNameSWB);
|
||||
encoderSampRate[senderIdx] = 32000;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("wideband.\n");
|
||||
OPEN_FILE_RB(inFile[senderIdx], fileNameWB);
|
||||
encoderSampRate[senderIdx] = 16000;
|
||||
}
|
||||
WebRtcIsac_SetEncSampRate(codecInstance[senderIdx], encoderSampRate[senderIdx]);
|
||||
WebRtcIsac_SetDecSampRate(codecInstance[receiverIdx], encoderSampRate[senderIdx]);
|
||||
|
||||
samplesIn10ms[clientCntr] = encoderSampRate[clientCntr] * 10;
|
||||
|
||||
numSamplesRead = (short)fread(audioBuff10ms, sizeof(short),
|
||||
samplesIn10ms[senderIdx], inFile[senderIdx]);
|
||||
if(numSamplesRead != samplesIn10ms[senderIdx])
|
||||
{
|
||||
printf(" File %s for client %d has not enough audio\n",
|
||||
(encoderSampRate[senderIdx]==16000)? "wideband":"super-wideband",
|
||||
senderIdx + 1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
num10ms[senderIdx]++;
|
||||
|
||||
// sanity check
|
||||
//if(num10ms[senderIdx] > 6)
|
||||
//{
|
||||
// printf("Client %d has got more than 60 ms audio and encoded no packet.\n",
|
||||
// senderIdx);
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
// Encode
|
||||
|
||||
|
||||
streamLen = WebRtcIsac_Encode(codecInstance[senderIdx],
|
||||
audioBuff10ms, (short*)bitStream);
|
||||
int16_t ggg;
|
||||
if (streamLen > 0) {
|
||||
if(( WebRtcIsac_ReadFrameLen(codecInstance[receiverIdx],
|
||||
(short *) bitStream, &ggg))<0)
|
||||
printf("ERROR\n");
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if(streamLen < 0)
|
||||
{
|
||||
printf(" Encoder error in client %d \n", senderIdx + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(streamLen > 0)
|
||||
{
|
||||
// Packet generated; model sending through a channel, do bandwidth
|
||||
// estimation at the receiver and decode.
|
||||
lenEncodedInBytes[senderIdx] += streamLen;
|
||||
lenAudioIn10ms[senderIdx] += (unsigned int)num10ms[senderIdx];
|
||||
lenEncodedInBytesTmp[senderIdx] += streamLen;
|
||||
lenAudioIn10msTmp[senderIdx] += (unsigned int)num10ms[senderIdx];
|
||||
|
||||
// Print after ~5 sec.
|
||||
if(lenAudioIn10msTmp[senderIdx] >= 100)
|
||||
{
|
||||
numPrint[senderIdx]++;
|
||||
printf(" %d, %6.3f => %6.3f ", senderIdx+1,
|
||||
bottleneck[senderIdx] / 1000.0,
|
||||
lenEncodedInBytesTmp[senderIdx] * 0.8 /
|
||||
lenAudioIn10msTmp[senderIdx]);
|
||||
|
||||
if(codingMode == 0)
|
||||
{
|
||||
int32_t bn;
|
||||
WebRtcIsac_GetUplinkBw(codecInstance[senderIdx], &bn);
|
||||
printf("[%d] ", bn);
|
||||
}
|
||||
//int16_t rateIndexLB;
|
||||
//int16_t rateIndexUB;
|
||||
//WebRtcIsac_GetDownLinkBwIndex(codecInstance[receiverIdx],
|
||||
// &rateIndexLB, &rateIndexUB);
|
||||
//printf(" (%2d, %2d) ", rateIndexLB, rateIndexUB);
|
||||
|
||||
cout << flush;
|
||||
lenEncodedInBytesTmp[senderIdx] = 0;
|
||||
lenAudioIn10msTmp[senderIdx] = 0;
|
||||
//if(senderIdx == (NUM_CLIENTS - 1))
|
||||
//{
|
||||
printf(" %0.1f \n", lenAudioIn10ms[senderIdx] * 10. /1000);
|
||||
//}
|
||||
|
||||
// After ~20 sec change the bottleneck.
|
||||
// if((numPrint[senderIdx] == 4) && (codingMode == 0))
|
||||
// {
|
||||
// numPrint[senderIdx] = 0;
|
||||
// if(codingMode == 0)
|
||||
// {
|
||||
// int newBottleneck = bottleneck[senderIdx] +
|
||||
// (bottleneckChange[senderIdx] * 1000);
|
||||
|
||||
// if(bottleneckChange[senderIdx] > 0)
|
||||
// {
|
||||
// if(newBottleneck >maxBn)
|
||||
// {
|
||||
// bottleneckChange[senderIdx] = -1;
|
||||
// newBottleneck = bottleneck[senderIdx] +
|
||||
// (bottleneckChange[senderIdx] * 1000);
|
||||
// if(newBottleneck > minBn)
|
||||
// {
|
||||
// bottleneck[senderIdx] = newBottleneck;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// bottleneck[senderIdx] = newBottleneck;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(newBottleneck < minBn)
|
||||
// {
|
||||
// bottleneckChange[senderIdx] = 1;
|
||||
// newBottleneck = bottleneck[senderIdx] +
|
||||
// (bottleneckChange[senderIdx] * 1000);
|
||||
// if(newBottleneck < maxBn)
|
||||
// {
|
||||
// bottleneck[senderIdx] = newBottleneck;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// bottleneck[senderIdx] = newBottleneck;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// model a channel of given bottleneck, to get the receive timestamp
|
||||
get_arrival_time(num10ms[senderIdx] * samplesIn10ms[senderIdx],
|
||||
streamLen, bottleneck[senderIdx], packetData[senderIdx],
|
||||
encoderSampRate[senderIdx]*1000, encoderSampRate[senderIdx]*1000);
|
||||
|
||||
// Write the arrival time.
|
||||
if(senderIdx == 0)
|
||||
{
|
||||
if (fwrite(&(packetData[senderIdx]->arrival_time),
|
||||
sizeof(unsigned int),
|
||||
1, arrivalTimeFile1) != 1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwrite(&(packetData[senderIdx]->arrival_time),
|
||||
sizeof(unsigned int),
|
||||
1, arrivalTimeFile2) != 1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// BWE
|
||||
if(WebRtcIsac_UpdateBwEstimate(codecInstance[receiverIdx],
|
||||
bitStream, streamLen, packetData[senderIdx]->rtp_number,
|
||||
packetData[senderIdx]->sample_count,
|
||||
packetData[senderIdx]->arrival_time) < 0)
|
||||
{
|
||||
printf(" BWE Error at client %d \n", receiverIdx + 1);
|
||||
return -1;
|
||||
}
|
||||
/**/
|
||||
// Decode
|
||||
lenDecodedAudio = WebRtcIsac_Decode(
|
||||
codecInstance[receiverIdx], bitStream, streamLen,
|
||||
audioBuff60ms, speechType);
|
||||
if(lenDecodedAudio < 0)
|
||||
{
|
||||
printf(" Decoder error in client %d \n", receiverIdx + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(encoderSampRate[senderIdx] == 16000)
|
||||
{
|
||||
WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms,
|
||||
resamplerState[receiverIdx]);
|
||||
if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1,
|
||||
outFile[receiverIdx]) !=
|
||||
static_cast<size_t>(lenDecodedAudio << 1)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio,
|
||||
outFile[receiverIdx]) !=
|
||||
static_cast<size_t>(lenDecodedAudio)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
num10ms[senderIdx] = 0;
|
||||
}
|
||||
//}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can 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_TEST_DEBUGUTILITY_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_TEST_DEBUGUTILITY_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "utility.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FILE* res0to4FilePtr;
|
||||
FILE* res4to8FilePtr;
|
||||
FILE* res8to12FilePtr;
|
||||
FILE* res8to16FilePtr;
|
||||
|
||||
FILE* res0to4DecFilePtr;
|
||||
FILE* res4to8DecFilePtr;
|
||||
FILE* res8to12DecFilePtr;
|
||||
FILE* res8to16DecFilePtr;
|
||||
|
||||
FILE* in0to4FilePtr;
|
||||
FILE* in4to8FilePtr;
|
||||
FILE* in8to12FilePtr;
|
||||
FILE* in8to16FilePtr;
|
||||
|
||||
FILE* out0to4FilePtr;
|
||||
FILE* out4to8FilePtr;
|
||||
FILE* out8to12FilePtr;
|
||||
FILE* out8to16FilePtr;
|
||||
|
||||
FILE* fftFilePtr;
|
||||
FILE* fftDecFilePtr;
|
||||
|
||||
FILE* arrivalTime;
|
||||
|
||||
float lastArrivalTime;
|
||||
|
||||
int prevPacketLost;
|
||||
int currPacketLost;
|
||||
int nextPacketLost;
|
||||
|
||||
//double residualSignal4kHZ[240];
|
||||
int packetLossPercent;
|
||||
|
||||
int maxPayloadLB;
|
||||
int maxPayloadUB;
|
||||
int lbBytes;
|
||||
int ubBytes;
|
||||
|
||||
|
||||
}debugStruct;
|
||||
|
||||
|
||||
#define PRINT_ENTROPY_INFO(obj) \
|
||||
do \
|
||||
{ \
|
||||
printf("%10u, %u; ", \
|
||||
obj->bitstr_obj.streamval, obj->bitstr_obj.stream_index); \
|
||||
} while(0)
|
||||
|
||||
int setupDebugStruct(debugStruct* str);
|
||||
|
||||
#endif
|
@@ -0,0 +1,645 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "windows.h"
|
||||
#define CLOCKS_PER_SEC 1000
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
/* include API */
|
||||
#include "isac.h"
|
||||
#include "utility.h"
|
||||
//#include "commonDefs.h"
|
||||
|
||||
/* max number of samples per frame (= 60 ms frame) */
|
||||
#define MAX_FRAMESAMPLES_SWB 1920
|
||||
/* number of samples per 10ms frame */
|
||||
#define FRAMESAMPLES_SWB_10ms 320
|
||||
#define FRAMESAMPLES_WB_10ms 160
|
||||
|
||||
/* sampling frequency (Hz) */
|
||||
#define FS_SWB 32000
|
||||
#define FS_WB 16000
|
||||
|
||||
//#define CHANGE_OUTPUT_NAME
|
||||
|
||||
#ifdef HAVE_DEBUG_INFO
|
||||
#include "debugUtility.h"
|
||||
debugStruct debugInfo;
|
||||
#endif
|
||||
|
||||
unsigned long framecnt = 0;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
//--- File IO ----
|
||||
FILE* inp;
|
||||
FILE* outp;
|
||||
char inname[500];
|
||||
char outname[500];
|
||||
|
||||
/* Runtime statistics */
|
||||
double rate;
|
||||
double rateRCU;
|
||||
unsigned long totalbits = 0;
|
||||
unsigned long totalBitsRCU = 0;
|
||||
unsigned long totalsmpls =0;
|
||||
|
||||
int32_t bottleneck = 39;
|
||||
int16_t frameSize = 30; /* ms */
|
||||
int16_t codingMode = 1;
|
||||
int16_t shortdata[FRAMESAMPLES_SWB_10ms];
|
||||
int16_t decoded[MAX_FRAMESAMPLES_SWB];
|
||||
//uint16_t streamdata[1000];
|
||||
int16_t speechType[1];
|
||||
int16_t payloadLimit;
|
||||
int32_t rateLimit;
|
||||
ISACStruct* ISAC_main_inst;
|
||||
|
||||
int16_t stream_len = 0;
|
||||
int16_t declen = 0;
|
||||
int16_t err;
|
||||
int16_t cur_framesmpls;
|
||||
int endfile;
|
||||
#ifdef WIN32
|
||||
double length_file;
|
||||
double runtime;
|
||||
char outDrive[10];
|
||||
char outPath[500];
|
||||
char outPrefix[500];
|
||||
char outSuffix[500];
|
||||
char bitrateFileName[500];
|
||||
FILE* bitrateFile;
|
||||
double starttime;
|
||||
double rateLB = 0;
|
||||
double rateUB = 0;
|
||||
#endif
|
||||
FILE* histFile;
|
||||
FILE* averageFile;
|
||||
int sampFreqKHz;
|
||||
int samplesIn10Ms;
|
||||
int16_t maxStreamLen = 0;
|
||||
char histFileName[500];
|
||||
char averageFileName[500];
|
||||
unsigned int hist[600];
|
||||
unsigned int tmpSumStreamLen = 0;
|
||||
unsigned int packetCntr = 0;
|
||||
unsigned int lostPacketCntr = 0;
|
||||
uint16_t payload[600];
|
||||
uint16_t payloadRCU[600];
|
||||
uint16_t packetLossPercent = 0;
|
||||
int16_t rcuStreamLen = 0;
|
||||
int onlyEncode;
|
||||
int onlyDecode;
|
||||
|
||||
|
||||
BottleNeckModel packetData;
|
||||
packetData.arrival_time = 0;
|
||||
packetData.sample_count = 0;
|
||||
packetData.rtp_number = 0;
|
||||
memset(hist, 0, sizeof(hist));
|
||||
|
||||
/* handling wrong input arguments in the command line */
|
||||
if(argc < 5)
|
||||
{
|
||||
int size;
|
||||
WebRtcIsac_AssignSize(&size);
|
||||
|
||||
printf("\n\nWrong number of arguments or flag values.\n\n");
|
||||
|
||||
printf("Usage:\n\n");
|
||||
printf("%s infile outfile -bn bottelneck [options] \n\n", argv[0]);
|
||||
printf("with:\n");
|
||||
printf("-I................... indicates encoding in instantaneous mode.\n");
|
||||
printf("-bn bottleneck....... the value of the bottleneck in bit/sec, e.g. 39742,\n");
|
||||
printf(" in instantaneous (channel-independent) mode.\n\n");
|
||||
printf("infile............... Normal speech input file\n\n");
|
||||
printf("outfile.............. Speech output file\n\n");
|
||||
printf("OPTIONS\n");
|
||||
printf("-------\n");
|
||||
printf("-fs sampFreq......... sampling frequency of codec 16 or 32 (default) kHz.\n");
|
||||
printf("-plim payloadLim..... payload limit in bytes,\n");
|
||||
printf(" default is the maximum possible.\n");
|
||||
printf("-rlim rateLim........ rate limit in bits/sec, \n");
|
||||
printf(" default is the maimum possible.\n");
|
||||
printf("-h file.............. record histogram and *append* to 'file'.\n");
|
||||
printf("-ave file............ record average rate of 3 sec intervales and *append* to 'file'.\n");
|
||||
printf("-ploss............... packet-loss percentage.\n");
|
||||
printf("-enc................. do only encoding and store the bit-stream\n");
|
||||
printf("-dec................. the input file is a bit-stream, decode it.\n");
|
||||
|
||||
printf("\n");
|
||||
printf("Example usage:\n\n");
|
||||
printf("%s speechIn.pcm speechOut.pcm -B 40000 -fs 32 \n\n", argv[0]);
|
||||
|
||||
printf("structure size %d bytes\n", size);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Get Bottleneck value */
|
||||
bottleneck = readParamInt(argc, argv, "-bn", 50000);
|
||||
fprintf(stderr,"\nfixed bottleneck rate of %d bits/s\n\n", bottleneck);
|
||||
|
||||
/* Get Input and Output files */
|
||||
sscanf(argv[1], "%s", inname);
|
||||
sscanf(argv[2], "%s", outname);
|
||||
codingMode = readSwitch(argc, argv, "-I");
|
||||
sampFreqKHz = (int16_t)readParamInt(argc, argv, "-fs", 32);
|
||||
if(readParamString(argc, argv, "-h", histFileName, 500) > 0)
|
||||
{
|
||||
histFile = fopen(histFileName, "a");
|
||||
if(histFile == NULL)
|
||||
{
|
||||
printf("cannot open hist file %s", histFileName);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NO recording of hitstogram
|
||||
histFile = NULL;
|
||||
}
|
||||
|
||||
|
||||
packetLossPercent = readParamInt(argc, argv, "-ploss", 0);
|
||||
|
||||
if(readParamString(argc, argv, "-ave", averageFileName, 500) > 0)
|
||||
{
|
||||
averageFile = fopen(averageFileName, "a");
|
||||
if(averageFile == NULL)
|
||||
{
|
||||
printf("cannot open file to write rate %s", averageFileName);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
averageFile = NULL;
|
||||
}
|
||||
|
||||
onlyEncode = readSwitch(argc, argv, "-enc");
|
||||
onlyDecode = readSwitch(argc, argv, "-dec");
|
||||
|
||||
|
||||
switch(sampFreqKHz)
|
||||
{
|
||||
case 16:
|
||||
{
|
||||
samplesIn10Ms = 160;
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
samplesIn10Ms = 320;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("A sampling frequency of %d kHz is not supported,\
|
||||
valid values are 8 and 16.\n", sampFreqKHz);
|
||||
exit(-1);
|
||||
}
|
||||
payloadLimit = (int16_t)readParamInt(argc, argv, "-plim", 400);
|
||||
rateLimit = readParamInt(argc, argv, "-rlim", 106800);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
_splitpath(outname, outDrive, outPath, outPrefix, outSuffix);
|
||||
_makepath(bitrateFileName, outDrive, outPath, "bitrate", ".txt");
|
||||
|
||||
bitrateFile = fopen(bitrateFileName, "a");
|
||||
fprintf(bitrateFile, "% %%s \n", inname);
|
||||
#endif
|
||||
|
||||
printf("\n");
|
||||
printf("Input.................... %s\n", inname);
|
||||
printf("Output................... %s\n", outname);
|
||||
printf("Encoding Mode............ %s\n",
|
||||
(codingMode == 1)? "Channel-Independent":"Channel-Adaptive");
|
||||
printf("Bottleneck............... %d bits/sec\n", bottleneck);
|
||||
printf("Packet-loss Percentage... %d\n", packetLossPercent);
|
||||
printf("\n");
|
||||
|
||||
#ifdef WIN32
|
||||
starttime = clock()/(double)CLOCKS_PER_SEC; /* Runtime statistics */
|
||||
#endif
|
||||
|
||||
/* Initialize the ISAC and BN structs */
|
||||
err = WebRtcIsac_Create(&ISAC_main_inst);
|
||||
|
||||
WebRtcIsac_SetEncSampRate(ISAC_main_inst, sampFreqKHz * 1000);
|
||||
WebRtcIsac_SetDecSampRate(ISAC_main_inst, sampFreqKHz >= 32 ? 32000 :
|
||||
16000);
|
||||
/* Error check */
|
||||
if (err < 0) {
|
||||
fprintf(stderr,"\n\n Error in create.\n\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
framecnt = 0;
|
||||
endfile = 0;
|
||||
|
||||
/* Initialize encoder and decoder */
|
||||
if(WebRtcIsac_EncoderInit(ISAC_main_inst, codingMode) < 0)
|
||||
{
|
||||
printf("cannot initialize encoder\n");
|
||||
return -1;
|
||||
}
|
||||
if(WebRtcIsac_DecoderInit(ISAC_main_inst) < 0)
|
||||
{
|
||||
printf("cannot initialize decoder\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//{
|
||||
// int32_t b1, b2;
|
||||
// FILE* fileID = fopen("GetBNTest.txt", "w");
|
||||
// b2 = 32100;
|
||||
// while(b2 <= 52000)
|
||||
// {
|
||||
// WebRtcIsac_Control(ISAC_main_inst, b2, frameSize);
|
||||
// WebRtcIsac_GetUplinkBw(ISAC_main_inst, &b1);
|
||||
// fprintf(fileID, "%5d %5d\n", b2, b1);
|
||||
// b2 += 10;
|
||||
// }
|
||||
//}
|
||||
|
||||
if(codingMode == 1)
|
||||
{
|
||||
if(WebRtcIsac_Control(ISAC_main_inst, bottleneck, frameSize) < 0)
|
||||
{
|
||||
printf("cannot set bottleneck\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(WebRtcIsac_ControlBwe(ISAC_main_inst, 15000, 30, 1) < 0)
|
||||
{
|
||||
printf("cannot configure BWE\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(WebRtcIsac_SetMaxPayloadSize(ISAC_main_inst, payloadLimit) < 0)
|
||||
{
|
||||
printf("cannot set maximum payload size %d.\n", payloadLimit);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rateLimit < 106800) {
|
||||
if(WebRtcIsac_SetMaxRate(ISAC_main_inst, rateLimit) < 0)
|
||||
{
|
||||
printf("cannot set the maximum rate %d.\n", rateLimit);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================
|
||||
//#ifdef HAVE_DEBUG_INFO
|
||||
// if(setupDebugStruct(&debugInfo) < 0)
|
||||
// {
|
||||
// exit(1);
|
||||
// }
|
||||
//#endif
|
||||
|
||||
while (endfile == 0)
|
||||
{
|
||||
fprintf(stderr," \rframe = %7li", framecnt);
|
||||
|
||||
//============== Readind from the file and encoding =================
|
||||
cur_framesmpls = 0;
|
||||
stream_len = 0;
|
||||
|
||||
|
||||
if(onlyDecode)
|
||||
{
|
||||
uint8_t auxUW8;
|
||||
size_t auxSizet;
|
||||
if(fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream_len = ((uint8_t)auxUW8) << 8;
|
||||
if(fread(&auxUW8, sizeof(uint8_t), 1, inp) < 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
stream_len |= (uint16_t)auxUW8;
|
||||
auxSizet = (size_t)stream_len;
|
||||
if(fread(payload, 1, auxSizet, inp) < auxSizet)
|
||||
{
|
||||
printf("last payload is corrupted\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(stream_len == 0)
|
||||
{
|
||||
// Read 10 ms speech block
|
||||
endfile = readframe(shortdata, inp, samplesIn10Ms);
|
||||
if(endfile)
|
||||
{
|
||||
break;
|
||||
}
|
||||
cur_framesmpls += samplesIn10Ms;
|
||||
|
||||
//-------- iSAC encoding ---------
|
||||
stream_len = WebRtcIsac_Encode(ISAC_main_inst, shortdata,
|
||||
(int16_t*)payload);
|
||||
|
||||
if(stream_len < 0)
|
||||
{
|
||||
// exit if returned with error
|
||||
//errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
|
||||
fprintf(stderr,"\nError in encoder\n");
|
||||
getchar();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//===================================================================
|
||||
if(endfile)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
rcuStreamLen = WebRtcIsac_GetRedPayload(ISAC_main_inst, (int16_t*)payloadRCU);
|
||||
|
||||
get_arrival_time(cur_framesmpls, stream_len, bottleneck, &packetData,
|
||||
sampFreqKHz * 1000, sampFreqKHz * 1000);
|
||||
if(WebRtcIsac_UpdateBwEstimate(ISAC_main_inst,
|
||||
payload, stream_len, packetData.rtp_number,
|
||||
packetData.sample_count,
|
||||
packetData.arrival_time) < 0)
|
||||
{
|
||||
printf(" BWE Error at client\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(endfile)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
maxStreamLen = (stream_len > maxStreamLen)? stream_len:maxStreamLen;
|
||||
packetCntr++;
|
||||
|
||||
hist[stream_len]++;
|
||||
if(averageFile != NULL)
|
||||
{
|
||||
tmpSumStreamLen += stream_len;
|
||||
if(packetCntr == 100)
|
||||
{
|
||||
// kbps
|
||||
fprintf(averageFile, "%8.3f ", (double)tmpSumStreamLen * 8.0 / (30.0 * packetCntr));
|
||||
packetCntr = 0;
|
||||
tmpSumStreamLen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(onlyEncode)
|
||||
{
|
||||
uint8_t auxUW8;
|
||||
auxUW8 = (uint8_t)(((stream_len & 0x7F00) >> 8) & 0xFF);
|
||||
if (fwrite(&auxUW8, sizeof(uint8_t), 1, outp) != 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
auxUW8 = (uint8_t)(stream_len & 0xFF);
|
||||
if (fwrite(&auxUW8, sizeof(uint8_t), 1, outp) != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (fwrite(payload, 1, stream_len,
|
||||
outp) != (size_t)stream_len) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//======================= iSAC decoding ===========================
|
||||
|
||||
if((rand() % 100) < packetLossPercent)
|
||||
{
|
||||
declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, payloadRCU,
|
||||
rcuStreamLen, decoded, speechType);
|
||||
lostPacketCntr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
declen = WebRtcIsac_Decode(ISAC_main_inst, payload,
|
||||
stream_len, decoded, speechType);
|
||||
}
|
||||
if(declen <= 0)
|
||||
{
|
||||
//errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
|
||||
fprintf(stderr,"\nError in decoder.\n");
|
||||
getchar();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Write decoded speech frame to file
|
||||
if (fwrite(decoded, sizeof(int16_t),
|
||||
declen, outp) != (size_t)declen) {
|
||||
return -1;
|
||||
}
|
||||
cur_framesmpls = declen;
|
||||
}
|
||||
// Update Statistics
|
||||
framecnt++;
|
||||
totalsmpls += cur_framesmpls;
|
||||
if(stream_len > 0)
|
||||
{
|
||||
totalbits += 8 * stream_len;
|
||||
}
|
||||
if(rcuStreamLen > 0)
|
||||
{
|
||||
totalBitsRCU += 8 * rcuStreamLen;
|
||||
}
|
||||
}
|
||||
|
||||
rate = ((double)totalbits * (sampFreqKHz)) / (double)totalsmpls;
|
||||
rateRCU = ((double)totalBitsRCU * (sampFreqKHz)) / (double)totalsmpls;
|
||||
|
||||
printf("\n\n");
|
||||
printf("Sampling Rate......................... %d kHz\n", sampFreqKHz);
|
||||
printf("Payload Limit......................... %d bytes \n", payloadLimit);
|
||||
printf("Rate Limit............................ %d bits/sec \n", rateLimit);
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef HAVE_DEBUG_INFO
|
||||
rateLB = ((double)debugInfo.lbBytes * 8. *
|
||||
(sampFreqKHz)) / (double)totalsmpls;
|
||||
rateUB = ((double)debugInfo.ubBytes * 8. *
|
||||
(sampFreqKHz)) / (double)totalsmpls;
|
||||
#endif
|
||||
|
||||
fprintf(bitrateFile, "%d %10u %d %6.3f %6.3f %6.3f\n",
|
||||
sampFreqKHz,
|
||||
framecnt,
|
||||
bottleneck,
|
||||
rateLB,
|
||||
rateUB,
|
||||
rate);
|
||||
fclose(bitrateFile);
|
||||
#endif // WIN32
|
||||
|
||||
printf("\n");
|
||||
printf("Measured bit-rate..................... %0.3f kbps\n", rate);
|
||||
printf("Measured RCU bit-ratre................ %0.3f kbps\n", rateRCU);
|
||||
printf("Maximum bit-rate/payloadsize.......... %0.3f / %d\n",
|
||||
maxStreamLen * 8 / 0.03, maxStreamLen);
|
||||
printf("Measured packet-loss.................. %0.1f%% \n",
|
||||
100.0f * (float)lostPacketCntr / (float)packetCntr);
|
||||
|
||||
//#ifdef HAVE_DEBUG_INFO
|
||||
// printf("Measured lower-band bit-rate.......... %0.3f kbps (%.0f%%)\n",
|
||||
// rateLB, (double)(rateLB) * 100. /(double)(rate));
|
||||
// printf("Measured upper-band bit-rate.......... %0.3f kbps (%.0f%%)\n",
|
||||
// rateUB, (double)(rateUB) * 100. /(double)(rate));
|
||||
//
|
||||
// printf("Maximum payload lower-band............ %d bytes (%0.3f kbps)\n",
|
||||
// debugInfo.maxPayloadLB, debugInfo.maxPayloadLB * 8.0 / 0.03);
|
||||
// printf("Maximum payload upper-band............ %d bytes (%0.3f kbps)\n",
|
||||
// debugInfo.maxPayloadUB, debugInfo.maxPayloadUB * 8.0 / 0.03);
|
||||
//#endif
|
||||
|
||||
printf("\n");
|
||||
|
||||
/* Runtime statistics */
|
||||
#ifdef WIN32
|
||||
runtime = (double)(clock()/(double)CLOCKS_PER_SEC-starttime);
|
||||
length_file = ((double)framecnt*(double)declen/(sampFreqKHz*1000));
|
||||
printf("Length 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));
|
||||
#endif
|
||||
printf("\n\n_______________________________________________\n");
|
||||
|
||||
if(histFile != NULL)
|
||||
{
|
||||
int n;
|
||||
for(n = 0; n < 600; n++)
|
||||
{
|
||||
fprintf(histFile, "%6d ", hist[n]);
|
||||
}
|
||||
fprintf(histFile, "\n");
|
||||
fclose(histFile);
|
||||
}
|
||||
if(averageFile != NULL)
|
||||
{
|
||||
if(packetCntr > 0)
|
||||
{
|
||||
fprintf(averageFile, "%8.3f ", (double)tmpSumStreamLen * 8.0 / (30.0 * packetCntr));
|
||||
}
|
||||
fprintf(averageFile, "\n");
|
||||
fclose(averageFile);
|
||||
}
|
||||
|
||||
fclose(inp);
|
||||
fclose(outp);
|
||||
|
||||
WebRtcIsac_Free(ISAC_main_inst);
|
||||
|
||||
|
||||
#ifdef CHANGE_OUTPUT_NAME
|
||||
{
|
||||
char* p;
|
||||
char myExt[50];
|
||||
char bitRateStr[10];
|
||||
char newOutName[500];
|
||||
strcpy(newOutName, outname);
|
||||
|
||||
myExt[0] = '\0';
|
||||
p = strchr(newOutName, '.');
|
||||
if(p != NULL)
|
||||
{
|
||||
strcpy(myExt, p);
|
||||
*p = '_';
|
||||
p++;
|
||||
*p = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat(newOutName, "_");
|
||||
}
|
||||
sprintf(bitRateStr, "%0.0fkbps", rate);
|
||||
strcat(newOutName, bitRateStr);
|
||||
strcat(newOutName, myExt);
|
||||
rename(outname, newOutName);
|
||||
}
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_DEBUG_INFO
|
||||
int setupDebugStruct(debugStruct* str)
|
||||
{
|
||||
str->prevPacketLost = 0;
|
||||
str->currPacketLost = 0;
|
||||
|
||||
OPEN_FILE_WB(str->res0to4FilePtr, "Res0to4.dat");
|
||||
OPEN_FILE_WB(str->res4to8FilePtr, "Res4to8.dat");
|
||||
OPEN_FILE_WB(str->res8to12FilePtr, "Res8to12.dat");
|
||||
OPEN_FILE_WB(str->res8to16FilePtr, "Res8to16.dat");
|
||||
|
||||
OPEN_FILE_WB(str->res0to4DecFilePtr, "Res0to4Dec.dat");
|
||||
OPEN_FILE_WB(str->res4to8DecFilePtr, "Res4to8Dec.dat");
|
||||
OPEN_FILE_WB(str->res8to12DecFilePtr, "Res8to12Dec.dat");
|
||||
OPEN_FILE_WB(str->res8to16DecFilePtr, "Res8to16Dec.dat");
|
||||
|
||||
OPEN_FILE_WB(str->in0to4FilePtr, "in0to4.dat");
|
||||
OPEN_FILE_WB(str->in4to8FilePtr, "in4to8.dat");
|
||||
OPEN_FILE_WB(str->in8to12FilePtr, "in8to12.dat");
|
||||
OPEN_FILE_WB(str->in8to16FilePtr, "in8to16.dat");
|
||||
|
||||
OPEN_FILE_WB(str->out0to4FilePtr, "out0to4.dat");
|
||||
OPEN_FILE_WB(str->out4to8FilePtr, "out4to8.dat");
|
||||
OPEN_FILE_WB(str->out8to12FilePtr, "out8to12.dat");
|
||||
OPEN_FILE_WB(str->out8to16FilePtr, "out8to16.dat");
|
||||
OPEN_FILE_WB(str->fftFilePtr, "riFFT.dat");
|
||||
OPEN_FILE_WB(str->fftDecFilePtr, "riFFTDec.dat");
|
||||
|
||||
OPEN_FILE_WB(str->arrivalTime, NULL/*"ArivalTime.dat"*/);
|
||||
str->lastArrivalTime = 0;
|
||||
|
||||
str->maxPayloadLB = 0;
|
||||
str->maxPayloadUB = 0;
|
||||
str->lbBytes = 0;
|
||||
str->ubBytes = 0;
|
||||
|
||||
return 0;
|
||||
};
|
||||
#endif
|
Reference in New Issue
Block a user