Skip to content

Commit 477a5d8

Browse files
committed
made Demuxer and File Functions
1 parent 8d3acf4 commit 477a5d8

File tree

27 files changed

+13255
-5868
lines changed

27 files changed

+13255
-5868
lines changed

linux/ut=report

Lines changed: 10119 additions & 0 deletions
Large diffs are not rendered by default.

src/ccextractor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ int api_start(struct ccx_s_options api_options)
201201
api_options.use_gop_as_pts = 0;
202202
if (api_options.ignore_pts_jumps)
203203
ccx_common_timing_settings.disable_sync_check = 1;
204-
mprint("\rAnalyzing data in general mode\n");
204+
mprint("\r\n Analyzing data in general mode\n");
205205
tmp = general_loop(ctx);
206206
if (!ret)
207207
ret = tmp;

src/lib_ccx/ccx_demuxer.c

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ void ccxr_demuxer_close(struct ccx_demuxer *ctx);
99
int ccxr_demuxer_isopen(const struct ccx_demuxer *ctx);
1010
int ccxr_demuxer_open(struct ccx_demuxer *ctx, const char *file);
1111
LLONG ccxr_demuxer_get_file_size(struct ccx_demuxer *ctx);
12-
int ccxr_demuxer_get_stream_mode(const struct ccx_demuxer *ctx);
1312
void ccxr_demuxer_print_cfg(const struct ccx_demuxer *ctx);
14-
void ccxr_demuxer_delete(struct ccx_demuxer **ctx);
1513
#endif
1614

1715
static void ccx_demuxer_reset(struct ccx_demuxer *ctx)
1816
{
19-
// #ifndef DISABLE_RUST
20-
// ccxr_demuxer_reset(ctx);
21-
// #else
17+
#ifndef DISABLE_RUST
18+
ccxr_demuxer_reset(ctx);
19+
#else
2220
ctx->startbytes_pos = 0;
2321
ctx->startbytes_avail = 0;
2422
ctx->num_of_PIDs = 0;
@@ -30,39 +28,38 @@ static void ccx_demuxer_reset(struct ccx_demuxer *ctx)
3028
}
3129
memset(ctx->stream_id_of_each_pid, 0, (MAX_PSI_PID + 1) * sizeof(uint8_t));
3230
memset(ctx->PIDs_programs, 0, 65536 * sizeof(struct PMT_entry *));
33-
// #endif
31+
#endif
3432
}
3533

3634
static void ccx_demuxer_close(struct ccx_demuxer *ctx)
3735
{
38-
// #ifndef DISABLE_RUST
39-
// ccxr_demuxer_close(ctx);
40-
// mprint("ctx.past = %lld\n", ctx->past);
41-
// mprint("ctx.infd = %lld\n", ctx->infd);
42-
// #else
36+
#ifndef DISABLE_RUST
37+
ccxr_demuxer_close(ctx);
38+
#else
4339
ctx->past = 0;
4440
if (ctx->infd != -1 && ccx_options.input_source == CCX_DS_FILE)
4541
{
4642
close(ctx->infd);
4743
ctx->infd = -1;
4844
activity_input_file_closed();
4945
}
50-
// #endif
46+
#endif
5147
}
5248

5349
static int ccx_demuxer_isopen(struct ccx_demuxer *ctx)
5450
{
55-
// #ifndef DISABLE_RUST
56-
// return ccxr_demuxer_isopen(ctx);
57-
// #else
51+
#ifndef DISABLE_RUST
52+
return ccxr_demuxer_isopen(ctx);
53+
#else
5854
return ctx->infd != -1;
59-
// #endif
55+
#endif
6056
}
57+
6158
static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
6259
{
63-
// #ifndef DISABLE_RUST
64-
// return ccxr_demuxer_open(ctx, file);
65-
// #else
60+
#ifndef DISABLE_RUST
61+
return ccxr_demuxer_open(ctx, file);
62+
#else
6663
ctx->past = 0;
6764
ctx->min_global_timestamp = 0;
6865
ctx->global_timestamp_inited = 0;
@@ -220,13 +217,14 @@ static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
220217
}
221218

222219
return 0;
223-
// #endif
220+
#endif
224221
}
222+
225223
LLONG ccx_demuxer_get_file_size(struct ccx_demuxer *ctx)
226224
{
227-
// #ifndef DISABLE_RUST
228-
// return ccxr_demuxer_get_file_size(ctx);
229-
// #else
225+
#ifndef DISABLE_RUST
226+
return ccxr_demuxer_get_file_size(ctx);
227+
#else
230228
LLONG ret = 0;
231229
int in = ctx->infd;
232230
LLONG current = LSEEK(in, 0, SEEK_CUR);
@@ -239,23 +237,19 @@ LLONG ccx_demuxer_get_file_size(struct ccx_demuxer *ctx)
239237
return -1;
240238

241239
return length;
242-
// #endif
240+
#endif
243241
}
244242

