summaryrefslogtreecommitdiff
blob: 3e1d7fa618e3469cd113201f4dcb21a5205d5570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* Copyright (C) 2001-2020 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
   CA 94945, U.S.A., +1(415)492-9861, for further information.
*/


/* Header file for testbed implementation of Even Better Screening. */

#ifndef evenbetter_rll_h_INCLUDED
#define evenbetter_rll_h_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

/* Definitions for source pixel format.
 * Reasonable settings are as follows:
 * 8-bit: unsigned char ET_SrcPixel; ET_SRC_MAX = 255
 * 12-bit 0..4095: unsigned short (or int) ET_SrcPixel; ET_SRC_MAX = 4095
 * 12-bit 0..4096: unsigned short (or int) ET_SrcPixel; ET_SRC_MAX = 4096
 * 16-bit 0..65535: unsigned short (or int) ET_SrcPixel; ET_SRC_MAX = 65535
 * 16-bit 0..65536: unsigned int ET_SrcPixel; ET_SRC_MAX = 65536
 */
typedef unsigned char ET_SrcPixel;
#define ET_SRC_MAX 255

/* Simple runlength code */
typedef struct {
  unsigned short length;
  ET_SrcPixel value;
} ET_Rll;

typedef unsigned char uchar;

/* To use the file dump capability:

   Open a file as with: fopen ("dumpfile", "wb");
   Put the resulting FILE * pointer in params->dump_file.
   Set params->dump_level to the desired level. EB_DUMP_ALL dumps all
   inputs and outputs. Other values will lead to much smaller files,
   but may not be as insightful.

   If no dump file is desired, set params->dump_file to NULL.
*/

typedef enum {
  EB_DUMP_MINIMAL,
  EB_DUMP_PARAMS,
  EB_DUMP_LUTS,
  EB_DUMP_INPUT,
  EB_DUMP_ALL
} EbDumpLevel;

typedef struct {
  int source_width;
  int dest_width;
  int n_planes;
  int levels; /* Number of levels on output, <= 256 */
  int **luts;
  double rbscale; /* Should be 0.95 for 1:1, 1.8 for 2:1 */
  int aspect;
  int *strengths;
  int rand_scale; /* 0 is default */
  int even_c1_scale; /* 0 is default */
  int do_shadows;
  int dotsize;
  FILE *dump_file;
  EbDumpLevel dump_level;
  double gamma;   /* 0 to enable luts, other values are 1.0, 1.8 and 2.0 */
} EvenBetterParams;

typedef struct _EvenBetterCtx EvenBetterCtx;

EvenBetterCtx *
even_better_new (const EvenBetterParams *params);

void
even_better_line_rll (EvenBetterCtx *ctx, uchar **dest,
                      const ET_Rll *const *src);

void
even_better_line (EvenBetterCtx *ctx, uchar **dest,
                  const ET_SrcPixel *const *src);

void
even_better_free (EvenBetterCtx *ctx);

void *
eb_malloc_aligned(int size, int align);

void
eb_free_aligned(void *p);

#ifdef __cplusplus
}
#endif

#endif