TestRunnerCodaJ12Dec.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. #!/bin/bash
  2. source TestRunnerCommon.sh
  3. # Global varaibles for decoder option
  4. fail_stop=0
  5. refc_exec="Nieuport_JpgDec"
  6. bin_dir="./"
  7. stream_dir="./stream"
  8. wiki_log_file="./log/dec_confluence.log"
  9. g_random_test="false";
  10. jenkins=""
  11. txt_param_switch=0
  12. output_path="output_fpga.yuv"
  13. default_yuv_fmt=""
  14. default_subsample="none"
  15. default_ordering="none"
  16. simulation="false"
  17. default_bssize=5242880 # 5MB
  18. MAX_BS_SIZE=10485760 # 10MB, You can allocate more memory.
  19. MIN_BS_SIZE=8192 # 8KB
  20. g_random_test="false"
  21. g_slice_height=0
  22. g_enable_slice_intr=0
  23. default_read_delay=
  24. default_write_delay=
  25. fmt_test_400_list=("none" "420p" "422p" "444p" "nv12" "nv21" "nv16" "nv61" "nv24" "nv42" "yuyv" "yvyu" "uyvy" "vyuy")
  26. fmt_test_420_list=("none" "420p" "422p" "444p" "nv12" "nv21" "nv16" "nv61" "nv24" "nv42" "yuyv" "yvyu" "uyvy" "vyuy")
  27. fmt_test_422_list=("none" "420p" "422p" "444p" "nv12" "nv21" "nv16" "nv61" "nv24" "nv42" "yuyv" "yvyu" "uyvy" "vyuy")
  28. fmt_test_440_list=("none" "420p" "422p" "444p" "nv12" "nv21" "nv16" "nv61" "nv16v" "nv61v" "nv24" "nv42" "yuyv" "yvyu" "uyvy" "vyuy")
  29. fmt_test_444_list=("none" "420p" "422p" "444p" "nv12" "nv21" "nv16" "nv61" "nv24" "nv42" "yuyv" "yvyu" "uyvy" "vyuy" "ayuv")
  30. fmt_test_400_num=${#fmt_test_400_list[@]}
  31. fmt_test_420_num=${#fmt_test_420_list[@]}
  32. fmt_test_422_num=${#fmt_test_422_list[@]}
  33. fmt_test_440_num=${#fmt_test_440_list[@]}
  34. fmt_test_444_num=${#fmt_test_444_list[@]}
  35. MAX_OUTPUT_FMT=$((${#SUPPORTED_YUV_FMT[@]} -1))
  36. function help {
  37. echo ""
  38. echo "-------------------------------------------------------------------------------"
  39. echo "Chips&Media conformance Tool v2.0"
  40. echo "All copyright reserved by Chips&Media"
  41. echo "-------------------------------------------------------------------------------"
  42. echo "$0 OPTION streamlist_file"
  43. echo "-h help"
  44. echo "-n num number of frames."
  45. echo "--enable-random generate random option."
  46. echo "--bin-dir ref-c directory, default: ./"
  47. echo "--stream-dir stream directory"
  48. echo "--12bit input stream is an extended sequential jpeg"
  49. echo "--stream-endian ENDIAN bitstream endianness. refer to datasheet Chapter 4."
  50. echo "--frame-endian ENDIAN pixel endianness of 16bit input source. refer to datasheet Chapter 4."
  51. echo "--pixelj 16bit-pixel justification. 0(default) - msb justified, 1 - lsb justified in little-endianness"
  52. echo "--subsample conversion sub-sample(ignore case: NONE, 420, 422, 444";
  53. echo "--ordering conversion ordering(ingore-case: NONE, NV12, NV21, YUYV, YVYU, UYVY, VYUY, AYUV";
  54. echo " NONE - planar format";
  55. echo " NV12, NV21 - semi-planar format for all the subsamples.";
  56. echo " If subsample isn't defined or is none, the sub-sample depends on jpeg information";
  57. echo " The subsample 440 can be converted to the semi-planar format. It means that the encoded sub-sample should be 440.";
  58. echo " YUVV..VYUY - packed format. subsample be ignored.";
  59. echo " AYUV - 444 packed format. subsample be ignored.";
  60. echo "--scaleH Horizontal downscale: 0(none), 1(1/2), 2(1/4), 3(1/8)";
  61. echo "--scaleV Vertical downscale : 0(none), 1(1/2), 2(1/4), 3(1/8)";
  62. echo "--rotation 0, 90, 180, 270 CCW"
  63. echo "--mirror 0, 1(vertical), 2(horizontal), 3(both)"
  64. }
  65. function generate_parameters {
  66. local val=0
  67. local list
  68. g_stream_endian=$(gen_val 0 3 $default_stream_endian)
  69. if [ "$g_jpeg_12bit" == "true" ]; then
  70. g_frame_endian=$(gen_val 0 7 $default_frame_endian)
  71. else
  72. g_frame_endian=$(gen_val 0 3 $default_frame_endian)
  73. fi
  74. # PPU AND SCALER
  75. if [ "$g_random_test" == "true" ]; then
  76. ppu_random=$(gen_val 0 1) # 0 - rotation/mirror, 1 - scaler
  77. if [ "$ppu_random" == "0" ]; then
  78. g_rotation=$(gen_val_angle $default_rotation)
  79. g_mirror=$(gen_val 0 3 $default_mirror)
  80. g_scale_h=0
  81. g_scale_v=0
  82. elif [ "$ppu_random" == "1" ]; then
  83. g_rotation=0
  84. g_mirror=0
  85. g_scale_h=$(gen_val 0 3 $default_scaleH)
  86. g_scale_v=$(gen_val 0 3 $default_scaleV)
  87. fi
  88. else
  89. g_rotation=$(gen_val_angle $default_rotation)
  90. g_mirror=$(gen_val 0 3 $default_mirror)
  91. g_scale_h=$(gen_val 0 3 $default_scaleH)
  92. g_scale_v=$(gen_val 0 3 $default_scaleV)
  93. if [ "$g_rotation" != "0" ] || [ "$g_mirror" != "0" ]; then
  94. if [ "$g_scale_h" != "0" ] || [ "$g_scale_h" != "0" ]; then
  95. echo "The PPU(rotator and mirror) doesn't work with the down-scaler"
  96. echo "rotation: $g_rotation, mirror: $mirror, scale-H: $g_scale_h, scale-V: $g_scale_v"
  97. exit 1
  98. fi
  99. fi
  100. fi
  101. # SUBSAMPLE AND ORDERING
  102. if [ "$g_random_test" == "true" ]; then
  103. default_yuv_fmt="-99"
  104. fi
  105. if [ "$default_yuv_fmt" == "-99" ]; then
  106. case $g_orig_fmt in
  107. 400) list=(${fmt_test_400_list[@]});;
  108. 420) list=(${fmt_test_420_list[@]});;
  109. 422) list=(${fmt_test_422_list[@]});;
  110. 440) list=(${fmt_test_440_list[@]});;
  111. 444) list=(${fmt_test_444_list[@]});;
  112. esac
  113. max_fmt_num=${#list[@]}
  114. val=$(gen_val 0 $((max_fmt_num-1)))
  115. output_format="${list[$val]}"
  116. # generate subsample and ordering parameter for ref-sw
  117. convert_fmt_val_for_refsw $output_format $g_orig_fmt
  118. else
  119. g_subsample="$default_subsample"
  120. g_ordering="$default_ordering"
  121. fi
  122. if [ "$g_rotation" != "0" ] || [ "$g_mirror" != "0" ]; then
  123. # color format converter and rotator cannot work together.
  124. if [ "$g_subsample" != "none" ]; then
  125. g_subsample="none"
  126. fi
  127. if [ "$g_ordering" != "nv12" ] && [ "$g_ordering" != "nv21" ]; then
  128. g_ordering="none"
  129. fi
  130. fi
  131. g_bs_size=$(gen_val $MIN_BS_SIZE $MAX_BS_SIZE $default_bssize)
  132. g_bs_size=$((($g_bs_size + 4095) & ~4095))
  133. g_pixel_just=$(gen_val 0 1 $default_pixelj)
  134. # generate -pn -pk and -v options for c-model
  135. convert_fmt_val_for_cmodel $g_subsample $g_orig_fmt $g_ordering
  136. }
  137. function build_test_param {
  138. local param=""
  139. param="$param --rotation=$g_rotation"
  140. param="$param --mirror=$g_mirror"
  141. param="$param --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian"
  142. param="$param --subsample=$g_subsample --ordering=$g_ordering"
  143. param="$param --scaleH=$g_scale_h"
  144. param="$param --scaleV=$g_scale_v"
  145. param="$param --bs-size=$g_bs_size"
  146. param="$param --pixelj=$g_pixel_just"
  147. if [ "$simulation" == "true" ]; then
  148. param="$param $g_fsdb_param --TestRunner=1"
  149. fi
  150. g_func_ret_str="$param"
  151. }
  152. function get_yuv_format {
  153. local format=""
  154. local cmd="${bin_dir}/${refc_exec} -i $1 -m 1"
  155. if [ "$g_jpeg_12bit" == "true" ]; then
  156. cmd="$cmd -u"
  157. fi
  158. $cmd > result.txt
  159. while read line; do
  160. line=$(echo $line | tr -d '\n')
  161. line=$(echo $line | tr -d '\r')
  162. line="${line%%\#*}"
  163. attr=$(echo $line | cut -d':' -f1)
  164. attr=$(echo $attr | tr -d ' ')
  165. value=$(echo $line | cut -d':' -f2-)
  166. value=$(echo $value | tr -d ' ')
  167. value="${value//:/}"
  168. if [ "$attr" == "OutputYUVformat" ]; then
  169. format="$value"
  170. break;
  171. fi
  172. done < result.txt
  173. echo "$format"
  174. }
  175. ################################################################################
  176. # Parse arguments #
  177. ################################################################################
  178. OPTSTRING="-o hw: -l enable-random,stream-dir:,bin-dir:"
  179. OPTSTRING="${OPTSTRING},stream-endian:,frame-endian:"
  180. OPTSTRING="${OPTSTRING},slice-height:,enable-slice-intr:,subsample:,ordering:,output:,input:,bs-size:"
  181. OPTSTRING="${OPTSTRING},scaleH:,scaleV:,rotation:,mirror:"
  182. OPTSTRING="${OPTSTRING},12bit,pixelj:"
  183. OPTS=`getopt $OPTSTRING -- "$@"`
  184. if [ $? -ne 0 ]; then
  185. exit 1
  186. fi
  187. eval set -- "$OPTS"
  188. while true; do
  189. case "$1" in
  190. -h)
  191. help
  192. exit 1
  193. shift;;
  194. --bin-dir)
  195. bin_dir=$2
  196. shift 2;;
  197. --enable-random)
  198. g_random_test="true"
  199. shift;;
  200. --stream-dir)
  201. echo "stream-dir"
  202. stream_dir=$2
  203. shift 2;;
  204. --stream-endian)
  205. default_stream_endian=$2
  206. shift 2;;
  207. --frame-endian)
  208. default_frame_endian="$2"
  209. shift 2;;
  210. --12bit)
  211. g_jpeg_12bit="true"
  212. shift;;
  213. --pixelj)
  214. default_pixelj="$2"
  215. shift 2;;
  216. --input)
  217. streamset_path="$2"
  218. shift 2;;
  219. --output)
  220. output_path="$2"
  221. shift 2;;
  222. --subsample)
  223. default_subsample="$2"
  224. shift 2;;
  225. --ordering)
  226. default_ordering="$2"
  227. shift 2;;
  228. --scaleH)
  229. default_scaleH="$2"
  230. shift 2;;
  231. --scaleV)
  232. default_scaleV="$2"
  233. shift 2;;
  234. --rotation)
  235. default_rotation="$2"
  236. shift 2;;
  237. --mirror)
  238. default_mirror="$2"
  239. shift 2;;
  240. --bs-size)
  241. default_bssize="$2"
  242. shift 2;;
  243. --)
  244. shift
  245. break;;
  246. esac
  247. done
  248. shift $(($OPTIND - 1))
  249. if [ "$simulation" == "true" ]; then
  250. ACLK_MIN=160
  251. ACLK_MAX=300
  252. CCLK_MIN=160
  253. CCLK_MAX=300
  254. DEFAULT_ACLK=200
  255. DEFAULT_CCLK=200
  256. test_exec="./runit"
  257. else
  258. DEFAULT_ACLK=20
  259. DEFAULT_CCLK=20
  260. test_exec="./jpg_dec_test"
  261. fi
  262. ################################################################################
  263. # Get param from target text file #
  264. ################################################################################
  265. name_value=()
  266. input_param_name="TestRunnerParamCodaJ12Dec.txt"
  267. if [ -f $input_param_name ]; then
  268. while read line; do
  269. # remove right comment
  270. line="${line%%\#*}"
  271. if [ "$line" = "" ]; then continue; fi
  272. OIFS=$IFS
  273. IFS='='
  274. count=0
  275. for word in $line; do
  276. word=${word// /}
  277. name_value[$count]="$word"
  278. count=$(($count+1))
  279. done
  280. IFS=$OIFS
  281. attr="${name_value[0]}"
  282. value="${name_value[1]}"
  283. case "$attr" in
  284. default) default_opt="$value";;
  285. aclk) [ ! -z $default_aclk ] || default_aclk="$value";;
  286. cclk) [ ! -z $default_cclk ] || default_cclk="$value";;
  287. n) g_frame_num="-n $value";;
  288. fake_test) fake_test="$value";;
  289. stream-endian) [ ! -z $default_stream_endian ] || default_stream_endian="$value";;
  290. frame-endian) [ ! -z $default_frame_endian ] || default_frame_endian="$value";;
  291. scaleH) [ ! -z $default_scaleH ] || default_scaleH="$value";;
  292. scaleV) [ ! -z $default_scaleV ] || default_scaleV="$value";;
  293. rotation) [ ! -z $default_rotation ] || default_rotation="$value";;
  294. mirror) [ ! -z $default_mirror ] || default_mirror="$value";;
  295. pixelj) [ ! -z $default_pixelj ] || default_pixelj="$value";;
  296. slice-height) [ ! -z $default_slice_height ] || default_slice_height="$value";;
  297. enable-slice-intr) [ ! -z $default_slice_int ] || default_slice_int="$value";;
  298. txt-param) txt_param_switch=1;;
  299. *) ;;
  300. esac
  301. done < $input_param_name
  302. else
  303. if [ ! -f $input_param_name ]; then
  304. echo "$input_param_name file doesn't exist";
  305. fi
  306. fi
  307. # SET DEFAULT VALUES
  308. if [ "$g_random_test" != "true" ]; then
  309. [ ! -z $default_aclk ] || default_aclk=$DEFAULT_ACLK
  310. [ ! -z $default_cclk ] || default_cclk=$DEFAULT_CCLK
  311. [ ! -z $default_stream_endian ] || default_stream_endian=0
  312. [ ! -z $default_frame_endian ] || default_frame_endian=0
  313. [ ! -z $default_scaleH ] || default_scaleH=0
  314. [ ! -z $default_scaleV ] || default_scaleV=0
  315. [ ! -z $default_rotation ] || default_rotation=0
  316. [ ! -z $default_mirror ] || default_mirror=0
  317. [ ! -z $default_slice_int ] || default_slice_int=0
  318. [ ! -z $default_slice_height ] || default_slice_height=0
  319. [ ! -z $default_pixelj ] || default_pixelj=0
  320. else
  321. default_slice_int=0
  322. default_slice_height=0
  323. fi
  324. if [ -z $streamset_path ]; then
  325. streamset_path=$1
  326. fi
  327. streamset_file=`basename ${streamset_path}`
  328. ################################################################################
  329. # count stream number #
  330. ################################################################################
  331. stream_file_array=()
  332. ext="${streamset_file##*.}"
  333. ext=$(tr '[:upper:]' '[:lower:]' <<< $ext)
  334. single_file="false"
  335. if [ "$ext" == "jpg" ] || [ "$ext" == "jpeg" ]; then
  336. stream_file_array[0]="$streamset_path"
  337. single_file="true"
  338. else
  339. if [ ! -e "${streamset_path}" ]; then
  340. echo "No such file: ${streamset_path}"
  341. exit 1
  342. fi
  343. parse_streamset_file $streamset_path stream_file_array
  344. fi
  345. num_of_streams=${#stream_file_array[@]}
  346. count=1
  347. success_count=0
  348. failure_count=0
  349. remain_count=${num_of_streams}
  350. basedir=${basedir//\/} # remove last delimeter
  351. mkdir -p temp
  352. mkdir -p output
  353. mkdir -p log/decoder_conformance
  354. conf_log_path="log/decoder_conformance/${streamset_file}.log"
  355. conf_err_log_path="log/decoder_conformance/${streamset_file}_error.log"
  356. temp_log_path="./temp/temp.log"
  357. # truncate contents of log file
  358. echo "" > $conf_log_path
  359. echo "" > $conf_err_log_path
  360. echo "" > $temp_log_path
  361. beginTime=$(date +%s%N)
  362. ################################################################################
  363. # read cmd file. #
  364. ################################################################################
  365. for (( c=0; c< $num_of_streams ; c++ )) do
  366. line=${stream_file_array[$c]}
  367. if [ "$single_file" == "true" ]; then
  368. stream="${line}"
  369. else
  370. stream="${stream_dir}/${line}"
  371. fi
  372. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  373. log_conf "[${count}/${num_of_streams}] ${stream}" ${temp_log_path}
  374. log_conf "--------------------------------------------------------------------------------" ${temp_log_path}
  375. if [ ! -f $stream ]; then
  376. log_conf "Not found $stream" $temp_log_path
  377. log_conf "[RESULT] FAILURE" $temp_log_path
  378. echo "Not found $stream" >> $conf_err_log_path
  379. echo "[RESULT] FAILURE" >> $conf_err_log_path
  380. cat $temp_log_path >> $conf_log_path
  381. failure_count=$(($failure_count + 1))
  382. remain_count=$(($remain_count - 1))
  383. count=$(($count + 1))
  384. continue
  385. fi
  386. result=0
  387. target_stream=$stream
  388. ################################################################################
  389. # make argc & argv parameter #
  390. ################################################################################
  391. if [ $result -eq 0 ]; then
  392. g_orig_fmt=$(get_yuv_format $target_stream)
  393. generate_parameters
  394. build_test_param
  395. test_param="$g_func_ret_str"
  396. ################################################################################
  397. # Golden YUV #
  398. ################################################################################
  399. golden_yuv_path="output_refc.yuv"
  400. generate_golden_yuv $stream $golden_yuv_path
  401. result=$?
  402. ################################################################################
  403. # print information #
  404. ################################################################################
  405. if [ $result -eq 0 ]; then
  406. log_conf "RANDOM TEST : $g_random_test" $temp_log_path
  407. log_conf "ENDIAN : STREAM($g_stream_endian) FRAME($g_frame_endian)" $temp_log_path
  408. log_conf "SUBSAMPLE : $g_subsample" $temp_log_path
  409. log_conf "ORDERING : $g_ordering" $temp_log_path
  410. log_conf "ROTATE : $g_rotation" $temp_log_path
  411. log_conf "MIRROR : ${MIRROR_NAME[$g_mirror]}" $temp_log_path
  412. log_conf "SCALE DOWN : H: ${SCALEDOWN_NAME[$g_scale_h]} V: ${SCALEDOWN_NAME[$g_scale_v]}" $temp_log_path
  413. log_conf "PIXEL_JUST. : ${JUSTIFY_NAME[$g_pixel_just]}" $temp_log_path
  414. rm -f output_fpga.yuv
  415. cmd="$test_exec $test_param --output=$output_path --input=$target_stream"
  416. cmd_log="$test_exec $test_param --output=$output_path --input=$stream"
  417. log_conf "$cmd_log" $temp_log_path
  418. cat $temp_log_path >> $conf_log_path
  419. if [ "$fake_test" == "1" ]; then
  420. echo "<< Testing just script >>"
  421. else
  422. exit
  423. $cmd
  424. result=$?
  425. if [ "$result" == "0" ]; then
  426. cmp $output_path output_refc.yuv
  427. if [ "$?" != "0" ]; then
  428. result=1
  429. fi
  430. fi
  431. fi
  432. fi
  433. else
  434. cat $temp_log_path >> $conf_log_path
  435. fi
  436. if [ $result -eq 0 ]; then
  437. log_conf "[RESULT] SUCCESS" $conf_log_path
  438. success_count=$(($success_count + 1))
  439. else
  440. cat ./ErrorLog.txt >> $conf_log_path
  441. log_conf "[RESULT] FAILURE" $conf_log_path
  442. failure_count=$(($failure_count + 1))
  443. cat $temp_log_path >> $conf_err_log_path
  444. cat ./ErrorLog.txt >> $conf_err_log_path
  445. echo "cmp $stream $target_stream"
  446. cmp $stream $target_stream
  447. echo "[RESULT] FAILURE" >> $conf_err_log_path
  448. if [ $result -eq 10 ]; then
  449. echo "Abnormal exit!!!"
  450. break
  451. fi
  452. fi
  453. remain_count=$(($remain_count - 1))
  454. count=$(($count + 1))
  455. # clear temp log
  456. echo "" > $temp_log_path
  457. # delete temporal input file
  458. if [ $fail_stop -eq 1 ] && [ $result -ne 0 ]; then
  459. break;
  460. fi
  461. done
  462. endTime=$(date +%s%N)
  463. elapsed=$((($endTime - $beginTime) / 1000000000))
  464. elapsedH=$(($elapsed / 3600))
  465. elapsedS=$(($elapsed % 60))
  466. elapsedM=$(((($elapsed - $elapsedS) / 60) % 60))
  467. if [ "$((elapsedS / 10))" == "0" ]; then elapsedS="0${elapsedS}" ;fi
  468. if [ "$((elapsedM / 10))" == "0" ]; then elapsedM="0${elapsedM}" ;fi
  469. if [ "$((elapsedH / 10))" == "0" ]; then elapsedH="0${elapsedH}" ;fi
  470. if [ $elapsed -le 60 ]; then
  471. time_hms="{color:red}*${elapsedH}:${elapsedM}:${elapsedS}*{color}"
  472. else
  473. time_hms="${elapsedH}:${elapsedM}:${elapsedS}"
  474. fi
  475. log_filename=$(basename $conf_log_path)
  476. log_err_filename=$(basename $conf_err_log_path)
  477. if [ $failure_count == 0 ] && [ $num_of_streams != 0 ]; then
  478. pass=${PASS}
  479. rm $conf_err_log_path
  480. log_err_filename=""
  481. else
  482. pass=${FAIL}
  483. fi
  484. wiki_log="| $streamset_file | $num_of_streams | $success_count | $failure_count | $remain_count | $log_filename | ${log_err_filename} | $pass | $time_hms | | | |"
  485. echo $wiki_log
  486. echo $wiki_log >> $wiki_log_file
  487. if [ "$num_of_streams" == "0" ]; then
  488. echo "num_of_streams: $num_of_streams = exit 1"
  489. exit 1
  490. fi
  491. exit $failure_count