Author: abrander
Date: 2009-12-21 00:49:49 +0100 (Mon, 21 Dec 2009)
New Revision: 2826

Added:
   attic/rs-1d-table.c
   attic/rs-1d-table.h
   attic/rs-exposure-ramp.c
   attic/rs-exposure-ramp.h
Log:
Added files not needed by DCP filter.

Added: attic/rs-1d-table.c
===================================================================
--- attic/rs-1d-table.c                         (rev 0)
+++ attic/rs-1d-table.c 2009-12-20 23:49:49 UTC (rev 2826)
@@ -0,0 +1,56 @@
+#include "rs-1d-table.h"
+#include "rs-1d-function.h"
+
+G_DEFINE_TYPE (RS1dTable, rs_1d_table, G_TYPE_OBJECT)
+
+static void
+rs_1d_table_dispose(GObject *object)
+{
+       G_OBJECT_CLASS (rs_1d_table_parent_class)->dispose (object);
+}
+
+static void
+rs_1d_table_class_init(RS1dTableClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       object_class->dispose = rs_1d_table_dispose;
+}
+
+static void
+rs_1d_table_init(RS1dTable *self)
+{
+}
+
+RS1dTable *
+rs_1d_table_new(RS1dFunction *func)
+{
+       gint index;
+       RS1dTable *table = g_object_new(RS_TYPE_1D_TABLE, NULL);
+
+       for (index=0; index <= RS_1D_TABLE_SIZE; index++)
+       {
+               gdouble x = index * (1.0 / (gdouble) RS_1D_TABLE_SIZE);
+               table->table[index] = (gfloat) rs_1d_function_evaluate(func, x);
+       }
+
+       table->table[RS_1D_TABLE_SIZE+1] = table->table[RS_1D_TABLE_SIZE];
+
+       return table;
+}
+
+gfloat
+rs_1d_table_interpolate(RS1dTable *table, gfloat x)
+{
+       gfloat y = x * (gfloat) RS_1D_TABLE_SIZE;
+
+       gint index = (gint) y;
+
+       g_assert(index >= 0 && index <= RS_1D_TABLE_SIZE);
+
+       gfloat z = (gfloat) index;
+
+       gfloat fract = y - z;
+
+       return table->table[index] * (1.0f - fract) + table->table [index + 1] 
* (fract);
+}

Added: attic/rs-1d-table.h
===================================================================
--- attic/rs-1d-table.h                         (rev 0)
+++ attic/rs-1d-table.h 2009-12-20 23:49:49 UTC (rev 2826)
@@ -0,0 +1,37 @@
+#ifndef RS_1D_TABLE_H
+#define RS_1D_TABLE_H
+
+#include <glib-object.h>
+#include "rs-1d-function.h"
+
+G_BEGIN_DECLS
+
+#define RS_TYPE_1D_TABLE rs_1d_table_get_type()
+#define RS_1D_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_1D_TABLE, 
RS1dTable))
+#define RS_1D_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), 
RS_TYPE_1D_TABLE, RS1dTableClass))
+#define RS_IS_1D_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
RS_TYPE_1D_TABLE))
+#define RS_IS_1D_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
RS_TYPE_1D_TABLE))
+#define RS_1D_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), 
RS_TYPE_1D_TABLE, RS1dTableClass))
+
+#define RS_1D_TABLE_BITS (12)
+#define RS_1D_TABLE_SIZE (1<<RS_1D_TABLE_BITS)
+
+typedef struct {
+       GObject parent;
+
+       gfloat table[RS_1D_TABLE_SIZE+2];
+} RS1dTable;
+
+typedef struct {
+       GObjectClass parent_class;
+} RS1dTableClass;
+
+GType rs_1d_table_get_type(void);
+
+RS1dTable *rs_1d_table_new(RS1dFunction *func);
+
+gfloat rs_1d_table_interpolate(RS1dTable *table, gfloat x);
+
+G_END_DECLS
+
+#endif /* RS_1D_TABLE_H */