245243
static int ccx_demuxer_get_stream_mode(struct ccx_demuxer *ctx)
246244
{
247-
// #ifndef DISABLE_RUST
248-
// return ccxr_demuxer_get_stream_mode(ctx);
249-
// #else
250245
return ctx->stream_mode;
251-
// #endif
252246
}
253247

254248
static void ccx_demuxer_print_cfg(struct ccx_demuxer *ctx)
255249
{
256-
// #ifndef DISABLE_RUST
257-
// ccxr_demuxer_print_cfg(ctx);
258-
// #else
250+
#ifndef DISABLE_RUST
251+
ccxr_demuxer_print_cfg(ctx);
252+
#else
259253
switch (ctx->auto_stream)
260254
{
261255
case CCX_SM_ELEMENTARY_OR_NOT_FOUND:
@@ -300,14 +294,11 @@ static void ccx_demuxer_print_cfg(struct ccx_demuxer *ctx)
300294
fatal(CCX_COMMON_EXIT_BUG_BUG, "BUG: Unknown stream mode. Please file a bug report on Github.\n");
301295
break;
302296
}
303-
// #endif
297+
#endif
304298
}
305299

306300
void ccx_demuxer_delete(struct ccx_demuxer **ctx)
307301
{
308-
// #ifndef DISABLE_RUST
309-
// ccxr_demuxer_delete(ctx);
310-
// #else
311302
struct ccx_demuxer *lctx = *ctx;
312303
int i;
313304
dinit_cap(lctx);
@@ -330,7 +321,6 @@ void ccx_demuxer_delete(struct ccx_demuxer **ctx)
330321

331322
freep(&lctx->filebuffer);
332323
freep(ctx);
333-
// #endif
334324
}
335325

336326
struct ccx_demuxer *init_demuxer(void *parent, struct demuxer_cfg *cfg)
@@ -451,4 +441,4 @@ struct demuxer_data *alloc_demuxer_data(void)
451441
data->next_stream = 0;
452442
data->next_program = 0;
453443
return data;
454-
}
444+
}

src/lib_ccx/ccx_demuxer_mxf.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@
1414
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
1515
#define IS_KLV_KEY_ANY_VERSION(x, y) (!memcmp(x, y, 7) && !memcmp(x + 8, y + 8, sizeof(y) - 8))
1616

17-
enum MXFCaptionType
18-
{
19-
MXF_CT_VBI,
20-
MXF_CT_ANC,
21-
};
2217

