/******************************************************************************** Copyright (C) 2012 Hugh Bailey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ********************************************************************************/ #include "DShowPlugin.h" //now properly takes CPU cache into account - it's just so much faster than it was. void PackPlanar(LPBYTE convertBuffer, LPBYTE lpPlanar, UINT renderCX, UINT renderCY, UINT pitch, UINT startY, UINT endY) { LPBYTE output = convertBuffer; LPBYTE input = lpPlanar; LPBYTE input2 = input+(renderCX*renderCY); LPBYTE input3 = input2+(renderCX*renderCY/4); UINT halfStartY = startY/2; UINT halfX = renderCX/2; UINT halfY = endY/2; for(UINT y=halfStartY; y>1; DWORD size = renderCY*halfWidth*4; DWORD dwDWSize = size>>2; LPDWORD inputDW = (LPDWORD)lp422; LPDWORD inputDWEnd = inputDW+dwDWSize; if(bLeadingY) { while(inputDW < inputDWEnd) { register DWORD dw = *inputDW; output[0] = dw; dw &= 0xFFFFFF00; dw |= BYTE(dw>>16); output[1] = dw; output += 2; inputDW++; } } else { while(inputDW < inputDWEnd) { register DWORD dw = *inputDW; output[0] = dw; dw &= 0xFFFF00FF; dw |= (dw>>16) & 0xFF00; output[1] = dw; output += 2; inputDW++; } } }