Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
ansel-curve-tool.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include <inttypes.h>
#include <errno.h>
#include "../../src/common/curve_tools.c"
+ Include dependency graph for ansel-curve-tool.c:

Data Structures

struct  dt_iop_basecurve_node_t
 
struct  dt_iop_basecurve_params_t
 
struct  dt_iop_tonecurve_node_t
 
struct  dt_iop_tonecurve_params_t
 
struct  options
 

Macros

#define CURVE_RESOLUTION   0x10000
 
#define BASECURVE_PARAMS_VERSION   2
 
#define DT_IOP_BASECURVE_MAXNODES   20
 
#define TONECURVE_PARAMS_VERSION   4
 
#define DT_IOP_TONECURVE_MAXNODES   20
 
#define SQUARE(a)   ((a)*(a))
 
#define CUBIC(a)   ((a)*SQUARE((a)))
 

Typedefs

typedef struct dt_iop_basecurve_node_t dt_iop_basecurve_node_t
 
typedef struct dt_iop_basecurve_params_t dt_iop_basecurve_params_t
 
typedef struct dt_iop_tonecurve_node_t dt_iop_tonecurve_node_t
 
typedef struct dt_iop_tonecurve_params_t dt_iop_tonecurve_params_t
 

Enumerations

enum  module_type {
  MODULE_BASECURVE = 0 ,
  MODULE_TONECURVE = 1 ,
  MODULE_MAX
}
 

Functions

int exif_get_ascii_datafield (const char *filename, const char *key, char *buf, size_t buflen)
 
static void hexify (uint8_t *out, const uint8_t *in, size_t len)
 
static int read_ppm_header (FILE *f, int *wd, int *ht)
 
static uint16_t * read_ppm16 (const char *filename, int *wd, int *ht)
 
static uint8_t * read_ppm8 (const char *filename, int *wd, int *ht)
 
static float get_error (CurveData *c, CurveSample *csample, float *basecurve, uint32_t *cnt)
 
static void mutate (CurveData *c, CurveData *t, float *basecurve)
 
static float linearize_sRGB (float val)
 
static float Lab (float val)
 
static void RGB2Lab (float *L, float *a, float *b, float R, float G, float B)
 
static void Lab2UnitCube (float *L, float *a, float *b)
 
static void linearize_8bit (int width, int height, uint8_t *_s, float *_d)
 
static void linearize_16bit (int width, int height, uint16_t *_s, float *_d)
 
static void build_channel_basecurve (int width_jpeg, int height_jpeg, float *buf_jpeg, int offx_raw, int offy_raw, int width_raw, float *buf_raw, int ch, float *curve, uint32_t *cnt)
 
static void build_tonecurve (int width_jpeg, int height_jpeg, float *buf_jpeg, int offx_raw, int offy_raw, int width_raw, float *buf_raw, float *curve, uint32_t *hist)
 
static void fit_curve (CurveData *best, int *nopt, float *minsqerr, CurveSample *csample, int num_nodes, float *curve, uint32_t *cnt)
 
static int is_bigendian ()
 
static void print_usage (const char *name)
 
static void set_default_options (struct options *opts)
 
static int parse_arguments (int argc, char **argv, struct options *opts)
 
void read_curveset (FILE *f, float *curve, uint32_t *hist)
 
int write_curveset (FILE *f, float *curve, uint32_t *hist)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ BASECURVE_PARAMS_VERSION

#define BASECURVE_PARAMS_VERSION   2

◆ CUBIC

#define CUBIC (   a)    ((a)*SQUARE((a)))

◆ CURVE_RESOLUTION

#define CURVE_RESOLUTION   0x10000

◆ DT_IOP_BASECURVE_MAXNODES

#define DT_IOP_BASECURVE_MAXNODES   20

◆ DT_IOP_TONECURVE_MAXNODES

#define DT_IOP_TONECURVE_MAXNODES   20

◆ SQUARE

#define SQUARE (   a)    ((a)*(a))

◆ TONECURVE_PARAMS_VERSION

#define TONECURVE_PARAMS_VERSION   4

Typedef Documentation

