main_dec_test.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. // SPDX-License-Identifier: LGPL-2.1 OR BSD-3-Clause
  2. /*
  3. * Copyright (c) 2019, Chips&Media
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  19. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include <signal.h>
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include <time.h>
  30. #include <getopt.h>
  31. #include "cnm_app.h"
  32. #include "decoder_listener.h"
  33. #include <sys/types.h>
  34. #include <sys/stat.h>
  35. #include <fcntl.h>
  36. #define PAGE_SHIFT (12)
  37. #define PAGE_SIZE (1UL << PAGE_SHIFT)
  38. #define PAGE_MASK (~(PAGE_SIZE - 1))
  39. #define DEV_PAGEMAP "/proc/self/pagemap"
  40. int page_fd;
  41. int vic_pagemap_init()
  42. {
  43. page_fd = open(DEV_PAGEMAP, O_RDONLY);
  44. if(page_fd == -1)
  45. {
  46. perror("page_fd open:\n");
  47. return -1;
  48. }
  49. return page_fd;
  50. }
  51. void vic_pagemap_release()
  52. {
  53. close(page_fd);
  54. }
  55. unsigned long us_virt_to_phy(void * vaddr)
  56. {
  57. unsigned long paddr,v_addr;
  58. unsigned long v_pageIndex,v_offset,page_offset;
  59. uint64_t phy_pageIndex,item = 0;
  60. int pageSize;
  61. v_addr = (unsigned long)vaddr;
  62. pageSize = PAGE_SIZE;
  63. page_offset = v_addr & ~PAGE_MASK;
  64. v_pageIndex = (v_addr & PAGE_MASK) >> PAGE_SHIFT;
  65. v_offset = v_pageIndex * sizeof(uint64_t);
  66. if(lseek(page_fd, v_offset, SEEK_SET) == -1)
  67. {
  68. perror("lseek:\n");
  69. goto page_error;
  70. }
  71. if(read(page_fd, &item, sizeof(uint64_t)) != sizeof(uint64_t))
  72. {
  73. perror("read item error\n");
  74. goto page_error;
  75. }
  76. if((((uint64_t)1 << 63) & item) == 0)
  77. {
  78. perror("page present is 0\n");
  79. goto page_error;
  80. }
  81. phy_pageIndex = (((uint64_t)1 << 55) - 1) & item;//¼ÆËãÎïÀíÒ³ºÅ£¬¼´È¡itemµÄbit0-54
  82. paddr = (phy_pageIndex * pageSize) + page_offset;
  83. return paddr;
  84. page_error:
  85. close(page_fd);
  86. return 0;
  87. }
  88. void print_in_line_u64(unsigned char *p_name, unsigned long phys_addr, unsigned long *p_buf, unsigned int len)
  89. {
  90. unsigned int len_tmp = len;
  91. unsigned int i = 0, j = 0;
  92. unsigned int line = 0;
  93. unsigned int rest = 0;
  94. unsigned int* ptmp = NULL;
  95. printf("%s: phys_addr:%#llx,vir_addr:%#llx, %#x\n", p_name, phys_addr,(unsigned long)p_buf, len);
  96. if(len >= 0x1000){
  97. len_tmp = 0x1000/32; //print 128 size of memory.
  98. //len_tmp = len/8; //for all
  99. }
  100. else{
  101. len_tmp = len/8; //print real 100% size of memory.
  102. }
  103. rest = len/4; //one line print 8 u32
  104. for (i = 0; i < len_tmp; i += 4)
  105. {
  106. if (!(i % 4))
  107. {
  108. printf(" %#llx: ", (sizeof(phys_addr)*i + phys_addr));
  109. }
  110. ptmp = (unsigned int*)(p_buf + i);
  111. line = (rest > 8) ? 8 : rest;
  112. for (j = 0; j < line; j++)
  113. {
  114. printf("%08x ", *(ptmp + j));
  115. }
  116. printf("\n");
  117. rest -= line;
  118. }
  119. }
  120. extern CodStd BSFeederFrameSize_GetDirectFormat(const char* path);
  121. typedef struct CommandLineArgument{
  122. int argc;
  123. char **argv;
  124. }CommandLineArgument;
  125. static void Help(struct OptionExt *opt, const char *programName)
  126. {
  127. int i;
  128. VLOG(INFO, "------------------------------------------------------------------------------\n");
  129. VLOG(INFO, "%s(API v%d.%d.%d)\n", GetBasename(programName), API_VERSION_MAJOR, API_VERSION_MINOR, API_VERSION_PATCH);
  130. VLOG(INFO, "\tAll rights reserved by Chips&Media(C)\n");
  131. VLOG(INFO, "------------------------------------------------------------------------------\n");
  132. VLOG(INFO, "%s [option] --input bistream\n", GetBasename(programName));
  133. VLOG(INFO, "-h help\n");
  134. VLOG(INFO, "-n [num] output frame number\n");
  135. VLOG(INFO, "-c compare with golden\n");
  136. VLOG(INFO, " 0 : no comparator\n");
  137. VLOG(INFO, " 1 : compare with golden yuv that specified --ref-yuv option\n");
  138. VLOG(INFO, "-d dual display. A linear fb is synchronous with a compressed fb.\n");
  139. for (i = 0;i < MAX_GETOPT_OPTIONS;i++) {
  140. if (opt[i].name == NULL)
  141. break;
  142. VLOG(INFO, "%s", opt[i].help);
  143. }
  144. }
  145. static BOOL CheckTestConfig(TestDecConfig testConfig) {
  146. BOOL isValidParameters = TRUE;
  147. /* Check parameters */
  148. if (testConfig.skipMode < 0 || testConfig.skipMode == 3 || testConfig.skipMode > 4) {
  149. VLOG(ERR, "Invalid skip mode: %d\n", testConfig.skipMode);
  150. isValidParameters = FALSE;
  151. }
  152. if ((FORMAT_422 < testConfig.wtlFormat && testConfig.wtlFormat <= FORMAT_400) ||
  153. testConfig.wtlFormat < FORMAT_420 || testConfig.wtlFormat >= FORMAT_MAX) {
  154. VLOG(ERR, "Invalid WTL format(%d)\n", testConfig.wtlFormat);
  155. isValidParameters = FALSE;
  156. }
  157. if (isValidParameters == TRUE && (testConfig.scaleDownWidth > 0 || testConfig.scaleDownHeight > 0)) {
  158. }
  159. if (testConfig.renderType < RENDER_DEVICE_NULL || testConfig.renderType >= RENDER_DEVICE_MAX) {
  160. VLOG(ERR, "unknown render device type(%d)\n", testConfig.renderType);
  161. isValidParameters = FALSE;
  162. }
  163. if (testConfig.thumbnailMode == TRUE && testConfig.skipMode != 0) {
  164. VLOG(ERR, "Turn off thumbnail mode or skip mode\n");
  165. isValidParameters = FALSE;
  166. }
  167. return isValidParameters;
  168. }
  169. static BOOL ParseArgumentAndSetTestConfig(CommandLineArgument argument, TestDecConfig* testConfig)
  170. {
  171. Int32 opt = 0, i = 0, index = 0;
  172. Uint32 argFeeding = 0; /* auto, depeding on --bsmode */
  173. int argc = argument.argc;
  174. char** argv = argument.argv;
  175. char** stop = NULL;
  176. char* optString = "c:hvn:";
  177. struct option options[MAX_GETOPT_OPTIONS];
  178. struct OptionExt options_help[MAX_GETOPT_OPTIONS] = {
  179. {"output", 1, NULL, 0, "--output output YUV path\n"}, /* 0 */
  180. {"input", 1, NULL, 0, "--input bitstream path\n"},
  181. {"codec", 1, NULL, 0, "--codec codec index, HEVC : 12, VP9 : 13, AVS2 : 14, AVC : 0\n"},
  182. {"render", 1, NULL, 0, "--render 0 : no rendering picture\n"
  183. " 1 : render a picture with the framebuffer device\n"},
  184. {"bsmode", 1, NULL, 0, "--bsmode 0: INTERRUPT MODE, 1: reserved, 2: PICEND MODE\n"},
  185. {"disable-wtl", 0, NULL, 0, "--disable-wtl disable WTL. default on.\n"}, /* 5 */
  186. {"coreIdx", 1, NULL, 0, "--coreIdx core index: default 0\n"},
  187. {"loop-count", 1, NULL, 0, "--loop-count integer number. loop test, default 0\n"},
  188. {"enable-cbcrinterleave", 0, NULL, 0, "--enable-cbcrinterleave enable cbcrInterleave(NV12), default off\n"},
  189. {"stream-endian", 1, NULL, 0, "--stream-endian 16~31, default 31(LE) Please refer programmer's guide or datasheet\n"},
  190. {"frame-endian", 1, NULL, 0, "--frame-endian 16~31, default 31(LE) Please refer programmer's guide or datasheet\n"},
  191. {"enable-nv21", 0, NULL, 0, "--enable-nv21 enable NV21, default off\n"},
  192. {"secondary-axi", 1, NULL, 0, "--secondary-axi 0~7: bit oring values, Please refer programmer's guide or datasheet\n"},
  193. {"wtl-format", 1, NULL, 0, "--wtl-format yuv format. default 0.\n"},
  194. {"num-vcores", 1, NULL, 0, "--num-vcores number vcores to be used, default 1\n"},
  195. {"enable-thumbnail", 0, NULL, 0, "--enable-thumbnail enable thumbnail mode. default off\n"},
  196. {"ref-yuv", 1, NULL, 0, "--ref-yuv golden yuv path\n"},
  197. {"skip-mode", 1, NULL, 0, "--skip-mode 0: off, 1: Non-IRAP, 2: Non-Ref, 4: skip-all\n"},
  198. {"bwopt", 1, NULL, 0, "--bwopt bandwidth opimization\n"},
  199. {"sclw", 1, NULL, 0, "--sclw scale width of picture down. ceil8(width/8) <= scaledW <= width, 99 for random test\n"}, /* 20 */
  200. {"sclh", 1, NULL, 0, "--sclh scale height of picture down, ceil8(height/8) <= scaledH <= height, 99 for random test\n"},
  201. {"cra-bla", 0, NULL, 0, "--cra-bla Handle CRA as BLA\n"},
  202. {"userdata", 1, NULL, 0, "--userdata hexadecimal(hevc) 0 - disable userdata 4 - VUI 10 - pic_timing 20 - itu_t_35 prefix\n"
  203. " 40 - unregistered prefix 80 - itu_t_35 suffix 100 - unregistered suffix 400 - mastering_col_vol\n"
  204. " 800 - chroma resample hint 1000 - knee function 2000 - tone mapping 4000 - film grain\n"
  205. " 8000 - content light level 10000 - color remapping 10000000 - itu_t_35 prefix 1 20000000 - itu_t_35 prefix 2\n"
  206. " 40000000 - itu_t_35 suffix 1 80000000 - itu_t_35 suffix 2 \n"
  207. "--userdata hexadecimal(avc) 0 - disable userdata 4 - VUI 10 - pic_timing 20 - itu_t_35\n"
  208. " 40 - unregistered 80 - reserved 100 - reserved 400 - reserved\n"
  209. " 800 - reserved 1000 - reserved 2000 - tone mapping 4000 - film grain\n"
  210. " 8000 - reserved 10000 - color remapping 10000000 - reserved 20000000 - reserved\n"
  211. " All bits can be or-ing. ex) 404 -> mastering_color_volume | VUI\n"},
  212. {"feeding", 1, NULL, 0, "--feeding 0: auto, 1: fixed-size, 2: ffempg, 3: size(4byte)+es\n"}, /* 25 */
  213. {"rseed", 1, NULL, 0, "--rseed random seed value, Hexadecimal\n"},
  214. {NULL, 0, NULL, 0},
  215. };
  216. Uint32 minScaleWidth, minScaleHeight;
  217. for (i = 0; i < MAX_GETOPT_OPTIONS;i++) {
  218. if (options_help[i].name == NULL)
  219. break;
  220. osal_memcpy(&options[i], &options_help[i], sizeof(struct option));
  221. }
  222. while ((opt=getopt_long(argc, argv, optString, options, (int *)&index)) != -1) {
  223. switch (opt) {
  224. case 'c':
  225. testConfig->compareType = atoi(optarg);
  226. if (testConfig->compareType < NO_COMPARE || testConfig->compareType > YUV_COMPARE) {
  227. VLOG(ERR, "Invalid compare type(%d)\n", testConfig->compareType);
  228. Help(options_help, argv[0]);
  229. exit(1);
  230. }
  231. break;
  232. case 'n':
  233. testConfig->forceOutNum = atoi(optarg);
  234. break;
  235. case 'h':
  236. Help(options_help, argv[0]);
  237. return FALSE;
  238. case 0:
  239. if (!strcmp(options[index].name, "output")) {
  240. osal_memcpy(testConfig->outputPath, optarg, strlen(optarg));
  241. ChangePathStyle(testConfig->outputPath);
  242. } else if (!strcmp(options[index].name, "input")) {
  243. osal_memcpy(testConfig->inputPath, optarg, strlen(optarg));
  244. ChangePathStyle(testConfig->inputPath);
  245. } else if (!strcmp(options[index].name, "codec")) {
  246. testConfig->bitFormat = atoi(optarg);
  247. } else if (!strcmp(options[index].name, "render")) {
  248. testConfig->renderType = (RenderDeviceType)atoi(optarg);
  249. if (testConfig->renderType < RENDER_DEVICE_NULL || testConfig->renderType >= RENDER_DEVICE_MAX) {
  250. VLOG(ERR, "unknown render device type(%d)\n", testConfig->renderType);
  251. Help(options_help, argv[0]);
  252. return FALSE;
  253. }
  254. } else if (!strcmp(options[index].name, "bsmode")) {
  255. testConfig->bitstreamMode = atoi(optarg);
  256. } else if (!strcmp(options[index].name, "disable-wtl")) {
  257. testConfig->enableWTL = FALSE;
  258. testConfig->wtlMode = FF_NONE;
  259. } else if (!strcmp(options[index].name, "coreIdx")) {
  260. testConfig->coreIdx = atoi(optarg);
  261. } else if (!strcmp(options[index].name, "loop-count")) {
  262. testConfig->loopCount = atoi(optarg);
  263. } else if (!strcmp(options[index].name, "enable-cbcrinterleave")) {
  264. testConfig->cbcrInterleave = TRUE;
  265. } else if (!strcmp(options[index].name, "stream-endian")) {
  266. testConfig->streamEndian = (EndianMode)atoi(optarg);
  267. } else if (!strcmp(options[index].name, "frame-endian")) {
  268. testConfig->frameEndian = (EndianMode)atoi(optarg);
  269. } else if (!strcmp(options[index].name, "enable-nv21")) {
  270. testConfig->nv21 = 1;
  271. } else if (!strcmp(options[index].name, "secondary-axi")) {
  272. testConfig->secondaryAXI = strtoul(optarg, stop, !strncmp("0x", optarg, 2) ? 16 : 10);
  273. } else if (!strcmp(options[index].name, "wtl-format")) {
  274. testConfig->wtlFormat = (FrameBufferFormat)atoi(optarg);
  275. } else if (!strcmp(options[index].name, "num-vcores")) {
  276. testConfig->wave.numVCores = atoi(optarg);
  277. } else if (!strcmp(options[index].name, "enable-thumbnail")) {
  278. testConfig->thumbnailMode = TRUE;
  279. } else if (!strcmp(options[index].name, "ref-yuv")) {
  280. osal_memcpy(testConfig->refYuvPath, optarg, strlen(optarg));
  281. ChangePathStyle(testConfig->refYuvPath);
  282. } else if (!strcmp(options[index].name, "skip-mode")) {
  283. testConfig->skipMode = atoi(optarg);
  284. } else if (!strcmp(options[index].name, "bwopt")) {
  285. testConfig->wave.bwOptimization = atoi(optarg);
  286. } else if (!strcmp(options[index].name, "sclw")) {
  287. testConfig->scaleDownWidth = VPU_CEIL(atoi(optarg), 2);
  288. } else if (!strcmp(options[index].name, "sclh")) {
  289. testConfig->scaleDownHeight = VPU_CEIL(atoi(optarg), 2);
  290. } else if (!strcmp(options[index].name, "cra-bla")) {
  291. testConfig->wave.craAsBla = TRUE;
  292. } else if (!strcmp(options[index].name, "userdata")) {
  293. testConfig->enableUserData = strtoul(optarg, stop, 16);
  294. } else if (!strcmp(options[index].name, "feeding")) {
  295. argFeeding = (Uint32)atoi(optarg);
  296. } else if (!strcmp(options[index].name, "fw-path")) {
  297. osal_memcpy(testConfig->fwPath, optarg, strlen(optarg));
  298. } else if (!strcmp(options[index].name, "annexb")) {
  299. testConfig->wave.av1Format = atoi(optarg);
  300. if (TRUE != testConfig->wave.av1Format) {
  301. testConfig->wave.av1Format = 1; //AV1_STREAM_OBU
  302. } else {
  303. testConfig->wave.av1Format = 2; //AV1_STREAM_ANNEXB
  304. }
  305. } else if (!strcmp(options[index].name, "rseed")) {
  306. randomSeed = strtoul(optarg, NULL, 16);
  307. srand(randomSeed);
  308. } else if (!strcmp(options[index].name, "bs-size")) {
  309. testConfig->bsSize = (size_t)atoi(optarg);
  310. } else {
  311. VLOG(ERR, "not exist param = %s\n", options[index].name);
  312. Help(options_help, argv[0]);
  313. return FALSE;
  314. }
  315. break;
  316. default:
  317. VLOG(ERR, "%s\n", optarg);
  318. Help(options_help, argv[0]);
  319. return FALSE;
  320. }
  321. }
  322. VLOG(INFO, "\n");
  323. switch (argFeeding) {
  324. case 0: /* AUTO */
  325. if (testConfig->bitstreamMode == BS_MODE_INTERRUPT) {
  326. testConfig->feedingMode = FEEDING_METHOD_FIXED_SIZE;
  327. }
  328. else {
  329. testConfig->feedingMode = FEEDING_METHOD_FRAME_SIZE;
  330. }
  331. break;
  332. case 1: /* FIXED SIZE */
  333. testConfig->feedingMode = FEEDING_METHOD_FIXED_SIZE;
  334. break;
  335. case 2: /* Using FFMPEG */
  336. testConfig->feedingMode = FEEDING_METHOD_FRAME_SIZE;
  337. break;
  338. case 3: /* for every frame, size(4byte) + es(1frame) */
  339. testConfig->feedingMode = FEEDING_METHOD_SIZE_PLUS_ES;
  340. break;
  341. default:
  342. VLOG(ERR, "--feeding=%d not supported\n", argFeeding);
  343. return FALSE;
  344. }
  345. if (testConfig->bitFormat == STD_VP9) {
  346. testConfig->feedingMode = FEEDING_METHOD_FRAME_SIZE;
  347. testConfig->bitstreamMode = BS_MODE_PIC_END;
  348. }
  349. minScaleWidth = 8;
  350. minScaleHeight = 8;
  351. if (testConfig->scaleDownWidth != 0 && testConfig->scaleDownWidth < minScaleWidth) {
  352. VLOG(ERR, "The minimum scale-downed width: %d\n", minScaleWidth);
  353. return FALSE;
  354. }
  355. if (testConfig->scaleDownHeight != 0 && testConfig->scaleDownHeight < minScaleHeight) {
  356. VLOG(ERR, "The minimum scale-downed height: %d\n", minScaleHeight);
  357. return FALSE;
  358. }
  359. return TRUE;
  360. }
  361. static BOOL s_abort = FALSE;
  362. static BOOL s_brun = FALSE;
  363. static void ctrlc_handler(int a)
  364. {
  365. s_abort = TRUE;
  366. if(s_brun==TRUE){
  367. CNMAppStop();
  368. s_brun = FALSE;
  369. }
  370. }
  371. int main(int argc, char **argv)
  372. {
  373. char* fwPath = NULL;
  374. TestDecConfig testConfig;
  375. CommandLineArgument argument;
  376. CNMComponentConfig config;
  377. CNMTask task;
  378. Component feeder;
  379. Component decoder;
  380. Component renderer;
  381. Uint32 sizeInWord;
  382. Uint16* pusBitCode=NULL;
  383. BOOL ret;
  384. BOOL testResult;
  385. DecListenerContext lsnCtx;
  386. signal(SIGINT,ctrlc_handler);
  387. osal_memset(&argument, 0x00, sizeof(CommandLineArgument));
  388. osal_memset(&config, 0x00, sizeof(CNMComponentConfig));
  389. InitLog();
  390. SetDefaultDecTestConfig(&testConfig);
  391. argument.argc = argc;
  392. argument.argv = argv;
  393. if (ParseArgumentAndSetTestConfig(argument, &testConfig) == FALSE) {
  394. VLOG(ERR, "fail to ParseArgumentAndSetTestConfig()\n");
  395. return 1;
  396. }
  397. if (CheckTestConfig(testConfig) == FALSE) {
  398. VLOG(ERR, "fail to CheckTestConfig()\n");
  399. return 1;
  400. }
  401. testConfig.productId = (ProductId)VPU_GetProductId(testConfig.coreIdx);
  402. /* Need to Add */
  403. /* FW load & show version case*/
  404. switch (testConfig.productId) {
  405. case PRODUCT_ID_521: fwPath = CORE_6_BIT_CODE_FILE_PATH; break;
  406. case PRODUCT_ID_511: fwPath = CORE_6_BIT_CODE_FILE_PATH; break;
  407. case PRODUCT_ID_517: fwPath = CORE_7_BIT_CODE_FILE_PATH; break;
  408. default:
  409. VLOG(ERR, "Unknown product id: %d\n", testConfig.productId);
  410. return 1;
  411. }
  412. VLOG(INFO, "FW PATH = %s\n", fwPath);
  413. if (LoadFirmware(testConfig.productId, (Uint8**)&pusBitCode, &sizeInWord, fwPath) < 0) {
  414. VLOG(ERR, "%s:%d Failed to load firmware: %s\n", __FUNCTION__, __LINE__, fwPath);
  415. return 1;
  416. }
  417. config.testDecConfig = testConfig;
  418. config.bitcode = (Uint8*)pusBitCode;
  419. config.sizeOfBitcode = sizeInWord;
  420. //vic_pagemap_init();
  421. //unsigned char name[] ="bitcode";
  422. //print_in_line_u64(name,us_virt_to_phy((void *)config.bitcode),(unsigned long *)config.bitcode,config.sizeOfBitcode*2);
  423. #ifdef SUPPORT_FFMPEG_DEMUX
  424. /* webb add */
  425. {
  426. CodStd vformat;
  427. vformat = BSFeederFrameSize_GetDirectFormat(config.testDecConfig.inputPath);
  428. VLOG(INFO,"%s bs-format is %d\n",config.testDecConfig.inputPath,vformat);
  429. if((vformat==STD_AVC)||(vformat==STD_HEVC)){
  430. config.testDecConfig.bitFormat = vformat;
  431. config.testDecConfig.feedingMode = FEEDING_METHOD_FRAME_SIZE;
  432. config.testDecConfig.bitstreamMode = BS_MODE_PIC_END;
  433. }
  434. else
  435. {
  436. VLOG(ERR,"bs-format can't be supported\n");
  437. return 1;
  438. }
  439. }
  440. #endif
  441. if (RETCODE_SUCCESS != (ret=SetUpDecoderOpenParam(&(config.decOpenParam), &(config.testDecConfig)))) {
  442. VLOG(ERR, "%s:%d SetUpDecoderOpenParam failed Error code is 0x%x \n", __FUNCTION__, __LINE__, ret);
  443. return 1;
  444. }
  445. CNMAppInit();
  446. task = CNMTaskCreate();
  447. feeder = ComponentCreate("feeder", &config);
  448. decoder = ComponentCreate("wave_decoder", &config);
  449. renderer = ComponentCreate("renderer", &config);
  450. CNMTaskAdd(task, feeder);
  451. CNMTaskAdd(task, decoder);
  452. CNMTaskAdd(task, renderer);
  453. CNMAppAdd(task);
  454. if ((ret=SetupDecListenerContext(&lsnCtx, &config, renderer)) == TRUE) {
  455. ComponentRegisterListener(decoder, COMPONENT_EVENT_DEC_ALL, DecoderListener, (void*)&lsnCtx);
  456. if(s_abort==FALSE){
  457. s_brun = TRUE;
  458. ret = CNMAppRun();
  459. }
  460. }
  461. else {
  462. CNMAppStop();
  463. }
  464. osal_free(pusBitCode);
  465. ClearDecListenerContext(&lsnCtx);
  466. testResult = (ret == TRUE && lsnCtx.match == TRUE && CNMErrorGet() == 0);
  467. VLOG(INFO, "[RESULT] %s\n", (testResult == TRUE) ? "SUCCESS" : "FAILURE");
  468. //vic_pagemap_release();
  469. if ( CNMErrorGet() != 0 )
  470. return CNMErrorGet();
  471. return testResult == TRUE ? 0 : 1;
  472. }