video: sort VIDEO_FORMATS_ALL

Test also ensures that the formats list returned by
gst_video_formats_raw() is properly sorted when running with feature
1.18.
This commit is contained in:
Guillaume Desmottes 2020-06-05 12:22:08 +02:00
parent ae57524502
commit 1d886727d9
3 changed files with 214 additions and 97 deletions

View file

@ -30,6 +30,9 @@ futures-util = "0.3"
[build-dependencies]
rustdoc-stripper = { version = "0.1", optional = true }
[dev-dependencies]
itertools = "0.9"
[features]
default = []
v1_10 = ["gstreamer/v1_10", "gstreamer-base/v1_10", "gstreamer-video-sys/v1_10"]

View file

@ -24,6 +24,9 @@ extern crate gstreamer_base_sys as gst_base_sys;
extern crate gstreamer_sys as gst_sys;
extern crate gstreamer_video_sys as gst_video_sys;
#[cfg(test)]
extern crate itertools;
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {

View file

@ -29,103 +29,206 @@ pub static VIDEO_FORMATS_ALL: Lazy<Box<[::VideoFormat]>> = Lazy::new(|| unsafe {
#[cfg(not(feature = "v1_18"))]
pub static VIDEO_FORMATS_ALL: Lazy<Box<[::VideoFormat]>> = Lazy::new(|| {
Box::new([
::VideoFormat::I420,
::VideoFormat::Yv12,
::VideoFormat::Yuy2,
::VideoFormat::Uyvy,
::VideoFormat::Ayuv,
::VideoFormat::Vuya,
::VideoFormat::Rgbx,
::VideoFormat::Bgrx,
::VideoFormat::Xrgb,
::VideoFormat::Xbgr,
::VideoFormat::Rgba,
::VideoFormat::Bgra,
::VideoFormat::Argb,
::VideoFormat::Abgr,
::VideoFormat::Rgb,
::VideoFormat::Bgr,
::VideoFormat::Y41b,
::VideoFormat::Y42b,
::VideoFormat::Yvyu,
::VideoFormat::Y444,
::VideoFormat::V210,
::VideoFormat::V216,
::VideoFormat::Y210,
::VideoFormat::Y410,
::VideoFormat::Nv12,
::VideoFormat::Nv21,
::VideoFormat::Gray8,
::VideoFormat::Gray16Be,
::VideoFormat::Gray16Le,
::VideoFormat::V308,
::VideoFormat::Rgb16,
::VideoFormat::Bgr16,
::VideoFormat::Rgb15,
::VideoFormat::Bgr15,
::VideoFormat::Uyvp,
::VideoFormat::A420,
::VideoFormat::Rgb8p,
::VideoFormat::Yuv9,
::VideoFormat::Yvu9,
::VideoFormat::Iyu1,
::VideoFormat::Argb64,
::VideoFormat::Ayuv64,
::VideoFormat::R210,
::VideoFormat::I42010be,
::VideoFormat::I42010le,
::VideoFormat::I42210be,
::VideoFormat::I42210le,
::VideoFormat::Y44410be,
::VideoFormat::Y44410le,
::VideoFormat::Gbr,
::VideoFormat::Gbr10be,
::VideoFormat::Gbr10le,
::VideoFormat::Nv16,
::VideoFormat::Nv24,
::VideoFormat::Nv1264z32,
::VideoFormat::A42010be,
::VideoFormat::A42010le,
::VideoFormat::A42210be,
::VideoFormat::A42210le,
::VideoFormat::A44410be,
::VideoFormat::A44410le,
::VideoFormat::Nv61,
::VideoFormat::P01010be,
::VideoFormat::P01010le,
::VideoFormat::Iyu2,
::VideoFormat::Vyuy,
::VideoFormat::Gbra,
::VideoFormat::Gbra10be,
::VideoFormat::Gbra10le,
::VideoFormat::Bgr10a2Le,
::VideoFormat::Rgb10a2Le,
::VideoFormat::Gbr12be,
::VideoFormat::Gbr12le,
::VideoFormat::Gbra12be,
::VideoFormat::Gbra12le,
::VideoFormat::P012Be,
::VideoFormat::P012Le,
::VideoFormat::I42012be,
::VideoFormat::I42012le,
::VideoFormat::Y212Be,
::VideoFormat::Y212Le,
::VideoFormat::I42212be,
::VideoFormat::I42212le,
::VideoFormat::Y412Be,
::VideoFormat::Y412Le,
::VideoFormat::Y44412be,
::VideoFormat::Y44412le,
::VideoFormat::Gray10Le32,
::VideoFormat::Nv1210le32,
::VideoFormat::Nv1610le32,
::VideoFormat::Nv1210le40,
::VideoFormat::Y44416be,
::VideoFormat::Y44416le,
::VideoFormat::P016Be,
::VideoFormat::P016Le,
])
#[cfg(target_endian = "little")]
{
Box::new([
::VideoFormat::Ayuv64,
::VideoFormat::Argb64,
::VideoFormat::Gbra12le,
::VideoFormat::Gbra12be,
::VideoFormat::Y412Le,
::VideoFormat::Y412Be,
::VideoFormat::A44410le,
::VideoFormat::Gbra10le,
::VideoFormat::A44410be,
::VideoFormat::Gbra10be,
::VideoFormat::A42210le,
::VideoFormat::A42210be,
::VideoFormat::A42010le,
::VideoFormat::A42010be,
::VideoFormat::Rgb10a2Le,
::VideoFormat::Bgr10a2Le,
::VideoFormat::Y410,
::VideoFormat::Gbra,
::VideoFormat::Abgr,
::VideoFormat::Vuya,
::VideoFormat::Bgra,
::VideoFormat::Ayuv,
::VideoFormat::Argb,
::VideoFormat::Rgba,
::VideoFormat::A420,
::VideoFormat::Y44416le,
::VideoFormat::Y44416be,
::VideoFormat::V216,
::VideoFormat::P016Le,
::VideoFormat::P016Be,
::VideoFormat::Y44412le,
::VideoFormat::Gbr12le,
::VideoFormat::Y44412be,
::VideoFormat::Gbr12be,
::VideoFormat::I42212le,
::VideoFormat::I42212be,
::VideoFormat::Y212Le,
::VideoFormat::Y212Be,
::VideoFormat::I42012le,
::VideoFormat::I42012be,
::VideoFormat::P012Le,
::VideoFormat::P012Be,
::VideoFormat::Y44410le,
::VideoFormat::Gbr10le,
::VideoFormat::Y44410be,
::VideoFormat::Gbr10be,
::VideoFormat::R210,
::VideoFormat::I42210le,
::VideoFormat::I42210be,
::VideoFormat::Nv1610le32,
::VideoFormat::Y210,
::VideoFormat::V210,
::VideoFormat::Uyvp,
::VideoFormat::I42010le,
::VideoFormat::I42010be,
::VideoFormat::P01010le,
::VideoFormat::Nv1210le32,
::VideoFormat::Nv1210le40,
::VideoFormat::P01010be,
::VideoFormat::Y444,
::VideoFormat::Gbr,
::VideoFormat::Nv24,
::VideoFormat::Xbgr,
::VideoFormat::Bgrx,
::VideoFormat::Xrgb,
::VideoFormat::Rgbx,
::VideoFormat::Bgr,
::VideoFormat::Iyu2,
::VideoFormat::V308,
::VideoFormat::Rgb,
::VideoFormat::Y42b,
::VideoFormat::Nv61,
::VideoFormat::Nv16,
::VideoFormat::Vyuy,
::VideoFormat::Uyvy,
::VideoFormat::Yvyu,
::VideoFormat::Yuy2,
::VideoFormat::I420,
::VideoFormat::Yv12,
::VideoFormat::Nv21,
::VideoFormat::Nv12,
::VideoFormat::Nv1264z32,
::VideoFormat::Y41b,
::VideoFormat::Iyu1,
::VideoFormat::Yvu9,
::VideoFormat::Yuv9,
::VideoFormat::Rgb16,
::VideoFormat::Bgr16,
::VideoFormat::Rgb15,
::VideoFormat::Bgr15,
::VideoFormat::Rgb8p,
::VideoFormat::Gray16Le,
::VideoFormat::Gray16Be,
::VideoFormat::Gray10Le32,
::VideoFormat::Gray8,
])
}
#[cfg(target_endian = "big")]
{
Box::new([
::VideoFormat::Ayuv64,
::VideoFormat::Argb64,
::VideoFormat::Gbra12be,
::VideoFormat::Gbra12le,
::VideoFormat::Y412Be,
::VideoFormat::Y412Le,
::VideoFormat::A44410be,
::VideoFormat::Gbra10be,
::VideoFormat::A44410le,
::VideoFormat::Gbra10le,
::VideoFormat::A42210be,
::VideoFormat::A42210le,
::VideoFormat::A42010be,
::VideoFormat::A42010le,
::VideoFormat::Y410,
::VideoFormat::Rgb10a2Le,
::VideoFormat::Bgr10a2Le,
::VideoFormat::Gbra,
::VideoFormat::Abgr,
::VideoFormat::Vuya,
::VideoFormat::Bgra,
::VideoFormat::Ayuv,
::VideoFormat::Argb,
::VideoFormat::Rgba,
::VideoFormat::A420,
::VideoFormat::Y44416be,
::VideoFormat::Y44416le,
::VideoFormat::V216,
::VideoFormat::P016Be,
::VideoFormat::P016Le,
::VideoFormat::Y44412be,
::VideoFormat::Gbr12be,
::VideoFormat::Y44412le,
::VideoFormat::Gbr12le,
::VideoFormat::I42212be,
::VideoFormat::I42212le,
::VideoFormat::Y212Be,
::VideoFormat::Y212Le,
::VideoFormat::I42012be,
::VideoFormat::I42012le,
::VideoFormat::P012Be,
::VideoFormat::P012Le,
::VideoFormat::Y44410be,
::VideoFormat::Gbr10be,
::VideoFormat::Y44410le,
::VideoFormat::Gbr10le,
::VideoFormat::R210,
::VideoFormat::I42210be,
::VideoFormat::I42210le,
::VideoFormat::Nv1610le32,
::VideoFormat::Y210,
::VideoFormat::V210,
::VideoFormat::Uyvp,
::VideoFormat::I42010be,
::VideoFormat::I42010le,
::VideoFormat::P01010be,
::VideoFormat::P01010le,
::VideoFormat::Nv1210le32,
::VideoFormat::Nv1210le40,
::VideoFormat::Y444,
::VideoFormat::Gbr,
::VideoFormat::Nv24,
::VideoFormat::Xbgr,
::VideoFormat::Bgrx,
::VideoFormat::Xrgb,
::VideoFormat::Rgbx,
::VideoFormat::Bgr,
::VideoFormat::Iyu2,
::VideoFormat::V308,
::VideoFormat::Rgb,
::VideoFormat::Y42b,
::VideoFormat::Nv61,
::VideoFormat::Nv16,
::VideoFormat::Vyuy,
::VideoFormat::Uyvy,
::VideoFormat::Yvyu,
::VideoFormat::Yuy2,
::VideoFormat::I420,
::VideoFormat::Yv12,
::VideoFormat::Nv21,
::VideoFormat::Nv12,
::VideoFormat::Nv1264z32,
::VideoFormat::Y41b,
::VideoFormat::Iyu1,
::VideoFormat::Yvu9,
::VideoFormat::Yuv9,
::VideoFormat::Rgb16,
::VideoFormat::Bgr16,
::VideoFormat::Rgb15,
::VideoFormat::Bgr15,
::VideoFormat::Rgb8p,
::VideoFormat::Gray16Be,
::VideoFormat::Gray16Le,
::VideoFormat::Gray10Le32,
::VideoFormat::Gray8,
])
}
});
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
@ -329,6 +432,7 @@ where
#[cfg(test)]
mod tests {
use gst;
use itertools::Itertools;
#[test]
fn test_display() {
@ -395,5 +499,12 @@ mod tests {
> ::VideoFormatInfo::from_format(::VideoFormat::Nv12)
);
assert!(::VideoFormat::I420 > ::VideoFormat::Yv12);
let sorted: Vec<::VideoFormat> = ::VideoFormat::iter_raw().sorted().rev().collect();
// FIXME: use is_sorted_by() once API is in stable
assert_eq!(
sorted,
::VideoFormat::iter_raw().collect::<Vec<::VideoFormat>>()
);
}
}