Skip to content

Commit 9e19c58

Browse files
cfsmp3claude
andcommitted
refactor: Replace platform-dependent 'long' with 'int64_t'
The C type 'long' has different sizes on different platforms: - Linux: 64-bit - Windows: 32-bit This causes ABI mismatches when interfacing with Rust, since Rust's c_long matches the platform's long size, but we were treating these values as 64-bit throughout. Changed the following fields from 'long' to 'int64_t': - asf_constants.h: parsebufsize - avc_functions.h: cc_databufsize, num_nal_unit_type_7, num_vcl_hrd, num_nal_hrd, num_jump_in_frames, num_unexpected_sei_length - ccx_decoders_608.h: bytes_processed_608 - ccx_demuxer.h: capbufsize, capbuflen - lib_ccx.h: ts_readstream() return type, FILEBUFFERSIZE - file_functions.c: FILEBUFFERSIZE definition - ts_functions.c: ts_readstream() implementation Also updated Rust code in common.rs to remove c_long casts, since bindgen will now generate i64 for these fields. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 2c67381 commit 9e19c58

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

src/lib_ccx/asf_constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef struct
5353
{
5454
// Generic buffer to hold data
5555
unsigned char *parsebuf;
56-
long parsebufsize;
56+
int64_t parsebufsize;
5757
// Header Object variables
5858
int64_t HeaderObjectSize;
5959
int64_t FileSize;

src/lib_ccx/avc_functions.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct avc_ctx
66
unsigned char cc_count;
77
// buffer to hold cc data
88
unsigned char *cc_data;
9-
long cc_databufsize;
9+
int64_t cc_databufsize;
1010
int cc_buffer_saved; // Was the CC buffer saved after it was last updated?
1111

1212
int is_hevc; // Flag to indicate HEVC (H.265) mode vs H.264
@@ -19,11 +19,11 @@ struct avc_ctx
1919
int frame_mbs_only_flag;
2020

2121
// Use and throw stats for debug, remove this ugliness soon
22-
long num_nal_unit_type_7;
23-
long num_vcl_hrd;
24-
long num_nal_hrd;
25-
long num_jump_in_frames;
26-
long num_unexpected_sei_length;
22+
int64_t num_nal_unit_type_7;
23+
int64_t num_vcl_hrd;
24+
int64_t num_nal_hrd;
25+
int64_t num_jump_in_frames;
26+
int64_t num_unexpected_sei_length;
2727

2828
int ccblocks_in_avc_total;
2929
int ccblocks_in_avc_lost;

src/lib_ccx/ccx_decoders_608.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef struct ccx_decoder_608_context
4848
int my_field; // Used for sanity checks
4949
int my_channel; // Used for sanity checks
5050
int rollup_from_popon; // Track transition from pop-on/paint-on to roll-up mode
51-
long bytes_processed_608; // To be written ONLY by process_608
51+
int64_t bytes_processed_608; // To be written ONLY by process_608
5252
int have_cursor_position;
5353

5454
int *halt; // Can be used to halt the feeding of caption data. Set to 1 if screens_to_progress != -1 && screenfuls_counter >= screens_to_process

src/lib_ccx/ccx_demuxer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ struct cap_info
5757
int program_number;
5858
enum ccx_stream_type stream;
5959
enum ccx_code_type codec;
60-
long capbufsize;
60+
int64_t capbufsize;
6161
unsigned char *capbuf;
62-
long capbuflen; // Bytes read in capbuf
62+
int64_t capbuflen; // Bytes read in capbuf
6363
int saw_pesstart;
6464
int prev_counter;
6565
void *codec_private_data;

src/lib_ccx/file_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "ccx_common_option.h"
33
#include "activity.h"
44
#include "file_buffer.h"
5-
long FILEBUFFERSIZE = 1024 * 1024 * 16; // 16 Mbytes no less. Minimize number of real read calls()
5+
int64_t FILEBUFFERSIZE = 1024 * 1024 * 16; // 16 Mbytes no less. Minimize number of real read calls()
66

77
#ifdef _WIN32
88
WSADATA wsaData = {0};

src/lib_ccx/lib_ccx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ int read_video_pes_header(struct ccx_demuxer *ctx, struct demuxer_data *data, un
237237
// ts_functions.c
238238
void init_ts(struct ccx_demuxer *ctx);
239239
int ts_readpacket(struct ccx_demuxer *ctx, struct ts_payload *payload);
240-
long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data);
240+
int64_t ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data);
241241
int ts_get_more_data(struct lib_ccx_ctx *ctx, struct demuxer_data **data);
242242
int write_section(struct ccx_demuxer *ctx, struct ts_payload *payload, unsigned char *buf, int size, struct program_info *pinfo);
243243
void ts_buffer_psi_packet(struct ccx_demuxer *ctx);
@@ -294,7 +294,7 @@ extern int strangeheader;
294294

295295
extern const char *desc[256];
296296

297-
extern long FILEBUFFERSIZE; // Uppercase because it used to be a define
297+
extern int64_t FILEBUFFERSIZE; // Uppercase because it used to be a define
298298

299299
extern int firstcall;
300300

src/lib_ccx/ts_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ uint64_t get_pts(uint8_t *buffer)
754754
// Threshold for enabling packet analysis mode when no PAT is found (in bytes)
755755
#define NO_PAT_THRESHOLD (188 * 1000) // After ~1000 packets
756756

757-
long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data)
757+
int64_t ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data)
758758
{
759759
int gotpes = 0;
760760
long pespcount = 0; // count packets in PES with captions

src/rust/src/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use lib_ccxr::time::units::Timestamp;
3232
use lib_ccxr::time::units::TimestampFormat;
3333
use lib_ccxr::util::encoding::Encoding;
3434
use lib_ccxr::util::log::{DebugMessageMask, OutputTarget};
35-
use std::os::raw::{c_int, c_long};
35+
use std::os::raw::c_int;
3636
use std::path::PathBuf;
3737
use std::str::FromStr;
3838

@@ -996,9 +996,9 @@ impl CType<cap_info> for CapInfo {
996996
program_number: self.program_number,
997997
stream: self.stream.to_ctype() as ccx_stream_type, // CType<ccx_stream_type> for StreamType
998998
codec: self.codec.to_ctype(), // CType<ccx_code_type> for Codec
999-
capbufsize: self.capbufsize as c_long,
999+
capbufsize: self.capbufsize,
10001000
capbuf: self.capbuf,
1001-
capbuflen: self.capbuflen as c_long,
1001+
capbuflen: self.capbuflen,
10021002
saw_pesstart: self.saw_pesstart,
10031003
prev_counter: self.prev_counter,
10041004
codec_private_data: self.codec_private_data,

0 commit comments

Comments
 (0)