Skip to content

[FIX] Fixed Unit Test Rust based on the new changes on Rust 1.86.0 #1694

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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions docs/CHANGES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- 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
25 changes: 18 additions & 7 deletions src/rust/src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,35 @@ pub struct Dtvcc<'a> {
impl<'a> Dtvcc<'a> {
/// Create a new dtvcc context
pub fn new(ctx: &'a mut dtvcc_ctx) -> Self {
let report = unsafe { &mut *ctx.report };
let encoder = unsafe { &mut *(ctx.encoder as *mut encoder_ctx) };
let timing = unsafe { &mut *ctx.timing };

let report = if !ctx.report.is_null() {
unsafe { Box::new(*(ctx.report)) }
} else {
Box::new(ccx_decoder_dtvcc_report::default())
};
let encoder = if !ctx.encoder.is_null() {
unsafe { Box::new(*(ctx.encoder as *mut encoder_ctx)) }
} else {
Box::new(encoder_ctx::default())
};
let timing = if !ctx.timing.is_null() {
unsafe { Box::new(*(ctx.timing)) }
} else {
Box::new(ccx_common_timing_ctx::default())
};
Self {
is_active: is_true(ctx.is_active),
active_services_count: ctx.active_services_count as u8,
services_active: ctx.services_active.to_vec(),
report_enabled: is_true(ctx.report_enabled),
report,
report: Box::leak(report),
decoders: ctx.decoders.iter_mut().collect(),
packet: ctx.current_packet.to_vec(),
packet_length: ctx.current_packet_length as u8,
is_header_parsed: is_true(ctx.is_current_packet_header_parsed),
last_sequence: ctx.last_sequence,
encoder,
encoder: Box::leak(encoder),
no_rollup: is_true(ctx.no_rollup),
timing,
timing: Box::leak(timing),
}
}
/// Process cc data and add it to the dtvcc packet
Expand Down
6 changes: 5 additions & 1 deletion src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ pub fn do_cb(ctx: &mut lib_cc_decode, dtvcc: &mut Dtvcc, cc_block: &[u8]) -> boo
0 | 1 => {}
// Type 2 and 3 are for CEA-708 data.
2 | 3 => {
let current_time = unsafe { (*ctx.timing).get_fts(ctx.current_field as u8) };
let current_time = if ctx.timing.is_null() {
0
} else {
unsafe { (*ctx.timing).get_fts(ctx.current_field as u8) }
};
ctx.current_field = 3;

// Check whether current time is within start and end bounds
Expand Down
Loading