main_jpg_dec_test.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. /*
  2. * Copyright (c) 2018, Chips&Media
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  18. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <getopt.h>
  28. #include <strings.h>
  29. #include "jpuapi.h"
  30. #include "regdefine.h"
  31. #include "jpulog.h"
  32. #include "jpuapifunc.h"
  33. #include "main_helper.h"
  34. #define NUM_FRAME_BUF MAX_FRAME
  35. #define MAX_ROT_BUF_NUM 1
  36. #ifdef SUPPORT_MULTI_INSTANCE_TEST
  37. #else
  38. static void Help(
  39. const char* programName
  40. )
  41. {
  42. JLOG(INFO, "------------------------------------------------------------------------------\n");
  43. JLOG(INFO, " CODAJ12 Decoder\n");
  44. JLOG(INFO, "------------------------------------------------------------------------------\n");
  45. JLOG(INFO, "%s [options] --input=jpg_file_path\n", programName);
  46. JLOG(INFO, "-h help\n");
  47. JLOG(INFO, "--input=FILE jpeg filepath\n");
  48. JLOG(INFO, "--output=FILE output file path\n");
  49. JLOG(INFO, "--stream-endian=ENDIAN bitstream endianness. refer to datasheet Chapter 4.\n");
  50. JLOG(INFO, "--frame-endian=ENDIAN pixel endianness of 16bit input source. refer to datasheet Chapter 4.\n");
  51. JLOG(INFO, "--pixelj=JUSTIFICATION 16bit-pixel justification. 0(default) - msb justified, 1 - lsb justified in little-endianness\n");
  52. JLOG(INFO, "--bs-size=SIZE bitstream buffer size in byte\n");
  53. JLOG(INFO, "--roi=x,y,w,h ROI region\n");
  54. JLOG(INFO, "--subsample conversion sub-sample(ignore case): NONE, 420, 422, 444\n");
  55. JLOG(INFO, "--ordering conversion ordering(ingore-case): NONE, NV12, NV21, YUYV, YVYU, UYVY, VYUY, AYUV\n");
  56. JLOG(INFO, " NONE - planar format\n");
  57. JLOG(INFO, " NV12, NV21 - semi-planar format for all the subsamples.\n");
  58. JLOG(INFO, " If subsample isn't defined or is none, the sub-sample depends on jpeg information\n");
  59. JLOG(INFO, " The subsample 440 can be converted to the semi-planar format. It means that the encoded sub-sample should be 440.\n");
  60. JLOG(INFO, " YUVV..VYUY - packed format. subsample be ignored.\n");
  61. JLOG(INFO, " AYUV - packed format. subsample be ignored.\n");
  62. JLOG(INFO, "--rotation 0, 90, 180, 270\n");
  63. JLOG(INFO, "--mirror 0(none), 1(V), 2(H), 3(VH)\n");
  64. JLOG(INFO, "--scaleH Horizontal downscale: 0(none), 1(1/2), 2(1/4), 3(1/8)\n");
  65. JLOG(INFO, "--scaleV Vertical downscale : 0(none), 1(1/2), 2(1/4), 3(1/8)\n");
  66. exit(1);
  67. }
  68. #endif /* SUPPORT_MULTI_INSTANCE_TEST */
  69. BOOL TestDecoder(
  70. DecConfigParam *param
  71. )
  72. {
  73. JpgDecHandle handle = {0};
  74. JpgDecOpenParam decOP = {0};
  75. JpgDecInitialInfo initialInfo = {0};
  76. JpgDecOutputInfo outputInfo = {0};
  77. JpgDecParam decParam = {0};
  78. JpgRet ret = JPG_RET_SUCCESS;
  79. FrameBuffer frameBuf[NUM_FRAME_BUF];
  80. jpu_buffer_t vbStream = {0};
  81. FRAME_BUF* pFrame[NUM_FRAME_BUF];
  82. Uint32 framebufWidth=0, framebufHeight=0, framebufStride = 0;
  83. Int32 i = 0, frameIdx = 0, saveIdx =0, totalNumofErrMbs = 0;
  84. BOOL suc = FALSE;
  85. Uint8* pYuv = NULL;
  86. FILE* fpYuv = NULL;
  87. Int32 needFrameBufCount = 0;
  88. Int32 int_reason = 0;
  89. Int32 instIdx = 0;
  90. Uint32 outbufSize=0;
  91. DecConfigParam decConfig;
  92. Uint32 decodingWidth, decodingHeight;
  93. Uint32 displayWidth, displayHeight;
  94. FrameFormat subsample;
  95. Uint32 bitDepth = 0;
  96. Uint32 temp;
  97. BOOL scalerOn = FALSE;
  98. BSFeeder feeder;
  99. memcpy(&decConfig, param, sizeof(DecConfigParam));
  100. memset(pFrame, 0x00, sizeof(pFrame));
  101. memset(frameBuf, 0x00, sizeof(frameBuf));
  102. ret = JPU_Init();
  103. if (ret != JPG_RET_SUCCESS && ret != JPG_RET_CALLED_BEFORE) {
  104. suc = 0;
  105. JLOG(ERR, "JPU_Init failed Error code is 0x%x \n", ret );
  106. goto ERR_DEC_INIT;
  107. }
  108. if ((feeder=BitstreamFeeder_Create(decConfig.bitstreamFileName, decConfig.feedingMode, (EndianMode)decConfig.StreamEndian)) == NULL) {
  109. goto ERR_DEC_INIT;
  110. }
  111. if (strlen(decConfig.yuvFileName)) {
  112. if ((fpYuv=fopen(decConfig.yuvFileName, "wb")) == NULL) {
  113. JLOG(ERR, "Can't open %s \n", decConfig.yuvFileName );
  114. goto ERR_DEC_INIT;
  115. }
  116. }
  117. // Open an instance and get initial information for decoding.
  118. vbStream.size = (decConfig.bsSize == 0) ? STREAM_BUF_SIZE : decConfig.bsSize;
  119. vbStream.size = (vbStream.size + 1023) & ~1023; // ceil128(size)
  120. if (jdi_allocate_dma_memory(&vbStream) < 0) {
  121. JLOG(ERR, "fail to allocate bitstream buffer\n" );
  122. goto ERR_DEC_INIT;
  123. }
  124. decOP.streamEndian = decConfig.StreamEndian;
  125. decOP.frameEndian = decConfig.FrameEndian;
  126. decOP.bitstreamBuffer = vbStream.phys_addr;
  127. decOP.bitstreamBufferSize = vbStream.size;
  128. //set virtual address mapped of physical address
  129. decOP.pBitStream = (BYTE *)vbStream.virt_addr; //lint !e511
  130. decOP.chromaInterleave = decConfig.cbcrInterleave;
  131. decOP.packedFormat = decConfig.packedFormat;
  132. decOP.roiEnable = decConfig.roiEnable;
  133. decOP.roiOffsetX = decConfig.roiOffsetX;
  134. decOP.roiOffsetY = decConfig.roiOffsetY;
  135. decOP.roiWidth = decConfig.roiWidth;
  136. decOP.roiHeight = decConfig.roiHeight;
  137. decOP.rotation = decConfig.rotation;
  138. decOP.mirror = decConfig.mirror;
  139. decOP.pixelJustification = decConfig.pixelJustification;
  140. decOP.outputFormat = decConfig.subsample;
  141. decOP.intrEnableBit = ((1<<INT_JPU_DONE) | (1<<INT_JPU_ERROR) | (1<<INT_JPU_BIT_BUF_EMPTY));
  142. ret = JPU_DecOpen(&handle, &decOP);
  143. if( ret != JPG_RET_SUCCESS ) {
  144. JLOG(ERR, "JPU_DecOpen failed Error code is 0x%x \n", ret );
  145. goto ERR_DEC_INIT;
  146. }
  147. instIdx = handle->instIndex;
  148. //JPU_DecGiveCommand(handle, ENABLE_LOGGING, NULL);
  149. do {
  150. /* Fill jpeg data in the bitstream buffer */
  151. BitstreamFeeder_Act(feeder, handle, &vbStream);
  152. if ((ret=JPU_DecGetInitialInfo(handle, &initialInfo)) != JPG_RET_SUCCESS) {
  153. if (JPG_RET_BIT_EMPTY == ret) {
  154. JLOG(INFO, "<%s:%d> BITSTREAM EMPTY\n", __FUNCTION__, __LINE__);
  155. continue;
  156. }
  157. else {
  158. JLOG(ERR, "JPU_DecGetInitialInfo failed Error code is 0x%x, inst=%d \n", ret, instIdx);
  159. goto ERR_DEC_OPEN;
  160. }
  161. }
  162. } while (JPG_RET_SUCCESS != ret);
  163. if (initialInfo.sourceFormat == FORMAT_420 || initialInfo.sourceFormat == FORMAT_422)
  164. framebufWidth = JPU_CEIL(16, initialInfo.picWidth);
  165. else
  166. framebufWidth = JPU_CEIL(8, initialInfo.picWidth);
  167. if (initialInfo.sourceFormat == FORMAT_420 || initialInfo.sourceFormat == FORMAT_440)
  168. framebufHeight = JPU_CEIL(16, initialInfo.picHeight);
  169. else
  170. framebufHeight = JPU_CEIL(8, initialInfo.picHeight);
  171. decodingWidth = framebufWidth >> decConfig.iHorScaleMode;
  172. decodingHeight = framebufHeight >> decConfig.iVerScaleMode;
  173. if (decOP.packedFormat != PACKED_FORMAT_NONE && decOP.packedFormat != PACKED_FORMAT_444) {
  174. // When packed format, scale-down resolution should be multiple of 2.
  175. decodingWidth = JPU_CEIL(2, decodingWidth);
  176. }
  177. subsample = (decConfig.subsample == FORMAT_MAX) ? initialInfo.sourceFormat : decConfig.subsample;
  178. temp = decodingWidth;
  179. decodingWidth = (decConfig.rotation == 90 || decConfig.rotation == 270) ? decodingHeight : decodingWidth;
  180. decodingHeight = (decConfig.rotation == 90 || decConfig.rotation == 270) ? temp : decodingHeight;
  181. if(decConfig.roiEnable == TRUE) {
  182. decodingWidth = framebufWidth = initialInfo.roiFrameWidth ;
  183. decodingHeight = framebufHeight = initialInfo.roiFrameHeight;
  184. }
  185. if (0 != decConfig.iHorScaleMode || 0 != decConfig.iVerScaleMode) {
  186. displayWidth = JPU_FLOOR(2, (framebufWidth >> decConfig.iHorScaleMode));
  187. displayHeight = JPU_FLOOR(2, (framebufHeight >> decConfig.iVerScaleMode));
  188. }
  189. else {
  190. displayWidth = decodingWidth;
  191. displayHeight = decodingHeight;
  192. }
  193. JLOG(INFO, "decodingWidth: %d, decodingHeight: %d\n", decodingWidth, decodingHeight);
  194. // Check restrictions
  195. if (decOP.rotation != 0 || decOP.mirror != MIRDIR_NONE) {
  196. if (decOP.outputFormat != FORMAT_MAX && decOP.outputFormat != initialInfo.sourceFormat) {
  197. JLOG(ERR, "The rotator cannot work with the format converter together.\n");
  198. goto ERR_DEC_OPEN;
  199. }
  200. }
  201. JLOG(INFO, "<INSTANCE %d>\n", instIdx);
  202. JLOG(INFO, "SOURCE PICTURE SIZE : W(%d) H(%d)\n", initialInfo.picWidth, initialInfo.picHeight);
  203. JLOG(INFO, "DECODED PICTURE SIZE: W(%d) H(%d)\n", displayWidth, displayHeight);
  204. JLOG(INFO, "SUBSAMPLE : %d\n", subsample);
  205. //Allocate frame buffer
  206. needFrameBufCount = initialInfo.minFrameBufferCount;
  207. bitDepth = initialInfo.bitDepth;
  208. scalerOn = (BOOL)(decConfig.iHorScaleMode || decConfig.iVerScaleMode);
  209. if (AllocateFrameBuffer(instIdx, subsample, decOP.chromaInterleave, decOP.packedFormat, decConfig.rotation, scalerOn, decodingWidth, decodingHeight, bitDepth, needFrameBufCount) == FALSE) {
  210. JLOG(ERR, "Failed to AllocateFrameBuffer()\n");
  211. goto ERR_DEC_OPEN;
  212. }
  213. for( i = 0; i < needFrameBufCount; ++i ) {
  214. pFrame[i] = GetFrameBuffer(instIdx, i);
  215. frameBuf[i].bufY = pFrame[i]->vbY.phys_addr;
  216. frameBuf[i].bufCb = pFrame[i]->vbCb.phys_addr;
  217. if (decOP.chromaInterleave == CBCR_SEPARATED)
  218. frameBuf[i].bufCr = pFrame[i]->vbCr.phys_addr;
  219. frameBuf[i].stride = pFrame[i]->strideY;
  220. frameBuf[i].strideC = pFrame[i]->strideC;
  221. frameBuf[i].endian = decOP.frameEndian;
  222. frameBuf[i].format = (FrameFormat)pFrame[i]->Format;
  223. }
  224. framebufStride = frameBuf[0].stride;
  225. outbufSize = decodingWidth * decodingHeight * 3 * (bitDepth+7)/8;
  226. if ((pYuv=malloc(outbufSize)) == NULL) {
  227. JLOG(ERR, "Fail to allocation memory for display buffer\n");
  228. goto ERR_DEC_OPEN;
  229. }
  230. // Register frame buffers requested by the decoder.
  231. if ((ret=JPU_DecRegisterFrameBuffer(handle, frameBuf, needFrameBufCount, framebufStride)) != JPG_RET_SUCCESS) {
  232. JLOG(ERR, "JPU_DecRegisterFrameBuffer failed Error code is 0x%x \n", ret );
  233. goto ERR_DEC_OPEN;
  234. }
  235. JPU_DecGiveCommand(handle, SET_JPG_SCALE_HOR, &(decConfig.iHorScaleMode));
  236. JPU_DecGiveCommand(handle, SET_JPG_SCALE_VER, &(decConfig.iVerScaleMode));
  237. /* LOG HEADER */
  238. JLOG(INFO, "I F FB_INDEX FRAME_START ECS_START CONSUME RD_PTR WR_PTR CYCLE\n");
  239. JLOG(INFO, "-------------------------------------------------------------------------------\n");
  240. while(1) {
  241. // Start decoding a frame.
  242. ret = JPU_DecStartOneFrame(handle, &decParam);
  243. if (ret != JPG_RET_SUCCESS && ret != JPG_RET_EOS) {
  244. if (ret == JPG_RET_BIT_EMPTY) {
  245. JLOG(INFO, "BITSTREAM NOT ENOUGH.............\n");
  246. BitstreamFeeder_Act(feeder, handle, &vbStream);
  247. continue;
  248. }
  249. JLOG(ERR, "JPU_DecStartOneFrame failed Error code is 0x%x \n", ret );
  250. goto ERR_DEC_OPEN;
  251. }
  252. if (ret == JPG_RET_EOS) {
  253. JPU_DecGetOutputInfo(handle, &outputInfo);
  254. suc = TRUE;
  255. break;
  256. }
  257. //JLOG(INFO, "\t<+>INSTANCE #%d JPU_WaitInterrupt\n", handle->instIndex);
  258. while(1) {
  259. if ((int_reason=JPU_WaitInterrupt(handle, JPU_INTERRUPT_TIMEOUT_MS)) == -1) {
  260. JLOG(ERR, "Error : timeout happened\n");
  261. JPU_SWReset(handle);
  262. break;
  263. }
  264. if (int_reason & ((1<<INT_JPU_DONE) | (1<<INT_JPU_ERROR) | (1<<INT_JPU_SLICE_DONE))) {
  265. // Do no clear INT_JPU_DONE and INT_JPU_ERROR interrupt. these will be cleared in JPU_DecGetOutputInfo.
  266. JLOG(INFO, "\tINSTANCE #%d int_reason: %08x\n", handle->instIndex, int_reason);
  267. break;
  268. }
  269. if (int_reason & (1<<INT_JPU_BIT_BUF_EMPTY)) {
  270. if (decConfig.feedingMode != FEEDING_METHOD_FRAME_SIZE) {
  271. BitstreamFeeder_Act(feeder, handle, &vbStream);
  272. }
  273. JPU_ClrStatus(handle, (1<<INT_JPU_BIT_BUF_EMPTY));
  274. }
  275. }
  276. //JLOG(INFO, "\t<->INSTANCE #%d JPU_WaitInterrupt\n", handle->instIndex);
  277. if ((ret=JPU_DecGetOutputInfo(handle, &outputInfo)) != JPG_RET_SUCCESS) {
  278. JLOG(ERR, "JPU_DecGetOutputInfo failed Error code is 0x%x \n", ret );
  279. goto ERR_DEC_OPEN;
  280. }
  281. if (outputInfo.decodingSuccess == 0)
  282. JLOG(ERR, "JPU_DecGetOutputInfo decode fail framdIdx %d \n", frameIdx);
  283. JLOG(INFO, "%02d %04d %8d %8x %8x %10d %8x %8x %10d\n",
  284. instIdx, frameIdx, outputInfo.indexFrameDisplay, outputInfo.bytePosFrameStart, outputInfo.ecsPtr, outputInfo.consumedByte,
  285. outputInfo.rdPtr, outputInfo.wrPtr, outputInfo.frameCycle);
  286. if (outputInfo.indexFrameDisplay == -1)
  287. break;
  288. saveIdx = outputInfo.indexFrameDisplay;
  289. if (!SaveYuvImageHelperFormat_V20(fpYuv, pYuv, &frameBuf[saveIdx], decOP.chromaInterleave, decOP.packedFormat, displayWidth, displayHeight, bitDepth, FALSE)) {
  290. goto ERR_DEC_OPEN;
  291. }
  292. if (outputInfo.numOfErrMBs) {
  293. Int32 errRstIdx, errPosX, errPosY;
  294. errRstIdx = (outputInfo.numOfErrMBs & 0x0F000000) >> 24;
  295. errPosX = (outputInfo.numOfErrMBs & 0x00FFF000) >> 12;
  296. errPosY = (outputInfo.numOfErrMBs & 0x00000FFF);
  297. JLOG(ERR, "Error restart Idx : %d, MCU x:%d, y:%d, in Frame : %d \n", errRstIdx, errPosX, errPosY, frameIdx);
  298. }
  299. frameIdx++;
  300. if (decConfig.outNum && (frameIdx == decConfig.outNum)) {
  301. suc = TRUE;
  302. break;
  303. }
  304. if (decConfig.feedingMode == FEEDING_METHOD_FRAME_SIZE) {
  305. JPU_DecSetRdPtrEx(handle, vbStream.phys_addr, TRUE);
  306. BitstreamFeeder_Act(feeder, handle, &vbStream);
  307. }
  308. }
  309. if (totalNumofErrMbs) {
  310. suc = 0;
  311. JLOG(ERR, "Total Num of Error MBs : %d\n", totalNumofErrMbs);
  312. }
  313. ERR_DEC_OPEN:
  314. // Now that we are done with decoding, close the open instance.
  315. ret = JPU_DecClose(handle);
  316. if (ret != JPG_RET_SUCCESS)
  317. suc = 0;
  318. JLOG(INFO, "\nDec End. Tot Frame %d\n", frameIdx);
  319. BitstreamFeeder_Destroy(feeder);
  320. ERR_DEC_INIT:
  321. FreeFrameBuffer(instIdx);
  322. jdi_free_dma_memory(&vbStream);
  323. if (pYuv)
  324. free(pYuv);
  325. if (fpYuv)
  326. fclose(fpYuv);
  327. JPU_DeInit();
  328. return suc;
  329. }
  330. #ifdef SUPPORT_MULTI_INSTANCE_TEST
  331. #else
  332. /*line -e14 to inhibit multiple main symbol error*/
  333. int main(int argc, char** argv)
  334. {
  335. Int32 ret = 1;
  336. struct option longOpt[] = {
  337. { "stream-endian", required_argument, NULL, 0 },
  338. { "frame-endian", required_argument, NULL, 0 },
  339. { "output", required_argument, NULL, 0 },
  340. { "input", required_argument, NULL, 0 },
  341. { "pixelj", required_argument, NULL, 0 },
  342. { "bs-size", required_argument, NULL, 0 },
  343. { "roi", required_argument, NULL, 0 },
  344. { "subsample", required_argument, NULL, 0 },
  345. { "ordering", required_argument, NULL, 0 },
  346. { "rotation", required_argument, NULL, 0 },
  347. { "mirror", required_argument, NULL, 0 },
  348. { "scaleH", required_argument, NULL, 0 },
  349. { "scaleV", required_argument, NULL, 0 },
  350. { NULL, no_argument, NULL, 0 },
  351. };
  352. Int32 c;
  353. int l;
  354. const char* shortOpt = "fh";
  355. DecConfigParam config;
  356. TestDevConfig devConfig = { ACLK_MIN, CCLK_MIN, TRUE };
  357. char* ext = NULL;
  358. memset((void*)&config, 0x00, sizeof(DecConfigParam));
  359. config.subsample = FORMAT_MAX;
  360. while ((c=getopt_long(argc, argv, shortOpt, longOpt, &l)) != -1) {
  361. switch (c) {
  362. case 'h':
  363. Help(argv[0]);
  364. break;
  365. case 'f':
  366. devConfig.reset = FALSE;
  367. break;
  368. case 0:
  369. if (strcmp(longOpt[l].name, "aclk") == 0) {
  370. devConfig.aclk=atoi(optarg);
  371. if (devConfig.aclk < ACLK_MIN || devConfig.aclk > ACLK_MAX) {
  372. JLOG(ERR, "Invalid ACLK(%d) valid range(%d ~ %d)\n", devConfig.aclk, ACLK_MIN, ACLK_MAX);
  373. Help(argv[0]);
  374. }
  375. }
  376. else if (strcmp(longOpt[l].name, "cclk") == 0) {
  377. devConfig.cclk=atoi(optarg);
  378. if (devConfig.cclk < CCLK_MIN || devConfig.cclk > CCLK_MAX) {
  379. JLOG(ERR, "Invalid CCLK(%d) valid range(%d ~ %d)\n", devConfig.cclk, CCLK_MIN, CCLK_MAX);
  380. Help(argv[0]);
  381. }
  382. }
  383. else {
  384. if (ParseDecTestLongArgs((void*)&config, longOpt[l].name, optarg) == FALSE) {
  385. Help(argv[0]);
  386. }
  387. }
  388. break;
  389. default:
  390. Help(argv[0]);
  391. break;
  392. }
  393. }
  394. if (CNM_InitTestDev(devConfig) == FALSE) {
  395. JLOG(ERR, "Failed to initialize FPGA\n");
  396. return 1;
  397. }
  398. #ifndef SUPPORT_FFMPEG
  399. config.feedingMode = FEEDING_METHOD_FIXED_SIZE;
  400. #endif
  401. /* CHECK PARAMETERS */
  402. if ((config.iHorScaleMode || config.iVerScaleMode) && config.roiEnable) {
  403. JLOG(ERR, "Invalid operation mode : ROI cannot work with the scaler\n");
  404. return 1;
  405. }
  406. if(config.packedFormat && config.roiEnable) {
  407. JLOG(ERR, "Invalid operation mode : ROI cannot work with the packed format conversion\n");
  408. return 1;
  409. }
  410. if (config.roiEnable && (config.rotation || config.mirror)) {
  411. JLOG(ERR, "Invalid operation mode : ROI cannot work with the PPU.\n");
  412. }
  413. ext = GetFileExtension(config.bitstreamFileName);
  414. if (strcasecmp("avi", ext) == 0 || strcasecmp("mkv", ext) == 0) {
  415. config.feedingMode = FEEDING_METHOD_FRAME_SIZE;
  416. }
  417. InitLog("ErrorLog.txt");
  418. ret = TestDecoder(&config);
  419. DeInitLog();
  420. return ret == TRUE ? 0 : 1;
  421. }
  422. #endif /* SUPPORT_MULTI_INSTANCE_TEST */