preprocglobals.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /****************************************************************************
  2. *
  3. * Module Title : PreProcGlobals
  4. *
  5. * Description : Pre-processor module globals.
  6. *
  7. * AUTHOR : Paul Wilkins
  8. *
  9. *****************************************************************************
  10. * Revision History
  11. *
  12. * 1.07 PGW 20 Feb 01 Disable history buffer mechanism.
  13. * 1.06 JBB 20 Sep 00 duck_ memory allocation calls
  14. * 1.05 JBB 02 Aug 00 Checked duck_malloc return codes
  15. * 1.04 PGW 24 Jul 00 Deleted BeThreshold & ShowVcapPramsDlg.
  16. * 1.03 PGW 10 Jul 00 Added KFIndicator.
  17. * 1.02 JBB 30/05/00 Removed hard coded size limits
  18. * 1.01 PGW 12/07/99 Changes to reduce uneccessary dependancies.
  19. * 1.00 PGW 14/06/99 Configuration baseline
  20. *
  21. *****************************************************************************
  22. */
  23. /****************************************************************************
  24. * Header Frames
  25. *****************************************************************************
  26. */
  27. #define STRICT /* Strict type checking. */
  28. #include "preprocconf.h"
  29. #include "preproc.h"
  30. #include <stdlib.h>
  31. #include "duck_mem.h"
  32. /****************************************************************************
  33. * Exported Global Variables
  34. *****************************************************************************
  35. */
  36. //PP_INSTANCE *ppi;
  37. /****************************************************************************
  38. *
  39. * ROUTINE : PDeleteFragmentInfo
  40. *
  41. *
  42. * INPUTS : Instance of PB to be initialized
  43. *
  44. * OUTPUTS :
  45. *
  46. * RETURNS :
  47. *
  48. *
  49. * FUNCTION : Initializes the Playback instance passed in
  50. *
  51. * SPECIAL NOTES : None.
  52. *
  53. *
  54. * ERRORS : None.
  55. *
  56. ****************************************************************************/
  57. void PDeleteFragmentInfo(PP_INSTANCE * ppi)
  58. {
  59. // duck_free prior allocs if present
  60. }
  61. /****************************************************************************
  62. *
  63. * ROUTINE : PAllocateFragmentInfo
  64. *
  65. *
  66. * INPUTS : Instance of PB to be initialized
  67. *
  68. * OUTPUTS :
  69. *
  70. * RETURNS :
  71. *
  72. *
  73. * FUNCTION : Initializes the Playback instance passed in
  74. *
  75. * SPECIAL NOTES : None.
  76. *
  77. *
  78. * ERRORS : None.
  79. *
  80. ****************************************************************************/
  81. void PAllocateFragmentInfo(PP_INSTANCE * ppi)
  82. {
  83. // clear any existing info
  84. PDeleteFragmentInfo(ppi);
  85. // Perform Fragment Allocations
  86. }
  87. /****************************************************************************
  88. *
  89. * ROUTINE : PDeleteFrameInfo
  90. *
  91. *
  92. * INPUTS : Instance of PB to be initialized
  93. *
  94. * OUTPUTS :
  95. *
  96. * RETURNS :
  97. *
  98. *
  99. * FUNCTION : Initializes the Playback instance passed in
  100. *
  101. * SPECIAL NOTES : None.
  102. *
  103. *
  104. * ERRORS : None.
  105. *
  106. ****************************************************************************/
  107. void PDeleteFrameInfo(PP_INSTANCE * ppi)
  108. {
  109. if( ppi->ScanPixelIndexTableAlloc )
  110. duck_free(ppi->ScanPixelIndexTableAlloc);
  111. ppi->ScanPixelIndexTableAlloc= 0;
  112. ppi->ScanPixelIndexTable= 0;
  113. if( ppi->ScanDisplayFragmentsAlloc )
  114. duck_free(ppi->ScanDisplayFragmentsAlloc);
  115. ppi->ScanDisplayFragmentsAlloc= 0;
  116. ppi->ScanDisplayFragments= 0;
  117. if( ppi->FragScoresAlloc )
  118. duck_free(ppi->FragScoresAlloc);
  119. ppi->FragScoresAlloc= 0;
  120. ppi->FragScores= 0;
  121. if( ppi->SameGreyDirPixelsAlloc )
  122. duck_free(ppi->SameGreyDirPixelsAlloc);
  123. ppi->SameGreyDirPixelsAlloc= 0;
  124. ppi->SameGreyDirPixels= 0;
  125. if( ppi->FragDiffPixelsAlloc )
  126. duck_free(ppi->FragDiffPixelsAlloc);
  127. ppi->FragDiffPixelsAlloc= 0;
  128. ppi->FragDiffPixels= 0;
  129. if( ppi->BarBlockMapAlloc )
  130. duck_free(ppi->BarBlockMapAlloc);
  131. ppi->BarBlockMapAlloc= 0;
  132. ppi->BarBlockMap= 0;
  133. if( ppi->TmpCodedMapAlloc )
  134. duck_free(ppi->TmpCodedMapAlloc);
  135. ppi->TmpCodedMapAlloc= 0;
  136. ppi->TmpCodedMap= 0;
  137. if( ppi->RowChangedPixelsAlloc )
  138. duck_free(ppi->RowChangedPixelsAlloc);
  139. ppi->RowChangedPixelsAlloc= 0;
  140. ppi->RowChangedPixels= 0;
  141. if( ppi->PixelScoresAlloc )
  142. duck_free(ppi->PixelScoresAlloc);
  143. ppi->PixelScoresAlloc= 0;
  144. ppi->PixelScores= 0;
  145. if( ppi->PixelChangedMapAlloc )
  146. duck_free(ppi->PixelChangedMapAlloc);
  147. ppi->PixelChangedMapAlloc= 0;
  148. ppi->PixelChangedMap= 0;
  149. if( ppi->ChLocalsAlloc )
  150. duck_free(ppi->ChLocalsAlloc);
  151. ppi->ChLocalsAlloc= 0;
  152. ppi->ChLocals= 0;
  153. if( ppi->yuv_differencesAlloc )
  154. duck_free(ppi->yuv_differencesAlloc);
  155. ppi->yuv_differencesAlloc= 0;
  156. ppi->yuv_differences= 0;
  157. }
  158. #define ROUNDUP32(X) ( ( ( (unsigned long) X ) + 31 )&( 0xFFFFFFE0 ) )
  159. /****************************************************************************
  160. *
  161. * ROUTINE : PAllocateFrameInfo
  162. *
  163. *
  164. * INPUTS : Instance of PB to be initialized
  165. *
  166. * OUTPUTS :
  167. *
  168. * RETURNS :
  169. *
  170. *
  171. * FUNCTION : Initializes the Playback instance passed in
  172. *
  173. * SPECIAL NOTES : None.
  174. *
  175. *
  176. * ERRORS : None.
  177. *
  178. ****************************************************************************/
  179. BOOL PAllocateFrameInfo(PP_INSTANCE * ppi)
  180. {
  181. PDeleteFrameInfo(ppi);
  182. ppi->ScanPixelIndexTableAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(UINT32), DMEM_GENERAL);
  183. if(!ppi->ScanPixelIndexTableAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  184. ppi->ScanPixelIndexTable = (UINT32 *) ROUNDUP32(ppi->ScanPixelIndexTableAlloc);
  185. ppi->ScanDisplayFragmentsAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(INT8), DMEM_GENERAL);
  186. if(!ppi->ScanDisplayFragmentsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  187. ppi->ScanDisplayFragments = (INT8 *) ROUNDUP32(ppi->ScanDisplayFragmentsAlloc);
  188. ppi->FragScoresAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(UINT32), DMEM_GENERAL);
  189. if(!ppi->FragScoresAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  190. ppi->FragScores = (UINT32 *) ROUNDUP32(ppi->FragScoresAlloc);
  191. ppi->SameGreyDirPixelsAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(INT8), DMEM_GENERAL);
  192. if(!ppi->SameGreyDirPixelsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  193. ppi->SameGreyDirPixels = (INT8 *) ROUNDUP32(ppi->SameGreyDirPixelsAlloc);
  194. ppi->FragDiffPixelsAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(UINT8), DMEM_GENERAL);
  195. if(!ppi->FragDiffPixelsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  196. ppi->FragDiffPixels = (UINT8 *) ROUNDUP32(ppi->FragDiffPixelsAlloc);
  197. ppi->BarBlockMapAlloc = duck_malloc(32 + 3 * ppi->ScanHFragments*sizeof(INT8), DMEM_GENERAL);
  198. if(!ppi->BarBlockMapAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  199. ppi->BarBlockMap = (INT8 *) ROUNDUP32(ppi->BarBlockMapAlloc);
  200. ppi->TmpCodedMapAlloc = duck_malloc(32 + ppi->ScanHFragments*sizeof(INT8), DMEM_GENERAL);
  201. if(!ppi->TmpCodedMapAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  202. ppi->TmpCodedMap = (INT8 *) ROUNDUP32(ppi->TmpCodedMapAlloc);
  203. ppi->RowChangedPixelsAlloc = duck_malloc(32 + 3 * ppi->ScanConfig.VideoFrameHeight *sizeof(INT32), DMEM_GENERAL);
  204. if(!ppi->RowChangedPixelsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  205. ppi->RowChangedPixels = (INT32 *) ROUNDUP32(ppi->RowChangedPixelsAlloc);
  206. ppi->PixelScoresAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth* sizeof(UINT8) * PSCORE_CB_ROWS, DMEM_GENERAL);
  207. if(!ppi->PixelScoresAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  208. ppi->PixelScores = (UINT8 *) ROUNDUP32(ppi->PixelScoresAlloc);
  209. ppi->PixelChangedMapAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth*sizeof(UINT8) * PMAP_CB_ROWS, DMEM_GENERAL);
  210. if(!ppi->PixelChangedMapAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  211. ppi->PixelChangedMap = ( UINT8 *) ROUNDUP32(ppi->PixelChangedMapAlloc);
  212. ppi->ChLocalsAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth*sizeof(UINT8) * CHLOCALS_CB_ROWS, DMEM_GENERAL);
  213. if(!ppi->ChLocalsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  214. ppi->ChLocals = (UINT8 *) ROUNDUP32(ppi->ChLocalsAlloc);
  215. ppi->yuv_differencesAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth*sizeof(INT16) * YDIFF_CB_ROWS, DMEM_GENERAL);
  216. if(!ppi->yuv_differencesAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
  217. ppi->yuv_differences = (INT16 *) ROUNDUP32(ppi->yuv_differencesAlloc);
  218. return TRUE;
  219. }
  220. /****************************************************************************
  221. *
  222. * ROUTINE : DeletePPInstance
  223. *
  224. *
  225. * INPUTS : Instance of PB to be deleted
  226. *
  227. * OUTPUTS :
  228. *
  229. * RETURNS :
  230. *
  231. *
  232. * FUNCTION : frees the Playback instance passed in
  233. *
  234. * SPECIAL NOTES : None.
  235. *
  236. *
  237. * ERRORS : None.
  238. *
  239. ****************************************************************************/
  240. void DeletePPInstance(PP_INSTANCE **ppi)
  241. {
  242. PDeleteFrameInfo(*ppi);
  243. duck_free(*ppi);
  244. *ppi=0;
  245. }
  246. /****************************************************************************
  247. *
  248. * ROUTINE : Createppinstance
  249. *
  250. *
  251. * INPUTS : Instance of CP to be initialized
  252. *
  253. * OUTPUTS :
  254. *
  255. * RETURNS :
  256. *
  257. *
  258. * FUNCTION : Create and Initializes the Compression instance
  259. *
  260. * SPECIAL NOTES : None.
  261. *
  262. *
  263. * ERRORS : None.
  264. *
  265. ****************************************************************************/
  266. PP_INSTANCE * CreatePPInstance(void)
  267. {
  268. PP_INSTANCE *ppi;
  269. /* The VCAP configuration. */
  270. SCAN_CONFIG_DATA ScanConfigInit =
  271. {
  272. NULL, NULL, NULL, 0,0, NULL,
  273. 176, 144,
  274. 8,8,
  275. };
  276. // allocate structure
  277. int ppi_size = sizeof(PP_INSTANCE);
  278. ppi=duck_calloc(1,ppi_size, DMEM_GENERAL);
  279. ppi->OutputBlocksUpdated = 0;
  280. ppi->KFIndicator = 0;
  281. // Initializations
  282. ppi->VideoYPlaneWidth = 0;
  283. ppi->VideoYPlaneHeight = 0;
  284. ppi->VideoUVPlaneWidth = 0;
  285. ppi->VideoUVPlaneHeight = 0;
  286. ppi->VideoYPlaneStride = 0;
  287. ppi->VideoUPlaneStride = 0;
  288. ppi->VideoVPlaneStride = 0;
  289. /* Scan control variables. */
  290. ppi->HFragPixels = 8;
  291. ppi->VFragPixels = 8;
  292. ppi->ScanFrameFragments = 0 ;
  293. ppi->ScanYPlaneFragments = 0;
  294. ppi->ScanUVPlaneFragments= 0;
  295. ppi->ScanHFragments= 0;
  296. ppi->ScanVFragments= 0;
  297. ppi->YFramePixels = 0;
  298. ppi->UVFramePixels = 0;
  299. ppi->TotFramePixels = 0;
  300. ppi->SRFGreyThresh = 4;
  301. ppi->SRFColThresh = 5;
  302. ppi->NoiseSupLevel = 3;
  303. ppi->SgcLevelThresh = 3;
  304. ppi->SuvcLevelThresh = 4;
  305. // Variables controlling S.A.D. break outs.
  306. ppi->GrpLowSadThresh = 10;
  307. ppi->GrpHighSadThresh = 64;
  308. ppi->PrimaryBlockThreshold = 5;
  309. ppi->SgcThresh = 16; // (Default values for 8x8 blocks).
  310. ppi->PAKEnabled = FALSE; //TRUE;
  311. ppi->LevelThresh = 0; // no initializaiton in Paul's
  312. ppi->NegLevelThresh = 0; // no initializaiton in Paul's
  313. ppi->SrfThresh = 0; // no initializaiton in Paul's
  314. ppi->NegSrfThresh = 0; // no initializaiton in Paul's
  315. ppi->HighChange = 0; // no initializaiton in Paul's
  316. ppi->NegHighChange = 0; // no initializaiton in Paul's
  317. ppi->ModifiedGrpLowSadThresh = 0;
  318. ppi->ModifiedGrpHighSadThresh = 0; // no initializaiton in Paul's
  319. ppi->PlaneHFragments = 0;
  320. ppi->PlaneVFragments = 0;
  321. ppi->PlaneHeight = 0;
  322. ppi->PlaneWidth = 0;
  323. ppi->PlaneStride = 0;
  324. ppi->BlockThreshold = 0; // no initializaiton in Paul's
  325. ppi->BlockSgcThresh = 0;
  326. ppi->UVBlockThreshCorrection = 1.25;
  327. ppi->UVSgcCorrection = 1.5;
  328. ppi->SpeedCritical = 3;
  329. // PC specific variables
  330. ppi->MmxEnabled = FALSE;
  331. ppi->YUVPlaneCorrectionFactor = 0; // no initialization in Paul's
  332. ppi->MaxLineSearchLen = MAX_SEARCH_LINE_LEN;
  333. ppi->YuvDiffsCircularBufferSize = 0; // no initializaiton in Paul's
  334. ppi->ChLocalsCircularBufferSize = 0;
  335. ppi->PixelMapCircularBufferSize = 0;
  336. // Function pointers for mmx switches
  337. ppi->RowSAD = 0;
  338. ppi->ScanPixelIndexTableAlloc= 0;
  339. ppi->ScanPixelIndexTable= 0;
  340. ppi->ScanDisplayFragmentsAlloc= 0;
  341. ppi->ScanDisplayFragments= 0;
  342. ppi->FragScores= 0;
  343. ppi->FragScores= 0;
  344. ppi->ScanDisplayFragmentsAlloc= 0;
  345. ppi->ScanDisplayFragments= 0;
  346. ppi->SameGreyDirPixelsAlloc= 0;
  347. ppi->SameGreyDirPixels= 0;
  348. ppi->FragDiffPixelsAlloc= 0;
  349. ppi->FragDiffPixels= 0;
  350. ppi->BarBlockMapAlloc= 0;
  351. ppi->BarBlockMap= 0;
  352. ppi->TmpCodedMapAlloc= 0;
  353. ppi->TmpCodedMap= 0;
  354. ppi->RowChangedPixelsAlloc= 0;
  355. ppi->RowChangedPixels= 0;
  356. ppi->PixelScoresAlloc= 0;
  357. ppi->PixelScores= 0;
  358. ppi->PixelChangedMapAlloc= 0;
  359. ppi->PixelChangedMap= 0;
  360. ppi->ChLocalsAlloc= 0;
  361. ppi->ChLocals= 0;
  362. ppi->yuv_differencesAlloc= 0;
  363. ppi->yuv_differences= 0;
  364. return ppi;
  365. }
  366. /****************************************************************************
  367. *
  368. * ROUTINE : VPInitLibrary
  369. *
  370. *
  371. * INPUTS : init VP library
  372. *
  373. * OUTPUTS :
  374. *
  375. * RETURNS :
  376. *
  377. *
  378. * FUNCTION : Fully initializes the playback library
  379. *
  380. * SPECIAL NOTES : None.
  381. *
  382. *
  383. * ERRORS : None.
  384. *
  385. ****************************************************************************/
  386. void VPPInitLibrary(void)
  387. {
  388. }
  389. /*********************************************************/
  390. /****************************************************************************
  391. *
  392. * ROUTINE : VPPDeinitLibrary
  393. *
  394. *
  395. * INPUTS : init VP library
  396. *
  397. * OUTPUTS :
  398. *
  399. * RETURNS :
  400. *
  401. *
  402. * FUNCTION : Fully initializes the playback library
  403. *
  404. * SPECIAL NOTES : None.
  405. *
  406. *
  407. * ERRORS : None.
  408. *
  409. ****************************************************************************/
  410. void VPPDeInitLibrary(void)
  411. {
  412. }