TestRunnerCodaJ12Enc.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. #!/bin/bash
  2. source TestRunnerCommon.sh
  3. # Global varaibles for encoder options
  4. wiki_log_file="./log/enc_confluence.log"
  5. jenkins=""
  6. txt_param_switch=0
  7. output_path="output_fpga.jpg"
  8. DEFAULT_BS_SIZE=5242880 # 5MB
  9. MIN_BS_SIZE=8192 # 8KB
  10. default_read_delay=
  11. default_write_delay=
  12. g_random_test=0
  13. simulation="false"
  14. yuv_dir="./yuv"
  15. bin_dir="./"
  16. cfg_dir="./cfg"
  17. g_aclk=$DEFAULT_ACLK
  18. g_cclk=$DEFAULT_CCLK
  19. refc_exec="Nieuport_JpgEnc"
  20. tiled_exec="./tiled_mode"
  21. ################################################################################
  22. # Initialize parameter variables #
  23. ################################################################################
  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 "--enable-random It generates random parameters"
  33. echo "--bin-dir ref-c directory, default: ./"
  34. echo "--cfg-dir base directory of encoder configuration files. default: ./cfg"
  35. echo "--yuv-dir base directory storing YUV. default: ./yuv"
  36. echo "--stream-endian ENDIAN bitstream endianness. refer to datasheet Chapter 4."
  37. echo "--frame-endian ENDIAN pixel endianness of 16bit input source. refer to datasheet Chapter 4."
  38. echo "--slice-height the vertical hieght of a slice. multiple of 16 for 420, multiple of 8 for others"
  39. echo "--enable-slice-intr=ONOFF enable get the interrupt at every slice encoded. ONOFF - 0 for disable, 1 for enable. default OFF"
  40. echo "--bs-size itstream buffer size in byte"
  41. echo "--output output path"
  42. echo "--input input path"
  43. echo "--rotation=angle 0, 90, 180, 270"
  44. echo "--mirror=value 0, 1(Vertical), 2(Horizontal), 3(both)"
  45. }
  46. function generate_parameters {
  47. local cfg=$1
  48. g_stream_endian=$(gen_val 0 3 $default_stream_endian)
  49. if [ "$jpeg_12bit" == "1" ]; then
  50. g_frame_endian=$(gen_val 0 7 $default_frame_endian)
  51. else
  52. g_frame_endian=$(gen_val 0 3 $default_frame_endian)
  53. fi
  54. g_pixel_just=$(gen_val 0 1 $default_pixelj)
  55. g_rotation=$(gen_val_angle $default_rotation)
  56. g_mirror=$(gen_val 0 3 $default_mirror)
  57. if [ "$g_random_test" == "1" ]; then
  58. slice_random=$(gen_val 0 1) # 0: disable slice done, 1: enable slice_done
  59. else
  60. slice_random=0
  61. fi
  62. if [ "$slice_random" == "1" ] || [ "$default_slice_height" != "0" ]; then
  63. read_cfg $cfg
  64. if [ "$g_rotation" == "90" ] || [ "$g_rotation" == "270" ]; then
  65. local temp=$cfg_width
  66. cfg_width=$cfg_height
  67. cfg_height=$temp
  68. if [ "$cfg_img_format" == "2" ]; then
  69. # 422 to 440
  70. cfg_img_format=3
  71. elif [ "$cfg_img_format" == "3" ]; then
  72. # 440 to 422
  73. cfg_img_format=2
  74. fi
  75. fi
  76. if [ "$g_rotation" != "0" ] || [ "$g_mirror" != "0" ]; then
  77. # disable the slice-encoding mode
  78. g_slice_height=0
  79. g_enable_slice_intr=0
  80. else
  81. g_slice_height=$(gen_valid_slice_height $cfg_width $cfg_height $cfg_img_format $default_slice_height)
  82. if [ "$g_slice_height" != "0" ]; then
  83. g_enable_slice_intr=$(gen_val 0 1 $default_slice_int)
  84. else
  85. g_enable_slice_intr=0
  86. fi
  87. fi
  88. else
  89. g_slice_height=0
  90. g_enable_slice_intr=0
  91. fi
  92. g_bs_size=$(gen_val $MIN_BS_SIZE $DEFAULT_BS_SIZE $default_bs_size)
  93. g_bs_size=$((($g_bs_size + 4095) & ~4095))
  94. g_tiled_mode=$default_tiled_mode
  95. }
  96. function build_test_param {
  97. local param=""
  98. if [ "$jpeg_12bit" == "1" ]; then
  99. param="$param --12bit"
  100. fi
  101. param="$param --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian"
  102. param="$param --pixelj=$g_pixel_just"
  103. param="$param --slice-height=$g_slice_height"
  104. param="$param --enable-slice-intr=$g_enable_slice_intr"
  105. param="$param --enable-tiledMode=$g_tiled_mode"
  106. param="$param --bs-size=$g_bs_size"
  107. param="$param --rotation=$g_rotation"
  108. param="$param --mirror=$g_mirror"
  109. g_func_ret_str="$param"
  110. }
  111. ################################################################################
  112. # Parse arguments #
  113. ################################################################################
  114. OPTSTRING="-o hw: -l enable-random,bin-dir:,cfg-dir:,yuv-dir:"
  115. OPTSTRING="${OPTSTRING},stream-endian:,frame-endian:"
  116. OPTSTRING="${OPTSTRING},slice-height:,enable-slice-intr:,bs-size:,output:,input:"
  117. OPTSTRING="${OPTSTRING},enable-tiledMode:"
  118. OPTSTRING="${OPTSTRING},12bit,pixelj:"
  119. OPTSTRING="${OPTSTRING},rotation:,mirror:"
  120. OPTS=`getopt $OPTSTRING -- "$@"`
  121. if [ $? -ne 0 ]; then
  122. exit 1
  123. fi
  124. eval set -- "$OPTS"
  125. while true; do
  126. case "$1" in
  127. -h)
  128. help
  129. exit 1
  130. shift;;
  131. --bin-dir)
  132. bin_dir_user=$2
  133. shift 2;;
  134. --enable-random)
  135. g_random_test=1
  136. shift;;
  137. --cfg-dir)
  138. cfg_dir_user=$2
  139. shift 2;;
  140. --yuv-dir)
  141. yuv_dir_user=$2
  142. shift 2;;
  143. --12bit)
  144. jpeg_12bit=1
  145. shift;;
  146. --pixelj)
  147. default_pixelj="$2"
  148. shift 2;;
  149. --enable-tiledMode)
  150. g_tiled_mode=$2
  151. shift 2;;
  152. --stream-endian)
  153. default_stream_endian="$2"
  154. shift 2;;
  155. --frame-endian)
  156. default_frame_endian="$2"
  157. shift 2;;
  158. --slice-height)
  159. default_slice_height="$2"
  160. shift 2;;
  161. --enable-slice-intr)
  162. default_slice_int="$2"
  163. shift 2;;
  164. --rotation)
  165. default_rotation="$2"
  166. shift 2;;
  167. --mirror)
  168. default_mirror="$2"
  169. shift 2;;
  170. --bs-size)
  171. default_bs_size="$2"
  172. shift 2;;
  173. --output)
  174. output_path="$2"
  175. shift 2;;
  176. --input)
  177. streamset_path="$2"
  178. shift 2;;
  179. --)
  180. shift
  181. break;;
  182. esac
  183. done
  184. shift $(($OPTIND - 1))
  185. if [ "$simulation" == "true" ]; then
  186. ACLK_MIN=160
  187. ACLK_MAX=300
  188. CCLK_MIN=160
  189. CCLK_MAX=300
  190. DEFAULT_ACLK=200
  191. DEFAULT_CCLK=200
  192. test_exec="./runit"
  193. else
  194. DEFAULT_ACLK=20
  195. DEFAULT_CCLK=20
  196. test_exec="./jpg_enc_test"
  197. fi
  198. if [ ! -f ./$test_exec ] ; then
  199. echo " $test_exec file doesn't exist";
  200. exit 1
  201. fi
  202. if [ ! -z $yuv_dir_user ]; then
  203. yuv_dir="$yuv_dir_user"
  204. fi
  205. if [ ! -z $cfg_dir_user ]; then
  206. cfg_dir="$cfg_dir_user"
  207. fi
  208. if [ ! -z $bin_dir_user ]; then
  209. bin_dir="$bin_dir_user"
  210. fi
  211. # SET DEFAULT VALUES
  212. if [ "$g_random_test" != "1" ]; then
  213. [ ! -z $default_aclk ] || default_aclk=$DEFAULT_ACLK
  214. [ ! -z $default_cclk ] || default_cclk=$DEFAULT_CCLK
  215. [ ! -z $default_stream_endian ] || default_stream_endian=0
  216. [ ! -z $default_frame_endian ] || default_frame_endian=0
  217. [ ! -z $default_pixelj ] || default_pixelj=0
  218. [ ! -z $default_rotation ] || default_rotation=0
  219. [ ! -z $default_mirror ] || default_mirror=0
  220. [ ! -z $default_slice_int ] || default_slice_int=0
  221. [ ! -z $default_slice_height ] || default_slice_height=0
  222. [ ! -z $default_bs_size ] || default_bs_size=$DEFAULT_BS_SIZE
  223. [ ! -z $default_tiled_mode ] || default_tiled_mode=0
  224. else
  225. # tiled option is not random value. It depends on a cfg name.
  226. default_tiled_mode=0
  227. fi
  228. if [ -z $streamset_path ]; then
  229. streamset_path=$1
  230. fi
  231. streamset_file=`basename ${streamset_path}`
  232. ################################################################################
  233. # count stream number #
  234. ################################################################################
  235. cfg_file_array=()
  236. ext="${streamset_file##*.}"
  237. if [ "$ext" == "cfg" ]; then
  238. cfg_file_array[0]="$streamset_path"
  239. else
  240. if [ ! -e "${streamset_path}" ]; then
  241. echo "No such file: ${streamset_path}"
  242. exit 1
  243. fi
  244. parse_streamset_file $streamset_path cfg_file_array
  245. fi
  246. num_of_cfgs=${#cfg_file_array[@]}
  247. count=1
  248. success_count=0
  249. failure_count=0
  250. remain_count=${num_of_cfgs}
  251. basedir=${basedir//\/} # remove last delimeter
  252. ################################################################################
  253. # make log info
  254. ################################################################################
  255. mkdir -p temp
  256. mkdir -p output
  257. mkdir -p log/encoder_conformance
  258. conf_log_path="log/encoder_conformance/${streamset_file}.log"
  259. conf_err_log_path="log/encoder_conformance/${streamset_file}_error.log"
  260. temp_log_path="./temp/temp.log"
  261. # truncate contents of log file
  262. echo "" > $conf_log_path
  263. echo "" > $conf_err_log_path
  264. echo "" > $temp_log_path
  265. beginTime=$(date +%s%N)
  266. ################################################################################
  267. # read cmd file. #
  268. ################################################################################
  269. for (( c=0; c< $num_of_cfgs ; c++ )) do
  270. line=${cfg_file_array[$c]}
  271. cfg="${line}"
  272. cfg_path="${cfg_dir}/${line}"
  273. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  274. log_conf "[${count}/${num_of_cfgs}] ${cfg_path}" ${temp_log_path}
  275. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  276. if [ ! -f $cfg_path ]; then
  277. log_conf "Not found $cfg_path" $conf_log_path
  278. log_conf "[RESULT] FAILURE" $conf_log_path
  279. echo "Not found $stream" >> $conf_err_log_path
  280. echo "[RESULT] FAILURE" >> $conf_err_log_path
  281. cat $temp_log_path >> $conf_log_path
  282. failure_count=$(($failure_count + 1))
  283. remain_count=$(($remain_count - 1))
  284. count=$(($count + 1))
  285. continue
  286. fi
  287. ################################################################################
  288. # read from cfg file name #
  289. ################################################################################
  290. if [[ $cfg == *"12b"* ]]; then
  291. echo "set jpeg_12bit from cfg file name"
  292. jpeg_12bit=1
  293. fi
  294. if [[ $cfg == *"tiled"* ]]; then
  295. echo "set g_tiled_mode from cfg file name"
  296. default_tiled_mode=1
  297. fi
  298. result=0
  299. ################################################################################
  300. # make argc & argv parameter #
  301. ################################################################################
  302. if [ $result -eq 0 ]; then
  303. generate_parameters $cfg_path
  304. build_test_param
  305. test_param="$g_func_ret_str"
  306. ################################################################################
  307. # Golden Data #
  308. ################################################################################
  309. golden_path="output_refc.jpg"
  310. generate_golden_stream $line $golden_path
  311. result=$?
  312. ################################################################################
  313. # print information #
  314. ################################################################################
  315. if [ $result -eq 0 ]; then
  316. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  317. log_conf "RANDOM TEST : ${ON_OFF[$g_random_test]}" $temp_log_path
  318. log_conf "ENDIAN : STREAM($g_stream_endian) FRAME($g_frame_endian)" $temp_log_path
  319. log_conf "STANDARD : JPEG" $temp_log_path
  320. log_conf "PIXEL JUST. : ${JUSTIFY_NAME[$g_pixel_just]}" $temp_log_path
  321. log_conf "TILED MODE : ${ON_OFF[$g_tiled_mode]}" $temp_log_path
  322. log_conf "WIDTH : $cfg_width" $temp_log_path
  323. log_conf "HEIGHT : $cfg_height" $temp_log_path
  324. log_conf "SLICE_HEIGHT : $g_slice_height" $temp_log_path
  325. log_conf "EN_SLICE_INTR : $g_enable_slice_intr" $temp_log_path
  326. log_conf "BS SIZE : $g_bs_size" $temp_log_path
  327. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  328. if [ -e $output_path ]; then
  329. rm -f $output_path
  330. fi
  331. cmd="$test_exec --output=$output_path --cfg-dir=$cfg_dir --yuv-dir=$yuv_dir $test_param --input=$cfg"
  332. if [ "$simulation" == "true" ]; then
  333. cmd="$cmd $g_w_param $g_fsdb_param --TestRunner=1"
  334. fi
  335. log_conf "$cmd" $temp_log_path
  336. cat $temp_log_path >> $conf_log_path
  337. if [ "$simulation" == "true" ]; then
  338. $cmd 2>&1 | tee -a $conf_log_path
  339. else
  340. exit
  341. $cmd
  342. fi
  343. log_conf "---------------- COMPARE ------------------" $conf_log_path
  344. log_conf "cmp $output_path output_refc.jpg" $conf_log_path
  345. if [ "$simulation" == "true" ]; then
  346. # For log messages.
  347. cmp $output_path output_refc.jpg 2>&1 | tee -a $conf_log_path > /dev/null #save the log
  348. fi
  349. cmp $output_path output_refc.jpg #get the result & show log
  350. if [ "$?" != "0" ]; then
  351. log_conf "------- COMPARE FAIL--------------" $conf_log_path
  352. result=1
  353. else
  354. log_conf "------- COMPARE SUCCESS-----------" $conf_log_path
  355. fi
  356. fi
  357. else
  358. cat $temp_log_path >> $conf_log_path
  359. fi
  360. if [ $result -eq 0 ]; then
  361. log_conf "[RESULT] SUCCESS" $conf_log_path
  362. success_count=$(($success_count + 1))
  363. else
  364. cat ./ErrorLog.txt >> $conf_log_path
  365. log_conf "[RESULT] FAILURE" $conf_log_path
  366. failure_count=$(($failure_count + 1))
  367. cat $temp_log_path >> $conf_err_log_path
  368. cat ./ErrorLog.txt >> $conf_err_log_path
  369. echo "[RESULT] FAILURE" >> $conf_err_log_path
  370. if [ $result -eq 10 ]; then
  371. echo "Abnormal exit!!!"
  372. break
  373. fi
  374. fi
  375. remain_count=$(($remain_count - 1))
  376. count=$(($count + 1))
  377. # clear temp log
  378. echo "" > $temp_log_path
  379. done
  380. ################################################################################
  381. # Create Test Log #
  382. ################################################################################
  383. endTime=$(date +%s%N)
  384. elapsed=$((($endTime - $beginTime) / 1000000000))
  385. elapsedH=$(($elapsed / 3600))
  386. elapsedS=$(($elapsed % 60))
  387. elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
  388. if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
  389. if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
  390. if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
  391. if [ $elapsed -le 60 ]; then
  392. time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
  393. else
  394. time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
  395. fi
  396. log_filename=$(basename $conf_log_path)
  397. log_err_filename=$(basename $conf_err_log_path)
  398. if [ "$failure_count" == "0" ] && [ $num_of_cfgs != 0 ]; then
  399. pass=${PASS}
  400. rm $conf_err_log_path
  401. log_err_filename=""
  402. else
  403. pass=${FAIL}
  404. fi
  405. wiki_log="| $streamset_file | $num_of_cfgs | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
  406. echo $wiki_log
  407. echo $wiki_log >> $wiki_log_file
  408. if [ "$num_of_cfgs" == "0" ]; then
  409. echo "num_of_cfgs: $num_of_cfgs = exit 1"
  410. exit 1
  411. fi
  412. exit $failure_count