Added: attic/rs-exposure-ramp.c
===================================================================
--- attic/rs-exposure-ramp.c                            (rev 0)
+++ attic/rs-exposure-ramp.c    2009-12-20 23:49:49 UTC (rev 2826)
@@ -0,0 +1,63 @@
+#include "rs-exposure-ramp.h"
+
+G_DEFINE_TYPE (RSExposureRamp, rs_exposure_ramp, RS_TYPE_1D_FUNCTION)
+
+static gdouble evaluate(RS1dFunction *func, gdouble x);
+
+static void
+rs_exposure_ramp_class_init(RSExposureRampClass *klass)
+{
+       RS1dFunctionClass *fclass = RS_1D_FUNCTION_CLASS(klass);
+
+       fclass->evaluate = evaluate;
+}
+
+static void
+rs_exposure_ramp_init(RSExposureRamp *self)
+{
+}
+
+RS1dFunction *
+rs_exposure_ramp_new(gdouble white, gdouble black, gdouble min_black)
+{
+       RSExposureRamp *ramp = g_object_new(RS_TYPE_EXPOSURE_RAMP, NULL);
+
+       /* FIXME: Watch out fordivision by zero */
+       ramp->slope = 1.0 / (white - black);
+       ramp->black = black;
+
+       gdouble kMaxCurveX = 0.5;          // Fraction of minBlack.
+
+       gdouble kMaxCurveY = 1.0 / 16.0;   // Fraction of white.
+
+       ramp->radius = MIN(kMaxCurveX * min_black, kMaxCurveY / ramp->slope);
+
+       if (ramp->radius > 0.0)
+               ramp->q_scale= ramp->slope / (4.0 * ramp->radius);
+       else
+               ramp->q_scale = 0.0;
+
+       return RS_1D_FUNCTION(ramp);
+}
+
+static gdouble
+evaluate(RS1dFunction *func, gdouble x)
+{
+       gdouble ret = x;
+
+       RSExposureRamp *ramp = RS_EXPOSURE_RAMP(func);
+
+       if (x <= ramp->black - ramp->radius)
+               ret = 0.0;
+
+       else if (x >= ramp->black + ramp->radius)
+               ret = MIN((x - ramp->black) * ramp->slope, 1.0);
+       else
+       {
+               gdouble y = x - (ramp->black - ramp->radius);
+
+               ret = ramp->q_scale * y * y;
+       }
+
+       return ret;
+}

Added: attic/rs-exposure-ramp.h
===================================================================
--- attic/rs-exposure-ramp.h                            (rev 0)
+++ attic/rs-exposure-ramp.h    2009-12-20 23:49:49 UTC (rev 2826)
@@ -0,0 +1,35 @@
+#ifndef RS_EXPOSURE_RAMP_H
+#define RS_EXPOSURE_RAMP_H
+
+#include <glib-object.h>
+#include "rs-1d-function.h"
+
+G_BEGIN_DECLS
+
+#define RS_TYPE_EXPOSURE_RAMP rs_exposure_ramp_get_type()
+#define RS_EXPOSURE_RAMP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
RS_TYPE_EXPOSURE_RAMP, RSExposureRamp))
+#define RS_EXPOSURE_RAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), 
RS_TYPE_EXPOSURE_RAMP, RSExposureRampClass))
+#define RS_IS_EXPOSURE_RAMP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
RS_TYPE_EXPOSURE_RAMP))
+#define RS_IS_EXPOSURE_RAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
RS_TYPE_EXPOSURE_RAMP))
+#define RS_EXPOSURE_RAMP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), 
RS_TYPE_EXPOSURE_RAMP, RSExposureRampClass))
+
+typedef struct {
+       RS1dFunction parent;
+
+       gdouble slope;
+       gdouble black;
+       gdouble radius;
+       gdouble q_scale;
+} RSExposureRamp;
+
+typedef struct {
+       RS1dFunctionClass parent_class;
+} RSExposureRampClass;
+
+GType rs_exposure_ramp_get_type (void);
+
+RS1dFunction *rs_exposure_ramp_new(gdouble white, gdouble black, gdouble 
min_black);
+
+G_END_DECLS
+
+#endif /* RS_EXPOSURE_RAMP_H */


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

Reply via email to