00001 00019 #include "mvc.h" 00020 00024 00028 00040 Mvc_Cube_t * Mvc_CubeAlloc( Mvc_Cover_t * pCover ) 00041 { 00042 Mvc_Cube_t * pCube; 00043 00044 assert( pCover->nWords >= 0 ); 00045 // allocate the cube 00046 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00047 if ( pCover->nWords == 0 ) 00048 pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) ); 00049 else 00050 pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); 00051 #else 00052 switch( pCover->nWords ) 00053 { 00054 case 0: 00055 case 1: 00056 pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan1 ); 00057 break; 00058 case 2: 00059 pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan2 ); 00060 break; 00061 case 3: 00062 case 4: 00063 pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan4 ); 00064 break; 00065 default: 00066 pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); 00067 break; 00068 } 00069 #endif 00070 // set the parameters charactering this cube 00071 if ( pCover->nWords == 0 ) 00072 pCube->iLast = pCover->nWords; 00073 else 00074 pCube->iLast = pCover->nWords - 1; 00075 pCube->nUnused = pCover->nUnused; 00076 return pCube; 00077 } 00078 00079 00091 Mvc_Cube_t * Mvc_CubeDup( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube ) 00092 { 00093 Mvc_Cube_t * pCubeCopy; 00094 pCubeCopy = Mvc_CubeAlloc( pCover ); 00095 Mvc_CubeBitCopy( pCubeCopy, pCube ); 00096 return pCubeCopy; 00097 } 00098 00099 00111 void Mvc_CubeFree( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube ) 00112 { 00113 if ( pCube == NULL ) 00114 return; 00115 00116 // verify the parameters charactering this cube 00117 assert( pCube->iLast == 0 || ((int)pCube->iLast) == pCover->nWords - 1 ); 00118 assert( ((int)pCube->nUnused) == pCover->nUnused ); 00119 00120 // deallocate the cube 00121 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT 00122 free( pCube ); 00123 #else 00124 switch( pCover->nWords ) 00125 { 00126 case 0: 00127 case 1: 00128 Extra_MmFixedEntryRecycle( pCover->pMem->pMan1, (char *)pCube ); 00129 break; 00130 case 2: 00131 Extra_MmFixedEntryRecycle( pCover->pMem->pMan2, (char *)pCube ); 00132 break; 00133 case 3: 00134 case 4: 00135 Extra_MmFixedEntryRecycle( pCover->pMem->pMan4, (char *)pCube ); 00136 break; 00137 default: 00138 free( pCube ); 00139 break; 00140 } 00141 #endif 00142 } 00143 00144 00156 void Mvc_CubeBitRemoveDcs( Mvc_Cube_t * pCube ) 00157 { 00158 unsigned Mask; 00159 int i; 00160 for ( i = Mvc_CubeReadLast(pCube); i >= 0; i-- ) 00161 { 00162 // detect those variables that are different (not DCs) 00163 Mask = (pCube->pData[i] ^ (pCube->pData[i] >> 1)) & BITS_DISJOINT; 00164 // create the mask of all that are different 00165 Mask |= (Mask << 1); 00166 // remove other bits from the set 00167 pCube->pData[i] &= Mask; 00168 } 00169 } 00170 00174 00175