gstreamer_video/
video_vbi.rs

1use crate::VideoFormat;
2pub(super) const VBI_HD_MIN_PIXEL_WIDTH: u32 = 1280;
3
4// rustdoc-stripper-ignore-next
5/// Video Vertical Blanking Interval related Errors.
6#[derive(thiserror::Error, Clone, Copy, Debug, Eq, PartialEq)]
7pub enum VideoVBIError {
8    #[error("Format and/or pixel_width is not supported")]
9    Unsupported,
10
11    #[error("Not enough space left in the current line")]
12    NotEnoughSpace,
13
14    #[error("Not enough data left in the current line")]
15    NotEnoughData,
16
17    #[error("Insufficient line buffer length {found}. Expected: {expected}")]
18    InsufficientLineBufLen { found: usize, expected: usize },
19}
20
21// rustdoc-stripper-ignore-next
22/// Returns the buffer length needed to store the line.
23pub(super) fn line_buffer_len(format: VideoFormat, width: u32) -> usize {
24    skip_assert_initialized!();
25    // Taken from gst-plugins-base/gst-libs/gst/video/video-info.c:fill_planes
26    match format {
27        VideoFormat::V210 => ((width as usize + 47) / 48) * 128,
28        VideoFormat::Uyvy => {
29            // round up width to the next multiple of 4
30            // FIXME: {integer}::next_multiple_of was stabilised in rustc 1.73.0
31            ((width as usize * 2) + 3) & !3
32        }
33        _ => unreachable!(),
34    }
35}