Skip to content

Commit ca93fa8

Browse files
committed
Fix Unit Test Rust based on the new changes on Rust 1.86.0
1 parent 888ffa4 commit ca93fa8

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- New: Add tesseract page segmentation modes control with `--psm` flag
4040
- Fix: Resolve compile-time error about implicit declarations (#1646)
4141
- Fix: fatal out of memory error extracting from a VOB PS
42+
- Fix: Unit Test Rust failing due to changes in Rust Version 1.86.0
4243

4344
0.94 (2021-12-14)
4445
-----------------

src/rust/src/decoder/mod.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,35 @@ pub struct Dtvcc<'a> {
4444
impl<'a> Dtvcc<'a> {
4545
/// Create a new dtvcc context
4646
pub fn new(ctx: &'a mut dtvcc_ctx) -> Self {
47-
let report = unsafe { &mut *ctx.report };
48-
let encoder = unsafe { &mut *(ctx.encoder as *mut encoder_ctx) };
49-
let timing = unsafe { &mut *ctx.timing };
50-
47+
let report = if !ctx.report.is_null() {
48+
unsafe { Box::new(*(ctx.report)) }
49+
} else {
50+
Box::new(ccx_decoder_dtvcc_report::default())
51+
};
52+
let encoder = if !ctx.encoder.is_null() {
53+
unsafe { Box::new(*(ctx.encoder as *mut encoder_ctx)) }
54+
} else {
55+
Box::new(encoder_ctx::default())
56+
};
57+
let timing = if !ctx.timing.is_null() {
58+
unsafe { Box::new(*(ctx.timing)) }
59+
} else {
60+
Box::new(ccx_common_timing_ctx::default())
61+
};
5162
Self {
5263
is_active: is_true(ctx.is_active),
5364
active_services_count: ctx.active_services_count as u8,
5465
services_active: ctx.services_active.to_vec(),
5566
report_enabled: is_true(ctx.report_enabled),
56-
report,
67+
report: Box::leak(report),
5768
decoders: ctx.decoders.iter_mut().collect(),
5869
packet: ctx.current_packet.to_vec(),
5970
packet_length: ctx.current_packet_length as u8,
6071
is_header_parsed: is_true(ctx.is_current_packet_header_parsed),
6172
last_sequence: ctx.last_sequence,
62-
encoder,
73+
encoder: Box::leak(encoder),
6374
no_rollup: is_true(ctx.no_rollup),
64-
timing,
75+
timing: Box::leak(timing),
6576
}
6677
}
6778
/// Process cc data and add it to the dtvcc packet

src/rust/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ pub fn do_cb(ctx: &mut lib_cc_decode, dtvcc: &mut Dtvcc, cc_block: &[u8]) -> boo
173173
0 | 1 => {}
174174
// Type 2 and 3 are for CEA-708 data.
175175
2 | 3 => {
176-
let current_time = unsafe { (*ctx.timing).get_fts(ctx.current_field as u8) };
176+
let current_time = if ctx.timing.is_null() {
177+
0
178+
} else {
179+
unsafe { (*ctx.timing).get_fts(ctx.current_field as u8) }
180+
};
177181
ctx.current_field = 3;
178182

179183
// Check whether current time is within start and end bounds

0 commit comments

Comments
 (0)