44#include "utility.h"
55#include "limits.h"
66
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+
717// #define DEBUG
818// #define COMMAND_DEBUG
919
@@ -281,6 +291,9 @@ typedef struct
281291 */
282292void delete_isdb_decoder (void * * isdb_ctx )
283293{
294+ #ifndef DISABLE_RUST
295+ ccxr_delete_isdb_decoder (isdb_ctx );
296+ #else
284297 ISDBSubContext * ctx = * isdb_ctx ;
285298 struct ISDBText * text = NULL ;
286299 struct ISDBText * text1 = NULL ;
@@ -298,6 +311,7 @@ void delete_isdb_decoder(void **isdb_ctx)
298311 free (text );
299312 }
300313 freep (isdb_ctx );
314+ #endif
301315}
302316
303317static void init_layout (ISDBSubLayout * ls )
@@ -312,6 +326,9 @@ static void init_layout(ISDBSubLayout *ls)
312326
313327void * init_isdb_decoder (void )
314328{
329+ #ifndef DISABLE_RUST
330+ return ccxr_init_isdb_decoder ();
331+ #else
315332 ISDBSubContext * ctx ;
316333
317334 ctx = malloc (sizeof (ISDBSubContext ));
@@ -326,6 +343,7 @@ void *init_isdb_decoder(void)
326343 ctx -> current_state .rollup_mode = 0 ;
327344 init_layout (& ctx -> current_state .layout_state );
328345 return ctx ;
346+ #endif
329347}
330348
331349/**
@@ -1328,6 +1346,9 @@ static int parse_caption_statement_data(ISDBSubContext *ctx, int lang_id, const
13281346 */
13291347int isdb_parse_data_group (void * codec_ctx , const uint8_t * buf , struct cc_subtitle * sub )
13301348{
1349+ #ifndef DISABLE_RUST
1350+ return ccxr_isdb_parse_data_group (codec_ctx , buf , 0 , sub );
1351+ #else
13311352 ISDBSubContext * ctx = codec_ctx ;
13321353 const uint8_t * buf_pivot = buf ;
13331354 int id = (* buf >> 2 );
@@ -1393,10 +1414,14 @@ int isdb_parse_data_group(void *codec_ctx, const uint8_t *buf, struct cc_subtitl
13931414 buf += 2 ;
13941415
13951416 return buf - buf_pivot ;
1417+ #endif
13961418}
13971419
13981420int isdbsub_decode (struct lib_cc_decode * dec_ctx , const uint8_t * buf , size_t buf_size , struct cc_subtitle * sub )
13991421{
1422+ #ifndef DISABLE_RUST
1423+ return ccxr_isdbsub_decode (dec_ctx , buf , buf_size , sub );
1424+ #else
14001425 const uint8_t * header_end = NULL ;
14011426 int ret = 0 ;
14021427 ISDBSubContext * ctx = dec_ctx -> private_data ;
@@ -1421,10 +1446,16 @@ int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf
14211446 return -1 ;
14221447
14231448 return 1 ;
1449+ #endif
14241450}
1451+
14251452int isdb_set_global_time (struct lib_cc_decode * dec_ctx , uint64_t timestamp )
14261453{
1454+ #ifndef DISABLE_RUST
1455+ return ccxr_isdb_set_global_time (dec_ctx , timestamp );
1456+ #else
14271457 ISDBSubContext * ctx = dec_ctx -> private_data ;
14281458 ctx -> timestamp = timestamp ;
14291459 return CCX_OK ;
1460+ #endif
14301461}
0 commit comments