int BlurZoomMain::start_realtime() { buf_width_blocks = project_frame_w / 32; buf_width = buf_width_blocks * 32; buf_height = project_frame_h; buf_area = buf_width * buf_height; buf_margin_left = (project_frame_w - buf_width) / 2; buf_margin_right = project_frame_w - buf_width - buf_margin_left; blurzoombuf = new unsigned char[buf_area * 2]; blurzoomx = new int[buf_width]; blurzoomy = new int[buf_height]; set_table(); make_palette(); bzero(blurzoombuf, buf_area * 2); background = new uint16_t[project_frame_w * project_frame_h]; diff = new unsigned char[project_frame_w * project_frame_h]; image_set_threshold_y(MAGIC_THRESHOLD); blurzoom_server = new BlurZoomServer(this, 1, 1); return 0; }
int BurnMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr) { this->input_ptr = input_ptr; this->output_ptr = output_ptr; load_configuration(); if(!burn_server) { effecttv = new EffectTV(input_ptr->get_w(), input_ptr->get_h()); buffer = (unsigned char *)new unsigned char[input_ptr->get_w() * input_ptr->get_h()]; make_palette(input_ptr->get_color_model()); effecttv->image_set_threshold_y(config.threshold); total = 0; burn_server = new BurnServer(this, 1, 1); } if(total == 0) { bzero(buffer, input_ptr->get_w() * input_ptr->get_h()); effecttv->image_bgset_y(input_ptr); } burn_server->process_packages(); total++; // if(total >= config.recycle * project_frame_rate) total = 0; return 0; }
static void setup_from_config (MateRRLabeler *labeler) { labeler->priv->num_outputs = count_outputs (labeler->priv->config); make_palette (labeler); create_label_windows (labeler); }
static void setup_from_config (CcRRLabeler *labeler) { labeler->priv->num_outputs = count_outputs (labeler->priv->config); make_palette (labeler); cc_rr_labeler_show (labeler); }
int main() { // apply FFT to real 2D data. double *in; double *apex; int W = 640; int H = 480; int half_H = (H / 2) + 1; int x; int y; fftw_complex *out; fftw_complex *apex_f; fftw_plan plan_backward; fftw_plan plan_apex; fftw_plan plan_forward; unsigned int seed = 123456789; srand(seed); in = (double *) malloc_check(sizeof(double) * W * H); for(x = 0; x < W; x++) { for(y = 0; y < H; y++) { #if 1 in[x*H+y] = ( double ) rand ( ) / ( RAND_MAX ); #else in[x*H+y] = 0; #endif } } in[(H/2) + (W/2)*H] = 1; in[(H/2)+3 + (W/2 + 3)*H] = 1; in[10 + (20)*H] = 1; in[H-3 + (W-3)*H] = 1; y = W * H; for (x = 0; x < y; x++) { in[x] *= PALETTE_LEN -10; } apex = (double*)malloc_check(sizeof(double) * W * H); double apex_sum = 0; for(x = 0; x < W; x++) { for(y = 0; y < H; y++) { double dist = 0; int xx = x; int yy = y; if (xx >= W/2) xx = W - x; if (yy >= H/2) yy = H - y; dist = sqrt(xx*xx + yy*yy); double v = 8.01 - dist; if (v < 0) v = 0; #if 0 if (x == 2 && y == 1) v = 302.1; #endif #if 0 if (x == W / 2 && y == H / 2) v = 850; #endif #if 0 if (x < W/2 || y > H / 2) v = -v * 1.85; #endif #if 0 if (x == W/3-1 && y == H/3-1) v = 200; if (x == W/3 && y == H/3) v = -200; #endif apex_sum += v; apex[x*H+y] = v; } } double burn = 1.005; double apex_mul = (burn / (W*H)) / apex_sum; printf("%f %f\n", apex_sum, apex_mul); y = W * H; for (x = 0; x < y; x++) { apex[x] *= apex_mul; } apex_f = fftw_malloc(sizeof(fftw_complex) * W * half_H); plan_apex = fftw_plan_dft_r2c_2d(W, H, apex, apex_f, FFTW_ESTIMATE); fftw_execute(plan_apex); out = fftw_malloc(sizeof(fftw_complex) * W * half_H); plan_forward = fftw_plan_dft_r2c_2d(W, H, in, out, FFTW_ESTIMATE); plan_backward = fftw_plan_dft_c2r_2d(W, H, out, in, FFTW_ESTIMATE); int winW = W; int winH = H; SDL_Window *window; window = SDL_CreateWindow("fftw3_test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, winW, winH, 0); if (!window) { fprintf(stderr, "Unable to set %dx%d video: %s\n", winW, winH, SDL_GetError()); exit(1); } SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { fprintf(stderr, "Unable to set %dx%d video: %s\n", winW, winH, SDL_GetError()); exit(1); } SDL_ShowCursor(SDL_DISABLE); SDL_PixelFormat *pixelformat = SDL_AllocFormat(SDL_PIXELFORMAT_RGBA8888); SDL_Texture *texture = SDL_CreateTexture(renderer, pixelformat->format, SDL_TEXTUREACCESS_STREAMING, winW, winH); if (!texture) { fprintf(stderr, "Cannot create texture\n"); exit(1); } #if 0 #define n_palette_points 2 palette_point_t palette_points[n_palette_points] = { { 0., 0, 0, 0 }, { 1., 1, 1, 1 }, }; #else #define n_palette_points 11 palette_point_t palette_points[n_palette_points] = { { 0./6, 1, 1, 1 }, { 0.5/6, 1, .9, 0 }, { 1./6, 1, .1, 1 }, { 1.5/6, 0, 0, 1 }, { 3./6, .5, 0, .7 }, { 3.5/6, 0, 1, .7 }, { 4.5/6, .2, .8, .2 }, { 4.8/6, 0, 0, 1 }, { 5.25/6, .8, .8, 0 }, { 5.55/6, .8, .2, 0.4 }, { 5.85/6, .0,.60,.50 }, }; #endif palette_t palette; make_palette(&palette, PALETTE_LEN, palette_points, n_palette_points, pixelformat); bool running = true; int frame_period = 50; int last_ticks = SDL_GetTicks() - frame_period; Uint32 *winbuf = (Uint32*)malloc_check(winW * winH * sizeof(Uint32)); while (running) { bool do_render = false; int elapsed = SDL_GetTicks() - last_ticks; if (elapsed > frame_period) { last_ticks += frame_period * (elapsed / frame_period); do_render = true; } if (do_render) { render(winbuf, winW, winH, &palette, in, W, H); SDL_UpdateTexture(texture, NULL, winbuf, winW * sizeof(Uint32)); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); fftw_execute(plan_forward); #if 1 for (x = 0; x < W; x++) { for (y = 0; y < half_H; y++) { double *o = out[x*half_H + y]; double *af = apex_f[x*half_H + y]; double a, b, c, d; a = o[0]; b = o[1]; c = af[0]; d = af[1]; #if 1 o[0] = (a*c - b*d); o[1] = (b*c + a*d); #else double l = sqrt(c*c + d*d); o[0] *= l; o[1] *= l; #endif } } #endif fftw_execute(plan_backward); } else SDL_Delay(5); SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: // If escape is pressed, return (and thus, quit) switch(event.key.keysym.sym) { case SDLK_ESCAPE: running = false; break; default: break; } break; case SDL_QUIT: running = false; break; } } } SDL_Quit(); fftw_destroy_plan(plan_apex); fftw_destroy_plan(plan_forward); fftw_destroy_plan(plan_backward); free(in); free(apex); fftw_free(out); fftw_free(apex_f); return 0; }