mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-03 10:23:48 +00:00
video-info: Add API for creating a builder from an existing VideoInfo
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1666>
This commit is contained in:
parent
bd4debd9a4
commit
31d99a91c6
1 changed files with 28 additions and 5 deletions
|
@ -307,7 +307,7 @@ pub struct VideoInfoBuilder<'a> {
|
||||||
size: Option<usize>,
|
size: Option<usize>,
|
||||||
views: Option<u32>,
|
views: Option<u32>,
|
||||||
chroma_site: Option<crate::VideoChromaSite>,
|
chroma_site: Option<crate::VideoChromaSite>,
|
||||||
colorimetry: Option<&'a crate::VideoColorimetry>,
|
colorimetry: Option<crate::VideoColorimetry>,
|
||||||
par: Option<gst::Fraction>,
|
par: Option<gst::Fraction>,
|
||||||
fps: Option<gst::Fraction>,
|
fps: Option<gst::Fraction>,
|
||||||
offset: Option<&'a [usize]>,
|
offset: Option<&'a [usize]>,
|
||||||
|
@ -559,16 +559,16 @@ impl<'a> VideoInfoBuilder<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn colorimetry(self, colorimetry: &'a crate::VideoColorimetry) -> VideoInfoBuilder<'a> {
|
pub fn colorimetry(self, colorimetry: &crate::VideoColorimetry) -> VideoInfoBuilder<'a> {
|
||||||
Self {
|
Self {
|
||||||
colorimetry: Some(colorimetry),
|
colorimetry: Some(*colorimetry),
|
||||||
..self
|
..self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn colorimetry_if(
|
pub fn colorimetry_if(
|
||||||
self,
|
self,
|
||||||
colorimetry: &'a crate::VideoColorimetry,
|
colorimetry: &crate::VideoColorimetry,
|
||||||
predicate: bool,
|
predicate: bool,
|
||||||
) -> VideoInfoBuilder<'a> {
|
) -> VideoInfoBuilder<'a> {
|
||||||
if predicate {
|
if predicate {
|
||||||
|
@ -580,7 +580,7 @@ impl<'a> VideoInfoBuilder<'a> {
|
||||||
|
|
||||||
pub fn colorimetry_if_some(
|
pub fn colorimetry_if_some(
|
||||||
self,
|
self,
|
||||||
colorimetry: Option<&'a crate::VideoColorimetry>,
|
colorimetry: Option<&crate::VideoColorimetry>,
|
||||||
) -> VideoInfoBuilder<'a> {
|
) -> VideoInfoBuilder<'a> {
|
||||||
if let Some(colorimetry) = colorimetry {
|
if let Some(colorimetry) = colorimetry {
|
||||||
self.colorimetry(colorimetry)
|
self.colorimetry(colorimetry)
|
||||||
|
@ -790,6 +790,29 @@ impl VideoInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn builder_from_info(info: &VideoInfo) -> VideoInfoBuilder<'_> {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
|
VideoInfoBuilder {
|
||||||
|
format: info.format(),
|
||||||
|
width: info.width(),
|
||||||
|
height: info.height(),
|
||||||
|
interlace_mode: Some(info.interlace_mode()),
|
||||||
|
flags: Some(info.flags()),
|
||||||
|
size: Some(info.size()),
|
||||||
|
views: Some(info.views()),
|
||||||
|
chroma_site: Some(info.chroma_site()),
|
||||||
|
colorimetry: Some(info.colorimetry()),
|
||||||
|
par: Some(info.par()),
|
||||||
|
fps: Some(info.fps()),
|
||||||
|
offset: Some(info.offset()),
|
||||||
|
stride: Some(info.stride()),
|
||||||
|
multiview_mode: Some(info.multiview_mode()),
|
||||||
|
multiview_flags: Some(info.multiview_flags()),
|
||||||
|
field_order: Some(info.field_order()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_valid(&self) -> bool {
|
pub fn is_valid(&self) -> bool {
|
||||||
!self.0.finfo.is_null() && self.0.width > 0 && self.0.height > 0 && self.0.size > 0
|
!self.0.finfo.is_null() && self.0.width > 0 && self.0.height > 0 && self.0.size > 0
|
||||||
|
|
Loading…
Reference in a new issue