summaryrefslogtreecommitdiff
path: root/ext/closedcaption/sliced.h
blob: 36f922dbf2d05a8b537be94a0219c4bb489402aa (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
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
/*
 *  libzvbi -- Sliced VBI data
 *
 *  Copyright (C) 2000, 2001 Michael H. Schimek
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library 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
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the 
 *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 *  Boston, MA  02110-1301  USA.
 */

/* $Id: sliced.h,v 1.11 2008-02-24 14:17:02 mschimek Exp $ */

#ifndef SLICED_H
#define SLICED_H

#ifdef __cplusplus
extern "C" {
#endif

/* Public */

#include <inttypes.h>

/**
 * @addtogroup Sliced Sliced VBI data
 * @ingroup Raw
 * @brief Definition of sliced VBI data.
 *
 * The output of the libzvbi raw VBI decoder, and input to the data
 * service decoder, is VBI data in binary format as defined in this
 * section. It is similar to the output of hardware VBI decoders
 * and VBI data transmitted in digital TV streams.
 */

/**
 * @name Data service symbols
 * @ingroup Sliced
 * @{
 */

/**
 * @anchor VBI_SLICED_
 * No data service, blank vbi_sliced structure.
 */
#define VBI_SLICED_NONE			0

/**
 * Unknown data service (vbi_dvb_demux).
 * @since 0.2.10
 */
#define VBI_SLICED_UNKNOWN              0

/**
 * Antiope a.k.a. Teletext System A
 *
 * Reference: <a href="http://www.itu.ch">ITU-R BT.653
 * "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 37 bytes, without clock run-in and
 * framing code, lsb first transmitted.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_ANTIOPE              0x00002000
/**
 * Synonym of VBI_SLICED_ANTIOPE.
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_A           0x00002000

#define VBI_SLICED_TELETEXT_B_L10_625	0x00000001
#define VBI_SLICED_TELETEXT_B_L25_625	0x00000002
/**
 * Teletext System B for 625 line systems
 *
 * Note this is separated into Level 1.0 and Level 2.5+ since the latter
 * permits occupation of scan line 6 which is frequently out of
 * range of raw VBI capture drivers. Clients should request decoding of both,
 * may then verify Level 2.5 is covered. vbi_sliced id can be
 * VBI_SLICED_TELETEXT_B, _B_L10_625 or _B_L25_625 regardless of line number.
 *
 * Reference: <a href="http://www.etsi.org">EN 300 706
 * "Enhanced Teletext specification"</a>, <a href="http://www.itu.ch">
 * ITU-R BT.653 "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 42 of the 45 byte Teletext packet, that is
 * without clock run-in and framing code, lsb first transmitted.
 */
#define VBI_SLICED_TELETEXT_B		(VBI_SLICED_TELETEXT_B_L10_625 | \
					 VBI_SLICED_TELETEXT_B_L25_625)
/**
 * Synonym of VBI_SLICED_TELETEXT_B.
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_B_625	VBI_SLICED_TELETEXT_B

/**
 * Teletext System C for 625 line systems
 *
 * Reference: <a href="http://www.itu.ch">ITU-R BT.653
 * "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 33 bytes, without clock run-in and
 * framing code, lsb first transmitted.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_C_625       0x00004000

/**
 * Teletext System D for 625 line systems
 *
 * Reference: <a href="http://www.itu.ch">ITU-R BT.653
 * "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 34 bytes, without clock run-in and
 * framing code, lsb first transmitted.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_D_625       0x00008000

/**
 * Video Program System
 *
 * Reference: <a href="http://www.etsi.org">ETS 300 231
 * "Specification of the domestic video Programme
 * Delivery Control system (PDC)"</a>, <a href="http://www.irt.de">
 * IRT 8R2 "Video-Programm-System (VPS)"</a>.
 *
 * vbi_sliced payload: Byte number 3 to 15 according to ETS 300 231
 * Figure 9, lsb first transmitted.
 */
#define VBI_SLICED_VPS                  0x00000004

/**
 * Pseudo-VPS signal transmitted on field 2
 *
 * vbi_sliced payload: 13 bytes.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_VPS_F2               0x00001000

#define VBI_SLICED_CAPTION_625_F1       0x00000008
#define VBI_SLICED_CAPTION_625_F2       0x00000010
/**
 * Closed Caption for 625 line systems
 *
 * Note this is split into field one and two services since for basic
 * caption decoding only field one is required. vbi_sliced id can be
 * VBI_SLICED_CAPTION_625, _625_F1 or _625_F2 regardless of line number.
 *
 * Reference: <a href="http://global.ihs.com">EIA 608
 * "Recommended Practice for Line 21 Data Service"</a>.
 *
 * vbi_sliced payload: First and second byte including parity,
 * lsb first transmitted.
 */
#define VBI_SLICED_CAPTION_625		(VBI_SLICED_CAPTION_625_F1 | \
                                         VBI_SLICED_CAPTION_625_F2)

/**
 * Wide Screen Signalling for 625 line systems
 *
 * Reference: <a href="http://www.etsi.org">EN 300 294
 * "625-line television Wide Screen Signalling (WSS)"</a>.
 *
 * vbi_sliced payload:
 * ```
 * Byte         0                  1
 *       msb         lsb  msb             lsb
 * bit   7 6 5 4 3 2 1 0  x x 13 12 11 10 9 8
 * ```
 * according to EN 300 294, Table 1, lsb first transmitted.
 */
