Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dither.c File Reference
#include "bauhaus/bauhaus.h"
#include "common/imagebuf.h"
#include "common/imageio.h"
#include "common/math.h"
#include "common/opencl.h"
#include "common/tea.h"
#include "control/control.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/imageop_math.h"
#include "develop/imageop_gui.h"
#include "develop/tiling.h"
#include "dtgtk/gradientslider.h"
#include "gui/gtk.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <inttypes.h>
+ Include dependency graph for dither.c:

Data Structures

struct  dt_iop_dither_params_t
 
struct  dt_iop_dither_gui_data_t
 
struct  dt_iop_dither_data_t
 
struct  dt_iop_dither_global_data_t
 

Macros

#define clipnan_pixel_sse   clipnan_pixel
 
#define RIGHT_WT   (7.0f/16.0f)
 
#define DOWNRIGHT_WT   (1.0f/16.0f)
 
#define DOWN_WT   (5.0f/16.0f)
 
#define DOWNLEFT_WT   (3.0f/16.0f)
 
#define PROCESS_PIXEL_FULL(_pixel, inpix)
 
#define PROCESS_PIXEL_LEFT(_pixel, inpix)
 
#define PROCESS_PIXEL_RIGHT(pixel)
 

Typedefs

typedef enum dt_iop_dither_type_t dt_iop_dither_type_t
 
typedef struct dt_iop_dither_params_t dt_iop_dither_params_t
 
typedef struct dt_iop_dither_gui_data_t dt_iop_dither_gui_data_t
 
typedef struct dt_iop_dither_data_t dt_iop_dither_data_t
 
typedef struct dt_iop_dither_global_data_t dt_iop_dither_global_data_t
 

Enumerations

enum  dt_iop_dither_type_t {
  DITHER_RANDOM ,
  DITHER_FS1BIT ,
  DITHER_FS4BIT_GRAY ,
  DITHER_FS8BIT ,
  DITHER_FS16BIT ,
  DITHER_FSAUTO
}
 

Functions

const char * name ()
 
const char ** description (struct dt_iop_module_t *self)
 
int default_group ()
 
int flags ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
void init_presets (dt_iop_module_so_t *self)
 
void reload_defaults (dt_iop_module_t *module)
 
static float _quantize (const float val, const float f, const float rf)
 
static float _rgb_to_gray (const float *const restrict val)
 
static void nearest_color (float *const restrict val, float *const restrict err, int graymode, const float f, const float rf)
 
static void _diffuse_error (float *const restrict val, const float *const restrict err, const float factor)
 
static float clipnan (const float x)
 
static void clipnan_pixel (float *const restrict out, const float *const restrict in)
 
static __attribute__ ((always_inline))
 
