void enable_multithreading() { graphite_multithreading = true ; Logger::out("Process") << "Enabled multithreading" << std::endl ; Logger::out("Process") << "Number of cores = " << number_of_cores() << std::endl ; Logger::out("Process") << "Max. concurrent threads = " << maximum_concurrent_threads() << std::endl ; if(maximum_concurrent_threads() == 1) { Logger::warn("Process") << "Processor is not a multicore or missing multithreading manager (e.g. cgal2graphite plugin)" << std::endl ; } }
void initialize() { set_thread_manager(new MonoThreadingThreadManager) ; std::ostringstream out ; out << number_of_cores() << std::ends ; Environment::instance()->set_value("nb_cores", out.str()) ; }
static pj_status_t pj_vpx_encoder_open(vpx_private *vpx) { vpx_codec_flags_t flags = 0; /* XXX: use VPX_CODEC_USE_OUTPUT_PARTITION ? */ const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo; struct vpx_codec_enc_cfg enccfg; int res; TRACE_((THIS_FILE, "vpx pj_vpx_encoder_open")); res = vpx_codec_enc_config_default(iface, &enccfg, 0); if (res != VPX_CODEC_OK) { PJ_LOG(1, (THIS_FILE, "Failed to get vpx default config : %s", vpx_codec_err_to_string(res))); return PJMEDIA_CODEC_EFAILED; } enccfg.g_w = vpx->param.enc_fmt.det.vid.size.w; enccfg.g_h = vpx->param.enc_fmt.det.vid.size.h; enccfg.g_timebase.num = vpx->param.enc_fmt.det.vid.fps.num; enccfg.g_timebase.den = vpx->param.enc_fmt.det.vid.fps.denum; //provide dummy value to initialize wrapper, values will be updated each _encode() vpx_img_wrap(&vpx->rawimg, VPX_IMG_FMT_I420, vpx->param.enc_fmt.det.vid.size.w, vpx->param.enc_fmt.det.vid.size.h, 1, NULL); enccfg.g_threads = number_of_threads(enccfg.g_w, enccfg.g_h, number_of_cores()); PJ_LOG(4, (THIS_FILE, "Using %d threads for VPX encoding", enccfg.g_threads)); enccfg.g_lag_in_frames = 0; enccfg.g_pass = VPX_RC_ONE_PASS; enccfg.rc_end_usage = VPX_CBR; enccfg.rc_target_bitrate = vpx->param.enc_fmt.det.vid.avg_bps / 1000; // in kbit/s enccfg.g_timebase.num = 1; enccfg.g_timebase.den = 90000; enccfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT; enccfg.rc_resize_allowed = 1; enccfg.rc_min_quantizer = 2; enccfg.rc_max_quantizer = 56; enccfg.rc_undershoot_pct = 100; enccfg.rc_overshoot_pct = 15; enccfg.rc_buf_initial_sz = 500; enccfg.rc_buf_optimal_sz = 600; enccfg.rc_buf_sz = 1000; enccfg.kf_mode = VPX_KF_AUTO; enccfg.kf_max_dist = 3000; vpx->rc_max_intra_target = PJ_MAX(300, enccfg.rc_buf_sz * 0.5 * enccfg.g_timebase.num / 10); res = vpx_codec_enc_init(&vpx->encoder, vpx_codec_vp8_cx(), &enccfg, flags); if (res != VPX_CODEC_OK) { PJ_LOG(1, (THIS_FILE, "Failed to init vpx encoder : %s", vpx_codec_err_to_string(res))); return PJMEDIA_CODEC_EFAILED; } vpx_codec_control(&vpx->encoder, VP8E_SET_STATIC_THRESHOLD, 1); vpx_codec_control(&vpx->encoder, VP8E_SET_CPUUSED, -6); // XXX: test vpx_codec_control(&vpx->encoder, VP8E_SET_TOKEN_PARTITIONS, VP8_ONE_TOKENPARTITION); vpx_codec_control(&vpx->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT, vpx->rc_max_intra_target); #ifdef VP8E_SET_SCREEN_CONTENT_MODE vpx_codec_control(&vpx->encoder, VP8E_SET_SCREEN_CONTENT_MODE, 0); #endif vpx->enc_iter = NULL; vpx->enc_buf_size = vpx->enc_vafp.framebytes; vpx->enc_buf = pj_pool_alloc(vpx->pool, vpx->enc_buf_size); vpx->dec_buf_size = vpx->dec_vafp.framebytes; vpx->dec_buf = pj_pool_alloc(vpx->pool, vpx->dec_buf_size); return PJ_SUCCESS; }
int rtapi_app_main(void) { int n, retval = 0; int rev, ncores, pinno; char *endptr; if ((rev = get_rpi_revision()) < 0) { rtapi_print_msg(RTAPI_MSG_ERR, "unrecognized Raspberry revision, see /proc/cpuinfo\n"); return -EINVAL; } ncores = number_of_cores(); rtapi_print_msg(RTAPI_MSG_INFO, "%d cores rev %d", ncores, rev); switch (rev) { case 3: rtapi_print_msg(RTAPI_MSG_INFO, "Raspberry2\n"); pins = rpi2_pins; gpios = rpi2_gpios; npins = sizeof(rpi2_pins); break; case 1: rtapi_print_msg(RTAPI_MSG_INFO, "Raspberry1 rev 1.0\n"); pins = rev1_pins; gpios = rev1_gpios; npins = sizeof(rev1_pins); break; case 2: rtapi_print_msg(RTAPI_MSG_INFO, "Raspberry1 Rev 2.0\n"); pins = rev2_pins; gpios = rev2_gpios; npins = sizeof(rev2_pins); break; default: rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: board revision %d not supported\n", rev); return -EINVAL; } port_data = hal_malloc(npins * sizeof(void *)); if (port_data == 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: hal_malloc() failed\n"); hal_exit(comp_id); return -1; } if (dir == 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: no config string\n"); return -1; } dir_map = strtoul(dir, &endptr,0); if (*endptr) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: dir=%s - trailing garbage: '%s'\n", dir, endptr); return -1; } if (exclude == 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: no exclude string\n"); return -1; } exclude_map = strtoul(exclude, &endptr,0); if (*endptr) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: exclude=%s - trailing garbage: '%s'\n", exclude, endptr); return -1; } if (setup_gpio_access(rev, ncores)) return -1; comp_id = hal_init("hal_gpio"); if (comp_id < 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: hal_init() failed\n"); return -1; } for (n = 0; n < npins; n++) { if (exclude_map & RTAPI_BIT(n)) continue; pinno = pins[n]; if (dir_map & RTAPI_BIT(n)) { bcm2835_gpio_fsel(gpios[n], BCM2835_GPIO_FSEL_OUTP); if ((retval = hal_pin_bit_newf(HAL_IN, &port_data[n], comp_id, "hal_gpio.pin-%02d-out", pinno)) < 0) break; } else { bcm2835_gpio_fsel(gpios[n], BCM2835_GPIO_FSEL_INPT); if ((retval = hal_pin_bit_newf(HAL_OUT, &port_data[n], comp_id, "hal_gpio.pin-%02d-in", pinno)) < 0) break; } } if (retval < 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: pin %d export failed with err=%i\n", n,retval); hal_exit(comp_id); return -1; } retval = hal_export_funct("hal_gpio.write", write_port, 0, 0, 0, comp_id); if (retval < 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: write funct export failed\n"); hal_exit(comp_id); return -1; } retval = hal_export_funct("hal_gpio.read", read_port, 0, 0, 0, comp_id); if (retval < 0) { rtapi_print_msg(RTAPI_MSG_ERR, "HAL_GPIO: ERROR: read funct export failed\n"); hal_exit(comp_id); return -1; } rtapi_print_msg(RTAPI_MSG_INFO, "HAL_GPIO: installed driver\n"); hal_ready(comp_id); return 0; }