1 /*
2  *  Copyright (C) 2005-2020 Team Kodi (https://kodi.tv)
3  *  Copyright (C) 2012 Marcel Ebmer
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  *  See LICENSE.md for more information.
7  */
8 
9 #ifndef FISCHE_H
10 #define FISCHE_H
11 
12 /* int types */
13 #include <stdint.h>
14 /* size_t */
15 #include <stdlib.h>
16 
17 typedef struct fische {
18 
19     /* 16 <= width <= 2048
20      * DEFAULT: 512
21      * constant after fische_start() */
22     uint16_t    width;
23 
24     /* 16 <= height <= 2048
25      * DEFAULT: 256
26      * constant after fische_start() */
27     uint16_t    height;
28 
29     /* 1 <= used_cpus <= 8
30      * DEFAULT: all available (autodetect)
31      * constant after fische_start() */
32     uint8_t     used_cpus;
33 
34     /* true (!=0) or false (0)
35      * DEFAULT: 0 */
36     uint8_t     nervous_mode;
37 
38     /* see below (audio format enum)
39      * DEFAULT: FISCHE_AUDIOFORMAT_FLOAT
40      * constant after fische_start() */
41     uint8_t     audio_format;
42 
43     /* see below (pixel format enum)
44      * DEFAULT: FISCHE_PIXELFORMAT_0xAABBGGRR
45      * constant after fische_start() */
46     uint8_t     pixel_format;
47 
48     /* see below (blur mode enum)
49      * DEFAULT: FISCHE_BLUR_SLICK
50      * constant after fische_start() */
51     uint8_t     blur_mode;
52 
53     /* see below (line style enum)
54      * DEFAULT: FISCHE_LINESTYLE_ALPHA_SIMULATION */
55     uint8_t     line_style;
56 
57     /* 0.5 <= scale <= 2.0
58      * DEFAULT: 1.0
59      * constant after fische_start() */
60     double      scale;
61 
62     /* -10 <= amplification <= 10
63      * DEFAULT: 0 */
64     double      amplification;
65 
66     /* if non-NULL,
67      * fische calls this to read vector fields from an external source
68      * takes a void** for data placement
69      * returns the number of bytes read */
70     size_t (*read_vectors) (void* handler, void**);
71 
72     /* if non-NULL,
73      * fische calls this to write vector field data to an external sink
74      * takes a void* and the number of bytes to be written */
75     void (*write_vectors) (void* handler, const void*, size_t);
76 
77     /* if non-NULL,
78      * fische calls this on major beats that are not handled internally
79      * takes frames per beat */
80     void (*on_beat) (void* handler, double);
81 
82     void* handler;
83 
84     /* read only */
85     uint32_t    frame_counter;
86 
87     /* read only */
88     const char* error_text;
89 
90     void*       priv;
91 
92 } FISCHE;
93 
94 
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
100 
101 
102     /* creates a new FISCHE object
103      * and initialzes it with default values */
104     FISCHE*     fische_new();
105 
106     /* starts FISCHE */
107     int         fische_start (FISCHE* handle);
108 
109     /* makes the next frame available */
110     uint32_t*   fische_render (FISCHE* handle);
111 
112     /* destructs the FISCHE object */
113     void        fische_free (FISCHE* handle);
114 
115     /* inserts audio data */
116     void        fische_audiodata (FISCHE* handle, const void* data, size_t data_size);
117 
118 
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 
125 
126 /* audio sample formats */
127 enum {FISCHE_AUDIOFORMAT_U8,
128       FISCHE_AUDIOFORMAT_S8,
129       FISCHE_AUDIOFORMAT_U16,
130       FISCHE_AUDIOFORMAT_S16,
131       FISCHE_AUDIOFORMAT_U32,
132       FISCHE_AUDIOFORMAT_S32,
133       FISCHE_AUDIOFORMAT_FLOAT,
134       FISCHE_AUDIOFORMAT_DOUBLE,
135       _FISCHE__AUDIOFORMAT_LAST_
136      };
137 
138 /* pixel formats */
139 enum {FISCHE_PIXELFORMAT_0xRRGGBBAA,
140       FISCHE_PIXELFORMAT_0xAABBGGRR,
141       FISCHE_PIXELFORMAT_0xAARRGGBB,
142       FISCHE_PIXELFORMAT_0xBBGGRRAA,
143       _FISCHE__PIXELFORMAT_LAST_
144      };
145 
146 /* blur style */
147 enum {FISCHE_BLUR_SLICK,
148       FISCHE_BLUR_FUZZY,
149       _FISCHE__BLUR_LAST_
150      };
151 
152 /* line style */
153 enum {FISCHE_LINESTYLE_THIN,
154       FISCHE_LINESTYLE_THICK,
155       FISCHE_LINESTYLE_ALPHA_SIMULATION,
156       _FISCHE__LINESTYLE_LAST_
157      };
158 
159 #endif
160