◆ dt_iop_basecurve_node_t

◆ dt_iop_basecurve_params_t

◆ dt_iop_tonecurve_node_t

◆ dt_iop_tonecurve_params_t

Enumeration Type Documentation

◆ module_type

Enumerator
MODULE_BASECURVE 
MODULE_TONECURVE 
MODULE_MAX 

Function Documentation

◆ build_channel_basecurve()

static void build_channel_basecurve ( int  width_jpeg,
int  height_jpeg,
float *  buf_jpeg,
int  offx_raw,
int  offy_raw,
int  width_raw,
float *  buf_raw,
int  ch,
float *  curve,
uint32_t *  cnt 
)
static

References CURVE_RESOLUTION.

Referenced by main().

◆ build_tonecurve()

static void build_tonecurve ( int  width_jpeg,
int  height_jpeg,
float *  buf_jpeg,
int  offx_raw,
int  offy_raw,
int  width_raw,
float *  buf_raw,
float *  curve,
uint32_t *  hist 
)
static

References CURVE_RESOLUTION, Lab2UnitCube(), and RGB2Lab().

Referenced by main().

◆ exif_get_ascii_datafield()

int exif_get_ascii_datafield ( const char *  filename,
const char *  key,
char *  buf,
size_t  buflen 
)
extern

References key.

Referenced by main().

◆ fit_curve()

static void fit_curve ( CurveData best,
int *  nopt,
float *  minsqerr,
CurveSample csample,
int  num_nodes,
float *  curve,
uint32_t *  cnt 
)
static

◆ get_error()

static float get_error ( CurveData c,
CurveSample csample,
float *  basecurve,
uint32_t *  cnt 
)
inlinestatic

◆ hexify()

static void hexify ( uint8_t *  out,
const uint8_t *  in,
size_t  len 
)
static

Referenced by main().

◆ is_bigendian()

static int is_bigendian ( )
inlinestatic

References __attribute__().

Referenced by main().

◆ Lab()

◆ Lab2UnitCube()

static void Lab2UnitCube ( float *  L,
float *  a,
float *  b 
)
inlinestatic

Referenced by build_tonecurve().

◆ linearize_16bit()

static void linearize_16bit ( int  width,
int  height,
uint16_t *  _s,
float *  _d 
)
static

References height, and width.

Referenced by main().

◆ linearize_8bit()

static void linearize_8bit ( int  width,
int  height,
uint8_t *  _s,
float *  _d 
)
static

References height, linearize_sRGB(), and width.

Referenced by main().

◆ linearize_sRGB()

static float linearize_sRGB ( float  val)
inlinestatic

Referenced by linearize_8bit().

◆ main()

◆ mutate()

static void mutate ( CurveData c,
CurveData t,
float *  basecurve 
)
inlinestatic

◆ parse_arguments()

◆ print_usage()

static void print_usage ( const char *  name)
static

References name.

Referenced by parse_arguments().

◆ read_curveset()

void read_curveset ( FILE *  f,
float *  curve,
uint32_t *  hist 
)

References CURVE_RESOLUTION, and f().

Referenced by main().

◆ read_ppm16()

static uint16_t * read_ppm16 ( const char *  filename,
int *  wd,
int *  ht 
)
static

References f(), and read_ppm_header().

Referenced by main().

◆ read_ppm8()

static uint8_t * read_ppm8 ( const char *  filename,
int *  wd,
int *  ht 
)
static

References f(), and read_ppm_header().

Referenced by main().

◆ read_ppm_header()

static int read_ppm_header ( FILE *  f,
int *  wd,
int *  ht 
)
static

References f().

Referenced by read_ppm16(), and read_ppm8().

◆ RGB2Lab()

static void RGB2Lab ( float *  L,
float *  a,
float *  b,
float  R,
float  G,
float  B 
)
inlinestatic

References B, Lab(), and R.

Referenced by build_tonecurve().

◆ set_default_options()

◆ write_curveset()

int write_curveset ( FILE *  f,
float *  curve,
uint32_t *  hist 
)

References CURVE_RESOLUTION, and f().

Referenced by main().