Skip to content

[FEAT] WIP module decoder_isdb in lib_ccxr #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions src/lib_ccx/ccx_decoders_isdb.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@

#include "ccx_decoders_isdb.h"
#include "lib_ccx.h"
#include "utility.h"
#include "limits.h"

#ifndef DISABLE_RUST

extern int ccxr_isdb_set_global_time(
struct lib_cc_decode *dec_ctx,
unsigned long long timestamp);

extern void ccxr_delete_isdb_decoder(
void **isdb_ctx);

extern struct ISDBSubContext *ccxr_init_isdb_decoder(
void);

extern int ccxr_isdb_parse_data_group(
struct ISDBSubContext *codec_ctx,
const unsigned char *buf,
struct cc_subtitle *sub);

extern int ccxr_isdbsub_decode(
struct lib_cc_decode *dec_ctx,
const unsigned char *buf,
size_t buf_len,
struct cc_subtitle *sub);

#endif

// #define DEBUG
// #define COMMAND_DEBUG

Expand Down Expand Up @@ -281,6 +305,9 @@ typedef struct
*/
void delete_isdb_decoder(void **isdb_ctx)
{
#ifndef DISABLE_RUST
ccxr_delete_isdb_decoder(isdb_ctx);
#else
ISDBSubContext *ctx = *isdb_ctx;
struct ISDBText *text = NULL;
struct ISDBText *text1 = NULL;
Expand All @@ -298,6 +325,7 @@ void delete_isdb_decoder(void **isdb_ctx)
free(text);
}
freep(isdb_ctx);
#endif
}

static void init_layout(ISDBSubLayout *ls)
Expand All @@ -312,6 +340,9 @@ static void init_layout(ISDBSubLayout *ls)

void *init_isdb_decoder(void)
{
#ifndef DISABLE_RUST
return ccxr_init_isdb_decoder();
#else
ISDBSubContext *ctx;

ctx = malloc(sizeof(ISDBSubContext));
Expand All @@ -326,6 +357,7 @@ void *init_isdb_decoder(void)
ctx->current_state.rollup_mode = 0;
init_layout(&ctx->current_state.layout_state);
return ctx;
#endif
}

/**
Expand Down Expand Up @@ -469,6 +501,7 @@ static int ccx_strstr_ignorespace(const unsigned char *str1, const unsigned char
}
return 1;
}

/**
* Copy data not more then len provided
* User should check for return type to check how much data he has got
Expand Down Expand Up @@ -1328,6 +1361,9 @@ static int parse_caption_statement_data(ISDBSubContext *ctx, int lang_id, const
*/
int isdb_parse_data_group(void *codec_ctx, const uint8_t *buf, struct cc_subtitle *sub)
{
#ifndef DISABLE_RUST
return ccxr_isdb_parse_data_group(codec_ctx, buf, sub);
#else
ISDBSubContext *ctx = codec_ctx;
const uint8_t *buf_pivot = buf;
int id = (*buf >> 2);
Expand Down Expand Up @@ -1393,10 +1429,14 @@ int isdb_parse_data_group(void *codec_ctx, const uint8_t *buf, struct cc_subtitl
buf += 2;

return buf - buf_pivot;
#endif
}

int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf_size, struct cc_subtitle *sub)
{
#ifndef DISABLE_RUST
return ccxr_isdbsub_decode(dec_ctx, buf, buf_size, sub);
#else
const uint8_t *header_end = NULL;
int ret = 0;
ISDBSubContext *ctx = dec_ctx->private_data;
Expand All @@ -1421,10 +1461,16 @@ int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf
return -1;

return 1;
#endif
}

int isdb_set_global_time(struct lib_cc_decode *dec_ctx, uint64_t timestamp)
{
#ifndef DISABLE_RUST
return ccxr_isdb_set_global_time(dec_ctx, timestamp);
#else
ISDBSubContext *ctx = dec_ctx->private_data;
ctx->timestamp = timestamp;
return CCX_OK;
}
#endif
}
4 changes: 3 additions & 1 deletion src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ num-integer = "0.1.46"
lib_ccxr = { path = "lib_ccxr" }
url = "2.5.4"


[build-dependencies]
bindgen = "0.64.0"
pkg-config = "0.3.32"
Expand All @@ -42,4 +43,4 @@ hardsubx_ocr = ["rsmpeg", "tesseract-sys", "leptonica-sys"]

[profile.release-with-debug]
inherits = "release"
debug = true
debug = true
Loading
Loading