Initial community commit
This commit is contained in:
391
Src/libvpShared/corelibs/cdxv/pp/generic/blockmap.c
Normal file
391
Src/libvpShared/corelibs/cdxv/pp/generic/blockmap.c
Normal file
@@ -0,0 +1,391 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : BlockMap.c
|
||||
*
|
||||
* Description : Contains functions used to create the block map
|
||||
*
|
||||
* AUTHOR : Paul Wilkins
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.08 PGW 28 Feb 01 Removal of history buffer mechanism.
|
||||
* 1.07 PGW 04 Oct 00 Changes to RowBarEnhBlockMap()
|
||||
* 1.06 JBB 03 Aug 00 Fixed Problem in which rownumber was compared to
|
||||
* PlaneHFragments instead of PlaneVFragments, added
|
||||
* statistic output functions
|
||||
* 1.05 PGW 27/07/00 Experiments with motion score.
|
||||
* 1.04 JBB 30/05/00 Removed hard coded size limits
|
||||
* 1.03 PGW 18/02/00 Changed weighting for History blocks.
|
||||
* Redundant functions deleted.
|
||||
* Deglobalization.
|
||||
* 1.02 PGW 12/07/99 Changes to reduce uneccessary dependancies.
|
||||
* 1.01 PGW 21/06/99 Alter function of RowBarEnhBlockMap() for VFW codec.
|
||||
* 1.00 PGW 14/06/99 Configuration baseline
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Frames
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#define STRICT /* Strict type checking. */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "preproc.h"
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Module constants.
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Module Types
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Imported Global Variables
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Exported Global Variables
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Foreward References
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Module Statics
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : RowBarEnhBlockMap
|
||||
*
|
||||
* INPUTS : UINT32 * FragNoiseScorePtr
|
||||
* INT8 * FragSgcPtr
|
||||
* UINT32 RowNumber
|
||||
*
|
||||
* OUTPUTS : INT8 * UpdatedBlockMapPtr
|
||||
* INT8 * BarBlockMapPtr
|
||||
*
|
||||
* RETURNS : None.
|
||||
*
|
||||
* FUNCTION : BAR Enhances block map on a row by row basis.
|
||||
*
|
||||
* SPECIAL NOTES : Note special cases for first and last row and first and last
|
||||
* block in each row.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void RowBarEnhBlockMap( PP_INSTANCE *ppi,
|
||||
UINT32 * FragScorePtr,
|
||||
INT8 * FragSgcPtr,
|
||||
INT8 * UpdatedBlockMapPtr,
|
||||
INT8 * BarBlockMapPtr,
|
||||
UINT32 RowNumber )
|
||||
{
|
||||
// For boundary blocks relax thresholds
|
||||
UINT32 BarBlockThresh = ppi->BlockThreshold / 10;
|
||||
UINT32 BarSGCThresh = ppi->BlockSgcThresh / 2;
|
||||
|
||||
INT32 i;
|
||||
|
||||
// Start by blanking the row in the bar block map structure.
|
||||
memset( BarBlockMapPtr, BLOCK_NOT_CODED, ppi->PlaneHFragments );
|
||||
|
||||
// First row
|
||||
if ( RowNumber == 0 )
|
||||
{
|
||||
|
||||
// For each fragment in the row.
|
||||
for ( i = 0; i < ppi->PlaneHFragments; i ++ )
|
||||
{
|
||||
// Test for CANDIDATE_BLOCK or CANDIDATE_BLOCK_LOW
|
||||
// Uncoded or coded blocks will be ignored.
|
||||
if ( UpdatedBlockMapPtr[i] <= CANDIDATE_BLOCK )
|
||||
{
|
||||
// Is one of the immediate neighbours updated in the main map.
|
||||
// Note special cases for blocks at the start and end of rows.
|
||||
if ( i == 0 )
|
||||
{
|
||||
|
||||
if ( (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( i == (ppi->PlaneHFragments - 1) )
|
||||
{
|
||||
|
||||
if ( (UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Last row
|
||||
// Used to read PlaneHFragments
|
||||
else if ( RowNumber == (UINT32)(ppi->PlaneVFragments-1))
|
||||
{
|
||||
|
||||
// For each fragment in the row.
|
||||
for ( i = 0; i < ppi->PlaneHFragments; i ++ )
|
||||
{
|
||||
// Test for CANDIDATE_BLOCK or CANDIDATE_BLOCK_LOW
|
||||
// Uncoded or coded blocks will be ignored.
|
||||
if ( UpdatedBlockMapPtr[i] <= CANDIDATE_BLOCK )
|
||||
{
|
||||
// Is one of the immediate neighbours updated in the main map.
|
||||
// Note special cases for blocks at the start and end of rows.
|
||||
if ( i == 0 )
|
||||
{
|
||||
if ( (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( i == (ppi->PlaneHFragments - 1) )
|
||||
{
|
||||
if ( (UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// All other rows
|
||||
else
|
||||
{
|
||||
// For each fragment in the row.
|
||||
for ( i = 0; i < ppi->PlaneHFragments; i ++ )
|
||||
{
|
||||
// Test for CANDIDATE_BLOCK or CANDIDATE_BLOCK_LOW
|
||||
// Uncoded or coded blocks will be ignored.
|
||||
if ( UpdatedBlockMapPtr[i] <= CANDIDATE_BLOCK )
|
||||
{
|
||||
// Is one of the immediate neighbours updated in the main map.
|
||||
// Note special cases for blocks at the start and end of rows.
|
||||
if ( i == 0 )
|
||||
{
|
||||
|
||||
if ( (UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
|
||||
}
|
||||
else if ( i == (ppi->PlaneHFragments - 1) )
|
||||
{
|
||||
|
||||
if ( (UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) )
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (UpdatedBlockMapPtr[i-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i-ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments-1] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments] > BLOCK_NOT_CODED ) ||
|
||||
(UpdatedBlockMapPtr[i+ppi->PlaneHFragments+1] > BLOCK_NOT_CODED ) )
|
||||
|
||||
{
|
||||
BarBlockMapPtr[i] = BLOCK_CODED_BAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : BarCopyBack
|
||||
*
|
||||
* INPUTS : INT8 * BarBlockMapPtr
|
||||
*
|
||||
* OUTPUTS : INT8 * UpdatedBlockMapPtr
|
||||
*
|
||||
* RETURNS : None.
|
||||
*
|
||||
* FUNCTION : Copies BAR blocks back into main block map.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void BarCopyBack( PP_INSTANCE *ppi,
|
||||
INT8 * UpdatedBlockMapPtr,
|
||||
INT8 * BarBlockMapPtr )
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
// For each fragment in the row.
|
||||
for ( i = 0; i < ppi->PlaneHFragments; i ++ )
|
||||
{
|
||||
if ( BarBlockMapPtr[i] > BLOCK_NOT_CODED )
|
||||
{
|
||||
UpdatedBlockMapPtr[i] = BarBlockMapPtr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : CreateOutputDisplayMap
|
||||
*
|
||||
* INPUTS : INT8 * InternalFragmentsPtr
|
||||
* Fragment list using internal format.
|
||||
* INT8 * RecentHistoryPtr
|
||||
* List of blocks that have been marked for update int he last few frames.
|
||||
*
|
||||
* UINT8 * ExternalFragmentsPtr
|
||||
* Fragment list using external format.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None.
|
||||
*
|
||||
* FUNCTION : Creates a block update map in the format expected by the caller.
|
||||
*
|
||||
* SPECIAL NOTES : The output block height and width must be an integer
|
||||
* multiple of the internal value.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void CreateOutputDisplayMap
|
||||
(
|
||||
PP_INSTANCE *ppi,
|
||||
INT8 *InternalFragmentsPtr
|
||||
)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 KFScore = 0;
|
||||
UINT32 YBand = (ppi->ScanYPlaneFragments/8); // 1/8th of Y image.
|
||||
|
||||
//#define DISPLAY_STATS
|
||||
#ifdef DISPLAY_STATS
|
||||
#include <stdio.h>
|
||||
{
|
||||
|
||||
FILE * StatsFilePtr;
|
||||
StatsFilePtr = fopen( "c:\\display_stats.stt", "a" );
|
||||
if ( StatsFilePtr )
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<ppi->ScanYPlaneFragments;i++)
|
||||
{
|
||||
if(i%ppi->ScanHFragments == 0 )
|
||||
fprintf( StatsFilePtr , "\n");
|
||||
|
||||
fprintf( StatsFilePtr, "%2d",
|
||||
InternalFragmentsPtr[i]);
|
||||
}
|
||||
fprintf( StatsFilePtr , "\n");
|
||||
fclose( StatsFilePtr );
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ppi->OutputBlocksUpdated = 0;
|
||||
for ( i = 0; i < ppi->ScanFrameFragments; i++ )
|
||||
{
|
||||
if ( InternalFragmentsPtr[i] > BLOCK_NOT_CODED )
|
||||
{
|
||||
ppi->OutputBlocksUpdated ++;
|
||||
setBlockCoded(i)
|
||||
}
|
||||
else
|
||||
{
|
||||
setBlockUncoded(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Now calculate a key frame candidate indicator.
|
||||
// This is based upon Y data only and only ignores the top and bottom 1/8 of the image.
|
||||
// Also ignore history blocks and BAR blocks.
|
||||
ppi->KFIndicator = 0;
|
||||
for ( i = YBand; i < (ppi->ScanYPlaneFragments - YBand); i++ )
|
||||
{
|
||||
if ( InternalFragmentsPtr[i] > BLOCK_CODED_BAR )
|
||||
{
|
||||
ppi->KFIndicator ++;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the KF score to a range 0-100
|
||||
ppi->KFIndicator = ((ppi->KFIndicator*100)/((ppi->ScanYPlaneFragments*3)/4));
|
||||
}
|
||||
96
Src/libvpShared/corelibs/cdxv/pp/generic/clamp.c
Normal file
96
Src/libvpShared/corelibs/cdxv/pp/generic/clamp.c
Normal file
@@ -0,0 +1,96 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : clamp.c
|
||||
*
|
||||
* Description : c
|
||||
*
|
||||
* AUTHOR : Jim Bankoski
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.09 YWX 26-Sep-01 Changed the default bandHeight from 5 to 4
|
||||
* 1.08 YWX 23-Jul-00 Changed horizontal scaling function names
|
||||
* 1.07 JBB 04 Dec 00 Added new Center vs Scale Bits
|
||||
* 1.06 YWX 01-Dec-00 Removed bi-cubic scale functions
|
||||
* 1.05 YWX 18-Oct-00 Added 1-2 scale functions
|
||||
* 1.04 YWX 11-Oct-00 Added ratio check to determine scaling or centering
|
||||
* 1.03 YWX 09-Oct-00 Added functions that do differen scaling in horizontal
|
||||
* and vertical directions
|
||||
* 1.02 YWX 04-Oct-00 Added 3-5 scaling functions
|
||||
* 1.01 YWX 03-Oct-00 Added a set of 4-5 scaling functions
|
||||
* 1.00 JBB 15 Sep 00 New Configuration baseline.
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
*****************************************************************************
|
||||
*/
|
||||
#include "postp.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Imported
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
void ClampLevels_C(
|
||||
POSTPROC_INSTANCE *pbi,
|
||||
INT32 BlackClamp, // number of values to clamp from 0
|
||||
INT32 WhiteClamp, // number of values to clamp from 255
|
||||
UINT8 *Src, // reconstruction buffer : passed in
|
||||
UINT8 *Dst // postprocessing buffer : passed in
|
||||
)
|
||||
{
|
||||
|
||||
unsigned char clamped[255];
|
||||
int width = pbi->HFragments*8;
|
||||
int height = pbi->VFragments*8; // Y plane will be done in two passes
|
||||
UINT8 *SrcPtr = Src + pbi->ReconYDataOffset;
|
||||
UINT8 *DestPtr = Dst + pbi->ReconYDataOffset;
|
||||
UINT32 LineLength = pbi->YStride * 2; // pitch is doubled for interlacing
|
||||
|
||||
// set up clamping table so we can avoid ifs while clamping
|
||||
int i;
|
||||
for(i=0;i<255;i++)
|
||||
{
|
||||
if(i<BlackClamp)
|
||||
clamped[i] = BlackClamp;
|
||||
|
||||
if(i>WhiteClamp)
|
||||
clamped[i] = WhiteClamp;
|
||||
}
|
||||
|
||||
Block = 0;
|
||||
|
||||
// clamping is for y only!
|
||||
for ( row = 0 ; row < height ; row ++)
|
||||
{
|
||||
for (col = 0; col < width ; col ++)
|
||||
{
|
||||
SrcPtr[col]=clamped[DestPtr[col]];
|
||||
}
|
||||
SrcPtr += LineLength;
|
||||
DestPtr += LineLength;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/****************************************************************************
|
||||
* Module constants.
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Exported Global Variables
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Module Static Variables
|
||||
*****************************************************************************
|
||||
*/
|
||||
2750
Src/libvpShared/corelibs/cdxv/pp/generic/cscanyuv.c
Normal file
2750
Src/libvpShared/corelibs/cdxv/pp/generic/cscanyuv.c
Normal file
File diff suppressed because it is too large
Load Diff
110
Src/libvpShared/corelibs/cdxv/pp/generic/preprocfunctions.c
Normal file
110
Src/libvpShared/corelibs/cdxv/pp/generic/preprocfunctions.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : PreProcFunctions.c
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
* AUTHOR : Paul Wilkins
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.00 JBB 22 Aug 00 Configuration baseline
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Header Files
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#define STRICT /* Strict type checking. */
|
||||
|
||||
#include "preproc.h"
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( disable : 4799 ) // Disable no emms instruction warning!
|
||||
#endif
|
||||
/****************************************************************************
|
||||
* Module constants.
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Imports.
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Exported Global Variables
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Exported Functions
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Module Statics
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Forward References
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : MachineSpecificConfig
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
* OUTPUTS : None
|
||||
*
|
||||
* RETURNS : None
|
||||
*
|
||||
* FUNCTION : Checks for machine specifc features such as MMX support
|
||||
* sets approipriate flags and function pointers.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
#define MMX_ENABLED 1
|
||||
void MachineSpecificConfig(PP_INSTANCE *ppi)
|
||||
{
|
||||
UINT32 FeatureFlags = 0;
|
||||
ppi->RowSAD = ScalarRowSAD;
|
||||
ppi->ColSAD = ScalarColSAD;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : ClearMmxState()
|
||||
*
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
* OUTPUTS :
|
||||
*
|
||||
* RETURNS :
|
||||
*
|
||||
*
|
||||
* FUNCTION : Clears down the MMX state
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void ClearMmxState(PP_INSTANCE *ppi)
|
||||
{
|
||||
return;
|
||||
}
|
||||
501
Src/libvpShared/corelibs/cdxv/pp/generic/preprocglobals.c
Normal file
501
Src/libvpShared/corelibs/cdxv/pp/generic/preprocglobals.c
Normal file
@@ -0,0 +1,501 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
252
Src/libvpShared/corelibs/cdxv/pp/generic/preprocif.c
Normal file
252
Src/libvpShared/corelibs/cdxv/pp/generic/preprocif.c
Normal file
@@ -0,0 +1,252 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Module Title : PreProcIf.c
|
||||
*
|
||||
* Description : Pre-processor dll interface module.
|
||||
*
|
||||
* AUTHOR : Paul Wilkins
|
||||
*
|
||||
*****************************************************************************
|
||||
* Revision History
|
||||
*
|
||||
* 1.09 PGW 27 Apr 01 Changes to use last frame coded list passed in from codec.
|
||||
* Removed code to set Y from UV.
|
||||
* 1.08 PGW 28 Feb 01 Removal of history buffer functionality.
|
||||
* 1.07 PGW 28 Feb 01 Removal of pre-processor output buffer.
|
||||
* 1.06 JBB 03 Aug 00 Added Malloc Checks
|
||||
* 1.05 PGW 27 Jul 00 Removed SetVcapParams() plus other housekeeping.
|
||||
* 1.04 PGW 10 Jul 00 Removed unused functions GetBlockStats(), BlockChangeVariance()
|
||||
* and GetBlockCategories().
|
||||
* Change interface to YUVAnalyseFrame() to include KF indicator.
|
||||
* 1.03 PGW 22/06/00 Removed speed specific code.
|
||||
* 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 <string.h>
|
||||
#include "type_aliases.h"
|
||||
#include "preproc.h"
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Module constants.
|
||||
*****************************************************************************
|
||||
*/
|
||||
#define MIN_STEP_THRESH 6
|
||||
|
||||
#define VARIANCE_THRESH 200
|
||||
#define LOW_VARIANCE_THRESH 100
|
||||
#define HIGH_SCORE 400
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Explicit Imports
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Exported Global Variables
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Foreward References
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Module Statics
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : ScanYUVInit
|
||||
*
|
||||
* INPUTS : SCAN_CONFIG_DATA * ScanConfigPtr
|
||||
* Configuration data.
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None.
|
||||
*
|
||||
* FUNCTION : Initialises the scan process.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
extern BOOL PAllocateFrameInfo(PP_INSTANCE * ppi);
|
||||
BOOL ScanYUVInit( PP_INSTANCE * ppi, SCAN_CONFIG_DATA * ScanConfigPtr)
|
||||
{
|
||||
// Test machine specific features such as MMX support
|
||||
MachineSpecificConfig(ppi);
|
||||
|
||||
/* Set up the various imported data structure pointers. */
|
||||
ppi->ScanConfig.Yuv0ptr = ScanConfigPtr->Yuv0ptr;
|
||||
ppi->ScanConfig.Yuv1ptr = ScanConfigPtr->Yuv1ptr;
|
||||
ppi->ScanConfig.FragInfo = ScanConfigPtr->FragInfo;
|
||||
ppi->ScanConfig.FragInfoElementSize = ScanConfigPtr->FragInfoElementSize;
|
||||
ppi->ScanConfig.FragInfoCodedMask = ScanConfigPtr->FragInfoCodedMask ;
|
||||
|
||||
ppi->ScanConfig.RegionIndex = ScanConfigPtr->RegionIndex;
|
||||
ppi->ScanConfig.HFragPixels = ScanConfigPtr->HFragPixels;
|
||||
ppi->ScanConfig.VFragPixels = ScanConfigPtr->VFragPixels;
|
||||
|
||||
ppi->ScanConfig.VideoFrameWidth = ScanConfigPtr->VideoFrameWidth;
|
||||
ppi->ScanConfig.VideoFrameHeight = ScanConfigPtr->VideoFrameHeight;
|
||||
|
||||
// UV plane sizes.
|
||||
ppi->VideoUVPlaneWidth = ScanConfigPtr->VideoFrameWidth / 2;
|
||||
ppi->VideoUVPlaneHeight = ScanConfigPtr->VideoFrameHeight / 2;
|
||||
|
||||
/* Note the size of the entire frame and plaes in pixels. */
|
||||
ppi->YFramePixels = ppi->ScanConfig.VideoFrameWidth * ppi->ScanConfig.VideoFrameHeight;
|
||||
ppi->UVFramePixels = ppi->VideoUVPlaneWidth * ppi->VideoUVPlaneHeight;
|
||||
ppi->TotFramePixels = ppi->YFramePixels + (2 * ppi->UVFramePixels);
|
||||
|
||||
/* Work out various fragment related values. */
|
||||
ppi->ScanYPlaneFragments = ppi->YFramePixels / (ppi->HFragPixels * ppi->VFragPixels);
|
||||
ppi->ScanUVPlaneFragments = ppi->UVFramePixels / (ppi->HFragPixels * ppi->VFragPixels);;
|
||||
ppi->ScanHFragments = ppi->ScanConfig.VideoFrameWidth / ppi->HFragPixels;
|
||||
ppi->ScanVFragments = ppi->ScanConfig.VideoFrameHeight / ppi->VFragPixels;
|
||||
ppi->ScanFrameFragments = ppi->ScanYPlaneFragments + (2 * ppi->ScanUVPlaneFragments);
|
||||
|
||||
if(!PAllocateFrameInfo(ppi))
|
||||
return FALSE;
|
||||
|
||||
/* Set up the scan pixel index table. */
|
||||
ScanCalcPixelIndexTable(ppi);
|
||||
|
||||
/* Initialise scan arrays */
|
||||
InitScanMapArrays(ppi);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : YUVAnalyseFrame
|
||||
*
|
||||
* INPUTS : None
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : Number of "output" blocks to be updated.
|
||||
*
|
||||
* FUNCTION : Scores the fragments for the YUV planes
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
UINT32 YUVAnalyseFrame( PP_INSTANCE *ppi, UINT32 * KFIndicator )
|
||||
{
|
||||
UINT32 UpdatedYBlocks = 0;
|
||||
UINT32 UpdatedUVBlocks = 0;
|
||||
UINT32 i;
|
||||
|
||||
/* Initialise the map arrays. */
|
||||
InitScanMapArrays(ppi);
|
||||
|
||||
/********** PGW 27/APR/2001 ***********/
|
||||
// If the block is already marked as coded in the input block map then
|
||||
// mark it as coded here to avoid unnecessary pre-processor work.
|
||||
for ( i = 0; i < ppi->ScanFrameFragments; i++ )
|
||||
{
|
||||
|
||||
if ( blockCoded(i) )
|
||||
ppi->ScanDisplayFragments[i] = BLOCK_ALREADY_MARKED_FOR_CODING;
|
||||
}
|
||||
|
||||
// If the motion level in the previous frame was high then adjust the high and low SAD
|
||||
// thresholds to speed things up.
|
||||
ppi->ModifiedGrpLowSadThresh = ppi->GrpLowSadThresh;
|
||||
ppi->ModifiedGrpHighSadThresh = ppi->GrpHighSadThresh;
|
||||
// testing force every block with any change to get coded
|
||||
//ppi->ModifiedGrpHighSadThresh = 0;
|
||||
|
||||
// Set up the internal plane height and width variables.
|
||||
ppi->VideoYPlaneWidth = ppi->ScanConfig.VideoFrameWidth;
|
||||
ppi->VideoYPlaneHeight = ppi->ScanConfig.VideoFrameHeight;
|
||||
ppi->VideoUVPlaneWidth = ppi->ScanConfig.VideoFrameWidth / 2;
|
||||
ppi->VideoUVPlaneHeight = ppi->ScanConfig.VideoFrameHeight / 2;
|
||||
|
||||
// To start with *** TBD **** the stides will be set from the widths
|
||||
ppi->VideoYPlaneStride = ppi->VideoYPlaneWidth;
|
||||
ppi->VideoUPlaneStride = ppi->VideoUVPlaneWidth;
|
||||
ppi->VideoVPlaneStride = ppi->VideoUVPlaneWidth;
|
||||
|
||||
// Set up the plane pointers
|
||||
ppi->YPlanePtr0 = ppi->ScanConfig.Yuv0ptr;
|
||||
ppi->YPlanePtr1 = ppi->ScanConfig.Yuv1ptr;
|
||||
ppi->UPlanePtr0 = (ppi->ScanConfig.Yuv0ptr + ppi->YFramePixels);
|
||||
ppi->UPlanePtr1 = (ppi->ScanConfig.Yuv1ptr + ppi->YFramePixels);
|
||||
ppi->VPlanePtr0 = (ppi->ScanConfig.Yuv0ptr + ppi->YFramePixels + ppi->UVFramePixels);
|
||||
ppi->VPlanePtr1 = (ppi->ScanConfig.Yuv1ptr + ppi->YFramePixels + ppi->UVFramePixels);
|
||||
|
||||
// Ananlyse the U and V palnes.
|
||||
AnalysePlane( ppi, ppi->UPlanePtr0, ppi->UPlanePtr1, ppi->ScanYPlaneFragments, ppi->VideoUVPlaneWidth, ppi->VideoUVPlaneHeight, ppi->VideoUPlaneStride );
|
||||
AnalysePlane( ppi, ppi->VPlanePtr0, ppi->VPlanePtr1, (ppi->ScanYPlaneFragments + ppi->ScanUVPlaneFragments), ppi->VideoUVPlaneWidth, ppi->VideoUVPlaneHeight, ppi->VideoVPlaneStride );
|
||||
|
||||
// Now analyse the Y plane.
|
||||
AnalysePlane( ppi, ppi->YPlanePtr0, ppi->YPlanePtr1, 0, ppi->VideoYPlaneWidth, ppi->VideoYPlaneHeight, ppi->VideoYPlaneStride );
|
||||
|
||||
// Create an output block map for the calling process.
|
||||
CreateOutputDisplayMap( ppi, ppi->ScanDisplayFragments);
|
||||
|
||||
// Set the candidate key frame indicator (0-100)
|
||||
*KFIndicator = ppi->KFIndicator;
|
||||
|
||||
// Return the normalised block count (this is actually a motion level
|
||||
// weighting not a true block count).
|
||||
return ppi->OutputBlocksUpdated;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* ROUTINE : SetScanParam
|
||||
*
|
||||
* INPUTS : ParamID
|
||||
* ParamValue
|
||||
*
|
||||
* OUTPUTS : None.
|
||||
*
|
||||
* RETURNS : None.
|
||||
*
|
||||
* FUNCTION : Sets a scan parameter.
|
||||
*
|
||||
* SPECIAL NOTES : None.
|
||||
*
|
||||
*
|
||||
* ERRORS : None.
|
||||
*
|
||||
****************************************************************************/
|
||||
void SetScanParam( PP_INSTANCE *ppi, UINT32 ParamId, INT32 ParamValue )
|
||||
{
|
||||
switch (ParamId)
|
||||
{
|
||||
|
||||
case SCP_SET_VCAP_LEVEL_OFFSET:
|
||||
SetVcapLevelOffset(ppi, ParamValue);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user