diff --git a/src/util/format/pixel.rs b/src/util/format/pixel.rs index d5ad96c..79bbd43 100644 --- a/src/util/format/pixel.rs +++ b/src/util/format/pixel.rs @@ -299,13 +299,10 @@ unsafe impl Sync for Descriptor {} impl Pixel { pub fn descriptor(self) -> Option { - let ptr = unsafe { av_pix_fmt_desc_get(self.into()) }; + unsafe { + let ptr = av_pix_fmt_desc_get(self.into()); - if ptr.is_null() { - None - } - else { - Some(Descriptor { ptr }) + ptr.as_ref().map(|ptr| Descriptor { ptr }) } } } diff --git a/src/util/frame/video.rs b/src/util/frame/video.rs index c202573..a23757d 100644 --- a/src/util/frame/video.rs +++ b/src/util/frame/video.rs @@ -256,12 +256,11 @@ impl Video { return self.height(); } - match self.format().descriptor() { - None => self.height(), - Some(desc) => { - let s = desc.log2_chroma_h(); - (self.height() + (1 << s) - 1) >> s - } + if let Some(desc) = self.format().descriptor() { + let s = desc.log2_chroma_h(); + (self.height() + (1 << s) - 1) >> s + } else { + self.height() } }