• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#*******************************************************************************
3# Encoder binary comparison test model
4#           -- Compared with benchmark version using SHA-1 string
5#           -- Test bit stream under folder  openh264/res
6#           -- SHA-1 string of benchmark version for  all cases  of all bit streams
7#               under folder  openh264/test/encoder_binary_comparion/SHA1Table
8#           -- For more detail,please refer to file AboutTest.
9#
10#brief:
11#           -- Prepare test space for all test bit streams
12#              1) update codec
13#              2) update configure files
14#              3) create test space for all test bit streams
15#           -- Usage: run_PrepareAllTestFolder.sh \
16#                           $AllTestDataFolder    \
17#                           $TestBitStreamFolder  \
18#                           $CodecFolder          \
19#                           $ScriptFolder         \
20#                           $SHA1TableFolder#
21#          -- WorkingDir=openh264/test/encoder_binary_comparison
22#           -- Before using this script, need to
23#                 cd  $WorkingDir
24#
25# date:    10/06/2014 Created
26#*******************************************************************************
27
28#build codec
29runBuildCodec()
30{
31    local MakeFileDir="../.."
32    local CurrentDir=`pwd`
33
34    echo "bit type is ${BitType}"
35    #***************************
36    #build codec
37    cd ${MakeFileDir}
38    if [ "${BitType}" -eq 64   ]
39    then
40        make clean
41        make -B ENABLE64BIT=Yes h264dec h264enc
42    elif [ "${BitType}" -eq 32   ]
43    then
44        make clean
45        make -B ENABLE64BIT=No h264dec h264enc
46    else
47        echo "usage: runBuildCodec  \64/32  #bits"
48        exit 1
49    fi
50
51    cd ${CurrentDir}
52
53    echo ""
54    if [ ! -e ${MakeFileDir}/h264enc  ]
55    then
56        echo "h264 Encoder build failed"
57        return 1
58    elif [ ! -e ${MakeFileDir}/h264dec  ]
59    then
60        echo "h264 Decoder build failed"
61        return 1
62    else
63        echo "codec build succeed!"
64        return 0
65    fi
66
67}
68
69
70#copy codec related files to TestSpace's codec folder
71runCopyFiles()
72{
73    local MakeFileDir="../.."
74    local ConfigureFileDir="../../testbin"
75
76    #copy codec and configure files
77    cp  -p  ${MakeFileDir}/h264enc    ${CodecFolder}/
78    cp  -p  ${MakeFileDir}/h264dec    ${CodecFolder}/
79    cp  -p  ${ConfigureFileDir}/layer2.cfg     ${CodecFolder}/layer0.cfg
80    cp  -p  ${ConfigureFileDir}/layer2.cfg     ${CodecFolder}/layer1.cfg
81    cp  -p  ${ConfigureFileDir}/layer2.cfg     ${CodecFolder}/layer2.cfg
82    cp  -p  ${ConfigureFileDir}/layer2.cfg     ${CodecFolder}/layer3.cfg
83    cp  -p  ${ConfigureFileDir}/welsenc.cfg    ${CodecFolder}/welsenc.cfg
84    return 0
85}
86
87runPrepareAllFolder()
88{
89    local SHA1TableName=""
90    local SubFolder=""
91    local IssueFolder="issue"
92    local TempDataFolder="TempData"
93    local ResultFolder="result"
94
95    if [ -d $AllTestDataFolder ]
96    then
97        ./${ScriptFolder}/run_SafeDelete.sh  $AllTestDataFolder
98    fi
99
100    for Bitsream in ${SHA1TableFolder}/*.csv
101    do
102        StreamName=`echo ${Bitsream} | awk 'BEGIN {FS="/"}  {print $NF}   ' `
103        StreamName=`echo ${StreamName} | awk 'BEGIN {FS=".264"}  {print $1}   ' `
104        StreamName="${StreamName}.264"
105        SubFolder="${AllTestDataFolder}/${StreamName}"
106        SHA1TableName="${StreamName}_AllCases_SHA1_Table.csv"
107        echo "BitSream is ${StreamName}"
108        echo "sub folder is  ${SubFolder}"
109        echo ""
110        mkdir -p ${SubFolder}
111        mkdir -p ${SubFolder}/${IssueFolder}
112        mkdir -p ${SubFolder}/${TempDataFolder}
113        mkdir -p ${SubFolder}/${ResultFolder}
114        cp  ${CodecFolder}/*   ${SubFolder}
115        cp  ${ScriptFolder}/*   ${SubFolder}
116        if [ -e ${SHA1TableFolder}/${SHA1TableName}  ]
117        then
118          cp  ${SHA1TableFolder}/${SHA1TableName}   ${SubFolder}
119        fi
120
121    done
122
123}
124#usage: run_PrepareAllTestFolder.sh     ${BitType}
125runMain()
126{
127    #parameter check!
128    if [ ! $# -eq 1  ]
129    then
130        echo "usage: run_PrepareAllTestFolder.sh   \${BitType}"
131        exit 1
132    fi
133
134    BitType=$1
135    AllTestDataFolder="./AllTestData"
136    CodecFolder="./Codec"
137    ScriptFolder="./Scripts"
138    SHA1TableFolder="./SHA1Table"
139
140    if [ -d ./Codec ]
141    then
142        ./Scripts/run_SafeDelete.sh ./Codec
143    fi
144
145    if [ -d ./FinalResult  ]
146    then
147        ./Scripts/run_SafeDelete.sh ./FinalResult
148    fi
149    mkdir Codec
150    mkdir FinalResult
151
152    echo ""
153    echo "building codec.........."
154    runBuildCodec  ${BitType}>build.log
155    if [ ! $? -eq 0 ]
156    then
157        echo "codec build failed ..."
158        exit 1
159    fi
160
161    echo ""
162    runCopyFiles
163    echo ""
164    echo "preparing All test data folders...."
165    echo ""
166    runPrepareAllFolder   $AllTestDataFolder  $CodecFolder  $ScriptFolder  $SHA1TableFolder
167    echo ""
168
169    return 0
170}
171
172BitType=$1
173runMain     ${BitType}
174
175