TestMultiInstance.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. #!/bin/bash
  2. source common.sh
  3. g_product_name=""
  4. enc_prebuilt=""
  5. enable_wtl=0
  6. enable_sync=0
  7. enable_afbce=0
  8. enable_afbcd=0
  9. enable_scaler=0
  10. enable_cframe50d=0
  11. multi_random_cfg=0
  12. haps=0
  13. process_test="true"
  14. test_exec="./multi_instance_test"
  15. wiki_log_file="./log/multi_confluence.log"
  16. yuv_base="yuv/"
  17. bin_dir="./"
  18. bitfile=0
  19. first_sfs=0
  20. function help {
  21. echo ""
  22. echo "-------------------------------------------------------------------------------"
  23. echo "Chips&Media conformance Tool v2.0"
  24. echo "All copyright reserved by Chips&Media"
  25. echo "-------------------------------------------------------------------------------"
  26. echo "$0 OPTION streamlist_file"
  27. echo "-h Help"
  28. echo "--product product name(coda960, coda980...)"
  29. }
  30. ################################################################################
  31. # Parse arguments #
  32. ################################################################################
  33. OPTSTRING="-o h -l product:"
  34. OPTS=`getopt $OPTSTRING -- "$@"`
  35. if [ $? -ne 0 ]; then
  36. exit 1
  37. fi
  38. eval set -- "$OPTS"
  39. while true; do
  40. case "$1" in
  41. -h)
  42. help
  43. exit 1
  44. shift;;
  45. --product)
  46. g_product_name=$2
  47. shift 2;;
  48. #ifdef CNM_FPGA_PLATFROM
  49. --bitfile)
  50. bitfile=$2
  51. shift 2;;
  52. --haps)
  53. haps=$2
  54. shift 2;;
  55. --vu440)
  56. vu440=$2
  57. shift 2;;
  58. #endif /* CNM_FPGA_PLATFORM */
  59. --)
  60. shift
  61. break;;
  62. esac
  63. done
  64. shift $(($OPTIND - 1))
  65. streamset_path=$1
  66. streamset_file=`basename ${streamset_path}`
  67. if [ ! -f "${streamset_path}" ]; then
  68. echo "No such file: ${streamset_path}"
  69. exit 1
  70. fi
  71. ################################################################################
  72. # count stream number #
  73. ################################################################################
  74. stream_command_array=()
  75. linenum=0
  76. while read -r line || [ -n "$line" ]; do
  77. line=$(echo $line | tr -d '\n')
  78. line=$(echo $line | tr -d '\r')
  79. line="${line//\\//}" # replace backslash to slash
  80. line=${line#*( )} # remove front whitespace
  81. firstchar=${line:0:1}
  82. case "$firstchar" in
  83. "@") break;; # exit flag
  84. "#") continue;; # comment
  85. ";") continue;; # comment
  86. "") continue;; # comment
  87. *)
  88. esac
  89. stream_command_array[$linenum]="$line"
  90. linenum=$(($linenum + 1))
  91. done < ${streamset_path}
  92. num_of_streams=${#stream_command_array[@]}
  93. success_count=0
  94. failure_count=0
  95. remain_count=2 # process test + thread test = 2
  96. if [ "$process_test" == "false" ]; then
  97. remain_count=1 # only thread test
  98. fi
  99. basedir=${basedir//\/} # remove last delimeter
  100. mkdir -p temp
  101. mkdir -p output
  102. mkdir -p log/multi_conformance
  103. conf_log_path="log/multi_conformance/${streamset_file}_r${revision}.log"
  104. conf_err_log_path="log/multi_conformance/${streamset_file}_error_r${revision}.log"
  105. temp_log_path="./temp/temp.log"
  106. # truncate contents of log file
  107. echo "" > $conf_log_path
  108. echo "" > $conf_err_log_path
  109. echo "" > $temp_log_path
  110. beginTime=$(date +%s%N)
  111. ################################################################################
  112. # Read CMD File && Make test param #
  113. ################################################################################
  114. for ((i=0;i<$num_of_streams;i++)) do
  115. ################################################################################
  116. # SET DEFAULT VALUE #
  117. ################################################################################
  118. codec_std[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f1)
  119. stream[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f2)
  120. ref_file_path[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f3)
  121. isEncoder[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f4)
  122. main10[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f5)
  123. pic_width[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f6)
  124. pic_height[$i]=$(echo ${stream_command_array[$i]} | cut -d' ' -f7)
  125. afbce[$i]=0
  126. afbcd[$i]=0
  127. cframe50d[$i]=0
  128. cframe50d_mbl[$i]=0
  129. cframe50d_422[$i]=0
  130. scaler[$i]=0
  131. wtl[$i]=1
  132. bsmode[$i]=0
  133. match_mode[$i]=1
  134. enable_mvc[$i]=0
  135. core[$i]=0
  136. case "${codec_std[$i]}" in
  137. "0") codec_name[$i]="avc";;
  138. "1") codec_name[$i]="vc1";;
  139. "2") codec_name[$i]="mp2";;
  140. "3") codec_name[$i]="mp4";;
  141. "4") codec_name[$i]="h263";;
  142. "5") codec_name[$i]="dv3";;
  143. "6") codec_name[$i]="rvx";;
  144. "7") codec_name[$i]="avs";;
  145. "9") codec_name[$i]="tho";;
  146. "10") codec_name[$i]="vp3";;
  147. "11") codec_name[$i]="vp8";;
  148. "12") codec_name[$i]="hevc";;
  149. "13") codec_name[$i]="vp9";;
  150. "14") codec_name[$i]="avs2";;
  151. "15") codec_name[$i]="svac";;
  152. "16") codec_name[$i]="av1";;
  153. *)
  154. echo "unsupported codec_std: ${codec_std[$i]}"
  155. help
  156. exit 1
  157. ;;
  158. esac
  159. if [ "${isEncoder[$i]}" = "1" ]; then
  160. output[$i]="instance_${i}_output.bin"
  161. else
  162. output[$i]=""
  163. fi
  164. ################################################################################
  165. # SET RANDOM VALUE #
  166. ################################################################################
  167. str=`echo ${stream[$i]} | grep "_MVC_\|MVCDS\|MVCICT\|MVCRP\|MVCSPS"` || echo ignore_error
  168. if [ "${str}" != "" ]; then
  169. enable_mvc[$i]=1
  170. fi
  171. if [ "${codec_name[$i]}" = "vp9" ] || [ "${codec_name[$i]}" = "dv3" ] || [ "${codec_name[$i]}" = "tho" ]; then
  172. bsmode[$i]=2
  173. ext=${stream[$i]##*.}
  174. if [ "$ext" = "ivf" ] && [ "${codec_name[$i]}" != "vp9" ]; then
  175. bsmode[$i]=0
  176. fi
  177. fi
  178. if [ "${isEncoder[$i]}" = "1" ]; then
  179. match_mode[$i]=3 # bitstream compare
  180. fi
  181. if [ "$enable_wtl" = "1" ]; then
  182. wtl[$i]=$(get_random 0 1)
  183. fi
  184. if [ "${g_product_name}" = "coda960" ] || [ "${g_product_name}" = "coda980" ]; then
  185. wtl[$i]=0
  186. fi
  187. if [ "${isEncoder[$i]}" = "1" ]; then
  188. wtl[$i]=0
  189. fi
  190. if [ "$enable_scaler" = "1" ]; then
  191. if [ "${i}" = "0" ]; then # at least one must use scaler.
  192. scaler[$i]=1
  193. else
  194. scaler[$i]=$(get_random 0 1)
  195. fi
  196. if [ "${scaler[$i]}" == "1" ]; then
  197. match_mode[$i]=1
  198. else
  199. match_mode[$i]=2
  200. fi
  201. wtl[$i]=1
  202. if [ "${scaler[$i]}" = "1" ]; then
  203. if [ "${pic_width[$i]}" = "" ] || [ "${pic_height[$i]}" = "" ]; then
  204. echo "stream size are not specified in cmd file"
  205. exit 1
  206. fi
  207. scaleWidth[$i]=$((${pic_width[$i]}/2))
  208. scaleWidth[$i]=$(ceiling ${scaleWidth[$i]} 2)
  209. scaleHeight[$i]=$((${pic_height[$i]}/2))
  210. scaleHeight[$i]=$(ceiling ${scaleHeight[$i]} 2)
  211. else
  212. scaleWidth[$i]=0
  213. scaleHeight[$i]=0
  214. fi
  215. fi
  216. if [ "${g_product_name}" = "wave521c_dual" ]; then
  217. core[$i]=$(get_random 1 2)
  218. ring[$i]=$(get_random 0 1)
  219. if [ ${ring[$i]} == 1 ]; then
  220. ring[$i]=2
  221. fi
  222. fi
  223. done
  224. ################################################################################
  225. # Generate compare file path #
  226. ################################################################################
  227. for ((i=0;i<$num_of_streams;i++)) do
  228. if [ "${isEncoder[$i]}" = "1" ]; then
  229. echo "[A] path -> ${ref_file_path[$i]}"
  230. else
  231. codec=${codec_name[$i]}
  232. if [ "${scaler[$i]}" = "1" ]; then
  233. if [ "$g_product_name" == "wave512" ]; then
  234. if [ "${codec_name[$i]}" = "vp9" ]; then
  235. bin_dir="../../../design/ref_c_vp9/bin/Linux"
  236. elif [ "${codec_name[$i]}" = "hevc" ]; then
  237. bin_dir="../../../design/ref_c_hevc/bin/Linux"
  238. g_support_minipippen=1
  239. fi
  240. else
  241. g_support_minipippen=1
  242. fi
  243. g_scaler="true"
  244. g_oriw=${pic_width[$i]}
  245. g_orih=${pic_height[$i]}
  246. g_sclw=${scaleWidth[$i]}
  247. g_sclh=${scaleHeight[$i]}
  248. g_codec_index=${codec_std[$i]}
  249. g_bsmode=${bsmode[$i]}
  250. ref_file_path[$i]="temp/output_${i}.yuv"
  251. fi
  252. if [ "${match_mode[$i]}" == "1" ]; then
  253. if [ "${main10[$i]}" == "1" ]; then
  254. is_main10=1
  255. fi
  256. generate_yuv ${stream[$i]} ${ref_file_path[$i]}
  257. fi
  258. fi
  259. done
  260. ################################################################################
  261. # Generate input file path #
  262. ################################################################################
  263. for ((i=0;i<$num_of_streams;i++)) do
  264. cframe50sd_tx16y[$i]=0
  265. cframe50sd_tx16c[$i]=0
  266. cframe50sd_lossless[$i]=0
  267. g_cframe_422[$i]=0
  268. if [ "${isEncoder[$i]}" = "1" ]; then
  269. if [ "${cframe50d[$i]}" = "1" ]; then
  270. # create cframe50 file.
  271. yuv_name=$(grep 'InputFile' ${stream[$i]} | sed -e 's/\r//g' | cut -d' ' -f3)
  272. src_width=$(grep 'SourceWidth' ${stream[$i]} | sed -e 's/\r//g' | cut -d' ' -f3)
  273. src_height=$(grep 'SourceHeight' ${stream[$i]} | sed -e 's/\r//g' | cut -d' ' -f3)
  274. yuv_dir=${yuv_base}${yuv_name}
  275. echo ${yuv_dir}
  276. cp ${yuv_dir} instance_${i}_input.yuv
  277. bit_depth=8
  278. if [ "${main10[$i]}" = "1" ]; then
  279. bit_depth=10
  280. fi
  281. format_value=1
  282. if [ "${cframe50d_422[$i]}" = "1" ]; then
  283. format_value=2
  284. fi
  285. mbl_value=0
  286. case "${cframe50d_mbl[$i]}" in
  287. "0") mbl_value=16;;
  288. "1") mbl_value=32;;
  289. "2") mbl_value=64;;
  290. "3") mbl_value=128;;
  291. *) ;;
  292. esac
  293. ref_c_param="../../../design/cframe50_c/bin/cframe -i instance_${i}_input.yuv -b ${bit_depth} -w ${src_width} -h ${src_height} -f 1000 -min_burst_len ${mbl_value} -c refc_output_${i}.cf50 -format ${format_value} -convert422 ${cframe50d_422[$i]}"
  294. echo ${ref_c_param}
  295. ${ref_c_param}
  296. cp refc_output_${i}.cf50 ${stream[$i]}.cf50
  297. fi
  298. if [ "${cframe50sd[$i]}" = "1" ]; then
  299. # create cframe50s file.
  300. cframe_c_exec=../../../design/cframe50_c/bin/cframe
  301. if [ "$cfg_InputBitDepth" == "8" ]; then
  302. g_cframetx16y=$(get_random 2 7)
  303. g_cframetx16c=$(get_random 2 7)
  304. else
  305. g_cframetx16y=$(get_random 2 9)
  306. g_cframetx16c=$(get_random 2 9)
  307. fi
  308. g_cframetx16y=$(($g_cframetx16y * 16))
  309. g_cframetx16c=$(($g_cframetx16c * 16))
  310. cframe50sd_tx16y[$i]=$g_cframetx16y
  311. cframe50sd_tx16c[$i]=$g_cframetx16c
  312. if [ "$g_product_name" = "wave521" ] || [ "$g_product_name" = "wave521c" ]; then
  313. g_cframe_422[$i]=$(get_random 0 1)
  314. fi
  315. g_cframelossless=1 #test only lossless
  316. cframe50sd_lossless[$i]=$g_cframelossless #test only lossless
  317. read_cfg ${stream[$i]}
  318. yuv_path="/nstream/qctool/img/${cfg_InputFile}"
  319. if [ "${codec_name[$i]}" = "hevc" ]; then
  320. codec_path=hevc
  321. elif [ "${codec_name[$i]}" = "avc" ]; then
  322. codec_path=avc
  323. else
  324. codec_path=svac
  325. fi
  326. cframe_input_dir=/nstream/qctool/work/ENC_REF_STREAM/WAVE521_CFRAME/${codec_path}/${cfg_base_path} #cfg_base_path
  327. check_and_create_dir $cframe_input_dir
  328. input_file=$(basename $cfg_InputFile)
  329. input_dir=$(dirname $cfg_InputFile)
  330. check_and_create_dir $input_dir
  331. cframe_name=cframe_${input_file}_${cfg_width}_${cfg_height}_${g_cframelossless}_${g_cframetx16y}_${g_cframetx16c}.cf50s
  332. cframe_path=$cframe_input_dir/$cframe_name
  333. #run cframe cmodel if not exist
  334. if [ "$g_product_name" = "wave521" ] || [ "$g_product_name" = "wave521c" ]; then
  335. if [ ${g_cframe_422[$i]} == 1 ]; then
  336. PARAM="-i $yuv_path -o ${cfg_InputFile}.422 -c temp.cf50s_${i} -b $cfg_InputBitDepth -w $cfg_width -h $cfg_height -format 2 -tx16 $g_cframetx16y -tx16_chroma $g_cframetx16c -lossless $g_cframelossless -f $cfg_FramesToBeEncoded -convert422 1 -oo ${cfg_InputFile} "
  337. else
  338. PARAM="-i $yuv_path -o $cfg_InputFile -c temp.cf50s_${i} -b $cfg_InputBitDepth -w $cfg_width -h $cfg_height -format 1 -tx16 $g_cframetx16y -tx16_chroma $g_cframetx16c -lossless $g_cframelossless -f $cfg_FramesToBeEncoded"
  339. fi
  340. else
  341. PARAM="-i $yuv_path -o $cfg_InputFile -c temp.cf50s_${i} -b $cfg_InputBitDepth -w $cfg_width -h $cfg_height -format 1 -tx16 $g_cframetx16y -tx16_chroma $g_cframetx16c -lossless $g_cframelossless -f $cfg_FramesToBeEncoded"
  342. fi
  343. echo "$cframe_c_exec $PARAM"
  344. $cframe_c_exec $PARAM
  345. if [ -s temp.cf50s_${i} ]; then
  346. #cp -v temp.cf50s_${i} $cframe_path
  347. #chmod 666 $cframe_path
  348. echo "cframe success"
  349. else
  350. echo "cframe error"
  351. echo "cframe error"
  352. echo "cframe error"
  353. echo "cframe error"
  354. echo "cframe error"
  355. exit 1;
  356. fi
  357. fi
  358. fi
  359. done
  360. ################################################################################
  361. # Add test param #
  362. # Options of the each instance are seperated by "," #
  363. ################################################################################
  364. test_param=""
  365. for ((i=0;i<$num_of_streams;i++)) do
  366. if [ "$i" = "0" ]; then
  367. codec_std_test_param="${codec_std[$i]}"
  368. stream_test_param="${stream[$i]}"
  369. if [ "${output[$i]}" != "" ]; then
  370. output_test_param="${output[$i]}"
  371. fi
  372. wtl_test_param="${wtl[$i]}"
  373. bsmode_test_param="${bsmode[$i]}"
  374. match_mode_test_param="${match_mode[$i]}"
  375. ref_file_path_test_param="${ref_file_path[$i]}"
  376. enc_dec_param="${isEncoder[$i]}"
  377. core_param="${core[$i]}"
  378. ring_param="${ring[$i]}"
  379. scaler_test_param="${scaler[$i]}"
  380. scaleWidth_test_param="${scaleWidth[$i]}"
  381. scaleHeight_test_param="${scaleHeight[$i]}"
  382. else
  383. codec_std_test_param="${codec_std_test_param},${codec_std[$i]}"
  384. stream_test_param="${stream_test_param},${stream[$i]}"
  385. if [ "${output[$i]}" != "" ]; then
  386. output_test_param="${output_test_param},${output[$i]}"
  387. fi
  388. wtl_test_param="${wtl_test_param},${wtl[$i]}"
  389. bsmode_test_param="${bsmode_test_param},${bsmode[$i]}"
  390. match_mode_test_param="${match_mode_test_param},${match_mode[$i]}"
  391. ref_file_path_test_param="${ref_file_path_test_param},${ref_file_path[$i]}"
  392. enc_dec_param="${enc_dec_param},${isEncoder[$i]}"
  393. core_param="${core_param},${core[$i]}"
  394. ring_param="${ring_param},${ring[$i]}"
  395. scaler_test_param="${scaler_test_param},${scaler[$i]}"
  396. scaleWidth_test_param="${scaleWidth_test_param},${scaleWidth[$i]}"
  397. scaleHeight_test_param="${scaleHeight_test_param},${scaleHeight[$i]}"
  398. fi
  399. done
  400. ################################################################################
  401. # make test param #
  402. ################################################################################
  403. if [ "${output_test_param}" != "" ]; then
  404. output_param="--output=${output_test_param}"
  405. fi
  406. test_param="--instance-num=${num_of_streams} -c ${match_mode_test_param} -e ${enc_dec_param} --codec=${codec_std_test_param}"
  407. test_param="$test_param --bsmode=${bsmode_test_param} --enable-wtl=${wtl_test_param}"
  408. test_param="$test_param --input=${stream_test_param} ${output_param} --ref_file_path=${ref_file_path_test_param}"
  409. if [ "$enable_scaler" = "1" ]; then
  410. test_param="${test_param} --scaler=${scaler_test_param} --sclw=${scaleWidth_test_param} --sclh=${scaleHeight_test_param}"
  411. fi
  412. if [ "$g_product_name" = "wave521c_dual" ]; then
  413. test_param="$test_param --cores=$core_param"
  414. test_param="$test_param --ring=$ring_param"
  415. fi
  416. ################################################################################
  417. # Test Mode Thread #
  418. ################################################################################
  419. result=0
  420. log_conf "MultiInstance test : Thread" ${temp_log_path}
  421. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  422. for ((i=0;i<$num_of_streams;i++)) do
  423. log_conf "[${i}/${num_of_streams}] ${stream[$i]}" ${temp_log_path}
  424. done
  425. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  426. cat $temp_log_path >> $conf_log_path
  427. echo "$test_exec $test_param"
  428. nice -n -5 $test_exec $test_param || result=$?
  429. if [ $result -eq 0 ]; then
  430. log_conf "[RESULT] SUCCESS" $conf_log_path
  431. success_count=$(($success_count + 1))
  432. else
  433. log_conf "[RESULT] FAILURE" $conf_log_path
  434. failure_count=$(($failure_count + 1))
  435. cat $temp_log_path >> $conf_err_log_path
  436. cat ./ErrorLog.txt >> $conf_err_log_path
  437. echo "[RESULT] FAILURE" >> $conf_err_log_path
  438. if [ $result -eq 10 ]; then
  439. echo "Abnormal exit!!!"
  440. break
  441. fi
  442. fi
  443. # clear temp log
  444. echo "" > $temp_log_path
  445. remain_count=$(($remain_count - 1))
  446. ################################################################################
  447. # Create Test Log #
  448. ################################################################################
  449. endTime=$(date +%s%N)
  450. elapsed=$((($endTime - $beginTime) / 1000000000))
  451. elapsedH=$(($elapsed / 3600))
  452. elapsedS=$(($elapsed % 60))
  453. elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
  454. if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
  455. if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
  456. if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
  457. time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
  458. log_filename=$(basename $conf_log_path)
  459. log_err_filename=$(basename $conf_err_log_path)
  460. if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
  461. pass=${PASS}
  462. rm $conf_err_log_path
  463. log_err_filename=""
  464. else
  465. pass=${FAIL}
  466. fi
  467. wiki_log="| $streamset_file | 2 | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | Instacne Num = $num_of_streams |"
  468. log_filename="[^$log_filename]"
  469. if [ "$log_err_filename" != "" ]; then
  470. log_err_filename="[^$log_err_filename]"
  471. fi
  472. wiki_log="| $streamset_file | 2 | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | [Jenkins|$jenkins] | | Instacne Num = $num_of_streams |"
  473. if [ "${haps}" = "1" ]; then
  474. wiki_log="| $streamset_file | 1 | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | [Jenkins|$jenkins] | | Instacne Num = $num_of_streams |"
  475. fi
  476. echo $wiki_log
  477. echo $wiki_log >> $wiki_log_file
  478. if [ "$num_of_streams" == "0" ]; then
  479. echo "num_of_streams: $num_of_streams = exit 1"
  480. exit 1
  481. fi
  482. exit $failure_count