~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/iop/colorcontrast.c

  • Committer: Package Import Robot
  • Author(s): David Bremner
  • Date: 2011-11-13 10:46:00 UTC
  • mfrom: (8.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20111113104600-56c59agrs615gjim
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "develop/imageop.h"
24
24
#include "control/control.h"
25
25
#include "dtgtk/slider.h"
 
26
#include "gui/accelerators.h"
26
27
#include "gui/gtk.h"
27
28
#include <gtk/gtk.h>
28
29
#include <stdlib.h>
29
30
#include <assert.h>
 
31
#include <xmmintrin.h>
30
32
 
31
33
DT_MODULE(1)
32
34
 
98
100
  return IOP_GROUP_COLOR;
99
101
}
100
102
 
101
 
void init_key_accels()
102
 
{
103
 
  dtgtk_slider_init_accel(darktable.control->accels_darkroom,"<Darktable>/darkroom/plugins/colorcontrast/green vs magenta");
104
 
  dtgtk_slider_init_accel(darktable.control->accels_darkroom,"<Darktable>/darkroom/plugins/colorcontrast/blue vs yellow");
 
103
void init_key_accels(dt_iop_module_so_t *self)
 
104
{
 
105
  dt_accel_register_slider_iop(self, FALSE, NC_("accel", "green vs magenta"));
 
106
  dt_accel_register_slider_iop(self, FALSE, NC_("accel", "blue vs yellow"));
 
107
}
 
108
 
 
109
void connect_key_accels(dt_iop_module_t *self)
 
110
{
 
111
  dt_iop_colorcontrast_gui_data_t *g =
 
112
      (dt_iop_colorcontrast_gui_data_t*)self->gui_data;
 
113
 
 
114
  dt_accel_connect_slider_iop(self, "green vs magenta",
 
115
                              GTK_WIDGET(g->a_scale));
 
116
  dt_accel_connect_slider_iop(self, "blue vs yellow",
 
117
                              GTK_WIDGET(g->b_scale));
105
118
}
106
119
 
107
120
/** modify regions of interest (optional, per pixel ops don't need this) */
124
137
#endif
125
138
  for(int j=0; j<roi_out->height; j++)
126
139
  {
 
140
 
127
141
    float *in  = ((float *)i) + ch*roi_in->width *j;
128
142
    float *out = ((float *)o) + ch*roi_out->width*j;
 
143
 
 
144
    const __m128 scale = _mm_set_ps(0.0f,d->b_steepness,d->a_steepness,1.0f);
 
145
    const __m128 offset = _mm_set_ps(0.0f,d->b_offset,d->a_offset,0.0f);
 
146
    const __m128 min = _mm_set_ps(0.0f,-128.0f,-128.0f, -INFINITY);
 
147
    const __m128 max = _mm_set_ps(0.0f, 128.0f, 128.0f,  INFINITY);
 
148
 
 
149
 
129
150
    for(int i=0; i<roi_out->width; i++)
130
151
    {
131
 
      float *pt_in = in + ch*i;
132
 
      float *pt_out = out + ch*i;
133
 
      float L_in = pt_in[0];
134
 
      float a_in = pt_in[1];
135
 
      float b_in = pt_in[2];
136
 
      pt_out[0] = L_in;
137
 
      pt_out[1] = CLAMPS(a_in*(d->a_steepness) + (d->a_offset), -128.0, 128.0);
138
 
      pt_out[2] = CLAMPS(b_in*(d->b_steepness) + (d->b_offset), -128.0, 128.0);
 
152
      _mm_stream_ps(out,_mm_min_ps(max,_mm_max_ps(min,_mm_add_ps(offset,_mm_mul_ps(scale,_mm_load_ps(in))))));
 
153
      in+=ch;
 
154
      out+=ch;
139
155
    }
140
156
  }
 
157
  _mm_sfence();
141
158
}
142
159
 
143
160
/** optional: if this exists, it will be called to init new defaults if a new image is loaded from film strip mode. */
194
211
  d->a_steepness = p->a_steepness;
195
212
  d->a_offset = p->a_offset;
196
213
  d->b_steepness = p->b_steepness;
197
 
  d->a_offset = p->a_offset;
 
214
  d->b_offset = p->b_offset;
198
215
}
199
216
 
200
217
void init_pipe     (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
251
268
  dt_iop_colorcontrast_params_t *p = (dt_iop_colorcontrast_params_t *)self->params;
252
269
  g->a_scale = DTGTK_SLIDER(dtgtk_slider_new_with_range(DARKTABLE_SLIDER_BAR, 0.0, 5.0, 0.01, p->a_steepness, 2));
253
270
  dtgtk_slider_set_label(g->a_scale,_("green vs magenta"));
254
 
  dtgtk_slider_set_accel(g->a_scale,darktable.control->accels_darkroom,"<Darktable>/darkroom/plugins/colorcontrast/green vs magenta");
255
271
  g->b_scale = DTGTK_SLIDER(dtgtk_slider_new_with_range(DARKTABLE_SLIDER_BAR, 0.0, 5.0, 0.01, p->b_steepness, 2));
256
272
  dtgtk_slider_set_label(g->b_scale,_("blue vs yellow"));
257
 
  dtgtk_slider_set_accel(g->b_scale,darktable.control->accels_darkroom,"<Darktable>/darkroom/plugins/colorcontrast/blue vs yellow");
258
273
  
259
274
  self->widget = GTK_WIDGET(gtk_hbox_new(FALSE, 0));
260
275
  g->vbox = GTK_VBOX(gtk_vbox_new(FALSE, DT_GUI_IOP_MODULE_CONTROL_SPACING));