vsf_err_t vsfos_modinit(struct vsf_module_t *module, struct app_hwcfg_t const *cfg) { struct vsfos_modifs_t *ifs; ifs = vsf_bufmgr_malloc(sizeof(struct vsfos_modifs_t)); if (!ifs) return VSFERR_FAIL; memset(ifs, 0, sizeof(*ifs)); ifs->hwcfg = cfg; ifs->pendsvq.size = dimof(ifs->pendsvq_ele); ifs->pendsvq.queue = ifs->pendsvq_ele; ifs->pendsvq.activate = vsfos_pendsv_activate; // init vsftimer ifs->vsftimer_memop.alloc = vsftimer_memop_alloc; ifs->vsftimer_memop.free = vsftimer_memop_free; // init fakefat32_fs ifs->fakefat32_fs.Windows_dir[0].memfile.file.name = "."; ifs->fakefat32_fs.Windows_dir[0].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.Windows_dir[1].memfile.file.name = ".."; ifs->fakefat32_fs.Windows_dir[1].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.Windows_dir[2].memfile.file.name = "VSFCDC.inf"; ifs->fakefat32_fs.Windows_dir[2].memfile.file.size = sizeof(vsfcdc_inf) - 1; ifs->fakefat32_fs.Windows_dir[2].memfile.file.attr = VSFILE_ATTR_ARCHIVE | VSFILE_ATTR_READONLY; ifs->fakefat32_fs.Windows_dir[2].memfile.f.buff = (uint8_t *)vsfcdc_inf; ifs->fakefat32_fs.Windows_dir[3].memfile.file.name = "VSFRNDIS.inf"; ifs->fakefat32_fs.Windows_dir[3].memfile.file.size = sizeof(vsfrndis_inf) - 1; ifs->fakefat32_fs.Windows_dir[3].memfile.file.attr = VSFILE_ATTR_ARCHIVE | VSFILE_ATTR_READONLY; ifs->fakefat32_fs.Windows_dir[3].memfile.f.buff = (uint8_t *)vsfrndis_inf; ifs->fakefat32_fs.Driver_dir[0].memfile.file.name = "."; ifs->fakefat32_fs.Driver_dir[0].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.Driver_dir[1].memfile.file.name = ".."; ifs->fakefat32_fs.Driver_dir[1].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.Driver_dir[2].memfile.file.name = "Windows"; ifs->fakefat32_fs.Driver_dir[2].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.Driver_dir[2].memfile.d.child = (struct vsfile_memfile_t *)ifs->fakefat32_fs.Windows_dir; ifs->fakefat32_fs.LOSTDIR_dir[0].memfile.file.name = "."; ifs->fakefat32_fs.LOSTDIR_dir[0].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.LOSTDIR_dir[1].memfile.file.name = ".."; ifs->fakefat32_fs.LOSTDIR_dir[1].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.RECYCLEBIN_dir[0].memfile.file.name = "."; ifs->fakefat32_fs.RECYCLEBIN_dir[0].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.RECYCLEBIN_dir[1].memfile.file.name = ".."; ifs->fakefat32_fs.RECYCLEBIN_dir[1].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.RECYCLEBIN_dir[2].memfile.file.name = "DESKTOP.INI"; ifs->fakefat32_fs.RECYCLEBIN_dir[2].memfile.file.size = sizeof(Win_recycle_DESKTOP_INI) - 1; ifs->fakefat32_fs.RECYCLEBIN_dir[2].memfile.file.attr = VSFILE_ATTR_ARCHIVE | VSFILE_ATTR_READONLY; ifs->fakefat32_fs.RECYCLEBIN_dir[2].memfile.f.buff = (uint8_t *)Win_recycle_DESKTOP_INI; ifs->fakefat32_fs.SVI_dir[0].memfile.file.name = "."; ifs->fakefat32_fs.SVI_dir[0].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.SVI_dir[1].memfile.file.name = ".."; ifs->fakefat32_fs.SVI_dir[1].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.SVI_dir[2].memfile.file.name = "IndexerVolumeGuid"; ifs->fakefat32_fs.SVI_dir[2].memfile.file.size = sizeof(Win10_IndexerVolumeGuid); ifs->fakefat32_fs.SVI_dir[2].memfile.file.attr = VSFILE_ATTR_ARCHIVE | VSFILE_ATTR_READONLY | VSFILE_ATTR_SYSTEM | VSFILE_ATTR_HIDDEN, ifs->fakefat32_fs.SVI_dir[2].memfile.f.buff = (uint8_t *)Win10_IndexerVolumeGuid; ifs->fakefat32_fs.SVI_dir[3].memfile.file.name = "WPSettings.dat"; ifs->fakefat32_fs.SVI_dir[3].memfile.file.size = sizeof(Win10_WPSettings_dat); ifs->fakefat32_fs.SVI_dir[3].memfile.file.attr = VSFILE_ATTR_ARCHIVE | VSFILE_ATTR_READONLY | VSFILE_ATTR_SYSTEM | VSFILE_ATTR_HIDDEN, ifs->fakefat32_fs.SVI_dir[3].memfile.f.buff = (uint8_t *)Win10_WPSettings_dat; ifs->fakefat32_fs.root_dir[0].memfile.file.name = "VSFDriver"; ifs->fakefat32_fs.root_dir[0].memfile.file.attr = VSFILE_ATTR_VOLUMID; ifs->fakefat32_fs.root_dir[1].memfile.file.name = "LOST.DIR"; ifs->fakefat32_fs.root_dir[1].memfile.file.attr = VSFILE_ATTR_DIRECTORY | VSFILE_ATTR_SYSTEM | VSFILE_ATTR_HIDDEN; ifs->fakefat32_fs.root_dir[1].memfile.d.child = (struct vsfile_memfile_t *)ifs->fakefat32_fs.LOSTDIR_dir; ifs->fakefat32_fs.root_dir[2].memfile.file.name = "$RECYCLE.BIN"; ifs->fakefat32_fs.root_dir[2].memfile.file.attr = VSFILE_ATTR_DIRECTORY | VSFILE_ATTR_SYSTEM | VSFILE_ATTR_HIDDEN; ifs->fakefat32_fs.root_dir[2].memfile.d.child = (struct vsfile_memfile_t *)ifs->fakefat32_fs.RECYCLEBIN_dir; ifs->fakefat32_fs.root_dir[3].memfile.file.name = "System Volume Information"; ifs->fakefat32_fs.root_dir[3].memfile.file.attr = VSFILE_ATTR_DIRECTORY | VSFILE_ATTR_SYSTEM | VSFILE_ATTR_HIDDEN; ifs->fakefat32_fs.root_dir[3].memfile.d.child = (struct vsfile_memfile_t *)ifs->fakefat32_fs.SVI_dir; ifs->fakefat32_fs.root_dir[4].memfile.file.name = "Driver"; ifs->fakefat32_fs.root_dir[4].memfile.file.attr = VSFILE_ATTR_DIRECTORY; ifs->fakefat32_fs.root_dir[4].memfile.d.child = (struct vsfile_memfile_t *)ifs->fakefat32_fs.Driver_dir; // init fakefat32 ifs->mal.fakefat32.sector_size = 512; ifs->mal.fakefat32.sector_number = 0x1000; ifs->mal.fakefat32.sectors_per_cluster = 8; ifs->mal.fakefat32.volume_id = 0xDEADBEEF; ifs->mal.fakefat32.disk_id = 0xBABECAFE; ifs->mal.fakefat32.root[0].memfile.file.name = "ROOT"; ifs->mal.fakefat32.root[0].memfile.d.child = (struct vsfile_memfile_t *)ifs->fakefat32_fs.root_dir, // init mal ifs->mal.mal.drv = &fakefat32_mal_drv; ifs->mal.mal.param = &ifs->mal.fakefat32; ifs->mal.pbuffer[0] = ifs->mal.buffer[0]; ifs->mal.pbuffer[1] = ifs->mal.buffer[1]; // init file ifs->fs.memop.alloc_vfs = vsfos_vsfile_alloc_vfs; ifs->fs.memop.free_vfs = vsfos_vsfile_free_vfs; // init mal2scsi ifs->mal.scsistream.mbuf.count = dimof(ifs->mal.buffer); ifs->mal.scsistream.mbuf.size = sizeof(ifs->mal.buffer[0]); ifs->mal.scsistream.mbuf.buffer_list = ifs->mal.pbuffer; ifs->mal.mal2scsi.malstream.mal = &ifs->mal.mal; ifs->mal.mal2scsi.cparam.block_size = 512; ifs->mal.mal2scsi.cparam.removable = false; memcpy(ifs->mal.mal2scsi.cparam.vendor, "Simon ", 8); memcpy(ifs->mal.mal2scsi.cparam.product, "VSFDriver ", 16); memcpy(ifs->mal.mal2scsi.cparam.revision, "1.00", 4); ifs->mal.mal2scsi.cparam.type = SCSI_PDT_DIRECT_ACCESS_BLOCK; // init scsi device ifs->mal.lun[0].op = &vsf_mal2scsi_op; ifs->mal.lun[0].stream = (struct vsf_stream_t *)&ifs->mal.scsistream; ifs->mal.lun[0].param = &ifs->mal.mal2scsi; ifs->mal.scsi_dev.max_lun = 0; ifs->mal.scsi_dev.lun = ifs->mal.lun; // init rndis ifs->usbd.rndis.param.CDCACM.CDC.ep_notify = 1; ifs->usbd.rndis.param.CDCACM.CDC.ep_out = 2; ifs->usbd.rndis.param.CDCACM.CDC.ep_in = 2; ifs->usbd.rndis.param.mac.size = 6; ifs->usbd.rndis.param.mac.addr.s_addr64 = 0x0605040302E0; ifs->usbd.rndis.param.netif.macaddr.size = 6; ifs->usbd.rndis.param.netif.macaddr.addr.s_addr64 = 0x0E0D0C0B0AE0; ifs->usbd.rndis.param.cb.param = &ifs->usbd.rndis; ifs->usbd.rndis.param.cb.on_connect = vsfos_rndis_on_connect; if (0) { ifs->usbd.rndis.param.netif.ipaddr.size = 4; ifs->usbd.rndis.param.netif.ipaddr.addr.s_addr = 0x01202020; ifs->usbd.rndis.param.netif.netmask.size = 4; ifs->usbd.rndis.param.netif.netmask.addr.s_addr = 0x00FFFFFF; ifs->usbd.rndis.param.netif.gateway.size = 4; ifs->usbd.rndis.param.netif.gateway.addr.s_addr = 0x01202020; } // init cdc ifs->usbd.cdc.stream_tx.stream.op = &fifostream_op; ifs->usbd.cdc.stream_tx.mem.buffer.buffer = ifs->usbd.cdc.txbuff; ifs->usbd.cdc.stream_tx.mem.buffer.size = sizeof(ifs->usbd.cdc.txbuff); ifs->usbd.cdc.stream_rx.stream.op = &fifostream_op; ifs->usbd.cdc.stream_rx.mem.buffer.buffer = ifs->usbd.cdc.rxbuff; ifs->usbd.cdc.stream_rx.mem.buffer.size = sizeof(ifs->usbd.cdc.rxbuff); ifs->usbd.cdc.param.CDC.ep_notify = 3; ifs->usbd.cdc.param.CDC.ep_out = 4; ifs->usbd.cdc.param.CDC.ep_in = 4; ifs->usbd.cdc.param.CDC.stream_tx = (struct vsf_stream_t *)&ifs->usbd.cdc.stream_tx; ifs->usbd.cdc.param.CDC.stream_rx = (struct vsf_stream_t *)&ifs->usbd.cdc.stream_rx; ifs->usbd.cdc.param.line_coding.bitrate = 115200; ifs->usbd.cdc.param.line_coding.stopbittype = 0; ifs->usbd.cdc.param.line_coding.paritytype = 0; ifs->usbd.cdc.param.line_coding.datatype = 8; // init msc ifs->usbd.msc.param.ep_in = 5; ifs->usbd.msc.param.ep_out = 5; ifs->usbd.msc.param.scsi_dev = &ifs->mal.scsi_dev; // init usbd ifs->usbd.desc[0] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_DEVICE(0, USB_DeviceDescriptor, sizeof(USB_DeviceDescriptor)); ifs->usbd.desc[1] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_CONFIG(0, 0, USB_ConfigDescriptor, sizeof(USB_ConfigDescriptor)); ifs->usbd.desc[2] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0, 0, USB_StringLangID, sizeof(USB_StringLangID)); ifs->usbd.desc[3] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0x0409, 1, USB_StringVendor, sizeof(USB_StringVendor)); ifs->usbd.desc[4] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0x0409, 2, USB_StringProduct, sizeof(USB_StringProduct)); ifs->usbd.desc[5] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0x0409, 3, USB_StringSerial, sizeof(USB_StringSerial)); ifs->usbd.desc[6] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0x0409, 4, RNDIS_StringFunc, sizeof(RNDIS_StringFunc)); ifs->usbd.desc[7] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0x0409, 5, CDC_StringFunc, sizeof(CDC_StringFunc)); ifs->usbd.desc[8] = (struct vsfusbd_desc_filter_t)VSFUSBD_DESC_STRING(0x0409, 6, MSC_StringFunc, sizeof(MSC_StringFunc)); ifs->usbd.ifaces[0].class_protocol = (struct vsfusbd_class_protocol_t *)&vsfusbd_RNDISControl_class; ifs->usbd.ifaces[0].protocol_param = &ifs->usbd.rndis.param; ifs->usbd.ifaces[1].class_protocol = (struct vsfusbd_class_protocol_t *)&vsfusbd_RNDISData_class; ifs->usbd.ifaces[1].protocol_param = &ifs->usbd.rndis.param; ifs->usbd.ifaces[2].class_protocol = (struct vsfusbd_class_protocol_t *)&vsfusbd_CDCACMControl_class; ifs->usbd.ifaces[2].protocol_param = &ifs->usbd.cdc.param; ifs->usbd.ifaces[3].class_protocol = (struct vsfusbd_class_protocol_t *)&vsfusbd_CDCACMData_class; ifs->usbd.ifaces[3].protocol_param = &ifs->usbd.cdc.param; ifs->usbd.ifaces[4].class_protocol = (struct vsfusbd_class_protocol_t *)&vsfusbd_MSCBOT_class; ifs->usbd.ifaces[4].protocol_param = &ifs->usbd.msc.param; ifs->usbd.config[0].num_of_ifaces = dimof(ifs->usbd.ifaces); ifs->usbd.config[0].iface = ifs->usbd.ifaces; ifs->usbd.device.num_of_configuration = dimof(ifs->usbd.config); ifs->usbd.device.config = ifs->usbd.config; ifs->usbd.device.desc_filter = ifs->usbd.desc; ifs->usbd.device.device_class_iface = 0; ifs->usbd.device.drv = vsfhal_usbd_if; ifs->usbd.device.int_priority = 0x01; // init telnetd ifs->tcpip.telnetd.telnetd.port = 23; ifs->tcpip.telnetd.telnetd.session_num = dimof(ifs->tcpip.telnetd.sessions); ifs->tcpip.telnetd.sessions[0].session.stream_tx = (struct vsf_stream_t *)&ifs->tcpip.telnetd.sessions[0].stream_tx; ifs->tcpip.telnetd.sessions[0].session.stream_rx = (struct vsf_stream_t *)&ifs->tcpip.telnetd.sessions[0].stream_rx; ifs->tcpip.telnetd.sessions[0].stream_tx.stream.op = &fifostream_op; ifs->tcpip.telnetd.sessions[0].stream_tx.mem.buffer.buffer = (uint8_t *)ifs->tcpip.telnetd.sessions[0].txbuff; ifs->tcpip.telnetd.sessions[0].stream_tx.mem.buffer.size = sizeof(ifs->tcpip.telnetd.sessions[0].txbuff); ifs->tcpip.telnetd.sessions[0].stream_rx.stream.op = &fifostream_op; ifs->tcpip.telnetd.sessions[0].stream_rx.mem.buffer.buffer = (uint8_t *)ifs->tcpip.telnetd.sessions[0].rxbuff; ifs->tcpip.telnetd.sessions[0].stream_rx.mem.buffer.size = sizeof(ifs->tcpip.telnetd.sessions[0].rxbuff); // init tcpip ifs->tcpip.mem_op.get_buffer = vsfos_vsfip_get_buffer; ifs->tcpip.mem_op.release_buffer = vsfos_vsfip_release_buffer; ifs->tcpip.mem_op.get_socket = vsfos_vsfip_get_socket; ifs->tcpip.mem_op.release_socket = vsfos_vsfip_release_socket; ifs->tcpip.mem_op.get_tcppcb = vsfos_vsfip_get_tcppcb; ifs->tcpip.mem_op.release_tcppcb = vsfos_vsfip_release_tcppcb; // init shell ifs->shell.echo = true; ifs->shell.stream_tx = (struct vsf_stream_t *)&ifs->usbd.cdc.stream_tx; ifs->shell.stream_rx = (struct vsf_stream_t *)&ifs->usbd.cdc.stream_rx; ifs->pt.user_data = ifs; ifs->pt.thread = vsfos_thread; module->ifs = ifs; vsfsm_evtq_init(&ifs->pendsvq); vsfsm_evtq_set(&ifs->pendsvq); vsfsm_pt_init(&ifs->sm, &ifs->pt); vsfhal_core_pendsv_config(vsfos_on_pendsv, &ifs->pendsvq); vsf_leave_critical(); vsfsm_evtq_set(NULL); while (1) { // no thread runs in mainq, just sleep in main loop vsfhal_core_sleep(0); } }
{VX_BIDIRECTIONAL, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; static vx_param_description_t accumulate_scaled_kernel_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_INPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_REQUIRED}, {VX_BIDIRECTIONAL, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; vx_kernel_description_t accumulate_kernel = { VX_KERNEL_ACCUMULATE, "org.khronos.openvx.accumulate", vxAccumulateKernel, accumulate_kernel_params, dimof(accumulate_kernel_params), vxAccumulateInputValidator, vxAccumulateOutputValidator, NULL, NULL, }; vx_kernel_description_t accumulate_weighted_kernel = { VX_KERNEL_ACCUMULATE_WEIGHTED, "org.khronos.openvx.accumulate_weighted", vxAccumulateWeightedKernel, accumulate_scaled_kernel_params, dimof(accumulate_scaled_kernel_params), vxAccumulateWeightedInputValidator, vxAccumulateOutputValidator, NULL, NULL,
} } } return status; } static vx_status VX_CALLBACK vxHarrisDeinitializer(vx_node node, vx_reference *parameters, vx_uint32 num) { vx_status status = VX_ERROR_INVALID_PARAMETERS; if (num == dimof(harris_kernel_params)) { vx_graph graph = vxGetChildGraphOfNode(node); vxReleaseGraph(&graph); /* set graph to "null" */ vxSetChildGraphOfNode(node, 0); status = VX_SUCCESS; } return status; } vx_kernel_description_t harris_kernel = { VX_KERNEL_HARRIS_CORNERS, "org.khronos.openvx.harris_corners", vxHarrisCornersKernel, harris_kernel_params, dimof(harris_kernel_params), vxHarrisInputValidator, vxHarrisOutputValidator, vxHarrisInitializer, vxHarrisDeinitializer, };
//----------------------------------------------------------------------------- // // header files // //----------------------------------------------------------------------------- #include "bsp.h" #include "ceddkex.h" #include "sdk_gpio.h" #include "bsp_padcfg.h" #include "sdk_padcfg.h" #include "oalex.h" DWORD g_GPIOId[] = {NOTIFICATION_LED_GPIO}; DWORD g_GPIOActiveState[dimof(g_GPIOId)] = {0}; DWORD g_dwNbLeds = dimof(g_GPIOId); BOOL g_LastLEDIsVibrator = FALSE; static const PAD_INFO LedPinMux[] = { WKUP_PAD_ENTRY(SYS_BOOT6, INPUT_DISABLED | PULL_RESISTOR_DISABLED | MUXMODE(4)) \ END_OF_PAD_ARRAY }; int NLedCpuFamily = -1; BOOL NLedBoardInit() { if (NLedCpuFamily == -1) {
static WCHAR *GetGhostscriptPath() { WCHAR *gsProducts[] = { L"AFPL Ghostscript", L"Aladdin Ghostscript", L"GPL Ghostscript", L"GNU Ghostscript", }; // find all installed Ghostscript versions WStrVec versions; REGSAM access = KEY_READ | KEY_WOW64_32KEY; TryAgain64Bit: for (int i = 0; i < dimof(gsProducts); i++) { HKEY hkey; ScopedMem<WCHAR> keyName(str::Join(L"Software\\", gsProducts[i])); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, access, &hkey) != ERROR_SUCCESS) continue; WCHAR subkey[32]; for (DWORD ix = 0; RegEnumKey(hkey, ix, subkey, dimof(subkey)) == ERROR_SUCCESS; ix++) versions.Append(str::Dup(subkey)); RegCloseKey(hkey); } if ((access & KEY_WOW64_32KEY)) { // also look for 64-bit Ghostscript versions under 64-bit Windows access = KEY_READ | KEY_WOW64_64KEY; #ifndef _WIN64 // (unless this is 32-bit Windows) if (IsRunningInWow64()) #endif goto TryAgain64Bit; } versions.SortNatural(); // return the path to the newest installation for (size_t ix = versions.Count(); ix > 0; ix--) { for (int i = 0; i < dimof(gsProducts); i++) { ScopedMem<WCHAR> keyName(str::Format(L"Software\\%s\\%s", gsProducts[i], versions.At(ix - 1))); ScopedMem<WCHAR> GS_DLL(ReadRegStr(HKEY_LOCAL_MACHINE, keyName, L"GS_DLL")); if (!GS_DLL) continue; ScopedMem<WCHAR> dir(path::GetDir(GS_DLL)); ScopedMem<WCHAR> exe(path::Join(dir, L"gswin32c.exe")); if (file::Exists(exe)) return exe.StealData(); exe.Set(path::Join(dir, L"gswin64c.exe")); if (file::Exists(exe)) return exe.StealData(); } } // if Ghostscript isn't found in the Registry, try finding it in the %PATH% DWORD size = GetEnvironmentVariable(L"PATH", NULL, 0); ScopedMem<WCHAR> envpath(AllocArray<WCHAR>(size)); if (size > 0 && envpath) { GetEnvironmentVariable(L"PATH", envpath, size); WStrVec paths; paths.Split(envpath, L";", true); for (size_t ix = 0; ix < paths.Count(); ix++) { ScopedMem<WCHAR> exe(path::Join(paths.At(ix), L"gswin32c.exe")); if (file::Exists(exe)) return exe.StealData(); exe.Set(path::Join(paths.At(ix), L"gswin64c.exe")); if (file::Exists(exe)) return exe.StealData(); } } return NULL; }
bool WriteAllUtf(const char *filePath, const void *data, size_t dataLen) { WCHAR buf[512]; str::Utf8ToWcharBuf(filePath, str::Len(filePath), buf, dimof(buf)); return WriteAll(buf, data, dataLen); }
{"FOURCC_Y800", T_FIXNUM, .value.l=FOURCC_Y800}, {"FOURCC_UYVY", T_FIXNUM, .value.l=FOURCC_UYVY}, {"FOURCC_RGB", T_FIXNUM, .value.l=FOURCC_RGB}, {"FOURCC_Y16", T_FIXNUM, .value.l=FOURCC_Y16}, {"FOURCC_Y32", T_FIXNUM, .value.l=FOURCC_Y32}, {"FOURCC_NV12", T_FIXNUM, .value.l=FOURCC_NV12}, }; static rext_const_t parameter_constants[] = { {"VX_INPUT", T_FIXNUM, .value.l=VX_INPUT}, {"VX_OUTPUT", T_FIXNUM, .value.l=VX_OUTPUT}, {"VX_BIDIRECTIONAL",T_FIXNUM, .value.l=VX_BIDIRECTIONAL}, }; static rext_object_t objects[] = { {0, &rb_cObject, "Reference", Reference_allocate, NULL, 0, NULL, 0, reference_methods, dimof(reference_methods)}, {0, &rb_cObject, "Kernel", Kernel_allocate, NULL, 0, NULL, 0, kernel_methods, dimof(kernel_methods)}, {0, &rb_cObject, "Graph", Graph_allocate, NULL, 0, NULL, 0, graph_methods, dimof(graph_methods)}, {0, &rb_cObject, "Image", Image_allocate, NULL, 0, image_constants, dimof(image_constants), image_methods, dimof(image_methods)}, {0, &rb_cObject, "Node", Node_allocate, NULL, 0, NULL, 0, node_methods, dimof(node_methods)}, {0, &rb_cObject, "Parameter", Parameter_allocate, NULL, 0, parameter_constants, dimof(parameter_constants), parameter_methods, dimof(parameter_methods)}, {0, &rb_cObject, "Buffer", Buffer_allocate, NULL, 0, NULL, 0, buffer_methods, dimof(buffer_methods)}, {0, &rb_cObject, "Scalar", Scalar_allocate, NULL, 0, NULL, 0, scalar_methods, dimof(scalar_methods)}, {0, &rb_cObject, "Target", Target_allocate, NULL, 0, NULL, 0, target_methods, dimof(target_methods)}, }; static rext_module_t modules[] = { {0, "OpenVX", NULL, 0, objects, dimof(objects), NULL, 0, openvx_global_methods, dimof(openvx_global_methods)}, }; //******************************************************************************
RectF TextRenderGdiplus::Measure(const char *s, size_t sLen) { CrashIf(!currFont); size_t strLen = str::Utf8ToWcharBuf(s, sLen, txtConvBuf, dimof(txtConvBuf)); return MeasureText(gfx, currFont->font, txtConvBuf, strLen, measureAlgo); }
Gdiplus::RectF TextRenderHdc::Measure(const char *s, size_t sLen) { CrashIf(!currFont); CrashIf(!hdc); size_t strLen = str::Utf8ToWcharBuf(s, sLen, txtConvBuf, dimof(txtConvBuf)); return Measure(txtConvBuf, strLen); }
if (num == 4) { vx_image in0 = (vx_image)parameters[0]; vx_image in1 = (vx_image)parameters[1]; vx_scalar policy_param = (vx_scalar)parameters[2]; vx_image output = (vx_image)parameters[3]; return vxAddition(in0, in1, policy_param, output); } return VX_ERROR_INVALID_PARAMETERS; } vx_kernel_description_t add_kernel = { VX_KERNEL_ADD, "org.khronos.openvx.add", vxAdditionKernel, add_subtract_kernel_params, dimof(add_subtract_kernel_params), vxAddSubtractInputValidator, vxAddSubtractOutputValidator, NULL, NULL, }; static vx_status VX_CALLBACK vxSubtractionKernel(vx_node node, const vx_reference *parameters, vx_uint32 num) { if (num == 4) { vx_image in0 = (vx_image)parameters[0]; vx_image in1 = (vx_image)parameters[1]; vx_scalar policy_param = (vx_scalar)parameters[2]; vx_image output = (vx_image)parameters[3]; return vxSubtraction(in0, in1, policy_param, output);
else { status = VX_ERROR_INVALID_PARAMETERS; } VX_PRINT(VX_ZONE_API, "%s:%u returned %d\n", __FUNCTION__, index, status); return status; } /*! \brief Declares the parameter types for \ref vxuColorConvert. * \ingroup group_implementation */ static vx_param_description_t channel_extract_kernel_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_INPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_REQUIRED}, {VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; /*! \brief The exported kernel table entry */ vx_kernel_description_t channelextract_kernel = { VX_KERNEL_CHANNEL_EXTRACT, "org.khronos.openvx.channel_extract", vxChannelExtractKernel, channel_extract_kernel_params, dimof(channel_extract_kernel_params), vxChannelExtractInputValidator, vxChannelExtractOutputValidator, NULL, NULL, };
bool_e thread_unittest(int argc, char *argv[]) { uint32_t i, counter = 10; pingpongevent_t events; int numErrors = 0; bool_e verbose = false_e; option_t hash_opts[] = { {OPTION_TYPE_BOOL, &verbose, sizeof(bool_e), "-v", "--verbose", "Used to print out debugging information"}, }; msg_t msgs[] = {{3}, {9283}, {27}, {42}}; // last value == TEST_RET_VALUE msg_thread_t msgt; thread_t t; thread_ret_t r; option_process(argc, argv, hash_opts, dimof(hash_opts)); if (verbose) { SOSAL_PRINT(SOSAL_ZONE_THREAD, "===THREAD TEST===\n"); } // simple start, stop test t = thread_create(thread_test, &counter); r = thread_join(t); if (r != TEST_RET_VALUE) numErrors++; if (verbose) { SOSAL_PRINT(SOSAL_ZONE_THREAD, "===PING PONG TEST===\n"); } // event test across threads event_init(&events.ping, false_e); event_init(&events.pong, false_e); t = thread_create(thread_test_events, &events); if (verbose) { SOSAL_PRINT(SOSAL_ZONE_THREAD, "Test is waiting for thread to wakeup!\n"); } if (event_wait(&events.ping, 500)) { if (verbose) SOSAL_PRINT(SOSAL_ZONE_THREAD, "Received Event from Thread!\n"); } else { if (verbose) SOSAL_PRINT(SOSAL_ZONE_THREAD, "ERROR! Thread Message Timedout!\n"); } if (verbose) SOSAL_PRINT(SOSAL_ZONE_THREAD, "Sending Event to Thread!\n"); event_set(&events.pong); r = thread_join(t); SOSAL_PRINT(SOSAL_ZONE_THREAD, "=== THREAD JOIN exit = "THREAD_RET_FMT" ===\n", r); if (r != TEST_RET_VALUE) numErrors++; event_deinit(&events.ping); event_deinit(&events.pong); if (verbose) { SOSAL_PRINT(SOSAL_ZONE_THREAD, "===QUEUE TEST===\n"); } msgt.msgs = queue_create(2, sizeof(msg_t)); msgt.running = true_e; event_init(&msgt.signal, false_e); t = thread_create(thread_test_msgs, &msgt); if (verbose) { SOSAL_PRINT(SOSAL_ZONE_THREAD, "Waiting for thread to start!\n"); SOSAL_PRINT(SOSAL_ZONE_THREAD, "Thread Started?(%s!)\n", (event_wait(&msgt.signal, 1000)?"true":"false")); } for (i = 0; i < dimof(msgs); i++) { if (queue_write(msgt.msgs, true_e, &msgs[i]) == false_e) { SOSAL_PRINT(SOSAL_ZONE_ERROR, "ERROR! Failed to write to queue!\n"); } else { if (verbose) SOSAL_PRINT(SOSAL_ZONE_THREAD, "Wrote message "FMT_SIZE_T" to the Queue!\n", msgs[i].code); } } r = thread_join(t); SOSAL_PRINT(SOSAL_ZONE_THREAD, "=== THREAD JOIN exit = "THREAD_RET_FMT" ===\n", r); queue_destroy(msgt.msgs); event_deinit(&msgt.signal); if (verbose) { SOSAL_PRINT(SOSAL_ZONE_THREAD, "===THREAD TEST EXIT Errors=%d ===\n", numErrors); } if (numErrors > 0) return false_e; else return true_e; }
//------------------------------------------------------------------------------ // // Function: DMA_Init // // Called by device manager to initialize device. // DWORD DMA_Init( LPCWSTR szContext, LPCVOID pBusContext ) { DWORD rc = (DWORD)NULL; UNREFERENCED_PARAMETER(pBusContext); UNREFERENCED_PARAMETER(szContext); DEBUGMSG(ZONE_FUNCTION, ( L"+DMA_Init(%s, 0x%08x)\r\n", szContext, pBusContext )); // Create device structure Device_t *pDevice = (Device_t *)LocalAlloc(LPTR, sizeof(Device_t)); if (pDevice == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: DMA_Init: " L"Failed allocate DMA controller structure\r\n" )); goto cleanUp; } // initialize memory memset(pDevice, 0, sizeof(Device_t)); // Set cookie pDevice->cookie = DMA_DEVICE_COOKIE; // Initalize critical section InitializeCriticalSection(&pDevice->cs); // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(s_deviceRegParams), s_deviceRegParams ) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: DMA_Init: " L"Failed read DMA driver registry parameters\r\n" )); goto cleanUp; } // Retrieve device ID pDevice->SdmaDevice = SOCGetDMADevice(pDevice->SdmaIndex); // Set hardware to full power EnableDeviceClocks(pDevice->SdmaDevice, TRUE); // DMA will be in smart idle mode so we don't need to // ever set the power state of the DMA to D4 // initialize general dma controller if (InitializeDevice(pDevice) == FALSE) { DEBUGMSG (ZONE_ERROR, (L"ERROR: DMA_Init: " L"Failed to initialize device\r\n" )); goto cleanUp; } rc = (DWORD)pDevice; cleanUp: if (rc == 0) DMA_Deinit((DWORD)pDevice); DEBUGMSG(ZONE_FUNCTION, (L"-DMA_Init(rc = %d)\r\n", rc)); return rc; }
{ ptr->dim.scalar.type = VX_TYPE_UINT32; status = VX_SUCCESS; } return status; } static vx_param_description_t minmaxloc_kernel_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_OUTPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL}, {VX_OUTPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL}, {VX_OUTPUT, VX_TYPE_ARRAY, VX_PARAMETER_STATE_OPTIONAL}, {VX_OUTPUT, VX_TYPE_ARRAY, VX_PARAMETER_STATE_OPTIONAL}, {VX_OUTPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL}, {VX_OUTPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL}, }; vx_kernel_description_t minmaxloc_kernel = { VX_KERNEL_MINMAXLOC, "org.khronos.openvx.minmaxloc", vxMinMaxLocKernel, minmaxloc_kernel_params, dimof(minmaxloc_kernel_params), NULL, vxMinMaxLocInputValidator, vxMinMaxLocOutputValidator, NULL, NULL, };
{VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; static vx_param_description_t euclidean_non_max_suppression_harris_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_INPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_REQUIRED}, /* strength_thresh */ {VX_INPUT, VX_TYPE_SCALAR, VX_PARAMETER_STATE_REQUIRED}, /* min_distance */ {VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; vx_kernel_description_t nonmax_kernel = { VX_KERNEL_EXTRAS_NONMAXSUPPRESSION, "org.khronos.extra.nonmaximasuppression", vxNonMaxSuppressionKernel, nonmaxsuppression_params, dimof(nonmaxsuppression_params), vxNonMaxSuppressionInputValidator, vxNonMaxSuppressionOutputValidator, NULL, NULL, }; vx_kernel_description_t euclidian_nonmax_harris_kernel = { VX_KERNEL_EXTRAS_EUCLIDEAN_NONMAXSUPPRESSION_HARRIS, "org.khronos.extra.euclidean_nonmaxsuppression_harris", vxEuclideanNonMaxSuppressionHarrisKernel, euclidean_non_max_suppression_harris_params, dimof(euclidean_non_max_suppression_harris_params), vxEuclideanNonMaxHarrisInputValidator, vxEuclideanNonMaxHarrisOutputValidator, NULL, NULL,
void TextRenderHdc::Draw(const char *s, size_t sLen, RectF& bb, bool isRtl) { size_t strLen = str::Utf8ToWcharBuf(s, sLen, txtConvBuf, dimof(txtConvBuf)); return Draw(txtConvBuf, strLen, bb, isRtl); }
char *ReadAllUtf(const char *filePath, size_t *fileSizeOut, Allocator *allocator) { WCHAR buf[512]; str::Utf8ToWcharBuf(filePath, str::Len(filePath), buf, dimof(buf)); return ReadAll(buf, fileSizeOut, allocator); }
RectF TextRenderGdi::Measure(const char *s, size_t sLen) { size_t strLen = str::Utf8ToWcharBuf(s, sLen, txtConvBuf, dimof(txtConvBuf)); return Measure(txtConvBuf, strLen); }
//------------------------------------------------------------------------------ // // Function: KPD_Init // // Called by device manager to initialize device. // DWORD KPD_Init(LPCTSTR szContext, LPCVOID pBusContext) { DWORD rc = (DWORD)NULL; KeypadDevice_t *pDevice = NULL; UINT8 regval; UNREFERENCED_PARAMETER(pBusContext); DEBUGMSG(ZONE_FUNCTION, ( L"+KPD_Init(%s, 0x%08x)\r\n", szContext, pBusContext )); // Create device structure pDevice = (KeypadDevice_t *)LocalAlloc(LPTR, sizeof(KeypadDevice_t)); if (pDevice == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed allocate KDP driver structure\r\n" )); goto cleanUp; } memset(pDevice, 0, sizeof(KeypadDevice_t)); // Set cookie & initialize critical section pDevice->cookie = KPD_DEVICE_COOKIE; // Read device parameters if (GetDeviceRegistryParams( szContext, pDevice, dimof(s_deviceRegParams), s_deviceRegParams) != ERROR_SUCCESS) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed read KPD driver registry parameters\r\n" )); goto cleanUp; } // Open parent bus pDevice->hTWL = TWLOpen(); if (pDevice->hTWL == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed open TWL bus driver\r\n" )); goto cleanUp; } // Set debounce delay and enable hardware mode regval = TWL_KBD_CTRL_KBD_ON | TWL_KBD_CTRL_NRESET | TWL_KBD_CTRL_NSOFT_MODE; TWLWriteRegs(pDevice->hTWL, TWL_KEYP_CTRL_REG, ®val, sizeof(regval)); regval = 0x07 << 5; TWLWriteRegs(pDevice->hTWL, TWL_LK_PTV_REG, ®val, sizeof(regval)); regval = (UINT8)pDevice->debounceCount & 0x3F; TWLWriteRegs(pDevice->hTWL, TWL_KEY_DEB_REG, ®val, sizeof(regval)); // Create interrupt event pDevice->hIntrEventKeypad = CreateEvent(NULL, FALSE, FALSE, NULL); if (pDevice->hIntrEventKeypad == NULL) { DEBUGMSG(ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed create keypad interrupt event\r\n" )); goto cleanUp; } // Associate event with TWL KP interrupt if (!TWLInterruptInitialize(pDevice->hTWL, TWL_INTR_ITKPI, pDevice->hIntrEventKeypad)) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed associate event with TWL KBD interrupt\r\n" )); goto cleanUp; } // Enable KP event if (!TWLInterruptMask(pDevice->hTWL, TWL_INTR_ITKPI, FALSE)) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed associate event with TWL KBD interrupt\r\n" )); } // register to be wake-up enabled if (pDevice->enableWake != 0) { TWLWakeEnable(pDevice->hTWL, TWL_INTR_ITKPI, TRUE); } // Start keypad interrupt service thread pDevice->hIntrThreadKeypad = CreateThread( NULL, 0, KPD_IntrThread, pDevice, 0,NULL ); if (!pDevice->hIntrThreadKeypad) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed create keypad interrupt thread\r\n" )); goto cleanUp; } if( pDevice->KpLedNum != -1) { // Create keypress notification event pDevice->hKeypressEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if ( pDevice->hKeypressEvent == NULL ) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed to create keypress event\r\n" )); goto cleanUp; } // Start interrupt service thread pDevice->hLightThread = CreateThread( NULL, 0, KPD_LightThread, pDevice, 0,NULL ); if (!pDevice->hLightThread) { DEBUGMSG (ZONE_ERROR, (L"ERROR: KPD_Init: " L"Failed to create keypad light thread\r\n" )); goto cleanUp; } } // Return non-null value rc = (DWORD)pDevice; cleanUp: if (rc == 0) { KPD_Deinit((DWORD)pDevice); } DEBUGMSG(ZONE_FUNCTION, (L"-KPD_Init(rc = %d\r\n", rc)); return rc; }
jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv *env; NVThreadInit(vm); DEBUG("JNI_OnLoad called"); if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { DEBUG("Failed to get the environment using GetEnv()"); return -1; } JNINativeMethod methods[] = { { "init", "()Z", (void *) NVEventJNIInit }, { "touchEvent", "(IIILandroid/view/MotionEvent;)Z", (void *) NVEventTouchEvent }, { "multiTouchEvent", "(IIIIIILandroid/view/MotionEvent;)Z", (void *) NVEventMultiTouchEvent }, { "keyEvent", "(IIILandroid/view/KeyEvent;)Z", (void *) NVEventKeyEvent }, { "accelerometerEvent", "(FFF)Z", (void *) NVEventAccelerometerEvent }, { "cleanup", "()V", (void *) NVEventCleanup }, // TODO TBD - this should be done in NVTimeInit(), but we use a different // class than most apps. Need to clean this up, as it is fragile w.r.t. // changes in nv_time { "nvAcquireTimeExtension", "()V", (void *) nvAcquireTimeExtensionJNI }, { "nvGetSystemTime", "()J", (void *) nvGetSystemTimeJNI }, { "setWindowSize", "(II)V", (void *) NVEventSetWindowSize }, { "quitAndWait", "()V", (void *) NVEventQuitAndWait }, { "postCleanup", "()V", (void *) NVEventPostCleanup }, { "resumeEvent", "()V", (void *) NVEventResumeEvent }, { "pauseEvent", "()V", (void *) NVEventPauseEvent }, }; jclass k; k = (env)->FindClass ("com/nvidia/devtech/NvEventQueueActivity"); (env)->RegisterNatives(k, methods, dimof(methods)); s_initEGL = env->GetMethodID(k, "InitEGLAndGLES2", "()Z"); s_finish = env->GetMethodID(k, "finish", "()V"); s_swap = env->GetMethodID(k, "swapBuffers", "()Z"); s_makeCurrent = env->GetMethodID(k, "makeCurrent", "()Z"); s_unMakeCurrent = env->GetMethodID(k, "unMakeCurrent", "()Z"); #ifdef _TIMFUDGE s_width = env->GetMethodID(k, "getSurfaceWidth", "()I"); s_height = env->GetMethodID(k, "getSurfaceHeight", "()I"); #endif return JNI_VERSION_1_4; }
vxReleaseParameter(¶m); } return status; } static vx_param_description_t filter_kernel_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; vx_cl_kernel_description_t box3x3_clkernel = { { VX_KERNEL_BOX_3x3, "org.khronos.openvx.box3x3", NULL, filter_kernel_params, dimof(filter_kernel_params), vxFilterInputValidator, vxFilterOutputValidator, }, VX_CL_SOURCEPATH""FILE_JOINER"vx_box3x3.cl", "vx_box3x3", INIT_PROGRAMS, INIT_KERNELS, INIT_NUMKERNELS, INIT_RETURNS, NULL, }; vx_cl_kernel_description_t gaussian3x3_clkernel = { { VX_KERNEL_GAUSSIAN_3x3,
//vxQueryImage(src, VX_IMAGE_ATTRIBUTE_FORMAT, &format, sizeof(format)); vxSetMetaFormatAttribute(meta, VX_IMAGE_ATTRIBUTE_FORMAT, &format, sizeof(format)); vxSetMetaFormatAttribute(meta, VX_IMAGE_ATTRIBUTE_WIDTH, &width, sizeof(width)); vxSetMetaFormatAttribute(meta, VX_IMAGE_ATTRIBUTE_HEIGHT, &height, sizeof(height)); status = VX_SUCCESS; vxReleaseImage(&src); } vxReleaseParameter(&src_param); } } return status; } static vx_param_description_t edge_trace_kernel_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_INPUT, VX_TYPE_THRESHOLD, VX_PARAMETER_STATE_REQUIRED}, {VX_OUTPUT,VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; vx_kernel_description_t edge_trace_kernel = { VX_KERNEL_EXTRAS_EDGE_TRACE, "org.khronos.extra.edge_trace", vxEdgeTraceKernel, edge_trace_kernel_params, dimof(edge_trace_kernel_params), vxEdgeTraceInputValidator, vxEdgeTraceOutputValidator, NULL, NULL, };
static void GeomTest() { PointD ptD(12.4, -13.6); utassert(ptD.x == 12.4 && ptD.y == -13.6); PointI ptI = ptD.ToInt(); utassert(ptI.x == 12 && ptI.y == -14); ptD = ptI.Convert<double>(); utassert(PointD(12, -14) == ptD); utassert(PointD(12.4, -13.6) != ptD); SizeD szD(7.7, -3.3); utassert(szD.dx == 7.7 && szD.dy == -3.3); SizeI szI = szD.ToInt(); utassert(szI.dx == 8 && szI.dy == -3); szD = szI.Convert<double>(); utassert(SizeD(8, -3) == szD); utassert(!szD.IsEmpty() && !szI.IsEmpty()); utassert(SizeI().IsEmpty() && SizeD().IsEmpty()); struct SRIData { int x1s, x1e, y1s, y1e; int x2s, x2e, y2s, y2e; bool intersect; int i_xs, i_xe, i_ys, i_ye; int u_xs, u_xe, u_ys, u_ye; } testData[] = { { 0,10, 0,10, 0,10, 0,10, true, 0,10, 0,10, 0,10, 0,10 }, /* complete intersect */ { 0,10, 0,10, 20,30,20,30, false, 0, 0, 0, 0, 0,30, 0,30 }, /* no intersect */ { 0,10, 0,10, 5,15, 0,10, true, 5,10, 0,10, 0,15, 0,10 }, /* { | } | */ { 0,10, 0,10, 5, 7, 0,10, true, 5, 7, 0,10, 0,10, 0,10 }, /* { | | } */ { 0,10, 0,10, 5, 7, 5, 7, true, 5, 7, 5, 7, 0,10, 0,10 }, { 0,10, 0,10, 5, 15,5,15, true, 5,10, 5,10, 0,15, 0,15 }, }; for (size_t i = 0; i < dimof(testData); i++) { struct SRIData *curr = &testData[i]; RectI rx1(curr->x1s, curr->y1s, curr->x1e - curr->x1s, curr->y1e - curr->y1s); RectI rx2 = RectI::FromXY(curr->x2s, curr->y2s, curr->x2e, curr->y2e); RectI isect = rx1.Intersect(rx2); if (curr->intersect) { utassert(!isect.IsEmpty()); utassert(isect.x == curr->i_xs && isect.y == curr->i_ys); utassert(isect.x + isect.dx == curr->i_xe && isect.y + isect.dy == curr->i_ye); } else { utassert(isect.IsEmpty()); } RectI urect = rx1.Union(rx2); utassert(urect.x == curr->u_xs && urect.y == curr->u_ys); utassert(urect.x + urect.dx == curr->u_xe && urect.y + urect.dy == curr->u_ye); /* if we swap rectangles, the results should be the same */ std::swap(rx1, rx2); isect = rx1.Intersect(rx2); if (curr->intersect) { utassert(!isect.IsEmpty()); utassert(isect.x == curr->i_xs && isect.y == curr->i_ys); utassert(isect.x + isect.dx == curr->i_xe && isect.y + isect.dy == curr->i_ye); } else { utassert(isect.IsEmpty()); } urect = rx1.Union(rx2); utassert(RectI::FromXY(curr->u_xs, curr->u_ys, curr->u_xe, curr->u_ye) == urect); utassert(!rx1.Contains(PointI(-2, -2))); utassert(rx1.Contains(rx1.TL())); utassert(!rx1.Contains(PointI(rx1.x, INT_MAX))); utassert(!rx1.Contains(PointI(INT_MIN, rx1.y))); } }
static vx_status vxEdgeTrace(vx_image norm, vx_threshold threshold, vx_image output) { vx_rectangle_t rect; vx_imagepatch_addressing_t norm_addr, output_addr; void *norm_base = NULL, *output_base = NULL; vx_uint32 y = 0, x = 0; vx_int32 lower = 0, upper = 0; vx_status status = VX_SUCCESS; vxQueryThreshold(threshold, VX_THRESHOLD_ATTRIBUTE_THRESHOLD_LOWER, &lower, sizeof(lower)); vxQueryThreshold(threshold, VX_THRESHOLD_ATTRIBUTE_THRESHOLD_UPPER, &upper, sizeof(upper)); vxGetValidRegionImage(norm, &rect); status |= vxAccessImagePatch(norm, &rect, 0, &norm_addr, &norm_base, VX_READ_ONLY); status |= vxAccessImagePatch(output, &rect, 0, &output_addr, &output_base, VX_WRITE_ONLY); if (status == VX_SUCCESS) { const vx_uint8 NO = 0, MAYBE = 127, YES = 255; /* Initially we add all YES pixels to the stack. Later we only add MAYBE pixels to it, and we reset their state to YES afterwards; so we can never add the same pixel more than once. That means that the stack size is bounded by the image size. */ vx_uint32 (*tracing_stack)[2] = malloc(output_addr.dim_y * output_addr.dim_x * sizeof *tracing_stack); vx_uint32 (*stack_top)[2] = tracing_stack; for (y = 0; y < norm_addr.dim_y; y++) for (x = 0; x < norm_addr.dim_x; x++) { vx_uint16 *norm_ptr = vxFormatImagePatchAddress2d(norm_base, x, y, &norm_addr); vx_uint8 *output_ptr = vxFormatImagePatchAddress2d(output_base, x, y, &output_addr); if (*norm_ptr > upper) { *output_ptr = YES; (*stack_top)[0] = x; (*stack_top)[1] = y; ++stack_top; } else if (*norm_ptr <= lower) { *output_ptr = NO; } else { *output_ptr = MAYBE; } } while (stack_top != tracing_stack) { int i; --stack_top; x = (*stack_top)[0]; y = (*stack_top)[1]; for (i = 0; i < dimof(dir_offsets); ++i) { const struct offset_t offset = dir_offsets[i]; vx_uint32 new_x, new_y; vx_uint8 *output_ptr; if (x == 0 && offset.x < 0) continue; if (x == output_addr.dim_x - 1 && offset.x > 0) continue; if (y == 0 && offset.y < 0) continue; if (y == output_addr.dim_y - 1 && offset.y > 0) continue; new_x = x + offset.x; new_y = y + offset.y; output_ptr = vxFormatImagePatchAddress2d(output_base, new_x, new_y, &output_addr); if (*output_ptr != MAYBE) continue; *output_ptr = YES; (*stack_top)[0] = new_x; (*stack_top)[1] = new_y; ++stack_top; } } free(tracing_stack); for (y = 0; y < output_addr.dim_y; y++) for (x = 0; x < output_addr.dim_x; x++) { vx_uint8 *output_ptr = vxFormatImagePatchAddress2d(output_base, x, y, &output_addr); if (*output_ptr == MAYBE) *output_ptr = NO; } status |= vxCommitImagePatch(norm, 0, 0, &norm_addr, norm_base); status |= vxCommitImagePatch(output, &rect, 0, &output_addr, output_base); } return status; }
cl_bool no_print_logo; cl_bool verbose; char cl_args[CL_MAX_STRING]; char precomp[CL_MAX_PATHSIZE]; char cl_device_types[CL_MAX_STRING]; clOpt options[] = { {"-f", CL_OPTION_TYPE_STRING, CL_MAX_PATHSIZE, filename, "The input kernel file."}, {"-d", CL_OPTION_TYPE_INT, sizeof(cl_uint), &numDevices, "The number of devices to target. Max of 10."}, {"-n", CL_OPTION_TYPE_BOOL, sizeof(cl_bool), &no_print_logo,"Disables printing of the logo."}, {"-v", CL_OPTION_TYPE_BOOL, sizeof(cl_bool), &verbose, "Enables debuging statements."}, {"-o", CL_OPTION_TYPE_STRING, CL_MAX_PATHSIZE, outfile, "The output binary file"}, {"-h", CL_OPTION_TYPE_STRING, CL_MAX_PATHSIZE, precomp, "The precompiled header output file"}, {"-W", CL_OPTION_TYPE_STRING, CL_MAX_STRING, cl_args, "Arguments to pass the OpenCL compiler for the kernels"}, {"-t", CL_OPTION_TYPE_STRING, CL_MAX_STRING, cl_device_types, "Specifies the device types supported [cpu|gpu|acc|all]"}, }; cl_uint numOpts = dimof(options); void clOptions(int argc, char *argv[]) { int i = 0; cl_uint j = 0; for (i = 1; i < argc; i++) { if (verbose) printf("ARGV[%u]: \"%s\"\n",i,argv[i]); for (j = 0; j < numOpts; j++) { if (strcmp(argv[i], options[j].arg) == 0) { switch (options[j].type) {
static void BencTestStress() { char key[64]; char val[64]; WCHAR tval[64]; Vec<BencObj*> stack(29); BencDict *startDict = new BencDict(); BencDict *d = startDict; BencArray *a = NULL; srand((unsigned int)time(NULL)); // generate new dict or array with 5% probability each, close an array or // dict with 8% probability (less than 10% probability of opening one, to // encourage nesting), generate int, string or raw strings uniformly // across the remaining 72% probability for (int i = 0; i < 10000; i++) { int n = rand() % 100; if (n < 5) { BencDict *nd = new BencDict(); if (a) { a->Add(nd); } else { GenRandStr(key, dimof(key)); d->Add(key, nd); } stack.Push(nd); d = nd; a = NULL; } else if (n < 10) { BencArray *na = new BencArray(); if (a) { a->Add(na); } else { GenRandStr(key, dimof(key)); d->Add(key, na); } stack.Push(na); d = NULL; a = na; } else if (n < 18) { if (stack.Count() > 0) { n = rand() % 100; stack.Pop(); BencObj *o = startDict; if (stack.Count() > 0) { o = stack.Last(); } a = NULL; d = NULL; if (BT_ARRAY == o->Type()) { a = static_cast<BencArray *>(o); } else { d = static_cast<BencDict *>(o); } } } else if (n < (18 + 24)) { int64_t v = rand(); if (a) { a->Add(v); } else { GenRandStr(key, dimof(key)); d->Add(key, v); } } else if (n < (18 + 24 + 24)) { GenRandStr(val, dimof(val)); if (a) { a->AddRaw(val); } else { GenRandStr(key, dimof(key)); d->AddRaw(key, val); } } else { GenRandTStr(tval, dimof(tval)); if (a) { a->Add(tval); } else { GenRandStr(key, dimof(key)); d->Add(key, tval); } } } ScopedMem<char> s(startDict->Encode()); delete startDict; }
ptr->dim.image.format = VX_DF_IMAGE_U8; ptr->dim.image.width = width; ptr->dim.image.height = height; status = VX_SUCCESS; vxReleaseImage(&input); } vxReleaseParameter(¶m); } return status; } static vx_param_description_t phase_kernel_params[] = { {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_INPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, {VX_OUTPUT, VX_TYPE_IMAGE, VX_PARAMETER_STATE_REQUIRED}, }; vx_kernel_description_t phase_kernel = { VX_KERNEL_PHASE, "org.khronos.openvx.phase", vxPhaseKernel, phase_kernel_params, dimof(phase_kernel_params), NULL, vxPhaseInputValidator, vxPhaseOutputValidator, NULL, NULL, };
static void OnButtonBrowse() { ScopedMem<WCHAR> installDir(win::GetText(gHwndTextboxInstDir)); // strip a trailing "\SumatraPDF" if that directory doesn't exist (yet) if (!dir::Exists(installDir)) installDir.Set(path::GetDir(installDir)); WCHAR path[MAX_PATH]; if (BrowseForFolder(gHwndFrame, installDir, L"Select the folder into which " TAPP L" should be installed:", path, dimof(path))) { WCHAR *installPath = path; // force paths that aren't entered manually to end in ...\SumatraPDF // to prevent unintended installations into e.g. %ProgramFiles% itself if (!str::EndsWithI(path, L"\\" TAPP)) installPath = path::Join(path, TAPP); win::SetText(gHwndTextboxInstDir, installPath); Edit_SetSel(gHwndTextboxInstDir, 0, -1); SetFocus(gHwndTextboxInstDir); if (installPath != path) free(installPath); } else SetFocus(gHwndButtonBrowseDir); }
static vx_status VX_CALLBACK vxHarrisInitializer(vx_node node, vx_reference parameters[], vx_uint32 num) { vx_status status = VX_FAILURE; if (num == dimof(harris_kernel_params)) { vx_image src = (vx_image)parameters[0]; vx_scalar str = (vx_scalar)parameters[1]; vx_scalar min = (vx_scalar)parameters[2]; vx_scalar sen = (vx_scalar)parameters[3]; vx_scalar win = (vx_scalar)parameters[4]; vx_scalar blk = (vx_scalar)parameters[5]; vx_array arr = (vx_array)parameters[6]; vx_scalar num_corners = (vx_scalar)parameters[7]; vx_context c = vxGetContext((vx_reference)node); vx_graph g = vxCreateGraph(c); vxLoadKernels(c, "openvx-extras"); vxLoadKernels(c, "openvx-debug"); if (g) { vx_uint32 i = 0; vx_int32 ds = 4; vx_scalar shift = vxCreateScalar(c, VX_TYPE_INT32, &ds); vx_image virts[] = { vxCreateVirtualImage(g, 0, 0, VX_DF_IMAGE_VIRT), // Gx vxCreateVirtualImage(g, 0, 0, VX_DF_IMAGE_VIRT), // Gy vxCreateVirtualImage(g, 0, 0, VX_DF_IMAGE_VIRT), // Score vxCreateVirtualImage(g, 0, 0, VX_DF_IMAGE_VIRT), // Suppressed vxCreateVirtualImage(g, 0, 0, VX_DF_IMAGE_U8), // Shifted Suppressed Log10 }; vx_node nodes[] = { vxSobelMxNNode(g, src, win, virts[0], virts[1]), vxHarrisScoreNode(g, virts[0], virts[1], sen, blk, virts[2]), vxEuclideanNonMaxNode(g, virts[2], str, min, virts[3]), vxImageListerNode(g, virts[3], arr, num_corners), #if defined(OPENVX_DEBUGGING) vxConvertDepthNode(g,virts[3],virts[4],VX_CONVERT_POLICY_WRAP,shift), vxFWriteImageNode(g,virts[4],"oharris_strength_power_up4.pgm"), #endif }; status = VX_SUCCESS; status |= vxAddParameterToGraphByIndex(g, nodes[0], 0); // src status |= vxAddParameterToGraphByIndex(g, nodes[2], 1); // str status |= vxAddParameterToGraphByIndex(g, nodes[2], 2); // min status |= vxAddParameterToGraphByIndex(g, nodes[1], 2); // sen status |= vxAddParameterToGraphByIndex(g, nodes[0], 1); // win status |= vxAddParameterToGraphByIndex(g, nodes[1], 3); // blk status |= vxAddParameterToGraphByIndex(g, nodes[3], 1); // arr status |= vxAddParameterToGraphByIndex(g, nodes[3], 2); // num_corners for (i = 0; i < dimof(nodes); i++) { vxReleaseNode(&nodes[i]); } for (i = 0; i < dimof(virts); i++) { vxReleaseImage(&virts[i]); } vxReleaseScalar(&shift); status |= vxVerifyGraph(g); VX_PRINT(VX_ZONE_INFO, "Status from Child Graph = %d\n", status); if (status == VX_SUCCESS) { status = vxSetChildGraphOfNode(node, g); } else { vxReleaseGraph(&g); } } } return status; }
void* OEMBootInit( ) { BootLoader_t *pLoader = &s_bootLoader; BootBlockBiosParameterBlockType1_t *pBpb1; BootBlockBiosParameterBlockType2_t *pBpb2; BootBlockBiosParameterBlockTypeEx_t *pBpbEx; BootDisplayBiosVbeInfoBlock_t *pInfo; uint32_t eax, ebx, ecx, edx, esi, edi; FWORDPtr IVTPtr; #pragma pack(push, 1) typedef struct e820_t { ULARGE_INTEGER addr; ULARGE_INTEGER size; uint32_t type; } e820_t; #pragma pack(pop) enum { usable = 1 }; e820_t * e820buffer; // Initialize boot arguments BootArgsInit(false); // Initalize supported drivers info pLoader->devices = dimof(s_devices); pLoader->pDevices = s_devices; // Get boot driver from Bios Parameter Block pBpbEx = (BootBlockBiosParameterBlockTypeEx_t *)0xFA03; pBpb2 = (BootBlockBiosParameterBlockType2_t *)0xFA03; pBpb1 = (BootBlockBiosParameterBlockType1_t *)0xFA03; if (memcmp(pBpbEx->versionId, "exFAT ", sizeof(pBpbEx->versionId)) == 0) { pLoader->driveId = pBpbEx->driveId; } else if (memcmp(pBpb2->fatType, "FAT32 ", sizeof(pBpb2->fatType)) == 0) { pLoader->driveId = pBpb2->driveId; } else if (memcmp(pBpb1->fatType, "FAT16 ", sizeof(pBpb1->fatType)) == 0) { pLoader->driveId = pBpb1->driveId; } else if (memcmp(pBpb1->fatType, "FAT12 ", sizeof(pBpb1->fatType)) == 0) { pLoader->driveId = pBpb1->driveId; } // Find if there is PCI BIOS extension eax = 0xB101; edi = 0x0000; _asm { sidt [IVTPtr] }; if (IVTPtr.Base == 0) { // IVT was setup by the BIOS, save it memcpy((DWORD*)pIVT, IVTPtr.Base, MAX_INTR*sizeof(DWORD)); } else { // IVT was overwritten by the kernel, restore the saved copy IVTPtr.Size = 0xffff; IVTPtr.Base = 0; memcpy(IVTPtr.Base, pIVT, MAX_INTR*sizeof(DWORD)); _asm { lidt [IVTPtr] }; } BootBiosInt1A(&eax, &ebx, &ecx, &edx, &esi, &edi); if (((eax & 0xFF00) == 0) && (edx == ' ICP')) { pLoader->pciBiosMajor = (uint8_t)((ebx & 0xFF00) >> 8); pLoader->pciBiosMinor = (uint8_t)((ebx & 0x00FF) >> 0); pLoader->pciBusMode = (uint8_t)((eax & 0x00FF) >> 0); pLoader->pciLastBus = (uint8_t)((ecx & 0x00FF) >> 0); }