From 6b4ff44201f830cf313d6a40f0def87f7efebf78 Mon Sep 17 00:00:00 2001 From: wangsijie Date: Mon, 9 Jul 2018 23:09:00 +0800 Subject: [PATCH 1/2] fix: get context failed Change-Id: Ifcfe2e5244211c4dce5f04bc0ca6cf250f1aac90 --- src/software/scaling/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, From 3925a760465561db04ded1bb4702caa5da34be0a Mon Sep 17 00:00:00 2001 From: wangsijie Date: Thu, 19 Jul 2018 00:35:53 +0800 Subject: [PATCH 2/2] Fix: get right align when get av_frame_get_buffer Change-Id: I55e1fdf06a95ce969388ffba1cb2378b50333508 --- src/util/frame/video.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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); } }