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 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
|
/* hacktv - Analogue video transmitter for the HackRF */
/*=======================================================================*/
/* Copyright 2017 Philip Heron <phil@sanslogic.co.uk> */
/* */
/* 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 "dance.h"
#include "fir.h"
typedef struct vid_line_t vid_line_t;
typedef struct vid_t vid_t;
#include "mac.h"
#include "teletext.h"
#include "wss.h"
#include "videocrypt.h"
#include "videocrypts.h"
#include "syster.h"
#include "acp.h"
#include "vits.h"
/* Return codes */
#define VID_OK 0
#define VID_ERROR -1
#define VID_OUT_OF_MEMORY -2
/* Frame type */
#define VID_RASTER_625 0
#define VID_RASTER_525 1
#define VID_RASTER_405 2
#define VID_RASTER_819 3
#define VID_BAIRD_240 4
#define VID_BAIRD_30 5
#define VID_NBTV_32 6
#define VID_APOLLO_320 7
#define VID_MAC 8
#define VID_CBS_405 9
/* 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
#define VID_CBS_FSC 5
/* 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 {
int32_t counter;
cint32_t phase;
cint32_t delta;
} _mod_offset_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;
/* Signal offset and passthru */
int64_t offset;
char *passthru;
/* 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;
double dance_level;
/* Video */
int type;
int frame_rate_num;
int frame_rate_den;
int lines;
int hline;
int active_lines;
int interlace;
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 systeraudio;
int acp;
int vits;
char *eurocrypt;
/* 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 burst_rise;
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;
/* DANCE audio */
double dance_carrier;
double dance_beta;
/* AM audio */
double am_mono_carrier;
double am_mono_bandwidth;
/* D/D2-MAC options */
int mac_mode;
uint16_t chid;
int scramble_video;
int scramble_audio;
/* Video filter enable flag */
int vfilter;
} vid_config_t;
typedef struct {
const char *id;
const vid_config_t *conf;
} vid_configs_t;
typedef struct {
int16_t y;
int16_t i;
int16_t q;
} _yiq16_t;
struct vid_line_t {
/* The output line buffer */
int16_t *output;
/* Frame and line number */
int frame;
int line;
/* Status */
int vbialloc;
/* Pointer the next line */
vid_line_t *next;
};
/* Line process function prototypes */
typedef int (*vid_lineprocess_process_t)(vid_t *s, void *arg, int nlines, vid_line_t **lines);
typedef void (*vid_lineprocess_free_t)(vid_t *s, void *arg);
typedef struct _lineprocess_t _lineprocess_t;
struct _lineprocess_t {
/* A simple identifier for this process */
char name[16];
/* Line window */
int nlines;
vid_line_t **lines;
/* Process callbacks */
vid_lineprocess_process_t process;
vid_lineprocess_free_t free;
/* Callback parameters */
vid_t *vid;
void *arg;
};
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 white_level;
int16_t black_level;
int16_t blanking_level;
int16_t sync_level;
_yiq16_t *yiq_level_lookup;
int colour_lookup_width;
int16_t *colour_lookup;
int burst_left;
int burst_width;
int16_t *burst_win;
_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;
/* The frame and line number being rendered next */
int bframe;
int bline;
/* The frame and line number returned by vid_next_line() */
int frame;
int line;
/* Current frame's aspect ratio */
float ratio;
/* 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;
/* VITS state */
vits_t vits;
/* 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;
/* DANCE audio state */
dance_mod_t dance;
int16_t dance_buf[DANCE_AUDIO_LEN * 2];
size_t dance_buf_len;
/* AM Mono audio state */
_mod_am_t am_mono;
/* FM Video state */
_mod_fm_t fm_video;
/* Offset signal */
_mod_offset_t offset;
/* Passthru source */
FILE *passthru;
int16_t *passline;
/* D/D2-MAC specific data */
mac_t mac;
/* Output line(s) buffer */
int olines;
vid_line_t *oline;
/* Line processes */
int nprocesses;
_lineprocess_t *processes;
_lineprocess_t *output_process;
};
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 void vid_get_colour_subcarrier(vid_t *s, int frame, int line, int16_t **pb, int16_t **pi, int16_t **pq);
extern int vid_av_close(vid_t *s);
extern void vid_info(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
|