static __DT_CLONE_TARGETS__ void process_floyd_steinberg (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
static __DT_CLONE_TARGETS__ void process_random (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
int process (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
void commit_params (struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void init_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void cleanup_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void init_global (dt_iop_module_so_t *module)
 
void cleanup_global (dt_iop_module_so_t *module)
 
void gui_update (struct dt_iop_module_t *self)
 
void gui_init (struct dt_iop_module_t *self)
 

Macro Definition Documentation

◆ clipnan_pixel_sse

#define clipnan_pixel_sse   clipnan_pixel

◆ DOWN_WT

#define DOWN_WT   (5.0f/16.0f)

◆ DOWNLEFT_WT

#define DOWNLEFT_WT   (3.0f/16.0f)

◆ DOWNRIGHT_WT

#define DOWNRIGHT_WT   (1.0f/16.0f)

◆ PROCESS_PIXEL_FULL

#define PROCESS_PIXEL_FULL (   _pixel,
  inpix 
)
Value:
{ \
float *const pixel_ = (_pixel); \
nearest_color(pixel_, err, graymode, f, rf); /* quantize pixel */ \
clipnan_pixel(pixel_ + downright,(inpix) + downright); /* prepare downright for first access */ \
_diffuse_error(pixel_ + right, err, RIGHT_WT); /* diffuse quantization error to neighbors */ \
_diffuse_error(pixel_ + downleft, err, DOWNLEFT_WT); \
_diffuse_error(pixel_ + down, err, DOWN_WT); \
_diffuse_error(pixel_ + downright, err, DOWNRIGHT_WT); \
}
const dt_aligned_pixel_t f
Definition colorspaces_inline_conversions.h:102
#define RIGHT_WT
Definition dither.c:326
#define DOWNRIGHT_WT
Definition dither.c:327
#define DOWNLEFT_WT
Definition dither.c:329
#define DOWN_WT
Definition dither.c:328

◆ PROCESS_PIXEL_LEFT

#define PROCESS_PIXEL_LEFT (   _pixel,
  inpix 
)
Value:
{ \
float *const pixel_ = (_pixel); \
nearest_color(pixel_, err, graymode, f, rf); /* quantize pixel */ \
clipnan_pixel(pixel_ + down,(inpix) + down); /* prepare down for first access */ \
clipnan_pixel(pixel_ + downright,(inpix) + downright); /* prepare downright for first access */ \
_diffuse_error(pixel_ + right, err, RIGHT_WT); /* diffuse quantization error to neighbors */ \
_diffuse_error(pixel_ + down, err, DOWN_WT); \
_diffuse_error(pixel_ + downright, err, DOWNRIGHT_WT); \
}

◆ PROCESS_PIXEL_RIGHT

#define PROCESS_PIXEL_RIGHT (   pixel)
Value:
nearest_color(pixel, err, graymode, f, rf); /* quantize pixel */ \
_diffuse_error(pixel + downleft, err, DOWNLEFT_WT); /* diffuse quantization error to neighbors */ \
_diffuse_error(pixel + down, err, DOWN_WT);
static void nearest_color(float *const restrict val, float *const restrict err, int graymode, const float f, const float rf)
Definition dither.c:191

◆ RIGHT_WT

#define RIGHT_WT   (7.0f/16.0f)

Typedef Documentation

◆ dt_iop_dither_data_t

◆ dt_iop_dither_global_data_t

◆ dt_iop_dither_gui_data_t

◆ dt_iop_dither_params_t

◆ dt_iop_dither_type_t

Enumeration Type Documentation

◆ dt_iop_dither_type_t

Enumerator
DITHER_RANDOM 
DITHER_FS1BIT 
DITHER_FS4BIT_GRAY 
DITHER_FS8BIT 
DITHER_FS16BIT 
DITHER_FSAUTO 

Function Documentation

◆ __attribute__()

◆ _diffuse_error()

static void _diffuse_error ( float *const restrict  val,
const float *const restrict  err,
const float  factor 
)
inlinestatic

References __OMP_SIMD__, and factor.

Referenced by process_floyd_steinberg().

◆ _quantize()

static float _quantize ( const float  val,
const float  f,
const float  rf 
)
inlinestatic

References f.

Referenced by nearest_color().

◆ _rgb_to_gray()

static float _rgb_to_gray ( const float *const restrict  val)
inlinestatic

Referenced by nearest_color().

◆ cleanup_global()

◆ cleanup_pipe()

void cleanup_pipe ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ clipnan()

static float clipnan ( const float  x)
inlinestatic

References x.

Referenced by clipnan_pixel().

◆ clipnan_pixel()

static void clipnan_pixel ( float *const restrict  out,
const float *const restrict  in 
)
inlinestatic

References __OMP_SIMD__, clipnan(), and out.

Referenced by process_floyd_steinberg().

◆ commit_params()

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece 
)

References IOP_CS_RGB_DISPLAY.

◆ default_group()

int default_group ( )

References IOP_GROUP_TECHNICAL.

◆ description()

const char ** description ( struct dt_iop_module_t self)

◆ flags()

int flags ( )

◆ gui_changed()

void gui_changed ( dt_iop_module_t self,
GtkWidget w,
void previous 
)

◆ gui_init()

◆ gui_update()

void gui_update ( struct dt_iop_module_t self)
Todo:
check why needed
Todo:
by hand

History navigation and fast module toggles can reload a newer parameter state into the module while an older throttled graph edit is still queued. Once GUI update sees that the history-backed module params no longer match the live graph cache, that delayed local commit is stale and must be dropped or it may replay obsolete parameters after the history stack already moved on.

References DITHER_RANDOM, dt_bauhaus_slider_set(), DTGTK_GRADIENT_SLIDER, dtgtk_gradient_slider_multivalue_set_value(), g, dt_iop_module_t::gui_data, p, and dt_iop_module_t::params.

◆ init_global()

◆ init_pipe()

◆ init_presets()

◆ name()

const char * name ( )

◆ nearest_color()

static void nearest_color ( float *const restrict  val,
float *const restrict  err,
int  graymode,
const float  f,
const float  rf 
)
inlinestatic

◆ process()

◆ process_floyd_steinberg()

◆ process_random()

◆ reload_defaults()

void reload_defaults ( dt_iop_module_t module)