forked from fsphil/hacktv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo.h
289 lines (216 loc) · 5.79 KB
/
video.h
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/* hacktv - Analogue video transmitter for the HackRF */
/*=======================================================================*/
/* Copyright 2017 Philip Heron <[email protected]> */
/* */
/* This program is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _VIDEO_H
#define _VIDEO_H
#include <stdint.h>
#include "nicam728.h"
#include "fir.h"
typedef struct vid_t vid_t;
#include "teletext.h"
#include "wss.h"
#include "videocrypt.h"
#include "videocrypts.h"
#include "syster.h"
#include "acp.h"
/* Return codes */
#define VID_OK 0
#define VID_ERROR -1
#define VID_OUT_OF_MEMORY -2
/* Output modulation types */
#define VID_NONE 0
#define VID_AM 1
#define VID_VSB 2
#define VID_FM 3
/* Colour modes */
#define VID_MONOCHROME 0
#define VID_PAL 1
#define VID_NTSC 2
#define VID_SECAM 3
#define VID_APOLLO_FSC 4
/* AV source function prototypes */
typedef uint32_t *(*vid_read_video_t)(void *private, float *ratio);
typedef int16_t *(*vid_read_audio_t)(void *private, size_t *samples);
typedef int (*vid_eof_t)(void *private);
typedef int (*vid_close_t)(void *private);
/* RF modulation */
typedef struct {
int16_t level;
int32_t counter;
cint32_t phase;
cint32_t *lut;
} _mod_fm_t;
typedef struct {
int16_t level;
int32_t counter;
cint32_t phase;
cint32_t delta;
} _mod_am_t;
typedef struct {
/* Output type */
int output_type;
/* Output modulation */
int modulation;
/* VSB modulation options */
double vsb_upper_bw;
double vsb_lower_bw;
/* FM modulation options */
double fm_level;
double fm_deviation;
/* Overall signal level (pre-modulation) */
double level;
/* Level of each component. The total sum should be exactly 1.0 */
double video_level;
double fm_audio_level;
double am_audio_level;
double nicam_level;
/* Video */
int frame_rate_num;
int frame_rate_den;
int lines;
int active_lines;
double hsync_width;
double vsync_short_width;
double vsync_long_width;
double white_level;
double black_level;
double blanking_level;
double sync_level;
double active_width;
double active_left;
double gamma;
char *teletext;
char *wss;
char *videocrypt;
char *videocrypt2;
char *videocrypts;
int syster;
int acp;
/* RGB weights, should add up to 1.0 */
double rw_co;
double gw_co;
double bw_co;
int colour_mode;
double colour_carrier;
int colour_lookup_lines;
double burst_width;
double burst_left;
double burst_level;
double fsc_flag_width;
double fsc_flag_left;
double fsc_flag_level;
double iu_co;
double iv_co;
double qu_co;
double qv_co;
/* FM audio */
double fm_mono_carrier;
double fm_left_carrier;
double fm_right_carrier;
double fm_audio_preemph;
double fm_audio_deviation;
/* Stereo NICAM audio */
double nicam_carrier;
double nicam_beta;
/* AM audio */
double am_mono_carrier;
double am_mono_bandwidth;
} vid_config_t;
typedef struct {
const char *id;
const vid_config_t *conf;
} vid_configs_t;
struct vid_t {
/* Source interface */
void *av_private;
vid_read_video_t av_read_video;
vid_read_audio_t av_read_audio;
vid_eof_t av_eof;
vid_close_t av_close;
/* Signal configuration */
vid_config_t conf;
/* Video setup */
int sample_rate;
int width;
int half_width;
int active_width;
int active_left;
int hsync_width;
int vsync_short_width;
int vsync_long_width;
int16_t blanking_level;
int16_t sync_level;
int16_t *y_level_lookup;
int16_t *i_level_lookup;
int16_t *q_level_lookup;
int colour_lookup_width;
int16_t *colour_lookup;
int burst_left;
int burst_width;
int16_t burst_level;
_mod_fm_t fm_secam_cr;
_mod_fm_t fm_secam_cb;
int fsc_flag_left;
int fsc_flag_width;
int16_t fsc_flag_level;
/* Video state */
uint32_t *framebuffer;
unsigned int frame;
unsigned int line;
float ratio;
unsigned int delay;
/* Video filter */
int16_t *video_filter_taps;
fir_int16_t video_filter;
/* Teletext state */
tt_t tt;
/* WSS state */
wss_t wss;
/* Videocrypt state */
vc_t vc;
vcs_t vcs;
/* Nagravision Syster state */
ng_t ng;
/* ACP state */
acp_t acp;
/* Audio state */
int audio;
int16_t *audiobuffer;
size_t audiobuffer_samples;
/* FM Mono/Stereo audio state */
_mod_fm_t fm_mono;
_mod_fm_t fm_left;
_mod_fm_t fm_right;
/* NICAM stereo audio state */
nicam_mod_t nicam;
int16_t nicam_buf[NICAM_AUDIO_LEN * 2];
size_t nicam_buf_len;
/* AM Mono audio state */
_mod_am_t am_mono;
/* FM Video state */
_mod_fm_t fm_video;
/* Output line buffer */
int16_t *output;
};
extern const vid_configs_t vid_configs[];
extern int vid_init(vid_t *s, unsigned int sample_rate, const vid_config_t * const conf);
extern void vid_free(vid_t *s);
extern int vid_av_close(vid_t *s);
extern void vid_info(vid_t *s);
extern int vid_init_filter(vid_t *s);
extern size_t vid_get_framebuffer_length(vid_t *s);
extern int16_t *vid_next_line(vid_t *s, size_t *samples);
#endif