void getClips (JsonReader * reader, GESLayer * layer, GESTrackType type, gboolean absolute_paths) { int i; json_reader_read_member (reader, "clips"); g_print ("= clips =\n"); for (i = 0; i < json_reader_count_elements (reader); i++) { json_reader_read_element (reader, i); const char *src = getString (reader, "src"); int start = getInt (reader, "start"); int in = getInt (reader, "in"); int dur = getInt (reader, "dur"); g_print ("Clip: %s (start: %d, in: %d, dur: %d)\n", src, start, in, dur); GESClip *clip; if (is_in_members (reader, "multi") && getBool (reader, "multi")) { g_print ("multi on.\n"); clip = ges_multi_clip_from_path (src, layer, start, in, dur, absolute_paths); } else { const char *path; if (absolute_paths == TRUE) { path = src; } else { path = ges_renderer_get_absolute_path (src); } clip = ges_clip_from_path (path, layer, start, in, dur, type); } GESTimeline *tl = ges_layer_get_timeline (layer); GList *tracks = ges_timeline_get_tracks (tl); GESTrack *trackv = g_list_first (tracks)->data; GESTrack *tracka = g_list_last (tracks)->data; if (is_in_members (reader, "volume")) { double volume = getDouble (reader, "volume"); GESTrackElement *audioElement = ges_clip_find_track_element (clip, tracka, G_TYPE_NONE); if (audioElement != NULL) { ges_track_element_set_child_properties (audioElement, "volume", volume, NULL); } } GESTrackElement *videoElement = ges_clip_find_track_element (clip, trackv, G_TYPE_NONE); if (videoElement != NULL) { if (is_in_members (reader, "x")) { int x = getInt (reader, "x"); ges_track_element_set_child_properties (videoElement, "posx", x, NULL); } if (is_in_members (reader, "y")) { int y = getInt (reader, "y"); ges_track_element_set_child_properties (videoElement, "posy", y, NULL); } if (is_in_members (reader, "alpha")) { gdouble alpha = getDouble (reader, "alpha"); ges_track_element_set_child_properties (videoElement, "alpha", alpha, NULL); } if (is_in_members (reader, "size")) { gdouble size = getDouble (reader, "size"); GESUriClipAsset *asset = GES_URI_CLIP_ASSET (ges_extractable_get_asset (GES_EXTRACTABLE (clip))); guint width = ges_asset_get_width (asset); guint height = ges_asset_get_height (asset); if (width != 0 && height != 0) { double dw = width * size; double dh = height * size; g_print ("%dx%d => * %f => %dx%d\n", width, height, size, (int) dw, (int) dh); ges_track_element_set_child_properties (videoElement, "width", (int) dw, "height", (int) dh, NULL); } } if (is_in_members (reader, "effect")) { const char *effect_str = getString (reader, "effect"); if (strcmp (effect_str, "") != 0) { g_print ("Using effect %s", effect_str); GESEffect *effect = ges_effect_new (effect_str); ges_container_add (GES_CONTAINER (clip), GES_TIMELINE_ELEMENT (effect)); } } } json_reader_end_element (reader); } json_reader_end_member (reader); }
bool StringParameterDescriptor::filePathExists() { return (getInt(kOfxParamPropStringFilePathExists, 0) == 1); }
void render_json (const char *filename) { JsonParser *parser; JsonNode *root; GError *error; parser = json_parser_new (); error = NULL; json_parser_load_from_file (parser, filename, &error); if (error) { g_print ("Parsing error `%s':\n %s\n", filename, error->message); g_error_free (error); g_object_unref (parser); exit (0); } root = json_parser_get_root (parser); JsonReader *reader = json_reader_new (root); GESTimeline *timeline; json_reader_read_member (reader, "composition"); // comp strings const char *name = getString (reader, "name"); //const char *src_dir = getString (reader, "src-dir"); //g_print ("Source Directory: %s\nName: %s\n", src_dir, name); // comp ints int width = getInt (reader, "width"); int height = getInt (reader, "height"); int fps = getInt (reader, "fps"); gboolean transparency = TRUE; if (is_in_members (reader, "transparency")) { transparency = getBool (reader, "transparency"); } gboolean absolute_paths = FALSE; if (is_in_members (reader, "absolute_paths")) { absolute_paths = getBool (reader, "absolute_paths"); } g_print ("Resolution: %dx%d, FPS: %d\n", width, height, fps); timeline = ges_timeline_new_audio_video (); int i; json_reader_read_member (reader, "layers"); for (i = 0; i < json_reader_count_elements (reader); i++) { json_reader_read_element (reader, i); GESLayer *layer = ges_layer_new (); g_object_set (layer, "priority", i, NULL); if (is_in_members (reader, "autotransition")) { gboolean autotransition = getBool (reader, "autotransition"); if (autotransition) g_print ("Auto Transitions on.\n"); g_object_set (layer, "auto-transition", autotransition, NULL); } ges_timeline_add_layer (timeline, layer); getClips (reader, layer, GES_TRACK_TYPE_UNKNOWN, absolute_paths); json_reader_end_element (reader); } json_reader_end_member (reader); ges_timeline_commit (timeline); const gchar *xges_path = g_strconcat ("file://", filename, ".xges", NULL); ges_timeline_save_xges (timeline, xges_path); //free(xges_path); // formats GESRendererProfile res = { width, height, fps, PROFILE_AAC_H264_QUICKTIME, NULL }; if (!transparency) { g_print ("Deactivating transparency\n"); res.format = "I420"; } json_reader_read_member (reader, "formats"); for (i = 0; i < json_reader_count_elements (reader); i++) { json_reader_read_element (reader, i); const char *format = json_reader_get_string_value (reader); json_reader_end_element (reader); g_print ("format: %s\n", format); EncodingProfile prof = PROFILE_AAC_H264_QUICKTIME; if (strcmp (format, "webm") == 0) { prof = PROFILE_VORBIS_VP8_WEBM; } else if (strcmp (format, "mkv") == 0) { prof = PROFILE_VORBIS_H264_MATROSKA; } else if (strcmp (format, "mp4") == 0) { prof = PROFILE_AAC_H264_QUICKTIME; } else if (strcmp (format, "ogg") == 0) { prof = PROFILE_VORBIS_THEORA_OGG; } res.profile = prof; ges_renderer_render (timeline, name, &res, absolute_paths); } json_reader_end_member (reader); json_reader_end_member (reader); g_object_unref (reader); g_object_unref (parser); }
FOR(tt, t) { long long int n = getInt(); int i = 2; while (data[i] < n) i++; printf("%d\n", i); }
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { // mexPrintf("Number of lhs = %d\n", nlhs); // mexPrintf("number of rhs = %d\n", nrhs); // create a log writer for error messages if this is the // first MATLAB function call initLogger(); // flag specifying the class int iclass = getInt(prhs[0]); // Hand off to the appropriate routine, based on the // value of the first parameter switch (iclass) { case NO_CLASS: ctfunctions(nlhs, plhs, nrhs, prhs); break; case XML_CLASS: xmlmethods(nlhs, plhs, nrhs, prhs); break; case THERMO_CLASS: thermomethods(nlhs, plhs, nrhs, prhs); break; case PHASE_CLASS: phasemethods(nlhs, plhs, nrhs, prhs); break; case MIXTURE_CLASS: mixturemethods(nlhs, plhs, nrhs, prhs); break; case KINETICS_CLASS: kineticsmethods(nlhs, plhs, nrhs, prhs); break; case TRANSPORT_CLASS: transportmethods(nlhs, plhs, nrhs, prhs); break; case REACTOR_CLASS: reactormethods(nlhs, plhs, nrhs, prhs); break; case REACTORNET_CLASS: reactornetmethods(nlhs, plhs, nrhs, prhs); break; case WALL_CLASS: wallmethods(nlhs, plhs, nrhs, prhs); break; case FLOWDEVICE_CLASS: flowdevicemethods(nlhs, plhs, nrhs, prhs); break; case ONEDIM_CLASS: onedimmethods(nlhs, plhs, nrhs, prhs); break; case SURF_CLASS: surfmethods(nlhs, plhs, nrhs, prhs); break; case FUNC_CLASS: funcmethods(nlhs, plhs, nrhs, prhs); break; default: mexPrintf("iclass = %d",iclass); //mexErrMsgTxt("unknown class"); } }
void RepoQuery::getAttr(int iCol, Attr& attrs) { int val; getInt(iCol, val); attrs = Attr(val); }
return minus ? -r : r; } int cmp(const void *p1, const void *p2) { return *((int *)p2) - *((int *)p1); } int main(void) { int n = getInt(); int totalNumbers = 0; int a[MAX_N]; FOR(i, n) { a[totalNumbers] = getInt(); if (a[totalNumbers] < 0) totalNumbers++; } long long int x = getInt(); long long int result = 0; if (totalNumbers > 0) { if (totalNumbers > x) { qsort(a, totalNumbers, sizeof(a[0]), cmp); int v = -a[totalNumbers - x]; result = v * x; FORE(i, totalNumbers - x + 1, totalNumbers) result += -a[i] - v; } else { FOR(i, totalNumbers) result += -a[i]; } } printf("%lld\n", result);
bool RegistrySettingsManager::getUINT(const TCHAR *name, UINT *value) { return getInt(name, (int *)value); }
void Config::loadValues(string country) { runtimeBaseDir = getString("common", "runtime_dir", "/usr/share/openalpr/runtime_data"); opencl_enabled = getBoolean("common", "opencl_enabled", false); multithreading_cores = getInt("common", "multithreading_cores", 1); detection_iteration_increase = getFloat("common", "detection_iteration_increase", 1.1); maxPlateWidthPercent = getFloat("common", "max_plate_width_percent", 100); maxPlateHeightPercent = getFloat("common", "max_plate_height_percent", 100); maxPlateAngleDegrees = getInt("common", "max_plate_angle_degrees", 15); minPlateSizeWidthPx = getInt(country, "min_plate_size_width_px", 100); minPlateSizeHeightPx = getInt(country, "min_plate_size_height_px", 100); plateWidthMM = getFloat(country, "plate_width_mm", 100); plateHeightMM = getFloat(country, "plate_height_mm", 100); charHeightMM = getFloat(country, "char_height_mm", 100); charWidthMM = getFloat(country, "char_width_mm", 100); charWhitespaceTopMM = getFloat(country, "char_whitespace_top_mm", 100); charWhitespaceBotMM = getFloat(country, "char_whitespace_bot_mm", 100); templateWidthPx = getInt(country, "template_max_width_px", 100); templateHeightPx = getInt(country, "template_max_height_px", 100); float ocrImagePercent = getFloat("common", "ocr_img_size_percent", 100); ocrImageWidthPx = round(((float) templateWidthPx) * ocrImagePercent); ocrImageHeightPx = round(((float)templateHeightPx) * ocrImagePercent); float stateIdImagePercent = getFloat("common", "state_id_img_size_percent", 100); stateIdImageWidthPx = round(((float)templateWidthPx) * ocrImagePercent); stateIdimageHeightPx = round(((float)templateHeightPx) * ocrImagePercent); charAnalysisMinPercent = getFloat(country, "char_analysis_min_pct", 0); charAnalysisHeightRange = getFloat(country, "char_analysis_height_range", 0); charAnalysisHeightStepSize = getFloat(country, "char_analysis_height_step_size", 0); charAnalysisNumSteps = getInt(country, "char_analysis_height_num_steps", 0); segmentationMinBoxWidthPx = getInt(country, "segmentation_min_box_width_px", 0); segmentationMinCharHeightPercent = getFloat(country, "segmentation_min_charheight_percent", 0); segmentationMaxCharWidthvsAverage = getFloat(country, "segmentation_max_segment_width_percent_vs_average", 0); plateLinesSensitivityVertical = getFloat(country, "plateline_sensitivity_vertical", 0); plateLinesSensitivityHorizontal = getFloat(country, "plateline_sensitivity_horizontal", 0); ocrLanguage = getString(country, "ocr_language", "none"); ocrMinFontSize = getInt("common", "ocr_min_font_point", 100); postProcessMinConfidence = getFloat("common", "postprocess_min_confidence", 100); postProcessConfidenceSkipLevel = getFloat("common", "postprocess_confidence_skip_level", 100); postProcessMaxSubstitutions = getInt("common", "postprocess_max_substitutions", 100); postProcessMinCharacters = getInt("common", "postprocess_min_characters", 100); postProcessMaxCharacters = getInt("common", "postprocess_max_characters", 100); debugGeneral = getBoolean("debug", "general", false); debugTiming = getBoolean("debug", "timing", false); debugStateId = getBoolean("debug", "state_id", false); debugPlateLines = getBoolean("debug", "plate_lines", false); debugPlateCorners = getBoolean("debug", "plate_corners", false); debugCharRegions = getBoolean("debug", "char_regions", false); debugCharSegmenter = getBoolean("debug", "char_segment", false); debugCharAnalysis = getBoolean("debug", "char_analysis", false); debugColorFiler = getBoolean("debug", "color_filter", false); debugOcr = getBoolean("debug", "ocr", false); debugPostProcess = getBoolean("debug", "postprocess", false); debugShowImages = getBoolean("debug", "show_images", false); debugPauseOnFrame = getBoolean("debug", "pause_on_frame", false); }
int TeSQLitePortal::getInt(const string& s) { return getInt(getColumnIndex(s)); }
void bridge_message(struct mosquitto *mosq, int sd, struct device *dev, char *msg) { char md_id[DEVICE_MD_ID_SIZE + 1]; struct module *md; struct device *target_dev; int code, i; if (config.debug > 2) printf("Bridge - message: %s\n", msg); if (!getInt(&msg, &code)) { if (config.debug > 1) printf("MQTT - Invalid data.\n"); return; } switch (code) { case PROTO_ERROR: case PROTO_ACK: case PROTO_NACK: case PROTO_ST_TIMEOUT: case PROTO_DEVICE: return; case PROTO_ST_ALIVE: if (!getInt(&msg, &code)) return; if (dev->modules == code) return; dev->modules = code; // no return here is purposeful case PROTO_ST_MODULES_UP: // Modules Update if (dev->type == DEVICE_TYPE_NODE) { // Message from a serial device if (dev->md_deps->type == MODULE_SERIAL && bridge.serial_ready) { snprintf(gbuf, GBUF_SIZE, "%s%s,%d", SERIAL_INIT_MSG, dev->id, PROTO_GET_MODULES); serialport_printlf(sd, gbuf); } // Message from a MQTT device else if (dev->md_deps->type == MODULE_MQTT) { snprintf(gbuf, GBUF_SIZE, "%s,%d", bridge.id, PROTO_GET_MODULES); mqtt_publish(mosq, dev->topic, gbuf); return; } } return; case PROTO_GET_MODULES: // Message from a MQTT device if (dev->md_deps->type == MODULE_MQTT) { for (md = bridge.module; md != NULL; md = md->next) { snprintf(gbuf, GBUF_SIZE, "%s,%d,%s,%s,%d", bridge.id, PROTO_MODULE, md->id, md->device, md->enabled); mqtt_publish(mosq, dev->topic, gbuf); } } return; case PROTO_GET_DEVICES: // Message from a MQTT device if (dev->md_deps->type == MODULE_MQTT) { for (i = 0; i < bridge.devices_len; i++) { target_dev = &bridge.devices[i]; snprintf(gbuf, GBUF_SIZE, "%s,%d,%s,%d,%d" , bridge.id, PROTO_DEVICE, target_dev->id, target_dev->modules, target_dev->alive); mqtt_publish(mosq, dev->topic, gbuf); } } return; case PROTO_SAVE_DEVICE: target_dev = device_get(&bridge, msg); if (!target_dev) return; if (config.debug > 1) { printf("Saving device:\n"); device_print_device(target_dev); } device_save(&bridge, config.devices_folder, target_dev); return; } if (!getString(&msg, md_id, DEVICE_MD_ID_SIZE, ',')) { if (config.debug > 1) printf("Missing module id - code: %d\n", code); return; } if (!device_isValid_md_id(md_id)) { if (config.debug > 1) printf("Invalid module id - code: %d\n", code); return; } md = device_get_module(&bridge, md_id); if (code == PROTO_MODULE) { if (!md) { if (device_add_module(&bridge, md_id, dev->id) == -1) { run = 0; return; } if (config.debug > 1) { md = device_get_module(&bridge, md_id); printf("New Module:\n"); device_print_module(md); } } return; } if (!md) return; target_dev = device_get(&bridge, md->device); if (!target_dev) { fprintf(stderr, "Error: Orphan module.\n"); device_remove_module(&bridge, md_id); return; } switch (code) { case PROTO_GET_MODULE: // Message from a MQTT device if (dev->md_deps->type == MODULE_MQTT) { snprintf(gbuf, GBUF_SIZE, "%s,%d,%s,%s,%d", bridge.id, PROTO_MODULE, md->id, md->device, md->enabled); mqtt_publish(mosq, dev->topic, gbuf); } return; case PROTO_MD_GET_TOPIC: // Message from a MQTT device if (dev->md_deps->type == MODULE_MQTT) { snprintf(gbuf, GBUF_SIZE, "%s,%d,%s,%s", bridge.id, PROTO_MD_TOPIC, md->id, md->topic); mqtt_publish(mosq, dev->topic, gbuf); } return; case PROTO_MD_SET_TOPIC: case PROTO_MD_TOPIC: code = device_set_md_topic(md, msg); if (code == -1) { // Memory problem run = 0; return; } if (code == 0) { // Module topic changed snprintf(gbuf, GBUF_SIZE, "%d,%s,%s", PROTO_MD_TOPIC, md->id, md->topic); mqtt_publish(mosq, bridge.status_topic, gbuf); } return; case PROTO_MD_RAW: mqtt_publish(mosq, md->topic, msg); return; case PROTO_MD_TO_RAW: // Target module at serial if (target_dev->md_deps->type == MODULE_SERIAL && bridge.serial_ready) { snprintf(gbuf, GBUF_SIZE, "%s%s,%d,%s,%s", SERIAL_INIT_MSG, target_dev->id, PROTO_MD_TO_RAW, md->id, msg); serialport_printlf(sd, gbuf); } // Target module at MQTT else if (target_dev->md_deps->type == MODULE_MQTT) { snprintf(gbuf, GBUF_SIZE, "%s,%d,%s,%s", bridge.id, PROTO_MD_TO_RAW, md->id, msg); mqtt_publish(mosq, target_dev->topic, gbuf); } else if (!strcmp(md->device, bridge.id)) { if (md->type == MODULE_SCRIPT) { code = run_script(config.scripts_folder, msg, gbuf, GBUF_SIZE, config.debug); if (code == -1) { run = 0; } else if (code == 1) { mqtt_publish(mosq, md->topic, "0"); } else if (code == 0) { if (strlen(gbuf) > 0) { if (config.debug > 1) printf("Script output:\n-\n%s\n-\n", gbuf); mqtt_publish(mosq, md->topic, gbuf); } else { mqtt_publish(mosq, md->topic, "1"); } } } else if (md->type == MODULE_BANDWIDTH) { if (bandwidth) { if (mqtt_publish_bandwidth(mosq, md->topic) == -1) run = 0; } } else if (md->type == MODULE_SERIAL) { snprintf(gbuf, GBUF_SIZE, "%d", bridge.serial_ready); mqtt_publish(mosq, md->topic, gbuf); } } return; case PROTO_MD_ENABLE: //TODO: implement case PROTO_MD_GET_ENABLE: //TODO: implement case PROTO_MD_SET_ENABLE: //TODO: implement return; default: if (config.debug > 2) printf("Bridge - code: %d - Not treated.\n", code); } }
int main(int argc, char *argv[]) { int numKeyFlags; /* Counts -f, -k, and -p options */ int flags, shmid, segSize; unsigned int perms; long lkey; key_t key; int opt; /* Option character from getopt() */ /* Parse command-line options and arguments */ numKeyFlags = 0; flags = 0; while ((opt = getopt(argc, argv, "cf:k:px")) != -1) { switch (opt) { case 'c': flags |= IPC_CREAT; break; case 'f': /* -f pathname */ key = ftok(optarg, 1); if (key == -1) errExit("ftok"); numKeyFlags++; break; case 'k': /* -k key (octal, decimal or hexadecimal) */ if (sscanf(optarg, "%li", &lkey) != 1) cmdLineErr("-k option requires a numeric argument\n"); key = lkey; numKeyFlags++; break; case 'p': key = IPC_PRIVATE; numKeyFlags++; break; case 'x': flags |= IPC_EXCL; break; default: usageError(argv[0], NULL); } } if (numKeyFlags != 1) usageError(argv[0], "Exactly one of the options -f, -k, " "or -p must be supplied\n"); if (optind >= argc) usageError(argv[0], "Size of segment must be specified\n"); segSize = getLong(argv[optind], GN_ANY_BASE, "seg-size"); perms = (argc <= optind + 1) ? (S_IRUSR | S_IWUSR) : getInt(argv[optind + 1], GN_BASE_8, "octal-perms"); shmid = shmget(key, segSize, flags | perms); if (shmid == -1) errExit("shmget"); printf("%d\n", shmid); /* On success, display shared mem. id */ exit(EXIT_SUCCESS); }
int ShadowCalculation_Impl::calculationFrequency() const { boost::optional<int> value = getInt(OS_ShadowCalculationFields::CalculationFrequency,true); OS_ASSERT(value); return value.get(); }
int ShadowCalculation_Impl::maximumFiguresInShadowOverlapCalculations() const { boost::optional<int> value = getInt(OS_ShadowCalculationFields::MaximumFiguresinShadowOverlapCalculations,true); OS_ASSERT(value); return value.get(); }
void RepoQuery::getId(int iCol, Id& id) { int val; getInt(iCol, val); id = Id(val); }
boost::optional<int> ProgramControl_Impl::numberofThreadsAllowed() const { return getInt(OS_ProgramControlFields::NumberofThreadsAllowed,true); }
void RepoQuery::getOffset(int iCol, Offset& offset) { int val; getInt(iCol, val); offset = Offset(val); }
int main(int argc, char *argv[]) { struct utmpx ut; char *devName; if (argc < 2 || strcmp(argv[1], "--help") == 0) usageErr("%s username [sleep-time]\n", argv[0]); /* Initialize login record for utmp and wtmp files */ memset(&ut, 0, sizeof(struct utmpx)); ut.ut_type = USER_PROCESS; /* This is a user login */ strncpy(ut.ut_user, argv[1], sizeof(ut.ut_user)); if (time((time_t *) &ut.ut_tv.tv_sec) == -1) errExit("time"); /* Stamp with current time */ ut.ut_pid = getpid(); /* Set ut_line and ut_id based on the terminal associated with 'stdin'. This code assumes terminals named "/dev/[pt]t[sy]*". The "/dev/" dirname is 5 characters; the "[pt]t[sy]" filename prefix is 3 characters (making 8 characters in all). */ devName = ttyname(STDIN_FILENO); if (devName == NULL) errExit("ttyname"); if (strlen(devName) <= 8) /* Should never happen */ fatal("Terminal name is too short: %s", devName); strncpy(ut.ut_line, devName + 5, sizeof(ut.ut_line)); strncpy(ut.ut_id, devName + 8, sizeof(ut.ut_id)); printf("Creating login entries in utmp and wtmp\n"); printf(" using pid %ld, line %.*s, id %.*s\n", (long) ut.ut_pid, (int) sizeof(ut.ut_line), ut.ut_line, (int) sizeof(ut.ut_id), ut.ut_id); setutxent(); /* Rewind to start of utmp file */ if (pututxline(&ut) == NULL) /* Write login record to utmp */ errExit("pututxline"); updwtmpx(_PATH_WTMP, &ut); /* Append login record to wtmp */ /* Sleep a while, so we can examine utmp and wtmp files */ sleep((argc > 2) ? getInt(argv[2], GN_NONNEG, "sleep-time") : 15); /* Now do a "logout"; use values from previously initialized 'ut', except for changes below */ ut.ut_type = DEAD_PROCESS; /* Required for logout record */ time((time_t *) &ut.ut_tv.tv_sec); /* Stamp with logout time */ memset(&ut.ut_user, 0, sizeof(ut.ut_user)); /* Logout record has null username */ printf("Creating logout entries in utmp and wtmp\n"); setutxent(); /* Rewind to start of utmp file */ if (pututxline(&ut) == NULL) /* Overwrite previous utmp record */ errExit("pututxline"); updwtmpx(_PATH_WTMP, &ut); /* Append logout record to wtmp */ endutxent(); exit(EXIT_SUCCESS); }
void RepoQuery::getBool(int iCol, bool& b) { int val; getInt(iCol, val); b = bool(val); }
RenderPass RenderStage::createRenderPassFromJson(const JSONValue& renderPassJSON) { GraphicSystem& graphicSystem = renderer.getGraphicSystem(); RenderPass renderPass; auto clearColorJSON = renderPassJSON.getJSONValue("clearColor"); auto colorWriteJSON = renderPassJSON.getJSONValue("colorWrite"); auto depthWriteJSON = renderPassJSON.getJSONValue("depthWrite"); auto renderTargetLayerJSON = renderPassJSON.getJSONValue("renderTargetLayer"); auto flagsJSON = renderPassJSON.getJSONValue("flags"); if(!clearColorJSON.isNull()) renderPass.clearColor = clearColorJSON.getVector4(); if(!colorWriteJSON.isNull()) renderPass.colorWrite = colorWriteJSON.getBool(); if(!depthWriteJSON.isNull()) renderPass.depthWrite = depthWriteJSON.getBool(); if(!renderTargetLayerJSON.isNull()) renderPass.renderTargetLayer = renderTargetLayerJSON.getInt(); if(!flagsJSON.isNull()) { unsigned int flags = 0; for(unsigned int i = 0; i < flagsJSON.getSize(); ++i) { if(flagsJSON.getJSONArrayItem(i).getString().compare("CLEAR_COLOR") == 0) flags |= CLEAR_COLOR; if(flagsJSON.getJSONArrayItem(i).getString().compare("CLEAR_DEPTH") == 0) flags |= CLEAR_DEPTH; } renderPass.flags = flags; } auto viewPortJSON = renderPassJSON.getJSONValue("viewPort"); if(!viewPortJSON.isNull()) { FixedArray<int, 4> viewPort = viewPortJSON.getInt4(); renderPass.viewPort.set(viewPort[0], viewPort[1], viewPort[2], viewPort[3]); } else renderPass.viewPort = renderer.getScreenViewPort(); auto renderTargetJSON = renderPassJSON.getJSONValue("renderTarget"); renderPass.renderTarget = graphicSystem.createRenderTarget(renderTargetJSON); auto shaderPasses = renderPassJSON.getJSONValue("shaderPasses"); if(!shaderPasses.isNull()) { for(unsigned int i = 0; i < shaderPasses.getSize(); ++i) { auto shaderPassJSON = shaderPasses.getJSONArrayItem(i); auto programJSON = shaderPassJSON.getJSONValue("shaderProgram"); auto vertexDataJSON = shaderPassJSON.getJSONValue("vertexData"); auto rasterStateJSON = shaderPassJSON.getJSONValue("rasterState"); auto shaderParameterBlocksJSON = shaderPassJSON.getJSONValue("shaderParameterBlocks"); auto texturesJSON = shaderPassJSON.getJSONValue("textures"); ShaderPass shaderPass; if(!vertexDataJSON.isNull()) { if(vertexDataJSON.getString().compare("fullScreenQuad") == 0) shaderPass.vertexData = renderer.getFullScreenQuad(); } if(!rasterStateJSON.isNull()) { auto blendFunctionJSON = rasterStateJSON.getJSONValue("blendFunction"); auto compareFunctionJSON = rasterStateJSON.getJSONValue("compareFunction"); auto cullFaceJSON = rasterStateJSON.getJSONValue("cullFace"); auto blendState = !blendFunctionJSON.isNull() ? BlendState(true, enumFromString<BlendFunction>(blendFunctionJSON.getString())) : BlendState(false, BlendFunction::Replace); auto compareState = !compareFunctionJSON.isNull() ? CompareState(true, enumFromString<CompareFunction>(compareFunctionJSON.getString())) : CompareState(false, CompareFunction::Never); auto cullState = !cullFaceJSON.isNull() ? CullState(true, enumFromString<CullFace>(cullFaceJSON.getString())) : CullState(false, CullFace::Back); shaderPass.rasterState = RasterState(blendState, compareState, cullState); } if(!shaderParameterBlocksJSON.isNull()) { for(unsigned int j = 0; j < shaderParameterBlocksJSON.getSize(); ++j) { ShaderParameterBlock* block = graphicSystem.createShaderParameterBlock(shaderParameterBlocksJSON.getJSONArrayItem(j)); if(block) shaderPass.shaderParameterBlocks.pushBack(block); } } if(!texturesJSON.isNull()) { for(unsigned int j = 0; j < texturesJSON.getSize(); ++j) { Texture* texture = graphicSystem.createTexture(texturesJSON.getJSONArrayItem(j)); if(texture) shaderPass.textures.pushBack(texture); } } if(!programJSON.isNull()) shaderPass.program = graphicSystem.createShaderProgram(programJSON); renderPass.shaderPasses.pushBack(shaderPass); } } return renderPass; }
long long int comb[MAX_C][MAX_C]; long long int data[MAX_C]; char c = 0; long long int getInt() { long long int r = 0; while (!(c >= '0' && c <= '9')) c = getc_unlocked(stdin); while (c >= '0' && c <= '9') { r = r * 10 + (c - '0'); c = getc_unlocked(stdin); } return r; } int main(void) { FOR(i, MAX_C) { comb[i][0] = comb[i][i] = 1; FORE(j, 1, i) comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j]; data[i] = comb[i][i >> 1]; } int t = getInt(); FOR(tt, t) { long long int n = getInt(); int i = 2; while (data[i] < n) i++; printf("%d\n", i); } }
unsigned RunPeriodControlSpecialDays_Impl::duration() const { boost::optional<int> result = getInt(OS_RunPeriodControl_SpecialDaysFields::Duration, true); OS_ASSERT(result); return *result; }
int CameraParameters::getPreviewFrameRate() const { return getInt(KEY_PREVIEW_FRAME_RATE); }
int parse( char * data, int n ) { w32::Lock lock( &critSec ); PROFILE; //int a[512]; //int nAlive = 0; int k=0,mode=0; char * b = data; while ( k < n ) { //fprintf( stderr, "$ %d %s\n", k, &b[k] ); if ( strstr( &b[k], "#bundle" ) ) { mode = 0; /// moved, see below //listener.startBundle(); // ok, we'll skip 'all the seconds there ever were' k += 16; } else { Packet packet = {0}; k += parsePacketHeader( &b[k], packet ); //printf("p %d\t'%s'\t'%s'\t'%s'\n",packet.len,packet.head,packet.cmd,packet.pinfo); // cursor or object ? if ( ! strcmp( packet.head, "/tuio/2Dobj" ) ) { // // this hack keeps our objects alive - // we only start a bundle for objects, // sending the cursors to the current bundle: // if ( mode == 0 ) listener.startBundle(); mode = 1; } else if ( ! strcmp( packet.head, "/tuio/2Dcur" ) ) { mode = 2; } // check the cmd: if ( ! strcmp( packet.cmd, "set" ) ) { Object o = {0}; o.type = mode; k += parseSet( &b[k], &o, mode ); listener.call( o ); } else if ( ! strcmp( packet.cmd, "fseq" ) ) { int s = 0; k += getInt( &b[k], s ); if ( seq > s ) { //fprintf( stderr, "!!!seq %d > %d\n", seq,s ); } seq = s; } else if ( ! strcmp( packet.cmd, "alive" ) ) { int na = strlen(packet.pinfo) - 2; // skip ',s' if ( na > 0 ) { for ( int i=0; i<na; i++ ) { int a = 0; k += getInt( &b[k], a ); listener.call( a ); } } } } } return n; }