video: Implement gst_video_color_range_offsets for Video(Format)Info

This commit is contained in:
Marijn Suijten 2021-04-30 11:40:39 +02:00
parent 7cb151dd46
commit 579ac6c4e4
2 changed files with 22 additions and 5 deletions

View file

@ -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 {}

View file

@ -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 {