add encoder binary comparison test model

This commit is contained in:
shihuade
2014-07-08 13:15:57 -04:00
parent ca61e286b4
commit 78771344b7
13 changed files with 9992 additions and 4 deletions

View File

@@ -1,15 +1,39 @@
language: cpp
compiler:
- g++
- clang
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq nasm g++-4.6-multilib gcc-multilib libc6-dev-i386
install:
- make gmp-bootstrap
- make gtest-bootstrap
before_script:
- WorkingDir=`pwd`
- cd test/encoder_binary_comparison
- ./run_PrepareAllTestData.sh 64
- cd ${WorkingDir}
env:
- TASK=UnitTest; TestParameter=""
- TASK=BinaryCompare; TestParameter=BA_MW_D.264;
- TASK=BinaryCompare; TestParameter=LS_SVA_D.264;
- TASK=BinaryCompare; TestParameter=CVPCMNL1_SVA_C.264;
matrix:
exclude:
- compiler: clang
env: TASK=BinaryCompare; TestParameter=BA_MW_D.264;
- compiler: clang
env: TASK=BinaryCompare; TestParameter=LS_SVA_D.264;
- compiler: clang
env: TASK=BinaryCompare; TestParameter=CVPCMNL1_SVA_C.264;
script:
- make -B ENABLE64BIT=Yes BUILDTYPE=Release all plugin test
- make -B ENABLE64BIT=Yes BUILDTYPE=Debug all plugin test
- make -B ENABLE64BIT=No BUILDTYPE=Release all plugin test
- make -B ENABLE64BIT=No BUILDTYPE=Debug all plugin test
- echo "currrent test is for ${TASK}"
- echo "test parameter is ${TestParameter}"
- ./run_Test.sh ${TASK} ${TestParameter}

