Author: abrander
Date: 2009-06-01 23:51:46 +0200 (Mon, 01 Jun 2009)
New Revision: 2499

Modified:
   trunk/plugins/basic-render/basic-render.c
   trunk/plugins/denoise/denoise.c
   trunk/plugins/resample/resample.c
Log:
Made RSDenoise, RSBasicRender and RSResample respect ROI.

Modified: trunk/plugins/basic-render/basic-render.c
===================================================================
--- trunk/plugins/basic-render/basic-render.c   2009-06-01 21:50:40 UTC (rev 
2498)
+++ trunk/plugins/basic-render/basic-render.c   2009-06-01 21:51:46 UTC (rev 
2499)
@@ -979,11 +979,12 @@
 get_image8(RSFilter *filter, RS_FILTER_PARAM *param)
 {
        RSBasicRenderClass *klass = RS_BASIC_RENDER_GET_CLASS(filter);
-       guint i, y_offset, y_per_thread, threaded_h;
+       guint i, x_offset, y_offset, y_per_thread, threaded_h;
        const guint threads = rs_get_number_of_processor_cores();
        RSBasicRender *basic_render = RS_BASIC_RENDER(filter);
        RS_IMAGE16 *input;
        GdkPixbuf *output = NULL;
+       gint width, height;
 
        input = rs_filter_get_image(filter->previous, param);
        if (!RS_IS_IMAGE16(input))
@@ -995,20 +996,34 @@
        render_matrix(basic_render);
        prepare_lcms(basic_render);
 
+       if (param && param->roi)
+       {
+               width = MIN(param->roi->width, input->w);
+               height = MIN(param->roi->height, input->h);
+               x_offset = MAX(param->roi->x, 0);
+               y_offset = MAX(param->roi->y, 0);
+       }
+       else
+       {
+               width = input->w;
+               height = input->h;
+               x_offset = 0;
+               y_offset = 0;
+       }
+
        ThreadInfo *t = g_new(ThreadInfo, threads);
-       threaded_h = input->h;
+       threaded_h = height;
        y_per_thread = (threaded_h + threads-1)/threads;
-       y_offset = 0;
 
        /* Set up job description for individual threads */
        for (i = 0; i < threads; i++)
        {
                t[i].basic_render = basic_render;
-               t[i].width = input->w;
+               t[i].width = width;
                t[i].height = MIN((input->h - y_offset), y_per_thread);
-               t[i].in = GET_PIXEL(input, 0, y_offset);
+               t[i].in = GET_PIXEL(input, x_offset, y_offset);
                t[i].in_rowstride = input->rowstride;
-               t[i].out = GET_PIXBUF_PIXEL(output, 0, y_offset);
+               t[i].out = GET_PIXBUF_PIXEL(output, x_offset, y_offset);
                t[i].out_rowstride = gdk_pixbuf_get_rowstride(output);
 
                y_offset += y_per_thread;

Modified: trunk/plugins/denoise/denoise.c
===================================================================
--- trunk/plugins/denoise/denoise.c     2009-06-01 21:50:40 UTC (rev 2498)
+++ trunk/plugins/denoise/denoise.c     2009-06-01 21:51:46 UTC (rev 2499)
@@ -177,6 +177,7 @@
        RSDenoise *denoise = RS_DENOISE(filter);
        RS_IMAGE16 *input;
        RS_IMAGE16 *output;
+       RS_IMAGE16 *tmp;
        input = rs_filter_get_image(filter->previous, param);
 //     if (!RS_IS_FILTER(input))
 //             return input;
@@ -187,7 +188,12 @@
        output = rs_image16_copy(input, TRUE);
        g_object_unref(input);
 
-       denoise->info.image = output;
+       if (param && param->roi)
+               tmp = rs_image16_new_subframe(output, param->roi);
+       else
+               tmp = g_object_ref(output);
+
+       denoise->info.image = tmp;
        denoise->info.sigmaLuma = ((float) denoise->denoise_luma) / 5.0;
        denoise->info.sigmaChroma = ((float) denoise->denoise_chroma) / 5.0;
        denoise->info.sharpenLuma = ((float) denoise->sharpen) / 40.0;
@@ -198,8 +204,9 @@
        GTimer *gt = g_timer_new();
        denoiseImage(&denoise->info);
        gfloat time = g_timer_elapsed(gt, NULL);
-       gfloat mpps = (output->w*output->h) / (time*1000000.0);
+       gfloat mpps = (tmp->w*tmp->h) / (time*1000000.0);
        printf("Denoising took:%.03fsec, %.03fMpix/sec\n", time, mpps );
+       g_object_unref(tmp);
        g_timer_destroy(gt);
 
        return output;

Modified: trunk/plugins/resample/resample.c
===================================================================
--- trunk/plugins/resample/resample.c   2009-06-01 21:50:40 UTC (rev 2498)
+++ trunk/plugins/resample/resample.c   2009-06-01 21:51:46 UTC (rev 2499)
@@ -192,7 +192,16 @@
        gint input_width = rs_filter_get_width(filter->previous);
        gint input_height = rs_filter_get_height(filter->previous);
 
-       input = rs_filter_get_image(filter->previous, param);
+       /* Remove ROI, it doesn't make sense across resampler */
+       if (param && param->roi)
+       {
+               RS_FILTER_PARAM new_param = *param;
+               new_param.roi = NULL;
+               input = rs_filter_get_image(filter->previous, &new_param);
+       }
+       else
+               input = rs_filter_get_image(filter->previous, param);
+
        if (!RS_IS_IMAGE16(input))
                return input;
 


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to