#define VBI_SLICED_WSS_625              0x00000400

#define VBI_SLICED_CAPTION_525_F1	0x00000020
#define VBI_SLICED_CAPTION_525_F2	0x00000040
/**
 * Closed Caption for 525 line systems (NTSC).
 *
 * Note this is split into field one and two services since for basic
 * caption decoding only field one is required. vbi_sliced id can be
 * VBI_SLICED_CAPTION_525, _525_F1 or _525_F2 regardless of line number.
 *
 * VBI_SLICED_CAPTION_525 also covers XDS (Extended Data Service),
 * V-Chip data and ITV / WebTV data.
 *
 * Reference: <a href="http://global.ihs.com">EIA 608
 * "Recommended Practice for Line 21 Data Service"</a>.
 *
 * vbi_sliced payload: First and second byte including parity,
 * lsb first transmitted.
 */
#define VBI_SLICED_CAPTION_525		(VBI_SLICED_CAPTION_525_F1 | \
					 VBI_SLICED_CAPTION_525_F2)
/**
 * Closed Caption at double bit rate for 525 line systems.
 *
 * Reference: ?
 *
 * vbi_sliced payload: First to fourth byte including parity bit,
 * lsb first transmitted.
 */
#define VBI_SLICED_2xCAPTION_525	0x00000080

/**
 * Teletext System B for 525 line systems
 *
 * Reference: <a href="http://www.itu.ch">ITU-R BT.653
 * "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 34 bytes, without clock run-in and
 * framing code, lsb first transmitted.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_B_525       0x00010000

/**
 * North American Basic Teletext Specification
 * a.k.a. Teletext System C for 525 line systems
 *
 * Reference: <a href="http://global.ihs.com">EIA-516
 * "North American Basic Teletext Specification (NABTS)"</a>,
 * <a href="http://www.itu.ch">ITU-R BT.653 "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 33 bytes, without clock run-in and
 * framing code, lsb first transmitted.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_NABTS                0x00000100

/**
 * Synonym of VBI_SLICED_NABTS.
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_C_525       0x00000100

/**
 * Misdefined.
 *
 * vbi_sliced payload: 34 bytes.
 *
 * @deprecated
 * This service was misdefined.
 * Use VBI_SLICED_TELETEXT_B_525 or VBI_SLICED_TELETEXT_D_525 in new code.
 */
#define VBI_SLICED_TELETEXT_BD_525	0x00000200

/**
 * Teletext System D for 525 line systems
 *
 * Reference: <a href="http://www.itu.ch">ITU-R BT.653
 * "Teletext Systems"</a>
 *
 * vbi_sliced payload: Last 34 bytes, without clock run-in and
 * framing code, lsb first transmitted.
 *
 * @since 0.2.10
 */
#define VBI_SLICED_TELETEXT_D_525       0x00020000

/**
 * Wide Screen Signalling for NTSC Japan
 *
 * Reference: <a href="http://www.jeita.or.jp">EIA-J CPR-1204</a>
 *
 * vbi_sliced payload:
 * ```
 * Byte         0                    1                  2
 *       msb         lsb  msb               lsb  msb             lsb
 * bit   7 6 5 4 3 2 1 0  15 14 13 12 11 10 9 8  x x x x 19 18 17 16
 * ```
 */

#define VBI_SLICED_WSS_CPR1204		0x00000800

/**
 * No actual data service. This symbol is used to request capturing
 * of all PAL/SECAM VBI data lines from the libzvbi driver interface,
 * as opposed to just those lines used to transmit the requested
 * data services.
 */
#define VBI_SLICED_VBI_625		0x20000000

/**
 * No actual data service. This symbol is used to request capturing
 * of all NTSC VBI data lines from the libzvbi driver interface,
 * as opposed to just those lines used to transmit the requested
 * data services.
 */
#define VBI_SLICED_VBI_525		0x40000000

/** @} */

typedef unsigned int vbi_service_set;

/**
 * @ingroup Sliced
 * @brief This structure holds one scan line of sliced vbi data.
 *
 * For example the contents of NTSC line 21, two bytes of Closed Caption
 * data. Usually an array of vbi_sliced is used, covering all
 * VBI lines of the two fields of a video frame.
 */
typedef struct {
	/**
	 * A @ref VBI_SLICED_ symbol identifying the data service. Under circumstances
	 * (see VBI_SLICED_TELETEXT_B) this can be a set of VBI_SLICED_ symbols.
	 */
	uint32_t		id;
	/**
	 * Source line number according to the ITU-R line numbering scheme,
	 * a value of @c 0 if the exact line number is unknown. Note that some
	 * data services cannot be reliable decoded without line number.
	 *
	 * @image html zvbi_625.gif "ITU-R PAL/SECAM line numbering scheme"
	 * @image html zvbi_525.gif "ITU-R NTSC line numbering scheme"
	 */
	uint32_t		line;
	/**
	 * The actual payload. See the documentation of @ref VBI_SLICED_ symbols
	 * for details.
	 */
	uint8_t			data[56];
} vbi_sliced;

/**
 * @addtogroup Sliced
 * @{
 */
extern const char *
vbi_sliced_name			(vbi_service_set	service)
  _vbi_const;
extern unsigned int
vbi_sliced_payload_bits		(vbi_service_set	service)
  _vbi_const;
/** @} */

/* Private */

#ifdef __cplusplus
}
#endif

#endif /* SLICED_H */

/*
Local variables:
c-set-style: K&R
c-basic-offset: 8
End:
*/