hlsdemux: Enable support for external subtitles
[platform/upstream/gstreamer.git] / ext / closedcaption / raw_decoder.h
1 /*
2  *  libzvbi -- Raw VBI decoder
3  *
4  *  Copyright (C) 2000-2004 Michael H. Schimek
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Library General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2 of the License, or (at your option) any later version.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Library General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Library General Public
17  *  License along with this library; if not, write to the 
18  *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
19  *  Boston, MA  02110-1301  USA.
20  */
21
22 /* $Id: raw_decoder.h,v 1.12 2008-02-19 00:35:21 mschimek Exp $ */
23
24 #ifndef __ZVBI_RAW_DECODER_H__
25 #define __ZVBI_RAW_DECODER_H__
26
27 #include <stdio.h>
28
29 #include "decoder.h"
30 #include "sampling_par.h"
31 #include "bit_slicer.h"
32
33 VBI_BEGIN_DECLS
34
35 /*
36  * $ingroup RawDecoder
37  * $brief Raw VBI decoder.
38  *
39  * The contents of this structure are private.
40  * Call vbi3_raw_decoder_new() to allocate a raw VBI decoder.
41  */
42 typedef struct _vbi3_raw_decoder vbi3_raw_decoder;
43
44 /*
45  * $addtogroup RawDecoder
46  * ${
47  */
48 extern vbi_bool
49 vbi3_raw_decoder_sampling_point (vbi3_raw_decoder *     rd,
50                                  vbi3_bit_slicer_point *point,
51                                  unsigned int           row,
52                                  unsigned int           nth_bit);
53 extern unsigned int
54 vbi3_raw_decoder_decode         (vbi3_raw_decoder *     rd,
55                                  vbi_sliced *           sliced,
56                                  unsigned int           sliced_lines,
57                                  const uint8_t *        raw);
58 extern void
59 vbi3_raw_decoder_reset          (vbi3_raw_decoder *     rd);
60 extern vbi_service_set
61 vbi3_raw_decoder_services       (vbi3_raw_decoder *     rd);
62 extern vbi_service_set
63 vbi3_raw_decoder_remove_services
64                                 (vbi3_raw_decoder *     rd,
65                                  vbi_service_set        services);
66 extern vbi_service_set
67 vbi3_raw_decoder_add_services   (vbi3_raw_decoder *     rd,
68                                  vbi_service_set        services,
69                                  int                    strict);
70 extern vbi_bool
71 vbi3_raw_decoder_debug          (vbi3_raw_decoder *     rd,
72                                  vbi_bool               enable);
73 extern vbi_service_set
74 vbi3_raw_decoder_set_sampling_par
75                                 (vbi3_raw_decoder *     rd,
76                                  const vbi_sampling_par *sp,
77                                  int                    strict);
78 extern void
79 vbi3_raw_decoder_get_sampling_par
80                                 (const vbi3_raw_decoder *rd,
81                                  vbi_sampling_par *     sp);
82 extern void
83 vbi3_raw_decoder_set_log_fn     (vbi3_raw_decoder *     rd,
84                                  vbi_log_fn *           log_fn,
85                                  void *                 user_data,
86                                  vbi_log_mask           mask);
87 extern void
88 vbi3_raw_decoder_delete         (vbi3_raw_decoder *     rd);
89 extern vbi3_raw_decoder *
90 vbi3_raw_decoder_new            (const vbi_sampling_par *sp);
91
92 /* $} */
93
94 /* Private */
95
96 /** @internal */
97 #define _VBI3_RAW_DECODER_MAX_JOBS 8
98 /** @internal */
99 #define _VBI3_RAW_DECODER_MAX_WAYS 8
100
101 /** @internal */
102 typedef struct {
103         vbi_service_set         id;
104         vbi3_bit_slicer         slicer;
105 } _vbi3_raw_decoder_job;
106
107 /** @internal */
108 typedef struct {
109         vbi3_bit_slicer_point   points[512];
110         unsigned int            n_points;
111 } _vbi3_raw_decoder_sp_line;
112
113 /**
114  * @internal
115  * Don't dereference pointers to this structure.
116  * I guarantee it will change.
117  */
118 struct _vbi3_raw_decoder {
119         vbi_sampling_par        sampling;
120
121         vbi_service_set         services;
122
123         _vbi_log_hook           log;
124         vbi_bool                debug;
125
126         unsigned int            n_jobs;
127         unsigned int            n_sp_lines;
128         int                     readjust;
129         int8_t *                pattern;        /* n scan lines * MAX_WAYS */
130         _vbi3_raw_decoder_job   jobs[_VBI3_RAW_DECODER_MAX_JOBS];
131         _vbi3_raw_decoder_sp_line *sp_lines;
132 };
133
134 /** @internal */
135 typedef enum {
136         /** Requires field line numbers. */
137         _VBI_SP_LINE_NUM        = (1 << 0),
138         /** Requires field numbers. */
139         _VBI_SP_FIELD_NUM       = (1 << 1),
140 } _vbi_service_par_flag;
141
142 typedef struct _vbi_service_par _vbi_service_par;
143
144 /** @internal */
145 struct _vbi_service_par {
146         vbi_service_set         id;
147         const char *            label;
148
149         /**
150          * Video standard
151          * - 525 lines, FV = 59.94 Hz, FH = 15734 Hz
152          * - 625 lines, FV = 50 Hz, FH = 15625 Hz
153          */
154         vbi_videostd_set        videostd_set;
155
156         /**
157          * Most scan lines used by the data service, first and last
158          * line of first and second field. ITU-R numbering scheme.
159          * Zero if no data from this field, requires field sync.
160          */
161         unsigned int            first[2];
162         unsigned int            last[2];
163
164         /**
165          * Leading edge hsync to leading edge first CRI one bit,
166          * half amplitude points, in nanoseconds.
167          */
168         unsigned int            offset;
169
170         unsigned int            cri_rate;       /**< Hz */
171         unsigned int            bit_rate;       /**< Hz */
172
173         /** Clock Run In and FRaming Code, LSB last txed bit of FRC. */
174         unsigned int            cri_frc;
175
176         /** CRI and FRC bits significant for identification. */
177         unsigned int            cri_frc_mask;
178
179         /**
180          * Number of significat cri_bits (at cri_rate),
181          * frc_bits (at bit_rate).
182          */
183         unsigned int            cri_bits;
184         unsigned int            frc_bits;
185
186         unsigned int            payload;        /**< bits */
187         vbi_modulation          modulation;
188
189         _vbi_service_par_flag   flags;
190 };
191
192 extern const _vbi_service_par _vbi_service_table [];
193
194 extern void
195 _vbi3_raw_decoder_dump          (const vbi3_raw_decoder *rd,
196                                  FILE *                 fp);
197 extern void
198 _vbi3_raw_decoder_destroy       (vbi3_raw_decoder *     rd);
199 extern vbi_bool
200 _vbi3_raw_decoder_init          (vbi3_raw_decoder *     rd,
201                                  const vbi_sampling_par *sp);
202
203 VBI_END_DECLS
204
205 #endif /* __ZVBI_RAW_DECODER_H__ */
206
207 /*
208 Local variables:
209 c-set-style: K&R
210 c-basic-offset: 8
211 End:
212 */