Skip to content

Commit 2f6f178

Browse files
author
vats004
committed
some serious code refactoring
1 parent 7d3f3d7 commit 2f6f178

File tree

18 files changed

+3820
-2658
lines changed

18 files changed

+3820
-2658
lines changed

src/lib_ccx/ccx_decoders_isdb.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1-
21
#include "ccx_decoders_isdb.h"
32
#include "lib_ccx.h"
43
#include "utility.h"
54
#include "limits.h"
65

76
#ifndef DISABLE_RUST
87

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);
8+
extern int ccxr_isdb_set_global_time(
9+
struct lib_cc_decode *dec_ctx,
10+
unsigned long long timestamp);
11+
12+
extern void ccxr_delete_isdb_decoder(
13+
void **isdb_ctx);
14+
15+
extern struct ISDBSubContext *ccxr_init_isdb_decoder(
16+
void);
17+
18+
extern int ccxr_isdb_parse_data_group(
19+
struct ISDBSubContext *codec_ctx,
20+
const unsigned char *buf,
21+
struct cc_subtitle *sub);
22+
23+
extern int ccxr_isdbsub_decode(
24+
struct lib_cc_decode *dec_ctx,
25+
const unsigned char *buf,
26+
size_t buf_len,
27+
struct cc_subtitle *sub);
1428

1529
#endif
1630

