From e8152228fe0bc7e5eeb2811f99d8a78f4982b2e8 Mon Sep 17 00:00:00 2001 From: xy Date: Mon, 9 Jul 2012 22:37:31 +0800 Subject: [PATCH] Deal with head/tail non-aligned part (Nv12/YV12 luma) --- src/subpic/MemSubPic.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/subpic/MemSubPic.cpp b/src/subpic/MemSubPic.cpp index c396eaf..9b4d9da 100644 --- a/src/subpic/MemSubPic.cpp +++ b/src/subpic/MemSubPic.cpp @@ -1165,17 +1165,31 @@ void CMemSubPic::AlphaBltYv12Luma(byte* dst, int dst_pitch, int w, int h, const byte* sub, const byte* alpha, int sub_pitch) { - if( ((reinterpret_cast(alpha) | reinterpret_cast(sub) | static_cast(sub_pitch) | - reinterpret_cast(dst) | static_cast(dst_pitch) ) & 15 )==0 ) + if( ( + ((reinterpret_cast(alpha) ^ reinterpret_cast(sub)) + |(reinterpret_cast(alpha) ^ reinterpret_cast(dst)) + | static_cast(sub_pitch) + | static_cast(dst_pitch) ) & 15 )==0 + && w > 32) { + int head = (16 - (reinterpret_cast(alpha)&15))&15; + int tail = (w-head) & 15; + int w1 = w - head - tail; for(int i=0; i(s2)&15) != 0; s2++, sa++, d2++) + { + if(sa[0] < 0xff) + { + d2[0] = ((d2[0]*sa[0])>>8) + s2[0]; + } + } for(; s2 < s2end_mod16; s2+=16, sa+=16, d2+=16) { pix_alpha_blend_yv12_luma_sse2(d2, sa, s2); @@ -1195,7 +1209,6 @@ void CMemSubPic::AlphaBltYv12Luma(byte* dst, int dst_pitch, { const BYTE* sa = alpha; const BYTE* s2 = sub; - const BYTE* s2end_mod16 = s2 + (w&~15); const BYTE* s2end = s2 + w; BYTE* d2 = dst; for(; s2 < s2end; s2+=1, sa+=1, d2+=1) -- 2.11.4.GIT