syn/unify with local SHA1 script and update SHA1 tables

This commit is contained in:
huade 2015-07-17 10:44:15 +08:00
parent c0feee817d
commit 057799e298
10 changed files with 8067 additions and 8831 deletions

View File

@ -1,430 +1,442 @@
#!/bin/bash
#*******************************************************************************
#***************************************************************************************************************
# Encoder binary comparison test model
# -- Compared with Benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of Benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest?¡ê
# -- Compared with Benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of Benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest?¡ê
#brief:
# -- Test all cases in SHA1TableFile
# 1) Generate SHA1 string for each case
# 2) Compare with benchmark SHA1 string
# 3) If the SHA1 string are the same with benchmark version, test case is marked as passed
# 4) Otherwise, test case is marked as unpass! this may caused by:
# --the design of encoder has been changed and the bit stream also change
# --there may be some bugs in encoder and bit stream is not right
# -- Usage: ./run_BinarySHA1Comparison.sh ${TestYUVName} ${AllCaseSHA1TaleFile}
# -- Test all cases in SHA1TableFile
# 1) Generate SHA1 string for each case
# 2) Compare with benchmark SHA1 string
# 3) If the SHA1 string are the same with benchmark version, test case is marked as passed
# 4) Otherwise, test case is marked as unpass! this may caused by:
# --the design of encoder has been changed and the bit stream also change
# --there may be some bugs in encoder and bit stream is not right
# -- Usage: ./run_BinarySHA1Comparison.sh ${TestYUVName} ${AllCaseSHA1TaleFile}
#
# date: 10/06/2014 Created
#*******************************************************************************
# date: 10/06/2014 Created
#***************************************************************************************************************
#global variable definition
#usage runGlobalVariableDef
runGlobalVariableDef()
{
WorkingDirDir=""
#test data space
FinalResultPath=""
IssueDataPath=""
TempDataPath=""
#for test sequence info
TestSequenceName=""
PicW=""
PicH=""
#test cfg file and test info output file
ConfigureFile=""
AllCaseFile=""
#xxx.csv
AllCasePassStatusFile=""
#for encoder command
declare -a aEncoderCommandSet
declare -a aEncoderCommandName
declare -a aEncoderCommandValue
declare -a aRecYUVFileList
#encoder parameters change based on the case info
let "EncoderFlag = 0"
CaseInfo=""
BitStreamFile=""
DiffFlag=""
#pass number
TotalCaseNum=""
PassCaseNum=""
UnpassCaseNum=""
WorkingDirDir=""
#test data space
FinalResultPath=""
IssueDataPath=""
TempDataPath=""
#for test sequence info
TestSequenceName=""
PicW=""
PicH=""
#test cfg file and test info output file
ConfigureFile=""
AllCaseFile=""
#xxx.csv
AllCasePassStatusFile=""
#for encoder command
declare -a aEncoderCommandSet
declare -a aEncoderCommandName
declare -a aEncoderCommandValue
declare -a aRecYUVFileList
#encoder parameters change based on the case info
let "EncoderFlag = 0"
CaseInfo=""
BitStreamFile=""
DiffFlag=""
#pass number
TotalCaseNum=""
PassCaseNum=""
UnpassCaseNum=""
}
#called by runGlobalVariableInitial
#usage runEncoderCommandInital
runEncoderCommandInital()
{
aEncoderCommandSet=( -utype -frms -numl -numtl \
-sw -sh "-dw 0" "-dh 0" "-dw 1" "-dh 1" "-dw 2" "-dh 2" "-dw 3" "-dh 3" \
"-frout 0" "-frout 1" "-frout 2" "-frout 3" \
"-lqp 0" "-lqp 1" "-lqp 2" "-lqp 3" \
-rc -tarb "-ltarb 0" "-ltarb 1" "-ltarb 2" "-ltarb 3" \
"-slcmd 0" "-slcnum 0" "-slcmd 1" "-slcnum 1"\
"-slcmd 2" "-slcnum 2" "-slcmd 3" "-slcnum 3"\
-nalsize \
-iper -thread -ltr \
-db -denois -scene -bgd -aq )
aEncoderCommandName=(usagetype frms numl numtl \
sw sh dw0 dh0 dw1 dh1 dw2 dh2 dw3 dh3 \
frout0 frout1 frout2 frout3 \
lqp0 lqp1 lqp2 lqp3 \
rc tarb ltarb0 ltarb1 ltarb2 ltarb3 \
slcmd0 slcnum0 slcmd1 slcnum1 \
slcmd2 slcnum2 slcmd3 slcnum3 \
MaxNalSZ \
iper thread ltr \
db denois scene bgd aq )
NumParameter=${#aEncoderCommandSet[@]}
for ((i=0;i<NumParameter; i++))
do
aEncoderCommandValue[$i]=0
done
aEncoderCommandSet=( -utype -frms -numl -numtl \
-sw -sh "-dw 0" "-dh 0" "-dw 1" "-dh 1" "-dw 2" "-dh 2" "-dw 3" "-dh 3" \
"-frout 0" "-frout 1" "-frout 2" "-frout 3" \
"-lqp 0" "-lqp 1" "-lqp 2" "-lqp 3" \
-rc -fs -tarb "-ltarb 0" "-ltarb 1" "-ltarb 2" "-ltarb 3" \
"-slcmd 0" "-slcnum 0" "-slcmd 1" "-slcnum 1"\
"-slcmd 2" "-slcnum 2" "-slcmd 3" "-slcnum 3"\
-nalsize \
-iper -thread -ltr \
-db -denois -scene -bgd -aq )
aEncoderCommandName=(usagetype frms numl numtl \
sw sh dw0 dh0 dw1 dh1 dw2 dh2 dw3 dh3 \
frout0 frout1 frout2 frout3 \
lqp0 lqp1 lqp2 lqp3 \
rc FrSkip tarb ltarb0 ltarb1 ltarb2 ltarb3 \
slcmd0 slcnum0 slcmd1 slcnum1 \
slcmd2 slcnum2 slcmd3 slcnum3 \
MaxNalSZ \
iper thread ltr \
db denois scene bgd aq )
NumParameter=${#aEncoderCommandSet[@]}
for ((i=0;i<NumParameter; i++))
do
aEncoderCommandValue[$i]=0
done
}
runGlobalVariableInitial()
{
#TestSpaceDir=../AllTestData CurrentDir=../AllTestData/TestSetXXX/***.264 eg ../AllTestData/TestSetCIF/BA1_MWD.264
CurrentDir=`pwd`
#test data space
FinalResultPath="${CurrentDir}/result"
IssueDataPath="${CurrentDir}/issue"
TempDataPath="TempData"
TestSequencePath="${CurrentDir}"
#get YUV detail info $picW $picH $FPS
declare -a aYUVInfo
aYUVInfo=(`./run_ParseYUVInfo.sh ${TestSequenceName}`)
PicW=${aYUVInfo[0]}
PicH=${aYUVInfo[1]}
#test cfg file and test info output file
ConfigureFile=welsenc.cfg
AllCasePassStatusFile="${FinalResultPath}/${TestSequenceName}_AllCaseOutput.csv"
UnpassCaseFile="${FinalResultPath}/${TestSequenceName}_unpassCaseOutput.csv"
UpdateSHA1TableFile="${FinalResultPath}/${TestSequenceName}_UpdateSHA1Table.csv"
HeadLine1="BitMatched Status, SHA-1-Target, SHA-1-Benchmark, MD5-Target, MD5-Benchmark,\
Bitstream-Target,Bitstream-Benchmark,YUV-Target,YUV-Benchmark,\
-utype, -frms, -numl, -numtl, -sw, -sh,\
-dw 0, -dh 0, -dw 1, -dh 1, -dw 2, -dh 2, -dw 3, -dh 3,\
-frout 0, -frout 1, -frout 2, -frout 3,\
-lqp 0, -lqp 1, -lqp 2, -lqp 3,\
-rc, -tarb, -ltarb 0, -ltarb 1, -ltarb 2, -ltarb 3,\
-slcmd 0, -slcnum 0, -slcmd 1, -slcnum 1,\
-slcmd 2, -slcnum 2, -slcmd 3, -slcnum 3,\
-nalsize,\
-iper, -thread, -ltr, -db, -denois,\
-scene, -bgd , -aq, "
HeadLine2="SHA-1 Value, MD5String, BitStreamSize, YUVSize, \
-utype, -frms, -numl, -numtl, -sw, -sh,\
-dw 0, -dh 0, -dw 1, -dh 1,-dw 2, -dh 2, -dw 3, -dh 3,\
-frout 0, -frout 1, -frout 2, -frout 3,\
-lqp 0, -lqp 1, -lqp 2, -lqp 3,\
-rc, -tarb, -ltarb 0, -ltarb 1, -ltarb 2, -ltarb 3,\
-slcmd 0, -slcnum 0, -slcmd 1, -slcnum 1,\
-slcmd 2, -slcnum 2, -slcmd 3, -slcnum 3,\
-nalsize,\
-iper, -thread, -ltr, -db, -denois,\
-scene , bgd , -aq "
echo ${HeadLine1}>${AllCasePassStatusFile}
echo ${HeadLine1}>${UnpassCaseFile}
echo ${HeadLine2}>${UpdateSHA1TableFile}
#TestSpaceDir=../AllTestData CurrentDir=../AllTestData/TestSetXXX/***.264 eg ../AllTestData/TestSetCIF/BA1_MWD.264
CurrentDir=`pwd`
#test data space
FinalResultPath="${CurrentDir}/result"
IssueDataPath="${CurrentDir}/issue"
TempDataPath="TempData"
TestSequencePath="${CurrentDir}"
#get YUV detail info $picW $picH $FPS
declare -a aYUVInfo
aYUVInfo=(`./run_ParseYUVInfo.sh ${TestSequenceName}`)
PicW=${aYUVInfo[0]}
PicH=${aYUVInfo[1]}
#test cfg file and test info output file
ConfigureFile=welsenc.cfg
AllCasePassStatusFile="${FinalResultPath}/${TestSequenceName}_AllCaseOutput.csv"
UnpassCaseFile="${FinalResultPath}/${TestSequenceName}_unpassCaseOutput.csv"
UpdateSHA1TableFile="${FinalResultPath}/${TestSequenceName}_UpdateSHA1Table.csv"
#intial Commandline parameters
runEncoderCommandInital
let "TotalCaseNum=0"
let "PassCaseNum=0"
let "UnpassCaseNum=0"
EncoderCommand=""
EncoderLogFile="${TempDataPath}/Encoder.log"
TargetSHA1=""
TargetMD5=""
TargetYUVSize=""
TargetBitstreamSize=""
BenchmarkSHA1=""
BenchmarkMD5=""
BenchmarkYUVSize=""
BenchmarkBitstreamSize=""
HeadLine1="EncoderFlag, DecoderFlag, FPS, BitSreamSHA1, BitSreamMD5, InputYUVSHA1, InputYUVMD5,\
-utype, -frms, -numl, -numtl, -sw, -sh,\
-dw 0, -dh 0, -dw 1, -dh 1, -dw 2, -dh 2, -dw 3, -dh 3,\
-frout 0, -frout 1, -frout 2, -frout 3,\
-lqp 0, -lqp 1, -lqp 2, -lqp 3,\
-rc,-fs, -tarb, -ltarb 0, -ltarb 1, -ltarb 2, -ltarb 3,\
-slcmd 0, -slcnum 0, -slcmd 1, -slcnum 1,\
-slcmd 2, -slcnum 2, -slcmd 3, -slcnum 3,\
-nalsize,\
-iper, -thread, -ltr, -db, -denois,\
-scene, -bgd , -aq, "
HeadLine2="BitSreamSHA1, BitSreamMD5, InputYUVSHA1, InputYUVMD5,\
-utype, -frms, -numl, -numtl, -sw, -sh,\
-dw 0, -dh 0, -dw 1, -dh 1,-dw 2, -dh 2, -dw 3, -dh 3,\
-frout 0, -frout 1, -frout 2, -frout 3,\
-lqp 0, -lqp 1, -lqp 2, -lqp 3,\
-rc, -fs, -tarb, -ltarb 0, -ltarb 1, -ltarb 2, -ltarb 3,\
-slcmd 0, -slcnum 0, -slcmd 1, -slcnum 1,\
-slcmd 2, -slcnum 2, -slcmd 3, -slcnum 3,\
-nalsize,\
-iper, -thread, -ltr, -db, -denois,\
-scene , bgd , -aq "
echo ${HeadLine1}>${AllCasePassStatusFile}
echo ${HeadLine1}>${UnpassCaseFile}
echo ${HeadLine2}>${UpdateSHA1TableFile}
#intial Commandline parameters
runEncoderCommandInital
let "TotalCaseNum=0"
let "PassCaseNum=0"
let "UnpassCaseNum=0"
EncoderCommand=""
EncoderLogFile="${TempDataPath}/Encoder.log"
TargetSHA1=""
TargetMD5=""
TargetYUVSHA1=""
TargetYUVMD5=""
BenchmarkSHA1=""
BenchmarkMD5=""
BenchmarkYUVSHA1=""
BenchmarkYUVMD5=""
}
#***********************************************************
#called by runAllCaseTest
#called by runAllCaseTest
# parse case info --encoder preprocess
#usage runParseCaseInfo $CaseData
#usage runParseCaseInfo $CaseData
runParseCaseInfo()
{
if [ $# -lt 1 ]
then
if [ $# -lt 1 ]
then
echo "no parameter!"
return 1
fi
local TempData=""
local CaseData=$@
local BitstreamPrefix=""
BenchmarkSHA1=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $1} ' `
BenchmarkMD5=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $2} ' `
BenchmarkYUVSize=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $4} ' `
BenchmarkBitstreamSize=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $3} ' `
fi
local TempData=""
local CaseData=$@
local BitstreamPrefix=""
BenchmarkSHA1=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $1} ' `
BenchmarkMD5=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $2} ' `
BenchmarkYUVSHA1=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $3} ' `
BenchmarkYUVMD5=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {print $4} ' `
declare -a aTempParamIndex=( 6 7 8 9 10 11 12 13 15 16 17 19 20 21 24 25 26 27 30 31 32 33 34 35 )
TempData=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {for(i=5;i<=NF;i++) printf(" %s",$i)} ' `
aEncoderCommandValue=(${TempData})
let "TempParamFlag=0"
for((i=0; i<$NumParameter; i++))
do
declare -a aTempParamIndex=( 6 7 8 9 10 11 12 13 15 16 17 19 20 21 25 26 27 28 31 32 33 34 35 36 )
TempData=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {for(i=5;i<=NF;i++) printf(" %s",$i)} ' `
aEncoderCommandValue=(${TempData})
let "TempParamFlag=0"
for((i=0; i<$NumParameter; i++))
do
for ParnmIndex in ${aTempParamIndex[@]}
do
if [ $i -eq ${ParnmIndex} ]
then
let "TempParamFlag=1"
fi
if [ $i -eq ${ParnmIndex} ]
then
let "TempParamFlag=1"
fi
done
if [ ${TempParamFlag} -eq 0 ]
then
BitstreamPrefix=${BitstreamPrefix}_${aEncoderCommandName[$i]}_${aEncoderCommandValue[$i]}
BitstreamPrefix=${BitstreamPrefix}_${aEncoderCommandName[$i]}_${aEncoderCommandValue[$i]}
fi
let "TempParamFlag=0"
done
done
BitstreamTarget=${TempDataPath}/${TestSequenceName}_${BitstreamPrefix}_codec_target.264
echo ""
echo "BitstreamPrefix is ${BitstreamPrefix}"
echo ""
BitstreamTarget=${TempDataPath}/${TestSequenceName}_${BitstreamPrefix}_codec_target.264
echo ""
echo "BitstreamPrefix is ${BitstreamPrefix}"
echo ""
}
runEncodeOneCase()
{
local ParamCommand=""
BitStreamFile=${BitstreamTarget}
local ParamCommand=""
BitStreamFile=${BitstreamTarget}
for ((i=4; i<${NumParameter}; i++))
do
for ((i=4; i<${NumParameter}; i++))
do
ParamCommand="${ParamCommand} ${aEncoderCommandSet[$i]} ${aEncoderCommandValue[$i]} "
done
for((i=0;i<4;i++))
do
aRecYUVFileList[$i]="${TempDataPath}/${TestYUVName}_rec${i}.yuv"
done
ParamCommand="${aEncoderCommandSet[0]} ${aEncoderCommandValue[0]} ${aEncoderCommandSet[1]} ${aEncoderCommandValue[1]} \
${aEncoderCommandSet[2]} ${aEncoderCommandValue[2]} \
-lconfig 0 layer0.cfg -lconfig 1 layer1.cfg -lconfig 2 layer2.cfg -lconfig 3 layer3.cfg \
${aEncoderCommandSet[3]} ${aEncoderCommandValue[3]} \
${ParamCommand}"
echo ""
echo "---------------Encode One Case-------------------------------------------"
echo "case line is :"
EncoderCommand="./h264enc welsenc.cfg ${ParamCommand} -bf ${BitStreamFile} \
-drec 0 ${aRecYUVFileList[0]} -drec 1 ${aRecYUVFileList[1]} \
-drec 2 ${aRecYUVFileList[2]} -drec 3 ${aRecYUVFileList[3]} \
-org ${TestSequencePath}/${TestSequenceName}"
echo ${EncoderCommand}
echo -e "\n\n"
./h264enc welsenc.cfg ${ParamCommand} -bf ${BitStreamFile} \
-drec 0 ${aRecYUVFileList[0]} -drec 1 ${aRecYUVFileList[1]} \
-drec 2 ${aRecYUVFileList[2]} -drec 3 ${aRecYUVFileList[3]} \
-org ${TestSequencePath}/${TestSequenceName} 2>${EncoderLogFile}
if [ $? -eq 0 ]
then
let "EncoderFlag=0"
else
let "EncoderFlag=1"
fi
done
#delete the core down file as core down files for disk space limitation
for file in ./core*
do
for((i=0;i<4;i++))
do
aRecYUVFileList[$i]="${TempDataPath}/${TestYUVName}_rec${i}.yuv"
done
ParamCommand="${aEncoderCommandSet[0]} ${aEncoderCommandValue[0]} ${aEncoderCommandSet[1]} ${aEncoderCommandValue[1]} \
${aEncoderCommandSet[2]} ${aEncoderCommandValue[2]} \
-lconfig 0 layer0.cfg -lconfig 1 layer1.cfg -lconfig 2 layer2.cfg -lconfig 3 layer3.cfg \
${aEncoderCommandSet[3]} ${aEncoderCommandValue[3]} \
${ParamCommand}"
echo ""
echo "---------------Encode One Case-------------------------------------------"
echo "case line is :"
EncoderCommand="./h264enc welsenc.cfg ${ParamCommand} -bf ${BitStreamFile} \
-drec 0 ${aRecYUVFileList[0]} -drec 1 ${aRecYUVFileList[1]} \
-drec 2 ${aRecYUVFileList[2]} -drec 3 ${aRecYUVFileList[3]} \
-org ${TestSequencePath}/${TestSequenceName}"
echo ${EncoderCommand}
echo -e "\n\n"
./h264enc welsenc.cfg ${ParamCommand} -bf ${BitStreamFile} \
-drec 0 ${aRecYUVFileList[0]} -drec 1 ${aRecYUVFileList[1]} \
-drec 2 ${aRecYUVFileList[2]} -drec 3 ${aRecYUVFileList[3]} \
-org ${TestSequencePath}/${TestSequenceName} 2>${EncoderLogFile}
if [ $? -eq 0 ]
then
let "EncoderFlag=0"
else
let "EncoderFlag=1"
fi
#delete the core down file as core down files for disk space limitation
for file in ./core*
do
if [ -e ${file} ]
then
./run_SafeDelete.sh ${file}
./run_SafeDelete.sh ${file}
fi
done
return 0
done
return 0
}
#usage? runGetFileSize $FileName
runGetFileSize()
{
if [ $# -lt 1 ]
then
echo "usage runGetFileSize $FileName!"
return 1
fi
local FileName=$1
local FileSize=""
local TempInfo=""
TempInfo=`ls -l $FileName`
FileSize=`echo $TempInfo | awk '{print $5}'`
echo $FileSize
}
#called by runAllCaseTest
#usage runJSVMVerify
#called by runAllCaseTest
#usage runJSVMVerify
runBitStreamVerify()
{
echo ""
echo "******************************************"
echo "Bit streamSHA1 value comparison.... "
#*******************************************
TargetSHA1="NULL"
TargetMD5="NULL"
TargetYUVSize="NULL"
TargetBitstreamSize="NULL"
echo ""
echo "******************************************"
echo "Bit streamSHA1 value comparison.... "
#*******************************************
TargetSHA1="NULL"
TargetMD5="NULL"
TargetYUVSHA1="NULL"
TargetYUVMD5="NULL"
if [ ${EncoderFlag} -eq 1 ]
then
let "UnpassCaseNum++"
echo "1:unpassed! encoder initial failed or crash!"
DiffFlag="1:unpassed! encoder initial failed or crash!"
return 1
fi
if [ ${EncoderFlag} -eq 1 ]
then
let "UnpassCaseNum++"
echo "1:unpassed! encoder initial failed or crash!"
DiffFlag="1:unpassed! encoder initial failed or crash!"
return 1
fi
if [ ! -s ${BitStreamFile} ]
then
let "UnpassCaseNum++"
echo "2:unpassed! 0 bits--bit stream"
DiffFlag="2:unpassed! 0 bits--bit stream"
return 1
fi
#*******************************************
#*******************************************
echo ""
echo "${BitStreamFile}"
#SHA1
TargetSHA1=`openssl sha1 ${BitStreamFile}`
TargetSHA1=`echo ${TargetSHA1} | awk '{print $2}' `
TargetMD5=`openssl md5 ${BitStreamFile}`
TargetMD5=`echo ${TargetMD5} | awk '{print $2}' `
TargetYUVSize=`runGetFileSize ${TestSequencePath}/${TestSequenceName} `
TargetBitstreamSize=`runGetFileSize ${BitStreamFile}`
if [[ "${TargetSHA1}" =~ "${BenchmarkSHA1}" ]]
then
echo "bitstream pass! SHA1--${TargetSHA1} ----- ${BenchmarkSHA1}"
echo "MD5 info: MD5--${TargetMD5} ----- ${BenchmarkMD5}"
echo "YUV size info: size--${TargetYUVSize} ---- ${BenchmarkYUVSize} "
echo "BitStreamSize info: size--${TargetBitstreamSize} ---- ${BenchmarkBitstreamSize}"
DiffFlag="0:passed!"
let "PassCaseNum++"
return 0
else
echo "!!! SHA1 string not match: ${TargetSHA1} ----- ${BenchmarkSHA1} "
echo "MD5 info: MD5--${TargetMD5} ----- ${BenchmarkMD5}"
echo "YUV size info: size--${TargetYUVSize} ---- ${BenchmarkYUVSize} "
echo "BitStreamSize info: size--${TargetBitstreamSize} ---- ${BenchmarkBitstreamSize}"
DiffFlag="3:unpassed!"
let "UnpassCaseNum++"
return 1
fi
if [ ! -s ${BitStreamFile} ]
then
let "UnpassCaseNum++"
echo "2:unpassed! 0 bits--bit stream"
DiffFlag="2:unpassed! 0 bits--bit stream"
return 1
fi
#*******************************************
#*******************************************
echo ""
echo "${BitStreamFile}"
#SHA1
TargetSHA1=`openssl sha1 ${BitStreamFile}`
TargetSHA1=`echo ${TargetSHA1} | awk '{print $2}' `
TargetMD5=`openssl md5 ${BitStreamFile}`
TargetMD5=`echo ${TargetMD5} | awk '{print $2}' `
TargetYUVSHA1=`openssl sha1 ${TestSequencePath}/${TestSequenceName} `
TargetYUVSHA1=`echo ${TargetYUVSHA1} | awk '{print $2}' `
TargetYUVMD5=`openssl md5 ${TestSequencePath}/${TestSequenceName} `
TargetYUVMD5=`echo ${TargetYUVMD5} | awk '{print $2}' `
if [[ "${TargetSHA1}" =~ "${BenchmarkSHA1}" ]]
then
echo "bitstream pass! SHA1--${TargetSHA1} ----- ${BenchmarkSHA1}"
echo "MD5 info: MD5--${TargetMD5} ----- ${BenchmarkMD5}"
echo "YUV SHA1 info: SHA1--${TargetYUVSHA1} ---- ${BenchmarkYUVSHA1} "
echo "YUV MD5 info: MD5--${TargetYUVMD5} ---- ${BenchmarkYUVMD5}"
DiffFlag="0:passed!"
let "PassCaseNum++"
return 0
else
echo "!!! SHA1 string not match: ${TargetSHA1} ----- ${BenchmarkSHA1} "
echo "MD5 info: MD5--${TargetMD5} ----- ${BenchmarkMD5}"
echo "YUV SHA1 info: SHA1--${TargetYUVSHA1} ---- ${BenchmarkYUVSHA1} "
echo "YUV MD5 info: MD5--${TargetYUVMD5} ---- ${BenchmarkYUVMD5}"
DiffFlag="3:unpassed!"
let "UnpassCaseNum++"
return 1
fi
}
#called by runAllCaseTest
#delete temp data files and output single case test result to log file
#usage runSingleCasePostAction $CaseData
#called by runAllCaseTest
#delete temp data files and output single case test result to log file
#usage runSingleCasePostAction $CaseData
runSingleCasePostAction()
{
if [ $# -lt 1 ]
then
echo "no parameter!"
return 1
fi
local CaseData=$@
CaseInfo=`echo $CaseData | awk 'BEGIN {FS="[,\r]"} {for(i=5;i<=NF;i++) printf(" %s,",$i)} '`
PassStatusInfo="${DiffFlag}, ${TargetSHA1}, ${BenchmarkSHA1}, ${TargetMD5}, ${BenchmarkMD5},\
${TargetBitstreamSize}, ${BenchmarkBitstreamSize}, ${TargetYUVSize}, ${BenchmarkYUVSize},\
${CaseInfo}, ${EncoderCommand} "
echo "${PassStatusInfo}">>${AllCasePassStatusFile}
if [ "$DiffFlag" != "0:passed!" ]
then
echo "${PassStatusInfo}">>${UnpassCaseFile}
fi
echo "${TargetSHA1}, ${TargetMD5},${TargetBitstreamSize}, ${TargetYUVSize},${CaseInfo}">>${UpdateSHA1TableFile}
./run_SafeDelete.sh ${BitstreamTarget} >>${AllCaseConsoleLogFile}
if [ $# -lt 1 ]
then
echo "no parameter!"
return 1
fi
local CaseData=$@
CaseInfo=`echo $CaseData | awk 'BEGIN {FS="[,\r]"} {for(i=5;i<=NF;i++) printf(" %s,",$i)} '`
PassStatusInfo="${DiffFlag}, ${TargetSHA1}, ${BenchmarkSHA1}, ${TargetMD5}, ${BenchmarkMD5},\
${TargetYUVMD5}, ${BenchmarkYUVMD5}, ${TargetYUVSHA1}, ${BenchmarkYUVSHA1},\
${CaseInfo}, ${EncoderCommand} "
echo "${PassStatusInfo}">>${AllCasePassStatusFile}
if [ "$DiffFlag" != "0:passed!" ]
then
echo "${PassStatusInfo}">>${UnpassCaseFile}
fi
echo "${TargetSHA1}, ${TargetMD5},${TargetYUVMD5}, ${TargetYUVSHA1},${CaseInfo}">>${UpdateSHA1TableFile}
./run_SafeDelete.sh ${BitstreamTarget} >>${AllCaseConsoleLogFile}
}
#usage runOutputPassNum
runOutputPassNum()
{
# output file locate in ../result
echo ""
echo "***********************************************************"
echo "${TestSequenceName}"
echo "total case Num is: ${TotalCaseNum}"
echo "pass case Num is: ${PassCaseNum}"
echo "unpass case Num is: ${UnpassCaseNum}"
echo "***********************************************************"
echo ""
# output file locate in ../result
echo ""
echo "***********************************************************"
echo "${TestSequenceName}"
echo "total case Num is: ${TotalCaseNum}"
echo "pass case Num is: ${PassCaseNum}"
echo "unpass case Num is: ${UnpassCaseNum}"
echo "***********************************************************"
echo ""
}
# run all test case based on XXXcase.csv file
#usage runAllCaseTest
#usage runAllCaseTest
runAllCaseTest()
{
local EncoderLogInfo=""
while read CaseData
do
#get case parameter's value
if [[ ! $CaseData =~ "SHA" ]]
then
echo "" >>${AllCaseConsoleLogFile}
echo "" >>${AllCaseConsoleLogFile}
echo "" >>${AllCaseConsoleLogFile}
echo "********************case index is ${TotalCaseNum}**************************************" >>${AllCaseConsoleLogFile}
runParseCaseInfo ${CaseData} >>${AllCaseConsoleLogFile}
echo "" >>${AllCaseConsoleLogFile}
runEncodeOneCase >>${AllCaseConsoleLogFile}
cat ${EncoderLogFile}>>${AllCaseConsoleLogFile}
runBitStreamVerify >>${AllCaseConsoleLogFile}
let "DisplayFlag=TotalCaseNum%100"
if [ ${DisplayFlag} -eq 0 ]
then
if [ "$DiffFlag" = "0:passed!" ]
local EncoderLogInfo=""
while read CaseData
do
#get case parameter's value
if [[ ! $CaseData =~ "SHA" ]]
then
echo -e "\033[32m OK! ${TestSequenceName} Case Index ${TotalCaseNum}:SHA-1(Current--Benchmark): ${TargetSHA1}-----${BenchmarkSHA1} \033[0m"
echo -e "\033[32m ----MD5 (Current--Benchmark): ${TargetMD5}-----${BenchmarkMD5} \033[0m"
echo -e "\033[32m ----BitstreamSize: ${TargetBitstreamSize}, ${BenchmarkBitstreamSize} YUVSize: ${TargetYUVSize}, ${BenchmarkYUVSize} \033[0m"
echo "" >>${AllCaseConsoleLogFile}
echo "" >>${AllCaseConsoleLogFile}
echo "" >>${AllCaseConsoleLogFile}
echo "********************case index is ${TotalCaseNum}**************************************" >>${AllCaseConsoleLogFile}
runParseCaseInfo ${CaseData} >>${AllCaseConsoleLogFile}
echo "" >>${AllCaseConsoleLogFile}
runEncodeOneCase >>${AllCaseConsoleLogFile}
cat ${EncoderLogFile} >>${AllCaseConsoleLogFile}
runBitStreamVerify >>${AllCaseConsoleLogFile}
let "DisplayFlag=TotalCaseNum%100"
if [ ${DisplayFlag} -eq 0 ]
then
if [ "$DiffFlag" = "0:passed!" ]
then
echo -e "\033[32m OK! ${TestSequenceName} Case Index ${TotalCaseNum}:SHA-1(Current--Benchmark): ${TargetSHA1}-----${BenchmarkSHA1} \033[0m"
echo -e "\033[32m ----MD5 (Current--Benchmark): ${TargetMD5}-----${BenchmarkMD5} \033[0m"
echo -e "\033[32m ----YUVMD5: ${TargetYUVMD5}, ${BenchmarkYUVMD5} YUVSHA1: ${TargetYUVSHA1}, ${BenchmarkYUVSHA1} \033[0m"
fi
fi
#******************************************
if [ ! "$DiffFlag" = "0:passed!" ]
then
echo -e "\033[31m Failed! ${TestSequenceName} Case Index ${TotalCaseNum}:SHA-1(Current--Benchmark): ${TargetSHA1}-----${BenchmarkSHA1} \033[0m"
echo -e "\033[31m ----MD5 (Current--Benchmark): ${TargetMD5}-----${BenchmarkMD5} \033[0m"
echo -e "\033[31m ----YUVMD5: ${TargetYUVMD5}, ${BenchmarkYUVMD5} YUVSHA1: ${TargetYUVSHA1}, ${BenchmarkYUVSHA1} \033[0m"
EncoderLogInfo=`cat ${EncoderLogFile}`
echo -e "\033[31m ${EncoderLogInfo} \033[0m"
fi
runSingleCasePostAction ${CaseData}
let "TotalCaseNum++"
fi
fi
#******************************************
if [ ! "$DiffFlag" = "0:passed!" ]
then
echo -e "\033[31m Failed! ${TestSequenceName} Case Index ${TotalCaseNum}:SHA-1(Current--Benchmark): ${TargetSHA1}-----${BenchmarkSHA1} \033[0m"
echo -e "\033[31m ----MD5 (Current--Benchmark): ${TargetMD5}-----${BenchmarkMD5} \033[0m"
echo -e "\033[31m ----BitstreamSize: ${TargetBitstreamSize}, ${BenchmarkBitstreamSize} YUVSize: ${TargetYUVSize}, ${BenchmarkYUVSize} \033[0m"
EncoderLogInfo=`cat ${EncoderLogFile}`
echo -e "\033[31m ${EncoderLogInfo} \033[0m"
fi
runSingleCasePostAction ${CaseData}
let "TotalCaseNum++"
fi
done <$AllCaseFile
done <$AllCaseFile
}
#***********************************************************
# usage: runMain $TestYUV $AllCaseFile
# usage: runMain $TestYUV $AllCaseFile
runMain()
{
if [ ! $# -eq 2 ]
then
echo "usage: run_BinarySHA1Comparison.sh \$TestYUV \$AllCaseFile"
return 1
fi
runGlobalVariableDef
#for test sequence info
TestSequenceName=$1
AllCaseFile=$2
runGlobalVariableInitial
TestFolder=`echo $CurrentDir | awk 'BEGIN {FS="/"} { i=NF; print $i}'`
AllCaseConsoleLogFile="${FinalResultPath}/${TestSequenceName}.TestLog"
CaseSummaryFile="${FinalResultPath}/${TestSequenceName}.Summary"
FlagFile=""
#run all cases
runAllCaseTest
# output file locate in ./result
echo "${TestSequenceName}, \
${PassCaseNum} pass!, \
${UnpassCaseNum} unpass!,\
detail file located in ../AllTestData/${TestFolder}/result">${CaseSummaryFile}
runOutputPassNum
#generate All case Flag
if [ ! ${UnpassCaseNum} -eq 0 ]
then
echo ""
exit 1
else
echo ""
exit 0
fi
if [ ! $# -eq 2 ]
then
echo "usage: run_BinarySHA1Comparison.sh \$TestYUV \$AllCaseFile"
return 1
fi
runGlobalVariableDef
#for test sequence info
TestSequenceName=$1
AllCaseFile=$2
runGlobalVariableInitial
TestFolder=`echo $CurrentDir | awk 'BEGIN {FS="/"} { i=NF; print $i}'`
AllCaseConsoleLogFile="${FinalResultPath}/${TestSequenceName}.TestLog"
CaseSummaryFile="${FinalResultPath}/${TestSequenceName}.Summary"
FlagFile=""
#run all cases
runAllCaseTest
# output file locate in ./result
echo "${TestSequenceName}, \
${PassCaseNum} pass!, \
${UnpassCaseNum} unpass!,\
detail file located in ../AllTestData/${TestFolder}/result">${CaseSummaryFile}
runOutputPassNum
#generate All case Flag
if [ ! ${UnpassCaseNum} -eq 0 ]
then
echo ""
exit 1
else
echo ""
exit 0
fi
}
TestYUVName=$1
AllCaseFile=$2
runMain ${TestYUVName} ${AllCaseFile}
runMain ${TestYUVName} ${AllCaseFile}

View File

@ -1,118 +1,123 @@
#!/bin/bash
#*******************************************************************************
# Encoder binary comparison test model
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
#
#brief:
# -- Transform test bit stream into YUV as test sequence,
# 1) Called by run_OneBitStream.sh before testing all cases
# 2) eg:
# -- input: ./run_BitStreamToYUV.sh TestABC.264
# -- output: TestABC.264_382X288.yuv
# -- Usage: run_BitStreamToYUV.sh ${BitStreamFile}
# -- Transform test bit stream into YUV as test sequence,
# 1) Called by run_OneBitStream.sh before testing all cases
# 2) eg:
# -- input: ./run_BitStreamToYUV.sh TestABC.264
# -- output: TestABC.264_382X288.yuv
# -- Usage: run_BitStreamToYUV.sh ${BitStreamFile}
#
#
# date: 10/06/2014 Created
# date: 10/06/2014 Created
#*******************************************************************************
#usage: run_ParseDecoderLog $Decoder_LogFile
#eg: input: run_ParseDecoderLog test.264.log
# output 1024 720
# usage: run_ParseDecoderLog $Decoder_LogFile
# eg: input: run_ParseDecoderLog test.264.log
# output 1024 720
run_ParseDecoderLog()
{
if [ ! $# -eq 1 ]
then
echo "usage: run_ParseDecoderLog \$Decoder_LogFile"
return 1
fi
local LogFile=$1
local Width=""
local Height=""
while read line
do
if [[ $line =~ "iWidth" ]]
if [ ! $# -eq 1 ]
then
Width=`echo $line | awk 'BEGIN {FS="[:\n]"} {print $2}'`
echo "usage: run_ParseDecoderLog \$Decoder_LogFile"
return 1
fi
if [[ $line =~ "height" ]]
then
Height=`echo $line | awk 'BEGIN {FS="[:\n]"} {print $2}'`
fi
done < ${LogFile}
echo "${Width} ${Height}"
local LogFile=$1
local Width=""
local Height=""
while read line
do
if [[ $line =~ "iWidth" ]]
then
Width=`echo $line | awk 'BEGIN {FS="[:\n]"} {print $2}'`
fi
if [[ $line =~ "height" ]]
then
Height=`echo $line | awk 'BEGIN {FS="[:\n]"} {print $2}'`
fi
done < ${LogFile}
echo "${Width} ${Height}"
}
#usage: run_BitStream2YUV $BitstreamName $OutputYUVName $LogFile
#usage: run_BitStream2YUV $BitstreamName $OutputYUVName $LogFile
run_BitStream2YUV()
{
if [ ! $# -eq 3 ]
then
echo "usage: run_BitStream2YUV \$BitstreamName \$OutputYUVName \$LogFile "
return 1
fi
local BitStreamName=$1
local OutputYUVName=$2
local LogFile=$3
if [ ! -f ${BitStreamName} ]
then
echo "bit stream file does not exist!"
echo "detected by run_BitStreamToYUV.sh"
return 1
fi
#decode bitstream
./h264dec ${BitStreamName} ${OutputYUVName} 2> ${LogFile}
return 0
if [ ! $# -eq 3 ]
then
echo "usage: run_BitStream2YUV \$BitstreamName \$OutputYUVName \$LogFile "
return 1
fi
local BitStreamName=$1
local OutputYUVName=$2
local LogFile=$3
if [ ! -f ${BitStreamName} ]
then
echo "bit stream file does not exist!"
echo "detected by run_BitStreamToYUV.sh"
return 1
fi
#decode bitstream
./h264dec ${BitStreamName} ${OutputYUVName} 2> ${LogFile}
return 0
}
#usage: run_RegularizeYUVName $BitstreamName $OutputYUVName $LogFile
run_RegularizeYUVName()
{
if [ ! $# -eq 3 ]
then
echo "usage: run_RegularizeYUVName \$BitstreamName \$OutputYUVName \$LogFile "
return 1
fi
local BitStreamName=$1
local OrignName=$2
local LogFile=$3
local RegularizedYUVName=""
declare -a aDecodedYUVInfo
aDecodedYUVInfo=(`run_ParseDecoderLog ${LogFile}`)
BitStreamName=`echo ${BitStreamName} | awk 'BEGIN {FS="/"} {print $NF}'`
RegularizedYUVName="${BitStreamName}_${aDecodedYUVInfo[0]}x${aDecodedYUVInfo[1]}.yuv"
mv -f ${OrignName} ${RegularizedYUVName}
echo ""
echo "file: ${OrignName} has been renamed as: ${RegularizedYUVName}"
echo ""
return 0
if [ ! $# -eq 3 ]
then
echo "usage: run_RegularizeYUVName \$BitstreamName \$OutputYUVName \$LogFile "
return 1
fi
local BitStreamName=$1
local OrignName=$2
local LogFile=$3
local RegularizedYUVName=""
declare -a aDecodedYUVInfo
aDecodedYUVInfo=(`run_ParseDecoderLog ${LogFile}`)
BitStreamName=`echo ${BitStreamName} | awk 'BEGIN {FS="/"} {print $NF}'`
RegularizedYUVName="${BitStreamName}_${aDecodedYUVInfo[0]}x${aDecodedYUVInfo[1]}.yuv"
mv -f ${OrignName} ${RegularizedYUVName}
echo ""
echo "file: ${OrignName} has been renamed as: ${RegularizedYUVName}"
echo ""
return 0
}
#usage: runMain ${BitStreamName}
#usage: runMain ${BitStreamName}
runMain()
{
if [ ! $# -eq 1 ]
then
echo "usage: runMain \${BitStreamName} "
return 1
fi
local BitStreameFile=$1
local BitSteamName=`echo ${BitStreameFile} | awk 'BEGIN {FS="/"} {print $NF}'`
local DecoderLogFile="${BitSteamName}_h264dec.log"
local DecodedYUVName="${BitSteamName}_dec.yuv"
local RegularizedName=""
#**********************
#decoded test bit stream
run_BitStream2YUV ${BitStreameFile} ${DecodedYUVName} ${DecoderLogFile}
if [ ! $? -eq 0 ]
then
echo "bit stream decoded failed!"
return 1
fi
#*********************
#regularized YUV name
run_RegularizeYUVName ${BitStreameFile} ${DecodedYUVName} ${DecoderLogFile}
return 0
if [ ! $# -eq 1 ]
then
echo "usage: runMain \${BitStreamName} "
return 1
fi
local BitStreameFile=$1
local BitSteamName=`echo ${BitStreameFile} | awk 'BEGIN {FS="/"} {print $NF}'`
local DecoderLogFile="${BitSteamName}_h264dec.log"
local DecodedYUVName="${BitSteamName}_dec.yuv"
local RegularizedName=""
#**********************
#decoded test bit stream
run_BitStream2YUV ${BitStreameFile} ${DecodedYUVName} ${DecoderLogFile}
if [ ! $? -eq 0 ]
then
echo "bit stream decoded failed!"
return 1
fi
#*********************
#regularized YUV name
run_RegularizeYUVName ${BitStreameFile} ${DecodedYUVName} ${DecoderLogFile}
return 0
}
BitStreamFile=$1
runMain ${BitStreamFile}
runMain ${BitStreamFile}

View File

@ -1,67 +1,67 @@
#!/bin/bash
#*******************************************************************************
# Encoder binary comparison test model
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
#
#brief:
# -- Parse sequence basic info such as picw pich and fps via name
# -- Usage: run_ParseYUVInfo.sh ${TestSequenceName}
# -- Parse sequence basic info such as picw pich and fps via name
# -- Usage: run_ParseYUVInfo.sh ${TestSequenceName}
#
# date: 10/06/2014 Created
# date: 10/06/2014 Created
#*******************************************************************************
#usage runGetYUVInfo $TestSequenceName
#eg. input: ABC_1920X1080_30fps_XXX.yuv output: 1920 1080 30
#eg. input: ABC_1920X1080_XXX.yuv output: 1920 1080 0
#eg. input: ABC_XXX.yuv output: 0 0 0
#usage runGetYUVInfo $TestSequenceName
#eg. input: ABC_1920X1080_30fps_XXX.yuv output: 1920 1080 30
#eg. input: ABC_1920X1080_XXX.yuv output: 1920 1080 0
#eg. input: ABC_XXX.yuv output: 0 0 0
runGetYUVInfo()
{
if [ ! $# -eq 1 ]
then
echo "runGetYUVInfo \$TestSequenceName"
echo "detected by run_ParseYUVInfo.sh"
return 1
fi
if [ ! $# -eq 1 ]
then
echo "runGetYUVInfo \$TestSequenceName"
echo "detected by run_ParseYUVInfo.sh"
return 1
fi
local SequenceName=$1
local PicWidth="0"
local PicHeight="0"
local FPS="0"
declare -a aPicInfo
aPicInfo=(`echo ${SequenceName} | awk 'BEGIN {FS="[_.]"} {for(i=1;i<=NF;i++) printf("%s ",$i)}'`)
local Iterm
local Index=""
local Pattern_01="[xX]"
local Pattern_02="^[1-9][0-9]"
local Pattern_03="[0-9][0-9]$"
local Pattern_04="fps$"
#get PicW PicH info
let "Index=0"
for Iterm in ${aPicInfo[@]}
do
if [[ $Iterm =~ $Pattern_01 ]] && [[ $Iterm =~ $Pattern_02 ]] && [[ $Iterm =~ $Pattern_03 ]]
then
PicWidth=`echo $Iterm | awk 'BEGIN {FS="[xX]"} {print $1}'`
PicHeight=`echo $Iterm | awk 'BEGIN {FS="[xX]"} {print $2}'`
break
fi
local SequenceName=$1
local PicWidth="0"
local PicHeight="0"
local FPS="0"
declare -a aPicInfo
aPicInfo=(`echo ${SequenceName} | awk 'BEGIN {FS="[_.]"} {for(i=1;i<=NF;i++) printf("%s ",$i)}'`)
local Iterm
local Index=""
local Pattern_01="[xX]"
local Pattern_02="^[1-9][0-9]"
local Pattern_03="[0-9][0-9]$"
local Pattern_04="fps$"
#get PicW PicH info
let "Index=0"
for Iterm in ${aPicInfo[@]}
do
if [[ $Iterm =~ $Pattern_01 ]] && [[ $Iterm =~ $Pattern_02 ]] && [[ $Iterm =~ $Pattern_03 ]]
then
PicWidth=`echo $Iterm | awk 'BEGIN {FS="[xX]"} {print $1}'`
PicHeight=`echo $Iterm | awk 'BEGIN {FS="[xX]"} {print $2}'`
break
fi
let "Index++"
done
#get fps info
let "Index++"
done
#get fps info
let "Index++"
if [ $Index -le ${#aPicInfo[@]} ]
then
if [[ ${aPicInfo[$Index]} =~ ^[1-9] ]] || [[ ${aPicInfo[$Index]} =~ $Pattern_04 ]]
if [ $Index -le ${#aPicInfo[@]} ]
then
FPS=`echo ${aPicInfo[$Index]} | awk 'BEGIN {FS="[a-zA-Z]" } {print $1} '`
if [[ ${aPicInfo[$Index]} =~ ^[1-9] ]] || [[ ${aPicInfo[$Index]} =~ $Pattern_04 ]]
then
FPS=`echo ${aPicInfo[$Index]} | awk 'BEGIN {FS="[a-zA-Z]" } {print $1} '`
fi
fi
fi
echo "$PicWidth $PicHeight $FPS"
echo "$PicWidth $PicHeight $FPS"
}
TestSequenceName=$1
runGetYUVInfo ${TestSequenceName}
runGetYUVInfo ${TestSequenceName}

View File

@ -1,246 +1,246 @@
#!/bin/bash
#*******************************************************************************
#***********************************************************************************************************
# Encoder binary comparison test model
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
#
#brief:
# -- Usage: ./run_SafeDelete.sh $DeleteItermPath
# eg: 1 ./run_SafeDelete.sh tempdata.info --->delete only one file
# eg: 2 ./run_SafeDelete.sh ../TempDataFolder --->delete entire folder
# ./run_SafeDelete.sh /opt/TempData/ABC --->delete entire folder ABC
# -- Usage: ./run_SafeDelete.sh $DeleteItermPath
# eg: 1 ./run_SafeDelete.sh tempdata.info --->delete only one file
# eg: 2 ./run_SafeDelete.sh ../TempDataFolder --->delete entire folder
# ./run_SafeDelete.sh /opt/TempData/ABC --->delete entire folder ABC
#
# date: 10/06/2014 Created
#*******************************************************************************
#usage: runGetFileName $FilePath
# date: 10/06/2014 Created
#***********************************************************************************************************
#usage: runGetFileName $FilePath
runGetFileName()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFileName \$FilePath"
return 1
fi
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFileName \$FilePath"
return 1
fi
local PathInfo=$1
local FileName=""
local PathInfo=$1
local FileName=""
if [[ $PathInfo =~ ^"/" ]]
then
FileName=` echo ${PathInfo} | awk 'BEGIN {FS="/"}; {print $NF}'`
echo "${FileName}"
return 0
elif [[ $PathInfo =~ ^".." ]]
then
FileName=` echo ${PathInfo} | awk 'BEGIN {FS="/"}; {print $NF}'`
echo "${FileName}"
return 0
else
FileName=${PathInfo}
echo "${FileName}"
return 0
fi
if [[ $PathInfo =~ ^"/" ]]
then
FileName=` echo ${PathInfo} | awk 'BEGIN {FS="/"}; {print $NF}'`
echo "${FileName}"
return 0
elif [[ $PathInfo =~ ^".." ]]
then
FileName=` echo ${PathInfo} | awk 'BEGIN {FS="/"}; {print $NF}'`
echo "${FileName}"
return 0
else
FileName=${PathInfo}
echo "${FileName}"
return 0
fi
}
#******************************************************************************************************
#usage: runGetFileFullPath $FilePathInfo
#eg: current path is /opt/VideoTest/openh264/ABC
# runGetFileFullPath abc.txt --->/opt/VideoTest/openh264/ABC
# runGetFileFullPath ../123.txt --->/opt/VideoTest/openh264
# runGetFileFullPath /opt/VieoTest/456.txt --->/opt/VieoTest
#usage: runGetFileFullPath $FilePathInfo
#eg: current path is /opt/VideoTest/openh264/ABC
# runGetFileFullPath abc.txt --->/opt/VideoTest/openh264/ABC
# runGetFileFullPath ../123.txt --->/opt/VideoTest/openh264
# runGetFileFullPath /opt/VieoTest/456.txt --->/opt/VieoTest
runGetFileFullPath()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFileFullPath \$FilePathInfo "
return 1
fi
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFileFullPath \$FilePathInfo "
return 1
fi
local PathInfo=$1
local FullPath=""
local CurrentDir=`pwd`
local PathInfo=$1
local FullPath=""
local CurrentDir=`pwd`
if [[ $PathInfo =~ ^"/" ]]
then
FullPath=`echo ${PathInfo} |awk 'BEGIN {FS="/"} {for (i=1;i<NF;i++) printf("%s/",$i)}'`
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
elif [[ $PathInfo =~ ^".." ]]
then
FullPath=`echo ${PathInfo} |awk 'BEGIN {FS="/"} {for (i=1;i<NF;i++) printf("%s/",$i)}'`
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
else
FullPath=${CurrentDir}
echo "${FullPath}"
return 0
fi
if [[ $PathInfo =~ ^"/" ]]
then
FullPath=`echo ${PathInfo} |awk 'BEGIN {FS="/"} {for (i=1;i<NF;i++) printf("%s/",$i)}'`
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
elif [[ $PathInfo =~ ^".." ]]
then
FullPath=`echo ${PathInfo} |awk 'BEGIN {FS="/"} {for (i=1;i<NF;i++) printf("%s/",$i)}'`
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
else
FullPath=${CurrentDir}
echo "${FullPath}"
return 0
fi
}
#******************************************************************************************************
#usage: runGetFolderFullPath $FolderPathInfo
#eg: current path is /opt/VideoTest/openh264/ABC
# runGetFolderFullPat SubFolder --->/opt/VideoTest/openh264/ABC/ SubFolder
# runGetFolderFullPat ../EFG --->/opt/VideoTest/openh264/EFG
# runGetFolderFullPat /opt/VieoTest/MyFolder --->/opt/VieoTest/MyFolder
#usage: runGetFolderFullPath $FolderPathInfo
#eg: current path is /opt/VideoTest/openh264/ABC
# runGetFolderFullPat SubFolder --->/opt/VideoTest/openh264/ABC/ SubFolder
# runGetFolderFullPat ../EFG --->/opt/VideoTest/openh264/EFG
# runGetFolderFullPat /opt/VieoTest/MyFolder --->/opt/VieoTest/MyFolder
runGetFolderFullPath()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFolderFullPath \$FolderPathInfo "
return 1
fi
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFolderFullPath \$FolderPathInfo "
return 1
fi
local PathInfo=$1
local FullPath=""
local CurrentDir=`pwd`
local PathInfo=$1
local FullPath=""
local CurrentDir=`pwd`
if [[ $PathInfo =~ ^"/" ]]
then
FullPath=${PathInfo}
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
elif [[ $PathInfo =~ ^".." ]]
then
cd ${PathInfo}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
else
FullPath="${CurrentDir}/${PathInfo}"
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
fi
if [[ $PathInfo =~ ^"/" ]]
then
FullPath=${PathInfo}
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
elif [[ $PathInfo =~ ^".." ]]
then
cd ${PathInfo}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
else
FullPath="${CurrentDir}/${PathInfo}"
cd ${FullPath}
FullPath=`pwd`
cd ${CurrentDir}
echo "${FullPath}"
return 0
fi
}
#******************************************************************************************************
#usage: runUserNameCheck $whoami
#usage: runUserNameCheck $whoami
runUserNameCheck()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runUserNameCheck \$whoami"
return 1
fi
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runUserNameCheck \$whoami"
return 1
fi
local UserName=$1
local UserName=$1
if [ ${UserName} = "root" ]
then
echo ""
echo "*********************************************"
echo "delete files under root is not allowed"
echo "detected by run_SafeDelete.sh"
return 1
else
echo ""
return 0
fi
if [ ${UserName} = "root" ]
then
echo ""
echo "*********************************************"
echo "delete files under root is not allowed"
echo "detected by run_SafeDelete.sh"
return 1
else
echo ""
return 0
fi
}
#******************************************************************************************************
#usage: runFolderLocationCheck $FullPath
#usage: runFolderLocationCheck $FullPath
runFolderLocationCheck()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runFolderLocationCheck \$FullPath"
return 1
fi
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runFolderLocationCheck \$FullPath"
return 1
fi
local Location=$1
local FileDirDepth=`echo ${Location} | awk 'BEGIN {FS="/"} {print NF}'`
local Location=$1
local FileDirDepth=`echo ${Location} | awk 'BEGIN {FS="/"} {print NF}'`
#for other non-project folder data protection
#eg /opt/VideoTest/DeletedItem depth=4
if [ $FileDirDepth -lt 5 ]
then
echo ""
echo "*********************************************"
echo "FileDepth is $FileDirDepth, and it is less thab the minimum depth(5)"
echo "unsafe delete! try to delete non-project related files: $FileDir"
echo "detected by run_SafeDelete.sh"
return 1
fi
#for other non-project folder data protection
#eg /opt/VideoTest/DeletedItem depth=4
if [ $FileDirDepth -lt 5 ]
then
echo ""
echo "*********************************************"
echo "FileDepth is $FileDirDepth, and it is less thab the minimum depth(5)"
echo "unsafe delete! try to delete non-project related files: $FileDir"
echo "detected by run_SafeDelete.sh"
return 1
fi
return 0
return 0
}
#******************************************************************************************************
#usage runSafeDelete $Pathinfo
runSafeDelete()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage runSafeDelete \$FileFullPath"
return 1
fi
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage runSafeDelete \$FileFullPath"
return 1
fi
local PathInfo=$1
local UserName=`whoami`
local FullPath=""
local DeleteIterm=""
local FileName=""
local PathInfo=$1
local UserName=`whoami`
local FullPath=""
local DeleteIterm=""
local FileName=""
#user validity check
runUserNameCheck ${UserName}
if [ ! $? -eq 0 ]
then
return 1
fi
#user validity check
runUserNameCheck ${UserName}
if [ ! $? -eq 0 ]
then
return 1
fi
#get full path
if [ -d $PathInfo ]
then
FullPath=`runGetFolderFullPath ${PathInfo} `
elif [ -f $PathInfo ]
then
FullPath=`runGetFileFullPath ${PathInfo} `
else
echo "delete item does not exist"
echo "detected by run_SafeDelete.sh"
return 1
fi
#get full path
if [ -d $PathInfo ]
then
FullPath=`runGetFolderFullPath ${PathInfo} `
elif [ -f $PathInfo ]
then
FullPath=`runGetFileFullPath ${PathInfo} `
else
echo "delete item does not exist"
echo "detected by run_SafeDelete.sh"
return 1
fi
#location validity check
runFolderLocationCheck ${FullPath}
if [ ! $? -eq 0 ]
then
return 1
fi
#location validity check
runFolderLocationCheck ${FullPath}
if [ ! $? -eq 0 ]
then
return 1
fi
#delete file/folder
if [ -d $PathInfo ]
then
DeleteIterm=${FullPath}
echo "deleted folder is: $DeleteIterm"
rm -rf ${DeleteIterm}
elif [ -f $PathInfo ]
then
FileName=`runGetFileName ${PathInfo}`
DeleteIterm="${FullPath}/${FileName}"
echo "deleted file is: $DeleteIterm"
rm ${DeleteIterm}
fi
echo ""
#delete file/folder
if [ -d $PathInfo ]
then
DeleteIterm=${FullPath}
echo "deleted folder is: $DeleteIterm"
rm -rf ${DeleteIterm}
elif [ -f $PathInfo ]
then
FileName=`runGetFileName ${PathInfo}`
DeleteIterm="${FullPath}/${FileName}"
echo "deleted file is: $DeleteIterm"
rm ${DeleteIterm}
fi
echo ""
}
PathInfo=$1

View File

@ -1,144 +1,150 @@
#!/bin/bash
#*******************************************************************************
#Encoder Binary comparison test model
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
#
#brief:
# -- This file is for local test under Linux/Unix OS
# -- Start point of the test model,
# -- For local test, please run below command:
# ./run_Main.sh LocalTest
# And wait minutes for the test result.
# Final test result, you can refer to test output files under folder
# openh264/test/encoder_binary_comparison/FinalResult.
# -- If there is something change in encoder design,and found that the bit stream
# also change,you need to update the SHA1 table files in ./SHA1Table.
# For update the SHA1 tables, please run below command:
# ./run_Main.sh UpdateSHA1Table
# There will be some mismatched warning info, please ignore it.
# Wait for minutes,the up-to-date will be copied to ./SHA1Table.
# date: 10/06/2014 Created
# -- This file is for local test under Linux/Unix OS
# -- Start point of the test model,
# -- For local test, please run below command:
# ./run_Main.sh LocalTest
# And wait minutes for the test result.
# Final test result, you can refer to test output files under folder
# openh264/test/encoder_binary_comparison/FinalResult.
# -- If there is something change in encoder design,and found that the bit stream
# also change,you need to update the SHA1 table files in ./SHA1Table.
# For update the SHA1 tables, please run below command:
# ./run_Main.sh UpdateSHA1Table
# There will be some mismatched warning info, please ignore it.
# Wait for minutes,the up-to-date will be copied to ./SHA1Table.
# date: 10/06/2014 Created
#*******************************************************************************
#usage: runTestTypeCheck ${TestType}
#usage: runTestTypeCheck ${TestType}
runTestTypeCheck()
{
if [ ! $# -eq 1 ]
then
echo "usage: runTestTypeCheck \${TestType}"
exit 1
fi
local TestType=$1
echo "TestType is ${TestType}"
if [ "${TestType}" = "LocalTest" ]
then
return 0
elif [ "${TestType}" = "UpdateSHA1Table" ]
then
return 0
else
echo "usage: --./run_Main.sh LocalTest"
echo " or --./run_Main.sh UpdateSHA1Table"
exit 1
fi
echo "TestType is ${TestType}"
if [ "${TestType}" = "LocalTest" ]
then
return 0
elif [ "${TestType}" = "UpdateSHA1Table" ]
then
return 0
else
echo "usage: --./run_Main.sh LocalTest"
echo " or --./run_Main.sh UpdateSHA1Table"
exit 1
fi
}
#delete temp files/folders
runLocalTestPostAction()
{
./Scripts/run_SafeDelete.sh ${AllTestDataFolder} >>${DeletedLog}
./Scripts/run_SafeDelete.sh ./Codec >>${DeletedLog}
echo -e "\n\n\n"
echo -e "\033[32m *************************************************************** \033[0m"
echo -e "\033[32m Local test completed, \033[0m"
if [ ${Flag} -eq 0 ]
then
echo -e "\033[32m --all cases pass!! ----bit stream: ${StreamName} \033[0m"
else
echo -e "\033[31m --not all cases passed .....\033[0m"
fi
echo ""
echo -e "\033[32m for more detail, please refer to xxx.log files and xxx.csv files in ./FinalResult \033[0m"
echo -e "\033[32m *************************************************************** \033[0m"
echo ""
./Scripts/run_SafeDelete.sh ${AllTestDataFolder} >>${DeletedLog}
./Scripts/run_SafeDelete.sh ./Codec >>${DeletedLog}
echo -e "\n\n\n"
echo -e "\033[32m *************************************************************** \033[0m"
echo -e "\033[32m Local test completed! \033[0m"
if [ ${Flag} -eq 0 ]
then
echo -e "\033[32m --all cases pass!! ----bit stream: ${StreamName} \033[0m"
else
echo -e "\033[31m --not all cases passed ..... \033[0m"
fi
echo ""
echo -e "\033[32m for more detail, please refer to *.log files and *.csv files \033[0m"
echo -e "\033[32m in ./FinalResult \033[0m"
echo -e "\033[32m *************************************************************** \033[0m"
echo ""
}
#copy up-to-date SHA1 table files to ./SHA1Table
#and delete temp files/folders
runUpdateSHA1TablePostAction()
{
local BitStreamName=""
local SHA1TableName=""
local FileName=""
for file in ${FinalResultFolder}/*
do
FileName=`echo $file | awk 'BEGIN {FS="/"} {print $NF}'`
if [[ "$FileName" =~ UpdateSHA1Table.csv$ ]]
then
BitStreamName=`echo $FileName | awk 'BEGIN {FS=".264"} {print $1}'`
SHA1TableName=${BitStreamName}.264_AllCases_SHA1_Table.csv
./Scripts/run_SafeDelete.sh ${SHA1TableFolder}/${SHA1TableName} >>${DeletedLog}
cp $file ${SHA1TableFolder}/${SHA1TableName}
fi
done
./Scripts/run_SafeDelete.sh ${AllTestDataFolder}>>${DeletedLog}
./Scripts/run_SafeDelete.sh ${FinalResultFolder}>>${DeletedLog}
./Scripts/run_SafeDelete.sh ./Codec>>${DeletedLog}
echo -e "\n\n\n"
echo -e "\033[32m *************************************************************** \033[0m"
echo -e "\033[32m all SHA1 tables in ./${SHA1TableFolder} have been updated \033[0m"
echo -e "\n"
echo -e "\033[32m *************************************************************** \033[0m"
echo -e "\n\n"
local BitStreamName=""
local SHA1TableName=""
local FileName=""
for file in ${FinalResultFolder}/*
do
FileName=`echo $file | awk 'BEGIN {FS="/"} {print $NF}'`
if [[ "$FileName" =~ UpdateSHA1Table.csv$ ]]
then
BitStreamName=`echo $FileName | awk 'BEGIN {FS=".264"} {print $1}'`
SHA1TableName=${BitStreamName}.264_AllCases_SHA1_Table.csv
./Scripts/run_SafeDelete.sh ${SHA1TableFolder}/${SHA1TableName} >>${DeletedLog}
cp $file ${SHA1TableFolder}/${SHA1TableName}
fi
done
./Scripts/run_SafeDelete.sh ${AllTestDataFolder}>>${DeletedLog}
./Scripts/run_SafeDelete.sh ${FinalResultFolder}>>${DeletedLog}
./Scripts/run_SafeDelete.sh ./Codec>>${DeletedLog}
echo -e "\n\n\n"
echo -e "\033[32m *************************************************************** \033[0m"
echo -e "\033[32m all SHA1 tables in ./${SHA1TableFolder} have been updated \033[0m"
echo -e "\n"
echo -e "\033[32m *************************************************************** \033[0m"
echo -e "\n\n"
}
#usage: --./run_Main.sh LocalTest
# or --./run_Main.sh UpdateSHA1Table
#usage: --./run_Main.sh LocalTest
# or --./run_Main.sh UpdateSHA1Table
runMain()
{
if [ ! $# -eq 1 ]
then
echo "usage: --./run_Main.sh LocalTest"
echo " or --./run_Main.sh UpdateSHA1Table"
exit 1
fi
local TestType=$1
local BitStreamName=""
Flag=""
SHA1TableFolder="SHA1Table"
FinalResultFolder="FinalResult"
AllTestDataFolder="AllTestData"
DeletedLog="Delete.log"
runTestTypeCheck ${TestType}
# 32 -->32 bits release version;64 -->64 bits release version
./run_PrepareAllTestData.sh 32
if [ ! $? -eq 0 ]
then
echo "failed to prepare test space for all test data!"
exit 1
fi
#test all cases
let "Flag=0"
for Bitsream in ./SHA1Table/*.csv
do
BitStreamName=`echo ${Bitsream} | awk 'BEGIN {FS="/"} {print $NF} ' `
BitStreamName=`echo ${BitStreamName} | awk 'BEGIN {FS="_AllCase"} {print $1} ' `
echo -e "\n\n\n"
./run_OneBitStream.sh ${BitStreamName} ${TestType}
if [ ! $# -eq 1 ]
then
echo "usage: --./run_Main.sh LocalTest"
echo " or --./run_Main.sh UpdateSHA1Table"
exit 1
fi
local TestType=$1
local BitStreamName=""
Flag=""
SHA1TableFolder="SHA1Table"
FinalResultFolder="FinalResult"
AllTestDataFolder="AllTestData"
DeletedLog="Delete.log"
runTestTypeCheck ${TestType}
# 32 -->32 bits release version;64 -->64 bits release version
./run_PrepareAllTestData.sh 32
if [ ! $? -eq 0 ]
then
let "Flag=1"
echo "failed to prepare test space for all test data!"
exit 1
fi
#test all cases
let "Flag=0"
for Bitsream in ./SHA1Table/*.csv
do
BitStreamName=`echo ${Bitsream} | awk 'BEGIN {FS="/"} {print $NF} ' `
BitStreamName=`echo ${BitStreamName} | awk 'BEGIN {FS=".264"} {print $1} ' `
BitStreamName="${BitStreamName}.264"
echo -e "\n\n\n"
./run_OneBitStream.sh ${BitStreamName} ${TestType}
if [ ! $? -eq 0 ]
then
let "Flag=1"
fi
done
#post action
if [ ${TestType} = "LocalTest" ]
then
runLocalTestPostAction
elif [ ${TestType} = "UpdateSHA1Table" ]
then
runUpdateSHA1TablePostAction
fi
done
#post action
if [ ${TestType} = "LocalTest" ]
then
runLocalTestPostAction
elif [ ${TestType} = "UpdateSHA1Table" ]
then
runUpdateSHA1TablePostAction
fi
}
TestType=$1
runMain ${TestType}
runMain ${TestType}

View File

@ -1,213 +1,212 @@
#!/bin/bash
#*******************************************************************************
# Encoder binary comparison test model
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
#
#brief:
# -- Usage: run_OneBitStream.sh $BitStreamName $TestType
# -- WorkingDir
# 1) For local test: WorkingDir=openh264/test/encoder_binary_comparison
# 2) For travis test: WorkingDir=openh264
# There will be an auto detection for working directory
# -- Before using this script, need to run below command:
# ./run_PrepareAllTestData.sh 32(or 64)
# cd $WorkingDir
# -- Usage: run_OneBitStream.sh $BitStreamName $TestType
# -- WorkingDir
# 1) For local test: WorkingDir=openh264/test/encoder_binary_comparison
# 2) For travis test: WorkingDir=openh264
# There will be an auto detection for working directory
# -- Before using this script, need to run below command:
# ./run_PrepareAllTestData.sh 32(or 64)
# cd $WorkingDir
#
# date: 10/06/2014 Created
# date: 10/06/2014 Created
#*******************************************************************************
#uasge: runGetCurrentYUVName $BitStreamToYUV.log
runGetCurrentYUVName()
{
if [ ! $# -eq 1 ]
then
echo "usage: runGetCurrentYUVName \$BitStreamToYUV.log"
echo "detected by run_OneBitStream.sh"
return 1
fi
local BitStreamToYUVLog=$1
local YUVName=""
while read line
do
if [[ "$line" =~ "renamed as" ]]
runInitial()
{
TestYUVName=""
StreamName=""
BitStreamToYUVLog="Bit2YUV.log"
SHA1Table="${BitStreamName}_AllCases_SHA1_Table.csv"
#dir info
WorkingDir=`pwd`
EncoderTestDir=""
BitStreamTestDir=""
FinalResultDir=""
StreamFileFullPath=""
BitSreamDir=""
if [[ "${WorkingDir}" =~ "test/encoder_binary_comparison" ]]
then
YUVName=`echo $line | awk 'BEGIN {FS=":"} {print $3}'`
#for local test: working dir is openh264/test/encoder_binary_comparison
EncoderTestDir=${WorkingDir}
BitStreamTestDir="${EncoderTestDir}/AllTestData/${BitStreamName}"
FinalResultDir="${EncoderTestDir}/FinalResult"
BitSreamDir="../../res"
else
#for travis test: working dir is openh264/
EncoderTestDir=${WorkingDir}/test/encoder_binary_comparison
BitStreamTestDir="${EncoderTestDir}/AllTestData/${BitStreamName}"
FinalResultDir="${EncoderTestDir}/FinalResult"
BitSreamDir="${WorkingDir}/res"
fi
done <${BitStreamToYUVLog}
echo ${YUVName}
cd ${BitSreamDir}
StreamFileFullPath=`pwd`
StreamFileFullPath=${StreamFileFullPath}/${BitStreamName}
cd ${WorkingDir}
}
runBitStreamToYUV()
{
./run_BitStreamToYUV.sh ${StreamFileFullPath}>${BitStreamToYUVLog}
if [ ! $? -eq 0 ]
then
echo "failed to translate bit stream to yuv !"
exit 1
fi
#parse basic info
TestYUVName=`runGetCurrentYUVName `
TestYUVName=`echo ${TestYUVName} | awk 'BEGIN {FS="/"} {print $NF} ' `
StreamName=`echo ${StreamFileFullPath} | awk 'BEGIN {FS="/"} {print $NF} ' `
echo ""
echo "TestYUVName is ${TestYUVName}"
echo "StreamName is ${StreamName} "
echo "SHA1Table is ${SHA1Table}"
echo ""
}
runGetCurrentYUVName()
{
local YUVName=""
while read line
do
if [[ "$line" =~ "renamed as" ]]
then
YUVName=`echo $line | awk 'BEGIN {FS=":"} {print $3}'`
fi
done <${BitStreamToYUVLog}
echo ${YUVName}
}
#usage: runSHA1TableCheck ${SHA1FileName}
runSHA1TableCheck()
{
if [ ! $# -eq 1 ]
then
echo "usage: runSHA1TableCheck \${SHA1FileName}"
return 1
fi
local SHA1File=$1
if [ ! -e "${SHA1File}" ]
then
echo "SHA1 table does not exist: ${SHA1File} "
echo "SHA1 table should be named as \${StreamName}_AllCases_SHA1_Table.csv"
exit 0
fi
return 0
if [ ! -e "${SHA1Table}" ]
then
echo "SHA1 table does not exist: ${SHA1Table} "
echo "SHA1 table should be named as \${StreamName}_AllCases_SHA1_Table.csv"
exit 0
fi
return 0
}
#usage: usage: runBitStreamCheck \$BitStreame
runBitStreamCheck()
{
if [ ! $# -eq 1 ]
then
echo "usage: runBitStreamCheck \$BitStreame"
return 1
fi
local BitStream=$1
local BitSreamName=`echo ${BitStream} | awk 'BEGIN {FS="/"} {print $NF}'`
echo "bit stream is $BitSreamName"
if [ ! -e ${BitStream} ]
then
echo -e "\033[31m bit stream does not exist: $BitSreamName \033[0m"
echo -e "\033[31m please double check under openh264/res folder \033[0m"
echo -e "\033[31m -----detected by run_OneBitStream.sh \033[0m"
exit 0
fi
return 0
local BitSreamName=`echo ${StreamFileFullPath} | awk 'BEGIN {FS="/"} {print $NF}'`
echo "bit stream is $BitSreamName"
if [ ! -e ${StreamFileFullPath} ]
then
echo -e "\033[31m bit stream does not exist: $BitSreamName \033[0m"
echo -e "\033[31m please double check under openh264/res folder \033[0m"
echo -e "\033[31m -----detected by run_OneBitStream.sh \033[0m"
exit 0
fi
return 0
}
#usage: runTestSpaceCheck ${BitStreamTestDir}
runTestSpaceCheck()
runTestSpaceCheck()
{
if [ ! $# -eq 1 ]
then
echo "usage: runMain \${BitStreamTestDir} "
echo "detected by run_OneBitStream.sh"
return 1
fi
local BitStreamTestDir=$1
if [ ! -d ${BitStreamTestDir} ]
then
echo ""
echo -e "\033[31m ----Test space for bitsream does not exist!--- ${BitStreamTestDir} \033[0m"
echo -e "\033[31m ---- before running this test locally, please follow step below: \033[0m"
echo -e "\033[31m ---- 1)cd test/encoder_binary_comparison/ \033[0m"
echo -e "\033[31m ---- 2)run script file: ./run_PrepareAllTestData.sh \033[0m"
echo ""
exit 1
fi
return 0
if [ ! -d ${BitStreamTestDir} ]
then
echo ""
echo -e "\033[31m ----Test space for bitsream does not exist!--- ${BitStreamTestDir} \033[0m"
echo -e "\033[31m ---- before running this test locally, please follow step below: \033[0m"
echo -e "\033[31m ---- 1)cd test/encoder_binary_comparison/ \033[0m"
echo -e "\033[31m ---- 2)run script file: ./run_PrepareAllTestData.sh \033[0m"
echo ""
exit 1
fi
return 0
}
#brief: delete temp files based on test type
runPostAction()
{
echo ""
echo "deleting temp data,entire folder will be deleted........ "
if [ -d ${BitStreamTestDir} ]
then
if [ -d ${BitStreamTestDir} ]
then
${EncoderTestDir}/Scripts/run_SafeDelete.sh ${BitStreamTestDir}
fi
fi
if [ ${TestType} = "TravisTest" ]
then
if [ -d ${FinalResultDir} ]
then
${EncoderTestDir}/Scripts/run_SafeDelete.sh ${FinalResultDir}
fi
fi
if [ ${TestType} = "TravisTest" ]
then
if [ -d ${FinalResultDir} ]
then
${EncoderTestDir}/Scripts/run_SafeDelete.sh ${FinalResultDir}
fi
fi
}
#usage: usage: runMain $BitStreamName $TestType
runMain()
{
if [ ! $# -eq 2 ]
then
echo "usage: runMain \$BitStreamName \$TestType"
echo "detected by run_OneBitStream.sh"
exit 1
fi
BitStreamName=$1
TestType=$2
TestYUVName=""
StreamName=""
BitStreamToYUVLog="Bit2YUV.log"
SHA1Table="${BitStreamName}_AllCases_SHA1_Table.csv"
#dir info
WorkingDir=`pwd`
EncoderTestDir=""
BitStreamTestDir=""
FinalResultDir=""
StreamFileFullPath=""
BitSreamDir=""
if [[ "${WorkingDir}" =~ "test/encoder_binary_comparison" ]]
then
#for local test: working dir is openh264/test/encoder_binary_comparison
EncoderTestDir=${WorkingDir}
BitStreamTestDir="${EncoderTestDir}/AllTestData/${BitStreamName}"
FinalResultDir="${EncoderTestDir}/FinalResult"
BitSreamDir="../../res"
else
#for travis test: working dir is openh264/
EncoderTestDir=${WorkingDir}/test/encoder_binary_comparison
BitStreamTestDir="${EncoderTestDir}/AllTestData/${BitStreamName}"
FinalResultDir="${EncoderTestDir}/FinalResult"
BitSreamDir="${WorkingDir}/res"
fi
cd ${BitSreamDir}
StreamFileFullPath=`pwd`
StreamFileFullPath=${StreamFileFullPath}/${BitStreamName}
cd ${WorkingDir}
runBitStreamCheck ${StreamFileFullPath}
runTestSpaceCheck ${BitStreamTestDir}
#go to Bitstream test space
if [ ! $# -eq 2 ]
then
echo "usage: runMain \$BitStreamName \$TestType"
echo "detected by run_OneBitStream.sh"
exit 1
fi
BitStreamName=$1
TestType=$2
cd ${BitStreamTestDir}
runSHA1TableCheck ${SHA1Table}
#bit stream to YUV
./run_BitStreamToYUV.sh ${StreamFileFullPath}>${BitStreamToYUVLog}
if [ ! $? -eq 0 ]
then
echo "failed to translate bit stream to yuv !"
exit 1
fi
#parse basic info
TestYUVName=`runGetCurrentYUVName ${BitStreamToYUVLog} `
TestYUVName=`echo ${TestYUVName} | awk 'BEGIN {FS="/"} {print $NF} ' `
StreamName=`echo ${StreamFileFullPath} | awk 'BEGIN {FS="/"} {print $NF} ' `
echo ""
echo "TestYUVName is ${TestYUVName}"
echo "StreamName is ${StreamName} "
echo "SHA1Table is ${SHA1Table}"
echo ""
#binary comparison
./run_BinarySHA1Comparison.sh ${TestYUVName} ${SHA1Table}
if [ ! $? -eq 0 ]
then
echo ""
echo -e "\033[31m not all cases passed .....\033[0m"
echo -e "\033[31m this may caused by: \033[0m"
echo -e "\033[31m --1) you changed encoder algorithm which changed the final bit stream \033[0m"
echo -e "\033[31m if so, you need to update the SHA1 table in folder ./test/encoder_binary_comparison/SHA1Table \033[0m"
echo -e "\033[31m --2) the decoder has been changed and since the test YUV is generated by h264dec,the input YUV changed,so bit stream will also change \033[0m"
echo -e "\033[31m if so, you need to update the SHA1 table in folder ./test/encoder_binary_comparison/SHA1Table \033[0m"
echo -e "\033[31m for how to update, please refer to doc: ./test/encoder_binary_comparison/AboutTest \033[0m"
echo -e "\033[31m --3) there may be something wrong in you code change (encoder or decoder) \033[0m"
echo -e "\033[31m if so, please fix bug in your code \033[0m"
cp ./result/* ${FinalResultDir}
cd ${WorkingDir}
#delete the test data
runPostAction
exit 1
else
echo -e "\033[32m all cases passed!! ----bit stream: ${StreamName} \033[0m"
cp ./result/* ${FinalResultDir}
cd ${WorkingDir}
#delete the test data
runPostAction
exit 0
fi
runInitial
runBitStreamCheck
runTestSpaceCheck
#go to Bitstream test space
cd ${BitStreamTestDir}
runSHA1TableCheck
#bit stream to YUV
runBitStreamToYUV
#binary comparison
./run_BinarySHA1Comparison.sh ${TestYUVName} ${SHA1Table}
if [ ! $? -eq 0 ]
then
echo ""
echo -e "\033[31m not all cases passed .....\033[0m"
echo -e "\033[31m this may caused by: \033[0m"
echo -e "\033[31m --1) you changed encoder algorithm which changed the final bit stream \033[0m"
echo -e "\033[31m if so, you need to update the SHA1 table in folder ./test/encoder_binary_comparison/SHA1Table \033[0m"
echo -e "\033[31m --2) the decoder has been changed and since the test YUV is generated by h264dec,the input YUV changed,so bit stream will also change \033[0m"
echo -e "\033[31m if so, you need to update the SHA1 table in folder ./test/encoder_binary_comparison/SHA1Table \033[0m"
echo -e "\033[31m for how to update, please refer to doc: ./test/encoder_binary_comparison/AboutTest \033[0m"
echo -e "\033[31m --3) there may be something wrong in you code change (encoder or decoder) \033[0m"
echo -e "\033[31m if so, please fix bug in your code \033[0m"
cp ./result/* ${FinalResultDir}
cd ${WorkingDir}
#delete the test data
runPostAction
exit 1
else
echo -e "\033[32m all cases passed!! ----bit stream: ${StreamName} \033[0m"
cp ./result/* ${FinalResultDir}
cd ${WorkingDir}
#delete the test data
runPostAction
exit 0
fi
}
BitSteamName=$1
TestType=$2
runMain "${BitSteamName}" "${TestType}"
runMain "${BitSteamName}" "${TestType}"

View File

@ -1,74 +1,68 @@
#!/bin/bash
#*******************************************************************************
# Encoder binary comparison test model
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
# -- Compared with benchmark version using SHA-1 string
# -- Test bit stream under folder openh264/res
# -- SHA-1 string of benchmark version for all cases of all bit streams
# under folder openh264/test/encoder_binary_comparion/SHA1Table
# -- For more detail,please refer to file AboutTest.
#
#brief:
# -- Prepare test space for all test bit streams
# 1) update codec
# 2) update configure files
# 3) create test space for all test bit streams
# -- Usage: run_PrepareAllTestFolder.sh \
# $AllTestDataFolder \
# $TestBitStreamFolder \
# $CodecFolder \
# $ScriptFolder \
# $SHA1TableFolder#
# -- WorkingDir=openh264/test/encoder_binary_comparison
# -- Before using this script, need to
# cd $WorkingDir
# -- Prepare test space for all test bit streams
# 1) update codec
# 2) update configure files
# 3) create test space for all test bit streams
# -- Usage: run_PrepareAllTestFolder.sh \
# $AllTestDataFolder \
# $TestBitStreamFolder \
# $CodecFolder \
# $ScriptFolder \
# $SHA1TableFolder#
# -- WorkingDir=openh264/test/encoder_binary_comparison
# -- Before using this script, need to
# cd $WorkingDir
#
# date: 10/06/2014 Created
# date: 10/06/2014 Created
#*******************************************************************************
#build codec
runBuildCodec()
{
if [ ! $# -eq 1 ]
then
echo "usage: runBuildCodec \64/32 #bits"
exit 1
fi
local MakeFileDir="../.."
local CurrentDir=`pwd`
local BitType=$1
local MakeFileDir="../.."
local CurrentDir=`pwd`
echo "bit type is ${BitType}"
#***************************
#build codec
cd ${MakeFileDir}
if [ "${BitType}" -eq 64 ]
then
make clean
make -B ENABLE64BIT=Yes h264dec h264enc
elif [ "${BitType}" -eq 32 ]
then
make clean
make -B ENABLE64BIT=No h264dec h264enc
else
echo "usage: runBuildCodec \64/32 #bits"
exit 1
fi
echo "bit type is ${BitType}"
#***************************
#build codec
cd ${MakeFileDir}
if [ "${BitType}" -eq 64 ]
then
make clean
make -B ENABLE64BIT=Yes h264dec h264enc
elif [ "${BitType}" -eq 32 ]
then
make clean
make -B ENABLE64BIT=No h264dec h264enc
else
echo "usage: runBuildCodec \64/32 #bits"
exit 1
fi
cd ${CurrentDir}
cd ${CurrentDir}
echo ""
if [ ! -e ${MakeFileDir}/h264enc ]
then
echo "h264 Encoder build failed"
return 1
elif [ ! -e ${MakeFileDir}/h264dec ]
then
echo "h264 Decoder build failed"
return 1
else
echo "codec build succeed!"
return 0
fi
echo ""
if [ ! -e ${MakeFileDir}/h264enc ]
then
echo "h264 Encoder build failed"
return 1
elif [ ! -e ${MakeFileDir}/h264dec ]
then
echo "h264 Decoder build failed"
return 1
else
echo "codec build succeed!"
return 0
fi
}
@ -76,117 +70,105 @@ runBuildCodec()
#copy codec related files to TestSpace's codec folder
runCopyFiles()
{
local CodecFolder="Codec"
local MakeFileDir="../.."
local ConfigureFileDir="../../testbin"
local MakeFileDir="../.."
local ConfigureFileDir="../../testbin"
#copy codec and configure files
cp -p ${MakeFileDir}/h264enc ${CodecFolder}/
cp -p ${MakeFileDir}/h264dec ${CodecFolder}/
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer0.cfg
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer1.cfg
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer2.cfg
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer3.cfg
cp -p ${ConfigureFileDir}/welsenc.cfg ${CodecFolder}/welsenc.cfg
return 0
#copy codec and configure files
cp -p ${MakeFileDir}/h264enc ${CodecFolder}/
cp -p ${MakeFileDir}/h264dec ${CodecFolder}/
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer0.cfg
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer1.cfg
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer2.cfg
cp -p ${ConfigureFileDir}/layer2.cfg ${CodecFolder}/layer3.cfg
cp -p ${ConfigureFileDir}/welsenc.cfg ${CodecFolder}/welsenc.cfg
return 0
}
#usage: runPrepareAllFolder $AllTestDataFolder $CodecFolder $ScriptFolder $SHA1TableFolder
runPrepareAllFolder()
{
#parameter check!
if [ ! $# -eq 4 ]
then
echo "usage: runPrepareAllFolder \$AllTestDataFolder \$CodecFolder \$ScriptFolder \$SHA1TableFolder"
return 1
fi
local SHA1TableName=""
local SubFolder=""
local IssueFolder="issue"
local TempDataFolder="TempData"
local ResultFolder="result"
local AllTestDataFolder=$1
local CodecFolder=$2
local ScriptFolder=$3
local SHA1TableFolder=$4
local SHA1TableName=""
local SubFolder=""
local IssueFolder="issue"
local TempDataFolder="TempData"
local ResultFolder="result"
if [ -d $AllTestDataFolder ]
then
./${ScriptFolder}/run_SafeDelete.sh $AllTestDataFolder
fi
for Bitsream in ${SHA1TableFolder}/*.csv
do
StreamName=`echo ${Bitsream} | awk 'BEGIN {FS="/"} {print $NF} ' `
StreamName=`echo ${StreamName} | awk 'BEGIN {FS="_AllCase"} {print $1} ' `
SubFolder="${AllTestDataFolder}/${StreamName}"
SHA1TableName="${StreamName}_AllCases_SHA1_Table.csv"
echo "BitSream is ${StreamName}"
echo "sub folder is ${SubFolder}"
echo ""
mkdir -p ${SubFolder}
mkdir -p ${SubFolder}/${IssueFolder}
mkdir -p ${SubFolder}/${TempDataFolder}
mkdir -p ${SubFolder}/${ResultFolder}
cp ${CodecFolder}/* ${SubFolder}
cp ${ScriptFolder}/* ${SubFolder}
if [ -e ${SHA1TableFolder}/${SHA1TableName} ]
if [ -d $AllTestDataFolder ]
then
cp ${SHA1TableFolder}/${SHA1TableName} ${SubFolder}
./${ScriptFolder}/run_SafeDelete.sh $AllTestDataFolder
fi
done
for Bitsream in ${SHA1TableFolder}/*.csv
do
StreamName=`echo ${Bitsream} | awk 'BEGIN {FS="/"} {print $NF} ' `
StreamName=`echo ${StreamName} | awk 'BEGIN {FS=".264"} {print $1} ' `
StreamName="${StreamName}.264"
SubFolder="${AllTestDataFolder}/${StreamName}"
SHA1TableName="${StreamName}_AllCases_SHA1_Table.csv"
echo "BitSream is ${StreamName}"
echo "sub folder is ${SubFolder}"
echo ""
mkdir -p ${SubFolder}
mkdir -p ${SubFolder}/${IssueFolder}
mkdir -p ${SubFolder}/${TempDataFolder}
mkdir -p ${SubFolder}/${ResultFolder}
cp ${CodecFolder}/* ${SubFolder}
cp ${ScriptFolder}/* ${SubFolder}
if [ -e ${SHA1TableFolder}/${SHA1TableName} ]
then
cp ${SHA1TableFolder}/${SHA1TableName} ${SubFolder}
fi
done
}
#usage: run_PrepareAllTestFolder.sh ${BitType}
#usage: run_PrepareAllTestFolder.sh ${BitType}
runMain()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: run_PrepareAllTestFolder.sh \${BitType}"
exit 1
fi
local BitType=$1
local AllTestDataFolder="./AllTestData"
local CodecFolder="./Codec"
local ScriptFolder="./Scripts"
local SHA1TableFolder="./SHA1Table"
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: run_PrepareAllTestFolder.sh \${BitType}"
exit 1
fi
if [ -d ./Codec ]
then
./Scripts/run_SafeDelete.sh ./Codec
fi
BitType=$1
AllTestDataFolder="./AllTestData"
CodecFolder="./Codec"
ScriptFolder="./Scripts"
SHA1TableFolder="./SHA1Table"
if [ -d ./FinalResult ]
then
./Scripts/run_SafeDelete.sh ./FinalResult
fi
mkdir Codec
mkdir FinalResult
if [ -d ./Codec ]
then
./Scripts/run_SafeDelete.sh ./Codec
fi
echo ""
echo "building codec.........."
runBuildCodec ${BitType}>build.log
if [ ! $? -eq 0 ]
then
echo "codec build failed ..."
exit 1
fi
if [ -d ./FinalResult ]
then
./Scripts/run_SafeDelete.sh ./FinalResult
fi
mkdir Codec
mkdir FinalResult
echo ""
runCopyFiles
echo ""
echo "preparing All test data folders...."
echo ""
runPrepareAllFolder $AllTestDataFolder $CodecFolder $ScriptFolder $SHA1TableFolder
echo ""
echo ""
echo "building codec.........."
runBuildCodec ${BitType}>build.log
if [ ! $? -eq 0 ]
then
echo "codec build failed ..."
exit 1
fi
return 0
echo ""
runCopyFiles
echo ""
echo "preparing All test data folders...."
echo ""
runPrepareAllFolder $AllTestDataFolder $CodecFolder $ScriptFolder $SHA1TableFolder
echo ""
return 0
}
BitType=$1
runMain ${BitType}
runMain ${BitType}