nokhwa-iter helper crate

This commit is contained in:
l1npengtul
2025-09-12 20:01:01 +09:00
parent 97048c2d49
commit f6594f7852
41 changed files with 613 additions and 21 deletions
+4 -2
View File
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::frame_format::FrameFormat;
use crate::frame_format::{CustomFrameFormat, FrameFormat};
use std::fmt::Debug;
use thiserror::Error;
use crate::types::Backends;
@@ -66,6 +66,8 @@ pub enum NokhwaError {
Decoder(String),
#[error("Unsupported FrameFormat: {0}")]
DecoderUnsupportedFrameFormat(FrameFormat),
#[error("The destination frame format from {0} to {1} is not supported.")]
DecoderUnsupportedCustomFrameFormatDestination(CustomFrameFormat, FrameFormat),
#[error("Unsupported pixel configuration {0} with width {1}b.")]
DecoderUnsupportedDestinationPixelFormat(&'static str, u32),
#[error("Bad decoder configuration: {0}")]
@@ -79,7 +81,7 @@ pub enum NokhwaError {
#[error("You need to pass in a destination hint, it is not optional for this decoder.")]
DecoderDestinationHintRequired,
#[error("Decoder already deinitialized. Unusable, please make a new decoder.")]
DecoderAlreadyDeinitialized
DecoderAlreadyDeinitialized,
}
//
// pub enum InitializeError {}
+16 -1
View File
@@ -205,13 +205,22 @@ define_frame_format_with_groups! {
]
}
impl FrameFormat {
pub fn is_custom(&self) -> bool {
if let FrameFormat::Custom(_) = self {
return true
}
false
}
}
impl Display for FrameFormat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
#[derive(Copy, Clone, Debug, Hash, PartialOrd, PartialEq)]
#[derive(Copy, Clone, Debug, Hash, Ord, PartialOrd, Eq, PartialEq)]
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
pub enum CustomFrameFormat {
UUID(u128),
@@ -222,6 +231,12 @@ pub enum CustomFrameFormat {
F64(OrderedFloat<f64>),
}
impl Display for CustomFrameFormat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
#[macro_export]
macro_rules! define_back_and_fourth_frame_format {
($fourcc_type:ty, { $( $frame_format:expr => $value:literal, )* }, $func_u8_8_to_fcc:expr, $func_fcc_to_u8_8:expr, $value_to_fcc_type:expr) => {