Skip to content

Commit 06dbf3c

Browse files
committed
Net module: Rebasing and formatting changes
1 parent 1ea6185 commit 06dbf3c

File tree

8 files changed

+758
-90
lines changed

8 files changed

+758
-90
lines changed

src/rust/lib_ccxr/Cargo.lock

Lines changed: 694 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/lib_ccxr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ pub mod activity;
22
pub mod common;
33
pub mod encoder;
44
pub mod hardsubx;
5+
pub mod net;
56
pub mod subtitle;
67
pub mod teletext;
7-
pub mod net;
88
pub mod time;
99
pub mod util;

src/rust/src/decoder/output.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a> Writer<'a> {
7070
pub fn write_done(&mut self) {
7171
if self.write_format == ccx_output_format::CCX_OF_SAMI {
7272
if let Err(err) = self.write_sami_footer() {
73-
warn!("{}", err);
73+
warn!("{err}");
7474
}
7575
} else {
7676
debug!("dtvcc_write_done: no handling required");
@@ -106,10 +106,7 @@ pub fn color_to_hex(color: u8) -> (u8, u8, u8) {
106106
let red = color >> 4;
107107
let green = (color >> 2) & 0x3;
108108
let blue = color & 0x3;
109-
debug!(
110-
"Color: {} [{:06x}] {} {} {}",
111-
color, color, red, green, blue
112-
);
109+
debug!("Color: {color} [{color:06x}] {red} {green} {blue}");
113110
(red, green, blue)
114111
}
115112

src/rust/src/decoder/service_decoder.rs

Lines changed: 39 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl dtvcc_service_decoder {
115115
let pd = match dtvcc_window_pd::new(window.attribs.print_direction) {
116116
Ok(val) => val,
117117
Err(e) => {
118-
warn!("{}", e);
118+
warn!("{e}");
119119
return;
120120
}
121121
};
@@ -218,7 +218,7 @@ impl dtvcc_service_decoder {
218218
let pd = match dtvcc_window_pd::new(window.attribs.print_direction) {
219219
Ok(val) => val,
220220
Err(e) => {
221-
warn!("{}", e);
221+
warn!("{e}");
222222
return;
223223
}
224224
};
@@ -283,7 +283,7 @@ impl dtvcc_service_decoder {
283283
return -1;
284284
}
285285

286-
debug!("C1: [{:?}] [{}] ({})", command, name, length);
286+
debug!("C1: [{command:?}] [{name}] ({length})");
287287
match command {
288288
C1CodeSet::CW0
289289
| C1CodeSet::CW1
@@ -344,7 +344,7 @@ impl dtvcc_service_decoder {
344344
for i in 0..CCX_DTVCC_MAX_WINDOWS {
345345
if windows_bitmap & 1 == 1 {
346346
let window = &mut self.windows[i as usize];
347-
debug!("[W{}]", i);
347+
debug!("[W{i}]");
348348
let window_had_content = is_true(window.is_defined)
349349
&& is_true(window.visible)
350350
&& is_false(window.is_empty);
@@ -381,7 +381,7 @@ impl dtvcc_service_decoder {
381381
for i in 0..CCX_DTVCC_MAX_WINDOWS {
382382
if windows_bitmap & 1 == 1 {
383383
let window = &mut self.windows[i as usize];
384-
debug!("[W{}]", i);
384+
debug!("[W{i}]");
385385
if is_true(window.visible) {
386386
screen_content_changed = true;
387387
window.visible = 0;
@@ -418,11 +418,11 @@ impl dtvcc_service_decoder {
418418
let window = &mut self.windows[i as usize];
419419
if windows_bitmap & 1 == 1 && is_true(window.is_defined) {
420420
if is_false(window.visible) {
421-
debug!("[W-{}: 0->1]", i);
421+
debug!("[W-{i}: 0->1]");
422422
window.visible = 1;
423423
window.update_time_show(timing);
424424
} else {
425-
debug!("[W-{}: 1->0]", i);
425+
debug!("[W-{i}: 1->0]");
426426
window.visible = 0;
427427
window.update_time_hide(timing);
428428
if is_false(window.is_empty) {
@@ -456,7 +456,7 @@ impl dtvcc_service_decoder {
456456
} else {
457457
for i in 0..CCX_DTVCC_MAX_WINDOWS {
458458
if windows_bitmap & 1 == 1 {
459-
debug!("Deleting [W{}]", i);
459+
debug!("Deleting [W{i}]");
460460
let window = &mut self.windows[i as usize];
461461
let window_had_content = is_true(window.is_defined)
462462
&& is_true(window.visible)
@@ -501,9 +501,9 @@ impl dtvcc_service_decoder {
501501
for i in 0..CCX_DTVCC_MAX_WINDOWS {
502502
if windows_bitmap & 1 == 1 {
503503
let window = &mut self.windows[i as usize];
504-
debug!("[W{}]", i);
504+
debug!("[W{i}]");
505505
if is_false(window.is_defined) {
506-
error!("Window {} was not defined", i);
506+
error!("Window {i} was not defined");
507507
continue;
508508
}
509509
if is_false(window.visible) {
@@ -525,10 +525,7 @@ impl dtvcc_service_decoder {
525525
block: &[c_uchar],
526526
timing: &mut ccx_common_timing_ctx,
527527
) {
528-
debug!(
529-
"dtvcc_handle_DFx_DefineWindow: W[{}], attributes:",
530-
window_id
531-
);
528+
debug!("dtvcc_handle_DFx_DefineWindow: W[{window_id}], attributes:");
532529
let window = &mut self.windows[window_id as usize];
533530
let block = &block[..=5];
534531
let is_command_repeated = window
@@ -562,12 +559,12 @@ impl dtvcc_service_decoder {
562559
let mut do_clear_window = false;
563560

564561
debug!("Visible: [{}]", if is_true(visible) { "Yes" } else { "No" });
565-
debug!("Priority: [{}]", priority);
566-
debug!("Row count: [{}]", row_count);
567-
debug!("Column count: [{}]", col_count);
568-
debug!("Anchor point: [{}]", anchor_point);
569-
debug!("Anchor vertical: [{}]", anchor_vertical);
570-
debug!("Anchor horizontal: [{}]", anchor_horizontal);
562+
debug!("Priority: [{priority}]");
563+
debug!("Row count: [{row_count}]");
564+
debug!("Column count: [{col_count}]");
565+
debug!("Anchor point: [{anchor_point}]");
566+
debug!("Anchor vertical: [{anchor_vertical}]");
567+
debug!("Anchor horizontal: [{anchor_horizontal}]");
571568
debug!(
572569
"Relative pos: [{}]",
573570
if is_true(relative_pos) { "Yes" } else { "No" }
@@ -580,8 +577,8 @@ impl dtvcc_service_decoder {
580577
"Column lock: [{}]",
581578
if is_true(col_lock) { "Yes" } else { "No" }
582579
);
583-
debug!("Pen style: [{}]", pen_style);
584-
debug!("Win style: [{}]", win_style);
580+
debug!("Pen style: [{pen_style}]");
581+
debug!("Win style: [{win_style}]");
585582

586583
// Korean samples have "anchor_vertical" and "anchor_horizontal" mixed up,
587584
// this seems to be an encoder issue, but we can workaround it
@@ -640,7 +637,7 @@ impl dtvcc_service_decoder {
640637
for i in 0..CCX_DTVCC_MAX_ROWS as usize {
641638
let layout = Layout::array::<dtvcc_symbol>(CCX_DTVCC_MAX_COLUMNS as usize);
642639
if let Err(e) = layout {
643-
error!("dtvcc_handle_DFx_DefineWindow: Incorrect Layout, {}", e);
640+
error!("dtvcc_handle_DFx_DefineWindow: Incorrect Layout, {e}");
644641
} else {
645642
let ptr = unsafe { alloc(layout.unwrap()) };
646643
if ptr.is_null() {
@@ -671,7 +668,7 @@ impl dtvcc_service_decoder {
671668
for i in 0..CCX_DTVCC_MAX_ROWS as usize {
672669
let layout = Layout::array::<dtvcc_symbol>(CCX_DTVCC_MAX_COLUMNS as usize);
673670
if let Err(e) = layout {
674-
error!("dtvcc_handle_DFx_DefineWindow: Incorrect Layout, {}", e);
671+
error!("dtvcc_handle_DFx_DefineWindow: Incorrect Layout, {e}");
675672
} else {
676673
unsafe { dealloc(window.rows[i] as *mut u8, layout.unwrap()) };
677674
}
@@ -699,13 +696,9 @@ impl dtvcc_service_decoder {
699696
let italic = (block[1] >> 7) & 0x1;
700697
debug!("dtvcc_handle_SPA_SetPenAttributes: attributes: ");
701698
debug!(
702-
"Pen size: [{}] Offset: [{}] Text tag: [{}] Font tag: [{}]",
703-
pen_size, offset, text_tag, font_tag
704-
);
705-
debug!(
706-
"Edge type: [{}] Underline: [{}] Italic: [{}]",
707-
edge_type, underline, italic
699+
"Pen size: [{pen_size}] Offset: [{offset}] Text tag: [{text_tag}] Font tag: [{font_tag}]"
708700
);
701+
debug!("Edge type: [{edge_type}] Underline: [{underline}] Italic: [{italic}]");
709702

710703
let window = &mut self.windows[self.current_window as usize];
711704
if window.pen_row == -1 {
@@ -738,15 +731,9 @@ impl dtvcc_service_decoder {
738731
let bg_opacity = (block[1] >> 6) & 0x03;
739732
let edge_color = (block[2]) & 0x3f;
740733
debug!("dtvcc_handle_SPC_SetPenColor: attributes: ");
741-
debug!(
742-
"Foreground color: [{}] Foreground opacity: [{}]",
743-
fg_color, fg_opacity
744-
);
745-
debug!(
746-
"Background color: [{}] Background opacity: [{}]",
747-
bg_color, bg_opacity
748-
);
749-
debug!("Edge color: [{}]", edge_color);
734+
debug!("Foreground color: [{fg_color}] Foreground opacity: [{fg_opacity}]");
735+
debug!("Background color: [{bg_color}] Background opacity: [{bg_opacity}]");
736+
debug!("Edge color: [{edge_color}]");
750737

751738
let window = &mut self.windows[self.current_window as usize];
752739
if window.pen_row == -1 {
@@ -774,7 +761,7 @@ impl dtvcc_service_decoder {
774761
debug!("dtvcc_handle_SPL_SetPenLocation: attributes: ");
775762
let row = block[0] & 0x0f;
776763
let col = block[1] & 0x3f;
777-
debug!("Row: [{}] Column: [{}]", row, col);
764+
debug!("Row: [{row}] Column: [{col}]");
778765

779766
let window = &mut self.windows[self.current_window as usize];
780767
window.pen_row = row as i32;
@@ -804,16 +791,13 @@ impl dtvcc_service_decoder {
804791
let effect_speed = (block[3] >> 4) & 0x0f;
805792
debug!("dtvcc_handle_SWA_SetWindowAttributes: attributes: ");
806793
debug!(
807-
"Fill color: [{}] Fill opacity: [{}] Border color: [{}] Border type: [{}]",
808-
fill_color, fill_opacity, border_color, border_type
794+
"Fill color: [{fill_color}] Fill opacity: [{fill_opacity}] Border color: [{border_color}] Border type: [{border_type}]"
809795
);
810796
debug!(
811-
"Justify: [{}] Scroll dir: [{}] Print dir: [{}] Word wrap: [{}]",
812-
justify, scroll_dir, print_dir, word_wrap
797+
"Justify: [{justify}] Scroll dir: [{scroll_dir}] Print dir: [{print_dir}] Word wrap: [{word_wrap}]"
813798
);
814799
debug!(
815-
"Border type: [{}] Display eff: [{}] Effect dir: [{}] Effect speed: [{}]",
816-
border_type, display_eff, effect_dir, effect_speed
800+
"Border type: [{border_type}] Display eff: [{display_eff}] Effect dir: [{effect_dir}] Effect speed: [{effect_speed}]"
817801
);
818802

819803
let window_attribts = &mut self.windows[self.current_window as usize].attribs;
@@ -834,23 +818,17 @@ impl dtvcc_service_decoder {
834818
///
835819
/// Change current window to the window id provided
836820
pub fn handle_set_current_window(&mut self, window_id: u8) {
837-
debug!("dtvcc_handle_CWx_SetCurrentWindow: [{}]", window_id);
821+
debug!("dtvcc_handle_CWx_SetCurrentWindow: [{window_id}]");
838822
if is_true(self.windows[window_id as usize].is_defined) {
839823
self.current_window = window_id as i32;
840824
} else {
841-
debug!(
842-
"dtvcc_handle_CWx_SetCurrentWindow: window [{}] is not defined",
843-
window_id
844-
);
825+
debug!("dtvcc_handle_CWx_SetCurrentWindow: window [{window_id}] is not defined");
845826
}
846827
}
847828

848829
/// DLY Delay
849830
pub fn handle_delay(&mut self, tenths_of_sec: u8) {
850-
debug!(
851-
"dtvcc_handle_DLY_Delay: dely for {} tenths of second",
852-
tenths_of_sec
853-
);
831+
debug!("dtvcc_handle_DLY_Delay: dely for {tenths_of_sec} tenths of second");
854832
}
855833

856834
/// DLC Delay Cancel
@@ -910,7 +888,7 @@ impl dtvcc_service_decoder {
910888
let anchor = match dtvcc_pen_anchor_point::new(window.anchor_point) {
911889
Ok(val) => val,
912890
Err(e) => {
913-
warn!("{}", e);
891+
warn!("{e}");
914892
return;
915893
}
916894
};
@@ -955,7 +933,7 @@ impl dtvcc_service_decoder {
955933
"For window {}: Anchor point -> {}, size {}:{}, real position {}:{}",
956934
window.number, window.anchor_point, window.row_count, window.col_count, top, left
957935
);
958-
debug!("we have top [{}] and left [{}]", top, left);
936+
debug!("we have top [{top}] and left [{left}]");
959937
if top < 0 {
960938
top = 0
961939
}
@@ -972,7 +950,7 @@ impl dtvcc_service_decoder {
972950
} else {
973951
window.col_count
974952
};
975-
debug!("{}*{} will be copied to the TV.", copy_rows, copy_cols);
953+
debug!("{copy_rows}*{copy_cols} will be copied to the TV.");
976954

977955
unsafe {
978956
let tv = &mut *self.tv;
@@ -997,7 +975,7 @@ impl dtvcc_service_decoder {
997975
let (a_x1, a_x2, a_y1, a_y2) = match window.get_dimensions() {
998976
Ok(val) => val,
999977
Err(e) => {
1000-
warn!("{}", e);
978+
warn!("{e}");
1001979
return false;
1002980
}
1003981
};
@@ -1006,7 +984,7 @@ impl dtvcc_service_decoder {
1006984
let (b_x1, b_x2, b_y1, b_y2) = match win_compare.get_dimensions() {
1007985
Ok(val) => val,
1008986
Err(e) => {
1009-
warn!("{}", e);
987+
warn!("{e}");
1010988
return false;
1011989
}
1012990
};
@@ -1156,7 +1134,7 @@ impl dtvcc_service_decoder {
11561134
let pd = match dtvcc_window_pd::new(window.attribs.print_direction) {
11571135
Ok(val) => val,
11581136
Err(e) => {
1159-
warn!("{}", e);
1137+
warn!("{e}");
11601138
return;
11611139
}
11621140
};

0 commit comments

Comments
 (0)