123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- /****************************************************************************
- *
- * Module Title : PreProcGlobals
- *
- * Description : Pre-processor module globals.
- *
- * AUTHOR : Paul Wilkins
- *
- *****************************************************************************
- * Revision History
- *
- * 1.07 PGW 20 Feb 01 Disable history buffer mechanism.
- * 1.06 JBB 20 Sep 00 duck_ memory allocation calls
- * 1.05 JBB 02 Aug 00 Checked duck_malloc return codes
- * 1.04 PGW 24 Jul 00 Deleted BeThreshold & ShowVcapPramsDlg.
- * 1.03 PGW 10 Jul 00 Added KFIndicator.
- * 1.02 JBB 30/05/00 Removed hard coded size limits
- * 1.01 PGW 12/07/99 Changes to reduce uneccessary dependancies.
- * 1.00 PGW 14/06/99 Configuration baseline
- *
- *****************************************************************************
- */
- /****************************************************************************
- * Header Frames
- *****************************************************************************
- */
- #define STRICT /* Strict type checking. */
- #include "preprocconf.h"
- #include "preproc.h"
- #include <stdlib.h>
- #include "duck_mem.h"
- /****************************************************************************
- * Exported Global Variables
- *****************************************************************************
- */
- //PP_INSTANCE *ppi;
- /****************************************************************************
- *
- * ROUTINE : PDeleteFragmentInfo
- *
- *
- * INPUTS : Instance of PB to be initialized
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Initializes the Playback instance passed in
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- void PDeleteFragmentInfo(PP_INSTANCE * ppi)
- {
- // duck_free prior allocs if present
- }
- /****************************************************************************
- *
- * ROUTINE : PAllocateFragmentInfo
- *
- *
- * INPUTS : Instance of PB to be initialized
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Initializes the Playback instance passed in
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- void PAllocateFragmentInfo(PP_INSTANCE * ppi)
- {
- // clear any existing info
- PDeleteFragmentInfo(ppi);
- // Perform Fragment Allocations
- }
- /****************************************************************************
- *
- * ROUTINE : PDeleteFrameInfo
- *
- *
- * INPUTS : Instance of PB to be initialized
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Initializes the Playback instance passed in
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- void PDeleteFrameInfo(PP_INSTANCE * ppi)
- {
- if( ppi->ScanPixelIndexTableAlloc )
- duck_free(ppi->ScanPixelIndexTableAlloc);
- ppi->ScanPixelIndexTableAlloc= 0;
- ppi->ScanPixelIndexTable= 0;
- if( ppi->ScanDisplayFragmentsAlloc )
- duck_free(ppi->ScanDisplayFragmentsAlloc);
- ppi->ScanDisplayFragmentsAlloc= 0;
- ppi->ScanDisplayFragments= 0;
- if( ppi->FragScoresAlloc )
- duck_free(ppi->FragScoresAlloc);
- ppi->FragScoresAlloc= 0;
- ppi->FragScores= 0;
- if( ppi->SameGreyDirPixelsAlloc )
- duck_free(ppi->SameGreyDirPixelsAlloc);
- ppi->SameGreyDirPixelsAlloc= 0;
- ppi->SameGreyDirPixels= 0;
- if( ppi->FragDiffPixelsAlloc )
- duck_free(ppi->FragDiffPixelsAlloc);
- ppi->FragDiffPixelsAlloc= 0;
- ppi->FragDiffPixels= 0;
- if( ppi->BarBlockMapAlloc )
- duck_free(ppi->BarBlockMapAlloc);
- ppi->BarBlockMapAlloc= 0;
- ppi->BarBlockMap= 0;
- if( ppi->TmpCodedMapAlloc )
- duck_free(ppi->TmpCodedMapAlloc);
- ppi->TmpCodedMapAlloc= 0;
- ppi->TmpCodedMap= 0;
- if( ppi->RowChangedPixelsAlloc )
- duck_free(ppi->RowChangedPixelsAlloc);
- ppi->RowChangedPixelsAlloc= 0;
- ppi->RowChangedPixels= 0;
- if( ppi->PixelScoresAlloc )
- duck_free(ppi->PixelScoresAlloc);
- ppi->PixelScoresAlloc= 0;
- ppi->PixelScores= 0;
- if( ppi->PixelChangedMapAlloc )
- duck_free(ppi->PixelChangedMapAlloc);
- ppi->PixelChangedMapAlloc= 0;
- ppi->PixelChangedMap= 0;
- if( ppi->ChLocalsAlloc )
- duck_free(ppi->ChLocalsAlloc);
- ppi->ChLocalsAlloc= 0;
- ppi->ChLocals= 0;
- if( ppi->yuv_differencesAlloc )
- duck_free(ppi->yuv_differencesAlloc);
- ppi->yuv_differencesAlloc= 0;
- ppi->yuv_differences= 0;
- }
- #define ROUNDUP32(X) ( ( ( (unsigned long) X ) + 31 )&( 0xFFFFFFE0 ) )
- /****************************************************************************
- *
- * ROUTINE : PAllocateFrameInfo
- *
- *
- * INPUTS : Instance of PB to be initialized
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Initializes the Playback instance passed in
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- BOOL PAllocateFrameInfo(PP_INSTANCE * ppi)
- {
- PDeleteFrameInfo(ppi);
- ppi->ScanPixelIndexTableAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(UINT32), DMEM_GENERAL);
- if(!ppi->ScanPixelIndexTableAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->ScanPixelIndexTable = (UINT32 *) ROUNDUP32(ppi->ScanPixelIndexTableAlloc);
- ppi->ScanDisplayFragmentsAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(INT8), DMEM_GENERAL);
- if(!ppi->ScanDisplayFragmentsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->ScanDisplayFragments = (INT8 *) ROUNDUP32(ppi->ScanDisplayFragmentsAlloc);
- ppi->FragScoresAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(UINT32), DMEM_GENERAL);
- if(!ppi->FragScoresAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->FragScores = (UINT32 *) ROUNDUP32(ppi->FragScoresAlloc);
- ppi->SameGreyDirPixelsAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(INT8), DMEM_GENERAL);
- if(!ppi->SameGreyDirPixelsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->SameGreyDirPixels = (INT8 *) ROUNDUP32(ppi->SameGreyDirPixelsAlloc);
- ppi->FragDiffPixelsAlloc = duck_malloc(32 + ppi->ScanFrameFragments*sizeof(UINT8), DMEM_GENERAL);
- if(!ppi->FragDiffPixelsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->FragDiffPixels = (UINT8 *) ROUNDUP32(ppi->FragDiffPixelsAlloc);
- ppi->BarBlockMapAlloc = duck_malloc(32 + 3 * ppi->ScanHFragments*sizeof(INT8), DMEM_GENERAL);
- if(!ppi->BarBlockMapAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->BarBlockMap = (INT8 *) ROUNDUP32(ppi->BarBlockMapAlloc);
- ppi->TmpCodedMapAlloc = duck_malloc(32 + ppi->ScanHFragments*sizeof(INT8), DMEM_GENERAL);
- if(!ppi->TmpCodedMapAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->TmpCodedMap = (INT8 *) ROUNDUP32(ppi->TmpCodedMapAlloc);
- ppi->RowChangedPixelsAlloc = duck_malloc(32 + 3 * ppi->ScanConfig.VideoFrameHeight *sizeof(INT32), DMEM_GENERAL);
- if(!ppi->RowChangedPixelsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->RowChangedPixels = (INT32 *) ROUNDUP32(ppi->RowChangedPixelsAlloc);
- ppi->PixelScoresAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth* sizeof(UINT8) * PSCORE_CB_ROWS, DMEM_GENERAL);
- if(!ppi->PixelScoresAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->PixelScores = (UINT8 *) ROUNDUP32(ppi->PixelScoresAlloc);
- ppi->PixelChangedMapAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth*sizeof(UINT8) * PMAP_CB_ROWS, DMEM_GENERAL);
- if(!ppi->PixelChangedMapAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->PixelChangedMap = ( UINT8 *) ROUNDUP32(ppi->PixelChangedMapAlloc);
- ppi->ChLocalsAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth*sizeof(UINT8) * CHLOCALS_CB_ROWS, DMEM_GENERAL);
- if(!ppi->ChLocalsAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->ChLocals = (UINT8 *) ROUNDUP32(ppi->ChLocalsAlloc);
- ppi->yuv_differencesAlloc = duck_malloc(32 + ppi->ScanConfig.VideoFrameWidth*sizeof(INT16) * YDIFF_CB_ROWS, DMEM_GENERAL);
- if(!ppi->yuv_differencesAlloc) {PDeleteFrameInfo(ppi);return FALSE;}
- ppi->yuv_differences = (INT16 *) ROUNDUP32(ppi->yuv_differencesAlloc);
- return TRUE;
- }
- /****************************************************************************
- *
- * ROUTINE : DeletePPInstance
- *
- *
- * INPUTS : Instance of PB to be deleted
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : frees the Playback instance passed in
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- void DeletePPInstance(PP_INSTANCE **ppi)
- {
- PDeleteFrameInfo(*ppi);
- duck_free(*ppi);
- *ppi=0;
- }
- /****************************************************************************
- *
- * ROUTINE : Createppinstance
- *
- *
- * INPUTS : Instance of CP to be initialized
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Create and Initializes the Compression instance
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- PP_INSTANCE * CreatePPInstance(void)
- {
- PP_INSTANCE *ppi;
- /* The VCAP configuration. */
- SCAN_CONFIG_DATA ScanConfigInit =
- {
- NULL, NULL, NULL, 0,0, NULL,
- 176, 144,
- 8,8,
- };
- // allocate structure
- int ppi_size = sizeof(PP_INSTANCE);
- ppi=duck_calloc(1,ppi_size, DMEM_GENERAL);
- ppi->OutputBlocksUpdated = 0;
- ppi->KFIndicator = 0;
- // Initializations
- ppi->VideoYPlaneWidth = 0;
- ppi->VideoYPlaneHeight = 0;
- ppi->VideoUVPlaneWidth = 0;
- ppi->VideoUVPlaneHeight = 0;
-
- ppi->VideoYPlaneStride = 0;
- ppi->VideoUPlaneStride = 0;
- ppi->VideoVPlaneStride = 0;
-
- /* Scan control variables. */
- ppi->HFragPixels = 8;
- ppi->VFragPixels = 8;
-
- ppi->ScanFrameFragments = 0 ;
- ppi->ScanYPlaneFragments = 0;
- ppi->ScanUVPlaneFragments= 0;
- ppi->ScanHFragments= 0;
- ppi->ScanVFragments= 0;
-
- ppi->YFramePixels = 0;
- ppi->UVFramePixels = 0;
- ppi->TotFramePixels = 0;
-
-
- ppi->SRFGreyThresh = 4;
- ppi->SRFColThresh = 5;
- ppi->NoiseSupLevel = 3;
- ppi->SgcLevelThresh = 3;
- ppi->SuvcLevelThresh = 4;
-
- // Variables controlling S.A.D. break outs.
- ppi->GrpLowSadThresh = 10;
- ppi->GrpHighSadThresh = 64;
- ppi->PrimaryBlockThreshold = 5;
- ppi->SgcThresh = 16; // (Default values for 8x8 blocks).
-
- ppi->PAKEnabled = FALSE; //TRUE;
-
- ppi->LevelThresh = 0; // no initializaiton in Paul's
- ppi->NegLevelThresh = 0; // no initializaiton in Paul's
- ppi->SrfThresh = 0; // no initializaiton in Paul's
- ppi->NegSrfThresh = 0; // no initializaiton in Paul's
- ppi->HighChange = 0; // no initializaiton in Paul's
- ppi->NegHighChange = 0; // no initializaiton in Paul's
-
- ppi->ModifiedGrpLowSadThresh = 0;
- ppi->ModifiedGrpHighSadThresh = 0; // no initializaiton in Paul's
-
- ppi->PlaneHFragments = 0;
- ppi->PlaneVFragments = 0;
- ppi->PlaneHeight = 0;
- ppi->PlaneWidth = 0;
- ppi->PlaneStride = 0;
-
- ppi->BlockThreshold = 0; // no initializaiton in Paul's
- ppi->BlockSgcThresh = 0;
- ppi->UVBlockThreshCorrection = 1.25;
- ppi->UVSgcCorrection = 1.5;
-
- ppi->SpeedCritical = 3;
-
- // PC specific variables
- ppi->MmxEnabled = FALSE;
-
- ppi->YUVPlaneCorrectionFactor = 0; // no initialization in Paul's
- ppi->MaxLineSearchLen = MAX_SEARCH_LINE_LEN;
-
- ppi->YuvDiffsCircularBufferSize = 0; // no initializaiton in Paul's
- ppi->ChLocalsCircularBufferSize = 0;
- ppi->PixelMapCircularBufferSize = 0;
-
- // Function pointers for mmx switches
- ppi->RowSAD = 0;
- ppi->ScanPixelIndexTableAlloc= 0;
- ppi->ScanPixelIndexTable= 0;
- ppi->ScanDisplayFragmentsAlloc= 0;
- ppi->ScanDisplayFragments= 0;
- ppi->FragScores= 0;
- ppi->FragScores= 0;
- ppi->ScanDisplayFragmentsAlloc= 0;
- ppi->ScanDisplayFragments= 0;
- ppi->SameGreyDirPixelsAlloc= 0;
- ppi->SameGreyDirPixels= 0;
- ppi->FragDiffPixelsAlloc= 0;
- ppi->FragDiffPixels= 0;
- ppi->BarBlockMapAlloc= 0;
- ppi->BarBlockMap= 0;
- ppi->TmpCodedMapAlloc= 0;
- ppi->TmpCodedMap= 0;
- ppi->RowChangedPixelsAlloc= 0;
- ppi->RowChangedPixels= 0;
- ppi->PixelScoresAlloc= 0;
- ppi->PixelScores= 0;
- ppi->PixelChangedMapAlloc= 0;
- ppi->PixelChangedMap= 0;
- ppi->ChLocalsAlloc= 0;
- ppi->ChLocals= 0;
- ppi->yuv_differencesAlloc= 0;
- ppi->yuv_differences= 0;
- return ppi;
- }
- /****************************************************************************
- *
- * ROUTINE : VPInitLibrary
- *
- *
- * INPUTS : init VP library
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Fully initializes the playback library
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- void VPPInitLibrary(void)
- {
- }
- /*********************************************************/
- /****************************************************************************
- *
- * ROUTINE : VPPDeinitLibrary
- *
- *
- * INPUTS : init VP library
- *
- * OUTPUTS :
- *
- * RETURNS :
- *
- *
- * FUNCTION : Fully initializes the playback library
- *
- * SPECIAL NOTES : None.
- *
- *
- * ERRORS : None.
- *
- ****************************************************************************/
- void VPPDeInitLibrary(void)
- {
- }
|