/**************************************************************************** * * Module Title : newLoopTest_asm.c * * Description : Codec specific functions * * AUTHOR : Yaowu Xu * ***************************************************************************** * Revision History * * 1.02 YWX 03-Nov-00 Changed confusing variable name * 1.01 YWX 02-Nov-00 Added the set of functions * 1.00 YWX 19-Oct-00 configuration baseline ***************************************************************************** */ /**************************************************************************** * Header Frames ***************************************************************************** */ #define STRICT /* Strict type checking. */ #include "codec_common.h" #include /**************************************************************************** * Module constants. ***************************************************************************** */ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /**************************************************************************** * Explicit Imports ***************************************************************************** */ extern void SatUnsigned8( UINT8 * ResultPtr, INT16 * DataBlock, UINT32 ResultLineStep, UINT32 DataLineStep ); /**************************************************************************** * Exported Global Variables ***************************************************************************** */ /**************************************************************************** * Exported Functions ***************************************************************************** */ /**************************************************************************** * Module Statics ***************************************************************************** */ /**************************************************************************** * Foreward References ***************************************************************************** */ /**************************************************************************** * * ROUTINE : ClearMmx() * * * INPUTS : None * * OUTPUTS : * * RETURNS : * * * FUNCTION : Clears down the MMX state * * SPECIAL NOTES : None. * * * ERRORS : None. * ****************************************************************************/ void ClearMmx(void) { __asm { emms ; Clear the MMX state. } } /**************************************************************************** * * ROUTINE : CopyBlockUsingMMX * * INPUTS : None * * OUTPUTS : None * * RETURNS : None. * * FUNCTION : Copies a block from source to destination * * SPECIAL NOTES : None. * * * ERRORS : None. * ****************************************************************************/ void CopyBlockMMX(unsigned char *src, unsigned char *dest, unsigned int srcstride) { unsigned char *s = src; unsigned char *d = dest; unsigned int stride = srcstride; // recon copy _asm { mov ecx, [stride] mov eax, [s] mov ebx, [d] lea edx, [ecx + ecx * 2] movq mm0, [eax] movq mm1, [eax + ecx] movq mm2, [eax + ecx*2] movq mm3, [eax + edx] lea eax, [eax + ecx*4] movq [ebx], mm0 movq [ebx + ecx], mm1 movq [ebx + ecx*2], mm2 movq [ebx + edx], mm3 lea ebx, [ebx + ecx * 4] movq mm0, [eax] movq mm1, [eax + ecx] movq mm2, [eax + ecx*2] movq mm3, [eax + edx] movq [ebx], mm0 movq [ebx + ecx], mm1 movq [ebx + ecx*2], mm2 movq [ebx + edx], mm3 } } /**************************************************************************** * * ROUTINE : CopyBlockUsingMMX * * INPUTS : None * * OUTPUTS : None * * RETURNS : None. * * FUNCTION : Copies a block from source to destination * * SPECIAL NOTES : None. * * * ERRORS : None. * ****************************************************************************/ void Copy12x12_MMX( const unsigned char *src, unsigned char *dest, unsigned int srcstride, unsigned int deststride) { int j=0; do { ((UINT32*)dest)[0] = ((UINT32*)src)[0]; ((UINT32*)dest)[1] = ((UINT32*)src)[1]; ((UINT32*)dest)[2] = ((UINT32*)src)[2]; src+=srcstride; dest+=deststride; } while(++j<12); } /**************************************************************************** /**************************************************************************** * * ROUTINE : AverageBlock_MMX * * INPUTS : Two block data to be averaged * * OUTPUTS : block with the average values * * RETURNS : None. * * FUNCTION : Do pixel averages on two reference blocks * * SPECIAL NOTES : This functions has a mmx version in newlooptest_asm.c * * ERRORS : None. * ****************************************************************************/ void AverageBlock_MMX( UINT8 *ReconPtr1, UINT8 *ReconPtr2, UINT16 *ReconRefPtr, UINT32 ReconPixelsPerLine) { __asm { mov esi, ReconPtr1 mov eax, ReconPtr2 mov edi, ReconRefPtr mov ecx, BLOCK_HEIGHT_WIDTH mov edx, ReconPixelsPerLine pxor mm7, mm7 AverageBlock_Loop: movq mm0, [esi] movq mm1, [eax] movq mm2, mm0 punpcklbw mm0, mm7 movq mm3, mm1 punpcklbw mm1, mm7 paddw mm0, mm1 punpckhbw mm2, mm7 psraw mm0, 1 punpckhbw mm3, mm7 paddw mm2, mm3 movq [edi], mm0 psraw mm2, 1 add esi, edx add eax, edx add edi, 16 movq [edi-8], mm2 dec ecx jnz AverageBlock_Loop } /* UINT32 i; // For each block row for ( i=0; i>1; ReconRefPtr[1] = (INT16)((INT32)(ReconPtr1[1])+ ((INT32)ReconPtr2[1]))>>1; ReconRefPtr[2] = (INT16)((INT32)(ReconPtr1[2])+ ((INT32)ReconPtr2[2]))>>1; ReconRefPtr[3] = (INT16)((INT32)(ReconPtr1[3])+ ((INT32)ReconPtr2[3]))>>1; ReconRefPtr[4] = (INT16)((INT32)(ReconPtr1[4])+ ((INT32)ReconPtr2[4]))>>1; ReconRefPtr[5] = (INT16)((INT32)(ReconPtr1[5])+ ((INT32)ReconPtr2[5]))>>1; ReconRefPtr[6] = (INT16)((INT32)(ReconPtr1[6])+ ((INT32)ReconPtr2[6]))>>1; ReconRefPtr[7] = (INT16)((INT32)(ReconPtr1[7])+ ((INT32)ReconPtr2[7]))>>1; // Start next row ReconPtr1 += ReconPixelsPerLine; ReconPtr2 += ReconPixelsPerLine; ReconRefPtr += BLOCK_HEIGHT_WIDTH; } */ } /**************************************************************************** * * ROUTINE : UnpackBlock * * INPUTS : Block of char data to be converted to short * * OUTPUTS : converted output * * RETURNS : None. * * FUNCTION : Converted char block data to short * * SPECIAL NOTES : This functions has a mmx version in newlooptest_asm.c * * ERRORS : None. * ****************************************************************************/ void UnpackBlock_MMX( UINT8 *ReconPtr, INT16 *ReconRefPtr, UINT32 ReconPixelsPerLine) { __asm { mov esi, ReconPtr mov edi, ReconRefPtr mov ecx, BLOCK_HEIGHT_WIDTH mov edx, ReconPixelsPerLine pxor mm7, mm7 UnpackBlock_Loop: movq mm0, [esi] movq mm2, mm0 punpcklbw mm0, mm7 movq [edi], mm0 punpckhbw mm2, mm7 add esi, edx movq [edi+8], mm2 add edi, 16 dec ecx jnz UnpackBlock_Loop } /* UINT32 i; // For each block row for ( i=0; i