diff --git a/gstreamer-video/src/video_format_info.rs b/gstreamer-video/src/video_format_info.rs index d3d02a52d..2521e1860 100644 --- a/gstreamer-video/src/video_format_info.rs +++ b/gstreamer-video/src/video_format_info.rs @@ -5,7 +5,7 @@ use std::ffi::CStr; use std::fmt; use std::str; -use glib::translate::{from_glib, IntoGlib}; +use glib::translate::{from_glib, IntoGlib, ToGlibPtr}; pub struct VideoFormatInfo(&'static ffi::GstVideoFormatInfo); @@ -288,6 +288,21 @@ impl VideoFormatInfo { ); } } + + #[doc(alias = "gst_video_color_range_offsets")] + pub fn range_offsets(&self, range: crate::VideoColorRange) -> ([i32; 4], [i32; 4]) { + let mut offset = [0i32; 4]; + let mut scale = [0i32; 4]; + unsafe { + ffi::gst_video_color_range_offsets( + range.into_glib(), + self.to_glib_none().0, + &mut offset, + &mut scale, + ) + } + (offset, scale) + } } unsafe impl Sync for VideoFormatInfo {} diff --git a/gstreamer-video/src/video_info.rs b/gstreamer-video/src/video_info.rs index 10d1ae2c5..5b4f93ad4 100644 --- a/gstreamer-video/src/video_info.rs +++ b/gstreamer-video/src/video_info.rs @@ -1,9 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::translate::{ - from_glib, from_glib_full, from_glib_none, FromGlib, FromGlibPtrFull, IntoGlib, ToGlibPtr, - ToGlibPtrMut, -}; +use glib::translate::*; use gst::prelude::*; use std::fmt; @@ -843,6 +840,11 @@ impl VideoInfo { Ok(plane_size) } + + #[doc(alias = "gst_video_color_range_offsets")] + pub fn range_offsets(&self, range: crate::VideoColorRange) -> ([i32; 4], [i32; 4]) { + self.format_info().range_offsets(range) + } } impl Clone for VideoInfo {