@@ -487,6 +501,7 @@ static int ccx_strstr_ignorespace(const unsigned char *str1, const unsigned char
487501
}
488502
return 1;
489503
}
504+
490505
/**
491506
* Copy data not more then len provided
492507
* User should check for return type to check how much data he has got
@@ -1347,7 +1362,7 @@ static int parse_caption_statement_data(ISDBSubContext *ctx, int lang_id, const
13471362
int isdb_parse_data_group(void *codec_ctx, const uint8_t *buf, struct cc_subtitle *sub)
13481363
{
13491364
#ifndef DISABLE_RUST
1350-
return ccxr_isdb_parse_data_group(codec_ctx, buf, 0, sub);
1365+
return ccxr_isdb_parse_data_group(codec_ctx, buf, sub);
13511366
#else
13521367
ISDBSubContext *ctx = codec_ctx;
13531368
const uint8_t *buf_pivot = buf;
@@ -1458,4 +1473,4 @@ int isdb_set_global_time(struct lib_cc_decode *dec_ctx, uint64_t timestamp)
14581473
ctx->timestamp = timestamp;
14591474
return CCX_OK;
14601475
#endif
1461-
}
1476+
}

src/rust/Cargo.lock

Lines changed: 3 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ time = "0.3.39"
2727
cfg-if = "1.0.0"
2828
num-integer = "0.1.46"
2929
lib_ccxr = { path = "lib_ccxr" }
30-
3130
url = "2.5.4"
32-
libc = "0.2.169"
33-
nanomsg = { version = "0.7.2" }
34-
prost = "0.13.4"
35-
prost-types = "0.13.4"
36-
lazy_static = "1.5.0"
37-
nanomsg-sys = "0.7.2"
31+
3832

3933
[build-dependencies]
4034
bindgen = "0.64.0"
@@ -49,4 +43,4 @@ hardsubx_ocr = ["rsmpeg", "tesseract-sys", "leptonica-sys"]
4943

5044
[profile.release-with-debug]
5145
inherits = "release"
52-
debug = true
46+
debug = true

src/rust/lib_ccxr/Cargo.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ strum = "0.26.3"
1515
strum_macros = "0.26.4"
1616
crc32fast = "1.4.2"
1717
num_enum = "0.6.1"
18-
libc = "0.2.169"
19-
nanomsg = "0.7.2"
20-
prost = "0.13.4"
21-
prost-types = "0.13.4"
22-
lazy_static = "1.5.0"
23-
nanomsg-sys = "0.7.2"
18+
log = "0.4.26"
19+
env_logger = "0.8.4"
2420

2521
[features]
2622
default = [
@@ -35,6 +31,4 @@ wtv_debug = []
3531
enable_ffmpeg = []
3632
debug_out = []
3733
debug = []
38-
with_libcurl = []
39-
40-
34+
with_libcurl = []
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Status codes
2+
pub const CCX_OK: i64 = 0;
3+
pub const CCX_FALSE: i64 = 0;
4+
pub const CCX_TRUE: i64 = 1;
5+
pub const CCX_EAGAIN: i64 = -100;
6+
pub const CCX_EOF: i64 = -101;
7+
pub const CCX_EINVAL: i64 = -102;
8+
pub const CCX_ENOSUPP: i64 = -103;
9+
pub const CCX_ENOMEM: i64 = -104;
10+
11+
pub const NUM_BYTES_PER_PACKET: i64 = 35; // Class + type (repeated for convenience) + data + zero
12+
pub const NUM_XDS_BUFFERS: i64 = 35; // CEA recommends no more than one level of interleaving. Play it safe
13+
14+
pub const MAXBFRAMES: usize = 50;
15+
pub const SORTBUF: usize = 2 * MAXBFRAMES + 1;
16+
17+
// Time at which we switched to XDS mode, -1 means it hasn't happened yet
18+
pub const TS_START_OF_XDS: i64 = -1;
19+
20+
// Exit codes
21+
pub const EXIT_OK: i64 = 0;
22+
pub const EXIT_NO_INPUT_FILES: i64 = 2;
23+
pub const EXIT_TOO_MANY_INPUT_FILES: i64 = 3;
24+
pub const EXIT_INCOMPATIBLE_PARAMETERS: i64 = 4;
25+
pub const EXIT_UNABLE_TO_DETERMINE_FILE_SIZE: i64 = 6;
26+
pub const EXIT_MALFORMED_PARAMETER: i64 = 7;
27+
pub const EXIT_READ_ERROR: i64 = 8;
28+
pub const EXIT_NO_CAPTIONS: i64 = 10;
29+
pub const EXIT_WITH_HELP: i64 = 11;
30+
pub const EXIT_NOT_CLASSIFIED: i64 = 300;
31+
pub const EXIT_ERROR_IN_CAPITALIZATION_FILE: i64 = 501;
32+
pub const EXIT_BUFFER_FULL: i64 = 502;
33+
pub const EXIT_MISSING_ASF_HEADER: i64 = 1001;
34+
pub const EXIT_MISSING_RCWT_HEADER: i64 = 1002;
35+
36+
// Common exit codes
37+
pub const CCX_COMMON_EXIT_FILE_CREATION_FAILED: i64 = 5;
38+
pub const CCX_COMMON_EXIT_UNSUPPORTED: i64 = 9;
39+
pub const EXIT_NOT_ENOUGH_MEMORY: i64 = 500;
40+
pub const CCX_COMMON_EXIT_BUG_BUG: i64 = 1000;
41+
42+
// Define max width in characters/columns on the screen
43+
pub const CCX_DECODER_608_SCREEN_ROWS: usize = 15;
44+
pub const CCX_DECODER_608_SCREEN_WIDTH: usize = 32;
45+
46+
//isdb specific codes
47+
pub const CCX_DTVCC_MAX_SERVICES: usize = 63;
48+
pub const CCX_DTVCC_MAX_WINDOWS: usize = 8;
49+
pub const CCX_DTVCC_MAX_ROWS: usize = 15;
50+
pub const CCX_DTVCC_SCREENGRID_COLUMNS: usize = 210;
51+
pub const CCX_DTVCC_MAX_PACKET_LENGTH: usize = 128;
52+
pub const CCX_DTVCC_SCREENGRID_ROWS: usize = 75;
53+
54+
pub const CCX_MESSAGES_QUIET: i32 = 0;
55+
pub const CCX_MESSAGES_STDOUT: i32 = 1;
56+
pub const CCX_MESSAGES_STDERR: i32 = 2;

0 commit comments

Comments
 (0)