summaryrefslogtreecommitdiff
path: root/src/libzvbi.h (plain)
blob: 4f562ee1e4219c2f7cf9a8a802c953c47df5695f
1/*
2 * libzvbi -- VBI decoding library
3 *
4 * Copyright (C) 2000, 2001, 2002 Michael H. Schimek
5 * Copyright (C) 2000, 2001 Iñaki García Etxebarria
6 *
7 * Originally based on AleVT 1.5.1 by Edgar Toernig
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 */
24
25/* Generated file, do not edit! */
26
27#ifndef __LIBZVBI_H__
28#define __LIBZVBI_H__
29
30#define VBI_VERSION_MAJOR 0
31#define VBI_VERSION_MINOR 2
32#define VBI_VERSION_MICRO 33
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38
39typedef struct vbi_decoder vbi_decoder;
40
41/* macros.h */
42
43#if __GNUC__ >= 4
44# define _vbi_sentinel __attribute__ ((__sentinel__(0)))
45# define _vbi_deprecated __attribute__ ((__deprecated__))
46#else
47# define _vbi_sentinel
48# define _vbi_deprecated
49# define __restrict__
50#endif
51
52#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ >= 4
53# define _vbi_nonnull(params) __attribute__ ((__nonnull__ params))
54# define _vbi_format(params) __attribute__ ((__format__ params))
55#else
56# define _vbi_nonnull(params)
57# define _vbi_format(params)
58#endif
59
60#if __GNUC__ >= 3
61# define _vbi_pure __attribute__ ((__pure__))
62# define _vbi_alloc __attribute__ ((__malloc__))
63#else
64# define _vbi_pure
65# define _vbi_alloc
66#endif
67
68#if __GNUC__ >= 2
69# define _vbi_unused __attribute__ ((__unused__))
70# define _vbi_const __attribute__ ((__const__))
71# define _vbi_inline static __inline__
72#else
73# define _vbi_unused
74# define _vbi_const
75# define _vbi_inline static
76#endif
77
78#ifndef TRUE
79# define TRUE 1
80#endif
81#ifndef FALSE
82# define FALSE 0
83#endif
84
85typedef int vbi_bool;
86
87
88#ifndef NULL
89# ifdef __cplusplus
90# define NULL (0L)
91# else
92# define NULL ((void *) 0)
93# endif
94#endif
95
96/* XXX Document me - for variadic funcs. */
97#define VBI_END ((void *) 0)
98
99#if 0
100typedef void
101vbi_lock_fn (void * user_data);
102typedef void
103vbi_unlock_fn (void * user_data);
104#endif
105
106typedef enum {
107
108 VBI_LOG_ERROR = 1 << 3,
109
110 VBI_LOG_WARNING = 1 << 4,
111
112 VBI_LOG_NOTICE = 1 << 5,
113
114
115 VBI_LOG_INFO = 1 << 6,
116
117
118 VBI_LOG_DEBUG = 1 << 7,
119
120
121 VBI_LOG_DRIVER = 1 << 8,
122
123
124 VBI_LOG_DEBUG2 = 1 << 9,
125 VBI_LOG_DEBUG3 = 1 << 10
126} vbi_log_mask;
127
128typedef void
129vbi_log_fn (vbi_log_mask level,
130 const char * context,
131 const char * message,
132 void * user_data);
133
134extern vbi_log_fn vbi_log_on_stderr;
135
136
137/* bcd.h */
138
139/* XXX unsigned? */
140typedef int vbi_pgno;
141
142typedef int vbi_subno;
143
144#define VBI_ANY_SUBNO 0x3F7F
145#define VBI_NO_SUBNO 0x3F7F
146
147_vbi_inline unsigned int
148vbi_dec2bcd(unsigned int dec)
149{
150 return (dec % 10) + ((dec / 10) % 10) * 16 + ((dec / 100) % 10) * 256;
151}
152
153#define vbi_bin2bcd(n) vbi_dec2bcd(n)
154
155_vbi_inline unsigned int
156vbi_bcd2dec(unsigned int bcd)
157{
158 return (bcd & 15) + ((bcd >> 4) & 15) * 10 + ((bcd >> 8) & 15) * 100;
159}
160
161#define vbi_bcd2bin(n) vbi_bcd2dec(n)
162
163_vbi_inline unsigned int
164vbi_add_bcd(unsigned int a, unsigned int b)
165{
166 unsigned int t;
167
168 a += 0x06666666;
169 t = a + b;
170 b ^= a ^ t;
171 b = (~b & 0x11111110) >> 3;
172 b |= b * 2;
173
174 return t - b;
175}
176
177_vbi_inline vbi_bool
178vbi_is_bcd(unsigned int bcd)
179{
180 static const unsigned int x = 0x06666666;
181
182 return (((bcd + x) ^ (bcd ^ x)) & 0x11111110) == 0;
183}
184
185_vbi_inline vbi_bool
186vbi_bcd_digits_greater (unsigned int bcd,
187 unsigned int maximum)
188{
189 maximum ^= ~0;
190
191 return 0 != (((bcd + maximum) ^ bcd ^ maximum) & 0x11111110);
192}
193
194/* conv.h */
195
196#include <stdio.h>
197#include <inttypes.h> /* uint16_t */
198
199
200#define VBI_NUL_TERMINATED -1
201
202extern unsigned long
203vbi_strlen_ucs2 (const uint16_t * src);
204extern char *
205vbi_strndup_iconv (const char * dst_codeset,
206 const char * src_codeset,
207 const char * src,
208 unsigned long src_size,
209 int repl_char)
210 _vbi_alloc;
211extern char *
212vbi_strndup_iconv_ucs2 (const char * dst_codeset,
213 const uint16_t * src,
214 long src_length,
215 int repl_char)
216 _vbi_alloc;
217extern char *
218vbi_strndup_iconv_caption (const char * dst_codeset,
219 const char * src,
220 long src_length,
221 int repl_char)
222 _vbi_alloc;
223#if 3 == VBI_VERSION_MINOR
224extern char *
225vbi_strndup_iconv_teletext (const char * dst_codeset,
226 const vbi_ttx_charset *cs,
227 const uint8_t * src,
228 long src_length,
229 int repl_char)
230 _vbi_alloc _vbi_nonnull ((2));
231#endif
232extern vbi_bool
233vbi_fputs_iconv (FILE * fp,
234 const char * dst_codeset,
235 const char * src_codeset,
236 const char * src,
237 unsigned long src_size,
238 int repl_char)
239 _vbi_nonnull ((1));
240extern vbi_bool
241vbi_fputs_iconv_ucs2 (FILE * fp,
242 const char * dst_codeset,
243 const uint16_t * src,
244 long src_length,
245 int repl_char)
246 _vbi_nonnull ((1));
247extern const char *
248vbi_locale_codeset (void);
249
250
251
252/* event.h */
253
254#include <inttypes.h>
255
256
257typedef unsigned int vbi_nuid;
258
259typedef struct {
260 vbi_nuid nuid;
261
262 signed char name[64];
263
264 signed char call[40];
265
266 int tape_delay;
267
268 int cni_vps;
269
270 int cni_8301;
271
272 int cni_8302;
273
274 int reserved;
275
276
277 int cycle;
278} vbi_network;
279
280/*
281 * Link
282 */
283
284typedef enum {
285 VBI_LINK_NONE = 0,
286 VBI_LINK_MESSAGE,
287 VBI_LINK_PAGE,
288 VBI_LINK_SUBPAGE,
289 VBI_LINK_HTTP,
290 VBI_LINK_FTP,
291 VBI_LINK_EMAIL,
292
293 VBI_LINK_LID,
294
295 VBI_LINK_TELEWEB
296} vbi_link_type;
297
298typedef enum {
299 VBI_WEBLINK_UNKNOWN = 0,
300 VBI_WEBLINK_PROGRAM_RELATED,
301 VBI_WEBLINK_NETWORK_RELATED,
302 VBI_WEBLINK_STATION_RELATED,
303 VBI_WEBLINK_SPONSOR_MESSAGE,
304 VBI_WEBLINK_OPERATOR
305} vbi_itv_type;
306
307typedef struct vbi_link {
308 vbi_link_type type;
309 vbi_bool eacem;
310 signed char name[80];
311 signed char url[256];
312 signed char script[256];
313 vbi_nuid nuid;
314 vbi_pgno pgno;
315 vbi_subno subno;
316 double expires;
317 vbi_itv_type itv_type;
318 int priority;
319 vbi_bool autoload;
320} vbi_link;
321
322/*
323 * Aspect ratio information.
324 */
325
326typedef enum {
327 VBI_SUBT_NONE,
328 VBI_SUBT_ACTIVE,
329 VBI_SUBT_MATTE,
330 VBI_SUBT_UNKNOWN
331} vbi_subt;
332
333typedef struct {
334 int first_line;
335 int last_line;
336 double ratio;
337 vbi_bool film_mode;
338 vbi_subt open_subtitles;
339} vbi_aspect_ratio;
340
341/*
342 * Program Info
343 *
344 * ATTN this is new stuff and subject to change
345 */
346
347typedef enum {
348 VBI_RATING_AUTH_NONE = 0,
349 VBI_RATING_AUTH_MPAA,
350 VBI_RATING_AUTH_TV_US,
351 VBI_RATING_AUTH_TV_CA_EN,
352 VBI_RATING_AUTH_TV_CA_FR
353} vbi_rating_auth;
354
355#define VBI_RATING_D 0x08
356#define VBI_RATING_L 0x04
357#define VBI_RATING_S 0x02
358#define VBI_RATING_V 0x01
359
360
361extern const char * vbi_rating_string(vbi_rating_auth auth, int id);
362
363typedef enum {
364 VBI_PROG_CLASSF_NONE = 0,
365 VBI_PROG_CLASSF_EIA_608,
366 VBI_PROG_CLASSF_ETS_300231
367} vbi_prog_classf;
368
369extern const char * vbi_prog_type_string(vbi_prog_classf classf, int id);
370
371
372/* code depends on order, don't change */
373typedef enum {
374 VBI_AUDIO_MODE_NONE = 0,
375 VBI_AUDIO_MODE_MONO,
376 VBI_AUDIO_MODE_STEREO,
377 VBI_AUDIO_MODE_STEREO_SURROUND,
378 VBI_AUDIO_MODE_SIMULATED_STEREO,
379 VBI_AUDIO_MODE_VIDEO_DESCRIPTIONS,
380 VBI_AUDIO_MODE_NON_PROGRAM_AUDIO,
381
382 VBI_AUDIO_MODE_SPECIAL_EFFECTS,
383 VBI_AUDIO_MODE_DATA_SERVICE,
384 VBI_AUDIO_MODE_UNKNOWN
385} vbi_audio_mode;
386
387typedef struct vbi_program_info {
388 /*
389 * Refers to the current or next program.
390 * (No [2] to allow clients filtering current data more easily.)
391 */
392 unsigned int future : 1;
393
394 /* 01 Program Identification Number */
395
396 /* If unknown all these fields are -1 */
397 signed char month; /* 0 ... 11 */
398 signed char day; /* 0 ... 30 */
399 signed char hour; /* 0 ... 23 */
400 signed char min; /* 0 ... 59 */
401
402 /*
403 * VD: "T indicates if a program is routinely tape delayed for the
404 * Mountain and Pacific time zones."
405 */
406 signed char tape_delayed;
407
408 /* 02 Program Length */
409
410 /* If unknown all these fields are -1 */
411 signed char length_hour; /* 0 ... 63 */
412 signed char length_min; /* 0 ... 59 */
413
414 signed char elapsed_hour; /* 0 ... 63 */
415 signed char elapsed_min; /* 0 ... 59 */
416 signed char elapsed_sec; /* 0 ... 59 */
417
418 /* 03 Program name */
419
420 /* If unknown title[0] == 0 */
421 signed char title[64]; /* ASCII + '\0' */
422
423 /* 04 Program type */
424
425 /*
426 * If unknown type_classf == VBI_PROG_CLASSF_NONE.
427 * VBI_PROG_CLASSF_EIA_608 can have up to 32 tags
428 * identifying 96 keywords. Their numerical value
429 * is given here instead of composing a string for
430 * easier filtering. Use vbi_prog_type_str_by_id to
431 * get the keywords. A zero marks the end.
432 */
433 vbi_prog_classf type_classf;
434 int type_id[33];
435
436 /* 05 Program rating */
437
438 /*
439 * For details STFW for "v-chip"
440 * If unknown rating_auth == VBI_RATING_NONE
441 */
442 vbi_rating_auth rating_auth;
443 int rating_id;
444
445 /* Only valid when auth == VBI_RATING_TV_US */
446 int rating_dlsv;
447
448 /* 06 Program Audio Services */
449
450 /*
451 * BTSC audio (two independent tracks) is flagged according to XDS,
452 * Zweiton/NICAM/EIA-J audio is flagged mono/none, stereo/none or
453 * mono/mono for bilingual transmissions.
454 */
455 struct {
456 /* If unknown mode == VBI_AUDIO_MODE_UNKNOWN */
457 vbi_audio_mode mode;
458 /* If unknown language == NULL */
459 unsigned char * language; /* Latin-1 */
460 } audio[2]; /* primary and secondary */
461
462 /* 07 Program Caption Services */
463
464 /*
465 * Bits 0...7 corresponding to Caption page 1...8.
466 * Note for the current program this information is also
467 * available via vbi_classify_page().
468 *
469 * If unknown caption_services == -1, _language[] = NULL
470 */
471 int caption_services;
472 unsigned char * caption_language[8]; /* Latin-1 */
473
474 /* 08 Copy Generation Management System */
475
476 /* If unknown cgms_a == -1 */
477 int cgms_a; /* XXX */
478
479 /* 09 Aspect Ratio */
480
481 /*
482 * Note for the current program this information is also
483 * available via VBI_EVENT_ASPECT.
484 *
485 * If unknown first_line == last_line == -1, ratio == 0.0
486 */
487 vbi_aspect_ratio aspect;
488
489 /* 10 - 17 Program Description */
490
491 /*
492 * 8 rows of 0...32 ASCII chars + '\0',
493 * if unknown description[0...7][0] == 0
494 */
495 signed char description[8][33];
496} vbi_program_info;
497
498extern void vbi_reset_prog_info(vbi_program_info *pi);
499
500
501
502#define VBI_EVENT_NONE 0x0000
503#define VBI_EVENT_CLOSE 0x0001
504#define VBI_EVENT_TTX_PAGE 0x0002
505#define VBI_EVENT_CAPTION 0x0004
506#define VBI_EVENT_NETWORK 0x0008
507#define VBI_EVENT_TRIGGER 0x0010
508#define VBI_EVENT_ASPECT 0x0040
509#define VBI_EVENT_PROG_INFO 0x0080
510#define VBI_EVENT_NETWORK_ID 0x0100
511
512
513
514#include <inttypes.h>
515
516/* XXX network, aspect, prog_info: should only notify about
517 * changes and provide functions to query current value.
518 */
519typedef struct vbi_event {
520 int type;
521 union {
522 struct {
523 int pgno;
524 int subno;
525 uint8_t * raw_header;
526 int pn_offset;
527 unsigned int roll_header : 1;
528 unsigned int header_update : 1;
529 unsigned int clock_update : 1;
530 } ttx_page;
531 struct {
532 int pgno;
533 } caption;
534 vbi_network network;
535 vbi_link * trigger;
536 vbi_aspect_ratio aspect;
537 vbi_program_info * prog_info;
538 } ev;
539} vbi_event;
540
541typedef void (* vbi_event_handler)(vbi_event *event, void *user_data);
542
543extern vbi_bool vbi_event_handler_add(vbi_decoder *vbi, int event_mask,
544 vbi_event_handler handler,
545 void *user_data);
546extern void vbi_event_handler_remove(vbi_decoder *vbi,
547 vbi_event_handler handler);
548extern vbi_bool vbi_event_handler_register(vbi_decoder *vbi, int event_mask,
549 vbi_event_handler handler,
550 void *user_data);
551extern void vbi_event_handler_unregister(vbi_decoder *vbi,
552 vbi_event_handler handler,
553 void *user_data);
554
555
556/* format.h */
557
558#include <inttypes.h>
559
560
561/* Code depends on order, don't change. */
562typedef enum {
563 VBI_BLACK,
564 VBI_RED,
565 VBI_GREEN,
566 VBI_YELLOW,
567 VBI_BLUE,
568 VBI_MAGENTA,
569 VBI_CYAN,
570 VBI_WHITE
571} vbi_color;
572
573typedef uint32_t vbi_rgba;
574
575#define VBI_RGBA(r, g, b) \
576 ((((r) & 0xFF) << 0) | (((g) & 0xFF) << 8) \
577 | (((b) & 0xFF) << 16) | (0xFF << 24))
578#define VBI_R(rgba) (((rgba) >> 0) & 0xFF)
579#define VBI_G(rgba) (((rgba) >> 8) & 0xFF)
580#define VBI_B(rgba) (((rgba) >> 16) & 0xFF)
581#define VBI_A(rgba) (((rgba) >> 24) & 0xFF)
582
583
584typedef enum {
585 VBI_TRANSPARENT_SPACE,
586 VBI_TRANSPARENT_FULL,
587 VBI_SEMI_TRANSPARENT,
588 VBI_OPAQUE
589} vbi_opacity;
590
591/* Code depends on order, don't change. */
592typedef enum {
593 VBI_NORMAL_SIZE, VBI_DOUBLE_WIDTH, VBI_DOUBLE_HEIGHT, VBI_DOUBLE_SIZE,
594 VBI_OVER_TOP, VBI_OVER_BOTTOM, VBI_DOUBLE_HEIGHT2, VBI_DOUBLE_SIZE2
595} vbi_size;
596
597typedef struct vbi_char {
598 unsigned underline : 1;
599 unsigned bold : 1;
600 unsigned italic : 1;
601 unsigned flash : 1;
602 unsigned conceal : 1;
603 unsigned proportional : 1;
604 unsigned link : 1;
605 unsigned reserved : 1;
606 unsigned size : 8;
607 unsigned opacity : 8;
608 unsigned foreground : 8;
609 unsigned background : 8;
610 unsigned drcs_clut_offs : 8;
611 unsigned unicode : 16;
612} vbi_char;
613
614struct vbi_font_descr;
615
616typedef struct vbi_page {
617 vbi_decoder * vbi;
618
619 vbi_nuid nuid;
620 /* FIXME this shouldn't be int */
621 int pgno;
622 /* FIXME this shouldn't be int */
623 int subno;
624 int rows;
625 int columns;
626 vbi_char text[1056];
627
628 struct {
629 /* int x0, x1; */
630 int y0, y1;
631 int roll;
632 } dirty;
633
634 vbi_color screen_color;
635 vbi_opacity screen_opacity;
636 vbi_rgba color_map[40];
637
638 uint8_t * drcs_clut; /* 64 entries */
639 uint8_t * drcs[32];
640
641 struct {
642 int pgno, subno;
643 } nav_link[6];
644 char nav_index[64];
645
646 struct vbi_font_descr * font[2];
647 unsigned int double_height_lower; /* legacy */
648
649 vbi_opacity page_opacity[2];
650 vbi_opacity boxed_opacity[2];
651} vbi_page;
652
653/* lang.h */
654
655typedef struct vbi_font_descr vbi_font_descr;
656
657_vbi_inline vbi_bool
658vbi_is_print(unsigned int unicode)
659{
660 return unicode < 0xE600;
661}
662
663_vbi_inline vbi_bool
664vbi_is_gfx(unsigned int unicode)
665{
666 return unicode >= 0xEE00 && unicode <= 0xEFFF;
667}
668
669_vbi_inline vbi_bool
670vbi_is_drcs(unsigned int unicode)
671{
672 return unicode >= 0xF000;
673}
674
675extern unsigned int
676vbi_caption_unicode (unsigned int c,
677 vbi_bool to_upper);
678
679/* export.h */
680
681#include <stdio.h> /* FILE */
682#include <sys/types.h> /* size_t, ssize_t */
683
684typedef struct vbi_export vbi_export;
685
686typedef struct vbi_export_info {
687 char * keyword;
688 char * label;
689 char * tooltip;
690 char * mime_type;
691 char * extension;
692} vbi_export_info;
693
694typedef enum {
695 VBI_OPTION_BOOL = 1,
696
697 VBI_OPTION_INT,
698
699 VBI_OPTION_REAL,
700
701 VBI_OPTION_STRING,
702
703 VBI_OPTION_MENU
704} vbi_option_type;
705
706typedef union {
707 int num;
708 double dbl;
709 char * str;
710} vbi_option_value;
711
712typedef union {
713 int * num;
714 double * dbl;
715 char ** str;
716} vbi_option_value_ptr;
717
718typedef struct {
719 vbi_option_type type;
720
721 char * keyword;
722
723 char * label;
724
725 vbi_option_value def;
726 vbi_option_value min;
727 vbi_option_value max;
728 vbi_option_value step;
729 vbi_option_value_ptr menu;
730
731 char * tooltip;
732} vbi_option_info;
733
734extern vbi_export_info * vbi_export_info_enum(int index);
735extern vbi_export_info * vbi_export_info_keyword(const char *keyword);
736extern vbi_export_info * vbi_export_info_export(vbi_export *);
737
738extern vbi_export * vbi_export_new(const char *keyword, char **errstr);
739extern void vbi_export_delete(vbi_export *);
740
741extern vbi_option_info * vbi_export_option_info_enum(vbi_export *, int index);
742extern vbi_option_info * vbi_export_option_info_keyword(vbi_export *, const char *keyword);
743
744extern vbi_bool vbi_export_option_set(vbi_export *, const char *keyword, ...);
745extern vbi_bool vbi_export_option_get(vbi_export *, const char *keyword,
746 vbi_option_value *value);
747extern vbi_bool vbi_export_option_menu_set(vbi_export *, const char *keyword, int entry);
748extern vbi_bool vbi_export_option_menu_get(vbi_export *, const char *keyword, int *entry);
749
750extern ssize_t
751vbi_export_mem (vbi_export * e,
752 void * buffer,
753 size_t buffer_size,
754 const vbi_page * pg)
755 _vbi_nonnull ((1)); /* sic */
756extern void *
757vbi_export_alloc (vbi_export * e,
758 void ** buffer,
759 size_t * buffer_size,
760 const vbi_page * pg)
761 _vbi_nonnull ((1)); /* sic */
762extern vbi_bool vbi_export_stdio(vbi_export *, FILE *fp, vbi_page *pg);
763extern vbi_bool vbi_export_file(vbi_export *, const char *name, vbi_page *pg);
764
765extern char * vbi_export_errstr(vbi_export *);
766
767
768/* cache.h */
769
770extern void vbi_unref_page(vbi_page *pg);
771extern int vbi_is_cached(vbi_decoder *, int pgno, int subno);
772extern int vbi_cache_hi_subno(vbi_decoder *vbi, int pgno);
773
774
775/* search.h */
776
777typedef enum {
778 VBI_SEARCH_ERROR = -3,
779 VBI_SEARCH_CACHE_EMPTY,
780 VBI_SEARCH_CANCELED,
781 VBI_SEARCH_NOT_FOUND = 0,
782 VBI_SEARCH_SUCCESS
783} vbi_search_status;
784
785typedef struct vbi_search vbi_search;
786
787extern vbi_search * vbi_search_new(vbi_decoder *vbi,
788 vbi_pgno pgno, vbi_subno subno,
789 uint16_t *pattern,
790 vbi_bool casefold, vbi_bool regexp,
791 int (* progress)(vbi_page *pg));
792extern void vbi_search_delete(vbi_search *search);
793extern vbi_search_status vbi_search_next(vbi_search *search, vbi_page **pg, int dir);
794
795
796/* sliced.h */
797
798#include <inttypes.h>
799
800
801
802#define VBI_SLICED_NONE 0
803
804#define VBI_SLICED_UNKNOWN 0
805
806#define VBI_SLICED_ANTIOPE 0x00002000
807#define VBI_SLICED_TELETEXT_A 0x00002000
808
809#define VBI_SLICED_TELETEXT_B_L10_625 0x00000001
810#define VBI_SLICED_TELETEXT_B_L25_625 0x00000002
811#define VBI_SLICED_TELETEXT_B (VBI_SLICED_TELETEXT_B_L10_625 | \
812 VBI_SLICED_TELETEXT_B_L25_625)
813#define VBI_SLICED_TELETEXT_B_625 VBI_SLICED_TELETEXT_B
814
815#define VBI_SLICED_TELETEXT_C_625 0x00004000
816
817#define VBI_SLICED_TELETEXT_D_625 0x00008000
818
819#define VBI_SLICED_VPS 0x00000004
820
821#define VBI_SLICED_VPS_F2 0x00001000
822
823#define VBI_SLICED_CAPTION_625_F1 0x00000008
824#define VBI_SLICED_CAPTION_625_F2 0x00000010
825#define VBI_SLICED_CAPTION_625 (VBI_SLICED_CAPTION_625_F1 | \
826 VBI_SLICED_CAPTION_625_F2)
827
828#define VBI_SLICED_WSS_625 0x00000400
829
830#define VBI_SLICED_CAPTION_525_F1 0x00000020
831#define VBI_SLICED_CAPTION_525_F2 0x00000040
832#define VBI_SLICED_CAPTION_525 (VBI_SLICED_CAPTION_525_F1 | \
833 VBI_SLICED_CAPTION_525_F2)
834#define VBI_SLICED_2xCAPTION_525 0x00000080
835
836#define VBI_SLICED_TELETEXT_B_525 0x00010000
837
838#define VBI_SLICED_NABTS 0x00000100
839
840#define VBI_SLICED_TELETEXT_C_525 0x00000100
841
842#define VBI_SLICED_TELETEXT_BD_525 0x00000200
843
844#define VBI_SLICED_TELETEXT_D_525 0x00020000
845
846
847#define VBI_SLICED_WSS_CPR1204 0x00000800
848
849#define VBI_SLICED_VBI_625 0x20000000
850
851#define VBI_SLICED_VBI_525 0x40000000
852
853
854
855typedef unsigned int vbi_service_set;
856
857typedef struct {
858 uint32_t id;
859 uint32_t line;
860 uint8_t data[56];
861} vbi_sliced;
862
863extern const char *
864vbi_sliced_name (vbi_service_set service)
865 _vbi_const;
866extern unsigned int
867vbi_sliced_payload_bits (vbi_service_set service)
868 _vbi_const;
869
870
871/* decoder.h */
872
873#include <pthread.h>
874
875/* Bit slicer */
876
877/* Attn: keep this in sync with rte, don't change order */
878typedef enum {
879 VBI_PIXFMT_YUV420 = 1,
880 VBI_PIXFMT_YUYV,
881 VBI_PIXFMT_YVYU,
882 VBI_PIXFMT_UYVY,
883 VBI_PIXFMT_VYUY,
884 VBI_PIXFMT_PAL8,
885 VBI_PIXFMT_RGBA32_LE = 32,
886 VBI_PIXFMT_RGBA32_BE,
887 VBI_PIXFMT_BGRA32_LE,
888 VBI_PIXFMT_BGRA32_BE,
889 VBI_PIXFMT_ABGR32_BE = 32, /* synonyms */
890 VBI_PIXFMT_ABGR32_LE,
891 VBI_PIXFMT_ARGB32_BE,
892 VBI_PIXFMT_ARGB32_LE,
893 VBI_PIXFMT_RGB24,
894 VBI_PIXFMT_BGR24,
895 VBI_PIXFMT_RGB16_LE,
896 VBI_PIXFMT_RGB16_BE,
897 VBI_PIXFMT_BGR16_LE,
898 VBI_PIXFMT_BGR16_BE,
899 VBI_PIXFMT_RGBA15_LE,
900 VBI_PIXFMT_RGBA15_BE,
901 VBI_PIXFMT_BGRA15_LE,
902 VBI_PIXFMT_BGRA15_BE,
903 VBI_PIXFMT_ARGB15_LE,
904 VBI_PIXFMT_ARGB15_BE,
905 VBI_PIXFMT_ABGR15_LE,
906 VBI_PIXFMT_ABGR15_BE
907} vbi_pixfmt;
908
909
910typedef enum {
911 VBI_MODULATION_NRZ_LSB,
912 VBI_MODULATION_NRZ_MSB,
913 VBI_MODULATION_BIPHASE_LSB,
914 VBI_MODULATION_BIPHASE_MSB
915} vbi_modulation;
916
917typedef struct vbi_bit_slicer {
918 vbi_bool (* func)(struct vbi_bit_slicer *slicer,
919 uint8_t *raw, uint8_t *buf);
920 unsigned int cri;
921 unsigned int cri_mask;
922 int thresh;
923 int cri_bytes;
924 int cri_rate;
925 int oversampling_rate;
926 int phase_shift;
927 int step;
928 unsigned int frc;
929 int frc_bits;
930 int payload;
931 int endian;
932 int skip;
933} vbi_bit_slicer;
934
935extern void vbi_bit_slicer_init(vbi_bit_slicer *slicer,
936 int raw_samples, int sampling_rate,
937 int cri_rate, int bit_rate,
938 unsigned int cri_frc, unsigned int cri_mask,
939 int cri_bits, int frc_bits, int payload,
940 vbi_modulation modulation, vbi_pixfmt fmt);
941_vbi_inline vbi_bool
942vbi_bit_slice(vbi_bit_slicer *slicer, uint8_t *raw, uint8_t *buf)
943{
944 return slicer->func(slicer, raw, buf);
945}
946
947
948typedef struct vbi_raw_decoder {
949 /* Sampling parameters */
950
951 int scanning;
952 vbi_pixfmt sampling_format;
953 int sampling_rate; /* Hz */
954 int bytes_per_line;
955 int offset; /* 0H, samples */
956 int start[2]; /* ITU-R numbering */
957 int count[2]; /* field lines */
958 vbi_bool interlaced;
959 vbi_bool synchronous;
960
961 /*< private >*/
962
963 pthread_mutex_t mutex;
964
965 unsigned int services;
966 int num_jobs;
967
968 int8_t * pattern;
969 struct _vbi_raw_decoder_job {
970 unsigned int id;
971 int offset;
972 vbi_bit_slicer slicer;
973 } jobs[8];
974} vbi_raw_decoder;
975
976extern void vbi_raw_decoder_init(vbi_raw_decoder *rd);
977extern void vbi_raw_decoder_reset(vbi_raw_decoder *rd);
978extern void vbi_raw_decoder_destroy(vbi_raw_decoder *rd);
979extern unsigned int vbi_raw_decoder_add_services(vbi_raw_decoder *rd,
980 unsigned int services,
981 int strict);
982extern unsigned int vbi_raw_decoder_check_services(vbi_raw_decoder *rd,
983 unsigned int services, int strict);
984extern unsigned int vbi_raw_decoder_remove_services(vbi_raw_decoder *rd,
985 unsigned int services);
986extern void vbi_raw_decoder_resize( vbi_raw_decoder *rd,
987 int * start, unsigned int * count );
988extern unsigned int vbi_raw_decoder_parameters(vbi_raw_decoder *rd, unsigned int services,
989 int scanning, int *max_rate);
990extern int vbi_raw_decode(vbi_raw_decoder *rd, uint8_t *raw, vbi_sliced *out);
991
992
993/* sampling_par.h */
994
995typedef vbi_raw_decoder vbi_sampling_par;
996
997#define VBI_VIDEOSTD_SET_EMPTY 0
998#define VBI_VIDEOSTD_SET_PAL_BG 1
999#define VBI_VIDEOSTD_SET_625_50 1
1000#define VBI_VIDEOSTD_SET_525_60 2
1001#define VBI_VIDEOSTD_SET_ALL 3
1002typedef uint64_t vbi_videostd_set;
1003
1004/* dvb_demux.h */
1005
1006
1007typedef struct _vbi_dvb_demux vbi_dvb_demux;
1008
1009typedef vbi_bool
1010vbi_dvb_demux_cb (vbi_dvb_demux * dx,
1011 void * user_data,
1012 const vbi_sliced * sliced,
1013 unsigned int sliced_lines,
1014 int64_t pts);
1015
1016extern void
1017vbi_dvb_demux_reset (vbi_dvb_demux * dx);
1018extern unsigned int
1019vbi_dvb_demux_cor (vbi_dvb_demux * dx,
1020 vbi_sliced * sliced,
1021 unsigned int sliced_lines,
1022 int64_t * pts,
1023 const uint8_t ** buffer,
1024 unsigned int * buffer_left);
1025extern vbi_bool
1026vbi_dvb_demux_feed (vbi_dvb_demux * dx,
1027 const uint8_t * buffer,
1028 unsigned int buffer_size);
1029extern void
1030vbi_dvb_demux_set_log_fn (vbi_dvb_demux * dx,
1031 vbi_log_mask mask,
1032 vbi_log_fn * log_fn,
1033 void * user_data);
1034extern void
1035vbi_dvb_demux_delete (vbi_dvb_demux * dx);
1036extern vbi_dvb_demux *
1037vbi_dvb_pes_demux_new (vbi_dvb_demux_cb * callback,
1038 void * user_data);
1039
1040
1041
1042/* dvb_mux.h */
1043
1044
1045extern vbi_bool
1046vbi_dvb_multiplex_sliced (uint8_t ** packet,
1047 unsigned int * packet_left,
1048 const vbi_sliced ** sliced,
1049 unsigned int * sliced_left,
1050 vbi_service_set service_mask,
1051 unsigned int data_identifier,
1052 vbi_bool stuffing)
1053#ifndef DOXYGEN_SHOULD_SKIP_THIS
1054 _vbi_nonnull ((1, 2, 3, 4))
1055#endif
1056 ;
1057extern vbi_bool
1058vbi_dvb_multiplex_raw (uint8_t ** packet,
1059 unsigned int * packet_left,
1060 const uint8_t ** raw,
1061 unsigned int * raw_left,
1062 unsigned int data_identifier,
1063 vbi_videostd_set videostd_set,
1064 unsigned int line,
1065 unsigned int first_pixel_position,
1066 unsigned int n_pixels_total,
1067 vbi_bool stuffing)
1068#ifndef DOXYGEN_SHOULD_SKIP_THIS
1069 _vbi_nonnull ((1, 2, 3, 4))
1070#endif
1071 ;
1072
1073typedef struct _vbi_dvb_mux vbi_dvb_mux;
1074
1075typedef vbi_bool
1076vbi_dvb_mux_cb (vbi_dvb_mux * mx,
1077 void * user_data,
1078 const uint8_t * packet,
1079 unsigned int packet_size);
1080
1081extern void
1082vbi_dvb_mux_reset (vbi_dvb_mux * mx)
1083 _vbi_nonnull ((1));
1084extern vbi_bool
1085vbi_dvb_mux_cor (vbi_dvb_mux * mx,
1086 uint8_t ** buffer,
1087 unsigned int * buffer_left,
1088 const vbi_sliced ** sliced,
1089 unsigned int * sliced_lines,
1090 vbi_service_set service_mask,
1091 const uint8_t * raw,
1092 const vbi_sampling_par *sampling_par,
1093 int64_t pts)
1094#ifndef DOXYGEN_SHOULD_SKIP_THIS
1095 _vbi_nonnull ((1, 2, 3, 4, 5))
1096#endif
1097 ;
1098extern vbi_bool
1099vbi_dvb_mux_feed (vbi_dvb_mux * mx,
1100 const vbi_sliced * sliced,
1101 unsigned int sliced_lines,
1102 vbi_service_set service_mask,
1103 const uint8_t * raw,
1104 const vbi_sampling_par *sampling_par,
1105 int64_t pts)
1106 _vbi_nonnull ((1));
1107extern unsigned int
1108vbi_dvb_mux_get_data_identifier (const vbi_dvb_mux * mx)
1109 _vbi_nonnull ((1));
1110extern vbi_bool
1111vbi_dvb_mux_set_data_identifier (vbi_dvb_mux * mx,
1112 unsigned int data_identifier)
1113 _vbi_nonnull ((1));
1114extern unsigned int
1115vbi_dvb_mux_get_min_pes_packet_size
1116 (vbi_dvb_mux * mx)
1117 _vbi_nonnull ((1));
1118extern unsigned int
1119vbi_dvb_mux_get_max_pes_packet_size
1120 (vbi_dvb_mux * mx)
1121 _vbi_nonnull ((1));
1122extern vbi_bool
1123vbi_dvb_mux_set_pes_packet_size (vbi_dvb_mux * mx,
1124 unsigned int min_size,
1125 unsigned int max_size)
1126 _vbi_nonnull ((1));
1127extern void
1128vbi_dvb_mux_delete (vbi_dvb_mux * mx);
1129extern vbi_dvb_mux *
1130vbi_dvb_pes_mux_new (vbi_dvb_mux_cb * callback,
1131 void * user_data)
1132 _vbi_alloc;
1133extern vbi_dvb_mux *
1134vbi_dvb_ts_mux_new (unsigned int pid,
1135 vbi_dvb_mux_cb * callback,
1136 void * user_data)
1137 _vbi_alloc;
1138
1139
1140
1141/* idl_demux.h */
1142
1143
1144typedef struct _vbi_idl_demux vbi_idl_demux;
1145
1146
1147
1148#define VBI_IDL_DATA_LOST (1 << 0)
1149
1150#define VBI_IDL_DEPENDENT (1 << 3)
1151
1152
1153
1154
1155typedef vbi_bool
1156vbi_idl_demux_cb (vbi_idl_demux * dx,
1157 const uint8_t * buffer,
1158 unsigned int n_bytes,
1159 unsigned int flags,
1160 void * user_data);
1161
1162extern void
1163vbi_idl_demux_reset (vbi_idl_demux * dx)
1164 _vbi_nonnull ((1));
1165extern vbi_bool
1166vbi_idl_demux_feed (vbi_idl_demux * dx,
1167 const uint8_t buffer[42])
1168#ifndef DOXYGEN_SHOULD_SKIP_THIS
1169 _vbi_nonnull ((1, 2))
1170#endif
1171 ;
1172extern vbi_bool
1173vbi_idl_demux_feed_frame (vbi_idl_demux * dx,
1174 const vbi_sliced * sliced,
1175 unsigned int n_lines)
1176#ifndef DOXYGEN_SHOULD_SKIP_THIS
1177 _vbi_nonnull ((1, 2))
1178#endif
1179 ;
1180extern void
1181vbi_idl_demux_delete (vbi_idl_demux * dx);
1182extern vbi_idl_demux *
1183vbi_idl_a_demux_new (unsigned int channel,
1184 unsigned int address,
1185 vbi_idl_demux_cb * callback,
1186 void * user_data)
1187#ifndef DOXYGEN_SHOULD_SKIP_THIS
1188 _vbi_alloc _vbi_nonnull ((3))
1189#endif
1190 ;
1191
1192
1193
1194/* pfc_demux.h */
1195
1196
1197typedef struct {
1198
1199 vbi_pgno pgno;
1200
1201
1202 unsigned int stream;
1203
1204
1205 unsigned int application_id;
1206
1207
1208 unsigned int block_size;
1209
1210
1211 uint8_t block[2048];
1212} vbi_pfc_block;
1213
1214typedef struct _vbi_pfc_demux vbi_pfc_demux;
1215
1216typedef vbi_bool
1217vbi_pfc_demux_cb (vbi_pfc_demux * dx,
1218 void * user_data,
1219 const vbi_pfc_block * block);
1220
1221extern void
1222vbi_pfc_demux_reset (vbi_pfc_demux * dx)
1223 _vbi_nonnull ((1));
1224extern vbi_bool
1225vbi_pfc_demux_feed (vbi_pfc_demux * dx,
1226 const uint8_t buffer[42])
1227#ifndef DOXYGEN_SHOULD_SKIP_THIS
1228 _vbi_nonnull ((1, 2))
1229#endif
1230 ;
1231extern vbi_bool
1232vbi_pfc_demux_feed_frame (vbi_pfc_demux * dx,
1233 const vbi_sliced * sliced,
1234 unsigned int n_lines)
1235#ifndef DOXYGEN_SHOULD_SKIP_THIS
1236 _vbi_nonnull ((1, 2))
1237#endif
1238 ;
1239extern void
1240vbi_pfc_demux_delete (vbi_pfc_demux * dx);
1241extern vbi_pfc_demux *
1242vbi_pfc_demux_new (vbi_pgno pgno,
1243 unsigned int stream,
1244 vbi_pfc_demux_cb * callback,
1245 void * user_data)
1246#ifndef DOXYGEN_SHOULD_SKIP_THIS
1247 _vbi_alloc _vbi_nonnull ((3))
1248#endif
1249 ;
1250
1251
1252
1253/* xds_demux.h */
1254
1255
1256typedef enum {
1257 VBI_XDS_CLASS_CURRENT = 0x00,
1258 VBI_XDS_CLASS_FUTURE,
1259 VBI_XDS_CLASS_CHANNEL,
1260 VBI_XDS_CLASS_MISC,
1261 VBI_XDS_CLASS_PUBLIC_SERVICE,
1262 VBI_XDS_CLASS_RESERVED,
1263 VBI_XDS_CLASS_UNDEFINED
1264} vbi_xds_class;
1265
1266#define VBI_XDS_MAX_CLASSES (VBI_XDS_CLASS_UNDEFINED + 1)
1267
1268typedef enum {
1269 VBI_XDS_PROGRAM_ID = 0x01,
1270 VBI_XDS_PROGRAM_LENGTH,
1271 VBI_XDS_PROGRAM_NAME,
1272 VBI_XDS_PROGRAM_TYPE,
1273 VBI_XDS_PROGRAM_RATING,
1274 VBI_XDS_PROGRAM_AUDIO_SERVICES,
1275 VBI_XDS_PROGRAM_CAPTION_SERVICES,
1276 VBI_XDS_PROGRAM_CGMS,
1277 VBI_XDS_PROGRAM_ASPECT_RATIO,
1278
1279 VBI_XDS_PROGRAM_DATA = 0x0C,
1280
1281 VBI_XDS_PROGRAM_MISC_DATA,
1282 VBI_XDS_PROGRAM_DESCRIPTION_BEGIN = 0x10,
1283 VBI_XDS_PROGRAM_DESCRIPTION_END = 0x18
1284} vbi_xds_subclass_program;
1285
1286
1287typedef enum {
1288 VBI_XDS_CHANNEL_NAME = 0x01,
1289 VBI_XDS_CHANNEL_CALL_LETTERS,
1290 VBI_XDS_CHANNEL_TAPE_DELAY,
1291
1292 VBI_XDS_CHANNEL_TSID
1293} vbi_xds_subclass_channel;
1294
1295
1296typedef enum {
1297 VBI_XDS_TIME_OF_DAY = 0x01,
1298 VBI_XDS_IMPULSE_CAPTURE_ID,
1299 VBI_XDS_SUPPLEMENTAL_DATA_LOCATION,
1300 VBI_XDS_LOCAL_TIME_ZONE,
1301
1302 VBI_XDS_OUT_OF_BAND_CHANNEL = 0x40,
1303
1304 VBI_XDS_CHANNEL_MAP_POINTER,
1305
1306 VBI_XDS_CHANNEL_MAP_HEADER,
1307
1308 VBI_XDS_CHANNEL_MAP
1309} vbi_xds_subclass_misc;
1310
1311#ifndef DOXYGEN_SHOULD_SKIP_THIS
1312
1313/* Compatibility. */
1314#define VBI_XDS_MISC_TIME_OF_DAY VBI_XDS_TIME_OF_DAY
1315#define VBI_XDS_MISC_IMPULSE_CAPTURE_ID VBI_XDS_IMPULSE_CAPTURE_ID
1316#define VBI_XDS_MISC_SUPPLEMENTAL_DATA_LOCATION \
1317 VBI_XDS_SUPPLEMENTAL_DATA_LOCATION
1318#define VBI_XDS_MISC_LOCAL_TIME_ZONE VBI_XDS_LOCAL_TIME_ZONE
1319
1320#endif /* DOXYGEN_SHOULD_SKIP_THIS */
1321
1322typedef enum {
1323 VBI_XDS_WEATHER_BULLETIN = 0x01,
1324 VBI_XDS_WEATHER_MESSAGE
1325} vbi_xds_subclass_public_service;
1326
1327#define VBI_XDS_MAX_SUBCLASSES (0x18)
1328
1329typedef unsigned int vbi_xds_subclass;
1330
1331typedef struct {
1332 vbi_xds_class xds_class;
1333 vbi_xds_subclass xds_subclass;
1334
1335
1336 unsigned int buffer_size;
1337
1338 uint8_t buffer[36];
1339} vbi_xds_packet;
1340
1341
1342
1343extern void
1344_vbi_xds_packet_dump (const vbi_xds_packet * xp,
1345 FILE * fp);
1346
1347
1348typedef struct _vbi_xds_demux vbi_xds_demux;
1349
1350typedef vbi_bool
1351vbi_xds_demux_cb (vbi_xds_demux * xd,
1352 const vbi_xds_packet * xp,
1353 void * user_data);
1354
1355extern void
1356vbi_xds_demux_reset (vbi_xds_demux * xd);
1357extern vbi_bool
1358vbi_xds_demux_feed (vbi_xds_demux * xd,
1359 const uint8_t buffer[2]);
1360extern vbi_bool
1361vbi_xds_demux_feed_frame (vbi_xds_demux * xd,
1362 const vbi_sliced * sliced,
1363 unsigned int n_lines);
1364extern void
1365vbi_xds_demux_delete (vbi_xds_demux * xd);
1366extern vbi_xds_demux *
1367vbi_xds_demux_new (vbi_xds_demux_cb * callback,
1368 void * user_data)
1369 _vbi_alloc;
1370
1371
1372
1373/* io.h */
1374
1375#include <sys/time.h> /* struct timeval */
1376
1377typedef struct vbi_capture_buffer {
1378 void * data;
1379 int size;
1380 double timestamp;
1381} vbi_capture_buffer;
1382
1383typedef struct vbi_capture vbi_capture;
1384
1385typedef enum {
1386 VBI_FD_HAS_SELECT = 1<<0,
1387 VBI_FD_HAS_MMAP = 1<<1,
1388 VBI_FD_IS_DEVICE = 1<<2
1389} VBI_CAPTURE_FD_FLAGS;
1390
1391extern vbi_capture * vbi_capture_v4l2_new(const char *dev_name, int buffers,
1392 unsigned int *services, int strict,
1393 char **errorstr, vbi_bool trace);
1394extern vbi_capture * vbi_capture_v4l2k_new(const char * dev_name,
1395 int fd,
1396 int buffers,
1397 unsigned int * services,
1398 int strict,
1399 char ** errorstr,
1400 vbi_bool trace);
1401extern vbi_capture * vbi_capture_v4l_new(const char *dev_name, int scanning,
1402 unsigned int *services, int strict,
1403 char **errorstr, vbi_bool trace);
1404extern vbi_capture * vbi_capture_v4l_sidecar_new(const char *dev_name, int given_fd,
1405 unsigned int *services,
1406 int strict, char **errorstr,
1407 vbi_bool trace);
1408extern vbi_capture * vbi_capture_bktr_new (const char * dev_name,
1409 int scanning,
1410 unsigned int * services,
1411 int strict,
1412 char ** errstr,
1413 vbi_bool trace);
1414extern int vbi_capture_dvb_filter(vbi_capture *cap, int pid);
1415
1416/* This function is deprecated. Use vbi_capture_dvb_new2() instead.
1417 See io-dvb.c or the Doxygen documentation for details. */
1418extern vbi_capture *
1419vbi_capture_dvb_new (char * dev,
1420 int scanning,
1421 unsigned int * services,
1422 int strict,
1423 char ** errstr,
1424 vbi_bool trace)
1425 _vbi_deprecated;
1426
1427extern int64_t
1428vbi_capture_dvb_last_pts (const vbi_capture * cap);
1429extern vbi_capture *
1430vbi_capture_dvb_new2 (const char * device_name,
1431 unsigned int pid,
1432 char ** errstr,
1433 vbi_bool trace);
1434
1435struct vbi_proxy_client;
1436
1437extern vbi_capture *
1438vbi_capture_proxy_new( struct vbi_proxy_client * vpc,
1439 int buffers, int scanning,
1440 unsigned int *p_services, int strict,
1441 char **pp_errorstr );
1442
1443extern int vbi_capture_read_raw(vbi_capture *capture, void *data,
1444 double *timestamp, struct timeval *timeout);
1445extern int vbi_capture_read_sliced(vbi_capture *capture, vbi_sliced *data, int *lines,
1446 double *timestamp, struct timeval *timeout);
1447extern int vbi_capture_read(vbi_capture *capture, void *raw_data,
1448 vbi_sliced *sliced_data, int *lines,
1449 double *timestamp, struct timeval *timeout);
1450extern int vbi_capture_pull_raw(vbi_capture *capture, vbi_capture_buffer **buffer,
1451 struct timeval *timeout);
1452extern int vbi_capture_pull_sliced(vbi_capture *capture, vbi_capture_buffer **buffer,
1453 struct timeval *timeout);
1454extern int vbi_capture_pull(vbi_capture *capture, vbi_capture_buffer **raw_buffer,
1455 vbi_capture_buffer **sliced_buffer, struct timeval *timeout);
1456extern vbi_raw_decoder *vbi_capture_parameters(vbi_capture *capture);
1457extern int vbi_capture_fd(vbi_capture *capture);
1458extern unsigned int vbi_capture_update_services(vbi_capture *capture,
1459 vbi_bool reset, vbi_bool commit,
1460 unsigned int services, int strict,
1461 char ** errorstr);
1462extern int vbi_capture_get_scanning(vbi_capture *capture);
1463extern void vbi_capture_flush(vbi_capture *capture);
1464extern void vbi_capture_delete(vbi_capture *capture);
1465
1466extern vbi_bool vbi_capture_set_video_path(vbi_capture *capture, const char * p_dev_video);
1467extern VBI_CAPTURE_FD_FLAGS vbi_capture_get_fd_flags(vbi_capture *capture);
1468
1469
1470/* io-sim.h */
1471
1472extern vbi_bool
1473vbi_raw_video_image (uint8_t * raw,
1474 unsigned long raw_size,
1475 const vbi_sampling_par *sp,
1476 int blank_level,
1477 int black_level,
1478 int white_level,
1479 unsigned int pixel_mask,
1480 vbi_bool swap_fields,
1481 const vbi_sliced * sliced,
1482 unsigned int n_sliced_lines);
1483extern vbi_bool
1484vbi_raw_add_noise (uint8_t * raw,
1485 const vbi_sampling_par *sp,
1486 unsigned int min_freq,
1487 unsigned int max_freq,
1488 unsigned int amplitude,
1489 unsigned int seed);
1490extern vbi_bool
1491vbi_raw_vbi_image (uint8_t * raw,
1492 unsigned long raw_size,
1493 const vbi_sampling_par *sp,
1494 int blank_level,
1495 int white_level,
1496 vbi_bool swap_fields,
1497 const vbi_sliced * sliced,
1498 unsigned int n_sliced_lines);
1499
1500extern void
1501vbi_capture_sim_add_noise (vbi_capture * cap,
1502 unsigned int min_freq,
1503 unsigned int max_freq,
1504 unsigned int amplitude);
1505#if 3 == VBI_VERSION_MINOR
1506extern vbi_bool
1507vbi_capture_sim_load_vps (vbi_capture * cap,
1508 const vbi_program_id *pid);
1509extern vbi_bool
1510vbi_capture_sim_load_wss_625 (vbi_capture * cap,
1511 const vbi_aspect_ratio *ar);
1512extern vbi_bool
1513vbi_capture_sim_load_caption (vbi_capture * cap,
1514 const char * stream,
1515 vbi_bool append);
1516#endif
1517extern void
1518vbi_capture_sim_decode_raw (vbi_capture * cap,
1519 vbi_bool enable);
1520extern vbi_capture *
1521vbi_capture_sim_new (int scanning,
1522 unsigned int * services,
1523 vbi_bool interlaced,
1524 vbi_bool synchronous);
1525
1526
1527/* proxy-msg.h */
1528
1529typedef enum
1530{
1531 VBI_CHN_PRIO_BACKGROUND = 1,
1532 VBI_CHN_PRIO_INTERACTIVE = 2,
1533 VBI_CHN_PRIO_DEFAULT = VBI_CHN_PRIO_INTERACTIVE,
1534 VBI_CHN_PRIO_RECORD = 3
1535
1536} VBI_CHN_PRIO;
1537
1538typedef enum
1539{
1540 VBI_CHN_SUBPRIO_MINIMAL = 0x00,
1541 VBI_CHN_SUBPRIO_CHECK = 0x10,
1542 VBI_CHN_SUBPRIO_UPDATE = 0x20,
1543 VBI_CHN_SUBPRIO_INITIAL = 0x30,
1544 VBI_CHN_SUBPRIO_VPS_PDC = 0x40
1545
1546} VBI_CHN_SUBPRIO;
1547
1548typedef struct
1549{
1550 uint8_t is_valid;
1551 uint8_t sub_prio;
1552 uint8_t allow_suspend;
1553
1554 uint8_t reserved0;
1555 time_t min_duration;
1556 time_t exp_duration;
1557
1558 uint8_t reserved1[16];
1559} vbi_channel_profile;
1560
1561typedef enum
1562{
1563 VBI_PROXY_DAEMON_NO_TIMEOUTS = 1<<0
1564
1565} VBI_PROXY_DAEMON_FLAGS;
1566
1567typedef enum
1568{
1569 VBI_PROXY_CLIENT_NO_TIMEOUTS = 1<<0,
1570 VBI_PROXY_CLIENT_NO_STATUS_IND = 1<<1
1571
1572} VBI_PROXY_CLIENT_FLAGS;
1573
1574typedef enum
1575{
1576 VBI_PROXY_CHN_RELEASE = 1<<0,
1577 VBI_PROXY_CHN_TOKEN = 1<<1,
1578 VBI_PROXY_CHN_FLUSH = 1<<2,
1579 VBI_PROXY_CHN_NORM = 1<<3,
1580 VBI_PROXY_CHN_FAIL = 1<<4,
1581
1582 VBI_PROXY_CHN_NONE = 0
1583
1584} VBI_PROXY_CHN_FLAGS;
1585
1586typedef enum
1587{
1588 VBI_API_UNKNOWN,
1589 VBI_API_V4L1,
1590 VBI_API_V4L2,
1591 VBI_API_BKTR
1592} VBI_DRIVER_API_REV;
1593
1594#define VBIPROXY_VERSION 0x00000100
1595#define VBIPROXY_COMPAT_VERSION 0x00000100
1596
1597/* proxy-client.h */
1598
1599#include <sys/time.h> /* struct timeval */
1600
1601typedef struct vbi_proxy_client vbi_proxy_client;
1602
1603typedef enum
1604{
1605 VBI_PROXY_EV_CHN_GRANTED = 1<<0,
1606 VBI_PROXY_EV_CHN_CHANGED = 1<<1,
1607 VBI_PROXY_EV_NORM_CHANGED = 1<<2,
1608 VBI_PROXY_EV_CHN_RECLAIMED = 1<<3,
1609 VBI_PROXY_EV_NONE = 0
1610} VBI_PROXY_EV_TYPE;
1611
1612typedef void VBI_PROXY_CLIENT_CALLBACK ( void * p_client_data,
1613 VBI_PROXY_EV_TYPE ev_mask );
1614
1615/* forward declaration from io.h */
1616struct vbi_capture_buffer;
1617
1618extern vbi_proxy_client *
1619vbi_proxy_client_create( const char *dev_name,
1620 const char *p_client_name,
1621 VBI_PROXY_CLIENT_FLAGS client_flags,
1622 char **pp_errorstr,
1623 int trace_level );
1624
1625extern void
1626vbi_proxy_client_destroy( vbi_proxy_client * vpc );
1627
1628extern vbi_capture *
1629vbi_proxy_client_get_capture_if( vbi_proxy_client * vpc );
1630
1631extern VBI_PROXY_CLIENT_CALLBACK *
1632vbi_proxy_client_set_callback( vbi_proxy_client * vpc,
1633 VBI_PROXY_CLIENT_CALLBACK * p_callback,
1634 void * p_data );
1635
1636extern VBI_DRIVER_API_REV
1637vbi_proxy_client_get_driver_api( vbi_proxy_client * vpc );
1638
1639extern int
1640vbi_proxy_client_channel_request( vbi_proxy_client * vpc,
1641 VBI_CHN_PRIO chn_prio,
1642 vbi_channel_profile * chn_profile );
1643
1644extern int
1645vbi_proxy_client_channel_notify( vbi_proxy_client * vpc,
1646 VBI_PROXY_CHN_FLAGS notify_flags,
1647 unsigned int scanning );
1648
1649typedef enum
1650{
1651 VBI_PROXY_SUSPEND_START,
1652 VBI_PROXY_SUSPEND_STOP
1653} VBI_PROXY_SUSPEND;
1654
1655extern int
1656vbi_proxy_client_channel_suspend( vbi_proxy_client * vpc,
1657 VBI_PROXY_SUSPEND cmd );
1658
1659int
1660vbi_proxy_client_device_ioctl( vbi_proxy_client * vpc,
1661 int request,
1662 void * p_arg );
1663
1664extern int
1665vbi_proxy_client_get_channel_desc( vbi_proxy_client * vpc,
1666 unsigned int * p_scanning,
1667 vbi_bool * p_granted );
1668
1669extern vbi_bool
1670vbi_proxy_client_has_channel_control( vbi_proxy_client * vpc );
1671
1672
1673
1674/* exp-gfx.h */
1675
1676extern void vbi_draw_vt_page_region(vbi_page *pg, vbi_pixfmt fmt,
1677 void *canvas, int rowstride,
1678 int column, int row,
1679 int width, int height,
1680 int reveal, int flash_on, int subtitle);
1681_vbi_inline void
1682vbi_draw_vt_page(vbi_page *pg, vbi_pixfmt fmt, void *canvas,
1683 int reveal, int flash_on, int subtitle)
1684{
1685 vbi_draw_vt_page_region(pg, fmt, canvas, -1, 0, 0,
1686 pg->columns, pg->rows, reveal, flash_on, subtitle);
1687}
1688
1689extern void vbi_draw_cc_page_region(vbi_page *pg, vbi_pixfmt fmt,
1690 void *canvas, int rowstride,
1691 int column, int row,
1692 int width, int height);
1693
1694_vbi_inline void
1695vbi_draw_cc_page(vbi_page *pg, vbi_pixfmt fmt, void *canvas)
1696{
1697 vbi_draw_cc_page_region(pg, fmt, canvas, -1, 0, 0, pg->columns, pg->rows);
1698}
1699
1700extern void vbi_get_max_rendered_size(int *w, int *h);
1701extern void vbi_get_vt_cell_size(int *w, int *h);
1702
1703
1704/* exp-txt.h */
1705
1706extern int vbi_print_page_region(vbi_page *pg, char *buf, int size,
1707 const char *format, vbi_bool table, vbi_bool ltr,
1708 int column, int row, int width, int height);
1709
1710_vbi_inline int
1711vbi_print_page(vbi_page *pg, char *buf, int size,
1712 const char *format, vbi_bool table, vbi_bool ltr)
1713{
1714 return vbi_print_page_region(pg, buf, size,
1715 format, table, ltr,
1716 0, 0, pg->columns, pg->rows);
1717}
1718
1719
1720/* hamm.h */
1721
1722extern const uint8_t _vbi_bit_reverse [256];
1723extern const uint8_t _vbi_hamm8_fwd [16];
1724extern const int8_t _vbi_hamm8_inv [256];
1725extern const int8_t _vbi_hamm24_inv_par [3][256];
1726
1727
1728_vbi_inline unsigned int
1729vbi_rev8 (unsigned int c)
1730{
1731 return _vbi_bit_reverse[(uint8_t) c];
1732}
1733
1734_vbi_inline unsigned int
1735vbi_rev16 (unsigned int c)
1736{
1737 return _vbi_bit_reverse[(uint8_t) c] * 256
1738 + _vbi_bit_reverse[(uint8_t)(c >> 8)];
1739}
1740
1741_vbi_inline unsigned int
1742vbi_rev16p (const uint8_t * p)
1743{
1744 return _vbi_bit_reverse[p[0]] * 256
1745 + _vbi_bit_reverse[p[1]];
1746}
1747
1748_vbi_inline unsigned int
1749vbi_par8 (unsigned int c)
1750{
1751 c &= 255;
1752
1753 /* if 0 == (inv_par[] & 32) change bit 7 of c. */
1754 c ^= 128 & ~(_vbi_hamm24_inv_par[0][c] << 2);
1755
1756 return c;
1757}
1758
1759_vbi_inline int
1760vbi_unpar8 (unsigned int c)
1761{
1762/* Disabled until someone finds a reliable way
1763 to test for cmov support at compile time. */
1764#if 0
1765 int r = c & 127;
1766
1767 /* This saves cache flushes and an explicit branch. */
1768 __asm__ (" testb %1,%1\n"
1769 " cmovp %2,%0\n"
1770 : "+&a" (r) : "c" (c), "rm" (-1));
1771 return r;
1772#endif
1773 if (_vbi_hamm24_inv_par[0][(uint8_t) c] & 32) {
1774 return c & 127;
1775 } else {
1776 /* The idea is to OR results together to find a parity
1777 error in a sequence, rather than a test and branch on
1778 each byte. */
1779 return -1;
1780 }
1781}
1782
1783extern void
1784vbi_par (uint8_t * p,
1785 unsigned int n);
1786extern int
1787vbi_unpar (uint8_t * p,
1788 unsigned int n);
1789
1790_vbi_inline unsigned int
1791vbi_ham8 (unsigned int c)
1792{
1793 return _vbi_hamm8_fwd[c & 15];
1794}
1795
1796_vbi_inline int
1797vbi_unham8 (unsigned int c)
1798{
1799 return _vbi_hamm8_inv[(uint8_t) c];
1800}
1801
1802_vbi_inline int
1803vbi_unham16p (const uint8_t * p)
1804{
1805 return ((int) _vbi_hamm8_inv[p[0]])
1806 | (((int) _vbi_hamm8_inv[p[1]]) << 4);
1807}
1808
1809extern void
1810vbi_ham24p (uint8_t * p,
1811 unsigned int c);
1812extern int
1813vbi_unham24p (const uint8_t * p)
1814 _vbi_pure;
1815
1816
1817
1818/* cc.h */
1819
1820extern vbi_bool vbi_fetch_cc_page(vbi_decoder *vbi, vbi_page *pg,
1821 vbi_pgno pgno, vbi_bool reset);
1822
1823
1824/* teletext_decoder.h */
1825
1826typedef enum {
1827 VBI_WST_LEVEL_1,
1828 VBI_WST_LEVEL_1p5,
1829 VBI_WST_LEVEL_2p5,
1830 VBI_WST_LEVEL_3p5
1831} vbi_wst_level;
1832
1833
1834extern void vbi_teletext_set_default_region(vbi_decoder *vbi, int default_region);
1835extern void vbi_teletext_set_level(vbi_decoder *vbi, int level);
1836
1837extern vbi_bool vbi_fetch_vt_page(vbi_decoder *vbi, vbi_page *pg,
1838 vbi_pgno pgno, vbi_subno subno,
1839 vbi_wst_level max_level, int display_rows,
1840 vbi_bool navigation);
1841extern int vbi_page_title(vbi_decoder *vbi, int pgno, int subno, char *buf);
1842
1843extern void vbi_resolve_link(vbi_page *pg, int column, int row,
1844 vbi_link *ld);
1845extern void vbi_resolve_home(vbi_page *pg, vbi_link *ld);
1846
1847extern vbi_bool vbi_get_next_pgno(vbi_decoder *vbi, int dir, vbi_pgno *pgno, vbi_pgno *subno);
1848extern vbi_bool vbi_get_next_sub_pgno(vbi_decoder *vbi, int dir, vbi_pgno *pgno, vbi_pgno *subno);
1849extern vbi_bool vbi_get_sub_info(vbi_decoder *vbi, vbi_pgno pgno, int *subs, int *len);
1850
1851
1852/* tables.h */
1853
1854extern const char * vbi_rating_string(vbi_rating_auth auth, int id);
1855extern const char * vbi_prog_type_string(vbi_prog_classf classf, int id);
1856
1857
1858/* vps.h */
1859
1860extern vbi_bool
1861vbi_decode_vps_cni (unsigned int * cni,
1862 const uint8_t buffer[13])
1863#ifndef DOXYGEN_SHOULD_SKIP_THIS
1864 _vbi_nonnull ((1, 2))
1865#endif
1866 ;
1867extern vbi_bool
1868vbi_encode_vps_cni (uint8_t buffer[13],
1869 unsigned int cni)
1870 _vbi_nonnull ((1));
1871
1872/* vbi.h */
1873
1874typedef enum {
1875 VBI_NO_PAGE = 0x00,
1876 VBI_NORMAL_PAGE = 0x01,
1877 VBI_SUBTITLE_PAGE = 0x70,
1878 VBI_SUBTITLE_INDEX = 0x78,
1879 VBI_NONSTD_SUBPAGES = 0x79,
1880 VBI_PROGR_WARNING = 0x7A,
1881 VBI_CURRENT_PROGR = 0x7C,
1882 VBI_NOW_AND_NEXT = 0x7D,
1883 VBI_PROGR_INDEX = 0x7F,
1884 VBI_PROGR_SCHEDULE = 0x81,
1885 VBI_UNKNOWN_PAGE = 0xFF
1886} vbi_page_type;
1887
1888extern void vbi_set_brightness(vbi_decoder *vbi, int brightness);
1889extern void vbi_set_contrast(vbi_decoder *vbi, int contrast);
1890
1891
1892extern vbi_decoder * vbi_decoder_new(void);
1893extern void vbi_decoder_delete(vbi_decoder *vbi);
1894extern void vbi_decode(vbi_decoder *vbi, vbi_sliced *sliced,
1895 int lines, double timestamp);
1896extern void vbi_channel_switched(vbi_decoder *vbi, vbi_nuid nuid);
1897extern vbi_page_type vbi_classify_page(vbi_decoder *vbi, vbi_pgno pgno,
1898 vbi_subno *subno, char **language);
1899extern void vbi_version(unsigned int *major, unsigned int *minor, unsigned int *micro);
1900extern void
1901vbi_set_log_fn (vbi_log_mask mask,
1902 vbi_log_fn * log_fn,
1903 void * user_data);
1904
1905
1906
1907#ifdef __cplusplus
1908}
1909#endif
1910
1911#endif /* __LIBZVBI_H__ */
1912