• 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#             -- Transform test bit stream into YUV as  test sequence,
12#                1) Called by run_OneBitStream.sh  before testing  all cases
13#                2) eg:
14#                    -- input:    ./run_BitStreamToYUV.sh   TestABC.264
15#                    -- output:   TestABC.264_382X288.yuv
16#             -- Usage:  run_BitStreamToYUV.sh   ${BitStreamFile}
17#
18#
19# date:    10/06/2014 Created
20#*******************************************************************************
21
22#  usage:    run_ParseDecoderLog          $Decoder_LogFile
23#  eg:       input: run_ParseDecoderLog   test.264.log
24#            output 1024  720
25run_ParseDecoderLog()
26{
27    if [ ! $# -eq 1 ]
28    then
29        echo "usage:  run_ParseDecoderLog  \$Decoder_LogFile"
30        return 1
31    fi
32    local LogFile=$1
33    local Width=""
34    local Height=""
35    while read line
36    do
37        if [[  $line =~  "iWidth"   ]]
38        then
39            Width=`echo $line | awk 'BEGIN  {FS="[:\n]"} {print $2}'`
40        fi
41        if [[  $line =~  "height"   ]]
42        then
43             Height=`echo $line | awk 'BEGIN  {FS="[:\n]"} {print $2}'`
44        fi
45    done < ${LogFile}
46    echo "${Width}  ${Height}"
47}
48
49#usage: run_BitStream2YUV    $BitstreamName  $OutputYUVName $LogFile
50run_BitStream2YUV()
51{
52    if [ ! $# -eq 3 ]
53    then
54        echo "usage: run_BitStream2YUV  \$BitstreamName \$OutputYUVName \$LogFile   "
55        return 1
56    fi
57    local BitStreamName=$1
58    local OutputYUVName=$2
59    local LogFile=$3
60    if [ ! -f ${BitStreamName}  ]
61    then
62        echo "bit stream file does not exist!"
63        echo "detected by run_BitStreamToYUV.sh"
64        return 1
65    fi
66    #decode bitstream
67    ./h264dec  ${BitStreamName}  ${OutputYUVName} 2> ${LogFile}
68    return 0
69}
70
71#usage: run_RegularizeYUVName $BitstreamName $OutputYUVName $LogFile
72run_RegularizeYUVName()
73{
74    if [ ! $# -eq 3 ]
75    then
76        echo "usage: run_RegularizeYUVName  \$BitstreamName  \$OutputYUVName \$LogFile "
77        return 1
78    fi
79    local BitStreamName=$1
80    local OrignName=$2
81    local LogFile=$3
82    local RegularizedYUVName=""
83    declare -a aDecodedYUVInfo
84    aDecodedYUVInfo=(`run_ParseDecoderLog  ${LogFile}`)
85    BitStreamName=`echo ${BitStreamName} | awk 'BEGIN {FS="/"} {print $NF}'`
86    RegularizedYUVName="${BitStreamName}_${aDecodedYUVInfo[0]}x${aDecodedYUVInfo[1]}.yuv"
87    mv -f  ${OrignName}   ${RegularizedYUVName}
88    echo ""
89    echo "file: ${OrignName}   has been renamed as: ${RegularizedYUVName}"
90    echo ""
91    return 0
92}
93
94#usage: runMain    ${BitStreamName}
95runMain()
96{
97    if [ ! $# -eq 1 ]
98    then
99        echo "usage: runMain  \${BitStreamName} "
100        return 1
101    fi
102    local BitStreameFile=$1
103    local BitSteamName=`echo ${BitStreameFile} | awk 'BEGIN {FS="/"} {print $NF}'`
104    local DecoderLogFile="${BitSteamName}_h264dec.log"
105    local DecodedYUVName="${BitSteamName}_dec.yuv"
106    local RegularizedName=""
107
108    #**********************
109    #decoded test bit stream
110    run_BitStream2YUV  ${BitStreameFile}  ${DecodedYUVName}  ${DecoderLogFile}
111    if [  ! $?  -eq 0  ]
112    then
113        echo "bit stream decoded  failed!"
114        return 1
115    fi
116    #*********************
117    #regularized  YUV name
118    run_RegularizeYUVName  ${BitStreameFile}  ${DecodedYUVName}  ${DecoderLogFile}
119    return 0
120}
121BitStreamFile=$1
122runMain    ${BitStreamFile}
123
124