common.sh 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022
  1. ###############################################################################
  2. # COMMON DATA
  3. ###############################################################################
  4. ON_OFF=(
  5. "OFF"
  6. "ON"
  7. )
  8. readonly C_YUV_8B_P420=0
  9. readonly C_YUV_8B_P422=1
  10. readonly C_YUV_10B_MSB_P420=5
  11. readonly C_YUV_10B_LSB_P420=6
  12. readonly C_YUV_3P4B_MSB_P420=7 # each pixel 10bit
  13. readonly C_YUV_3P4B_LSB_P420=8 # each pixel 10bit
  14. readonly C_YUV_10B_MSB_P422=9
  15. readonly C_YUV_10B_LSB_P422=10
  16. readonly C_YUV_3P4B_MSB_P422=11 # each pixel 10bit
  17. readonly C_YUV_3P4B_LSB_P422=12 # each pixel 10bit
  18. readonly C_YUV_8B_YUYV=13
  19. readonly C_YUV_10B_MSB_YUYV=14
  20. readonly C_YUV_10B_LSB_YUYV=15
  21. readonly C_YUV_3P4B_MSB_YUYV=16
  22. readonly C_YUV_3P4B_LSB_YUYV=17
  23. readonly C_YUV_8B_YVYU=18
  24. readonly C_YUV_10B_MSB_YVYU=19
  25. readonly C_YUV_10B_LSB_YVYU=20
  26. readonly C_YUV_3P4B_MSB_YVYU=21
  27. readonly C_YUV_3P4B_LSB_YVYU=22
  28. readonly C_YUV_8B_UYVY=23
  29. readonly C_YUV_10B_MSB_UYVY=24
  30. readonly C_YUV_10B_LSB_UYVY=25
  31. readonly C_YUV_3P4B_MSB_UYVY=26
  32. readonly C_YUV_3P4B_LSB_UYVY=27
  33. readonly C_YUV_8B_VYUY=28
  34. readonly C_YUV_10B_MSB_VYUY=29
  35. readonly C_YUV_10B_LSB_VYUY=30
  36. readonly C_YUV_3P4B_MSB_VYUY=31
  37. readonly C_YUV_3P4B_LSB_VYUY=32
  38. readonly CODA_MIN_ENDIAN=0
  39. readonly CODA_MAX_ENDIAN=3
  40. readonly WAVE_MIN_ENDIAN=16
  41. readonly WAVE_MAX_ENDIAN=31
  42. readonly CODA_SEC_AXI_MAX=63
  43. readonly SCALER_SEC_AXI_MAX=15
  44. readonly BWB_SECONDARY_AXI_MAX=7
  45. readonly WAVE517_BWB_SECONDARY_AXI_MAX=3
  46. YUV_FORMAT_LIST=(
  47. "FORMAT_420"
  48. "RESERVED"
  49. "RESERVED"
  50. "RESERVED"
  51. "RESERVED"
  52. "FORMAT_420_P10_16BIT_MSB"
  53. "FORMAT_420_P10_16BIT_LSB"
  54. "FORMAT_420_P10_32BIT_MSB"
  55. "FORMAT_420_P10_32BIT_LSB"
  56. )
  57. YUV_FORMAT_LIST_8BIT=(
  58. "FORMAT_420"
  59. )
  60. # DO NOT CHANGE ORDER
  61. YUV_FORMAT_LIST_SCALER_10BIT=(
  62. "FORMAT_420"
  63. "FORMAT_422"
  64. "RESERVED"
  65. "RESERVED"
  66. "RESERVED"
  67. "FORMAT_420_P10_16BIT_MSB"
  68. "FORMAT_420_P10_16BIT_LSB"
  69. "FORMAT_420_P10_32BIT_MSB"
  70. "FORMAT_420_P10_32BIT_LSB"
  71. "FORMAT_422_P10_16BIT_MSB"
  72. "FORMAT_422_P10_16BIT_LSB"
  73. "FORMAT_422_P10_32BIT_MSB"
  74. "FORMAT_422_P10_32BIT_LSB"
  75. )
  76. # DISABLED YUV422 CONVERSION UNTIL SCALER FIXED
  77. YUV_FORMAT_LIST_SCALER_8BIT=(
  78. "FORMAT_420"
  79. "FORMAT_422"
  80. )
  81. AFBCE_FORMAT_NAME=(
  82. "NONE"
  83. "AFBCE_FORMAT_8BIT"
  84. "AFBCE_FORMAT_10BIT"
  85. )
  86. C9_ENDIAN_NAME=(
  87. "VDI_64BIT_LE"
  88. "VDI_64BIT_BE"
  89. "VDI_32BIT_LE"
  90. "VDI_32BIT_BE"
  91. )
  92. W4_ENDIAN_NAME=(
  93. "VDI_128BIT_BIG_ENDIAN"
  94. "VDI_128BIT_BE_BYTE_SWAP"
  95. "VDI_128BIT_BE_WORD_SWAP"
  96. "VDI_128BIT_BE_WORD_BYTE_SWAP"
  97. "VDI_128BIT_BE_DWORD_SWAP"
  98. "VDI_128BIT_BE_DWORD_BYTE_SWAP"
  99. "VDI_128BIT_BE_DWORD_WORD_SWAP"
  100. "VDI_128BIT_BE_DWORD_WORD_BYTE_SWAP"
  101. "VDI_128BIT_LE_DWORD_WORD_BYTE_SWAP"
  102. "VDI_128BIT_LE_DWORD_WORD_SWAP"
  103. "VDI_128BIT_LE_DWORD_BYTE_SWAP"
  104. "VDI_128BIT_LE_DWORD_SWAP"
  105. "VDI_128BIT_LE_WORD_BYTE_SWAP"
  106. "VDI_128BIT_LE_WORD_SWAP"
  107. "VDI_128BIT_LE_BYTE_SWAP"
  108. "VDI_128BIT_LITTLE_ENDIAN"
  109. )
  110. DEC_BSMODE_NAME=(
  111. "Interrupt"
  112. "Reserved"
  113. "PicEnd"
  114. )
  115. ENC_BSMODE_NAME=(
  116. "Ringbuffer"
  117. "Linebuffer"
  118. )
  119. ENC_WAVE_BSMODE_NAME=(
  120. "Linebuffer"
  121. "Ringbuffer, Wrap On"
  122. "Ringbuffer, Wrap Off"
  123. )
  124. CODA980_MAPTYPE_NAME=(
  125. "LINEAR_FRAME"
  126. "TILED_FRAME_V"
  127. "TILED_FRAME_H"
  128. "TILED_FIELD_V"
  129. "TILED_MIXED_V"
  130. "TILED_FRAME_MB_RASTER"
  131. "TILED_FIELD_MB_RASTER"
  132. "TILED_FRAME_NO_BANK"
  133. "TILED_FIELD_NO_BANK"
  134. )
  135. CODA960_MAPTYPE_NAME=(
  136. "LINEAR_FRAME"
  137. "TILED_FRAME_V"
  138. "TILED_FRAME_H"
  139. "TILED_FIELD_V"
  140. "TILED_MIXED_V"
  141. "TILED_FRAME_MB_RASTER"
  142. "TILED_FIELD_MB_RASTER"
  143. )
  144. MIRROR_NAME=(
  145. "NONE"
  146. "VERTICAL"
  147. "HORIZONTAL"
  148. "BOTH"
  149. )
  150. CODEC_NAME=(
  151. "H.264"
  152. "VC-1"
  153. "MPEG-2"
  154. "MPEG-4"
  155. "H.263"
  156. "DIVX3"
  157. "RV"
  158. "AVS"
  159. "NONE"
  160. "THEORA"
  161. "NONE"
  162. "VP8"
  163. "HEVC"
  164. "VP9"
  165. "AVS2"
  166. "SVAC"
  167. )
  168. SRC_FORMAT_NAME=(
  169. "8BIT"
  170. "10BIT - 1Pixel 2bytes MSB"
  171. "10BIT - 1Pixel 2bytes LSB"
  172. "10BIT - 3Pixel 4bytes MSB"
  173. "10BIT - 3Pixel 4bytes LSB"
  174. )
  175. PASS="PASS"
  176. FAIL="FAIL"
  177. ###############################################################################
  178. # GLOBAL VARIABLES
  179. ###############################################################################
  180. g_fpga_reset=0 # 1 : reset fpga every time
  181. g_multi_vcore=0
  182. g_force_num_cores=0
  183. ######################## COMMON VARAIABLES FOR DECODER ########################
  184. g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
  185. g_match_mode=1 # 0 - nomatch, 1 - yuv, 2 - md5
  186. g_secondary_axi=0
  187. g_stream_endian=0
  188. g_source_endian=0
  189. g_frame_endian=0
  190. g_bsmode=0
  191. g_enable_thumbnail=0
  192. g_cbcr_interleave=0
  193. g_enable_nv21=0
  194. g_enable_wtl=1
  195. g_wtl_format=0
  196. g_bs_size=0
  197. g_codec_index=0
  198. g_cframe_temp=0
  199. g_subFrameSync_temp=0
  200. g_cframe_422=0
  201. g_scaler="false"
  202. g_revision=""
  203. ########################## WAVE5xx DECODER VARAIABLES #########################
  204. g_tid_test=0
  205. g_bw_opt=0
  206. g_afbce=0
  207. ####################### CODA9&CODA7 DECODER VARAIABLES ########################
  208. g_maptype_index=0 # CODA9xx feature
  209. g_enable_tiled2linear=0
  210. g_enable_deblock=0
  211. g_enable_dering=0
  212. g_enable_mvc=0 # H.264 MVC
  213. g_mp4class=0
  214. g_maptype_num=1
  215. g_enable_ppu=1
  216. ######################## VARAIABLES FOR WAVE5 ENCODER #########################
  217. g_subframe_sync=0
  218. g_lowLatencyMode=0
  219. g_packedFormat=0
  220. g_srcFormat=0
  221. ######################## VARAIABLES FOR CODA9 ENCODER #########################
  222. g_enable_linear2tiled=0
  223. g_linebuf_int=0
  224. ########################## VARAIABLES FOR PPU #################################
  225. g_rotAngle=0
  226. g_mirDir=0
  227. g_oriw=0
  228. g_orih=0
  229. g_sclw=0
  230. g_sclh=0
  231. g_min_scale_w=0
  232. g_min_scale_h=0
  233. ###############################################################################
  234. # GLOBAL FUNCTIONS
  235. ###############################################################################
  236. # ceiling function
  237. function ceiling {
  238. local value=$1
  239. local align=$2
  240. echo "$(((($value+$align-1)/$align)*$align))"
  241. }
  242. # check_and_create_dir
  243. function check_and_create_dir {
  244. CHECK_PATH=$1
  245. if [ ! -d "$CHECK_PATH" ]; then
  246. mkdir -p $CHECK_PATH
  247. chmod 777 $CHECK_PATH
  248. echo "create $CHECK_PATH"
  249. else
  250. echo "Already $CHECK_PATH Exist"
  251. fi
  252. }
  253. # get_random start end
  254. # generate constraint random value with @start end @end.
  255. #
  256. function get_random {
  257. start=$1
  258. end=$2
  259. size=$(($end - $start + 1))
  260. val2=$RANDOM
  261. val1=$(($val2 % size))
  262. val=$(($start + $val1%$size))
  263. echo "$val"
  264. }
  265. function get_random_min_max {
  266. start=$1
  267. end=$2
  268. use_min_max_value=$(($RANDOM % 5))
  269. size=$(($end - $start - 1))
  270. if [ $use_min_max_value = 1 ] || [ $size -le 0 ]; then
  271. val2=$RANDOM
  272. val1=$(($val2 % 2))
  273. if [ $val1 = 1 ]; then
  274. val=$end
  275. else
  276. val=$start
  277. fi
  278. else
  279. val2=$RANDOM
  280. val1=$(($val2 % size))
  281. val=$(($start + $val1%$size + 1))
  282. fi
  283. echo "$val"
  284. }
  285. # log_conf log_message log_file
  286. # write @log_message to @log_file
  287. #
  288. function log_conf {
  289. echo "$1" | tee -a "$2"
  290. }
  291. # parse_streamset_file streamset_path *array
  292. # - parse streamset file and store data into @g_stream_file_array
  293. #
  294. function parse_streamset_file {
  295. local f="$1"
  296. local index=0
  297. local line=""
  298. while read -r line || [ -n "$line" ]; do
  299. line="${line#*( )}" # remove front whitespace
  300. line="${line%%[ $'\t']*}" # remove start of whitespace
  301. line="${line//\\//}" # replace backslash to slash
  302. line="${line/$'\r'/}" # remove carriage return
  303. firstchar=${line:0:1}
  304. case "$firstchar" in
  305. "@") break;; # exit flag
  306. "#") continue;; # comment
  307. ";") continue;; # comment
  308. "") continue;; # comment
  309. *)
  310. esac
  311. eval $2[$index]="$line"
  312. index=$(($index + 1))
  313. done < $f
  314. }
  315. function gen_val {
  316. local min_val=$1
  317. local max_val=$2
  318. local default_val=$3
  319. local val
  320. if [ -z "$default_val" ] || [ "$default_val" == "-99" ]; then
  321. # Generate random value
  322. val=$(get_random $min_val $max_val)
  323. else
  324. val=$default_val
  325. fi
  326. echo "$val"
  327. }
  328. function gen_min_max_val {
  329. local min_val=$1
  330. local max_val=$2
  331. local default_val=$3
  332. local val
  333. if [ -z "$default_val" ] || [ "$default_val" == "-99" ]; then
  334. # Generate random value
  335. val=$(get_random_min_max $min_val $max_val)
  336. else
  337. val=$default_val
  338. fi
  339. echo "$val"
  340. }
  341. function set_min_max_param {
  342. if [[ $g_product_name =~ coda9* ]]; then
  343. MIN_ENDIAN=$CODA_MIN_ENDIAN
  344. MAX_ENDIAN=$CODA_MAX_ENDIAN
  345. MAX_SEC_AXI=$CODA_SEC_AXI_MAX
  346. else
  347. MIN_ENDIAN=$WAVE_MIN_ENDIAN
  348. MAX_ENDIAN=$WAVE_MAX_ENDIAN
  349. if [ $g_scaler == "true" ]; then
  350. MAX_SEC_AXI=$SCALER_SEC_AXI_MAX
  351. else
  352. MAX_SEC_AXI=$BWB_SECONDARY_AXI_MAX
  353. fi
  354. if [ "$g_product_name" == "wave517" ]; then
  355. MAX_SEC_AXI=$WAVE517_BWB_SECONDARY_AXI_MAX
  356. fi
  357. fi
  358. }
  359. function set_yuv_mode_dual {
  360. local max_val=$1
  361. g_cbcr_interleave=0
  362. g_enable_nv21=0
  363. case $(gen_val 0 $max_val $g_yuv_mode_temp) in
  364. 0) g_cbcr_interleave=1 # NV12
  365. g_enable_nv21=0;;
  366. 1) g_cbcr_interleave=1 # NV21
  367. g_enable_nv21=1;;
  368. esac
  369. }
  370. function set_yuv_mode {
  371. local max_val=$1
  372. g_cbcr_interleave=0
  373. g_enable_nv21=0
  374. g_packedFormat=0
  375. case $(gen_val 0 $max_val $g_yuv_mode_temp) in
  376. 0) g_cbcr_interleave=0 # separate YUV
  377. g_enable_nv21=0;;
  378. 1) g_cbcr_interleave=1 # NV12
  379. g_enable_nv21=0;;
  380. 2) g_cbcr_interleave=1 # NV21
  381. g_enable_nv21=1;;
  382. 3) g_packedFormat=1;; #YUYV
  383. 4) g_packedFormat=2;; #YVYU
  384. 5) g_packedFormat=3;; #UYVY
  385. 6) g_packedFormat=4;; #VYUY
  386. *) g_cbcr_interleave=0
  387. g_enable_nv21=0
  388. g_packedFormat=0;;
  389. esac
  390. }
  391. function set_bsmode {
  392. g_bsmode=$(gen_val 0 1 $bsmode_temp)
  393. if [ -n "$g_bsmode_force" ]; then #only coda
  394. g_bsmode=$g_bsmode_force
  395. fi
  396. if [ "$g_bsmode" = "1" ]; then
  397. g_bsmode=2;
  398. fi
  399. # VP9 constraint(PIC_END Mode)
  400. if [ "$codec" = "vp9" ]; then
  401. g_bsmode=2
  402. fi
  403. # av1 constraint(Interrupt Mode)
  404. if [ "$codec" = "av1" ]; then
  405. g_bsmode=0
  406. fi
  407. }
  408. function set_rot_mir {
  409. val=$(gen_val 0 3 $rotAngle_temp)
  410. if [ "$val" -le "3" ]; then
  411. g_rotAngle=$(expr $val \* 90)
  412. else
  413. g_rotAngle=$val
  414. fi
  415. g_mirDir=$(gen_val 0 3 $mirDir_temp)
  416. }
  417. function set_decoder_option_w511 {
  418. local output_hw
  419. g_enable_wtl=1
  420. if [ "$g_scaler" = "true" ]; then
  421. # DOWN SCALING TEST
  422. output_hw="scaler"
  423. else
  424. if [ -n "$disable_wtl_temp" ]; then
  425. if [ "$disable_wtl_temp" == "0" ]; then
  426. output_hw="bwb"
  427. else
  428. output_hw="fbc"
  429. fi
  430. else
  431. val=$(gen_val 0 1)
  432. if [ "$val" == "0" ]; then
  433. output_hw="bwb"
  434. else
  435. output_hw="fbc"
  436. fi
  437. fi
  438. fi
  439. case $output_hw in
  440. "bwb") # BWB
  441. if [ "$is_main10" == "1" ]; then
  442. g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
  443. else
  444. g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
  445. fi
  446. g_wtl_format=$(gen_wtl_format $wtl_format_temp)
  447. ;;
  448. "fbc") # FBC
  449. # FBC IS A COMPRESSED FRAMEBUFFER FORMAT. DISABLE NV12/21
  450. g_enable_wtl=0
  451. g_cbcr_interleave=0
  452. g_enable_nv21=0
  453. ;;
  454. "scaler")
  455. g_wtl_format=0
  456. # SCALER
  457. if [ "$g_scaler" == "true" ]; then
  458. if [ "$is_main10" == "1" ]; then
  459. g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_10BIT[@]}")
  460. else
  461. g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_8BIT[@]}")
  462. fi
  463. else
  464. if [ "$is_main10" == "1" ]; then
  465. g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
  466. else
  467. g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
  468. fi
  469. fi
  470. g_wtl_format=$(gen_wtl_format $wtl_format_temp)
  471. ;;
  472. esac
  473. # BANDWIDTH OPTIMIZATION
  474. if [ $g_enable_wtl -eq 1 ]; then
  475. g_bw_opt=$(gen_val 0 1 $g_bw_opt_temp)
  476. fi
  477. }
  478. function set_decoder_option_w512 {
  479. # WAVE512 has three output H/W modules.
  480. # 0 - BWB, 1 - AFBCE, 2 - DOWN-SCALER, 3 - DISABLE-WTL
  481. # BWB, AFBCE AND DOWNSCALER NEED WTL FUNCTION
  482. g_enable_wtl=1
  483. g_afbce=0
  484. if [ "$g_scaler" = "true" ]; then
  485. # DOWN SCALING TEST
  486. val=2
  487. else
  488. val=$(gen_val 0 3 $g_output_hw_temp)
  489. fi
  490. # WAVE515 do not support afbce
  491. if [ "$g_product_name" = "wave515" ] && [ "$val" == "1" ]; then
  492. val=0
  493. fi
  494. # WAVE511 do not support afbce
  495. if [ "$g_product_name" = "wave511" ] && [ "$val" == "1" ]; then
  496. val=0
  497. fi
  498. # WAVE521c_dual do not support afbce,
  499. if [ "$g_product_name" = "wave521c_dual" ] && [ "$val" == "1" ]; then
  500. val=0
  501. fi
  502. if [ -z "$wtl_format_temp" ]; then
  503. val=0
  504. fi
  505. case $val in
  506. 0) # BWB
  507. if [ "$is_main10" == "1" ]; then
  508. g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
  509. else
  510. g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
  511. fi
  512. g_wtl_format=$(gen_wtl_format $wtl_format_temp)
  513. ;;
  514. 1)
  515. g_wtl_format=0
  516. ;;
  517. 2)
  518. g_wtl_format=0
  519. # SCALER
  520. if [ "$g_scaler" == "true" ]; then
  521. if [ "$is_main10" == "1" ]; then
  522. g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_10BIT[@]}")
  523. else
  524. g_yuv_fmt_list=("${YUV_FORMAT_LIST_SCALER_8BIT[@]}")
  525. fi
  526. else
  527. if [ "$is_main10" == "1" ]; then
  528. g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
  529. else
  530. g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
  531. fi
  532. fi
  533. g_wtl_format=$(gen_wtl_format $wtl_format_temp)
  534. ;;
  535. 3) # FBC
  536. # FBC IS A COMPRESSED FRAMEBUFFER FORMAT. DISABLE NV12/21
  537. g_enable_wtl=0
  538. g_cbcr_interleave=0
  539. g_enable_nv21=0
  540. ;;
  541. esac
  542. # BANDWIDTH OPTIMIZATION
  543. if [ $g_enable_wtl -eq 1 ]; then
  544. g_bw_opt=$(gen_val 0 1 $g_bw_opt_temp)
  545. fi
  546. }
  547. function set_decoder_option_w525 {
  548. # WAVE512 has three output H/W modules.
  549. # 0 - BWB, 1 - DISABLE-WTL
  550. g_enable_wtl=1
  551. val=$(gen_val 0 1 $g_output_hw_temp)
  552. case $val in
  553. 0) # BWB
  554. if [ "$is_main10" == "1" ]; then
  555. g_yuv_fmt_list=("${YUV_FORMAT_LIST[@]}")
  556. else
  557. g_yuv_fmt_list=("${YUV_FORMAT_LIST_8BIT[@]}")
  558. fi
  559. g_wtl_format=$(gen_wtl_format $wtl_format_temp)
  560. ;;
  561. 1)
  562. # FBC IS A COMPRESSED FRAMEBUFFER FORMAT. DISABLE NV12/21
  563. g_enable_wtl=0
  564. g_cbcr_interleave=0
  565. g_enable_nv21=0
  566. ;;
  567. esac
  568. # BANDWIDTH OPTIMIZATION
  569. if [ $g_enable_wtl -eq 1 ]; then
  570. g_bw_opt=$(gen_val 0 1 $g_bw_opt_temp)
  571. fi
  572. }
  573. function set_decoder_option {
  574. set_bsmode
  575. set_yuv_mode 2 #2:without packedformat
  576. # CODA9 features
  577. if [[ $g_product_name =~ coda9* ]]; then
  578. set_rot_mir
  579. if [ "$codec" = "mp2" ] || [ "$codec" = "mp4" ]; then
  580. g_enable_deblock=$(gen_val 0 1 $deblock_temp)
  581. g_enable_dering=$(gen_val 0 1 $dering_temp)
  582. else
  583. g_enable_deblock=0
  584. g_enable_dering=0
  585. fi
  586. g_maptype_index=$(gen_val 0 $(($g_maptype_num-1)) $maptype_temp)
  587. # TILED2LINEAR
  588. g_enable_wtl=0
  589. g_enable_tiled2linear=0
  590. if [ $g_maptype_index -gt 0 ]; then
  591. local val=$(get_random 0 1)
  592. if [ $val -eq 0 ]; then
  593. g_enable_tiled2linear=1
  594. else
  595. g_enable_wtl=1
  596. fi
  597. fi
  598. # check combination of parameters
  599. if [ $g_enable_wtl -eq 1 ] || [ $g_enable_ppu -eq 0 ]; then
  600. g_rotAngle=0
  601. g_mirDir=0
  602. g_enable_dering=0
  603. fi
  604. else
  605. case $g_product_name in
  606. wave511 | wave517)
  607. set_decoder_option_w511;; #bwb, scaler, fbc
  608. wave521c | wave512 | wave515 | wave521c_dual)
  609. set_decoder_option_w512;; #bwb, afbce, scaler, fbc
  610. *) echo "Unknown product name: $g_product_name"
  611. exit 1;;
  612. esac
  613. fi
  614. }
  615. function set_encoder_option {
  616. set_rot_mir
  617. if [[ $g_product_name =~ coda9* ]]; then
  618. set_yuv_mode 2 #2:without packedformat
  619. g_maptype_index=$(gen_val 0 $(($g_maptype_num -1)) $maptype_temp)
  620. g_enable_linear2tiled=$(gen_val 0 1 $linear2tiled_temp)
  621. g_linebuf_int=$(gen_val 0 1 $linebuf_int_temp)
  622. g_bsmode=$(gen_val 0 1 $bsmode_temp)
  623. else
  624. if [ "$g_product_name" = "wave521c_dual" ]; then #constraint
  625. set_yuv_mode_dual 1 #nv12 and nv21 only
  626. else
  627. set_yuv_mode 6 #6:with packedFormat
  628. fi
  629. MODE_COMP_ENCODED=$(gen_val 0 1 $MODE_COMP_ENCODED_temp)
  630. g_lowLatencyMode=$(gen_val 0 3 $g_lowLatencyMode_temp) #bit[1]: low latency interrupt enable, bit[0]: fast bitstream-packing enable
  631. if [ "$g_product_name" = "wave521c_dual" ]; then #constraint
  632. g_srcFormat=$(gen_val 3 4 $srcFormat_temp)
  633. if [ "$g_srcFormat" == "1" ] || [ "$g_srcFormat" == "2" ]; then
  634. g_srcFormat=$(get_random 3 4)
  635. fi
  636. else
  637. g_srcFormat=$(gen_val 1 4 $srcFormat_temp)
  638. fi
  639. if [ $cfg_InputBitDepth == 8 ]; then
  640. g_srcFormat=0
  641. fi
  642. g_ringBuffer=$(gen_val 0 2 $g_ringBuffer_temp)
  643. g_cframe=$(gen_val 0 1 $g_cframe_temp)
  644. if [ "$g_cframe" == "1" ]; then
  645. if [ "$g_product_name" == "wave521" ] || [ "$g_product_name" == "wave521c" ]; then
  646. g_cframelossless=$(gen_val 0 1 $g_cframelossless_temp)
  647. if [ "$cfg_InputBitDepth" == "8" ]; then
  648. #32, 48, 64, 80, 96, 112
  649. g_cframetx16y=$(gen_val 2 7 $g_cframetx16y_temp)
  650. #32, 48, 64, 80, 96, 112
  651. g_cframetx16c=$(gen_val 2 7 $g_cframetx16c_temp)
  652. else
  653. #32, 48, 64, 80, 96, 112, 128, 144
  654. g_cframetx16y=$(gen_val 2 9 $g_cframetx16y_temp)
  655. #32, 48, 64, 80, 96, 112, 128, 144
  656. g_cframetx16c=$(gen_val 2 9 $g_cframetx16c_temp)
  657. fi
  658. if [ $g_cframetx16y -le 10 ]; then
  659. g_cframetx16y=$(($g_cframetx16y * 16))
  660. fi
  661. if [ $g_cframetx16c -le 10 ]; then
  662. g_cframetx16c=$(($g_cframetx16c * 16))
  663. fi
  664. fi
  665. if [ "$g_product_name" == "wave521" ] || [ "$g_product_name" == "wave521c" ]; then
  666. g_cframe_422=$(gen_val 0 1 $g_cframe_422_temp)
  667. fi
  668. fi
  669. g_subFrameSync=$(gen_val 0 1 $g_subFrameSync_temp)
  670. if [ "$g_product_name" = "wave521c_dual" ]; then
  671. g_rotAngle=0
  672. g_mirDir=0
  673. fi
  674. fi
  675. }
  676. #set common options - fpga(clk, latency) , secAxi, endian
  677. function set_common_option {
  678. set_min_max_param
  679. g_secondary_axi=$(gen_val 0 $MAX_SEC_AXI $secondary_axi_temp)
  680. g_stream_endian=$(gen_val $MIN_ENDIAN $MAX_ENDIAN $stream_endian_temp)
  681. g_frame_endian=$(gen_val $MIN_ENDIAN $MAX_ENDIAN $frame_endian_temp)
  682. g_source_endian=$(gen_val $MIN_ENDIAN $MAX_ENDIAN $source_endian_temp) #only for encoder
  683. }
  684. function get_default_option {
  685. g_secondary_axi=0
  686. g_stream_endian=0
  687. g_source_endian=0
  688. g_frame_endian=0
  689. g_bsmode=0
  690. g_cbcr_interleave=0
  691. g_enable_nv21=0
  692. g_rotAngle=0
  693. g_mirDir=0
  694. if [ $is_decoder -eq 1 ]; then
  695. g_enable_thumbnail=0
  696. g_enable_wtl=1
  697. g_wtl_format=0
  698. # CODA9 features
  699. g_enable_deblock=0
  700. g_enable_dering=0
  701. g_maptype_index=0
  702. if [[ $g_product_name =~ coda9* ]]; then
  703. g_enable_wtl=0;
  704. fi
  705. # END CODA9
  706. else
  707. g_subframe_sync=0
  708. g_lowLatencyMode=0
  709. g_packedFormat=0
  710. fi
  711. if [ "$codec" = "vp9" ]; then
  712. g_bsmode=2
  713. fi
  714. }
  715. function get_default_param {
  716. local is_decoder=$1
  717. local g_product_name=$2
  718. echo "default_opt=$default_opt"
  719. if [ "$default_opt" = "0" ]; then
  720. set_common_option
  721. if [ $is_decoder -eq 1 ]; then
  722. set_decoder_option
  723. else
  724. set_encoder_option
  725. fi
  726. else
  727. get_default_option
  728. fi
  729. }
  730. function gen_wtl_format {
  731. local default_val=$1
  732. local val
  733. # g_yuv_fmt_list variable should be defined in TestRunnerXXX.sh
  734. if [ -z "$default_val" ] || [ "$default_val" == "-99" ]; then
  735. while : ; do
  736. val=$(get_random 0 ${#g_yuv_fmt_list[@]}-1)
  737. if [ "${g_yuv_fmt_list[$val]}" != "RESERVED" ]; then
  738. break
  739. fi
  740. done
  741. else
  742. val=$default_val
  743. fi
  744. echo "$val"
  745. }
  746. function build_encoder_test_param {
  747. # ENCODER
  748. if [ "$MODE_COMP_ENCODED" == "1" ]; then param="${param} -c"; fi
  749. param="$param $param2"
  750. if [[ $g_product_name =~ coda9* ]]; then
  751. if [ $g_enable_linear2tiled -eq 1 ]; then
  752. param="$param --enable-linear2tiled"
  753. fi
  754. if [ $g_bsmode -eq 0 ]; then
  755. param="$param --enable-ringBuffer"
  756. else
  757. param="$param --enable-lineBufInt"
  758. fi
  759. if [ $g_cbcr_interleave -eq 1 ]; then
  760. param="$param --enable-cbcrInterleave"
  761. if [ $g_enable_nv21 -eq 1 ]; then
  762. param="$param --enable-nv21"
  763. fi
  764. fi
  765. param="$param --rotate=$g_rotAngle"
  766. param="$param --mirror=$g_mirDir"
  767. else
  768. ### WAVE5xx ###
  769. param="$param --codec=$g_codec_index"
  770. param="$param --source-endian=$g_source_endian"
  771. param="$param --rotAngle=${g_rotAngle} --mirDir=${g_mirDir}"
  772. if [ "$g_cframe" == "1" ] && [ "$g_rotAngle" == "0" ] && [ "$g_mirDir" == "0" ]; then
  773. if [ "$g_product_name" == "wave521" ] || [ "$g_product_name" == "wave521c" ]; then
  774. param="${param} --cframe50Enable=1 --cframe50Lossless=$g_cframelossless --cframe50Tx16Y=$g_cframetx16y --cframe50Tx16C=$g_cframetx16c --cframe50_422=$g_cframe_422"
  775. fi
  776. if [ $cfg_InputBitDepth == 8 ]; then
  777. param="${param} --srcFormat=0"
  778. else
  779. param="${param} --srcFormat=${g_srcFormat}"
  780. fi
  781. else
  782. if [ $cfg_InputBitDepth == 8 ]; then
  783. param="${param} --srcFormat=0"
  784. else
  785. param="${param} --srcFormat=${g_srcFormat}"
  786. fi
  787. if [ $g_packedFormat -ne 0 ]; then
  788. param="${param} --packedFormat=${g_packedFormat}"
  789. elif [ "$g_enable_nv21" == "0" ] && [ "$g_cbcr_interleave" == "1" ]; then
  790. param="${param} --enable-cbcrInterleave --nv21=${g_enable_nv21}"
  791. elif [ "$g_enable_nv21" == "1" ] && [ "$g_cbcr_interleave" == "1" ]; then
  792. param="${param} --enable-cbcrInterleave --nv21=${g_enable_nv21}"
  793. fi
  794. fi
  795. if [[ $g_product_name =~ wave5* ]]; then
  796. param="${param} --lowLatencyMode=${g_lowLatencyMode}"
  797. fi
  798. if [ "$g_subFrameSync" == "1" ]; then
  799. param="${param} --subFrameSyncEn=${g_subFrameSync}"
  800. fi
  801. fi
  802. }
  803. function build_decoder_test_param {
  804. if [ "$g_match_mode" == "3" ]; then
  805. param="$param -c 0"
  806. else
  807. param="$param -c $g_match_mode"
  808. fi
  809. param="$param --render 0"
  810. param="$param --codec $g_codec_index"
  811. # CODA9 features.
  812. if [ $g_codec_index -eq 3 ]; then
  813. param="$param --mp4class=$g_mp4class"
  814. fi
  815. if [ $g_enable_deblock -eq 1 ]; then
  816. param="$param --enable-deblock"
  817. fi
  818. if [ $g_enable_mvc -eq 1 ]; then
  819. param="$param --enable-mvc"
  820. fi
  821. # END and CODA9
  822. param="$param $param2"
  823. if [ $g_bsmode -gt 0 ]; then
  824. param="$param --bsmode=$g_bsmode"
  825. fi
  826. if [ $g_enable_thumbnail -eq 1 ]; then
  827. param="$param --enable-thumbnail"
  828. fi
  829. if [ $g_cbcr_interleave -eq 1 ]; then
  830. param="$param --enable-cbcrinterleave"
  831. if [ $g_enable_nv21 -eq 1 ]; then
  832. param="$param --enable-nv21"
  833. fi
  834. fi
  835. if [[ $g_product_name =~ coda9* ]]; then
  836. if [ $g_enable_dering -eq 1 ]; then
  837. param="$param --enable-dering"
  838. fi
  839. if [ $g_enable_wtl -eq 0 ] && [ $g_maptype_index -gt 0 ]; then
  840. param="$param --disable-wtl"
  841. fi
  842. if [ $g_enable_tiled2linear -eq 1 ]; then
  843. param="$param --enable-tiled2linear"
  844. fi
  845. if [ $g_rotAngle -gt 0 ]; then
  846. param="$param --rotate=$g_rotAngle"
  847. fi
  848. if [ $g_mirDir -gt 0 ]; then
  849. param="$param --mirror=$g_mirDir"
  850. fi
  851. else
  852. if [ $g_enable_wtl -eq 0 ]; then
  853. param="${param} --disable-wtl"
  854. else
  855. param="${param} --wtl-format=$g_wtl_format"
  856. if [ $g_bw_opt -eq 1 ]; then
  857. param="${param} --bwopt=1"
  858. fi
  859. fi
  860. if [ "$g_pvric" == "1" ] || [ "$g_pvric" == "2" ]; then
  861. param="$param --pvric=$g_pvric"
  862. param="$param --ifbc_pad_y=$g_ifbc_pad_y"
  863. param="$param --ifbc_pad_c=$g_ifbc_pad_c"
  864. fi
  865. fi
  866. if [ $g_scaler == "true" ]; then
  867. param="$param --sclw=$g_sclw --sclh=$g_sclh"
  868. fi
  869. }
  870. function build_test_param {
  871. local is_decoder=$1
  872. local param=""
  873. local param2=""
  874. if [[ $g_product_name =~ coda9* ]]; then
  875. if [ $g_maptype_index -gt 0 ]; then
  876. param2="$param2 --maptype=$g_maptype_index"
  877. fi
  878. else
  879. if [ "$g_fbc_mode" == "" ]; then
  880. pram="$param --fbc-mode=0x0c"
  881. else
  882. param="$param --fbc-mode=$g_fbc_mode"
  883. fi
  884. fi
  885. param2="$param2 --stream-endian=$g_stream_endian"
  886. param2="$param2 --frame-endian=$g_frame_endian"
  887. param2="$param2 --secondary-axi=$g_secondary_axi"
  888. if [ $is_decoder -eq 1 ]; then
  889. build_decoder_test_param
  890. else
  891. build_encoder_test_param
  892. fi
  893. g_func_ret_str="$param"
  894. }
  895. function get_random_param {
  896. default_opt=0
  897. aclk_freq_temp=-99
  898. bclk_freq_temp=-99
  899. cclk_freq_temp=-99
  900. read_latency_temp=-99
  901. write_latency_temp=-99
  902. secondary_axi_temp=-99
  903. stream_endian_temp=-99
  904. frame_endian_temp=-99
  905. source_endian_temp=-99
  906. g_maptype_index_temp=-99 #coda960 & coda980
  907. g_yuv_mode_temp=-99
  908. if [ $is_decoder -eq 1 ]; then
  909. bsmode_temp=-99
  910. deblock_temp=-99
  911. dering_temp=-99
  912. rotAngle_temp=-99
  913. mirDir_temp=-99
  914. maptype_temp=-99
  915. wtl_format_temp=-99
  916. g_bw_opt_temp=-99
  917. else
  918. rotAngle_temp=-99
  919. mirDir_temp=-99
  920. if [[ $g_product_name =~ coda9* ]]; then
  921. maptype_temp=-99
  922. linear2tiled_temp=-99
  923. linebuf_int_temp=-99
  924. bsmode_temp=-99
  925. else
  926. lowLatencyMode_temp=-99
  927. fi
  928. fi
  929. if [ "$g_product_name" = "wave512" ] || [ "$g_product_name" = "wave515" ] || [ "$g_product_name" = "wave511" ] || [ "$g_product_name" = "wave517" ]; then
  930. g_output_hw_temp=-99
  931. fi
  932. get_default_param $1 $2
  933. g_func_ret_str="$param"
  934. }
  935. function run_refc_scaler {
  936. local input_path=$1
  937. local output_path=$2
  938. local fmt=$3
  939. if [ -e $output_path ]; then
  940. rm ${output_path}
  941. fi
  942. is_422=0
  943. case $fmt in
  944. FORMAT_420)
  945. mode_index=0
  946. ;;
  947. FORMAT_422)
  948. mode_index=0
  949. is_422=1
  950. ;;
  951. FORMAT_422_P10_16BIT_MSB)
  952. mode_index=1
  953. is_422=1
  954. ;;
  955. FORMAT_422_P10_16BIT_LSB)
  956. mode_index=1
  957. is_422=1
  958. ;;
  959. FORMAT_422_P10_32BIT_MSB)
  960. mode_index=1
  961. is_422=1
  962. ;;
  963. FORMAT_422_P10_32BIT_LSB)
  964. mode_index=1
  965. is_422=1
  966. ;;
  967. *)
  968. mode_index=1
  969. ;;
  970. esac
  971. scaler_options="-i $input_path -x $g_oriw -y $g_orih -o $output_path -a $g_sclw -b $g_sclh -n 0"
  972. if [ $mode_index -eq 0 ]; then
  973. # refc output 8bit
  974. if [ "$is_main10" == "1" ]; then
  975. scaler_options="$scaler_options -g 2 -h 0"
  976. else
  977. scaler_options="$scaler_options -g 0 -h 0"
  978. fi
  979. else
  980. # refc output 10bit
  981. scaler_options="$scaler_options -g 2 -h 1"
  982. fi
  983. str_cmd="${bin_dir}/scaler ${scaler_options}"
  984. echo "${str_cmd}"
  985. ${str_cmd}
  986. return $?
  987. }
  988. function run_refc_dec_av1 {
  989. local stream_path="$1"
  990. local output_path="$2"
  991. local wtl_mode_index=0
  992. local skip_option=0
  993. local max_frames=""
  994. local output_param=""
  995. local file_ext=${stream_path##*.}
  996. local stream_format_param="--ivf"
  997. if [ "$file_ext" = "obu" ]; then
  998. stream_format_param="--annexb"
  999. elif [ "$file_ext" = "av1" ]; then
  1000. stream_format_param=""
  1001. fi
  1002. if [ $g_enable_thumbnail -eq 1 ]; then
  1003. skip_option=1
  1004. fi
  1005. output_param="-o $output_path"
  1006. if [ $g_match_mode -eq 2 ]; then
  1007. if [ $wtl_mode_index -ne 5 ]; then
  1008. wtl_mode_index=1
  1009. fi
  1010. if [ $is_main10 -eq 1 ] && [ $g_enable_wtl -eq 0 ]; then
  1011. wtl_mode_index=1
  1012. fi
  1013. str_opt="--codec av1_dec -i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
  1014. elif [ $g_match_mode -eq 3 ]; then
  1015. if [ $g_wtl_format -eq 7 ] || [ $g_wtl_format -eq 8] ; then
  1016. wtl_mode_index=5
  1017. fi
  1018. str_opt="--codec av1_dec -i ${stream_path} $ref_stream_format_option -c -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
  1019. else
  1020. str_opt="--codec av1_dec -i ${stream_path} -c -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
  1021. fi
  1022. str_cmd="${bin_dir}/av1_dec ${str_opt} --sbs 46080 $stream_format_param"
  1023. echo "${str_cmd}"
  1024. ${str_cmd}
  1025. if [ "$?" != "0" ]; then
  1026. echo "Failed to ref-c"
  1027. return 1;
  1028. fi
  1029. return 0
  1030. }
  1031. function run_refc_dec_h265 {
  1032. local stream_path="$1"
  1033. local output_path="$2"
  1034. local wtl_mode_index=0
  1035. local skip_option=0
  1036. local max_frames=""
  1037. local output_param=""
  1038. local file_ext=${stream_path##*.}
  1039. if [ "$file_ext" = "mp4" ] || [ "$file_ext" = "mkv" ] || [ "$file_ext" = "avi" ]; then
  1040. cp ${bin_dir}/../../../util/bin/Linux/vcp ${bin_dir} || echo ingore_err
  1041. ${bin_dir}/vcp -i $stream_path output.bin
  1042. stream_path="output.bin"
  1043. fi
  1044. if [ $g_enable_thumbnail -eq 1 ]; then
  1045. skip_option=1
  1046. fi
  1047. if [ "$g_scaler" == "true" ]; then
  1048. scale_output_path="$output_path"
  1049. output_path="output_orig.yuv"
  1050. fi
  1051. output_param="-o $output_path"
  1052. if [ $g_match_mode -eq 2 ]; then
  1053. if [ $wtl_mode_index -ne 5 ]; then
  1054. wtl_mode_index=1
  1055. fi
  1056. if [ $is_main10 -eq 1 ] && [ $g_enable_wtl -eq 0 ]; then
  1057. wtl_mode_index=1
  1058. fi
  1059. str_opt="-i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
  1060. else
  1061. local cmodel_wtl_mode=$wtl_mode_index
  1062. if [ $g_scaler == "true" ]; then
  1063. if [ "$is_main10" == "1" ]; then
  1064. wtl_mode_index=5
  1065. fi
  1066. fi
  1067. str_opt="-i ${stream_path} -c -y ${wtl_mode_index} ${output_param} ${max_frames} $g_refc_frame_num"
  1068. fi
  1069. str_cmd="${bin_dir}/hevc_dec ${str_opt} --sbs 46080"
  1070. echo "${str_cmd}"
  1071. ${str_cmd}
  1072. if [ "$?" != "0" ]; then
  1073. echo "Failed to ref-c"
  1074. return 1;
  1075. fi
  1076. if [ $g_scaler == "true" ]; then
  1077. local fmt_name="${g_yuv_fmt_list[$g_wtl_format]}"
  1078. run_refc_scaler "output_orig.yuv" "${scale_output_path}" "$fmt_name"
  1079. if [ "$?" != "0" ]; then
  1080. echo "Failed to ref-c"
  1081. return 1;
  1082. fi
  1083. fi
  1084. return 0
  1085. }
  1086. function run_refc_dec_vp9 {
  1087. local stream_path="$1"
  1088. local output_path="$2"
  1089. local arg_cci=""
  1090. local wtl_mode_index=0
  1091. local max_frames=""
  1092. # VP9 refc only support wtl_format 0 and 5
  1093. if [ $g_wtl_format -eq 0 ]; then
  1094. wtl_mode_index=0;
  1095. elif [ $g_wtl_format -eq 1 ]; then
  1096. wtl_mode_index=0;
  1097. elif [ $g_wtl_format -eq 13 ]; then
  1098. wtl_mode_index=0;
  1099. elif [ $g_wtl_format -eq 18 ]; then
  1100. wtl_mode_index=0;
  1101. elif [ $g_wtl_format -eq 23 ]; then
  1102. wtl_mode_index=0;
  1103. elif [ $g_wtl_format -eq 28 ]; then
  1104. wtl_mode_index=0;
  1105. else
  1106. wtl_mode_index=5;
  1107. fi
  1108. if [ $g_match_mode -eq 2 ]; then
  1109. if [ $wtl_mode_index -ne 0 ]; then
  1110. wtl_mode_index=5 # 16BIT MSB
  1111. fi
  1112. param="--input=${stream_path} --outmd5=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian --bsmode=$g_bsmode"
  1113. else
  1114. if [ $g_scaler == "true" ]; then
  1115. param="--input=${stream_path} --output=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian --bsmode=$g_bsmode --sclw $g_sclw --sclh $g_sclh"
  1116. else
  1117. param="--input=${stream_path} --output=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian --bsmode=$g_bsmode"
  1118. fi
  1119. fi
  1120. param="$param $g_frame_num "
  1121. if [ $g_bsmode -gt 0 ]; then
  1122. param="$param --bsmode=$g_bsmode"
  1123. fi
  1124. if [ $g_enable_thumbnail -eq 1 ]; then
  1125. param="$param --enable-thumbnail"
  1126. fi
  1127. if [ $g_enable_wtl -eq 0 ]; then
  1128. param="${param} --disable-wtl"
  1129. else
  1130. if [ "$g_product_name" = "wave512" ] || [ "$g_product_name" = "wave515" ] || [ "$g_product_name" = "wave511" ] || [ "$g_product_name" = "wave517" ]; then
  1131. param="${param} --wtl-format=${wtl_mode_index}"
  1132. else
  1133. param="${param} --wtl-format=$g_wtl_format"
  1134. fi
  1135. fi
  1136. if [ $g_cbcr_interleave -eq 1 ]; then
  1137. param="${param} --enable-cbcrinterleave"
  1138. if [ $g_enable_nv21 -eq 1 ]; then
  1139. param="${param} --enable-nv21"
  1140. fi
  1141. fi
  1142. str_cmd="${bin_dir}/vp9_dec_bwb ${param}"
  1143. if [ $g_scaler == "true" ]; then
  1144. str_cmd="${bin_dir}/vp9_dec_scaler ${param}"
  1145. fi
  1146. echo "${str_cmd}"
  1147. ${str_cmd}
  1148. if [ "$?" != "0" ]; then
  1149. echo "Failed to ref-c"
  1150. return 1;
  1151. fi
  1152. return 0
  1153. }
  1154. function run_refc_dec_avs2 {
  1155. local stream_path="$1"
  1156. local output_path="$2"
  1157. local wtl_mode_index=0
  1158. # AVS2 refc only support wtl_format 0 and 5
  1159. if [ $g_wtl_format -eq 0 ]; then
  1160. wtl_mode_index=0;
  1161. elif [ $g_wtl_format -eq 1 ]; then
  1162. wtl_mode_index=0;
  1163. elif [ $g_wtl_format -eq 13 ]; then
  1164. wtl_mode_index=0;
  1165. elif [ $g_wtl_format -eq 18 ]; then
  1166. wtl_mode_index=0;
  1167. elif [ $g_wtl_format -eq 23 ]; then
  1168. wtl_mode_index=0;
  1169. elif [ $g_wtl_format -eq 28 ]; then
  1170. wtl_mode_index=0;
  1171. else
  1172. wtl_mode_index=5;
  1173. fi
  1174. if [ $g_match_mode -eq 2 ]; then
  1175. if [ $wtl_mode_index -ne 0 ]; then
  1176. wtl_mode_index=5 # 16BIT MSB
  1177. fi
  1178. param="--input=${stream_path} --outmd5=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian"
  1179. else
  1180. param="--input=${stream_path} --output=${output_path} --render 0 --codec $g_codec_index --stream-endian=$g_stream_endian --frame-endian=$g_frame_endian"
  1181. fi
  1182. param="$param $g_frame_num "
  1183. if [ $g_enable_wtl -eq 0 ]; then
  1184. param="${param} --disable-wtl"
  1185. else
  1186. if [ $g_scaler == "true" ] && [ $is_main10 -eq 1 ]; then
  1187. param="${param} --wtl-format=5"
  1188. else
  1189. param="${param} --wtl-format=${wtl_mode_index}"
  1190. fi
  1191. fi
  1192. if [ $g_cbcr_interleave -eq 1 ]; then
  1193. param="${param} --enable-cbcrinterleave"
  1194. if [ $g_enable_nv21 -eq 1 ]; then
  1195. param="${param} --enable-nv21"
  1196. fi
  1197. fi
  1198. if [ $g_enable_thumbnail -eq 1 ]; then
  1199. param="$param --enable-thumbnail"
  1200. fi
  1201. str_cmd="${bin_dir}/avs2_dec_bwb ${param}"
  1202. echo "${str_cmd}"
  1203. ${str_cmd}
  1204. if [ "$?" != "0" ]; then
  1205. echo "Failed to ref-c"
  1206. return 1;
  1207. fi
  1208. if [ $g_scaler == "true" ]; then
  1209. if [ -z "$is_main10" ]; then
  1210. is_main10="0"
  1211. fi
  1212. run_refc_scaler "scaler_input.yuv" "${output_path}" "$g_wtl_format"
  1213. if [ "$?" != "0" ]; then
  1214. echo "Failed to ref-c"
  1215. return 1;
  1216. fi
  1217. fi
  1218. return 0
  1219. }
  1220. function run_refc_dec_svac {
  1221. local stream_path="$1"
  1222. local output_path="$2"
  1223. local wtl_mode_index=0
  1224. local output_param=""
  1225. local file_ext=${stream_path##*.}
  1226. if [ "$file_ext" = "mp4" ] || [ "$file_ext" = "mkv" ] || [ "$file_ext" = "avi" ]; then
  1227. cp ${bin_dir}/../../../util/bin/Linux/vcp ${bin_dir} || echo ingore_err
  1228. ${bin_dir}/vcp -i $stream_path output.bin
  1229. stream_path="output.bin"
  1230. fi
  1231. # Not implemented yet
  1232. if [ $g_enable_thumbnail -eq 1 ]; then
  1233. skip_option=1
  1234. fi
  1235. case $g_wtl_format in
  1236. 0) # 8BIT 420
  1237. wtl_mode_index=0;;
  1238. 5) # 16bit MSB
  1239. wtl_mode_index=1;;
  1240. 6) # 16bit LSB
  1241. wtl_mode_index=5;;
  1242. 7) # 32bit MSB
  1243. wtl_mode_index=2;;
  1244. 8) # 32bit LSB
  1245. wtl_mode_index=6;;
  1246. *) echo "Not supported WTL format: $g_wtl_format"
  1247. exit 1
  1248. esac
  1249. output_param="-o $output_path"
  1250. if [ $g_match_mode -eq 2 ]; then
  1251. if [ $wtl_mode_index -ne 0 ]; then
  1252. wtl_mode_index=1
  1253. fi
  1254. str_opt="-i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param}"
  1255. else
  1256. str_opt="-i ${stream_path} -c -y ${wtl_mode_index} ${output_param}"
  1257. fi
  1258. str_cmd="${bin_dir}/svac_dec ${str_opt}"
  1259. echo "${str_cmd}"
  1260. ${str_cmd}
  1261. if [ "$?" != "0" ]; then
  1262. echo "Failed to ref-c"
  1263. return 1;
  1264. fi
  1265. return 0
  1266. }
  1267. function run_refc_dec_avc {
  1268. local stream_path="$1"
  1269. local output_path="$2"
  1270. local wtl_mode_index=0
  1271. local output_param=""
  1272. local file_ext=${stream_path##*.}
  1273. if [ "$file_ext" = "mp4" ] || [ "$file_ext" = "mkv" ] || [ "$file_ext" = "avi" ]; then
  1274. cp ${bin_dir}/../../../util/bin/Linux/vcp ${bin_dir} || echo ingore_err
  1275. ${bin_dir}/vcp -i $stream_path output.bin
  1276. stream_path="output.bin"
  1277. fi
  1278. # Not implemented yet
  1279. if [ $g_enable_thumbnail -eq 1 ]; then
  1280. skip_option=1
  1281. fi
  1282. output_param="-o $output_path"
  1283. if [ "$g_scaler" == "true" ]; then
  1284. output_param="-o output_orig.yuv"
  1285. fi
  1286. if [ $g_match_mode -eq 2 ]; then
  1287. if [ $wtl_mode_index -ne 5 ]; then
  1288. wtl_mode_index=1
  1289. fi
  1290. if [ $is_main10 -eq 1 ] && [ $g_enable_wtl -eq 0 ]; then
  1291. wtl_mode_index=1
  1292. fi
  1293. str_opt="--codec avc_dec -i ${stream_path} -c -5 -y ${wtl_mode_index} ${output_param}"
  1294. else
  1295. if [ "$g_scaler" == "true" ]; then
  1296. if [ "$is_main10" == "1" ]; then
  1297. wtl_mode_index=5
  1298. fi
  1299. fi
  1300. str_opt="--codec avc_dec -i ${stream_path} -c -y ${wtl_mode_index} ${output_param}"
  1301. fi
  1302. str_cmd="${bin_dir}/avc_dec ${str_opt}"
  1303. echo "${str_cmd}"
  1304. ${str_cmd}
  1305. if [ "$?" != "0" ]; then
  1306. echo "Failed to ref-c"
  1307. return 1;
  1308. fi
  1309. if [ $g_scaler == "true" ]; then
  1310. local fmt_name="${g_yuv_fmt_list[$g_wtl_format]}"
  1311. run_refc_scaler "output_orig.yuv" "${output_path}" "$fmt_name"
  1312. if [ "$?" != "0" ]; then
  1313. echo "Failed to ref-c"
  1314. return 1;
  1315. fi
  1316. fi
  1317. return 0
  1318. }
  1319. function run_refc_dec_coda9 {
  1320. local stream_path=$1
  1321. local output_yuv=$2
  1322. local ext=${stream_path##*.}
  1323. if [ "$ext" = "rmvb" ]; then
  1324. stream_path=${stream_path%.*}.rvf
  1325. fi
  1326. cmodel_param="-i $stream_path -o $output_yuv"
  1327. ext_param=""
  1328. shopt -s nocasematch
  1329. case "$codec" in
  1330. avc) if [ $g_enable_mvc -eq 1 ]; then
  1331. cmodel="RefMvcDec"
  1332. else
  1333. cmodel="RefAvcDec"
  1334. fi
  1335. ;;
  1336. vc1) cmodel="RefVc1Dec";;
  1337. mp2) cmodel="RefMp2Dec";;
  1338. mp4) cmodel="RefMp4Dec"
  1339. cmodel_param="$cmodel_param -s $g_mp4class";;
  1340. avs) cmodel="RefAvsDec";;
  1341. dv3) cmodel="RefDivDec"
  1342. cmodel_param="$cmodel_param -E host_div3_rtl_cmd.org"
  1343. if [ "$ext" = "ivf" ]; then
  1344. ext_param="-v"
  1345. fi
  1346. ;;
  1347. rvx) cmodel="RefRvxDec";;
  1348. vp8) cmodel="RefVpxDec"
  1349. cmodel_param="$cmodel_param --std 2";;
  1350. tho) cmodel="RefThoDec"
  1351. cmodel_param="$cmodel_param --make_stream --stream_filename temp/host_tho_rtl_cmd.org --stream_endian $g_stream_endian";;
  1352. *) echo ""; return;;
  1353. esac
  1354. shopt -u nocasematch
  1355. ppu_option=0
  1356. if [ $g_match_mode -eq 1 ]; then
  1357. if [ $g_rotAngle -ne 0 ]; then
  1358. local index=$(($g_rotAngle/90))
  1359. ppu_option=$((0x10 | $index))
  1360. fi
  1361. if [ $g_mirDir -ne 0 ]; then
  1362. ppu_option=$(($ppu_option | 0x10 | ($g_mirDir<<2)))
  1363. fi
  1364. if [ $ppu_option -gt 0 ]; then
  1365. cmodel_param="$cmodel_param -g $ppu_option"
  1366. fi
  1367. fi
  1368. if [ $g_enable_dering -eq 1 ]; then
  1369. cmodel_param="$cmodel_param -p"
  1370. fi
  1371. if [ $g_enable_deblock -eq 1 ]; then
  1372. cmodel_param="$cmodel_param -d"
  1373. fi
  1374. exec_cmd="${bin_dir}/$cmodel $cmodel_param -l $ext_param -c"
  1375. echo "$exec_cmd"
  1376. $exec_cmd
  1377. return $?
  1378. }
  1379. function run_refc_enc_coda9 {
  1380. local val=0
  1381. local input=$1
  1382. local output=$2
  1383. local postfix=""
  1384. if [ "$g_product_name" = "coda980" ]; then
  1385. postfix="_980_rev"
  1386. fi
  1387. refc_exe="$bin_dir"
  1388. case $codec in
  1389. avc)
  1390. if [ $g_enable_mvc -eq 0 ]; then
  1391. refc_exe="$refc_exe/RefAvcEnc$postfix"
  1392. else
  1393. refc_exe="$refc_exe/RefMvcEnc$postfix"
  1394. fi
  1395. ;;
  1396. mp4)
  1397. refc_exe="$refc_exe/RefMp4Enc$postfix" ;;
  1398. *)
  1399. echo "run_refc_enc: Unknown codec $codec"
  1400. return 1;;
  1401. esac
  1402. refc_param="-i $input -o $output -p $yuv_dir/"
  1403. val=$(($g_rotAngle/90))
  1404. val=$(($val | ($g_mirDir<<2)))
  1405. if [ $val -ne 0 ]; then
  1406. refc_param="$refc_param -g $val"
  1407. fi
  1408. refc_param=$(echo $refc_param | sed -e 's/\\/\//g')
  1409. cmd="$refc_exe $refc_param"
  1410. echo $cmd
  1411. echo ""
  1412. $cmd
  1413. return $?
  1414. }
  1415. function generate_golden_data_path {
  1416. local codec=$1
  1417. local streamset=$2
  1418. local streamfile=$3
  1419. local layer=$4
  1420. codec_dir=""
  1421. shopt -s nocasematch
  1422. case "$codec" in
  1423. vp9) codec_dir="vp9dec";;
  1424. hevc) codec_dir="hvcdec";;
  1425. avc) codec_dir="avcdec";;
  1426. vc1) codec_dir="vc1dec";;
  1427. mp2) codec_dir="mp2dec";;
  1428. mp4) codec_dir="mp4dec";;
  1429. h263) codec_dir="mp4dec";;
  1430. avs) codec_dir="avsdec";;
  1431. dv3) codec_dir="dv3dec";;
  1432. rvx) codec_dir="rvxdec";;
  1433. vp8) codec_dir="vp8dec";;
  1434. tho) codec_dir="thodec";;
  1435. avs2) codec_dir="avs2dec";;
  1436. av1) codec_dir="av1dec";;
  1437. *) codec_dir="";;
  1438. esac
  1439. shopt -u nocasematch
  1440. if [ "$is_main10" = "" ]; then is_main10=0; fi
  1441. yuvext=""
  1442. if [ "$g_enable_wtl" == "1" ]; then
  1443. case "$codec" in
  1444. hevc | vp9 | avs2 | svac | avc | av1 )
  1445. if [ $is_main10 -eq 1 ]; then
  1446. if [ $g_wtl_format -eq 0 ]; then
  1447. yuvext="_bwb_8"
  1448. elif [ $g_wtl_format -eq 1 ]; then
  1449. # FORMAT_422
  1450. yuvext="_422_8"
  1451. elif [ $g_wtl_format -gt 8 ] && [ $g_wtl_format -lt 13 ]; then
  1452. # FORMAT_422_16BIT_XXX
  1453. yuvext="_422"
  1454. elif [ $g_wtl_format -ge 13 ] && [ $g_wtl_format -le 17 ]; then
  1455. if [ $g_wtl_format -eq 13 ]; then
  1456. yuvext="_yuyv_8"
  1457. else
  1458. yuvext="_yuyv"
  1459. fi
  1460. elif [ $g_wtl_format -ge 18 ] && [ $g_wtl_format -le 22 ]; then
  1461. if [ $g_wtl_format -eq 18 ]; then
  1462. yuvext="_yvyu_8"
  1463. else
  1464. yuvext="_yvyu"
  1465. fi
  1466. elif [ $g_wtl_format -ge 23 ] && [ $g_wtl_format -le 27 ]; then
  1467. if [ $g_wtl_format -eq 23 ]; then
  1468. yuvext="_uyvy_8"
  1469. else
  1470. yuvext="_uyvy"
  1471. fi
  1472. elif [ $g_wtl_format -ge 28 ] && [ $g_wtl_format -le 32 ]; then
  1473. if [ $g_wtl_format -eq 28 ]; then
  1474. yuvext="_vyuy_8"
  1475. else
  1476. yuvext="_vyuy"
  1477. fi
  1478. fi
  1479. else
  1480. if [ $g_wtl_format -eq 1 ]; then
  1481. yuvext="_422_8"
  1482. elif [ $g_wtl_format -eq 13 ]; then
  1483. yuvext="_yuyv_8"
  1484. elif [ $g_wtl_format -eq 18 ]; then
  1485. yuvext="_yvyu_8"
  1486. elif [ $g_wtl_format -eq 23 ]; then
  1487. yuvext="_uyvy_8"
  1488. elif [ $g_wtl_format -eq 28 ]; then
  1489. yuvext="_vyuy_8"
  1490. fi
  1491. fi
  1492. ;;
  1493. *)
  1494. ;;
  1495. esac
  1496. elif [ $g_afbce -eq 1 ]; then
  1497. case "$codec" in
  1498. hevc | vp9)
  1499. if [ $is_main10 -eq 1 ]; then
  1500. yuvext="_bwb_8"
  1501. fi
  1502. esac
  1503. fi
  1504. # CODA9xx & CODA7x features
  1505. local dering_str=""
  1506. if [ $g_enable_dering -eq 1 ]; then
  1507. dering_str="_dr"
  1508. fi
  1509. local deblk_str=""
  1510. if [ $g_enable_deblock -eq 1 ]; then
  1511. deblk_str="_dbk"
  1512. fi
  1513. # END CODA9xx & CODA7x
  1514. streamset_name=$(basename $streamset)
  1515. filename=$(basename $streamfile)
  1516. local target_base="$yuv_dir/$codec_dir"
  1517. local target_path=""
  1518. thumbnail_ext=""
  1519. if [ $g_enable_thumbnail -eq 1 ]; then
  1520. thumbnail_ext="_thumb"
  1521. fi
  1522. local wtl_format_ext=""
  1523. case $g_wtl_format in
  1524. 0) wtl_format_ext="";;
  1525. 5) wtl_format_ext="_16bit_msb";;
  1526. 6) wtl_format_ext="_16bit_lsb";;
  1527. 7) wtl_format_ext="_32bit_msb";;
  1528. 8) wtl_format_ext="_32bit_lsb";;
  1529. esac
  1530. local rot_index=0
  1531. if [ $g_rotAngle -eq 0 ] && [ $g_mirDir -eq 0 ]; then
  1532. rot_index=0
  1533. fi
  1534. if [ $g_rotAngle -eq 180 ] && [ $g_mirDir -eq 3 ]; then
  1535. rot_index=0
  1536. fi
  1537. if [ $g_rotAngle -eq 90 ] && [ $g_mirDir -eq 0 ]; then
  1538. rot_index=1
  1539. fi
  1540. if [ $g_rotAngle -eq 270 ] && [ $g_mirDir -eq 3 ]; then
  1541. rot_index=1
  1542. fi
  1543. if [ $g_rotAngle -eq 180 ] && [ $g_mirDir -eq 0 ]; then
  1544. rot_index=2
  1545. fi
  1546. if [ $g_rotAngle -eq 0 ] && [ $g_mirDir -eq 3 ]; then
  1547. rot_index=2
  1548. fi
  1549. if [ $g_rotAngle -eq 270 ] && [ $g_mirDir -eq 0 ]; then
  1550. rot_index=3
  1551. fi
  1552. if [ $g_rotAngle -eq 90 ] && [ $g_mirDir -eq 3 ]; then
  1553. rot_index=3
  1554. fi
  1555. if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 0 ]; then
  1556. rot_index=4
  1557. fi
  1558. if [ $g_rotAngle -eq 180 ] && [ $g_mirDir -eq 2 ]; then
  1559. rot_index=4
  1560. fi
  1561. if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 90 ]; then
  1562. rot_index=5
  1563. fi
  1564. if [ $g_mirDir -eq 2 ] && [ $g_rotAngle -eq 270 ]; then
  1565. rot_index=5
  1566. fi
  1567. if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 180 ]; then
  1568. rot_index=6
  1569. fi
  1570. if [ $g_mirDir -eq 2 ] && [ $g_rotAngle -eq 0 ]; then
  1571. rot_index=6
  1572. fi
  1573. if [ $g_mirDir -eq 1 ] && [ $g_rotAngle -eq 270 ]; then
  1574. rot_index=7
  1575. fi
  1576. if [ $g_mirDir -eq 2 ] && [ $g_rotAngle -eq 90 ]; then
  1577. rot_index=7
  1578. fi
  1579. local target_ext="yuv"
  1580. svac_layer_name=""
  1581. if [ "$layer" == "1" ]; then
  1582. svac_layer_name="_BL"
  1583. elif [ "$layer" == "2" ]; then
  1584. svac_layer_name="_EL"
  1585. fi
  1586. if [ "$streamset_name" = "" ]; then
  1587. target_path="${target_base}/${filename}${wtl_format_ext}${deblk_str}${thumbnail_ext}${yuvext}_${rot_index}${svac_layer_name}.$target_ext"
  1588. else
  1589. # ex) xxxx_01.cmd -> xxxx.cmd
  1590. temp=`expr match "$streamset_name" '.*\(_[0-9]*\.cmd\)'`
  1591. if [ "$temp" != "" ]; then
  1592. streamset_name="${streamset_name%_[0-9]*\.cmd}.cmd"
  1593. fi
  1594. target_base="${target_base}/${streamset_name}"
  1595. target_path="${target_base}/${filename}${wtl_format_ext}${deblk_str}${dering_str}${thumbnail_ext}${yuvext}_${rot_index}${svac_layer_name}.$target_ext"
  1596. fi
  1597. if [ ! -d $target_base ]; then
  1598. mkdir -p $target_base
  1599. fi
  1600. g_func_ret_str="$target_path"
  1601. }
  1602. # execute the ref-c program to get the decoded image or md5
  1603. # generate_yuv(stream_path, output_yuv_path)
  1604. function generate_yuv {
  1605. local src=$1
  1606. local output=$2
  1607. case "$codec" in
  1608. av1)
  1609. echo "run_refc_dec_av1 $src $output"
  1610. run_refc_dec_av1 $src $output;;
  1611. vp9)
  1612. echo "run_refc_dec_vp9 $src $output"
  1613. run_refc_dec_vp9 $src $output;;
  1614. hevc)
  1615. echo "run_refc_dec_h265 $src $output"
  1616. run_refc_dec_h265 $src $output;;
  1617. avs2)
  1618. echo "run_refc_dec_avs2 $src $output"
  1619. run_refc_dec_avs2 $src $output;;
  1620. svac)
  1621. echo "run_refc_dec_svac $src $output"
  1622. run_refc_dec_svac $src $output;;
  1623. avc)
  1624. if [[ $g_product_name =~ coda9* ]]; then
  1625. echo "run_refc_dec_coda9 $src $output $codec"
  1626. run_refc_dec_coda9 $src $output $codec
  1627. else
  1628. echo "run_refc_dec_avc $src $output"
  1629. run_refc_dec_avc $src $output
  1630. fi
  1631. ;;
  1632. *)
  1633. echo "run_refc_dec_coda9 $src $output $codec"
  1634. run_refc_dec_coda9 $src $output $codec
  1635. ;;
  1636. esac
  1637. if [ $? != 0 ]; then
  1638. return 1;
  1639. fi
  1640. }
  1641. # generate_md5(stream_path, md5_path, force_run)
  1642. function generate_md5 {
  1643. local src=$1
  1644. local _output_path=$2
  1645. local force_run=$3
  1646. local run=0
  1647. echo "dirname ${_output_path}"
  1648. basedir=`dirname ${_output_path}`
  1649. mkdir -p "${basedir}"
  1650. [ -e $_output_path ] || run=1
  1651. if [ "$force_run" != "" ];then
  1652. run=$force_run
  1653. fi
  1654. if [ $run -eq 1 ]; then
  1655. case "$codec" in
  1656. vp9)
  1657. run_refc_dec_vp9 ${src} md5_result.txt ;; # generate linear md5
  1658. hevc)
  1659. run_refc_dec_h265 ${src} md5_result.txt ;; # generate linear md5
  1660. svac)
  1661. run_refc_dec_svac ${src} md5_result.txt ;; # generate linear md5
  1662. avs2)
  1663. run_refc_dec_avs2 ${src} md5_result.txt ;; # generate linear md5
  1664. avc)
  1665. if [[ $g_product_name =~ coda9* ]]; then
  1666. run_refc_dec_coda9 $src md5_result.txt $codec
  1667. local npath=${_output_path%_[0-7].md5}
  1668. chmod 666 md5_result.txt_*.md5
  1669. for (( i=0; i<=7; i++ )); do
  1670. cp --preserve=mode md5_result.txt_${i}.md5 ${npath}_${i}.md5
  1671. done
  1672. rm md5_result.txt_*.md5
  1673. return
  1674. else
  1675. run_refc_dec_avc ${src} md5_result.txt # generate linear md5
  1676. fi
  1677. ;;
  1678. *)
  1679. run_refc_dec_coda9 $src md5_result.txt $codec
  1680. local npath=${_output_path%_[0-7].md5}
  1681. chmod 666 md5_result.txt_*.md5
  1682. for (( i=0; i<=7; i++ )); do
  1683. cp --preserve=mode md5_result.txt_${i}.md5 ${npath}_${i}.md5
  1684. done
  1685. rm md5_result.txt_*.md5
  1686. return
  1687. ;;
  1688. esac
  1689. if [ "$?" != "0" ]; then
  1690. return 1;
  1691. fi
  1692. chmod 666 *.txt
  1693. echo "cp --preserve=mode md5_result.txt $_output_path"
  1694. cp --preserve=mode md5_result.txt $_output_path
  1695. rm md5_result.txt
  1696. fi
  1697. }
  1698. ###############################################################################
  1699. # ENCODER FUNCTIONS
  1700. ###############################################################################
  1701. # void c9_parse_cfg(cfg_path, &w, &h, &field_flag)
  1702. # desc: parse cfg file to get width, height and field_flag information
  1703. function c9_parse_cfg {
  1704. local _cfg_path="$1"
  1705. local _width=$2
  1706. local _height=$3
  1707. local _is_field=$4
  1708. local _name=""
  1709. local _firstchar=""
  1710. shopt -s nocasematch
  1711. while read line; do
  1712. _firstchar=${line:0:1}
  1713. case "$_firstchar" in
  1714. "#") continue;; # comment
  1715. ";") continue;; # comment
  1716. "") continue;;
  1717. esac
  1718. name=$(echo $line | cut -d' ' -f1)
  1719. if [ "$name" = "PICTURE_WIDTH" ]; then
  1720. eval $_width=$(echo $line | cut -d' ' -f2)
  1721. elif [ "$name" = "PICTURE_HEIGHT" ]; then
  1722. eval $_height=$(echo $line | cut -d' ' -f2)
  1723. elif [ "$name" = "INTERLACED_PIC" ]; then
  1724. eval $_is_field=$(echo $line | cut -d' ' -f2)
  1725. fi
  1726. done < $_cfg_path
  1727. shopt -u nocasematch
  1728. }
  1729. function read_cfg {
  1730. local _cfg_path="$1"
  1731. cfg_FramesToBeEncoded=0
  1732. cfg_InputFile=0
  1733. cfg_width=0
  1734. cfg_height=0
  1735. cfg_ScalingListFile=0
  1736. cfg_EnModeMap=0
  1737. cfg_ModeMapFile=0
  1738. cfg_EnLambdaMap=0
  1739. cfg_LambdaMapFile=0
  1740. cfg_EnCustomLambda=0
  1741. cfg_CustomLambdaFile=0
  1742. cfg_InputBitDepth=0
  1743. cfg_GopPreset=0
  1744. cfg_EnSVC=0
  1745. cfg_EnRoi=0
  1746. cfg_RoiFile=0
  1747. cfg_GopPreset=0
  1748. cfg_WeightedPred=0
  1749. cfg_BitstreamFile=""
  1750. cfg_EnBgDetect=0
  1751. cfg_RateControl=0
  1752. cfg_EnHvsQp=0
  1753. cfg_EnNoiseEst=0
  1754. cfg_CULevelRateControl=0
  1755. cfg_IntraCtuRefreshMode=0
  1756. cfg_WaveFrontSynchro=0
  1757. cfg_EncBitrate=0
  1758. cfg_LookAheadRcEnable=0
  1759. if [ -f ${_cfg_path} ]; then
  1760. while read line2; do
  1761. # remove right comment
  1762. line2=$(echo $line2 | tr -d '\n')
  1763. line2=$(echo $line2 | tr -d '\r')
  1764. line2="${line2%%\#*}"
  1765. attr=$(echo $line2 | cut -d':' -f1)
  1766. attr=$(echo $attr | tr -d ' ')
  1767. value=$(echo $line2 | cut -d':' -f2)
  1768. value=$(echo $value | tr -d ' ')
  1769. #echo "attr=$attr, value=${value},"
  1770. case "$attr" in
  1771. FramesToBeEncoded) cfg_FramesToBeEncoded="$value";;
  1772. InputFile) cfg_InputFile="$value";;
  1773. SourceWidth) cfg_width="$value";;
  1774. SourceHeight) cfg_height="$value";;
  1775. ScalingListFile) cfg_ScalingListFile="$value";;
  1776. EnModeMap) cfg_EnModeMap="$value";;
  1777. ModeMapFile) cfg_ModeMapFile="$value";;
  1778. EnLambdaMap) cfg_EnLambdaMap="$value";;
  1779. LambdaMapFile) cfg_LambdaMapFile="$value";;
  1780. EnCustomLambda) cfg_EnCustomLambda="$value";;
  1781. CustomLambdaFile) cfg_CustomLambdaFile="$value";;
  1782. InputBitDepth) cfg_InputBitDepth="$value";;
  1783. GopPreset) cfg_GopPreset="$value";;
  1784. EnSVC) cfg_EnSVC="$value";;
  1785. EnRoi) cfg_EnRoi="$value";;
  1786. RoiFile) cfg_RoiFile="$value";;
  1787. GopPreset) cfg_GopPreset="$value";;
  1788. WeightedPred) cfg_WeightedPred="$value";;
  1789. BitstreamFile) cfg_BitstreamFile="$value";;
  1790. EnBgDetect) cfg_EnBgDetect="$value";;
  1791. RateControl) cfg_RateControl="$value";;
  1792. EnHvsQp) cfg_EnHvsQp="$value";;
  1793. EnNoiseEst) cfg_EnNoiseEst="$value";;
  1794. CULevelRateControl) cfg_CULevelRateControl="$value";;
  1795. IntraCtuRefreshMode) cfg_IntraCtuRefreshMode="$value";;
  1796. WaveFrontSynchro) cfg_WaveFrontSynchro="$value";;
  1797. EncBitrate) cfg_EncBitrate="$value";;
  1798. LookAheadRcEnable) cfg_LookAheadRcEnable="$value";;
  1799. *) ;;
  1800. esac
  1801. done < $_cfg_path
  1802. else
  1803. echo "cfg not exist, cfg_path=$_cfg_path"
  1804. fi
  1805. }