shithub: openh264

Download patch

ref: 4633626d69220ed0a1776fbe510454a94279f80e
parent: 3cf52554f771fcdf247904fba9714270c7f9e6c1
author: Martin Storsjö <[email protected]>
date: Fri Mar 14 18:57:24 EDT 2014

Remove XMMREG_PROTECT

This isn't necessary any longer, when all the assembly routines
take care of restoring registers as necessary.

--- a/codec/common/cpu.cpp
+++ b/codec/common/cpu.cpp
@@ -207,9 +207,6 @@
   }
 }
 
-void WelsXmmRegEmptyOp(void * pSrc) {
-}
-
 #elif defined(HAVE_NEON) //For supporting both android platform and iOS platform
 #if defined(ANDROID_NDK)
 uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors)
--- a/codec/common/cpu.h
+++ b/codec/common/cpu.h
@@ -67,60 +67,14 @@
  */
 void     WelsCPURestore (const uint32_t kuiCPU);
 
-#ifdef  WIN64
-void     WelsXmmRegStore(void * src);
-void     WelsXmmRegLoad(void * src);
-#endif
-
 #else
 #define WelsEmms()
 #endif
 
-void     WelsXmmRegEmptyOp(void * pSrc);
-
 uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
 
 #if defined(__cplusplus)
 }
 #endif//__cplusplus
-
-typedef  void (*WelsXmmRegProtectFunc)(void * pSrc);
-
-
-#if defined(WIN64) && defined(X86_ASM)
-#define   XMMREG_PROTECT_DECLARE(name) \
-  WelsXmmRegProtectFunc name##load;\
-  WelsXmmRegProtectFunc name##store;\
-  uint8_t               name##Buffer[160];
-
-#define   XMMREG_PROTECT_INIT(name) \
-  { \
-    uint32_t uiCpuFlag = WelsCPUFeatureDetect(NULL);\
-    if( uiCpuFlag & WELS_CPU_SSE2 ){\
-      name##load = WelsXmmRegLoad;\
-      name##store = WelsXmmRegStore; \
-    } else { \
-      name##load = WelsXmmRegEmptyOp; \
-      name##store = WelsXmmRegEmptyOp; \
-    } \
-  }
-
-#define   XMMREG_PROTECT_UNINIT(name) \
-
-#define   XMMREG_PROTECT_STORE(name) \
-  name##store(name##Buffer);
-
-#define   XMMREG_PROTECT_LOAD(name) \
-  name##load(name##Buffer);
-
-#else
-
-#define   XMMREG_PROTECT_DECLARE(name)
-#define   XMMREG_PROTECT_INIT(name)
-#define   XMMREG_PROTECT_UNINIT(name)
-#define   XMMREG_PROTECT_STORE(name)
-#define   XMMREG_PROTECT_LOAD(name)
-
-#endif
 
 #endif//WELS_CPU_DETECTION_H__
--- a/codec/common/cpuid.asm
+++ b/codec/common/cpuid.asm
@@ -220,44 +220,3 @@
 	emms	; empty mmx technology states
 	ret
 
-
-%ifdef     WIN64
-
-WELS_EXTERN WelsXmmRegStore
-ALIGN 16
-;******************************************************************************************
-;   void WelsXmmRegStore(void *src)
-;******************************************************************************************
-WelsXmmRegStore:
-  movdqu [rcx], xmm6
-  movdqu [rcx+16], xmm7
-  movdqu [rcx+32], xmm8
-  movdqu [rcx+48], xmm9
-  movdqu [rcx+64], xmm10
-  movdqu [rcx+80], xmm11
-  movdqu [rcx+96], xmm12
-  movdqu [rcx+112], xmm13
-  movdqu [rcx+128], xmm14
-  movdqu [rcx+144], xmm15
-  ret
-
-WELS_EXTERN WelsXmmRegLoad
-ALIGN 16
-;******************************************************************************************
-;   void WelsXmmRegLoad(void *src)
-;******************************************************************************************
-WelsXmmRegLoad:
-  movdqu xmm6, [rcx]
-  movdqu xmm7, [rcx+16]
-  movdqu xmm8, [rcx+32]
-  movdqu xmm9, [rcx+48]
-  movdqu xmm10, [rcx+64]
-  movdqu xmm11, [rcx+80]
-  movdqu xmm12, [rcx+96]
-  movdqu xmm13, [rcx+112]
-  movdqu xmm14, [rcx+128]
-  movdqu xmm15, [rcx+144]
-  ret
-%endif
-
-
--- a/codec/decoder/plus/inc/welsDecoderExt.h
+++ b/codec/decoder/plus/inc/welsDecoderExt.h
@@ -104,8 +104,6 @@
 void InitDecoder (void);
 void UninitDecoder (void);
 
-XMMREG_PROTECT_DECLARE(CWelsH264Decoder);
-
 #ifdef OUTPUT_BIT_STREAM
 WelsFileHandle* m_pFBS;
 WelsFileHandle* m_pFBSSize;
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -101,7 +101,6 @@
   m_pTrace = CreateWelsTrace (Wels_Trace_Type);
 
   IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
-  XMMREG_PROTECT_INIT(CWelsH264Decoder);
 
 #ifdef OUTPUT_BIT_STREAM
   SWelsTime sCurTime;
