TestRunnerWave420lEnc.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. #!/bin/bash
  2. source common.sh
  3. # default values
  4. g_product_name="wave4"
  5. test_exec="./w4_enc_test"
  6. wiki_log_file="./log/enc_confluence.log"
  7. enable_random=0;
  8. txt_param_switch=0;
  9. secondary_axi_def=0
  10. build_stream=0
  11. cfg_dir=./cfg
  12. yuv_base_path=./yuv
  13. if [ "${OS}" = "Windows_NT" ]; then
  14. ref_c_exec=./hevc_enc.exe
  15. else
  16. ref_c_exec=./hevc_enc
  17. fi
  18. ACLK_MAX=27
  19. BCLK_MAX=27
  20. CCLK_MAX=21
  21. MCLK_MAX=29
  22. VCLK_MAX=29
  23. cframe50d_temp=0
  24. function help {
  25. echo ""
  26. echo "-------------------------------------------------------------------------------"
  27. echo "Chips&Media conformance Tool v2.0"
  28. echo "All copyright reserved by Chips&Media"
  29. echo "-------------------------------------------------------------------------------"
  30. echo "$0 OPTION streamlist_file"
  31. echo "-h help"
  32. echo "--yuv-dir input yuv directory"
  33. echo "--ref-dir ref-c directory"
  34. echo "--bin-dir ref-c directory"
  35. echo "--enable-random [optional] generate random opton"
  36. echo "--build-stream Just generate golden stream with Ref-C."
  37. }
  38. OPTSTRING="-o hn:c:"
  39. #ifdef SUPPORT_CONFTEST
  40. OPTSTRING="${OPTSTRING}t"
  41. #endif
  42. OPTSTRING="${OPTSTRING} -l jump-stream:,bsmode:,enable-random,md5-dir:,yuv-dir:,build-stream,ref-dir:,wiki:,n:"
  43. OPTS=`getopt $OPTSTRING -- "$@"`
  44. if [ $? != 0 ]; then
  45. exit 1;
  46. fi
  47. eval set -- "$OPTS"
  48. while true; do
  49. case "$1" in
  50. -h)
  51. help
  52. exit 0
  53. shift;;
  54. -n)
  55. frame_num="-n $2"
  56. if [ "$2" = "" ]; then
  57. frame_num_refc=""
  58. else
  59. frame_num_refc="-f $2"
  60. fi
  61. shift 2;;
  62. -c)
  63. codec=$(echo $2 | tr '[:upper:]' '[:lower:]')
  64. shift 2;;
  65. --enable-random)
  66. enable_random=1
  67. shift;;
  68. --yuv-dir)
  69. yuv_dir=$2
  70. shift 2;;
  71. --ref-dir)
  72. ref_dir=$2
  73. shift 2;;
  74. --build-stream)
  75. build_stream=1;
  76. shift;;
  77. --wiki)
  78. wiki_log_file=$2
  79. shift 2;;
  80. --)
  81. shift
  82. break;;
  83. esac
  84. done
  85. shift $(($OPTIND - 1))
  86. ################################################################################
  87. # Get param from target text file #
  88. ################################################################################
  89. input_param_name=TestRunnerParamWave420lEnc.txt
  90. if [ -f $input_param_name ] && [ $enable_random == 0 ]; then
  91. echo "read $input_param_name"
  92. while read line; do
  93. # remove right comment
  94. line=$(echo $line | tr -d '\n')
  95. line=$(echo $line | tr -d '\r')
  96. line="${line%%\#*}"
  97. attr=$(echo $line | cut -d'=' -f1)
  98. attr=$(echo $attr | tr -d ' ')
  99. if [ "$attr" == "enable-cbcrInterleave" ]; then
  100. value=$(echo $line | cut -d '=' -f3)
  101. else
  102. value=$(echo $line | cut -d'=' -f2)
  103. fi
  104. if [ "$attr" != "MODE_COMP" ]; then
  105. value=$(echo $value | tr -d ' ')
  106. fi
  107. case "$attr" in
  108. default) default_opt="$value";;
  109. secondary-axi) secondary_axi_temp="$value";;
  110. enable-cbcrInterleave) nv21_temp="$value";;
  111. enable_nv21) nv21_temp="$value";;
  112. yuv_src_mode) yuv_src_mode_temp="$value";;
  113. srcFormat3p4b) srcFormat3p4b_temp="$value";;
  114. stream-endian) stream_endian_temp="$value";;
  115. source-endian) source_endian_temp="$value";;
  116. frame-endian) frame_endian_temp="$value";;
  117. bsmode) bsmode_temp="$value";;
  118. rotAngle) rotAngle_temp="$value";;
  119. mirDir) mirDir_temp="$value";;
  120. MODE_COMP_ENCODED) MODE_COMP_ENCODED_temp="$value";;
  121. n) frame_num="-n $value"
  122. if [ "$value" = "0" ]; then
  123. frame_num_refc=""
  124. else
  125. frame_num_refc="-f $value"
  126. fi;;
  127. subFrameSyncEn) subframe_sync_temp="$value";;
  128. cframe50d) cframe50d_temp=0;;
  129. txt-param) txt_param_switch=1;;
  130. *) ;;
  131. esac
  132. done < $input_param_name
  133. else
  134. if [ ! -f "$input_param_name" ]; then
  135. echo " $input_param_name file doesn't exist";
  136. fi
  137. fi
  138. streamset_path=$1
  139. echo "streamset_path=$1"
  140. streamset_file=`basename ${streamset_path}`
  141. if [ ! -f "${streamset_path}" ]; then
  142. echo "No such file: ${streamset_path}"
  143. exit 1
  144. fi
  145. ################################################################################
  146. # Get version information #
  147. ################################################################################
  148. if [ $build_stream -eq 0 ]; then
  149. get_product_id $test_exec
  150. product_id=$?
  151. if [ "${g_revision}" = "" ] || [ ${productId} != 6 ]; then
  152. echo "Invalid product ID($product_id), expected value(6)"
  153. exit 1
  154. fi
  155. fi
  156. ################################################################################
  157. # calculate stream number #
  158. ################################################################################
  159. stream_file_array=()
  160. index=0
  161. num_of_streams=0
  162. while read line || [ -n "$line" ]; do
  163. line=$(echo $line | tr -d '\n')
  164. line=$(echo $line | tr -d '\r')
  165. line=${line#*( )} # remove front whitespace
  166. line=$(echo $line | cut -d' ' -f1)
  167. firstchar=${line:0:1}
  168. case "$firstchar" in
  169. "@") break;; # exit flag
  170. "#") continue;; # comment
  171. ";") continue;; # comment
  172. "") continue;; # comment
  173. *)
  174. esac
  175. stream_file_array[$index]="$line"
  176. index=$(($index + 1))
  177. done < ${streamset_path}
  178. num_of_streams=${#stream_file_array[@]}
  179. #echo ${stream_file_array[@]}
  180. count=1
  181. success_count=0
  182. failure_count=0
  183. remain_count=${num_of_streams}
  184. basedir=${basedir//\/} # remove last delimeter
  185. mkdir -p temp
  186. mkdir -p output
  187. mkdir -p log/encoder_conformance
  188. conf_log_path="log/encoder_conformance/${streamset_file}_r${revision}.log"
  189. conf_err_log_path="log/encoder_conformance/${streamset_file}_error_r${revision}.log"
  190. temp_log_path="./temp/temp.log"
  191. # truncate contents of log file
  192. echo "" > $conf_log_path
  193. echo "" > $conf_err_log_path
  194. echo "" > $temp_log_path
  195. beginTime=$(date +%s%N)
  196. ################################################################################
  197. # read cfg file. #
  198. ################################################################################
  199. for line in ${stream_file_array[@]}; do
  200. cfg_path="${cfg_dir}/${line}"
  201. cfg_base_path=$(dirname $line)
  202. if [ "$cfg_base_path" == "" ]; then
  203. cfg_base_path="."
  204. fi
  205. test_param=""
  206. while read line2; do
  207. #remove right comment
  208. line2=$(echo $line2 | tr -d '\n')
  209. line2=$(echo $line2 | tr -d '\r')
  210. line2="${line2%%\#*}"
  211. attr=$(echo $line2 | cut -d':' -f1)
  212. attr=$(echo $attr | tr -d ' ')
  213. value=$(echo $line2 | cut -d':' -f2)
  214. value=$(echo $value | tr -d ' ')
  215. value="${value//\"}"
  216. case "$attr" in
  217. BitstreamFile)
  218. BitstreamFile="$value"
  219. ;;
  220. InputFile)
  221. input_yuv="$value"
  222. ;;
  223. SourceWidth)
  224. source_width="$value"
  225. ;;
  226. SourceHeight)
  227. source_height="$value"
  228. ;;
  229. WaveFrontSynchro)
  230. WaveFrontSynchro="$value"
  231. ;;
  232. DeSliceMode)
  233. deslice_mode="$value"
  234. ;;
  235. *) ;;
  236. esac
  237. #echo "attr: $attr, value: $value"
  238. done < $cfg_path
  239. #default value
  240. MODE_COMP_ENCODED=1 #MODE_COMP_ENCODED(bit_stream)
  241. if [ $enable_random == 1 ] && [ $txt_param_switch == 0 ]; then
  242. get_random_param 0 $g_product_name
  243. else
  244. get_default_param 0 $g_product_name
  245. fi
  246. g_secondary_axi=$(($g_secondary_axi >> 1))
  247. if [ "$MODE_COMP_CONV_YUV" == "1" ]; then
  248. g_subCtuMap=0
  249. fi
  250. ################################################################################
  251. # WAVE420L CONSTRAINTS #
  252. ################################################################################
  253. g_rotAngle=0
  254. g_mirDir=0
  255. g_srcFormat3p4b=0
  256. g_bsmode=1
  257. g_afbcd=0
  258. g_enableWtl=0
  259. g_cframe50d=0
  260. g_minBurstLength=0
  261. g_yuv422=0
  262. ################################################################################
  263. # make argv parameter #
  264. ################################################################################
  265. build_test_param 0
  266. test_param="${test_param} $g_func_ret_str"
  267. rot_arg=0
  268. output_filename="$(basename $line).bin"
  269. test_param="${test_param} --output=$output_filename --cfgFileName=$cfg_path"
  270. yuv_path="${yuv_base_path}/${input_yuv}"
  271. file_name=${BitstreamFile%.*}
  272. file_ext=${BitstreamFile##*.}
  273. ref_stream_path="${ref_dir}/${cfg_base_path}/${file_name}_${rot_arg}.${file_ext}"
  274. test_param="${test_param} --ref_stream_path=${ref_stream_path}"
  275. ################################################################################
  276. # print information #
  277. ################################################################################
  278. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  279. log_conf "[${count}/${num_of_streams}] ${cfg_path}" ${temp_log_path}
  280. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  281. log_conf "yuv_path : $yuv_path" $temp_log_path
  282. log_conf "ref_stream_path : $ref_stream_path" $temp_log_path
  283. log_conf "width X Height : $source_width X $source_height" $temp_log_path
  284. log_conf "BitstreamFile : $BitstreamFile" $temp_log_path
  285. log_conf "-------------------------------------------" $temp_log_path
  286. log_conf "RANDOM TEST : ${ON_OFF[$enable_random]}" $temp_log_path
  287. log_conf "BITSTREAM MODE : ${ENC_BSMODE_NAME[$g_bsmode]}" $temp_log_path
  288. log_conf "Endian : ${g_stream_endian}, ${g_frame_endian}, ${g_source_endian}" $temp_log_path
  289. log_conf "Standard : HEVC" $temp_log_path
  290. if [ "$g_packedFormat" == "1" ]; then
  291. log_conf "YUV Format : (${g_packedFormat})YUYV" $temp_log_path
  292. elif [ "$g_packedFormat" == "2" ]; then
  293. log_conf "YUV Format : (${g_packedFormat})YVYU" $temp_log_path
  294. elif [ "$g_packedFormat" == "3" ]; then
  295. log_conf "YUV Format : (${g_packedFormat})UYVY" $temp_log_path
  296. elif [ "$g_packedFormat" == "4" ]; then
  297. log_conf "YUV Format : (${g_packedFormat})VYUY" $temp_log_path
  298. elif [ "$g_enable_nv21" == "0" ] || [ "$g_enable_nv21" == "1" ]; then
  299. log_conf "YUV Format : cbcrInterleave nv21=${g_enable_nv21}" $temp_log_path
  300. else
  301. log_conf "YUV Format : 420 Planar" $temp_log_path
  302. fi
  303. log_conf "rot_arg : $rot_arg" $temp_log_path
  304. log_conf "--------------------------------------------------------------------------------" $temp_log_path
  305. cat $temp_log_path >> $conf_log_path
  306. ################################################################################
  307. # make ref-prebuilt stream #
  308. ################################################################################
  309. if [ ! -f "$ref_stream_path" ] || [ $build_stream -eq 1 ]; then
  310. ref_stream_base_dir=$(dirname $ref_stream_path)
  311. if [ ! -d "$ref_stream_base_dir" ]; then
  312. mkdir -p "$ref_stream_base_dir"
  313. chmod 755 "$ref_stream_base_dir"
  314. echo "CREATE REF-STREAM DIR: $ref_stream_base_dir"
  315. fi
  316. echo "$ref_c_exec -c $cfg_path -p $yuv_base_path -b temp.bin --PrpMode=$rot_arg $extra_param --enable_fbc=0 --TLevel=0 --DumpPicOut=1 --ApiScenario=0 -t ./ $frame_num_refc"
  317. rm -rf vcpu_pic_out_qc.txt
  318. $ref_c_exec -c $cfg_path -p $yuv_base_path -b temp.bin --PrpMode=$rot_arg $extra_param --enable_fbc=0 --TLevel=0 --DumpPicOut=1 --ApiScenario=0 -t ./ $frame_num_refc
  319. cp -v temp.bin $ref_stream_path
  320. cp -v vcpu_pic_out_qc.txt $recon_md5_base_path/${file_name}.265_0.txt
  321. if [ $build_stream -eq 1 ]; then
  322. remain_count=$(($remain_count - 1))
  323. count=$(($count + 1))
  324. continue
  325. fi
  326. fi
  327. ################################################################################
  328. # run Test #
  329. ################################################################################
  330. result=0
  331. test_param_print=$test_param
  332. log_conf "$test_exec $test_param_print" $temp_log_path
  333. cat $temp_log_path >> $conf_log_path
  334. test_exec_param="$test_exec $test_param"
  335. $test_exec_param || result=1
  336. if [ "$result" == "0" ]; then
  337. log_conf "[RESULT] SUCCESS" $conf_log_path
  338. success_count=$(($success_count + 1))
  339. else
  340. cat ./ErrorLog.txt >> $conf_log_path
  341. log_conf "[RESULT] FAILURE" $conf_log_path
  342. failure_count=$(($failure_count + 1))
  343. cat $temp_log_path >> $conf_err_log_path
  344. cat ./ErrorLog.txt >> $conf_err_log_path
  345. echo "[RESULT] FAILURE" >> $conf_err_log_path
  346. if [ $result -eq 10 ]; then
  347. echo "Abnormal exit!!!"
  348. break
  349. fi
  350. fi
  351. remain_count=$(($remain_count - 1))
  352. count=$(($count + 1))
  353. # clear temp log
  354. echo "" > $temp_log_path
  355. done
  356. endTime=$(date +%s%N)
  357. elapsed=$((($endTime - $beginTime) / 1000000000))
  358. elapsedH=$(($elapsed / 3600))
  359. elapsedS=$(($elapsed % 60))
  360. elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
  361. if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
  362. if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
  363. if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
  364. if [ $elapsed -le 60 ]; then
  365. time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
  366. else
  367. time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
  368. fi
  369. log_filename=$(basename $conf_log_path)
  370. log_err_filename=$(basename $conf_err_log_path)
  371. if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
  372. pass=${PASS}
  373. rm $conf_err_log_path
  374. log_err_filename=""
  375. else
  376. pass=${FAIL}
  377. fi
  378. wiki_log="| $streamset_file | $num_of_streams | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
  379. echo $wiki_log
  380. echo $wiki_log >> $wiki_log_file
  381. if [ "$num_of_streams" == "0" ]; then
  382. echo "num_of_streams: $num_of_streams = exit 1"
  383. exit 1
  384. fi
  385. exit $failure_count