int main(int argc, char** argv) { android::ProcessState::self()->startThreadPool(); printf("Decoding jpeg with libjpeg...\n"); SkJPEGImageDecoder* libjpeg = new SkJPEGImageDecoder; testDecoder(libjpeg, argv[1]); printf("\nDecoding jpeg with OMX...\n"); OmxJpegImageDecoder* omx = new OmxJpegImageDecoder; testDecoder(omx, argv[1]); return 0; }
/** * Test the UTF-7 decoder. */ nsresult testUTF7Decoder() { char * testName = "T108"; printf("\n[%s] Unicode <- UTF7\n", testName); // create converter CREATE_DECODER("utf-7"); // test data char src[] = {"+ADwAIQ-DOC"}; PRUnichar exp[] = {'<','!','D','O','C'}; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
/** * Test the M-UTF-7 decoder. */ nsresult testMUTF7Decoder() { char * testName = "T107"; printf("\n[%s] Unicode <- MUTF7\n", testName); // create converter CREATE_DECODER("x-imap4-modified-utf7"); // test data char src[] = {"\x50\x51\x52\x53&AAAAAAAA-&-&AAA-"}; PRUnichar exp[] = {0x0050,0x0051,0x0052,0x0053,0x0000,0x0000,0x0000,'&',0x0000}; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
/** * Test the UTF8 decoder. */ nsresult testUTF8Decoder() { char * testName = "T106"; printf("\n[%s] Unicode <- UTF8\n", testName); // create converter CREATE_DECODER("utf-8"); #ifdef NOPE // XXX decomment this when I have test data // test data char src[] = {}; PRUnichar exp[] = {}; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); #endif // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
/** * Test the EUCJP decoder. */ nsresult testEUCJPDecoder() { char * testName = "T103"; printf("\n[%s] Unicode <- EUCJP\n", testName); // create converter CREATE_DECODER("euc-jp"); // test data char src[] = {"\x45"}; PRUnichar exp[] = {0x0045}; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
/** * Test the ISO2022JP decoder. */ nsresult testISO2022JPDecoder() { char * testName = "T102"; printf("\n[%s] Unicode <- ISO2022JP\n", testName); // create converter CREATE_DECODER("iso-2022-jp"); // test data char src[] = {"\x0d\x7f\xdd" "\x1b(J\xaa\xdc\x41" "\x1b$B\x21\x21" "\x1b$@\x32\x37" "\x1b(J\x1b(B\xcc"}; PRUnichar exp[] = {0x000d,0x007f,0xfffd, 0xff6a,0xFF9C,0x0041, 0x3000, 0x5378, 0xfffd}; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
nsresult testDecoderFromFiles(char * aCharset, char * aSrcFile, char * aResultFile) { // create converter CREATE_DECODER(aCharset); PRInt32 srcLen = GENERAL_BUFFER; char src[GENERAL_BUFFER]; PRInt32 expLen = GENERAL_BUFFER/2; PRUnichar exp[GENERAL_BUFFER/2]; res = loadBinaryFile(aSrcFile, src, &srcLen); if (NS_FAILED(res)) return res; res = loadUnicodeFile(aResultFile, exp, &expLen); if (NS_FAILED(res)) return res; // test converter - easy test res = testDecoder(dec, src, srcLen, exp, expLen, "dec"); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } return NS_OK; }
/** * A standard decoder test. */ nsresult standardDecoderTest(char * aTestName, char * aCharset, char * aSrc, PRInt32 aSrcLen, PRUnichar * aRes, PRInt32 aResLen) { printf("\n[%s] Unicode <- %s\n", aTestName, aCharset); // create converter CREATE_DECODER(aCharset); // test converter - easy test res = testDecoder(dec, aSrc, aSrcLen, aRes, aResLen, aTestName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, aTestName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, aSrc, aSrcLen, aRes, aResLen, aTestName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
/** * Test the SJIS decoder. */ nsresult testSJISDecoder() { char * testName = "T105"; printf("\n[%s] Unicode <- SJIS\n", testName); // create converter CREATE_DECODER("Shift_JIS"); // test data char src[] = { "Japanese" /* English */ "\x8a\xbf\x8e\x9a" /* Kanji */ "\x83\x4a\x83\x5e\x83\x4a\x83\x69" /* Kantakana */ "\x82\xd0\x82\xe7\x82\xaa\x82\xc8" /* Hiragana */ "\x82\x50\x82\x51\x82\x52\x82\x60\x82\x61\x82\x62" /* full width 123ABC */ }; PRUnichar exp[] = { 0x004A, 0x0061, 0x0070, 0x0061, 0x006E, 0x0065, 0x0073, 0x0065, 0x6f22, 0x5b57, 0x30ab, 0x30bf, 0x30ab, 0x30ca, 0x3072, 0x3089, 0x304c, 0x306a, 0xff11, 0xff12, 0xff13, 0xff21, 0xff22, 0xff23 }; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
/** * Test the ISO88597 decoder. */ nsresult testISO88597Decoder() { char * testName = "T104"; printf("\n[%s] Unicode <- ISO88597\n", testName); // create converter CREATE_DECODER("iso-8859-7"); // test data char src[] = { "\x09\x0d\x20\x40" "\x80\x98\xa3\xaf" "\xa7\xb1\xb3\xc9" "\xd9\xe3\xf4\xff" }; PRUnichar exp[] = { 0x0009, 0x000d, 0x0020, 0x0040, 0xfffd, 0xfffd, 0x00a3, 0x2015, 0x00a7, 0x00b1, 0x00b3, 0x0399, 0x03a9, 0x03b3, 0x03c4, 0xfffd }; // test converter - normal operation res = testDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // reset converter if (NS_SUCCEEDED(res)) res = resetDecoder(dec, testName); // test converter - stress test if (NS_SUCCEEDED(res)) res = testStressDecoder(dec, src, ARRAY_SIZE(src)-1, exp, ARRAY_SIZE(exp), testName); // release converter NS_RELEASE(dec); if (NS_FAILED(res)) { return res; } else { printf("Test Passed.\n"); return NS_OK; } }
int main(int argc, char **argv) { int i; struct node node = { -1 }; struct node video_node = { -1 }; struct node video_node2 = { -1 }; struct node radio_node = { -1, true }; struct node radio_node2 = { -1, true }; struct node vbi_node = { -1 }; struct node vbi_node2 = { -1 }; /* command args */ int ch; const char *device = NULL; const char *video_device = NULL; /* -d device */ const char *radio_device = NULL; /* -r device */ const char *vbi_device = NULL; /* -V device */ struct v4l2_capability vcap; /* list_cap */ char short_options[26 * 2 * 2 + 1]; int idx = 0; for (i = 0; long_options[i].name; i++) { if (!isalpha(long_options[i].val)) continue; short_options[idx++] = long_options[i].val; if (long_options[i].has_arg == required_argument) short_options[idx++] = ':'; } while (1) { int option_index = 0; short_options[idx] = 0; ch = getopt_long(argc, argv, short_options, long_options, &option_index); if (ch == -1) break; options[(int)ch] = 1; switch (ch) { case OptHelp: usage(); return 0; case OptSetDevice: video_device = optarg; if (video_device[0] >= '0' && video_device[0] <= '9' && strlen(video_device) <= 3) { static char newdev[20]; sprintf(newdev, "/dev/video%s", video_device); video_device = newdev; } break; case OptSetRadioDevice: radio_device = optarg; if (radio_device[0] >= '0' && radio_device[0] <= '9' && strlen(radio_device) <= 3) { static char newdev[20]; sprintf(newdev, "/dev/radio%s", radio_device); radio_device = newdev; } break; case OptSetVbiDevice: vbi_device = optarg; if (vbi_device[0] >= '0' && vbi_device[0] <= '9' && strlen(vbi_device) <= 3) { static char newdev[20]; sprintf(newdev, "/dev/vbi%s", vbi_device); vbi_device = newdev; } break; case OptNoWarnings: show_warnings = false; break; case OptVerbose: show_info = true; break; case ':': fprintf(stderr, "Option `%s' requires a value\n", argv[optind]); usage(); return 1; case '?': fprintf(stderr, "Unknown argument `%s'\n", argv[optind]); usage(); return 1; } } if (optind < argc) { printf("unknown arguments: "); while (optind < argc) printf("%s ", argv[optind++]); printf("\n"); usage(); return 1; } wrapper = options[OptUseWrapper]; struct utsname uts; int v1, v2, v3; uname(&uts); sscanf(uts.release, "%d.%d.%d", &v1, &v2, &v3); if (v1 == 2 && v2 == 6) kernel_version = v3; if (!video_device && !radio_device && !vbi_device) video_device = "/dev/video0"; if (video_device && (video_node.fd = test_open(video_device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", video_device, strerror(errno)); exit(1); } if (radio_device && (radio_node.fd = test_open(radio_device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", radio_device, strerror(errno)); exit(1); } if (vbi_device && (vbi_node.fd = test_open(vbi_device, O_RDWR)) < 0) { fprintf(stderr, "Failed to open %s: %s\n", vbi_device, strerror(errno)); exit(1); } if (video_node.fd >= 0) { node.fd = video_node.fd; device = video_device; node.is_video = true; } else if (radio_node.fd >= 0) { node.fd = radio_node.fd; device = radio_device; node.is_radio = true; printf("is radio\n"); } else if (vbi_node.fd >= 0) { node.fd = vbi_node.fd; device = vbi_device; node.is_vbi = true; } node.device = device; doioctl(&node, VIDIOC_QUERYCAP, &vcap); if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) node.caps = vcap.device_caps; else node.caps = vcap.capabilities; if (node.caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_RDS_CAPTURE | V4L2_CAP_RADIO | V4L2_CAP_TUNER)) node.has_inputs = true; if (node.caps & (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_RDS_OUTPUT | V4L2_CAP_MODULATOR)) node.has_outputs = true; if (node.caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_RDS_CAPTURE)) node.can_capture = true; if (node.caps & (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VBI_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_VIDEO_M2M | V4L2_CAP_SLICED_VBI_OUTPUT | V4L2_CAP_RDS_OUTPUT)) node.can_output = true; /* Information Opts */ if (kernel_version) printf("Running on 2.6.%d\n\n", kernel_version); printf("Driver Info:\n"); printf("\tDriver name : %s\n", vcap.driver); printf("\tCard type : %s\n", vcap.card); printf("\tBus info : %s\n", vcap.bus_info); printf("\tDriver version: %d.%d.%d\n", vcap.version >> 16, (vcap.version >> 8) & 0xff, vcap.version & 0xff); printf("\tCapabilities : 0x%08X\n", vcap.capabilities); printf("%s", cap2s(vcap.capabilities).c_str()); if (vcap.capabilities & V4L2_CAP_DEVICE_CAPS) { printf("\tDevice Caps : 0x%08X\n", vcap.device_caps); printf("%s", cap2s(vcap.device_caps).c_str()); } printf("\nCompliance test for device %s (%susing libv4l2):\n\n", device, wrapper ? "" : "not "); /* Required ioctls */ printf("Required ioctls:\n"); printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&node))); printf("\n"); /* Multiple opens */ printf("Allow for multiple opens:\n"); if (video_device) { video_node2 = node; printf("\ttest second video open: %s\n", ok((video_node2.fd = test_open(video_device, O_RDWR)) < 0)); if (video_node2.fd >= 0) { printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&video_node2))); printf("\ttest VIDIOC_G/S_PRIORITY: %s\n", ok(testPrio(&node, &video_node2))); node.node2 = &video_node2; } } if (radio_device) { radio_node2 = node; printf("\ttest second radio open: %s\n", ok((radio_node2.fd = test_open(radio_device, O_RDWR)) < 0)); if (radio_node2.fd >= 0) { printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&radio_node2))); printf("\ttest VIDIOC_G/S_PRIORITY: %s\n", ok(testPrio(&node, &radio_node2))); node.node2 = &video_node2; } } if (vbi_device) { vbi_node2 = node; printf("\ttest second vbi open: %s\n", ok((vbi_node2.fd = test_open(vbi_device, O_RDWR)) < 0)); if (vbi_node2.fd >= 0) { printf("\ttest VIDIOC_QUERYCAP: %s\n", ok(testCap(&vbi_node2))); printf("\ttest VIDIOC_G/S_PRIORITY: %s\n", ok(testPrio(&node, &vbi_node2))); node.node2 = &video_node2; } } printf("\n"); /* Debug ioctls */ printf("Debug ioctls:\n"); printf("\ttest VIDIOC_DBG_G/S_REGISTER: %s\n", ok(testRegister(&node))); printf("\ttest VIDIOC_LOG_STATUS: %s\n", ok(testLogStatus(&node))); printf("\n"); /* Input ioctls */ printf("Input ioctls:\n"); printf("\ttest VIDIOC_G/S_TUNER: %s\n", ok(testTuner(&node))); printf("\ttest VIDIOC_G/S_FREQUENCY: %s\n", ok(testTunerFreq(&node))); printf("\ttest VIDIOC_S_HW_FREQ_SEEK: %s\n", ok(testTunerHwSeek(&node))); printf("\ttest VIDIOC_ENUMAUDIO: %s\n", ok(testEnumInputAudio(&node))); printf("\ttest VIDIOC_G/S/ENUMINPUT: %s\n", ok(testInput(&node))); printf("\ttest VIDIOC_G/S_AUDIO: %s\n", ok(testInputAudio(&node))); printf("\tInputs: %d Audio Inputs: %d Tuners: %d\n", node.inputs, node.audio_inputs, node.tuners); printf("\n"); /* Output ioctls */ printf("Output ioctls:\n"); printf("\ttest VIDIOC_G/S_MODULATOR: %s\n", ok(testModulator(&node))); printf("\ttest VIDIOC_G/S_FREQUENCY: %s\n", ok(testModulatorFreq(&node))); printf("\ttest VIDIOC_ENUMAUDOUT: %s\n", ok(testEnumOutputAudio(&node))); printf("\ttest VIDIOC_G/S/ENUMOUTPUT: %s\n", ok(testOutput(&node))); printf("\ttest VIDIOC_G/S_AUDOUT: %s\n", ok(testOutputAudio(&node))); printf("\tOutputs: %d Audio Outputs: %d Modulators: %d\n", node.outputs, node.audio_outputs, node.modulators); printf("\n"); /* Control ioctls */ printf("Control ioctls:\n"); printf("\ttest VIDIOC_QUERYCTRL/MENU: %s\n", ok(testQueryControls(&node))); printf("\ttest VIDIOC_G/S_CTRL: %s\n", ok(testSimpleControls(&node))); printf("\ttest VIDIOC_G/S/TRY_EXT_CTRLS: %s\n", ok(testExtendedControls(&node))); printf("\ttest VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: %s\n", ok(testControlEvents(&node))); printf("\ttest VIDIOC_G/S_JPEGCOMP: %s\n", ok(testJpegComp(&node))); printf("\tStandard Controls: %d Private Controls: %d\n", node.std_controls, node.priv_controls); printf("\n"); /* I/O configuration ioctls */ printf("Input/Output configuration ioctls:\n"); printf("\ttest VIDIOC_ENUM/G/S/QUERY_STD: %s\n", ok(testStd(&node))); printf("\ttest VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: %s\n", ok(testTimings(&node))); printf("\ttest VIDIOC_DV_TIMINGS_CAP: %s\n", ok(testTimingsCap(&node))); printf("\n"); /* Format ioctls */ printf("Format ioctls:\n"); printf("\ttest VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: %s\n", ok(testEnumFormats(&node))); printf("\ttest VIDIOC_G/S_PARM: %s\n", ok(testParm(&node))); printf("\ttest VIDIOC_G_FBUF: %s\n", ok(testFBuf(&node))); printf("\ttest VIDIOC_G_FMT: %s\n", ok(testGetFormats(&node))); printf("\ttest VIDIOC_TRY_FMT: %s\n", ok(testTryFormats(&node))); printf("\ttest VIDIOC_S_FMT: %s\n", ok(testSetFormats(&node))); printf("\ttest VIDIOC_G_SLICED_VBI_CAP: %s\n", ok(testSlicedVBICap(&node))); printf("\n"); /* Codec ioctls */ printf("Codec ioctls:\n"); printf("\ttest VIDIOC_(TRY_)ENCODER_CMD: %s\n", ok(testEncoder(&node))); printf("\ttest VIDIOC_G_ENC_INDEX: %s\n", ok(testEncIndex(&node))); printf("\ttest VIDIOC_(TRY_)DECODER_CMD: %s\n", ok(testDecoder(&node))); printf("\n"); /* Buffer ioctls */ printf("Buffer ioctls:\n"); printf("\ttest VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: %s\n", ok(testReqBufs(&node))); //printf("\ttest read/write: %s\n", ok(testReadWrite(&node))); printf("\n"); /* TODO: VIDIOC_CROPCAP, VIDIOC_G/S_CROP, VIDIOC_G/S_SELECTION VIDIOC_S_FBUF/OVERLAY VIDIOC_QBUF/DQBUF/QUERYBUF/PREPARE_BUFS/EXPBUF VIDIOC_STREAMON/OFF */ /* Final test report */ test_close(node.fd); if (node.node2) test_close(node.node2->fd); printf("Total: %d, Succeeded: %d, Failed: %d, Warnings: %d\n", tests_total, tests_ok, tests_total - tests_ok, warnings); exit(app_result); }