54
run_Test.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
#usage:runMain ${TestType} ${TestBitStream}
runMain()
{
local ParameterFlag=""
if [ $# -eq 1 -a "$1" = "UnitTest" ]
then
let "ParameterFlag=0"
elif [ $# -eq 2 -a "$1" = "BinaryCompare" ]
then
let "ParameterFlag=0"
else
let "ParameterFlag=1"
fi
if [ ! ${ParameterFlag} -eq 0 ]
then
echo "usage: runMain UnitTest "
echo " or runMain BinaryCompare \${TestBitStreamName} "
exit 1
fi
local TestType=$1
local TestBitStream=$2
if [ "${TestType}" = "UnitTest" ]
then
make -B ENABLE64BIT=Yes BUILDTYPE=Release all plugin test
make -B ENABLE64BIT=Yes BUILDTYPE=Debug all plugin test
make -B ENABLE64BIT=No BUILDTYPE=Release all plugin test
make -B ENABLE64BIT=No BUILDTYPE=Debug all plugin test
elif [ "${TestType}" = "BinaryCompare" ]
then
echo ""
echo " binary compare test, test bit stream is ${TestBitStream}"
echo ""
./test/encoder_binary_comparison/run_OneBitStream.sh ${TestBitStream}
fi
}
TestType=$1
TestBitStream=$2
runMain ${TestType} ${TestBitStream}

View File

@@ -0,0 +1,66 @@
about
#*******************************************************************************
1.This file is about how to run encoder binary comparison test.
Binary comparison is the comparison between target encoder and benchmark encoder.
2.As SHA1 string is unique for bit stream file. so in current test, we only compare
the SHA1 string of bit stream. If the SHA1 string of target bit stream is the same
with benchmark's, the related test case can be verified as pass status.
3.SHA1 table files for each test bit stream are pre-generated.
For how to update SHA1 tables, please go to below part "how to update SHA1 table"
4.SHA1 tables can be found in folder ./SHA1Table/
5.Test bit streams are those xxx.264 files in folder openh264/res/
--If you want to change the test bit stream on travis test,
please go to part "for travis test"
--If you want to run test locally, please to go part "for local test"
how to update SHA1 table
#*******************************************************************************
If there is something change in bit stream due to your encoder design;
you need to update the SHA1 tables in ./SHA1Table.As the SHA1 string is unique, once the
bit stream change, the SHA1 string will also change.
If you want to update SHA1 table files in ./SHA1Tabel, please run below command under
openh264/test/encoder_binary_test,
./run_Main.sh UpdateSHA1Table
for travis test
#*******************************************************************************
Currently, travis only allow 5 jobs on parallel status, and 2 jobs are for
unit test with g++ and clang compiler. So there will be only 3 jobs left for encoder
binary comparison test, which means that 3 of 27 bit stream in ./res folder are chosen for test.
Actually, you can use all of test bit streams in ./res folder, but it will take
a long time to wait for the test result. So we do not suggest to do so.
If you want to test all cases for all test bit steams in ./res,you need to generate related
SHA1 table files before you add those bit streams into below setting.
To change the test bit steam in travis, you can edit file .travis.yml.
For example,if you want to add CVPCMNL1_SVA_C.264 as test bit stream, you can add on line and
change the TestParameter value to CVPCMNL1_SVA_C.264
- TASK=BinaryCompare; TestParameter=CVPCMNL1_SVA_C.264;
Below is the example for adding CVPCMNL1_SVA_C.264 into test list.
****************************************************************************************
env:
- TASK=UnitTest; TestParameter=""
- TASK=BinaryCompare; TestParameter=BA_MW_D.264;
- TASK=BinaryCompare; TestParameter=MR2_MW_A.264;
- TASK=BinaryCompare; TestParameter=CVPCMNL1_SVA_C.264;
****************************************************************************************
for local test
#*******************************************************************************
If you want to run the test locally,you can run below command:
./run_Main.sh LocalTest
All SHA1 tables in ./SHA1Table/ folder will be tested.
And the final result can be found in folder ./FinalResult, which include:
--console log for each test bit stream (XXXX.TestLog)
--pass status for each case each bit stream (xxx_AllCaseOutput.csv)
--pass status for each case each bit stream (xxx_unpassCaseOutput.csv)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,408 @@
#!/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¡£
#
#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}
#
# 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 EncoderCommandSet
declare -a EncoderCommandName
declare -a EncoderCommandValue
#encoder parameters change based on the case info
CaseInfo=""
BitStreamFile=""
DiffFlag=""
#pass number
TotalCaseNum=""
PassCaseNum=""
UnpassCaseNum=""
}
#called by runGlobalVariableInitial
#usage runEncoderCommandInital
runEncoderCommandInital()
{
EncoderCommandSet=(-frms \
-numtl \
-scrsig \
-rc \
-tarb \
"-lqp 0" \
-iper \
"-slcmd 0" \
"-slcnum 0" \
-thread \
-ltr \
-db \
-nalsize \
-denois \
-scene \
-bgd \
-aq)
EncoderCommandName=(FrEcoded \
NumTempLayer \
ContentSig \
RC \
BitRate \
QP \
IntraPeriod \
SlcMd \
SlcMum \
ThrMum \
LTR \
LFilterIDC \
MacNalSize \
DenoiseFlag \
SceneChangeFlag \
BackgroundFlag \
AQFlag)
EncoderCommandValue=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
NumParameter=${#EncoderCommandSet[@]}
}
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"
echo "BitMatched Status, \
SHA-1-Target, SHA-1-Benchmark, \
MD5-Target, MD5-Benchmark, \
Bitstream-Target,Bitstream-Benchmark, \
YUV-Target,YUV-Benchmark, \
-frms, -numtl, -scrsig, -rc, \
-tarb, -lqp 0, -iper, \
-slcmd 0,-slcnum 0, -thread, \
-ltr, -db, -nalsize,-denois, \
-scene, -bgd, -aq">${AllCasePassStatusFile}
echo "BitMatched Status, \
SHA-1-Target, SHA-1-Benchmark, \
MD5-Target, MD5-Benchmark, \
Bitstream-Target,Bitstream-Benchmark,\
YUV-Target,YUV-Benchmark, \
-frms, -numtl, -scrsig, -rc, \
-tarb, -lqp 0, -iper, \
-slcmd 0,-slcnum 0, -thread, \
-ltr, -db, -nalsize,-denois, \
-scene, -bgd, -aq">${UnpassCaseFile}
echo "SHA-1 Value, \
MD5String, BitStreamSize, YUVSize, \
-frms, -numtl, -scrsig, -rc, \
-tarb, -lqp 0, -iper, \
-slcmd 0,-slcnum 0, -thread, \
-ltr, -db, -MaxNalSize,-denois, \
-scene, -bgd, -aq">${UpdateSHA1TableFile}
#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=""
}
#***********************************************************
#called by runAllCaseTest
# parse case info --encoder preprocess
#usage runParseCaseInfo $CaseData
runParseCaseInfo()
{
if [ $# -lt 1 ]
then
echo "runParseCaseInfo \$CaseData"
return 1
fi
local TempData=""
local BitstreamPrefix=""
local CaseData=$@
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} ' `
TempData=`echo $CaseData |awk 'BEGIN {FS="[,\r]"} {for(i=5;i<=NF;i++) printf(" %s",$i)} ' `
EncoderCommandValue=(${TempData})
for((i=0; i<$NumParameter; i++))
do
BitstreamPrefix=${BitstreamPrefix}_${EncoderCommandName[$i]}_${EncoderCommandValue[$i]}
done
BitstreamTarget=${TempDataPath}/${TestSequenceName}_${BitstreamPrefix}_codec_target.264
echo ""
echo "BitstreamPrefix is ${BitstreamPrefix}"
echo ""
}
#called by runAllCaseTest
#usage runEncodeOneCase
runEncodeOneCase()
{
BitStreamFile=${BitstreamTarget}
CaseCommand=" ${ConfigureFile} \
-numl 1 \
-lconfig 0 layer2.cfg \
-sw ${PicW} -sh ${PicH} \
-dw 0 ${PicW} -dh 0 ${PicH} \
-frout 0 30 \
-ltarb 0 ${EncoderCommandValue[4]} \
${EncoderCommandSet[0]} ${EncoderCommandValue[0]} \
${EncoderCommandSet[1]} ${EncoderCommandValue[1]} \
${EncoderCommandSet[2]} ${EncoderCommandValue[2]} \
${EncoderCommandSet[3]} ${EncoderCommandValue[3]} \
${EncoderCommandSet[4]} ${EncoderCommandValue[4]} \
${EncoderCommandSet[5]} ${EncoderCommandValue[5]} \
${EncoderCommandSet[6]} ${EncoderCommandValue[6]} \
${EncoderCommandSet[7]} ${EncoderCommandValue[7]} \
${EncoderCommandSet[8]} ${EncoderCommandValue[8]} \
${EncoderCommandSet[9]} ${EncoderCommandValue[9]} \
${EncoderCommandSet[10]} ${EncoderCommandValue[10]} \
${EncoderCommandSet[11]} ${EncoderCommandValue[11]} \
${EncoderCommandSet[12]} ${EncoderCommandValue[12]} \
${EncoderCommandSet[13]} ${EncoderCommandValue[13]} \
${EncoderCommandSet[14]} ${EncoderCommandValue[14]} \
${EncoderCommandSet[15]} ${EncoderCommandValue[15]} \
${EncoderCommandSet[16]} ${EncoderCommandValue[16]}"
echo ${EncoderCommandSet[@]}
echo ${EncoderCommandValue[@]}
echo ${EncoderCommandSet[11]}
echo ${EncoderCommandValue[11]}
echo ${EncoderCommandSet[12]}
echo ${EncoderCommandValue[12]}
EncoderCommand="./h264enc ${CaseCommand} -bf ${BitStreamFile} -org ${TestSequencePath}/${TestSequenceName} "
echo ""
echo "case line is :"
echo " ${EncoderCommand}"
echo -e "\n\n"
./h264enc ${CaseCommand} \
-bf ${BitStreamFile} \
-org ${TestSequencePath}/${TestSequenceName} 2>${EncoderLogFile}
}
#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
runBitStreamVerify()
{
echo ""
echo "******************************************"
echo "Bit streamSHA1 value comparison.... "
#*******************************************
if [ ! -s ${BitStreamFile} ]
then
let "UnpassCaseNum++"
DiffFlag="2:unpassed! 0 bits--bit stream"
return 1
fi
#*******************************************
#*******************************************
#SHA1(run_Test.sh)= fde74d9e8194d0cf28991a0481c7158a033ec920
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 "bitstream pass! MD5-- ${TargetMD5} ----- ${BenchmarkMD5}"
echo "YUV size pass! size--${TargetYUVSize}--${BenchmarkYUVSize} "
echo "BitStreamSize pass! size--${TargetBitstreamSize}--${BenchmarkBitstreamSize}"
DiffFlag="0:passed!"
let "PassCaseNum++"
return 0
else
echo "!!! SHA1 string not match: ${TargetSHA1} ----- ${BenchmarkSHA1} "
echo "bitstream pass! MD5-- ${TargetMD5} ----- ${BenchmarkMD5}"
echo "YUV size pass! size--${TargetYUVSize}--${BenchmarkYUVSize} "
echo "BitStreamSize pass! size--${TargetBitstreamSize}--${BenchmarkBitstreamSize}"
DiffFlag="1: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
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)} '`
echo "${DiffFlag}, ${TargetSHA1}, ${BenchmarkSHA1}, {TargetMD5}, ${BenchmarkMD5}, \
${TargetBitstreamSize} , ${BenchmarkBitstreamSize},\
${TargetYUVSize}, ${BenchmarkYUVSize},\
${CaseInfo}, ${EncoderCommand} " >>${AllCasePassStatusFile}
echo "${TargetSHA1}, ${TargetMD5},${TargetBitstreamSize}, ${TargetYUVSize},${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 ""
}
# run all test case based on XXXcase.csv file
#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!" ]
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"
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"
echo "${DiffFlag}, ${TargetSHA1}, ${BenchmarkSHA1}, ${TargetMD5}, ${BenchmarkMD5}, \
${TargetBitstreamSize} , ${BenchmarkBitstreamSize}, \
${TargetYUVSize}, ${BenchmarkYUVSize}, \
${CaseInfo}, ${EncoderCommand} ">>${UnpassCaseFile}
fi
runSingleCasePostAction ${CaseData}
let "TotalCaseNum++"
fi
done <$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
}
TestYUVName=$1
AllCaseFile=$2
runMain ${TestYUVName} ${AllCaseFile}

