-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_UpdateCodec.sh
executable file
·122 lines (101 loc) · 3.73 KB
/
run_UpdateCodec.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
#***************************************************************************************
#brief: build and copy codec to Codec folder
#
# usage: run_UpdateCodec.sh ${CodecDir}
#
#date: 5/08/2014 Created
#***************************************************************************************
runUsage()
{
echo -e "\033[32m ******************************************** \033[0m"
echo -e "\033[32m usage: \033[0m"
echo -e "\033[32m ./run_UpdateCodec.sh \${Openh264SrcDir} \033[0m"
echo -e "\033[32m ******************************************** \033[0m"
}
runGlobalVariableInitial()
{
CurrentDir=`pwd`
[ ! -d ${Openh264SrcDir} ] && echo "openh264 dir ${Openh264SrcDir} does not exist!" && exit 1
cd ${Openh264SrcDir} && Openh264SrcDir=`pwd` && cd ${CurrentDir}
YUVDumpMacroFileName="as264_common.h"
YUVDumpMacroFile="${Openh264SrcDir}/codec/encoder/core/inc/${YUVDumpMacroFileName}"
[ ! -f "$YUVDumpMacroFile" ] && echo "file ${YUVDumpMacroFile} does not exist! " && exit 1
CodecDir="Codec"
[ ! -d ${CodecDir} ] && mkdir -p ${CodecDir}
BuildLog="${CurrentDir}/CodecBuildInfo.log"
}
runYUVDumpMacroOpen()
{
TempFile="${YUVDumpMacroFile}.Team.h"
OpenLine="#define WELS_TESTBED"
PreviousLine=""
echo "">${TempFile}
while read line
do
if [[ ${PreviousLine} =~ "#define AS264_COMMON_H_" ]]
then
echo "${OpenLine}">>${TempFile}
fi
echo "${line}">>${TempFile}
PreviousLine=$line
done < ${YUVDumpMacroFile}
mv -f ${TempFile} ${YUVDumpMacroFile}
}
#useage: ./runBuildCodec ${Openh264SrcDir}
runBuildCodec()
{
cd ${Openh264SrcDir}
make clean >${BuildLog}
make >>${BuildLog} 2>&1
[ ! -e h264enc ] || [ ! -e h264dec ] && echo "encoder build failed" && let " Flag = 1 "
cd ${CurrentDir}
return ${Flag}
}
#useage: runCopyFile ${Openh264SrcDir}
runCopyFile()
{
cp -f ${Openh264SrcDir}/h264enc ${CodecDir}
cp -f ${Openh264SrcDir}/h264dec ${CodecDir}
cp -f ${Openh264SrcDir}/testbin/layer2.cfg ${CodecDir}/layer0.cfg
cp -f ${Openh264SrcDir}/testbin/layer2.cfg ${CodecDir}/layer1.cfg
cp -f ${Openh264SrcDir}/testbin/layer2.cfg ${CodecDir}/layer2.cfg
cp -f ${Openh264SrcDir}/testbin/layer2.cfg ${CodecDir}/layer3.cfg
cp -f ${Openh264SrcDir}/testbin/welsenc.cfg ${CodecDir}
}
#useage: ./run_UpdateCodec.sh ${Openh264SrcDir}
runMain()
{
runGlobalVariableInitial
echo -e "\033[32m ******************************************** \033[0m"
echo -e "\033[32m **** enable macro for Rec YUV dump! **** \033[0m"
echo -e "\033[32m ******************************************** \033[0m"
runYUVDumpMacroOpen
echo -e "\033[32m ******************************************** \033[0m"
echo -e "\033[32m **** building codec! **** \033[0m"
echo -e "\033[32m ******************************************** \033[0m"
runBuildCodec
[ ! $? -eq 0 ] && echo "Codec Build failed" && exit 1
echo -e "\033[32m ******************************************** \033[0m"
echo -e "\033[32m copying codec and .cfg files to ${CodecDir} \033[0m"
echo -e "\033[32m ******************************************** \033[0m"
runCopyFile
[ ! $? -eq 0 ] && echo "copy files failed" && exit 1
return 0
}
#****************************************************************************************
echo ""
echo "*********************************************************"
echo " call bash file is $0"
echo " input parameters is:"
echo " $0 $@"
echo "*********************************************************"
echo ""
if [ ! $# -eq 1 ]
then
runUsage
exit 1
fi
Openh264SrcDir=$1
runMain
#****************************************************************************************