Skip to content

Commit b5fb2ad

Browse files
refactor: Convert some portion of code to rust
Code contains flushing the active decoders of `dtvcc_rust`
1 parent 144ab5f commit b5fb2ad

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/lib_ccx/ccx_decoders_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ made to reuse, not duplicate, as many functions as possible */
1717

1818
#ifndef DISABLE_RUST
1919
extern int ccxr_process_cc_data(struct lib_cc_decode *dec_ctx, unsigned char *cc_data, int cc_count);
20-
extern void ccxr_flush_decoder(struct dtvcc_ctx *dtvcc, struct dtvcc_service_decoder *decoder);
20+
extern void ccxr_flush_decoder(void *dtvcc_rust, struct dtvcc_service_decoder *decoder);
2121
#endif
2222

2323
uint64_t utc_refvalue = UINT64_MAX; /* _UI64_MAX/UINT64_MAX means don't use UNIX, 0 = use current system time as reference, +1 use a specific reference */
@@ -449,6 +449,9 @@ void flush_cc_decode(struct lib_cc_decode *ctx, struct cc_subtitle *sub)
449449
}
450450
}
451451
}
452+
#ifndef DISABLE_RUST
453+
ccxr_flush_active_decoders(ctx);
454+
#else
452455
if (ctx->dtvcc->is_active)
453456
{
454457
for (int i = 0; i < CCX_DTVCC_MAX_SERVICES; i++)
@@ -459,14 +462,11 @@ void flush_cc_decode(struct lib_cc_decode *ctx, struct cc_subtitle *sub)
459462
if (decoder->cc_count > 0)
460463
{
461464
ctx->current_field = 3;
462-
#ifndef DISABLE_RUST
463-
ccxr_flush_decoder(ctx->dtvcc, decoder);
464-
#else
465465
dtvcc_decoder_flush(ctx->dtvcc, decoder);
466-
#endif
467466
}
468467
}
469468
}
469+
#endif
470470
}
471471
struct encoder_ctx *copy_encoder_context(struct encoder_ctx *ctx)
472472
{

src/lib_ccx/ccx_decoders_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ struct cc_subtitle* copy_subtitle(struct cc_subtitle *sub);
3232
void free_encoder_context(struct encoder_ctx *ctx);
3333
void free_decoder_context(struct lib_cc_decode *ctx);
3434
void free_subtitle(struct cc_subtitle* sub);
35+
#ifndef DISABLE_RUST
36+
void ccxr_flush_active_decoders(struct lib_cc_decode *ctx);
37+
#endif // !DISABLE_RUST
38+
3539
#endif

0 commit comments

Comments
 (0)