use crate::model::shape::CaptionDirection;
pub(super) fn stored_gap(info: &[u8], direction: CaptionDirection) -> i16 {
if !matches!(direction, CaptionDirection::Top | CaptionDirection::Bottom) {
return 0;
}
let Some(frame) = info.get(48..50) else {
return 0;
};
let Some(content) = info.get(50..52) else {
return 0;
};
let frame = u32::from(u16::from_le_bytes([frame[0], frame[1]])) * 4;
let content = u32::from(u16::from_le_bytes([content[0], content[1]])) * 4;
frame.saturating_sub(content).min(i16::MAX as u32) as i16
}