doptsystemdependant.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /****************************************************************************
  2. *
  3. * Module Title : SystemDependant.c
  4. *
  5. * Description : Miscellaneous system dependant functions
  6. *
  7. ****************************************************************************/
  8. /****************************************************************************
  9. * Header Files
  10. ****************************************************************************/
  11. #include "postp.h"
  12. /****************************************************************************
  13. * Imports
  14. *****************************************************************************/
  15. extern void GetProcessorFlags(INT32 *MmxEnabled, INT32 *XmmEnabled, INT32 *WmtEnabled);
  16. // c imports
  17. extern void FilteringVert_12_C(UINT32 QValue,UINT8 * Src, INT32 Pitch);
  18. extern void FilteringHoriz_12_C(UINT32 QValue, UINT8 * Src, INT32 Pitch );
  19. extern void FilteringVert_8_C(UINT32 QValue, UINT8 * Src, INT32 Pitch );
  20. extern void FilteringHoriz_8_C(UINT32 QValue, UINT8 * Src, INT32 Pitch );
  21. extern void HorizontalLine_1_2_Scale_C( const unsigned char * source, unsigned int sourceWidth, unsigned char * dest, unsigned int destWidth );
  22. extern void HorizontalLine_3_5_Scale_C( const unsigned char * source, unsigned int sourceWidth, unsigned char * dest, unsigned int destWidth );
  23. extern void HorizontalLine_4_5_Scale_C( const unsigned char * source, unsigned int sourceWidth, unsigned char * dest, unsigned int destWidth );
  24. extern void VerticalBand_4_5_Scale_C( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  25. extern void LastVerticalBand_4_5_Scale_C( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  26. extern void VerticalBand_3_5_Scale_C( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  27. extern void LastVerticalBand_3_5_Scale_C( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  28. extern void VerticalBand_1_2_Scale_C( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  29. extern void LastVerticalBand_1_2_Scale_C( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  30. extern void FilterHoriz_Simple_C( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  31. extern void FilterVert_Simple_C( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  32. extern void FilterHoriz_Generic( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  33. extern void FilterVert_Generic( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  34. extern INT32 *SetupBoundingValueArray_Generic( POSTPROC_INSTANCE *pbi, INT32 FLimit );
  35. extern INT32 *SetupDeblockValueArray_Generic( POSTPROC_INSTANCE *pbi, INT32 FLimit );
  36. extern void DeringBlockWeak_C( const POSTPROC_INSTANCE *pbi, const UINT8 *SrcPtr, UINT8 *DstPtr, const INT32 Pitch, UINT32 FragQIndex, UINT32 *QuantScale );
  37. extern void DeringBlockStrong_C( const POSTPROC_INSTANCE *pbi, const UINT8 *SrcPtr, UINT8 *DstPtr, const INT32 Pitch, UINT32 FragQIndex, UINT32 *QuantScale);
  38. extern void DeblockLoopFilteredBand_C( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  39. extern void DeblockNonFilteredBand_C( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  40. extern void DeblockNonFilteredBandNewFilter_C( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  41. extern void PlaneAddNoise_C( UINT8 *Start, UINT32 Width, UINT32 Height, INT32 Pitch, int q);
  42. // mmx imports
  43. extern void FilteringVert_12_MMX(UINT32 QValue,UINT8 * Src, INT32 Pitch);
  44. extern void FilteringHoriz_12_MMX(UINT32 QValue, UINT8 * Src, INT32 Pitch );
  45. extern void FilteringVert_8_MMX(UINT32 QValue, UINT8 * Src, INT32 Pitch );
  46. extern void FilteringHoriz_8_MMX(UINT32 QValue, UINT8 * Src, INT32 Pitch );
  47. extern void HorizontalLine_1_2_Scale_MMX( const unsigned char * source, unsigned int sourceWidth, unsigned char * dest, unsigned int destWidth );
  48. extern void HorizontalLine_3_5_Scale_MMX( const unsigned char * source, unsigned int sourceWidth, unsigned char * dest, unsigned int destWidth );
  49. extern void HorizontalLine_4_5_Scale_MMX( const unsigned char * source, unsigned int sourceWidth, unsigned char * dest, unsigned int destWidth );
  50. extern void VerticalBand_4_5_Scale_MMX( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  51. extern void LastVerticalBand_4_5_Scale_MMX( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  52. extern void VerticalBand_3_5_Scale_MMX( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  53. extern void LastVerticalBand_3_5_Scale_MMX( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  54. extern void VerticalBand_1_2_Scale_MMX( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  55. extern void LastVerticalBand_1_2_Scale_MMX( unsigned char * dest, unsigned int destPitch, unsigned int destWidth );
  56. extern void FilterHoriz_Simple_MMX( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  57. extern void FilterVert_Simple_MMX( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  58. extern void FilterHoriz_MMX( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  59. extern void FilterVert_MMX( POSTPROC_INSTANCE *pbi, UINT8 * PixelPtr, INT32 LineLength, INT32 *BoundingValuePtr );
  60. extern INT32 *SetupBoundingValueArray_ForMMX( POSTPROC_INSTANCE *pbi, INT32 FLimit );
  61. extern INT32 *SetupDeblockValueArray_ForMMX( POSTPROC_INSTANCE *pbi, INT32 FLimit );
  62. extern void DeringBlockWeak_MMX( const POSTPROC_INSTANCE *pbi, const UINT8 *SrcPtr, UINT8 *DstPtr, const INT32 Pitch, UINT32 FragQIndex, UINT32 *QuantScale );
  63. extern void DeringBlockStrong_MMX( const POSTPROC_INSTANCE *pbi, const UINT8 *SrcPtr, UINT8 *DstPtr, const INT32 Pitch, UINT32 FragQIndex, UINT32 *QuantScale);
  64. extern void DeblockLoopFilteredBand_MMX( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  65. extern void DeblockNonFilteredBand_MMX( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  66. extern void DeblockNonFilteredBandNewFilter_MMX( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  67. extern void FillLoopFilterLimitValues_MMX(void);
  68. extern INT16 *LoopFilterLimitValuesV2_MMX;
  69. extern void PlaneAddNoise_mmx( UINT8 *Start, UINT32 Width, UINT32 Height, INT32 Pitch, int q);
  70. // wmt imports
  71. extern void DeblockLoopFilteredBand_WMT( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  72. extern void DeblockNonFilteredBand_WMT( POSTPROC_INSTANCE *pbi, UINT8 *SrcPtr, UINT8 *DesPtr, UINT32 PlaneLineStep, UINT32 FragsAcross, UINT32 StartFrag, UINT32 *QuantScale );
  73. extern void DeringBlockWeak_WMT( const POSTPROC_INSTANCE *pbi, const UINT8 *SrcPtr, UINT8 *DstPtr, const INT32 Pitch, UINT32 FragQIndex, UINT32 *QuantScale );
  74. extern void DeringBlockStrong_WMT( const POSTPROC_INSTANCE *pbi, const UINT8 *SrcPtr, UINT8 *DstPtr, const INT32 Pitch, UINT32 FragQIndex, UINT32 *QuantScale );
  75. extern void CFastDeInterlace(UINT8 * SrcPtr,UINT8 * DstPtr,INT32 Width,INT32 Height,INT32 Stride);
  76. extern void MmxFastDeInterlace(UINT8 * SrcPtr,UINT8 * DstPtr,INT32 Width,INT32 Height,INT32 Stride);
  77. extern void WmtFastDeInterlace(UINT8 * SrcPtr,UINT8 * DstPtr,INT32 Width,INT32 Height,INT32 Stride);
  78. extern void ClampLevels_C( POSTPROC_INSTANCE *pbi,INT32 BlackClamp,INT32 WhiteClamp,UINT8 *Src,UINT8 *Dst);
  79. extern void ClampLevels_wmt( POSTPROC_INSTANCE *pbi,INT32 BlackClamp,INT32 WhiteClamp,UINT8 *Src,UINT8 *Dst);
  80. extern void ClampLevels_mmx( POSTPROC_INSTANCE *pbi,INT32 BlackClamp,INT32 WhiteClamp,UINT8 *Src,UINT8 *Dst);
  81. extern void PlaneAddNoise_wmt( UINT8 *Start, UINT32 Width, UINT32 Height, INT32 Pitch, int q);
  82. /****************************************************************************
  83. *
  84. * ROUTINE : PostProcMachineSpecificConfig
  85. *
  86. * INPUTS : UINT32 Version : Codec version number.
  87. *
  88. * OUTPUTS : None.
  89. *
  90. * RETURNS : void
  91. *
  92. * FUNCTION : Checks for machine specifc features such as MMX support
  93. * sets appropriate flags and function pointers.
  94. *
  95. * SPECIAL NOTES : None.
  96. *
  97. ****************************************************************************/
  98. void PostProcMachineSpecificConfig ( UINT32 Version )
  99. {
  100. // If MMX supported then set to use MMX versions of functions else
  101. // use original 'C' versions.
  102. INT32 MmxEnabled;
  103. INT32 XmmEnabled;
  104. INT32 WmtEnabled;
  105. GetProcessorFlags( &MmxEnabled, &XmmEnabled, &WmtEnabled );
  106. if ( WmtEnabled )
  107. {
  108. // Willamette
  109. FillLoopFilterLimitValues_MMX();
  110. FilterHoriz = FilterHoriz_MMX;
  111. FilterVert = FilterVert_MMX;
  112. SetupBoundingValueArray = SetupBoundingValueArray_ForMMX;
  113. SetupDeblockValueArray = SetupDeblockValueArray_ForMMX;
  114. DeringBlockWeak = DeringBlockWeak_WMT;
  115. DeringBlockStrong = DeringBlockStrong_WMT;
  116. DeblockLoopFilteredBand = DeblockLoopFilteredBand_WMT;
  117. DeblockNonFilteredBand = DeblockNonFilteredBand_WMT;
  118. DeblockNonFilteredBandNewFilter = DeblockNonFilteredBandNewFilter_MMX;
  119. FilterHoriz_Simple = FilterHoriz_Simple_MMX;
  120. FilterVert_Simple = FilterVert_Simple_MMX;
  121. HorizontalLine_1_2_Scale = HorizontalLine_1_2_Scale_MMX;
  122. HorizontalLine_3_5_Scale = HorizontalLine_3_5_Scale_MMX;
  123. HorizontalLine_4_5_Scale = HorizontalLine_4_5_Scale_MMX;
  124. VerticalBand_1_2_Scale = VerticalBand_1_2_Scale_MMX;
  125. LastVerticalBand_1_2_Scale = LastVerticalBand_1_2_Scale_MMX;
  126. VerticalBand_3_5_Scale = VerticalBand_3_5_Scale_MMX;
  127. LastVerticalBand_3_5_Scale = LastVerticalBand_3_5_Scale_MMX;
  128. VerticalBand_4_5_Scale = VerticalBand_4_5_Scale_MMX;
  129. LastVerticalBand_4_5_Scale = LastVerticalBand_4_5_Scale_MMX;
  130. FilteringHoriz_8 = FilteringHoriz_8_MMX;
  131. FilteringVert_8 = FilteringVert_8_MMX;
  132. FilteringHoriz_12 = FilteringHoriz_12_MMX;
  133. FilteringVert_12 = FilteringVert_12_MMX;
  134. FastDeInterlace = WmtFastDeInterlace;
  135. ClampLevels = ClampLevels_wmt;
  136. PlaneAddNoise = PlaneAddNoise_wmt;
  137. }
  138. else if ( MmxEnabled )
  139. {
  140. FillLoopFilterLimitValues_MMX();
  141. FilterHoriz = FilterHoriz_MMX;
  142. FilterVert = FilterVert_MMX;
  143. SetupBoundingValueArray = SetupBoundingValueArray_ForMMX;
  144. SetupDeblockValueArray = SetupDeblockValueArray_ForMMX;
  145. DeringBlockWeak = DeringBlockWeak_MMX;
  146. DeringBlockStrong = DeringBlockStrong_MMX;
  147. DeblockLoopFilteredBand = DeblockLoopFilteredBand_MMX;
  148. DeblockNonFilteredBand = DeblockNonFilteredBand_MMX;
  149. DeblockNonFilteredBandNewFilter = DeblockNonFilteredBandNewFilter_MMX;
  150. FilterHoriz_Simple = FilterHoriz_Simple_MMX;
  151. FilterVert_Simple = FilterVert_Simple_MMX;
  152. HorizontalLine_1_2_Scale = HorizontalLine_1_2_Scale_MMX;
  153. HorizontalLine_3_5_Scale = HorizontalLine_3_5_Scale_MMX;
  154. HorizontalLine_4_5_Scale = HorizontalLine_4_5_Scale_MMX;
  155. VerticalBand_1_2_Scale = VerticalBand_1_2_Scale_MMX;
  156. LastVerticalBand_1_2_Scale = LastVerticalBand_1_2_Scale_MMX;
  157. VerticalBand_3_5_Scale = VerticalBand_3_5_Scale_MMX;
  158. LastVerticalBand_3_5_Scale = LastVerticalBand_3_5_Scale_MMX;
  159. VerticalBand_4_5_Scale = VerticalBand_4_5_Scale_MMX;
  160. LastVerticalBand_4_5_Scale = LastVerticalBand_4_5_Scale_MMX;
  161. FilteringHoriz_8 = FilteringHoriz_8_MMX;
  162. FilteringVert_8 = FilteringVert_8_MMX;
  163. FilteringHoriz_12 = FilteringHoriz_12_MMX;
  164. FilteringVert_12 = FilteringVert_12_MMX;
  165. FastDeInterlace = MmxFastDeInterlace;
  166. ClampLevels = ClampLevels_mmx;
  167. PlaneAddNoise = PlaneAddNoise_mmx;
  168. }
  169. else
  170. {
  171. FilterHoriz = FilterHoriz_Generic;
  172. FilterVert = FilterVert_Generic;
  173. SetupBoundingValueArray = SetupBoundingValueArray_Generic;
  174. SetupDeblockValueArray = SetupDeblockValueArray_Generic;
  175. DeringBlockWeak = DeringBlockWeak_C;
  176. DeringBlockStrong = DeringBlockStrong_C;
  177. DeblockLoopFilteredBand = DeblockLoopFilteredBand_C;
  178. DeblockNonFilteredBand = DeblockNonFilteredBand_C;
  179. DeblockNonFilteredBandNewFilter = DeblockNonFilteredBandNewFilter_C;
  180. FilterHoriz_Simple = FilterHoriz_Simple_C;
  181. FilterVert_Simple = FilterVert_Simple_C;
  182. HorizontalLine_1_2_Scale = HorizontalLine_1_2_Scale_C;
  183. VerticalBand_1_2_Scale = VerticalBand_1_2_Scale_C;
  184. LastVerticalBand_1_2_Scale = LastVerticalBand_1_2_Scale_C;
  185. HorizontalLine_3_5_Scale = HorizontalLine_3_5_Scale_C;
  186. VerticalBand_3_5_Scale = VerticalBand_3_5_Scale_C;
  187. LastVerticalBand_3_5_Scale = LastVerticalBand_3_5_Scale_C;
  188. HorizontalLine_4_5_Scale = HorizontalLine_4_5_Scale_C;
  189. VerticalBand_4_5_Scale = VerticalBand_4_5_Scale_C;
  190. LastVerticalBand_4_5_Scale = LastVerticalBand_4_5_Scale_C;
  191. FilteringHoriz_8 = FilteringHoriz_8_C;
  192. FilteringVert_8 = FilteringVert_8_C;
  193. FilteringHoriz_12 = FilteringHoriz_12_C;
  194. FilteringVert_12 = FilteringVert_12_C;
  195. FastDeInterlace = CFastDeInterlace;
  196. ClampLevels = ClampLevels_C;
  197. PlaneAddNoise = PlaneAddNoise_C;
  198. }
  199. }