#ifdef CFG_SHARP_INTRA

#ifndef _UPSAMPLE_
#define _UPSAMPLE_

#ifdef CFG_SHARP_DISABLE
#define FILTERS_MAX	   1
#else
#define FILTERS_MAX    4
#endif

#define FILTER_TAPS    8
#define FILTERS_PHASE  2
#define FILTER_BANKS   1

#define FILTERBANK_4X4 0
#define FILTERBANK_8X8 0

//#define LOAD_EXTERNAL_FILTERS

// REALLY SIMPLE FILTERS
#define UP_FILTER1   int piFilter1 [16] = {  0,  0,  1,  0,  -5,  0, 20,   32,   20,    0,  -5,  0,  1,  0,  0,   64 };
#define UP_FILTER2   int piFilter2 [16] = {  0,  0,  0,  0,   0,  0,  8,   32,   32,    0,  -8,  0,  0,  0,  0,   64 };
#define UP_FILTER3   int piFilter3 [16] = {  0,  0,  0,  0,  -8,  0, 32,   32,    8,    0,   0,  0,  0,  0,  0,   64 };
#define UP_FILTER4   int piFilter4 [16] = {  0,  0,  0,  0,   0,  0, 16,   32,   16,    0,   0,  0,  0,  0,  0,   64 };

#define FILTER_DEF UP_FILTER

H264AVC_NAMESPACE_BEGIN

class H264AVCCOMMONLIB_API Upsample
{
protected:
  Upsample ();
  ~Upsample();

public:
  static ErrVal create( Upsample*& rpcUpsample );
  ErrVal destroy();  
  
  ErrVal upsample4x4Blk			( IntYuvMbBuffer* pcPelData,
								  IntYuvMbBufferExtension* pcSrcData,
								  int hfilter_id,
								  int vfilter_id );

  ErrVal upsample4x4Blk			( XPel* pSrc, 
								  int iSrcStride, 
								  XPel* pDst, 
								  int iDstStride, 
								  int hfilter_id, 
								  int vfilter_id );

  ErrVal upsample8x8Blk			( IntYuvMbBuffer* pcPelData,
								  IntYuvMbBufferExtension* pcSrcData,
								  int hfilter_id,
								  int vfilter_id );

  ErrVal upsample8x8Blk			( XPel* pSrc, 
								  int iSrcStride, 
								  XPel* pDst, 
								  int iDstStride, 
								  int hfilter_id, 
								  int vfilter_id );

  ErrVal upsample16x16Blk		( XPel* pSrc, 
								  int iSrcStride, 
								  XPel* pDst, 
								  int iDstStride, 
								  int hfilter_id, 
								  int vfilter_id );

  ErrVal upsample16x16Blk		( IntYuvMbBuffer* pcPelData,
								  IntYuvMbBufferExtension* pcSrcData,
								  int hfilter_id,
								  int vfilter_id );

  int NumFilters				( ){ return FILTERS_MAX; };

  
private:

	ErrVal init                    ( );
	
	void xInterpolate4x4Blk       ( short *piSrcBuffer, 
									short *piDstBuffer,
									int iSrcStride, 
									int iDstStride,
									int iHFilterID,
									int iVFilterID,
									int iBankID );									
	
	void xInterpolate8x8Blk       ( short *piSrcBuffer, 
									short *piDstBuffer,
									int iSrcStride, 
									int iDstStride,
									int iHFilterID,
									int iVFilterID );

	void xInterpolate16x16Blk	( short *piSrcBuffer, 
								  short *piDstBuffer,
								  int iSrcStride, 
								  int iDstStride,
								  int iHFilterID, 
								  int iVFilterID );

	void xLoadFilter			  ( int*				piFilter,
									int                 FilterID );

	void xLoadFilter			  ( int*				piFilter,
									int					BankID,
									int                 FilterID );

	void xLoadFilter			  ( int*                piFilterList[FILTERS_MAX] );

	int* xGetFilter				  ( int BankID, int iFilterID );

    
private:
	Bool*  m_pabFilterLoaded;
	int**  m_paiFilterBank;
  
};


H264AVC_NAMESPACE_END

#endif // _UPSAMPLE_

#endif
