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).div_ceil(48) * 128,
28        VideoFormat::Uyvy => {
29            // round up width to the next multiple of 4
30            (width as usize * 2).next_multiple_of(4)
31        }
32        _ => unreachable!(),
33    }
34}