TestRunnerWave511Dec.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. #echo $attr
  264. case "$attr" in
  265. default) default_opt="$value";;
  266. n) g_frame_num="-n $value"
  267. g_refc_frame_num="-m $value";;
  268. secondary-axi) secondary_axi_temp="$value";;
  269. stream-endian) stream_endian_temp="$value";;
  270. frame-endian) frame_endian_temp="$value";;
  271. bsmode) bsmode_temp="$value";;
  272. match-mode) g_match_mode="$value";;
  273. cbcr_interleave_mode) g_yuv_mode_temp="$value";;
  274. cbcr) g_yuv_mode_temp="$value";;
  275. disable_wtl) disable_wtl_temp="$value";;
  276. wtl-format) wtl_format_temp="$value";;
  277. enable-thumbnail) g_enable_thumbnail="$value";;
  278. fpga-reset) g_fpga_reset="$value";;
  279. fbc-mode) g_fbc_mode_temp="$value"
  280. g_force_fbc_mode=1;;
  281. txt-param) txt_param_switch=1;;
  282. output_hw) g_output_hw_temp="$value";;
  283. bwopt) g_bw_opt_temp="$value";;
  284. *) ;;
  285. esac
  286. done < $input_param_name
  287. else
  288. if [ ! -f $input_param_name ]; then
  289. echo "$input_param_name file doesn't exist";
  290. fi
  291. fi
  292. streamset_path=$1
  293. streamset_file=`basename ${streamset_path}`
  294. if [ ! -e "${streamset_path}" ]; then
  295. echo "No such file: ${streamset_path}"
  296. exit 1
  297. fi
  298. if [ "$wtl_format_temp" != "-99" ] && [ -z "$wtl_format_temp" ]; then
  299. g_enable_wtl=1
  300. g_wtl_format="$wtl_format_temp"
  301. fi
  302. ################################################################################
  303. # scaler test #
  304. ################################################################################
  305. if [ ! -z "$scaler_test_mode" ]; then
  306. g_enable_wtl=1
  307. g_match_mode=1
  308. calc_scale_tot
  309. scaler_step_cnt_2=1
  310. temp_path=scaler.cmd
  311. if [ $scaler_step_cnt ] && [ "$scaler_step_cnt" != "ALL" ] ; then
  312. tot_scaler_cnt=$scaler_step_cnt
  313. fi
  314. max=$(($tot_scaler_cnt + 1))
  315. rm -rf $temp_path
  316. for (( c=1; c< $max ; c++ )) do
  317. echo `cat ${streamset_path}` >> ${temp_path}
  318. done
  319. streamset_path=$temp_path
  320. fi
  321. ################################################################################
  322. # count stream number #
  323. ################################################################################
  324. stream_file_array=()
  325. echo ****$streamset_path
  326. parse_streamset_file $streamset_path stream_file_array
  327. echo ****hahah
  328. num_of_streams=${#stream_file_array[@]}
  329. #echo ${stream_file_array[@]}
  330. count=1
  331. success_count=0
  332. failure_count=0
  333. remain_count=${num_of_streams}
  334. basedir=${basedir//\/} # remove last delimeter
  335. mkdir -p temp
  336. mkdir -p output
  337. mkdir -p log/decoder_conformance
  338. conf_log_path="log/decoder_conformance/${streamset_file}_r${g_revision}.log"
  339. conf_err_log_path="log/decoder_conformance/${streamset_file}_error_r${g_revision}.log"
  340. if [ "$g_scaler" == "true" ]; then
  341. conf_log_path="log/decoder_conformance/${stream_set_name}_r${g_revision}.log"
  342. conf_err_log_path="log/decoder_conformance/${stream_set_name}_error_r${g_revision}.log"
  343. fi
  344. temp_log_path="./temp/temp.log"
  345. # truncate contents of log file
  346. echo "" > $conf_log_path
  347. echo "" > $conf_err_log_path
  348. echo "" > $temp_log_path
  349. beginTime=$(date +%s%N)
  350. echo ""
  351. echo ""
  352. echo "##### PRESS 'q' for stop #####"
  353. echo ""
  354. echo ""
  355. log_conf "STREAM BASE DIR: ${stream_dir}" ${conf_log_path}
  356. ################################################################################
  357. # read cmd file. #
  358. ################################################################################
  359. force_reset=0
  360. for (( c=0; c< $num_of_streams ; c++ )) do
  361. line=${stream_file_array[$c]}
  362. # press 'q' for stop
  363. read -t 1 -n 1 key
  364. if [[ $key == q ]]; then
  365. break;
  366. fi
  367. test_param=""
  368. stream="${stream_dir}/${line}"
  369. #log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  370. #log_conf "[${count}/${num_of_streams}] ${stream}" ${temp_log_path}
  371. #log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  372. #if [ ! -f $stream ]; then
  373. # log_conf "Not found $stream" $temp_log_path
  374. # log_conf "[RESULT] FAILURE" $temp_log_path
  375. # failure_count=$(($failure_count + 1))
  376. # remain_count=$(($remain_count - 1))
  377. # count=$(($count + 1))
  378. # continue
  379. #fi
  380. result=0
  381. target_stream=$stream
  382. echo ****** $target_stream
  383. ################################################################################
  384. # scaler test #
  385. ################################################################################
  386. #if [ ! -z "$scaler_test_mode" ]; then
  387. # g_match_mode=1 #0 : 1:1(same size)
  388. # calc_scale_val
  389. # echo "scaler_step_cnt_2 = $scaler_step_cnt_2, tot_scaler_cnt = $scaler_step_cnt"
  390. # g_frame_num="-n 2"
  391. # g_refc_frame_num="-m 2" #for HEVC ref-c
  392. # if [ $scaler_step_cnt_2 -gt $tot_scaler_cnt ]; then
  393. # echo "same value"
  394. # break;
  395. # else
  396. # scaler_step_cnt_2=$(($scaler_step_cnt_2 + 1))
  397. # fi
  398. #fi
  399. echo hahaha#######
  400. ################################################################################
  401. # make argc & argv parameter #
  402. ################################################################################
  403. if [ "$g_match_mode" == "1" ]; then
  404. disable_wtl_temp=0
  405. fi
  406. if [ $result -eq 0 ]; then
  407. if [ $enable_random -eq 1 ] && [ $txt_param_switch -eq 0 ]; then
  408. get_random_param 1 wave511
  409. else
  410. get_default_param 1 wave511
  411. fi
  412. # FBC does not support the endianness.
  413. if [ "$g_enable_wtl" == "0" ]; then
  414. g_frame_endian=16
  415. fi
  416. if [ "$force_wtl" != "" ]; then
  417. g_enable_wtl=1
  418. g_wtl_format=$force_wtl
  419. fi
  420. # reset after hangup
  421. backup=$g_fpga_reset
  422. if [ $force_reset -eq 1 ]; then
  423. g_fpga_reset=1
  424. force_reset=0
  425. fi
  426. #make argc & argv parameter
  427. build_test_param 1
  428. g_fpga_reset=$backup
  429. test_param="$test_param $g_func_ret_str"
  430. test_param="${test_param} $g_frame_num"
  431. ################################################################################
  432. # make prebuilt stream #
  433. ################################################################################
  434. if [ $build_yuv -eq 1 ]; then
  435. build_golden_yuvs $stream
  436. remain_count=$(($remain_count - 1))
  437. count=$(($count + 1))
  438. continue
  439. fi
  440. output_filename="$(basename $line).yuv"
  441. case $g_match_mode in
  442. 1) generate_golden_data_path $codec $streamset_path $stream
  443. golden_yuv_path="$g_func_ret_str"
  444. test_param="$test_param --ref-yuv=$golden_yuv_path";;
  445. esac
  446. ################################################################################
  447. # print information #
  448. ################################################################################
  449. if [ $result -eq 0 ]; then
  450. log_conf "RANDOM TEST : ${ON_OFF[$enable_random]}" $temp_log_path
  451. log_conf "BITSTREAM MODE : ${DEC_BSMODE_NAME[$g_bsmode]}" $temp_log_path
  452. log_conf "ENDIAN : STREAM($g_stream_endian) FRAME($g_frame_endian)" $temp_log_path
  453. log_conf "STANDARD : ${CODEC_NAME[$g_codec_index]}" $temp_log_path
  454. log_conf "REORDER : ON" $temp_log_path
  455. log_conf "MAP TYPE : Compressed" $temp_log_path
  456. log_conf "WTL MODE : ${ON_OFF[$g_enable_wtl]}" $temp_log_path
  457. if [ "$g_enable_wtl" == "1" ]; then
  458. log_conf "WTL FORMAT : ${g_yuv_fmt_list[$g_wtl_format]}" $temp_log_path
  459. else
  460. log_conf "WTL FORMAT : NONE" $temp_log_path
  461. fi
  462. log_conf "CBCR interleave: ${ON_OFF[$g_cbcr_interleave]}" $temp_log_path
  463. log_conf "NV21 : ${ON_OFF[$g_enable_nv21]}" $temp_log_path
  464. log_conf "Secondary AXI : ${g_secondary_axi}" $temp_log_path
  465. test_param_print=$test_param
  466. log_conf "Unix : $test_exec $test_param_print --input=$stream" $temp_log_path
  467. winexec=$(echo "$test_exec $test_param_print --input=$stream" | sed -e 's/\//\\/g')
  468. log_conf "Windows: $winexec" $temp_log_path
  469. cat $temp_log_path >> $conf_log_path
  470. chmod 777 $test_exec
  471. test_exec_param="$test_exec $test_param --input=$target_stream"
  472. result=0
  473. if [ "$simulation" == "true" ]; then
  474. test_exec_param="$test_exec_param $g_w_param $g_fsdb_param $g_ius_param --TestRunner=1"
  475. set -o pipefail; $test_exec_param 2>&1 | tee -a $conf_log_path || result=?
  476. else
  477. echo ******************
  478. echo $test_exec_param
  479. $test_exec_param || result=$?
  480. fi
  481. if [ $result -eq $RET_HANGUP ]; then
  482. force_reset=1
  483. fi
  484. fi
  485. else
  486. cat $temp_log_path >> $conf_log_path
  487. fi
  488. if [ $result -eq 0 ]; then
  489. log_conf "[RESULT] SUCCESS" $conf_log_path
  490. success_count=$(($success_count + 1))
  491. else
  492. cat ./ErrorLog.txt >> $conf_log_path
  493. log_conf "[RESULT] FAILURE" $conf_log_path
  494. failure_count=$(($failure_count + 1))
  495. cat $temp_log_path >> $conf_err_log_path
  496. cat ./ErrorLog.txt >> $conf_err_log_path
  497. echo "[RESULT] FAILURE" >> $conf_err_log_path
  498. if [ $result -eq 10 ]; then
  499. echo "Abnormal exit!!!"
  500. break
  501. fi
  502. #############
  503. # Error Stop
  504. #############
  505. if [ "$error_stop" == "1" ]; then
  506. break;
  507. fi
  508. fi
  509. remain_count=$(($remain_count - 1))
  510. count=$(($count + 1))
  511. # clear temp log
  512. echo "" > $temp_log_path
  513. # delete temporal input file
  514. rm -f $g_copy_stream
  515. if [ $fail_stop -eq 1 ] && [ $result -ne 0 ]; then
  516. break;
  517. fi
  518. done
  519. if [ $build_yuv -eq 1 ]; then
  520. exit 0
  521. fi
  522. endTime=$(date +%s%N)
  523. elapsed=$((($endTime - $beginTime) / 1000000000))
  524. elapsedH=$(($elapsed / 3600))
  525. elapsedS=$(($elapsed % 60))
  526. elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
  527. if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
  528. if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
  529. if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
  530. if [ $elapsed -le 60 ]; then
  531. time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
  532. else
  533. time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
  534. fi
  535. log_filename=$(basename $conf_log_path)
  536. log_err_filename=$(basename $conf_err_log_path)
  537. if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
  538. pass=${PASS}
  539. rm $conf_err_log_path
  540. log_err_filename=""
  541. else
  542. pass=${FAIL}
  543. fi
  544. wiki_log="| $streamset_file | $num_of_streams | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
  545. echo "$wiki_log"
  546. echo "$wiki_log" >> $wiki_log_file
  547. if [ "$num_of_streams" == "0" ]; then
  548. echo "num_of_streams: $num_of_streams = exit 1"
  549. exit 1
  550. fi
  551. exit $failure_count