View File

@@ -0,0 +1,131 @@
#!/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.
#
#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}
#
#
# date: 10/06/2014 Created
#*******************************************************************************
#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" ]]
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
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
}
#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
}
#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
}
BitStreamFile=$1
runMain ${BitStreamFile}

View File

@@ -0,0 +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.
#
#brief:
# -- Parse sequence basic info such as picw pich and fps via name
# -- Usage: run_ParseYUVInfo.sh ${TestSequenceName}
#
# 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
runGetYUVInfo()
{
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
let "Index++"
done
#get fps info
let "Index++"
if [ $Index -le ${#aPicInfo[@]} ]
then
if [[ ${aPicInfo[$Index]} =~ ^[1-9] ]] || [[ ${aPicInfo[$Index]} =~ $Pattern_04 ]]
then
FPS=`echo ${aPicInfo[$Index]} | awk 'BEGIN {FS="[a-zA-Z]" } {print $1} '`
fi
fi
echo "$PicWidth $PicHeight $FPS"
}
TestSequenceName=$1
runGetYUVInfo ${TestSequenceName}

View File

@@ -0,0 +1,249 @@
#!/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.
#
#brief:
# -- Usage: ./run_SafeDelere.sh $DeleteItermPath
# eg: 1 ./run_SafeDelere.sh tempdata.info --->delete only one file
# eg: 2 ./run_SafeDelere.sh ../TempDataFolder --->delete entire folder
# ./run_SafeDelere.sh /opt/TempData/ABC --->delete entire folder ABC
#
# date: 10/06/2014 Created
#*******************************************************************************
#usage: runGetFileName $FilePath
runGetFileName()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runGetFileName \$FilePath"
return 1
fi
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
}
#******************************************************************************************************
#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
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
}
#******************************************************************************************************
#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
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
}
#******************************************************************************************************
#usage: runUserNameCheck $whoami
runUserNameCheck()
{
#parameter check!
if [ ! $# -eq 1 ]
then
echo "usage: runUserNameCheck \$whoami"
return 1
fi
local UserName=$1
if [ ${UserName} = "root" ]
then
echo ""
echo "*********************************************"
echo "delete files under root is not allowed"
echo "detected by run_SafeDelere.sh"
return 1
else
echo ""
return 0
fi
}
#******************************************************************************************************
#usage: runFolderLocationCheck $FullPath
runFolderLocationCheck()
{
#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}'`
#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_SafeDelere.sh"
return 1
fi
return 0
}
#******************************************************************************************************
#usage runSafeDelete $Pathinfo
runSafeDelete()
{
#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=""
#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 iterm does not exist"
echo "detected by run_SafeDelere.sh"
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 ""
}
PathInfo=$1
runSafeDelete $PathInfo

View File

@@ -0,0 +1,154 @@
#!/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.
#
#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
#*******************************************************************************
#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
}
#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 ""
}
#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_AllCase_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
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}
if [ ! $? -eq 0 ]
then
let "Flag=1"
fi
done
#post action
if [ ${TestType} = "LocalTest" ]
then
runLocalTestPostAction
elif [ ${TestType} = "UpdateSHA1Table" ]
then
runUpdateSHA1TablePostAction
fi
}
TestType=$1
runMain ${TestType}

