Skip to content

[FEAT] added demuxer and file_functions module #1662

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 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1bae1a8
feat: added demuxer module
steel-bucket Feb 11, 2025
a1dc67e
Cargo Lock Update
steel-bucket Mar 23, 2025
26aba5e
Completed file_functions and demuxer
steel-bucket Mar 25, 2025
7718d7b
Completed file_functions and demuxer
steel-bucket Mar 25, 2025
9ad0e05
written extern functions for demuxer
steel-bucket Mar 25, 2025
63da17f
Removed libc completely, added tests for gxf and ported gxf to C
steel-bucket Mar 27, 2025
6bc2607
Hardsubx error fixed
steel-bucket Mar 29, 2025
985a188
Fixing format issues
steel-bucket Mar 29, 2025
1cbe989
clippy errors fixed
steel-bucket Mar 30, 2025
7e15406
fixing format issues
steel-bucket Mar 30, 2025
3e7ba4f
fixing format issues
steel-bucket Mar 30, 2025
efdd506
Windows failing tests
steel-bucket Mar 30, 2025
f48d695
Windows failing tests
steel-bucket Mar 30, 2025
b5346ed
demuxer: added demuxer data transfer functions and removed some structs
steel-bucket May 19, 2025
27c7f3a
made Demuxer and File Functions
steel-bucket Jun 7, 2025
9a91d25
Minor formatting changes
steel-bucket Jun 7, 2025
de98427
Minor Rebasing changes
steel-bucket Jun 7, 2025
dd630f1
demuxer: format rust and unit test rust checks
steel-bucket Jun 7, 2025
02445a0
C formatting
steel-bucket Jun 7, 2025
cdc4e9b
Windows Failing test
steel-bucket Jun 7, 2025
6cec4d7
Windows Failing test
steel-bucket Jun 7, 2025
687acff
Update CHANGES.TXT
steel-bucket Jun 7, 2025
7ff6453
Update CHANGES.TXT
steel-bucket Jun 11, 2025
1d71058
Windows Failing Tests
steel-bucket Jun 11, 2025
3353303
Windows Failing Tests
steel-bucket Jun 11, 2025
914c0be
Problem in Copy to Rust and some typos that copilot review suggested
steel-bucket Jun 13, 2025
191c3db
Minor Formatting Error
steel-bucket Jun 13, 2025
a7021f1
Windows Failing Regressions
steel-bucket Jun 14, 2025
08fcbea
Windows Failing Regressions
steel-bucket Jun 15, 2025
4f2590a
Minor Comment Change
steel-bucket Jun 16, 2025
4a92178
Data transfer module for DemuxerData added and more rustlike syntax t…
steel-bucket Jun 22, 2025
48397ff
Minor Formatting Changes
steel-bucket Jun 22, 2025
8ab4f83
demuxer: Rebase and a few tweaks to file_functions
steel-bucket Jun 30, 2025
a3383b9
demuxer: Minor Formatting Error
steel-bucket Jun 30, 2025
638b6e4
Merge branch 'master' into migration-demuxer-module
steel-bucket Jul 7, 2025
90840b6
demuxer: minor formatting changes
steel-bucket Jul 7, 2025
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
5 changes: 4 additions & 1 deletion docs/CHANGES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
- Fix: Segmentation faults on XDS files
- Fix: Clippy Errors Based on Rust 1.88
- IMPROVEMENT: Refactor and optimize Dockerfile
- New: Add demuxer and file_functions module in lib_ccxr (#1662)
- New: Add demuxer and file_functions module (#1662)
- Fix: Unit Test Rust failing due to changes in Rust Version 1.86.0 (#1694)
- IMPROVEMENT: Refactor and optimize Dockerfile
- Fix: Improved handling of IETF language tags in Matroska files (#1665)
- New: Create unit test for rust code (#1615)
- Breaking: Major argument flags revamp for CCExtractor (#1564 & #1619)
Expand Down Expand Up @@ -42,7 +46,6 @@
- New: Add tesseract page segmentation modes control with `--psm` flag
- Fix: Resolve compile-time error about implicit declarations (#1646)
- Fix: fatal out of memory error extracting from a VOB PS
- Fix: Unit Test Rust failing due to changes in Rust Version 1.86.0

0.94 (2021-12-14)
-----------------
Expand Down
2 changes: 1 addition & 1 deletion src/ccextractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ int api_start(struct ccx_s_options api_options)
api_options.use_gop_as_pts = 0;
if (api_options.ignore_pts_jumps)
ccx_common_timing_settings.disable_sync_check = 1;
mprint("\rAnalyzing data in general mode\n");
mprint("\r\n Analyzing data in general mode\n");
tmp = general_loop(ctx);
if (!ret)
ret = tmp;
Expand Down
36 changes: 35 additions & 1 deletion src/lib_ccx/ccx_demuxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
#include "lib_ccx.h"
#include "utility.h"
#include "ffmpeg_intgr.h"
#ifndef DISABLE_RUST
void ccxr_demuxer_reset(struct ccx_demuxer *ctx);
void ccxr_demuxer_close(struct ccx_demuxer *ctx);
int ccxr_demuxer_isopen(const struct ccx_demuxer *ctx);
int ccxr_demuxer_open(struct ccx_demuxer *ctx, const char *file);
LLONG ccxr_demuxer_get_file_size(struct ccx_demuxer *ctx);
void ccxr_demuxer_print_cfg(const struct ccx_demuxer *ctx);
#endif

static void ccx_demuxer_reset(struct ccx_demuxer *ctx)
{
#ifndef DISABLE_RUST
ccxr_demuxer_reset(ctx);
#else
ctx->startbytes_pos = 0;
ctx->startbytes_avail = 0;
ctx->num_of_PIDs = 0;
Expand All @@ -17,25 +28,38 @@ static void ccx_demuxer_reset(struct ccx_demuxer *ctx)
}
memset(ctx->stream_id_of_each_pid, 0, (MAX_PSI_PID + 1) * sizeof(uint8_t));
memset(ctx->PIDs_programs, 0, 65536 * sizeof(struct PMT_entry *));
#endif
}

static void ccx_demuxer_close(struct ccx_demuxer *ctx)
{
#ifndef DISABLE_RUST
ccxr_demuxer_close(ctx);
#else
ctx->past = 0;
if (ctx->infd != -1 && ccx_options.input_source == CCX_DS_FILE)
{
close(ctx->infd);
ctx->infd = -1;
activity_input_file_closed();
}
#endif
}

static int ccx_demuxer_isopen(struct ccx_demuxer *ctx)
{
#ifndef DISABLE_RUST
return ccxr_demuxer_isopen(ctx);
#else
return ctx->infd != -1;
#endif
}

static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
{
#ifndef DISABLE_RUST
return ccxr_demuxer_open(ctx, file);
#else
ctx->past = 0;
ctx->min_global_timestamp = 0;
ctx->global_timestamp_inited = 0;
Expand Down Expand Up @@ -193,9 +217,14 @@ static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
}

return 0;
#endif
}

LLONG ccx_demuxer_get_file_size(struct ccx_demuxer *ctx)
{
#ifndef DISABLE_RUST
return ccxr_demuxer_get_file_size(ctx);
#else
LLONG ret = 0;
int in = ctx->infd;
LLONG current = LSEEK(in, 0, SEEK_CUR);
Expand All @@ -208,6 +237,7 @@ LLONG ccx_demuxer_get_file_size(struct ccx_demuxer *ctx)
return -1;

return length;
#endif
}

static int ccx_demuxer_get_stream_mode(struct ccx_demuxer *ctx)
Expand All @@ -217,6 +247,9 @@ static int ccx_demuxer_get_stream_mode(struct ccx_demuxer *ctx)

static void ccx_demuxer_print_cfg(struct ccx_demuxer *ctx)
{
#ifndef DISABLE_RUST
ccxr_demuxer_print_cfg(ctx);
#else
switch (ctx->auto_stream)
{
case CCX_SM_ELEMENTARY_OR_NOT_FOUND:
Expand Down Expand Up @@ -261,6 +294,7 @@ static void ccx_demuxer_print_cfg(struct ccx_demuxer *ctx)
fatal(CCX_COMMON_EXIT_BUG_BUG, "BUG: Unknown stream mode. Please file a bug report on Github.\n");
break;
}
#endif
}

void ccx_demuxer_delete(struct ccx_demuxer **ctx)
Expand Down Expand Up @@ -407,4 +441,4 @@ struct demuxer_data *alloc_demuxer_data(void)
data->next_stream = 0;
data->next_program = 0;
return data;
}
}
24 changes: 0 additions & 24 deletions src/lib_ccx/ccx_demuxer_mxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
#define IS_KLV_KEY_ANY_VERSION(x, y) (!memcmp(x, y, 7) && !memcmp(x + 8, y + 8, sizeof(y) - 8))

enum MXFCaptionType
{
MXF_CT_VBI,
MXF_CT_ANC,
};

typedef uint8_t UID[16];
typedef struct KLVPacket
{
UID key;
Expand All @@ -35,29 +28,12 @@ typedef struct MXFCodecUL

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

typedef struct
{
int track_id;
uint8_t track_number[4];
} MXFTrack;

typedef struct MXFReadTableEntry
{
const UID key;
ReadFunc *read;
} MXFReadTableEntry;

typedef struct MXFContext
{
enum MXFCaptionType type;
int cap_track_id;
UID cap_essence_key;
MXFTrack tracks[32];
int nb_tracks;
int cap_count;
struct ccx_rational edit_rate;
} MXFContext;

typedef struct MXFLocalTAGS
{
uint16_t tag;
Expand Down
29 changes: 27 additions & 2 deletions src/lib_ccx/ccx_demuxer_mxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@

#include "ccx_demuxer.h"

int ccx_probe_mxf(struct ccx_demuxer *ctx);
struct MXFContext *ccx_mxf_init(struct ccx_demuxer *demux);
typedef uint8_t UID[16];

enum MXFCaptionType
{
MXF_CT_VBI,
MXF_CT_ANC,
};

typedef struct
{
int track_id;
uint8_t track_number[4];
} MXFTrack;

typedef struct MXFContext
{
enum MXFCaptionType type;
int cap_track_id;
UID cap_essence_key;
MXFTrack tracks[32];
int nb_tracks;
int cap_count;
struct ccx_rational edit_rate;
} MXFContext;

int ccx_probe_mxf(struct ccx_demuxer* ctx);
struct MXFContext* ccx_mxf_init(struct ccx_demuxer* demux);
#endif
Loading
Loading