OMX_ERRORTYPE cmd_process(HTEST *hTest) { char rep[10]; OMX_BOOL bExit = OMX_FALSE; while(bExit == OMX_FALSE) { printf("Input test cmd:\n"); printf("[l]load component\n"); printf("[s]state trans\n"); printf("[x]exit\n"); scanf("%s", rep); if(rep[0] == 'l') load_component(hTest); else if(rep[0] == 's') { OMX_U32 state = 0; printf("State trans to:\n"); printf("1 -- Loaded\n"); printf("2 -- Idle\n"); printf("3 -- Executing\n"); printf("4 -- Pause\n"); scanf("%d", &state); StateTrans(hTest, (OMX_STATETYPE)state); } else if(rep[0] == 'x') { unload_component(hTest); bExit = OMX_TRUE; } } return OMX_ErrorNone; }
int main(int argc, char *argv[]) { HTEST *hTest = NULL; OMX_STRING component = NULL; OMX_STRING in_file = NULL, out_file = NULL; OMX_S32 width, height, bitrate; FORMAT fmt; if(argc < 6) { printf("Unit test of vpu encoder component.\n"); printf("This test read data from in_file then store the encoded data to out_file.\n"); printf("Usage: ./bin <in_file> <width> <height> <out_file> <bitrate>\n"); return 0; } OMX_Init(); in_file = argv[1]; width = atoi(argv[2]); height = atoi(argv[3]); out_file = argv[4]; bitrate = atoi(argv[5]); fmt = H264; if (fmt == H264) { component = "OMX.Freescale.std.video_encoder.avc.hw-based"; } else if (fmt == H263) { component = "OMX.Freescale.std.video_encoder.h263.hw-based"; } else { printf("wrong format.\n"); return 0; } hTest = create_test(component, in_file, width, height, out_file, fmt, bitrate); if(hTest == NULL) { printf("Create test failed.\n"); return 0; } load_component(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateExecuting); wait_eos(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateLoaded); unload_component(hTest); delete_test(hTest); OMX_Deinit(); printf("Vpu component test is done.\n"); return 1; }
int main(int argc, char *argv[]) { HTEST *hTest = NULL; OMX_STRING component = NULL; OMX_STRING in_file = NULL, out_file = NULL; FORMAT fmt; if(argc < 4) { printf("Unit test of vpu component.\n"); printf("This test read data from in_file then store the decoded data to out_file.\n"); printf("Usage: ./bin <in_file> <out_file> <format>\n"); printf("format: 0 -- mpeg4\n"); printf(" 1 -- h264\n"); return 0; } OMX_Init(); component = "OMX.Freescale.std.video_decoder.avc.v3.hw-based"; in_file = argv[1]; out_file = argv[2]; fmt = (FORMAT) atoi(argv[3]); hTest = create_test(component, in_file, out_file, fmt); if(hTest == NULL) { printf("Create test failed.\n"); return 0; } #if 1 load_component(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateExecuting); wait_eos(hTest); StateTrans(hTest, OMX_StateIdle); StateTrans(hTest, OMX_StateLoaded); unload_component(hTest); #else cmd_process(hTest); #endif delete_test(hTest); OMX_Deinit(); printf("Vpu component test is done.\n"); return 1; }
OMX_ERRORTYPE cmd_process(HTEST *hTest) { char rep[10]; OMX_BOOL bExit = OMX_FALSE; while(bExit == OMX_FALSE) { printf("Input test cmd:\n"); printf("[f]flush\n"); printf("[x]exit\n"); scanf("%s", rep); if(rep[0] == 'l') load_component(hTest); else if(rep[0] == 's') { OMX_U32 state = 0; printf("State trans to:\n"); printf("0 -- Invalid\n"); printf("1 -- Loaded\n"); printf("2 -- Idle\n"); printf("3 -- Executing\n"); printf("4 -- Pause\n"); printf("5 -- WaitForResources\n"); scanf("%d", &state); StateTrans(hTest, (OMX_STATETYPE)state); } else if(rep[0] == 'f') { OMX_U32 nPortIndex = 0; printf("Want to flush port number:\n"); scanf("%d", &nPortIndex); port_flush(hTest, nPortIndex); } else if(rep[0] == 'd') { OMX_U32 nPortIndex = 0; printf("Want to disbale port number:\n"); scanf("%d", &nPortIndex); port_disable(hTest, nPortIndex); } else if(rep[0] == 'e') { OMX_U32 nPortIndex = 0; printf("Want to enable port number:\n"); scanf("%d", &nPortIndex); port_enable(hTest, nPortIndex); } else if(rep[0] == 'k') { OMX_U32 nSeekPos = 0; printf("seek to second:\n"); scanf("%d", &nSeekPos); OMX_U32 nSeekMode = 0; printf("seek mode [0:Fast,1:Accurate]:\n"); scanf("%d", &nSeekMode); do_seek(hTest, nSeekPos, (OMX_TIME_SEEKMODETYPE)nSeekMode); } else if(rep[0] == 'x') { MSG sMsg; sMsg.type = EXIT; hTest->pMsgQ->Add(&sMsg); hTest->bStop = OMX_TRUE; bExit = OMX_TRUE; StateTrans(hTest, (OMX_STATETYPE)2); StateTrans(hTest, (OMX_STATETYPE)1); unload_component(hTest); } } return OMX_ErrorNone; }