s3c6410 JPEG

void TestDecoder()
{
	char 	*InBuf = NULL;
	char 	*OutBuf = NULL;
	FILE 	*fp;
	FILE 	*CTRfp;
	UINT32 	fileSize;
	long 	streamSize;
	int		handle;
	INT32 	width, height, samplemode;
	JPEG_ERRORTYPE ret;
	char 	outFilename[128];
	char 	inFilename[128];
	BOOL	result = TRUE;
#ifdef FPS
	struct timeval start;
	struct timeval stop;
	unsigned int	time = 0;
#endif


	printf("------------------------Decoder Test Start ---------------------\n");

	//
	// Get input/output file name                            //
	//
	
	CTRfp = fopen(CTRL_FILE_NAME, "rb");
	if(CTRfp == NULL){
		printf("file open error : %s\n", CTRL_FILE_NAME);
		return;
	}

	do{
		memset(outFilename, 0x00, sizeof(outFilename));
		memset(inFilename, 0x00, sizeof(inFilename));

		fscanf(CTRfp, "%s", inFilename);

		if(inFilename[0] == '#'){
			printf("------------------------Decoder Test Done ---------------------\n");
			fclose(CTRfp);
			return;
		}

		fscanf(CTRfp, "%s", outFilename);

		if(inFilename == NULL || outFilename == NULL){
			printf("read file error\n");
			printf("------------------------Decoder Test Done ---------------------\n");
			fclose(CTRfp);
			return;
		}
	
		printf("inFilename : %s \noutFilename : %s\n", inFilename, outFilename);
		//
		// 1. handle Init                                           //
		//
		#ifdef FPS
			gettimeofday(&start, NULL);
		#endif
		
		handle = SsbSipJPEGDecodeInit();
		if(handle < 0)
			break;

		#ifdef FPS
			gettimeofday(&stop, NULL);
			time += measureTime(&start, &stop);
		#endif

		//
		// 2. open JPEG file to decode                              //
		//
		fp = fopen(inFilename, "rb");
		if(fp == NULL){
			result = FALSE;
			printf("file open error : %s\n", inFilename);
			break;
		}
		fseek(fp, 0, SEEK_END);
		fileSize = ftell(fp);
		fseek(fp, 0, SEEK_SET);

		printD("filesize : %d\n", fileSize);

		//
		// 3. get Input buffer address                              //
		//
		InBuf = SsbSipJPEGGetDecodeInBuf(handle, fileSize);
		if(InBuf == NULL){
			printf("Input buffer is NULL\n");
			result = FALSE;
			break;
		}
		printD("inBuf : 0x%x\n", InBuf);

		//
		// 4. put JPEG frame to Input buffer                        //
		//
		fread(InBuf, 1, fileSize, fp);
		fclose(fp);


		//
		// 5. Decode JPEG frame                                     //
		//
		#ifdef FPS
			gettimeofday(&start, NULL);
		#endif
		
		ret = SsbSipJPEGDecodeExe(handle);
		
		#ifdef FPS
			gettimeofday(&stop, NULL);
			time += measureTime(&start, &stop);
			printf("[JPEG Decoding Performance] Elapsed time : %u\n", time);
			time = 0;
		#endif

		if(ret != JPEG_OK){
			printf("Decoding failed\n");
			result = FALSE;
			break;
		}
		
		//
		// 6. get Output buffer address                             //
		//
		OutBuf = SsbSipJPEGGetDecodeOutBuf(handle, &streamSize);
		if(OutBuf == NULL){
			printf("Output buffer is NULL\n");
			result = FALSE;
			break;
		}
		printD("OutBuf : 0x%x streamsize : %d\n", OutBuf, streamSize);

		//
		// 7. get decode config.                                    //
		//
		SsbSipJPEGGetConfig(JPEG_GET_DECODE_WIDTH, &width);
		SsbSipJPEGGetConfig(JPEG_GET_DECODE_HEIGHT, &height);
		SsbSipJPEGGetConfig(JPEG_GET_SAMPING_MODE, &samplemode);

		printD("width : %d height : %d samplemode : %d\n", width, height, samplemode);

		//
		// 8. wirte output file & dispaly to LCD                    //
		//
	#if (TEST_DECODE_OUTPUT_YCBYCR == 1)
		DecodeFileOutYCBYCR(OutBuf, streamSize, outFilename); // YCBYCR interleaved
	#elif (TEST_DECODE_OUTPUT_YUV422 == 1)
		DecodeFileOutYUV422(OutBuf, streamSize, outFilename);  // yuv422 non-interleaved
	#endif

		//
		// 9. finalize handle                                      //
		//
		SsbSipJPEGDecodeDeInit(handle);
		sleep(1);
	}while(1);

	if(result == FALSE){
		SsbSipJPEGDecodeDeInit(handle);
	}
	
	fclose(CTRfp);
	printf("------------------------Decoder Test Done ---------------------\n");
}


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值