4
4
#include "utility.h"
5
5
#include "limits.h"
6
6
7
+ #ifndef DISABLE_RUST
8
+
9
+ extern int ccxr_isdb_set_global_time (struct lib_cc_decode * dec_ctx , uint64_t timestamp );
10
+ extern void ccxr_delete_isdb_decoder (void * * isdb_ctx );
11
+ extern void * ccxr_init_isdb_decoder (void );
12
+ extern int ccxr_isdb_parse_data_group (void * codec_ctx , const uint8_t * buf , int size , struct cc_subtitle * sub );
13
+ extern int ccxr_isdbsub_decode (struct lib_cc_decode * dec_ctx , const uint8_t * buf , size_t buf_size , struct cc_subtitle * sub );
14
+
15
+ #endif
16
+
7
17
// #define DEBUG
8
18
// #define COMMAND_DEBUG
9
19
@@ -281,6 +291,9 @@ typedef struct
281
291
*/
282
292
void delete_isdb_decoder (void * * isdb_ctx )
283
293
{
294
+ #ifndef DISABLE_RUST
295
+ ccxr_delete_isdb_decoder (isdb_ctx );
296
+ #else
284
297
ISDBSubContext * ctx = * isdb_ctx ;
285
298
struct ISDBText * text = NULL ;
286
299
struct ISDBText * text1 = NULL ;
@@ -298,6 +311,7 @@ void delete_isdb_decoder(void **isdb_ctx)
298
311
free (text );
299
312
}
300
313
freep (isdb_ctx );
314
+ #endif
301
315
}
302
316
303
317
static void init_layout (ISDBSubLayout * ls )
@@ -308,10 +322,14 @@ static void init_layout(ISDBSubLayout *ls)
308
322
309
323
ls -> font_scale .fscx = 100 ;
310
324
ls -> font_scale .fscy = 100 ;
325
+
311
326
}
312
327
313
328
void * init_isdb_decoder (void )
314
329
{
330
+ #ifndef DISABLE_RUST
331
+ return ccxr_init_isdb_decoder ();
332
+ #else
315
333
ISDBSubContext * ctx ;
316
334
317
335
ctx = malloc (sizeof (ISDBSubContext ));
@@ -326,6 +344,7 @@ void *init_isdb_decoder(void)
326
344
ctx -> current_state .rollup_mode = 0 ;
327
345
init_layout (& ctx -> current_state .layout_state );
328
346
return ctx ;
347
+ #endif
329
348
}
330
349
331
350
/**
@@ -585,6 +604,9 @@ static int get_text(ISDBSubContext *ctx, unsigned char *buffer, int len)
585
604
586
605
static void set_writing_format (ISDBSubContext * ctx , uint8_t * arg )
587
606
{
607
+ #ifdef DISABLE_RUST
608
+ ccxr_set_writing_format (& ctx , arg );
609
+ #else
588
610
ISDBSubLayout * ls = & ctx -> current_state .layout_state ;
589
611
590
612
/* One param means its initialization */
@@ -637,6 +659,7 @@ static void set_writing_format(ISDBSubContext *ctx, uint8_t *arg)
637
659
}
638
660
639
661
return ;
662
+ #endif
640
663
}
641
664
642
665
/** move pen position to (col, row) relative to display area's top left.
@@ -1328,6 +1351,9 @@ static int parse_caption_statement_data(ISDBSubContext *ctx, int lang_id, const
1328
1351
*/
1329
1352
int isdb_parse_data_group (void * codec_ctx , const uint8_t * buf , struct cc_subtitle * sub )
1330
1353
{
1354
+ #ifndef DISABLE_RUST
1355
+ return ccxr_isdb_parse_data_group (codec_ctx , buf , 0 , sub );
1356
+ #else
1331
1357
ISDBSubContext * ctx = codec_ctx ;
1332
1358
const uint8_t * buf_pivot = buf ;
1333
1359
int id = (* buf >> 2 );
@@ -1393,10 +1419,14 @@ int isdb_parse_data_group(void *codec_ctx, const uint8_t *buf, struct cc_subtitl
1393
1419
buf += 2 ;
1394
1420
1395
1421
return buf - buf_pivot ;
1422
+ #endif
1396
1423
}
1397
1424
1398
1425
int isdbsub_decode (struct lib_cc_decode * dec_ctx , const uint8_t * buf , size_t buf_size , struct cc_subtitle * sub )
1399
1426
{
1427
+ #ifndef DISABLE_RUST
1428
+ return ccxr_isdbsub_decode (dec_ctx , buf , buf_size , sub );
1429
+ #else
1400
1430
const uint8_t * header_end = NULL ;
1401
1431
int ret = 0 ;
1402
1432
ISDBSubContext * ctx = dec_ctx -> private_data ;
@@ -1421,10 +1451,16 @@ int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf
1421
1451
return -1 ;
1422
1452
1423
1453
return 1 ;
1454
+ #endif
1424
1455
}
1456
+
1425
1457
int isdb_set_global_time (struct lib_cc_decode * dec_ctx , uint64_t timestamp )
1426
1458
{
1459
+ #ifndef DISABLE_RUST
1460
+ return ccxr_isdb_set_global_time (dec_ctx , timestamp );
1461
+ #else
1427
1462
ISDBSubContext * ctx = dec_ctx -> private_data ;
1428
1463
ctx -> timestamp = timestamp ;
1429
1464
return CCX_OK ;
1465
+ #endif
1430
1466
}
0 commit comments