23-
typedef uint8_t UID[16];
2418
typedef struct KLVPacket
2519
{
2620
UID key;
@@ -35,28 +29,13 @@ typedef struct MXFCodecUL
3529

3630
typedef int ReadFunc(struct ccx_demuxer *ctx, uint64_t size);
3731

38-
typedef struct
39-
{
40-
int track_id;
41-
uint8_t track_number[4];
42-
} MXFTrack;
4332

4433
typedef struct MXFReadTableEntry
4534
{
4635
const UID key;
4736
ReadFunc *read;
4837
} MXFReadTableEntry;
4938

50-
typedef struct MXFContext
51-
{
52-
enum MXFCaptionType type;
53-
int cap_track_id;
54-
UID cap_essence_key;
55-
MXFTrack tracks[32];
56-
int nb_tracks;
57-
int cap_count;
58-
struct ccx_rational edit_rate;
59-
} MXFContext;
6039

6140
typedef struct MXFLocalTAGS
6241
{

src/lib_ccx/ccx_demuxer_mxf.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33

44
#include "ccx_demuxer.h"
55

6-
int ccx_probe_mxf(struct ccx_demuxer *ctx);
7-
struct MXFContext *ccx_mxf_init(struct ccx_demuxer *demux);
6+
typedef uint8_t UID[16];
7+
8+
enum MXFCaptionType
9+
{
10+
MXF_CT_VBI,
11+
MXF_CT_ANC,
12+
};
13+
14+
typedef struct
15+
{
16+
int track_id;
17+
uint8_t track_number[4];
18+
} MXFTrack;
19+
20+
typedef struct MXFContext
21+
{
22+
enum MXFCaptionType type;
23+
int cap_track_id;
24+
UID cap_essence_key;
25+
MXFTrack tracks[32];
26+
int nb_tracks;
27+
int cap_count;
28+
struct ccx_rational edit_rate;
29+
} MXFContext;
30+
31+
int ccx_probe_mxf(struct ccx_demuxer* ctx);
32+
struct MXFContext* ccx_mxf_init(struct ccx_demuxer* demux);
833
#endif

src/lib_ccx/ccx_gxf.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "ccx_demuxer.h"
2020
#include "file_buffer.h"
2121

22-
#define STR_LEN 256u
2322

2423
#define CLOSED_CAP_DID 0x61
2524
#define CLOSED_C708_SDID 0x01
@@ -303,52 +302,6 @@ struct ccx_gxf_ancillary_data_track
303302
uint32_t field_per_frame;
304303
};
305304

306-
struct ccx_gxf
307-
{
308-
int nb_streams;
309-
310-
/* Name of Media File */
311-
char media_name[STR_LEN];
312-
313-
/**
314-
* The first field number shall represent the position on a playout
315-
* time line of the first recorded field on a track
316-
*/
317-
int32_t first_field_nb;
318-
319-
/**
320-
* The last field number shall represent the position on a playout
321-
* time line of the last recorded field plus one.
322-
*/
323-
int32_t last_field_nb;
324-
325-
/**
326-
* The mark in field number shall represent the position on a playout
327-
* time line of the first field to be played from a track.
328-
*/
329-
int32_t mark_in;
330-
331-
/**
332-
* The mark out field number shall represent the position on a playout
333-
* time line of the last field to be played plus one
334-
*/
335-
int32_t mark_out;
336-
337-
/**
338-
* Estimated size in kb for bytes multiply by 1024
339-
*/
340-
int32_t stream_size;
341-
342-
struct ccx_gxf_ancillary_data_track *ad_track;
343-
344-
struct ccx_gxf_video_track *vid_track;
345-
346-
/**
347-
* cdp data buffer
348-
*/
349-
unsigned char *cdp;
350-
size_t cdp_len;
351-
};
352305

353306
/**
354307
* @brief parses a packet header, extracting type and length

src/lib_ccx/ccx_gxf.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,55 @@
44
#include "ccx_demuxer.h"
55
#include "lib_ccx.h"
66

7+
#define STR_LEN 256u
8+
9+
struct ccx_gxf
10+
{
11+
int nb_streams;
12+
13+
/* Name of Media File */
14+
char media_name[STR_LEN];
15+
16+
/**
17+
* The first field number shall represent the position on a playout
18+
* time line of the first recorded field on a track
19+
*/
20+
int32_t first_field_nb;
21+
22+
/**
23+
* The last field number shall represent the position on a playout
24+
* time line of the last recorded field plus one.
25+
*/
26+
int32_t last_field_nb;
27+
28+
/**
29+
* The mark in field number shall represent the position on a playout
30+
* time line of the first field to be played from a track.
31+
*/
32+
int32_t mark_in;
33+
34+
/**
35+
* The mark out field number shall represent the position on a playout
36+
* time line of the last field to be played plus one
37+
*/
38+
int32_t mark_out;
39+
40+
/**
41+
* Estimated size in kb for bytes multiply by 1024
42+
*/
43+
int32_t stream_size;
44+
45+
struct ccx_gxf_ancillary_data_track *ad_track;
46+
47+
struct ccx_gxf_video_track *vid_track;
48+
49+
/**
50+
* cdp data buffer
51+
*/
52+
unsigned char *cdp;
53+
size_t cdp_len;
54+
};
55+
756
int ccx_gxf_probe(unsigned char *buf, int len);
857
int ccx_gxf_get_more_data(struct lib_ccx_ctx *ctx, struct demuxer_data **data);
958
struct ccx_gxf *ccx_gxf_init(struct ccx_demuxer *arg);

src/rust/Cargo.lock

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

src/rust/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ fn main() {
1313
"version",
1414
"set_binary_mode",
1515
"print_file_report",
16+
"start_upd_srv", // shall be removed after NET
17+
"start_tcp_srv", // shall be removed after NET
18+
"net_tcp_read", // shall be removed after NET
19+
"net_udp_read", // shall be removed after NET
20+
"ccx_probe_mxf", // shall be removed after mxf
21+
"ccx_mxf_init", // shall be removed after mxf
22+
"ccx_gxf_probe", // shall be removed after gxf
23+
"ccx_gxf_init", // shall be removed after gxf
24+
#[cfg(feature = "enable_ffmpeg")]
25+
"init_ffmpeg",
1626
]);
1727

1828
#[cfg(feature = "hardsubx_ocr")]
@@ -41,6 +51,8 @@ fn main() {
4151
"ccx_encoding_type",
4252
"ccx_decoder_608_settings",
4353
"ccx_decoder_608_report",
54+
"ccx_gxf",
55+
"MXFContext",
4456
"uint8_t",
4557
"word_list",
4658
]);

0 commit comments

Comments
 (0)