/// Returns the byte offset for the given plane.
///
/// Returns an error if the `plane` is unsupported or a valid offset can't be generated from
/// `image_format`.
Returns the byte offset for the given plane.
Returns an error if the `plane` is unsupported or a valid offset can't be generated from
`image_format`.
Returns the byte offset for the given plane . Returns an error if the ` plane ` is unsupported or a valid offset can ' t be generated from ` image_format ` .
pub fn image_format_plane_byte_offset(
    image_format: &fsysmem::ImageFormat2,
    plane: u32,
) -> Result<u32, Error> {
    match plane {
        0 => Ok(0),
        1 => match image_format.pixel_format.type_ {
            fsysmem::PixelFormatType::Nv12
            | fsysmem::PixelFormatType::I420
            | fsysmem::PixelFormatType::Yv12 => {
                Ok(image_format.coded_height * image_format.bytes_per_row)
            }
            _ => Err(anyhow!("Invalid pixelformat for plane 1.")),
        },
        2 => match image_format.pixel_format.type_ {
            fsysmem::PixelFormatType::I420 | fsysmem::PixelFormatType::Yv12 => {
                Ok(image_format.coded_height * image_format.bytes_per_row
                    + image_format.coded_height / 2 * image_format.bytes_per_row / 2)
            }
            _ => Err(anyhow!("Invalid pixelformat for plane 2.")),
        },
        _ => Err(anyhow!("Invalid plane.")),
    }
}
pub fn image_format_plane_byte_offset ( image_format : & fsysmem :: ImageFormat2 , plane : u32 , ) -> Result < u32 , Error > { match plane { 0 => Ok ( 0 ) , 1 => match image_format . pixel_format . type_ { fsysmem :: PixelFormatType :: Nv12 | fsysmem :: PixelFormatType :: I420 | fsysmem :: PixelFormatType :: Yv12 => { Ok ( image_format . coded_height * image_format . bytes_per_row ) } _ => Err ( anyhow ! ( " " ) ) , } , 2 => match image_format . pixel_format . type_ { fsysmem :: PixelFormatType :: I420 | fsysmem :: PixelFormatType :: Yv12 => { Ok ( image_format . coded_height * image_format . bytes_per_row + image_format . coded_height / 2 * image_format . bytes_per_row / 2 ) } _ => Err ( anyhow ! ( " " ) ) , } , _ => Err ( anyhow ! ( " " ) ) , } }
Returns the byte offset for the given plane.
Returns the byte offset for the given plane .
image_format
&fsysmem::ImageFormat2
plane
u32