#[repr(C)]pub struct PixFormat { /* private fields */ }
Expand description
Single-planar pixel format
Applications set width and height to request an image size, drivers return the closest possible values. In case of planar formats the width and height applies to the largest plane. To avoid ambiguities drivers must return values rounded up to a multiple of the scale factor of any smaller planes. For example when the image format is YUV 4:2:0, width and height must be multiples of two.
For compressed formats that contain the resolution information encoded inside the stream, when fed to a stateful mem2mem decoder, the fields may be zero to rely on the decoder to detect the right values. For more details see Memory-to-Memory Stateful Video Decoder Interface and format descriptions.
For compressed formats on the capture side of a stateful mem2mem encoder, the ields must be zero, since the coded size is expected to be calculated internally by the encoder itself, based on the OUTPUT side. For more details see Memory-to-Memory Stateful Video Encoder Interface and format descriptions.
Implementations§
Source§impl PixFormat
impl PixFormat
Sourcepub fn height(&self) -> u32
pub fn height(&self) -> u32
Image height in pixels
If field is one of Field::Top, Field::Bottom or Field::Alternate then height refers to the number of lines in the field, otherwise it refers to the number of lines in the frame (which is twice the field height for interlaced formats).
Sourcepub fn pixel_format(&self) -> FourCc
pub fn pixel_format(&self) -> FourCc
Pixel format
The pixel format or type of compression, set by the application. This is a little endian four character code. V4L2 defines standard RGB formats in RGB Formats, YUV formats in YUV Formats, and reserved codes in Reserved Image Formats.
Sourcepub fn field(&self) -> Field
pub fn field(&self) -> Field
Field order, from enum Field.
Video images are typically interlaced. Applications can request to capture or output only the top or bottom field, or both fields interlaced or sequentially stored in one buffer or alternating in separate buffers. Drivers return the actual field order selected. For more details on fields see Field Order.
Sourcepub fn bytes_per_line(&self) -> u32
pub fn bytes_per_line(&self) -> u32
Distance in bytes between the leftmost pixels in two adjacent lines.
Both applications and drivers can set bytes_per_line to request padding bytes at the end of each line. Drivers however may ignore the value requested by the application, returning width times bytes per pixel or a larger value required by the hardware. That implies applications can just set this field to zero to get a reasonable default.
Video hardware may access padding bytes, therefore they must reside in accessible memory. Consider cases where padding bytes after the last line of an image cross a system page boundary. Input devices may write padding bytes, the value is undefined. Output devices ignore the contents of padding bytes.
When the image format is planar the bytesperline value applies to the first plane and is divided by the same factor as the width field for the other planes. For example the Cb and Cr planes of a YUV 4:2:0 image have half as many padding bytes following each line as the Y plane. To avoid ambiguities drivers must return a bytesperline value rounded up to a multiple of the scale factor.
For compressed formats the bytesperline value makes no sense. Applications and drivers must set this to 0 in that case.
Sourcepub fn size_image(&self) -> u32
pub fn size_image(&self) -> u32
Image size
Size in bytes of the buffer to hold a complete image, set by the driver. Usually this is bytesperline times height. When the image consists of variable length compressed data this is the number of bytes required by the codec to support the worst-case compression scenario.
The driver will set the value for uncompressed images.
Clients are allowed to set the sizeimage field for variable length compressed data flagged with FmtFlag::Compressed, but the driver may ignore it and set the value itself, or it may modify the provided value based on alignment requirements or minimum/maximum size requirements. If the client wants to leave this to the driver, then it should set sizeimage to 0.
Sourcepub fn color_space(&self) -> ColorSpace
pub fn color_space(&self) -> ColorSpace
Image colorspace, from enum ColorSpace.
This information supplements the pixelformat and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific colorspace for the captured image data. If the driver cannot handle requested conversion, it will return another supported colorspace. The driver indicates that colorspace conversion is supported by setting the flag FmtFlag::CscColorSpace in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Sourcepub fn flags(&self) -> PixFmtFlag
pub fn flags(&self) -> PixFmtFlag
Pixel format flags
Flags set by the application or driver, see PixFmtFlag.
Sourcepub fn quantization(&self) -> Quantization
pub fn quantization(&self) -> Quantization
Quantization range, from enum Quantization.
This information supplements the colorspace and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific quantization range for the captured image data. If the driver cannot handle requested conversion, it will return another supported quantization. The driver indicates that quantization conversion is supported by setting the flag FmtFlag::CscQuantization in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Sourcepub fn xfer_func(&self) -> XferFunc
pub fn xfer_func(&self) -> XferFunc
Transfer function, from enum XferFunc.
This information supplements the colorspace and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific transfer function for the captured image data. If the driver cannot handle requested conversion, it will return another supported transfer function. The driver indicates that XferFunc conversion is supported by setting the flag FmtFlag::CscXferFunc in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Source§impl PixFormat
impl PixFormat
Sourcepub fn set_height(&mut self, val: u32) -> &mut Self
pub fn set_height(&mut self, val: u32) -> &mut Self
Image height in pixels
If field is one of Field::Top, Field::Bottom or Field::Alternate then height refers to the number of lines in the field, otherwise it refers to the number of lines in the frame (which is twice the field height for interlaced formats).
Sourcepub fn set_pixel_format(&mut self, val: FourCc) -> &mut Self
pub fn set_pixel_format(&mut self, val: FourCc) -> &mut Self
Pixel format
The pixel format or type of compression, set by the application. This is a little endian four character code. V4L2 defines standard RGB formats in RGB Formats, YUV formats in YUV Formats, and reserved codes in Reserved Image Formats.
Sourcepub fn set_field(&mut self, val: Field) -> &mut Self
pub fn set_field(&mut self, val: Field) -> &mut Self
Field order, from enum Field.
Video images are typically interlaced. Applications can request to capture or output only the top or bottom field, or both fields interlaced or sequentially stored in one buffer or alternating in separate buffers. Drivers return the actual field order selected. For more details on fields see Field Order.
Sourcepub fn set_bytes_per_line(&mut self, val: u32) -> &mut Self
pub fn set_bytes_per_line(&mut self, val: u32) -> &mut Self
Distance in bytes between the leftmost pixels in two adjacent lines.
Both applications and drivers can set bytes_per_line to request padding bytes at the end of each line. Drivers however may ignore the value requested by the application, returning width times bytes per pixel or a larger value required by the hardware. That implies applications can just set this field to zero to get a reasonable default.
Video hardware may access padding bytes, therefore they must reside in accessible memory. Consider cases where padding bytes after the last line of an image cross a system page boundary. Input devices may write padding bytes, the value is undefined. Output devices ignore the contents of padding bytes.
When the image format is planar the bytesperline value applies to the first plane and is divided by the same factor as the width field for the other planes. For example the Cb and Cr planes of a YUV 4:2:0 image have half as many padding bytes following each line as the Y plane. To avoid ambiguities drivers must return a bytesperline value rounded up to a multiple of the scale factor.
For compressed formats the bytesperline value makes no sense. Applications and drivers must set this to 0 in that case.
Sourcepub fn set_size_image(&mut self, val: u32) -> &mut Self
pub fn set_size_image(&mut self, val: u32) -> &mut Self
Image size
Size in bytes of the buffer to hold a complete image, set by the driver. Usually this is bytesperline times height. When the image consists of variable length compressed data this is the number of bytes required by the codec to support the worst-case compression scenario.
The driver will set the value for uncompressed images.
Clients are allowed to set the sizeimage field for variable length compressed data flagged with FmtFlag::Compressed, but the driver may ignore it and set the value itself, or it may modify the provided value based on alignment requirements or minimum/maximum size requirements. If the client wants to leave this to the driver, then it should set sizeimage to 0.
Sourcepub fn set_color_space(&mut self, val: ColorSpace) -> &mut Self
pub fn set_color_space(&mut self, val: ColorSpace) -> &mut Self
Image colorspace, from enum ColorSpace.
This information supplements the pixelformat and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific colorspace for the captured image data. If the driver cannot handle requested conversion, it will return another supported colorspace. The driver indicates that colorspace conversion is supported by setting the flag FmtFlag::CscColorSpace in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Sourcepub fn set_flags(&mut self, val: PixFmtFlag) -> &mut Self
pub fn set_flags(&mut self, val: PixFmtFlag) -> &mut Self
Pixel format flags
Flags set by the application or driver, see PixFmtFlag.
Sourcepub fn set_quantization(&mut self, val: Quantization) -> &mut Self
pub fn set_quantization(&mut self, val: Quantization) -> &mut Self
Quantization range, from enum Quantization.
This information supplements the colorspace and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific quantization range for the captured image data. If the driver cannot handle requested conversion, it will return another supported quantization. The driver indicates that quantization conversion is supported by setting the flag FmtFlag::CscQuantization in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Sourcepub fn set_xfer_func(&mut self, val: XferFunc) -> &mut Self
pub fn set_xfer_func(&mut self, val: XferFunc) -> &mut Self
Transfer function, from enum XferFunc.
This information supplements the colorspace and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific transfer function for the captured image data. If the driver cannot handle requested conversion, it will return another supported transfer function. The driver indicates that XferFunc conversion is supported by setting the flag FmtFlag::CscXferFunc in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Source§impl PixFormat
impl PixFormat
Sourcepub fn ycbcr_enc(&self) -> Option<YcbcrEncoding>
pub fn ycbcr_enc(&self) -> Option<YcbcrEncoding>
Get Y’CbCr encoding, from enum YcbcrEncoding
This information supplements the colorspace and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific Y’CbCr encoding for the captured image data. If the driver cannot handle requested conversion, it will return another supported encoding. This field is ignored for HSV pixel formats. The driver indicates that YcbcrEncoding conversion is supported by setting the flag FmtFlag::CscYcbcrEnc in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Sourcepub fn set_ycbcr_enc(&mut self, ycbcr_enc: YcbcrEncoding)
pub fn set_ycbcr_enc(&mut self, ycbcr_enc: YcbcrEncoding)
Set Y’CbCr encoding, from enum YcbcrEncoding
Sourcepub fn hsv_enc(&self) -> Option<HsvEncoding>
pub fn hsv_enc(&self) -> Option<HsvEncoding>
Get HSV encoding, from enum HsvEncoding
This information supplements the colorspace and must be set by the driver for capture streams and by the application for output streams, see Colorspaces. If the application sets the flag PixFmtFlag::SetCsc then the application can set this field for a capture stream to request a specific HSV encoding for the captured image data. If the driver cannot handle requested conversion, it will return another supported encoding. This field is ignored for non-HSV pixel formats. The driver indicates that hsv_enc conversion is supported by setting the flag FmtFlag::CscYcbcrEnc in the corresponding struct FmtDesc during enumeration. See FmtFlag.
Sourcepub fn set_hsv_enc(&mut self, hsv_enc: HsvEncoding)
pub fn set_hsv_enc(&mut self, hsv_enc: HsvEncoding)
Set HSV encoding, from enum HsvEncoding