5
5
#include "utility.h"
6
6
7
7
#ifndef DISABLE_RUST
8
-
9
- extern struct ccx_decoders_xds_context * ccxr_ccx_decoders_xds_init_library (
10
- struct ccx_common_timing_ctx timing ,
11
- int xds_write_to_file );
12
-
13
- extern int ccxr_write_xds_string (
14
- struct cc_subtitle * sub ,
15
- struct ccx_decoders_xds_context * ctx ,
16
- const char * p ,
17
- size_t len );
18
-
19
- extern void ccxr_xdsprint (
20
- struct cc_subtitle * sub ,
21
- struct ccx_decoders_xds_context * ctx ,
22
- const char * _fmt ,
23
- va_list args );
24
-
25
- extern void ccxr_clear_xds_buffer (
26
- struct ccx_decoders_xds_context * ctx ,
27
- int64_t num );
28
-
29
- extern int64_t ccxr_how_many_used (
30
- const struct ccx_decoders_xds_context * ctx );
31
-
32
8
extern void ccxr_process_xds_bytes (
33
9
struct ccx_decoders_xds_context * ctx ,
34
- uint8_t hi ,
35
- int64_t lo );
36
-
37
- extern void ccxr_xds_do_copy_generation_management_system (
38
- struct cc_subtitle * sub ,
39
- struct ccx_decoders_xds_context * ctx ,
40
- uint8_t c1 ,
41
- uint8_t c2 );
42
-
43
- extern void ccxr_xds_do_content_advisory (
44
- struct cc_subtitle * sub ,
45
- struct ccx_decoders_xds_context * ctx ,
46
- uint8_t c1 ,
47
- uint8_t c2 );
48
-
49
- extern int64_t ccxr_xds_do_private_data (
50
- struct cc_subtitle * sub ,
51
- struct ccx_decoders_xds_context * ctx );
52
-
53
- extern int64_t ccxr_xds_do_misc (
54
- const struct ccx_decoders_xds_context * ctx );
55
-
56
- extern int64_t ccxr_xds_do_current_and_future (
57
- struct cc_subtitle * sub ,
58
- struct ccx_decoders_xds_context * ctx );
10
+ unsigned char hi ,
11
+ unsigned char lo );
59
12
60
13
extern void ccxr_do_end_of_xds (
61
14
struct cc_subtitle * sub ,
62
15
struct ccx_decoders_xds_context * ctx ,
63
- int64_t expected_checksum );
64
-
65
- extern int64_t ccxr_xds_do_channel (
66
- struct cc_subtitle * sub ,
67
- struct ccx_decoders_xds_context * ctx );
16
+ unsigned char expected_checksum );
68
17
69
- extern void ccxr_xds_debug_test (
70
- struct ccx_decoders_xds_context * ctx ,
71
- struct cc_subtitle * sub );
18
+ extern struct ccx_decoders_xds_context * ccxr_ccx_decoders_xds_init_library (
19
+ struct ccx_common_timing_ctx * timing ,
20
+ int xds_write_to_file );
72
21
73
22
extern void ccxr_xds_cea608_test (
74
23
struct ccx_decoders_xds_context * ctx ,
75
24
struct cc_subtitle * sub );
76
-
77
25
#endif
78
26
79
27
LLONG ts_start_of_xds = -1 ; // Time at which we switched to XDS mode, =-1 hasn't happened yet
@@ -153,7 +101,7 @@ static const char *XDSProgramTypes[] =
153
101
struct ccx_decoders_xds_context * ccx_decoders_xds_init_library (struct ccx_common_timing_ctx * timing , int xds_write_to_file )
154
102
{
155
103
#ifndef DISABLE_RUST
156
- return ccxr_ccx_decoders_xds_init_library (* timing , xds_write_to_file );
104
+ return ccxr_ccx_decoders_xds_init_library (timing , xds_write_to_file ); // Use the Rust implementation
157
105
#else
158
106
int i ;
159
107
struct ccx_decoders_xds_context * ctx = NULL ;
@@ -201,9 +149,6 @@ struct ccx_decoders_xds_context *ccx_decoders_xds_init_library(struct ccx_common
201
149
202
150
int write_xds_string (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , char * p , size_t len )
203
151
{
204
- #ifndef DISABLE_RUST
205
- return ccxr_write_xds_string (sub , ctx , p , len );
206
- #else
207
152
struct eia608_screen * data = NULL ;
208
153
data = (struct eia608_screen * )realloc (sub -> data , (sub -> nb_data + 1 ) * sizeof (* data ));
209
154
if (!data )
@@ -217,31 +162,25 @@ int write_xds_string(struct cc_subtitle *sub, struct ccx_decoders_xds_context *c
217
162
{
218
163
sub -> data = data ;
219
164
sub -> datatype = CC_DATATYPE_GENERIC ;
165
+
220
166
data = (struct eia608_screen * )sub -> data + sub -> nb_data ;
221
167
data -> format = SFORMAT_XDS ;
222
168
data -> start_time = ts_start_of_xds ;
223
169
data -> end_time = get_fts (ctx -> timing , 2 );
224
170
data -> xds_str = p ;
225
171
data -> xds_len = len ;
226
172
data -> cur_xds_packet_class = ctx -> cur_xds_packet_class ;
173
+
227
174
sub -> nb_data ++ ;
228
175
sub -> type = CC_608 ;
229
176
sub -> got_output = 1 ;
230
177
}
231
178
232
179
return 0 ;
233
- #endif
234
180
}
235
181
236
182
void xdsprint (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , const char * fmt , ...)
237
183
{
238
- #ifndef DISABLE_RUST
239
- va_list ap ;
240
- va_start (ap , fmt );
241
- ccxr_xdsprint (sub , ctx , fmt , ap );
242
- va_end (ap );
243
- #else
244
-
245
184
if (!ctx -> xds_write_to_file )
246
185
return ;
247
186
/* Guess we need no more than 100 bytes. */
@@ -279,24 +218,19 @@ void xdsprint(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx, con
279
218
p = np ;
280
219
}
281
220
}
282
- #endif
283
221
}
284
222
285
223
void xds_debug_test (struct ccx_decoders_xds_context * ctx , struct cc_subtitle * sub )
286
224
{
287
- #ifndef DISABLE_RUST
288
- ccxr_xds_debug_test (ctx , sub );
289
- #else
290
225
process_xds_bytes (ctx , 0x05 , 0x02 );
291
226
process_xds_bytes (ctx , 0x20 , 0x20 );
292
227
do_end_of_xds (sub , ctx , 0x2a );
293
- #endif
294
228
}
295
229
296
230
void xds_cea608_test (struct ccx_decoders_xds_context * ctx , struct cc_subtitle * sub )
297
231
{
298
232
#ifndef DISABLE_RUST
299
- ccxr_xds_cea608_test (ctx , sub );
233
+ return ccxr_xds_cea608_test (ctx , sub );
300
234
#else
301
235
/* This test is the sample data that comes in CEA-608. It sets the program name
302
236
to be "Star Trek". The checksum is 0x1d and the validation must succeed. */
@@ -314,34 +248,26 @@ void xds_cea608_test(struct ccx_decoders_xds_context *ctx, struct cc_subtitle *s
314
248
315
249
int how_many_used (struct ccx_decoders_xds_context * ctx )
316
250
{
317
- #ifndef DISABLE_RUST
318
- ccxr_how_many_used (ctx );
319
- #else
320
251
int c = 0 ;
321
252
for (int i = 0 ; i < NUM_XDS_BUFFERS ; i ++ )
322
253
if (ctx -> xds_buffers [i ].in_use )
323
254
c ++ ;
324
255
return c ;
325
- #endif
326
256
}
327
257
328
258
void clear_xds_buffer (struct ccx_decoders_xds_context * ctx , int num )
329
259
{
330
- #ifndef DISABLE_RUST
331
- ccxr_clear_xds_buffer (ctx , num );
332
- #else
333
260
ctx -> xds_buffers [num ].in_use = 0 ;
334
261
ctx -> xds_buffers [num ].xds_class = -1 ;
335
262
ctx -> xds_buffers [num ].xds_type = -1 ;
336
263
ctx -> xds_buffers [num ].used_bytes = 0 ;
337
264
memset (ctx -> xds_buffers [num ].bytes , 0 , NUM_BYTES_PER_PACKET );
338
- #endif
339
265
}
340
266
341
267
void process_xds_bytes (struct ccx_decoders_xds_context * ctx , const unsigned char hi , int lo )
342
268
{
343
269
#ifndef DISABLE_RUST
344
- ccxr_process_xds_bytes (ctx , hi , lo );
270
+ return ccxr_process_xds_bytes (ctx , hi , lo ); // Use the Rust implementation
345
271
#else
346
272
int is_new ;
347
273
if (!ctx )
@@ -420,9 +346,6 @@ void process_xds_bytes(struct ccx_decoders_xds_context *ctx, const unsigned char
420
346
*/
421
347
void xds_do_copy_generation_management_system (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned c1 , unsigned c2 )
422
348
{
423
- #ifndef DISABLE_RUST
424
- ccxr_xds_do_copy_generation_management_system (sub , ctx , c1 , c2 );
425
- #else
426
349
static unsigned last_c1 = -1 , last_c2 = -1 ;
427
350
static char copy_permited [256 ];
428
351
static char aps [256 ];
@@ -476,14 +399,10 @@ void xds_do_copy_generation_management_system(struct cc_subtitle *sub, struct cc
476
399
ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , copy_permited );
477
400
ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , aps );
478
401
ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , rcd );
479
- #endif
480
402
}
481
403
482
404
void xds_do_content_advisory (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned c1 , unsigned c2 )
483
405
{
484
- #ifndef DISABLE_RUST
485
- ccxr_xds_do_content_advisory (sub , ctx , c1 , c2 );
486
- #else
487
406
static unsigned last_c1 = -1 , last_c2 = -1 ;
488
407
static char age [256 ];
489
408
static char content [256 ];
@@ -593,14 +512,10 @@ void xds_do_content_advisory(struct cc_subtitle *sub, struct ccx_decoders_xds_co
593
512
594
513
if (changed && !supported )
595
514
ccx_common_logging .log_ftn ("XDS: Unsupported ContentAdvisory encoding, please submit sample.\n" );
596
- #endif
597
515
}
598
516
599
517
int xds_do_current_and_future (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
600
518
{
601
- #ifndef DISABLE_RUST
602
- ccxr_xds_do_current_and_future (sub , ctx );
603
- #else
604
519
int was_proc = 0 ;
605
520
606
521
char * str = malloc (1024 );
@@ -847,14 +762,10 @@ int xds_do_current_and_future(struct cc_subtitle *sub, struct ccx_decoders_xds_c
847
762
848
763
free (str );
849
764
return was_proc ;
850
- #endif
851
765
}
852
766
853
767
int xds_do_channel (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
854
768
{
855
- #ifndef DISABLE_RUST
856
- ccxr_xds_do_channel (sub , ctx );
857
- #else
858
769
int was_proc = 0 ;
859
770
if (!ctx )
860
771
return CCX_EINVAL ;
@@ -914,14 +825,10 @@ int xds_do_channel(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx
914
825
break ;
915
826
}
916
827
return was_proc ;
917
- #endif
918
828
}
919
829
920
830
int xds_do_private_data (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
921
831
{
922
- #ifndef DISABLE_RUST
923
- ccxr_xds_do_private_data (sub , ctx );
924
- #else
925
832
char * str ;
926
833
int i ;
927
834
@@ -938,14 +845,10 @@ int xds_do_private_data(struct cc_subtitle *sub, struct ccx_decoders_xds_context
938
845
xdsprint (sub , ctx , str );
939
846
free (str );
940
847
return 1 ;
941
- #endif
942
848
}
943
849
944
850
int xds_do_misc (struct ccx_decoders_xds_context * ctx )
945
851
{
946
- #ifndef DISABLE_RUST
947
- ccxr_xds_do_misc (ctx );
948
- #else
949
852
int was_proc = 0 ;
950
853
if (!ctx )
951
854
return CCX_EINVAL ;
@@ -985,13 +888,12 @@ int xds_do_misc(struct ccx_decoders_xds_context *ctx)
985
888
break ;
986
889
}
987
890
return was_proc ;
988
- #endif
989
891
}
990
892
991
893
void do_end_of_xds (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned char expected_checksum )
992
894
{
993
895
#ifndef DISABLE_RUST
994
- ccxr_do_end_of_xds (sub , ctx , expected_checksum );
896
+ return ccxr_do_end_of_xds (sub , ctx , expected_checksum );
995
897
#else
996
898
997
899
int cs = 0 ;
0 commit comments