mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-04-15 04:14:07 +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/1674>
This commit is contained in:
parent
60901e27d1
commit
a46d7d18b9
1 changed files with 28 additions and 5 deletions
|
@ -307,7 +307,7 @@ pub struct VideoInfoBuilder<'a> {
|
|||
size: Option<usize>,
|
||||
views: Option<u32>,
|
||||
chroma_site: Option<crate::VideoChromaSite>,
|
||||
colorimetry: Option<&'a crate::VideoColorimetry>,
|
||||
colorimetry: Option<crate::VideoColorimetry>,
|
||||
par: Option<gst::Fraction>,
|
||||
fps: Option<gst::Fraction>,
|
||||
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 {
|
||||
colorimetry: Some(colorimetry),
|
||||
colorimetry: Some(*colorimetry),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn colorimetry_if(
|
||||
self,
|
||||
colorimetry: &'a crate::VideoColorimetry,
|
||||
colorimetry: &crate::VideoColorimetry,
|
||||
predicate: bool,
|
||||
) -> VideoInfoBuilder<'a> {
|
||||
if predicate {
|
||||
|
@ -580,7 +580,7 @@ impl<'a> VideoInfoBuilder<'a> {
|
|||
|
||||
pub fn colorimetry_if_some(
|
||||
self,
|
||||
colorimetry: Option<&'a crate::VideoColorimetry>,
|
||||
colorimetry: Option<&crate::VideoColorimetry>,
|
||||
) -> VideoInfoBuilder<'a> {
|
||||
if let Some(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]
|
||||
pub fn is_valid(&self) -> bool {
|
||||
!self.0.finfo.is_null() && self.0.width > 0 && self.0.height > 0 && self.0.size > 0
|
||||
|
|
Loading…
Reference in a new issue