use ffmpeg_next::{self as ffmpeg, ffi};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CudaFrameFormat {
Nv12,
Bgra,
}
impl CudaFrameFormat {
pub(crate) fn sw_format(self) -> ffi::AVPixelFormat {
match self {
Self::Nv12 => ffi::AVPixelFormat::AV_PIX_FMT_NV12,
Self::Bgra => ffi::AVPixelFormat::AV_PIX_FMT_BGRA,
}
}
pub(crate) fn pixel(self) -> ffmpeg::format::Pixel {
match self {
Self::Nv12 => ffmpeg::format::Pixel::NV12,
Self::Bgra => ffmpeg::format::Pixel::BGRA,
}
}
pub(crate) fn from_sw_format(format: ffi::AVPixelFormat) -> Option<Self> {
match format {
ffi::AVPixelFormat::AV_PIX_FMT_NV12 => Some(Self::Nv12),
ffi::AVPixelFormat::AV_PIX_FMT_BGRA => Some(Self::Bgra),
_ => None,
}
}
}