tttocea608: insert preambles in roll-up mode

I thought I could spare some bandwidth by letting renderers pick
the base row, but it turns out this triggers some unwanted behaviours
with compliant renderers.

Instead, we now follow the protocol laid out in EIA/CEA-608-B,
section B.8.1

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/355>
This commit is contained in:
Mathieu Duponchelle 2020-06-10 21:36:29 +02:00
parent 321f418518
commit ed4fa7fde4
2 changed files with 23 additions and 5 deletions

View file

@ -384,6 +384,7 @@ impl TtToCea608 {
Mode::RollUp4 => roll_up_4(&mut buffers),
_ => (),
}
preamble_buffer(&mut buffers, 14, 0);
state.send_roll_up = false;
state.roll_up_column = 0;
}
@ -416,7 +417,14 @@ impl TtToCea608 {
let mut prev_char: u16 = if state.settings.mode == Mode::PopOn || col == 0 {
0
} else if col >= 31 {
match state.settings.mode {
Mode::RollUp2 => roll_up_2(&mut buffers),
Mode::RollUp3 => roll_up_3(&mut buffers),
Mode::RollUp4 => roll_up_4(&mut buffers),
_ => (),
}
carriage_return(&mut buffers);
preamble_buffer(&mut buffers, 14, 0);
col = 0;
0
} else {
@ -508,7 +516,15 @@ impl TtToCea608 {
prev_char = 0;
}
match state.settings.mode {
Mode::RollUp2 => roll_up_2(&mut buffers),
Mode::RollUp3 => roll_up_3(&mut buffers),
Mode::RollUp4 => roll_up_4(&mut buffers),
_ => (),
}
carriage_return(&mut buffers);
preamble_buffer(&mut buffers, 14, 0);
col = 0;
}
}

View file

@ -316,14 +316,16 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
let inbuf = new_timed_buffer(&"World", gst::SECOND, 1.into());
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let expected: [(gst::ClockTime, gst::ClockTime, [u8; 2usize]); 10] = [
let expected: [(gst::ClockTime, gst::ClockTime, [u8; 2usize]); 12] = [
(1_000_000_000.into(), 33_333_333.into(), [0x94, 0x2c]), /* erase_display_memory */
(1_033_333_333.into(), 33_333_334.into(), [0x94, 0x2c]), /* control doubled */
(1_066_666_667.into(), 33_333_333.into(), [0x94, 0x25]), /* roll_up_2 */
(1_100_000_000.into(), 33_333_333.into(), [0x94, 0x25]), /* control doubled */
(1_133_333_333.into(), 33_333_334.into(), [0xc8, 0xe5]), /* H e */
(1_166_666_667.into(), 33_333_333.into(), [0xec, 0xec]), /* l l */
(1_200_000_000.into(), 33_333_333.into(), [0xef, 0x80]), /* o, nil */
(1_133_333_333.into(), 33_333_334.into(), [0x94, 0xe0]), /* preamble */
(1_166_666_667.into(), 33_333_333.into(), [0x94, 0xe0]), /* control doubled */
(1_200_000_000.into(), 33_333_333.into(), [0xc8, 0xe5]), /* H e */
(1_233_333_333.into(), 33_333_334.into(), [0xec, 0xec]), /* l l */
(1_266_666_667.into(), 33_333_333.into(), [0xef, 0x80]), /* o, nil */
(2_000_000_000.into(), 0.into(), [0x20, 0x57]), /* SPACE, W */
(2_000_000_000.into(), 0.into(), [0xef, 0xf2]), /* o, r */
(2_000_000_000.into(), 0.into(), [0xec, 0x64]), /* l, d */
@ -355,7 +357,7 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
let expected_gaps: [(gst::ClockTime, gst::ClockTime); 2] = [
(0.into(), 1_000_000_000.into()),
(1_233_333_333.into(), 766_666_667.into()),
(1_300_000_000.into(), 700_000_000.into()),
];
for e in &expected_gaps {