From anders at brander.dk Thu Oct 1 07:52:51 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 01 Oct 2009 07:52:51 +0200 Subject: [Rawstudio-commit] r2694 - trunk/plugins/basic-render Message-ID: Author: abrander Date: 2009-10-01 07:52:50 +0200 (Thu, 01 Oct 2009) New Revision: 2694 Modified: trunk/plugins/basic-render/basic-render.c Log: Now disposes properly of RSSettings in RSBasicRender. Modified: trunk/plugins/basic-render/basic-render.c =================================================================== --- trunk/plugins/basic-render/basic-render.c 2009-09-29 23:49:39 UTC (rev 2693) +++ trunk/plugins/basic-render/basic-render.c 2009-10-01 05:52:50 UTC (rev 2694) @@ -38,6 +38,7 @@ struct _RSBasicRender { RSFilter parent; + gboolean dispose_has_run; gboolean dirty_tables; gboolean dirty_matrix; @@ -110,6 +111,7 @@ PROP_ICC_PROFILE }; +static void dispose(GObject *object); static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void previous_changed(RSFilter *filter, RSFilter *parent, RSFilterChangedMask mask); @@ -151,6 +153,7 @@ object_class->get_property = get_property; object_class->set_property = set_property; + object_class->dispose = dispose; g_object_class_install_property(object_class, PROP_GAMMA, g_param_spec_float( @@ -233,6 +236,20 @@ } static void +dispose(GObject *object) +{ + RSBasicRender *basic_render = RS_BASIC_RENDER(object); + + if (!basic_render->dispose_has_run) + { + basic_render->dispose_has_run = TRUE; + + if (basic_render->settings && basic_render->settings_signal_id) + g_signal_handler_disconnect(basic_render->settings, basic_render->settings_signal_id); + } +} + +static void get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { RSBasicRender *basic_render = RS_BASIC_RENDER(object); From anders at brander.dk Fri Oct 2 01:06:13 2009 From: anders at brander.dk (Anders Brander) Date: Fri, 02 Oct 2009 01:06:13 +0200 Subject: [Rawstudio-commit] r2695 - trunk/src Message-ID: Author: abrander Date: 2009-10-02 01:06:13 +0200 (Fri, 02 Oct 2009) New Revision: 2695 Modified: trunk/src/rs-actions.c Log: [283] Fixed copy'n'pasting of denoise (Patch by Viktor Kojouharov). Modified: trunk/src/rs-actions.c =================================================================== --- trunk/src/rs-actions.c 2009-10-01 05:52:50 UTC (rev 2694) +++ trunk/src/rs-actions.c 2009-10-01 23:06:13 UTC (rev 2695) @@ -338,7 +338,7 @@ gint mask = 0xffffff; /* Should be RSSettingsMask, is gint to satisfy rs_conf_get_integer() */ GtkWidget *dialog, *cb_box; - GtkWidget *cb_exposure, *cb_saturation, *cb_hue, *cb_contrast, *cb_whitebalance, *cb_curve, *cb_sharpen, *cb_channelmixer; + GtkWidget *cb_exposure, *cb_saturation, *cb_hue, *cb_contrast, *cb_whitebalance, *cb_curve, *cb_sharpen, *cb_denoise_luma, *cb_denoise_chroma, *cb_channelmixer; if (rs->settings_buffer) { @@ -349,6 +349,8 @@ cb_contrast = gtk_check_button_new_with_label (_("Contrast")); cb_whitebalance = gtk_check_button_new_with_label (_("White balance")); cb_sharpen = gtk_check_button_new_with_label (_("Sharpen")); + cb_denoise_luma = gtk_check_button_new_with_label (_("Denoise")); + cb_denoise_chroma = gtk_check_button_new_with_label (_("Color denoise")); cb_channelmixer = gtk_check_button_new_with_label (_("Channel mixer")); cb_curve = gtk_check_button_new_with_label (_("Curve")); @@ -366,6 +368,10 @@ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_whitebalance), TRUE); if (mask & MASK_SHARPEN) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_sharpen), TRUE); + if (mask & MASK_DENOISE_LUMA) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_denoise_luma), TRUE); + if (mask & MASK_DENOISE_CHROMA) + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_denoise_chroma), TRUE); if (mask & MASK_CHANNELMIXER) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_channelmixer), TRUE); if (mask & MASK_CURVE) @@ -379,6 +385,8 @@ gtk_box_pack_start (GTK_BOX (cb_box), cb_contrast, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cb_box), cb_whitebalance, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cb_box), cb_sharpen, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (cb_box), cb_denoise_luma, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (cb_box), cb_denoise_chroma, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cb_box), cb_channelmixer, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (cb_box), cb_curve, FALSE, TRUE, 0); @@ -405,6 +413,10 @@ mask |= MASK_WB; if (GTK_TOGGLE_BUTTON(cb_sharpen)->active) mask |= MASK_SHARPEN; + if (GTK_TOGGLE_BUTTON(cb_denoise_luma)->active) + mask |= MASK_DENOISE_LUMA; + if (GTK_TOGGLE_BUTTON(cb_denoise_chroma)->active) + mask |= MASK_DENOISE_CHROMA; if (GTK_TOGGLE_BUTTON(cb_channelmixer)->active) mask |= MASK_CHANNELMIXER; if (GTK_TOGGLE_BUTTON(cb_curve)->active) From klauspost at gmail.com Mon Oct 5 17:07:10 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 05 Oct 2009 17:07:10 +0200 Subject: [Rawstudio-commit] rawspeed r155 - / RawSpeed Message-ID: Author: post Date: 2009-10-05 17:07:10 +0200 (Mon, 05 Oct 2009) New Revision: 155 Modified: RawSpeed/RawDecoder.cpp RawSpeed/Rw2Decoder.cpp cameras.xml Log: - Added support for Panasonic DMC-FZ35 (only 4:3 mode). - Made "mode" non-optional for Panasonic cameras to avoid unneeded code maintenance. - Fixed Win32 threads. Modified: RawSpeed/RawDecoder.cpp =================================================================== --- RawSpeed/RawDecoder.cpp 2009-09-29 18:26:02 UTC (rev 154) +++ RawSpeed/RawDecoder.cpp 2009-10-05 15:07:10 UTC (rev 155) @@ -176,10 +176,16 @@ } void RawDecoder::startThreads() { - guint threads = rs_get_number_of_processor_cores(); + guint threads; +#ifdef WIN32 + threads = pthread_num_processors_np(); +#else + // FIXME: Don't depend on Rawstudio. + threads = rs_get_number_of_processor_cores(); +#endif int y_offset = 0; int y_per_thread = (mRaw->dim.y + threads - 1) / threads; - RawDecoderThread t[threads]; + RawDecoderThread *t = new RawDecoderThread[threads]; pthread_attr_t attr; @@ -202,6 +208,7 @@ errors.push_back(t[i].error); } } + delete[] t; } void RawDecoder::decodeThreaded(RawDecoderThread * t) { Modified: RawSpeed/Rw2Decoder.cpp =================================================================== --- RawSpeed/Rw2Decoder.cpp 2009-09-29 18:26:02 UTC (rev 154) +++ RawSpeed/Rw2Decoder.cpp 2009-10-05 15:07:10 UTC (rev 155) @@ -163,16 +163,14 @@ ratio = (float)mRaw->dim.x / (float)mRaw->dim.y; } - if (!model.compare("DMC-LX3") || !model.compare("DMC-G1") || !model.compare("DMC-GH1") || !model.compare("DMC-GF1")) { - if (almostEqualRelative(ratio, 16.0f / 9.0f, 0.02f)) - return "16:9"; - if (almostEqualRelative(ratio, 3.0f / 2.0f, 0.02f)) - return "3:2"; - if (almostEqualRelative(ratio, 4.0f / 3.0f, 0.02f)) - return "4:3"; - if (almostEqualRelative(ratio, 1.0f, 0.02f)) - return "1:1"; - } + if (almostEqualRelative(ratio, 16.0f / 9.0f, 0.02f)) + return "16:9"; + if (almostEqualRelative(ratio, 3.0f / 2.0f, 0.02f)) + return "3:2"; + if (almostEqualRelative(ratio, 4.0f / 3.0f, 0.02f)) + return "4:3"; + if (almostEqualRelative(ratio, 1.0f, 0.02f)) + return "1:1"; return ""; } Modified: cameras.xml =================================================================== --- cameras.xml 2009-09-29 18:26:02 UTC (rev 154) +++ cameras.xml 2009-10-05 15:07:10 UTC (rev 155) @@ -683,7 +683,7 @@ - + BLUEGREEN GREENRED @@ -691,7 +691,7 @@ - + BLUEGREEN GREENRED @@ -731,8 +731,16 @@ - + + GREENBLUE + REDGREEN + + + + + + BLUEGREEN GREENRED From klauspost at gmail.com Mon Oct 5 17:23:20 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 05 Oct 2009 17:23:20 +0200 Subject: [Rawstudio-commit] rawspeed r156 - / Message-ID: Author: post Date: 2009-10-05 17:23:19 +0200 (Mon, 05 Oct 2009) New Revision: 156 Modified: cameras.xml Log: - Adjusted CFA and blacklevel on Panasonic FZ35. Modified: cameras.xml =================================================================== --- cameras.xml 2009-10-05 15:07:10 UTC (rev 155) +++ cameras.xml 2009-10-05 15:23:19 UTC (rev 156) @@ -733,11 +733,11 @@ - GREENBLUE - REDGREEN + BLUEGREEN + GREENRED - + From klauspost at gmail.com Mon Oct 5 22:20:14 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 05 Oct 2009 22:20:14 +0200 Subject: [Rawstudio-commit] rawspeed r157 - RawSpeed Message-ID: Author: post Date: 2009-10-05 22:20:13 +0200 (Mon, 05 Oct 2009) New Revision: 157 Modified: RawSpeed/BitPumpMSB.cpp RawSpeed/BitPumpMSB.h RawSpeed/OrfDecoder.cpp Log: Minor optimization to ORF-reader. Modified: RawSpeed/BitPumpMSB.cpp =================================================================== --- RawSpeed/BitPumpMSB.cpp 2009-10-05 15:23:19 UTC (rev 156) +++ RawSpeed/BitPumpMSB.cpp 2009-10-05 20:20:13 UTC (rev 157) @@ -65,6 +65,9 @@ guint BitPumpMSB::getBits(guint nbits) { if (mLeft < nbits) { + if (nbits>24) + throw IOException("Invalid data, attempting to read more than 24 bits."); + fill(); } @@ -79,6 +82,9 @@ guint BitPumpMSB::peekBits(guint nbits) { if (mLeft < nbits) { + if (nbits>24) + throw IOException("Invalid data, attempting to read more than 24 bits."); + fill(); } @@ -132,6 +138,10 @@ mLeft -= nbits; } +void BitPumpMSB::skipBitsNoFill(unsigned int nbits) { + mLeft -= nbits; +} + unsigned char BitPumpMSB::getByte() { if (mLeft < 8) { fill(); Modified: RawSpeed/BitPumpMSB.h =================================================================== --- RawSpeed/BitPumpMSB.h 2009-10-05 15:23:19 UTC (rev 156) +++ RawSpeed/BitPumpMSB.h 2009-10-05 20:20:13 UTC (rev 157) @@ -38,6 +38,7 @@ guint peekBit(); guint peekByte(); void skipBits(guint nbits); + void skipBitsNoFill(guint nbits); __inline void checkPos() { if (off>size) throw IOException("Out of buffer read");}; // Check if we have a valid position guchar getByte(); guchar getByteSafe(); Modified: RawSpeed/OrfDecoder.cpp =================================================================== --- RawSpeed/OrfDecoder.cpp 2009-10-05 15:23:19 UTC (rev 156) +++ RawSpeed/OrfDecoder.cpp 2009-10-05 20:20:13 UTC (rev 157) @@ -102,6 +102,16 @@ guchar* data = mRaw->getData(); gint pitch = mRaw->pitch; + /* Build a table to quickly look up "high" value */ + gchar bittable[4096]; + for (i = 0; i < 4096; i++) { + int b = i; + for (high = 0; high < 12; high++) + if ((b>>(11-high))&1) + break; + bittable[i] = high; + } + s.skipBytes(7); BitPumpMSB bits(&s); @@ -114,10 +124,13 @@ carry = acarry[x & 1]; i = 2 * (carry[2] < 3); for (nbits = 2 + i; (gushort) carry[0] >> (nbits + i); nbits++); - sign = bits.getBitNoFill() * -1; - low = bits.getBitsNoFill(2); - for (high = 0; high < 12; high++) - if (bits.getBitNoFill()) break; + int b = bits.peekBitsNoFill(15); + sign = (b >> 14) * -1; + low = (b >> 12) & 3; + high = bittable[b&4095]; + // Skip bits used above. + bits.skipBitsNoFill(min(12+3, high + 1 + 3)); + if (high == 12) high = bits.getBits(16 - nbits) >> 1; carry[0] = (high << nbits) | bits.getBits(nbits); From klauspost at gmail.com Fri Oct 9 17:13:38 2009 From: klauspost at gmail.com (Klaus Post) Date: Fri, 09 Oct 2009 17:13:38 +0200 Subject: [Rawstudio-commit] rawspeed r158 - / Message-ID: Author: post Date: 2009-10-09 17:13:38 +0200 (Fri, 09 Oct 2009) New Revision: 158 Modified: cameras.xml Log: Added support for Nikon D300S. Modified: cameras.xml =================================================================== --- cameras.xml 2009-10-05 20:20:13 UTC (rev 157) +++ cameras.xml 2009-10-09 15:13:38 UTC (rev 158) @@ -363,6 +363,16 @@ + + + RED + GREEN + GREEN + BLUE + + + + GREEN From klauspost at gmail.com Fri Oct 9 18:02:53 2009 From: klauspost at gmail.com (Klaus Post) Date: Fri, 09 Oct 2009 18:02:53 +0200 Subject: [Rawstudio-commit] rawspeed r159 - RawSpeed Message-ID: Author: post Date: 2009-10-09 18:02:52 +0200 (Fri, 09 Oct 2009) New Revision: 159 Modified: RawSpeed/OrfDecoder.cpp Log: - Added comment to ORF decoder. Modified: RawSpeed/OrfDecoder.cpp =================================================================== --- RawSpeed/OrfDecoder.cpp 2009-10-09 15:13:38 UTC (rev 158) +++ RawSpeed/OrfDecoder.cpp 2009-10-09 16:02:52 UTC (rev 159) @@ -94,6 +94,12 @@ return mRaw; } +/* This is probably the slowest decoder of them all. + * I cannot see any way to effectively speed up the prediction + * phase, which is by far the slowest part of this algorithm. + * Also there is no way to multithread this code, since prediction + * is based on the output of all previous pixel (bar the first four) + */ void OrfDecoder::decodeCompressed(ByteStream& s, guint w, guint h) { int nbits, sign, low, high, i, wo, n, nw; From klauspost at gmail.com Sat Oct 10 23:42:48 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 10 Oct 2009 23:42:48 +0200 Subject: [Rawstudio-commit] r2696 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-10 23:42:48 +0200 (Sat, 10 Oct 2009) New Revision: 2696 Modified: trunk/plugins/dcp/dcp.c Log: Added SSE2 DCP processing, approx 2x as fast. Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-01 23:06:13 UTC (rev 2695) +++ trunk/plugins/dcp/dcp.c 2009-10-10 21:42:48 UTC (rev 2696) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2009 Anders Brander and + * Copyright (C) 2006-2009 Anders Brander and * Anders Kvist * * This program is free software; you can redistribute it and/or @@ -22,7 +22,9 @@ #include "config.h" #include #include /* pow() */ - +#if defined (__SSE2__) +#include +#endif /* __SSE2__ */ #define RS_TYPE_DCP (rs_dcp_type) #define RS_DCP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_DCP, RSDcp)) #define RS_DCP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_DCP, RSDcpClass)) @@ -96,6 +98,9 @@ static void set_white_xy(RSDcp *dcp, const RS_xy_COORD *xy); static void precalc(RSDcp *dcp); static void render(RSDcp *dcp, RS_IMAGE16 *image); +#if defined (__SSE2__) +static void render_SSE2(RSDcp *dcp, RS_IMAGE16 *image); +#endif static void read_profile(RSDcp *dcp, RSDcpFile *dcp_file); static RSIccProfile *get_icc_profile(RSFilter *filter); @@ -312,7 +317,12 @@ else tmp = g_object_ref(output); - render(dcp, tmp); +#if defined (__SSE2__) + if (rs_detect_cpu_features() & RS_CPU_FLAG_SSE2) + render_SSE2(dcp, tmp); + else +#endif + render(dcp, tmp); g_object_unref(tmp); @@ -387,7 +397,85 @@ } } +#if defined (__SSE2__) + inline void +RGBtoHSV_SSE(__m128 *c0, __m128 *c1, __m128 *c2) +{ + + __m128 zero_ps = _mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f); + __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + // Any number > 1 + __m128 add_v = _mm_set_ps(10.0f, 10.0f, 10.0f, 10.0f); + + __m128 r = *c0; + __m128 g = *c1; + __m128 b = *c2; + + __m128 h, v; + v = _mm_max_ps(b,_mm_max_ps(r,g)); + + __m128 m = _mm_min_ps(b,_mm_min_ps(r,g)); + __m128 gap = _mm_sub_ps(v,m); + __m128 v_mask = _mm_cmpeq_ps(gap, zero_ps); + v = _mm_add_ps(v, _mm_and_ps(add_v, v_mask)); + + h = _mm_xor_ps(r,r); + + /* Set gap to one where sat = 0, this will avoid divisions by zero, these values will not be used */ + ones_ps = _mm_and_ps(ones_ps, v_mask); + gap = _mm_or_ps(gap, ones_ps); + /* gap_inv = 1.0 / gap */ + __m128 gap_inv = _mm_rcp_ps(gap); + + /* if r == v */ + /* h = (g - b) / gap; */ + __m128 mask = _mm_cmpeq_ps(r, v); + __m128 val = _mm_mul_ps(gap_inv, _mm_sub_ps(g, b)); + + /* fill h */ + v = _mm_add_ps(v, _mm_and_ps(add_v, mask)); + h = _mm_or_ps(h, _mm_and_ps(val, mask)); + + /* if g == v */ + /* h = 2.0f + (b - r) / gap; */ + __m128 two_ps = _mm_set_ps(2.0f, 2.0f, 2.0f, 2.0f); + mask = _mm_cmpeq_ps(g, v); + val = _mm_sub_ps(b, r); + val = _mm_mul_ps(val, gap_inv); + val = _mm_add_ps(val, two_ps); + + v = _mm_add_ps(v, _mm_and_ps(add_v, mask)); + h = _mm_or_ps(h, _mm_and_ps(val, mask)); + + /* If (b == v) */ + /* h = 4.0f + (r - g) / gap; */ + __m128 four_ps = _mm_add_ps(two_ps, two_ps); + mask = _mm_cmpeq_ps(b, v); + val = _mm_add_ps(four_ps, _mm_mul_ps(gap_inv, _mm_sub_ps(r, g))); + + v = _mm_add_ps(v, _mm_and_ps(add_v, mask)); + h = _mm_or_ps(h, _mm_and_ps(val, mask)); + + __m128 s; + /* Fill s, if gap > 0 */ + v = _mm_sub_ps(v, add_v); + val = _mm_mul_ps(gap,_mm_rcp_ps(v)); + s = _mm_andnot_ps(v_mask, val ); + + /* Check if h < 0 */ + __m128 six_ps = _mm_set_ps(6.0f, 6.0f, 6.0f, 6.0f); + mask = _mm_cmplt_ps(h, zero_ps); + h = _mm_add_ps(h, _mm_and_ps(mask, six_ps)); + + + *c0 = h; + *c1 = s; + *c2 = v; +} +#endif + +inline void HSVtoRGB(gfloat h, gfloat s, gfloat v, gfloat *r, gfloat *g, gfloat *b) { if (s > 0.0f) @@ -598,7 +686,7 @@ gfloat rr; gfloat gg; gfloat bb; - + #define RGBTone(r, g, b, rr, gg, bb)\ {\ \ @@ -610,95 +698,375 @@ gg = bb + ((rr - bb) * (g - b) / (r - b));\ \ } - + if (r >= g) { - + if (g > b) { - + // Case 1: r >= g > b - + RGBTone (r, g, b, rr, gg, bb); - + } - + else if (b > r) { - + // Case 2: b > r >= g - + RGBTone (b, r, g, bb, rr, gg); - + } - + else if (b > g) { - + // Case 3: r >= b > g - + RGBTone (r, b, g, rr, bb, gg); - + } - + else { - + // Case 4: r >= g == b - + // DNG_ASSERT (r >= g && g == b, "Logic Error 2"); - + rr = tone_lut[_S(r)]; gg = tone_lut[_S(b)]; // rr = table.Interpolate (r); // gg = table.Interpolate (g); bb = gg; - + } - + } - + else { - + if (r >= b) { - + // Case 5: g > r >= b - + RGBTone (g, r, b, gg, rr, bb); - + } - + else if (b > g) { - + // Case 6: b > g > r - + RGBTone (b, g, r, bb, gg, rr); - + } - + else { - + // Case 7: g >= b > r - + RGBTone (g, b, r, gg, bb, rr); - + } - + } - + #undef RGBTone - + *_r = rr; *_g = gg; *_b = bb; - + } +#if defined (__SSE2__) + +inline __m128 +sse_matrix3_mul(float* mul, __m128 a, __m128 b, __m128 c) +{ + + __m128 v = _mm_set_ps(mul[0], mul[0], mul[0], mul[0]); + __m128 acc = _mm_mul_ps(a, v); + + v = _mm_set_ps(mul[1], mul[1], mul[1], mul[1]); + acc = _mm_add_ps(acc, _mm_mul_ps(b, v)); + + v = _mm_set_ps(mul[2], mul[2], mul[2], mul[2]); + acc = _mm_add_ps(acc, _mm_mul_ps(c, v)); + + return acc; +} + static void +render_SSE2(RSDcp *dcp, RS_IMAGE16 *image) +{ + gint x, y; + __m128 h, s, v; + __m128i p1,p2; + __m128 p1f, p2f, p3f, p4f; + __m128 r, g, b, r2, g2, b2; + __m128i zero; + + printf("Using SSE2\n"); + int xfer[4] __attribute__ ((aligned (16))); + + const gfloat exposure_comp = pow(2.0, dcp->exposure); + const gfloat saturation = dcp->saturation; + const gfloat hue = dcp->hue; + gfloat r_coeffs[3] = {dcp->camera_to_prophoto.coeff[0][0], dcp->camera_to_prophoto.coeff[0][1], dcp->camera_to_prophoto.coeff[0][2]}; + gfloat g_coeffs[3] = {dcp->camera_to_prophoto.coeff[1][0], dcp->camera_to_prophoto.coeff[1][1], dcp->camera_to_prophoto.coeff[1][2]}; + gfloat b_coeffs[3] = {dcp->camera_to_prophoto.coeff[2][0], dcp->camera_to_prophoto.coeff[2][1], dcp->camera_to_prophoto.coeff[2][2]}; + + for(y = 0 ; y < image->h; y++) + { + for(x=0; x < image->w; x+=4) + { + __m128i* pixel = (__m128i*)GET_PIXEL(image, x, y); + + zero = _mm_xor_si128(zero,zero); + + /* Convert to float */ + p1 = _mm_load_si128(pixel); + p2 = _mm_load_si128(pixel + 1); + + /* Unpack to R G B x */ + p2f = _mm_cvtepi32_ps(_mm_unpackhi_epi16(p1, zero)); + p4f = _mm_cvtepi32_ps(_mm_unpackhi_epi16(p2, zero)); + p1f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(p1, zero)); + p3f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(p2, zero)); + + /* Normalize to 0 to 1 range */ + __m128 rgb_div = _mm_set_ps(1.0/65535.0, 1.0/65535.0, 1.0/65535.0, 1.0/65535.0); + p1f = _mm_mul_ps(p1f, rgb_div); + p2f = _mm_mul_ps(p2f, rgb_div); + p3f = _mm_mul_ps(p3f, rgb_div); + p4f = _mm_mul_ps(p4f, rgb_div); + + /* Restric to camera white */ + __m128 min_cam = _mm_set_ps(0.0f, dcp->camera_white.z, dcp->camera_white.y, dcp->camera_white.x); + p1f = _mm_min_ps(p1f, min_cam); + p2f = _mm_min_ps(p2f, min_cam); + p3f = _mm_min_ps(p3f, min_cam); + p4f = _mm_min_ps(p4f, min_cam); + + /* Convert to planar */ + __m128 g1g0r1r0 = _mm_unpacklo_ps(p1f, p2f); + __m128 b1b0 = _mm_unpackhi_ps(p1f, p2f); + __m128 g3g2r3r2 = _mm_unpacklo_ps(p3f, p4f); + __m128 b3b2 = _mm_unpackhi_ps(p3f, p4f); + r = _mm_movelh_ps(g1g0r1r0, g3g2r3r2); + g = _mm_movehl_ps(g3g2r3r2, g1g0r1r0); + b = _mm_movelh_ps(b1b0, b3b2); + + /* Convert to Prophoto */ + r2 = sse_matrix3_mul(r_coeffs, r, g, b); + g2 = sse_matrix3_mul(g_coeffs, r, g, b); + b2 = sse_matrix3_mul(b_coeffs, r, g, b); + + /* Set min/max before HSV conversion */ + __m128 min_val = _mm_set_ps(1e-15, 1e-15, 1e-15, 1e-15); + __m128 max_val = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + r = _mm_max_ps(_mm_min_ps(r2, max_val), min_val); + g = _mm_max_ps(_mm_min_ps(g2, max_val), min_val); + b = _mm_max_ps(_mm_min_ps(b2, max_val), min_val); + + RGBtoHSV_SSE(&r, &g, &b); + h = r; s = g; v = b; + + if (dcp->huesatmap) + { + gfloat* h_p = (gfloat*)&h; + gfloat* s_p = (gfloat*)&s; + gfloat* v_p = (gfloat*)&v; + + huesat_map(dcp->huesatmap, &h_p[0], &s_p[0], &v_p[0]); + huesat_map(dcp->huesatmap, &h_p[1], &s_p[1], &v_p[1]); + huesat_map(dcp->huesatmap, &h_p[2], &s_p[2], &v_p[2]); + huesat_map(dcp->huesatmap, &h_p[3], &s_p[3], &v_p[3]); + } + + /* Exposure */ + __m128 exp = _mm_set_ps(exposure_comp, exposure_comp, exposure_comp, exposure_comp); + v = _mm_min_ps(max_val, _mm_mul_ps(v, exp)); + + + /* Saturation */ + __m128 sat = _mm_set_ps(saturation, saturation, saturation, saturation); + s = _mm_min_ps(max_val, _mm_mul_ps(s, sat)); + + /* Hue */ + __m128 hue_add = _mm_set_ps(hue, hue, hue, hue); + __m128 six_ps = _mm_set_ps(6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15); + __m128 zero_ps = _mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f); + h = _mm_add_ps(h, hue_add); + + /* Check if hue > 6 or < 0*/ + __m128 h_mask_gt = _mm_cmpgt_ps(h, six_ps); + __m128 h_mask_lt = _mm_cmplt_ps(h, zero_ps); + __m128 six_masked_gt = _mm_and_ps(six_ps, h_mask_gt); + __m128 six_masked_lt = _mm_and_ps(six_ps, h_mask_lt); + h = _mm_sub_ps(h, six_masked_gt); + h = _mm_add_ps(h, six_masked_lt); + + /* Convert v to lookup values */ + + /* TODO: Use 8 bit fraction as interpolation, for interpolating + * a more precise lookup using linear interpolation. Maybe use less than + * 16 bits for lookup for speed, 10 bits with interpolation should be enough */ + __m128 v_mul = _mm_set_ps(65535.0, 65535.0, 65535.0, 65535.0); + v = _mm_mul_ps(v, v_mul); + __m128i lookup = _mm_cvtps_epi32(v); + gfloat* v_p = (gfloat*)&v; + _mm_store_si128((__m128i*)&xfer[0], lookup); + + v_p[0] = dcp->curve_samples[xfer[0]]; + v_p[1] = dcp->curve_samples[xfer[1]]; + v_p[2] = dcp->curve_samples[xfer[2]]; + v_p[3] = dcp->curve_samples[xfer[3]]; + + + if (dcp->looktable) { + gfloat* h_p = (gfloat*)&h; + gfloat* s_p = (gfloat*)&s; + huesat_map(dcp->looktable, &h_p[0], &s_p[0], &v_p[0]); + huesat_map(dcp->looktable, &h_p[1], &s_p[1], &v_p[1]); + huesat_map(dcp->looktable, &h_p[2], &s_p[2], &v_p[2]); + huesat_map(dcp->looktable, &h_p[3], &s_p[3], &v_p[3]); + } + + + /* Back to RGB */ + + /* ensure that hue is within range */ + h_mask_gt = _mm_cmpgt_ps(h, six_ps); + h_mask_lt = _mm_cmplt_ps(h, zero_ps); + six_masked_gt = _mm_and_ps(six_ps, h_mask_gt); + six_masked_lt = _mm_and_ps(six_ps, h_mask_lt); + h = _mm_sub_ps(h, six_masked_gt); + h = _mm_add_ps(h, six_masked_lt); + + /* s always slightly > 0 */ + s = _mm_max_ps(s, min_val); + + + /* Convert get the fraction of h + * h_fraction = h - (float)(int)h */ + __m128 half_ps = _mm_set_ps(0.5f, 0.5f, 0.5f, 0.5f); + __m128 h_fraction = _mm_sub_ps(h,_mm_cvtepi32_ps(_mm_cvtps_epi32(_mm_sub_ps(h, half_ps)))); + __m128 ones_ps = _mm_add_ps(half_ps, half_ps); + + /* p = v * (1.0f - s) */ + __m128 p = _mm_mul_ps(v, _mm_sub_ps(ones_ps, s)); + /* q = (v * (1.0f - s * f)) */ + __m128 q = _mm_mul_ps(v, _mm_sub_ps(ones_ps, _mm_mul_ps(s, h_fraction))); + /* t = (v * (1.0f - s * (1.0f - f))) */ + __m128 t = _mm_mul_ps(v, _mm_sub_ps(ones_ps, _mm_mul_ps(s, _mm_sub_ps(ones_ps, h_fraction)))); + + /* h < 1 (case 0)*/ + /* case 0: *r = v; *g = t; *b = p; break; */ + __m128 h_threshold = _mm_add_ps(ones_ps, ones_ps); + __m128 out_mask = _mm_cmplt_ps(h, ones_ps); + r = _mm_and_ps(v, out_mask); + g = _mm_and_ps(t, out_mask); + b = _mm_and_ps(p, out_mask); + + /* h < 2 (case 1) */ + /* case 1: *r = q; *g = v; *b = p; break; */ + __m128 m = _mm_cmplt_ps(h, h_threshold); + h_threshold = _mm_add_ps(h_threshold, ones_ps); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(q, m)); + g = _mm_or_ps(g, _mm_and_ps(v, m)); + b = _mm_or_ps(b, _mm_and_ps(p, m)); + out_mask = _mm_or_ps(out_mask, m); + + /* h < 3 (case 2)*/ + /* case 2: *r = p; *g = v; *b = t; break; */ + m = _mm_cmplt_ps(h, h_threshold); + h_threshold = _mm_add_ps(h_threshold, ones_ps); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(p, m)); + g = _mm_or_ps(g, _mm_and_ps(v, m)); + b = _mm_or_ps(b, _mm_and_ps(t, m)); + out_mask = _mm_or_ps(out_mask, m); + + /* h < 4 (case 3)*/ + /* case 3: *r = p; *g = q; *b = v; break; */ + m = _mm_cmplt_ps(h, h_threshold); + h_threshold = _mm_add_ps(h_threshold, ones_ps); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(p, m)); + g = _mm_or_ps(g, _mm_and_ps(q, m)); + b = _mm_or_ps(b, _mm_and_ps(v, m)); + out_mask = _mm_or_ps(out_mask, m); + + /* h < 5 (case 4)*/ + /* case 4: *r = t; *g = p; *b = v; break; */ + m = _mm_cmplt_ps(h, h_threshold); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(t, m)); + g = _mm_or_ps(g, _mm_and_ps(p, m)); + b = _mm_or_ps(b, _mm_and_ps(v, m)); + out_mask = _mm_or_ps(out_mask, m); + + + /* Remainder (case 5) */ + /* case 5: *r = v; *g = p; *b = q; break; */ + __m128 all_ones = _mm_cmpeq_ps(h,h); + m = _mm_xor_ps(out_mask, all_ones); + r = _mm_or_ps(r, _mm_and_ps(v, m)); + g = _mm_or_ps(g, _mm_and_ps(p, m)); + b = _mm_or_ps(b, _mm_and_ps(q, m)); + + + __m128 rgb_mul = _mm_set_ps(65535.0, 65535.0, 65535.0, 65535.0); + r = _mm_mul_ps(r, rgb_mul); + g = _mm_mul_ps(g, rgb_mul); + b = _mm_mul_ps(b, rgb_mul); + + __m128i r_i = _mm_cvtps_epi32(r); + __m128i g_i = _mm_cvtps_epi32(g); + __m128i b_i = _mm_cvtps_epi32(b); + + __m128i sub_32 = _mm_set_epi32(32768, 32768, 32768, 32768); + __m128i signxor = _mm_set_epi32(0x80008000, 0x80008000, 0x80008000, 0x80008000); + + /* Subtract 32768 to avoid saturation */ + r_i = _mm_sub_epi32(r_i, sub_32); + g_i = _mm_sub_epi32(g_i, sub_32); + b_i = _mm_sub_epi32(b_i, sub_32); + + /* 32 bit signed -> 16 bit signed conversion, all in lower 64 bit */ + r_i = _mm_packs_epi32(r_i, r_i); + g_i = _mm_packs_epi32(g_i, g_i); + b_i = _mm_packs_epi32(b_i, b_i); + + /* Interleave*/ + __m128i rg_i = _mm_unpacklo_epi16(r_i, g_i); + __m128i bb_i = _mm_unpacklo_epi16(b_i, b_i); + p1 = _mm_unpacklo_epi32(rg_i, bb_i); + p2 = _mm_unpackhi_epi32(rg_i, bb_i); + + /* Convert sign back */ + p1 = _mm_xor_si128(p1, signxor); + p2 = _mm_xor_si128(p2, signxor); + + /* Store processed pixel */ + _mm_store_si128(pixel, p1); + _mm_store_si128(pixel + 1, p2); + } + } +} +#endif + +static void render(RSDcp *dcp, RS_IMAGE16 *image) { gint x, y; @@ -727,24 +1095,19 @@ pix.G = g; pix.B = b; pix = vector3_multiply_matrix(&pix, &dcp->camera_to_prophoto); - r = pix.R; - g = pix.G; - b = pix.B; r = CLAMP(pix.R, 0.0, 1.0); g = CLAMP(pix.G, 0.0, 1.0); b = CLAMP(pix.B, 0.0, 1.0); - /* Does it matter if we're above 1.0 at this point? */ - /* To HSV */ RGBtoHSV(r, g, b, &h, &s, &v); - v = MIN(v * exposure_comp, 1.0); - if (dcp->huesatmap) huesat_map(dcp->huesatmap, &h, &s, &v); + v = MIN(v * exposure_comp, 1.0); + /* Saturation */ s *= dcp->saturation; s = MIN(s, 1.0); From klauspost at gmail.com Sun Oct 11 15:52:17 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 11 Oct 2009 15:52:17 +0200 Subject: [Rawstudio-commit] r2697 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-11 15:52:17 +0200 (Sun, 11 Oct 2009) New Revision: 2697 Modified: trunk/plugins/dcp/dcp.c Log: Added SSE2 optimized DCP huesatmap processing. Results of valdiv > 2 verified against reference implementation. About 2x as fast. Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-10 21:42:48 UTC (rev 2696) +++ trunk/plugins/dcp/dcp.c 2009-10-11 13:52:17 UTC (rev 2697) @@ -676,6 +676,241 @@ *v = MIN(*v * valScale, 1.0); } +#if defined (__SSE2__) + +/* SSE2 implementation, matches the reference implementation pretty closely */ + +static void +huesat_map_SSE2(RSHuesatMap *map, __m128 *_h, __m128 *_s, __m128 *_v) +{ + g_assert(RS_IS_HUESAT_MAP(map)); + + __m128 h = *_h; + __m128 s = *_s; + __m128 v = *_v; + gint i; + gint xfer_0[4] __attribute__ ((aligned (16))); + gint xfer_1[4] __attribute__ ((aligned (16))); + + //TODO: Precalc BEGIN + gfloat hScale = (map->hue_divisions < 2) ? 0.0f : (map->hue_divisions * (1.0f / 6.0f)); + gfloat sScale = (gfloat) (map->sat_divisions - 1); + gfloat vScale = (gfloat) (map->val_divisions - 1); + // END precalc this. + + gint _maxHueIndex0 = map->hue_divisions - 1; + gint _maxSatIndex0 = map->sat_divisions - 2; + gint _maxValIndex0 = map->val_divisions - 2; + + const RS_VECTOR3 *tableBase = map->deltas; + + gint _valStep = map->hue_divisions * map->sat_divisions; + + __m128 hueShift; + __m128 satScale; + __m128 valScale; + + if (map->val_divisions < 2) + { + __m128 hScaled = _mm_mul_ps(h, _mm_set_ps( hScale, hScale, hScale, hScale)); + __m128 sScaled = _mm_mul_ps(s, _mm_set_ps( sScale, sScale, sScale, sScale)); + + __m128 half_ps = _mm_set_ps(0.5, 0.5, 0.5, 0.5); + __m128i maxHueIndex0 = _mm_set_epi32(_maxHueIndex0, _maxHueIndex0, _maxHueIndex0, _maxHueIndex0); + __m128i maxSatIndex0 = _mm_set_epi32(_maxSatIndex0, _maxSatIndex0, _maxSatIndex0, _maxSatIndex0); + __m128i hIndex0 = _mm_cvtps_epi32(_mm_sub_ps( hScaled, half_ps )); + __m128i sIndex0 = _mm_cvtps_epi32(_mm_sub_ps( sScaled, half_ps )); + + sIndex0 = _mm_min_epi16(sIndex0, maxSatIndex0); + __m128i ones_epi32 = _mm_set_epi32(1,1,1,1); + __m128i hIndex1 = _mm_add_epi32(hIndex0, ones_epi32); + + /* if (hIndex0 >= maxHueIndex0) */ + __m128i hIndexMask = _mm_cmpgt_epi32( hIndex0, _mm_sub_epi32(maxHueIndex0, ones_epi32)); + hIndex0 = _mm_andnot_si128(hIndexMask, hIndex0); + /* hIndex1 = 0; */ + hIndex1 = _mm_andnot_si128(hIndexMask, hIndex1); + /* hIndex0 = maxHueIndex0 */ + hIndex0 = _mm_or_si128(hIndex0, _mm_and_si128(hIndexMask, maxHueIndex0)); + + __m128 hFract1 = _mm_sub_ps( hScaled, _mm_cvtepi32_ps(hIndex0)); + __m128 sFract1 = _mm_sub_ps( sScaled, _mm_cvtepi32_ps(sIndex0)); + __m128 ones_ps = _mm_add_ps( half_ps, half_ps); + + __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); + __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); + __m128i hueStep = _mm_set_epi32(map->sat_divisions, map->sat_divisions, map->sat_divisions, map->sat_divisions); + __m128i table_offsets = _mm_add_epi32(sIndex0, _mm_mullo_epi16(hIndex0, hueStep)); + __m128i next_offsets = _mm_add_epi32(sIndex0, _mm_mullo_epi16(hIndex1, hueStep)); + + _mm_store_si128((__m128i*)xfer_0, table_offsets); + _mm_store_si128((__m128i*)xfer_1, next_offsets); + + const RS_VECTOR3 *entry00[4] = { tableBase + xfer_0[0], tableBase + xfer_0[1], tableBase + xfer_0[2], tableBase + xfer_0[3]}; + const RS_VECTOR3 *entry01[4] = { tableBase + xfer_1[0], tableBase + xfer_1[1], tableBase + xfer_1[2], tableBase + xfer_1[3]}; + + __m128 hs0 = _mm_set_ps(entry00[3]->fHueShift, entry00[2]->fHueShift, entry00[1]->fHueShift, entry00[0]->fHueShift); + __m128 hs1 = _mm_set_ps(entry01[3]->fHueShift, entry01[2]->fHueShift, entry01[1]->fHueShift, entry01[0]->fHueShift); + __m128 hueShift0 = _mm_add_ps(_mm_mul_ps(hs0, hFract0), _mm_mul_ps(hs1, hFract1)); + hueShift0 = _mm_mul_ps(hueShift0, sFract0); + + __m128 ss0 = _mm_set_ps(entry00[3]->fSatScale, entry00[2]->fSatScale, entry00[1]->fSatScale, entry00[0]->fSatScale); + __m128 ss1 = _mm_set_ps(entry01[3]->fSatScale, entry01[2]->fSatScale, entry01[1]->fSatScale, entry01[0]->fSatScale); + __m128 satScale0 = _mm_add_ps(_mm_mul_ps(ss0, hFract0), _mm_mul_ps(ss1, hFract1)); + satScale0 = _mm_mul_ps(satScale0, sFract0); + + __m128 vs0 = _mm_set_ps(entry00[3]->fValScale, entry00[2]->fValScale, entry00[1]->fValScale, entry00[0]->fValScale); + __m128 vs1 = _mm_set_ps(entry01[3]->fValScale, entry01[2]->fValScale, entry01[1]->fValScale, entry01[0]->fValScale); + __m128 valScale0 = _mm_add_ps(_mm_mul_ps(vs0, hFract0), _mm_mul_ps(vs1, hFract1)); + valScale0 = _mm_mul_ps(valScale0, sFract0); + + + for (i = 0; i < 4; i++) { + entry00[i]++; + entry01[i]++; + } + + hs0 = _mm_set_ps(entry00[3]->fHueShift, entry00[2]->fHueShift, entry00[1]->fHueShift, entry00[0]->fHueShift); + hs1 = _mm_set_ps(entry01[3]->fHueShift, entry01[2]->fHueShift, entry01[1]->fHueShift, entry01[0]->fHueShift); + __m128 hueShift1 = _mm_add_ps(_mm_mul_ps(hs0, hFract0), _mm_mul_ps(hs1, hFract1)); + hueShift = _mm_add_ps(hueShift0, _mm_mul_ps(hueShift1, sFract1)); + + ss0 = _mm_set_ps(entry00[3]->fSatScale, entry00[2]->fSatScale, entry00[1]->fSatScale, entry00[0]->fSatScale); + ss1 = _mm_set_ps(entry01[3]->fSatScale, entry01[2]->fSatScale, entry01[1]->fSatScale, entry01[0]->fSatScale); + __m128 satScale1 = _mm_add_ps(_mm_mul_ps(ss0, hFract0), _mm_mul_ps(ss1, hFract1)); + satScale = _mm_add_ps(satScale0, _mm_mul_ps(satScale1, sFract1)); + + vs0 = _mm_set_ps(entry00[3]->fValScale, entry00[2]->fValScale, entry00[1]->fValScale, entry00[0]->fValScale); + vs1 = _mm_set_ps(entry01[3]->fValScale, entry01[2]->fValScale, entry01[1]->fValScale, entry01[0]->fValScale); + __m128 valScale1 = _mm_add_ps(_mm_mul_ps(vs0, hFract0), _mm_mul_ps(vs1, hFract1)); + valScale = _mm_add_ps(valScale0, _mm_mul_ps(valScale1, sFract1)); + + } + else + { + __m128 hScaled = _mm_mul_ps(h, _mm_set_ps( hScale, hScale, hScale, hScale)); + __m128 sScaled = _mm_mul_ps(s, _mm_set_ps( sScale, sScale, sScale, sScale)); + __m128 vScaled = _mm_mul_ps(v, _mm_set_ps( vScale, vScale, vScale, vScale)); + + __m128 half_ps = _mm_set_ps(0.5, 0.5, 0.5, 0.5); + __m128i maxHueIndex0 = _mm_set_epi32(_maxHueIndex0, _maxHueIndex0, _maxHueIndex0, _maxHueIndex0); + __m128i maxSatIndex0 = _mm_set_epi32(_maxSatIndex0, _maxSatIndex0, _maxSatIndex0, _maxSatIndex0); + __m128i maxValIndex0 = _mm_set_epi32(_maxValIndex0, _maxValIndex0, _maxValIndex0, _maxValIndex0); + __m128i hIndex0 = _mm_cvtps_epi32(_mm_sub_ps( hScaled, half_ps )); + __m128i sIndex0 = _mm_cvtps_epi32(_mm_sub_ps( sScaled, half_ps )); + __m128i vIndex0 = _mm_cvtps_epi32(_mm_sub_ps( vScaled, half_ps )); + + // Requires that maxSatIndex0 and sIndex0 can be contained within a 16 bit signed word. + sIndex0 = _mm_min_epi16(sIndex0, maxSatIndex0); + vIndex0 = _mm_min_epi16(vIndex0, maxValIndex0); + __m128i ones_epi32 = _mm_set_epi32(1,1,1,1); + __m128i hIndex1 = _mm_add_epi32(hIndex0, ones_epi32); + + /* if (hIndex0 > (maxHueIndex0 - 1)) */ + __m128i hIndexMask = _mm_cmpgt_epi32( hIndex0, _mm_sub_epi32(maxHueIndex0, ones_epi32)); + /* Make room in hIndex0 */ + hIndex0 = _mm_andnot_si128(hIndexMask, hIndex0); + /* hIndex1 = 0; */ + hIndex1 = _mm_andnot_si128(hIndexMask, hIndex1); + /* hIndex0 = maxHueIndex0, where hIndex0 >= (maxHueIndex0) */ + hIndex0 = _mm_or_si128(hIndex0, _mm_and_si128(hIndexMask, maxHueIndex0)); + + __m128 hFract1 = _mm_sub_ps( hScaled, _mm_cvtepi32_ps(hIndex0)); + __m128 sFract1 = _mm_sub_ps( sScaled, _mm_cvtepi32_ps(sIndex0)); + __m128 vFract1 = _mm_sub_ps( vScaled, _mm_cvtepi32_ps(vIndex0)); + __m128 ones_ps = _mm_add_ps( half_ps, half_ps); + + __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); + __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); + __m128 vFract0 = _mm_sub_ps(ones_ps, vFract1); + + __m128i hueStep = _mm_set_epi32(map->sat_divisions, map->sat_divisions, map->sat_divisions, map->sat_divisions); + __m128i valStep = _mm_set_epi32(_valStep, _valStep, _valStep, _valStep); + + // This requires that hueStep and valStep can be contained in a 16 bit signed integer. + __m128i table_offsets = _mm_add_epi32(sIndex0, _mm_mullo_epi16(vIndex0, valStep)); + __m128i next_offsets = _mm_mullo_epi16(hIndex1, hueStep); + next_offsets = _mm_add_epi32(next_offsets, table_offsets); + table_offsets = _mm_add_epi32(table_offsets, _mm_mullo_epi16(hIndex0, hueStep)); + + // TODO: This will result in a store->load forward size mismatch penalty, if possible, avoid. + _mm_store_si128((__m128i*)xfer_0, table_offsets); + _mm_store_si128((__m128i*)xfer_1, next_offsets); + + const RS_VECTOR3 *entry00[4] = { tableBase + xfer_0[0], tableBase + xfer_0[1], tableBase + xfer_0[2], tableBase + xfer_0[3]}; + const RS_VECTOR3 *entry01[4] = { tableBase + xfer_1[0], tableBase + xfer_1[1], tableBase + xfer_1[2], tableBase + xfer_1[3]}; + const RS_VECTOR3 *entry10[4] = { entry00[0] + _valStep, entry00[1] + _valStep, entry00[2] + _valStep, entry00[3] + _valStep}; + const RS_VECTOR3 *entry11[4] = { entry01[0] + _valStep, entry01[1] + _valStep, entry01[2] + _valStep, entry01[3] + _valStep}; + + __m128 hs00 = _mm_set_ps(entry00[3]->fHueShift, entry00[2]->fHueShift, entry00[1]->fHueShift, entry00[0]->fHueShift); + __m128 hs01 = _mm_set_ps(entry01[3]->fHueShift, entry01[2]->fHueShift, entry01[1]->fHueShift, entry01[0]->fHueShift); + __m128 hs10 = _mm_set_ps(entry10[3]->fHueShift, entry10[2]->fHueShift, entry10[1]->fHueShift, entry10[0]->fHueShift); + __m128 hs11 = _mm_set_ps(entry11[3]->fHueShift, entry11[2]->fHueShift, entry11[1]->fHueShift, entry11[0]->fHueShift); + __m128 hueShift0 = _mm_mul_ps(vFract0, _mm_add_ps(_mm_mul_ps(hs00, hFract0), _mm_mul_ps(hs01, hFract1))); + __m128 hueShift1 = _mm_mul_ps(vFract1, _mm_add_ps(_mm_mul_ps(hs10, hFract0), _mm_mul_ps(hs11, hFract1))); + hueShift = _mm_mul_ps(sFract0, _mm_add_ps(hueShift0, hueShift1)); + + __m128 ss00 = _mm_set_ps(entry00[3]->fSatScale, entry00[2]->fSatScale, entry00[1]->fSatScale, entry00[0]->fSatScale); + __m128 ss01 = _mm_set_ps(entry01[3]->fSatScale, entry01[2]->fSatScale, entry01[1]->fSatScale, entry01[0]->fSatScale); + __m128 ss10 = _mm_set_ps(entry10[3]->fSatScale, entry10[2]->fSatScale, entry10[1]->fSatScale, entry10[0]->fSatScale); + __m128 ss11 = _mm_set_ps(entry11[3]->fSatScale, entry11[2]->fSatScale, entry11[1]->fSatScale, entry11[0]->fSatScale); + __m128 satScale0 = _mm_mul_ps(vFract0, _mm_add_ps(_mm_mul_ps(ss00, hFract0), _mm_mul_ps(ss01, hFract1))); + __m128 satScale1 = _mm_mul_ps(vFract1, _mm_add_ps(_mm_mul_ps(ss10, hFract0), _mm_mul_ps(ss11, hFract1))); + satScale = _mm_mul_ps(sFract0, _mm_add_ps(satScale0, satScale1)); + + __m128 vs00 = _mm_set_ps(entry00[3]->fValScale, entry00[2]->fValScale, entry00[1]->fValScale, entry00[0]->fValScale); + __m128 vs01 = _mm_set_ps(entry01[3]->fValScale, entry01[2]->fValScale, entry01[1]->fValScale, entry01[0]->fValScale); + __m128 vs10 = _mm_set_ps(entry10[3]->fValScale, entry10[2]->fValScale, entry10[1]->fValScale, entry10[0]->fValScale); + __m128 vs11 = _mm_set_ps(entry11[3]->fValScale, entry11[2]->fValScale, entry11[1]->fValScale, entry11[0]->fValScale); + __m128 valScale0 = _mm_mul_ps(vFract0, _mm_add_ps(_mm_mul_ps(vs00, hFract0), _mm_mul_ps(vs01, hFract1))); + __m128 valScale1 = _mm_mul_ps(vFract1, _mm_add_ps(_mm_mul_ps(vs10, hFract0), _mm_mul_ps(vs11, hFract1))); + valScale = _mm_mul_ps(sFract0, _mm_add_ps(valScale0, valScale1)); + + for (i = 0; i < 4; i++) { + entry00[i]++; + entry01[i]++; + entry10[i]++; + entry11[i]++; + } + + hs00 = _mm_set_ps(entry00[3]->fHueShift, entry00[2]->fHueShift, entry00[1]->fHueShift, entry00[0]->fHueShift); + hs01 = _mm_set_ps(entry01[3]->fHueShift, entry01[2]->fHueShift, entry01[1]->fHueShift, entry01[0]->fHueShift); + hs10 = _mm_set_ps(entry10[3]->fHueShift, entry10[2]->fHueShift, entry10[1]->fHueShift, entry10[0]->fHueShift); + hs11 = _mm_set_ps(entry11[3]->fHueShift, entry11[2]->fHueShift, entry11[1]->fHueShift, entry11[0]->fHueShift); + hueShift0 = _mm_mul_ps(vFract0, _mm_add_ps(_mm_mul_ps(hs00, hFract0), _mm_mul_ps(hs01, hFract1))); + hueShift1 = _mm_mul_ps(vFract1, _mm_add_ps(_mm_mul_ps(hs10, hFract0), _mm_mul_ps(hs11, hFract1))); + hueShift = _mm_add_ps(hueShift, _mm_mul_ps(sFract1, _mm_add_ps(hueShift0, hueShift1))); + + ss00 = _mm_set_ps(entry00[3]->fSatScale, entry00[2]->fSatScale, entry00[1]->fSatScale, entry00[0]->fSatScale); + ss01 = _mm_set_ps(entry01[3]->fSatScale, entry01[2]->fSatScale, entry01[1]->fSatScale, entry01[0]->fSatScale); + ss10 = _mm_set_ps(entry10[3]->fSatScale, entry10[2]->fSatScale, entry10[1]->fSatScale, entry10[0]->fSatScale); + ss11 = _mm_set_ps(entry11[3]->fSatScale, entry11[2]->fSatScale, entry11[1]->fSatScale, entry11[0]->fSatScale); + satScale0 = _mm_mul_ps(vFract0, _mm_add_ps(_mm_mul_ps(ss00, hFract0), _mm_mul_ps(ss01, hFract1))); + satScale1 = _mm_mul_ps(vFract1, _mm_add_ps(_mm_mul_ps(ss10, hFract0), _mm_mul_ps(ss11, hFract1))); + satScale = _mm_add_ps(satScale, _mm_mul_ps(sFract1, _mm_add_ps(satScale0, satScale1))); + + vs00 = _mm_set_ps(entry00[3]->fValScale, entry00[2]->fValScale, entry00[1]->fValScale, entry00[0]->fValScale); + vs01 = _mm_set_ps(entry01[3]->fValScale, entry01[2]->fValScale, entry01[1]->fValScale, entry01[0]->fValScale); + vs10 = _mm_set_ps(entry10[3]->fValScale, entry10[2]->fValScale, entry10[1]->fValScale, entry10[0]->fValScale); + vs11 = _mm_set_ps(entry11[3]->fValScale, entry11[2]->fValScale, entry11[1]->fValScale, entry11[0]->fValScale); + valScale0 = _mm_mul_ps(vFract0, _mm_add_ps(_mm_mul_ps(vs00, hFract0), _mm_mul_ps(vs01, hFract1))); + valScale1 = _mm_mul_ps(vFract1, _mm_add_ps(_mm_mul_ps(vs10, hFract0), _mm_mul_ps(vs11, hFract1))); + valScale = _mm_add_ps(valScale, _mm_mul_ps(sFract1, _mm_add_ps(valScale0, valScale1))); + } + + __m128 mul_hue = _mm_set_ps(6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f); + __m128 ones_ps = _mm_set_ps(1.0, 1.0, 1.0, 1.0); + hueShift = _mm_mul_ps(hueShift, mul_hue); + s = _mm_min_ps(ones_ps, _mm_mul_ps(s, satScale)); + v = _mm_min_ps(ones_ps, _mm_mul_ps(v, valScale)); + h = _mm_add_ps(h, hueShift); + *_h = h; + *_s = s; + *_v = v; +} + +#endif // defined __SSE2__ + /* RefBaselineRGBTone() */ void rgb_tone(gfloat *_r, gfloat *_g, gfloat *_b, const gfloat * const tone_lut) @@ -814,7 +1049,6 @@ __m128 r, g, b, r2, g2, b2; __m128i zero; - printf("Using SSE2\n"); int xfer[4] __attribute__ ((aligned (16))); const gfloat exposure_comp = pow(2.0, dcp->exposure); @@ -882,14 +1116,7 @@ if (dcp->huesatmap) { - gfloat* h_p = (gfloat*)&h; - gfloat* s_p = (gfloat*)&s; - gfloat* v_p = (gfloat*)&v; - - huesat_map(dcp->huesatmap, &h_p[0], &s_p[0], &v_p[0]); - huesat_map(dcp->huesatmap, &h_p[1], &s_p[1], &v_p[1]); - huesat_map(dcp->huesatmap, &h_p[2], &s_p[2], &v_p[2]); - huesat_map(dcp->huesatmap, &h_p[3], &s_p[3], &v_p[3]); + huesat_map_SSE2(dcp->huesatmap, &h, &s, &v); } /* Exposure */ @@ -933,12 +1160,7 @@ if (dcp->looktable) { - gfloat* h_p = (gfloat*)&h; - gfloat* s_p = (gfloat*)&s; - huesat_map(dcp->looktable, &h_p[0], &s_p[0], &v_p[0]); - huesat_map(dcp->looktable, &h_p[1], &s_p[1], &v_p[1]); - huesat_map(dcp->looktable, &h_p[2], &s_p[2], &v_p[2]); - huesat_map(dcp->looktable, &h_p[3], &s_p[3], &v_p[3]); + huesat_map_SSE2(dcp->looktable, &h, &s, &v); } From klauspost at gmail.com Sun Oct 11 17:36:37 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 11 Oct 2009 17:36:37 +0200 Subject: [Rawstudio-commit] r2698 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-11 17:36:36 +0200 (Sun, 11 Oct 2009) New Revision: 2698 Modified: trunk/plugins/dcp/dcp.c Log: Made DCP renderer multithreaded. Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-11 13:52:17 UTC (rev 2697) +++ trunk/plugins/dcp/dcp.c 2009-10-11 15:36:36 UTC (rev 2698) @@ -81,6 +81,16 @@ RSIccProfile *prophoto_profile; }; +typedef struct { + RSDcp *dcp; + GThread *threadid; + gint start_x; + gint start_y; + gint end_y; + RS_IMAGE16 *tmp; + +} ThreadInfo; + RS_DEFINE_FILTER(rs_dcp, RSDcp) enum { @@ -97,9 +107,9 @@ static RS_MATRIX3 find_xyz_to_camera(RSDcp *dcp, const RS_xy_COORD *white_xy, RS_MATRIX3 *forward_matrix); static void set_white_xy(RSDcp *dcp, const RS_xy_COORD *xy); static void precalc(RSDcp *dcp); -static void render(RSDcp *dcp, RS_IMAGE16 *image); +static void render(ThreadInfo* t); #if defined (__SSE2__) -static void render_SSE2(RSDcp *dcp, RS_IMAGE16 *image); +static void render_SSE2(ThreadInfo* t); #endif static void read_profile(RSDcp *dcp, RSDcpFile *dcp_file); static RSIccProfile *get_icc_profile(RSFilter *filter); @@ -285,6 +295,32 @@ } } +gpointer +start_single_dcp_thread(gpointer _thread_info) +{ + ThreadInfo* t = _thread_info; + RS_IMAGE16 *tmp = t->tmp; + +#if defined (__SSE2__) + if (rs_detect_cpu_features() & RS_CPU_FLAG_SSE2) + { + render_SSE2(t); + if (tmp->w & 3) + { + t->start_x = tmp->w - (tmp->w & 3); + render(t); + } + + } + else +#endif + render(t); + + g_thread_exit(NULL); + + return NULL; /* Make the compiler shut up - we'll never return */ +} + static RSFilterResponse * get_image(RSFilter *filter, const RSFilterParam *param) { @@ -317,13 +353,33 @@ else tmp = g_object_ref(output); -#if defined (__SSE2__) - if (rs_detect_cpu_features() & RS_CPU_FLAG_SSE2) - render_SSE2(dcp, tmp); - else -#endif - render(dcp, tmp); + guint i, y_offset, y_per_thread, threaded_h; + const guint threads = rs_get_number_of_processor_cores(); + ThreadInfo *t = g_new(ThreadInfo, threads); + threaded_h = tmp->h; + y_per_thread = (threaded_h + threads-1)/threads; + y_offset = 0; + + for (i = 0; i < threads; i++) + { + t[i].tmp = tmp; + t[i].start_y = y_offset; + t[i].start_x = 0; + t[i].dcp = dcp; + y_offset += y_per_thread; + y_offset = MIN(tmp->h, y_offset); + t[i].end_y = y_offset; + + t[i].threadid = g_thread_create(start_single_dcp_thread, &t[i], TRUE, NULL); + } + + /* Wait for threads to finish */ + for(i = 0; i < threads; i++) + g_thread_join(t[i].threadid); + + g_free(t); + g_object_unref(tmp); return response; @@ -1040,8 +1096,10 @@ } static void -render_SSE2(RSDcp *dcp, RS_IMAGE16 *image) +render_SSE2(ThreadInfo* t) { + RS_IMAGE16 *image = t->tmp; + RSDcp *dcp = t->dcp; gint x, y; __m128 h, s, v; __m128i p1,p2; @@ -1057,10 +1115,11 @@ gfloat r_coeffs[3] = {dcp->camera_to_prophoto.coeff[0][0], dcp->camera_to_prophoto.coeff[0][1], dcp->camera_to_prophoto.coeff[0][2]}; gfloat g_coeffs[3] = {dcp->camera_to_prophoto.coeff[1][0], dcp->camera_to_prophoto.coeff[1][1], dcp->camera_to_prophoto.coeff[1][2]}; gfloat b_coeffs[3] = {dcp->camera_to_prophoto.coeff[2][0], dcp->camera_to_prophoto.coeff[2][1], dcp->camera_to_prophoto.coeff[2][2]}; + gint end_x = image->w - (image->w & 3); - for(y = 0 ; y < image->h; y++) + for(y = t->start_y ; y < t->end_y; y++) { - for(x=0; x < image->w; x+=4) + for(x=0; x < end_x; x+=4) { __m128i* pixel = (__m128i*)GET_PIXEL(image, x, y); @@ -1289,8 +1348,11 @@ #endif static void -render(RSDcp *dcp, RS_IMAGE16 *image) +render(ThreadInfo* t) { + RS_IMAGE16 *image = t->tmp; + RSDcp *dcp = t->dcp; + gint x, y; gfloat h, s, v; gfloat r, g, b; @@ -1298,9 +1360,9 @@ const gfloat exposure_comp = pow(2.0, dcp->exposure); - for(y = 0 ; y < image->h; y++) + for(y = t->start_y ; y < t->end_y; y++) { - for(x=0; x < image->w; x++) + for(x=t->start_x; x < image->w; x++) { gushort *pixel = GET_PIXEL(image, x, y); From klauspost at gmail.com Mon Oct 12 17:35:30 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 12 Oct 2009 17:35:30 +0200 Subject: [Rawstudio-commit] r2699 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-12 17:35:30 +0200 (Mon, 12 Oct 2009) New Revision: 2699 Modified: trunk/plugins/dcp/dcp.c Log: DCP Assembler: Convert to int using truncation (instead of subtracting 0.5 before). Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-11 15:36:36 UTC (rev 2698) +++ trunk/plugins/dcp/dcp.c 2009-10-12 15:35:30 UTC (rev 2699) @@ -771,11 +771,10 @@ __m128 hScaled = _mm_mul_ps(h, _mm_set_ps( hScale, hScale, hScale, hScale)); __m128 sScaled = _mm_mul_ps(s, _mm_set_ps( sScale, sScale, sScale, sScale)); - __m128 half_ps = _mm_set_ps(0.5, 0.5, 0.5, 0.5); __m128i maxHueIndex0 = _mm_set_epi32(_maxHueIndex0, _maxHueIndex0, _maxHueIndex0, _maxHueIndex0); __m128i maxSatIndex0 = _mm_set_epi32(_maxSatIndex0, _maxSatIndex0, _maxSatIndex0, _maxSatIndex0); - __m128i hIndex0 = _mm_cvtps_epi32(_mm_sub_ps( hScaled, half_ps )); - __m128i sIndex0 = _mm_cvtps_epi32(_mm_sub_ps( sScaled, half_ps )); + __m128i hIndex0 = _mm_cvttps_epi32( hScaled ); + __m128i sIndex0 = _mm_cvttps_epi32( sScaled ); sIndex0 = _mm_min_epi16(sIndex0, maxSatIndex0); __m128i ones_epi32 = _mm_set_epi32(1,1,1,1); @@ -791,7 +790,7 @@ __m128 hFract1 = _mm_sub_ps( hScaled, _mm_cvtepi32_ps(hIndex0)); __m128 sFract1 = _mm_sub_ps( sScaled, _mm_cvtepi32_ps(sIndex0)); - __m128 ones_ps = _mm_add_ps( half_ps, half_ps); + __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); @@ -848,13 +847,12 @@ __m128 sScaled = _mm_mul_ps(s, _mm_set_ps( sScale, sScale, sScale, sScale)); __m128 vScaled = _mm_mul_ps(v, _mm_set_ps( vScale, vScale, vScale, vScale)); - __m128 half_ps = _mm_set_ps(0.5, 0.5, 0.5, 0.5); __m128i maxHueIndex0 = _mm_set_epi32(_maxHueIndex0, _maxHueIndex0, _maxHueIndex0, _maxHueIndex0); __m128i maxSatIndex0 = _mm_set_epi32(_maxSatIndex0, _maxSatIndex0, _maxSatIndex0, _maxSatIndex0); __m128i maxValIndex0 = _mm_set_epi32(_maxValIndex0, _maxValIndex0, _maxValIndex0, _maxValIndex0); - __m128i hIndex0 = _mm_cvtps_epi32(_mm_sub_ps( hScaled, half_ps )); - __m128i sIndex0 = _mm_cvtps_epi32(_mm_sub_ps( sScaled, half_ps )); - __m128i vIndex0 = _mm_cvtps_epi32(_mm_sub_ps( vScaled, half_ps )); + __m128i hIndex0 = _mm_cvttps_epi32(hScaled); + __m128i sIndex0 = _mm_cvttps_epi32(sScaled); + __m128i vIndex0 = _mm_cvttps_epi32(vScaled); // Requires that maxSatIndex0 and sIndex0 can be contained within a 16 bit signed word. sIndex0 = _mm_min_epi16(sIndex0, maxSatIndex0); @@ -874,7 +872,7 @@ __m128 hFract1 = _mm_sub_ps( hScaled, _mm_cvtepi32_ps(hIndex0)); __m128 sFract1 = _mm_sub_ps( sScaled, _mm_cvtepi32_ps(sIndex0)); __m128 vFract1 = _mm_sub_ps( vScaled, _mm_cvtepi32_ps(vIndex0)); - __m128 ones_ps = _mm_add_ps( half_ps, half_ps); + __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); @@ -1239,9 +1237,8 @@ /* Convert get the fraction of h * h_fraction = h - (float)(int)h */ - __m128 half_ps = _mm_set_ps(0.5f, 0.5f, 0.5f, 0.5f); - __m128 h_fraction = _mm_sub_ps(h,_mm_cvtepi32_ps(_mm_cvtps_epi32(_mm_sub_ps(h, half_ps)))); - __m128 ones_ps = _mm_add_ps(half_ps, half_ps); + __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + __m128 h_fraction = _mm_sub_ps(h,_mm_cvtepi32_ps(_mm_cvttps_epi32(h))); /* p = v * (1.0f - s) */ __m128 p = _mm_mul_ps(v, _mm_sub_ps(ones_ps, s)); From klauspost at gmail.com Mon Oct 12 17:54:32 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 12 Oct 2009 17:54:32 +0200 Subject: [Rawstudio-commit] r2700 - trunk/plugins/resample Message-ID: Author: post Date: 2009-10-12 17:54:32 +0200 (Mon, 12 Oct 2009) New Revision: 2700 Modified: trunk/plugins/resample/resample.c Log: Add soft prefetch to vertical resampler. Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-10-12 15:35:30 UTC (rev 2699) +++ trunk/plugins/resample/resample.c 2009-10-12 15:54:32 UTC (rev 2700) @@ -759,12 +759,16 @@ for (i = 0; i < fir_filter_size; i++) { /* Load weight */ __m128i w = _mm_set_epi32(wg[i],wg[i],wg[i],wg[i]); - /* Load source */ + + /* Load source and prefetch next line */ + int pos = i * input->rowstride; __m128i src1i, src2i, src3i; - __m128i* in_sse = (__m128i*)&in[i * input->rowstride]; + __m128i* in_sse = (__m128i*)&in[pos]; src1i = _mm_load_si128(in_sse); src2i = _mm_load_si128(in_sse+1); src3i = _mm_load_si128(in_sse+2); + _mm_prefetch(&in[pos + input->rowstride], _MM_HINT_T0); + /* Unpack to dwords */ __m128i src1i_h, src2i_h, src3i_h; src1i_h = _mm_unpackhi_epi16(src1i, zero); From klauspost at gmail.com Mon Oct 12 18:17:44 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 12 Oct 2009 18:17:44 +0200 Subject: [Rawstudio-commit] r2701 - trunk/plugins/resample Message-ID: Author: post Date: 2009-10-12 18:17:43 +0200 (Mon, 12 Oct 2009) New Revision: 2701 Modified: trunk/plugins/resample/resample.c Log: Resample prefetch prefetches next cacheline of current line (greater prefetch distance). Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-10-12 15:54:32 UTC (rev 2700) +++ trunk/plugins/resample/resample.c 2009-10-12 16:17:43 UTC (rev 2701) @@ -767,7 +767,7 @@ src1i = _mm_load_si128(in_sse); src2i = _mm_load_si128(in_sse+1); src3i = _mm_load_si128(in_sse+2); - _mm_prefetch(&in[pos + input->rowstride], _MM_HINT_T0); + _mm_prefetch(&in[pos + 32], _MM_HINT_T0); /* Unpack to dwords */ __m128i src1i_h, src2i_h, src3i_h; From klauspost at gmail.com Mon Oct 12 19:17:39 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 12 Oct 2009 19:17:39 +0200 Subject: [Rawstudio-commit] r2702 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-12 19:17:39 +0200 (Mon, 12 Oct 2009) New Revision: 2702 Modified: trunk/plugins/dcp/Makefile.am Log: -Enable faster compiler math to help non-SSE2 machines. Modified: trunk/plugins/dcp/Makefile.am =================================================================== --- trunk/plugins/dcp/Makefile.am 2009-10-12 16:17:43 UTC (rev 2701) +++ trunk/plugins/dcp/Makefile.am 2009-10-12 17:17:39 UTC (rev 2702) @@ -1,17 +1,12 @@ plugindir = $(libdir)/rawstudio/plugins -AM_CFLAGS =\ - -Wall \ - -g3 \ - -O4 +AM_CFLAGS = -O4 -Wall -ffast-math -funsafe-math-optimizations \ + -ffinite-math-only -g3 AM_CXXFLAGS = $(AM_CFLAGS) -INCLUDES = \ - -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ - -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - @PACKAGE_CFLAGS@ \ - -I../../librawstudio/ +INCLUDES = -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" -I../../librawstudio/ @PACKAGE_CFLAGS@ lib_LTLIBRARIES = dcp.la From anders at brander.dk Mon Oct 12 19:20:24 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 12 Oct 2009 19:20:24 +0200 Subject: [Rawstudio-commit] r2702 - trunk/plugins/dcp In-Reply-To: References: Message-ID: <1255368024.20182.14.camel@video64> Hi, On Mon, 2009-10-12 at 19:17 +0200, Klaus Post wrote: > -INCLUDES = \ > - -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ > - -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ > - @PACKAGE_CFLAGS@ \ > - -I../../librawstudio/ > +INCLUDES = -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ > + -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" -I../../librawstudio/ @PACKAGE_CFLAGS@ What is the purpose of reversing these flags? /abrander From klauspost at gmail.com Mon Oct 12 20:11:00 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 12 Oct 2009 20:11:00 +0200 Subject: [Rawstudio-commit] r2702 - trunk/plugins/dcp In-Reply-To: <1255368024.20182.14.camel@video64> References: <1255368024.20182.14.camel@video64> Message-ID: Er det ikke bare en newline, der har skiftet plads? Jeg tror det er kdevelop der har gemt det p? en anden m?de. Regards, Klaus Post http://www.klauspost.com On Mon, Oct 12, 2009 at 7:20 PM, Anders Brander wrote: > Hi, > > On Mon, 2009-10-12 at 19:17 +0200, Klaus Post wrote: >> -INCLUDES = \ >> - ? ? -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ >> - ? ? -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ >> - ? ? @PACKAGE_CFLAGS@ \ >> - ? ? -I../../librawstudio/ >> +INCLUDES = -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ >> + ? ? -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" -I../../librawstudio/ @PACKAGE_CFLAGS@ > > What is the purpose of reversing these flags? > > /abrander > > _______________________________________________ > Rawstudio-commit mailing list > Rawstudio-commit at rawstudio.org > http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit > From klauspost at gmail.com Mon Oct 12 20:23:24 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 12 Oct 2009 20:23:24 +0200 Subject: [Rawstudio-commit] r2703 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-12 20:23:24 +0200 (Mon, 12 Oct 2009) New Revision: 2703 Modified: trunk/plugins/dcp/dcp.c Log: DCP: Load constants from static variable to avoid generation of load+shuffle from intrinsics. Approx 10% faster overall. Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-12 17:17:39 UTC (rev 2702) +++ trunk/plugins/dcp/dcp.c 2009-10-12 18:23:24 UTC (rev 2703) @@ -455,14 +455,19 @@ #if defined (__SSE2__) +static gfloat _zero_ps[4] __attribute__ ((aligned (16))) = {0.0f, 0.0f, 0.0f, 0.0f}; +static gfloat _ones_ps[4] __attribute__ ((aligned (16))) = {1.0f, 1.0f, 1.0f, 1.0f}; +static gfloat _two_ps[4] __attribute__ ((aligned (16))) = {2.0f, 2.0f, 2.0f, 2.0f}; +static gfloat _six_ps[4] __attribute__ ((aligned (16))) = {6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15}; + inline void RGBtoHSV_SSE(__m128 *c0, __m128 *c1, __m128 *c2) { - __m128 zero_ps = _mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f); - __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + __m128 zero_ps = _mm_load_ps(_zero_ps); + __m128 ones_ps = _mm_load_ps(_ones_ps); // Any number > 1 - __m128 add_v = _mm_set_ps(10.0f, 10.0f, 10.0f, 10.0f); + __m128 add_v = _mm_load_ps(_two_ps); __m128 r = *c0; __m128 g = *c1; @@ -495,7 +500,7 @@ /* if g == v */ /* h = 2.0f + (b - r) / gap; */ - __m128 two_ps = _mm_set_ps(2.0f, 2.0f, 2.0f, 2.0f); + __m128 two_ps = _mm_load_ps(_two_ps); mask = _mm_cmpeq_ps(g, v); val = _mm_sub_ps(b, r); val = _mm_mul_ps(val, gap_inv); @@ -520,7 +525,7 @@ s = _mm_andnot_ps(v_mask, val ); /* Check if h < 0 */ - __m128 six_ps = _mm_set_ps(6.0f, 6.0f, 6.0f, 6.0f); + __m128 six_ps = _mm_load_ps(_six_ps); mask = _mm_cmplt_ps(h, zero_ps); h = _mm_add_ps(h, _mm_and_ps(mask, six_ps)); @@ -736,6 +741,9 @@ /* SSE2 implementation, matches the reference implementation pretty closely */ +static gfloat _mul_hue_ps[4] __attribute__ ((aligned (16))) = {6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f}; +static gint _ones_epi32[4] __attribute__ ((aligned (16))) = {1,1,1,1}; + static void huesat_map_SSE2(RSHuesatMap *map, __m128 *_h, __m128 *_s, __m128 *_v) { @@ -777,7 +785,7 @@ __m128i sIndex0 = _mm_cvttps_epi32( sScaled ); sIndex0 = _mm_min_epi16(sIndex0, maxSatIndex0); - __m128i ones_epi32 = _mm_set_epi32(1,1,1,1); + __m128i ones_epi32 = _mm_load_si128((__m128i*)_ones_epi32); __m128i hIndex1 = _mm_add_epi32(hIndex0, ones_epi32); /* if (hIndex0 >= maxHueIndex0) */ @@ -790,7 +798,7 @@ __m128 hFract1 = _mm_sub_ps( hScaled, _mm_cvtepi32_ps(hIndex0)); __m128 sFract1 = _mm_sub_ps( sScaled, _mm_cvtepi32_ps(sIndex0)); - __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + __m128 ones_ps = _mm_load_ps(_ones_ps); __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); @@ -872,7 +880,7 @@ __m128 hFract1 = _mm_sub_ps( hScaled, _mm_cvtepi32_ps(hIndex0)); __m128 sFract1 = _mm_sub_ps( sScaled, _mm_cvtepi32_ps(sIndex0)); __m128 vFract1 = _mm_sub_ps( vScaled, _mm_cvtepi32_ps(vIndex0)); - __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + __m128 ones_ps = _mm_load_ps(_ones_ps); __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); @@ -952,8 +960,8 @@ valScale = _mm_add_ps(valScale, _mm_mul_ps(sFract1, _mm_add_ps(valScale0, valScale1))); } - __m128 mul_hue = _mm_set_ps(6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f); - __m128 ones_ps = _mm_set_ps(1.0, 1.0, 1.0, 1.0); + __m128 mul_hue = _mm_load_ps(_mul_hue_ps); + __m128 ones_ps = _mm_load_ps(_ones_ps); hueShift = _mm_mul_ps(hueShift, mul_hue); s = _mm_min_ps(ones_ps, _mm_mul_ps(s, satScale)); v = _mm_min_ps(ones_ps, _mm_mul_ps(v, valScale)); @@ -1081,18 +1089,24 @@ sse_matrix3_mul(float* mul, __m128 a, __m128 b, __m128 c) { - __m128 v = _mm_set_ps(mul[0], mul[0], mul[0], mul[0]); + __m128 v = _mm_load_ps(mul); __m128 acc = _mm_mul_ps(a, v); - v = _mm_set_ps(mul[1], mul[1], mul[1], mul[1]); + v = _mm_load_ps(mul+4); acc = _mm_add_ps(acc, _mm_mul_ps(b, v)); - v = _mm_set_ps(mul[2], mul[2], mul[2], mul[2]); + v = _mm_load_ps(mul+8); acc = _mm_add_ps(acc, _mm_mul_ps(c, v)); return acc; } +static gfloat _rgb_div_ps[4] __attribute__ ((aligned (16))) = {1.0/65535.0, 1.0/65535.0, 1.0/65535.0, 1.0/65535.0}; +static gfloat _very_small_ps[4] __attribute__ ((aligned (16))) = {1e-15, 1e-15, 1e-15, 1e-15}; +static gfloat _16_bit_ps[4] __attribute__ ((aligned (16))) = {65535.0, 65535.0, 65535.0, 65535.0}; +static gint _15_bit_epi32[4] __attribute__ ((aligned (16))) = { 32768, 32768, 32768, 32768}; +static guint _16_bit_sign[4] __attribute__ ((aligned (16))) = {0x80008000,0x80008000,0x80008000,0x80008000}; + static void render_SSE2(ThreadInfo* t) { @@ -1103,16 +1117,27 @@ __m128i p1,p2; __m128 p1f, p2f, p3f, p4f; __m128 r, g, b, r2, g2, b2; - __m128i zero; + __m128i zero = _mm_load_si128((__m128i*)_15_bit_epi32); int xfer[4] __attribute__ ((aligned (16))); const gfloat exposure_comp = pow(2.0, dcp->exposure); const gfloat saturation = dcp->saturation; const gfloat hue = dcp->hue; - gfloat r_coeffs[3] = {dcp->camera_to_prophoto.coeff[0][0], dcp->camera_to_prophoto.coeff[0][1], dcp->camera_to_prophoto.coeff[0][2]}; - gfloat g_coeffs[3] = {dcp->camera_to_prophoto.coeff[1][0], dcp->camera_to_prophoto.coeff[1][1], dcp->camera_to_prophoto.coeff[1][2]}; - gfloat b_coeffs[3] = {dcp->camera_to_prophoto.coeff[2][0], dcp->camera_to_prophoto.coeff[2][1], dcp->camera_to_prophoto.coeff[2][2]}; + + float cam_prof[4*4*3] __attribute__ ((aligned (16))); + for (x = 0; x < 4; x++ ) { + cam_prof[x] = dcp->camera_to_prophoto.coeff[0][0]; + cam_prof[x+4] = dcp->camera_to_prophoto.coeff[0][1]; + cam_prof[x+8] = dcp->camera_to_prophoto.coeff[0][2]; + cam_prof[12+x] = dcp->camera_to_prophoto.coeff[1][0]; + cam_prof[12+x+4] = dcp->camera_to_prophoto.coeff[1][1]; + cam_prof[12+x+8] = dcp->camera_to_prophoto.coeff[1][2]; + cam_prof[24+x] = dcp->camera_to_prophoto.coeff[2][0]; + cam_prof[24+x+4] = dcp->camera_to_prophoto.coeff[2][1]; + cam_prof[24+x+8] = dcp->camera_to_prophoto.coeff[2][2]; + } + gint end_x = image->w - (image->w & 3); for(y = t->start_y ; y < t->end_y; y++) @@ -1134,7 +1159,7 @@ p3f = _mm_cvtepi32_ps(_mm_unpacklo_epi16(p2, zero)); /* Normalize to 0 to 1 range */ - __m128 rgb_div = _mm_set_ps(1.0/65535.0, 1.0/65535.0, 1.0/65535.0, 1.0/65535.0); + __m128 rgb_div = _mm_load_ps(_rgb_div_ps); p1f = _mm_mul_ps(p1f, rgb_div); p2f = _mm_mul_ps(p2f, rgb_div); p3f = _mm_mul_ps(p3f, rgb_div); @@ -1157,13 +1182,13 @@ b = _mm_movelh_ps(b1b0, b3b2); /* Convert to Prophoto */ - r2 = sse_matrix3_mul(r_coeffs, r, g, b); - g2 = sse_matrix3_mul(g_coeffs, r, g, b); - b2 = sse_matrix3_mul(b_coeffs, r, g, b); + r2 = sse_matrix3_mul(cam_prof, r, g, b); + g2 = sse_matrix3_mul(&cam_prof[12], r, g, b); + b2 = sse_matrix3_mul(&cam_prof[24], r, g, b); /* Set min/max before HSV conversion */ - __m128 min_val = _mm_set_ps(1e-15, 1e-15, 1e-15, 1e-15); - __m128 max_val = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + __m128 min_val = _mm_load_ps(_very_small_ps); + __m128 max_val = _mm_load_ps(_ones_ps); r = _mm_max_ps(_mm_min_ps(r2, max_val), min_val); g = _mm_max_ps(_mm_min_ps(g2, max_val), min_val); b = _mm_max_ps(_mm_min_ps(b2, max_val), min_val); @@ -1187,8 +1212,8 @@ /* Hue */ __m128 hue_add = _mm_set_ps(hue, hue, hue, hue); - __m128 six_ps = _mm_set_ps(6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15); - __m128 zero_ps = _mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f); + __m128 six_ps = _mm_load_ps(_six_ps); + __m128 zero_ps = _mm_load_ps(_zero_ps); h = _mm_add_ps(h, hue_add); /* Check if hue > 6 or < 0*/ @@ -1204,7 +1229,7 @@ /* TODO: Use 8 bit fraction as interpolation, for interpolating * a more precise lookup using linear interpolation. Maybe use less than * 16 bits for lookup for speed, 10 bits with interpolation should be enough */ - __m128 v_mul = _mm_set_ps(65535.0, 65535.0, 65535.0, 65535.0); + __m128 v_mul = _mm_load_ps(_16_bit_ps); v = _mm_mul_ps(v, v_mul); __m128i lookup = _mm_cvtps_epi32(v); gfloat* v_p = (gfloat*)&v; @@ -1237,7 +1262,7 @@ /* Convert get the fraction of h * h_fraction = h - (float)(int)h */ - __m128 ones_ps = _mm_set_ps(1.0f, 1.0f, 1.0f, 1.0f); + __m128 ones_ps = _mm_load_ps(_ones_ps); __m128 h_fraction = _mm_sub_ps(h,_mm_cvtepi32_ps(_mm_cvttps_epi32(h))); /* p = v * (1.0f - s) */ @@ -1304,7 +1329,7 @@ b = _mm_or_ps(b, _mm_and_ps(q, m)); - __m128 rgb_mul = _mm_set_ps(65535.0, 65535.0, 65535.0, 65535.0); + __m128 rgb_mul = _mm_load_ps(_16_bit_ps); r = _mm_mul_ps(r, rgb_mul); g = _mm_mul_ps(g, rgb_mul); b = _mm_mul_ps(b, rgb_mul); @@ -1313,8 +1338,8 @@ __m128i g_i = _mm_cvtps_epi32(g); __m128i b_i = _mm_cvtps_epi32(b); - __m128i sub_32 = _mm_set_epi32(32768, 32768, 32768, 32768); - __m128i signxor = _mm_set_epi32(0x80008000, 0x80008000, 0x80008000, 0x80008000); + __m128i sub_32 = _mm_load_si128((__m128i*)_15_bit_epi32); + __m128i signxor = _mm_load_si128((__m128i*)_16_bit_sign); /* Subtract 32768 to avoid saturation */ r_i = _mm_sub_epi32(r_i, sub_32); From anders at brander.dk Mon Oct 12 23:26:47 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 12 Oct 2009 23:26:47 +0200 Subject: [Rawstudio-commit] r2704 - trunk/profiles Message-ID: Author: abrander Date: 2009-10-12 23:26:46 +0200 (Mon, 12 Oct 2009) New Revision: 2704 Modified: trunk/profiles/prophoto.icc Log: Changed Prophoto profile to match DNG's gamma of 1.0. Modified: trunk/profiles/prophoto.icc =================================================================== (Binary files differ) From anders at brander.dk Tue Oct 13 00:59:35 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 13 Oct 2009 00:59:35 +0200 Subject: [Rawstudio-commit] r2705 - in trunk: librawstudio plugins/basic-render plugins/cache plugins/crop plugins/dcp plugins/demosaic plugins/denoise plugins/exposure-mask plugins/input-file plugins/input-image16 plugins/lensfun plugins/meta-tiff plugins/resample plugins/rotate src Message-ID: Author: abrander Date: 2009-10-13 00:59:34 +0200 (Tue, 13 Oct 2009) New Revision: 2705 Added: trunk/librawstudio/rs-filter-request.c trunk/librawstudio/rs-filter-request.h Removed: trunk/librawstudio/rs-filter-param.c trunk/librawstudio/rs-filter-param.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h trunk/librawstudio/rs-filter.c trunk/librawstudio/rs-filter.h trunk/plugins/basic-render/basic-render.c trunk/plugins/cache/cache.c trunk/plugins/crop/crop.c trunk/plugins/dcp/dcp.c trunk/plugins/demosaic/demosaic.c trunk/plugins/denoise/denoise.c trunk/plugins/exposure-mask/exposure-mask.c trunk/plugins/input-file/input-file.c trunk/plugins/input-image16/input-image16.c trunk/plugins/lensfun/lensfun.c trunk/plugins/meta-tiff/tiff-meta.c trunk/plugins/resample/resample.c trunk/plugins/rotate/rotate.c trunk/src/rs-loupe.c trunk/src/rs-preview-widget.c Log: Renamed RSFilterParam to RSFilterRequest. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/librawstudio/Makefile.am 2009-10-12 22:59:34 UTC (rev 2705) @@ -20,7 +20,7 @@ rs-metadata.h \ rs-filetypes.h \ rs-filter.h \ - rs-filter-param.h \ + rs-filter-request.h \ rs-filter-response.h \ rs-output.h \ rs-plugin-manager.h \ @@ -54,7 +54,7 @@ rs-metadata.c rs-metadata.h \ rs-filetypes.c rs-filetypes.h \ rs-filter.c rs-filter.h \ - rs-filter-param.c rs-filter-param.h \ + rs-filter-request.c rs-filter-request.h \ rs-filter-response.c rs-filter-response.h \ rs-output.c rs-output.h \ rs-plugin-manager.c rs-plugin-manager.h \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/librawstudio/rawstudio.h 2009-10-12 22:59:34 UTC (rev 2705) @@ -40,7 +40,7 @@ #include "rs-lens-db.h" #include "rs-filetypes.h" #include "rs-plugin.h" -#include "rs-filter-param.h" +#include "rs-filter-request.h" #include "rs-filter-response.h" #include "rs-filter.h" #include "rs-output.h" Deleted: trunk/librawstudio/rs-filter-param.c =================================================================== --- trunk/librawstudio/rs-filter-param.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/librawstudio/rs-filter-param.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2006-2009 Anders Brander and - * Anders Kvist - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include "rs-filter-param.h" - -struct _RSFilterParam { - GObject parent; - gboolean roi_set; - GdkRectangle roi; - gboolean quick; -}; - -G_DEFINE_TYPE(RSFilterParam, rs_filter_param, G_TYPE_OBJECT) - -static void -rs_filter_param_finalize(GObject *object) -{ - G_OBJECT_CLASS (rs_filter_param_parent_class)->finalize (object); -} - -static void -rs_filter_param_class_init(RSFilterParamClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = rs_filter_param_finalize; -} - -static void -rs_filter_param_init(RSFilterParam *filter_param) -{ - filter_param->roi_set = FALSE; - filter_param->quick = FALSE; -} - -/** - * Instantiate a new RSFilterParam - * @return A new RSFilterParam with a refcount of 1 - */ -RSFilterParam * -rs_filter_param_new(void) -{ - return g_object_new(RS_TYPE_FILTER_PARAM, NULL); -} - -/** - * Clone a RSFilterParam - * @param filter_param A RSFilterParam - * @return A new RSFilterParam with a refcount of 1 with the same settings as - * filter_param - */ -RSFilterParam * -rs_filter_param_clone(const RSFilterParam *filter_param) -{ - RSFilterParam *new_filter_param = rs_filter_param_new(); - - if (RS_IS_FILTER_PARAM(filter_param)) - { - new_filter_param->roi_set = filter_param->roi_set; - new_filter_param->roi = filter_param->roi; - new_filter_param->quick = filter_param->quick; - } - - return new_filter_param; -} - -/** - * Set a region of interest - * @param filter_param A RSFilterParam - * @param roi A GdkRectangle describing the ROI or NULL to disable - */ -void -rs_filter_param_set_roi(RSFilterParam *filter_param, GdkRectangle *roi) -{ - g_assert(RS_IS_FILTER_PARAM(filter_param)); - - filter_param->roi_set = FALSE; - - if (roi) - { - filter_param->roi_set = TRUE; - filter_param->roi = *roi; - } -} - -/** - * Get the region of interest from a RSFilterParam - * @param filter_param A RSFilterParam - * @return A GdkRectangle describing the ROI or NULL if none is set, the - * GdkRectangle belongs to the filter_param and should not be freed - */ -GdkRectangle * -rs_filter_param_get_roi(const RSFilterParam *filter_param) -{ - GdkRectangle *ret = NULL; - - if (RS_IS_FILTER_PARAM(filter_param) && filter_param->roi_set) - ret = &RS_FILTER_PARAM(filter_param)->roi; - - return ret; -} - -/** - * Mark a request as "quick" allowing filters to priotize speed over quality - * @param filter_param A RSFilterParam - * @param quick TRUE to mark a request as QUICK, FALSE to set normal (default) - */ -void rs_filter_param_set_quick(RSFilterParam *filter_param, gboolean quick) -{ - g_assert(RS_IS_FILTER_PARAM(filter_param)); - - filter_param->quick = quick; -} - -/** - * Get quick status of a RSFilterParam - * @param filter_param A RSFilterParam - * @return TRUE if quality should be sacrified for speed, FALSE otherwise - */ -gboolean rs_filter_param_get_quick(const RSFilterParam *filter_param) -{ - gboolean ret = FALSE; - - if (RS_IS_FILTER_PARAM(filter_param)) - ret = filter_param->quick; - - return ret; -} Deleted: trunk/librawstudio/rs-filter-param.h =================================================================== --- trunk/librawstudio/rs-filter-param.h 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/librawstudio/rs-filter-param.h 2009-10-12 22:59:34 UTC (rev 2705) @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2006-2009 Anders Brander and - * Anders Kvist - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef RS_FILTER_PARAM_H -#define RS_FILTER_PARAM_H - -#include - -G_BEGIN_DECLS - -#define RS_TYPE_FILTER_PARAM rs_filter_param_get_type() -#define RS_FILTER_PARAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_FILTER_PARAM, RSFilterParam)) -#define RS_FILTER_PARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_FILTER_PARAM, RSFilterParamClass)) -#define RS_IS_FILTER_PARAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_FILTER_PARAM)) -#define RS_IS_FILTER_PARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_FILTER_PARAM)) -#define RS_FILTER_PARAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_FILTER_PARAM, RSFilterParamClass)) - -typedef struct _RSFilterParam RSFilterParam; - -typedef struct { - GObjectClass parent_class; -} RSFilterParamClass; - -GType rs_filter_param_get_type(void); - -/** - * Instantiate a new RSFilterParam - * @return A new RSFilterParam with a refcount of 1 - */ -RSFilterParam *rs_filter_param_new(void); - -/** - * Clone a RSFilterParam - * @param filter_param A RSFilterParam - * @return A new RSFilterParam with a refcount of 1 with the same settings as - * filter_param - */ -RSFilterParam *rs_filter_param_clone(const RSFilterParam *filter_param); - -/** - * Set a region of interest - * @param filter_param A RSFilterParam - * @param roi A GdkRectangle describing the ROI or NULL to disable - */ -void rs_filter_param_set_roi(RSFilterParam *filter_param, GdkRectangle *roi); - -/** - * Get the region of interest from a RSFilterParam - * @param filter_param A RSFilterParam - * @return A GdkRectangle describing the ROI or NULL if none is set, the - * GdkRectangle belongs to the filter_param and should not be freed - */ -GdkRectangle *rs_filter_param_get_roi(const RSFilterParam *filter_param); - -/** - * Mark a request as "quick" allowing filters to priotize speed over quality - * @param filter_param A RSFilterParam - * @param quick TRUE to mark a request as QUICK, FALSE to set normal (default) - */ -void rs_filter_param_set_quick(RSFilterParam *filter_param, gboolean quick); - -/** - * Get quick status of a RSFilterParam - * @param filter_param A RSFilterParam - * @return TRUE if quality should be sacrified for speed, FALSE otherwise - */ -gboolean rs_filter_param_get_quick(const RSFilterParam *filter_param); - -G_END_DECLS - -#endif /* RS_FILTER_PARAM_H */ Copied: trunk/librawstudio/rs-filter-request.c (from rev 2703, trunk/librawstudio/rs-filter-param.c) =================================================================== --- trunk/librawstudio/rs-filter-request.c (rev 0) +++ trunk/librawstudio/rs-filter-request.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include "rs-filter-request.h" + +struct _RSFilterRequest { + GObject parent; + gboolean roi_set; + GdkRectangle roi; + gboolean quick; +}; + +G_DEFINE_TYPE(RSFilterRequest, rs_filter_request, G_TYPE_OBJECT) + +static void +rs_filter_request_finalize(GObject *object) +{ + G_OBJECT_CLASS (rs_filter_request_parent_class)->finalize (object); +} + +static void +rs_filter_request_class_init(RSFilterRequestClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = rs_filter_request_finalize; +} + +static void +rs_filter_request_init(RSFilterRequest *filter_request) +{ + filter_request->roi_set = FALSE; + filter_request->quick = FALSE; +} + +/** + * Instantiate a new RSFilterRequest + * @return A new RSFilterRequest with a refcount of 1 + */ +RSFilterRequest * +rs_filter_request_new(void) +{ + return g_object_new(RS_TYPE_FILTER_REQUEST, NULL); +} + +/** + * Clone a RSFilterRequest + * @param filter_request A RSFilterRequest + * @return A new RSFilterRequest with a refcount of 1 with the same settings as + * filter_request + */ +RSFilterRequest * +rs_filter_request_clone(const RSFilterRequest *filter_request) +{ + RSFilterRequest *new_filter_request = rs_filter_request_new(); + + if (RS_IS_FILTER_REQUEST(filter_request)) + { + new_filter_request->roi_set = filter_request->roi_set; + new_filter_request->roi = filter_request->roi; + new_filter_request->quick = filter_request->quick; + } + + return new_filter_request; +} + +/** + * Set a region of interest + * @param filter_request A RSFilterRequest + * @param roi A GdkRectangle describing the ROI or NULL to disable + */ +void +rs_filter_request_set_roi(RSFilterRequest *filter_request, GdkRectangle *roi) +{ + g_assert(RS_IS_FILTER_REQUEST(filter_request)); + + filter_request->roi_set = FALSE; + + if (roi) + { + filter_request->roi_set = TRUE; + filter_request->roi = *roi; + } +} + +/** + * Get the region of interest from a RSFilterRequest + * @param filter_request A RSFilterRequest + * @return A GdkRectangle describing the ROI or NULL if none is set, the + * GdkRectangle belongs to the filter_request and should not be freed + */ +GdkRectangle * +rs_filter_request_get_roi(const RSFilterRequest *filter_request) +{ + GdkRectangle *ret = NULL; + + if (RS_IS_FILTER_REQUEST(filter_request) && filter_request->roi_set) + ret = &RS_FILTER_REQUEST(filter_request)->roi; + + return ret; +} + +/** + * Mark a request as "quick" allowing filters to priotize speed over quality + * @param filter_request A RSFilterRequest + * @param quick TRUE to mark a request as QUICK, FALSE to set normal (default) + */ +void rs_filter_request_set_quick(RSFilterRequest *filter_request, gboolean quick) +{ + g_assert(RS_IS_FILTER_REQUEST(filter_request)); + + filter_request->quick = quick; +} + +/** + * Get quick status of a RSFilterRequest + * @param filter_request A RSFilterRequest + * @return TRUE if quality should be sacrified for speed, FALSE otherwise + */ +gboolean rs_filter_request_get_quick(const RSFilterRequest *filter_request) +{ + gboolean ret = FALSE; + + if (RS_IS_FILTER_REQUEST(filter_request)) + ret = filter_request->quick; + + return ret; +} Property changes on: trunk/librawstudio/rs-filter-request.c ___________________________________________________________________ Name: svn:mergeinfo + Copied: trunk/librawstudio/rs-filter-request.h (from rev 2703, trunk/librawstudio/rs-filter-param.h) =================================================================== --- trunk/librawstudio/rs-filter-request.h (rev 0) +++ trunk/librawstudio/rs-filter-request.h 2009-10-12 22:59:34 UTC (rev 2705) @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef RS_FILTER_REQUEST_H +#define RS_FILTER_REQUEST_H + +#include + +G_BEGIN_DECLS + +#define RS_TYPE_FILTER_REQUEST rs_filter_request_get_type() +#define RS_FILTER_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_FILTER_REQUEST, RSFilterRequest)) +#define RS_FILTER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_FILTER_REQUEST, RSFilterRequestClass)) +#define RS_IS_FILTER_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_FILTER_REQUEST)) +#define RS_IS_FILTER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_FILTER_REQUEST)) +#define RS_FILTER_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_FILTER_REQUEST, RSFilterRequestClass)) + +typedef struct _RSFilterRequest RSFilterRequest; + +typedef struct { + GObjectClass parent_class; +} RSFilterRequestClass; + +GType rs_filter_request_get_type(void); + +/** + * Instantiate a new RSFilterRequest + * @return A new RSFilterRequest with a refcount of 1 + */ +RSFilterRequest *rs_filter_request_new(void); + +/** + * Clone a RSFilterRequest + * @param filter_request A RSFilterRequest + * @return A new RSFilterRequest with a refcount of 1 with the same settings as + * filter_request + */ +RSFilterRequest *rs_filter_request_clone(const RSFilterRequest *filter_request); + +/** + * Set a region of interest + * @param filter_request A RSFilterRequest + * @param roi A GdkRectangle describing the ROI or NULL to disable + */ +void rs_filter_request_set_roi(RSFilterRequest *filter_request, GdkRectangle *roi); + +/** + * Get the region of interest from a RSFilterRequest + * @param filter_request A RSFilterRequest + * @return A GdkRectangle describing the ROI or NULL if none is set, the + * GdkRectangle belongs to the filter_request and should not be freed + */ +GdkRectangle *rs_filter_request_get_roi(const RSFilterRequest *filter_request); + +/** + * Mark a request as "quick" allowing filters to priotize speed over quality + * @param filter_request A RSFilterRequest + * @param quick TRUE to mark a request as QUICK, FALSE to set normal (default) + */ +void rs_filter_request_set_quick(RSFilterRequest *filter_request, gboolean quick); + +/** + * Get quick status of a RSFilterRequest + * @param filter_request A RSFilterRequest + * @return TRUE if quality should be sacrified for speed, FALSE otherwise + */ +gboolean rs_filter_request_get_quick(const RSFilterRequest *filter_request); + +G_END_DECLS + +#endif /* RS_FILTER_REQUEST_H */ Property changes on: trunk/librawstudio/rs-filter-request.h ___________________________________________________________________ Name: svn:mergeinfo + Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/librawstudio/rs-filter.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -173,11 +173,11 @@ /** * Get the output image from a RSFilter * @param filter A RSFilter - * @param param A RSFilterParam defining parameters for a image request + * @param param A RSFilterRequest defining parameters for a image request * @return A RS_IMAGE16, this must be unref'ed */ RSFilterResponse * -rs_filter_get_image(RSFilter *filter, const RSFilterParam *param) +rs_filter_get_image(RSFilter *filter, const RSFilterRequest *request) { filter_debug("rs_filter_get_image(%s [%p])", RS_FILTER_NAME(filter), filter); @@ -196,9 +196,9 @@ count++; if (RS_FILTER_GET_CLASS(filter)->get_image && filter->enabled) - response = RS_FILTER_GET_CLASS(filter)->get_image(filter, param); + response = RS_FILTER_GET_CLASS(filter)->get_image(filter, request); else - response = rs_filter_get_image(filter->previous, param); + response = rs_filter_get_image(filter->previous, request); g_assert(RS_IS_FILTER_RESPONSE(response)); @@ -234,11 +234,11 @@ /** * Get 8 bit output image from a RSFilter * @param filter A RSFilter - * @param param A RSFilterParam defining parameters for a image request + * @param param A RSFilterRequest defining parameters for a image request * @return A RS_IMAGE16, this must be unref'ed */ RSFilterResponse * -rs_filter_get_image8(RSFilter *filter, const RSFilterParam *param) +rs_filter_get_image8(RSFilter *filter, const RSFilterRequest *request) { filter_debug("rs_filter_get_image8(%s [%p])", RS_FILTER_NAME(filter), filter); @@ -257,9 +257,9 @@ count++; if (RS_FILTER_GET_CLASS(filter)->get_image8 && filter->enabled) - response = RS_FILTER_GET_CLASS(filter)->get_image8(filter, param); + response = RS_FILTER_GET_CLASS(filter)->get_image8(filter, request); else if (filter->previous) - response = rs_filter_get_image8(filter->previous, param); + response = rs_filter_get_image8(filter->previous, request); g_assert(RS_IS_FILTER_RESPONSE(response)); Modified: trunk/librawstudio/rs-filter.h =================================================================== --- trunk/librawstudio/rs-filter.h 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/librawstudio/rs-filter.h 2009-10-12 22:59:34 UTC (rev 2705) @@ -79,7 +79,7 @@ typedef struct _RSFilter RSFilter; typedef struct _RSFilterClass RSFilterClass; -typedef RSFilterResponse *(*RSFilterFunc)(RSFilter *filter, const RSFilterParam *param); +typedef RSFilterResponse *(*RSFilterFunc)(RSFilter *filter, const RSFilterRequest *request); struct _RSFilter { GObject parent; @@ -131,18 +131,18 @@ /** * Get the output image from a RSFilter * @param filter A RSFilter - * @param param A RSFilterParam defining parameters for a image request + * @param param A RSFilterRequest defining parameters for a image request * @return A RS_IMAGE16, this must be unref'ed */ -extern RSFilterResponse *rs_filter_get_image(RSFilter *filter, const RSFilterParam *param); +extern RSFilterResponse *rs_filter_get_image(RSFilter *filter, const RSFilterRequest *request); /** * Get 8 bit output image from a RSFilter * @param filter A RSFilter - * @param param A RSFilterParam defining parameters for a image request + * @param param A RSFilterRequest defining parameters for a image request * @return A RS_IMAGE16, this must be unref'ed */ -extern RSFilterResponse *rs_filter_get_image8(RSFilter *filter, const RSFilterParam *param); +extern RSFilterResponse *rs_filter_get_image8(RSFilter *filter, const RSFilterRequest *request); /** * Get the ICC profile from a filter Modified: trunk/plugins/basic-render/basic-render.c =================================================================== --- trunk/plugins/basic-render/basic-render.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/basic-render/basic-render.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -125,8 +125,8 @@ static gpointer thread_func_sse8(gpointer _thread_info); static gpointer thread_func_sse8_cms(gpointer _thread_info); #endif /* __i386__ || __x86_64__ */ -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); -static RSFilterResponse *get_image8(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); +static RSFilterResponse *get_image8(RSFilter *filter, const RSFilterRequest *request); static RSIccProfile *get_icc_profile(RSFilter *filter); static RSFilterClass *rs_basic_render_parent_class = NULL; @@ -957,7 +957,7 @@ #endif /* __i386__ || __x86_64__ */ static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSBasicRenderClass *klass = RS_BASIC_RENDER_GET_CLASS(filter); guint i, y_offset, y_per_thread, threaded_h; @@ -968,7 +968,7 @@ RS_IMAGE16 *input; RS_IMAGE16 *output = NULL; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); input = rs_filter_response_get_image(previous_response); if (!RS_IS_IMAGE16(input)) return previous_response; @@ -1018,7 +1018,7 @@ } static RSFilterResponse * -get_image8(RSFilter *filter, const RSFilterParam *param) +get_image8(RSFilter *filter, const RSFilterRequest *request) { RSBasicRenderClass *klass = RS_BASIC_RENDER_GET_CLASS(filter); guint i, x_offset, y_offset, y_per_thread, threaded_h; @@ -1031,7 +1031,7 @@ gint width, height; GdkRectangle *roi; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); input = rs_filter_response_get_image(previous_response); if (!RS_IS_IMAGE16(input)) return previous_response; @@ -1046,7 +1046,7 @@ render_matrix(basic_render); prepare_lcms(basic_render); - if ((roi = rs_filter_param_get_roi(param))) + if ((roi = rs_filter_request_get_roi(request))) { width = MIN(roi->width, input->w); height = MIN(roi->height, input->h); Modified: trunk/plugins/cache/cache.c =================================================================== --- trunk/plugins/cache/cache.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/cache/cache.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -54,8 +54,8 @@ static void finalize(GObject *object); static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); -static RSFilterResponse *get_image8(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); +static RSFilterResponse *get_image8(RSFilter *filter, const RSFilterRequest *request); static void flush(RSCache *cache); static void previous_changed(RSFilter *filter, RSFilter *parent, RSFilterChangedMask mask); @@ -179,14 +179,14 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSCache *cache = RS_CACHE(filter); - GdkRectangle *roi = rs_filter_param_get_roi(param); + GdkRectangle *roi = rs_filter_request_get_roi(request); if (rs_filter_response_has_image(cache->cached_image)) { - if (rs_filter_response_get_quick(cache->cached_image) && !rs_filter_param_get_quick(param)) + if (rs_filter_response_get_quick(cache->cached_image) && !rs_filter_request_get_quick(request)) flush(cache); if (!rs_filter_response_get_roi(cache->cached_image) && roi) @@ -204,9 +204,9 @@ if (!rs_filter_response_has_image(cache->cached_image)) { g_object_unref(cache->cached_image); - cache->cached_image = rs_filter_get_image(filter->previous, param); + cache->cached_image = rs_filter_get_image(filter->previous, request); rs_filter_response_set_roi(cache->cached_image, roi); - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) rs_filter_response_set_quick(cache->cached_image); } @@ -222,14 +222,14 @@ static RSFilterResponse * -get_image8(RSFilter *filter, const RSFilterParam *param) +get_image8(RSFilter *filter, const RSFilterRequest *request) { RSCache *cache = RS_CACHE(filter); - GdkRectangle *roi = rs_filter_param_get_roi(param); + GdkRectangle *roi = rs_filter_request_get_roi(request); if (rs_filter_response_has_image8(cache->cached_image)) { - if (rs_filter_response_get_quick(cache->cached_image) && !rs_filter_param_get_quick(param)) + if (rs_filter_response_get_quick(cache->cached_image) && !rs_filter_request_get_quick(request)) flush(cache); if (!rs_filter_response_get_roi(cache->cached_image) && roi) @@ -247,9 +247,9 @@ if (!rs_filter_response_has_image8(cache->cached_image)) { g_object_unref(cache->cached_image); - cache->cached_image = rs_filter_get_image8(filter->previous, param); + cache->cached_image = rs_filter_get_image8(filter->previous, request); rs_filter_response_set_roi(cache->cached_image, roi); - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) rs_filter_response_set_quick(cache->cached_image); } Modified: trunk/plugins/crop/crop.c =================================================================== --- trunk/plugins/crop/crop.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/crop/crop.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -63,7 +63,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void calc(RSCrop *crop); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static gint get_width(RSFilter *filter); static gint get_height(RSFilter *filter); @@ -250,7 +250,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { g_assert(RS_IS_FILTER(filter)); RSCrop *crop = RS_CROP(filter); @@ -264,7 +264,7 @@ calc(crop); - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); /* Special case for full crop */ if ((crop->width == parent_width) && (crop->height==parent_height)) return previous_response; Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/dcp/dcp.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -101,7 +101,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static void settings_changed(RSSettings *settings, RSSettingsMask mask, RSDcp *dcp); static RS_xy_COORD neutral_to_xy(RSDcp *dcp, const RS_VECTOR3 *neutral); static RS_MATRIX3 find_xyz_to_camera(RSDcp *dcp, const RS_xy_COORD *white_xy, RS_MATRIX3 *forward_matrix); @@ -322,7 +322,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSDcp *dcp = RS_DCP(filter); GdkRectangle *roi; @@ -332,7 +332,7 @@ RS_IMAGE16 *output; RS_IMAGE16 *tmp; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); if (!RS_IS_FILTER(filter->previous)) return previous_response; @@ -348,7 +348,7 @@ rs_filter_response_set_image(response, output); g_object_unref(output); - if ((roi = rs_filter_param_get_roi(param))) + if ((roi = rs_filter_request_get_roi(request))) tmp = rs_image16_new_subframe(output, roi); else tmp = g_object_ref(output); Modified: trunk/plugins/demosaic/demosaic.c =================================================================== --- trunk/plugins/demosaic/demosaic.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/demosaic/demosaic.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -71,7 +71,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static inline int fc_INDI (const unsigned int filters, const int row, const int col); static void border_interpolate_INDI (const ThreadInfo* t, int colors, int border); static void lin_interpolate_INDI(RS_IMAGE16 *image, RS_IMAGE16 *output, const unsigned int filters, const int colors); @@ -163,7 +163,7 @@ (int)(filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3) static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSDemosaic *demosaic = RS_DEMOSAIC(filter); RSFilterResponse *previous_response; @@ -173,7 +173,7 @@ guint filters; RS_DEMOSAIC method; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); input = rs_filter_response_get_image(previous_response); @@ -197,7 +197,7 @@ g_object_unref(output); method = demosaic->method; - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) { method = RS_DEMOSAIC_NONE; rs_filter_response_set_quick(response); Modified: trunk/plugins/denoise/denoise.c =================================================================== --- trunk/plugins/denoise/denoise.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/denoise/denoise.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -58,7 +58,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static void settings_changed(RSSettings *settings, RSSettingsMask mask, RSDenoise *denoise); static RSFilterClass *rs_denoise_parent_class = NULL; @@ -223,7 +223,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSDenoise *denoise = RS_DENOISE(filter); GdkRectangle *roi; @@ -233,7 +233,7 @@ RS_IMAGE16 *output; RS_IMAGE16 *tmp; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); if (!RS_IS_FILTER(filter->previous)) return previous_response; @@ -246,7 +246,7 @@ g_object_unref(previous_response); /* If the request is marked as "quick", bail out, we're slow */ - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) { rs_filter_response_set_image(response, input); rs_filter_response_set_quick(response); @@ -260,7 +260,7 @@ rs_filter_response_set_image(response, output); g_object_unref(output); - if ((roi = rs_filter_param_get_roi(param))) + if ((roi = rs_filter_request_get_roi(request))) tmp = rs_image16_new_subframe(output, roi); else tmp = g_object_ref(output); Modified: trunk/plugins/exposure-mask/exposure-mask.c =================================================================== --- trunk/plugins/exposure-mask/exposure-mask.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/exposure-mask/exposure-mask.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -48,7 +48,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image8(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image8(RSFilter *filter, const RSFilterRequest *request); static RSFilterClass *rs_exposure_mask_parent_class = NULL; @@ -116,7 +116,7 @@ } static RSFilterResponse * -get_image8(RSFilter *filter, const RSFilterParam *param) +get_image8(RSFilter *filter, const RSFilterRequest *request) { RSExposureMask *exposure_mask = RS_EXPOSURE_MASK(filter); RSFilterResponse *previous_response; @@ -129,7 +129,7 @@ guchar *out_pixel; gint channels; - previous_response = rs_filter_get_image8(filter->previous, param); + previous_response = rs_filter_get_image8(filter->previous, request); input = rs_filter_response_get_image8(previous_response); response = rs_filter_response_clone(previous_response); g_object_unref(previous_response); Modified: trunk/plugins/input-file/input-file.c =================================================================== --- trunk/plugins/input-file/input-file.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/input-file/input-file.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -47,7 +47,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static gint get_width(RSFilter *filter); static gint get_height(RSFilter *filter); @@ -125,7 +125,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSFilterResponse *response = rs_filter_response_new(); RSInputFile *input = RS_INPUT_FILE(filter); Modified: trunk/plugins/input-image16/input-image16.c =================================================================== --- trunk/plugins/input-image16/input-image16.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/input-image16/input-image16.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -53,7 +53,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static RSIccProfile *get_icc_profile(RSFilter *filter); static void dispose (GObject *object); static gint get_width(RSFilter *filter); @@ -176,7 +176,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSFilterResponse *response = rs_filter_response_new(); RSInputImage16 *input_image16 = RS_INPUT_IMAGE16(filter); Modified: trunk/plugins/lensfun/lensfun.c =================================================================== --- trunk/plugins/lensfun/lensfun.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/lensfun/lensfun.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -61,7 +61,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static void inline rs_image16_nearest_full(RS_IMAGE16 *in, gushort *out, gfloat *pos); static void inline rs_image16_bilinear_full(RS_IMAGE16 *in, gushort *out, gfloat *pos); @@ -239,7 +239,7 @@ static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSLensfun *lensfun = RS_LENSFUN(filter); RSFilterResponse *previous_response; @@ -249,12 +249,12 @@ const gchar *make = NULL; const gchar *model = NULL; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); input = rs_filter_response_get_image(previous_response); response = rs_filter_response_clone(previous_response); g_object_unref(previous_response); - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) { rs_filter_response_set_quick(response); if (input) Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -1430,13 +1430,13 @@ RSFilter *finput = rs_filter_new("RSInputFile", NULL); RSFilter *fdemosaic = rs_filter_new("RSDemosaic", finput); - RSFilterParam *param = rs_filter_param_new(); + RSFilterRequest *request = rs_filter_request_new(); g_object_set(finput, "filename", service, NULL); - rs_filter_param_set_roi(param, FALSE); - rs_filter_param_set_quick(param, TRUE); + rs_filter_request_set_roi(request, FALSE); + rs_filter_request_set_quick(request, TRUE); - RSFilterResponse *response = rs_filter_get_image(fdemosaic, param); + RSFilterResponse *response = rs_filter_get_image(fdemosaic, request); if (rs_filter_response_has_image(response)) { @@ -1447,21 +1447,21 @@ image_raw = rs_filter_response_get_image(response); /* Scale down for higher speed */ - g_object_unref(param); + g_object_unref(request); g_object_unref(finput); g_object_unref(response); - param = rs_filter_param_new(); + request = rs_filter_request_new(); finput = rs_filter_new("RSInputImage16", NULL); RSFilter *fresample = rs_filter_new("RSResample", finput); g_object_set(finput, "image", image_raw, "filename", service, NULL); - rs_filter_param_set_roi(param, FALSE); - rs_filter_param_set_quick(param, TRUE); + rs_filter_request_set_roi(request, FALSE); + rs_filter_request_set_quick(request, TRUE); g_object_set(fresample, "width", image_raw->w/8, "height", image_raw->h/8, NULL); /* Request the scaled image */ - response = rs_filter_get_image(fresample, param); + response = rs_filter_get_image(fresample, request); image_raw_scaled = rs_filter_response_get_image(response); /* Transform image */ @@ -1486,7 +1486,7 @@ g_object_unref(rct); } - g_object_unref(param); + g_object_unref(request); g_object_unref(response); g_object_unref(finput); g_object_unref(fdemosaic); Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/resample/resample.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -77,7 +77,7 @@ static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void previous_changed(RSFilter *filter, RSFilter *parent, RSFilterChangedMask mask); static RSFilterChangedMask recalculate_dimensions(RSResample *resample); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static gint get_width(RSFilter *filter); static gint get_height(RSFilter *filter); static void ResizeH(ResampleInfo *info); @@ -277,7 +277,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { gboolean use_fast = FALSE; RSResample *resample = RS_RESAMPLE(filter); @@ -290,15 +290,15 @@ gint input_height = rs_filter_get_height(filter->previous); /* Remove ROI, it doesn't make sense across resampler */ - if (rs_filter_param_get_roi(param)) + if (rs_filter_request_get_roi(request)) { - RSFilterParam *new_param = rs_filter_param_clone(param); - rs_filter_param_set_roi(new_param, NULL); - previous_response = rs_filter_get_image(filter->previous, new_param); - g_object_unref(new_param); + RSFilterRequest *new_request = rs_filter_request_clone(request); + rs_filter_request_set_roi(new_request, NULL); + previous_response = rs_filter_get_image(filter->previous, new_request); + g_object_unref(new_request); } else - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); /* Return the input, if the new size is uninitialized */ if ((resample->new_width == -1) || (resample->new_height == -1)) @@ -319,7 +319,7 @@ /* Use compatible (and slow) version if input isn't 3 channels and pixelsize 4 */ gboolean use_compatible = ( ! ( input->pixelsize == 4 && input->channels == 3)); - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) { use_fast = TRUE; rs_filter_response_set_quick(response); Modified: trunk/plugins/rotate/rotate.c =================================================================== --- trunk/plugins/rotate/rotate.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/plugins/rotate/rotate.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -70,7 +70,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static void previous_changed(RSFilter *filter, RSFilter *parent, RSFilterChangedMask mask); -static RSFilterResponse *get_image(RSFilter *filter, const RSFilterParam *param); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static void turn_right_angle(RS_IMAGE16 *in, RS_IMAGE16 *out, gint start_y, gint end_y, const int direction); static gint get_width(RSFilter *filter); static gint get_height(RSFilter *filter); @@ -188,7 +188,7 @@ } static RSFilterResponse * -get_image(RSFilter *filter, const RSFilterParam *param) +get_image(RSFilter *filter, const RSFilterRequest *request) { RSRotate *rotate = RS_ROTATE(filter); RSFilterResponse *previous_response; @@ -197,7 +197,7 @@ RS_IMAGE16 *output = NULL; gboolean use_fast = FALSE; - previous_response = rs_filter_get_image(filter->previous, param); + previous_response = rs_filter_get_image(filter->previous, request); if ((rotate->angle < 0.001) && (rotate->orientation==0)) return previous_response; @@ -224,7 +224,7 @@ recalculate(rotate); } - if (rs_filter_param_get_quick(param)) + if (rs_filter_request_get_quick(request)) { use_fast = TRUE; rs_filter_response_set_quick(response); Modified: trunk/src/rs-loupe.c =================================================================== --- trunk/src/rs-loupe.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/src/rs-loupe.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -232,23 +232,23 @@ gtk_window_get_size(GTK_WINDOW(loupe), &window_width, &window_height); /* Create request ROI */ - RSFilterParam *param = rs_filter_param_new(); - GdkRectangle request; - request.x = CLAMP(loupe->center_x - window_width/2, 0, width-window_width-1); - request.y = CLAMP(loupe->center_y - window_height/2, 0, height-window_height-1); - request.width = window_width; - request.height = window_height; - rs_filter_param_set_roi(param, &request); + RSFilterRequest *request = rs_filter_request_new(); + GdkRectangle roi; + roi.x = CLAMP(loupe->center_x - window_width/2, 0, width-window_width-1); + roi.y = CLAMP(loupe->center_y - window_height/2, 0, height-window_height-1); + roi.width = window_width; + roi.height = window_height; + rs_filter_request_set_roi(request, &roi); - RSFilterResponse *response = rs_filter_get_image8(loupe->filter, param); + RSFilterResponse *response = rs_filter_get_image8(loupe->filter, request); GdkPixbuf *buffer = rs_filter_response_get_image8(response); g_object_unref(response); - g_object_unref(param); + g_object_unref(request); - add_border(loupe, buffer, &request); + add_border(loupe, buffer, &roi); - gdk_draw_pixbuf(drawable, gc, buffer, request.x, request.y, 0, 0, request.width, request.height, GDK_RGB_DITHER_NONE, 0, 0); + gdk_draw_pixbuf(drawable, gc, buffer, roi.x, roi.y, 0, 0, roi.width, roi.height, GDK_RGB_DITHER_NONE, 0, 0); g_object_unref(buffer); g_object_unref(gc); Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-10-12 21:26:46 UTC (rev 2704) +++ trunk/src/rs-preview-widget.c 2009-10-12 22:59:34 UTC (rev 2705) @@ -152,7 +152,7 @@ RSFilter *filter_cache3[MAX_VIEWS]; RSFilter *filter_end[MAX_VIEWS]; /* For convenience */ - RSFilterParam *param[MAX_VIEWS]; + RSFilterRequest *request[MAX_VIEWS]; GdkRectangle *last_roi[MAX_VIEWS]; RS_PHOTO *photo; void *transform; @@ -345,7 +345,7 @@ g_object_set(preview->filter_resample[i], "bounding-box", TRUE, NULL); g_object_set(preview->filter_cache3[i], "latency", 1, NULL); - preview->param[i] = rs_filter_param_new(); + preview->request[i] = rs_filter_request_new(); #if MAX_VIEWS > 3 #error Fix line below #endif @@ -584,7 +584,7 @@ for(view=0;viewparam[view], TRUE); + rs_filter_request_set_quick(preview->request[view], TRUE); g_object_set(preview->filter_render[view], "settings", preview->photo->settings[preview->snapshot[view]], NULL); g_object_set(preview->filter_denoise[view], "settings", preview->photo->settings[preview->snapshot[view]], NULL); } @@ -902,7 +902,7 @@ return; /* FIXME: Check all views.*/ - if (rs_filter_param_get_quick(preview->param[0]) && !preview->keep_quick_enabled) + if (rs_filter_request_get_quick(preview->request[0]) && !preview->keep_quick_enabled) full_redraw = TRUE; if (full_redraw) @@ -1117,7 +1117,7 @@ preview->keep_quick_enabled = keep_quick; for(i=0;iparam[i], TRUE); + rs_filter_request_set_quick(preview->request[i], TRUE); } @@ -1373,12 +1373,12 @@ preview->last_roi[i] = g_new(GdkRectangle, 1); *preview->last_roi[i] = roi; - rs_filter_param_set_roi(preview->param[i], &roi); + rs_filter_request_set_roi(preview->request[i], &roi); /* Clone, now so it cannot change while filters are being called */ - RSFilterParam *new_param = rs_filter_param_clone(preview->param[i]); + RSFilterRequest *new_request = rs_filter_request_clone(preview->request[i]); - RSFilterResponse *response = rs_filter_get_image8(preview->filter_end[i], new_param); + RSFilterResponse *response = rs_filter_get_image8(preview->filter_end[i], new_request); GdkPixbuf *buffer = rs_filter_response_get_image8(response); if (buffer) @@ -1396,12 +1396,12 @@ g_object_unref(buffer); } - if(rs_filter_param_get_quick(new_param) && !preview->keep_quick_enabled) + if(rs_filter_request_get_quick(new_request) && !preview->keep_quick_enabled) { - rs_filter_param_set_quick(preview->param[i], FALSE); + rs_filter_request_set_quick(preview->request[i], FALSE); gdk_window_invalidate_rect(window, &area, FALSE); } - g_object_unref(new_param); + g_object_unref(new_request); g_object_unref(response); } @@ -2432,11 +2432,11 @@ if (!preview->last_roi[view]) return FALSE; - RSFilterResponse *response = rs_filter_get_image(preview->filter_cache1[view], preview->param[view]); + RSFilterResponse *response = rs_filter_get_image(preview->filter_cache1[view], preview->request[view]); RS_IMAGE16 *image = rs_filter_response_get_image(response); g_object_unref(response); - response = rs_filter_get_image8(preview->filter_end[view], preview->param[view]); + response = rs_filter_get_image8(preview->filter_end[view], preview->request[view]); GdkPixbuf *buffer = rs_filter_response_get_image8(response); g_object_unref(response); From anders at brander.dk Tue Oct 13 02:47:36 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 13 Oct 2009 02:47:36 +0200 Subject: [Rawstudio-commit] r2706 - trunk/src Message-ID: Author: abrander Date: 2009-10-13 02:47:36 +0200 (Tue, 13 Oct 2009) New Revision: 2706 Modified: trunk/src/rs-loupe.c Log: Draw border using GDK primitive in redraw(). Modified: trunk/src/rs-loupe.c =================================================================== --- trunk/src/rs-loupe.c 2009-10-12 22:59:34 UTC (rev 2705) +++ trunk/src/rs-loupe.c 2009-10-13 00:47:36 UTC (rev 2706) @@ -24,7 +24,6 @@ static gboolean expose(GtkWidget *widget, GdkEventExpose *event, RSLoupe *loupe); static void move(RSLoupe *loupe); -static void add_border(RSLoupe *loupe, GdkPixbuf *buffer, GdkRectangle *request); static void redraw(RSLoupe *loupe); static void @@ -189,30 +188,6 @@ } static void -add_border(RSLoupe *loupe, GdkPixbuf *buffer, GdkRectangle *request) -{ - guchar *img = gdk_pixbuf_get_pixels(buffer); - gint rs = gdk_pixbuf_get_rowstride (buffer); - gint ch = gdk_pixbuf_get_n_channels (buffer); - - gint i; - img = &img[request->x*ch+request->y*rs]; - guchar* img2 = &img[rs*(request->height-1)]; - for (i = 0; i < request->width*ch; i++) - { - img[i] = 0; - img2[i] = 0; - } - - img2 = &img[(request->width-1)*ch]; - for (i = 1; i < request->height; i++) - { - img[i*rs] =img[i*rs+1] = img[i*rs+2] = 0; - img2[i*rs] = img2[i*rs+1] = img2[i*rs+2] = 0; - } -} - -static void redraw(RSLoupe *loupe) { if (!loupe->filter) @@ -246,10 +221,13 @@ g_object_unref(request); - add_border(loupe, buffer, &roi); - gdk_draw_pixbuf(drawable, gc, buffer, roi.x, roi.y, 0, 0, roi.width, roi.height, GDK_RGB_DITHER_NONE, 0, 0); + /* Draw border */ + static const GdkColor black = {0,0,0,0}; + gdk_gc_set_foreground(gc, &black); + gdk_draw_rectangle(drawable, gc, FALSE, 0, 0, roi.width-1, roi.height-1); + g_object_unref(buffer); g_object_unref(gc); } From klauspost at gmail.com Tue Oct 13 12:45:50 2009 From: klauspost at gmail.com (Klaus Post) Date: Tue, 13 Oct 2009 12:45:50 +0200 Subject: [Rawstudio-commit] r2707 - trunk/plugins/resample Message-ID: Author: post Date: 2009-10-13 12:45:50 +0200 (Tue, 13 Oct 2009) New Revision: 2707 Modified: trunk/plugins/resample/resample.c Log: Resampler: Don't add fraction, since SSE2 conversion does this automatically. Move constants out out loop. Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-10-13 00:47:36 UTC (rev 2706) +++ trunk/plugins/resample/resample.c 2009-10-13 10:45:50 UTC (rev 2707) @@ -737,12 +737,13 @@ /* 24 pixels = 48 bytes/loop */ gint end_x_sse = (end_x/24)*24; - /* Rounder after accumulation, half because input is scaled down */ - gint add_round_sub = (FPScale >> 2); /* Subtract 32768 as it would appear after shift */ - add_round_sub -= (32768 << (FPScaleShift-1)); + gint add_round_sub = (32768 << (FPScaleShift-1)); /* 0.5 pixel value is lost to rounding times fir_filter_size, compensate */ add_round_sub += fir_filter_size * (FPScale >> 2); + + __m128i add_32 = _mm_set_epi32(add_round_sub, add_round_sub, add_round_sub, add_round_sub); + __m128i signxor = _mm_set_epi32(0x80008000, 0x80008000, 0x80008000, 0x80008000); for (y = 0; y < new_size ; y++) { @@ -802,8 +803,6 @@ acc2 = _mm_add_epi32(acc2, src2i); acc3 = _mm_add_epi32(acc3, src3i); } - __m128i add_32 = _mm_set_epi32(add_round_sub, add_round_sub, add_round_sub, add_round_sub); - __m128i signxor = _mm_set_epi32(0x80008000, 0x80008000, 0x80008000, 0x80008000); /* Add rounder and subtract 32768 */ acc1_h = _mm_add_epi32(acc1_h, add_32); From klauspost at gmail.com Tue Oct 13 17:57:51 2009 From: klauspost at gmail.com (Klaus Post) Date: Tue, 13 Oct 2009 17:57:51 +0200 Subject: [Rawstudio-commit] r2708 - trunk/plugins/resample Message-ID: Author: post Date: 2009-10-13 17:57:51 +0200 (Tue, 13 Oct 2009) New Revision: 2708 Modified: trunk/plugins/resample/resample.c Log: Resampler Broken: Subtraction was addition, since a '-' was left out. Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-10-13 10:45:50 UTC (rev 2707) +++ trunk/plugins/resample/resample.c 2009-10-13 15:57:51 UTC (rev 2708) @@ -738,7 +738,7 @@ gint end_x_sse = (end_x/24)*24; /* Subtract 32768 as it would appear after shift */ - gint add_round_sub = (32768 << (FPScaleShift-1)); + gint add_round_sub = -(32768 << (FPScaleShift-1)); /* 0.5 pixel value is lost to rounding times fir_filter_size, compensate */ add_round_sub += fir_filter_size * (FPScale >> 2); From klauspost at gmail.com Tue Oct 13 18:00:09 2009 From: klauspost at gmail.com (Klaus Post) Date: Tue, 13 Oct 2009 18:00:09 +0200 Subject: [Rawstudio-commit] r2709 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-13 18:00:09 +0200 (Tue, 13 Oct 2009) New Revision: 2709 Modified: trunk/plugins/dcp/dcp.c Log: DCP-renderer: Moved table constant calculation out of pixel loop, and load all values in one go. Moved hue+sat+exposure constants out of loop. Overall 5-10% speedup. Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-13 15:57:51 UTC (rev 2708) +++ trunk/plugins/dcp/dcp.c 2009-10-13 16:00:09 UTC (rev 2709) @@ -34,6 +34,22 @@ typedef struct _RSDcp RSDcp; typedef struct _RSDcpClass RSDcpClass; +#if defined (__SSE2__) + +typedef struct { + //Precalc: + gfloat hScale[4] __attribute__ ((aligned (16))); + gfloat sScale[4] __attribute__ ((aligned (16))); + gfloat vScale[4] __attribute__ ((aligned (16))); + gint maxHueIndex0[4] __attribute__ ((aligned (16))); + gint maxSatIndex0[4] __attribute__ ((aligned (16))); + gint maxValIndex0[4] __attribute__ ((aligned (16))); + gint hueStep[4] __attribute__ ((aligned (16))); + gint valStep[4] __attribute__ ((aligned (16))); +} PrecalcHSM; + +#endif // defined (__SSE2__) + struct _RSDcp { RSFilter parent; @@ -73,6 +89,11 @@ RS_VECTOR3 camera_white; RS_MATRIX3 camera_to_prophoto; + +#if defined (__SSE2__) + PrecalcHSM huesatmap_precalc; + PrecalcHSM looktable_precalc; +#endif // defined (__SSE2__) }; struct _RSDcpClass { @@ -110,6 +131,7 @@ static void render(ThreadInfo* t); #if defined (__SSE2__) static void render_SSE2(ThreadInfo* t); +static void calc_hsm_constants(const RSHuesatMap *map, PrecalcHSM* table); #endif static void read_profile(RSDcp *dcp, RSDcpFile *dcp_file); static RSIccProfile *get_icc_profile(RSFilter *filter); @@ -741,11 +763,30 @@ /* SSE2 implementation, matches the reference implementation pretty closely */ + +static void +calc_hsm_constants(const RSHuesatMap *map, PrecalcHSM* table) +{ + g_assert(RS_IS_HUESAT_MAP(map)); + int i; + for (i = 0; i < 4; i++) + { + table->hScale[i] = (map->hue_divisions < 2) ? 0.0f : (map->hue_divisions * (1.0f / 6.0f)); + table->sScale[i] = (gfloat) (map->sat_divisions - 1); + table->vScale[i] = (gfloat) (map->val_divisions - 1); + table->maxHueIndex0[i] = map->hue_divisions - 1; + table->maxSatIndex0[i] = map->sat_divisions - 2; + table->maxValIndex0[i] = map->val_divisions - 2; + table->hueStep[i] = map->sat_divisions; + table->valStep[i] = map->hue_divisions * map->sat_divisions; + } +} + static gfloat _mul_hue_ps[4] __attribute__ ((aligned (16))) = {6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f, 6.0f / 360.0f}; static gint _ones_epi32[4] __attribute__ ((aligned (16))) = {1,1,1,1}; static void -huesat_map_SSE2(RSHuesatMap *map, __m128 *_h, __m128 *_s, __m128 *_v) +huesat_map_SSE2(RSHuesatMap *map, const PrecalcHSM* precalc, __m128 *_h, __m128 *_s, __m128 *_v) { g_assert(RS_IS_HUESAT_MAP(map)); @@ -756,31 +797,19 @@ gint xfer_0[4] __attribute__ ((aligned (16))); gint xfer_1[4] __attribute__ ((aligned (16))); - //TODO: Precalc BEGIN - gfloat hScale = (map->hue_divisions < 2) ? 0.0f : (map->hue_divisions * (1.0f / 6.0f)); - gfloat sScale = (gfloat) (map->sat_divisions - 1); - gfloat vScale = (gfloat) (map->val_divisions - 1); - // END precalc this. - - gint _maxHueIndex0 = map->hue_divisions - 1; - gint _maxSatIndex0 = map->sat_divisions - 2; - gint _maxValIndex0 = map->val_divisions - 2; - const RS_VECTOR3 *tableBase = map->deltas; - gint _valStep = map->hue_divisions * map->sat_divisions; - __m128 hueShift; __m128 satScale; __m128 valScale; if (map->val_divisions < 2) { - __m128 hScaled = _mm_mul_ps(h, _mm_set_ps( hScale, hScale, hScale, hScale)); - __m128 sScaled = _mm_mul_ps(s, _mm_set_ps( sScale, sScale, sScale, sScale)); + __m128 hScaled = _mm_mul_ps(h, _mm_load_ps(precalc->hScale)); + __m128 sScaled = _mm_mul_ps(s, _mm_load_ps(precalc->sScale)); - __m128i maxHueIndex0 = _mm_set_epi32(_maxHueIndex0, _maxHueIndex0, _maxHueIndex0, _maxHueIndex0); - __m128i maxSatIndex0 = _mm_set_epi32(_maxSatIndex0, _maxSatIndex0, _maxSatIndex0, _maxSatIndex0); + __m128i maxHueIndex0 = _mm_load_si128((__m128i*)precalc->maxHueIndex0); + __m128i maxSatIndex0 = _mm_load_si128((__m128i*)precalc->maxSatIndex0); __m128i hIndex0 = _mm_cvttps_epi32( hScaled ); __m128i sIndex0 = _mm_cvttps_epi32( sScaled ); @@ -802,7 +831,7 @@ __m128 hFract0 = _mm_sub_ps(ones_ps, hFract1); __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); - __m128i hueStep = _mm_set_epi32(map->sat_divisions, map->sat_divisions, map->sat_divisions, map->sat_divisions); + __m128i hueStep = _mm_load_si128((__m128i*)precalc->hueStep); __m128i table_offsets = _mm_add_epi32(sIndex0, _mm_mullo_epi16(hIndex0, hueStep)); __m128i next_offsets = _mm_add_epi32(sIndex0, _mm_mullo_epi16(hIndex1, hueStep)); @@ -827,7 +856,6 @@ __m128 valScale0 = _mm_add_ps(_mm_mul_ps(vs0, hFract0), _mm_mul_ps(vs1, hFract1)); valScale0 = _mm_mul_ps(valScale0, sFract0); - for (i = 0; i < 4; i++) { entry00[i]++; entry01[i]++; @@ -851,13 +879,14 @@ } else { - __m128 hScaled = _mm_mul_ps(h, _mm_set_ps( hScale, hScale, hScale, hScale)); - __m128 sScaled = _mm_mul_ps(s, _mm_set_ps( sScale, sScale, sScale, sScale)); - __m128 vScaled = _mm_mul_ps(v, _mm_set_ps( vScale, vScale, vScale, vScale)); + __m128 hScaled = _mm_mul_ps(h, _mm_load_ps(precalc->hScale)); + __m128 sScaled = _mm_mul_ps(s, _mm_load_ps(precalc->sScale)); + __m128 vScaled = _mm_mul_ps(v, _mm_load_ps(precalc->vScale)); - __m128i maxHueIndex0 = _mm_set_epi32(_maxHueIndex0, _maxHueIndex0, _maxHueIndex0, _maxHueIndex0); - __m128i maxSatIndex0 = _mm_set_epi32(_maxSatIndex0, _maxSatIndex0, _maxSatIndex0, _maxSatIndex0); - __m128i maxValIndex0 = _mm_set_epi32(_maxValIndex0, _maxValIndex0, _maxValIndex0, _maxValIndex0); + __m128i maxHueIndex0 = _mm_load_si128((__m128i*)precalc->maxHueIndex0); + __m128i maxSatIndex0 = _mm_load_si128((__m128i*)precalc->maxSatIndex0); + __m128i maxValIndex0 = _mm_load_si128((__m128i*)precalc->maxValIndex0); + __m128i hIndex0 = _mm_cvttps_epi32(hScaled); __m128i sIndex0 = _mm_cvttps_epi32(sScaled); __m128i vIndex0 = _mm_cvttps_epi32(vScaled); @@ -865,7 +894,7 @@ // Requires that maxSatIndex0 and sIndex0 can be contained within a 16 bit signed word. sIndex0 = _mm_min_epi16(sIndex0, maxSatIndex0); vIndex0 = _mm_min_epi16(vIndex0, maxValIndex0); - __m128i ones_epi32 = _mm_set_epi32(1,1,1,1); + __m128i ones_epi32 = _mm_load_si128((__m128i*)_ones_epi32); __m128i hIndex1 = _mm_add_epi32(hIndex0, ones_epi32); /* if (hIndex0 > (maxHueIndex0 - 1)) */ @@ -886,8 +915,8 @@ __m128 sFract0 = _mm_sub_ps(ones_ps, sFract1); __m128 vFract0 = _mm_sub_ps(ones_ps, vFract1); - __m128i hueStep = _mm_set_epi32(map->sat_divisions, map->sat_divisions, map->sat_divisions, map->sat_divisions); - __m128i valStep = _mm_set_epi32(_valStep, _valStep, _valStep, _valStep); + __m128i hueStep = _mm_load_si128((__m128i*)precalc->hueStep); + __m128i valStep = _mm_load_si128((__m128i*)precalc->valStep); // This requires that hueStep and valStep can be contained in a 16 bit signed integer. __m128i table_offsets = _mm_add_epi32(sIndex0, _mm_mullo_epi16(vIndex0, valStep)); @@ -898,7 +927,8 @@ // TODO: This will result in a store->load forward size mismatch penalty, if possible, avoid. _mm_store_si128((__m128i*)xfer_0, table_offsets); _mm_store_si128((__m128i*)xfer_1, next_offsets); - + gint _valStep = precalc->valStep[0]; + const RS_VECTOR3 *entry00[4] = { tableBase + xfer_0[0], tableBase + xfer_0[1], tableBase + xfer_0[2], tableBase + xfer_0[3]}; const RS_VECTOR3 *entry01[4] = { tableBase + xfer_1[0], tableBase + xfer_1[1], tableBase + xfer_1[2], tableBase + xfer_1[3]}; const RS_VECTOR3 *entry10[4] = { entry00[0] + _valStep, entry00[1] + _valStep, entry00[2] + _valStep, entry00[3] + _valStep}; @@ -1122,8 +1152,9 @@ int xfer[4] __attribute__ ((aligned (16))); const gfloat exposure_comp = pow(2.0, dcp->exposure); - const gfloat saturation = dcp->saturation; - const gfloat hue = dcp->hue; + __m128 exp = _mm_set_ps(exposure_comp, exposure_comp, exposure_comp, exposure_comp); + __m128 hue_add = _mm_set_ps(dcp->hue, dcp->hue, dcp->hue, dcp->hue); + __m128 sat = _mm_set_ps(dcp->saturation, dcp->saturation, dcp->saturation, dcp->saturation); float cam_prof[4*4*3] __attribute__ ((aligned (16))); for (x = 0; x < 4; x++ ) { @@ -1198,20 +1229,17 @@ if (dcp->huesatmap) { - huesat_map_SSE2(dcp->huesatmap, &h, &s, &v); + huesat_map_SSE2(dcp->huesatmap, &dcp->huesatmap_precalc, &h, &s, &v); } /* Exposure */ - __m128 exp = _mm_set_ps(exposure_comp, exposure_comp, exposure_comp, exposure_comp); v = _mm_min_ps(max_val, _mm_mul_ps(v, exp)); /* Saturation */ - __m128 sat = _mm_set_ps(saturation, saturation, saturation, saturation); s = _mm_min_ps(max_val, _mm_mul_ps(s, sat)); /* Hue */ - __m128 hue_add = _mm_set_ps(hue, hue, hue, hue); __m128 six_ps = _mm_load_ps(_six_ps); __m128 zero_ps = _mm_load_ps(_zero_ps); h = _mm_add_ps(h, hue_add); @@ -1240,14 +1268,12 @@ v_p[2] = dcp->curve_samples[xfer[2]]; v_p[3] = dcp->curve_samples[xfer[3]]; - + /* Apply looktable */ if (dcp->looktable) { - huesat_map_SSE2(dcp->looktable, &h, &s, &v); + huesat_map_SSE2(dcp->looktable, &dcp->looktable_precalc, &h, &s, &v); } - /* Back to RGB */ - /* ensure that hue is within range */ h_mask_gt = _mm_cmpgt_ps(h, six_ps); h_mask_lt = _mm_cmplt_ps(h, zero_ps); @@ -1549,6 +1575,13 @@ /* Camera to ProPhoto */ matrix3_multiply(&xyz_to_prophoto, &dcp->camera_to_pcs, &dcp->camera_to_prophoto); /* verified by SDK */ +#if defined (__SSE2__) + if (dcp->huesatmap) + calc_hsm_constants(dcp->huesatmap, &dcp->huesatmap_precalc); + if (dcp->looktable) + calc_hsm_constants(dcp->looktable, &dcp->looktable_precalc); +#endif + } static void From anders at brander.dk Wed Oct 14 00:43:19 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 14 Oct 2009 00:43:19 +0200 Subject: [Rawstudio-commit] r2710 - in trunk: plugins/denoise src Message-ID: Author: abrander Date: 2009-10-14 00:43:18 +0200 (Wed, 14 Oct 2009) New Revision: 2710 Modified: trunk/plugins/denoise/denoise.c trunk/src/application.c trunk/src/rs-batch.c trunk/src/rs-preview-widget.c trunk/src/rs-save-dialog.c Log: Made RSDenoise properly aware of RSSettings. Modified: trunk/plugins/denoise/denoise.c =================================================================== --- trunk/plugins/denoise/denoise.c 2009-10-13 16:00:09 UTC (rev 2709) +++ trunk/plugins/denoise/denoise.c 2009-10-13 22:43:18 UTC (rev 2710) @@ -35,6 +35,9 @@ struct _RSDenoise { RSFilter parent; + RSSettings *settings; + gulong settings_signal_id; + FFTDenoiseInfo info; gint sharpen; gint denoise_luma; @@ -58,6 +61,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +static void settings_weak_notify(gpointer data, GObject *where_the_object_was); static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static void settings_changed(RSSettings *settings, RSSettingsMask mask, RSDenoise *denoise); @@ -81,31 +85,6 @@ object_class->set_property = set_property; g_object_class_install_property(object_class, - PROP_SHARPEN, g_param_spec_int ( - "sharpen", - _("Sharpen Amount"), - _("How much image will be sharpened"), - 0, 100, 0, - G_PARAM_READWRITE) - ); - g_object_class_install_property(object_class, - PROP_DENOISE_LUMA, g_param_spec_int ( - "denoise_luma", - _("Denoise"), - "FIXME", - 0, 100, 0, - G_PARAM_READWRITE) - ); - g_object_class_install_property(object_class, - PROP_DENOISE_CHROMA, g_param_spec_int ( - "denoise_chroma", - _("Color denoise"), - "FIXME", - 0, 100, 0, - G_PARAM_READWRITE) - ); - - g_object_class_install_property(object_class, PROP_SETTINGS, g_param_spec_object( "settings", "Settings", "Settings to render from", RS_TYPE_SETTINGS, G_PARAM_READWRITE) @@ -143,6 +122,28 @@ } } + if (mask & (MASK_SHARPEN|MASK_DENOISE_LUMA|MASK_DENOISE_CHROMA)) + { + const gfloat sharpen; + const gfloat denoise_luma; + const gfloat denoise_chroma; + + g_object_get(settings, + "sharpen", &sharpen, + "denoise_luma", &denoise_luma, + "denoise_chroma", &denoise_chroma, + NULL); + if (ABS(((gint) sharpen) - denoise->sharpen) > 0 + || ABS(((gint) denoise_luma) - denoise->denoise_luma) > 0 + || ABS(((gint) denoise_chroma) - denoise->denoise_chroma) > 0) + { + changed = TRUE; + denoise->sharpen = (gint) sharpen; + denoise->denoise_luma = (gint) denoise_luma; + denoise->denoise_chroma = (gint) denoise_chroma; + } + } + if (changed) rs_filter_changed(RS_FILTER(denoise), RS_FILTER_CHANGED_PIXELDATA); } @@ -186,42 +187,30 @@ set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { RSDenoise *denoise = RS_DENOISE(object); - RSFilter *filter = RS_FILTER(denoise); - RSSettings *settings; switch (property_id) { - case PROP_SHARPEN: - if ((denoise->sharpen-g_value_get_int(value)) != 0) - { - denoise->sharpen = g_value_get_int(value); - rs_filter_changed(filter, RS_FILTER_CHANGED_PIXELDATA); - } - break; - case PROP_DENOISE_LUMA: - if ((denoise->denoise_luma-g_value_get_int(value)) != 0) - { - denoise->denoise_luma = g_value_get_int(value); - rs_filter_changed(filter, RS_FILTER_CHANGED_PIXELDATA); - } - break; - case PROP_DENOISE_CHROMA: - if ((denoise->denoise_chroma-g_value_get_int(value)) != 0) - { - denoise->denoise_chroma = g_value_get_int(value); - rs_filter_changed(filter, RS_FILTER_CHANGED_PIXELDATA); - } - break; case PROP_SETTINGS: - settings = g_value_get_object(value); - g_signal_connect(settings, "settings-changed", G_CALLBACK(settings_changed), denoise); - settings_changed(settings, MASK_ALL, denoise); + if (denoise->settings && denoise->settings_signal_id) + g_signal_handler_disconnect(denoise->settings, denoise->settings_signal_id); + denoise->settings = g_value_get_object(value); + denoise->settings_signal_id = g_signal_connect(denoise->settings, "settings-changed", G_CALLBACK(settings_changed), denoise); + settings_changed(denoise->settings, MASK_ALL, denoise); + g_object_weak_ref(G_OBJECT(denoise->settings), settings_weak_notify, denoise); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } } +static void +settings_weak_notify(gpointer data, GObject *where_the_object_was) +{ + RSDenoise *denoise = RS_DENOISE(data); + + denoise->settings = NULL; +} + static RSFilterResponse * get_image(RSFilter *filter, const RSFilterRequest *request) { Modified: trunk/src/application.c =================================================================== --- trunk/src/application.c 2009-10-13 16:00:09 UTC (rev 2709) +++ trunk/src/application.c 2009-10-13 22:43:18 UTC (rev 2710) @@ -140,9 +140,6 @@ g_object_set(frotate, "angle", photo->angle, "orientation", photo->orientation, NULL); g_object_set(fcrop, "rectangle", photo->crop, NULL); actual_scale = ((gdouble) width / (gdouble) rs_filter_get_width(finput)); - g_object_set(fdenoise, "sharpen", (gint) (actual_scale * photo->settings[snapshot]->sharpen), NULL); - g_object_set(fdenoise, "denoise_luma", (gint) photo->settings[snapshot]->denoise_luma, NULL); - g_object_set(fdenoise, "denoise_chroma", (gint) photo->settings[snapshot]->denoise_chroma, NULL); if (0 < width && 0 < height) /* We only wan't to set width and height if they are not -1 */ g_object_set(fresample, "width", width, "height", height, NULL); g_object_set(fbasic_render, "settings", photo->settings[snapshot], NULL); Modified: trunk/src/rs-batch.c =================================================================== --- trunk/src/rs-batch.c 2009-10-13 16:00:09 UTC (rev 2709) +++ trunk/src/rs-batch.c 2009-10-13 22:43:18 UTC (rev 2710) @@ -564,9 +564,6 @@ break; } g_object_set(fresample, "width", width, "height", height, NULL); - g_object_set(fdenoise, "sharpen", (gint) photo->settings[setting_id]->sharpen, NULL); - g_object_set(fdenoise, "denoise_luma", (gint) photo->settings[setting_id]->denoise_luma, NULL); - g_object_set(fdenoise, "denoise_chroma", (gint) photo->settings[setting_id]->denoise_chroma, NULL); g_object_set(fdenoise, "settings", photo->settings[setting_id], NULL); /* Save the image */ Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-10-13 16:00:09 UTC (rev 2709) +++ trunk/src/rs-preview-widget.c 2009-10-13 22:43:18 UTC (rev 2710) @@ -115,7 +115,6 @@ GtkWidget *hscrollbar; GtkDrawingArea *canvas; - guint adjustment_changed_helper_timeout; RSToolbox *toolbox; gboolean zoom_to_fit; @@ -531,20 +530,8 @@ rs_filter_set_previous(preview->loupe_filter_cache, preview->filter_input); /* FIXME: view is hardcoded to 0 */ g_object_set(preview->loupe_filter_render, "settings", preview->photo->settings[preview->snapshot[0]], NULL); - gfloat sharpen, denoise_luma, denoise_chroma; + g_object_set(preview->loupe_filter_denoise, "settings", preview->photo->settings[preview->snapshot[0]], NULL); - g_object_get(preview->photo->settings[preview->snapshot[0]], - "sharpen", &sharpen, - "denoise_luma", &denoise_luma, - "denoise_chroma", &denoise_chroma, - NULL); - g_object_set(preview->loupe_filter_denoise, - "sharpen", (gint) sharpen, - "denoise_luma", (gint) denoise_luma, - "denoise_chroma", (gint) denoise_chroma, - "settings", preview->photo->settings[preview->snapshot[0]], - NULL); - gtk_widget_show_all(GTK_WIDGET(preview->loupe)); } else @@ -580,21 +567,12 @@ if (preview->photo) { - g_signal_connect(G_OBJECT(preview->photo), "settings-changed", G_CALLBACK(settings_changed), preview); - for(view=0;viewrequest[view], TRUE); g_object_set(preview->filter_render[view], "settings", preview->photo->settings[preview->snapshot[view]], NULL); g_object_set(preview->filter_denoise[view], "settings", preview->photo->settings[preview->snapshot[view]], NULL); } - - for(view=0;viewfilter_denoise[view], - "sharpen", (gint) (preview->photo->settings[preview->snapshot[view]]->sharpen), - "denoise_luma", (gint) (preview->photo->settings[preview->snapshot[view]]->denoise_luma), - "denoise_chroma", (gint) (preview->photo->settings[preview->snapshot[view]]->denoise_chroma), - NULL); } } @@ -837,12 +815,6 @@ g_object_set(preview->filter_render[view], "settings", preview->photo->settings[preview->snapshot[view]], NULL); g_object_set(preview->filter_denoise[view], "settings", preview->photo->settings[preview->snapshot[view]], NULL); - g_object_set(preview->filter_denoise[view], - "sharpen", (gint) (preview->photo->settings[preview->snapshot[view]]->sharpen), - "denoise_luma", (gint) (preview->photo->settings[preview->snapshot[view]]->denoise_luma), - "denoise_chroma", (gint) (preview->photo->settings[preview->snapshot[view]]->denoise_chroma), - NULL); - DIRTY(preview->dirty[view], SCREEN); rs_preview_widget_update(preview, TRUE); } @@ -1758,18 +1730,6 @@ return FALSE; } -static gboolean -adjustment_changed_helper(gpointer data) -{ - RSPreviewWidget *preview = RS_PREVIEW_WIDGET(data); - - rs_preview_widget_update(preview, FALSE); - - preview->adjustment_changed_helper_timeout = 0; - - return FALSE; -} - static void adjustment_changed(GtkAdjustment *adjustment, gpointer user_data) { @@ -2191,46 +2151,6 @@ } static void -settings_changed(RS_PHOTO *photo, RSSettingsMask mask, RSPreviewWidget *preview) -{ - gint view; - - /* Seperate snapshot */ - const gint snapshot = mask>>24; - mask &= 0x00ffffff; - - /* Return if no more relevant */ - if (photo != preview->photo) - return; - - for(view=0;viewviews;view++) - { - if (preview->snapshot[view] == snapshot) - { - DIRTY(preview->dirty[view], SCREEN); - if (mask & MASK_SHARPEN) - { - gfloat f = 0.0; - g_object_get(preview->photo->settings[preview->snapshot[view]], "sharpen", &f, NULL); - g_object_set(preview->filter_denoise[view], "sharpen", (gint) f, NULL); - } - if (mask & MASK_DENOISE_LUMA) - { - gfloat f = 0.0; - g_object_get(preview->photo->settings[preview->snapshot[view]], "denoise_luma", &f, NULL); - g_object_set(preview->filter_denoise[view], "denoise_luma", (gint) f, NULL); - } - if (mask & MASK_DENOISE_CHROMA) - { - gfloat f = 0.0; - g_object_get(preview->photo->settings[preview->snapshot[view]], "denoise_chroma", &f, NULL); - g_object_set(preview->filter_denoise[view], "denoise_chroma", (gint) f, NULL); - } - } - } -} - -static void filter_changed(RSFilter *filter, RSFilterChangedMask mask, RSPreviewWidget *preview) { gint view; Modified: trunk/src/rs-save-dialog.c =================================================================== --- trunk/src/rs-save-dialog.c 2009-10-13 16:00:09 UTC (rev 2709) +++ trunk/src/rs-save-dialog.c 2009-10-13 22:43:18 UTC (rev 2710) @@ -248,9 +248,6 @@ actual_scale = ((gdouble) dialog->save_width / (gdouble) rs_filter_get_width(dialog->filter_crop)); g_object_set(dialog->filter_resample, "width", dialog->save_width, "height", dialog->save_height, NULL); - g_object_set(dialog->filter_denoise, "sharpen", (gint) (actual_scale * dialog->photo->settings[dialog->snapshot]->sharpen), NULL); - g_object_set(dialog->filter_denoise, "denoise_luma", (gint) dialog->photo->settings[dialog->snapshot]->denoise_luma, NULL); - g_object_set(dialog->filter_denoise, "denoise_chroma", (gint) dialog->photo->settings[dialog->snapshot]->denoise_chroma, NULL); g_object_set(dialog->filter_basic_render, "settings", dialog->photo->settings[dialog->snapshot], NULL); g_object_set(dialog->filter_denoise, "settings", dialog->photo->settings[dialog->snapshot], NULL); From anders at brander.dk Wed Oct 14 02:39:05 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 14 Oct 2009 02:39:05 +0200 Subject: [Rawstudio-commit] r2711 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-14 02:39:05 +0200 (Wed, 14 Oct 2009) New Revision: 2711 Modified: trunk/librawstudio/rs-filter-response.c trunk/librawstudio/rs-filter-response.h Log: Added a simple property table to RSFilterResponse. Modified: trunk/librawstudio/rs-filter-response.c =================================================================== --- trunk/librawstudio/rs-filter-response.c 2009-10-13 22:43:18 UTC (rev 2710) +++ trunk/librawstudio/rs-filter-response.c 2009-10-14 00:39:05 UTC (rev 2711) @@ -28,6 +28,8 @@ gboolean quick; RS_IMAGE16 *image; GdkPixbuf *image8; + + GHashTable *properties; }; G_DEFINE_TYPE(RSFilterResponse, rs_filter_response, G_TYPE_OBJECT) @@ -46,6 +48,8 @@ if (filter_response->image8) g_object_unref(filter_response->image8); + + g_hash_table_destroy(filter_response->properties); } G_OBJECT_CLASS (rs_filter_response_parent_class)->dispose (object); @@ -66,13 +70,42 @@ object_class->finalize = rs_filter_response_finalize; } +static inline GValue * +new_value(GType type) +{ + GValue *value = g_slice_new0(GValue); + g_value_init(value, type); + + return value; +} + static void +free_value(gpointer data) +{ + GValue *value = (GValue *) data; + + g_value_unset(value); + g_slice_free(GValue, value); +} + +static inline GValue * +clone_value(const GValue *value) +{ + GType type = G_VALUE_TYPE(value); + GValue *ret = new_value(type); + g_value_copy(value, ret); + + return ret; +} + +static void rs_filter_response_init(RSFilterResponse *filter_response) { filter_response->roi_set = FALSE; filter_response->quick = FALSE; filter_response->image = NULL; filter_response->image8 = NULL; + filter_response->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_value); filter_response->dispose_has_run = FALSE; } @@ -101,6 +134,14 @@ new_filter_response->roi_set = filter_response->roi_set; new_filter_response->roi = filter_response->roi; new_filter_response->quick = filter_response->quick; + + /* Clone the properties table */ + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, filter_response->properties); + while (g_hash_table_iter_next (&iter, &key, &value)) + g_hash_table_insert(new_filter_response->properties, (gpointer) g_strdup(key), clone_value(value)); } return new_filter_response; @@ -274,3 +315,88 @@ return ret; } +static void +rs_filter_response_set_gvalue(const RSFilterResponse *filter_response, const gchar *name, GValue * value) +{ + g_assert(RS_IS_FILTER_RESPONSE(filter_response)); + g_assert(name != NULL); + g_assert(name[0] != '\0'); + + g_hash_table_insert(filter_response->properties, (gpointer) g_strdup(name), value); +} + +static GValue * +rs_filter_response_get_gvalue(const RSFilterResponse *filter_response, const gchar *name) +{ + g_assert(RS_IS_FILTER_RESPONSE(filter_response)); + + GValue *value = g_hash_table_lookup(filter_response->properties, name); + + return value; +} + +/** + * Set a string property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param str NULL-terminated string to set (will be copied) + */ +void +rs_filter_response_set_string(const RSFilterResponse *filter_response, const gchar *name, const gchar *str) +{ + GValue *val = new_value(G_TYPE_STRING); + g_value_set_string(val, str); + + rs_filter_response_set_gvalue(filter_response, name, val); +} + +/** + * Get a string property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param str A pointer to a string pointer where the value of the property can be saved. Should not be freed + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean +rs_filter_response_get_string(const RSFilterResponse *filter_response, const gchar *name, const gchar ** const str) +{ + GValue *val = rs_filter_response_get_gvalue(filter_response, name); + + if (val && G_VALUE_HOLDS_STRING(val)) + *str = g_value_get_string(val); + + return (val != NULL); +} + +/** + * Set a float property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param value A value to store + */ +void +rs_filter_response_set_float(const RSFilterResponse *filter_response, const gchar *name, const gfloat value) +{ + GValue *val = new_value(G_TYPE_FLOAT); + g_value_set_float(val, value); + + rs_filter_response_set_gvalue(filter_response, name, val); +} + +/** + * Get a float property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param value A pointer to a gfloat where the value will be stored + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean +rs_filter_response_get_float(const RSFilterResponse *filter_response, const gchar *name, gfloat *value) +{ + GValue *val = rs_filter_response_get_gvalue(filter_response, name); + + if (val && G_VALUE_HOLDS_FLOAT(val)) + *value = g_value_get_float(val); + + return (val != NULL); +} Modified: trunk/librawstudio/rs-filter-response.h =================================================================== --- trunk/librawstudio/rs-filter-response.h 2009-10-13 22:43:18 UTC (rev 2710) +++ trunk/librawstudio/rs-filter-response.h 2009-10-14 00:39:05 UTC (rev 2711) @@ -129,7 +129,41 @@ */ GdkPixbuf *rs_filter_response_get_image8(const RSFilterResponse *filter_response); +/** + * Set a string property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param str NULL-terminated string to set (will be copied) + */ +void rs_filter_response_set_string(const RSFilterResponse *filter_response, const gchar *name, const gchar *str); +/** + * Get a string property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param str A pointer to a string pointer where the value of the property can be saved. Should not be freed + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean rs_filter_response_get_string(const RSFilterResponse *filter_response, const gchar *name, const gchar ** const str); + +/** + * Set a float property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param value A value to store + */ +void +rs_filter_response_set_float(const RSFilterResponse *filter_response, const gchar *name, const gfloat value) + +/** + * Get a float property + * @param filter_response A RSFilterResponse + * @param name The name of the property + * @param value A pointer to a gfloat where the value will be stored + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean rs_filter_response_get_float(const RSFilterResponse *filter_response, const gchar *name, gfloat *value) + G_END_DECLS #endif /* RS_FILTER_RESPONSE_H */ From anders at brander.dk Wed Oct 14 02:42:36 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 14 Oct 2009 02:42:36 +0200 Subject: [Rawstudio-commit] r2712 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-14 02:42:36 +0200 (Wed, 14 Oct 2009) New Revision: 2712 Modified: trunk/librawstudio/rs-filter-response.h Log: Fixed typo. Modified: trunk/librawstudio/rs-filter-response.h =================================================================== --- trunk/librawstudio/rs-filter-response.h 2009-10-14 00:39:05 UTC (rev 2711) +++ trunk/librawstudio/rs-filter-response.h 2009-10-14 00:42:36 UTC (rev 2712) @@ -153,7 +153,7 @@ * @param value A value to store */ void -rs_filter_response_set_float(const RSFilterResponse *filter_response, const gchar *name, const gfloat value) +rs_filter_response_set_float(const RSFilterResponse *filter_response, const gchar *name, const gfloat value); /** * Get a float property @@ -162,7 +162,7 @@ * @param value A pointer to a gfloat where the value will be stored * @return TRUE if the property was found, FALSE otherwise */ -gboolean rs_filter_response_get_float(const RSFilterResponse *filter_response, const gchar *name, gfloat *value) +gboolean rs_filter_response_get_float(const RSFilterResponse *filter_response, const gchar *name, gfloat *value); G_END_DECLS From anders at brander.dk Wed Oct 14 14:39:07 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 14 Oct 2009 14:39:07 +0200 Subject: [Rawstudio-commit] r2713 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-14 14:39:07 +0200 (Wed, 14 Oct 2009) New Revision: 2713 Modified: trunk/librawstudio/rs-filter.c trunk/librawstudio/rs-filter.h Log: Implemented rs_filter_set_recursive(). Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-10-14 00:42:36 UTC (rev 2712) +++ trunk/librawstudio/rs-filter.c 2009-10-14 12:39:07 UTC (rev 2713) @@ -347,6 +347,95 @@ } /** + * Set a GObject property on zero or more filters above #filter recursively + * @param filter A RSFilter + * @param ... Pairs of property names and values followed by NULL + */ +void +rs_filter_set_recursive(RSFilter *filter, ...) +{ + va_list ap; + gchar *property_name; + RSFilter *current_filter; + GParamSpec *spec; + RSFilter *first_seen_here; + GTypeValueTable *table = NULL; + GType type; + union CValue { + gint v_int; + glong v_long; + gint64 v_int64; + gdouble v_double; + gpointer v_pointer; + } value; + + g_assert(RS_IS_FILTER(filter)); + + va_start(ap, filter); + + /* Loop through all properties */ + while ((property_name = va_arg(ap, gchar *))) + { + /* We set table to NULL for every property to indicate that we (again) + * have an "unknown" type */ + table = NULL; + + current_filter = filter; + /* Iterate through all filters previous to filter */ + do { + if (spec = g_object_class_find_property(G_OBJECT_GET_CLASS(current_filter), property_name)) + if (spec->flags & G_PARAM_WRITABLE) + { + /* If we got no GTypeValueTable at this point, we aquire + * one. We rely on all filters using the same type for all + * properties equally named */ + if (!table) + { + first_seen_here = current_filter; + type = spec->value_type; + table = g_type_value_table_peek(type); + + /* If we have no valuetable, we're screwed, bail out */ + if (!table) + g_error("No GTypeValueTable found for '%s'", g_type_name(type)); + + switch (table->collect_format[0]) + { + case 'i': value.v_int = va_arg(ap, gint); break; + case 'l': value.v_long = va_arg(ap, glong); break; + case 'd': value.v_double = va_arg(ap, gdouble); break; + case 'p': value.v_pointer = va_arg(ap, gpointer); break; + default: g_error("Don't know how to collect for '%s'", g_type_name(type)); break; + } + } + + if (table) + { + /* We try to catch cases where different filters use + * the same property name for different types */ + if (type != spec->value_type) + g_warning("Diverging types found for property '%s' (on filter '%s' and '%s')", + property_name, + RS_FILTER_NAME(first_seen_here), + RS_FILTER_NAME(current_filter)); + + switch (table->collect_format[0]) + { + case 'i': g_object_set(current_filter, property_name, value.v_int, NULL); break; + case 'l': g_object_set(current_filter, property_name, value.v_long, NULL); break; + case 'd': g_object_set(current_filter, property_name, value.v_double, NULL); break; + case 'p': g_object_set(current_filter, property_name, value.v_pointer, NULL); break; + default: break; + } + } + } + } while (RS_IS_FILTER(current_filter = current_filter->previous)); + } + + va_end(ap); +} + +/** * Get a GObject property from a RSFilter chain recursively * @param filter A RSFilter * @param ... Pairs of property names and a return pointers followed by NULL Modified: trunk/librawstudio/rs-filter.h =================================================================== --- trunk/librawstudio/rs-filter.h 2009-10-14 00:42:36 UTC (rev 2712) +++ trunk/librawstudio/rs-filter.h 2009-10-14 12:39:07 UTC (rev 2713) @@ -166,6 +166,14 @@ extern gint rs_filter_get_height(RSFilter *filter); /** + * Set a GObject property on zero or more filters above #filter recursively + * @param filter A RSFilter + * @param ... Pairs of property names and values followed by NULL + */ +void +rs_filter_set_recursive(RSFilter *filter, ...); + +/** * Get a GObject property from a RSFilter chain recursively * @param filter A RSFilter * @param ... Pairs of property names and a return pointers followed by NULL From anders at brander.dk Wed Oct 14 14:46:08 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 14 Oct 2009 14:46:08 +0200 Subject: [Rawstudio-commit] r2714 - trunk/src Message-ID: Author: abrander Date: 2009-10-14 14:46:08 +0200 (Wed, 14 Oct 2009) New Revision: 2714 Modified: trunk/src/application.c trunk/src/rs-batch.c trunk/src/rs-save-dialog.c Log: Ported some obvious places to rs_filter_set_recursive(). Modified: trunk/src/application.c =================================================================== --- trunk/src/application.c 2009-10-14 12:39:07 UTC (rev 2713) +++ trunk/src/application.c 2009-10-14 12:46:08 UTC (rev 2714) @@ -79,7 +79,7 @@ /* Apply lens information to RSLensfun */ if (lens) { - g_object_set(rs->filter_lensfun, + rs_filter_set_recursive(rs->filter_end, "make", meta->make_ascii, "model", meta->model_ascii, "lens", lens, @@ -88,18 +88,17 @@ NULL); g_object_unref(lens); } - g_object_set(rs->filter_input, + + g_object_unref(meta); + + rs_filter_set_recursive(rs->filter_end, "image", rs->photo->input, "filename", rs->photo->filename, + "rectangle", rs_photo_get_crop(photo), + "angle", rs_photo_get_angle(photo), + "orientation", rs->photo->orientation, NULL); - g_object_unref(meta); - - /* Update crop and rotate filters */ - g_object_set(rs->filter_crop, "rectangle", rs_photo_get_crop(photo), NULL); - g_object_set(rs->filter_rotate, "angle", rs_photo_get_angle(photo), "orientation", rs->photo->orientation, NULL); - g_object_set(rs->filter_rotate, "angle", rs_photo_get_angle(photo), NULL); - g_signal_connect(G_OBJECT(rs->photo), "spatial-changed", G_CALLBACK(photo_spatial_changed), rs); } } @@ -110,9 +109,11 @@ if (photo == rs->photo) { /* Update crop and rotate filters */ - g_object_set(rs->filter_crop, "rectangle", rs_photo_get_crop(photo), NULL); - g_object_set(rs->filter_rotate, "angle", rs_photo_get_angle(photo), "orientation", rs->photo->orientation, NULL); - g_object_set(rs->filter_rotate, "angle", rs_photo_get_angle(photo), NULL); + rs_filter_set_recursive(rs->filter_end, + "rectangle", rs_photo_get_crop(photo), + "angle", rs_photo_get_angle(photo), + "orientation", rs->photo->orientation, + NULL); } } @@ -136,14 +137,17 @@ RSFilter *fbasic_render = rs_filter_new("RSBasicRender", fdenoise); RSFilter *fend = fbasic_render; - g_object_set(finput, "image", photo->input, "filename", photo->filename, NULL); - g_object_set(frotate, "angle", photo->angle, "orientation", photo->orientation, NULL); - g_object_set(fcrop, "rectangle", photo->crop, NULL); + rs_filter_set_recursive(fend, + "image", photo->input, + "filename", photo->filename, + "angle", photo->angle, + "orientation", photo->orientation, + "rectangle", photo->crop, + "settings", photo->settings[snapshot], + NULL); actual_scale = ((gdouble) width / (gdouble) rs_filter_get_width(finput)); if (0 < width && 0 < height) /* We only wan't to set width and height if they are not -1 */ - g_object_set(fresample, "width", width, "height", height, NULL); - g_object_set(fbasic_render, "settings", photo->settings[snapshot], NULL); - g_object_set(fdenoise, "settings", photo->settings[snapshot], NULL); + rs_filter_set_recursive(fend, "width", width, "height", height, NULL); /* Set input ICC profile */ profile_filename = rs_conf_get_cms_profile(CMS_PROFILE_INPUT); Modified: trunk/src/rs-batch.c =================================================================== --- trunk/src/rs-batch.c 2009-10-14 12:39:07 UTC (rev 2713) +++ trunk/src/rs-batch.c 2009-10-14 12:46:08 UTC (rev 2714) @@ -511,16 +511,19 @@ g_string_append(filename, rs_output_get_extension(queue->output)); parsed_filename = filename_parse(filename->str, filename_in, setting_id); - g_object_set(finput, "image", photo->input, "filename", photo->filename, NULL); - g_object_set(frotate, "angle", photo->angle, "orientation", photo->orientation, NULL); - g_object_set(fcrop, "rectangle", photo->crop, NULL); - g_object_set(fbasic_render, "settings", photo->settings[setting_id], NULL); + rs_filter_set_recursive(fend, + "image", photo->input, + "filename", photo->filename, + "settings", photo->settings[setting_id], + "angle", photo->angle, + "orientation", photo->orientation, + "rectangle", photo->crop, + "settings", photo->settings[setting_id], + "bounding-box", TRUE, + "width", 250, + "height", 250, + NULL); - width = rs_filter_get_width(fcrop); - height = rs_filter_get_height(fcrop); - rs_constrain_to_bounding_box(250, 250, &width, &height); - g_object_set(fresample, "width", width, "height", height, NULL); - /* Render preview image */ filter_response = rs_filter_get_image8(fend, NULL); pixbuf = rs_filter_response_get_image8(filter_response); @@ -563,8 +566,10 @@ rs_constrain_to_bounding_box(queue->width, queue->height, &width, &height); break; } - g_object_set(fresample, "width", width, "height", height, NULL); - g_object_set(fdenoise, "settings", photo->settings[setting_id], NULL); + g_object_set(fend, + "width", width, + "height", height, + NULL); /* Save the image */ g_object_set(queue->output, "filename", parsed_filename, NULL); Modified: trunk/src/rs-save-dialog.c =================================================================== --- trunk/src/rs-save-dialog.c 2009-10-14 12:39:07 UTC (rev 2713) +++ trunk/src/rs-save-dialog.c 2009-10-14 12:46:08 UTC (rev 2714) @@ -153,6 +153,7 @@ dialog->filter_resample = rs_filter_new("RSResample", dialog->filter_crop); dialog->filter_denoise = rs_filter_new("RSDenoise", dialog->filter_resample); dialog->filter_basic_render = rs_filter_new("RSBasicRender", dialog->filter_denoise); + dialog->filter_end = dialog->filter_basic_render; RSIccProfile *profile; gchar *filename; @@ -197,12 +198,14 @@ g_assert(RS_IS_PHOTO(photo)); /* This should be enough to calculate "original" size */ - g_object_set(dialog->filter_input, "image", photo->input, NULL); - g_object_set(dialog->filter_rotate, "angle", photo->angle, "orientation", photo->orientation, NULL); - g_object_set(dialog->filter_crop, "rectangle", photo->crop, NULL); + rs_filter_set_recursive(dialog->filter_end, + "image", photo->input, + "angle", photo->angle, + "orientation", photo->orientation, + "rectangle", photo->crop, + "filename", photo->filename, + NULL); - g_object_set(dialog->filter_input, "filename", photo->filename, NULL); - if (dialog->photo) g_object_unref(dialog->photo); dialog->photo = g_object_ref(photo); @@ -247,9 +250,11 @@ actual_scale = ((gdouble) dialog->save_width / (gdouble) rs_filter_get_width(dialog->filter_crop)); - g_object_set(dialog->filter_resample, "width", dialog->save_width, "height", dialog->save_height, NULL); - g_object_set(dialog->filter_basic_render, "settings", dialog->photo->settings[dialog->snapshot], NULL); - g_object_set(dialog->filter_denoise, "settings", dialog->photo->settings[dialog->snapshot], NULL); + rs_filter_set_recursive(dialog->filter_end, + "width", dialog->save_width, + "height", dialog->save_height, + "settings", dialog->photo->settings[dialog->snapshot], + NULL); g_object_set(dialog->output, "filename", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->chooser)), NULL); rs_output_execute(dialog->output, dialog->filter_basic_render); From anders at brander.dk Wed Oct 14 14:53:43 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 14 Oct 2009 14:53:43 +0200 Subject: [Rawstudio-commit] r2715 - trunk/src Message-ID: Author: abrander Date: 2009-10-14 14:53:43 +0200 (Wed, 14 Oct 2009) New Revision: 2715 Modified: trunk/src/rs-save-dialog.h Log: Fixes last commit :) Modified: trunk/src/rs-save-dialog.h =================================================================== --- trunk/src/rs-save-dialog.h 2009-10-14 12:46:08 UTC (rev 2714) +++ trunk/src/rs-save-dialog.h 2009-10-14 12:53:43 UTC (rev 2715) @@ -61,6 +61,7 @@ RSFilter *filter_resample; RSFilter *filter_denoise; RSFilter *filter_basic_render; + RSFilter *filter_end; RS_PHOTO *photo; gint snapshot; From klauspost at gmail.com Wed Oct 14 16:26:41 2009 From: klauspost at gmail.com (Klaus Post) Date: Wed, 14 Oct 2009 16:26:41 +0200 Subject: [Rawstudio-commit] r2716 - trunk/plugins/dcp Message-ID: Author: post Date: 2009-10-14 16:26:41 +0200 (Wed, 14 Oct 2009) New Revision: 2716 Modified: trunk/plugins/dcp/dcp.c Log: DCP: Took out HSV2RGB SSE code and put it into its own function for more flexibility. Made SSE functions static to facilitate inlining. Modified: trunk/plugins/dcp/dcp.c =================================================================== --- trunk/plugins/dcp/dcp.c 2009-10-14 12:53:43 UTC (rev 2715) +++ trunk/plugins/dcp/dcp.c 2009-10-14 14:26:41 UTC (rev 2716) @@ -482,7 +482,7 @@ static gfloat _two_ps[4] __attribute__ ((aligned (16))) = {2.0f, 2.0f, 2.0f, 2.0f}; static gfloat _six_ps[4] __attribute__ ((aligned (16))) = {6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15, 6.0f-1e-15}; -inline void +static inline void RGBtoHSV_SSE(__m128 *c0, __m128 *c1, __m128 *c2) { @@ -551,11 +551,93 @@ mask = _mm_cmplt_ps(h, zero_ps); h = _mm_add_ps(h, _mm_and_ps(mask, six_ps)); - *c0 = h; *c1 = s; *c2 = v; } + + +static inline void +HSVtoRGB_SSE(__m128 *c0, __m128 *c1, __m128 *c2) +{ + __m128 h = *c0; + __m128 s = *c1; + __m128 v = *c2; + __m128 r, g, b; + + /* Convert get the fraction of h + * h_fraction = h - (float)(int)h */ + __m128 ones_ps = _mm_load_ps(_ones_ps); + __m128 h_fraction = _mm_sub_ps(h,_mm_cvtepi32_ps(_mm_cvttps_epi32(h))); + + /* p = v * (1.0f - s) */ + __m128 p = _mm_mul_ps(v, _mm_sub_ps(ones_ps, s)); + /* q = (v * (1.0f - s * f)) */ + __m128 q = _mm_mul_ps(v, _mm_sub_ps(ones_ps, _mm_mul_ps(s, h_fraction))); + /* t = (v * (1.0f - s * (1.0f - f))) */ + __m128 t = _mm_mul_ps(v, _mm_sub_ps(ones_ps, _mm_mul_ps(s, _mm_sub_ps(ones_ps, h_fraction)))); + + /* h < 1 (case 0)*/ + /* case 0: *r = v; *g = t; *b = p; break; */ + __m128 h_threshold = _mm_add_ps(ones_ps, ones_ps); + __m128 out_mask = _mm_cmplt_ps(h, ones_ps); + r = _mm_and_ps(v, out_mask); + g = _mm_and_ps(t, out_mask); + b = _mm_and_ps(p, out_mask); + + /* h < 2 (case 1) */ + /* case 1: *r = q; *g = v; *b = p; break; */ + __m128 m = _mm_cmplt_ps(h, h_threshold); + h_threshold = _mm_add_ps(h_threshold, ones_ps); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(q, m)); + g = _mm_or_ps(g, _mm_and_ps(v, m)); + b = _mm_or_ps(b, _mm_and_ps(p, m)); + out_mask = _mm_or_ps(out_mask, m); + + /* h < 3 (case 2)*/ + /* case 2: *r = p; *g = v; *b = t; break; */ + m = _mm_cmplt_ps(h, h_threshold); + h_threshold = _mm_add_ps(h_threshold, ones_ps); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(p, m)); + g = _mm_or_ps(g, _mm_and_ps(v, m)); + b = _mm_or_ps(b, _mm_and_ps(t, m)); + out_mask = _mm_or_ps(out_mask, m); + + /* h < 4 (case 3)*/ + /* case 3: *r = p; *g = q; *b = v; break; */ + m = _mm_cmplt_ps(h, h_threshold); + h_threshold = _mm_add_ps(h_threshold, ones_ps); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(p, m)); + g = _mm_or_ps(g, _mm_and_ps(q, m)); + b = _mm_or_ps(b, _mm_and_ps(v, m)); + out_mask = _mm_or_ps(out_mask, m); + + /* h < 5 (case 4)*/ + /* case 4: *r = t; *g = p; *b = v; break; */ + m = _mm_cmplt_ps(h, h_threshold); + m = _mm_andnot_ps(out_mask, m); + r = _mm_or_ps(r, _mm_and_ps(t, m)); + g = _mm_or_ps(g, _mm_and_ps(p, m)); + b = _mm_or_ps(b, _mm_and_ps(v, m)); + out_mask = _mm_or_ps(out_mask, m); + + + /* Remainder (case 5) */ + /* case 5: *r = v; *g = p; *b = q; break; */ + __m128 all_ones = _mm_cmpeq_ps(h,h); + m = _mm_xor_ps(out_mask, all_ones); + r = _mm_or_ps(r, _mm_and_ps(v, m)); + g = _mm_or_ps(g, _mm_and_ps(p, m)); + b = _mm_or_ps(b, _mm_and_ps(q, m)); + + *c0 = r; + *c1 = g; + *c2 = b; +} + #endif inline void @@ -1115,7 +1197,7 @@ #if defined (__SSE2__) -inline __m128 +static inline __m128 sse_matrix3_mul(float* mul, __m128 a, __m128 b, __m128 c) { @@ -1272,9 +1354,8 @@ if (dcp->looktable) { huesat_map_SSE2(dcp->looktable, &dcp->looktable_precalc, &h, &s, &v); } - - /* Back to RGB */ - /* ensure that hue is within range */ + + /* Ensure that hue is within range */ h_mask_gt = _mm_cmpgt_ps(h, six_ps); h_mask_lt = _mm_cmplt_ps(h, zero_ps); six_masked_gt = _mm_and_ps(six_ps, h_mask_gt); @@ -1284,86 +1365,18 @@ /* s always slightly > 0 */ s = _mm_max_ps(s, min_val); + + HSVtoRGB_SSE(&h, &s, &v); + r = h; g = s; b = v; - - /* Convert get the fraction of h - * h_fraction = h - (float)(int)h */ - __m128 ones_ps = _mm_load_ps(_ones_ps); - __m128 h_fraction = _mm_sub_ps(h,_mm_cvtepi32_ps(_mm_cvttps_epi32(h))); - - /* p = v * (1.0f - s) */ - __m128 p = _mm_mul_ps(v, _mm_sub_ps(ones_ps, s)); - /* q = (v * (1.0f - s * f)) */ - __m128 q = _mm_mul_ps(v, _mm_sub_ps(ones_ps, _mm_mul_ps(s, h_fraction))); - /* t = (v * (1.0f - s * (1.0f - f))) */ - __m128 t = _mm_mul_ps(v, _mm_sub_ps(ones_ps, _mm_mul_ps(s, _mm_sub_ps(ones_ps, h_fraction)))); - - /* h < 1 (case 0)*/ - /* case 0: *r = v; *g = t; *b = p; break; */ - __m128 h_threshold = _mm_add_ps(ones_ps, ones_ps); - __m128 out_mask = _mm_cmplt_ps(h, ones_ps); - r = _mm_and_ps(v, out_mask); - g = _mm_and_ps(t, out_mask); - b = _mm_and_ps(p, out_mask); - - /* h < 2 (case 1) */ - /* case 1: *r = q; *g = v; *b = p; break; */ - __m128 m = _mm_cmplt_ps(h, h_threshold); - h_threshold = _mm_add_ps(h_threshold, ones_ps); - m = _mm_andnot_ps(out_mask, m); - r = _mm_or_ps(r, _mm_and_ps(q, m)); - g = _mm_or_ps(g, _mm_and_ps(v, m)); - b = _mm_or_ps(b, _mm_and_ps(p, m)); - out_mask = _mm_or_ps(out_mask, m); - - /* h < 3 (case 2)*/ - /* case 2: *r = p; *g = v; *b = t; break; */ - m = _mm_cmplt_ps(h, h_threshold); - h_threshold = _mm_add_ps(h_threshold, ones_ps); - m = _mm_andnot_ps(out_mask, m); - r = _mm_or_ps(r, _mm_and_ps(p, m)); - g = _mm_or_ps(g, _mm_and_ps(v, m)); - b = _mm_or_ps(b, _mm_and_ps(t, m)); - out_mask = _mm_or_ps(out_mask, m); - - /* h < 4 (case 3)*/ - /* case 3: *r = p; *g = q; *b = v; break; */ - m = _mm_cmplt_ps(h, h_threshold); - h_threshold = _mm_add_ps(h_threshold, ones_ps); - m = _mm_andnot_ps(out_mask, m); - r = _mm_or_ps(r, _mm_and_ps(p, m)); - g = _mm_or_ps(g, _mm_and_ps(q, m)); - b = _mm_or_ps(b, _mm_and_ps(v, m)); - out_mask = _mm_or_ps(out_mask, m); - - /* h < 5 (case 4)*/ - /* case 4: *r = t; *g = p; *b = v; break; */ - m = _mm_cmplt_ps(h, h_threshold); - m = _mm_andnot_ps(out_mask, m); - r = _mm_or_ps(r, _mm_and_ps(t, m)); - g = _mm_or_ps(g, _mm_and_ps(p, m)); - b = _mm_or_ps(b, _mm_and_ps(v, m)); - out_mask = _mm_or_ps(out_mask, m); - - - /* Remainder (case 5) */ - /* case 5: *r = v; *g = p; *b = q; break; */ - __m128 all_ones = _mm_cmpeq_ps(h,h); - m = _mm_xor_ps(out_mask, all_ones); - r = _mm_or_ps(r, _mm_and_ps(v, m)); - g = _mm_or_ps(g, _mm_and_ps(p, m)); - b = _mm_or_ps(b, _mm_and_ps(q, m)); - - __m128 rgb_mul = _mm_load_ps(_16_bit_ps); r = _mm_mul_ps(r, rgb_mul); g = _mm_mul_ps(g, rgb_mul); b = _mm_mul_ps(b, rgb_mul); - + __m128i r_i = _mm_cvtps_epi32(r); __m128i g_i = _mm_cvtps_epi32(g); __m128i b_i = _mm_cvtps_epi32(b); - __m128i sub_32 = _mm_load_si128((__m128i*)_15_bit_epi32); __m128i signxor = _mm_load_si128((__m128i*)_16_bit_sign); From anders at brander.dk Thu Oct 15 16:51:02 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 16:51:02 +0200 Subject: [Rawstudio-commit] r2717 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-15 16:51:02 +0200 (Thu, 15 Oct 2009) New Revision: 2717 Added: trunk/librawstudio/rs-1d-function.c trunk/librawstudio/rs-1d-function.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h Log: Added RS1dFunction. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-10-14 14:26:41 UTC (rev 2716) +++ trunk/librawstudio/Makefile.am 2009-10-15 14:51:02 UTC (rev 2717) @@ -12,6 +12,7 @@ rs-plugin.h \ rs-rawfile.h \ rs-exif.h \ + rs-1d-function.h \ rs-icc-profile.h \ rs-image.h \ rs-image16.h \ @@ -46,6 +47,7 @@ rs-plugin.c rs-plugin.h \ rs-rawfile.c rs-rawfile.h \ rs-exif.cc rs-exif.h \ + rs-1d-function.c rs-1d-function.h \ rs-icc-profile.c rs-icc-profile.h \ rs-image.c rs-image.h \ rs-image16.c rs-image16.h \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-10-14 14:26:41 UTC (rev 2716) +++ trunk/librawstudio/rawstudio.h 2009-10-15 14:51:02 UTC (rev 2717) @@ -32,6 +32,7 @@ #include "rs-rawfile.h" #include "rs-settings.h" #include "rs-exif.h" +#include "rs-1d-function.h" #include "rs-icc-profile.h" #include "rs-image.h" #include "rs-image16.h" Added: trunk/librawstudio/rs-1d-function.c =================================================================== --- trunk/librawstudio/rs-1d-function.c (rev 0) +++ trunk/librawstudio/rs-1d-function.c 2009-10-15 14:51:02 UTC (rev 2717) @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "rs-1d-function.h" + +G_DEFINE_TYPE(RS1dFunction, rs_1d_function, G_TYPE_OBJECT) + +static void +rs_1d_function_class_init(RS1dFunctionClass *klass) +{ +} + +static void +rs_1d_function_init(RS1dFunction *func) +{ +} + +/** + * Instantiate a new RS1dFunction, it will behave as an identity function (y = x) + * @return A new RS1dFunction with arefcount of 1. + */ +RS1dFunction * +rs_1d_function_new(void) +{ + return g_object_new (RS_TYPE_1D_FUNCTION, NULL); +} + +/** + * Behaves like #rs_1d_function_new but returns a singleton + * @return A new RS1dFunction singleton which should not be unreffed + */ +RS1dFunction * +rs_1d_function_new_singleton(void) +{ + static GStaticMutex lock = G_STATIC_MUTEX_INIT; + static RS1dFunction *func = NULL; + + g_static_mutex_lock(&lock); + if (!func) + func = rs_1d_function_new(); + g_static_mutex_unlock(&lock); + + return func; +} + +/** + * Map x to a new y value + * @param func A RS1dFunction + * @param x An input parameter in the range 0.0-1.0 + * @return Mapped value for x + */ +gdouble +rs_1d_function_evaluate(RS1dFunction *func, gdouble x) +{ + g_assert(RS_IS_1D_FUNCTION(func)); + + RS1dFunctionEvaluate *evaluate = RS_1D_FUNCTION_GET_CLASS(func)->evaluate; + + if (evaluate) + return evaluate(func, x); + else + return x; +} + +/** + * Map y to a new x value + * @param func A RS1dFunction + * @param x An input parameter in the range 0.0-1.0 + * @return Inverse value for y + */ +gdouble +rs_1d_function_evaluate_inverse(RS1dFunction *func, gdouble y) +{ + g_assert(RS_IS_1D_FUNCTION(func)); + + RS1dFunctionEvaluate *evaluate_inverse = RS_1D_FUNCTION_GET_CLASS(func)->evaluate_inverse; + + if (evaluate_inverse) + return evaluate_inverse(func, y); + else + return y; +} + +/** + * Return TRUE if rs_1d_function_evaluate(#func, x) == x for all x + * @param func A RS1dFunction + * @return TRUE if rs_1d_function_evaluate(#func, x) == x for all x, FALSE otherwise + */ +gboolean +rs_1d_function_is_identity(RS1dFunction *func) +{ + g_assert(RS_IS_1D_FUNCTION(func)); + + RS1dFunctionIsIdentity *is_identity = RS_1D_FUNCTION_GET_CLASS(func)->is_identity; + RS1dFunctionEvaluate *evaluate = RS_1D_FUNCTION_GET_CLASS(func)->evaluate; + + if (!is_identity && !evaluate) + return TRUE; + else if (is_identity) + return is_identity(func); + else + return FALSE; +} Added: trunk/librawstudio/rs-1d-function.h =================================================================== --- trunk/librawstudio/rs-1d-function.h (rev 0) +++ trunk/librawstudio/rs-1d-function.h 2009-10-15 14:51:02 UTC (rev 2717) @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef RS_1D_FUNCTION_H +#define RS_1D_FUNCTION_H + +#include + +G_BEGIN_DECLS + +#define RS_TYPE_1D_FUNCTION rs_1d_function_get_type() +#define RS_1D_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_1D_FUNCTION, RS1dFunction)) +#define RS_1D_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_1D_FUNCTION, RS1dFunctionClass)) +#define RS_IS_1D_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_1D_FUNCTION)) +#define RS_IS_1D_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_1D_FUNCTION)) +#define RS_1D_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_1D_FUNCTION, RS1dFunctionClass)) + +typedef struct { + GObject parent; +} RS1dFunction; + +typedef gdouble (RS1dFunctionEvaluate)(RS1dFunction *func, gdouble x); +typedef gboolean (RS1dFunctionIsIdentity)(RS1dFunction *func); + +typedef struct { + GObjectClass parent_class; + + RS1dFunctionIsIdentity *is_identity; + RS1dFunctionEvaluate *evaluate; + RS1dFunctionEvaluate *evaluate_inverse; +} RS1dFunctionClass; + +GType rs_1d_function_get_type(void); + +/** + * Instantiate a new RS1dFunction, it will behave as an identity function (y = x) + * @return A new RS1dFunction with arefcount of 1. + */ +RS1dFunction * +rs_1d_function_new(void); + +/** + * Behaves like #rs_1d_function_new but returns a singleton + * @return A new RS1dFunction singleton which should not be unreffed + */ +RS1dFunction * +rs_1d_function_new_singleton(void); + +/** + * Map x to a new y value + * @param func A RS1dFunction + * @param x An input parameter in the range 0.0-1.0 + * @return Mapped value for x + */ +gdouble +rs_1d_function_evaluate(RS1dFunction *func, gdouble x); + +/** + * Map y to a new x value + * @param func A RS1dFunction + * @param x An input parameter in the range 0.0-1.0 + * @return Inverse value for y + */ +gdouble +rs_1d_function_evaluate_inverse(RS1dFunction *func, gdouble y); + +/** + * Return TRUE if rs_1d_function_evaluate(#func, x) == x for all x + * @param func A RS1dFunction + * @return TRUE if rs_1d_function_evaluate(#func, x) == x for all x, FALSE otherwise + */ +gboolean +rs_1d_function_is_identity(RS1dFunction *func); + +G_END_DECLS + +#endif /* RS_1D_FUNCTION_H */ From anders at brander.dk Thu Oct 15 17:04:14 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 17:04:14 +0200 Subject: [Rawstudio-commit] r2718 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-15 17:04:14 +0200 (Thu, 15 Oct 2009) New Revision: 2718 Modified: trunk/librawstudio/rs-1d-function.c trunk/librawstudio/rs-1d-function.h Log: Added a few missing const. Modified: trunk/librawstudio/rs-1d-function.c =================================================================== --- trunk/librawstudio/rs-1d-function.c 2009-10-15 14:51:02 UTC (rev 2717) +++ trunk/librawstudio/rs-1d-function.c 2009-10-15 15:04:14 UTC (rev 2718) @@ -45,7 +45,7 @@ * Behaves like #rs_1d_function_new but returns a singleton * @return A new RS1dFunction singleton which should not be unreffed */ -RS1dFunction * +const RS1dFunction * rs_1d_function_new_singleton(void) { static GStaticMutex lock = G_STATIC_MUTEX_INIT; @@ -66,7 +66,7 @@ * @return Mapped value for x */ gdouble -rs_1d_function_evaluate(RS1dFunction *func, gdouble x) +rs_1d_function_evaluate(const RS1dFunction *func, const gdouble x) { g_assert(RS_IS_1D_FUNCTION(func)); @@ -85,7 +85,7 @@ * @return Inverse value for y */ gdouble -rs_1d_function_evaluate_inverse(RS1dFunction *func, gdouble y) +rs_1d_function_evaluate_inverse(const RS1dFunction *func, const gdouble y) { g_assert(RS_IS_1D_FUNCTION(func)); @@ -103,7 +103,7 @@ * @return TRUE if rs_1d_function_evaluate(#func, x) == x for all x, FALSE otherwise */ gboolean -rs_1d_function_is_identity(RS1dFunction *func) +rs_1d_function_is_identity(const RS1dFunction *func) { g_assert(RS_IS_1D_FUNCTION(func)); Modified: trunk/librawstudio/rs-1d-function.h =================================================================== --- trunk/librawstudio/rs-1d-function.h 2009-10-15 14:51:02 UTC (rev 2717) +++ trunk/librawstudio/rs-1d-function.h 2009-10-15 15:04:14 UTC (rev 2718) @@ -35,8 +35,8 @@ GObject parent; } RS1dFunction; -typedef gdouble (RS1dFunctionEvaluate)(RS1dFunction *func, gdouble x); -typedef gboolean (RS1dFunctionIsIdentity)(RS1dFunction *func); +typedef gdouble (RS1dFunctionEvaluate)(const RS1dFunction *func, const gdouble); +typedef gboolean (RS1dFunctionIsIdentity)(const RS1dFunction *func); typedef struct { GObjectClass parent_class; @@ -59,7 +59,7 @@ * Behaves like #rs_1d_function_new but returns a singleton * @return A new RS1dFunction singleton which should not be unreffed */ -RS1dFunction * +const RS1dFunction * rs_1d_function_new_singleton(void); /** @@ -69,7 +69,7 @@ * @return Mapped value for x */ gdouble -rs_1d_function_evaluate(RS1dFunction *func, gdouble x); +rs_1d_function_evaluate(const RS1dFunction *func, gdouble x); /** * Map y to a new x value @@ -78,7 +78,7 @@ * @return Inverse value for y */ gdouble -rs_1d_function_evaluate_inverse(RS1dFunction *func, gdouble y); +rs_1d_function_evaluate_inverse(const RS1dFunction *func, gdouble y); /** * Return TRUE if rs_1d_function_evaluate(#func, x) == x for all x @@ -86,7 +86,7 @@ * @return TRUE if rs_1d_function_evaluate(#func, x) == x for all x, FALSE otherwise */ gboolean -rs_1d_function_is_identity(RS1dFunction *func); +rs_1d_function_is_identity(const RS1dFunction *func); G_END_DECLS From anders at brander.dk Thu Oct 15 17:25:29 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 17:25:29 +0200 Subject: [Rawstudio-commit] r2719 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-15 17:25:29 +0200 (Thu, 15 Oct 2009) New Revision: 2719 Added: trunk/librawstudio/rs-color-space.c trunk/librawstudio/rs-color-space.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h Log: Added RSColorSpace. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-10-15 15:04:14 UTC (rev 2718) +++ trunk/librawstudio/Makefile.am 2009-10-15 15:25:29 UTC (rev 2719) @@ -14,6 +14,7 @@ rs-exif.h \ rs-1d-function.h \ rs-icc-profile.h \ + rs-color-space.h \ rs-image.h \ rs-image16.h \ rs-lens.h \ @@ -49,6 +50,7 @@ rs-exif.cc rs-exif.h \ rs-1d-function.c rs-1d-function.h \ rs-icc-profile.c rs-icc-profile.h \ + rs-color-space.c rs-color-space.h \ rs-image.c rs-image.h \ rs-image16.c rs-image16.h \ rs-lens.c rs-lens.h \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-10-15 15:04:14 UTC (rev 2718) +++ trunk/librawstudio/rawstudio.h 2009-10-15 15:25:29 UTC (rev 2719) @@ -34,6 +34,7 @@ #include "rs-exif.h" #include "rs-1d-function.h" #include "rs-icc-profile.h" +#include "rs-color-space.h" #include "rs-image.h" #include "rs-image16.h" #include "rs-metadata.h" Added: trunk/librawstudio/rs-color-space.c =================================================================== --- trunk/librawstudio/rs-color-space.c (rev 0) +++ trunk/librawstudio/rs-color-space.c 2009-10-15 15:25:29 UTC (rev 2719) @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "rs-color-space.h" + +G_DEFINE_TYPE (RSColorSpace, rs_color_space, G_TYPE_OBJECT) + +static void +rs_color_space_class_init(RSColorSpaceClass *klass) +{ +} + +static void +rs_color_space_init(RSColorSpace *color_space) +{ +} + +/** + * Get a color space definition + * @param name The GType name for the colorspace (not the registered name) + * @return A colorspace singleton if found, NULL otherwise. This should not be unreffed. + */ +const RSColorSpace * +rs_color_space_new_singleton(const gchar *name) +{ + RSColorSpace *color_space = NULL; + static GHashTable *singletons = NULL; + static GStaticMutex lock = G_STATIC_MUTEX_INIT; + + g_assert(name != NULL); + + g_static_mutex_lock(&lock); + + if (!singletons) + singletons = g_hash_table_new(g_str_hash, g_str_equal); + + color_space = g_hash_table_lookup(singletons, name); + if (!color_space) + { + GType type = g_type_from_name(name); + if (g_type_is_a (type, RS_TYPE_COLOR_SPACE)) + color_space = g_object_new(type, NULL); + + if (!RS_IS_COLOR_SPACE(color_space)) + g_warning("Could not instantiate color space of type \"%s\"", name); + else + g_hash_table_insert(singletons, (gpointer) name, color_space); + } + + g_static_mutex_unlock(&lock); + + return color_space; +} + +/** + * Set (RGB) to PCS matrix + * @note This is only interesting for color space implementations + * @param color_space A RSColorSpace + * @param matrix A matrix, xyz2rgb will be the inverse of this + */ +void +rs_color_space_set_matrix_to_pcs(RSColorSpace *color_space, const RS_MATRIX3 * const matrix) +{ + g_assert(RS_IS_COLOR_SPACE(color_space)); + + /* Could this be replaced by bradford? */ + const RS_VECTOR3 identity = {1.0, 1.0, 1.0}; + const RS_VECTOR3 w1 = vector3_multiply_matrix(&identity, matrix); + const RS_VECTOR3 w2 = XYZ_WP_D50; + + const RS_VECTOR3 scale_vector = { w2.x/w1.x, w2.y/w1.y, w2.z/w2.z }; + const RS_MATRIX3 scale = vector3_as_diagonal(&scale_vector); + + matrix3_multiply(&scale, matrix, &color_space->matrix_to_pcs); + color_space->matrix_from_pcs = matrix3_invert(&color_space->matrix_to_pcs); +} + +/** + * Get a matrix that will transform this color space to PCS + * @param color_space A RSColorSpace + * @return from_pcs matrix + */ +RS_MATRIX3 +rs_color_space_get_matrix_to_pcs(const RSColorSpace *color_space) +{ + g_assert(RS_IS_COLOR_SPACE(color_space)); + + return color_space->matrix_from_pcs; +} + +/** + * Get a matrix that will transform PCS to this color space + * @param color_space A RSColorSpace + * @return to_pcs matrix + */ +RS_MATRIX3 +rs_color_space_get_matrix_from_pcs(const RSColorSpace *color_space) +{ + g_assert(RS_IS_COLOR_SPACE(color_space)); + + return color_space->matrix_to_pcs; +} + +/** + * Get the ICC profile for this colorspace if any + * @param color_space A RSColorSpace + * @return A RSIccProfile (or NULL) that should not be unreffed + */ +const RSIccProfile * +rs_color_space_get_icc_profile(const RSColorSpace *color_space) +{ + RSColorSpaceClass *klass = RS_COLOR_SPACE_GET_CLASS(color_space); + + if (klass->get_icc_profile) + return klass->get_icc_profile(color_space); + else + return NULL; +} + +/** + * Get the gamma transfer function for this color space + * @param color_space A RSColorSpace + * @return A RS1dFunction that should not be unreffed + */ +const RS1dFunction * +rs_color_space_get_gamma_function(const RSColorSpace *color_space) +{ + RSColorSpaceClass *klass = RS_COLOR_SPACE_GET_CLASS(color_space); + + if (klass->get_gamma_function) + return klass->get_gamma_function(color_space); + else + return rs_1d_function_new_singleton(); +} Added: trunk/librawstudio/rs-color-space.h =================================================================== --- trunk/librawstudio/rs-color-space.h (rev 0) +++ trunk/librawstudio/rs-color-space.h 2009-10-15 15:25:29 UTC (rev 2719) @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef RS_COLOR_SPACE_H +#define RS_COLOR_SPACE_H + +#include +#include "rawstudio.h" + +G_BEGIN_DECLS + +#define RS_DEFINE_COLOR_SPACE(type_name, TypeName) \ +static GType type_name##_get_type (GTypeModule *module); \ +static void type_name##_class_init(TypeName##Class *klass); \ +static void type_name##_init(TypeName *color_space); \ +static GType type_name##_type = 0; \ +static GType \ +type_name##_get_type(GTypeModule *module) \ +{ \ + if (!type_name##_type) \ + { \ + static const GTypeInfo color_space_info = \ + { \ + sizeof (TypeName##Class), \ + (GBaseInitFunc) NULL, \ + (GBaseFinalizeFunc) NULL, \ + (GClassInitFunc) type_name##_class_init, \ + NULL, \ + NULL, \ + sizeof (TypeName), \ + 0, \ + (GInstanceInitFunc) type_name##_init \ + }; \ + \ + type_name##_type = g_type_module_register_type( \ + module, \ + RS_TYPE_COLOR_SPACE, \ + #TypeName, \ + &color_space_info, \ + 0); \ + } \ + return type_name##_type; \ +} + +#define RS_TYPE_COLOR_SPACE rs_color_space_get_type() +#define RS_COLOR_SPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_COLOR_SPACE, RSColorSpace)) +#define RS_COLOR_SPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_COLOR_SPACE, RSColorSpaceClass)) +#define RS_IS_COLOR_SPACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_COLOR_SPACE)) +#define RS_IS_COLOR_SPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_COLOR_SPACE)) +#define RS_COLOR_SPACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_COLOR_SPACE, RSColorSpaceClass)) + +typedef struct { + GObject parent; + + RS_MATRIX3 matrix_to_pcs; + RS_MATRIX3 matrix_from_pcs; +} RSColorSpace; + +typedef struct { + GObjectClass parent_class; + + const gchar *name; + const gchar *description; + + RS_MATRIX3 (*get_to_pcs)(const RSColorSpace *color_space); + RS_MATRIX3 (*get_from_pcs)(const RSColorSpace *color_space); + const RSIccProfile *(*get_icc_profile)(const RSColorSpace *color_space); + const RS1dFunction *(*get_gamma_function)(const RSColorSpace *color_space); +} RSColorSpaceClass; + +GType rs_color_space_get_type(void); + +/** + * Get a color space definition + * @param name The GType name for the colorspace (not the registered name) + * @return A colorspace singleton if found, NULL otherwise. This should not be unreffed. + */ +const RSColorSpace * +rs_color_space_new_singleton(const gchar *name); + +/** + * Set (RGB) to PCS matrix + * @note This is only interesting for color space implementations + * @param color_space A RSColorSpace + * @param matrix A matrix, xyz2rgb will be the inverse of this + */ +void +rs_color_space_set_matrix_to_pcs(RSColorSpace *color_space, const RS_MATRIX3 * const matrix); + +/** + * Get a matrix that will transform this color space to PCS + * @param color_space A RSColorSpace + * @return from_pcs matrix + */ +RS_MATRIX3 +rs_color_space_get_matrix_to_pcs(const RSColorSpace *color_space); + +/** + * Get a matrix that will transform PCS to this color space + * @param color_space A RSColorSpace + * @return to_pcs matrix + */ +RS_MATRIX3 +rs_color_space_get_matrix_from_pcs(const RSColorSpace *color_space); + +/** + * Get the ICC profile for this colorspace if any + * @param color_space A RSColorSpace + * @return A RSIccProfile (or NULL) that should not be unreffed + */ +const RSIccProfile * +rs_color_space_get_icc_profile(const RSColorSpace *color_space); + +/** + * Get the gamma transfer function for this color space + * @param color_space A RSColorSpace + * @return A RS1dFunction that should not be unreffed + */ +const RS1dFunction * +rs_color_space_get_gamma_function(const RSColorSpace *color_space); + +G_END_DECLS + +#endif /* RS_COLOR_SPACE_H */ From anders at brander.dk Thu Oct 15 17:28:31 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 17:28:31 +0200 Subject: [Rawstudio-commit] r2720 - in trunk: . plugins plugins/colorspace-prophoto plugins/colorspace-srgb Message-ID: Author: abrander Date: 2009-10-15 17:28:31 +0200 (Thu, 15 Oct 2009) New Revision: 2720 Added: trunk/plugins/colorspace-prophoto/ trunk/plugins/colorspace-prophoto/Makefile.am trunk/plugins/colorspace-prophoto/colorspace-prophoto.c trunk/plugins/colorspace-srgb/ trunk/plugins/colorspace-srgb/Makefile.am trunk/plugins/colorspace-srgb/colorspace-srgb.c Modified: trunk/configure.in trunk/plugins/Makefile.am Log: Added RSProphoto and RSSrgb color spaces. Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-10-15 15:25:29 UTC (rev 2719) +++ trunk/configure.in 2009-10-15 15:28:31 UTC (rev 2720) @@ -77,6 +77,8 @@ plugins/Makefile plugins/basic-render/Makefile plugins/cache/Makefile +plugins/colorspace-prophoto/Makefile +plugins/colorspace-srgb/Makefile plugins/crop/Makefile plugins/dcp/Makefile plugins/demosaic/Makefile Modified: trunk/plugins/Makefile.am =================================================================== --- trunk/plugins/Makefile.am 2009-10-15 15:25:29 UTC (rev 2719) +++ trunk/plugins/Makefile.am 2009-10-15 15:28:31 UTC (rev 2720) @@ -1,6 +1,8 @@ SUBDIRS = \ basic-render \ cache \ + colorspace-prophoto \ + colorspace-srgb \ crop \ dcp \ demosaic \ Added: trunk/plugins/colorspace-prophoto/Makefile.am =================================================================== --- trunk/plugins/colorspace-prophoto/Makefile.am (rev 0) +++ trunk/plugins/colorspace-prophoto/Makefile.am 2009-10-15 15:28:31 UTC (rev 2720) @@ -0,0 +1,19 @@ +plugindir = $(libdir)/rawstudio/plugins + +AM_CFLAGS = -Wall + +AM_CXXFLAGS = $(AM_CFLAGS) + +INCLUDES = \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + @PACKAGE_CFLAGS@ \ + -I../../librawstudio/ + +lib_LTLIBRARIES = colorspace_prophoto.la + +libdir = $(datadir)/rawstudio/plugins/ + +colorspace_prophoto_la_LIBADD = @PACKAGE_LIBS@ +colorspace_prophoto_la_LDFLAGS = -module -avoid-version +colorspace_prophoto_la_SOURCES = colorspace-prophoto.c Added: trunk/plugins/colorspace-prophoto/colorspace-prophoto.c =================================================================== --- trunk/plugins/colorspace-prophoto/colorspace-prophoto.c (rev 0) +++ trunk/plugins/colorspace-prophoto/colorspace-prophoto.c 2009-10-15 15:28:31 UTC (rev 2720) @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* Plugin tmpl version 4 */ + +#include +#include "config.h" +#include "gettext.h" + +#define RS_TYPE_PROPHOTO (rs_prophoto_type) +#define RS_PROPHOTO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_PROPHOTO, RSProphoto)) +#define RS_PROPHOTO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_PROPHOTO, RSProphotoClass)) +#define RS_IS_PROPHOTO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_PROPHOTO)) + +typedef struct { + RSColorSpace parent; +} RSProphoto; + +typedef struct { + RSColorSpaceClass parent_class; + + const RSIccProfile *icc_profile; +} RSProphotoClass; + +RS_DEFINE_COLOR_SPACE(rs_prophoto, RSProphoto) + +static const RSIccProfile *get_icc_profile(const RSColorSpace *color_space); + +G_MODULE_EXPORT void +rs_plugin_load(RSPlugin *plugin) +{ + rs_prophoto_get_type(G_TYPE_MODULE(plugin)); +} + +static void +rs_prophoto_class_init(RSProphotoClass *klass) +{ + RSColorSpaceClass *colorclass = RS_COLOR_SPACE_CLASS(klass); + + colorclass->get_icc_profile = get_icc_profile; + colorclass->name = "Linear ProPhoto"; + colorclass->description = _("Large gamut color space"); + + klass->icc_profile = rs_icc_profile_new_from_file(PACKAGE_DATA_DIR "/" PACKAGE "/profiles/prophoto.icc"); +} + +static void +rs_prophoto_init(RSProphoto *prophoto) +{ + /* Source: http://brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html */ + const static RS_MATRIX3 to_pcs = {{ + { 0.7976749, 0.1351917, 0.0313534 }, + { 0.2880402, 0.7118741, 0.0000857 }, + { 0.0000000, 0.0000000, 0.8252100 } + }}; + + rs_color_space_set_matrix_to_pcs(RS_COLOR_SPACE(prophoto), &to_pcs); +} + +static const RSIccProfile * +get_icc_profile(const RSColorSpace *color_space) +{ + RSProphoto *prophoto = RS_PROPHOTO(color_space); + + return RS_PROPHOTO_CLASS(prophoto)->icc_profile; +} Added: trunk/plugins/colorspace-srgb/Makefile.am =================================================================== --- trunk/plugins/colorspace-srgb/Makefile.am (rev 0) +++ trunk/plugins/colorspace-srgb/Makefile.am 2009-10-15 15:28:31 UTC (rev 2720) @@ -0,0 +1,15 @@ +plugindir = $(libdir)/rawstudio/plugins + +INCLUDES = \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + @PACKAGE_CFLAGS@ \ + -I../../librawstudio/ + +lib_LTLIBRARIES = colorspace_srgb.la + +libdir = $(datadir)/rawstudio/plugins/ + +colorspace_srgb_la_LIBADD = @PACKAGE_LIBS@ +colorspace_srgb_la_LDFLAGS = -module -avoid-version +colorspace_srgb_la_SOURCES = colorspace-srgb.c Added: trunk/plugins/colorspace-srgb/colorspace-srgb.c =================================================================== --- trunk/plugins/colorspace-srgb/colorspace-srgb.c (rev 0) +++ trunk/plugins/colorspace-srgb/colorspace-srgb.c 2009-10-15 15:28:31 UTC (rev 2720) @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* Color space tmpl version 1 */ + +#include /* pow() */ +#include +#include "config.h" +#include "gettext.h" + +#define RS_TYPE_SRGB (rs_srgb_type) +#define RS_SRGB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_SRGB, RSSrgb)) +#define RS_SRGB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_SRGB, RSSrgbClass)) +#define RS_IS_SRGB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_SRGB)) + +typedef struct { + RSColorSpace parent; +} RSSrgb; + +typedef struct { + RSColorSpaceClass parent_class; + + RSIccProfile *icc_profile; +} RSSrgbClass; + +RS_DEFINE_COLOR_SPACE(rs_srgb, RSSrgb) + +static const RSIccProfile *get_icc_profile(const RSColorSpace *color_space); +static const RS1dFunction *get_gamma_function(const RSColorSpace *color_space); + +G_MODULE_EXPORT void +rs_plugin_load(RSPlugin *plugin) +{ + rs_srgb_get_type(G_TYPE_MODULE(plugin)); +} + +static void +rs_srgb_class_init(RSSrgbClass *klass) +{ + RSColorSpaceClass *colorclass = RS_COLOR_SPACE_CLASS(klass); + + colorclass->name = "sRGB"; + colorclass->description = _(""); + + colorclass->get_icc_profile = get_icc_profile; + colorclass->get_gamma_function = get_gamma_function; + + klass->icc_profile = rs_icc_profile_new_from_file(PACKAGE_DATA_DIR "/" PACKAGE "/profiles/sRGB.icc"); + +} + +static void +rs_srgb_init(RSSrgb *srgb) +{ + /* Source: http://brucelindbloom.com/Eqn_RGB_XYZ_Matrix.html */ + const static RS_MATRIX3 to_pcs = {{ + { 0.4360747, 0.3850649, 0.1430804 }, + { 0.2225045, 0.7168786, 0.0606169 }, + { 0.0139322, 0.0971045, 0.7141733 }, + }}; + + rs_color_space_set_matrix_to_pcs(RS_COLOR_SPACE(srgb), &to_pcs); +} + +static const RSIccProfile * +get_icc_profile(const RSColorSpace *color_space) +{ + RSSrgb *srgb = RS_SRGB(color_space); + + return RS_SRGB_CLASS(srgb)->icc_profile; +} + +/* Gamma */ + +static gdouble evaluate(const RS1dFunction *func, const gdouble x); +static gdouble evaluate_inverse(const RS1dFunction *func, const gdouble y); + +#define RS_TYPE_SRGB_GAMMA rs_srgb_gamma_get_type() +#define RS_SRGB_GAMMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_SRGB_GAMMA, RSSrgbGamma)) +#define RS_SRGB_GAMMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_SRGB_GAMMA, RSSrgbGammaClass)) +#define RS_IS_SRGB_GAMMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_SRGB_GAMMA)) + +typedef struct { + RS1dFunction parent; +} RSSrgbGamma; + +typedef struct { + RS1dFunctionClass parent_class; +} RSSrgbGammaClass; + +GType rs_srgb_gamma_get_type(void); + +RS1dFunction *rs_srgb_gamma_new(void); + +G_DEFINE_TYPE (RSSrgbGamma, rs_srgb_gamma, RS_TYPE_1D_FUNCTION) + +static void +rs_srgb_gamma_class_init(RSSrgbGammaClass *klass) +{ + RS1dFunctionClass *fclass = RS_1D_FUNCTION_CLASS(klass); + + fclass->evaluate = evaluate; + fclass->evaluate_inverse = evaluate_inverse; +} + +static void +rs_srgb_gamma_init(RSSrgbGamma *gamma) +{ +} + +RS1dFunction * +rs_srgb_gamma_new(void) +{ + return RS_1D_FUNCTION(g_object_new(RS_TYPE_SRGB_GAMMA, NULL)); +} + +static const RS1dFunction * +get_gamma_function(const RSColorSpace *color_space) +{ + static GStaticMutex lock = G_STATIC_MUTEX_INIT; + static RS1dFunction *func = NULL; + + g_static_mutex_lock(&lock); + if (!func) + func = rs_srgb_gamma_new(); + g_static_mutex_unlock(&lock); + + return func; +} + +static gdouble +evaluate(const RS1dFunction *func, const gdouble x) +{ + const gdouble junction = 0.0031308; + + if (x <= junction) + return x * 12.92; + else + return 1.055 * pow(x, 1.0/2.4) - 0.055; +} + +static gdouble +evaluate_inverse(const RS1dFunction *func, const gdouble y) +{ + const gdouble junction = 0.04045; + + if (y <= junction) + return y / 12.92; + else + return pow((y+0.055)/1.055, 2.4); +} From anders at brander.dk Thu Oct 15 17:48:37 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 17:48:37 +0200 Subject: [Rawstudio-commit] r2721 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-15 17:48:36 +0200 (Thu, 15 Oct 2009) New Revision: 2721 Added: trunk/librawstudio/rs-filter-param.c trunk/librawstudio/rs-filter-param.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h Log: Added RSFilterParam skeleton. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-10-15 15:28:31 UTC (rev 2720) +++ trunk/librawstudio/Makefile.am 2009-10-15 15:48:36 UTC (rev 2721) @@ -22,6 +22,7 @@ rs-metadata.h \ rs-filetypes.h \ rs-filter.h \ + rs-filter-param.h \ rs-filter-request.h \ rs-filter-response.h \ rs-output.h \ @@ -58,6 +59,7 @@ rs-metadata.c rs-metadata.h \ rs-filetypes.c rs-filetypes.h \ rs-filter.c rs-filter.h \ + rs-filter-param.c rs-filter-param.h \ rs-filter-request.c rs-filter-request.h \ rs-filter-response.c rs-filter-response.h \ rs-output.c rs-output.h \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-10-15 15:28:31 UTC (rev 2720) +++ trunk/librawstudio/rawstudio.h 2009-10-15 15:48:36 UTC (rev 2721) @@ -42,6 +42,7 @@ #include "rs-lens-db.h" #include "rs-filetypes.h" #include "rs-plugin.h" +#include "rs-filter-param.h" #include "rs-filter-request.h" #include "rs-filter-response.h" #include "rs-filter.h" Added: trunk/librawstudio/rs-filter-param.c =================================================================== --- trunk/librawstudio/rs-filter-param.c (rev 0) +++ trunk/librawstudio/rs-filter-param.c 2009-10-15 15:48:36 UTC (rev 2721) @@ -0,0 +1,35 @@ +#include "rs-filter-param.h" + +G_DEFINE_TYPE(RSFilterParam, rs_filter_param, G_TYPE_OBJECT) + +static void +rs_filter_param_dispose(GObject *object) +{ + G_OBJECT_CLASS(rs_filter_param_parent_class)->dispose (object); +} + +static void +rs_filter_param_finalize(GObject *object) +{ + G_OBJECT_CLASS(rs_filter_param_parent_class)->finalize (object); +} + +static void +rs_filter_param_class_init(RSFilterParamClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = rs_filter_param_dispose; + object_class->finalize = rs_filter_param_finalize; +} + +static void +rs_filter_param_init(RSFilterParam *param) +{ +} + +RSFilterParam * +rs_filter_param_new(void) +{ + return g_object_new (RS_TYPE_FILTER_PARAM, NULL); +} Added: trunk/librawstudio/rs-filter-param.h =================================================================== --- trunk/librawstudio/rs-filter-param.h (rev 0) +++ trunk/librawstudio/rs-filter-param.h 2009-10-15 15:48:36 UTC (rev 2721) @@ -0,0 +1,29 @@ +#ifndef RS_FILTER_PARAM_H +#define RS_FILTER_PARAM_H + +#include + +G_BEGIN_DECLS + +#define RS_TYPE_FILTER_PARAM rs_filter_param_get_type() +#define RS_FILTER_PARAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_FILTER_PARAM, RSFilterParam)) +#define RS_FILTER_PARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_FILTER_PARAM, RSFilterParamClass)) +#define RS_IS_FILTER_PARAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_FILTER_PARAM)) +#define RS_IS_FILTER_PARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_FILTER_PARAM)) +#define RS_FILTER_PARAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_FILTER_PARAM, RSFilterParamClass)) + +typedef struct { + GObject parent; +} RSFilterParam; + +typedef struct { + GObjectClass parent_class; +} RSFilterParamClass; + +GType rs_filter_param_get_type(void); + +RSFilterParam *rs_filter_param_new(void); + +G_END_DECLS + +#endif /* RS_FILTER_PARAM_H */ From anders at brander.dk Thu Oct 15 17:50:30 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 17:50:30 +0200 Subject: [Rawstudio-commit] r2722 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-15 17:50:30 +0200 (Thu, 15 Oct 2009) New Revision: 2722 Modified: trunk/librawstudio/rs-filter-request.c trunk/librawstudio/rs-filter-request.h trunk/librawstudio/rs-filter-response.c trunk/librawstudio/rs-filter-response.h Log: Made RSFilterResponse and RSFilterRequest inherit from RSFilterParam. Modified: trunk/librawstudio/rs-filter-request.c =================================================================== --- trunk/librawstudio/rs-filter-request.c 2009-10-15 15:48:36 UTC (rev 2721) +++ trunk/librawstudio/rs-filter-request.c 2009-10-15 15:50:30 UTC (rev 2722) @@ -21,13 +21,13 @@ #include "rs-filter-request.h" struct _RSFilterRequest { - GObject parent; + RSFilterParam parent; gboolean roi_set; GdkRectangle roi; gboolean quick; }; -G_DEFINE_TYPE(RSFilterRequest, rs_filter_request, G_TYPE_OBJECT) +G_DEFINE_TYPE(RSFilterRequest, rs_filter_request, RS_TYPE_FILTER_PARAM) static void rs_filter_request_finalize(GObject *object) Modified: trunk/librawstudio/rs-filter-request.h =================================================================== --- trunk/librawstudio/rs-filter-request.h 2009-10-15 15:48:36 UTC (rev 2721) +++ trunk/librawstudio/rs-filter-request.h 2009-10-15 15:50:30 UTC (rev 2722) @@ -21,6 +21,7 @@ #define RS_FILTER_REQUEST_H #include +#include "rs-filter-param.h" G_BEGIN_DECLS @@ -34,7 +35,7 @@ typedef struct _RSFilterRequest RSFilterRequest; typedef struct { - GObjectClass parent_class; + RSFilterParamClass parent_class; } RSFilterRequestClass; GType rs_filter_request_get_type(void); Modified: trunk/librawstudio/rs-filter-response.c =================================================================== --- trunk/librawstudio/rs-filter-response.c 2009-10-15 15:48:36 UTC (rev 2721) +++ trunk/librawstudio/rs-filter-response.c 2009-10-15 15:50:30 UTC (rev 2722) @@ -20,7 +20,7 @@ #include "rs-filter-response.h" struct _RSFilterResponse { - GObject parent; + RSFilterParam parent; gboolean dispose_has_run; gboolean roi_set; @@ -32,7 +32,7 @@ GHashTable *properties; }; -G_DEFINE_TYPE(RSFilterResponse, rs_filter_response, G_TYPE_OBJECT) +G_DEFINE_TYPE(RSFilterResponse, rs_filter_response, RS_TYPE_FILTER_PARAM) static void rs_filter_response_dispose(GObject *object) Modified: trunk/librawstudio/rs-filter-response.h =================================================================== --- trunk/librawstudio/rs-filter-response.h 2009-10-15 15:48:36 UTC (rev 2721) +++ trunk/librawstudio/rs-filter-response.h 2009-10-15 15:50:30 UTC (rev 2722) @@ -23,6 +23,7 @@ #include #include #include +#include "rs-filter-param.h" G_BEGIN_DECLS @@ -36,7 +37,7 @@ typedef struct _RSFilterResponse RSFilterResponse; typedef struct { - GObjectClass parent_class; + RSFilterParamClass parent_class; } RSFilterResponseClass; GType rs_filter_response_get_type(void); From anders at brander.dk Thu Oct 15 18:08:04 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 15 Oct 2009 18:08:04 +0200 Subject: [Rawstudio-commit] r2723 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-15 18:08:04 +0200 (Thu, 15 Oct 2009) New Revision: 2723 Modified: trunk/librawstudio/rs-filter-param.c trunk/librawstudio/rs-filter-param.h trunk/librawstudio/rs-filter-response.c trunk/librawstudio/rs-filter-response.h Log: Moved generic filter parameters from RSFilterResponse to RSFilterParam. Modified: trunk/librawstudio/rs-filter-param.c =================================================================== --- trunk/librawstudio/rs-filter-param.c 2009-10-15 15:50:30 UTC (rev 2722) +++ trunk/librawstudio/rs-filter-param.c 2009-10-15 16:08:04 UTC (rev 2723) @@ -5,6 +5,15 @@ static void rs_filter_param_dispose(GObject *object) { + RSFilterParam *filter_param = RS_FILTER_PARAM(object); + + if (!filter_param->dispose_has_run) + { + filter_param->dispose_has_run = TRUE; + + g_hash_table_destroy(filter_param->properties); + } + G_OBJECT_CLASS(rs_filter_param_parent_class)->dispose (object); } @@ -23,9 +32,38 @@ object_class->finalize = rs_filter_param_finalize; } +static inline GValue * +new_value(GType type) +{ + GValue *value = g_slice_new0(GValue); + g_value_init(value, type); + + return value; +} + static void +free_value(gpointer data) +{ + GValue *value = (GValue *) data; + + g_value_unset(value); + g_slice_free(GValue, value); +} + +static inline GValue * +clone_value(const GValue *value) +{ + GType type = G_VALUE_TYPE(value); + GValue *ret = new_value(type); + g_value_copy(value, ret); + + return ret; +} + +static void rs_filter_param_init(RSFilterParam *param) { + param->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_value); } RSFilterParam * @@ -33,3 +71,104 @@ { return g_object_new (RS_TYPE_FILTER_PARAM, NULL); } + +void +rs_filter_param_clone(RSFilterParam *destination, const RSFilterParam *source) +{ + g_assert(RS_IS_FILTER_PARAM(destination)); + g_assert(RS_IS_FILTER_PARAM(source)); + + /* Clone the properties table */ + GHashTableIter iter; + gpointer key, value; + + g_hash_table_iter_init (&iter, source->properties); + while (g_hash_table_iter_next (&iter, &key, &value)) + g_hash_table_insert(destination->properties, (gpointer) g_strdup(key), clone_value(value)); +} + +static void +rs_filter_param_set_gvalue(RSFilterParam *filter_param, const gchar *name, GValue * value) +{ + g_assert(RS_IS_FILTER_PARAM(filter_param)); + g_assert(name != NULL); + g_assert(name[0] != '\0'); + + g_hash_table_insert(filter_param->properties, (gpointer) g_strdup(name), value); +} + +static GValue * +rs_filter_param_get_gvalue(const RSFilterParam *filter_param, const gchar *name) +{ + g_assert(RS_IS_FILTER_PARAM(filter_param)); + + GValue *value = g_hash_table_lookup(filter_param->properties, name); + + return value; +} + +/** + * Set a string property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param str NULL-terminated string to set (will be copied) + */ +void +rs_filter_param_set_string(RSFilterParam *filter_param, const gchar *name, const gchar *str) +{ + GValue *val = new_value(G_TYPE_STRING); + g_value_set_string(val, str); + + rs_filter_param_set_gvalue(filter_param, name, val); +} + +/** + * Get a string property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param str A pointer to a string pointer where the value of the property can be saved. Should not be freed + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean +rs_filter_param_get_string(const RSFilterParam *filter_param, const gchar *name, const gchar ** const str) +{ + GValue *val = rs_filter_param_get_gvalue(filter_param, name); + + if (val && G_VALUE_HOLDS_STRING(val)) + *str = g_value_get_string(val); + + return (val != NULL); +} + +/** + * Set a float property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param value A value to store + */ +void +rs_filter_param_set_float(RSFilterParam *filter_param, const gchar *name, const gfloat value) +{ + GValue *val = new_value(G_TYPE_FLOAT); + g_value_set_float(val, value); + + rs_filter_param_set_gvalue(filter_param, name, val); +} + +/** + * Get a float property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param value A pointer to a gfloat where the value will be stored + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean +rs_filter_param_get_float(const RSFilterParam *filter_param, const gchar *name, gfloat *value) +{ + GValue *val = rs_filter_param_get_gvalue(filter_param, name); + + if (val && G_VALUE_HOLDS_FLOAT(val)) + *value = g_value_get_float(val); + + return (val != NULL); +} Modified: trunk/librawstudio/rs-filter-param.h =================================================================== --- trunk/librawstudio/rs-filter-param.h 2009-10-15 15:50:30 UTC (rev 2722) +++ trunk/librawstudio/rs-filter-param.h 2009-10-15 16:08:04 UTC (rev 2723) @@ -14,6 +14,9 @@ typedef struct { GObject parent; + gboolean dispose_has_run; + + GHashTable *properties; } RSFilterParam; typedef struct { @@ -24,6 +27,44 @@ RSFilterParam *rs_filter_param_new(void); +void +rs_filter_param_clone(RSFilterParam *destination, const RSFilterParam *source); + +/** + * Set a string property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param str NULL-terminated string to set (will be copied) + */ +void rs_filter_param_set_string(RSFilterParam *filter_param, const gchar *name, const gchar *str); + +/** + * Get a string property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param str A pointer to a string pointer where the value of the property can be saved. Should not be freed + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean rs_filter_param_get_string(const RSFilterParam *filter_param, const gchar *name, const gchar ** const str); + +/** + * Set a float property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param value A value to store + */ +void +rs_filter_param_set_float(RSFilterParam *filter_param, const gchar *name, const gfloat value); + +/** + * Get a float property + * @param filter_param A RSFilterParam + * @param name The name of the property + * @param value A pointer to a gfloat where the value will be stored + * @return TRUE if the property was found, FALSE otherwise + */ +gboolean rs_filter_param_get_float(const RSFilterParam *filter_param, const gchar *name, gfloat *value); + G_END_DECLS #endif /* RS_FILTER_PARAM_H */ Modified: trunk/librawstudio/rs-filter-response.c =================================================================== --- trunk/librawstudio/rs-filter-response.c 2009-10-15 15:50:30 UTC (rev 2722) +++ trunk/librawstudio/rs-filter-response.c 2009-10-15 16:08:04 UTC (rev 2723) @@ -28,8 +28,6 @@ gboolean quick; RS_IMAGE16 *image; GdkPixbuf *image8; - - GHashTable *properties; }; G_DEFINE_TYPE(RSFilterResponse, rs_filter_response, RS_TYPE_FILTER_PARAM) @@ -48,8 +46,6 @@ if (filter_response->image8) g_object_unref(filter_response->image8); - - g_hash_table_destroy(filter_response->properties); } G_OBJECT_CLASS (rs_filter_response_parent_class)->dispose (object); @@ -70,42 +66,13 @@ object_class->finalize = rs_filter_response_finalize; } -static inline GValue * -new_value(GType type) -{ - GValue *value = g_slice_new0(GValue); - g_value_init(value, type); - - return value; -} - static void -free_value(gpointer data) -{ - GValue *value = (GValue *) data; - - g_value_unset(value); - g_slice_free(GValue, value); -} - -static inline GValue * -clone_value(const GValue *value) -{ - GType type = G_VALUE_TYPE(value); - GValue *ret = new_value(type); - g_value_copy(value, ret); - - return ret; -} - -static void rs_filter_response_init(RSFilterResponse *filter_response) { filter_response->roi_set = FALSE; filter_response->quick = FALSE; filter_response->image = NULL; filter_response->image8 = NULL; - filter_response->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_value); filter_response->dispose_has_run = FALSE; } @@ -135,13 +102,7 @@ new_filter_response->roi = filter_response->roi; new_filter_response->quick = filter_response->quick; - /* Clone the properties table */ - GHashTableIter iter; - gpointer key, value; - - g_hash_table_iter_init (&iter, filter_response->properties); - while (g_hash_table_iter_next (&iter, &key, &value)) - g_hash_table_insert(new_filter_response->properties, (gpointer) g_strdup(key), clone_value(value)); + rs_filter_param_clone(RS_FILTER_PARAM(new_filter_response), RS_FILTER_PARAM(filter_response)); } return new_filter_response; @@ -314,89 +275,3 @@ return ret; } - -static void -rs_filter_response_set_gvalue(const RSFilterResponse *filter_response, const gchar *name, GValue * value) -{ - g_assert(RS_IS_FILTER_RESPONSE(filter_response)); - g_assert(name != NULL); - g_assert(name[0] != '\0'); - - g_hash_table_insert(filter_response->properties, (gpointer) g_strdup(name), value); -} - -static GValue * -rs_filter_response_get_gvalue(const RSFilterResponse *filter_response, const gchar *name) -{ - g_assert(RS_IS_FILTER_RESPONSE(filter_response)); - - GValue *value = g_hash_table_lookup(filter_response->properties, name); - - return value; -} - -/** - * Set a string property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param str NULL-terminated string to set (will be copied) - */ -void -rs_filter_response_set_string(const RSFilterResponse *filter_response, const gchar *name, const gchar *str) -{ - GValue *val = new_value(G_TYPE_STRING); - g_value_set_string(val, str); - - rs_filter_response_set_gvalue(filter_response, name, val); -} - -/** - * Get a string property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param str A pointer to a string pointer where the value of the property can be saved. Should not be freed - * @return TRUE if the property was found, FALSE otherwise - */ -gboolean -rs_filter_response_get_string(const RSFilterResponse *filter_response, const gchar *name, const gchar ** const str) -{ - GValue *val = rs_filter_response_get_gvalue(filter_response, name); - - if (val && G_VALUE_HOLDS_STRING(val)) - *str = g_value_get_string(val); - - return (val != NULL); -} - -/** - * Set a float property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param value A value to store - */ -void -rs_filter_response_set_float(const RSFilterResponse *filter_response, const gchar *name, const gfloat value) -{ - GValue *val = new_value(G_TYPE_FLOAT); - g_value_set_float(val, value); - - rs_filter_response_set_gvalue(filter_response, name, val); -} - -/** - * Get a float property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param value A pointer to a gfloat where the value will be stored - * @return TRUE if the property was found, FALSE otherwise - */ -gboolean -rs_filter_response_get_float(const RSFilterResponse *filter_response, const gchar *name, gfloat *value) -{ - GValue *val = rs_filter_response_get_gvalue(filter_response, name); - - if (val && G_VALUE_HOLDS_FLOAT(val)) - *value = g_value_get_float(val); - - return (val != NULL); -} Modified: trunk/librawstudio/rs-filter-response.h =================================================================== --- trunk/librawstudio/rs-filter-response.h 2009-10-15 15:50:30 UTC (rev 2722) +++ trunk/librawstudio/rs-filter-response.h 2009-10-15 16:08:04 UTC (rev 2723) @@ -130,41 +130,6 @@ */ GdkPixbuf *rs_filter_response_get_image8(const RSFilterResponse *filter_response); -/** - * Set a string property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param str NULL-terminated string to set (will be copied) - */ -void rs_filter_response_set_string(const RSFilterResponse *filter_response, const gchar *name, const gchar *str); - -/** - * Get a string property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param str A pointer to a string pointer where the value of the property can be saved. Should not be freed - * @return TRUE if the property was found, FALSE otherwise - */ -gboolean rs_filter_response_get_string(const RSFilterResponse *filter_response, const gchar *name, const gchar ** const str); - -/** - * Set a float property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param value A value to store - */ -void -rs_filter_response_set_float(const RSFilterResponse *filter_response, const gchar *name, const gfloat value); - -/** - * Get a float property - * @param filter_response A RSFilterResponse - * @param name The name of the property - * @param value A pointer to a gfloat where the value will be stored - * @return TRUE if the property was found, FALSE otherwise - */ -gboolean rs_filter_response_get_float(const RSFilterResponse *filter_response, const gchar *name, gfloat *value); - G_END_DECLS #endif /* RS_FILTER_RESPONSE_H */ From klauspost at gmail.com Mon Oct 19 19:41:24 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 19 Oct 2009 19:41:24 +0200 Subject: [Rawstudio-commit] r2724 - trunk/librawstudio Message-ID: Author: post Date: 2009-10-19 19:41:23 +0200 (Mon, 19 Oct 2009) New Revision: 2724 Modified: trunk/librawstudio/rs-filter.c Log: Only print console timing information on "slow" filters, that takes >50ms to complete, and calculate MP/s on the ROI-part of the image, if present. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-10-15 16:08:04 UTC (rev 2723) +++ trunk/librawstudio/rs-filter.c 2009-10-19 17:41:23 UTC (rev 2724) @@ -206,25 +206,39 @@ elapsed = g_timer_elapsed(gt, NULL) - last_elapsed; - printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); - if ((elapsed > 0.001) && (image != NULL)) - printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(image->w*image->h))/elapsed/1000000.0); - if (image) - printf(" [w: %d, h: %d, channels: %d, pixelsize: %d, rowstride: %d]", - image->w, image->h, image->channels, image->pixelsize, image->rowstride); - printf("\n"); - last_elapsed += elapsed; - g_assert(RS_IS_IMAGE16(image) || (image == NULL)); + if ((elapsed > 0.05) && (image != NULL)) + { + gint iw = image->w; + gint ih = image->h; + if (rs_filter_response_get_roi(response)) + { + GdkRectangle *roi = rs_filter_response_get_roi(response); + iw = roi->width; + ih = roi->height; + } + printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); + if ((elapsed > 0.001) && (image != NULL)) + printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(iw*ih))/elapsed/1000000.0); + if (image) + printf(" [w: %d, h: %d, channels: %d, pixelsize: %d, rowstride: %d]", + image->w, image->h, image->channels, image->pixelsize, image->rowstride); + printf("\n"); + g_assert(RS_IS_IMAGE16(image) || (image == NULL)); + } + count--; if (count == -1) { last_elapsed = 0.0; - printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); + if (g_timer_elapsed(gt,NULL) > 0.1) + printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); g_timer_destroy(gt); } - + + last_elapsed += elapsed; + if (image) g_object_unref(image); @@ -265,23 +279,32 @@ image = rs_filter_response_get_image8(response); elapsed = g_timer_elapsed(gt, NULL) - last_elapsed; + + if ((elapsed > 0.05) && (image != NULL)) { + gint iw = gdk_pixbuf_get_width(image); + gint ih = gdk_pixbuf_get_height(image); + if (rs_filter_response_get_roi(response)) + { + GdkRectangle *roi = rs_filter_response_get_roi(response); + iw = roi->width; + ih = roi->height; + } + printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed * 1000); + printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(iw * ih)) / elapsed / 1000000.0); + printf("\n"); + } - printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); - if ((elapsed > 0.001) && (image != NULL)) - printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(gdk_pixbuf_get_width(image)*gdk_pixbuf_get_height(image)))/elapsed/1000000.0); - printf("\n"); - last_elapsed += elapsed; - g_assert(GDK_IS_PIXBUF(image) || (image == NULL)); count--; if (count == -1) { last_elapsed = 0.0; - printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); + if (g_timer_elapsed(gt,NULL) > 0.1) + printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); g_timer_destroy(gt); } - + last_elapsed += elapsed; if (image) g_object_unref(image); From klauspost at gmail.com Mon Oct 19 19:43:25 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 19 Oct 2009 19:43:25 +0200 Subject: [Rawstudio-commit] r2725 - trunk/librawstudio Message-ID: Author: post Date: 2009-10-19 19:43:25 +0200 (Mon, 19 Oct 2009) New Revision: 2725 Modified: trunk/librawstudio/rs-filter.c Log: rs_filter_get_recursive: Only return ask enabled filters for settings. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-10-19 17:41:23 UTC (rev 2724) +++ trunk/librawstudio/rs-filter.c 2009-10-19 17:43:25 UTC (rev 2725) @@ -485,7 +485,7 @@ current_filter = filter; /* Iterate through all filter previous to filter */ do { - if (g_object_class_find_property(G_OBJECT_GET_CLASS(current_filter), property_name)) + if (current_filter->enabled && g_object_class_find_property(G_OBJECT_GET_CLASS(current_filter), property_name)) { g_object_get(current_filter, property_name, property_ret, NULL); break; From klauspost at gmail.com Mon Oct 19 19:49:59 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 19 Oct 2009 19:49:59 +0200 Subject: [Rawstudio-commit] r2726 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-10-19 19:49:59 +0200 (Mon, 19 Oct 2009) New Revision: 2726 Modified: trunk/plugins/denoise/complexfilter-x86.cpp trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h trunk/plugins/denoise/denoise.c trunk/plugins/denoise/denoiseinterface.h trunk/plugins/denoise/fftdenoiser.cpp trunk/plugins/denoise/fftdenoiseryuv.cpp trunk/plugins/denoise/fftdenoiseryuv.h Log: Denoiser: - Adjust settings based on scale, so 100% view visually matches scaled view. - "Beta" (noise-retain) parameter can now be set individually on chroma/luma components. - Per-block division of beta is factored out. - Overall strength of sharpen/denoise adjusted (more agressive settings are now possible, especially chroma noise). Modified: trunk/plugins/denoise/complexfilter-x86.cpp =================================================================== --- trunk/plugins/denoise/complexfilter-x86.cpp 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/complexfilter-x86.cpp 2009-10-19 17:49:59 UTC (rev 2726) @@ -366,7 +366,6 @@ #if defined (__x86_64__) void ComplexWienerFilterDeGrid::processSharpen_SSE3( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; @@ -461,7 +460,6 @@ void ComplexWienerFilterDeGrid::processSharpen_SSE3( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; @@ -552,7 +550,6 @@ void ComplexWienerFilterDeGrid::processSharpen_SSE( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; @@ -648,7 +645,6 @@ void ComplexWienerFilterDeGrid::processNoSharpen_SSE( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; @@ -722,7 +718,6 @@ #if defined (__x86_64__) void ComplexWienerFilterDeGrid::processNoSharpen_SSE3( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; @@ -882,7 +877,6 @@ #else // 32 bits void ComplexWienerFilterDeGrid::processNoSharpen_SSE3( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; Modified: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/complexfilter.cpp 2009-10-19 17:49:59 UTC (rev 2726) @@ -158,7 +158,7 @@ ComplexWienerFilter::ComplexWienerFilter( int block_width, int block_height,float _beta, float _sigma ) : ComplexFilter(block_width, block_height) { - beta = _beta; + lowlimit = (_beta-1)/_beta; sigmaSquaredNoiseNormed = _sigma*_sigma/norm; } @@ -175,7 +175,6 @@ void ComplexWienerFilter::processNoSharpen( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; float WienerFactor; @@ -197,7 +196,6 @@ void ComplexWienerFilter::processSharpen( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; float WienerFactor; @@ -227,7 +225,7 @@ ComplexFilter(block_width, block_height), pfactor(pattern_strength) { - beta = _beta; + lowlimit = (_beta-1)/_beta; pattern = _pattern; } @@ -240,7 +238,6 @@ void ComplexPatternFilter::processNoSharpen( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 g_assert(bw == block->w); g_assert(bh == block->h); int x,y; @@ -279,7 +276,7 @@ fftwf_plan plan_forward, FFTWindow *_window) : DeGridComplexFilter(block_width, block_height, _degrid, _window, plan_forward) { - beta = _beta; + lowlimit = (_beta-1)/_beta; sigmaSquaredNoiseNormed = _sigma*_sigma/norm; } @@ -308,7 +305,6 @@ return processNoSharpen_SSE(block); #endif - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; float WienerFactor; @@ -349,7 +345,6 @@ return processSharpen_SSE(block); #endif - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; float WienerFactor; @@ -386,7 +381,7 @@ DeGridComplexFilter(block_width, block_height, _degrid, _window, plan_forward), pattern(_pattern) { - beta = _beta; + lowlimit = (_beta-1)/_beta; sigmaSquaredNoiseNormed = _sigma*_sigma/norm; } @@ -401,7 +396,6 @@ void ComplexFilterPatternDeGrid::processNoSharpen( ComplexBlock* block ) { - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; float WienerFactor; @@ -436,7 +430,6 @@ if (sigmaSquaredNoiseNormed <= 1e-15f) return processSharpenOnly(block); - float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; float WienerFactor; Modified: trunk/plugins/denoise/complexfilter.h =================================================================== --- trunk/plugins/denoise/complexfilter.h 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/complexfilter.h 2009-10-19 17:49:59 UTC (rev 2726) @@ -38,7 +38,7 @@ const int bw; const int bh; const float norm; // Normalization factor - float beta; + float lowlimit; float sharpen; float sigmaSquaredSharpenMin; float sigmaSquaredSharpenMax; Modified: trunk/plugins/denoise/denoise.c =================================================================== --- trunk/plugins/denoise/denoise.c 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/denoise.c 2009-10-19 17:49:59 UTC (rev 2726) @@ -242,6 +242,9 @@ g_object_unref(input); return response; } + + gfloat scale = 1.0; + rs_filter_get_recursive(RS_FILTER(denoise), "scale", &scale, NULL); output = rs_image16_copy(input, TRUE); g_object_unref(input); @@ -254,17 +257,22 @@ else tmp = g_object_ref(output); + denoise->info.image = tmp; - denoise->info.sigmaLuma = ((float) denoise->denoise_luma) / 3.0; - denoise->info.sigmaChroma = ((float) denoise->denoise_chroma) / 2.0; - denoise->info.sharpenLuma = ((float) denoise->sharpen) / 20.0; - denoise->info.sharpenCutoffLuma = 0.1f; - denoise->info.beta = 1.0; + denoise->info.sigmaLuma = ((float) denoise->denoise_luma * scale) / 3.0; + denoise->info.sigmaChroma = ((float) denoise->denoise_chroma * scale) / 1.5; + denoise->info.sharpenLuma = (float) denoise->sharpen / 20.0f; + denoise->info.sharpenCutoffLuma = 0.15f * scale; + denoise->info.betaLuma = 1.025; denoise->info.sharpenChroma = 0.0f; - denoise->info.sharpenMinSigmaLuma = denoise->info.sigmaLuma * 1.25; - + denoise->info.sharpenMinSigmaLuma = denoise->info.sigmaLuma * 2.0; + denoise->info.sharpenMaxSigmaLuma = denoise->info.sharpenMinSigmaLuma + denoise->info.sharpenLuma * 2.0f; denoise->info.redCorrection = (1.0+denoise->warmth)*(2.0-denoise->tint); denoise->info.blueCorrection = (1.0-denoise->warmth)*(2.0-denoise->tint); + + //TODO: Enable, when DCP is inserted +// denoise->info.redCorrection = 1.0f; +// denoise->info.blueCorrection = 1.0f; denoiseImage(&denoise->info); g_object_unref(tmp); Modified: trunk/plugins/denoise/denoiseinterface.h =================================================================== --- trunk/plugins/denoise/denoiseinterface.h 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/denoiseinterface.h 2009-10-19 17:49:59 UTC (rev 2726) @@ -41,7 +41,9 @@ RS_IMAGE16* image; // This will be input and output float sigmaLuma; // In RGB mode this is used for all planes, YUV mode only luma. float sigmaChroma; // Used only in YUV mode. - float beta; // Used in all modes. + float betaLuma; // In RGB mode this is used for all planes, YUV mode only luma. + float betaChroma; // Used only in YUV mode. + /* Sharpening - Luma is used for all planes in RGB */ float sharpenLuma; // sharpening strength (default=0 - not sharpen) float sharpenCutoffLuma; // sharpening cutoff frequency, relative to max (default=0.3) Modified: trunk/plugins/denoise/fftdenoiser.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiser.cpp 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/fftdenoiser.cpp 2009-10-19 17:49:59 UTC (rev 2726) @@ -168,7 +168,7 @@ void FFTDenoiser::setParameters( FFTDenoiseInfo *info ) { sigma = info->sigmaLuma *SIGMA_FACTOR; - beta = max(1.0f, info->beta); + beta = max(1.0f, info->betaLuma); sharpen = info->sharpenLuma; sharpenCutoff = info->sharpenCutoffLuma; sharpenMinSigma = info->sharpenMinSigmaLuma*SIGMA_FACTOR; @@ -195,8 +195,9 @@ } info->_this = t; // Initialize parameters to default - info->beta = 1.0f; - info->sigmaLuma = 1.0f; + info->betaLuma = 1.0f; + info->betaChroma = 1.0f; + info->sigmaLuma = 1.0f; info->sigmaChroma = 1.0f; info->sharpenLuma = 0.0f; info->sharpenChroma = 0.0f; Modified: trunk/plugins/denoise/fftdenoiseryuv.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-10-19 17:49:59 UTC (rev 2726) @@ -57,11 +57,11 @@ filter->setSharpen(sharpen, sharpenMinSigma, sharpenMaxSigma, sharpenCutoff); img.setFilter(0,filter,&window); - filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, beta, sigmaChroma, 1.0, plan_forward, &window); + filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, betaChroma, sigmaChroma, 1.0, plan_forward, &window); filter->setSharpen(sharpenChroma, sharpenMinSigmaChroma, sharpenMaxSigmaChroma, sharpenCutoffChroma); img.setFilter(1,filter,&window); - filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, beta, sigmaChroma, 1.0, plan_forward, &window); + filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, betaChroma, sigmaChroma, 1.0, plan_forward, &window); filter->setSharpen(sharpenChroma, sharpenMinSigmaChroma, sharpenMaxSigmaChroma, sharpenCutoffChroma); img.setFilter(2,filter,&window); @@ -80,6 +80,7 @@ FFTDenoiser::setParameters(info); sigmaLuma = info->sigmaLuma*SIGMA_FACTOR; sigmaChroma = info->sigmaChroma*SIGMA_FACTOR; + betaChroma = info->betaChroma; sharpen = info->sharpenLuma; sharpenCutoff = info->sharpenCutoffLuma; sharpenMinSigma = info->sharpenMinSigmaLuma*SIGMA_FACTOR; Modified: trunk/plugins/denoise/fftdenoiseryuv.h =================================================================== --- trunk/plugins/denoise/fftdenoiseryuv.h 2009-10-19 17:43:25 UTC (rev 2725) +++ trunk/plugins/denoise/fftdenoiseryuv.h 2009-10-19 17:49:59 UTC (rev 2726) @@ -29,6 +29,7 @@ virtual ~FFTDenoiserYUV(void); virtual void denoiseImage(RS_IMAGE16* image); virtual void setParameters( FFTDenoiseInfo *info); + float betaChroma; float sigmaLuma; float sigmaChroma; float sharpenChroma; From anders at brander.dk Mon Oct 19 22:26:20 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 19 Oct 2009 22:26:20 +0200 Subject: [Rawstudio-commit] r2727 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-19 22:26:20 +0200 (Mon, 19 Oct 2009) New Revision: 2727 Modified: trunk/librawstudio/rs-filter.c Log: Fixed duration calculation in rs_filter_get_image() and rs_filter_get_image8(). Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-10-19 17:49:59 UTC (rev 2726) +++ trunk/librawstudio/rs-filter.c 2009-10-19 20:26:20 UTC (rev 2727) @@ -228,6 +228,8 @@ g_assert(RS_IS_IMAGE16(image) || (image == NULL)); } + last_elapsed += elapsed; + count--; if (count == -1) { @@ -237,8 +239,6 @@ g_timer_destroy(gt); } - last_elapsed += elapsed; - if (image) g_object_unref(image); @@ -294,6 +294,8 @@ printf("\n"); } + last_elapsed += elapsed; + g_assert(GDK_IS_PIXBUF(image) || (image == NULL)); count--; @@ -304,7 +306,7 @@ printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); g_timer_destroy(gt); } - last_elapsed += elapsed; + if (image) g_object_unref(image); From anders at brander.dk Tue Oct 20 00:26:14 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 20 Oct 2009 00:26:14 +0200 Subject: [Rawstudio-commit] r2728 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-20 00:26:13 +0200 (Tue, 20 Oct 2009) New Revision: 2728 Modified: trunk/librawstudio/rs-filter-request.c Log: Remember to clone params in rs_filter_request_clone(). Modified: trunk/librawstudio/rs-filter-request.c =================================================================== --- trunk/librawstudio/rs-filter-request.c 2009-10-19 20:26:20 UTC (rev 2727) +++ trunk/librawstudio/rs-filter-request.c 2009-10-19 22:26:13 UTC (rev 2728) @@ -76,6 +76,8 @@ new_filter_request->roi_set = filter_request->roi_set; new_filter_request->roi = filter_request->roi; new_filter_request->quick = filter_request->quick; + + rs_filter_param_clone(RS_FILTER_PARAM(new_filter_request), RS_FILTER_PARAM(filter_request)); } return new_filter_request; From anders at brander.dk Tue Oct 20 00:58:28 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 20 Oct 2009 00:58:28 +0200 Subject: [Rawstudio-commit] r2729 - trunk/contrib Message-ID: Author: abrander Date: 2009-10-20 00:58:28 +0200 (Tue, 20 Oct 2009) New Revision: 2729 Modified: trunk/contrib/filter-template.c Log: Updated filter template. Modified: trunk/contrib/filter-template.c =================================================================== --- trunk/contrib/filter-template.c 2009-10-19 22:26:13 UTC (rev 2728) +++ trunk/contrib/filter-template.c 2009-10-19 22:58:28 UTC (rev 2729) @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Plugin tmpl version 4 */ +/* Plugin tmpl version 5 */ #include @@ -48,7 +48,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static RS_IMAGE16 *get_image(RSFilter *filter); +static RSFilterResponse *get_image(RSFilter *filter, const RSFilterRequest *request); static gint get_width(RSFilter *filter); static gint get_height(RSFilter *filter); @@ -123,19 +123,30 @@ } } -static RS_IMAGE16 * -get_image(RSFilter *filter) +static RSFilterResponse * +get_image(RSFilter *filter, const RSFilterRequest *request) { RSTemplate *template = RS_TEMPLATE(filter); + RSFilterResponse *previous_response; + RSFilterResponse *response; RS_IMAGE16 *input; RS_IMAGE16 *output = NULL; - input = rs_filter_get_image(filter->previous); + previous_response = rs_filter_get_image(filter->previous, request); + input = rs_filter_response_get_image(previous_response); + if (!RS_IS_IMAGE16(input)) + return previous_response; - /* Process */ + response = rs_filter_response_clone(previous_response); + g_object_unref(previous_response); + output = rs_image16_copy(input, FALSE); + rs_filter_response_set_image(response, output); + g_object_unref(output); + /* Process output */ + g_object_unref(input); - return output; + return response; } static gint From anders at brander.dk Wed Oct 21 02:52:26 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 21 Oct 2009 02:52:26 +0200 Subject: [Rawstudio-commit] r2730 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-21 02:52:25 +0200 (Wed, 21 Oct 2009) New Revision: 2730 Modified: trunk/librawstudio/rs-color-space.c Log: Initialize transform matrices in rs_color_space_init(). Modified: trunk/librawstudio/rs-color-space.c =================================================================== --- trunk/librawstudio/rs-color-space.c 2009-10-19 22:58:28 UTC (rev 2729) +++ trunk/librawstudio/rs-color-space.c 2009-10-21 00:52:25 UTC (rev 2730) @@ -29,6 +29,8 @@ static void rs_color_space_init(RSColorSpace *color_space) { + matrix3_identity(&color_space->matrix_to_pcs); + matrix3_identity(&color_space->matrix_from_pcs); } /** From anders at brander.dk Wed Oct 21 02:53:20 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 21 Oct 2009 02:53:20 +0200 Subject: [Rawstudio-commit] r2731 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-21 02:53:20 +0200 (Wed, 21 Oct 2009) New Revision: 2731 Modified: trunk/librawstudio/rs-color-space.h Log: Removed unused get_to_pcs and get_from_pcs from RSColorSpaceClass. Modified: trunk/librawstudio/rs-color-space.h =================================================================== --- trunk/librawstudio/rs-color-space.h 2009-10-21 00:52:25 UTC (rev 2730) +++ trunk/librawstudio/rs-color-space.h 2009-10-21 00:53:20 UTC (rev 2731) @@ -78,8 +78,6 @@ const gchar *name; const gchar *description; - RS_MATRIX3 (*get_to_pcs)(const RSColorSpace *color_space); - RS_MATRIX3 (*get_from_pcs)(const RSColorSpace *color_space); const RSIccProfile *(*get_icc_profile)(const RSColorSpace *color_space); const RS1dFunction *(*get_gamma_function)(const RSColorSpace *color_space); } RSColorSpaceClass; From anders at brander.dk Wed Oct 21 03:01:37 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 21 Oct 2009 03:01:37 +0200 Subject: [Rawstudio-commit] r2732 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-21 03:01:36 +0200 (Wed, 21 Oct 2009) New Revision: 2732 Modified: trunk/librawstudio/rs-color-space.h Log: Added flags to RSColorSpace. Modified: trunk/librawstudio/rs-color-space.h =================================================================== --- trunk/librawstudio/rs-color-space.h 2009-10-21 00:53:20 UTC (rev 2731) +++ trunk/librawstudio/rs-color-space.h 2009-10-21 01:01:36 UTC (rev 2732) @@ -65,9 +65,14 @@ #define RS_IS_COLOR_SPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_COLOR_SPACE)) #define RS_COLOR_SPACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_COLOR_SPACE, RSColorSpaceClass)) +typedef enum { + RS_COLOR_SPACE_FLAG_REQUIRES_CMS = 1 +} RSColorSpaceFlag; + typedef struct { GObject parent; + RSColorSpaceFlag flags; RS_MATRIX3 matrix_to_pcs; RS_MATRIX3 matrix_from_pcs; } RSColorSpace; @@ -82,6 +87,8 @@ const RS1dFunction *(*get_gamma_function)(const RSColorSpace *color_space); } RSColorSpaceClass; +#define RS_COLOR_SPACE_REQUIRES_CMS(color_space) (!!((color_space)->flags & RS_COLOR_SPACE_FLAG_REQUIRES_CMS)) + GType rs_color_space_get_type(void); /** From anders at brander.dk Wed Oct 21 03:22:14 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 21 Oct 2009 03:22:14 +0200 Subject: [Rawstudio-commit] r2733 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-21 03:22:14 +0200 (Wed, 21 Oct 2009) New Revision: 2733 Modified: trunk/librawstudio/rs-color-space.c trunk/librawstudio/rs-color-space.h Log: Moved rawstudio.h include to better support tailing. Modified: trunk/librawstudio/rs-color-space.c =================================================================== --- trunk/librawstudio/rs-color-space.c 2009-10-21 01:01:36 UTC (rev 2732) +++ trunk/librawstudio/rs-color-space.c 2009-10-21 01:22:14 UTC (rev 2733) @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "rs-color-space.h" +#include "rawstudio.h" G_DEFINE_TYPE (RSColorSpace, rs_color_space, G_TYPE_OBJECT) Modified: trunk/librawstudio/rs-color-space.h =================================================================== --- trunk/librawstudio/rs-color-space.h 2009-10-21 01:01:36 UTC (rev 2732) +++ trunk/librawstudio/rs-color-space.h 2009-10-21 01:22:14 UTC (rev 2733) @@ -21,7 +21,6 @@ #define RS_COLOR_SPACE_H #include -#include "rawstudio.h" G_BEGIN_DECLS From anders at brander.dk Wed Oct 21 03:52:01 2009 From: anders at brander.dk (Anders Brander) Date: Wed, 21 Oct 2009 03:52:01 +0200 Subject: [Rawstudio-commit] r2734 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-10-21 03:52:00 +0200 (Wed, 21 Oct 2009) New Revision: 2734 Modified: trunk/librawstudio/rs-filter-param.c trunk/librawstudio/rs-filter-param.h Log: Added missing GPL header to rs-filter-param.*. Modified: trunk/librawstudio/rs-filter-param.c =================================================================== --- trunk/librawstudio/rs-filter-param.c 2009-10-21 01:22:14 UTC (rev 2733) +++ trunk/librawstudio/rs-filter-param.c 2009-10-21 01:52:00 UTC (rev 2734) @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + #include "rs-filter-param.h" G_DEFINE_TYPE(RSFilterParam, rs_filter_param, G_TYPE_OBJECT) Modified: trunk/librawstudio/rs-filter-param.h =================================================================== --- trunk/librawstudio/rs-filter-param.h 2009-10-21 01:22:14 UTC (rev 2733) +++ trunk/librawstudio/rs-filter-param.h 2009-10-21 01:52:00 UTC (rev 2734) @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + #ifndef RS_FILTER_PARAM_H #define RS_FILTER_PARAM_H From klauspost at gmail.com Thu Oct 22 16:41:02 2009 From: klauspost at gmail.com (Klaus Post) Date: Thu, 22 Oct 2009 16:41:02 +0200 Subject: [Rawstudio-commit] rawspeed r160 - / Message-ID: Author: post Date: 2009-10-22 16:41:02 +0200 (Thu, 22 Oct 2009) New Revision: 160 Modified: cameras.xml Log: - Added support for Nikon D3s. Modified: cameras.xml =================================================================== --- cameras.xml 2009-10-09 16:02:52 UTC (rev 159) +++ cameras.xml 2009-10-22 14:41:02 UTC (rev 160) @@ -343,6 +343,16 @@ + + + RED + GREEN + GREEN + BLUE + + + + RED From klauspost at gmail.com Thu Oct 22 18:00:50 2009 From: klauspost at gmail.com (Klaus Post) Date: Thu, 22 Oct 2009 18:00:50 +0200 Subject: [Rawstudio-commit] rawspeed r161 - / Message-ID: Author: post Date: 2009-10-22 18:00:50 +0200 (Thu, 22 Oct 2009) New Revision: 161 Modified: cameras.xml Log: - Added support for Canon Powershot G11. Modified: cameras.xml =================================================================== --- cameras.xml 2009-10-22 14:41:02 UTC (rev 160) +++ cameras.xml 2009-10-22 16:00:50 UTC (rev 161) @@ -233,6 +233,16 @@ + + + RED + GREEN + GREEN + BLUE + + + + GREEN From klauspost at gmail.com Sun Oct 25 13:34:37 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 25 Oct 2009 13:34:37 +0100 Subject: [Rawstudio-commit] rawspeed r162 - RawSpeed Message-ID: Author: post Date: 2009-10-25 13:34:36 +0100 (Sun, 25 Oct 2009) New Revision: 162 Modified: RawSpeed/ArwDecoder.cpp RawSpeed/ArwDecoder.h RawSpeed/BitPumpJPEG.cpp RawSpeed/BitPumpJPEG.h RawSpeed/BitPumpMSB.cpp RawSpeed/BitPumpMSB.h RawSpeed/BitPumpPlain.cpp RawSpeed/BitPumpPlain.h RawSpeed/BlackArea.cpp RawSpeed/BlackArea.h RawSpeed/ByteStream.cpp RawSpeed/ByteStream.h RawSpeed/Camera.cpp RawSpeed/Camera.h RawSpeed/CameraMetaData.cpp RawSpeed/CameraMetaData.h RawSpeed/CameraMetadataException.cpp RawSpeed/CameraMetadataException.h RawSpeed/ColorFilterArray.cpp RawSpeed/ColorFilterArray.h RawSpeed/Common.h RawSpeed/Cr2Decoder.cpp RawSpeed/Cr2Decoder.h RawSpeed/DngDecoder.cpp RawSpeed/DngDecoder.h RawSpeed/DngDecoderSlices.cpp RawSpeed/DngDecoderSlices.h RawSpeed/FileIOException.cpp RawSpeed/FileIOException.h RawSpeed/FileMap.cpp RawSpeed/FileMap.h RawSpeed/FileReader.cpp RawSpeed/FileReader.h RawSpeed/LJpegDecompressor.cpp RawSpeed/LJpegDecompressor.h RawSpeed/LJpegPlain.cpp RawSpeed/LJpegPlain.h RawSpeed/NefDecoder.cpp RawSpeed/NefDecoder.h RawSpeed/NikonDecompressor.cpp RawSpeed/NikonDecompressor.h RawSpeed/OrfDecoder.cpp RawSpeed/OrfDecoder.h RawSpeed/PefDecoder.cpp RawSpeed/PefDecoder.h RawSpeed/PentaxDecompressor.cpp RawSpeed/PentaxDecompressor.h RawSpeed/PlanarRawImage.cpp RawSpeed/PlanarRawImage.h RawSpeed/Point.h RawSpeed/RawDecoder.cpp RawSpeed/RawDecoder.h RawSpeed/RawDecoderException.cpp RawSpeed/RawDecoderException.h RawSpeed/RawImage.cpp RawSpeed/RawImage.h RawSpeed/RawSpeed.cpp RawSpeed/RgbImage.cpp RawSpeed/RgbImage.h RawSpeed/Rw2Decoder.cpp RawSpeed/Rw2Decoder.h RawSpeed/TiffEntry.cpp RawSpeed/TiffEntry.h RawSpeed/TiffEntryBE.cpp RawSpeed/TiffEntryBE.h RawSpeed/TiffIFD.cpp RawSpeed/TiffIFD.h RawSpeed/TiffIFDBE.cpp RawSpeed/TiffIFDBE.h RawSpeed/TiffParser.cpp RawSpeed/TiffParser.h RawSpeed/TiffParserException.cpp RawSpeed/TiffParserException.h RawSpeed/TiffParserHeaderless.cpp RawSpeed/TiffParserHeaderless.h RawSpeed/TiffParserOlympus.cpp RawSpeed/TiffParserOlympus.h RawSpeed/TiffTag.h RawSpeed/rawstudio-plugin-api.cpp Log: Put all code in "RawSpeed" namespace. Modified: RawSpeed/ArwDecoder.cpp =================================================================== --- RawSpeed/ArwDecoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/ArwDecoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,7 @@ http://www.klauspost.com */ +namespace RawSpeed { ArwDecoder::ArwDecoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD) { @@ -210,3 +211,5 @@ } } } + +} // namespace RawSpeed Modified: RawSpeed/ArwDecoder.h =================================================================== --- RawSpeed/ArwDecoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/ArwDecoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,8 @@ #include "TiffIFD.h" #include "BitPumpPlain.h" +namespace RawSpeed { + class ArwDecoder : public RawDecoder { @@ -42,3 +44,5 @@ guint curve[0x4001]; ByteStream *in; }; + +} // namespace RawSpeed Modified: RawSpeed/BitPumpJPEG.cpp =================================================================== --- RawSpeed/BitPumpJPEG.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BitPumpJPEG.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,7 @@ Copyright (C) 2007 Hubert Figuiere, released under LGPL */ +namespace RawSpeed { /*** Used for entropy encoded sections ***/ @@ -201,3 +202,4 @@ BitPumpJPEG::~BitPumpJPEG(void) { } +} // namespace RawSpeed Modified: RawSpeed/BitPumpJPEG.h =================================================================== --- RawSpeed/BitPumpJPEG.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BitPumpJPEG.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,9 +22,10 @@ #pragma once #include "ByteStream.h" +namespace RawSpeed { + // Note: Allocated buffer MUST be at least size+sizeof(guint) large. - class BitPumpJPEG { public: @@ -63,4 +64,4 @@ private: }; - +} // namespace RawSpeed Modified: RawSpeed/BitPumpMSB.cpp =================================================================== --- RawSpeed/BitPumpMSB.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BitPumpMSB.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + /*** Used for entropy encoded sections ***/ #define BITS_PER_LONG (8*sizeof(guint)) @@ -177,3 +179,4 @@ BitPumpMSB::~BitPumpMSB(void) { } +} // namespace RawSpeed Modified: RawSpeed/BitPumpMSB.h =================================================================== --- RawSpeed/BitPumpMSB.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BitPumpMSB.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,9 +22,10 @@ #pragma once #include "ByteStream.h" +namespace RawSpeed { + // Note: Allocated buffer MUST be at least size+sizeof(guint) large. - class BitPumpMSB { public: @@ -63,4 +64,4 @@ private: }; - +} // namespace RawSpeed Modified: RawSpeed/BitPumpPlain.cpp =================================================================== --- RawSpeed/BitPumpPlain.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BitPumpPlain.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + /*** Used for entropy encoded sections ***/ #define BITS_PER_LONG (8*sizeof(guint)) @@ -113,3 +115,5 @@ BitPumpPlain::~BitPumpPlain(void) { } + +} // namespace RawSpeed Modified: RawSpeed/BitPumpPlain.h =================================================================== --- RawSpeed/BitPumpPlain.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BitPumpPlain.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,9 +22,10 @@ #pragma once #include "ByteStream.h" +namespace RawSpeed { + // Note: Allocated buffer MUST be at least size+sizeof(guint) large. - class BitPumpPlain { public: @@ -53,4 +54,4 @@ private: }; - +} // namespace RawSpeed Modified: RawSpeed/BlackArea.cpp =================================================================== --- RawSpeed/BlackArea.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BlackArea.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + BlackArea::BlackArea( int _offset, int _size, gboolean _isVertical ) : offset(_offset), size(_size), isVertical(isVertical) { @@ -31,3 +33,5 @@ BlackArea::~BlackArea(void) { } + +} // namespace RawSpeed Modified: RawSpeed/BlackArea.h =================================================================== --- RawSpeed/BlackArea.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/BlackArea.h 2009-10-25 12:34:36 UTC (rev 162) @@ -20,6 +20,7 @@ http://www.klauspost.com */ +namespace RawSpeed { class BlackArea { @@ -30,3 +31,5 @@ guint size; // Size in bayer pixels. gboolean isVertical; // Otherwise horizontal }; + +} // namespace RawSpeed Modified: RawSpeed/ByteStream.cpp =================================================================== --- RawSpeed/ByteStream.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/ByteStream.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,7 @@ http://www.klauspost.com */ +namespace RawSpeed { ByteStream::ByteStream(const guchar* _buffer, guint _size) : buffer(_buffer), size(_size), off(0) { @@ -84,3 +85,5 @@ } // _RPT1(0,"Skipped %u bytes.\n", c); } + +} // namespace RawSpeed Modified: RawSpeed/ByteStream.h =================================================================== --- RawSpeed/ByteStream.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/ByteStream.h 2009-10-25 12:34:36 UTC (rev 162) @@ -21,6 +21,8 @@ */ #pragma once +namespace RawSpeed { + class ByteStream { public: @@ -51,3 +53,5 @@ _RPT1(0, "IO Exception: %s\n", _msg.c_str()); } }; + +} // namespace RawSpeed Modified: RawSpeed/Camera.cpp =================================================================== --- RawSpeed/Camera.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Camera.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + Camera::Camera(xmlDocPtr doc, xmlNodePtr cur) { xmlChar *key; key = xmlGetProp(cur, (const xmlChar *)"make"); @@ -188,3 +190,4 @@ return i; } +} // namespace RawSpeed Modified: RawSpeed/Camera.h =================================================================== --- RawSpeed/Camera.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Camera.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class Camera { public: @@ -48,3 +50,5 @@ int StringToInt(const xmlChar *in, const xmlChar *tag, const char* attribute); int getAttributeAsInt( xmlNodePtr cur , const xmlChar *tag, const char* attribute); }; + +} // namespace RawSpeed Modified: RawSpeed/CameraMetaData.cpp =================================================================== --- RawSpeed/CameraMetaData.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/CameraMetaData.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + CameraMetaData::CameraMetaData(char *docname) { ctxt = xmlNewParserCtxt(); doc = xmlCtxtReadFile(ctxt, docname, NULL, XML_PARSE_DTDVALID); @@ -117,3 +119,5 @@ return NULL; return cameras[id]; } + +} // namespace RawSpeed Modified: RawSpeed/CameraMetaData.h =================================================================== --- RawSpeed/CameraMetaData.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/CameraMetaData.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class CameraMetaData { public: @@ -38,3 +40,5 @@ protected: void dumpCameraXML(Camera* cam); }; + +} // namespace RawSpeed Modified: RawSpeed/CameraMetadataException.cpp =================================================================== --- RawSpeed/CameraMetadataException.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/CameraMetadataException.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + void ThrowCME(const char* fmt, ...) { va_list val; va_start(val, fmt); @@ -39,3 +41,5 @@ CameraMetadataException::CameraMetadataException(const string _msg): runtime_error(_msg) { _RPT1(0, "CameraMetadata Exception: %s\n", _msg.c_str()); } + +} // namespace RawSpeed Modified: RawSpeed/CameraMetadataException.h =================================================================== --- RawSpeed/CameraMetadataException.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/CameraMetadataException.h 2009-10-25 12:34:36 UTC (rev 162) @@ -21,6 +21,8 @@ */ #pragma once +namespace RawSpeed { + void ThrowCME(const char* fmt, ...); class CameraMetadataException : @@ -29,3 +31,5 @@ public: CameraMetadataException(const string _msg); }; + +} // namespace RawSpeed Modified: RawSpeed/ColorFilterArray.cpp =================================================================== --- RawSpeed/ColorFilterArray.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/ColorFilterArray.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + ColorFilterArray::ColorFilterArray(void) { setCFA(CFA_UNKNOWN, CFA_UNKNOWN, CFA_UNKNOWN, CFA_UNKNOWN); } @@ -122,3 +124,5 @@ cfa[2] = tmp1; cfa[3] = tmp2; } + +} // namespace RawSpeed Modified: RawSpeed/ColorFilterArray.h =================================================================== --- RawSpeed/ColorFilterArray.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/ColorFilterArray.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + typedef enum { CFA_COLOR_MIN = 0, CFA_RED = 0, @@ -62,3 +64,5 @@ private: CFAColor cfa[4]; }; + +} // namespace RawSpeed Modified: RawSpeed/Common.h =================================================================== --- RawSpeed/Common.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Common.h 2009-10-25 12:34:36 UTC (rev 162) @@ -52,6 +52,7 @@ typedef char* LPCWSTR; #endif // __unix__ +namespace RawSpeed { inline void BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) { if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { @@ -113,3 +114,5 @@ inline guint clampbits(gint x, guint n) { guint32 _y_temp; if( (_y_temp=x>>n) ) x = ~_y_temp >> (32-n); return x;} + +} // namespace RawSpeed Modified: RawSpeed/Cr2Decoder.cpp =================================================================== --- RawSpeed/Cr2Decoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Cr2Decoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -24,6 +24,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + Cr2Decoder::Cr2Decoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD) { @@ -404,3 +406,5 @@ STORE_RGB(c_line, off + 3, off + 4, off + 5); } } + +} // namespace RawSpeed Modified: RawSpeed/Cr2Decoder.h =================================================================== --- RawSpeed/Cr2Decoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Cr2Decoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -24,6 +24,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class Cr2Decoder : public RawDecoder { @@ -51,4 +53,6 @@ guint h; guint offset; guint count; -}; \ No newline at end of file +}; + +} // namespace RawSpeed \ No newline at end of file Modified: RawSpeed/DngDecoder.cpp =================================================================== --- RawSpeed/DngDecoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/DngDecoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -24,6 +24,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + //#define PRINT_INFO DngDecoder::DngDecoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD) { @@ -474,4 +476,4 @@ } - +} // namespace RawSpeed Modified: RawSpeed/DngDecoder.h =================================================================== --- RawSpeed/DngDecoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/DngDecoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -24,8 +24,8 @@ http://www.klauspost.com */ +namespace RawSpeed { - class DngDecoder : public RawDecoder { @@ -50,3 +50,5 @@ guint count; guint offsetY; }; + +} // namespace RawSpeed Modified: RawSpeed/DngDecoderSlices.cpp =================================================================== --- RawSpeed/DngDecoderSlices.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/DngDecoderSlices.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + void *DecodeThread(void *_this) { DngDecoderThread* me = (DngDecoderThread*)_this; DngDecoderSlices* parent = me->parent; @@ -112,3 +114,5 @@ int DngDecoderSlices::size() { return (int)slices.size(); } + +} // namespace RawSpeed Modified: RawSpeed/DngDecoderSlices.h =================================================================== --- RawSpeed/DngDecoderSlices.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/DngDecoderSlices.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class DngSliceElement { public: @@ -69,3 +71,4 @@ guint nThreads; }; +} // namespace RawSpeed Modified: RawSpeed/FileIOException.cpp =================================================================== --- RawSpeed/FileIOException.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/FileIOException.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -27,6 +27,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + FileIOException::FileIOException(const string error) : RawDecoderException(error) { } @@ -40,3 +42,5 @@ _RPT1(0, "EXCEPTION: %s\n", buf); throw FileIOException(buf); } + +} // namespace RawSpeed Modified: RawSpeed/FileIOException.h =================================================================== --- RawSpeed/FileIOException.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/FileIOException.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ */ #pragma once +namespace RawSpeed { + void ThrowTPE(const char* fmt, ...); class FileIOException: public RawDecoderException @@ -30,3 +32,5 @@ public: FileIOException(const string); }; + +} // namespace RawSpeed Modified: RawSpeed/FileMap.cpp =================================================================== --- RawSpeed/FileMap.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/FileMap.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + FileMap::FileMap(guint _size) : size(_size) { data = (unsigned char*)_aligned_malloc(size + 4, 16); if (!data) { @@ -55,3 +57,5 @@ data[pos] = rand() & 0xff; } } + +} // namespace RawSpeed Modified: RawSpeed/FileMap.h =================================================================== --- RawSpeed/FileMap.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/FileMap.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + /************************************************************************* * This is the basic file map * @@ -47,3 +49,5 @@ guint size; gboolean mOwnAlloc; }; + +} // namespace RawSpeed Modified: RawSpeed/FileReader.cpp =================================================================== --- RawSpeed/FileReader.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/FileReader.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -29,6 +29,7 @@ http://www.klauspost.com */ +namespace RawSpeed { FileReader::FileReader(LPCWSTR _filename) : mFilename(_filename) { } @@ -86,3 +87,5 @@ FileReader::~FileReader(void) { } + +} // namespace RawSpeed Modified: RawSpeed/FileReader.h =================================================================== --- RawSpeed/FileReader.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/FileReader.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ #include "FileIOException.h" #include "FileMap.h" +namespace RawSpeed { + class FileReader { public: @@ -35,3 +37,5 @@ private: LPCWSTR mFilename; }; + +} // namespace RawSpeed Modified: RawSpeed/LJpegDecompressor.cpp =================================================================== --- RawSpeed/LJpegDecompressor.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/LJpegDecompressor.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -58,6 +58,8 @@ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ +namespace RawSpeed { + const guint bitMask[] = { 0xffffffff, 0x7fffffff, 0x3fffffff, 0x1fffffff, 0x0fffffff, 0x07ffffff, @@ -592,3 +594,4 @@ return 0; } +} // namespace RawSpeed Modified: RawSpeed/LJpegDecompressor.h =================================================================== --- RawSpeed/LJpegDecompressor.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/LJpegDecompressor.h 2009-10-25 12:34:36 UTC (rev 162) @@ -28,6 +28,8 @@ * Comments added by tm. See Copyright in LJpegDecompressor.cpp */ +namespace RawSpeed { + typedef enum { /* JPEG marker codes */ M_STUFF = 0x00, M_SOF0 = 0xc0, /* baseline DCT */ @@ -191,4 +193,4 @@ HuffmanTable huff[4]; }; - +} // namespace RawSpeed Modified: RawSpeed/LJpegPlain.cpp =================================================================== --- RawSpeed/LJpegPlain.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/LJpegPlain.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,7 @@ http://www.klauspost.com */ +namespace RawSpeed { LJpegPlain::LJpegPlain(FileMap* file, RawImage img) : LJpegDecompressor(file, img) { @@ -773,3 +774,4 @@ } } +} // namespace RawSpeed Modified: RawSpeed/LJpegPlain.h =================================================================== --- RawSpeed/LJpegPlain.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/LJpegPlain.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + /****************** * Decompresses Lossless non subsampled JPEGs, with 2-4 components *****************/ @@ -45,3 +47,5 @@ guint *offset; int* slice_width; }; + +} // namespace RawSpeed Modified: RawSpeed/NefDecoder.cpp =================================================================== --- RawSpeed/NefDecoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/NefDecoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + NefDecoder::NefDecoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD) { @@ -239,5 +241,6 @@ mRaw->whitePoint = white; if (black >= 0) mRaw->blackLevel = black; +} -} +} // namespace RawSpeed Modified: RawSpeed/NefDecoder.h =================================================================== --- RawSpeed/NefDecoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/NefDecoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -27,6 +27,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class NefDecoder : public RawDecoder { @@ -50,4 +52,6 @@ guint h; guint offset; guint count; -}; \ No newline at end of file +}; + +} // namespace RawSpeed \ No newline at end of file Modified: RawSpeed/NikonDecompressor.cpp =================================================================== --- RawSpeed/NikonDecompressor.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/NikonDecompressor.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + NikonDecompressor::NikonDecompressor(FileMap* file, RawImage img) : LJpegDecompressor(file, img) { for (guint i = 0; i < 0xffff ; i++) { @@ -198,3 +200,4 @@ return diff; } +} // namespace RawSpeed Modified: RawSpeed/NikonDecompressor.h =================================================================== --- RawSpeed/NikonDecompressor.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/NikonDecompressor.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class NikonDecompressor : public LJpegDecompressor { @@ -51,3 +53,5 @@ 8,0x5c,0x4b,0x3a,0x29,7,6,5,4,3,2,1,0,13,14 }, { 0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0, /* 14-bit lossless */ 7,6,8,5,9,4,10,3,11,12,2,0,1,13,14 } }; + +} // namespace RawSpeed Modified: RawSpeed/OrfDecoder.cpp =================================================================== --- RawSpeed/OrfDecoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/OrfDecoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -26,6 +26,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + OrfDecoder::OrfDecoder(TiffIFD *rootIFD, FileMap* file): RawDecoder(file), mRootIFD(rootIFD) { } @@ -182,5 +184,6 @@ string model = data[0]->getEntry(MODEL)->getString(); setMetaData(meta, make, model, ""); +} -} +} // namespace RawSpeed Modified: RawSpeed/OrfDecoder.h =================================================================== --- RawSpeed/OrfDecoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/OrfDecoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,9 @@ http://www.klauspost.com */ + +namespace RawSpeed { + class OrfDecoder : public RawDecoder { @@ -37,5 +40,6 @@ private: void decodeCompressed(ByteStream& s,guint w, guint h); TiffIFD *mRootIFD; +}; -}; +} // namespace RawSpeed Modified: RawSpeed/PefDecoder.cpp =================================================================== --- RawSpeed/PefDecoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/PefDecoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + PefDecoder::PefDecoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD) { } @@ -105,3 +107,5 @@ } */ } + +} // namespace RawSpeed Modified: RawSpeed/PefDecoder.h =================================================================== --- RawSpeed/PefDecoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/PefDecoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,9 @@ http://www.klauspost.com */ + +namespace RawSpeed { + class PefDecoder : public RawDecoder { @@ -34,3 +37,5 @@ virtual void checkSupport(CameraMetaData *meta); TiffIFD *mRootIFD; }; + +} // namespace RawSpeed Modified: RawSpeed/PentaxDecompressor.cpp =================================================================== --- RawSpeed/PentaxDecompressor.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/PentaxDecompressor.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + PentaxDecompressor::PentaxDecompressor(FileMap* file, RawImage img) : LJpegDecompressor(file, img) { pentaxBits = 0; @@ -162,3 +164,4 @@ return 0; } +} // namespace RawSpeed Modified: RawSpeed/PentaxDecompressor.h =================================================================== --- RawSpeed/PentaxDecompressor.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/PentaxDecompressor.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,9 @@ http://www.klauspost.com */ + +namespace RawSpeed { + class PentaxDecompressor : public LJpegDecompressor { @@ -32,3 +35,5 @@ void decodePentax( guint offset, guint size ); BitPumpMSB *pentaxBits; }; + +} // namespace RawSpeed Modified: RawSpeed/PlanarRawImage.cpp =================================================================== --- RawSpeed/PlanarRawImage.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/PlanarRawImage.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,8 +22,12 @@ http://www.klauspost.com */ +namespace RawSpeed { + PlanarRawImage::PlanarRawImage(void) { } PlanarRawImage::~PlanarRawImage(void) { } + +} // namespace RawSpeed Modified: RawSpeed/PlanarRawImage.h =================================================================== --- RawSpeed/PlanarRawImage.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/PlanarRawImage.h 2009-10-25 12:34:36 UTC (rev 162) @@ -21,6 +21,9 @@ http://www.klauspost.com */ + +namespace RawSpeed { + /**** * Conventions: * @@ -44,3 +47,5 @@ virtual ~PlanarRawImage(void); PlanarPlane p[4]; }; + +} // namespace RawSpeed Modified: RawSpeed/Point.h =================================================================== --- RawSpeed/Point.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Point.h 2009-10-25 12:34:36 UTC (rev 162) @@ -19,6 +19,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + #ifndef SS_Point_H #define SS_Point_H @@ -42,4 +44,6 @@ int x,y; }; +} // namespace RawSpeed + #endif // SS_Point_H Modified: RawSpeed/RawDecoder.cpp =================================================================== --- RawSpeed/RawDecoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawDecoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + RawDecoder::RawDecoder(FileMap* file) : mFile(file), mRaw(RawImage::create()) { } @@ -215,3 +217,4 @@ ThrowRDE("Internal Error: This class does not support threaded decoding"); } +} // namespace RawSpeed \ No newline at end of file Modified: RawSpeed/RawDecoder.h =================================================================== --- RawSpeed/RawDecoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawDecoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -28,6 +28,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class RawDecoder; class RawDecoderThread @@ -62,4 +64,4 @@ void TrimSpaces( string& str); }; - +} // namespace RawSpeed Modified: RawSpeed/RawDecoderException.cpp =================================================================== --- RawSpeed/RawDecoderException.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawDecoderException.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -27,6 +27,7 @@ */ +namespace RawSpeed { void ThrowRDE(const char* fmt, ...) { va_list val; @@ -37,3 +38,5 @@ _RPT1(0, "EXCEPTION: %s\n", buf); throw RawDecoderException(buf); } + +} // namespace RawSpeed Modified: RawSpeed/RawDecoderException.h =================================================================== --- RawSpeed/RawDecoderException.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawDecoderException.h 2009-10-25 12:34:36 UTC (rev 162) @@ -21,6 +21,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + void ThrowRDE(const char* fmt, ...); class RawDecoderException : public std::runtime_error @@ -30,3 +32,5 @@ _RPT1(0, "RawDecompressor Exception: %s\n", _msg.c_str()); } }; + +} // namespace RawSpeed Modified: RawSpeed/RawImage.cpp =================================================================== --- RawSpeed/RawImage.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawImage.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,7 @@ http://www.klauspost.com */ +namespace RawSpeed { RawImageData::RawImageData(void): dim(0, 0), bpp(0), isCFA(true), @@ -316,3 +317,5 @@ if (--old->dataRefCount == 0) delete old; return *this; } + +} // namespace RawSpeed Modified: RawSpeed/RawImage.h =================================================================== --- RawSpeed/RawImage.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawImage.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class RawImage; class RawImageData { @@ -80,3 +82,5 @@ inline RawImage RawImage::create() { return new RawImageData(); } inline RawImage RawImage::create(iPoint2D dim, guint bytesPerPixel, guint componentsPerPixel) { return new RawImageData(dim, bytesPerPixel, componentsPerPixel); } + +} // namespace RawSpeed Modified: RawSpeed/RawSpeed.cpp =================================================================== --- RawSpeed/RawSpeed.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RawSpeed.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -27,7 +27,9 @@ http://www.klauspost.com */ -//#define _USE_GFL_ +using namespace RawSpeed; + +#define _USE_GFL_ #ifdef _USE_GFL_ #include "libgfl.h" #pragma comment(lib, "libgfl.lib") @@ -42,7 +44,7 @@ RawDecoder *d = 0; FileMap* m = 0; try { - wprintf(L"Opening:%s\n",f.Filename()); +// wprintf(L"Opening:%s\n",f.Filename()); m = f.readFile(); TiffParser t(m); t.parseData(); @@ -54,18 +56,18 @@ d->decodeRaw(); d->decodeMetaData(meta); RawImage r = d->mRaw; + r->scaleBlackWhite(); guint time = GetTickCount()-startTime; float mpps = (float)r->dim.x * (float)r->dim.y * (float)r->getCpp() / (1000.0f * (float)time); wprintf(L"Decoding %s took: %u ms, %4.2f Mpixel/s\n", f.Filename(), time, mpps); - r->scaleBlackWhite(); for (guint i = 0; i < d->errors.size(); i++) { printf("Error Encountered:%s", d->errors[i]); } if (r->isCFA) { - printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); - printf(r->cfa.asString().c_str()); +// printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); +// printf(r->cfa.asString().c_str()); } #ifdef _USE_GFL_ @@ -174,7 +176,37 @@ #endif CameraMetaData meta("..\\cameras.xml"); //meta.dumpXML(); +/* + OpenFile(FileReader(L"..\\testimg\\Panasonic_FZ35FARI0200.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_FZ35hSLI0200.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_FZ35hVFAWB.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_DMCGF1hSLI0200_NR_LOW.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_DMCGF1hMULTII0200.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_02.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\gh1_sample_iso100.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\gh1_sample_iso400.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\gh1_studio_iso100.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\gh1_studio_iso1600.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_DMC-FX150.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_FZ28.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_01.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_02.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_03.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_04.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_05.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_lumix_dmc_lx3_06.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Panasonic_LX3.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_DMC_gh1_sample_iso100.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_DMC_gh1_sample_iso400.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_DMC_gh1_studio_iso100.RW2"),&meta); + OpenFile(FileReader(L"..\\testimg\\panasonic_DMC_gh1_studio_iso1600.RW2"),&meta); + + OpenFile(FileReader(L"..\\testimg\\camera_dngs\\ricoh_gr_digital_iii_01.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\camera_dngs\\ricoh_gr_digital_iii_07.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\camera_dngs\\ricoh_gr_digital_iii_09.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\camera_dngs\\ricoh_gr_digital_iii_10.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\camera_dngs\\ricoh_gr_digital_iii_14.dng"),&meta); OpenFile(FileReader(L"..\\testimg\\camera_dngs\\Pentax-K7FARI0200.DNG"),&meta); OpenFile(FileReader(L"..\\testimg\\camera_dngs\\Pentax-K7FARI6400.DNG"),&meta); OpenFile(FileReader(L"..\\testimg\\camera_dngs\\Pentax-K7hMULTII0200.DNG"),&meta); @@ -222,7 +254,7 @@ OpenFile(FileReader(L"..\\testimg\\Pentax_K20D.pef"),&meta); OpenFile(FileReader(L"..\\testimg\\Pentax_optio_33wr.pef"),&meta); - + OpenFile(FileReader(L"..\\testimg\\SONY-DSLR-A700.arw"),&meta); OpenFile(FileReader(L"..\\testimg\\SONY_A200.ARW"),&meta); OpenFile(FileReader(L"..\\testimg\\Sony_A300.arw"),&meta); @@ -231,6 +263,17 @@ OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900-2.arw"),&meta); OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900.arw"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_a700_ISO1600_compressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_a700_ISO1600_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_a700_ISO200_compressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_a700_ISO200_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_a700_ISO6400_compressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_a700_ISO6400_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_A900_ISO1600_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_A900_ISO3200_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_A900_ISO400_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_A900_ISO6400_uncompressed.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_A900_ISO800_uncompressed.ARW"),&meta); OpenFile(FileReader(L"..\\testimg\\nikon_coolpix_p6000_05.nrw"),&meta); OpenFile(FileReader(L"..\\testimg\\Nikon_D1.nef"),&meta); OpenFile(FileReader(L"..\\testimg\\Nikon_D100-backhigh.nef"),&meta); @@ -256,7 +299,25 @@ OpenFile(FileReader(L"..\\testimg\\Nikon_E5400.nef"),&meta); OpenFile(FileReader(L"..\\testimg\\Nikon_E5700.nef"),&meta); OpenFile(FileReader(L"..\\testimg\\Nikon_E5700_(sRGB).nef"),&meta); +*/ +OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_SX1IShMULTII1600.CR2"),&meta); +OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_SX1ISFARI0200.CR2"),&meta); +OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_SX1IShMULTII0200.CR2"),&meta); +OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_SX1IShSLI0080.CR2"),&meta); +OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_SX1IShSLI0200.CR2"),&meta); +OpenFile(FileReader(L"..\\testimg\\canon_powershot_g11_02.cr2"),&meta); +OpenFile(FileReader(L"..\\testimg\\canon_powershot_g11_07.cr2"),&meta); +OpenFile(FileReader(L"..\\testimg\\canon_powershot_g11_08.cr2"),&meta); + + OpenFile(FileReader(L"..\\testimg\\nikon_d3s_Ycircus_vidrig_102400.NEF"),&meta); + OpenFile(FileReader(L"..\\testimg\\nikon_d3s_Ycircus_dogjump3_2500.NEF"),&meta); + OpenFile(FileReader(L"..\\testimg\\nikon_d3s_Ycircus_granny_10000.NEF"),&meta); + + OpenFile(FileReader(L"..\\testimg\\nikon_d300s_01.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\nikon_d300s_03.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\nikon_d300s_06.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_500UZ.orf"),&meta); OpenFile(FileReader(L"..\\testimg\\Olympus_C7070WZ.orf"),&meta); OpenFile(FileReader(L"..\\testimg\\Olympus_C8080.orf"),&meta); @@ -408,6 +469,22 @@ OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-5.dng"),&meta); OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520.dng"),&meta); OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_SP350.dng"),&meta); + + OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_DMC-FX150(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_DMC-G1FARI0200(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_DMC-G1hMULTII0200(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_DMC-G1hSLI0400(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_DMC-G1LL0207LENROFF(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_FZ28(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_lumix_dmc_lx3_01(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_lumix_dmc_lx3_02(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_lumix_dmc_lx3_03(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_lumix_dmc_lx3_04(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_lumix_dmc_lx3_05(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\panasonic_lumix_dmc_lx3_06(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_LX3(010909).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_LX3(300109).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\PENTAX-ISD-linear.dng"),&meta); OpenFile(FileReader(L"..\\testimg\\dng\\PENTAX-ISD.dng"),&meta); OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K100D.dng"),&meta); Modified: RawSpeed/RgbImage.cpp =================================================================== --- RawSpeed/RgbImage.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RgbImage.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + RgbImage::RgbImage(int _w, int _h, int _bpp) : w(_w), h(_h), bpp(_bpp), owned(true) { pitch = ((w * bpp + 15) / 16) * 16; data = (unsigned char*)_aligned_malloc(pitch * h, 16); @@ -38,3 +40,5 @@ _aligned_free(data); } } + +} // namespace RawSpeed Modified: RawSpeed/RgbImage.h =================================================================== --- RawSpeed/RgbImage.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/RgbImage.h 2009-10-25 12:34:36 UTC (rev 162) @@ -21,6 +21,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class RgbImage { public: @@ -36,3 +38,5 @@ const int bpp; unsigned char* data; }; + +} // namespace RawSpeed Modified: RawSpeed/Rw2Decoder.cpp =================================================================== --- RawSpeed/Rw2Decoder.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Rw2Decoder.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,7 @@ http://www.klauspost.com */ +namespace RawSpeed { Rw2Decoder::Rw2Decoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD), input_start(0) { @@ -218,3 +219,5 @@ byte = vbits >> 3 ^ 0x3ff0; return (buf[byte] | buf[byte+1] << 8) >> (vbits & 7) & ~(-1 << nbits); } + +} // namespace RawSpeed Modified: RawSpeed/Rw2Decoder.h =================================================================== --- RawSpeed/Rw2Decoder.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/Rw2Decoder.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class PanaBitpump { public: PanaBitpump(ByteStream* input); @@ -56,3 +58,5 @@ ByteStream* input_start; guint load_flags; }; + +} // namespace RawSpeed Modified: RawSpeed/TiffEntry.cpp =================================================================== --- RawSpeed/TiffEntry.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffEntry.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,7 @@ http://www.klauspost.com */ +namespace RawSpeed { TiffEntry::TiffEntry() { } @@ -112,3 +113,5 @@ int TiffEntry::getElementShift() { return datashifts[type]; } + +} // namespace RawSpeed Modified: RawSpeed/TiffEntry.h =================================================================== --- RawSpeed/TiffEntry.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffEntry.h 2009-10-25 12:34:36 UTC (rev 162) @@ -24,6 +24,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + const guint datasizes[] = {0,1,1,2,4,8,1,1,2,4, 8, 4, 8, 4}; // 0-1-2-3-4-5-6-7-8-9-10-11-12-13 const guint datashifts[] = {0,0,0,1,2,3,0,0,1,2, 3, 2, 3, 2}; @@ -86,3 +88,5 @@ float debug_floatVal; #endif }; + +} // namespace RawSpeed Modified: RawSpeed/TiffEntryBE.cpp =================================================================== --- RawSpeed/TiffEntryBE.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffEntryBE.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,7 @@ http://www.klauspost.com */ +namespace RawSpeed { TiffEntryBE::TiffEntryBE(FileMap* f, guint offset) : mDataSwapped(false) { type = TIFF_UNDEFINED; // We set type to undefined to avoid debug assertion errors. @@ -102,3 +103,5 @@ mDataSwapped = true; return d; } + +} // namespace RawSpeed Modified: RawSpeed/TiffEntryBE.h =================================================================== --- RawSpeed/TiffEntryBE.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffEntryBE.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class TiffEntryBE : public TiffEntry { @@ -38,3 +40,4 @@ bool mDataSwapped; }; +} // namespace RawSpeed Modified: RawSpeed/TiffIFD.cpp =================================================================== --- RawSpeed/TiffIFD.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffIFD.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + #ifdef CHECKSIZE #undef CHECKSIZE #endif @@ -95,3 +97,5 @@ bool TiffIFD::hasEntry(TiffTag tag) { return mEntry.find(tag) != mEntry.end(); } + +} // namespace RawSpeed Modified: RawSpeed/TiffIFD.h =================================================================== --- RawSpeed/TiffIFD.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffIFD.h 2009-10-25 12:34:36 UTC (rev 162) @@ -25,6 +25,7 @@ http://www.klauspost.com */ +namespace RawSpeed { typedef enum Endianness { big, little @@ -48,6 +49,4 @@ gint nextIFD; }; - - - +} // namespace RawSpeed Modified: RawSpeed/TiffIFDBE.cpp =================================================================== --- RawSpeed/TiffIFDBE.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffIFDBE.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + TiffIFDBE::TiffIFDBE() { endian = big; } @@ -55,3 +57,5 @@ TiffIFDBE::~TiffIFDBE(void) { } + +} // namespace RawSpeed Modified: RawSpeed/TiffIFDBE.h =================================================================== --- RawSpeed/TiffIFDBE.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffIFDBE.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class TiffIFDBE : public TiffIFD { @@ -30,3 +32,5 @@ TiffIFDBE(FileMap* f, guint offset); virtual ~TiffIFDBE(void); }; + +} // namespace RawSpeed Modified: RawSpeed/TiffParser.cpp =================================================================== --- RawSpeed/TiffParser.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParser.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + TiffParser::TiffParser(FileMap* inputData): mInput(inputData), mRootIFD(0) { } @@ -132,3 +134,5 @@ throw TiffParserException("No decoder found. Sorry."); return NULL; } + +} // namespace RawSpeed Modified: RawSpeed/TiffParser.h =================================================================== --- RawSpeed/TiffParser.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParser.h 2009-10-25 12:34:36 UTC (rev 162) @@ -34,6 +34,8 @@ #include "OrfDecoder.h" #include "Rw2Decoder.h" +namespace RawSpeed { + class TiffParser { public: @@ -49,3 +51,4 @@ TiffIFD* mRootIFD; }; +} // namespace RawSpeed Modified: RawSpeed/TiffParserException.cpp =================================================================== --- RawSpeed/TiffParserException.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParserException.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -27,6 +27,7 @@ http://www.klauspost.com */ +namespace RawSpeed { TiffParserException::TiffParserException(const string _msg) : runtime_error(_msg) { _RPT1(0, "TIFF Exception: %s\n", _msg.c_str()); @@ -41,3 +42,5 @@ _RPT1(0, "EXCEPTION: %s\n", buf); throw TiffParserException(buf); } + +} // namespace RawSpeed Modified: RawSpeed/TiffParserException.h =================================================================== --- RawSpeed/TiffParserException.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParserException.h 2009-10-25 12:34:36 UTC (rev 162) @@ -21,6 +21,8 @@ */ #pragma once +namespace RawSpeed { + void ThrowTPE(const char* fmt, ...); class TiffParserException : public std::runtime_error @@ -28,3 +30,5 @@ public: TiffParserException(const string _msg); }; + +} // namespace RawSpeed Modified: RawSpeed/TiffParserHeaderless.cpp =================================================================== --- RawSpeed/TiffParserHeaderless.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParserHeaderless.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + TiffParserHeaderless::TiffParserHeaderless(FileMap* input, Endianness _end) : TiffParser(input) { endian = _end; @@ -65,3 +67,5 @@ nextIFD = mRootIFD->mSubIFD.back()->getNextIFD(); } while (nextIFD); } + +} // namespace RawSpeed Modified: RawSpeed/TiffParserHeaderless.h =================================================================== --- RawSpeed/TiffParserHeaderless.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParserHeaderless.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class TiffParserHeaderless : public TiffParser { @@ -31,3 +33,5 @@ void parseData(guint firstIfdOffset); virtual void parseData(); }; + +} // namespace RawSpeed Modified: RawSpeed/TiffParserOlympus.cpp =================================================================== --- RawSpeed/TiffParserOlympus.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParserOlympus.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -24,6 +24,8 @@ // More relaxed Tiff parser for olympus makernote +namespace RawSpeed { + TiffParserOlympus::TiffParserOlympus(FileMap* input) : TiffParser(input) { } @@ -72,3 +74,5 @@ nextIFD = mRootIFD->mSubIFD.back()->getNextIFD(); } while (nextIFD); } + +} // namespace RawSpeed Modified: RawSpeed/TiffParserOlympus.h =================================================================== --- RawSpeed/TiffParserOlympus.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffParserOlympus.h 2009-10-25 12:34:36 UTC (rev 162) @@ -22,6 +22,8 @@ http://www.klauspost.com */ +namespace RawSpeed { + class TiffParserOlympus : public TiffParser { @@ -30,3 +32,5 @@ virtual void parseData(); virtual ~TiffParserOlympus(void); }; + +} // namespace RawSpeed Modified: RawSpeed/TiffTag.h =================================================================== --- RawSpeed/TiffTag.h 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/TiffTag.h 2009-10-25 12:34:36 UTC (rev 162) @@ -23,6 +23,7 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +namespace RawSpeed { typedef enum { INTEROPERABILITYINDEX = 0x0001, @@ -304,3 +305,5 @@ // PRINT IMAGE MATCHING DATA PIMIFDPOINTER = 0xC4A5 } TiffTag; + +} // namespace RawSpeed Modified: RawSpeed/rawstudio-plugin-api.cpp =================================================================== --- RawSpeed/rawstudio-plugin-api.cpp 2009-10-22 16:00:50 UTC (rev 161) +++ RawSpeed/rawstudio-plugin-api.cpp 2009-10-25 12:34:36 UTC (rev 162) @@ -29,6 +29,8 @@ #define TIME_LOAD 1 +using namespace RawSpeed; + extern "C" { RS_IMAGE16 * From klauspost at gmail.com Sun Oct 25 13:49:40 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 25 Oct 2009 13:49:40 +0100 Subject: [Rawstudio-commit] rawspeed r163 - RawSpeed Message-ID: Author: post Date: 2009-10-25 13:49:40 +0100 (Sun, 25 Oct 2009) New Revision: 163 Removed: RawSpeed/PlanarRawImage.cpp RawSpeed/PlanarRawImage.h RawSpeed/RgbImage.cpp RawSpeed/RgbImage.h Modified: RawSpeed/RawSpeed.vcproj Log: Removed unused image classes. Deleted: RawSpeed/PlanarRawImage.cpp =================================================================== --- RawSpeed/PlanarRawImage.cpp 2009-10-25 12:34:36 UTC (rev 162) +++ RawSpeed/PlanarRawImage.cpp 2009-10-25 12:49:40 UTC (rev 163) @@ -1,33 +0,0 @@ -#include "StdAfx.h" -#include "PlanarRawImage.h" -/* - RawSpeed - RAW file decoder. - - Copyright (C) 2009 Klaus Post - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - http://www.klauspost.com -*/ - -namespace RawSpeed { - -PlanarRawImage::PlanarRawImage(void) { -} - -PlanarRawImage::~PlanarRawImage(void) { -} - -} // namespace RawSpeed Deleted: RawSpeed/PlanarRawImage.h =================================================================== --- RawSpeed/PlanarRawImage.h 2009-10-25 12:34:36 UTC (rev 162) +++ RawSpeed/PlanarRawImage.h 2009-10-25 12:49:40 UTC (rev 163) @@ -1,51 +0,0 @@ -#pragma once -#include "RawImage.h" -/* - RawSpeed - RAW file decoder. - - Copyright (C) 2009 Klaus Post - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - http://www.klauspost.com -*/ - -namespace RawSpeed { - -/**** -* Conventions: -* -* The dimensions of an image is determined by the largest plane. -* Each plane size is defined as the largest plane divided by a power of two. -* Each plane can only hold one component. -* Each planar image can only hold up to four planes. -****/ -class PlanarPlane { -public: - PlanarPlane() : data(0), subfactor(0) {}; - guchar* data; - guint subfactor; -}; - -class PlanarRawImage : - public RawImage -{ -public: - PlanarRawImage(void); - virtual ~PlanarRawImage(void); - PlanarPlane p[4]; -}; - -} // namespace RawSpeed Modified: RawSpeed/RawSpeed.vcproj =================================================================== --- RawSpeed/RawSpeed.vcproj 2009-10-25 12:34:36 UTC (rev 162) +++ RawSpeed/RawSpeed.vcproj 2009-10-25 12:49:40 UTC (rev 163) @@ -188,6 +188,10 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -240,10 +244,6 @@ - - Author: post Date: 2009-10-29 17:14:00 +0100 (Thu, 29 Oct 2009) New Revision: 164 Modified: cameras.xml Log: Added support for Pentax Kx. Modified: cameras.xml =================================================================== --- cameras.xml 2009-10-25 12:49:40 UTC (rev 163) +++ cameras.xml 2009-10-29 16:14:00 UTC (rev 164) @@ -853,6 +853,16 @@ + + + BLUE + GREEN + GREEN + RED + + + + RED