Beispiel #1
0
/***************************************************************************************************
	Func:
		malloc_frame
	Description:
		malloc a new empty frame
	Return:
		VPU_OK:		malloc sucessfully
		VPU_ERR:	malloc failed
	Author:
		Jian Huan
	Date:
		2010-12-7 17:29:53
 **************************************************************************************************/
RK_S32 framemanager::malloc_frame(VPU_FRAME *frame, RK_U32 size)
{
	RK_S32		status;
    RK_S32      timeout = 0xFF;
	do{
		/*@jh:这里缺少一个延时判断,一旦malloc总是不成功,则需要有个时间判断,防止死循环*/
		status = VPUMallocLinear(&frame->vpumem, size);
        if(status != VPU_OK)
        {
            usleep(5000);
            if(timeout-- < 0)
            return status;
        }
	}while(status != VPU_OK);

	return status;
}
/***************************************************************************************************
	Func:
		malloc_frame
	Description:
		malloc a new empty frame
	Return:
		VPU_OK:		malloc sucessfully
		VPU_ERR:	malloc failed
	Author:
		Jian Huan
	Date:
		2010-12-7 17:29:53
 **************************************************************************************************/
RK_S32 framemanager::malloc_frame(VPU_FRAME *frame, RK_U32 size,void *ctx)
{
	RK_S32		status;
    RK_S32      timeout = 0xFF;
	do{
		/*@jh:这里缺少一个延时判断,一旦malloc总是不成功,则需要有个时间判断,防止死循环*/
        if(ctx != NULL){
		status = VPUMallocLinearFromRender(&frame->vpumem, size,ctx);
            if(status != VPU_OK){
                return status;
            }
        }else{
		    status = VPUMallocLinear(&frame->vpumem, size);
        }
        if(status != VPU_OK)
        {
            usleep(5000);
            if(timeout-- < 0)
            return status;
        }
	}while(status != VPU_OK);

	return status;
}
Beispiel #3
0
status_t deinterlace_dev::perform(VPU_FRAME *frm, uint32_t bypass)
{
    status_t ret = NO_INIT;
    VPUMemLinear_t deInterlaceFrame;
    ret = VPUMallocLinear(&deInterlaceFrame, frm->FrameHeight*frm->FrameWidth*3/2);
    if (!ret) {
        uint32_t width    = frm->FrameWidth;
        uint32_t height   = frm->FrameHeight;
        uint32_t srcYAddr = frm->FrameBusAddr[0];
        uint32_t srcCAddr = frm->FrameBusAddr[1];
        uint32_t dstYAddr = deInterlaceFrame.phy_addr;
        uint32_t dstCAddr = deInterlaceFrame.phy_addr + width*height;
        frm->FrameBusAddr[0] = dstYAddr;
        frm->FrameBusAddr[1] = dstCAddr;
        switch (dev_status) {
        case USING_IPP : {
            struct rk29_ipp_req ipp_req;
            memset(&ipp_req,0,sizeof(rk29_ipp_req));
            ipp_req.src0.YrgbMst = srcYAddr;
            ipp_req.src0.CbrMst  = srcCAddr;
            ipp_req.src0.w = width;
            ipp_req.src0.h = height;
            ipp_req.src0.fmt = IPP_Y_CBCR_H2V2;
            ipp_req.dst0.w = width;
            ipp_req.dst0.h = height;
            ipp_req.src_vir_w = width;
            ipp_req.dst_vir_w = width;
            ipp_req.timeout = 100;
            ipp_req.flag = IPP_ROT_0;
            ipp_req.deinterlace_enable = bypass ? 0 : 1;
            ipp_req.deinterlace_para0 = 8;
            ipp_req.deinterlace_para1 = 16;
            ipp_req.deinterlace_para2 = 8;
            ipp_req.dst0.YrgbMst = dstYAddr;
            ipp_req.dst0.CbrMst  = dstCAddr;
            ret = ioctl(dev_fd, IPP_BLIT_ASYNC, &ipp_req);
        } break;
        case USING_IEP : {
            /**
            IEP_FORMAT_ARGB_8888    = 0x0,
            IEP_FORMAT_ABGR_8888    = 0x1,
            IEP_FORMAT_RGBA_8888    = 0x2,
            IEP_FORMAT_BGRA_8888    = 0x3,
            IEP_FORMAT_RGB_565      = 0x4,
            IEP_FORMAT_BGR_565      = 0x5,

            IEP_FORMAT_YCbCr_422_SP = 0x10,
            IEP_FORMAT_YCbCr_422_P  = 0x11,
            IEP_FORMAT_YCbCr_420_SP = 0x12,
            IEP_FORMAT_YCbCr_420_P  = 0x13,
            IEP_FORMAT_YCrCb_422_SP = 0x14,
            IEP_FORMAT_YCrCb_422_P  = 0x15,
            IEP_FORMAT_YCrCb_420_SP = 0x16,
            IEP_FORMAT_YCrCb_420_P  = 0x17
            */

            ops.init_discrete(api, width, height, 0, 0, width, height, 0x12, srcYAddr, srcCAddr, 0,
                                  width, height, 0, 0, width, height, 0x12, dstYAddr, dstCAddr, 0);

            if (!bypass) {
                if (0 > ops.config_yuv_deinterlace(api)) {
                    DEINTER_ERR("Failure to Configure YUV DEINTERLACE\n");
                }
            }

            ops.run_async_ncb(api);

        } break;
        case USING_PP : {
            if (NULL == priv_data) {
                PP_OPERATION opt;
                memset(&opt, 0, sizeof(opt));
                opt.srcAddr     = srcYAddr;
                opt.srcFormat   = PP_IN_FORMAT_YUV420SEMI;
                opt.srcWidth    = opt.srcHStride = width;
                opt.srcHeight   = opt.srcVStride = height;

                opt.dstAddr     = dstYAddr;
                opt.dstFormat   = PP_OUT_FORMAT_YUV420INTERLAVE;
                opt.dstWidth    = opt.dstHStride = width;
                opt.dstHeight   = opt.dstVStride = height;
                opt.deinterlace = 1;
                opt.vpuFd       = dev_fd;
                ret = ppOpInit(&priv_data, &opt);
                if (ret) {
                    DEINTER_ERR("ppOpInit failed");
                    priv_data = NULL;
                }
            }

            if (NULL != priv_data) {
                PP_OP_HANDLE hnd = (PP_OP_HANDLE)priv_data;
                ppOpSet(hnd, PP_SET_SRC_ADDR, srcYAddr);
                ppOpSet(hnd, PP_SET_DST_ADDR, dstYAddr);
                ret = ppOpPerform(hnd);
            }
        } break;
        default : {
            ret = BAD_VALUE;
        } break;
        }

        if (!ret) {
            VPUMemDuplicate(&frm->vpumem,&deInterlaceFrame);
        } else {
            DEINTER_ERR("ioctl: IPP_BLIT_ASYNC faild!");
        }
        VPUFreeLinear(&deInterlaceFrame);
    }
    return ret;
}
Beispiel #4
0
/*放大:
	重视速度:fast_bilinear, point
	重视质量:cubic, spline, lanczos
  缩小:
    重视速度:fast_bilinear, point
	重视质量:gauss, bilinear
	重视锐度:cubic,spline,lanczos
*/
int main(int argc, char **argv){
	printf("  <%s>_%d \n", __func__, __LINE__);
	VpuApiDemoCmdContext_t demoCmdCtx;
	VpuApiDemoCmdContext_t* cmd = &demoCmdCtx;
	RK_S32 ret =0;
	if ((ret = parse_options(argc, argv, cmd)) !=0) {
        	if (ret == VPU_DEMO_PARSE_HELP_OK) {
        		return 0;
        	}
		printf("  <%s>_%d    error argv ..... \n", __func__, __LINE__);
		return 0;
	}
#if TEST_SCALE
	VPUMemLinear_t inMem;
	//VPUMemLinear_t outMem;
	int inputw = 2592;
	int inputh = 1944;
	int outw = 160;
	int outh = 128;
	FILE *yuvFile = NULL;
	int in_size = inputw*inputh*3;
	VPUMallocLinear(&inMem, in_size);
	yuvFile = fopen("/flash/yuv2592_1944.yuv","rb");
	fread(inMem.vir_addr,1,in_size,yuvFile);
	VPUMemFlush(&inMem);
	fclose(yuvFile);
	{
		int w = inputw;
		int h = inputh;
		uint8_t * src = (uint8_t*)inMem.vir_addr;
		uint8_t * yuvsrc[4] = {src, src+w*h, NULL, NULL};
		int yuvsrcstride[4] = {inputw, inputw, 0, 0};
		uint8_t * dst = (uint8_t*)malloc(outw*outh*3/2);
		uint8_t * yuvdst[4] = {dst, dst+outw*outh, NULL, NULL};
		int yuvdststride[4] = {outw, outw, 0, 0};
		struct SwsContext *sws = sws_getContext(w,h, PIX_FMT_NV12, outw, outh, PIX_FMT_NV12,
			SWS_FAST_BILINEAR, NULL, NULL, NULL);
		ALOGE("before sws_scale.");
		sws_scale(sws, yuvsrc, yuvsrcstride, 0, inputh, yuvdst, yuvdststride);
		ALOGE("after sws_scale.");
		sws_freeContext(sws);
		yuvFile = fopen("/flash/yuv160_128.yuv", "wb");
		fwrite(dst, 1, outw*outh*3/2, yuvFile);
		fclose(yuvFile);
		free(dst);
	}
	VPUFreeLinear(&inMem);	
#else
	int loopCounts = 0;
	JpegEncInInfo JpegInInfo;
	RkExifInfo exifInfo;
	RkGPSInfo gpsInfo;
	char* maker = "rockchip sb";
	char* model = "rockchip camera";
	JpegEncOutInfo JpegOutInfo;
	char *time = "2011:07:05 17:53:53";
	char* gpsprocessmethod = "GPS chuli ge mao a.";
	int jpegw = cmd->width;//1680;//2592;
	int jpegh = cmd->height;//1050;//1944;
	//int jpegw = 160;
	//int jpegh = 120;
	VPUMemLinear_t inMem;
	VPUMemLinear_t outMem;
	printf("  <%s>_%d   <%d, %d>\n", __func__, __LINE__, jpegw, jpegh);
VPUMemLinear_t tmp180Mem;
//#define RGB_DEBUG

#ifndef RGB_DEBUG
	int in_size = jpegw*jpegh*3/2+897;//yuv420
#else
	int in_size;
	int pixelBytes = 2;
	int in_rgb_size = in_size = jpegw*jpegh*pixelBytes;//xrgb888 rgb565
	int in_yuv420_size = jpegw*jpegh*3/2;//yuv420
#endif
	printf("  <%s>_%d \n", __func__, __LINE__);
	int out_size = jpegw*jpegh + 160 * 128*16;
	//void* thumbBuf = NULL;
	//FILE *tFile = NULL;
	int thumbfilelen = -1;
FILE *file = NULL;
FILE *yuvFile = NULL;
#ifdef RGB_DEBUG
char* yuvdata = (char*)malloc(in_yuv420_size);
	printf("  <%s>_%d \n", __func__, __LINE__);
if(yuvdata == NULL){
	ALOGE("f**k 1.");
}
	printf("  <%s>_%d \n", __func__, __LINE__);
VPUMallocLinear(&inMem, in_rgb_size);
#else
	printf("  <%s>_%d \n", __func__, __LINE__);
VPUMallocLinear(&inMem, in_size);
	printf("  <%s>_%d \n", __func__, __LINE__);
#endif
	VPUMallocLinear(&outMem, out_size);
	gMem = &outMem;

//yuvFile = fopen("/sdcard/1680_1050_yuv420sp.yuv","rb");
yuvFile = fopen(cmd->input_file,"rb");
//yuvFile = fopen("/flash/160_120_yuv420sp.yuv","rb");
#ifdef RGB_DEBUG//rgb
fread(yuvdata, 1, in_yuv420_size, yuvFile);
//memset(yuvdata, 0xf0, in_yuv420_size);
#if 1
{
	int w = jpegw;
        int h = jpegh;
        uint8_t * dst = (uint8_t*)inMem.vir_addr;
        uint8_t * yuvdst[4] = {dst, NULL, NULL, NULL};
        int yuvdststride[4] = {pixelBytes*w, 0, 0, 0};
        uint8_t * src = (uint8_t*)yuvdata;
        uint8_t * yuvsrc[4] = {src, src+w*h, NULL, NULL};
        int yuvsrcstride[4] = {w, w, 0, 0};
        struct SwsContext *sws = sws_getContext(w,h, PIX_FMT_NV12, w, h, PIX_FMT_RGB565,//PIX_FMT_RGB32
                  SWS_FAST_BILINEAR, NULL, NULL, NULL);
        ALOGE("before sws_scale1.");
        sws_scale(sws, yuvsrc, yuvsrcstride, 0, h, yuvdst, yuvdststride);
        ALOGE("after sws_scale1.");
        sws_freeContext(sws);
        //yuvFile = fopen("/flash/yuv160_128.yuv", "wb");
        //fwrite(dst, 1, outw*outh*3/2, yuvFile);
        //fclose(yuvFile);
        //free(dst);
}
free(yuvdata);
#else
free(yuvdata);
{
int i = 0;
unsigned char* st = (unsigned char*)inMem.vir_addr;
unsigned int c = 0xff;
int j = 0;
for(;i<jpegh;i++){
	for(j = 0; j<jpegw; j++){
		*st++ = 0;
		*st++ = 0;
		*st++ = 0xff;
		*st++ = 0;
	}
	//c += 0xff;
}
printf("color: 0x%x\n", *(unsigned int*)inMem.vir_addr);
}
#endif
#else
fread(inMem.vir_addr,1,in_size,yuvFile);
#endif
VPUMemFlush(&inMem);
fclose(yuvFile);

	exifInfo.maker = maker;
	exifInfo.makerchars = 12;
	exifInfo.modelstr = model;
	exifInfo.modelchars = 16;
	exifInfo.Orientation = 1;
	memcpy(exifInfo.DateTime, time, 20);
	exifInfo.ExposureTime.num = 400;
	exifInfo.ExposureTime.denom = 1;
	exifInfo.ApertureFNumber.num = 0x118;
	exifInfo.ApertureFNumber.denom = 0x64;
	exifInfo.ISOSpeedRatings = 0x59;
	exifInfo.CompressedBitsPerPixel.num = 0x4;
	exifInfo.CompressedBitsPerPixel.denom = 0x1;
	exifInfo.ShutterSpeedValue.num = 0x452;
	exifInfo.ShutterSpeedValue.denom = 0x100;
	exifInfo.ApertureValue.num = 0x2f8;
	exifInfo.ApertureValue.denom = 0x100;
	exifInfo.ExposureBiasValue.num = 0;
	exifInfo.ExposureBiasValue.denom = 0x100;
	exifInfo.MaxApertureValue.num = 0x02f8;
	exifInfo.MaxApertureValue.denom = 0x100;
	exifInfo.MeteringMode = 02;
	exifInfo.Flash = 0x10;
	exifInfo.FocalLength.num = 0x4;
	exifInfo.FocalLength.denom = 0x1;
	exifInfo.FocalPlaneXResolution.num = 0x8383;
	exifInfo.FocalPlaneXResolution.denom = 0x67;
	exifInfo.FocalPlaneYResolution.num = 0x7878;
	exifInfo.FocalPlaneYResolution.denom = 0x76;
	exifInfo.SensingMethod = 2;
	exifInfo.FileSource = 3;
	exifInfo.CustomRendered = 1;
	exifInfo.ExposureMode = 0;
	exifInfo.WhiteBalance = 0;
	exifInfo.DigitalZoomRatio.num = jpegw;
	exifInfo.DigitalZoomRatio.denom = jpegw;
	exifInfo.SceneCaptureType = 0x01;

	gpsInfo.GPSLatitudeRef[0] = 'N';
	gpsInfo.GPSLatitudeRef[1] = '\0';
	gpsInfo.GPSLatitude[0].num = 0x77;
	gpsInfo.GPSLatitude[0].denom = 1;
	gpsInfo.GPSLatitude[1].num = 0x66;
	gpsInfo.GPSLatitude[1].denom = 1;
	gpsInfo.GPSLatitude[2].num = 0x55;
	gpsInfo.GPSLatitude[2].denom = 1;
	gpsInfo.GPSLongitudeRef[0] = 'E';
	gpsInfo.GPSLongitudeRef[1] = '\0';
	gpsInfo.GPSLongitude[0].num = 0x44;
	gpsInfo.GPSLongitude[0].denom = 1;
	gpsInfo.GPSLongitude[1].num = 0x33;
	gpsInfo.GPSLongitude[1].denom = 1;
	gpsInfo.GPSLongitude[2].num = 0x22;
	gpsInfo.GPSLongitude[2].denom = 1;
	gpsInfo.GPSAltitudeRef = 1;
	gpsInfo.GPSAltitude.num = 0x88;
	gpsInfo.GPSAltitude.denom = 0x1;
	gpsInfo.GpsTimeStamp[0].num = 18;
	gpsInfo.GpsTimeStamp[0].denom = 1;
	gpsInfo.GpsTimeStamp[1].num = 36;
	gpsInfo.GpsTimeStamp[1].denom = 1;
	gpsInfo.GpsTimeStamp[2].num = 48;
	gpsInfo.GpsTimeStamp[2].denom = 1;
	memcpy(gpsInfo.GpsDateStamp,"2011:07:05",11);//"YYYY:MM:DD\0"
	gpsInfo.GPSProcessingMethod = gpsprocessmethod;
	gpsInfo.GpsProcessingMethodchars = 20;//length of GpsProcessingMethod

	JpegInInfo.frameHeader = 1;
	JpegInInfo.rotateDegree = DEGREE_0;
	JpegInInfo.y_rgb_addr = inMem.phy_addr;
#ifndef RGB_DEBUG
	JpegInInfo.uv_addr = inMem.phy_addr + (jpegw*jpegh);
#else
	JpegInInfo.uv_addr = 0;
#endif
	JpegInInfo.y_vir_addr = (unsigned char*)inMem.vir_addr;
#ifndef RGB_DEBUG
	JpegInInfo.uv_vir_addr = ((unsigned char*)inMem.vir_addr + jpegw*jpegh);
#else
	JpegInInfo.uv_vir_addr = 0;
#endif
	if(JpegInInfo.rotateDegree == DEGREE_180){
		VPUMallocLinear(&tmp180Mem, in_size);
		JpegInInfo.yuvaddrfor180 = tmp180Mem.phy_addr;
	}else{
		JpegInInfo.yuvaddrfor180 = NULL;
	}
	JpegInInfo.inputW = jpegw;
	JpegInInfo.inputH = jpegh;
#ifdef RGB_DEBUG
	JpegInInfo.type = HWJPEGENC_RGB565;//HWJPEGENC_RGB888;
#else
	JpegInInfo.type = JPEGENC_YUV420_SP;
#endif
	JpegInInfo.qLvl = 9;
//tFile = fopen("/flash/thumbtest.jpg","rb");
//fseek(tFile, SEEK_SET, SEEK_END);
//thumbfilelen = ftell(tFile);//bu chao guo 2G
//thumbBuf = malloc(thumbfilelen);
//fseek(tFile, SEEK_SET, SEEK_SET);
//fread(thumbBuf,1, thumbfilelen, tFile);
//fclose(tFile);
#ifdef RGB_DEBUG
	JpegInInfo.doThumbNail = 1;
#else
	JpegInInfo.doThumbNail = 0;//insert thumbnail at APP0 extension if motionjpeg, else at APP1 extension
#endif
	JpegInInfo.thumbData = NULL;//if thumbData is NULL, do scale, the type above can not be 420_P or 422_UYVY
	JpegInInfo.thumbDataLen = -1;
	JpegInInfo.thumbW = 160;
	JpegInInfo.thumbH = 128;//128;
	JpegInInfo.thumbqLvl = 5;
	JpegInInfo.exifInfo = &exifInfo;
	JpegInInfo.gpsInfo = &gpsInfo;

	JpegOutInfo.outBufPhyAddr = outMem.phy_addr;
	JpegOutInfo.outBufVirAddr = (unsigned char*)outMem.vir_addr;
	JpegOutInfo.outBuflen = out_size;
	JpegOutInfo.jpegFileLen = 0;
	JpegOutInfo.cacheflush = flush;
ALOGE("outbuflen: %d", out_size);
static char str[32] = {'\0'};
for(loopCounts = 0; loopCounts < 1; loopCounts++){
	if(hw_jpeg_encode(&JpegInInfo, &JpegOutInfo) < 0 || JpegOutInfo.jpegFileLen <= 0){
		ALOGE("hw jpeg encode fail.");
	}else{
ALOGD("final file offset: %d, size: %d", JpegOutInfo.finalOffset, JpegOutInfo.jpegFileLen);
		//VPUMemFlush(&outMem);
		//SkBitmap bitmap;
		//SkImageDecoder::DecodeMemory(JpegOutInfo.outBufVirAddr + JpegOutInfo.finalOffset, JpegOutInfo.jpegFileLen, &bitmap,
                //             SkBitmap::kARGB_8888_Config, SkImageDecoder::kDecodePixels_Mode);
		//ALOGE("decode complete. %p", bitmap.getPixels());
		sprintf(str, cmd->output_file, loopCounts);
		file = fopen(str,"wb");
		fwrite(JpegOutInfo.outBufVirAddr + JpegOutInfo.finalOffset, 1, JpegOutInfo.jpegFileLen, file);
		fclose(file);
		//ALOGE();
	}
}
	//free(thumbBuf);
	VPUFreeLinear(&inMem);
	VPUFreeLinear(&outMem);
	if(JpegInInfo.rotateDegree == DEGREE_180){
		VPUFreeLinear(&tmp180Mem);
	}
#endif
	return 0;
}
int main(int argc, char **argv)
{
    int i;
    pthread_t td;
    int ch;

    int pmem_phy_head;
    uint8_t *pmem_vir_head;

    VPUMemLinear_t vpumem; 
    mem_region_t mr;

    mr.src_fmt = IEP_FORMAT_YCbCr_420_SP;
    mr.src_w = 640;
    mr.src_h = 480;

    mr.dst_fmt = IEP_FORMAT_YCbCr_420_SP;
    mr.dst_w = 640;
    mr.dst_h = 480;

    /// get options
    opterr = 0;
    while ((ch = getopt(argc, argv, "f:w:h:c:F:W:H:C:t:x:")) != -1) {
        switch (ch) {
        case 'w':
            mr.src_w = atoi(optarg);
            break;
        case 'h':
            mr.src_h = atoi(optarg);
            break;
        case 'c':
            if (strcmp(optarg, "argb8888") == 0) {
                mr.src_fmt = IEP_FORMAT_ARGB_8888;
            } else if (strcmp(optarg, "abgr8888") == 0) {
                mr.src_fmt = IEP_FORMAT_ABGR_8888;
            } else if (strcmp(optarg, "rgba8888") == 0) {
                mr.src_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "bgra8888") == 0) {
                mr.src_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "rgb565") == 0) {
                mr.src_fmt = IEP_FORMAT_RGB_565;
            } else if (strcmp(optarg, "bgr565") == 0) {
                mr.src_fmt = IEP_FORMAT_BGR_565;
            } else if (strcmp(optarg, "yuv422sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_422_SP;
            } else if (strcmp(optarg, "yuv422p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_422_P;
            } else if (strcmp(optarg, "yuv420sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_420_SP;
            } else if (strcmp(optarg, "yuv420p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_420_P;
            } else if (strcmp(optarg, "yvu422sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_422_SP;
            } else if (strcmp(optarg, "yvu422p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_422_P;
            } else if (strcmp(optarg, "yvu420sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_420_SP;
            } else if (strcmp(optarg, "yvu420p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_420_P;
            }
            break;
        case 'W':
            mr.dst_w = atoi(optarg);
            break;
        case 'H':
            mr.dst_h = atoi(optarg);
            break;
        case 'C':
            if (strcmp(optarg, "argb8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_ARGB_8888;
            } else if (strcmp(optarg, "abgr8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_ABGR_8888;
            } else if (strcmp(optarg, "rgba8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "bgra8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "rgb565") == 0) {
                mr.dst_fmt = IEP_FORMAT_RGB_565;
            } else if (strcmp(optarg, "bgr565") == 0) {
                mr.dst_fmt = IEP_FORMAT_BGR_565;
            } else if (strcmp(optarg, "yuv422sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_422_SP;
            } else if (strcmp(optarg, "yuv422p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_422_P;
            } else if (strcmp(optarg, "yuv420sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_420_SP;
            } else if (strcmp(optarg, "yuv420p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_420_P;
            } else if (strcmp(optarg, "yvu422sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_422_SP;
            } else if (strcmp(optarg, "yvu422p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_422_P;
            } else if (strcmp(optarg, "yvu420sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_420_SP;
            } else if (strcmp(optarg, "yvu420p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_420_P;
            }
            break;
        case 'f':
            ALOGD("input filename: %s\n", optarg);
            strcpy(mr.src_url, optarg);
            break;
        case 'F':
            ALOGD("output filename: %s\n", optarg);
            strcpy(mr.dst_url, optarg);
            break;
        case 't':
            if (strcmp(optarg, "denoise") == 0) {
                mr.testcase = TEST_CASE_DENOISE;
            } else if (strcmp(optarg, "yuvenhance") == 0) {
                mr.testcase = TEST_CASE_YUVENHANCE;
            } else if (strcmp(optarg, "rgbenhance") == 0) {
                mr.testcase = TEST_CASE_RGBENHANCE;
            } else if (strcmp(optarg, "deinterlace") == 0) {
                mr.testcase = TEST_CASE_DEINTERLACE;
            } else {
                mr.testcase = TEST_CASE_NONE;
            }
            break;
        case 'x':
            ALOGD("configure filename: %s\n", optarg);
            strcpy(mr.cfg_url, optarg);
            break;
        default:
            ;
        }
    }


    /// allocate in/out memory and initialize memory address
    VPUMallocLinear(&vpumem, 12<<20);

    pmem_phy_head = vpumem.phy_addr;//region.offset;
    pmem_vir_head = (uint8_t*)vpumem.vir_addr;

    mr.len_reg = 0x100;
    mr.len_src = 5<<20;
    mr.len_dst = 5<<20;

    mr.phy_reg = vpumem.phy_addr;
    pmem_phy_head += mr.len_reg;
    mr.phy_src = pmem_phy_head;
    pmem_phy_head += mr.len_src;
    mr.phy_dst = pmem_phy_head;
    pmem_phy_head += mr.len_dst;

    mr.vir_reg = (uint8_t*)vpumem.vir_addr;
    pmem_vir_head += mr.len_reg;
    mr.vir_src = pmem_vir_head;
    pmem_vir_head += mr.len_src;
    mr.vir_dst = pmem_vir_head;
    pmem_vir_head += mr.len_dst;

    pthread_create(&td, NULL, iep_process_thread, &mr);

    pthread_join(td, NULL);

    VPUFreeLinear(&vpumem);

    return 0;
}