TestRunnerWave511Dec.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. #!/bin/bash
  2. source common.sh
  3. g_product_name="wave511"
  4. # Global varaibles for decoder option
  5. is_main10=0
  6. build_yuv=0
  7. fail_stop=0
  8. fake_test=0
  9. yuv_dir="./yuv"
  10. stream_dir="./stream"
  11. test_exec="./w5_dec_test"
  12. bin_dir="."
  13. wiki_log_file="./log/dec_confluence.log"
  14. enable_random=0;
  15. md5_path=""
  16. codec=vp9
  17. jenkins=""
  18. txt_param_switch=0
  19. simulation="false"
  20. ACLK_MIN=13
  21. BCLK_MIN=13
  22. CCLK_MIN=13
  23. ACLK_MAX=33
  24. BCLK_MAX=33
  25. CCLK_MAX=33
  26. RET_SUCCESS=0
  27. RET_HANGUP=2
  28. function build_golden_yuvs {
  29. local src=$1
  30. local wtl_fmt_indexes=(0)
  31. if [ $is_main10 -eq 1 ]; then
  32. wtl_fmt_indexes=(0 5 6 7 8)
  33. fi
  34. for i in ${wtl_fmt_indexes[@]}; do
  35. g_wtl_format=$i
  36. echo ""
  37. echo "Generating ${g_yuv_fmt_list[$g_wtl_format]}..."
  38. generate_golden_data_path $codec $streamset_path $src
  39. golden_yuv_path="$g_func_ret_str"
  40. generate_yuv $stream $golden_yuv_path
  41. done
  42. }
  43. rotAngle_temp=0
  44. mirDir_temp=0
  45. ################################################################################
  46. # scaler test #
  47. ################################################################################
  48. function calc_scale_tot {
  49. local min_x=0
  50. local min_y=0
  51. g_oriw=$ori_width
  52. g_orih=$ori_height
  53. g_ori_align_x=$ori_width
  54. g_ori_align_y=$ori_height
  55. min_x=$(($g_ori_align_x / 8))
  56. min_x=$(ceiling $min_x 8)
  57. min_y=$(($g_ori_align_y / 8))
  58. min_y=$(ceiling $min_y 8)
  59. num_x_steps=$(($g_ori_align_x - $min_x))
  60. num_x_steps=$(($num_x_steps/2 + 1))
  61. num_y_steps=$(($g_ori_align_y - $min_y))
  62. num_y_steps=$(($num_y_steps/2 + 1))
  63. echo "orign_x = $g_ori_align_x, orign_y = $g_ori_align_y"
  64. echo "min_x = $min_x, min_y = $min_y"
  65. echo "num_x_steps = $num_x_steps num_y_steps = $num_y_steps"
  66. tot_scaler_cnt=$(($num_x_steps * $num_y_steps))
  67. g_min_scale_w=$min_x
  68. g_min_scale_h=$min_y
  69. echo "calculated_tot_scaler_cnt=$tot_scaler_cnt"
  70. }
  71. function calc_scale_val {
  72. local x=0
  73. local y=0
  74. local min_x=$g_min_scale_w
  75. local min_y=$g_min_scale_h
  76. echo "scaler_step_cnt_2: $scaler_step_cnt_2"
  77. echo "min_x: $min_x"
  78. echo "min_y: $min_y"
  79. if [ $scaler_test_mode -eq 1 ]; then
  80. if [ $num_x_steps -eq 0 ]; then
  81. g_sclw=$ori_width
  82. else
  83. x=$(($scaler_step_cnt_2 % $num_x_steps))
  84. g_sclw=$(($g_ori_align_x - $x * 2))
  85. fi
  86. if [ $num_y_steps -eq 0 ]; then
  87. g_sclh=$ori_height
  88. else
  89. y=$(($scaler_step_cnt_2 % $num_y_steps))
  90. g_sclh=$(($g_ori_align_y - $y * 2))
  91. fi
  92. elif [ $scaler_test_mode -eq 2 ]; then
  93. if [ $num_x_steps -eq 0 ]; then
  94. g_sclw=$ori_width
  95. else
  96. x=$(($scaler_step_cnt_2 % $num_x_steps))
  97. g_sclw=$(($min_x + $x * 2))
  98. fi
  99. if [ $num_y_steps -eq 0 ]; then
  100. g_sclh=$ori_height
  101. else
  102. y=$(($scaler_step_cnt_2 % $num_y_steps))
  103. g_sclh=$(($min_y + $y * 2))
  104. fi
  105. elif [ $scaler_test_mode -eq 3 ]; then
  106. g_sclw=$(get_random $min_x $g_ori_align_x)
  107. g_sclh=$(get_random $min_y $g_ori_align_y)
  108. elif [ $scaler_test_mode -eq 4 ]; then
  109. g_sclw=$g_ori_align_x
  110. g_sclh=$(get_random $min_y $g_ori_align_y)
  111. elif [ $scaler_test_mode -eq 5 ]; then
  112. g_sclw=$min_x
  113. g_sclh=$(get_random $min_y $g_ori_align_y)
  114. elif [ $scaler_test_mode -eq 6 ]; then
  115. g_sclw=$(get_random $min_x $g_ori_align_x)
  116. g_sclh=$g_ori_align_y
  117. elif [ $scaler_test_mode -eq 7 ]; then
  118. g_sclw=$(get_random $min_x $g_ori_align_x)
  119. g_sclh=$min_y
  120. fi
  121. g_sclw=$(ceiling $g_sclw 2)
  122. g_sclh=$(ceiling $g_sclh 2)
  123. echo "x=$x y=$y"
  124. echo "g_sclw=$g_sclw, g_sclh=$g_sclh"
  125. }
  126. function help {
  127. echo ""
  128. echo "-------------------------------------------------------------------------------"
  129. echo "Chips&Media conformance Tool v2.0"
  130. echo "All copyright reserved by Chips&Media"
  131. echo "-------------------------------------------------------------------------------"
  132. echo "$0 OPTION streamlist_file"
  133. echo "-h help"
  134. echo "-c codec. default: hevc"
  135. echo " valid codec list: avc, hevc"
  136. echo "--bsmode [optional] interrupt or picend, default: interrupt mode"
  137. echo "--bin-dir ref-c directory"
  138. echo "--enable-random generate random option."
  139. echo "--enable-thumbnail enable thumbnail mode, default: off"
  140. echo "--main10 true or false. Just use in conformance env."
  141. echo "--stream-dir stream directory"
  142. echo "--yuv-dir Golden yuv directory"
  143. echo "--fail-stop Stop testing if current test is failure"
  144. echo "--build-yuv Just generate golden YUV with Ref-C."
  145. echo "--fbc-mode Compressed mode: 0 ~ 0x3e"
  146. }
  147. ################################################################################
  148. # Parse arguments #
  149. ################################################################################
  150. OPTSTRING="-o hwc:n:f -l bsmode:,enable-random,stream-dir:,bin-dir:,match-mode:,test_bin_name:"
  151. OPTSTRING="${OPTSTRING},enable-thumbnail,main10,build-yuv,yuv-dir:,fbc-mode:,md5-dir:"
  152. OPTSTRING="${OPTSTRING},scaler-test-mode:,scaler-step-cnt:,ori-width:,enable-scaler,ori-height:"
  153. OPTS=`getopt $OPTSTRING -- "$@"`
  154. if [ $? -ne 0 ]; then
  155. exit 1
  156. fi
  157. eval set -- "$OPTS"
  158. while true; do
  159. case "$1" in
  160. -h)
  161. help
  162. exit 1
  163. shift;;
  164. -n)
  165. g_frame_num="-n $2"
  166. g_refc_frame_num="-m $2"
  167. shift 2;;
  168. -c)
  169. codec=$(echo $2 | tr '[:upper:]' '[:lower:]')
  170. shift 2;;
  171. -f)
  172. g_fpga_reset=1
  173. shift;;
  174. --bsmode)
  175. g_bsmode=$2
  176. g_bsmode_force=$2
  177. shift 2;;
  178. --bin-dir)
  179. bin_dir=$2
  180. shift 2;;
  181. --enable-random)
  182. enable_random=1
  183. shift;;
  184. --enable-thumbnail)
  185. g_enable_thumbnail=1
  186. shift;;
  187. --md5-dir)
  188. md5_dir=$2
  189. shift 2;;
  190. --match-mode)
  191. g_match_mode=$2
  192. shift 2;;
  193. --stream-dir)
  194. stream_dir=$2
  195. shift 2;;
  196. --main10)
  197. is_main10=1
  198. shift;;
  199. --build-yuv)
  200. build_yuv=1
  201. shift;;
  202. --yuv-dir)
  203. yuv_dir=$2
  204. shift 2;;
  205. --fail-stop)
  206. fail_stop=1
  207. shift;;
  208. --fbc-mode)
  209. g_fbc_mode_temp=$2
  210. g_force_fbc_mode=1
  211. shift 2;;
  212. --enable-scaler)
  213. g_scaler="true"
  214. shift;;
  215. --scaler-test-mode)
  216. g_scaler="true"
  217. scaler_test_mode=$2
  218. shift 2;;
  219. --scaler-step-cnt)
  220. g_scaler="true"
  221. scaler_step_cnt=$2
  222. shift 2;;
  223. --ori-width)
  224. ori_width=$2
  225. shift 2;;
  226. --ori-height)
  227. ori_height=$2
  228. shift 2;;
  229. --test_bin_name)
  230. test_exec="$2"
  231. shift 2;;
  232. --)
  233. shift
  234. break;;
  235. esac
  236. done
  237. shift $(($OPTIND - 1))
  238. case "${codec}" in
  239. "hevc") g_codec_index=12;;
  240. "avc") g_codec_index=0;;
  241. *)
  242. echo "unsupported codec: ${codec}"
  243. help
  244. exit 1
  245. ;;
  246. esac
  247. ################################################################################
  248. # Get param from target text file #
  249. ################################################################################
  250. name_value=()
  251. input_param_name=TestRunnerParamWave511Dec.txt
  252. if [ -f $input_param_name ] && [ $enable_random -eq 0 ]; then
  253. while read line; do
  254. # remove right comment
  255. line="${line%%\#*}"
  256. attr=$(echo $line | cut -d'=' -f1)
  257. attr=$(echo $attr | tr -d ' ')
  258. if [ "$attr" == "debug" ]; then
  259. value=$(echo $line | sed 's/debug=//')
  260. else
  261. value=$(echo $line | cut -d '=' -f2)
  262. fi
  263. case "$attr" in
  264. default) default_opt="$value";;
  265. n) g_frame_num="-n $value"
  266. g_refc_frame_num="-m $value";;
  267. secondary-axi) secondary_axi_temp="$value";;
  268. stream-endian) stream_endian_temp="$value";;
  269. frame-endian) frame_endian_temp="$value";;
  270. bsmode) bsmode_temp="$value";;
  271. match-mode) g_match_mode="$value";;
  272. cbcr_interleave_mode) g_yuv_mode_temp="$value";;
  273. cbcr) g_yuv_mode_temp="$value";;
  274. disable_wtl) disable_wtl_temp="$value";;
  275. wtl-format) wtl_format_temp="$value";;
  276. enable-thumbnail) g_enable_thumbnail="$value";;
  277. fpga-reset) g_fpga_reset="$value";;
  278. fbc-mode) g_fbc_mode_temp="$value"
  279. g_force_fbc_mode=1;;
  280. txt-param) txt_param_switch=1;;
  281. output_hw) g_output_hw_temp="$value";;
  282. bwopt) g_bw_opt_temp="$value";;
  283. *) ;;
  284. esac
  285. done < $input_param_name
  286. else
  287. if [ ! -f $input_param_name ]; then
  288. echo "$input_param_name file doesn't exist";
  289. fi
  290. fi
  291. streamset_path=$1
  292. streamset_file=`basename ${streamset_path}`
  293. if [ ! -e "${streamset_path}" ]; then
  294. echo "No such file: ${streamset_path}"
  295. exit 1
  296. fi
  297. if [ "$wtl_format_temp" != "-99" ] && [ -z "$wtl_format_temp" ]; then
  298. g_enable_wtl=1
  299. g_wtl_format="$wtl_format_temp"
  300. fi
  301. ################################################################################
  302. # scaler test #
  303. ################################################################################
  304. if [ ! -z "$scaler_test_mode" ]; then
  305. g_enable_wtl=1
  306. g_match_mode=1
  307. calc_scale_tot
  308. scaler_step_cnt_2=1
  309. temp_path=scaler.cmd
  310. if [ $scaler_step_cnt ] && [ "$scaler_step_cnt" != "ALL" ] ; then
  311. tot_scaler_cnt=$scaler_step_cnt
  312. fi
  313. max=$(($tot_scaler_cnt + 1))
  314. rm -rf $temp_path
  315. for (( c=1; c< $max ; c++ )) do
  316. echo `cat ${streamset_path}` >> ${temp_path}
  317. done
  318. streamset_path=$temp_path
  319. fi
  320. ################################################################################
  321. # count stream number #
  322. ################################################################################
  323. stream_file_array=()
  324. parse_streamset_file $streamset_path stream_file_array
  325. num_of_streams=${#stream_file_array[@]}
  326. #echo ${stream_file_array[@]}
  327. count=1
  328. success_count=0
  329. failure_count=0
  330. remain_count=${num_of_streams}
  331. basedir=${basedir//\/} # remove last delimeter
  332. mkdir -p temp
  333. mkdir -p output
  334. mkdir -p log/decoder_conformance
  335. conf_log_path="log/decoder_conformance/${streamset_file}_r${g_revision}.log"
  336. conf_err_log_path="log/decoder_conformance/${streamset_file}_error_r${g_revision}.log"
  337. if [ "$g_scaler" == "true" ]; then
  338. conf_log_path="log/decoder_conformance/${stream_set_name}_r${g_revision}.log"
  339. conf_err_log_path="log/decoder_conformance/${stream_set_name}_error_r${g_revision}.log"
  340. fi
  341. temp_log_path="./temp/temp.log"
  342. # truncate contents of log file
  343. echo "" > $conf_log_path
  344. echo "" > $conf_err_log_path
  345. echo "" > $temp_log_path
  346. beginTime=$(date +%s%N)
  347. echo ""
  348. echo ""
  349. echo "##### PRESS 'q' for stop #####"
  350. echo ""
  351. echo ""
  352. log_conf "STREAM BASE DIR: ${stream_dir}" ${conf_log_path}
  353. ################################################################################
  354. # read cmd file. #
  355. ################################################################################
  356. force_reset=0
  357. for (( c=0; c< $num_of_streams ; c++ )) do
  358. line=${stream_file_array[$c]}
  359. # press 'q' for stop
  360. read -t 1 -n 1 key
  361. if [[ $key == q ]]; then
  362. break;
  363. fi
  364. test_param=""
  365. stream="${stream_dir}/${line}"
  366. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  367. log_conf "[${count}/${num_of_streams}] ${stream}" ${temp_log_path}
  368. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  369. if [ ! -f $stream ]; then
  370. log_conf "Not found $stream" $temp_log_path
  371. log_conf "[RESULT] FAILURE" $temp_log_path
  372. failure_count=$(($failure_count + 1))
  373. remain_count=$(($remain_count - 1))
  374. count=$(($count + 1))
  375. continue
  376. fi
  377. result=0
  378. target_stream=$stream
  379. ################################################################################
  380. # scaler test #
  381. ################################################################################
  382. if [ ! -z "$scaler_test_mode" ]; then
  383. g_match_mode=1 #0 : 1:1(same size)
  384. calc_scale_val
  385. echo "scaler_step_cnt_2 = $scaler_step_cnt_2, tot_scaler_cnt = $scaler_step_cnt"
  386. g_frame_num="-n 2"
  387. g_refc_frame_num="-m 2" #for HEVC ref-c
  388. if [ $scaler_step_cnt_2 -gt $tot_scaler_cnt ]; then
  389. echo "same value"
  390. break;
  391. else
  392. scaler_step_cnt_2=$(($scaler_step_cnt_2 + 1))
  393. fi
  394. fi
  395. ################################################################################
  396. # make argc & argv parameter #
  397. ################################################################################
  398. if [ "$g_match_mode" == "1" ]; then
  399. disable_wtl_temp=0
  400. fi
  401. if [ $result -eq 0 ]; then
  402. if [ $enable_random -eq 1 ] && [ $txt_param_switch -eq 0 ]; then
  403. get_random_param 1 wave511
  404. else
  405. get_default_param 1 wave511
  406. fi
  407. # FBC does not support the endianness.
  408. if [ "$g_enable_wtl" == "0" ]; then
  409. g_frame_endian=16
  410. fi
  411. if [ "$force_wtl" != "" ]; then
  412. g_enable_wtl=1
  413. g_wtl_format=$force_wtl
  414. fi
  415. # reset after hangup
  416. backup=$g_fpga_reset
  417. if [ $force_reset -eq 1 ]; then
  418. g_fpga_reset=1
  419. force_reset=0
  420. fi
  421. #make argc & argv parameter
  422. build_test_param 1
  423. g_fpga_reset=$backup
  424. test_param="$test_param $g_func_ret_str"
  425. test_param="${test_param} $g_frame_num"
  426. ################################################################################
  427. # make prebuilt stream #
  428. ################################################################################
  429. if [ $build_yuv -eq 1 ]; then
  430. build_golden_yuvs $stream
  431. remain_count=$(($remain_count - 1))
  432. count=$(($count + 1))
  433. continue
  434. fi
  435. output_filename="$(basename $line).yuv"
  436. case $g_match_mode in
  437. 1) generate_golden_data_path $codec $streamset_path $stream
  438. golden_yuv_path="$g_func_ret_str"
  439. test_param="$test_param --ref-yuv=$golden_yuv_path";;
  440. esac
  441. ################################################################################
  442. # print information #
  443. ################################################################################
  444. if [ $result -eq 0 ]; then
  445. log_conf "RANDOM TEST : ${ON_OFF[$enable_random]}" $temp_log_path
  446. log_conf "BITSTREAM MODE : ${DEC_BSMODE_NAME[$g_bsmode]}" $temp_log_path
  447. log_conf "ENDIAN : STREAM($g_stream_endian) FRAME($g_frame_endian)" $temp_log_path
  448. log_conf "STANDARD : ${CODEC_NAME[$g_codec_index]}" $temp_log_path
  449. log_conf "REORDER : ON" $temp_log_path
  450. log_conf "MAP TYPE : Compressed" $temp_log_path
  451. log_conf "WTL MODE : ${ON_OFF[$g_enable_wtl]}" $temp_log_path
  452. if [ "$g_enable_wtl" == "1" ]; then
  453. log_conf "WTL FORMAT : ${g_yuv_fmt_list[$g_wtl_format]}" $temp_log_path
  454. else
  455. log_conf "WTL FORMAT : NONE" $temp_log_path
  456. fi
  457. log_conf "CBCR interleave: ${ON_OFF[$g_cbcr_interleave]}" $temp_log_path
  458. log_conf "NV21 : ${ON_OFF[$g_enable_nv21]}" $temp_log_path
  459. log_conf "Secondary AXI : ${g_secondary_axi}" $temp_log_path
  460. test_param_print=$test_param
  461. log_conf "Unix : $test_exec $test_param_print --input=$stream" $temp_log_path
  462. winexec=$(echo "$test_exec $test_param_print --input=$stream" | sed -e 's/\//\\/g')
  463. log_conf "Windows: $winexec" $temp_log_path
  464. cat $temp_log_path >> $conf_log_path
  465. chmod 777 $test_exec
  466. test_exec_param="$test_exec $test_param --input=$target_stream"
  467. result=0
  468. if [ "$simulation" == "true" ]; then
  469. test_exec_param="$test_exec_param $g_w_param $g_fsdb_param $g_ius_param --TestRunner=1"
  470. set -o pipefail; $test_exec_param 2>&1 | tee -a $conf_log_path || result=?
  471. else
  472. $test_exec_param || result=$?
  473. fi
  474. if [ $result -eq $RET_HANGUP ]; then
  475. force_reset=1
  476. fi
  477. fi
  478. else
  479. cat $temp_log_path >> $conf_log_path
  480. fi
  481. if [ $result -eq 0 ]; then
  482. log_conf "[RESULT] SUCCESS" $conf_log_path
  483. success_count=$(($success_count + 1))
  484. else
  485. cat ./ErrorLog.txt >> $conf_log_path
  486. log_conf "[RESULT] FAILURE" $conf_log_path
  487. failure_count=$(($failure_count + 1))
  488. cat $temp_log_path >> $conf_err_log_path
  489. cat ./ErrorLog.txt >> $conf_err_log_path
  490. echo "[RESULT] FAILURE" >> $conf_err_log_path
  491. if [ $result -eq 10 ]; then
  492. echo "Abnormal exit!!!"
  493. break
  494. fi
  495. #############
  496. # Error Stop
  497. #############
  498. if [ "$error_stop" == "1" ]; then
  499. break;
  500. fi
  501. fi
  502. remain_count=$(($remain_count - 1))
  503. count=$(($count + 1))
  504. # clear temp log
  505. echo "" > $temp_log_path
  506. # delete temporal input file
  507. rm -f $g_copy_stream
  508. if [ $fail_stop -eq 1 ] && [ $result -ne 0 ]; then
  509. break;
  510. fi
  511. done
  512. if [ $build_yuv -eq 1 ]; then
  513. exit 0
  514. fi
  515. endTime=$(date +%s%N)
  516. elapsed=$((($endTime - $beginTime) / 1000000000))
  517. elapsedH=$(($elapsed / 3600))
  518. elapsedS=$(($elapsed % 60))
  519. elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
  520. if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
  521. if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
  522. if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
  523. if [ $elapsed -le 60 ]; then
  524. time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
  525. else
  526. time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
  527. fi
  528. log_filename=$(basename $conf_log_path)
  529. log_err_filename=$(basename $conf_err_log_path)
  530. if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
  531. pass=${PASS}
  532. rm $conf_err_log_path
  533. log_err_filename=""
  534. else
  535. pass=${FAIL}
  536. fi
  537. wiki_log="| $streamset_file | $num_of_streams | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
  538. echo "$wiki_log"
  539. echo "$wiki_log" >> $wiki_log_file
  540. if [ "$num_of_streams" == "0" ]; then
  541. echo "num_of_streams: $num_of_streams = exit 1"
  542. exit 1
  543. fi
  544. exit $failure_count