From b738d5933db85e33f1ea51e1ace44d52a9aaa613 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Sat, 13 Nov 2021 00:16:51 +0100 Subject: [PATCH] tttojson: fix row computation I hadn't really tested the element with pop-on mode, and the row for each line in the input text was hardcoded to 13, which was clearly wrong. Switch to incrementing it properly. --- video/closedcaption/src/tttojson/imp.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/video/closedcaption/src/tttojson/imp.rs b/video/closedcaption/src/tttojson/imp.rs index be6bd46cd..9eda203e9 100644 --- a/video/closedcaption/src/tttojson/imp.rs +++ b/video/closedcaption/src/tttojson/imp.rs @@ -22,6 +22,7 @@ use gst::subclass::prelude::*; use once_cell::sync::Lazy; +use std::cmp::min; use std::sync::Mutex; use crate::ttutils::{Cea608Mode, Chunk, Line, Lines, TextStyle}; @@ -91,11 +92,13 @@ impl TtToJson { clear: Some(false), }; + let mut row = min(15usize.saturating_sub(text.lines().count()), 13usize) as u32; + for phrase in text.lines() { lines.lines.push(Line { carriage_return: Some(true), column: Some(0), - row: Some(13), + row: Some(row), chunks: vec![Chunk { // Default CEA 608 styling style: TextStyle::White, @@ -103,6 +106,8 @@ impl TtToJson { text: phrase.to_string(), }], }); + + row = min(14u32, row + 1); } let json = serde_json::to_string(&lines).map_err(|err| {