diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2021-02-10 23:19:51 +0300 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-02-15 22:25:18 +0300 |
commit | 19611f0ebe84ff813f1779c80f256739449fa81f (patch) | |
tree | 67200004ce053c69635c685ff6c47822f5f69697 | |
parent | 20607fe3465e1b2f2524e1a0e733cc06230b1704 (diff) |
tttocea608: be more conservative when inserting spaces
We don't need to insert a space when starting a new line,
or before punctuation.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/474>
-rw-r--r-- | video/closedcaption/src/tttocea608/imp.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs index 50be30821..f6d61d539 100644 --- a/video/closedcaption/src/tttocea608/imp.rs +++ b/video/closedcaption/src/tttocea608/imp.rs @@ -29,6 +29,10 @@ use std::sync::Mutex; use crate::ttutils::{Cea608Mode, Chunk, Line, Lines, TextStyle}; +fn is_punctuation(word: &str) -> bool { + word == "." || word == "," || word == "?" || word == "!" || word == ";" || word == ":" +} + fn is_basicna(cc_data: u16) -> bool { 0x0000 != (0x6000 & cc_data) } @@ -525,6 +529,8 @@ impl TtToCea608 { state.underline = chunk.underline; state.send_roll_up_preamble = false; ret = false; + } else if *col == self.settings.lock().unwrap().origin_column { + ret = false; } if self.open_chunk(element, state, chunk, bufferlist, *col) { @@ -657,6 +663,10 @@ impl TtToCea608 { col += 1; } + if is_punctuation(&chunk.text) { + prepend_space = false; + } + let text = { if prepend_space { let mut text = " ".to_string(); |