diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2015-02-28 10:25:40 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2015-05-02 21:36:45 +0200 |
commit | 02e5b6af7df001cc105e874ade35b47d560b1f83 (patch) | |
tree | 866241a14487cbd2dd63677025dcdde7ff7eea45 | |
parent | 9841a4e5fa5b3b17f3b95f4e3c2c0e5ed8b445fd (diff) | |
download | pucket-02e5b6af7df001cc105e874ade35b47d560b1f83.tar.gz pucket-02e5b6af7df001cc105e874ade35b47d560b1f83.tar.bz2 pucket-02e5b6af7df001cc105e874ade35b47d560b1f83.zip |
Drop oversampling
Just scale it down.
-rw-r--r-- | filters.c | 56 | ||||
-rw-r--r-- | flam3.c | 5 | ||||
-rw-r--r-- | flam3.h | 1 | ||||
-rw-r--r-- | interpolation.c | 1 | ||||
-rw-r--r-- | main.c | 15 | ||||
-rw-r--r-- | palettes.c | 2 | ||||
-rw-r--r-- | parser.c | 4 | ||||
-rw-r--r-- | rect.c | 68 |
8 files changed, 15 insertions, 137 deletions
@@ -217,62 +217,6 @@ int normalize_vector(double *v, int n) { return 0; } - -int flam3_create_spatial_filter(flam3_frame *spec, int field, double **filter) { - - int sf_kernel = spec->genomes[0].spatial_filter_select; - int supersample = spec->genomes[0].spatial_oversample; - double sf_radius = spec->genomes[0].spatial_filter_radius; - double aspect_ratio = spec->pixel_aspect_ratio; - double sf_supp = flam3_spatial_support[sf_kernel]; - - double fw = 2.0 * sf_supp * supersample * sf_radius / aspect_ratio; - double adjust, ii, jj; - - int fwidth = ((int) fw) + 1; - int i,j; - - - /* Make sure the filter kernel has same parity as oversample */ - if ((fwidth ^ supersample) & 1) - fwidth++; - - /* Calculate the coordinate scaling factor for the kernel values */ - if (fw > 0.0) - adjust = sf_supp * fwidth / fw; - else - adjust = 1.0; - - /* Calling function MUST FREE THE RETURNED KERNEL, lest ye leak memory */ - (*filter) = (double *)calloc(fwidth * fwidth,sizeof(double)); - - /* fill in the coefs */ - for (i = 0; i < fwidth; i++) - for (j = 0; j < fwidth; j++) { - - /* Calculate the function inputs for the kernel function */ - ii = ((2.0 * i + 1.0) / (double)fwidth - 1.0)*adjust; - jj = ((2.0 * j + 1.0) / (double)fwidth - 1.0)*adjust; - - /* Scale for scanlines */ - if (field) jj *= 2.0; - - /* Adjust for aspect ratio */ - jj /= aspect_ratio; - - (*filter)[i + j * fwidth] = - flam3_spatial_filter(sf_kernel,ii) * flam3_spatial_filter(sf_kernel,jj); - } - - - if (normalize_vector((*filter), fwidth * fwidth)) { - fprintf(stderr, "Spatial filter value is too small: %g. Terminating.\n",sf_radius); - return(-1); - } - - return (fwidth); -} - double flam3_create_temporal_filter(int numsteps, int filter_type, double filter_exp, double filter_width, double **temporal_filter, double **temporal_deltas) { @@ -1061,7 +1061,6 @@ void clear_cp(flam3_genome *cp, int default_flag) { cp->background[2] = 0.0; cp->width = 100; cp->height = 100; - cp->spatial_oversample = 1; cp->spatial_filter_radius = 0.5; cp->zoom = 0.0; cp->sample_density = 1; @@ -1083,7 +1082,6 @@ void clear_cp(flam3_genome *cp, int default_flag) { cp->background[1] = -1.0; cp->background[2] = -1.0; cp->zoom = 999999999; - cp->spatial_oversample = -1; cp->spatial_filter_radius = -1; cp->nbatches = -1; cp->ntemporal_samples = -1; @@ -1304,8 +1302,6 @@ void flam3_apply_template(flam3_genome *cp, flam3_genome *templ) { cp->background[2] = templ->background[2]; if (templ->zoom < 999999998) cp->zoom = templ->zoom; - if (templ->spatial_oversample > 0) - cp->spatial_oversample = templ->spatial_oversample; if (templ->spatial_filter_radius >= 0) cp->spatial_filter_radius = templ->spatial_filter_radius; if (templ->sample_density > 0) @@ -1410,7 +1406,6 @@ void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_ed fprintf(f, " zoom=\"%g\"", cp->zoom); fprintf(f, " rotate=\"%g\"", cp->rotate); - fprintf(f, " supersample=\"%d\"", cp->spatial_oversample); fprintf(f, " filter=\"%g\"", cp->spatial_filter_radius); /* Need to print the correct kernel to use */ @@ -469,7 +469,6 @@ typedef struct { double gamma; double highlight_power; int width, height; /* of the final image */ - int spatial_oversample; double center[2]; /* of camera */ double rot_center[2]; /* really the center */ double rotate; /* camera */ diff --git a/interpolation.c b/interpolation.c index 78b798f..8a5c87b 100644 --- a/interpolation.c +++ b/interpolation.c @@ -424,7 +424,6 @@ void flam3_interpolate_n(flam3_genome *result, int ncp, INTERP(hue_rotation); INTERI(width); INTERI(height); - INTERI(spatial_oversample); INTERP(center[0]); INTERP(center[1]); INTERP(rot_center[0]); @@ -33,7 +33,7 @@ const char *argp_program_version = typedef struct { bool verbose; - unsigned int threads, bpc, quality, oversample; + unsigned int threads, bpc, quality; float scale; } render_arguments; @@ -51,16 +51,6 @@ static error_t parse_render_opt (int key, char *arg, break; } - case 'o': { - int i = atoi (arg); - if (i < 1) { - argp_error (state, "Oversample must be >= 1"); - } else { - arguments->oversample = i; - } - break; - } - case 'q': { int i = atoi (arg); if (i < 1) { @@ -126,7 +116,6 @@ static void do_render (const render_arguments * const arguments) { genome->height *= arguments->scale; genome->width *= arguments->scale; genome->pixels_per_unit *= arguments->scale; - genome->spatial_oversample = arguments->oversample; flam3_frame f; f.genomes = genome; @@ -510,7 +499,6 @@ int main (int argc, char **argv) { {"scale", 's', "factor", 0, "Scale image dimensions by factor (1.0)" }, {"bpc", 'b', "8|16", 0, "Bits per channel of output image (8)" }, {"quality", 'q', "num", 0, "Average samples per pixel (100)" }, - {"oversample", 'o', "num", 0, "Super-/Oversample image (1)" }, {"width", 'w', "pixels", 0, "Output image width" }, {"height", 'h', "pixels", 0, "Output image height" }, { 0 }, @@ -527,7 +515,6 @@ int main (int argc, char **argv) { .scale = 1.0, .quality = 100, .verbose = true, - .oversample = 1, }; argp_parse (&argp, argc, argv, 0, NULL, &arguments); @@ -359,7 +359,6 @@ static double try_colors(flam3_genome *g, int color_resolution) { flam3_copy(&saved, g); g->sample_density = 1; - g->spatial_oversample = 1; /* Scale the image so that the total number of pixels is ~10000 */ pixtotal = g->width * g->height; @@ -424,7 +423,6 @@ static double try_colors(flam3_genome *g, int color_resolution) { g->sample_density = saved.sample_density; g->width = saved.width; g->height = saved.height; - g->spatial_oversample = saved.spatial_oversample; g->pixels_per_unit = saved.pixels_per_unit; g->nbatches = saved.nbatches; g->ntemporal_samples = saved.ntemporal_samples; @@ -389,10 +389,6 @@ int parse_flame_element(xmlNode *flame_node, flam3_genome *loc_current_cp, cp->rotate = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"zoom")) { cp->zoom = flam3_atof(att_str); - } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"oversample")) { - cp->spatial_oversample = flam3_atoi(att_str); - } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"supersample")) { - cp->spatial_oversample = flam3_atoi(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"filter")) { cp->spatial_filter_radius = flam3_atof(att_str); } else if (!xmlStrcmp(cur_att->name, (const xmlChar *)"filter_shape")) { @@ -304,18 +304,15 @@ int render_rectangle(flam3_frame *spec, void *out, long nbuckets; int i, j, k, batch_num, temporal_sample_num; double nsamples, batch_size; - double *filter, *temporal_filter, *temporal_deltas, *batch_filter; + double *temporal_filter, *temporal_deltas, *batch_filter; double ppux=0, ppuy=0; int image_width, image_height; /* size of the image to produce */ int out_width; - int filter_width=0; int bytes_per_channel = spec->bytes_per_channel; - int oversample; double highpow; int nbatches; int ntemporal_samples; flam3_palette dmap; - int gutter_width; double vibrancy = 0.0; double gamma = 0.0; int vib_gam_n = 0; @@ -352,7 +349,6 @@ int render_rectangle(flam3_frame *spec, void *out, /* interpolate and get a control point */ flam3_interpolate(spec->genomes, spec->ngenomes, spec->time, 0, &cp); - oversample = cp.spatial_oversample; highpow = cp.highlight_power; nbatches = cp.nbatches; ntemporal_samples = cp.ntemporal_samples; @@ -362,11 +358,6 @@ int render_rectangle(flam3_frame *spec, void *out, return(1); } - if (oversample < 1) { - fprintf(stderr, "oversample must be positive, not %d.\n", oversample); - return(1); - } - /* Initialize the thread helper structures */ fth = (flam3_thread_helper *)calloc(spec->nthreads,sizeof(flam3_thread_helper)); for (i=0;i<spec->nthreads;i++) @@ -387,17 +378,6 @@ int render_rectangle(flam3_frame *spec, void *out, image_height = cp.height; - /* Spatial Filter kernel creation */ - filter_width = flam3_create_spatial_filter(spec, field, &filter); - - /* handle error */ - if (filter_width<0) { - fprintf(stderr,"flam3_create_spatial_filter returned error: aborting\n"); - return(1); - } - - /* note we must free 'filter' at the end */ - /* batch filter */ /* may want to revisit this at some point */ batch_filter = (double *) malloc(sizeof(double) * nbatches); @@ -412,15 +392,9 @@ int render_rectangle(flam3_frame *spec, void *out, &temporal_filter, &temporal_deltas); - /* - the number of additional rows of buckets we put at the edge so - that the filter doesn't go off the edge - */ - gutter_width = (filter_width - oversample) / 2; - /* Allocate the space required to render the image */ - fic.height = oversample * image_height + 2 * gutter_width; - fic.width = oversample * image_width + 2 * gutter_width; + fic.height = image_height; + fic.width = image_width; nbuckets = (long)fic.width * (long)fic.height; @@ -484,7 +458,7 @@ int render_rectangle(flam3_frame *spec, void *out, /* compute camera */ if (1) { - double t0, t1, shift=0.0, corner0, corner1; + double shift=0.0, corner0, corner1; double scale; if (cp.sample_density <= 0.0) { @@ -506,14 +480,12 @@ int render_rectangle(flam3_frame *spec, void *out, case flam3_field_odd: shift = 0.5; break; } shift = shift / ppux; - t0 = (double) gutter_width / (oversample * ppux); - t1 = (double) gutter_width / (oversample * ppuy); corner0 = cp.center[0] - image_width / ppux / 2.0; corner1 = cp.center[1] - image_height / ppuy / 2.0; - fic.bounds[0] = corner0 - t0; - fic.bounds[1] = corner1 - t1 + shift; - fic.bounds[2] = corner0 + image_width / ppux + t0; - fic.bounds[3] = corner1 + image_height / ppuy + t1 + shift; + fic.bounds[0] = corner0; + fic.bounds[1] = corner1 + shift; + fic.bounds[2] = corner0 + image_width / ppux; + fic.bounds[3] = corner1 + image_height / ppuy + shift; fic.size[0] = 1.0 / (fic.bounds[2] - fic.bounds[0]); fic.size[1] = 1.0 / (fic.bounds[3] - fic.bounds[1]); rotate_center ((double2) { cp.rot_center[0], cp.rot_center[1] }, @@ -613,14 +585,13 @@ int render_rectangle(flam3_frame *spec, void *out, /* XXX: the original formula has a factor 268/256 in here, not sure why */ k1 = cp.contrast * cp.brightness * batch_filter[batch_num]; area = image_width * image_height / (ppux * ppuy); - k2 = (oversample * oversample * nbatches) / - (cp.contrast * area * sample_density * sumfilt); + k2 = nbatches / (cp.contrast * area * sample_density * sumfilt); #if 0 printf("iw=%d,ih=%d,ppux=%f,ppuy=%f\n",image_width,image_height,ppux,ppuy); printf("contrast=%f, brightness=%f, PREFILTER=%d, temporal_filter=%f\n", cp.contrast, cp.brightness, PREFILTER_WHITE, temporal_filter[batch_num]); - printf("oversample=%d, nbatches=%d, area = %f, WHITE_LEVEL=%d, sample_density=%f\n", - oversample, nbatches, area, WHITE_LEVEL, sample_density); + printf("nbatches=%d, area = %f, WHITE_LEVEL=%d, sample_density=%f\n", + nbatches, area, WHITE_LEVEL, sample_density); printf("k1=%f,k2=%15.12f\n",k1,k2); #endif @@ -672,17 +643,7 @@ int render_rectangle(flam3_frame *spec, void *out, for (j = 0; j < image_height; j++) { x = 0; for (i = 0; i < image_width; i++) { - int ii, jj; - double4 t = (double4) { 0.0, 0.0, 0.0, 0.0 }; - - for (ii = 0; ii < filter_width; ii++) { - for (jj = 0; jj < filter_width; jj++) { - const double k = filter[ii + jj * filter_width]; - const double4 ac = accumulate[x+ii + (y+jj)*fic.width]; - - t += k * ac; - } - } + double4 t = accumulate[x + y * fic.width]; /* The old way, spatial filter first and then clip after gamma */ if (!spec->earlyclip) { @@ -708,9 +669,9 @@ int render_rectangle(flam3_frame *spec, void *out, assert (0); } - x += oversample; + x += 1; } - y += oversample; + y += 1; } } @@ -721,7 +682,6 @@ int render_rectangle(flam3_frame *spec, void *out, free(temporal_filter); free(temporal_deltas); free(batch_filter); - free(filter); free(buckets); free(accumulate); /* We have to clear the cps in fth first */ |