@@ -167,7 +166,6 @@
   IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
 
   UninitDecoder();
-  XMMREG_PROTECT_UNINIT(CWelsH264Decoder);
 
 #ifdef OUTPUT_BIT_STREAM
   if (m_pFBS) {
@@ -361,10 +359,8 @@
 
   m_pDecContext->iFeedbackTidInAu             = -1; //initialize
 
-  XMMREG_PROTECT_STORE(CWelsH264Decoder);
   WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst,
                 pDstInfo); //iErrorCode has been modified in this function
-  XMMREG_PROTECT_LOAD(CWelsH264Decoder);
 
   if (m_pDecContext->iErrorCode) {
     ENalUnitType eNalType =
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -132,8 +132,6 @@
   void    InitEncoder (void);
   int32_t RawData2SrcPic (const uint8_t* pSrc);
   void    DumpSrcPicture (const uint8_t* pSrc);
-
-  XMMREG_PROTECT_DECLARE(CWelsH264SVCEncoder);
 };
 }
 #endif // !defined(AFX_WELSH264ENCODER_H__D9FAA1D1_5403_47E1_8E27_78F11EE65F02__INCLUDED_)
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -138,7 +138,6 @@
 #endif//OUTPUT_BIT_STREAM
 
   InitEncoder();
-  XMMREG_PROTECT_INIT(CWelsH264SVCEncoder);
 }
 
 CWelsH264SVCEncoder::~CWelsH264SVCEncoder() {
@@ -172,7 +171,6 @@
 #endif//OUTPUT_BIT_STREAM
 
   Uninitialize();
-  XMMREG_PROTECT_UNINIT(CWelsH264SVCEncoder);
 }
 
 void CWelsH264SVCEncoder::InitEncoder (void) {
@@ -535,9 +533,7 @@
 
   int32_t iFrameTypeReturned = 0;
   int32_t iFrameType = videoFrameTypeInvalid;
-  XMMREG_PROTECT_STORE(CWelsH264SVCEncoder);
   const int32_t kiEncoderReturn = WelsEncoderEncodeExt (m_pEncContext, pBsInfo, pSrcPic);
-  XMMREG_PROTECT_LOAD(CWelsH264SVCEncoder);
 
   switch (kiEncoderReturn) {
   case ENC_RETURN_MEMALLOCERR:
--- a/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp
+++ b/codec/processing/src/adaptivequantization/AdaptiveQuantization.cpp
@@ -49,11 +49,9 @@
   m_pfVar   = NULL;
   WelsMemset (&m_sAdaptiveQuantParam, 0, sizeof (m_sAdaptiveQuantParam));
   WelsInitVarFunc (m_pfVar, m_CPUFlag);
-  XMMREG_PROTECT_INIT(AdaptiveQuantization);
 }
 
 CAdaptiveQuantization::~CAdaptiveQuantization() {
-  XMMREG_PROTECT_UNINIT(AdaptiveQuantization);
 }
 
 EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
@@ -102,7 +100,6 @@
       pRefFrameTmp  = pRefFrameY;
       pCurFrameTmp  = pCurFrameY;
       for (i = 0; i < iMbWidth; i++) {
-        XMMREG_PROTECT_STORE(AdaptiveQuantization);
         iSumDiff =  pVaaCalcResults->pSad8x8[iMbIndex][0];
         iSumDiff += pVaaCalcResults->pSad8x8[iMbIndex][1];
         iSumDiff += pVaaCalcResults->pSad8x8[iMbIndex][2];
@@ -111,7 +108,6 @@
         iSQDiff = pVaaCalcResults->pSsd16x16[iMbIndex];
         uiSum = pVaaCalcResults->pSum16x16[iMbIndex];
         iSQSum = pVaaCalcResults->pSumOfSquare16x16[iMbIndex];
-        XMMREG_PROTECT_LOAD(AdaptiveQuantization);
 
         iSumDiff = iSumDiff >> 8;
         pMotionTexture->uiMotionIndex = (iSQDiff >> 8) - (iSumDiff * iSumDiff);
@@ -134,9 +130,7 @@
       pRefFrameTmp  = pRefFrameY;
       pCurFrameTmp  = pCurFrameY;
       for (i = 0; i < iMbWidth; i++) {
-        XMMREG_PROTECT_STORE(AdaptiveQuantization);
         m_pfVar (pRefFrameTmp, iRefStride, pCurFrameTmp, iCurStride, pMotionTexture);
-        XMMREG_PROTECT_LOAD(AdaptiveQuantization);
         dAverageMotionIndex += pMotionTexture->uiMotionIndex;
         dAverageTextureIndex += pMotionTexture->uiTextureIndex;
         pMotionTexture++;
--- a/codec/processing/src/adaptivequantization/AdaptiveQuantization.h
+++ b/codec/processing/src/adaptivequantization/AdaptiveQuantization.h
@@ -84,7 +84,6 @@
   PVarFunc			                   m_pfVar;
   int32_t                                  m_CPUFlag;
   SAdaptiveQuantizationParam    m_sAdaptiveQuantParam;
-  XMMREG_PROTECT_DECLARE(AdaptiveQuantization);
 };
 
 WELSVP_NAMESPACE_END