View File

@@ -0,0 +1,195 @@
#!/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.
#
#brief:
# -- Usage: run_OneBitStream.sh $BitSteamName
# -- 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
#*******************************************************************************
#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" ]]
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}_AllCase_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
}
#usage: runTestSpaceCheck ${BitStreamTestDir}
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
}
#usage: usage: runMain \$BitStreamName
runMain()
{
if [ ! $# -eq 1 ]
then
echo "usage: runMain \$BitStreamName "
echo "detected by run_OneBitStream.sh"
return 1
fi
local BitStreamName=$1
local TestYUVName=""
local StreamName=""
local BitStreamToYUVLog="Bit2YUV.log"
local SHA1Table="${BitStreamName}_AllCase_SHA1_Table.csv"
#dir info
local WorkingDir=`pwd`
local EncoderTestDir=""
local BitStreamTestDir=""
local FinalResultDir=""
local StreamFileFullPath=""
local 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
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
echo ""
echo "deleting temp data,entire folder will be deleted........ "
${EncoderTestDir}/Scripts/run_SafeDelete.sh ${BitStreamTestDir}
exit 1
else
echo -e "\033[32m all cases passed!! ----bit stream: ${StreamName} \033[0m"
cp ./result/* ${FinalResultDir}
cd ${WorkingDir}
#delete the test data
echo ""
echo "deleting temp data,entire folder will be deleted........ "
${EncoderTestDir}/Scripts/run_SafeDelete.sh ${BitStreamTestDir}
exit 0
fi
}
BitSteamName=$1
runMain $BitSteamName

View File

@@ -0,0 +1,189 @@
#!/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.
#
#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
#
# date: 10/06/2014 Created
#*******************************************************************************
#build codec
runBuildCodec()
{
if [ ! $# -eq 1 ]
then
echo "usage: runBuildCodec \64/32 #bits"
exit 1
fi
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
elif [ "${BitType}" -eq 32 ]
then
make clean
make -B ENABLE64BIT=No
else
echo "usage: runBuildCodec \64/32 #bits"
exit 1
fi
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
}
#copy codec related files to TestSpace's codec folder
runCopyFiles()
{
local CodecFolder="Codec"
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}/
cp -p ${ConfigureFileDir}/welsenc.cfg ${CodecFolder}/
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 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}_AllCase_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}
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"
if [ -d ./Codec ]
then
./Scripts/run_SafeDelete.sh ./Codec
fi
if [ -d ./FinalResult ]
then
./Scripts/run_SafeDelete.sh ./FinalResult
fi
mkdir Codec
mkdir FinalResult
echo ""
echo "building codec.........."
runBuildCodec ${BitType}>build.log
if [ ! $? -eq 0 ]
then
echo "codec build failed ..."
exit 1
fi
echo ""
runCopyFiles
echo ""
echo "preparing All test data folders...."
echo ""
runPrepareAllFolder $AllTestDataFolder $CodecFolder $ScriptFolder $SHA1TableFolder
echo ""
return 0
}
BitType=$1
runMain ${BitType}