forked from fsphil/hacktv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teletext.h
136 lines (100 loc) · 3.76 KB
/
teletext.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
/* hacktv - Analogue video transmitter for the HackRF */
/*=======================================================================*/
/* Copyright 2018 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 _TELETEXT_H
#define _TELETEXT_H
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include "video.h"
typedef struct _tt_page_t {
/* The page number, 0x100 - 0x8FF */
uint16_t page;
/* Subpage number: 0x00 - 0xFF */
uint8_t subpage;
/* Subcode: 0x0000 - 0x3F7F */
uint16_t subcode;
/* Page status 0x0000 - 0xFFFF */
uint16_t page_status;
/* Cycle mode / time */
int cycle_mode; /* 0 = Seconds, 1 = Cycles */
int cycle_time; /* Seconds / cycles until next subpage */
int cycle_count; /* Cycle counter */
/* Fastext links */
int links[6];
/* Flag to transmit the erasure code, only done on a new subpage */
int erase; /* 0 = Don't erase, 1 = Erase */
/* The number of packets that make up the page,
* not including the header */
int packets;
/* The number of packets that can be transmitted
* within 20ms of the header packet */
int nodelay_packets;
/* Pointer to the packets that make up this
* page. Each packet is 45 bytes long and
* represents the full VBI line. */
uint8_t *data;
/* A pointer to the first subpage */
struct _tt_page_t *subpages;
/* A pointer to the next subpage */
struct _tt_page_t *next_subpage;
/* A pointer to the next page */
struct _tt_page_t *next;
} tt_page_t;
typedef struct {
/* The magazine number, 1-8 */
int magazine;
/* Set to 1 if the next magazine packet has to
* to be a header filler packet */
int filler;
/* A pointer to the first page */
tt_page_t *pages;
/* A pointer to the currently active page */
tt_page_t *page;
/* The currently active row */
int row;
/* Timecode to resume sending display packets */
int delay;
} tt_magazine_t;
typedef struct {
/* The current timestamp to use for the clock */
time_t timestamp;
/* The number of ticks that represent 20ms. This is
* used to enforce a minimum time between header
* packets and displayable packets of the same page.
* Sometimes referred to as the 20ms rule, page
* erasure interval or page clearing interval. */
unsigned int header_delay;
/* The number of clock ticks that represent 1s.
* This is used to determine when to send the next
* 8/30 packet, containing the updated time */
unsigned int second_delay;
/* The currently active magazine */
unsigned int magazine;
/* The available magazines */
tt_magazine_t magazines[8];
} tt_service_t;
typedef struct {
vid_t *vid;
int16_t *lut;
FILE *raw;
tt_service_t service;
unsigned int timecode;
} tt_t;
extern int tt_init(tt_t *s, vid_t *vid, char *path);
extern void tt_free(tt_t *s);
extern void tt_render_line(tt_t *s);
#endif