Skip to content

Commit 32f9c73

Browse files
committed
Demuxer: Failing ES regressions
1 parent 3f56e47 commit 32f9c73

5 files changed

Lines changed: 42 additions & 37 deletions

File tree

src/rust/src/ctorust.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl FromCType<ccx_decoder_dtvcc_settings> for DecoderDtvccSettings {
131131
print_file_reports: settings.print_file_reports != 0,
132132
no_rollup: settings.no_rollup != 0,
133133
report: if !settings.report.is_null() {
134-
Some(DecoderDtvccReport::from_ctype(*settings.report)?)
134+
Some(DecoderDtvccReport::from_ctype(settings.report)?)
135135
} else {
136136
None
137137
},
@@ -143,11 +143,16 @@ impl FromCType<ccx_decoder_dtvcc_settings> for DecoderDtvccSettings {
143143
}
144144

145145
// Implementation for DecoderDtvccReport
146-
impl FromCType<ccx_decoder_dtvcc_report> for DecoderDtvccReport {
147-
unsafe fn from_ctype(report: ccx_decoder_dtvcc_report) -> Option<Self> {
146+
impl FromCType<*const ccx_decoder_dtvcc_report> for DecoderDtvccReport {
147+
unsafe fn from_ctype(report_ptr: *const ccx_decoder_dtvcc_report) -> Option<Self> {
148+
if report_ptr.is_null() {
149+
return None;
150+
}
151+
152+
let report = &*report_ptr; // Get a reference instead of copying
148153
Some(DecoderDtvccReport {
149154
reset_count: report.reset_count,
150-
services: report.services.map(|svc| svc),
155+
services: report.services,
151156
})
152157
}
153158
}

src/rust/src/es/core.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,26 +201,26 @@ pub unsafe fn dump(start: *const u8, l: i32, abs_start: u64, clear_high_bit: u32
201201

202202
let mut x = 0;
203203
while x < l {
204-
info!("{:08} | ", x + abs_start as i32);
204+
debug!(msg_type = DebugMessageFlag::VERBOSE;"{:08} | ", x + abs_start as i32);
205205

206206
for j in 0..16 {
207207
if x + j < l {
208-
info!("{:02X} ", data[(x + j) as usize]);
208+
debug!(msg_type = DebugMessageFlag::VERBOSE;"{:02X} ", data[(x + j) as usize]);
209209
} else {
210-
info!(" ");
210+
debug!(msg_type = DebugMessageFlag::VERBOSE;" ");
211211
}
212212
}
213-
info!(" | ");
213+
debug!(msg_type = DebugMessageFlag::VERBOSE;" | ");
214214

215215
for j in 0..16 {
216216
if x + j < l && data[(x + j) as usize] >= b' ' {
217217
let ch = data[(x + j) as usize] & (if clear_high_bit != 0 { 0x7F } else { 0xFF });
218-
info!("{}", ch as char);
218+
debug!(msg_type = DebugMessageFlag::VERBOSE;"{}", ch as char);
219219
} else {
220-
info!(" ");
220+
debug!(msg_type = DebugMessageFlag::VERBOSE;" ");
221221
}
222222
}
223-
info!("\n");
223+
debug!(msg_type = DebugMessageFlag::VERBOSE;"\n");
224224
x += 16;
225225
}
226226
}

src/rust/src/es/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use crate::bindings::{cc_subtitle, encoder_ctx, lib_cc_decode};
22
use crate::ccx_options;
33
use crate::es::core::process_m2v;
44
use lib_ccxr::common::Options;
5+
use lib_ccxr::debug;
6+
use lib_ccxr::util::log::DebugMessageFlag;
57

68
pub mod core;
79
pub mod eau;
@@ -31,13 +33,15 @@ pub unsafe extern "C" fn ccxr_process_m2v(
3133
};
3234

3335
let data_slice = std::slice::from_raw_parts(data, length);
34-
process_m2v(
36+
let processedvalue = process_m2v(
3537
&mut *enc_ctx,
3638
&mut *dec_ctx,
3739
data_slice,
3840
length,
3941
&mut *sub,
4042
&mut CcxOptions,
4143
)
42-
.unwrap_or(0)
44+
.unwrap_or(0);
45+
debug!(msg_type = DebugMessageFlag::VERBOSE;"Data slice is {:p} with length {} \n", data, length);
46+
processedvalue
4347
}

src/rust/src/es/userdata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub unsafe fn user_data(
265265
debug!(msg_type = DebugMessageFlag::VERBOSE; "Reading {} HDTV CC blocks", cc_count);
266266

267267
let mut proceed = true;
268-
let cc_data = ustream.read_bytes(cc_count as usize * 3)?;
268+
let cc_data = ustream.read_bytes(cc_count as usize * 3 + 1)?;
269269
if ustream.bits_left < 0 {
270270
fatal!(cause = ExitCause::Bug; "In user_data: ustream->bitsleft < 0. Cannot continue.");
271271
}

src/rust/src/lib.rs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,25 @@ extern "C" {
150150
len: usize,
151151
sub: *mut cc_subtitle,
152152
) -> c_int;
153+
fn print_file_report(ctx: *mut lib_ccx_ctx);
154+
#[allow(dead_code)]
155+
#[cfg(feature = "enable_ffmpeg")]
156+
fn init_ffmpeg(path: *const c_char);
157+
pub fn start_tcp_srv(port: *const c_char, pwd: *const c_char) -> c_int;
158+
pub fn start_upd_srv(src: *const c_char, addr: *const c_char, port: c_uint) -> c_int;
159+
pub fn net_udp_read(
160+
socket: c_int,
161+
buffer: *mut c_void,
162+
length: usize,
163+
src_str: *const c_char,
164+
addr_str: *const c_char,
165+
) -> c_int;
166+
pub fn net_tcp_read(socket: c_int, buffer: *mut c_void, length: usize) -> c_int;
167+
pub fn ccx_probe_mxf(ctx: *mut ccx_demuxer) -> c_int;
168+
pub fn ccx_mxf_init(demux: *mut ccx_demuxer) -> *mut MXFContext;
169+
#[allow(clashing_extern_declarations)]
170+
pub fn ccx_gxf_probe(buf: *const c_uchar, len: c_int) -> c_int;
171+
pub fn ccx_gxf_init(arg: *mut ccx_demuxer) -> *mut ccx_gxf;
153172
}
154173

155174
/// Initialize env logger with custom format, using stdout as target
@@ -292,29 +311,6 @@ extern "C" fn ccxr_close_handle(handle: RawHandle) {
292311
}
293312
}
294313

295-
extern "C" {
296-
#[allow(dead_code)]
297-
fn print_file_report(ctx: *mut lib_ccx_ctx);
298-
#[allow(dead_code)]
299-
#[cfg(feature = "enable_ffmpeg")]
300-
fn init_ffmpeg(path: *const c_char);
301-
pub fn start_tcp_srv(port: *const c_char, pwd: *const c_char) -> c_int;
302-
pub fn start_upd_srv(src: *const c_char, addr: *const c_char, port: c_uint) -> c_int;
303-
pub fn net_udp_read(
304-
socket: c_int,
305-
buffer: *mut c_void,
306-
length: usize,
307-
src_str: *const c_char,
308-
addr_str: *const c_char,
309-
) -> c_int;
310-
pub fn net_tcp_read(socket: c_int, buffer: *mut c_void, length: usize) -> c_int;
311-
pub fn ccx_probe_mxf(ctx: *mut ccx_demuxer) -> c_int;
312-
pub fn ccx_mxf_init(demux: *mut ccx_demuxer) -> *mut MXFContext;
313-
#[allow(clashing_extern_declarations)]
314-
pub fn ccx_gxf_probe(buf: *const c_uchar, len: c_int) -> c_int;
315-
pub fn ccx_gxf_init(arg: *mut ccx_demuxer) -> *mut ccx_gxf;
316-
}
317-
318314
/// # Safety
319315
/// Safe if argv is a valid pointer
320316
///

0 commit comments

Comments
 (0)