diff --git a/src/software/scaling/context.rs b/src/software/scaling/context.rs index e0aa4d74..4c73280d 100644 --- a/src/software/scaling/context.rs +++ b/src/software/scaling/context.rs @@ -56,7 +56,7 @@ impl Context { ptr::null_mut(), ); - if ptr.is_null() { + if !ptr.is_null() { Ok(Context { ptr: ptr, diff --git a/src/util/frame/video.rs b/src/util/frame/video.rs index d62b41c8..8299bdc8 100644 --- a/src/util/frame/video.rs +++ b/src/util/frame/video.rs @@ -26,7 +26,15 @@ impl Video { self.set_width(width); self.set_height(height); - av_frame_get_buffer(self.as_mut_ptr(), 32); + const INIT_ALIGN: usize = 32; + let mut align = INIT_ALIGN; + + let width = width as usize; + while width & (align-1) != 0 { + align = align >> 1; + } + + av_frame_get_buffer(self.as_mut_ptr(), align as c_int); } }