Merge pull request #1015 from huili2/astyle_all_UT

astyle all
This commit is contained in:
ruil2 2014-06-26 10:25:56 +08:00
commit e1152f9483
85 changed files with 4734 additions and 4529 deletions

View File

@ -413,9 +413,9 @@ typedef struct TagLevelInfo {
ELevelIdc uiLevelIdc; //the level info
} SLevelInfo;
typedef struct TagDeliveryStatus{
typedef struct TagDeliveryStatus {
int iDropNum; //the number of video frames that are dropped continuously before delivery to encoder, which is used by screen content.
int iDropFrameType; // the frame type that is dropped
int iDropFrameSize; // the frame size that is dropped
}SDeliveryStatus;
} SDeliveryStatus;
#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__

View File

@ -34,6 +34,6 @@
@interface DEMOAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow* window;
@end

View File

@ -32,18 +32,17 @@
#import <UIKit/UIKit.h>
@interface DEMOViewController : UIViewController
{
BOOL bEnableFlag;
@interface DEMOViewController : UIViewController {
BOOL bEnableFlag;
}
@property (strong, nonatomic) NSMutableArray *resFileArray;
@property (retain, nonatomic)UIAlertView *statusIndication;
@property (strong, nonatomic) NSMutableArray* resFileArray;
@property (retain, nonatomic)UIAlertView* statusIndication;
@property (assign, nonatomic) NSUInteger selectedRow;
- (IBAction)startDecoderAll:(id)sender;
- (IBAction)startDecoderOne:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *currentSelectedFileTF;
- (IBAction)startDecoderAll: (id)sender;
- (IBAction)startDecoderOne: (id)sender;
@property (weak, nonatomic) IBOutlet UITextField* currentSelectedFileTF;
//unwind segue
- (IBAction)unwindSegueForShowResourceViewController:(UIStoryboardSegue *)segue;
- (IBAction)unwindSegueForShowResourceViewController: (UIStoryboardSegue*)segue;
@end

View File

@ -33,6 +33,6 @@
#import <UIKit/UIKit.h>
@interface DEMOViewControllerShowResource : UITableViewController
@property (strong, nonatomic) NSMutableArray *resFileArray;
@property (strong, nonatomic) NSMutableArray* resFileArray;
@property (assign, nonatomic) NSUInteger selectedRow;
@end

View File

@ -34,6 +34,6 @@
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow* window;
@end

View File

@ -33,12 +33,12 @@
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
UILabel * statusText_;
UILabel* statusText_;
}
@property (retain, nonatomic) IBOutlet UILabel * statusText;
@property (retain, nonatomic) IBOutlet UILabel* statusText;
-(IBAction) buttonPressed:(id)sender;
- (IBAction) buttonPressed: (id)sender;
@end

View File

@ -56,10 +56,10 @@ void DeblockLumaEq4V_AArch64_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlp
void DeblockLumaLt4H_AArch64_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc);
void DeblockLumaEq4H_AArch64_neon (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4V_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
int8_t* pTC);
void DeblockChromaEq4V_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
void DeblockChromaLt4H_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
int8_t* pTC);
int8_t* pTC);
void DeblockChromaEq4H_AArch64_neon (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta);
#endif
#if defined(__cplusplus)

View File

@ -161,7 +161,8 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt&
return -1;
}
if (pDLayer->iMaxSpatialBitrate < pDLayer->iSpatialBitrate) {
fprintf (stderr, "Invalid max spatial(#%d) bitrate(%d) setting::: < layerBitrate(%d)!\n", iLayer, pDLayer->iMaxSpatialBitrate, pDLayer->iSpatialBitrate);
fprintf (stderr, "Invalid max spatial(#%d) bitrate(%d) setting::: < layerBitrate(%d)!\n", iLayer,
pDLayer->iMaxSpatialBitrate, pDLayer->iSpatialBitrate);
return -1;
}
}
@ -436,7 +437,7 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
pSvcParam.iLtrMarkPeriod = atoi (argv[n++]);
else if (!strcmp (pCommand, "-threadIdc") && (n < argc))
pSvcParam.iMultipleThreadIdc= atoi (argv[n++]);
pSvcParam.iMultipleThreadIdc = atoi (argv[n++]);
else if (!strcmp (pCommand, "-deblockIdc") && (n < argc))
pSvcParam.iLoopFilterDisableIdc = atoi (argv[n++]);
@ -454,15 +455,14 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
g_LevelSetting = atoi (argv[n++]);
else if (!strcmp (pCommand, "-tarb") && (n < argc))
pSvcParam.iTargetBitrate = 1000*atoi (argv[n++]);
pSvcParam.iTargetBitrate = 1000 * atoi (argv[n++]);
else if (!strcmp (pCommand, "-maxbrTotal") && (n < argc))
pSvcParam.iMaxBitrate = 1000*atoi (argv[n++]);
pSvcParam.iMaxBitrate = 1000 * atoi (argv[n++]);
else if (!strcmp (pCommand, "-numl") && (n < argc)) {
pSvcParam.iSpatialLayerNum = atoi (argv[n++]);
}
else if (!strcmp (pCommand, "-lconfig") && (n < argc)) {
} else if (!strcmp (pCommand, "-lconfig") && (n < argc)) {
unsigned int iLayer = atoi (argv[n++]);
sFileSet.strLayerCfgFile[iLayer].assign (argv[n++]);
CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]);
@ -630,7 +630,7 @@ int FillSpecificParameters (SEncParamExt& sParam) {
return 0;
}
int ProcessEncoding(ISVCEncoder* pPtrEnc, int argc, char** argv,bool bConfigFile) {
int ProcessEncoding (ISVCEncoder* pPtrEnc, int argc, char** argv, bool bConfigFile) {
int iRet = 0;
if (pPtrEnc == NULL)
@ -677,7 +677,7 @@ int ProcessEncoding(ISVCEncoder* pPtrEnc, int argc, char** argv,bool bConfigFile
pSrcPic->uiTimeStamp = 0;
// if configure file exit, reading configure file firstly
if(bConfigFile){
if (bConfigFile) {
iParsedNum = 2;
cRdCfg.Openf (argv[1]);
if (!cRdCfg.ExistFile()) {
@ -969,7 +969,7 @@ int main (int argc, char** argv)
} else {
if (!strstr (argv[1], ".cfg")) { // check configuration type (like .cfg?)
if (argc > 2) {
iRet = ProcessEncoding(pSVCEncoder, argc, argv,false);
iRet = ProcessEncoding (pSVCEncoder, argc, argv, false);
if (iRet != 0)
goto exit;
} else if (argc == 2 && ! strcmp (argv[1], "-h"))
@ -979,7 +979,7 @@ int main (int argc, char** argv)
goto exit;
}
} else {
iRet = ProcessEncoding(pSVCEncoder, argc, argv,true);
iRet = ProcessEncoding (pSVCEncoder, argc, argv, true);
if (iRet > 0)
goto exit;
}

View File

@ -58,11 +58,11 @@
namespace WelsDec {
typedef struct TagDataBuffer {
uint8_t* pHead;
uint8_t* pEnd;
uint8_t* pHead;
uint8_t* pEnd;
uint8_t* pStartPos;
uint8_t* pCurPos;
uint8_t* pStartPos;
uint8_t* pCurPos;
} SDataBuffer;
//#ifdef __cplusplus
@ -83,40 +83,40 @@ typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const
/**/
typedef struct TagRefPic {
PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT];
PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT];
uint8_t uiRefCount[LIST_A];
uint8_t uiShortRefCount[LIST_A];
uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module
int32_t iMaxLongTermFrameIdx;
PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
PPicture pShortRefList[LIST_A][MAX_SHORT_REF_COUNT];
PPicture pLongRefList[LIST_A][MAX_LONG_REF_COUNT];
uint8_t uiRefCount[LIST_A];
uint8_t uiShortRefCount[LIST_A];
uint8_t uiLongRefCount[LIST_A]; // dependend on ref pic module
int32_t iMaxLongTermFrameIdx;
} SRefPic, *PRefPic;
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
typedef struct TagMcFunc {
PWelsMcFunc pMcLumaFunc;
PWelsMcFunc pMcChromaFunc;
PWelsMcFunc pMcLumaFunc;
PWelsMcFunc pMcChromaFunc;
} SMcFunc;
typedef void (*PCopyFunc) (uint8_t* pDst, int32_t iStrideD, uint8_t* pSrc, int32_t iStrideS);
typedef struct TagCopyFunc {
PCopyFunc pCopyLumaFunc;
PCopyFunc pCopyChromaFunc;
PCopyFunc pCopyLumaFunc;
PCopyFunc pCopyChromaFunc;
} SCopyFunc;
//deblock module defination
struct TagDeblockingFunc;
typedef struct tagDeblockingFilter {
uint8_t* pCsData[3]; // pointer to reconstructed picture data
int32_t iCsStride[2]; // Cs stride
ESliceType eSliceType;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
int8_t iChromaQP;
int8_t iLumaQP;
struct TagDeblockingFunc* pLoopf;
uint8_t* pCsData[3]; // pointer to reconstructed picture data
int32_t iCsStride[2]; // Cs stride
ESliceType eSliceType;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
int8_t iChromaQP;
int8_t iLumaQP;
struct TagDeblockingFunc* pLoopf;
} SDeblockingFilter, *PDeblockingFilter;
typedef void (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag);
@ -129,21 +129,21 @@ typedef void (*PChromaDeblockingEQ4Func) (uint8_t* iSampleCb, uint8_t* iSampleCr
int32_t iBeta);
typedef struct TagDeblockingFunc {
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Ver;
PLumaDeblockingLT4Func pfLumaDeblockingLT4Hor;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Hor;
PLumaDeblockingLT4Func pfLumaDeblockingLT4Ver;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Ver;
PLumaDeblockingLT4Func pfLumaDeblockingLT4Hor;
PLumaDeblockingEQ4Func pfLumaDeblockingEQ4Hor;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Ver;
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Ver;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Hor;
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Hor;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Ver;
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Ver;
PChromaDeblockingLT4Func pfChromaDeblockingLT4Hor;
PChromaDeblockingEQ4Func pfChromaDeblockingEQ4Hor;
} SDeblockingFunc, *PDeblockingFunc;
typedef void (*PWelsNonZeroCountFunc) (int8_t* pNonZeroCount);
typedef struct TagBlockFunc {
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
PWelsNonZeroCountFunc pWelsSetNonZeroCountFunc;
} SBlockFunc;
typedef void (*PWelsFillNeighborMbInfoIntra4x4Func) (PNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
@ -153,10 +153,10 @@ typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PNeighAvail pNeighAvail, int8_t*
typedef int32_t (*PWelsParseIntra16x16ModeFunc) (PNeighAvail pNeighAvail, PBitStringAux pBs, PDqLayer pCurDqLayer);
enum {
OVERWRITE_NONE = 0,
OVERWRITE_PPS = 1,
OVERWRITE_SPS = 1 << 1,
OVERWRITE_SUBSETSPS = 1 << 2
OVERWRITE_NONE = 0,
OVERWRITE_PPS = 1,
OVERWRITE_SPS = 1 << 1,
OVERWRITE_SUBSETSPS = 1 << 2
};
/*
@ -164,173 +164,173 @@ enum {
*/
typedef struct TagWelsDecoderContext {
SLogContext sLogCtx;
// Input
void* pArgDec; // structured arguments for decoder, reserved here for extension in the future
SLogContext sLogCtx;
// Input
void* pArgDec; // structured arguments for decoder, reserved here for extension in the future
SDataBuffer sRawData;
SDataBuffer sRawData;
// Configuration
SDecodingParam* pParam;
uint32_t uiCpuFlag; // CPU compatibility detected
// Configuration
SDecodingParam* pParam;
uint32_t uiCpuFlag; // CPU compatibility detected
int32_t iOutputColorFormat; // color space format to be outputed
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
bool bErrorResilienceFlag; // error resilience flag
bool bHaveGotMemory; // global memory for decoder context related ever requested?
int32_t iOutputColorFormat; // color space format to be outputed
VIDEO_BITSTREAM_TYPE eVideoType; //indicate the type of video to decide whether or not to do qp_delta error detection.
bool bErrorResilienceFlag; // error resilience flag
bool bHaveGotMemory; // global memory for decoder context related ever requested?
int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output
int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output
int32_t iImgWidthInPixel; // width of image in pixel reconstruction picture to be output
int32_t iImgHeightInPixel;// height of image in pixel reconstruction picture to be output
// Derived common elements
SNalUnitHeader sCurNalHead;
ESliceType eSliceType; // Slice type
int32_t iFrameNum;
int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
bool bLastHasMmco5; //
int32_t iErrorCode; // error code return while decoding in case packets lost
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
PFmo pFmo; // current fmo context after parsed slice_header
int32_t iActiveFmoNum; // active count number of fmo context in list
// Derived common elements
SNalUnitHeader sCurNalHead;
ESliceType eSliceType; // Slice type
int32_t iFrameNum;
int32_t iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
bool bLastHasMmco5; //
int32_t iErrorCode; // error code return while decoding in case packets lost
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
PFmo pFmo; // current fmo context after parsed slice_header
int32_t iActiveFmoNum; // active count number of fmo context in list
/*needed info by decode slice level and mb level*/
int32_t
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
/*needed info by decode slice level and mb level*/
int32_t
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
struct {
int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
int8_t* pChromaQp[LAYER_NUM_EXCHANGEABLE]; /*mb chroma_qp*/
int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
int8_t* pCbp[LAYER_NUM_EXCHANGEABLE];
uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE];
int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc
int8_t* pResidualPredFlag[LAYER_NUM_EXCHANGEABLE];
int8_t* pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE];
bool* pMbCorrectlyDecodedFlag[LAYER_NUM_EXCHANGEABLE];
uint32_t iMbWidth;
uint32_t iMbHeight;
} sMb;
struct {
int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
int8_t* pChromaQp[LAYER_NUM_EXCHANGEABLE]; /*mb chroma_qp*/
int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
int8_t* pCbp[LAYER_NUM_EXCHANGEABLE];
uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
int8_t (*pSubMbType[LAYER_NUM_EXCHANGEABLE])[MB_SUB_PARTITION_SIZE];
int32_t* pSliceIdc[LAYER_NUM_EXCHANGEABLE]; // using int32_t for slice_idc
int8_t* pResidualPredFlag[LAYER_NUM_EXCHANGEABLE];
int8_t* pInterPredictionDoneFlag[LAYER_NUM_EXCHANGEABLE];
bool* pMbCorrectlyDecodedFlag[LAYER_NUM_EXCHANGEABLE];
uint32_t iMbWidth;
uint32_t iMbHeight;
} sMb;
// reconstruction picture
PPicture pDec; //pointer to current picture being reconstructed
// reconstruction picture
PPicture pDec; //pointer to current picture being reconstructed
// reference pictures
SRefPic sRefPic;
// reference pictures
SRefPic sRefPic;
SVlcTable sVlcTable; // vlc table
SVlcTable sVlcTable; // vlc table
SBitStringAux sBs;
int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer
SBitStringAux sBs;
int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer
/* Global memory external */
/* Global memory external */
SPosOffset sFrameCrop;
SPosOffset sFrameCrop;
SSps sSpsBuffer[MAX_SPS_COUNT + 1];
SPps sPpsBuffer[MAX_PPS_COUNT + 1];
PSliceHeader pSliceHeader;
SSps sSpsBuffer[MAX_SPS_COUNT + 1];
SPps sPpsBuffer[MAX_PPS_COUNT + 1];
PSliceHeader pSliceHeader;
PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding.
int32_t iPicQueueNumber;
PPicBuff pPicBuff[LIST_A]; // Initially allocated memory for pictures which are used in decoding.
int32_t iPicQueueNumber;
SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1];
SNalUnit sPrefixNal;
SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1];
SNalUnit sPrefixNal;
PAccessUnit pAccessUnitList; // current access unit list to be performed
PSps pActiveLayerSps[MAX_LAYER_NUM];
PSps pSps; // used by current AU
PPps pPps; // used by current AU
// Memory for pAccessUnitList is dynamically held till decoder destruction.
PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
PAccessUnit pAccessUnitList; // current access unit list to be performed
PSps pActiveLayerSps[MAX_LAYER_NUM];
PSps pSps; // used by current AU
PPps pPps; // used by current AU
// Memory for pAccessUnitList is dynamically held till decoder destruction.
PDqLayer pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
int32_t iPicWidthReq; // picture width have requested the memory
int32_t iPicHeightReq; // picture height have requested the memory
int32_t iPicWidthReq; // picture width have requested the memory
int32_t iPicHeightReq; // picture height have requested the memory
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
bool bAvcBasedFlag; // For decoding bitstream:
bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer
bool bInstantDecFlag; // Flag for no-delay decoding
bool bInitialDqLayersMem; // dq layers related memory is available?
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
bool bAvcBasedFlag; // For decoding bitstream:
bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer
bool bInstantDecFlag; // Flag for no-delay decoding
bool bInitialDqLayersMem; // dq layers related memory is available?
bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
// for EC parameter sets
bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
// for EC parameter sets
bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
bool bSpsAvailFlags[MAX_SPS_COUNT];
bool bSubspsAvailFlags[MAX_SPS_COUNT];
bool bPpsAvailFlags[MAX_PPS_COUNT];
bool bReferenceLostAtT0Flag;
int32_t iTotalNumMbRec; //record current number of decoded MB
bool bSpsAvailFlags[MAX_SPS_COUNT];
bool bSubspsAvailFlags[MAX_SPS_COUNT];
bool bPpsAvailFlags[MAX_PPS_COUNT];
bool bReferenceLostAtT0Flag;
int32_t iTotalNumMbRec; //record current number of decoded MB
#ifdef LONG_TERM_REF
bool bParamSetsLostFlag; //sps or pps do not exist or not correct
bool bParamSetsLostFlag; //sps or pps do not exist or not correct
bool
bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
bool
bCurAuContainLtrMarkSeFlag; //current AU has the LTR marking syntax element, mark the previous frame or self
int32_t iFrameNumOfAuMarkedLtr; //if bCurAuContainLtrMarkSeFlag==true, SHOULD set this variable
uint16_t uiCurIdrPicId;
uint16_t uiCurIdrPicId;
#endif
bool bNewSeqBegin;
bool bNextNewSeqBegin;
int iOverwriteFlags;
int32_t iErrorConMethod; //
PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
PIdctResAddPredFunc pIdctResAddPredFunc;
SMcFunc sMcFunc;
bool bNewSeqBegin;
bool bNextNewSeqBegin;
int iOverwriteFlags;
int32_t iErrorConMethod; //
PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
PIdctResAddPredFunc pIdctResAddPredFunc;
SMcFunc sMcFunc;
//For error concealment
SCopyFunc sCopyFunc;
/* For Deblocking */
SDeblockingFunc sDeblockingFunc;
SExpandPicFunc sExpandPicFunc;
//For error concealment
SCopyFunc sCopyFunc;
/* For Deblocking */
SDeblockingFunc sDeblockingFunc;
SExpandPicFunc sExpandPicFunc;
/* For Block */
SBlockFunc sBlockFunc;
/* For Block */
SBlockFunc sBlockFunc;
int32_t iCurSeqIntervalTargetDependId;
int32_t iCurSeqIntervalMaxPicWidth;
int32_t iCurSeqIntervalMaxPicHeight;
int32_t iCurSeqIntervalTargetDependId;
int32_t iCurSeqIntervalMaxPicWidth;
int32_t iCurSeqIntervalMaxPicHeight;
PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
PWelsParseIntra4x4ModeFunc pParseIntra4x4ModeFunc;
PWelsParseIntra16x16ModeFunc pParseIntra16x16ModeFunc;
PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
PWelsParseIntra4x4ModeFunc pParseIntra4x4ModeFunc;
PWelsParseIntra16x16ModeFunc pParseIntra16x16ModeFunc;
//feedback whether or not have VCL in current AU, and the temporal ID
int32_t iFeedbackVclNalInAu;
int32_t iFeedbackTidInAu;
//feedback whether or not have VCL in current AU, and the temporal ID
int32_t iFeedbackVclNalInAu;
int32_t iFeedbackTidInAu;
bool bAuReadyFlag; // true: one au is ready for decoding; false: default value
bool bAuReadyFlag; // true: one au is ready for decoding; false: default value
//trace handle
void* pTraceHandle;
//trace handle
void* pTraceHandle;
//Save the last nal header info
SNalUnitHeaderExt sLastNalHdrExt;
SSliceHeader sLastSliceHeader;
//Save the last nal header info
SNalUnitHeaderExt sLastNalHdrExt;
SSliceHeader sLastSliceHeader;
} SWelsDecoderContext, *PWelsDecoderContext;
static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
pCtx->pActiveLayerSps[i] = NULL;
}
for (int i = 0; i < MAX_LAYER_NUM; i++) {
pCtx->pActiveLayerSps[i] = NULL;
}
}
//#ifdef __cplusplus
//}

View File

@ -43,12 +43,12 @@
namespace WelsDec {
typedef enum TagWelsErr {
ERR_NONE = 0,
ERR_INVALID_PARAMETERS = 1,
ERR_MALLOC_FAILED = 2,
ERR_API_FAILED = 3,
ERR_NONE = 0,
ERR_INVALID_PARAMETERS = 1,
ERR_MALLOC_FAILED = 2,
ERR_API_FAILED = 3,
ERR_BOUND = 31,
ERR_BOUND = 31,
} EWelsErr;
/*
@ -62,13 +62,13 @@ typedef enum TagWelsErr {
/* ERR_LEVEL */
//-----------------------------------------------------------------------------------------------------------
enum {
ERR_LEVEL_ACCESS_UNIT = 1,
ERR_LEVEL_NAL_UNIT_HEADER,
ERR_LEVEL_PREFIX_NAL,
ERR_LEVEL_PARAM_SETS,
ERR_LEVEL_SLICE_HEADER,
ERR_LEVEL_SLICE_DATA,
ERR_LEVEL_MB_DATA,
ERR_LEVEL_ACCESS_UNIT = 1,
ERR_LEVEL_NAL_UNIT_HEADER,
ERR_LEVEL_PREFIX_NAL,
ERR_LEVEL_PARAM_SETS,
ERR_LEVEL_SLICE_HEADER,
ERR_LEVEL_SLICE_DATA,
ERR_LEVEL_MB_DATA,
};
//-----------------------------------------------------------------------------------------------------------
@ -79,108 +79,108 @@ enum {
#define ERR_INFO_SYNTAX_BASE 1001
#define ERR_INFO_LOGIC_BASE 10001
enum {
/* Error from common system level: 1-1000 */
ERR_INFO_OUT_OF_MEMORY = ERR_INFO_COMMON_BASE,
ERR_INFO_INVALID_ACCESS,
ERR_INFO_INVALID_PTR,
ERR_INFO_INVALID_PARAM,
ERR_INFO_FILE_NO_FOUND,
ERR_INFO_PATH_NO_FOUND,
ERR_INFO_ACCESS_DENIED,
ERR_INFO_NOT_READY,
ERR_INFO_WRITE_FAULT,
ERR_INFO_READ_FAULT,
ERR_INFO_READ_OVERFLOW,
ERR_INFO_READ_LEADING_ZERO,
/* Error from H.264 syntax elements parser: 1001-10000 */
ERR_INFO_NO_PREFIX_CODE = ERR_INFO_SYNTAX_BASE, // No start prefix code indication
ERR_INFO_NO_PARAM_SETS, // No SPS and/ PPS before sequence header
ERR_INFO_PARAM_SETS_NOT_INTEGRATED, // Parameters sets (sps/pps) are not integrated at all before to decode VCL nal
ERR_INFO_SPS_ID_OVERFLOW,
ERR_INFO_PPS_ID_OVERFLOW,
ERR_INFO_INVALID_PROFILE_IDC,
ERR_INFO_UNMATCHED_LEVEL_IDC,
ERR_INFO_INVALID_POC_TYPE,
ERR_INFO_INVALID_MB_SIZE_INFO,
ERR_INFO_REF_COUNT_OVERFLOW,
ERR_INFO_CROPPING_NO_SUPPORTED,
ERR_INFO_INVALID_SLICEGROUP,
ERR_INFO_INVALID_SLICEGROUP_MAP_TYPE,
ERR_INFO_INVALID_FRAME_NUM,
ERR_INFO_INVALID_IDR_PIC_ID,
ERR_INFO_INVALID_REDUNDANT_PIC_CNT,
ERR_INFO_INVALID_MAX_NUM_REF_FRAMES,
ERR_INFO_INVALID_MAX_MB_SIZE,
ERR_INFO_INVALID_FIRST_MB_IN_SLICE,
ERR_INFO_INVALID_NUM_REF_IDX_L0_ACTIVE_MINUS1,
ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2,
ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2,
ERR_INFO_FMO_INIT_FAIL,
ERR_INFO_SLICE_TYPE_OVERFLOW,
ERR_INFO_INVALID_QP,
ERR_INFO_INVALID_PIC_INIT_QS,
ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET,
ERR_INFO_INVALID_PIC_INIT_QP,
ERR_INFO_INVALID_LOG2_MAX_FRAME_NUM_MINUS4,
ERR_INFO_INVALID_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4,
ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE,
ERR_INFO_INVALID_DBLOCKING_IDC,
ERR_INFO_INVALID_MB_TYPE,
ERR_INFO_INVALID_SPS_ID,
ERR_INFO_INVALID_PPS_ID,
ERR_INFO_INVALID_SUB_MB_TYPE,
ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA,
ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA,
ERR_INFO_INVALID_REF_INDEX,
ERR_INFO_INVALID_CBP,
ERR_INFO_DQUANT_OUT_OF_RANGE,
ERR_INFO_CAVLC_INVALID_PREFIX,
ERR_INFO_CAVLC_INVALID_LEVEL,
ERR_INFO_CAVLC_INVALID_TOTAL_COEFF_OR_TRAILING_ONES,
ERR_INFO_CAVLC_INVALID_ZERO_LEFT,
ERR_INFO_CAVLC_INVALID_RUN_BEFORE,
ERR_INFO_MV_OUT_OF_RANGE,
/* Error from common system level: 1-1000 */
ERR_INFO_OUT_OF_MEMORY = ERR_INFO_COMMON_BASE,
ERR_INFO_INVALID_ACCESS,
ERR_INFO_INVALID_PTR,
ERR_INFO_INVALID_PARAM,
ERR_INFO_FILE_NO_FOUND,
ERR_INFO_PATH_NO_FOUND,
ERR_INFO_ACCESS_DENIED,
ERR_INFO_NOT_READY,
ERR_INFO_WRITE_FAULT,
ERR_INFO_READ_FAULT,
ERR_INFO_READ_OVERFLOW,
ERR_INFO_READ_LEADING_ZERO,
/* Error from H.264 syntax elements parser: 1001-10000 */
ERR_INFO_NO_PREFIX_CODE = ERR_INFO_SYNTAX_BASE, // No start prefix code indication
ERR_INFO_NO_PARAM_SETS, // No SPS and/ PPS before sequence header
ERR_INFO_PARAM_SETS_NOT_INTEGRATED, // Parameters sets (sps/pps) are not integrated at all before to decode VCL nal
ERR_INFO_SPS_ID_OVERFLOW,
ERR_INFO_PPS_ID_OVERFLOW,
ERR_INFO_INVALID_PROFILE_IDC,
ERR_INFO_UNMATCHED_LEVEL_IDC,
ERR_INFO_INVALID_POC_TYPE,
ERR_INFO_INVALID_MB_SIZE_INFO,
ERR_INFO_REF_COUNT_OVERFLOW,
ERR_INFO_CROPPING_NO_SUPPORTED,
ERR_INFO_INVALID_SLICEGROUP,
ERR_INFO_INVALID_SLICEGROUP_MAP_TYPE,
ERR_INFO_INVALID_FRAME_NUM,
ERR_INFO_INVALID_IDR_PIC_ID,
ERR_INFO_INVALID_REDUNDANT_PIC_CNT,
ERR_INFO_INVALID_MAX_NUM_REF_FRAMES,
ERR_INFO_INVALID_MAX_MB_SIZE,
ERR_INFO_INVALID_FIRST_MB_IN_SLICE,
ERR_INFO_INVALID_NUM_REF_IDX_L0_ACTIVE_MINUS1,
ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2,
ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2,
ERR_INFO_FMO_INIT_FAIL,
ERR_INFO_SLICE_TYPE_OVERFLOW,
ERR_INFO_INVALID_QP,
ERR_INFO_INVALID_PIC_INIT_QS,
ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET,
ERR_INFO_INVALID_PIC_INIT_QP,
ERR_INFO_INVALID_LOG2_MAX_FRAME_NUM_MINUS4,
ERR_INFO_INVALID_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4,
ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE,
ERR_INFO_INVALID_DBLOCKING_IDC,
ERR_INFO_INVALID_MB_TYPE,
ERR_INFO_INVALID_SPS_ID,
ERR_INFO_INVALID_PPS_ID,
ERR_INFO_INVALID_SUB_MB_TYPE,
ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA,
ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA,
ERR_INFO_INVALID_REF_INDEX,
ERR_INFO_INVALID_CBP,
ERR_INFO_DQUANT_OUT_OF_RANGE,
ERR_INFO_CAVLC_INVALID_PREFIX,
ERR_INFO_CAVLC_INVALID_LEVEL,
ERR_INFO_CAVLC_INVALID_TOTAL_COEFF_OR_TRAILING_ONES,
ERR_INFO_CAVLC_INVALID_ZERO_LEFT,
ERR_INFO_CAVLC_INVALID_RUN_BEFORE,
ERR_INFO_MV_OUT_OF_RANGE,
ERR_INFO_INVALID_I4x4_PRED_MODE,
ERR_INFO_INVALID_I16x16_PRED_MODE,
ERR_INFO_INVALID_I_CHROMA_PRED_MODE,
ERR_INFO_INVALID_I4x4_PRED_MODE,
ERR_INFO_INVALID_I16x16_PRED_MODE,
ERR_INFO_INVALID_I_CHROMA_PRED_MODE,
ERR_INFO_UNSUPPORTED_NON_BASELINE,
ERR_INFO_UNSUPPORTED_FMOTYPE,
ERR_INFO_UNSUPPORTED_MBAFF,
ERR_INFO_UNSUPPORTED_ILP,
ERR_INFO_UNSUPPORTED_CABAC_EL,
ERR_INFO_UNSUPPORTED_SPSI,
ERR_INFO_UNSUPPORTED_MGS,
ERR_INFO_UNSUPPORTED_BIPRED,
ERR_INFO_UNSUPPORTED_WP,
ERR_INFO_UNSUPPORTED_NON_BASELINE,
ERR_INFO_UNSUPPORTED_FMOTYPE,
ERR_INFO_UNSUPPORTED_MBAFF,
ERR_INFO_UNSUPPORTED_ILP,
ERR_INFO_UNSUPPORTED_CABAC_EL,
ERR_INFO_UNSUPPORTED_SPSI,
ERR_INFO_UNSUPPORTED_MGS,
ERR_INFO_UNSUPPORTED_BIPRED,
ERR_INFO_UNSUPPORTED_WP,
ERR_INFO_FRAMES_LOST,
ERR_INFO_DEPENDENCY_SPATIAL_LAYER_LOST,
ERR_INFO_DEPENDENCY_QUALIT_LAYER_LOST,
ERR_INFO_REFERENCE_PIC_LOST,
ERR_INFO_INVALID_REORDERING,
ERR_INFO_INVALID_MARKING,
ERR_INFO_FRAMES_LOST,
ERR_INFO_DEPENDENCY_SPATIAL_LAYER_LOST,
ERR_INFO_DEPENDENCY_QUALIT_LAYER_LOST,
ERR_INFO_REFERENCE_PIC_LOST,
ERR_INFO_INVALID_REORDERING,
ERR_INFO_INVALID_MARKING,
ERR_INFO_FMO_NOT_SUPPORTED_IN_BASE_LAYER,
ERR_INFO_INVALID_ESS,
ERR_INFO_INVALID_SLICE_TYPE,
ERR_INFO_INVALID_REF_MARKING,
ERR_INFO_INVALID_REF_REORDERING,
ERR_INFO_FMO_NOT_SUPPORTED_IN_BASE_LAYER,
ERR_INFO_INVALID_ESS,
ERR_INFO_INVALID_SLICE_TYPE,
ERR_INFO_INVALID_REF_MARKING,
ERR_INFO_INVALID_REF_REORDERING,
/* Error from corresponding logic, 10001-65535 */
ERR_INFO_NO_IDR_PIC = ERR_INFO_LOGIC_BASE, // NO IDR picture available before sequence header
ERR_INFO_EC_NO_NEIGHBOUR_MBS,
ERR_INFO_EC_UNEXPECTED_MB_TYPE,
ERR_INFO_EC_NO_ENOUGH_NEIGHBOUR_MBS,
/* Error from corresponding logic, 10001-65535 */
ERR_INFO_NO_IDR_PIC = ERR_INFO_LOGIC_BASE, // NO IDR picture available before sequence header
ERR_INFO_EC_NO_NEIGHBOUR_MBS,
ERR_INFO_EC_UNEXPECTED_MB_TYPE,
ERR_INFO_EC_NO_ENOUGH_NEIGHBOUR_MBS,
//for LTR
ERR_INFO_INVALID_MMCO_OPCODE_BASE,
ERR_INFO_INVALID_MMCO_SHORT2UNUSED,
EER_INFO_INVALID_MMCO_LONG2UNUSED,
ERR_INFO_INVALID_MMCO_SHOART2LONG,
ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW,
ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH,
ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX,
ERR_INFO_INVALID_MMCO_OPCODE_BASE,
ERR_INFO_INVALID_MMCO_SHORT2UNUSED,
EER_INFO_INVALID_MMCO_LONG2UNUSED,
ERR_INFO_INVALID_MMCO_SHOART2LONG,
ERR_INFO_INVALID_MMCO_REF_NUM_OVERFLOW,
ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH,
ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX,
};
//-----------------------------------------------------------------------------------------------------------

View File

@ -54,12 +54,12 @@ namespace WelsDec {
* \brief Wels Flexible Macroblock Ordering (FMO)
*/
typedef struct TagFmo {
uint8_t* pMbAllocMap;
int32_t iCountMbNum;
int32_t iSliceGroupCount;
int32_t iSliceGroupType;
bool bActiveFlag;
uint8_t uiReserved[3]; // reserved padding bytes
uint8_t* pMbAllocMap;
int32_t iCountMbNum;
int32_t iSliceGroupCount;
int32_t iSliceGroupType;
bool bActiveFlag;
uint8_t uiReserved[3]; // reserved padding bytes
} SFmo, *PFmo;

View File

@ -65,15 +65,15 @@ extern const uint8_t g_kuiCacheNzcScanIdx[24];
extern const uint8_t g_kuiScan4[16];
typedef struct TagNeighborAvail {
int32_t iTopAvail;
int32_t iLeftAvail;
int32_t iRightTopAvail;
int32_t iLeftTopAvail; //used for check intra_pred_mode avail or not //1: avail; 0: unavail
int32_t iTopAvail;
int32_t iLeftAvail;
int32_t iRightTopAvail;
int32_t iLeftTopAvail; //used for check intra_pred_mode avail or not //1: avail; 0: unavail
int32_t iLeftType;
int32_t iTopType;
int32_t iLeftTopType;
int32_t iRightTopType;
int32_t iLeftType;
int32_t iTopType;
int32_t iLeftTopType;
int32_t iRightTopType;
} SNeighAvail, *PNeighAvail;
} // namespace WelsDec

View File

@ -44,41 +44,41 @@ namespace WelsDec {
/* NAL Unix Header in AVC, refer to Page 56 in JVT X201wcm */
typedef struct TagNalUnitHeader {
uint8_t uiForbiddenZeroBit;
uint8_t uiNalRefIdc;
ENalUnitType eNalUnitType;
uint8_t uiReservedOneByte; // only padding usage
uint8_t uiForbiddenZeroBit;
uint8_t uiNalRefIdc;
ENalUnitType eNalUnitType;
uint8_t uiReservedOneByte; // only padding usage
} SNalUnitHeader, *PNalUnitHeader;
/* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */
typedef struct TagNalUnitHeaderExt {
SNalUnitHeader sNalUnitHeader;
SNalUnitHeader sNalUnitHeader;
// uint8_t reserved_one_bit;
bool bIdrFlag;
uint8_t uiPriorityId;
int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder
uint8_t uiDependencyId;
bool bIdrFlag;
uint8_t uiPriorityId;
int8_t iNoInterLayerPredFlag; // change as int8_t to support 3 values probably in encoder
uint8_t uiDependencyId;
uint8_t uiQualityId;
uint8_t uiTemporalId;
bool bUseRefBasePicFlag;
bool bDiscardableFlag;
uint8_t uiQualityId;
uint8_t uiTemporalId;
bool bUseRefBasePicFlag;
bool bDiscardableFlag;
bool bOutputFlag;
uint8_t uiReservedThree2Bits;
// Derived variable(s)
uint8_t uiLayerDqId;
bool bNalExtFlag;
bool bOutputFlag;
uint8_t uiReservedThree2Bits;
// Derived variable(s)
uint8_t uiLayerDqId;
bool bNalExtFlag;
} SNalUnitHeaderExt, *PNalUnitHeaderExt;
/* Prefix NAL Unix syntax, refer to Page 392 in JVT X201wcm */
typedef struct TagPrefixNalUnit {
SRefBasePicMarking sRefPicBaseMarking;
bool bStoreRefBasePicFlag;
bool bPrefixNalUnitAdditionalExtFlag;
bool bPrefixNalUnitExtFlag;
bool bPrefixNalCorrectFlag;
SRefBasePicMarking sRefPicBaseMarking;
bool bStoreRefBasePicFlag;
bool bPrefixNalUnitAdditionalExtFlag;
bool bPrefixNalUnitExtFlag;
bool bPrefixNalCorrectFlag;
} SPrefixNalUnit, *PPrefixNalUnit;
} // namespace WelsDec

View File

@ -45,18 +45,18 @@ namespace WelsDec {
/* NAL Unit Structure */
typedef struct TagNalUnit {
SNalUnitHeaderExt sNalHeaderExt;
SNalUnitHeaderExt sNalHeaderExt;
union {
struct SVclNal {
SSliceHeaderExt sSliceHeaderExt;
SBitStringAux sSliceBitsRead;
uint8_t* pNalPos; // save the address of slice nal for GPU function
int32_t iNalLength; // save the nal length for GPU function
bool bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
union {
struct SVclNal {
SSliceHeaderExt sSliceHeaderExt;
SBitStringAux sSliceBitsRead;
uint8_t* pNalPos; // save the address of slice nal for GPU function
int32_t iNalLength; // save the nal length for GPU function
bool bSliceHeaderExtFlag;
} sVclNal;
SPrefixNalUnit sPrefixNal;
} sNalData;
} SNalUnit, *PNalUnit;
@ -64,14 +64,14 @@ typedef struct TagNalUnit {
/* Access Unit structure */
typedef struct TagAccessUnits {
PNalUnit* pNalUnitsList; // list of NAL Units pointer in this AU
uint32_t uiAvailUnitsNum; // Number of NAL Units available in each AU list based current bitstream,
uint32_t uiActualUnitsNum; // actual number of NAL units belong to current au
PNalUnit* pNalUnitsList; // list of NAL Units pointer in this AU
uint32_t uiAvailUnitsNum; // Number of NAL Units available in each AU list based current bitstream,
uint32_t uiActualUnitsNum; // actual number of NAL units belong to current au
// While available number exceeds count size below, need realloc extra NAL Units for list space.
uint32_t uiCountUnitsNum; // Count size number of malloced NAL Units in each AU list
uint32_t uiStartPos;
uint32_t uiEndPos;
bool bCompletedAuFlag; // Indicate whether it is a completed AU
uint32_t uiCountUnitsNum; // Count size number of malloced NAL Units in each AU list
uint32_t uiStartPos;
uint32_t uiEndPos;
bool bCompletedAuFlag; // Indicate whether it is a completed AU
} SAccessUnit, *PAccessUnit;
} // namespace WelsDec

View File

@ -40,66 +40,66 @@
namespace WelsDec {
typedef struct TagLevelLimits {
int32_t iMaxMBPS; // Max macroblock processing rate(MB/s)
int32_t iMaxFS; // Max frame sizea(MBs)
int32_t iMaxDPBMbs;// Max decoded picture buffer size(MBs)
int32_t iMaxBR; // Max video bit rate
int32_t iMaxCPB; // Max CPB size
int16_t iMinVmv; // Vertical MV component range upper bound
int16_t iMaxVmv; // Vertical MV component range lower bound
int16_t iMinCR; // Min compression ration
int16_t iMaxMvsPer2Mb; // Max number of motion vectors per two consecutive MBs
int32_t iMaxMBPS; // Max macroblock processing rate(MB/s)
int32_t iMaxFS; // Max frame sizea(MBs)
int32_t iMaxDPBMbs;// Max decoded picture buffer size(MBs)
int32_t iMaxBR; // Max video bit rate
int32_t iMaxCPB; // Max CPB size
int16_t iMinVmv; // Vertical MV component range upper bound
int16_t iMaxVmv; // Vertical MV component range lower bound
int16_t iMinCR; // Min compression ration
int16_t iMaxMvsPer2Mb; // Max number of motion vectors per two consecutive MBs
} SLevelLimits;
/* Sequence Parameter Set, refer to Page 57 in JVT X201wcm */
typedef struct TagSps {
int32_t iSpsId;
uint32_t iMbWidth;
uint32_t iMbHeight;
uint32_t uiTotalMbCount; //used in decode_slice_data()
int32_t iSpsId;
uint32_t iMbWidth;
uint32_t iMbHeight;
uint32_t uiTotalMbCount; //used in decode_slice_data()
uint32_t uiLog2MaxFrameNum;
uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
int32_t iOffsetForNonRefPic;
uint32_t uiLog2MaxFrameNum;
uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
int32_t iOffsetForNonRefPic;
int32_t iOffsetForTopToBottomField;
int32_t iNumRefFramesInPocCycle;
int8_t iOffsetForRefFrame[256];
int32_t iNumRefFrames;
int32_t iOffsetForTopToBottomField;
int32_t iNumRefFramesInPocCycle;
int8_t iOffsetForRefFrame[256];
int32_t iNumRefFrames;
SPosOffset sFrameCrop;
SPosOffset sFrameCrop;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
uint8_t uiChromaFormatIdc;
uint8_t uiChromaArrayType;
ProfileIdc uiProfileIdc;
uint8_t uiLevelIdc;
uint8_t uiChromaFormatIdc;
uint8_t uiChromaArrayType;
uint8_t uiBitDepthLuma;
uint8_t uiBitDepthChroma;
/* TO BE CONTINUE: POC type 1 */
bool bDeltaPicOrderAlwaysZeroFlag;
bool bGapsInFrameNumValueAllowedFlag;
uint8_t uiBitDepthLuma;
uint8_t uiBitDepthChroma;
/* TO BE CONTINUE: POC type 1 */
bool bDeltaPicOrderAlwaysZeroFlag;
bool bGapsInFrameNumValueAllowedFlag;
bool bFrameMbsOnlyFlag;
bool bMbaffFlag; // MB Adapative Frame Field
bool bDirect8x8InferenceFlag;
bool bFrameCroppingFlag;
bool bFrameMbsOnlyFlag;
bool bMbaffFlag; // MB Adapative Frame Field
bool bDirect8x8InferenceFlag;
bool bFrameCroppingFlag;
bool bVuiParamPresentFlag;
bool bVuiParamPresentFlag;
// bool bTimingInfoPresentFlag;
// bool bFixedFrameRateFlag;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
bool bSeparateColorPlaneFlag;
bool bQpPrimeYZeroTransfBypassFlag;
bool bSeqScalingMatrixPresentFlag;
bool bSeqScalingListPresentFlag[12];
const SLevelLimits* pSLevelLimits;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
bool bSeparateColorPlaneFlag;
bool bQpPrimeYZeroTransfBypassFlag;
bool bSeqScalingMatrixPresentFlag;
bool bSeqScalingListPresentFlag[12];
const SLevelLimits* pSLevelLimits;
} SSps, *PSps;
@ -117,63 +117,63 @@ typedef struct TagSps {
/* Sequence Parameter Set extension syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSpsSvcExt {
SPosOffset sSeqScaledRefLayer;
SPosOffset sSeqScaledRefLayer;
uint8_t uiExtendedSpatialScalability; // ESS
uint8_t uiChromaPhaseXPlus1Flag;
uint8_t uiChromaPhaseYPlus1;
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
bool bInterLayerDeblockingFilterCtrlPresentFlag;
bool bSeqTCoeffLevelPredFlag;
bool bAdaptiveTCoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
uint8_t uiExtendedSpatialScalability; // ESS
uint8_t uiChromaPhaseXPlus1Flag;
uint8_t uiChromaPhaseYPlus1;
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
bool bInterLayerDeblockingFilterCtrlPresentFlag;
bool bSeqTCoeffLevelPredFlag;
bool bAdaptiveTCoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
} SSpsSvcExt, *PSpsSvcExt;
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSubsetSps {
SSps sSps;
SSpsSvcExt sSpsSvcExt;
bool bSvcVuiParamPresentFlag;
bool bAdditionalExtension2Flag;
bool bAdditionalExtension2DataFlag;
SSps sSps;
SSpsSvcExt sSpsSvcExt;
bool bSvcVuiParamPresentFlag;
bool bAdditionalExtension2Flag;
bool bAdditionalExtension2DataFlag;
} SSubsetSps, *PSubsetSps;
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
typedef struct TagPps {
int32_t iSpsId;
int32_t iPpsId;
int32_t iSpsId;
int32_t iPpsId;
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* slice_group_map_type = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 3, 4 or 5 */
uint32_t uiSliceGroupChangeRate;
/* slice_group_map_type = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* slice_group_map_type = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* slice_group_map_type = 3, 4 or 5 */
uint32_t uiSliceGroupChangeRate;
/* slice_group_map_type = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
uint32_t uiNumRefIdxL0Active;
uint32_t uiNumRefIdxL1Active;
uint32_t uiNumRefIdxL0Active;
uint32_t uiNumRefIdxL1Active;
int32_t iPicInitQp;
int32_t iPicInitQs;
int32_t iChromaQpIndexOffset;
int32_t iPicInitQp;
int32_t iPicInitQs;
int32_t iChromaQpIndexOffset;
bool bEntropyCodingModeFlag;
bool bPicOrderPresentFlag;
/* slice_group_map_type = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
bool bDeblockingFilterControlPresentFlag;
bool bEntropyCodingModeFlag;
bool bPicOrderPresentFlag;
/* slice_group_map_type = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
bool bDeblockingFilterControlPresentFlag;
bool bConstainedIntraPredFlag;
bool bRedundantPicCntPresentFlag;
bool bWeightedPredFlag;
uint8_t uiWeightedBipredIdc;
bool bConstainedIntraPredFlag;
bool bRedundantPicCntPresentFlag;
bool bWeightedPredFlag;
uint8_t uiWeightedBipredIdc;
} SPps, *PPps;

View File

@ -56,82 +56,82 @@ namespace WelsDec {
#define CHROMA_AC 5
typedef struct TagReadBitsCache {
uint32_t uiCache32Bit;
uint8_t uiRemainBits;
uint8_t* pBuf;
uint32_t uiCache32Bit;
uint8_t uiRemainBits;
uint8_t* pBuf;
} SReadBitsCache;
#define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); }
#define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; }
static const uint8_t g_kuiZigzagScan[16] = { //4*4block residual zig-zag scan order
0, 1, 4, 8,
5, 2, 3, 6,
9, 12, 13, 10,
7, 11, 14, 15,
0, 1, 4, 8,
5, 2, 3, 6,
9, 12, 13, 10,
7, 11, 14, 15,
};
typedef struct TagI16PredInfo {
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
} SI16PredInfo;
static const SI16PredInfo g_ksI16PredInfo[4] = {
{I16_PRED_V, 0, 1, 0},
{I16_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I16_PRED_P, 1, 1, 1},
{I16_PRED_V, 0, 1, 0},
{I16_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I16_PRED_P, 1, 1, 1},
};
static const SI16PredInfo g_ksChromaPredInfo[4] = {
{ 0, 0, 0, 0},
{C_PRED_H, 1, 0, 0},
{C_PRED_V, 0, 1, 0},
{C_PRED_P, 1, 1, 1},
{ 0, 0, 0, 0},
{C_PRED_H, 1, 0, 0},
{C_PRED_V, 0, 1, 0},
{C_PRED_P, 1, 1, 1},
};
typedef struct TagI4PredInfo {
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
int8_t iPredMode;
int8_t iLeftAvail;
int8_t iTopAvail;
int8_t iLeftTopAvail;
// int8_t right_top_avail; //when right_top unavailable but top avail, we can pad the right-top with the rightmost pixel of top
} SI4PredInfo;
static const SI4PredInfo g_ksI4PredInfo[9] = {
{ I4_PRED_V, 0, 1, 0},
{ I4_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I4_PRED_DDL, 0, 1, 0},
{I4_PRED_DDR, 1, 1, 1},
{ I4_PRED_VR, 1, 1, 1},
{ I4_PRED_HD, 1, 1, 1},
{ I4_PRED_VL, 0, 1, 0},
{ I4_PRED_HU, 1, 0, 0},
{ I4_PRED_V, 0, 1, 0},
{ I4_PRED_H, 1, 0, 0},
{ 0, 0, 0, 0},
{I4_PRED_DDL, 0, 1, 0},
{I4_PRED_DDR, 1, 1, 1},
{ I4_PRED_VR, 1, 1, 1},
{ I4_PRED_HD, 1, 1, 1},
{ I4_PRED_VL, 0, 1, 0},
{ I4_PRED_HU, 1, 0, 0},
};
static const uint8_t g_kuiI16CbpTable[6] = {0, 16, 32, 15, 31, 47}; //reference to JM
typedef struct TagPartMbInfo {
MbType iType;
int8_t iPartCount; //P_16*16, P_16*8, P_8*16, P_8*8 based on 8*8 block; P_8*4, P_4*8, P_4*4 based on 4*4 block
int8_t iPartWidth; //based on 4*4 block
MbType iType;
int8_t iPartCount; //P_16*16, P_16*8, P_8*16, P_8*8 based on 8*8 block; P_8*4, P_4*8, P_4*4 based on 4*4 block
int8_t iPartWidth; //based on 4*4 block
} SPartMbInfo;
static const SPartMbInfo g_ksInterMbTypeInfo[5] = {
{MB_TYPE_16x16, 1, 4},
{MB_TYPE_16x8, 2, 4},
{MB_TYPE_8x16, 2, 2},
{MB_TYPE_8x8, 4, 4},
{MB_TYPE_8x8_REF0, 4, 4}, //ref0--ref_idx not present in bit-stream and default as 0
{MB_TYPE_16x16, 1, 4},
{MB_TYPE_16x8, 2, 4},
{MB_TYPE_8x16, 2, 2},
{MB_TYPE_8x8, 4, 4},
{MB_TYPE_8x8_REF0, 4, 4}, //ref0--ref_idx not present in bit-stream and default as 0
};
static const SPartMbInfo g_ksInterSubMbTypeInfo[4] = {
{SUB_MB_TYPE_8x8, 1, 2},
{SUB_MB_TYPE_8x4, 2, 2},
{SUB_MB_TYPE_4x8, 2, 1},
{SUB_MB_TYPE_4x4, 4, 1},
{SUB_MB_TYPE_8x8, 1, 2},
{SUB_MB_TYPE_8x4, 2, 2},
{SUB_MB_TYPE_4x8, 2, 1},
{SUB_MB_TYPE_4x4, 4, 1},
};
void GetNeighborAvailMbType (PNeighAvail pNeighAvail, PDqLayer pCurLayer);

View File

@ -43,9 +43,9 @@ namespace WelsDec {
typedef struct TagPicBuff {
PPicture* ppPic;
int32_t iCapacity; // capacity size of queue
int32_t iCurrentIdx;
PPicture* ppPic;
int32_t iCapacity; // capacity size of queue
int32_t iCurrentIdx;
} SPicBuff, *PPicBuff;
/*

View File

@ -43,36 +43,36 @@ namespace WelsDec {
* It is used to express reference picture, also consequent reconstruction picture for output
*/
typedef struct TagPicture {
/************************************payload data*********************************/
uint8_t* pBuffer[4]; // pointer to the first allocated byte, basical offset of buffer, dimension:
uint8_t* pData[4]; // pointer to picture planes respectively
int32_t iLinesize[4];// linesize of picture planes respectively used currently
int32_t iPlanes; // How many planes are introduced due to color space format?
/************************************payload data*********************************/
uint8_t* pBuffer[4]; // pointer to the first allocated byte, basical offset of buffer, dimension:
uint8_t* pData[4]; // pointer to picture planes respectively
int32_t iLinesize[4];// linesize of picture planes respectively used currently
int32_t iPlanes; // How many planes are introduced due to color space format?
// picture information
/*******************************from other standard syntax****************************/
/*from sps*/
int32_t iWidthInPixel; // picture width in pixel
int32_t iHeightInPixel;// picture height in pixel
/*from slice header*/
int32_t iFramePoc; // frame POC
/*******************************from other standard syntax****************************/
/*from sps*/
int32_t iWidthInPixel; // picture width in pixel
int32_t iHeightInPixel;// picture height in pixel
/*from slice header*/
int32_t iFramePoc; // frame POC
/*******************************sef_definition for misc use****************************/
bool bUsedAsRef; //for ref pic management
bool bIsLongRef; // long term reference frame flag //for ref pic management
uint8_t uiRefCount;
bool bAvailableFlag; // indicate whether it is available in this picture memory block.
/*******************************sef_definition for misc use****************************/
bool bUsedAsRef; //for ref pic management
bool bIsLongRef; // long term reference frame flag //for ref pic management
uint8_t uiRefCount;
bool bAvailableFlag; // indicate whether it is available in this picture memory block.
/*******************************for future use****************************/
uint8_t uiTemporalId;
uint8_t uiSpatialId;
uint8_t uiQualityId;
/*******************************for future use****************************/
uint8_t uiTemporalId;
uint8_t uiSpatialId;
uint8_t uiQualityId;
int32_t iFrameNum; // frame number //for ref pic management
int32_t iLongTermFrameIdx; //id for long term ref pic
int32_t iFrameNum; // frame number //for ref pic management
int32_t iLongTermFrameIdx; //id for long term ref pic
int32_t iSpsId; //against mosaic caused by cross-IDR interval reference.
int32_t iPpsId;
int32_t iSpsId; //against mosaic caused by cross-IDR interval reference.
int32_t iPpsId;
} SPicture, *PPicture; // "Picture" declaration is comflict with Mac system
} // namespace WelsDec

View File

@ -46,157 +46,157 @@ namespace WelsDec {
* Reference picture list reordering syntax, refer to page 64 in JVT X201wcm
*/
typedef struct TagRefPicListReorderSyntax {
struct {
uint32_t uiAbsDiffPicNumMinus1;
uint16_t uiLongTermPicNum;
uint16_t uiReorderingOfPicNumsIdc;
} sReorderingSyn[LIST_A][MAX_REF_PIC_COUNT];
bool bRefPicListReorderingFlag[LIST_A];
struct {
uint32_t uiAbsDiffPicNumMinus1;
uint16_t uiLongTermPicNum;
uint16_t uiReorderingOfPicNumsIdc;
} sReorderingSyn[LIST_A][MAX_REF_PIC_COUNT];
bool bRefPicListReorderingFlag[LIST_A];
} SRefPicListReorderSyn, *PRefPicListReorderSyn;
/*
* Prediction weight table syntax, refer to page 65 in JVT X201wcm
*/
typedef struct TagPredWeightTabSyntax {
uint32_t uiLumaLog2WeightDenom;
uint32_t uiChromaLog2WeightDenom;
struct {
int32_t iLumaWeight[MAX_REF_PIC_COUNT];
int32_t iLumaOffset[MAX_REF_PIC_COUNT];
int32_t iChromaWeight[MAX_REF_PIC_COUNT][2];
int32_t iChromaOffset[MAX_REF_PIC_COUNT][2];
bool bLumaWeightFlag;
bool bChromaWeightFlag;
} sPredList[LIST_A];
uint32_t uiLumaLog2WeightDenom;
uint32_t uiChromaLog2WeightDenom;
struct {
int32_t iLumaWeight[MAX_REF_PIC_COUNT];
int32_t iLumaOffset[MAX_REF_PIC_COUNT];
int32_t iChromaWeight[MAX_REF_PIC_COUNT][2];
int32_t iChromaOffset[MAX_REF_PIC_COUNT][2];
bool bLumaWeightFlag;
bool bChromaWeightFlag;
} sPredList[LIST_A];
} SPredWeightTabSyn;
/* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */
typedef struct TagRefPicMarking {
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
int32_t iDiffOfPicNum;
uint32_t uiLongTermPicNum;
int32_t iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx;
} sMmcoRef[MAX_MMCO_COUNT];
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
int32_t iDiffOfPicNum;
uint32_t uiLongTermPicNum;
int32_t iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx;
} sMmcoRef[MAX_MMCO_COUNT];
bool bNoOutputOfPriorPicsFlag;
bool bLongTermRefFlag;
bool bAdaptiveRefPicMarkingModeFlag;
bool bNoOutputOfPriorPicsFlag;
bool bLongTermRefFlag;
bool bAdaptiveRefPicMarkingModeFlag;
} SRefPicMarking, *PRefPicMarking;
/* Decode reference base picture marking syntax in Page 396 of JVT X201wcm */
typedef struct TagRefBasePicMarkingSyn {
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
uint32_t uiDiffOfPicNums;
uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum.
} mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame
struct {
uint32_t uiMmcoType;
int32_t iShortFrameNum;
uint32_t uiDiffOfPicNums;
uint32_t uiLongTermPicNum; //should uint32_t, cover larger range of iFrameNum.
} mmco_base[MAX_MMCO_COUNT]; // MAX_REF_PIC for reference picture based on frame
bool bAdaptiveRefBasePicMarkingModeFlag;
bool bAdaptiveRefBasePicMarkingModeFlag;
} SRefBasePicMarking, *PRefBasePicMarking;
/* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */
typedef struct TagSliceHeaders {
/*****************************slice header syntax and generated****************************/
int32_t iFirstMbInSlice;
int32_t iFrameNum;
int32_t iPicOrderCntLsb;
int32_t iDeltaPicOrderCntBottom;
int32_t iDeltaPicOrderCnt[2];
int32_t iRedundantPicCnt;
int32_t uiRefCount[LIST_A];
int32_t iSliceQpDelta; //no use for iSliceQp is used directly
int32_t iSliceQp;
int32_t iSliceQsDelta; // For SP/SI slices
uint32_t uiDisableDeblockingFilterIdc;
int32_t iSliceAlphaC0Offset;
int32_t iSliceBetaOffset;
int32_t iSliceGroupChangeCycle;
/*****************************slice header syntax and generated****************************/
int32_t iFirstMbInSlice;
int32_t iFrameNum;
int32_t iPicOrderCntLsb;
int32_t iDeltaPicOrderCntBottom;
int32_t iDeltaPicOrderCnt[2];
int32_t iRedundantPicCnt;
int32_t uiRefCount[LIST_A];
int32_t iSliceQpDelta; //no use for iSliceQp is used directly
int32_t iSliceQp;
int32_t iSliceQsDelta; // For SP/SI slices
uint32_t uiDisableDeblockingFilterIdc;
int32_t iSliceAlphaC0Offset;
int32_t iSliceBetaOffset;
int32_t iSliceGroupChangeCycle;
PSps pSps;
PPps pPps;
int32_t iSpsId;
int32_t iPpsId;
PSps pSps;
PPps pPps;
int32_t iSpsId;
int32_t iPpsId;
/*********************got from other layer for efficency if possible*********************/
SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs
SPredWeightTabSyn sPredWeightTable;
int32_t iCabacInitIdc;
int32_t iMbWidth; //from?
int32_t iMbHeight; //from?
SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs
/*********************got from other layer for efficency if possible*********************/
SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs
SPredWeightTabSyn sPredWeightTable;
int32_t iCabacInitIdc;
int32_t iMbWidth; //from?
int32_t iMbHeight; //from?
SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs
uint16_t uiIdrPicId;
ESliceType eSliceType;
bool bNumRefIdxActiveOverrideFlag;
bool bFieldPicFlag; //not supported in base profile
bool bBottomFiledFlag; //not supported in base profile
uint8_t uiPadding1Byte;
bool bSpForSwitchFlag; // For SP/SI slices
int16_t iPadding2Bytes;
uint16_t uiIdrPicId;
ESliceType eSliceType;
bool bNumRefIdxActiveOverrideFlag;
bool bFieldPicFlag; //not supported in base profile
bool bBottomFiledFlag; //not supported in base profile
uint8_t uiPadding1Byte;
bool bSpForSwitchFlag; // For SP/SI slices
int16_t iPadding2Bytes;
} SSliceHeader, *PSliceHeader;
/* Slice header in scalable extension syntax, refer to Page 394 in JVT X201wcm */
typedef struct TagSliceHeaderExt {
SSliceHeader sSliceHeader;
PSubsetSps pSubsetSps;
SSliceHeader sSliceHeader;
PSubsetSps pSubsetSps;
uint32_t uiNumMbsInSlice;
uint32_t uiDisableInterLayerDeblockingFilterIdc;
int32_t iInterLayerSliceAlphaC0Offset;
int32_t iInterLayerSliceBetaOffset;
uint32_t uiNumMbsInSlice;
uint32_t uiDisableInterLayerDeblockingFilterIdc;
int32_t iInterLayerSliceAlphaC0Offset;
int32_t iInterLayerSliceBetaOffset;
//SPosOffset sScaledRefLayer;
int32_t iScaledRefLayerPicWidthInSampleLuma;
int32_t iScaledRefLayerPicHeightInSampleLuma;
//SPosOffset sScaledRefLayer;
int32_t iScaledRefLayerPicWidthInSampleLuma;
int32_t iScaledRefLayerPicHeightInSampleLuma;
SRefBasePicMarking sRefBasePicMarking;
bool bBasePredWeightTableFlag;
bool bStoreRefBasePicFlag;
bool bConstrainedIntraResamplingFlag;
bool bSliceSkipFlag;
SRefBasePicMarking sRefBasePicMarking;
bool bBasePredWeightTableFlag;
bool bStoreRefBasePicFlag;
bool bConstrainedIntraResamplingFlag;
bool bSliceSkipFlag;
bool bAdaptiveBaseModeFlag;
bool bDefaultBaseModeFlag;
bool bAdaptiveMotionPredFlag;
bool bDefaultMotionPredFlag;
bool bAdaptiveResidualPredFlag;
bool bDefaultResidualPredFlag;
bool bTCoeffLevelPredFlag;
uint8_t uiRefLayerChromaPhaseXPlus1Flag;
bool bAdaptiveBaseModeFlag;
bool bDefaultBaseModeFlag;
bool bAdaptiveMotionPredFlag;
bool bDefaultMotionPredFlag;
bool bAdaptiveResidualPredFlag;
bool bDefaultResidualPredFlag;
bool bTCoeffLevelPredFlag;
uint8_t uiRefLayerChromaPhaseXPlus1Flag;
uint8_t uiRefLayerChromaPhaseYPlus1;
uint8_t uiRefLayerDqId;
uint8_t uiScanIdxStart;
uint8_t uiScanIdxEnd;
uint8_t uiRefLayerChromaPhaseYPlus1;
uint8_t uiRefLayerDqId;
uint8_t uiScanIdxStart;
uint8_t uiScanIdxEnd;
} SSliceHeaderExt, *PSliceHeaderExt;
typedef struct TagSlice {
/*******************************slice_header****************************/
SSliceHeaderExt sSliceHeaderExt;
/*******************************slice_header****************************/
SSliceHeaderExt sSliceHeaderExt;
/*******************************use for future****************************/
// for Macroblock coding within slice
int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
/*******************************use for future****************************/
// for Macroblock coding within slice
int32_t iLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
/*******************************slice_data****************************/
/*slice_data_ext()*/
int32_t iMbSkipRun;
int32_t iTotalMbInCurSlice; //record the total number of MB in current slice.
/*******************************slice_data****************************/
/*slice_data_ext()*/
int32_t iMbSkipRun;
int32_t iTotalMbInCurSlice; //record the total number of MB in current slice.
/*slice_data_ext() generate*/
/*slice_data_ext() generate*/
/*******************************misc use****************************/
bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
/*************got from other layer for effiency if possible***************/
/*from lower layer: slice header*/
uint8_t eSliceType;
uint8_t uiPadding[2];
/*******************************misc use****************************/
bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
/*************got from other layer for effiency if possible***************/
/*from lower layer: slice header*/
uint8_t eSliceType;
uint8_t uiPadding[2];
} SSlice, *PSlice;
} // namespace WelsDec

View File

@ -39,10 +39,10 @@
namespace WelsDec {
typedef struct TagVlcTable {
const uint8_t (*kpCoeffTokenVlcTable[4][8])[2];
const uint8_t (*kpChromaCoeffTokenVlcTable)[2];
const uint8_t (*kpZeroTable[7])[2];
const uint8_t (*kpTotalZerosTable[2][15])[2];
const uint8_t (*kpCoeffTokenVlcTable[4][8])[2];
const uint8_t (*kpChromaCoeffTokenVlcTable)[2];
const uint8_t (*kpZeroTable[7])[2];
const uint8_t (*kpTotalZerosTable[2][15])[2];
} SVlcTable;
// for data sharing cross modules and try to reduce size of binary generated
@ -117,58 +117,58 @@ extern const uint8_t g_kuiZeroLeftBitNumMap[16];
#endif
static inline void InitVlcTable (SVlcTable* pVlcTable) {
pVlcTable->kpChromaCoeffTokenVlcTable = g_kuiVlcChromaTable;
pVlcTable->kpChromaCoeffTokenVlcTable = g_kuiVlcChromaTable;
pVlcTable->kpCoeffTokenVlcTable[0][0] = g_kuiVlcTable_0;
pVlcTable->kpCoeffTokenVlcTable[0][1] = g_kuiVlcTable_1;
pVlcTable->kpCoeffTokenVlcTable[0][2] = g_kuiVlcTable_2;
pVlcTable->kpCoeffTokenVlcTable[0][3] = g_kuiVlcTable_3;
pVlcTable->kpCoeffTokenVlcTable[0][0] = g_kuiVlcTable_0;
pVlcTable->kpCoeffTokenVlcTable[0][1] = g_kuiVlcTable_1;
pVlcTable->kpCoeffTokenVlcTable[0][2] = g_kuiVlcTable_2;
pVlcTable->kpCoeffTokenVlcTable[0][3] = g_kuiVlcTable_3;
pVlcTable->kpCoeffTokenVlcTable[1][0] = g_kuiVlcTable_0_0;
pVlcTable->kpCoeffTokenVlcTable[1][1] = g_kuiVlcTable_0_1;
pVlcTable->kpCoeffTokenVlcTable[1][2] = g_kuiVlcTable_0_2;
pVlcTable->kpCoeffTokenVlcTable[1][3] = g_kuiVlcTable_0_3;
pVlcTable->kpCoeffTokenVlcTable[1][0] = g_kuiVlcTable_0_0;
pVlcTable->kpCoeffTokenVlcTable[1][1] = g_kuiVlcTable_0_1;
pVlcTable->kpCoeffTokenVlcTable[1][2] = g_kuiVlcTable_0_2;
pVlcTable->kpCoeffTokenVlcTable[1][3] = g_kuiVlcTable_0_3;
pVlcTable->kpCoeffTokenVlcTable[2][0] = g_kuiVlcTable_1_0;
pVlcTable->kpCoeffTokenVlcTable[2][1] = g_kuiVlcTable_1_1;
pVlcTable->kpCoeffTokenVlcTable[2][2] = g_kuiVlcTable_1_2;
pVlcTable->kpCoeffTokenVlcTable[2][3] = g_kuiVlcTable_1_3;
pVlcTable->kpCoeffTokenVlcTable[2][0] = g_kuiVlcTable_1_0;
pVlcTable->kpCoeffTokenVlcTable[2][1] = g_kuiVlcTable_1_1;
pVlcTable->kpCoeffTokenVlcTable[2][2] = g_kuiVlcTable_1_2;
pVlcTable->kpCoeffTokenVlcTable[2][3] = g_kuiVlcTable_1_3;
pVlcTable->kpCoeffTokenVlcTable[3][0] = g_kuiVlcTable_2_0;
pVlcTable->kpCoeffTokenVlcTable[3][1] = g_kuiVlcTable_2_1;
pVlcTable->kpCoeffTokenVlcTable[3][2] = g_kuiVlcTable_2_2;
pVlcTable->kpCoeffTokenVlcTable[3][3] = g_kuiVlcTable_2_3;
pVlcTable->kpCoeffTokenVlcTable[3][4] = g_kuiVlcTable_2_4;
pVlcTable->kpCoeffTokenVlcTable[3][5] = g_kuiVlcTable_2_5;
pVlcTable->kpCoeffTokenVlcTable[3][6] = g_kuiVlcTable_2_6;
pVlcTable->kpCoeffTokenVlcTable[3][7] = g_kuiVlcTable_2_7;
pVlcTable->kpCoeffTokenVlcTable[3][0] = g_kuiVlcTable_2_0;
pVlcTable->kpCoeffTokenVlcTable[3][1] = g_kuiVlcTable_2_1;
pVlcTable->kpCoeffTokenVlcTable[3][2] = g_kuiVlcTable_2_2;
pVlcTable->kpCoeffTokenVlcTable[3][3] = g_kuiVlcTable_2_3;
pVlcTable->kpCoeffTokenVlcTable[3][4] = g_kuiVlcTable_2_4;
pVlcTable->kpCoeffTokenVlcTable[3][5] = g_kuiVlcTable_2_5;
pVlcTable->kpCoeffTokenVlcTable[3][6] = g_kuiVlcTable_2_6;
pVlcTable->kpCoeffTokenVlcTable[3][7] = g_kuiVlcTable_2_7;
pVlcTable->kpZeroTable[0] = g_kuiZeroLeftTable0;
pVlcTable->kpZeroTable[1] = g_kuiZeroLeftTable1;
pVlcTable->kpZeroTable[2] = g_kuiZeroLeftTable2;
pVlcTable->kpZeroTable[3] = g_kuiZeroLeftTable3;
pVlcTable->kpZeroTable[4] = g_kuiZeroLeftTable4;
pVlcTable->kpZeroTable[5] = g_kuiZeroLeftTable5;
pVlcTable->kpZeroTable[6] = g_kuiZeroLeftTable6;
pVlcTable->kpZeroTable[0] = g_kuiZeroLeftTable0;
pVlcTable->kpZeroTable[1] = g_kuiZeroLeftTable1;
pVlcTable->kpZeroTable[2] = g_kuiZeroLeftTable2;
pVlcTable->kpZeroTable[3] = g_kuiZeroLeftTable3;
pVlcTable->kpZeroTable[4] = g_kuiZeroLeftTable4;
pVlcTable->kpZeroTable[5] = g_kuiZeroLeftTable5;
pVlcTable->kpZeroTable[6] = g_kuiZeroLeftTable6;
pVlcTable->kpTotalZerosTable[0][0] = g_kuiTotalZerosTable0;
pVlcTable->kpTotalZerosTable[0][1] = g_kuiTotalZerosTable1;
pVlcTable->kpTotalZerosTable[0][2] = g_kuiTotalZerosTable2;
pVlcTable->kpTotalZerosTable[0][3] = g_kuiTotalZerosTable3;
pVlcTable->kpTotalZerosTable[0][4] = g_kuiTotalZerosTable4;
pVlcTable->kpTotalZerosTable[0][5] = g_kuiTotalZerosTable5;
pVlcTable->kpTotalZerosTable[0][6] = g_kuiTotalZerosTable6;
pVlcTable->kpTotalZerosTable[0][7] = g_kuiTotalZerosTable7;
pVlcTable->kpTotalZerosTable[0][8] = g_kuiTotalZerosTable8;
pVlcTable->kpTotalZerosTable[0][9] = g_kuiTotalZerosTable9;
pVlcTable->kpTotalZerosTable[0][10] = g_kuiTotalZerosTable10;
pVlcTable->kpTotalZerosTable[0][11] = g_kuiTotalZerosTable11;
pVlcTable->kpTotalZerosTable[0][12] = g_kuiTotalZerosTable12;
pVlcTable->kpTotalZerosTable[0][13] = g_kuiTotalZerosTable13;
pVlcTable->kpTotalZerosTable[0][14] = g_kuiTotalZerosTable14;
pVlcTable->kpTotalZerosTable[1][0] = g_kuiTotalZerosChromaTable0;
pVlcTable->kpTotalZerosTable[1][1] = g_kuiTotalZerosChromaTable1;
pVlcTable->kpTotalZerosTable[1][2] = g_kuiTotalZerosChromaTable2;
pVlcTable->kpTotalZerosTable[0][0] = g_kuiTotalZerosTable0;
pVlcTable->kpTotalZerosTable[0][1] = g_kuiTotalZerosTable1;
pVlcTable->kpTotalZerosTable[0][2] = g_kuiTotalZerosTable2;
pVlcTable->kpTotalZerosTable[0][3] = g_kuiTotalZerosTable3;
pVlcTable->kpTotalZerosTable[0][4] = g_kuiTotalZerosTable4;
pVlcTable->kpTotalZerosTable[0][5] = g_kuiTotalZerosTable5;
pVlcTable->kpTotalZerosTable[0][6] = g_kuiTotalZerosTable6;
pVlcTable->kpTotalZerosTable[0][7] = g_kuiTotalZerosTable7;
pVlcTable->kpTotalZerosTable[0][8] = g_kuiTotalZerosTable8;
pVlcTable->kpTotalZerosTable[0][9] = g_kuiTotalZerosTable9;
pVlcTable->kpTotalZerosTable[0][10] = g_kuiTotalZerosTable10;
pVlcTable->kpTotalZerosTable[0][11] = g_kuiTotalZerosTable11;
pVlcTable->kpTotalZerosTable[0][12] = g_kuiTotalZerosTable12;
pVlcTable->kpTotalZerosTable[0][13] = g_kuiTotalZerosTable13;
pVlcTable->kpTotalZerosTable[0][14] = g_kuiTotalZerosTable14;
pVlcTable->kpTotalZerosTable[1][0] = g_kuiTotalZerosChromaTable0;
pVlcTable->kpTotalZerosTable[1][1] = g_kuiTotalZerosChromaTable1;
pVlcTable->kpTotalZerosTable[1][2] = g_kuiTotalZerosChromaTable2;
}

View File

@ -51,55 +51,55 @@ extern __align16 (const uint16_t, g_kuiDequantCoeff[52][8]);
/* Profile IDC */
typedef uint8_t ProfileIdc;
enum {
PRO_BASELINE = 66,
PRO_MAIN = 77,
PRO_EXTENDED = 88,
PRO_HIGH = 100,
PRO_HIGH10 = 110,
PRO_HIGH422 = 122,
PRO_HIGH444 = 144,
PRO_CAVLC444 = 244,
PRO_BASELINE = 66,
PRO_MAIN = 77,
PRO_EXTENDED = 88,
PRO_HIGH = 100,
PRO_HIGH10 = 110,
PRO_HIGH422 = 122,
PRO_HIGH444 = 144,
PRO_CAVLC444 = 244,
PRO_SCALABLE_BASELINE = 83,
PRO_SCALABLE_HIGH = 86,
PRO_SCALABLE_BASELINE = 83,
PRO_SCALABLE_HIGH = 86,
};
/*
* NAL Unit Type (5 Bits)
*/
typedef enum TagNalUnitType {
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
NAL_UNIT_CODED_SLICE_DPB = 3,
NAL_UNIT_CODED_SLICE_DPC = 4,
NAL_UNIT_CODED_SLICE_IDR = 5,
NAL_UNIT_SEI = 6,
NAL_UNIT_SPS = 7,
NAL_UNIT_PPS = 8,
NAL_UNIT_AU_DELIMITER = 9,
NAL_UNIT_END_OF_SEQ = 10,
NAL_UNIT_END_OF_STR = 11,
NAL_UNIT_FILLER_DATA = 12,
NAL_UNIT_SPS_EXT = 13,
NAL_UNIT_PREFIX = 14,
NAL_UNIT_SUBSET_SPS = 15,
NAL_UNIT_RESV_16 = 16,
NAL_UNIT_RESV_17 = 17,
NAL_UNIT_RESV_18 = 18,
NAL_UNIT_AUX_CODED_SLICE = 19,
NAL_UNIT_CODED_SLICE_EXT = 20,
NAL_UNIT_RESV_21 = 21,
NAL_UNIT_RESV_22 = 22,
NAL_UNIT_RESV_23 = 23,
NAL_UNIT_UNSPEC_24 = 24,
NAL_UNIT_UNSPEC_25 = 25,
NAL_UNIT_UNSPEC_26 = 26,
NAL_UNIT_UNSPEC_27 = 27,
NAL_UNIT_UNSPEC_28 = 28,
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
NAL_UNIT_CODED_SLICE_DPB = 3,
NAL_UNIT_CODED_SLICE_DPC = 4,
NAL_UNIT_CODED_SLICE_IDR = 5,
NAL_UNIT_SEI = 6,
NAL_UNIT_SPS = 7,
NAL_UNIT_PPS = 8,
NAL_UNIT_AU_DELIMITER = 9,
NAL_UNIT_END_OF_SEQ = 10,
NAL_UNIT_END_OF_STR = 11,
NAL_UNIT_FILLER_DATA = 12,
NAL_UNIT_SPS_EXT = 13,
NAL_UNIT_PREFIX = 14,
NAL_UNIT_SUBSET_SPS = 15,
NAL_UNIT_RESV_16 = 16,
NAL_UNIT_RESV_17 = 17,
NAL_UNIT_RESV_18 = 18,
NAL_UNIT_AUX_CODED_SLICE = 19,
NAL_UNIT_CODED_SLICE_EXT = 20,
NAL_UNIT_RESV_21 = 21,
NAL_UNIT_RESV_22 = 22,
NAL_UNIT_RESV_23 = 23,
NAL_UNIT_UNSPEC_24 = 24,
NAL_UNIT_UNSPEC_25 = 25,
NAL_UNIT_UNSPEC_26 = 26,
NAL_UNIT_UNSPEC_27 = 27,
NAL_UNIT_UNSPEC_28 = 28,
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
} ENalUnitType;
static const uint8_t g_kuiEmulationPreventionThreeByte = 0x03;
@ -109,10 +109,10 @@ static const uint8_t g_kuiEmulationPreventionThreeByte = 0x03;
*/
typedef uint8_t NalRefIdc;
enum {
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
};
/*
@ -120,9 +120,9 @@ enum {
*/
typedef uint8_t VclType;
enum {
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
};
/*
@ -147,58 +147,58 @@ extern const VclType g_kuiVclTypeMap[32][2];
* meaning mapped version after eSliceType minus 4.
*/
typedef enum TagSliceType {
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
} ESliceType;
/* List Index */
typedef uint8_t ListIndex;
enum {
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
};
/* Picture Size */
typedef struct TagPictureSize {
int32_t iWidth;
int32_t iHeight;
int32_t iWidth;
int32_t iHeight;
} SPictureSize;
/* Motion Vector components */
typedef uint8_t MvComp;
enum {
MV_X = 0,
MV_Y = 1,
MV_A = 2
MV_X = 0,
MV_Y = 1,
MV_A = 2
};
/* Chroma Components */
typedef uint8_t ChromaComp;
enum {
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
};
/* Position Offset structure */
typedef struct TagPosOffset {
int32_t iLeftOffset;
int32_t iTopOffset;
int32_t iRightOffset;
int32_t iBottomOffset;
int32_t iLeftOffset;
int32_t iTopOffset;
int32_t iRightOffset;
int32_t iBottomOffset;
} SPosOffset;
enum EMbPosition { //
MB_LEFT = 0x01, // A
MB_TOP = 0x02, // B
MB_TOPRIGHT = 0x04, // C
MB_TOPLEFT = 0x08, // D,
MB_PRIVATE = 0x10,
MB_LEFT = 0x01, // A
MB_TOP = 0x02, // B
MB_TOPRIGHT = 0x04, // C
MB_TOPLEFT = 0x08, // D,
MB_PRIVATE = 0x10,
};
/* MB Type & Sub-MB Type */
typedef int32_t MbType;
@ -237,13 +237,13 @@ typedef int32_t SubMbType;
* Memory Management Control Operation (MMCO) code
*/
enum {
MMCO_END = 0,
MMCO_SHORT2UNUSED = 1,
MMCO_LONG2UNUSED = 2,
MMCO_SHORT2LONG = 3,
MMCO_SET_MAX_LONG = 4,
MMCO_RESET = 5,
MMCO_LONG = 6
MMCO_END = 0,
MMCO_SHORT2UNUSED = 1,
MMCO_LONG2UNUSED = 2,
MMCO_SHORT2LONG = 3,
MMCO_SET_MAX_LONG = 4,
MMCO_RESET = 5,
MMCO_LONG = 6
};
/////////intra16x16 Luma

View File

@ -56,57 +56,57 @@ namespace WelsDec {
class CWelsDecoder : public ISVCDecoder {
public:
CWelsDecoder (void);
virtual ~CWelsDecoder();
CWelsDecoder (void);
virtual ~CWelsDecoder();
virtual long EXTAPI Initialize (const SDecodingParam* pParam);
virtual long EXTAPI Uninitialize();
virtual long EXTAPI Initialize (const SDecodingParam* pParam);
virtual long EXTAPI Uninitialize();
/***************************************************************************
* Description:
* Decompress one frame, and output I420 or RGB24(in the future) decoded stream and its length.
* Input parameters:
* Parameter TYPE Description
* pSrc unsigned char* the h264 stream to decode
* srcLength int the length of h264 steam
* pDst unsigned char* buffer pointer of decoded data
* pDstInfo SBufferInfo& information provided to API including width, height, SW/HW option, etc
*
* return: if decode frame success return 0, otherwise corresponding error returned.
***************************************************************************/
virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight);
/***************************************************************************
* Description:
* Decompress one frame, and output I420 or RGB24(in the future) decoded stream and its length.
* Input parameters:
* Parameter TYPE Description
* pSrc unsigned char* the h264 stream to decode
* srcLength int the length of h264 steam
* pDst unsigned char* buffer pointer of decoded data
* pDstInfo SBufferInfo& information provided to API including width, height, SW/HW option, etc
*
* return: if decode frame success return 0, otherwise corresponding error returned.
***************************************************************************/
virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
int* pStride,
int& iWidth,
int& iHeight);
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
SBufferInfo* pDstInfo);
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& color_format);
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char** ppDst,
SBufferInfo* pDstInfo);
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* kpSrc,
const int kiSrcLen,
unsigned char* pDst,
int iDstStride,
int& iDstLen,
int& iWidth,
int& iHeight,
int& color_format);
virtual long EXTAPI SetOption (DECODER_OPTION eOptID, void* pOption);
virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption);
virtual long EXTAPI SetOption (DECODER_OPTION eOptID, void* pOption);
virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption);
private:
PWelsDecoderContext m_pDecContext;
welsCodecTrace* m_pWelsTrace;
PWelsDecoderContext m_pDecContext;
welsCodecTrace* m_pWelsTrace;
void InitDecoder (void);
void UninitDecoder (void);
void InitDecoder (void);
void UninitDecoder (void);
#ifdef OUTPUT_BIT_STREAM
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
#endif//OUTPUT_BIT_STREAM
};

View File

@ -139,6 +139,6 @@ int32_t WelsInitPps (SWelsPPS* pPps,
const uint32_t kuiPpsId,
const bool kbDeblockingFilterPresentFlag,
const bool kbUsingSubsetSps);
int32_t WelsCheckRefFrameLimitation(SLogContext* pLogCtx,SWelsSvcCodingParam* pParam);
int32_t WelsCheckRefFrameLimitation (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam);
}
#endif//WELS_ACCESS_UNIT_PARSER_H__

View File

@ -43,12 +43,12 @@ namespace WelsSVCEnc {
* auxiliary struct for bit-stream reading / writing
*/
typedef struct TagBitStringAux {
uint8_t* pBuf; // pBuffer to start position
uint8_t* pBufEnd; // pBuffer + length
uint8_t* pBufPtr; // current writing position
uint32_t uiCurBits;
int32_t iLeftBits; // count number of available bits left ([1, 8]),
// need pointer to next byte start position in case 0 bit left then 8 instead
uint8_t* pBuf; // pBuffer to start position
uint8_t* pBufEnd; // pBuffer + length
uint8_t* pBufPtr; // current writing position
uint32_t uiCurBits;
int32_t iLeftBits; // count number of available bits left ([1, 8]),
// need pointer to next byte start position in case 0 bit left then 8 instead
} SBitStringAux;
/*!
@ -61,15 +61,15 @@ typedef struct TagBitStringAux {
* \return iSize of pBuffer pData in byte; failed in -1 return
*/
static inline int32_t InitBits (SBitStringAux* pBs, const uint8_t* kpBuf, const int32_t kiSize) {
uint8_t* ptr = (uint8_t*)kpBuf;
uint8_t* ptr = (uint8_t*)kpBuf;
pBs->pBuf = ptr;
pBs->pBufPtr = ptr;
pBs->pBufEnd = ptr + kiSize;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0;
pBs->pBuf = ptr;
pBs->pBufPtr = ptr;
pBs->pBufEnd = ptr + kiSize;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0;
return kiSize;
return kiSize;
}
}

View File

@ -50,15 +50,15 @@ namespace WelsSVCEnc {
//struct tagDeblockingFunc;
typedef struct TagDeblockingFilter {
uint8_t* pCsData[3]; // pointer to reconstructed picture pData
int32_t iCsStride[3]; // Cs iStride
int16_t iMbStride;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
uint8_t uiLumaQP;
uint8_t uiChromaQP;
uint8_t uiFilterIdc;
uint8_t uiReserved;
uint8_t* pCsData[3]; // pointer to reconstructed picture pData
int32_t iCsStride[3]; // Cs iStride
int16_t iMbStride;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
uint8_t uiLumaQP;
uint8_t uiChromaQP;
uint8_t uiFilterIdc;
uint8_t uiReserved;
} SDeblockingFilter;
#if defined(__cplusplus)
@ -71,7 +71,8 @@ void DeblockingBSCalcEnc_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBoundryFla
#endif
#if defined(HAVE_NEON_AARCH64)
void WelsNonZeroCount_AArch64_neon (int8_t* pNonZeroCount);
void DeblockingBSCalcEnc_AArch64_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBoundryFlag, int32_t iMbStride, uint8_t (*pBS)[4][4]);
void DeblockingBSCalcEnc_AArch64_neon (int8_t* pNzc, SMVUnitXY* pMv, int32_t iBoundryFlag, int32_t iMbStride,
uint8_t (*pBS)[4][4]);
#endif
#if defined(__cplusplus)
}

View File

@ -48,9 +48,9 @@ namespace WelsSVCEnc {
*/
typedef struct TagDqIdc {
uint16_t iPpsId; // pPps id
uint8_t iSpsId; // pSps id
int8_t uiSpatialId; // spatial id
uint16_t iPpsId; // pPps id
uint8_t iSpsId; // pSps id
int8_t uiSpatialId; // spatial id
} SDqIdc;
}

View File

@ -64,159 +64,159 @@ namespace WelsSVCEnc {
* reference list for each quality layer in SVC
*/
typedef struct TagRefList {
SPicture* pShortRefList[1 + MAX_SHORT_REF_COUNT]; // reference list 0 - int16_t
SPicture* pLongRefList[1 + MAX_REF_PIC_COUNT]; // reference list 1 - int32_t
SPicture* pNextBuffer;
SPicture* pRef[1 + MAX_REF_PIC_COUNT]; // plus 1 for swap intend
uint8_t uiShortRefCount;
uint8_t uiLongRefCount; // dependend on pRef pic module
SPicture* pShortRefList[1 + MAX_SHORT_REF_COUNT]; // reference list 0 - int16_t
SPicture* pLongRefList[1 + MAX_REF_PIC_COUNT]; // reference list 1 - int32_t
SPicture* pNextBuffer;
SPicture* pRef[1 + MAX_REF_PIC_COUNT]; // plus 1 for swap intend
uint8_t uiShortRefCount;
uint8_t uiLongRefCount; // dependend on pRef pic module
} SRefList;
typedef struct TagLTRState {
// LTR mark feedback
uint32_t uiLtrMarkState; // LTR mark state, indicate whether there is a LTR mark feedback unsolved
int32_t iLtrMarkFbFrameNum;// the unsolved LTR mark feedback, the marked iFrameNum feedback from decoder
// LTR mark feedback
uint32_t uiLtrMarkState; // LTR mark state, indicate whether there is a LTR mark feedback unsolved
int32_t iLtrMarkFbFrameNum;// the unsolved LTR mark feedback, the marked iFrameNum feedback from decoder
// LTR used as recovery reference
int32_t iLastRecoverFrameNum; // reserve the last LTR or IDR recover iFrameNum
int32_t
iLastCorFrameNumDec; // reserved the last correct position in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
int32_t
iCurFrameNumInDec; // current iFrameNum in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
// LTR used as recovery reference
int32_t iLastRecoverFrameNum; // reserve the last LTR or IDR recover iFrameNum
int32_t
iLastCorFrameNumDec; // reserved the last correct position in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
int32_t
iCurFrameNumInDec; // current iFrameNum in decoder side, use to select valid LTR to recover or to decide the LTR mark validation
// LTR mark
int32_t iLTRMarkMode; // direct mark or delay mark
int32_t iLTRMarkSuccessNum; //successful marked num, for mark mode switch
int32_t iCurLtrIdx;// current int32_t term reference index to mark
int32_t iLastLtrIdx[MAX_TEMPORAL_LAYER_NUM];
int32_t iSceneLtrIdx;// related to Scene LTR, used by screen content
// LTR mark
int32_t iLTRMarkMode; // direct mark or delay mark
int32_t iLTRMarkSuccessNum; //successful marked num, for mark mode switch
int32_t iCurLtrIdx;// current int32_t term reference index to mark
int32_t iLastLtrIdx[MAX_TEMPORAL_LAYER_NUM];
int32_t iSceneLtrIdx;// related to Scene LTR, used by screen content
uint32_t uiLtrMarkInterval;// the interval from the last int32_t term pRef mark
uint32_t uiLtrMarkInterval;// the interval from the last int32_t term pRef mark
bool bLTRMarkingFlag; //decide whether current frame marked as LTR
bool bLTRMarkEnable; //when LTR is confirmed and the interval is no smaller than the marking period
bool bReceivedT0LostFlag; // indicate whether a t0 lost feedback is recieved, for LTR recovery
bool bLTRMarkingFlag; //decide whether current frame marked as LTR
bool bLTRMarkEnable; //when LTR is confirmed and the interval is no smaller than the marking period
bool bReceivedT0LostFlag; // indicate whether a t0 lost feedback is recieved, for LTR recovery
} SLTRState;
typedef struct TagSpatialPicIndex {
SPicture* pSrc; // I420 based and after color space converted
int32_t iDid; // dependency id
SPicture* pSrc; // I420 based and after color space converted
int32_t iDid; // dependency id
} SSpatialPicIndex;
typedef struct TagStrideTables {
int32_t* pStrideDecBlockOffset[MAX_DEPENDENCY_LAYER][2]; // [iDid][tid==0][24 x 4]: luma+chroma= 24 x 4
int32_t* pStrideEncBlockOffset[MAX_DEPENDENCY_LAYER]; // [iDid][24 x 4]: luma+chroma= 24 x 4
int16_t* pMbIndexX[MAX_DEPENDENCY_LAYER]; // [iDid][iMbX]: map for iMbX in each spatial layer coding
int16_t* pMbIndexY[MAX_DEPENDENCY_LAYER]; // [iDid][iMbY]: map for iMbY in each spatial layer coding
int32_t* pStrideDecBlockOffset[MAX_DEPENDENCY_LAYER][2]; // [iDid][tid==0][24 x 4]: luma+chroma= 24 x 4
int32_t* pStrideEncBlockOffset[MAX_DEPENDENCY_LAYER]; // [iDid][24 x 4]: luma+chroma= 24 x 4
int16_t* pMbIndexX[MAX_DEPENDENCY_LAYER]; // [iDid][iMbX]: map for iMbX in each spatial layer coding
int16_t* pMbIndexY[MAX_DEPENDENCY_LAYER]; // [iDid][iMbY]: map for iMbY in each spatial layer coding
} SStrideTables;
typedef struct TagWelsEncCtx {
SLogContext sLogCtx;
// Input
SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h
SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx]
SLogContext sLogCtx;
// Input
SWelsSvcCodingParam* pSvcParam; // SVC parameter, WelsSVCParamConfig in svc_param_settings.h
SWelsSliceBs* pSliceBs; // bitstream buffering for various slices, [uiSliceIdx]
int32_t* pSadCostMb;
/* MVD cost tables for Inter MB */
int32_t iMvRange;
uint16_t* pMvdCostTableInter; //[52]; // adaptive to spatial layers
SMVUnitXY*
pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer
int8_t*
pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer
int8_t* pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM];
int8_t*
pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11)
int32_t* pSadCostMb;
/* MVD cost tables for Inter MB */
int32_t iMvRange;
uint16_t* pMvdCostTableInter; //[52]; // adaptive to spatial layers
SMVUnitXY*
pMvUnitBlock4x4; // (*pMvUnitBlock4x4[2])[MB_BLOCK4x4_NUM]; // for store each 4x4 blocks' mv unit, the two swap after different d layer
int8_t*
pRefIndexBlock4x4; // (*pRefIndexBlock4x4[2])[MB_BLOCK8x8_NUM]; // for store each 4x4 blocks' pRef index, the two swap after different d layer
int8_t* pNonZeroCountBlocks; // (*pNonZeroCountBlocks)[MB_LUMA_CHROMA_BLOCK4x4_NUM];
int8_t*
pIntra4x4PredModeBlocks; // (*pIntra4x4PredModeBlocks)[INTRA_4x4_MODE_NUM]; //last byte is not used; the first 4 byte is for the bottom 12,13,14,15 4x4 block intra mode, and 3 byte for (3,7,11)
SMB** ppMbListD; // [MAX_DEPENDENCY_LAYER];
SStrideTables* pStrideTab; // stride tables for internal coding used
SWelsFuncPtrList* pFuncList;
SMB** ppMbListD; // [MAX_DEPENDENCY_LAYER];
SStrideTables* pStrideTab; // stride tables for internal coding used
SWelsFuncPtrList* pFuncList;
SSliceThreading* pSliceThreading;
SSliceThreading* pSliceThreading;
// SSlice context
SSliceCtx* pSliceCtxList;// slice context table for each dependency quality layer
// pointers
SPicture* pEncPic; // pointer to current picture to be encoded
SPicture* pDecPic; // pointer to current picture being reconstructed
SPicture* pRefPic; // pointer to current reference picture
// SSlice context
SSliceCtx* pSliceCtxList;// slice context table for each dependency quality layer
// pointers
SPicture* pEncPic; // pointer to current picture to be encoded
SPicture* pDecPic; // pointer to current picture being reconstructed
SPicture* pRefPic; // pointer to current reference picture
SDqLayer*
pCurDqLayer; // DQ layer context used to being encoded currently, for reference base layer to refer: pCurDqLayer->pRefLayer if applicable
SDqLayer** ppDqLayerList; // overall DQ layers encoded for storage
SDqLayer*
pCurDqLayer; // DQ layer context used to being encoded currently, for reference base layer to refer: pCurDqLayer->pRefLayer if applicable
SDqLayer** ppDqLayerList; // overall DQ layers encoded for storage
SRefList** ppRefPicListExt; // reference picture list for SVC
SPicture* pRefList0[16];
SLTRState* pLtr;//[MAX_DEPENDENCY_LAYER];
bool bCurFrameMarkedAsSceneLtr;
// Derived
int32_t iCodingIndex;
int32_t iFrameIndex; // count how many frames elapsed during coding context currently
int32_t iFrameNum; // current frame number coding
int32_t iPOC; // frame iPOC
EWelsSliceType eSliceType; // currently coding slice type
EWelsNalUnitType eNalType; // NAL type
EWelsNalRefIdc eNalPriority; // NAL_Reference_Idc currently
EWelsNalRefIdc eLastNalPriority; // NAL_Reference_Idc in last frame
uint8_t iNumRef0;
SRefList** ppRefPicListExt; // reference picture list for SVC
SPicture* pRefList0[16];
SLTRState* pLtr;//[MAX_DEPENDENCY_LAYER];
bool bCurFrameMarkedAsSceneLtr;
// Derived
int32_t iCodingIndex;
int32_t iFrameIndex; // count how many frames elapsed during coding context currently
int32_t iFrameNum; // current frame number coding
int32_t iPOC; // frame iPOC
EWelsSliceType eSliceType; // currently coding slice type
EWelsNalUnitType eNalType; // NAL type
EWelsNalRefIdc eNalPriority; // NAL_Reference_Idc currently
EWelsNalRefIdc eLastNalPriority; // NAL_Reference_Idc in last frame
uint8_t iNumRef0;
uint8_t uiDependencyId; // Idc of dependecy layer to be coded
uint8_t uiTemporalId; // Idc of temporal layer to be coded
bool bNeedPrefixNalFlag; // whether add prefix nal
bool bEncCurFrmAsIdrFlag;
uint8_t uiDependencyId; // Idc of dependecy layer to be coded
uint8_t uiTemporalId; // Idc of temporal layer to be coded
bool bNeedPrefixNalFlag; // whether add prefix nal
bool bEncCurFrmAsIdrFlag;
// Rate control routine
SWelsSvcRc* pWelsSvcRc;
int32_t iSkipFrameFlag; //_GOM_RC_
int32_t iGlobalQp; // global qp
// Rate control routine
SWelsSvcRc* pWelsSvcRc;
int32_t iSkipFrameFlag; //_GOM_RC_
int32_t iGlobalQp; // global qp
// VAA
SVAAFrameInfo* pVaa; // VAA information of reference
CWelsPreProcess* pVpp;
// VAA
SVAAFrameInfo* pVaa; // VAA information of reference
CWelsPreProcess* pVpp;
SWelsSPS* pSpsArray; // MAX_SPS_COUNT by standard compatible
SWelsSPS* pSps;
SWelsPPS* pPPSArray; // MAX_PPS_COUNT by standard compatible
SWelsPPS* pPps;
/* SVC only */
SSubsetSps* pSubsetArray; // MAX_SPS_COUNT by standard compatible
SSubsetSps* pSubsetSps;
int32_t iSpsNum; // number of pSps used
int32_t iPpsNum; // number of pPps used
SWelsSPS* pSpsArray; // MAX_SPS_COUNT by standard compatible
SWelsSPS* pSps;
SWelsPPS* pPPSArray; // MAX_PPS_COUNT by standard compatible
SWelsPPS* pPps;
/* SVC only */
SSubsetSps* pSubsetArray; // MAX_SPS_COUNT by standard compatible
SSubsetSps* pSubsetSps;
int32_t iSpsNum; // number of pSps used
int32_t iPpsNum; // number of pPps used
// Output
SWelsEncoderOutput* pOut; // for NAL raw pData (need allocating memory for sNalList internal)
uint8_t* pFrameBs; // restoring bitstream pBuffer of all NALs in a frame
int32_t iFrameBsSize; // count size of frame bs in bytes allocated
int32_t iPosBsBuffer; // current writing position of frame bs pBuffer
// Output
SWelsEncoderOutput* pOut; // for NAL raw pData (need allocating memory for sNalList internal)
uint8_t* pFrameBs; // restoring bitstream pBuffer of all NALs in a frame
int32_t iFrameBsSize; // count size of frame bs in bytes allocated
int32_t iPosBsBuffer; // current writing position of frame bs pBuffer
SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER];
SSpatialPicIndex sSpatialIndexMap[MAX_DEPENDENCY_LAYER];
bool bLongTermRefFlag[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1/*+LONG_TERM_REF_NUM*/];
bool bLongTermRefFlag[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL + 1/*+LONG_TERM_REF_NUM*/];
int16_t iMaxSliceCount;// maximal count number of slices for all layers observation
int16_t iActiveThreadsNum; // number of threads active so far
int16_t iMaxSliceCount;// maximal count number of slices for all layers observation
int16_t iActiveThreadsNum; // number of threads active so far
/*
* DQ layer idc map for svc encoding, might be a better scheme than that of design before,
* can aware idc of referencing layer and that idc of successive layer to be coded
*/
/* SVC only */
SDqIdc*
pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData
/*
* DQ layer idc map for svc encoding, might be a better scheme than that of design before,
* can aware idc of referencing layer and that idc of successive layer to be coded
*/
/* SVC only */
SDqIdc*
pDqIdcMap; // overall DQ map of full scalability in specific frame (All full D/T/Q layers involved) // pDqIdcMap[dq_index] for each SDqIdc pData
SParaSetOffset sPSOVector;
CMemoryAlign* pMemAlign;
SParaSetOffset sPSOVector;
CMemoryAlign* pMemAlign;
#if defined(STAT_OUTPUT)
// overall stat pData, refer to SStatData in stat.h, in case avc to use stat[0][0]
SStatData sStatData [ MAX_DEPENDENCY_LAYER ] [ MAX_QUALITY_LEVEL ];
SStatSliceInfo sPerInfo;
// overall stat pData, refer to SStatData in stat.h, in case avc to use stat[0][0]
SStatData sStatData [ MAX_DEPENDENCY_LAYER ] [ MAX_QUALITY_LEVEL ];
SStatSliceInfo sPerInfo;
#endif//STAT_OUTPUT
int32_t iEncoderError;
WELS_MUTEX mutexEncoderError;
int32_t iDropNumber;
int32_t iEncoderError;
WELS_MUTEX mutexEncoderError;
int32_t iDropNumber;
} sWelsEncCtx/*, *PWelsEncCtx*/;
}
#endif//sWelsEncCtx_H__

View File

@ -65,79 +65,79 @@ extern const uint8_t g_kuiCache48CountScan4Idx[24];
typedef struct TagDCTCoeff {
//ALIGNED_DECLARE( int16_t, residual_ac[16], 16 ); //I_16x16
int16_t iLumaBlock[16][16]; //based on block4x4 luma DC/AC
int16_t iLumaBlock[16][16]; //based on block4x4 luma DC/AC
//ALIGNED_DECLARE( int16_t, iLumaI16x16Dc[16], 16 ); //I_16x16 DC
int16_t iLumaI16x16Dc[16];
int16_t iLumaI16x16Dc[16];
//ALIGNED_DECLARE( int16_t, iChromaDc[2][4], 16 ); //chroma DC
int16_t iChromaBlock[8][16]; //based on block4x4 chroma DC/AC
int16_t iChromaDc[2][4];
int16_t iChromaBlock[8][16]; //based on block4x4 chroma DC/AC
int16_t iChromaDc[2][4];
} SDCTCoeff ;
typedef struct TagMbCache {
//the followed pData now is promised aligned to 16 bytes
ALIGNED_DECLARE (SMVComponentUnit, sMvComponents, 16);
ALIGNED_DECLARE (SMVComponentUnit, sMvComponents, 16);
ALIGNED_DECLARE_MATRIX_1D (iNonZeroCoeffCount, 48, int8_t, 16); // Cache line size
ALIGNED_DECLARE_MATRIX_1D (iNonZeroCoeffCount, 48, int8_t, 16); // Cache line size
// int8_t iNonZeroCoeffCount[6 * 8]; // Right luma, Chroma(Left Top Cb, Left btm Cr); must follow by iIntraPredMode!
ALIGNED_DECLARE_MATRIX_1D (iIntraPredMode, 48, int8_t, 16);
ALIGNED_DECLARE_MATRIX_1D (iIntraPredMode, 48, int8_t, 16);
// must follow with iNonZeroCoeffCount!
int32_t iSadCost[4]; //avail 1; unavail 0
SMVUnitXY sMbMvp[MB_BLOCK8x8_NUM];// for write bs
int32_t iSadCost[4]; //avail 1; unavail 0
SMVUnitXY sMbMvp[MB_BLOCK8x8_NUM];// for write bs
//for residual decoding (recovery) at the side of Encoder
int16_t* pCoeffLevel; // tmep
int16_t* pCoeffLevel; // tmep
//malloc memory for prediction
uint8_t* pSkipMb;
uint8_t* pSkipMb;
//ALIGNED_DECLARE(uint8_t, pMemPredMb[2][256], 16);//One: Best I_16x16 Luma and refine frac_pixel pBuffer; another: PingPong I_8x8&&Inter Cb + Cr
uint8_t* pMemPredMb;
uint8_t* pMemPredLuma;// inter && intra share same pointer;
uint8_t* pMemPredMb;
uint8_t* pMemPredLuma;// inter && intra share same pointer;
//ALIGNED_DECLARE(uint8_t, pMemPredChroma[2][64*2], 16); //another PingPong pBuffer: Best Cb + Cr;
uint8_t* pMemPredChroma;// inter && intra share same pointer;
uint8_t* pBestPredIntraChroma; //Cb:0~63; Cr:64~127
uint8_t* pMemPredChroma;// inter && intra share same pointer;
uint8_t* pBestPredIntraChroma; //Cb:0~63; Cr:64~127
//ALIGNED_DECLARE(uint8_t, pMemPredBlk4[2][16], 16); //I_4x4
uint8_t* pMemPredBlk4;
uint8_t* pMemPredBlk4;
uint8_t* pBestPredI4x4Blk4;//I_4x4
uint8_t* pBestPredI4x4Blk4;//I_4x4
//ALIGNED_DECLARE(uint8_t, pBufferInterPredMe[4][400], 16);//inter type pBuffer for ME h & v & hv
uint8_t* pBufferInterPredMe; // [4][400] is enough because only h&v or v&hv or h&hv. but if both h&v&hv is needed when 8 quart pixel, future we have to use [5][400].
uint8_t* pBufferInterPredMe; // [4][400] is enough because only h&v or v&hv or h&hv. but if both h&v&hv is needed when 8 quart pixel, future we have to use [5][400].
//no scan4[] order, just as memory order to store
//ALIGNED_DECLARE(bool, pPrevIntra4x4PredModeFlag[16], 16);//if 1, means no rem_intra4x4_pred_mode; if 0, means rem_intra4x4_pred_mode != 0
bool* pPrevIntra4x4PredModeFlag;
bool* pPrevIntra4x4PredModeFlag;
//ALIGNED_DECLARE(int8_t, pRemIntra4x4PredModeFlag[16], 16);//-1 as default; if pPrevIntra4x4PredModeFlag==0,
//pRemIntra4x4PredModeFlag or added by 1 is the best pred_mode
int8_t* pRemIntra4x4PredModeFlag;
int8_t* pRemIntra4x4PredModeFlag;
int32_t iSadCostSkip[4]; //avail 1; unavail 0
bool bMbTypeSkip[4]; //1: skip; 0: non-skip
int32_t* pEncSad;
int32_t iSadCostSkip[4]; //avail 1; unavail 0
bool bMbTypeSkip[4]; //1: skip; 0: non-skip
int32_t* pEncSad;
//for residual encoding at the side of Encoder
SDCTCoeff* pDct;
SDCTCoeff* pDct;
uint8_t uiNeighborIntra; // LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPLEFT_MB_POS = 0x04 ,TOPRIGHT_MB_POS = 0x08;
uint8_t uiLumaI16x16Mode;
uint8_t uiChmaI8x8Mode;
uint8_t uiNeighborIntra; // LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPLEFT_MB_POS = 0x04 ,TOPRIGHT_MB_POS = 0x08;
uint8_t uiLumaI16x16Mode;
uint8_t uiChmaI8x8Mode;
bool bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0).
uint32_t uiRefMbType;
bool bCollocatedPredFlag;//denote if current MB is collocated predicted (MV==0).
uint32_t uiRefMbType;
struct {
/* pointer of current mb location in original frame */
uint8_t* pEncMb[3];
/* pointer of current mb location in recovery frame */
uint8_t* pDecMb[3];
/* pointer of co-located mb location in reference frame */
uint8_t* pRefMb[3];
//for SVC
uint8_t* pCsMb[3];//locating current mb's CS in whole frame
struct {
/* pointer of current mb location in original frame */
uint8_t* pEncMb[3];
/* pointer of current mb location in recovery frame */
uint8_t* pDecMb[3];
/* pointer of co-located mb location in reference frame */
uint8_t* pRefMb[3];
//for SVC
uint8_t* pCsMb[3];//locating current mb's CS in whole frame
// int16_t *p_rs[3];//locating current mb's RS in whole frame
} SPicData;
} SPicData;
} SMbCache;
}//end of namespace

View File

@ -84,43 +84,43 @@ extern const int8_t g_kiMapModeIntraChroma[7];
// if we want keep total sizeof(SWelsMD) <= 256, we maybe need to seperate three member of SWelsME.
typedef struct TagWelsMD {
int32_t iLambda;
uint16_t* pMvdCost;
int32_t iLambda;
uint16_t* pMvdCost;
int32_t iCostLuma;
int32_t iCostChroma;//satd+lambda(best_pred_mode) //i_sad_chroma;
int32_t iSadPredMb;
int32_t iCostLuma;
int32_t iCostChroma;//satd+lambda(best_pred_mode) //i_sad_chroma;
int32_t iSadPredMb;
uint8_t uiRef; //uiRefIndex appointed by Encoder, used for MC
bool bMdUsingSad;
uint16_t uiReserved;
uint8_t uiRef; //uiRefIndex appointed by Encoder, used for MC
bool bMdUsingSad;
uint16_t uiReserved;
int32_t iCostSkipMb;
int32_t iSadPredSkip;
int32_t iCostSkipMb;
int32_t iSadPredSkip;
int32_t iMbPixX; // pixel position of MB in horizontal axis
int32_t iMbPixY; // pixel position of MB in vertical axis
int32_t iBlock8x8StaticIdc[4];
int32_t iMbPixX; // pixel position of MB in horizontal axis
int32_t iMbPixY; // pixel position of MB in vertical axis
int32_t iBlock8x8StaticIdc[4];
//NO B frame in our Wels, we can ignore list1
struct {
SWelsME sMe16x16; //adjust each SWelsME for 8 D-word!
SWelsME sMe8x8[4];
SWelsME sMe16x8[2];
SWelsME sMe8x16[2];
struct {
SWelsME sMe16x16; //adjust each SWelsME for 8 D-word!
SWelsME sMe8x8[4];
SWelsME sMe16x8[2];
SWelsME sMe8x16[2];
// SMVUnitXY i_mvbs[MB_BLOCK8x8_NUM]; //scaled MVB
} sMe;
} sMe;
} SWelsMD;
typedef struct TagMeRefinePointer {
uint8_t* pHalfPixH;
uint8_t* pHalfPixV;
uint8_t* pHalfPixHV;
uint8_t* pHalfPixH;
uint8_t* pHalfPixV;
uint8_t* pHalfPixHV;
uint8_t* pQuarPixBest;
uint8_t* pQuarPixTmp;
uint8_t* pQuarPixBest;
uint8_t* pQuarPixTmp;
} SMeRefinePointer;

View File

@ -43,30 +43,30 @@ namespace WelsSVCEnc {
class CMemoryAlign {
public:
CMemoryAlign (const uint32_t kuiCacheLineSize);
virtual ~CMemoryAlign();
CMemoryAlign (const uint32_t kuiCacheLineSize);
virtual ~CMemoryAlign();
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
void WelsFree (void* pPointer, const char* kpTag);
const uint32_t WelsGetCacheLineSize() const;
const uint32_t WelsGetMemoryUsage() const;
void* WelsMallocz (const uint32_t kuiSize, const char* kpTag);
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag);
void WelsFree (void* pPointer, const char* kpTag);
const uint32_t WelsGetCacheLineSize() const;
const uint32_t WelsGetMemoryUsage() const;
private:
// private copy & assign constructors adding to fix klocwork scan issues
CMemoryAlign (const CMemoryAlign& kcMa);
CMemoryAlign& operator= (const CMemoryAlign& kcMa);
CMemoryAlign (const CMemoryAlign& kcMa);
CMemoryAlign& operator= (const CMemoryAlign& kcMa);
protected:
uint32_t m_nCacheLineSize;
uint32_t m_nCacheLineSize;
#ifdef MEMORY_MONITOR
uint32_t m_nMemoryUsageInBytes;
uint32_t m_nMemoryUsageInBytes;
#endif//MEMORY_MONITOR
#ifdef MEMORY_CHECK
FILE* m_fpMemChkPoint;
uint32_t m_nCountRequestNum;
FILE* m_fpMemChkPoint;
uint32_t m_nCountRequestNum;
#endif//MEMORY_CHECK
};

View File

@ -59,36 +59,36 @@
#define THRESHOLD_RMSE_CORE2 0.0200f // v1.1: 0.0200f; v1.0: 0.04f
typedef struct TagSliceThreadPrivateData {
void* pWelsPEncCtx;
SLayerBSInfo* pLayerBs;
int32_t iSliceIndex; // slice index, zero based
int32_t iThreadIndex; // thread index, zero based
void* pWelsPEncCtx;
SLayerBSInfo* pLayerBs;
int32_t iSliceIndex; // slice index, zero based
int32_t iThreadIndex; // thread index, zero based
// for dynamic slicing mode
int32_t iStartMbIndex; // inclusive
int32_t iEndMbIndex; // exclusive
int32_t iStartMbIndex; // inclusive
int32_t iEndMbIndex; // exclusive
} SSliceThreadPrivateData;
typedef struct TagSliceThreading {
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
char eventNamespace[100];
WELS_THREAD_HANDLE pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx]
WELS_EVENT pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
WELS_EVENT pSliceCodedMasterEvent; // events for signalling that some event in pSliceCodedEvent has been signalled
WELS_EVENT pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
WELS_EVENT pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list neighbor for various slices
WELS_EVENT pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
WELS_EVENT pExitEncodeEvent[MAX_THREADS_NUM]; // event for exit encoding event
WELS_EVENT
pThreadMasterEvent[MAX_THREADS_NUM]; // event for indicating that some event has been signalled to the thread
SSliceThreadPrivateData* pThreadPEncCtx;// thread context, [iThreadIdx]
char eventNamespace[100];
WELS_THREAD_HANDLE pThreadHandles[MAX_THREADS_NUM];// thread handles, [iThreadIdx]
WELS_EVENT pSliceCodedEvent[MAX_THREADS_NUM];// events for slice coded state, [iThreadIdx]
WELS_EVENT pSliceCodedMasterEvent; // events for signalling that some event in pSliceCodedEvent has been signalled
WELS_EVENT pReadySliceCodingEvent[MAX_THREADS_NUM]; // events for slice coding ready, [iThreadIdx]
WELS_EVENT pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list neighbor for various slices
WELS_EVENT pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
WELS_EVENT pExitEncodeEvent[MAX_THREADS_NUM]; // event for exit encoding event
WELS_EVENT
pThreadMasterEvent[MAX_THREADS_NUM]; // event for indicating that some event has been signalled to the thread
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT
uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx]
int32_t* pSliceComplexRatio[MAX_DEPENDENCY_LAYER]; // *INT_MULTIPLY
uint32_t* pSliceConsumeTime[MAX_DEPENDENCY_LAYER]; // consuming time for each slice, [iSpatialIdx][uiSliceIdx]
int32_t* pSliceComplexRatio[MAX_DEPENDENCY_LAYER]; // *INT_MULTIPLY
#ifdef MT_DEBUG
FILE* pFSliceDiff; // file handle for debug
FILE* pFSliceDiff; // file handle for debug
#endif//MT_DEBUG
} SSliceThreading;

View File

@ -52,29 +52,29 @@ namespace WelsSVCEnc {
* Raw payload pData for NAL unit, AVC/SVC compatible
*/
typedef struct TagWelsNalRaw {
uint8_t* pRawData; // pRawNal payload for slice pData
int32_t iPayloadSize; // size of pRawNal pData
uint8_t* pRawData; // pRawNal payload for slice pData
int32_t iPayloadSize; // size of pRawNal pData
SNalUnitHeaderExt sNalExt; // NAL header information
SNalUnitHeaderExt sNalExt; // NAL header information
int32_t iStartPos; //NAL start position in buffer
int32_t iStartPos; //NAL start position in buffer
} SWelsNalRaw;
/*
* Encoder majoy output pData
*/
typedef struct TagWelsEncoderOutput {
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded picture, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded picture, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
SBitStringAux sBsWrite;
SBitStringAux sBsWrite;
// SWelsNalRaw raw_nals[MAX_DEPENDENCY_LAYER*2+MAX_DEPENDENCY_LAYER*MAX_QUALITY_LEVEL]; // AVC: max up to SPS+PPS+max_slice_idc (2 + 8) for FMO;
SWelsNalRaw* sNalList; // nal list, adaptive for AVC/SVC in case single slice, multiple slices or fmo
int32_t* pNalLen;
int32_t iCountNals; // count number of NAL in list
SWelsNalRaw* sNalList; // nal list, adaptive for AVC/SVC in case single slice, multiple slices or fmo
int32_t* pNalLen;
int32_t iCountNals; // count number of NAL in list
// SVC: num_sps (MAX_D) + num_pps (MAX_D) + num_vcl (MAX_D * MAX_Q)
int32_t iNalIndex; // coding NAL currently, 0 based
int32_t iNalIndex; // coding NAL currently, 0 based
// bool bAnnexBFlag; // annexeb flag, to figure it pOut the packetization mode whether need 4 bytes (0 0 0 1) of start code prefix
} SWelsEncoderOutput;
@ -82,21 +82,21 @@ typedef struct TagWelsEncoderOutput {
//#define MT_DEBUG_BS_WR 0 // for MT debugging if needed
typedef struct TagWelsSliceBs {
uint8_t* pBs; // output bitstream, pBitStringAux not needed for slice 0 due to no dependency of pFrameBs available
uint32_t uiBsPos; // position of output bitstream
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded slice, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
uint8_t* pBs; // output bitstream, pBitStringAux not needed for slice 0 due to no dependency of pFrameBs available
uint32_t uiBsPos; // position of output bitstream
uint8_t* pBsBuffer; // overall bitstream pBuffer allocation for a coded slice, recycling use intend.
uint32_t uiSize; // size of allocation pBuffer above
SBitStringAux sBsWrite;
SBitStringAux sBsWrite;
SWelsNalRaw sNalList[2]; // nal list, PREFIX NAL(if applicable) + SLICE NAL
SWelsNalRaw sNalList[2]; // nal list, PREFIX NAL(if applicable) + SLICE NAL
// int32_t iCountNals; // count number of NAL in list
int32_t iNalLen[2];
int32_t iNalIndex; // coding NAL currently, 0 based
int32_t iNalLen[2];
int32_t iNalIndex; // coding NAL currently, 0 based
// bool bAnnexBFlag; // annexeb flag, to figure it pOut the packetization mode whether need 4 bytes (0 0 0 1) of start code prefix
#if MT_DEBUG_BS_WR
bool bSliceCodedFlag;
bool bSliceCodedFlag;
#endif//MT_DEBUG_BS_WR
} SWelsSliceBs;

View File

@ -43,20 +43,20 @@ namespace WelsSVCEnc {
/* NAL Unix Header in AVC, refer to Page 56 in JVT X201wcm */
typedef struct TagNalUnitHeader {
uint8_t uiForbiddenZeroBit;
uint8_t uiNalRefIdc;
EWelsNalUnitType eNalUnitType;
uint8_t uiReservedOneByte;
uint8_t uiForbiddenZeroBit;
uint8_t uiNalRefIdc;
EWelsNalUnitType eNalUnitType;
uint8_t uiReservedOneByte;
} SNalUnitHeader, *PNalUnitHeader;
/* NAL Unit Header in scalable extension syntax, refer to Page 390 in JVT X201wcm */
typedef struct TagNalUnitHeaderExt {
SNalUnitHeader sNalHeader;
SNalUnitHeader sNalHeader;
bool bIdrFlag;
uint8_t uiDependencyId;
uint8_t uiTemporalId;
bool bDiscardableFlag;
bool bIdrFlag;
uint8_t uiDependencyId;
uint8_t uiTemporalId;
bool bDiscardableFlag;
} SNalUnitHeaderExt, *PNalUnitHeaderExt;

View File

@ -64,32 +64,32 @@ extern const uint8_t g_kuiTemporalIdListTable[MAX_TEMPORAL_LEVEL][MAX_GOP_SIZE
* \return 2 based scaling factor
*/
static inline uint32_t GetLogFactor (float base, float upper) {
const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0);
const double dEpsilon = 0.0001;
const double dRound = floor (dLog2factor + 0.5);
const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0);
const double dEpsilon = 0.0001;
const double dRound = floor (dLog2factor + 0.5);
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
return (uint32_t) (dRound);
}
return UINT_MAX;
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
return (uint32_t) (dRound);
}
return UINT_MAX;
}
/*
* Dependency Layer Parameter
*/
typedef struct TagDLayerParam {
int32_t iActualWidth; // input source picture actual width
int32_t iActualHeight; // input source picture actual height
int32_t iTemporalResolution;
int32_t iDecompositionStages;
uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1];
int32_t iActualWidth; // input source picture actual width
int32_t iActualHeight; // input source picture actual height
int32_t iTemporalResolution;
int32_t iDecompositionStages;
uint8_t uiCodingIdx2TemporalId[ (1 << MAX_TEMPORAL_LEVEL) + 1];
int8_t iHighestTemporalId;
float fInputFrameRate; // input frame rate
float fOutputFrameRate; // output frame rate
int8_t iHighestTemporalId;
float fInputFrameRate; // input frame rate
float fOutputFrameRate; // output frame rate
#ifdef ENABLE_FRAME_DUMP
char sRecFileName[MAX_FNAME_LEN]; // file to be constructed
char sRecFileName[MAX_FNAME_LEN]; // file to be constructed
#endif//ENABLE_FRAME_DUMP
} SSpatialLayerInternal;
@ -97,424 +97,424 @@ typedef struct TagDLayerParam {
* Cisco OpenH264 Encoder Parameter Configuration
*/
typedef struct TagWelsSvcCodingParam: SEncParamExt {
SSpatialLayerInternal sDependencyLayers[MAX_DEPENDENCY_LAYER];
SSpatialLayerInternal sDependencyLayers[MAX_DEPENDENCY_LAYER];
/* General */
uint32_t uiGopSize; // GOP size (at maximal frame rate: 16)
struct {
int32_t iLeft;
int32_t iTop;
int32_t iWidth;
int32_t iHeight;
} SUsedPicRect; // the rect in input picture that encoder actually used
/* General */
uint32_t uiGopSize; // GOP size (at maximal frame rate: 16)
struct {
int32_t iLeft;
int32_t iTop;
int32_t iWidth;
int32_t iHeight;
} SUsedPicRect; // the rect in input picture that encoder actually used
char* pCurPath; // record current lib path such as:/pData/pData/com.wels.enc/lib/
char* pCurPath; // record current lib path such as:/pData/pData/com.wels.enc/lib/
bool bDeblockingParallelFlag; // deblocking filter parallelization control flag
bool bDeblockingParallelFlag; // deblocking filter parallelization control flag
short
iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
short
iCountThreadsNum; // # derived from disable_multiple_slice_idc (=0 or >1) means;
int8_t iDecompStages; // GOP size dependency
int32_t iMaxNumRefFrame;
int8_t iDecompStages; // GOP size dependency
int32_t iMaxNumRefFrame;
public:
TagWelsSvcCodingParam() {
FillDefault();
}
~TagWelsSvcCodingParam() {}
TagWelsSvcCodingParam() {
FillDefault();
}
~TagWelsSvcCodingParam() {}
static void FillDefault (SEncParamExt& param) {
memset (&param, 0, sizeof (param));
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used
static void FillDefault (SEncParamExt& param) {
memset (&param, 0, sizeof (param));
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used
param.iPicWidth = 0; // actual input picture width
param.iPicHeight = 0; // actual input picture height
param.iPicWidth = 0; // actual input picture width
param.iPicHeight = 0; // actual input picture height
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
param.iInputCsp = videoFormatI420; // input sequence color space in default
param.uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
param.iInputCsp = videoFormatI420; // input sequence color space in default
param.uiFrameToBeCoded = (uint32_t) - 1; // frame to be encoded (at input frame rate)
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
param.iMaxBitrate = MAX_BIT_RATE;
param.iMultipleThreadIdc = 1;
param.iTargetBitrate = 0; // overall target bitrate introduced in RC module
param.iMaxBitrate = MAX_BIT_RATE;
param.iMultipleThreadIdc = 1;
param.iLTRRefNum = 0;
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
param.iLTRRefNum = 0;
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
param.bEnableSSEI = true;
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
param.bEnableSSEI = true;
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
// false: Streaming Video Sharing; true: Video Conferencing Meeting;
/* Deblocking loop filter */
param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries
param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
/* Deblocking loop filter */
param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries
param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
/* Rate Control */
param.iRCMode = RC_QUALITY_MODE;
param.iPaddingFlag = 0;
/* Rate Control */
param.iRCMode = RC_QUALITY_MODE;
param.iPaddingFlag = 0;
param.bEnableDenoise = false; // denoise control
param.bEnableSceneChangeDetect = true; // scene change detection control
param.bEnableBackgroundDetection = true; // background detection control
param.bEnableAdaptiveQuant = true; // adaptive quantization control
param.bEnableFrameSkip = true; // frame skipping
param.bEnableLongTermReference = false; // long term reference control
param.bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
param.iTemporalLayerNum = 1; // number of temporal layer specified
param.bEnableDenoise = false; // denoise control
param.bEnableSceneChangeDetect = true; // scene change detection control
param.bEnableBackgroundDetection = true; // background detection control
param.bEnableAdaptiveQuant = true; // adaptive quantization control
param.bEnableFrameSkip = true; // frame skipping
param.bEnableLongTermReference = false; // long term reference control
param.bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
param.iTemporalLayerNum = 1; // number of temporal layer specified
param.iMaxQp = 51;
param.iMinQp = 0;
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.uiMaxNalSize = 0;
param.iMaxQp = 51;
param.iMinQp = 0;
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.uiMaxNalSize = 0;
for (int32_t iLayer = 0; iLayer < MAX_SPATIAL_LAYER_NUM; iLayer++) {
param.sSpatialLayers[iLayer].uiProfileIdc = PRO_BASELINE;
param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_5_0;
param.sSpatialLayers[iLayer].iDLayerQp = SVC_QUALITY_BASE_QP;
param.sSpatialLayers[iLayer].fFrameRate = param.fMaxFrameRate;
param.sSpatialLayers[iLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
}
}
void FillDefault() {
FillDefault (*this);
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
iMaxNumRefFrame = 1;
SUsedPicRect.iLeft =
SUsedPicRect.iTop =
SUsedPicRect.iWidth =
SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used
pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
memset (sDependencyLayers, 0, sizeof (SSpatialLayerInternal)*MAX_DEPENDENCY_LAYER);
memset (sSpatialLayers, 0 , sizeof (SSpatialLayerConfig)*MAX_SPATIAL_LAYER_NUM);
//init multi-slice
sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 1;
for (int32_t iLayer = 0; iLayer < MAX_SPATIAL_LAYER_NUM; iLayer++) {
param.sSpatialLayers[iLayer].uiProfileIdc = PRO_BASELINE;
param.sSpatialLayers[iLayer].uiLevelIdc = LEVEL_5_0;
param.sSpatialLayers[iLayer].iDLayerQp = SVC_QUALITY_BASE_QP;
param.sSpatialLayers[iLayer].fFrameRate = param.fMaxFrameRate;
param.sSpatialLayers[iLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sSpatialLayers[0].iDLayerQp = SVC_QUALITY_BASE_QP;
param.sSpatialLayers[iLayer].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
}
}
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
void FillDefault() {
FillDefault (*this);
uiGopSize = 1; // GOP size (at maximal frame rate: 16)
iMaxNumRefFrame = 1;
SUsedPicRect.iLeft =
SUsedPicRect.iTop =
SUsedPicRect.iWidth =
SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iTargetBitrate = pCodingParam.iTargetBitrate;
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag
iRCMode = pCodingParam.iRCMode; // rc mode
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
int8_t iIdxSpatial = 0;
EProfileIdc uiProfileIdc = PRO_BASELINE;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
memset (sDependencyLayers, 0, sizeof (SSpatialLayerInternal)*MAX_DEPENDENCY_LAYER);
memset (sSpatialLayers, 0 , sizeof (SSpatialLayerConfig)*MAX_SPATIAL_LAYER_NUM);
while (iIdxSpatial < iSpatialLayerNum) {
sSpatialLayers->uiProfileIdc = uiProfileIdc;
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
MIN_FRAME_RATE, MAX_FRAME_RATE);
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
MAX_FRAME_RATE);
//init multi-slice
sSpatialLayers[0].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 1500;
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = 1;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
for (int32_t idx = 0; idx < kiLesserSliceNum; idx++)
sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceMbNum[idx] = 960;
sSpatialLayers[0].iDLayerQp = SVC_QUALITY_BASE_QP;
}
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iTargetBitrate = pCodingParam.iTargetBitrate;
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
iRCMode = pCodingParam.iRCMode; // rc mode
int8_t iIdxSpatial = 0;
EProfileIdc uiProfileIdc = PRO_BASELINE;
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
while (iIdxSpatial < iSpatialLayerNum) {
sSpatialLayers->uiProfileIdc = uiProfileIdc;
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
MIN_FRAME_RATE, MAX_FRAME_RATE);
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
MAX_FRAME_RATE);
#ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
sSpatialLayers->iSpatialBitrate =
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
sSpatialLayers->iSpatialBitrate =
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP;
sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ iIdxSpatial;
}
SetActualPicResolution();
return 0;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ iIdxSpatial;
}
void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iUsageType = iUsageType;
pCodingParam->iInputCsp = iInputCsp;
pCodingParam->iPicWidth = iPicWidth;
pCodingParam->iPicHeight = iPicHeight;
pCodingParam->iTargetBitrate = iTargetBitrate;
pCodingParam->iRCMode = iRCMode;
pCodingParam->fMaxFrameRate = fMaxFrameRate;
SetActualPicResolution();
return 0;
}
void GetBaseParams (SEncParamBase* pCodingParam) {
pCodingParam->iUsageType = iUsageType;
pCodingParam->iInputCsp = iInputCsp;
pCodingParam->iPicWidth = iPicWidth;
pCodingParam->iPicHeight = iPicHeight;
pCodingParam->iTargetBitrate = iTargetBitrate;
pCodingParam->iRCMode = iRCMode;
pCodingParam->fMaxFrameRate = fMaxFrameRate;
}
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
uiFrameToBeCoded = (uint32_t) -
1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
/* Deblocking loop filter */
iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries,
if (iLoopFilterDisableIdc == 0) // Loop filter requested to be enabled
iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0
iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag;
/* Rate Control */
iRCMode = pCodingParam.iRCMode; // rc mode
iPaddingFlag = pCodingParam.iPaddingFlag;
iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate
iMaxBitrate = pCodingParam.iMaxBitrate;
if (iMaxBitrate < iTargetBitrate) {
iMaxBitrate = iTargetBitrate;
}
int32_t ParamTranscode (const SEncParamExt& pCodingParam) {
float fParamMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iInputCsp = pCodingParam.iInputCsp; // color space of input sequence
uiFrameToBeCoded = (uint32_t) -
1; // frame to be encoded (at input frame rate), -1 dependents on length of input sequence
iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight;
uiMaxNalSize = pCodingParam.uiMaxNalSize;
/* Denoise Control */
bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now
SUsedPicRect.iLeft = 0;
SUsedPicRect.iTop = 0;
SUsedPicRect.iWidth = ((iPicWidth >> 1) << 1);
SUsedPicRect.iHeight = ((iPicHeight >> 1) << 1);
/* Scene change detection control */
bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect;
/* Deblocking loop filter */
iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries,
if (iLoopFilterDisableIdc == 0) // Loop filter requested to be enabled
iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0
iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
/* Background detection Control */
bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false;
bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag;
/* Adaptive quantization control */
bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false;
/* Rate Control */
iRCMode = pCodingParam.iRCMode; // rc mode
iPaddingFlag = pCodingParam.iPaddingFlag;
/* Frame skipping */
bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false;
iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate
iMaxBitrate = pCodingParam.iMaxBitrate;
if (iMaxBitrate < iTargetBitrate) {
iMaxBitrate = iTargetBitrate;
}
/* Enable int32_t term reference */
bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
uiMaxNalSize = pCodingParam.uiMaxNalSize;
/* Denoise Control */
bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now
iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc;
/* Scene change detection control */
bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect;
/* For ssei information */
bEnableSSEI = pCodingParam.bEnableSSEI;
/* Background detection Control */
bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false;
/* Layer definition */
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
MAX_TEMPORAL_LEVEL); // number of temporal layer specified
/* Adaptive quantization control */
bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false;
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired)
if (uiIntraPeriod == (uint32_t) (-1))
uiIntraPeriod = 0;
else if (uiIntraPeriod & (uiGopSize - 1)) // none multiple of GOP size
uiIntraPeriod = ((uiIntraPeriod + uiGopSize - 1) / uiGopSize) * uiGopSize;
/* Frame skipping */
bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false;
/* Enable int32_t term reference */
bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc;
/* For ssei information */
bEnableSSEI = pCodingParam.bEnableSSEI;
/* Layer definition */
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
MAX_DEPENDENCY_LAYER); // number of dependency(Spatial/CGS) layers used to be encoded
iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
MAX_TEMPORAL_LEVEL); // number of temporal layer specified
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired)
if (uiIntraPeriod == (uint32_t) (-1))
uiIntraPeriod = 0;
else if (uiIntraPeriod & (uiGopSize - 1)) // none multiple of GOP size
uiIntraPeriod = ((uiIntraPeriod + uiGopSize - 1) / uiGopSize) * uiGopSize;
if (iUsageType == SCREEN_CONTENT_REAL_TIME) {
if (bEnableLongTermReference) {
iLTRRefNum = WELS_CLIP3 (pCodingParam.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN);
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
} else {
iLTRRefNum = 0;
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, uiGopSize >> 1);
}
if (iUsageType == SCREEN_CONTENT_REAL_TIME) {
if (bEnableLongTermReference) {
iLTRRefNum = WELS_CLIP3 (pCodingParam.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN);
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
} else {
iLTRRefNum = bEnableLongTermReference ? WELS_CLIP3 (pCodingParam.iLTRRefNum, 1, LONG_TERM_REF_NUM) : 0;
if (iNumRefFrame == AUTO_REF_PIC_COUNT) {
iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
}
iLTRRefNum = 0;
if (iNumRefFrame == AUTO_REF_PIC_COUNT)
iNumRefFrame = WELS_MAX (1, uiGopSize >> 1);
}
if (iNumRefFrame > iMaxNumRefFrame)
iMaxNumRefFrame = iNumRefFrame;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
} else {
iLTRRefNum = bEnableLongTermReference ? WELS_CLIP3 (pCodingParam.iLTRRefNum, 1, LONG_TERM_REF_NUM) : 0;
if (iNumRefFrame == AUTO_REF_PIC_COUNT) {
iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
}
}
if (iNumRefFrame > iMaxNumRefFrame)
iMaxNumRefFrame = iNumRefFrame;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
bEnableSpsPpsIdAddition =
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
//SHOULD enable this feature.
bEnableSpsPpsIdAddition =
pCodingParam.bEnableSpsPpsIdAddition;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
//SHOULD enable this feature.
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
float fMaxFr = .0f;
EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t iIdxSpatial = 0;
while (iIdxSpatial < iSpatialLayerNum) {
pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
pSpatialLayer->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN) ? LEVEL_5_0 :
pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
float fMaxFr = .0f;
EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t iIdxSpatial = 0;
while (iIdxSpatial < iSpatialLayerNum) {
pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
pSpatialLayer->uiLevelIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc == LEVEL_UNKNOWN) ? LEVEL_5_0 :
pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
MIN_FRAME_RATE, fParamMaxFrameRate);
pSpatialLayer->fFrameRate =
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
if (pDlp->fInputFrameRate > fMaxFr + EPSN)
fMaxFr = pDlp->fInputFrameRate;
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
MIN_FRAME_RATE, fParamMaxFrameRate);
pSpatialLayer->fFrameRate =
pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
if (pDlp->fInputFrameRate > fMaxFr + EPSN)
fMaxFr = pDlp->fInputFrameRate;
#ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed
pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP
pSpatialLayer->iVideoWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
pSpatialLayer->iVideoHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
pSpatialLayer->iSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
pSpatialLayer->iVideoWidth = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth; // frame width
pSpatialLayer->iVideoHeight = pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight;// frame height
pSpatialLayer->iSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
//multi slice
pSpatialLayer->sSliceCfg.uiSliceMode = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
= (uint32_t) (pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum
= pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
memcpy (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum,
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
kiLesserSliceNum * sizeof (uint32_t)) ;
//multi slice
pSpatialLayer->sSliceCfg.uiSliceMode = pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.uiSliceMode;
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint
= (uint32_t) (pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceSizeConstraint);
pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceNum
= pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceNum;
const int32_t kiLesserSliceNum = ((MAX_SLICES_NUM < MAX_SLICES_NUM_TMP) ? MAX_SLICES_NUM : MAX_SLICES_NUM_TMP);
memcpy (pSpatialLayer->sSliceCfg.sSliceArgument.uiSliceMbNum,
pCodingParam.sSpatialLayers[iIdxSpatial].sSliceCfg.sSliceArgument.uiSliceMbNum, // confirmed_safe_unsafe_usage
kiLesserSliceNum * sizeof (uint32_t)) ;
pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
pSpatialLayer->iDLayerQp = pCodingParam.sSpatialLayers[iIdxSpatial].iDLayerQp;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ pSpatialLayer;
++ iIdxSpatial;
}
fMaxFrameRate = fMaxFr;
SetActualPicResolution();
return 0;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ pSpatialLayer;
++ iIdxSpatial;
}
fMaxFrameRate = fMaxFr;
SetActualPicResolution();
return 0;
}
// assuming that the width/height ratio of all spatial layers are the same
void SetActualPicResolution() {
int32_t iSpatialIdx = iSpatialLayerNum - 1;
for (; iSpatialIdx >= 0; iSpatialIdx --) {
SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx];
SSpatialLayerConfig* pDlayer = &sSpatialLayers[iSpatialIdx];
void SetActualPicResolution() {
int32_t iSpatialIdx = iSpatialLayerNum - 1;
for (; iSpatialIdx >= 0; iSpatialIdx --) {
SSpatialLayerInternal* pDlayerInternal = &sDependencyLayers[iSpatialIdx];
SSpatialLayerConfig* pDlayer = &sSpatialLayers[iSpatialIdx];
pDlayerInternal->iActualWidth = pDlayer->iVideoWidth;
pDlayerInternal->iActualHeight = pDlayer->iVideoHeight;
pDlayer->iVideoWidth = WELS_ALIGN (pDlayerInternal->iActualWidth, MB_WIDTH_LUMA);
pDlayer->iVideoHeight = WELS_ALIGN (pDlayerInternal->iActualHeight, MB_HEIGHT_LUMA);
}
pDlayerInternal->iActualWidth = pDlayer->iVideoWidth;
pDlayerInternal->iActualHeight = pDlayer->iVideoHeight;
pDlayer->iVideoWidth = WELS_ALIGN (pDlayerInternal->iActualWidth, MB_WIDTH_LUMA);
pDlayer->iVideoHeight = WELS_ALIGN (pDlayerInternal->iActualHeight, MB_HEIGHT_LUMA);
}
}
/*!
* \brief determined key coding tables for temporal scalability, uiProfileIdc etc for each spatial layer settings
* \param SWelsSvcCodingParam, and carried with known GOP size, max, input and output frame rate of each spatial
* \return NONE (should ensure valid parameter before this procedure)
*/
void DetermineTemporalSettings() {
const int32_t iDecStages = WELS_LOG2 (
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t i = 0;
/*!
* \brief determined key coding tables for temporal scalability, uiProfileIdc etc for each spatial layer settings
* \param SWelsSvcCodingParam, and carried with known GOP size, max, input and output frame rate of each spatial
* \return NONE (should ensure valid parameter before this procedure)
*/
void DetermineTemporalSettings() {
const int32_t iDecStages = WELS_LOG2 (
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t i = 0;
while (i < iSpatialLayerNum) {
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
int32_t iNotCodedMask = 0;
int8_t iMaxTemporalId = 0;
while (i < iSpatialLayerNum) {
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
int32_t iNotCodedMask = 0;
int8_t iMaxTemporalId = 0;
memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId));
pSpatialLayer->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
memset (pDlp->uiCodingIdx2TemporalId, INVALID_TEMPORAL_ID, sizeof (pDlp->uiCodingIdx2TemporalId));
pSpatialLayer->uiProfileIdc = uiProfileIdc; // PRO_BASELINE, PRO_SCALABLE_BASELINE;
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) {
if (0 == (uiFrameIdx & iNotCodedMask)) {
const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx];
pDlp->uiCodingIdx2TemporalId[uiFrameIdx] = kiTemporalId;
if (kiTemporalId > iMaxTemporalId) {
iMaxTemporalId = kiTemporalId;
}
iNotCodedMask = (1 << (kuiLogFactorInOutRate + kuiLogFactorMaxInRate)) - 1;
for (uint32_t uiFrameIdx = 0; uiFrameIdx <= uiGopSize; ++ uiFrameIdx) {
if (0 == (uiFrameIdx & iNotCodedMask)) {
const int8_t kiTemporalId = pTemporalIdList[uiFrameIdx];
pDlp->uiCodingIdx2TemporalId[uiFrameIdx] = kiTemporalId;
if (kiTemporalId > iMaxTemporalId) {
iMaxTemporalId = kiTemporalId;
}
}
pDlp->iHighestTemporalId = iMaxTemporalId;
pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate;
pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ pSpatialLayer;
++ i;
}
iDecompStages = (int8_t)iDecStages;
pDlp->iHighestTemporalId = iMaxTemporalId;
pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate;
pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate;
uiProfileIdc = PRO_SCALABLE_BASELINE;
++ pDlp;
++ pSpatialLayer;
++ i;
}
iDecompStages = (int8_t)iDecStages;
}
} SWelsSvcCodingParam;
static inline int32_t FreeCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
if (pParam == NULL || *pParam == NULL || pMa == NULL)
return 1;
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
*pParam = NULL;
return 0;
if (pParam == NULL || *pParam == NULL || pMa == NULL)
return 1;
pMa->WelsFree (*pParam, "SWelsSvcCodingParam");
*pParam = NULL;
return 0;
}
static inline int32_t AllocCodingParam (SWelsSvcCodingParam** pParam, CMemoryAlign* pMa) {
if (pParam == NULL || pMa == NULL)
return 1;
if (*pParam != NULL) {
FreeCodingParam (pParam, pMa);
}
SWelsSvcCodingParam* pCodingParam = (SWelsSvcCodingParam*)pMa->WelsMalloc (sizeof (SWelsSvcCodingParam),
"SWelsSvcCodingParam");
if (NULL == pCodingParam)
return 1;
*pParam = pCodingParam;
return 0;
if (pParam == NULL || pMa == NULL)
return 1;
if (*pParam != NULL) {
FreeCodingParam (pParam, pMa);
}
SWelsSvcCodingParam* pCodingParam = (SWelsSvcCodingParam*)pMa->WelsMalloc (sizeof (SWelsSvcCodingParam),
"SWelsSvcCodingParam");
if (NULL == pCodingParam)
return 1;
*pParam = pCodingParam;
return 0;
}
}//end of namespace WelsSVCEnc

View File

@ -41,48 +41,48 @@ namespace WelsSVCEnc {
/* Sequence Parameter Set, refer to Page 57 in JVT X201wcm */
typedef struct TagWelsSPS {
uint32_t uiSpsId;
int16_t iMbWidth;
int16_t iMbHeight;
uint32_t uiLog2MaxFrameNum;
uint32_t uiSpsId;
int16_t iMbWidth;
int16_t iMbHeight;
uint32_t uiLog2MaxFrameNum;
// uint32_t uiPocType;
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
/* POC type 0 */
int32_t iLog2MaxPocLsb;
/* POC type 1 */
// int32_t iOffsetForNonRefPic;
// int32_t iOffsetForTopToBottomField;
// int32_t iNumRefFramesInPocCycle;
// int8_t iOffsetForRefFrame[256];
SCropOffset sFrameCrop;
int16_t iNumRefFrames;
SCropOffset sFrameCrop;
int16_t iNumRefFrames;
// uint32_t uiNumUnitsInTick;
// uint32_t uiTimeScale;
uint8_t uiProfileIdc;
uint8_t iLevelIdc;
uint8_t uiProfileIdc;
uint8_t iLevelIdc;
// uint8_t uiChromaFormatIdc;
// uint8_t uiChromaArrayType; //support =1
// uint8_t uiBitDepthLuma; //=8, only used in decoder, encoder in general_***; it can be removed when removed general up_sample
// uint8_t uiBitDepthChroma; //=8
/* TO BE CONTINUE: POC type 1 */
/* TO BE CONTINUE: POC type 1 */
// bool bDeltaPicOrderAlwaysZeroFlag;
// bool bGapsInFrameNumValueAllowedFlag; //=true
// bool bFrameMbsOnlyFlag;
// bool bMbaffFlag; // MB Adapative Frame Field
// bool bDirect8x8InferenceFlag;
bool bFrameCroppingFlag;
bool bFrameCroppingFlag;
// bool bVuiParamPresentFlag;
// bool bTimingInfoPresentFlag;
// bool bFixedFrameRateFlag;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
bool bConstraintSet0Flag;
bool bConstraintSet1Flag;
bool bConstraintSet2Flag;
bool bConstraintSet3Flag;
// bool bSeparateColorPlaneFlag; // =false,: only used in decoder, encoder in general_***; it can be removed when removed general up_sample
} SWelsSPS, *PWelsSPS;
@ -92,21 +92,21 @@ typedef struct TagWelsSPS {
typedef struct TagSpsSvcExt {
// SCropOffset sSeqScaledRefLayer;
uint8_t iExtendedSpatialScalability; // ESS
uint8_t iExtendedSpatialScalability; // ESS
// uint8_t uiChromaPhaseXPlus1Flag;
// uint8_t uiChromaPhaseYPlus1;
// uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
// uint8_t uiSeqRefLayerChromaPhaseYPlus1;
// bool bInterLayerDeblockingFilterCtrlPresentFlag;
bool bSeqTcoeffLevelPredFlag;
bool bAdaptiveTcoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
bool bSeqTcoeffLevelPredFlag;
bool bAdaptiveTcoeffLevelPredFlag;
bool bSliceHeaderRestrictionFlag;
} SSpsSvcExt, *PSpsSvcExt;
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
typedef struct TagSubsetSps {
SWelsSPS pSps;
SSpsSvcExt sSpsSvcExt;
SWelsSPS pSps;
SSpsSvcExt sSpsSvcExt;
// bool bSvcVuiParamPresentFlag;
// bool bAdditionalExtension2Flag;
@ -115,40 +115,40 @@ typedef struct TagSubsetSps {
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
typedef struct TagWelsPPS {
uint32_t iSpsId;
uint32_t iPpsId;
uint32_t iSpsId;
uint32_t iPpsId;
#if !defined(DISABLE_FMO_FEATURE)
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* uiSliceGroupMapType = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 3, 4 or 5 */
/* uiSliceGroupMapType = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
uint32_t uiSliceGroupChangeRate;
/* uiSliceGroupMapType = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
uint32_t uiNumSliceGroups;
uint32_t uiSliceGroupMapType;
/* uiSliceGroupMapType = 0 */
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 2 */
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
/* uiSliceGroupMapType = 3, 4 or 5 */
/* uiSliceGroupMapType = 3, 4 or 5 */
bool bSliceGroupChangeDirectionFlag;
uint32_t uiSliceGroupChangeRate;
/* uiSliceGroupMapType = 6 */
uint32_t uiPicSizeInMapUnits;
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
#endif//!DISABLE_FMO_FEATURE
// uint32_t uiNumRefIdxL0Active;
// uint32_t uiNumRefIdxL1Active;
int8_t iPicInitQp;
int8_t iPicInitQs;
uint8_t uiChromaQpIndexOffset;
int8_t iPicInitQp;
int8_t iPicInitQs;
uint8_t uiChromaQpIndexOffset;
/* potential application for High profile */
/* potential application for High profile */
// int32_t iSecondChromaQpIndexOffset;
// /* potential application for High profile */
// bool bPicOrderPresentFlag;
bool bDeblockingFilterControlPresentFlag;
bool bDeblockingFilterControlPresentFlag;
// bool bConstainedIntraPredFlag;
// bool bRedundantPicCntPresentFlag;

View File

@ -41,19 +41,19 @@
namespace WelsSVCEnc {
#define LIST_SIZE 0x10000 //(256*256)
typedef struct TagScreenBlockFeatureStorage {
//Input
uint16_t* pFeatureOfBlockPointer; // Pointer to pFeatureOfBlock
int32_t iIs16x16; //Feature block size
uint8_t uiFeatureStrategyIndex;// index of hash strategy
//Input
uint16_t* pFeatureOfBlockPointer; // Pointer to pFeatureOfBlock
int32_t iIs16x16; //Feature block size
uint8_t uiFeatureStrategyIndex;// index of hash strategy
//Modify
uint32_t* pTimesOfFeatureValue; // times of every value in Feature
uint16_t**
pLocationOfFeature; // uint16_t *pLocationOfFeature[LIST_SIZE], pLocationOfFeature[i] saves all the location(x,y) whose Feature = i;
uint16_t* pLocationPointer; // buffer of position array
int32_t iActualListSize; // actual list size
uint32_t uiSadCostThreshold[BLOCK_SIZE_ALL];
bool bRefBlockFeatureCalculated; // flag of whether pre-process is done
//Modify
uint32_t* pTimesOfFeatureValue; // times of every value in Feature
uint16_t**
pLocationOfFeature; // uint16_t *pLocationOfFeature[LIST_SIZE], pLocationOfFeature[i] saves all the location(x,y) whose Feature = i;
uint16_t* pLocationPointer; // buffer of position array
int32_t iActualListSize; // actual list size
uint32_t uiSadCostThreshold[BLOCK_SIZE_ALL];
bool bRefBlockFeatureCalculated; // flag of whether pre-process is done
} SScreenBlockFeatureStorage; //should be stored with RefPic, one for each frame
/*
@ -61,43 +61,43 @@ typedef struct TagScreenBlockFeatureStorage {
* It is used to express reference picture, also consequent reconstruction picture for output
*/
typedef struct TagPicture {
/************************************payload pData*********************************/
uint8_t* pBuffer; // pointer to the first allocated byte, basical offset of pBuffer, dimension:
uint8_t* pData[3]; // pointer to picture planes respectively
int32_t iLineSize[3]; // iLineSize of picture planes respectively
/************************************payload pData*********************************/
uint8_t* pBuffer; // pointer to the first allocated byte, basical offset of pBuffer, dimension:
uint8_t* pData[3]; // pointer to picture planes respectively
int32_t iLineSize[3]; // iLineSize of picture planes respectively
// picture information
/*******************************from other standard syntax****************************/
/*from pSps*/
int32_t iWidthInPixel; // picture width in pixel
int32_t iHeightInPixel;// picture height in pixel
int32_t iPictureType; // got from sSliceHeader(): eSliceType
int32_t iFramePoc; // frame POC
// picture information
/*******************************from other standard syntax****************************/
/*from pSps*/
int32_t iWidthInPixel; // picture width in pixel
int32_t iHeightInPixel;// picture height in pixel
int32_t iPictureType; // got from sSliceHeader(): eSliceType
int32_t iFramePoc; // frame POC
float fFrameRate; // MOVE
int32_t iFrameNum; // frame number //for pRef pic management
float fFrameRate; // MOVE
int32_t iFrameNum; // frame number //for pRef pic management
uint32_t* uiRefMbType; // for iMbWidth*iMbHeight
uint8_t* pRefMbQp; // for iMbWidth*iMbHeight
uint32_t* uiRefMbType; // for iMbWidth*iMbHeight
uint8_t* pRefMbQp; // for iMbWidth*iMbHeight
int32_t* pMbSkipSad; //for iMbWidth*iMbHeight
int32_t* pMbSkipSad; //for iMbWidth*iMbHeight
SMVUnitXY* sMvList;
SMVUnitXY* sMvList;
/*******************************sef_definition for misc use****************************/
int32_t iMarkFrameNum;
int32_t iLongTermPicNum;
/*******************************sef_definition for misc use****************************/
int32_t iMarkFrameNum;
int32_t iLongTermPicNum;
bool bUsedAsRef; //for pRef pic management
bool bIsLongRef; // long term reference frame flag //for pRef pic management
bool bIsSceneLTR; //long term reference & large scene change
uint8_t uiRecieveConfirmed;
uint8_t uiTemporalId;
uint8_t uiSpatialId;
int32_t iFrameAverageQp;
bool bUsedAsRef; //for pRef pic management
bool bIsLongRef; // long term reference frame flag //for pRef pic management
bool bIsSceneLTR; //long term reference & large scene change
uint8_t uiRecieveConfirmed;
uint8_t uiTemporalId;
uint8_t uiSpatialId;
int32_t iFrameAverageQp;
/*******************************for screen reference frames****************************/
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage;
/*******************************for screen reference frames****************************/
SScreenBlockFeatureStorage* pScreenBlockFeatureStorage;
} SPicture;
/*

View File

@ -56,53 +56,53 @@ namespace WelsSVCEnc {
#define WELS_RC_GOM 1
enum {
BITS_NORMAL,
BITS_LIMITED,
BITS_EXCEEDED,
BITS_NORMAL,
BITS_LIMITED,
BITS_EXCEEDED,
};
enum {
//virtual gop size
VGOP_SIZE = 8,
//virtual gop size
VGOP_SIZE = 8,
//qp information
GOM_MIN_QP_MODE = 12,
GOM_MAX_QP_MODE = 36,
MAX_LOW_BR_QP = 42,
MIN_IDR_QP = 26,
MAX_IDR_QP = 32,
DELTA_QP = 2,
DELTA_QP_BGD_THD = 3,
//qp information
GOM_MIN_QP_MODE = 12,
GOM_MAX_QP_MODE = 36,
MAX_LOW_BR_QP = 42,
MIN_IDR_QP = 26,
MAX_IDR_QP = 32,
DELTA_QP = 2,
DELTA_QP_BGD_THD = 3,
//frame skip constants
SKIP_QP_90P = 24,
SKIP_QP_180P = 24,
SKIP_QP_360P = 31,
SKIP_QP_720P = 31,
LAST_FRAME_QP_RANGE_UPPER_MODE0 = 3,
LAST_FRAME_QP_RANGE_LOWER_MODE0 = 2,
LAST_FRAME_QP_RANGE_UPPER_MODE1 = 5,
LAST_FRAME_QP_RANGE_LOWER_MODE1 = 3,
//frame skip constants
SKIP_QP_90P = 24,
SKIP_QP_180P = 24,
SKIP_QP_360P = 31,
SKIP_QP_720P = 31,
LAST_FRAME_QP_RANGE_UPPER_MODE0 = 3,
LAST_FRAME_QP_RANGE_LOWER_MODE0 = 2,
LAST_FRAME_QP_RANGE_UPPER_MODE1 = 5,
LAST_FRAME_QP_RANGE_LOWER_MODE1 = 3,
MB_WIDTH_THRESHOLD_90P = 15,
MB_WIDTH_THRESHOLD_180P = 30,
MB_WIDTH_THRESHOLD_360P = 60,
MB_WIDTH_THRESHOLD_90P = 15,
MB_WIDTH_THRESHOLD_180P = 30,
MB_WIDTH_THRESHOLD_360P = 60,
//Mode 0 parameter
GOM_ROW_MODE0_90P = 2,
GOM_ROW_MODE0_180P = 2,
GOM_ROW_MODE0_360P = 4,
GOM_ROW_MODE0_720P = 4,
QP_RANGE_MODE0 = 3,
//Mode 0 parameter
GOM_ROW_MODE0_90P = 2,
GOM_ROW_MODE0_180P = 2,
GOM_ROW_MODE0_360P = 4,
GOM_ROW_MODE0_720P = 4,
QP_RANGE_MODE0 = 3,
//Mode 1 parameter
GOM_ROW_MODE1_90P = 1,
GOM_ROW_MODE1_180P = 1,
GOM_ROW_MODE1_360P = 2,
GOM_ROW_MODE1_720P = 2,
QP_RANGE_UPPER_MODE1 = 9,
QP_RANGE_LOWER_MODE1 = 4,
QP_RANGE_INTRA_MODE1 = 3,
//Mode 1 parameter
GOM_ROW_MODE1_90P = 1,
GOM_ROW_MODE1_180P = 1,
GOM_ROW_MODE1_360P = 2,
GOM_ROW_MODE1_720P = 2,
QP_RANGE_UPPER_MODE1 = 9,
QP_RANGE_LOWER_MODE1 = 4,
QP_RANGE_INTRA_MODE1 = 3,
};
//bits allocation
@ -122,118 +122,119 @@ enum {
#define SKIP_RATIO 50 // *INT_MULTIPLY
#define PADDING_BUFFER_RATIO 50 // *INT_MULTIPLY
#define PADDING_THRESHOLD 5 //*INT_MULTIPLY
typedef struct TagRCSlicing {
int32_t iComplexityIndexSlice;
int32_t iCalculatedQpSlice;
int32_t iStartMbSlice;
int32_t iEndMbSlice;
int32_t iTotalQpSlice;
int32_t iTotalMbSlice;
int32_t iTargetBitsSlice;
int32_t iBsPosSlice;
int32_t iFrameBitsSlice;
int32_t iGomBitsSlice;
int32_t iGomTargetBits;
//int32_t gom_coded_mb;
int32_t iComplexityIndexSlice;
int32_t iCalculatedQpSlice;
int32_t iStartMbSlice;
int32_t iEndMbSlice;
int32_t iTotalQpSlice;
int32_t iTotalMbSlice;
int32_t iTargetBitsSlice;
int32_t iBsPosSlice;
int32_t iFrameBitsSlice;
int32_t iGomBitsSlice;
int32_t iGomTargetBits;
//int32_t gom_coded_mb;
} SRCSlicing;
typedef struct TagRCTemporal {
int32_t iMinBitsTl;
int32_t iMaxBitsTl;
int32_t iTlayerWeight;
int32_t iGopBitsDq;
//P frame level R-Q Model
int64_t iLinearCmplx; // *INT_MULTIPLY
int32_t iPFrameNum;
int32_t iFrameCmplxMean;
int32_t iMinBitsTl;
int32_t iMaxBitsTl;
int32_t iTlayerWeight;
int32_t iGopBitsDq;
//P frame level R-Q Model
int64_t iLinearCmplx; // *INT_MULTIPLY
int32_t iPFrameNum;
int32_t iFrameCmplxMean;
} SRCTemporal;
typedef struct TagWelsRc {
int32_t iRcVaryPercentage;
int32_t iRcVaryRatio;
int32_t iInitialQp; //initial qp
int32_t iBitRate;
int32_t iPreviousBitrate;
int32_t iPreviousGopSize;
double fFrameRate;
int32_t iBitsPerFrame; // *INT_MULTIPLY
double dPreviousFps;
// bits allocation and status
int32_t iRemainingBits;
int32_t iTargetBits;
int32_t iCurrentBitsLevel;//0:normal; 1:limited; 2:exceeded.
int32_t iIdrNum;
int32_t iIntraComplexity;
int32_t iIntraMbCount;
int8_t iTlOfFrames[VGOP_SIZE];
int32_t iRemainingWeights;
int32_t iFrameDqBits;
double* pGomComplexity;
int32_t* pGomForegroundBlockNum;
int32_t* pCurrentFrameGomSad;
int32_t* pGomCost;
int32_t iAverageFrameQp;
int32_t iNumberMbFrame;
int32_t iNumberMbGom;
int32_t iSliceNum;
int32_t iGomSize;
int32_t iSkipFrameNum;
int32_t iFrameCodedInVGop;
int32_t iSkipFrameInVGop;
int32_t iGopNumberInVGop;
int32_t iGopIndexInVGop;
int32_t iSkipQpValue;
int32_t iQpRangeUpperInFrame;
int32_t iQpRangeLowerInFrame;
int32_t iMinQp;
int32_t iMaxQp;
//int32_t delta_adaptive_qp;
int32_t iSkipBufferRatio;
int32_t iQStep; // *INT_MULTIPLY
int32_t iFrameDeltaQpUpper;
int32_t iFrameDeltaQpLower;
int32_t iLastCalculatedQScale;
//for skip frame and padding
int32_t iBufferSizeSkip;
int32_t iBufferFullnessSkip;
int32_t iBufferSizePadding;
int32_t iBufferFullnessPadding;
int32_t iPaddingSize;
int32_t iPaddingBitrateStat;
bool bSkipFlag;
SRCSlicing* pSlicingOverRc;
SRCTemporal* pTemporalOverRc;
int32_t iRcVaryPercentage;
int32_t iRcVaryRatio;
int32_t iInitialQp; //initial qp
int32_t iBitRate;
int32_t iPreviousBitrate;
int32_t iPreviousGopSize;
double fFrameRate;
int32_t iBitsPerFrame; // *INT_MULTIPLY
double dPreviousFps;
// bits allocation and status
int32_t iRemainingBits;
int32_t iTargetBits;
int32_t iCurrentBitsLevel;//0:normal; 1:limited; 2:exceeded.
int32_t iIdrNum;
int32_t iIntraComplexity;
int32_t iIntraMbCount;
int8_t iTlOfFrames[VGOP_SIZE];
int32_t iRemainingWeights;
int32_t iFrameDqBits;
double* pGomComplexity;
int32_t* pGomForegroundBlockNum;
int32_t* pCurrentFrameGomSad;
int32_t* pGomCost;
int32_t iAverageFrameQp;
int32_t iNumberMbFrame;
int32_t iNumberMbGom;
int32_t iSliceNum;
int32_t iGomSize;
int32_t iSkipFrameNum;
int32_t iFrameCodedInVGop;
int32_t iSkipFrameInVGop;
int32_t iGopNumberInVGop;
int32_t iGopIndexInVGop;
int32_t iSkipQpValue;
int32_t iQpRangeUpperInFrame;
int32_t iQpRangeLowerInFrame;
int32_t iMinQp;
int32_t iMaxQp;
//int32_t delta_adaptive_qp;
int32_t iSkipBufferRatio;
int32_t iQStep; // *INT_MULTIPLY
int32_t iFrameDeltaQpUpper;
int32_t iFrameDeltaQpLower;
int32_t iLastCalculatedQScale;
//for skip frame and padding
int32_t iBufferSizeSkip;
int32_t iBufferFullnessSkip;
int32_t iBufferSizePadding;
int32_t iBufferFullnessPadding;
int32_t iPaddingSize;
int32_t iPaddingBitrateStat;
bool bSkipFlag;
SRCSlicing* pSlicingOverRc;
SRCTemporal* pTemporalOverRc;
} SWelsSvcRc;
typedef void (*PWelsRCPictureInitFunc) (void* pCtx);
typedef void (*PWelsRCPictureDelayJudgeFunc) (void* pCtx);
typedef void (*PWelsRCPictureInfoUpdateFunc) (void* pCtx, int32_t iLayerSize);
typedef void (*PWelsRCMBInfoUpdateFunc) (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice);
typedef void (*PWelsRCMBInitFunc) (void* pCtx, SMB* pCurMb, SSlice* pSlice);
typedef struct WelsRcFunc_s {
PWelsRCPictureInitFunc pfWelsRcPictureInit;
PWelsRCPictureDelayJudgeFunc pfWelsRcPicDelayJudge;
PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate;
PWelsRCMBInitFunc pfWelsRcMbInit;
PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate;
PWelsRCPictureInitFunc pfWelsRcPictureInit;
PWelsRCPictureDelayJudgeFunc pfWelsRcPicDelayJudge;
PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate;
PWelsRCMBInitFunc pfWelsRcMbInit;
PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate;
} SWelsRcFunc;
void WelsRcInitModule (void* pCtx, int32_t iModule);
void WelsRcFreeMemory (void* pCtx);
}
#endif //RC_H

View File

@ -48,21 +48,21 @@
namespace WelsSVCEnc {
typedef enum {
RECIEVE_UNKOWN = 0,
RECIEVE_SUCCESS = 1,
RECIEVE_FAILED = 2,
RECIEVE_UNKOWN = 0,
RECIEVE_SUCCESS = 1,
RECIEVE_FAILED = 2,
} LTR_MARKING_RECEIVE_STATE;
typedef enum {
LTR_DIRECT_MARK = 0,
LTR_DELAY_MARK = 1,
LTR_DIRECT_MARK = 0,
LTR_DELAY_MARK = 1,
} LTR_MARKING_PROCESS_MODE;
typedef enum {
FRAME_NUM_EQUAL = 0x01,
FRAME_NUM_BIGGER = 0x02,
FRAME_NUM_SMALLER = 0x04,
FRAME_NUM_OVER_MAX = 0x08,
FRAME_NUM_EQUAL = 0x01,
FRAME_NUM_BIGGER = 0x02,
FRAME_NUM_SMALLER = 0x04,
FRAME_NUM_OVER_MAX = 0x08,
} COMPARE_FRAME_NUM;
/*

View File

@ -49,11 +49,11 @@ namespace WelsSVCEnc {
enum EResidualProperty {
LUMA_DC = 0,
LUMA_AC = 1,
LUMA_4x4 = 2,
CHROMA_DC = 3,
CHROMA_AC = 4
LUMA_DC = 0,
LUMA_AC = 1,
LUMA_4x4 = 2,
CHROMA_DC = 3,
CHROMA_AC = 4
};
@ -63,16 +63,16 @@ typedef int32_t (*PCavlcParamCalFunc) (int16_t* pCoff, uint8_t* pRun, int16_t*
int32_t iEndIdx);
typedef struct TagCoeffFunc {
PCavlcParamCalFunc pfCavlcParamCal;
PCavlcParamCalFunc pfCavlcParamCal;
} SCoeffFunc;
/* For CAVLC */
extern SCoeffFunc sCoeffFunc;
typedef struct TagCavlcTableItem {
uint16_t uiBits;
uint8_t uiLen;
uint8_t uiSuffixLength;
uint16_t uiBits;
uint8_t uiLen;
uint8_t uiSuffixLength;
} SCavlcTableItem;
void InitCoeffFunc (const uint32_t uiCpuFlag);

View File

@ -53,131 +53,131 @@ namespace WelsSVCEnc {
* Reference picture list reordering syntax, refer to page 64 in JVT X201wcm
*/
typedef struct TagRefPicListReorderSyntax {
struct {
uint32_t uiAbsDiffPicNumMinus1; //uiAbsDiffPicNumMinus1 SHOULD be in the range of [4, (1<<pSps->uiLog2MaxFrameNum)-1], {p104, JVT-X201wcm1}
//but int8_t can't cover the range, SHOULD modify it.
uint16_t iLongTermPicNum;
uint16_t uiReorderingOfPicNumsIdc; //in order to pack 2-uint16_t into 1-(u)int32_t, so modify the type into uint16_t.
} SReorderingSyntax[MAX_REFERENCE_REORDER_COUNT_NUM]; // MAX_REF_PIC_COUNT
struct {
uint32_t uiAbsDiffPicNumMinus1; //uiAbsDiffPicNumMinus1 SHOULD be in the range of [4, (1<<pSps->uiLog2MaxFrameNum)-1], {p104, JVT-X201wcm1}
//but int8_t can't cover the range, SHOULD modify it.
uint16_t iLongTermPicNum;
uint16_t uiReorderingOfPicNumsIdc; //in order to pack 2-uint16_t into 1-(u)int32_t, so modify the type into uint16_t.
} SReorderingSyntax[MAX_REFERENCE_REORDER_COUNT_NUM]; // MAX_REF_PIC_COUNT
} SRefPicListReorderSyntax;
/* Decoded reference picture marking syntax, refer to Page 66 in JVT X201wcm */
typedef struct TagRefPicMarking {
struct {
int32_t iMmcoType;
int32_t iShortFrameNum;
int32_t iDiffOfPicNum;
int32_t iLongTermPicNum;
int32_t iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx;
} SMmcoRef[MAX_REFERENCE_MMCO_COUNT_NUM]; // MAX_MMCO_COUNT
struct {
int32_t iMmcoType;
int32_t iShortFrameNum;
int32_t iDiffOfPicNum;
int32_t iLongTermPicNum;
int32_t iLongTermFrameIdx;
int32_t iMaxLongTermFrameIdx;
} SMmcoRef[MAX_REFERENCE_MMCO_COUNT_NUM]; // MAX_MMCO_COUNT
// int32_t mmco_index;
uint8_t uiMmcoCount;
bool bNoOutputOfPriorPicsFlag;
bool bLongTermRefFlag;
bool bAdaptiveRefPicMarkingModeFlag;
// int32_t mmco_index;
uint8_t uiMmcoCount;
bool bNoOutputOfPriorPicsFlag;
bool bLongTermRefFlag;
bool bAdaptiveRefPicMarkingModeFlag;
} SRefPicMarking;
/* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */
typedef struct TagSliceHeader {
/*****************************slice header syntax and generated****************************/
int32_t iFirstMbInSlice;
/*****************************slice header syntax and generated****************************/
int32_t iFirstMbInSlice;
// uint32_t pic_parameter_set_id;
int32_t iFrameNum;
int32_t iPicOrderCntLsb;
int32_t iFrameNum;
int32_t iPicOrderCntLsb;
// int32_t delta_pic_order_cnt_bottom;
// int32_t delta_pic_order_cnt[2];
// int32_t redundant_pic_cnt;
EWelsSliceType eSliceType;
uint8_t uiNumRefIdxL0Active; //
//int32_t num_ref_idx_l1_active_minus1 //B frame is not supported
uint8_t uiRefCount;
//Ref_Pic *ref_pic;
uint8_t uiRefIndex; // exact reference picture index for slice
EWelsSliceType eSliceType;
uint8_t uiNumRefIdxL0Active; //
//int32_t num_ref_idx_l1_active_minus1 //B frame is not supported
uint8_t uiRefCount;
//Ref_Pic *ref_pic;
uint8_t uiRefIndex; // exact reference picture index for slice
int8_t iSliceQpDelta;
int8_t iSliceQpDelta;
// int32_t slice_qp;
// int32_t slice_qs_delta; // For SP/SI slices
uint8_t uiDisableDeblockingFilterIdc;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
uint8_t uiDisableDeblockingFilterIdc;
int8_t iSliceAlphaC0Offset;
int8_t iSliceBetaOffset;
#if !defined(DISABLE_FMO_FEATURE)
int32_t iSliceGroupChangeCycle;
int32_t iSliceGroupChangeCycle;
#endif//!DISABLE_FMO_FEATURE
SWelsSPS* pSps;
SWelsPPS* pPps;
int32_t iSpsId;
int32_t iPpsId;
SWelsSPS* pSps;
SWelsPPS* pPps;
int32_t iSpsId;
int32_t iPpsId;
uint16_t uiIdrPicId;
uint16_t uiIdrPicId;
// uint8_t color_plane_id;//from?
bool bNumRefIdxActiveOverrideFlag;
bool bNumRefIdxActiveOverrideFlag;
// bool field_pic_flag; //not supported in base profile
// bool bottom_field_flag; //not supported in base profile
uint8_t uiPadding1Bytes;
uint8_t uiPadding1Bytes;
SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs
SRefPicMarking sRefMarking; // Decoded reference picture marking syntaxs
SRefPicListReorderSyntax sRefReordering; // Reference picture list reordering syntaxs
SRefPicListReorderSyntax sRefReordering; // Reference picture list reordering syntaxs
} SSliceHeader, *PSliceHeader;
/* SSlice header in scalable extension syntax, refer to Page 394 in JVT X201wcm */
typedef struct TagSliceHeaderExt {
SSliceHeader sSliceHeader;
SSliceHeader sSliceHeader;
SSubsetSps* pSubsetSps;
SSubsetSps* pSubsetSps;
uint32_t uiNumMbsInSlice;
uint32_t uiNumMbsInSlice;
bool bStoreRefBasePicFlag;
bool bConstrainedIntraResamplingFlag;
bool bSliceSkipFlag;
bool bStoreRefBasePicFlag;
bool bConstrainedIntraResamplingFlag;
bool bSliceSkipFlag;
bool bAdaptiveBaseModeFlag;
bool bDefaultBaseModeFlag;
bool bAdaptiveMotionPredFlag;
bool bDefaultMotionPredFlag;
bool bAdaptiveBaseModeFlag;
bool bDefaultBaseModeFlag;
bool bAdaptiveMotionPredFlag;
bool bDefaultMotionPredFlag;
bool bAdaptiveResidualPredFlag;
bool bDefaultResidualPredFlag;
bool bTcoeffLevelPredFlag;
uint8_t uiDisableInterLayerDeblockingFilterIdc;
bool bAdaptiveResidualPredFlag;
bool bDefaultResidualPredFlag;
bool bTcoeffLevelPredFlag;
uint8_t uiDisableInterLayerDeblockingFilterIdc;
} SSliceHeaderExt, *PSliceHeaderExt;
typedef struct TagSlice {
// mainly for multiple threads imp.
SMbCache sMbCacheInfo; // MBCache is introduced within slice dependency
SBitStringAux* pSliceBsa;
// mainly for multiple threads imp.
SMbCache sMbCacheInfo; // MBCache is introduced within slice dependency
SBitStringAux* pSliceBsa;
/*******************************sSliceHeader****************************/
SSliceHeaderExt sSliceHeaderExt;
/*******************************sSliceHeader****************************/
SSliceHeaderExt sSliceHeaderExt;
SMVUnitXY sMvStartMin;
SMVUnitXY sMvStartMax;
SMVUnitXY sMvc[5];
uint8_t uiMvcNum;
uint8_t sScaleShift;
SMVUnitXY sMvStartMin;
SMVUnitXY sMvStartMax;
SMVUnitXY sMvc[5];
uint8_t uiMvcNum;
uint8_t sScaleShift;
uint8_t uiSliceIdx;
bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
uint8_t uiLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
uint8_t uiSliceIdx;
bool bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
uint8_t uiLastMbQp; // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
bool bDynamicSlicingSliceSizeCtrlFlag;
uint8_t uiAssumeLog2BytePerMb;
bool bDynamicSlicingSliceSizeCtrlFlag;
uint8_t uiAssumeLog2BytePerMb;
uint32_t uiSliceFMECostDown;//TODO: for FME switch under MT, to opt after ME final?
uint32_t uiSliceFMECostDown;//TODO: for FME switch under MT, to opt after ME final?
uint8_t uiReservedFillByte; // reserved to meet 4 bytes alignment
uint8_t uiReservedFillByte; // reserved to meet 4 bytes alignment
} SSlice, *PSlice;
}

View File

@ -47,9 +47,9 @@ namespace WelsSVCEnc {
*/
typedef struct TagStatQuality {
float rYPsnr[5];
float rUPsnr[5];
float rVPsnr[5];
float rYPsnr[5];
float rUPsnr[5];
float rVPsnr[5];
} SStatQuality;
@ -59,13 +59,13 @@ typedef struct TagStatQuality {
typedef struct TagComplexityStat {
#ifdef FME_TEST
int32_t cost_time;
int32_t me_time;
int32_t mvp_time;
int32_t mvb_time;
int32_t cost_time;
int32_t me_time;
int32_t mvp_time;
int32_t mvb_time;
#endif
// any else?
// any else?
} SComplexityStat;
@ -74,10 +74,10 @@ typedef struct TagComplexityStat {
*/
typedef struct TagStatSliceInfo {
/* per slice info */
int32_t iSliceCount[5];
int32_t iSliceSize [5];
int32_t iMbCount [5][18];
/* per slice info */
int32_t iSliceCount[5];
int32_t iSliceSize [5];
int32_t iMbCount [5][18];
} SStatSliceInfo;
@ -86,14 +86,14 @@ typedef struct TagStatSliceInfo {
*/
typedef struct TagStatData {
// Quality
SStatQuality sQualityStat;
// Quality
SStatQuality sQualityStat;
// Complexity
SComplexityStat sComplexityStat;
// Complexity
SComplexityStat sComplexityStat;
// SSlice information output
SStatSliceInfo sSliceData;
// SSlice information output
SStatSliceInfo sSliceData;
} SStatData;

View File

@ -59,61 +59,61 @@ typedef struct TagDqLayer SDqLayer;
typedef SDqLayer* pDqLayer;
typedef struct TagFeatureSearchPreparation {
SScreenBlockFeatureStorage* pRefBlockFeature;//point the the ref frame storage
SScreenBlockFeatureStorage* pRefBlockFeature;//point the the ref frame storage
uint16_t* pFeatureOfBlock; // Feature of every block (8x8), begin with the point
uint8_t uiFeatureStrategyIndex;// index of hash strategy
uint16_t* pFeatureOfBlock; // Feature of every block (8x8), begin with the point
uint8_t uiFeatureStrategyIndex;// index of hash strategy
/* for FME frame-level switch */
bool bFMESwitchFlag;
uint8_t uiFMEGoodFrameCount;
int32_t iHighFreMbCount;
/* for FME frame-level switch */
bool bFMESwitchFlag;
uint8_t uiFMEGoodFrameCount;
int32_t iHighFreMbCount;
} SFeatureSearchPreparation; //maintain only one
typedef struct TagLayerInfo {
SNalUnitHeaderExt sNalHeaderExt;
SSlice*
pSliceInLayer;// Here SSlice identify to Frame on concept, [iSliceIndex], need memory block external side for MT
SSubsetSps* pSubsetSpsP; // current pSubsetSps used, memory alloc in external
SWelsSPS* pSpsP; // current pSps based avc used, memory alloc in external
SWelsPPS* pPpsP; // current pPps used
SNalUnitHeaderExt sNalHeaderExt;
SSlice*
pSliceInLayer;// Here SSlice identify to Frame on concept, [iSliceIndex], need memory block external side for MT
SSubsetSps* pSubsetSpsP; // current pSubsetSps used, memory alloc in external
SWelsSPS* pSpsP; // current pSps based avc used, memory alloc in external
SWelsPPS* pPpsP; // current pPps used
} SLayerInfo;
/* Layer Representation */
struct TagDqLayer {
SLayerInfo sLayerInfo;
SLayerInfo sLayerInfo;
uint8_t* pCsData[3]; // pointer to reconstructed picture pData
int32_t iCsStride[3]; // Cs stride
uint8_t* pCsData[3]; // pointer to reconstructed picture pData
int32_t iCsStride[3]; // Cs stride
uint8_t* pEncData[3]; // pData picture to be encoded in current layer
int32_t iEncStride[3]; // pData picture stride
uint8_t* pEncData[3]; // pData picture to be encoded in current layer
int32_t iEncStride[3]; // pData picture stride
SMB* sMbDataP; // pointer to mb of mbAddr equal to 0 in slice, mb_data_ptr = mb_base_ptr + (1+iMbStride).
int16_t iMbWidth; // MB width of this picture, equal to pSps.iMbWidth
int16_t iMbHeight; // MB height of this picture, equal to pSps.iMbHeight;
SMB* sMbDataP; // pointer to mb of mbAddr equal to 0 in slice, mb_data_ptr = mb_base_ptr + (1+iMbStride).
int16_t iMbWidth; // MB width of this picture, equal to pSps.iMbWidth
int16_t iMbHeight; // MB height of this picture, equal to pSps.iMbHeight;
bool bBaseLayerAvailableFlag; // whether base layer is available for prediction?
uint8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
uint8_t uiDisableInterLayerDeblockingFilterIdc;
int8_t iInterLayerSliceAlphaC0Offset;
int8_t iInterLayerSliceBetaOffset;
bool bDeblockingParallelFlag; //parallel_deblocking_flag
bool bBaseLayerAvailableFlag; // whether base layer is available for prediction?
uint8_t iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries
int8_t iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
int8_t iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
uint8_t uiDisableInterLayerDeblockingFilterIdc;
int8_t iInterLayerSliceAlphaC0Offset;
int8_t iInterLayerSliceBetaOffset;
bool bDeblockingParallelFlag; //parallel_deblocking_flag
SPicture* pRefPic; // reference picture pointer
SPicture* pDecPic; // reconstruction picture pointer for layer
SPicture* pRefOri[MAX_REF_PIC_COUNT];
SPicture* pRefPic; // reference picture pointer
SPicture* pDecPic; // reconstruction picture pointer for layer
SPicture* pRefOri[MAX_REF_PIC_COUNT];
SSliceCtx* pSliceEncCtx; // current slice context
SSliceCtx* pSliceEncCtx; // current slice context
int32_t* pNumSliceCodedOfPartition; // for dynamic slicing mode
int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode
int32_t* pLastMbIdxOfPartition; // for dynamic slicing mode
int32_t* pNumSliceCodedOfPartition; // for dynamic slicing mode
int32_t* pLastCodedMbIdxOfPartition; // for dynamic slicing mode
int32_t* pLastMbIdxOfPartition; // for dynamic slicing mode
SFeatureSearchPreparation* pFeatureSearchPreparation;
SFeatureSearchPreparation* pFeatureSearchPreparation;
SDqLayer* pRefLayer; // pointer to referencing dq_layer of current layer to be decoded
SDqLayer* pRefLayer; // pointer to referencing dq_layer of current layer to be decoded
};

View File

@ -93,138 +93,138 @@ extern const uint32_t g_uiGolombUELength[256];
* Get size of unsigned exp golomb codes
*/
static inline uint32_t BsSizeUE (const uint32_t kiValue) {
if (256 > kiValue) {
return g_uiGolombUELength[kiValue];
} else {
uint32_t n = 0;
uint32_t iTmpValue = kiValue + 1;
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
return ((n << 1) + 1);
if (256 > kiValue) {
return g_uiGolombUELength[kiValue];
} else {
uint32_t n = 0;
uint32_t iTmpValue = kiValue + 1;
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
return ((n << 1) + 1);
}
}
/*
* Get size of signed exp golomb codes
*/
static inline uint32_t BsSizeSE (const int32_t kiValue) {
uint32_t iTmpValue;
if (0 == kiValue) {
return 1;
} else if (0 < kiValue) {
iTmpValue = (kiValue << 1) - 1;
return BsSizeUE (iTmpValue);
} else {
iTmpValue = ((-kiValue) << 1);
return BsSizeUE (iTmpValue);
}
uint32_t iTmpValue;
if (0 == kiValue) {
return 1;
} else if (0 < kiValue) {
iTmpValue = (kiValue << 1) - 1;
return BsSizeUE (iTmpValue);
} else {
iTmpValue = ((-kiValue) << 1);
return BsSizeUE (iTmpValue);
}
}
/*
* Get size of truncated exp golomb codes
*/
static inline int32_t BsSizeTE (const int32_t kiX, const int32_t kiValue) {
return 0;
return 0;
}
static inline int32_t BsWriteBits (SBitStringAux* pBs, int32_t n, const uint32_t kuiValue) {
if (n < pBs->iLeftBits) {
pBs->uiCurBits = (pBs->uiCurBits << n) | kuiValue;
pBs->iLeftBits -= n;
} else {
n -= pBs->iLeftBits;
pBs->uiCurBits = (pBs->uiCurBits << pBs->iLeftBits) | (kuiValue >> n);
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits);
pBs->pBufPtr += 4;
pBs->uiCurBits = kuiValue & ((1 << n) - 1);
pBs->iLeftBits = 32 - n;
}
return 0;
if (n < pBs->iLeftBits) {
pBs->uiCurBits = (pBs->uiCurBits << n) | kuiValue;
pBs->iLeftBits -= n;
} else {
n -= pBs->iLeftBits;
pBs->uiCurBits = (pBs->uiCurBits << pBs->iLeftBits) | (kuiValue >> n);
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits);
pBs->pBufPtr += 4;
pBs->uiCurBits = kuiValue & ((1 << n) - 1);
pBs->iLeftBits = 32 - n;
}
return 0;
}
/*
* Write 1 bit
*/
static inline int32_t BsWriteOneBit (SBitStringAux* pBs, const uint32_t kuiValue) {
BsWriteBits (pBs, 1, kuiValue);
BsWriteBits (pBs, 1, kuiValue);
return 0;
return 0;
}
static inline void BsFlush (SBitStringAux* pBs) {
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits << pBs->iLeftBits);
pBs->pBufPtr += 4 - pBs->iLeftBits / 8;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0; // for future writing safe, 5/19/2010
WRITE_BE_32 (pBs->pBufPtr, pBs->uiCurBits << pBs->iLeftBits);
pBs->pBufPtr += 4 - pBs->iLeftBits / 8;
pBs->iLeftBits = 32;
pBs->uiCurBits = 0; // for future writing safe, 5/19/2010
}
/*
* Write unsigned exp golomb codes
*/
static inline void BsWriteUE (SBitStringAux* pBs, const uint32_t kuiValue) {
uint32_t iTmpValue = kuiValue + 1;
if (256 > kuiValue) {
BsWriteBits (pBs, g_uiGolombUELength[kuiValue], kuiValue + 1);
} else {
uint32_t n = 0;
uint32_t iTmpValue = kuiValue + 1;
if (256 > kuiValue) {
BsWriteBits (pBs, g_uiGolombUELength[kuiValue], kuiValue + 1);
} else {
uint32_t n = 0;
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
BsWriteBits (pBs, (n << 1) + 1, kuiValue + 1);
if (iTmpValue & 0xffff0000) {
iTmpValue >>= 16;
n += 16;
}
return;
if (iTmpValue & 0xff00) {
iTmpValue >>= 8;
n += 8;
}
//n += (g_uiGolombUELength[iTmpValue] >> 1);
n += (g_uiGolombUELength[iTmpValue - 1] >> 1);
BsWriteBits (pBs, (n << 1) + 1, kuiValue + 1);
}
return;
}
/*
* Write signed exp golomb codes
*/
static inline void BsWriteSE (SBitStringAux* pBs, int32_t iValue) {
uint32_t iTmpValue;
if (0 == iValue) {
BsWriteOneBit (pBs, 1);
} else if (0 < iValue) {
iTmpValue = (iValue << 1) - 1;
BsWriteUE (pBs, iTmpValue);
} else {
iTmpValue = ((-iValue) << 1);
BsWriteUE (pBs, iTmpValue);
}
return;
uint32_t iTmpValue;
if (0 == iValue) {
BsWriteOneBit (pBs, 1);
} else if (0 < iValue) {
iTmpValue = (iValue << 1) - 1;
BsWriteUE (pBs, iTmpValue);
} else {
iTmpValue = ((-iValue) << 1);
BsWriteUE (pBs, iTmpValue);
}
return;
}
/*
* Write truncated exp golomb codes
*/
static inline void BsWriteTE (SBitStringAux* pBs, const int32_t kiX, const uint32_t kuiValue) {
if (1 == kiX) {
BsWriteOneBit (pBs, !kuiValue);
} else {
BsWriteUE (pBs, kuiValue);
}
if (1 == kiX) {
BsWriteOneBit (pBs, !kuiValue);
} else {
BsWriteUE (pBs, kuiValue);
}
}
@ -232,18 +232,18 @@ static inline void BsWriteTE (SBitStringAux* pBs, const int32_t kiX, const uint3
* Write RBSP trailing bits
*/
static inline void BsRbspTrailingBits (SBitStringAux* pBs) {
BsWriteOneBit (pBs, 1);
BsFlush (pBs);
BsWriteOneBit (pBs, 1);
BsFlush (pBs);
}
static inline bool BsCheckByteAlign (SBitStringAux* pBs) {
return ! (pBs->iLeftBits & 0x7);
return ! (pBs->iLeftBits & 0x7);
}
static inline int32_t BsGetBitsPos (SBitStringAux* pBs) {
return (int32_t) (((pBs->pBufPtr - pBs->pBuf) << 3) + 32 - pBs->iLeftBits);
return (int32_t) (((pBs->pBufPtr - pBs->pBuf) << 3) + 32 - pBs->iLeftBits);
}
}

View File

@ -47,29 +47,29 @@ namespace WelsSVCEnc {
// keep the most essential level pData structure be 64 Bytes, which matches cache line size; if so, the order with structure maybe negligible.
// pls take care when modify MB structure size
typedef struct TagMB {
/*************************mb_layer() syntax and generated********************************/
/*mb_layer():*/
Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list
int16_t iMbXY; // offset position of MB top left point based
int16_t iMbX; // position of MB in horizontal axis
int16_t iMbY; // position of MB in vertical axis
/*************************mb_layer() syntax and generated********************************/
/*mb_layer():*/
Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list
int16_t iMbXY; // offset position of MB top left point based
int16_t iMbX; // position of MB in horizontal axis
int16_t iMbY; // position of MB in vertical axis
uint8_t uiNeighborAvail; // avail && same_slice: LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPRIGHT_MB_POS = 0x04 ,TOPLEFT_MB_POS = 0x08;
uint8_t uiCbp;
uint8_t uiNeighborAvail; // avail && same_slice: LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPRIGHT_MB_POS = 0x04 ,TOPLEFT_MB_POS = 0x08;
uint8_t uiCbp;
SMVUnitXY* sMv;
int8_t* pRefIndex;
SMVUnitXY* sMv;
int8_t* pRefIndex;
int32_t* pSadCost; // mb sad. set to 0 for intra mb
int8_t* pIntra4x4PredMode; // [MB_BLOCK4x4_NUM]
int8_t* pNonZeroCount; // [MB_LUMA_CHROMA_BLOCK4x4_NUM]
int32_t* pSadCost; // mb sad. set to 0 for intra mb
int8_t* pIntra4x4PredMode; // [MB_BLOCK4x4_NUM]
int8_t* pNonZeroCount; // [MB_LUMA_CHROMA_BLOCK4x4_NUM]
SMVUnitXY sP16x16Mv;
SMVUnitXY sP16x16Mv;
uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant.
uint8_t uiChromaQp;
uint8_t uiSliceIdc; // AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId);
uint8_t reserved_filling_bytes[1]; // filling bytes reserved to make structure aligned with 4 bytes, higher cache hit on less structure size by 2 cache lines( 2 * 64 bytes) once hit
uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant.
uint8_t uiChromaQp;
uint8_t uiSliceIdc; // AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId);
uint8_t reserved_filling_bytes[1]; // filling bytes reserved to make structure aligned with 4 bytes, higher cache hit on less structure size by 2 cache lines( 2 * 64 bytes) once hit
} SMB, *PMb;
}

View File

@ -73,29 +73,29 @@ namespace WelsSVCEnc {
*/
/* Single/multiple slices */
typedef struct SlicepEncCtx_s {
SliceModeEnum uiSliceMode; /* 0: single slice in frame; 1: multiple slices in frame; */
int16_t iMbWidth; /* width of picture size in mb */
int16_t iMbHeight; /* height of picture size in mb */
int16_t iSliceNumInFrame; /* count number of slices in frame; */
int32_t iMbNumInFrame; /* count number of MBs in frame */
uint8_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */
int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
uint32_t uiSliceSizeConstraint;/*in byte*/
int32_t iMaxSliceNumConstraint;/*maximal number of slices constraint*/
SliceModeEnum uiSliceMode; /* 0: single slice in frame; 1: multiple slices in frame; */
int16_t iMbWidth; /* width of picture size in mb */
int16_t iMbHeight; /* height of picture size in mb */
int16_t iSliceNumInFrame; /* count number of slices in frame; */
int32_t iMbNumInFrame; /* count number of MBs in frame */
uint8_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */
int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
uint32_t uiSliceSizeConstraint;/*in byte*/
int32_t iMaxSliceNumConstraint;/*maximal number of slices constraint*/
} SSliceCtx;
typedef struct TagDynamicSlicingStack {
int32_t iStartPos;
int32_t iCurrentPos;
int32_t iStartPos;
int32_t iCurrentPos;
uint8_t* pBsStackBufPtr; // current writing position
uint32_t uiBsStackCurBits;
int32_t iBsStackLeftBits;
uint8_t* pBsStackBufPtr; // current writing position
uint32_t uiBsStackCurBits;
int32_t iBsStackLeftBits;
int32_t iMbSkipRunStack;
uint8_t uiLastMbQp;
int32_t iMbSkipRunStack;
uint8_t uiLastMbQp;
} SDynamicSlicingStack;
/*!

View File

@ -54,8 +54,8 @@ namespace WelsSVCEnc {
#define DELTA_QP_SCD_THD 5
typedef enum {
STATIC,
SCROLLED,
STATIC,
SCROLLED,
} ESkipModes;
// NOILP ILFMD ENTRANCE

View File

@ -55,78 +55,78 @@ namespace WelsSVCEnc {
#define EXPANDED_MVD_RANGE ((504+1)<<1)
enum {
ME_DIA = 0x01, // LITTLE DIAMOND= 0x01
ME_CROSS = 0x02, // CROSS= 0x02
ME_FME = 0x04, // FME = 0x04
ME_FULL = 0x10, // FULL
ME_DIA = 0x01, // LITTLE DIAMOND= 0x01
ME_CROSS = 0x02, // CROSS= 0x02
ME_FME = 0x04, // FME = 0x04
ME_FULL = 0x10, // FULL
// derived ME methods combination
ME_DIA_CROSS = (ME_DIA | ME_CROSS), // DIA+CROSS
ME_DIA_CROSS_FME = (ME_DIA_CROSS | ME_FME), // DIA+CROSS+FME
// derived ME methods combination
ME_DIA_CROSS = (ME_DIA | ME_CROSS), // DIA+CROSS
ME_DIA_CROSS_FME = (ME_DIA_CROSS | ME_FME), // DIA+CROSS+FME
};
union SadPredISatdUnit {
uint32_t uiSadPred;
uint32_t uiSatd; //reuse the sad_pred as a temp satd pData
uint32_t uiSadPred;
uint32_t uiSatd; //reuse the sad_pred as a temp satd pData
};
typedef struct TagWelsME {
/* input */
uint16_t* pMvdCost;
union SadPredISatdUnit uSadPredISatd; //reuse the sad_pred as a temp pData
uint32_t
uiSadCost; //used by ME and RC //max SAD should be max_delta*size+lambda*mvdsize = 255*256+91*33*2 = 65280 + 6006 = 71286 > (2^16)-1 = 65535
uint32_t uiSatdCost; /* satd + lm * nbits */
uint32_t uiSadCostThreshold;
int32_t iCurMeBlockPixX;
int32_t iCurMeBlockPixY;
uint8_t uiBlockSize; /* BLOCK_WxH */
uint8_t uiReserved;
/* input */
uint16_t* pMvdCost;
union SadPredISatdUnit uSadPredISatd; //reuse the sad_pred as a temp pData
uint32_t
uiSadCost; //used by ME and RC //max SAD should be max_delta*size+lambda*mvdsize = 255*256+91*33*2 = 65280 + 6006 = 71286 > (2^16)-1 = 65535
uint32_t uiSatdCost; /* satd + lm * nbits */
uint32_t uiSadCostThreshold;
int32_t iCurMeBlockPixX;
int32_t iCurMeBlockPixY;
uint8_t uiBlockSize; /* BLOCK_WxH */
uint8_t uiReserved;
uint8_t* pEncMb;
uint8_t* pRefMb;
uint8_t* pColoRefMb;
uint8_t* pEncMb;
uint8_t* pRefMb;
uint8_t* pColoRefMb;
SMVUnitXY sMvp;
SMVUnitXY sMvBase;
SMVUnitXY sDirectionalMv;
SMVUnitXY sMvp;
SMVUnitXY sMvBase;
SMVUnitXY sDirectionalMv;
SScreenBlockFeatureStorage* pRefFeatureStorage;
SScreenBlockFeatureStorage* pRefFeatureStorage;
/* output */
SMVUnitXY sMv;
/* output */
SMVUnitXY sMv;
} SWelsME;
typedef struct TagFeatureSearchIn {
PSampleSadSatdCostFunc pSad;
PSampleSadSatdCostFunc pSad;
uint32_t* pTimesOfFeature;
uint16_t** pQpelLocationOfFeature;
uint16_t* pMvdCostX;
uint16_t* pMvdCostY;
uint32_t* pTimesOfFeature;
uint16_t** pQpelLocationOfFeature;
uint16_t* pMvdCostX;
uint16_t* pMvdCostY;
uint8_t* pEnc;
uint8_t* pColoRef;
int32_t iEncStride;
int32_t iRefStride;
uint16_t uiSadCostThresh;
uint8_t* pEnc;
uint8_t* pColoRef;
int32_t iEncStride;
int32_t iRefStride;
uint16_t uiSadCostThresh;
int32_t iFeatureOfCurrent;
int32_t iFeatureOfCurrent;
int32_t iCurPixX;
int32_t iCurPixY;
int32_t iCurPixXQpel;
int32_t iCurPixYQpel;
int32_t iCurPixX;
int32_t iCurPixY;
int32_t iCurPixXQpel;
int32_t iCurPixYQpel;
int32_t iMinQpelX;
int32_t iMinQpelY;
int32_t iMaxQpelX;
int32_t iMaxQpelY;
int32_t iMinQpelX;
int32_t iMinQpelY;
int32_t iMaxQpelX;
int32_t iMaxQpelY;
} SFeatureSearchIn;
typedef struct TagFeatureSearchOut {
SMVUnitXY sBestMv;
uint32_t uiBestSadCost;
uint8_t* pBestRef;
SMVUnitXY sBestMv;
uint32_t uiBestSadCost;
uint8_t* pBestRef;
} SFeatureSearchOut;
#define COST_MVD(table, mx, my) (table[mx] + table[my])
@ -207,8 +207,8 @@ void LineFullSearch_c (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
#ifdef X86_ASM
extern "C"
{
uint32_t SampleSad8x8Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
uint32_t SampleSad16x16Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
uint32_t SampleSad8x8Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
uint32_t SampleSad16x16Hor8_sse41 (uint8_t*, int32_t, uint8_t*, int32_t, uint16_t*, int32_t*);
}
void VerticalFullSearchUsingSSE41 (SWelsFuncPtrList* pFuncList, SWelsME* pMe,
@ -277,27 +277,27 @@ inline void SetMvWithinIntegerMvRange (const int32_t kiMbWidth, const int32_t ki
const int32_t kiMbY,
const int32_t kiMaxMvRange,
SMVUnitXY* pMvMin, SMVUnitXY* pMvMax) {
pMvMin->iMvX = WELS_MAX (-1 * ((kiMbX + 1) << 4) + INTPEL_NEEDED_MARGIN, -1 * kiMaxMvRange);
pMvMin->iMvY = WELS_MAX (-1 * ((kiMbY + 1) << 4) + INTPEL_NEEDED_MARGIN, -1 * kiMaxMvRange);
pMvMax->iMvX = WELS_MIN (((kiMbWidth - kiMbX) << 4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
pMvMax->iMvY = WELS_MIN (((kiMbHeight - kiMbY) << 4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
pMvMin->iMvX = WELS_MAX (-1 * ((kiMbX + 1) << 4) + INTPEL_NEEDED_MARGIN, -1 * kiMaxMvRange);
pMvMin->iMvY = WELS_MAX (-1 * ((kiMbY + 1) << 4) + INTPEL_NEEDED_MARGIN, -1 * kiMaxMvRange);
pMvMax->iMvX = WELS_MIN (((kiMbWidth - kiMbX) << 4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
pMvMax->iMvY = WELS_MIN (((kiMbHeight - kiMbY) << 4) - INTPEL_NEEDED_MARGIN, kiMaxMvRange);
}
inline bool CheckMvInRange (const int16_t kiCurrentMv, const int16_t kiMinMv, const int16_t kiMaxMv) {
return ((kiCurrentMv >= kiMinMv) && (kiCurrentMv < kiMaxMv));
return ((kiCurrentMv >= kiMinMv) && (kiCurrentMv < kiMaxMv));
}
inline bool CheckMvInRange (const SMVUnitXY ksCurrentMv, const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv) {
return (CheckMvInRange (ksCurrentMv.iMvX, ksMinMv.iMvX, ksMaxMv.iMvX)
&& CheckMvInRange (ksCurrentMv.iMvY, ksMinMv.iMvY, ksMaxMv.iMvY));
return (CheckMvInRange (ksCurrentMv.iMvX, ksMinMv.iMvX, ksMaxMv.iMvX)
&& CheckMvInRange (ksCurrentMv.iMvY, ksMinMv.iMvY, ksMaxMv.iMvY));
}
//FME switch related
inline bool CalcFMESwitchFlag (const uint8_t uiFMEGoodFrameCount, const int32_t iHighFreMbPrecentage,
const int32_t iAvgMbSAD, const bool bScrollingDetected) {
return (bScrollingDetected || (uiFMEGoodFrameCount > 0 && iAvgMbSAD > FMESWITCH_MBSAD_THRESHOLD));
//TODO: add the logic of iHighFreMbPrecentage
//return ( iHighFreMbPrecentage > 2
// && ( bScrollingDetected || iHighFreMbPrecentage >15
// ||( uiFMEGoodFrameCount>0 && iFrameSAD > FMESWITCH_FRAMESAD_THRESHOLD ) ) );
return (bScrollingDetected || (uiFMEGoodFrameCount > 0 && iAvgMbSAD > FMESWITCH_MBSAD_THRESHOLD));
//TODO: add the logic of iHighFreMbPrecentage
//return ( iHighFreMbPrecentage > 2
// && ( bScrollingDetected || iHighFreMbPrecentage >15
// ||( uiFMEGoodFrameCount>0 && iFrameSAD > FMESWITCH_FRAMESAD_THRESHOLD ) ) );
}
}
#endif

View File

@ -58,36 +58,36 @@ extern const ALIGNED_DECLARE (uint8_t, g_kuiEncNcMapTable[18], 16);
static inline int32_t WriteTotalCoeffTrailingones (SBitStringAux* pBs, uint8_t uiNc, uint8_t uiTotalCoeff,
uint8_t uiTrailingOnes) {
const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc];
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc];
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
}
static inline int32_t WriteTotalcoeffTrailingonesChroma (SBitStringAux* pBs, uint8_t uiTotalCoeff,
uint8_t uiTrailingOnes) {
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[4][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
}
//kuiZeroCount = level_prefix;
static inline int32_t WriteLevelPrefix (SBitStringAux* pBs, const uint32_t kuiZeroCount) {
BsWriteBits (pBs, kuiZeroCount + 1, 1);
return 0;
BsWriteBits (pBs, kuiZeroCount + 1, 1);
return 0;
}
static inline int32_t WriteTotalZeros (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]);
const uint8_t* kpTotalZeros = &g_kuiVlcTotalZeros[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZeros[1], kpTotalZeros[0]);
}
static inline int32_t WriteTotalZerosChromaDc (SBitStringAux* pBs, uint32_t uiTotalCoeff, uint32_t uiTotalZeros) {
const uint8_t* kpTotalZerosChromaDc = &g_kuiVlcTotalZerosChromaDc[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZerosChromaDc[1], kpTotalZerosChromaDc[0]);
const uint8_t* kpTotalZerosChromaDc = &g_kuiVlcTotalZerosChromaDc[uiTotalCoeff][uiTotalZeros][0];
return BsWriteBits (pBs, kpTotalZerosChromaDc[1], kpTotalZerosChromaDc[0]);
}
static inline int32_t WriteRunBefore (SBitStringAux* pBs, uint8_t uiZeroLeft, uint8_t uiRunBefore) {
const uint8_t* kpRunBefore = &g_kuiVlcRunBefore[uiZeroLeft][uiRunBefore][0];
return BsWriteBits (pBs, kpRunBefore[1], kpRunBefore[0]);
const uint8_t* kpRunBefore = &g_kuiVlcRunBefore[uiZeroLeft][uiRunBefore][0];
return BsWriteBits (pBs, kpRunBefore[1], kpRunBefore[0]);
}
}
#endif

View File

@ -50,38 +50,38 @@ extern const uint8_t g_kuiChromaQpTable[52];
* NAL Unit Type (5 Bits)
*/
enum EWelsNalUnitType {
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
NAL_UNIT_CODED_SLICE_DPB = 3,
NAL_UNIT_CODED_SLICE_DPC = 4,
NAL_UNIT_CODED_SLICE_IDR = 5,
NAL_UNIT_SEI = 6,
NAL_UNIT_SPS = 7,
NAL_UNIT_PPS = 8,
NAL_UNIT_AU_DELIMITER = 9,
NAL_UNIT_END_OF_SEQ = 10,
NAL_UNIT_END_OF_STR = 11,
NAL_UNIT_FILLER_DATA = 12,
NAL_UNIT_SPS_EXT = 13,
NAL_UNIT_PREFIX = 14,
NAL_UNIT_SUBSET_SPS = 15,
NAL_UNIT_RESV_16 = 16,
NAL_UNIT_RESV_17 = 17,
NAL_UNIT_RESV_18 = 18,
NAL_UNIT_AUX_CODED_SLICE = 19,
NAL_UNIT_CODED_SLICE_EXT = 20,
NAL_UNIT_RESV_21 = 21,
NAL_UNIT_RESV_22 = 22,
NAL_UNIT_RESV_23 = 23,
NAL_UNIT_UNSPEC_24 = 24,
NAL_UNIT_UNSPEC_25 = 25,
NAL_UNIT_UNSPEC_26 = 26,
NAL_UNIT_UNSPEC_27 = 27,
NAL_UNIT_UNSPEC_28 = 28,
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
NAL_UNIT_UNSPEC_0 = 0,
NAL_UNIT_CODED_SLICE = 1,
NAL_UNIT_CODED_SLICE_DPA = 2,
NAL_UNIT_CODED_SLICE_DPB = 3,
NAL_UNIT_CODED_SLICE_DPC = 4,
NAL_UNIT_CODED_SLICE_IDR = 5,
NAL_UNIT_SEI = 6,
NAL_UNIT_SPS = 7,
NAL_UNIT_PPS = 8,
NAL_UNIT_AU_DELIMITER = 9,
NAL_UNIT_END_OF_SEQ = 10,
NAL_UNIT_END_OF_STR = 11,
NAL_UNIT_FILLER_DATA = 12,
NAL_UNIT_SPS_EXT = 13,
NAL_UNIT_PREFIX = 14,
NAL_UNIT_SUBSET_SPS = 15,
NAL_UNIT_RESV_16 = 16,
NAL_UNIT_RESV_17 = 17,
NAL_UNIT_RESV_18 = 18,
NAL_UNIT_AUX_CODED_SLICE = 19,
NAL_UNIT_CODED_SLICE_EXT = 20,
NAL_UNIT_RESV_21 = 21,
NAL_UNIT_RESV_22 = 22,
NAL_UNIT_RESV_23 = 23,
NAL_UNIT_UNSPEC_24 = 24,
NAL_UNIT_UNSPEC_25 = 25,
NAL_UNIT_UNSPEC_26 = 26,
NAL_UNIT_UNSPEC_27 = 27,
NAL_UNIT_UNSPEC_28 = 28,
NAL_UNIT_UNSPEC_29 = 29,
NAL_UNIT_UNSPEC_30 = 30,
NAL_UNIT_UNSPEC_31 = 31
};
/*
@ -89,10 +89,10 @@ enum EWelsNalUnitType {
*/
enum EWelsNalRefIdc {
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
NRI_PRI_LOWEST = 0,
NRI_PRI_LOW = 1,
NRI_PRI_HIGH = 2,
NRI_PRI_HIGHEST = 3
};
/*
@ -100,9 +100,9 @@ enum EWelsNalRefIdc {
*/
enum EVclType {
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
NON_VCL = 0,
VCL = 1,
NOT_APP = 2
};
/*
@ -129,64 +129,64 @@ extern const EVclType g_keTypeMap[32][2];
*/
enum EWelsSliceType {
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
P_SLICE = 0,
B_SLICE = 1,
I_SLICE = 2,
SP_SLICE = 3,
SI_SLICE = 4,
UNKNOWN_SLICE = 5
};
/* SSlice Types in scalable extension */ ;
enum ESliceTypeExt {
EP_SLICE = 0, // EP_SLICE: 0, 5
EB_SLICE = 1, // EB_SLICE: 1, 6
EI_SLICE = 2 // EI_SLICE: 2, 7
EP_SLICE = 0, // EP_SLICE: 0, 5
EB_SLICE = 1, // EB_SLICE: 1, 6
EI_SLICE = 2 // EI_SLICE: 2, 7
};
/* List Index */
enum EListIndex {
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
LIST_0 = 0,
LIST_1 = 1,
LIST_A = 2
};
struct SMVUnitXY { // each 4 Bytes
int16_t iMvX;
int16_t iMvY;
int16_t iMvX;
int16_t iMvY;
public:
SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) {
iMvX = _v0.iMvX - _v1.iMvX;
iMvY = _v0.iMvY - _v1.iMvY;
return (*this);
}
SMVUnitXY& sDeltaMv (const SMVUnitXY& _v0, const SMVUnitXY& _v1) {
iMvX = _v0.iMvX - _v1.iMvX;
iMvY = _v0.iMvY - _v1.iMvY;
return (*this);
}
};
typedef struct TagMVComponentUnit { // each LIST_0/LIST_1
SMVUnitXY sMotionVectorCache[5 * 6 - 1]; // Luma only: 5 x 6 - 1 = 29 D-Words
int8_t iRefIndexCache[5 * 6]; // Luma only: 5 x 6 = 30 bytes
SMVUnitXY sMotionVectorCache[5 * 6 - 1]; // Luma only: 5 x 6 - 1 = 29 D-Words
int8_t iRefIndexCache[5 * 6]; // Luma only: 5 x 6 = 30 bytes
} SMVComponentUnit, *PMVComponentUnit;
typedef struct TagParaSetOffsetVariable {
int32_t iParaSetIdDelta[MAX_DQ_LAYER_NUM/*+1*/]; //mark delta between SPS_ID_in_bs and sps_id_in_encoder, can be minus, for each dq-layer
int32_t iParaSetIdDelta[MAX_DQ_LAYER_NUM/*+1*/]; //mark delta between SPS_ID_in_bs and sps_id_in_encoder, can be minus, for each dq-layer
//need not extra +1 due no MGS and FMO case so far
bool bUsedParaSetIdInBs[MAX_PPS_COUNT]; //mark the used SPS_ID with 1
uint32_t uiNextParaSetIdToUseInBs; //mark the next SPS_ID_in_bs, for all layers
bool bUsedParaSetIdInBs[MAX_PPS_COUNT]; //mark the used SPS_ID with 1
uint32_t uiNextParaSetIdToUseInBs; //mark the next SPS_ID_in_bs, for all layers
} SParaSetOffsetVariable;
typedef struct TagParaSetOffset {
//in PS0 design, "sParaSetOffsetVariable" record the previous paras before current IDR, AND NEED to be stacked and recover across IDR
SParaSetOffsetVariable
sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS
SParaSetOffsetVariable
sParaSetOffsetVariable[PARA_SET_TYPE]; //PARA_SET_TYPE=3; paraset_type = 0: AVC_SPS; =1: Subset_SPS; =2: PPS
//in PSO design, "bPpsIdMappingIntoSubsetsps" uses the current para of current IDR period
bool
bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
uint16_t
uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR!! Can we just NOT put this into the SParaSetOffset structure?!!
bool
bPpsIdMappingIntoSubsetsps[MAX_DQ_LAYER_NUM/*+1*/]; // need not extra +1 due no MGS and FMO case so far
uint16_t
uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR!! Can we just NOT put this into the SParaSetOffset structure?!!
#if _DEBUG
bool bEnableSpsPpsIdAddition;
bool bEnableSpsPpsIdAddition;
#endif
} SParaSetOffset;
@ -194,47 +194,47 @@ typedef struct TagParaSetOffset {
/* Motion Vector components */
enum EMvComp {
MV_X = 0,
MV_Y = 1,
MV_A = 2
MV_X = 0,
MV_Y = 1,
MV_A = 2
};
/* Chroma Components */
enum EChromaComp {
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
CHROMA_CB = 0,
CHROMA_CR = 1,
CHROMA_A = 2
};
/* Position Offset structure */
typedef struct TagCropOffset {
int16_t iCropLeft;
int16_t iCropRight;
int16_t iCropTop;
int16_t iCropBottom;
int16_t iCropLeft;
int16_t iCropRight;
int16_t iCropTop;
int16_t iCropBottom;
} SCropOffset;
/* Transform Type */
enum ETransType {
T_4x4 = 0,
T_8x8 = 1,
T_16x16 = 2,
T_PCM = 3
T_4x4 = 0,
T_8x8 = 1,
T_16x16 = 2,
T_PCM = 3
};
enum EMbPosition {
LEFT_MB_POS = 0x01, // A
TOP_MB_POS = 0x02, // B
TOPRIGHT_MB_POS = 0x04, // C
TOPLEFT_MB_POS = 0x08, // D,
RIGHT_MB_POS = 0x10, // add followed four case to reuse when intra up-sample
BOTTOM_MB_POS = 0x20, //
BOTTOMRIGHT_MB_POS = 0x40, //
BOTTOMLEFT_MB_POS = 0x80, //
MB_POS_A = 0x100
LEFT_MB_POS = 0x01, // A
TOP_MB_POS = 0x02, // B
TOPRIGHT_MB_POS = 0x04, // C
TOPLEFT_MB_POS = 0x08, // D,
RIGHT_MB_POS = 0x10, // add followed four case to reuse when intra up-sample
BOTTOM_MB_POS = 0x20, //
BOTTOMRIGHT_MB_POS = 0x40, //
BOTTOMLEFT_MB_POS = 0x80, //
MB_POS_A = 0x100
};
#define MB_ON_PIC_BOUNDRY (RIGHT_MB_POS|BOTTOM_MB_POS|LEFT_MB_POS|TOP_MB_POS)
@ -301,13 +301,13 @@ typedef uint32_t Mb_Type;
enum {
Intra4x4 = 0,
Intra16x16 = 1,
Inter16x16 = 2,
Inter16x8 = 3,
Inter8x16 = 4,
Inter8x8 = 5,
PSkip = 6
Intra4x4 = 0,
Intra16x16 = 1,
Inter16x16 = 2,
Inter16x8 = 3,
Inter8x16 = 4,
Inter8x8 = 5,
PSkip = 6
};
@ -315,13 +315,13 @@ enum {
* Memory Management Control Operation (MMCO) code
*/
enum EMmcoCode {
MMCO_END = 0,
MMCO_SHORT2UNUSED = 1,
MMCO_LONG2UNUSED = 2,
MMCO_SHORT2LONG = 3,
MMCO_SET_MAX_LONG = 4,
MMCO_RESET = 5,
MMCO_LONG = 6
MMCO_END = 0,
MMCO_SHORT2UNUSED = 1,
MMCO_LONG2UNUSED = 2,
MMCO_SHORT2LONG = 3,
MMCO_SET_MAX_LONG = 4,
MMCO_RESET = 5,
MMCO_LONG = 6
};
/////////intra16x16 Luma

View File

@ -179,14 +179,14 @@
#define SLICE_NUM_EXPAND_COEF 2
enum {
BLOCK_16x16 = 0,
BLOCK_16x8 = 1,
BLOCK_8x16 = 2,
BLOCK_8x8 = 3,
BLOCK_4x4 = 4,
BLOCK_16x16 = 0,
BLOCK_16x8 = 1,
BLOCK_8x16 = 2,
BLOCK_8x8 = 3,
BLOCK_4x4 = 4,
// BLOCK_8x4 = 5,
// BLOCK_4x8 = 6,
BLOCK_SIZE_ALL = 5
BLOCK_SIZE_ALL = 5
};
enum {

View File

@ -126,7 +126,7 @@ class CWelsPreProcess {
int32_t AnalyzeSpatialPic (sWelsEncCtx* pEncCtx, const int32_t kiDIdx);
int32_t UpdateSpatialPictures (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, const int8_t iCurTid,
const int32_t d_idx);
int32_t GetRefFrameInfo (int32_t iRefIdx,SPicture *&pRefOri);
int32_t GetRefFrameInfo (int32_t iRefIdx, SPicture*& pRefOri);
void AnalyzePictureComplexity (sWelsEncCtx* pCtx, SPicture* pCurPicture, SPicture* pRefPicture,
const int32_t kiDependencyId, const bool kbCalculateBGD);

View File

@ -575,22 +575,22 @@ void DeblockingBSCalc_neon (SWelsFuncPtrList* pFunc, SMB* pCurMb, uint8_t uiBS[2
#if defined(HAVE_NEON_AARCH64) && defined(SINGLE_REF_FRAME)
void DeblockingBSCalc_AArch64_neon (SWelsFuncPtrList* pFunc, SMB* pCurMb, uint8_t uiBS[2][4][4], Mb_Type uiCurMbType,
int32_t iMbStride, int32_t iLeftFlag, int32_t iTopFlag) {
DeblockingBSCalcEnc_AArch64_neon (pCurMb->pNonZeroCount, pCurMb->sMv, pCurMb->uiNeighborAvail, iMbStride, uiBS);
if (iLeftFlag) {
if (IS_INTRA ((pCurMb - 1)->uiMbType)) {
* (uint32_t*)uiBS[0][0] = 0x04040404;
}
} else {
* (uint32_t*)uiBS[0][0] = 0;
int32_t iMbStride, int32_t iLeftFlag, int32_t iTopFlag) {
DeblockingBSCalcEnc_AArch64_neon (pCurMb->pNonZeroCount, pCurMb->sMv, pCurMb->uiNeighborAvail, iMbStride, uiBS);
if (iLeftFlag) {
if (IS_INTRA ((pCurMb - 1)->uiMbType)) {
* (uint32_t*)uiBS[0][0] = 0x04040404;
}
if (iTopFlag) {
if (IS_INTRA ((pCurMb - iMbStride)->uiMbType)) {
* (uint32_t*)uiBS[1][0] = 0x04040404;
}
} else {
* (uint32_t*)uiBS[1][0] = 0;
} else {
* (uint32_t*)uiBS[0][0] = 0;
}
if (iTopFlag) {
if (IS_INTRA ((pCurMb - iMbStride)->uiMbType)) {
* (uint32_t*)uiBS[1][0] = 0x04040404;
}
} else {
* (uint32_t*)uiBS[1][0] = 0;
}
}
#endif
@ -787,9 +787,9 @@ void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu)
}
#endif
#ifdef HAVE_NEON_AARCH64
if (iCpu & WELS_CPU_NEON) {
*pfSetNZCZero = WelsNonZeroCount_AArch64_neon;
}
if (iCpu & WELS_CPU_NEON) {
*pfSetNZCZero = WelsNonZeroCount_AArch64_neon;
}
#endif
}
@ -839,21 +839,21 @@ void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu) {
#endif
#if defined(HAVE_NEON_AARCH64)
if (iCpu & WELS_CPU_NEON) {
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_AArch64_neon;
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_AArch64_neon;
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_AArch64_neon;
pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_AArch64_neon;
if (iCpu & WELS_CPU_NEON) {
pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_AArch64_neon;
pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_AArch64_neon;
pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_AArch64_neon;
pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_AArch64_neon;
pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_AArch64_neon;
pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_AArch64_neon;
pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_AArch64_neon;
pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_AArch64_neon;
pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_AArch64_neon;
pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_AArch64_neon;
pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_AArch64_neon;
pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_AArch64_neon;
#if defined(SINGLE_REF_FRAME)
pFunc->pfDeblockingBSCalc = DeblockingBSCalc_AArch64_neon;
pFunc->pfDeblockingBSCalc = DeblockingBSCalc_AArch64_neon;
#endif
}
}
#endif
}

View File

@ -57,11 +57,12 @@ FILE* fp_vgop = NULL;
#endif
#define _BITS_RANGE 0
const int32_t g_kiQpToQstepTable[52] = { 63, 71, 79, 89, 100, 112, 126, 141, 159, 178,
200, 224, 252, 283, 317, 356, 400, 449, 504, 566,
635, 713, 800, 898, 1008, 1131, 1270, 1425, 1600, 1796,
2016, 2263, 2540, 2851, 3200, 3592, 4032, 4525, 5080, 5702,
6400, 7184, 8063, 9051,10159,11404,12800,14368,16127,18102,
20319,22807}; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
200, 224, 252, 283, 317, 356, 400, 449, 504, 566,
635, 713, 800, 898, 1008, 1131, 1270, 1425, 1600, 1796,
2016, 2263, 2540, 2851, 3200, 3592, 4032, 4525, 5080, 5702,
6400, 7184, 8063, 9051, 10159, 11404, 12800, 14368, 16127, 18102,
20319, 22807
}; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) {
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
@ -106,7 +107,7 @@ static inline int32_t RcConvertQp2QStep (int32_t iQP) {
return g_kiQpToQstepTable[iQP];
}
static inline int32_t RcConvertQStep2Qp (int32_t iQpStep) {
return WELS_ROUND((6 * log (iQpStep*1.0f/INT_MULTIPLY) / log (2.0) + 4.0));
return WELS_ROUND ((6 * log (iQpStep * 1.0f / INT_MULTIPLY) / log (2.0) + 4.0));
}
void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
@ -135,10 +136,12 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
pWelsSvcRc->iQpRangeLowerInFrame = (QP_RANGE_LOWER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) *
pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
pWelsSvcRc->iQpRangeLowerInFrame = (QP_RANGE_LOWER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) *
pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
if (iMbWidth <= MB_WIDTH_THRESHOLD_90P) {
pWelsSvcRc->iSkipQpValue = SKIP_QP_90P;
@ -223,8 +226,9 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
int32_t input_iBitsPerFrame = WELS_ROUND(pDLayerParam->iSpatialBitrate * INT_MULTIPLY / pDLayerParamInternal->fInputFrameRate);
const int32_t kiGopBits = WELS_DIV_ROUND(input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
int32_t input_iBitsPerFrame = WELS_ROUND (pDLayerParam->iSpatialBitrate * INT_MULTIPLY /
pDLayerParamInternal->fInputFrameRate);
const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
int32_t i;
pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
@ -236,12 +240,14 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
for (i = 0; i <= kiHighestTid; i++) {
const int64_t kdConstraitBits = kiGopBits * pTOverRc[i].iTlayerWeight;
pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND(kdConstraitBits * iMinBitsRatio, INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND(kdConstraitBits * iMaxBitsRatio, INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMinBitsRatio,
INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMaxBitsRatio,
INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
}
//When bitrate is changed, pBuffer size should be updated
pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND(pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND(pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
//change remaining bits
if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
@ -256,7 +262,7 @@ void RcInitVGop (sWelsEncCtx* pEncCtx) {
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND(VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
pWelsSvcRc->iRemainingWeights = pWelsSvcRc->iGopNumberInVGop * WEIGHT_MULTIPLY;
pWelsSvcRc->iFrameCodedInVGop = 0;
@ -427,7 +433,7 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iIntraMbCount;
}
pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iIntraComplexity /
pWelsSvcRc->iTargetBits);
pWelsSvcRc->iTargetBits);
pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
@ -465,17 +471,19 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = WELS_CLIP3 ((iLumaQp*INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp)/INT_MULTIPLY, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
iLumaQp = WELS_CLIP3 ((iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) /
INT_MULTIPLY, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
}
pEncCtx->iGlobalQp = iLumaQp;
return;
} else {
int64_t iCmplxRatio = WELS_DIV_ROUND64(pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity *INT_MULTIPLY, pTOverRc->iFrameCmplxMean);
int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
pTOverRc->iFrameCmplxMean);
iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
pWelsSvcRc->iQStep = WELS_DIV_ROUND((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
//limit QP
@ -501,7 +509,8 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
#ifndef _NOT_USE_AQ_FOR_TEST_
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = WELS_DIV_ROUND(iLumaQp*INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,INT_MULTIPLY);
iLumaQp = WELS_DIV_ROUND (iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,
INT_MULTIPLY);
if (pEncCtx->pSvcParam->iRCMode != RC_LOW_BW_MODE)
iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
@ -516,7 +525,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiBitsPerMb = WELS_DIV_ROUND(pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
const int32_t kiBitsPerMb = WELS_DIV_ROUND (pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
for (int32_t i = 0; i < kiSliceNum; i++) {
pSOverRc->iStartMbSlice =
@ -524,7 +533,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1);
pSOverRc->iTotalQpSlice = 0;
pSOverRc->iTotalMbSlice = 0;
pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND(kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY);
pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY);
pSOverRc->iFrameBitsSlice = 0;
pSOverRc->iGomBitsSlice = 0;
++ pSOverRc;
@ -538,10 +547,10 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL;
//allocate bits
if (pEncCtx->eSliceType == I_SLICE) {
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
} else {
pWelsSvcRc->iTargetBits = (int32_t)((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
pWelsSvcRc->iRemainingWeights);
pWelsSvcRc->iTargetBits = (int32_t) ((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
pWelsSvcRc->iRemainingWeights);
if ((pWelsSvcRc->iTargetBits <= 0) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) {
pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED;
} else if ((pWelsSvcRc->iTargetBits <= pTOverRc->iMinBitsTl) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) {
@ -635,9 +644,10 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
iSumSad += pWelsSvcRc_Base->pCurrentFrameGomSad[i];
}
if (0 == iSumSad)
iAllocateBits = WELS_DIV_ROUND(iLeftBits, (iLastGomIndex - kiComplexityIndex));
iAllocateBits = WELS_DIV_ROUND (iLeftBits, (iLastGomIndex - kiComplexityIndex));
else
iAllocateBits = WELS_DIV_ROUND((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1], iSumSad);
iAllocateBits = WELS_DIV_ROUND ((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1],
iSumSad);
}
pSOverRc->iGomTargetBits = iAllocateBits;
@ -657,7 +667,7 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
pSOverRc->iCalculatedQpSlice += 2;
} else {
//globe decision
iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits+1);
iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits + 1);
if (iBitsRatio < 8409) //2^(-1.5/6)*10000
pSOverRc->iCalculatedQpSlice += 2;
else if (iBitsRatio < 9439) //2^(-0.5/6)*10000
@ -680,11 +690,11 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
const int32_t kiOutputBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
//condition 1: whole pBuffer fullness
pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
//condition 2: VGOP bits constraint
const int32_t kiVGopBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame * VGOP_SIZE, INT_MULTIPLY);
const int32_t kiVGopBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE, INT_MULTIPLY);
int32_t iVGopBitsPred = 0;
for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
@ -705,32 +715,32 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iBufferFullnessSkip = 0;
if (pEncCtx->iSkipFrameFlag == 1) {
pWelsSvcRc->iRemainingBits += WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
pWelsSvcRc->iRemainingBits += WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
pWelsSvcRc->iSkipFrameNum++;
pWelsSvcRc->iSkipFrameInVGop++;
}
}
void WelsRcFrameDelayJudge(void* pCtx) {
void WelsRcFrameDelayJudge (void* pCtx) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
int32_t iSentBits = WELS_ROUND(pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
int32_t iSentBits = WELS_ROUND (pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
pWelsSvcRc->bSkipFlag = false;
if (pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip) {
pWelsSvcRc->bSkipFlag = true;
pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX(pWelsSvcRc->iBufferFullnessSkip, 0);
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
}
}
void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
const int32_t kiOutputBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
const int32_t kiBufferThreshold = WELS_DIV_ROUND(PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
const int32_t kiBufferThreshold = WELS_DIV_ROUND (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
pWelsSvcRc->iBufferFullnessPadding += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
@ -767,7 +777,7 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
++ pSOverRc;
}
if (iTotalMb > 0)
pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND(INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND (INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
else
pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
} else {
@ -779,11 +789,12 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
int32_t iAlpha = WELS_DIV_ROUND(INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
if (iAlpha < (INT_MULTIPLY/4)) iAlpha = INT_MULTIPLY/4;
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
int64_t iIntraCmplx = pWelsSvcRc->iQStep * pWelsSvcRc->iFrameDqBits;
pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND(((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha * iIntraCmplx), INT_MULTIPLY);
pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
iIntraCmplx), INT_MULTIPLY);
pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
pWelsSvcRc->iIdrNum++;
@ -799,14 +810,15 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
if (0 == pTOverRc->iPFrameNum) {
pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;
} else {
pTOverRc->iLinearCmplx = WELS_DIV_ROUND64((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
+ (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t)(pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)), INT_MULTIPLY);
pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
+ (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)),
INT_MULTIPLY);
}
int32_t iAlpha = WELS_DIV_ROUND(INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
iAlpha = SMOOTH_FACTOR_MIN_VALUE;
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND(((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
pTOverRc->iPFrameNum++;
if (pTOverRc->iPFrameNum > 255)
@ -951,8 +963,8 @@ void WelsRcPictureInitDisable (void* pCtx) {
pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp);
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
pEncCtx->iGlobalQp = WELS_CLIP3 ( (pEncCtx->iGlobalQp *INT_MULTIPLY -
pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp)/INT_MULTIPLY, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
} else {
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);
}

View File

@ -284,7 +284,7 @@ void GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight,
while (uiSliceIdx + 1 < kuiSliceNum) {
// GOM boundary aligned
int32_t iNumMbAssigning = WELS_DIV_ROUND(INT_MULTIPLY * kiMbNumPerSlice, iGomSize * INT_MULTIPLY) * iGomSize;
int32_t iNumMbAssigning = WELS_DIV_ROUND (INT_MULTIPLY * kiMbNumPerSlice, iGomSize * INT_MULTIPLY) * iGomSize;
// make sure one GOM at least in each slice for safe
if (iNumMbAssigning < iMinimalMbNum)

View File

@ -341,7 +341,7 @@ bool MdInterSCDPskipProcess (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSl
if (bSkipFlag) {
bool bQpSimilarFlag = (kiRefMbQp - kiCurMbQp <= DELTA_QP_SCD_THD || kiRefMbQp <= 26);
SMVUnitXY sVaaPredSkipMv = {0,0}, sCurMbMv[2] = {{0,0},{0,0}};
SMVUnitXY sVaaPredSkipMv = {0, 0}, sCurMbMv[2] = {{0, 0}, {0, 0}};
PredSkipMv (pMbCache, &sVaaPredSkipMv);
if (eSkipMode == SCROLLED) {

View File

@ -142,8 +142,8 @@ EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPix
pCurFrameY += (iCurStride) << 4;
}
}
iAverageMotionIndex = WELS_DIV_ROUND64(iAverageMotionIndex * AQ_INT_MULTIPLY,iMbTotalNum);
iAverageTextureIndex = WELS_DIV_ROUND64(iAverageTextureIndex * AQ_INT_MULTIPLY, iMbTotalNum);
iAverageMotionIndex = WELS_DIV_ROUND64 (iAverageMotionIndex * AQ_INT_MULTIPLY, iMbTotalNum);
iAverageTextureIndex = WELS_DIV_ROUND64 (iAverageTextureIndex * AQ_INT_MULTIPLY, iMbTotalNum);
if ((iAverageMotionIndex <= AQ_PESN) && (iAverageMotionIndex >= -AQ_PESN)) {
iAverageMotionIndex = AQ_INT_MULTIPLY;
}
@ -153,34 +153,37 @@ EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPix
// motion mb residual map to QP
// texture mb original map to QP
iAverMotionTextureIndexToDeltaQp = 0;
iAverageMotionIndex = WELS_DIV_ROUND64(AVERAGE_TIME_MOTION * iAverageMotionIndex, AQ_TIME_INT_MULTIPLY);
iAverageMotionIndex = WELS_DIV_ROUND64 (AVERAGE_TIME_MOTION * iAverageMotionIndex, AQ_TIME_INT_MULTIPLY);
if (m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_QUALITY_MODE) {
iAverageTextureIndex = WELS_DIV_ROUND64(AVERAGE_TIME_TEXTURE_QUALITYMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY);
iAverageTextureIndex = WELS_DIV_ROUND64 (AVERAGE_TIME_TEXTURE_QUALITYMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY);
} else {
iAverageTextureIndex = WELS_DIV_ROUND64(AVERAGE_TIME_TEXTURE_BITRATEMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY);
iAverageTextureIndex = WELS_DIV_ROUND64 (AVERAGE_TIME_TEXTURE_BITRATEMODE * iAverageTextureIndex, AQ_TIME_INT_MULTIPLY);
}
int64_t iAQ_EPSN = -((int64_t)AQ_PESN*AQ_TIME_INT_MULTIPLY*AQ_QSTEP_INT_MULTIPLY/AQ_INT_MULTIPLY);
int64_t iAQ_EPSN = - ((int64_t)AQ_PESN * AQ_TIME_INT_MULTIPLY * AQ_QSTEP_INT_MULTIPLY / AQ_INT_MULTIPLY);
pMotionTexture = m_sAdaptiveQuantParam.pMotionTextureUnit;
for (j = 0; j < iMbHeight; j ++) {
for (i = 0; i < iMbWidth; i++) {
int64_t a = WELS_DIV_ROUND64((int64_t)(pMotionTexture->uiTextureIndex) *AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY, iAverageTextureIndex);
iQStep = WELS_DIV_ROUND64((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA));
int64_t a = WELS_DIV_ROUND64 ((int64_t) (pMotionTexture->uiTextureIndex) * AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY,
iAverageTextureIndex);
iQStep = WELS_DIV_ROUND64 ((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA));
iLumaTextureDeltaQp = MODEL_TIME * iQStep;// range +- 6
iMotionTextureIndexToDeltaQp = ((int32_t)(iLumaTextureDeltaQp/(AQ_TIME_INT_MULTIPLY)));
iMotionTextureIndexToDeltaQp = ((int32_t) (iLumaTextureDeltaQp / (AQ_TIME_INT_MULTIPLY)));
a = WELS_DIV_ROUND64(((int64_t)pMotionTexture->uiMotionIndex)*AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY, iAverageMotionIndex);
iQStep = WELS_DIV_ROUND64((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA));
a = WELS_DIV_ROUND64 (((int64_t)pMotionTexture->uiMotionIndex) * AQ_INT_MULTIPLY * AQ_TIME_INT_MULTIPLY,
iAverageMotionIndex);
iQStep = WELS_DIV_ROUND64 ((a - AQ_TIME_INT_MULTIPLY) * AQ_QSTEP_INT_MULTIPLY, (a + MODEL_ALPHA));
iLumaMotionDeltaQp = MODEL_TIME * iQStep;// range +- 6
if ((m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_QUALITY_MODE && iLumaMotionDeltaQp < iAQ_EPSN)
|| (m_sAdaptiveQuantParam.iAdaptiveQuantMode == AQ_BITRATE_MODE)) {
iMotionTextureIndexToDeltaQp += ((int32_t)(iLumaMotionDeltaQp/(AQ_TIME_INT_MULTIPLY)));
iMotionTextureIndexToDeltaQp += ((int32_t) (iLumaMotionDeltaQp / (AQ_TIME_INT_MULTIPLY)));
}
m_sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[j * iMbWidth + i] = (int8_t)(iMotionTextureIndexToDeltaQp/AQ_QSTEP_INT_MULTIPLY);
m_sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[j * iMbWidth + i] = (int8_t) (iMotionTextureIndexToDeltaQp /
AQ_QSTEP_INT_MULTIPLY);
iAverMotionTextureIndexToDeltaQp += iMotionTextureIndexToDeltaQp;
pMotionTexture++;
}

File diff suppressed because it is too large Load Diff

View File

@ -24,19 +24,19 @@ class BaseDecoderTest {
};
struct Callback {
virtual void onDecodeFrame(const Frame& frame) = 0;
virtual void onDecodeFrame (const Frame& frame) = 0;
};
BaseDecoderTest();
void SetUp();
void TearDown();
void DecodeFile(const char* fileName, Callback* cbk);
void DecodeFile (const char* fileName, Callback* cbk);
bool Open(const char* fileName);
bool DecodeNextFrame(Callback* cbk);
bool Open (const char* fileName);
bool DecodeNextFrame (Callback* cbk);
private:
void DecodeFrame(const uint8_t* src, int sliceSize, Callback* cbk);
void DecodeFrame (const uint8_t* src, int sliceSize, Callback* cbk);
ISVCDecoder* decoder_;
std::ifstream file_;

View File

@ -8,14 +8,16 @@
class BaseEncoderTest {
public:
struct Callback {
virtual void onEncodeFrame(const SFrameBSInfo& frameInfo) = 0;
virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) = 0;
};
BaseEncoderTest();
void SetUp();
void TearDown();
void EncodeFile(const char* fileName, EUsageType usageType, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk);
void EncodeStream(InputStream* in, EUsageType usageType, int width, int height, float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk);
void EncodeFile (const char* fileName, EUsageType usageType, int width, int height, float frameRate,
SliceModeEnum slices, bool denoise, int layers, Callback* cbk);
void EncodeStream (InputStream* in, EUsageType usageType, int width, int height, float frameRate, SliceModeEnum slices,
bool denoise, int layers, Callback* cbk);
private:
ISVCEncoder* encoder_;

View File

@ -5,18 +5,18 @@
#include "utils/BufferedData.h"
#include "BaseDecoderTest.h"
static void ReadFrame(std::ifstream* file, BufferedData* buf) {
static void ReadFrame (std::ifstream* file, BufferedData* buf) {
// start code of a frame is {0, 0, 0, 1}
int zeroCount = 0;
char b;
buf->Clear();
for (;;) {
file->read(&b, 1);
file->read (&b, 1);
if (file->gcount() != 1) { // end of file
return;
}
if (!buf->PushBack(b)) {
if (!buf->PushBack (b)) {
FAIL() << "unable to allocate memory";
}
@ -28,8 +28,8 @@ static void ReadFrame(std::ifstream* file, BufferedData* buf) {
zeroCount = b != 0 ? 0 : zeroCount + 1;
} else {
if (b == 1) {
if (file->seekg(-4, file->cur).good()) {
buf->SetLength(buf->Length() - 4);
if (file->seekg (-4, file->cur).good()) {
buf->SetLength (buf->Length() - 4);
return;
} else {
FAIL() << "unable to seek file";
@ -44,94 +44,97 @@ static void ReadFrame(std::ifstream* file, BufferedData* buf) {
}
BaseDecoderTest::BaseDecoderTest()
: decoder_(NULL), decodeStatus_(OpenFile) {}
: decoder_ (NULL), decodeStatus_ (OpenFile) {}
void BaseDecoderTest::SetUp() {
long rv = WelsCreateDecoder(&decoder_);
ASSERT_EQ(0, rv);
ASSERT_TRUE(decoder_ != NULL);
long rv = WelsCreateDecoder (&decoder_);
ASSERT_EQ (0, rv);
ASSERT_TRUE (decoder_ != NULL);
SDecodingParam decParam;
memset(&decParam, 0, sizeof(SDecodingParam));
memset (&decParam, 0, sizeof (SDecodingParam));
decParam.iOutputColorFormat = videoFormatI420;
decParam.uiTargetDqLayer = UCHAR_MAX;
decParam.uiEcActiveFlag = 1;
decParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
rv = decoder_->Initialize(&decParam);
ASSERT_EQ(0, rv);
rv = decoder_->Initialize (&decParam);
ASSERT_EQ (0, rv);
}
void BaseDecoderTest::TearDown() {
if (decoder_ != NULL) {
decoder_->Uninitialize();
WelsDestroyDecoder(decoder_);
WelsDestroyDecoder (decoder_);
}
}
void BaseDecoderTest::DecodeFrame(const uint8_t* src, int sliceSize, Callback* cbk) {
void BaseDecoderTest::DecodeFrame (const uint8_t* src, int sliceSize, Callback* cbk) {
uint8_t* data[3];
SBufferInfo bufInfo;
memset(data, 0, sizeof(data));
memset(&bufInfo, 0, sizeof(SBufferInfo));
memset (data, 0, sizeof (data));
memset (&bufInfo, 0, sizeof (SBufferInfo));
DECODING_STATE rv = decoder_->DecodeFrame2(src, sliceSize, data, &bufInfo);
ASSERT_TRUE(rv == dsErrorFree);
DECODING_STATE rv = decoder_->DecodeFrame2 (src, sliceSize, data, &bufInfo);
ASSERT_TRUE (rv == dsErrorFree);
if (bufInfo.iBufferStatus == 1 && cbk != NULL) {
const Frame frame = {
{ // y plane
data[0],
bufInfo.UsrData.sSystemBuffer.iWidth,
bufInfo.UsrData.sSystemBuffer.iHeight,
bufInfo.UsrData.sSystemBuffer.iStride[0]
},
{ // u plane
data[1],
bufInfo.UsrData.sSystemBuffer.iWidth / 2,
bufInfo.UsrData.sSystemBuffer.iHeight / 2,
bufInfo.UsrData.sSystemBuffer.iStride[1]
},
{ // v plane
data[2],
bufInfo.UsrData.sSystemBuffer.iWidth / 2,
bufInfo.UsrData.sSystemBuffer.iHeight / 2,
bufInfo.UsrData.sSystemBuffer.iStride[1]
},
{
// y plane
data[0],
bufInfo.UsrData.sSystemBuffer.iWidth,
bufInfo.UsrData.sSystemBuffer.iHeight,
bufInfo.UsrData.sSystemBuffer.iStride[0]
},
{
// u plane
data[1],
bufInfo.UsrData.sSystemBuffer.iWidth / 2,
bufInfo.UsrData.sSystemBuffer.iHeight / 2,
bufInfo.UsrData.sSystemBuffer.iStride[1]
},
{
// v plane
data[2],
bufInfo.UsrData.sSystemBuffer.iWidth / 2,
bufInfo.UsrData.sSystemBuffer.iHeight / 2,
bufInfo.UsrData.sSystemBuffer.iStride[1]
},
};
cbk->onDecodeFrame(frame);
cbk->onDecodeFrame (frame);
}
}
void BaseDecoderTest::DecodeFile(const char* fileName, Callback* cbk) {
std::ifstream file(fileName, std::ios::in | std::ios::binary);
ASSERT_TRUE(file.is_open());
void BaseDecoderTest::DecodeFile (const char* fileName, Callback* cbk) {
std::ifstream file (fileName, std::ios::in | std::ios::binary);
ASSERT_TRUE (file.is_open());
BufferedData buf;
while (true) {
ReadFrame(&file, &buf);
ReadFrame (&file, &buf);
if (::testing::Test::HasFatalFailure()) {
return;
}
if (buf.Length() == 0) {
break;
}
DecodeFrame(buf.data(), buf.Length(), cbk);
DecodeFrame (buf.data(), buf.Length(), cbk);
if (::testing::Test::HasFatalFailure()) {
return;
}
}
int32_t iEndOfStreamFlag = 1;
decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
// Get pending last frame
DecodeFrame(NULL, 0, cbk);
DecodeFrame (NULL, 0, cbk);
}
bool BaseDecoderTest::Open(const char* fileName) {
bool BaseDecoderTest::Open (const char* fileName) {
if (decodeStatus_ == OpenFile) {
file_.open(fileName, std::ios_base::out | std::ios_base::binary);
file_.open (fileName, std::ios_base::out | std::ios_base::binary);
if (file_.is_open()) {
decodeStatus_ = Decoding;
return true;
@ -140,10 +143,10 @@ bool BaseDecoderTest::Open(const char* fileName) {
return false;
}
bool BaseDecoderTest::DecodeNextFrame(Callback* cbk) {
bool BaseDecoderTest::DecodeNextFrame (Callback* cbk) {
switch (decodeStatus_) {
case Decoding:
ReadFrame(&file_, &buf_);
ReadFrame (&file_, &buf_);
if (::testing::Test::HasFatalFailure()) {
return false;
}
@ -151,15 +154,15 @@ bool BaseDecoderTest::DecodeNextFrame(Callback* cbk) {
decodeStatus_ = EndOfStream;
return true;
}
DecodeFrame(buf_.data(), buf_.Length(), cbk);
DecodeFrame (buf_.data(), buf_.Length(), cbk);
if (::testing::Test::HasFatalFailure()) {
return false;
}
return true;
case EndOfStream: {
int32_t iEndOfStreamFlag = 1;
decoder_->SetOption(DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
DecodeFrame(NULL, 0, cbk);
decoder_->SetOption (DECODER_OPTION_END_OF_STREAM, &iEndOfStreamFlag);
DecodeFrame (NULL, 0, cbk);
decodeStatus_ = End;
break;
}

View File

@ -5,12 +5,12 @@
#include "utils/FileInputStream.h"
#include "BaseEncoderTest.h"
static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width,
int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) {
static int InitWithParam (ISVCEncoder* encoder, EUsageType usageType, int width,
int height, float frameRate, SliceModeEnum sliceMode, bool denoise, int layers) {
if (SM_SINGLE_SLICE == sliceMode && !denoise && layers == 1) {
SEncParamBase param;
memset (&param, 0, sizeof(SEncParamBase));
memset (&param, 0, sizeof (SEncParamBase));
param.iUsageType = usageType;
param.fMaxFrameRate = frameRate;
param.iPicWidth = width;
@ -18,10 +18,10 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width,
param.iTargetBitrate = 5000000;
param.iInputCsp = videoFormatI420;
return encoder->Initialize(&param);
return encoder->Initialize (&param);
} else {
SEncParamExt param;
encoder->GetDefaultParams(&param);
encoder->GetDefaultParams (&param);
param.iUsageType = usageType;
param.fMaxFrameRate = frameRate;
@ -49,62 +49,62 @@ static int InitWithParam(ISVCEncoder* encoder, EUsageType usageType,int width,
}
param.iTargetBitrate *= param.iSpatialLayerNum;
return encoder->InitializeExt(&param);
return encoder->InitializeExt (&param);
}
}
BaseEncoderTest::BaseEncoderTest() : encoder_(NULL) {}
BaseEncoderTest::BaseEncoderTest() : encoder_ (NULL) {}
void BaseEncoderTest::SetUp() {
int rv = WelsCreateSVCEncoder(&encoder_);
ASSERT_EQ(0, rv);
ASSERT_TRUE(encoder_ != NULL);
int rv = WelsCreateSVCEncoder (&encoder_);
ASSERT_EQ (0, rv);
ASSERT_TRUE (encoder_ != NULL);
}
void BaseEncoderTest::TearDown() {
if (encoder_) {
encoder_->Uninitialize();
WelsDestroySVCEncoder(encoder_);
WelsDestroySVCEncoder (encoder_);
}
}
void BaseEncoderTest::EncodeStream(InputStream* in, EUsageType usageType, int width, int height,
float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
int rv = InitWithParam(encoder_, usageType, width, height, frameRate, slices, denoise, layers);
ASSERT_TRUE(rv == cmResultSuccess);
void BaseEncoderTest::EncodeStream (InputStream* in, EUsageType usageType, int width, int height,
float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
int rv = InitWithParam (encoder_, usageType, width, height, frameRate, slices, denoise, layers);
ASSERT_TRUE (rv == cmResultSuccess);
// I420: 1(Y) + 1/4(U) + 1/4(V)
int frameSize = width * height * 3 / 2;
BufferedData buf;
buf.SetLength(frameSize);
ASSERT_TRUE(buf.Length() == (size_t)frameSize);
buf.SetLength (frameSize);
ASSERT_TRUE (buf.Length() == (size_t)frameSize);
SFrameBSInfo info;
memset(&info, 0, sizeof(SFrameBSInfo));
memset (&info, 0, sizeof (SFrameBSInfo));
SSourcePicture pic;
memset(&pic,0,sizeof(SSourcePicture));
memset (&pic, 0, sizeof (SSourcePicture));
pic.iPicWidth = width;
pic.iPicHeight = height;
pic.iColorFormat = videoFormatI420;
pic.iStride[0] = pic.iPicWidth;
pic.iStride[1] = pic.iStride[2] = pic.iPicWidth>>1;
pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;
pic.pData[0] = buf.data();
pic.pData[1] = pic.pData[0] + width *height;
pic.pData[2] = pic.pData[1] + (width*height>>2);
while (in->read(buf.data(), frameSize) == frameSize) {
rv = encoder_->EncodeFrame(&pic, &info);
ASSERT_TRUE(rv == cmResultSuccess);
pic.pData[1] = pic.pData[0] + width * height;
pic.pData[2] = pic.pData[1] + (width * height >> 2);
while (in->read (buf.data(), frameSize) == frameSize) {
rv = encoder_->EncodeFrame (&pic, &info);
ASSERT_TRUE (rv == cmResultSuccess);
if (info.eFrameType != videoFrameTypeSkip && cbk != NULL) {
cbk->onEncodeFrame(info);
cbk->onEncodeFrame (info);
}
}
}
void BaseEncoderTest::EncodeFile(const char* fileName, EUsageType usageType, int width, int height,
float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
void BaseEncoderTest::EncodeFile (const char* fileName, EUsageType usageType, int width, int height,
float frameRate, SliceModeEnum slices, bool denoise, int layers, Callback* cbk) {
FileInputStream fileStream;
ASSERT_TRUE(fileStream.Open(fileName));
EncodeStream(&fileStream, usageType, width, height, frameRate, slices, denoise, layers, cbk);
ASSERT_TRUE (fileStream.Open (fileName));
EncodeStream (&fileStream, usageType, width, height, frameRate, slices, denoise, layers, cbk);
}

View File

@ -7,35 +7,34 @@
using namespace std;
bool YUVPixelDataGenerator( uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride )
{
bool YUVPixelDataGenerator (uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride) {
#define SRC_FRAME_WIDTH (160)
#define SRC_FRAME_HEIGHT (96)
if ( SRC_FRAME_WIDTH-iWidth <= 0 || SRC_FRAME_HEIGHT-iHeight <= 0 ) {
if (SRC_FRAME_WIDTH - iWidth <= 0 || SRC_FRAME_HEIGHT - iHeight <= 0) {
return false;
}
const int32_t kiFrameSize = SRC_FRAME_WIDTH*SRC_FRAME_HEIGHT;
const int32_t kiFrameSize = SRC_FRAME_WIDTH * SRC_FRAME_HEIGHT;
BufferedData sBuf;
sBuf.SetLength(kiFrameSize);
sBuf.SetLength (kiFrameSize);
if (sBuf.Length() != (size_t)kiFrameSize) {
return false;
}
FileInputStream fileStream;
if (!fileStream.Open("res/CiscoVT2people_160x96_6fps.yuv")) {
if (!fileStream.Open ("res/CiscoVT2people_160x96_6fps.yuv")) {
return false;
}
if (fileStream.read(sBuf.data(), kiFrameSize) == kiFrameSize) {
srand((uint32_t)time(NULL));
int32_t iStartPosX = rand()%(SRC_FRAME_WIDTH-iWidth);
int32_t iStartPosY = rand()%(SRC_FRAME_HEIGHT-iHeight);
uint8_t* pSrcPointer = sBuf.data() + iStartPosX + iStartPosY*SRC_FRAME_WIDTH;
if (fileStream.read (sBuf.data(), kiFrameSize) == kiFrameSize) {
srand ((uint32_t)time (NULL));
int32_t iStartPosX = rand() % (SRC_FRAME_WIDTH - iWidth);
int32_t iStartPosY = rand() % (SRC_FRAME_HEIGHT - iHeight);
uint8_t* pSrcPointer = sBuf.data() + iStartPosX + iStartPosY * SRC_FRAME_WIDTH;
uint8_t* pLocalPointer = pPointer;
for (int j=0;j<iHeight;j++) {
memcpy(pLocalPointer, pSrcPointer, iWidth*sizeof(uint8_t));
for (int j = 0; j < iHeight; j++) {
memcpy (pLocalPointer, pSrcPointer, iWidth * sizeof (uint8_t));
pLocalPointer += iStride;
pSrcPointer += SRC_FRAME_WIDTH;
}
@ -44,24 +43,21 @@ bool YUVPixelDataGenerator( uint8_t* pPointer, int32_t iWidth, int32_t iHeight,
return false;
}
void RandomPixelDataGenerator( uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride, int32_t iIdx )
{
void RandomPixelDataGenerator (uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride, int32_t iIdx) {
uint8_t* pLocalPointer = pPointer;
srand((uint32_t)(time(NULL)+iIdx));
for (int32_t j=0;j<iHeight;j++) {
for (int32_t i=0;i<iWidth;i++) {
pLocalPointer[i] = rand()%256;
srand ((uint32_t) (time (NULL) + iIdx));
for (int32_t j = 0; j < iHeight; j++) {
for (int32_t i = 0; i < iWidth; i++) {
pLocalPointer[i] = rand() % 256;
}
pLocalPointer += iStride;
}
}
void RandomResidueDataGenerator( uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride )
{
void RandomResidueDataGenerator (uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride) {
}
void RandomCoeffDataGenerator( uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride )
{
void RandomCoeffDataGenerator (uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride) {
}

View File

@ -2,16 +2,16 @@
#include "codec_api.h"
#include <stddef.h>
static void CheckFunctionOrder(int expect, int actual, const char* name) {
EXPECT_EQ(expect, actual) << "Wrong function order: " << name;
static void CheckFunctionOrder (int expect, int actual, const char* name) {
EXPECT_EQ (expect, actual) << "Wrong function order: " << name;
}
typedef void(*CheckFunc)(int, int, const char*);
extern "C" void CheckEncoderInterface(ISVCEncoder* p, CheckFunc);
extern "C" void CheckDecoderInterface(ISVCDecoder* p, CheckFunc);
extern "C" size_t GetBoolSize(void);
extern "C" size_t GetBoolOffset(void);
extern "C" size_t GetBoolStructSize(void);
typedef void (*CheckFunc) (int, int, const char*);
extern "C" void CheckEncoderInterface (ISVCEncoder* p, CheckFunc);
extern "C" void CheckDecoderInterface (ISVCDecoder* p, CheckFunc);
extern "C" size_t GetBoolSize (void);
extern "C" size_t GetBoolOffset (void);
extern "C" size_t GetBoolStructSize (void);
// Store the 'this' pointer to verify 'this' is received as expected from C code.
static void* gThis;
@ -22,98 +22,98 @@ static void* gThis;
*/
struct SVCEncoderImpl : public ISVCEncoder {
virtual ~SVCEncoderImpl() {}
virtual int EXTAPI Initialize(const SEncParamBase* pParam) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI Initialize (const SEncParamBase* pParam) {
EXPECT_TRUE (gThis == this);
return 1;
}
virtual int EXTAPI InitializeExt(const SEncParamExt* pParam) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI InitializeExt (const SEncParamExt* pParam) {
EXPECT_TRUE (gThis == this);
return 2;
}
virtual int EXTAPI GetDefaultParams(SEncParamExt* pParam) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI GetDefaultParams (SEncParamExt* pParam) {
EXPECT_TRUE (gThis == this);
return 3;
}
virtual int EXTAPI Uninitialize() {
EXPECT_TRUE(gThis == this);
EXPECT_TRUE (gThis == this);
return 4;
}
virtual int EXTAPI EncodeFrame(const SSourcePicture* kpSrcPic,
SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic,
SFrameBSInfo* pBsInfo) {
EXPECT_TRUE (gThis == this);
return 5;
}
virtual int EXTAPI EncodeParameterSets(SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI EncodeParameterSets (SFrameBSInfo* pBsInfo) {
EXPECT_TRUE (gThis == this);
return 6;
}
virtual int EXTAPI PauseFrame(const SSourcePicture* kpSrcPic,
SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI PauseFrame (const SSourcePicture* kpSrcPic,
SFrameBSInfo* pBsInfo) {
EXPECT_TRUE (gThis == this);
return 7;
}
virtual int EXTAPI ForceIntraFrame(bool bIDR) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI ForceIntraFrame (bool bIDR) {
EXPECT_TRUE (gThis == this);
return 8;
}
virtual int EXTAPI SetOption(ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI SetOption (ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE (gThis == this);
return 9;
}
virtual int EXTAPI GetOption(ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this);
virtual int EXTAPI GetOption (ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE (gThis == this);
return 10;
}
};
struct SVCDecoderImpl : public ISVCDecoder {
virtual ~SVCDecoderImpl() {}
virtual long EXTAPI Initialize(const SDecodingParam* pParam) {
EXPECT_TRUE(gThis == this);
virtual long EXTAPI Initialize (const SDecodingParam* pParam) {
EXPECT_TRUE (gThis == this);
return 1;
}
virtual long EXTAPI Uninitialize() {
EXPECT_TRUE(gThis == this);
EXPECT_TRUE (gThis == this);
return 2;
}
virtual DECODING_STATE EXTAPI DecodeFrame(const unsigned char* pSrc,
virtual DECODING_STATE EXTAPI DecodeFrame (const unsigned char* pSrc,
const int iSrcLen, unsigned char** ppDst, int* pStride,
int& iWidth, int& iHeight) {
EXPECT_TRUE(gThis == this);
return static_cast<DECODING_STATE>(3);
EXPECT_TRUE (gThis == this);
return static_cast<DECODING_STATE> (3);
}
virtual DECODING_STATE EXTAPI DecodeFrame2(const unsigned char* pSrc,
virtual DECODING_STATE EXTAPI DecodeFrame2 (const unsigned char* pSrc,
const int iSrcLen, unsigned char** ppDst, SBufferInfo* pDstInfo) {
EXPECT_TRUE(gThis == this);
return static_cast<DECODING_STATE>(4);
EXPECT_TRUE (gThis == this);
return static_cast<DECODING_STATE> (4);
}
virtual DECODING_STATE EXTAPI DecodeFrameEx(const unsigned char* pSrc,
virtual DECODING_STATE EXTAPI DecodeFrameEx (const unsigned char* pSrc,
const int iSrcLen, unsigned char* pDst, int iDstStride,
int& iDstLen, int& iWidth, int& iHeight, int& iColorFormat) {
EXPECT_TRUE(gThis == this);
return static_cast<DECODING_STATE>(5);
EXPECT_TRUE (gThis == this);
return static_cast<DECODING_STATE> (5);
}
virtual long EXTAPI SetOption (DECODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this);
EXPECT_TRUE (gThis == this);
return 6;
}
virtual long EXTAPI GetOption (DECODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this);
EXPECT_TRUE (gThis == this);
return 7;
}
};
TEST(ISVCEncoderTest, CheckFunctionOrder) {
TEST (ISVCEncoderTest, CheckFunctionOrder) {
SVCEncoderImpl* p = new SVCEncoderImpl;
gThis = p;
CheckEncoderInterface(p, CheckFunctionOrder);
CheckEncoderInterface (p, CheckFunctionOrder);
delete p;
}
TEST(ISVCDecoderTest, CheckFunctionOrder) {
TEST (ISVCDecoderTest, CheckFunctionOrder) {
SVCDecoderImpl* p = new SVCDecoderImpl;
gThis = p;
CheckDecoderInterface(p, CheckFunctionOrder);
CheckDecoderInterface (p, CheckFunctionOrder);
delete p;
}
@ -122,8 +122,8 @@ struct bool_test_struct {
bool b;
};
TEST(ISVCDecoderEncoderTest, CheckCAbi) {
EXPECT_EQ(sizeof(bool), GetBoolSize()) << "Wrong size of bool type";
EXPECT_EQ(offsetof(bool_test_struct, b), GetBoolOffset()) << "Wrong alignment of bool in a struct";
EXPECT_EQ(sizeof(bool_test_struct), GetBoolStructSize()) << "Wrong size of struct with a bool";
TEST (ISVCDecoderEncoderTest, CheckCAbi) {
EXPECT_EQ (sizeof (bool), GetBoolSize()) << "Wrong size of bool type";
EXPECT_EQ (offsetof (bool_test_struct, b), GetBoolOffset()) << "Wrong alignment of bool in a struct";
EXPECT_EQ (sizeof (bool_test_struct), GetBoolStructSize()) << "Wrong size of struct with a bool";
}

View File

@ -6,21 +6,21 @@
#include "BaseDecoderTest.h"
#include "BaseEncoderTest.h"
static void UpdateHashFromFrame(const SFrameBSInfo& info, SHA1Context* ctx) {
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
for (int i = 0; i < info.iLayerNum; ++i) {
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
int layerSize = 0;
for (int j = 0; j < layerInfo.iNalCount; ++j) {
layerSize += layerInfo.pNalLengthInByte[j];
}
SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
SHA1Input (ctx, layerInfo.pBsBuf, layerSize);
}
}
static void WritePlaneBuffer(BufferedData* buf, const uint8_t* plane,
int width, int height, int stride) {
static void WritePlaneBuffer (BufferedData* buf, const uint8_t* plane,
int width, int height, int stride) {
for (int i = 0; i < height; i++) {
if (!buf->PushBack(plane, width)) {
if (!buf->PushBack (plane, width)) {
FAIL() << "unable to allocate memory";
}
plane += stride;
@ -36,9 +36,9 @@ struct DecodeEncodeFileParam {
};
class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
public BaseDecoderTest, public BaseDecoderTest::Callback,
public BaseEncoderTest , public BaseEncoderTest::Callback,
public InputStream {
public BaseDecoderTest, public BaseDecoderTest::Callback,
public BaseEncoderTest , public BaseEncoderTest::Callback,
public InputStream {
public:
virtual void SetUp() {
BaseDecoderTest::SetUp();
@ -49,7 +49,7 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
if (HasFatalFailure()) {
return;
}
SHA1Reset(&ctx_);
SHA1Reset (&ctx_);
}
virtual void TearDown() {
@ -57,22 +57,22 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
BaseEncoderTest::TearDown();
}
virtual void onDecodeFrame(const Frame& frame) {
virtual void onDecodeFrame (const Frame& frame) {
const Plane& y = frame.y;
const Plane& u = frame.u;
const Plane& v = frame.v;
WritePlaneBuffer(&buf_, y.data, y.width, y.height, y.stride);
WritePlaneBuffer(&buf_, u.data, u.width, u.height, u.stride);
WritePlaneBuffer(&buf_, v.data, v.width, v.height, v.stride);
WritePlaneBuffer (&buf_, y.data, y.width, y.height, y.stride);
WritePlaneBuffer (&buf_, u.data, u.width, u.height, u.stride);
WritePlaneBuffer (&buf_, v.data, v.width, v.height, v.stride);
}
virtual void onEncodeFrame(const SFrameBSInfo& frameInfo) {
UpdateHashFromFrame(frameInfo, &ctx_);
virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) {
UpdateHashFromFrame (frameInfo, &ctx_);
}
virtual int read(void* ptr, size_t len) {
virtual int read (void* ptr, size_t len) {
while (buf_.Length() < len) {
bool hasNext = DecodeNextFrame(this);
bool hasNext = DecodeNextFrame (this);
if (HasFatalFailure()) {
return -1;
}
@ -83,7 +83,7 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
break;
}
}
return buf_.PopFront(static_cast<uint8_t*>(ptr), len);
return buf_.PopFront (static_cast<uint8_t*> (ptr), len);
}
protected:
@ -91,15 +91,15 @@ class DecodeEncodeTest : public ::testing::TestWithParam<DecodeEncodeFileParam>,
BufferedData buf_;
};
TEST_P(DecodeEncodeTest, CompareOutput) {
TEST_P (DecodeEncodeTest, CompareOutput) {
DecodeEncodeFileParam p = GetParam();
ASSERT_TRUE(Open(p.fileName));
EncodeStream(this, CAMERA_VIDEO_REAL_TIME,p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);
ASSERT_TRUE (Open (p.fileName));
EncodeStream (this, CAMERA_VIDEO_REAL_TIME, p.width, p.height, p.frameRate, SM_SINGLE_SLICE, false, 1, this);
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result(&ctx_, digest);
SHA1Result (&ctx_, digest);
if (!HasFatalFailure()) {
CompareHash(digest, p.hashStr);
CompareHash (digest, p.hashStr);
}
}
@ -108,5 +108,5 @@ static const DecodeEncodeFileParam kFileParamArray[] = {
{"res/test_vd_rc.264", "106fd8cc978c1801b0d1f8297e9b7f17d5336e15", 320, 192, 12.0f},
};
INSTANTIATE_TEST_CASE_P(DecodeEncodeFile, DecodeEncodeTest,
::testing::ValuesIn(kFileParamArray));
INSTANTIATE_TEST_CASE_P (DecodeEncodeFile, DecodeEncodeTest,
::testing::ValuesIn (kFileParamArray));

View File

@ -2,10 +2,10 @@
#include "utils/HashFunctions.h"
#include "BaseDecoderTest.h"
static void UpdateHashFromPlane(SHA1Context* ctx, const uint8_t* plane,
int width, int height, int stride) {
static void UpdateHashFromPlane (SHA1Context* ctx, const uint8_t* plane,
int width, int height, int stride) {
for (int i = 0; i < height; i++) {
SHA1Input(ctx, plane, width);
SHA1Input (ctx, plane, width);
plane += stride;
}
}
@ -21,7 +21,7 @@ class DecoderInitTest : public ::testing::Test, public BaseDecoderTest {
}
};
TEST_F(DecoderInitTest, JustInit) {}
TEST_F (DecoderInitTest, JustInit) {}
struct FileParam {
const char* fileName;
@ -29,35 +29,35 @@ struct FileParam {
};
class DecoderOutputTest : public ::testing::WithParamInterface<FileParam>,
public DecoderInitTest, public BaseDecoderTest::Callback {
public DecoderInitTest, public BaseDecoderTest::Callback {
public:
virtual void SetUp() {
DecoderInitTest::SetUp();
if (HasFatalFailure()) {
return;
}
SHA1Reset(&ctx_);
SHA1Reset (&ctx_);
}
virtual void onDecodeFrame(const Frame& frame) {
virtual void onDecodeFrame (const Frame& frame) {
const Plane& y = frame.y;
const Plane& u = frame.u;
const Plane& v = frame.v;
UpdateHashFromPlane(&ctx_, y.data, y.width, y.height, y.stride);
UpdateHashFromPlane(&ctx_, u.data, u.width, u.height, u.stride);
UpdateHashFromPlane(&ctx_, v.data, v.width, v.height, v.stride);
UpdateHashFromPlane (&ctx_, y.data, y.width, y.height, y.stride);
UpdateHashFromPlane (&ctx_, u.data, u.width, u.height, u.stride);
UpdateHashFromPlane (&ctx_, v.data, v.width, v.height, v.stride);
}
protected:
SHA1Context ctx_;
};
TEST_P(DecoderOutputTest, CompareOutput) {
TEST_P (DecoderOutputTest, CompareOutput) {
FileParam p = GetParam();
DecodeFile(p.fileName, this);
DecodeFile (p.fileName, this);
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result(&ctx_, digest);
SHA1Result (&ctx_, digest);
if (!HasFatalFailure()) {
CompareHash(digest, p.hashStr);
CompareHash (digest, p.hashStr);
}
}
@ -96,5 +96,5 @@ static const FileParam kFileParamArray[] = {
{"res/SVA_NL2_E.264", "70453ef8097c94dd190d6d2d1d5cb83c67e66238"}
};
INSTANTIATE_TEST_CASE_P(DecodeFile, DecoderOutputTest,
::testing::ValuesIn(kFileParamArray));
INSTANTIATE_TEST_CASE_P (DecodeFile, DecoderOutputTest,
::testing::ValuesIn (kFileParamArray));

View File

@ -2,14 +2,14 @@
#include "utils/HashFunctions.h"
#include "BaseEncoderTest.h"
static void UpdateHashFromFrame(const SFrameBSInfo& info, SHA1Context* ctx) {
static void UpdateHashFromFrame (const SFrameBSInfo& info, SHA1Context* ctx) {
for (int i = 0; i < info.iLayerNum; ++i) {
const SLayerBSInfo& layerInfo = info.sLayerInfo[i];
int layerSize = 0;
for (int j = 0; j < layerInfo.iNalCount; ++j) {
layerSize += layerInfo.pNalLengthInByte[j];
}
SHA1Input(ctx, layerInfo.pBsBuf, layerSize);
SHA1Input (ctx, layerInfo.pBsBuf, layerSize);
}
}
@ -23,7 +23,7 @@ class EncoderInitTest : public ::testing::Test, public BaseEncoderTest {
}
};
TEST_F(EncoderInitTest, JustInit) {}
TEST_F (EncoderInitTest, JustInit) {}
struct EncodeFileParam {
const char* fileName;
@ -38,80 +38,80 @@ struct EncodeFileParam {
};
class EncoderOutputTest : public ::testing::WithParamInterface<EncodeFileParam>,
public EncoderInitTest , public BaseEncoderTest::Callback {
public EncoderInitTest , public BaseEncoderTest::Callback {
public:
virtual void SetUp() {
EncoderInitTest::SetUp();
if (HasFatalFailure()) {
return;
}
SHA1Reset(&ctx_);
SHA1Reset (&ctx_);
}
virtual void onEncodeFrame(const SFrameBSInfo& frameInfo) {
UpdateHashFromFrame(frameInfo, &ctx_);
virtual void onEncodeFrame (const SFrameBSInfo& frameInfo) {
UpdateHashFromFrame (frameInfo, &ctx_);
}
protected:
SHA1Context ctx_;
};
TEST_P(EncoderOutputTest, CompareOutput) {
TEST_P (EncoderOutputTest, CompareOutput) {
EncodeFileParam p = GetParam();
EncodeFile(p.fileName, p.usageType ,p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, this);
EncodeFile (p.fileName, p.usageType , p.width, p.height, p.frameRate, p.slices, p.denoise, p.layers, this);
//will remove this after screen content algorithms are ready,
//because the bitstream output will vary when the different algorithms are added.
if(p.usageType == SCREEN_CONTENT_REAL_TIME)
if (p.usageType == SCREEN_CONTENT_REAL_TIME)
return;
unsigned char digest[SHA_DIGEST_LENGTH];
SHA1Result(&ctx_, digest);
SHA1Result (&ctx_, digest);
if (!HasFatalFailure()) {
CompareHash(digest, p.hashStr);
CompareHash (digest, p.hashStr);
}
}
static const EncodeFileParam kFileParamArray[] = {
{
"res/CiscoVT2people_320x192_12fps.yuv",
"0a36b75e423fc6b49f6adf7eee12c039a096f538", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
"res/CiscoVT2people_320x192_12fps.yuv",
"0a36b75e423fc6b49f6adf7eee12c039a096f538", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
},
{
"res/CiscoVT2people_160x96_6fps.yuv",
"73981e6ea5b62f7338212c538a7cc755e7c9c030", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
"res/CiscoVT2people_160x96_6fps.yuv",
"73981e6ea5b62f7338212c538a7cc755e7c9c030", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
},
{
"res/Static_152_100.yuv",
"83db4c0e3006bbe039bd327b6e78c57fbb05316f", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
"res/Static_152_100.yuv",
"83db4c0e3006bbe039bd327b6e78c57fbb05316f", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"c8b759bcec7ffa048f1d3ded594b8815bed0aead", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1 // One slice per MB row
"res/CiscoVT2people_320x192_12fps.yuv",
"c8b759bcec7ffa048f1d3ded594b8815bed0aead", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1 // One slice per MB row
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"e64ba75456c821ca35a949eda89f85bff8ee69fa", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1
"res/CiscoVT2people_320x192_12fps.yuv",
"e64ba75456c821ca35a949eda89f85bff8ee69fa", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"684e6d141ada776892bdb01ee93efe475983ed36", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2
"res/CiscoVT2people_320x192_12fps.yuv",
"684e6d141ada776892bdb01ee93efe475983ed36", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2
},
{
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"6df1ece77c0de63cdf8ab52ccef3a7d139022717", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
"6df1ece77c0de63cdf8ab52ccef3a7d139022717", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1
},
{
"res/CiscoVT2people_320x192_12fps.yuv",
"", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
"res/CiscoVT2people_320x192_12fps.yuv",
"", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1
},
{
"res/CiscoVT2people_160x96_6fps.yuv",
"", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
"res/CiscoVT2people_160x96_6fps.yuv",
"", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1
},
{
"res/Static_152_100.yuv",
"", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
"res/Static_152_100.yuv",
"", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1
}
};
INSTANTIATE_TEST_CASE_P(EncodeFile, EncoderOutputTest,
::testing::ValuesIn(kFileParamArray));
INSTANTIATE_TEST_CASE_P (EncodeFile, EncoderOutputTest,
::testing::ValuesIn (kFileParamArray));

View File

@ -5,15 +5,15 @@
#if (defined(ANDROID_NDK)||defined(APPLE_IOS))
int CodecUtMain(int argc , char** argv ) {
int CodecUtMain (int argc , char** argv) {
#else
int main (int argc, char** argv) {
#endif
#if defined(ANDROID_NDK)
char xmlPath[1024] = "";
sprintf(xmlPath,"xml:%s",argv[1]);
::testing::GTEST_FLAG(output) = xmlPath;
char xmlPath[1024] = "";
sprintf (xmlPath, "xml:%s", argv[1]);
::testing::GTEST_FLAG (output) = xmlPath;
#endif
::testing::InitGoogleTest (&argc, argv);

View File

@ -8,7 +8,7 @@
#define LOG_TAG "codec_unittest"
#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
int CodecUtMain(int argc, char** argv);
int CodecUtMain (int argc, char** argv);
extern "C"
JNIEXPORT void JNICALL Java_com_cisco_codec_unittest_MainActivity_DoUnittest
(JNIEnv* env, jobject thiz, jstring directory, jstring jspath) {
@ -16,11 +16,11 @@ JNIEXPORT void JNICALL Java_com_cisco_codec_unittest_MainActivity_DoUnittest
char* argv[2];
int argc = 2;
argv[0] = (char*) ("codec_unittest.exe");
argv[1] = (char*) ((*env).GetStringUTFChars (jspath,NULL));
chdir((*env).GetStringUTFChars (directory, NULL));
argv[1] = (char*) ((*env).GetStringUTFChars (jspath, NULL));
chdir ((*env).GetStringUTFChars (directory, NULL));
LOGI ("PATH: %s", argv[1]);
LOGI ("Start to run JNI module!+++");
CodecUtMain(argc,argv);
CodecUtMain (argc, argv);
LOGI ("End to run JNI module!+++");
}

View File

@ -10,6 +10,6 @@
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow* window;
@end

View File

@ -141,6 +141,8 @@ GENERATE_LUMA_UT (LumaEq4H_AArch64_neon, DeblockLumaEq4H_AArch64_neon_wrap, Debl
GENERATE_CHROMA_UT (ChromaLt4V_AArch64_neon, DeblockChromaLt4V_AArch64_neon, DeblockChromaLt4V_c, WELS_CPU_NEON, 0)
GENERATE_CHROMA_UT (ChromaLt4H_AArch64_neon, DeblockChromaLt4H_AArch64_neon, DeblockChromaLt4H_c, WELS_CPU_NEON, 1)
GENERATE_CHROMA_UT (ChromaEq4V_AArch64_neon, DeblockChromaEq4V_AArch64_neon_wrap, DeblockChromaEq4V_c_wrap, WELS_CPU_NEON, 0)
GENERATE_CHROMA_UT (ChromaEq4H_AArch64_neon, DeblockChromaEq4H_AArch64_neon_wrap, DeblockChromaEq4H_c_wrap, WELS_CPU_NEON, 1)
GENERATE_CHROMA_UT (ChromaEq4V_AArch64_neon, DeblockChromaEq4V_AArch64_neon_wrap, DeblockChromaEq4V_c_wrap,
WELS_CPU_NEON, 0)
GENERATE_CHROMA_UT (ChromaEq4H_AArch64_neon, DeblockChromaEq4H_AArch64_neon_wrap, DeblockChromaEq4H_c_wrap,
WELS_CPU_NEON, 1)
#endif

View File

@ -9,156 +9,156 @@
using namespace WelsSVCEnc;
TEST(DecodeMbAuxTest, TestIhdm_4x4_dc) {
short W[16],T[16],Y[16];
srand((uint32_t)time(NULL));
for(int i=0;i<16;i++)
W[i]=rand()%256+1;
TEST (DecodeMbAuxTest, TestIhdm_4x4_dc) {
short W[16], T[16], Y[16];
srand ((uint32_t)time (NULL));
for (int i = 0; i < 16; i++)
W[i] = rand() % 256 + 1;
T[0]=W[0]+W[4]+W[8]+W[12];
T[1]=W[1]+W[5]+W[9]+W[13];
T[2]=W[2]+W[6]+W[10]+W[14];
T[3]=W[3]+W[7]+W[11]+W[15];
T[0] = W[0] + W[4] + W[8] + W[12];
T[1] = W[1] + W[5] + W[9] + W[13];
T[2] = W[2] + W[6] + W[10] + W[14];
T[3] = W[3] + W[7] + W[11] + W[15];
T[4]=W[0]+W[4]-W[8]-W[12];
T[5]=W[1]+W[5]-W[9]-W[13];
T[6]=W[2]+W[6]-W[10]-W[14];
T[7]=W[3]+W[7]-W[11]-W[15];
T[4] = W[0] + W[4] - W[8] - W[12];
T[5] = W[1] + W[5] - W[9] - W[13];
T[6] = W[2] + W[6] - W[10] - W[14];
T[7] = W[3] + W[7] - W[11] - W[15];
T[8]=W[0]-W[4]-W[8]+W[12];
T[9]=W[1]-W[5]-W[9]+W[13];
T[10]=W[2]-W[6]-W[10]+W[14];
T[11]=W[3]-W[7]-W[11]+W[15];
T[8] = W[0] - W[4] - W[8] + W[12];
T[9] = W[1] - W[5] - W[9] + W[13];
T[10] = W[2] - W[6] - W[10] + W[14];
T[11] = W[3] - W[7] - W[11] + W[15];
T[12]=W[0]-W[4]+W[8]-W[12];
T[13]=W[1]-W[5]+W[9]-W[13];
T[14]=W[2]-W[6]+W[10]-W[14];
T[15]=W[3]-W[7]+W[11]-W[15];
T[12] = W[0] - W[4] + W[8] - W[12];
T[13] = W[1] - W[5] + W[9] - W[13];
T[14] = W[2] - W[6] + W[10] - W[14];
T[15] = W[3] - W[7] + W[11] - W[15];
Y[0]=T[0]+T[1]+T[2]+T[3];
Y[1]=T[0]+T[1]-T[2]-T[3];
Y[2]=T[0]-T[1]-T[2]+T[3];
Y[3]=T[0]-T[1]+T[2]-T[3];
Y[0] = T[0] + T[1] + T[2] + T[3];
Y[1] = T[0] + T[1] - T[2] - T[3];
Y[2] = T[0] - T[1] - T[2] + T[3];
Y[3] = T[0] - T[1] + T[2] - T[3];
Y[4]=T[4]+T[5]+T[6]+T[7];
Y[5]=T[4]+T[5]-T[6]-T[7];
Y[6]=T[4]-T[5]-T[6]+T[7];
Y[7]=T[4]-T[5]+T[6]-T[7];
Y[4] = T[4] + T[5] + T[6] + T[7];
Y[5] = T[4] + T[5] - T[6] - T[7];
Y[6] = T[4] - T[5] - T[6] + T[7];
Y[7] = T[4] - T[5] + T[6] - T[7];
Y[8]=T[8]+T[9]+T[10]+T[11];
Y[9]=T[8]+T[9]-T[10]-T[11];
Y[10]=T[8]-T[9]-T[10]+T[11];
Y[11]=T[8]-T[9]+T[10]-T[11];
Y[8] = T[8] + T[9] + T[10] + T[11];
Y[9] = T[8] + T[9] - T[10] - T[11];
Y[10] = T[8] - T[9] - T[10] + T[11];
Y[11] = T[8] - T[9] + T[10] - T[11];
Y[12]=T[12]+T[13]+T[14]+T[15];
Y[13]=T[12]+T[13]-T[14]-T[15];
Y[14]=T[12]-T[13]-T[14]+T[15];
Y[15]=T[12]-T[13]+T[14]-T[15];
Y[12] = T[12] + T[13] + T[14] + T[15];
Y[13] = T[12] + T[13] - T[14] - T[15];
Y[14] = T[12] - T[13] - T[14] + T[15];
Y[15] = T[12] - T[13] + T[14] - T[15];
WelsIHadamard4x4Dc(W);
for(int i=0;i<16;i++)
EXPECT_EQ( Y[i],W[i] );
WelsIHadamard4x4Dc (W);
for (int i = 0; i < 16; i++)
EXPECT_EQ (Y[i], W[i]);
}
TEST(DecodeMbAuxTest, TestDequant_4x4_luma_dc) {
short T[16],W[16];
srand((uint32_t)time(NULL));
TEST (DecodeMbAuxTest, TestDequant_4x4_luma_dc) {
short T[16], W[16];
srand ((uint32_t)time (NULL));
for (int qp=0; qp<12; qp++) {
for(int i=0; i<16; i++) {
T[i]=rand()%256+1;
W[i]=T[i];
for (int qp = 0; qp < 12; qp++) {
for (int i = 0; i < 16; i++) {
T[i] = rand() % 256 + 1;
W[i] = T[i];
}
WelsDequantLumaDc4x4(W,qp);
for(int i=0; i<16; i++) {
T[i]= (((T[i]*g_kuiDequantCoeff[qp%6][0]+(1 << (1 - qp / 6))))>>(2- qp / 6));
EXPECT_EQ(T[i],W[i]);
WelsDequantLumaDc4x4 (W, qp);
for (int i = 0; i < 16; i++) {
T[i] = (((T[i] * g_kuiDequantCoeff[qp % 6][0] + (1 << (1 - qp / 6)))) >> (2 - qp / 6));
EXPECT_EQ (T[i], W[i]);
}
}
}
TEST(DecodeMbAuxTest, TestDequant_ihdm_4x4_c) {
short W[16],T[16],Y[16];
srand((uint32_t)time(NULL));
const unsigned short mf=rand()%16+1;
for(int i=0;i<16;i++)
W[i]=rand()%256+1;
TEST (DecodeMbAuxTest, TestDequant_ihdm_4x4_c) {
short W[16], T[16], Y[16];
srand ((uint32_t)time (NULL));
const unsigned short mf = rand() % 16 + 1;
for (int i = 0; i < 16; i++)
W[i] = rand() % 256 + 1;
T[0]=W[0]+W[4]+W[8]+W[12];
T[1]=W[1]+W[5]+W[9]+W[13];
T[2]=W[2]+W[6]+W[10]+W[14];
T[3]=W[3]+W[7]+W[11]+W[15];
T[0] = W[0] + W[4] + W[8] + W[12];
T[1] = W[1] + W[5] + W[9] + W[13];
T[2] = W[2] + W[6] + W[10] + W[14];
T[3] = W[3] + W[7] + W[11] + W[15];
T[4]=W[0]+W[4]-W[8]-W[12];
T[5]=W[1]+W[5]-W[9]-W[13];
T[6]=W[2]+W[6]-W[10]-W[14];
T[7]=W[3]+W[7]-W[11]-W[15];
T[4] = W[0] + W[4] - W[8] - W[12];
T[5] = W[1] + W[5] - W[9] - W[13];
T[6] = W[2] + W[6] - W[10] - W[14];
T[7] = W[3] + W[7] - W[11] - W[15];
T[8]=W[0]-W[4]-W[8]+W[12];
T[9]=W[1]-W[5]-W[9]+W[13];
T[10]=W[2]-W[6]-W[10]+W[14];
T[11]=W[3]-W[7]-W[11]+W[15];
T[8] = W[0] - W[4] - W[8] + W[12];
T[9] = W[1] - W[5] - W[9] + W[13];
T[10] = W[2] - W[6] - W[10] + W[14];
T[11] = W[3] - W[7] - W[11] + W[15];
T[12]=W[0]-W[4]+W[8]-W[12];
T[13]=W[1]-W[5]+W[9]-W[13];
T[14]=W[2]-W[6]+W[10]-W[14];
T[15]=W[3]-W[7]+W[11]-W[15];
T[12] = W[0] - W[4] + W[8] - W[12];
T[13] = W[1] - W[5] + W[9] - W[13];
T[14] = W[2] - W[6] + W[10] - W[14];
T[15] = W[3] - W[7] + W[11] - W[15];
Y[0]=(T[0]+T[1]+T[2]+T[3])*mf;
Y[1]=(T[0]+T[1]-T[2]-T[3])*mf;
Y[2]=(T[0]-T[1]-T[2]+T[3])*mf;
Y[3]=(T[0]-T[1]+T[2]-T[3])*mf;
Y[0] = (T[0] + T[1] + T[2] + T[3]) * mf;
Y[1] = (T[0] + T[1] - T[2] - T[3]) * mf;
Y[2] = (T[0] - T[1] - T[2] + T[3]) * mf;
Y[3] = (T[0] - T[1] + T[2] - T[3]) * mf;
Y[4]=(T[4]+T[5]+T[6]+T[7])*mf;
Y[5]=(T[4]+T[5]-T[6]-T[7])*mf;
Y[6]=(T[4]-T[5]-T[6]+T[7])*mf;
Y[7]=(T[4]-T[5]+T[6]-T[7])*mf;
Y[4] = (T[4] + T[5] + T[6] + T[7]) * mf;
Y[5] = (T[4] + T[5] - T[6] - T[7]) * mf;
Y[6] = (T[4] - T[5] - T[6] + T[7]) * mf;
Y[7] = (T[4] - T[5] + T[6] - T[7]) * mf;
Y[8]=(T[8]+T[9]+T[10]+T[11])*mf;
Y[9]=(T[8]+T[9]-T[10]-T[11])*mf;
Y[10]=(T[8]-T[9]-T[10]+T[11])*mf;
Y[11]=(T[8]-T[9]+T[10]-T[11])*mf;
Y[8] = (T[8] + T[9] + T[10] + T[11]) * mf;
Y[9] = (T[8] + T[9] - T[10] - T[11]) * mf;
Y[10] = (T[8] - T[9] - T[10] + T[11]) * mf;
Y[11] = (T[8] - T[9] + T[10] - T[11]) * mf;
Y[12]=(T[12]+T[13]+T[14]+T[15])*mf;
Y[13]=(T[12]+T[13]-T[14]-T[15])*mf;
Y[14]=(T[12]-T[13]-T[14]+T[15])*mf;
Y[15]=(T[12]-T[13]+T[14]-T[15])*mf;
Y[12] = (T[12] + T[13] + T[14] + T[15]) * mf;
Y[13] = (T[12] + T[13] - T[14] - T[15]) * mf;
Y[14] = (T[12] - T[13] - T[14] + T[15]) * mf;
Y[15] = (T[12] - T[13] + T[14] - T[15]) * mf;
WelsDequantIHadamard4x4_c(W,mf);
for(int i=0;i<16;i++)
EXPECT_EQ( Y[i],W[i] );
WelsDequantIHadamard4x4_c (W, mf);
for (int i = 0; i < 16; i++)
EXPECT_EQ (Y[i], W[i]);
}
TEST(DecodeMbAuxTest, TestDequant_4x4_c) {
TEST (DecodeMbAuxTest, TestDequant_4x4_c) {
short W[16], T[16];
unsigned short mf[16];
srand((uint32_t)time(NULL));
for(int i=0;i<16;i++) {
W[i]=rand()%256+1;
T[i]=W[i];
srand ((uint32_t)time (NULL));
for (int i = 0; i < 16; i++) {
W[i] = rand() % 256 + 1;
T[i] = W[i];
}
for(int i=0;i<8;i++)
mf[i]=rand()%16+1;
WelsDequant4x4_c(W,mf);
for(int i=0;i<16;i++)
EXPECT_EQ( T[i]*mf[i%8],W[i] );
for (int i = 0; i < 8; i++)
mf[i] = rand() % 16 + 1;
WelsDequant4x4_c (W, mf);
for (int i = 0; i < 16; i++)
EXPECT_EQ (T[i]*mf[i % 8], W[i]);
}
TEST(DecodeMbAuxTest, TestDequant_4_4x4_c) {
TEST (DecodeMbAuxTest, TestDequant_4_4x4_c) {
short W[64], T[64];
unsigned short mf[16];
srand((uint32_t)time(NULL));
for(int i=0;i<64;i++) {
W[i]=rand()%256+1;
T[i]=W[i];
srand ((uint32_t)time (NULL));
for (int i = 0; i < 64; i++) {
W[i] = rand() % 256 + 1;
T[i] = W[i];
}
for(int i=0;i<8;i++)
mf[i]=rand()%16+1;
WelsDequantFour4x4_c(W,mf);
for(int i=0;i<64;i++)
EXPECT_EQ( T[i]*mf[i%8],W[i] );
for (int i = 0; i < 8; i++)
mf[i] = rand() % 16 + 1;
WelsDequantFour4x4_c (W, mf);
for (int i = 0; i < 64; i++)
EXPECT_EQ (T[i]*mf[i % 8], W[i]);
}
void WelsDequantHadamard2x2DcAnchor( int16_t* pDct, int16_t iMF) {
void WelsDequantHadamard2x2DcAnchor (int16_t* pDct, int16_t iMF) {
const int16_t iSumU = pDct[0] + pDct[2];
const int16_t iDelU = pDct[0] - pDct[2];
const int16_t iSumD = pDct[1] + pDct[3];
@ -168,220 +168,223 @@ void WelsDequantHadamard2x2DcAnchor( int16_t* pDct, int16_t iMF) {
pDct[2] = (iDelU + iDelD) * iMF;
pDct[3] = (iDelU - iDelD) * iMF;
}
TEST(DecodeMbAuxTest, WelsDequantIHadamard2x2Dc) {
TEST (DecodeMbAuxTest, WelsDequantIHadamard2x2Dc) {
int16_t iDct[4], iRefDct[4];
int16_t iMF;
srand((unsigned int)time(NULL));
srand ((unsigned int)time (NULL));
iMF = rand() & 127;
for(int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
iDct[i] = iRefDct[i] = (rand() & 65535) - 32768;
WelsDequantHadamard2x2DcAnchor(iRefDct, iMF);
WelsDequantIHadamard2x2Dc(iDct, iMF);
WelsDequantHadamard2x2DcAnchor (iRefDct, iMF);
WelsDequantIHadamard2x2Dc (iDct, iMF);
bool ok = true;
for(int i = 0; i < 4; i++) {
if(iDct[i] != iRefDct[i]) {
for (int i = 0; i < 4; i++) {
if (iDct[i] != iRefDct[i]) {
ok = false;
break;
}
}
EXPECT_TRUE(ok);
EXPECT_TRUE (ok);
}
#define FDEC_STRIDE 32
void WelsIDctT4Anchor( uint8_t *p_dst, int16_t dct[16] ) {
void WelsIDctT4Anchor (uint8_t* p_dst, int16_t dct[16]) {
int16_t tmp[16];
int32_t iStridex2 = (FDEC_STRIDE<<1);
int32_t iStridex2 = (FDEC_STRIDE << 1);
int32_t iStridex3 = iStridex2 + FDEC_STRIDE;
uint8_t uiDst = 0;
int i;
for( i = 0; i < 4; i++ ) {
tmp[i<<2] = dct[i<<2] + dct[(i<<2)+1] + dct[(i<<2)+2] + (dct[(i<<2)+3]>>1);
tmp[(i<<2)+1] = dct[i<<2] + (dct[(i<<2)+1]>>1) - dct[(i<<2)+2] - dct[(i<<2)+3];
tmp[(i<<2)+2] = dct[i<<2] - (dct[(i<<2)+1]>>1) - dct[(i<<2)+2] + dct[(i<<2)+3];
tmp[(i<<2)+3] = dct[i<<2] - dct[(i<<2)+1] + dct[(i<<2)+2] - (dct[(i<<2)+3]>>1);
for (i = 0; i < 4; i++) {
tmp[i << 2] = dct[i << 2] + dct[ (i << 2) + 1] + dct[ (i << 2) + 2] + (dct[ (i << 2) + 3] >> 1);
tmp[ (i << 2) + 1] = dct[i << 2] + (dct[ (i << 2) + 1] >> 1) - dct[ (i << 2) + 2] - dct[ (i << 2) + 3];
tmp[ (i << 2) + 2] = dct[i << 2] - (dct[ (i << 2) + 1] >> 1) - dct[ (i << 2) + 2] + dct[ (i << 2) + 3];
tmp[ (i << 2) + 3] = dct[i << 2] - dct[ (i << 2) + 1] + dct[ (i << 2) + 2] - (dct[ (i << 2) + 3] >> 1);
}
for( i = 0; i < 4; i++ ) {
for (i = 0; i < 4; i++) {
uiDst = p_dst[i];
p_dst[i] = WelsClip1(uiDst + ((tmp[i]+tmp[4+i]+ tmp[8+i]+(tmp[12+i]>>1)+32)>>6));
uiDst = p_dst[i+FDEC_STRIDE];
p_dst[i+FDEC_STRIDE] = WelsClip1(uiDst + ((tmp[i]+(tmp[4+i]>>1)-tmp[8+i]-tmp[12+i]+32) >>6));
uiDst = p_dst[i+iStridex2];
p_dst[i+iStridex2] = WelsClip1(uiDst + ((tmp[i]-(tmp[4+i]>>1)-tmp[8+i]+tmp[12+i]+32) >>6));
uiDst = p_dst[i+iStridex3];
p_dst[i+iStridex3] = WelsClip1(uiDst + ((tmp[i]-tmp[4+i]+ tmp[8+i]-(tmp[12+i]>>1)+32)>>6));
p_dst[i] = WelsClip1 (uiDst + ((tmp[i] + tmp[4 + i] + tmp[8 + i] + (tmp[12 + i] >> 1) + 32) >> 6));
uiDst = p_dst[i + FDEC_STRIDE];
p_dst[i + FDEC_STRIDE] = WelsClip1 (uiDst + ((tmp[i] + (tmp[4 + i] >> 1) - tmp[8 + i] - tmp[12 + i] + 32) >> 6));
uiDst = p_dst[i + iStridex2];
p_dst[i + iStridex2] = WelsClip1 (uiDst + ((tmp[i] - (tmp[4 + i] >> 1) - tmp[8 + i] + tmp[12 + i] + 32) >> 6));
uiDst = p_dst[i + iStridex3];
p_dst[i + iStridex3] = WelsClip1 (uiDst + ((tmp[i] - tmp[4 + i] + tmp[8 + i] - (tmp[12 + i] >> 1) + 32) >> 6));
}
}
TEST(DecodeMbAuxTest, WelsIDctT4Rec_c) {
int16_t iRefDct[16]; uint8_t iRefDst[16*FDEC_STRIDE];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16*FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16*FDEC_STRIDE, 16);
srand((unsigned int)time(NULL));
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
iRefDct[i*4+j] = iDct[i*4+j] = (rand() & 65535) - 32768;
iPred[i*FDEC_STRIDE+j] = iRefDst[i*FDEC_STRIDE+j] = rand() & 255;
TEST (DecodeMbAuxTest, WelsIDctT4Rec_c) {
int16_t iRefDct[16];
uint8_t iRefDst[16 * FDEC_STRIDE];
ENFORCE_STACK_ALIGN_1D (int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iRec, 16 * FDEC_STRIDE, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
iRefDct[i * 4 + j] = iDct[i * 4 + j] = (rand() & 65535) - 32768;
iPred[i * FDEC_STRIDE + j] = iRefDst[i * FDEC_STRIDE + j] = rand() & 255;
}
}
WelsIDctT4Anchor(iRefDst, iRefDct);
WelsIDctT4Rec_c(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
WelsIDctT4Anchor (iRefDst, iRefDct);
WelsIDctT4Rec_c (iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
if(iRec[i*FDEC_STRIDE+j] != iRefDst[i*FDEC_STRIDE+j]) {
ok = i*4+j;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 4 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
EXPECT_EQ (ok, -1);
}
#if defined(X86_ASM)
TEST(DecodeMbAuxTest, WelsIDctT4Rec_mmx) {
TEST (DecodeMbAuxTest, WelsIDctT4Rec_mmx) {
int32_t iCpuCores = 0;
uint32_t uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores);
if(uiCpuFeatureFlag & WELS_CPU_MMXEXT) {
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16*FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRecC, 16*FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRecM, 16*FDEC_STRIDE, 16);
srand((unsigned int)time(NULL));
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
iDct[i*4+j] = (rand() & ((1 << 12)-1)) - (1 << 11);
iPred[i*FDEC_STRIDE+j] = rand() & 255;
uint32_t uiCpuFeatureFlag = WelsCPUFeatureDetect (&iCpuCores);
if (uiCpuFeatureFlag & WELS_CPU_MMXEXT) {
ENFORCE_STACK_ALIGN_1D (int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iRecC, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iRecM, 16 * FDEC_STRIDE, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
iDct[i * 4 + j] = (rand() & ((1 << 12) - 1)) - (1 << 11);
iPred[i * FDEC_STRIDE + j] = rand() & 255;
}
}
WelsIDctT4Rec_c(iRecC, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
WelsIDctT4Rec_mmx(iRecM, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
WelsIDctT4Rec_c (iRecC, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
WelsIDctT4Rec_mmx (iRecM, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
if(iRecC[i*FDEC_STRIDE+j] != iRecM[i*FDEC_STRIDE+j]) {
ok = i*4+j;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (iRecC[i * FDEC_STRIDE + j] != iRecM[i * FDEC_STRIDE + j]) {
ok = i * 4 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
EXPECT_EQ (ok, -1);
}
}
#endif
void WelsIDctT8Anchor( uint8_t *p_dst, int16_t dct[4][16] ) {
WelsIDctT4Anchor( &p_dst[0], dct[0] );
WelsIDctT4Anchor( &p_dst[4], dct[1] );
WelsIDctT4Anchor( &p_dst[4*FDEC_STRIDE+0], dct[2] );
WelsIDctT4Anchor( &p_dst[4*FDEC_STRIDE+4], dct[3] );
void WelsIDctT8Anchor (uint8_t* p_dst, int16_t dct[4][16]) {
WelsIDctT4Anchor (&p_dst[0], dct[0]);
WelsIDctT4Anchor (&p_dst[4], dct[1]);
WelsIDctT4Anchor (&p_dst[4 * FDEC_STRIDE + 0], dct[2]);
WelsIDctT4Anchor (&p_dst[4 * FDEC_STRIDE + 4], dct[3]);
}
TEST(DecodeMbAuxTest, WelsIDctFourT4Rec_c) {
int16_t iRefDct[4][16]; uint8_t iRefDst[16*FDEC_STRIDE];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 64, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16*FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16*FDEC_STRIDE, 16);
srand((unsigned int)time(NULL));
for(int k = 0; k < 4; k++)
for(int i = 0; i < 16; i++)
iRefDct[k][i] = iDct[k*16+i] = (rand() & 65535) - 32768;
TEST (DecodeMbAuxTest, WelsIDctFourT4Rec_c) {
int16_t iRefDct[4][16];
uint8_t iRefDst[16 * FDEC_STRIDE];
ENFORCE_STACK_ALIGN_1D (int16_t, iDct, 64, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iRec, 16 * FDEC_STRIDE, 16);
srand ((unsigned int)time (NULL));
for (int k = 0; k < 4; k++)
for (int i = 0; i < 16; i++)
iRefDct[k][i] = iDct[k * 16 + i] = (rand() & 65535) - 32768;
for(int i = 0; i < 8; i++)
for(int j = 0; j < 8; j++)
iPred[i*FDEC_STRIDE+j] = iRefDst[i*FDEC_STRIDE+j] = rand() & 255;
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
iPred[i * FDEC_STRIDE + j] = iRefDst[i * FDEC_STRIDE + j] = rand() & 255;
WelsIDctT8Anchor(iRefDst, iRefDct);
WelsIDctFourT4Rec_c(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
WelsIDctT8Anchor (iRefDst, iRefDct);
WelsIDctFourT4Rec_c (iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {
if(iRec[i*FDEC_STRIDE+j] != iRefDst[i*FDEC_STRIDE+j]) {
ok = i*8+j;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 8 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
EXPECT_EQ (ok, -1);
}
void WelsIDctRecI16x4DcAnchor( uint8_t *p_dst, int16_t dct[4] ) {
for(int i = 0; i < 4; i++, p_dst += FDEC_STRIDE) {
p_dst[0] = WelsClip1(p_dst[0] + ((dct[0]+32)>>6));
p_dst[1] = WelsClip1(p_dst[1] + ((dct[0]+32)>>6));
p_dst[2] = WelsClip1(p_dst[2] + ((dct[0]+32)>>6));
p_dst[3] = WelsClip1(p_dst[3] + ((dct[0]+32)>>6));
void WelsIDctRecI16x4DcAnchor (uint8_t* p_dst, int16_t dct[4]) {
for (int i = 0; i < 4; i++, p_dst += FDEC_STRIDE) {
p_dst[0] = WelsClip1 (p_dst[0] + ((dct[0] + 32) >> 6));
p_dst[1] = WelsClip1 (p_dst[1] + ((dct[0] + 32) >> 6));
p_dst[2] = WelsClip1 (p_dst[2] + ((dct[0] + 32) >> 6));
p_dst[3] = WelsClip1 (p_dst[3] + ((dct[0] + 32) >> 6));
p_dst[4] = WelsClip1(p_dst[4] + ((dct[1]+32)>>6));
p_dst[5] = WelsClip1(p_dst[5] + ((dct[1]+32)>>6));
p_dst[6] = WelsClip1(p_dst[6] + ((dct[1]+32)>>6));
p_dst[7] = WelsClip1(p_dst[7] + ((dct[1]+32)>>6));
p_dst[4] = WelsClip1 (p_dst[4] + ((dct[1] + 32) >> 6));
p_dst[5] = WelsClip1 (p_dst[5] + ((dct[1] + 32) >> 6));
p_dst[6] = WelsClip1 (p_dst[6] + ((dct[1] + 32) >> 6));
p_dst[7] = WelsClip1 (p_dst[7] + ((dct[1] + 32) >> 6));
p_dst[8] = WelsClip1(p_dst[8] + ((dct[2]+32)>>6));
p_dst[9] = WelsClip1(p_dst[9] + ((dct[2]+32)>>6));
p_dst[10] = WelsClip1(p_dst[10] + ((dct[2]+32)>>6));
p_dst[11] = WelsClip1(p_dst[11] + ((dct[2]+32)>>6));
p_dst[8] = WelsClip1 (p_dst[8] + ((dct[2] + 32) >> 6));
p_dst[9] = WelsClip1 (p_dst[9] + ((dct[2] + 32) >> 6));
p_dst[10] = WelsClip1 (p_dst[10] + ((dct[2] + 32) >> 6));
p_dst[11] = WelsClip1 (p_dst[11] + ((dct[2] + 32) >> 6));
p_dst[12] = WelsClip1(p_dst[12] + ((dct[3]+32)>>6));
p_dst[13] = WelsClip1(p_dst[13] + ((dct[3]+32)>>6));
p_dst[14] = WelsClip1(p_dst[14] + ((dct[3]+32)>>6));
p_dst[15] = WelsClip1(p_dst[15] + ((dct[3]+32)>>6));
p_dst[12] = WelsClip1 (p_dst[12] + ((dct[3] + 32) >> 6));
p_dst[13] = WelsClip1 (p_dst[13] + ((dct[3] + 32) >> 6));
p_dst[14] = WelsClip1 (p_dst[14] + ((dct[3] + 32) >> 6));
p_dst[15] = WelsClip1 (p_dst[15] + ((dct[3] + 32) >> 6));
}
}
void WelsIDctRecI16x16DcAnchor( uint8_t *p_dst, int16_t dct[4][4] ) {
for( int i = 0; i < 4; i++, p_dst += 4*FDEC_STRIDE )
WelsIDctRecI16x4DcAnchor(&p_dst[0], dct[i]);
void WelsIDctRecI16x16DcAnchor (uint8_t* p_dst, int16_t dct[4][4]) {
for (int i = 0; i < 4; i++, p_dst += 4 * FDEC_STRIDE)
WelsIDctRecI16x4DcAnchor (&p_dst[0], dct[i]);
}
TEST(DecodeMbAuxTest, WelsIDctRecI16x16Dc_c) {
uint8_t iRefDst[16*FDEC_STRIDE];
TEST (DecodeMbAuxTest, WelsIDctRecI16x16Dc_c) {
uint8_t iRefDst[16 * FDEC_STRIDE];
int16_t iRefDct[4][4];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16*FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16*FDEC_STRIDE, 16);
for(int i = 0; i < 16; i++)
for(int j = 0; j < 16; j++)
iRefDst[i*FDEC_STRIDE+j] = iPred[i*FDEC_STRIDE+j] = rand() & 255;
ENFORCE_STACK_ALIGN_1D (int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iRec, 16 * FDEC_STRIDE, 16);
for (int i = 0; i < 16; i++)
for (int j = 0; j < 16; j++)
iRefDst[i * FDEC_STRIDE + j] = iPred[i * FDEC_STRIDE + j] = rand() & 255;
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
iRefDct[i][j] = iDct[i*4+j] = (rand() & 65535) - 32768;
WelsIDctRecI16x16DcAnchor(iRefDst, iRefDct);
WelsIDctRecI16x16Dc_c(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
iRefDct[i][j] = iDct[i * 4 + j] = (rand() & 65535) - 32768;
WelsIDctRecI16x16DcAnchor (iRefDst, iRefDct);
WelsIDctRecI16x16Dc_c (iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for(int i = 0; i < 16; i++) {
for(int j = 0; j < 16; j++) {
if(iRec[i*FDEC_STRIDE+j] != iRefDst[i*FDEC_STRIDE+j]) {
ok = i*16+j;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 16 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
EXPECT_EQ (ok, -1);
}
#if defined(X86_ASM)
TEST(DecodeMbAuxTest, WelsIDctRecI16x16Dc_sse2) {
TEST (DecodeMbAuxTest, WelsIDctRecI16x16Dc_sse2) {
int32_t iCpuCores = 0;
uint32_t uiCpuFeatureFlag = WelsCPUFeatureDetect(&iCpuCores);
uint32_t uiCpuFeatureFlag = WelsCPUFeatureDetect (&iCpuCores);
if(uiCpuFeatureFlag & WELS_CPU_SSE2) {
uint8_t iRefDst[16*FDEC_STRIDE];
if (uiCpuFeatureFlag & WELS_CPU_SSE2) {
uint8_t iRefDst[16 * FDEC_STRIDE];
int16_t iRefDct[4][4];
ENFORCE_STACK_ALIGN_1D(int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iPred, 16*FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D(uint8_t, iRec, 16*FDEC_STRIDE, 16);
for(int i = 0; i < 16; i++)
for(int j = 0; j < 16; j++)
iRefDst[i*FDEC_STRIDE+j] = iPred[i*FDEC_STRIDE+j] = rand() & 255;
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
iRefDct[i][j] = iDct[i*4+j] = (rand() & ((1<<15)-1)) - (1<<14); //2^14 limit, (2^15+32) will cause overflow for SSE2.
WelsIDctRecI16x16DcAnchor(iRefDst, iRefDct);
WelsIDctRecI16x16Dc_sse2(iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
ENFORCE_STACK_ALIGN_1D (int16_t, iDct, 16, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iPred, 16 * FDEC_STRIDE, 16);
ENFORCE_STACK_ALIGN_1D (uint8_t, iRec, 16 * FDEC_STRIDE, 16);
for (int i = 0; i < 16; i++)
for (int j = 0; j < 16; j++)
iRefDst[i * FDEC_STRIDE + j] = iPred[i * FDEC_STRIDE + j] = rand() & 255;
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
iRefDct[i][j] = iDct[i * 4 + j] = (rand() & ((1 << 15) - 1)) - (1 <<
14); //2^14 limit, (2^15+32) will cause overflow for SSE2.
WelsIDctRecI16x16DcAnchor (iRefDst, iRefDct);
WelsIDctRecI16x16Dc_sse2 (iRec, FDEC_STRIDE, iPred, FDEC_STRIDE, iDct);
int ok = -1;
for(int i = 0; i < 16; i++) {
for(int j = 0; j < 16; j++) {
if(iRec[i*FDEC_STRIDE+j] != iRefDst[i*FDEC_STRIDE+j]) {
ok = i*16+j;
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
if (iRec[i * FDEC_STRIDE + j] != iRefDst[i * FDEC_STRIDE + j]) {
ok = i * 16 + j;
break;
}
}
}
EXPECT_EQ(ok, -1);
EXPECT_EQ (ok, -1);
}
}
#endif

View File

@ -6,195 +6,195 @@
using namespace WelsSVCEnc;
#include "encode_mb_aux.h"
__align16( const int16_t, g_kiQuantInterFFCompare[104][8] ) = {
/* 0*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
/* 1*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
/* 2*/ { 1, 1, 1, 1, 1, 1, 1, 1 },
/* 3*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 4*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 5*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 6*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 7*/ { 1, 2, 1, 2, 2, 2, 2, 2 },
/* 8*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 9*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/*10*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/*11*/ { 2, 2, 2, 2, 2, 4, 2, 4 },
/*12*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
/*13*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/*14*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/*15*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
/*16*/ { 3, 4, 3, 4, 4, 7, 4, 7 },
/*17*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
/*18*/ { 3, 6, 3, 6, 6, 9, 6, 9 },
/*19*/ { 4, 6, 4, 6, 6, 10, 6, 10 },
/*20*/ { 4, 7, 4, 7, 7, 11, 7, 11 },
/*21*/ { 5, 8, 5, 8, 8, 12, 8, 12 },
/*22*/ { 6, 9, 6, 9, 9, 13, 9, 13 },
/*23*/ { 6, 10, 6, 10, 10, 16, 10, 16 },
/*24*/ { 7, 11, 7, 11, 11, 17, 11, 17 },
/*25*/ { 8, 12, 8, 12, 12, 19, 12, 19 },
/*26*/ { 9, 14, 9, 14, 14, 21, 14, 21 },
/*27*/ { 10, 15, 10, 15, 15, 25, 15, 25 },
/*28*/ { 11, 17, 11, 17, 17, 27, 17, 27 },
/*29*/ { 12, 20, 12, 20, 20, 31, 20, 31 },
/*30*/ { 14, 22, 14, 22, 22, 34, 22, 34 },
/*31*/ { 15, 24, 15, 24, 24, 39, 24, 39 },
/*32*/ { 18, 27, 18, 27, 27, 43, 27, 43 },
/*33*/ { 19, 31, 19, 31, 31, 49, 31, 49 },
/*34*/ { 22, 34, 22, 34, 34, 54, 34, 54 },
/*35*/ { 25, 40, 25, 40, 40, 62, 40, 62 },
/*36*/ { 27, 45, 27, 45, 45, 69, 45, 69 },
/*37*/ { 30, 48, 30, 48, 48, 77, 48, 77 },
/*38*/ { 36, 55, 36, 55, 55, 86, 55, 86 },
/*39*/ { 38, 62, 38, 62, 62, 99, 62, 99 },
/*40*/ { 44, 69, 44, 69, 69, 107, 69, 107 },
/*41*/ { 49, 79, 49, 79, 79, 125, 79, 125 },
/*42*/ { 55, 89, 55, 89, 89, 137, 89, 137 },
/*43*/ { 61, 96, 61, 96, 96, 154, 96, 154 },
/*44*/ { 71, 110, 71, 110, 110, 171, 110, 171 },
/*45*/ { 77, 124, 77, 124, 124, 198, 124, 198 },
/*46*/ { 88, 137, 88, 137, 137, 217, 137, 217 },
/*47*/ { 99, 159, 99, 159, 159, 250, 159, 250 },
/*48*/ { 110, 179, 110, 179, 179, 275, 179, 275 },
/*49*/ { 121, 191, 121, 191, 191, 313, 191, 313 },
/*50*/ { 143, 221, 143, 221, 221, 341, 221, 341 },
/*51*/ { 154, 245, 154, 245, 245, 402, 245, 402 },
__align16 (const int16_t, g_kiQuantInterFFCompare[104][8]) = {
/* 0*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
/* 1*/ { 0, 1, 0, 1, 1, 1, 1, 1 },
/* 2*/ { 1, 1, 1, 1, 1, 1, 1, 1 },
/* 3*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 4*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 5*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 6*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 7*/ { 1, 2, 1, 2, 2, 2, 2, 2 },
/* 8*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 9*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/*10*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/*11*/ { 2, 2, 2, 2, 2, 4, 2, 4 },
/*12*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
/*13*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/*14*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/*15*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
/*16*/ { 3, 4, 3, 4, 4, 7, 4, 7 },
/*17*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
/*18*/ { 3, 6, 3, 6, 6, 9, 6, 9 },
/*19*/ { 4, 6, 4, 6, 6, 10, 6, 10 },
/*20*/ { 4, 7, 4, 7, 7, 11, 7, 11 },
/*21*/ { 5, 8, 5, 8, 8, 12, 8, 12 },
/*22*/ { 6, 9, 6, 9, 9, 13, 9, 13 },
/*23*/ { 6, 10, 6, 10, 10, 16, 10, 16 },
/*24*/ { 7, 11, 7, 11, 11, 17, 11, 17 },
/*25*/ { 8, 12, 8, 12, 12, 19, 12, 19 },
/*26*/ { 9, 14, 9, 14, 14, 21, 14, 21 },
/*27*/ { 10, 15, 10, 15, 15, 25, 15, 25 },
/*28*/ { 11, 17, 11, 17, 17, 27, 17, 27 },
/*29*/ { 12, 20, 12, 20, 20, 31, 20, 31 },
/*30*/ { 14, 22, 14, 22, 22, 34, 22, 34 },
/*31*/ { 15, 24, 15, 24, 24, 39, 24, 39 },
/*32*/ { 18, 27, 18, 27, 27, 43, 27, 43 },
/*33*/ { 19, 31, 19, 31, 31, 49, 31, 49 },
/*34*/ { 22, 34, 22, 34, 34, 54, 34, 54 },
/*35*/ { 25, 40, 25, 40, 40, 62, 40, 62 },
/*36*/ { 27, 45, 27, 45, 45, 69, 45, 69 },
/*37*/ { 30, 48, 30, 48, 48, 77, 48, 77 },
/*38*/ { 36, 55, 36, 55, 55, 86, 55, 86 },
/*39*/ { 38, 62, 38, 62, 62, 99, 62, 99 },
/*40*/ { 44, 69, 44, 69, 69, 107, 69, 107 },
/*41*/ { 49, 79, 49, 79, 79, 125, 79, 125 },
/*42*/ { 55, 89, 55, 89, 89, 137, 89, 137 },
/*43*/ { 61, 96, 61, 96, 96, 154, 96, 154 },
/*44*/ { 71, 110, 71, 110, 110, 171, 110, 171 },
/*45*/ { 77, 124, 77, 124, 124, 198, 124, 198 },
/*46*/ { 88, 137, 88, 137, 137, 217, 137, 217 },
/*47*/ { 99, 159, 99, 159, 159, 250, 159, 250 },
/*48*/ { 110, 179, 110, 179, 179, 275, 179, 275 },
/*49*/ { 121, 191, 121, 191, 191, 313, 191, 313 },
/*50*/ { 143, 221, 143, 221, 221, 341, 221, 341 },
/*51*/ { 154, 245, 154, 245, 245, 402, 245, 402 },
//from here below is intra
/* 0*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 1*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 2*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 3*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 4*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 5*/ { 1, 2, 1, 2, 2, 4, 2, 4 },
/* 6*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
/* 7*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/* 8*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/* 9*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
/*10*/ { 3, 4, 3, 4, 4, 6, 4, 6 },
/*11*/ { 3, 5, 3, 5, 5, 7, 5, 7 },
/*12*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
/*13*/ { 4, 6, 4, 6, 6, 9, 6, 9 },
/*14*/ { 4, 7, 4, 7, 7, 10, 7, 10 },
/*15*/ { 5, 7, 5, 7, 7, 12, 7, 12 },
/*16*/ { 5, 8, 5, 8, 8, 13, 8, 13 },
/*17*/ { 6, 9, 6, 9, 9, 15, 9, 15 },
/*18*/ { 7, 11, 7, 11, 11, 16, 11, 16 },
/*19*/ { 7, 11, 7, 11, 11, 18, 11, 18 },
/*20*/ { 9, 13, 9, 13, 13, 20, 13, 20 },
/*21*/ { 9, 15, 9, 15, 15, 24, 15, 24 },
/*22*/ { 11, 16, 11, 16, 16, 26, 16, 26 },
/*23*/ { 12, 19, 12, 19, 19, 30, 19, 30 },
/*24*/ { 13, 21, 13, 21, 21, 33, 21, 33 },
/*25*/ { 14, 23, 14, 23, 23, 37, 23, 37 },
/*26*/ { 17, 26, 17, 26, 26, 41, 26, 41 },
/*27*/ { 18, 30, 18, 30, 30, 47, 30, 47 },
/*28*/ { 21, 33, 21, 33, 33, 51, 33, 51 },
/*29*/ { 24, 38, 24, 38, 38, 59, 38, 59 },
/*30*/ { 26, 43, 26, 43, 43, 66, 43, 66 },
/*31*/ { 29, 46, 29, 46, 46, 74, 46, 74 },
/*32*/ { 34, 52, 34, 52, 52, 82, 52, 82 },
/*33*/ { 37, 59, 37, 59, 59, 94, 59, 94 },
/*34*/ { 42, 66, 42, 66, 66, 102, 66, 102 },
/*35*/ { 47, 75, 47, 75, 75, 119, 75, 119 },
/*36*/ { 52, 85, 52, 85, 85, 131, 85, 131 },
/*37*/ { 58, 92, 58, 92, 92, 147, 92, 147 },
/*38*/ { 68, 105, 68, 105, 105, 164, 105, 164 },
/*39*/ { 73, 118, 73, 118, 118, 189, 118, 189 },
/*40*/ { 84, 131, 84, 131, 131, 205, 131, 205 },
/*41*/ { 94, 151, 94, 151, 151, 239, 151, 239 },
/*42*/ { 105, 171, 105, 171, 171, 262, 171, 262 },
/*43*/ { 116, 184, 116, 184, 184, 295, 184, 295 },
/*44*/ { 136, 211, 136, 211, 211, 326, 211, 326 },
/*45*/ { 147, 236, 147, 236, 236, 377, 236, 377 },
/*46*/ { 168, 262, 168, 262, 262, 414, 262, 414 },
/*47*/ { 189, 303, 189, 303, 303, 478, 303, 478 },
/*48*/ { 211, 341, 211, 341, 341, 524, 341, 524 },
/*49*/ { 231, 364, 231, 364, 364, 597, 364, 597 },
/*50*/ { 272, 422, 272, 422, 422, 652, 422, 652 },
/*51*/ { 295, 467, 295, 467, 467, 768, 467, 768 }
/* 0*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 1*/ { 1, 1, 1, 1, 1, 2, 1, 2 },
/* 2*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 3*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 4*/ { 1, 2, 1, 2, 2, 3, 2, 3 },
/* 5*/ { 1, 2, 1, 2, 2, 4, 2, 4 },
/* 6*/ { 2, 3, 2, 3, 3, 4, 3, 4 },
/* 7*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/* 8*/ { 2, 3, 2, 3, 3, 5, 3, 5 },
/* 9*/ { 2, 4, 2, 4, 4, 6, 4, 6 },
/*10*/ { 3, 4, 3, 4, 4, 6, 4, 6 },
/*11*/ { 3, 5, 3, 5, 5, 7, 5, 7 },
/*12*/ { 3, 5, 3, 5, 5, 8, 5, 8 },
/*13*/ { 4, 6, 4, 6, 6, 9, 6, 9 },
/*14*/ { 4, 7, 4, 7, 7, 10, 7, 10 },
/*15*/ { 5, 7, 5, 7, 7, 12, 7, 12 },
/*16*/ { 5, 8, 5, 8, 8, 13, 8, 13 },
/*17*/ { 6, 9, 6, 9, 9, 15, 9, 15 },
/*18*/ { 7, 11, 7, 11, 11, 16, 11, 16 },
/*19*/ { 7, 11, 7, 11, 11, 18, 11, 18 },
/*20*/ { 9, 13, 9, 13, 13, 20, 13, 20 },
/*21*/ { 9, 15, 9, 15, 15, 24, 15, 24 },
/*22*/ { 11, 16, 11, 16, 16, 26, 16, 26 },
/*23*/ { 12, 19, 12, 19, 19, 30, 19, 30 },
/*24*/ { 13, 21, 13, 21, 21, 33, 21, 33 },
/*25*/ { 14, 23, 14, 23, 23, 37, 23, 37 },
/*26*/ { 17, 26, 17, 26, 26, 41, 26, 41 },
/*27*/ { 18, 30, 18, 30, 30, 47, 30, 47 },
/*28*/ { 21, 33, 21, 33, 33, 51, 33, 51 },
/*29*/ { 24, 38, 24, 38, 38, 59, 38, 59 },
/*30*/ { 26, 43, 26, 43, 43, 66, 43, 66 },
/*31*/ { 29, 46, 29, 46, 46, 74, 46, 74 },
/*32*/ { 34, 52, 34, 52, 52, 82, 52, 82 },
/*33*/ { 37, 59, 37, 59, 59, 94, 59, 94 },
/*34*/ { 42, 66, 42, 66, 66, 102, 66, 102 },
/*35*/ { 47, 75, 47, 75, 75, 119, 75, 119 },
/*36*/ { 52, 85, 52, 85, 85, 131, 85, 131 },
/*37*/ { 58, 92, 58, 92, 92, 147, 92, 147 },
/*38*/ { 68, 105, 68, 105, 105, 164, 105, 164 },
/*39*/ { 73, 118, 73, 118, 118, 189, 118, 189 },
/*40*/ { 84, 131, 84, 131, 131, 205, 131, 205 },
/*41*/ { 94, 151, 94, 151, 151, 239, 151, 239 },
/*42*/ { 105, 171, 105, 171, 171, 262, 171, 262 },
/*43*/ { 116, 184, 116, 184, 184, 295, 184, 295 },
/*44*/ { 136, 211, 136, 211, 211, 326, 211, 326 },
/*45*/ { 147, 236, 147, 236, 236, 377, 236, 377 },
/*46*/ { 168, 262, 168, 262, 262, 414, 262, 414 },
/*47*/ { 189, 303, 189, 303, 303, 478, 303, 478 },
/*48*/ { 211, 341, 211, 341, 341, 524, 341, 524 },
/*49*/ { 231, 364, 231, 364, 364, 597, 364, 597 },
/*50*/ { 272, 422, 272, 422, 422, 652, 422, 652 },
/*51*/ { 295, 467, 295, 467, 467, 768, 467, 768 }
};
#define ThValue 2
void TestQuant(uint32_t qp,uint8_t *pSrc,uint8_t *pPred,int16_t *pDct,
int16_t *pDctCompare,int16_t iWidth,int16_t iHeight) {
const int16_t *pMf = g_kiQuantMF[qp];
const int16_t *pFfCompareI = g_kiQuantInterFFCompare[52 + qp];
const int16_t *pFfCompareP = g_kiQuantInterFFCompare[qp];
const int16_t *pFfI = g_kiQuantInterFF[6 + qp];
const int16_t *pFfP = g_kiQuantInterFF[qp];
void TestQuant (uint32_t qp, uint8_t* pSrc, uint8_t* pPred, int16_t* pDct,
int16_t* pDctCompare, int16_t iWidth, int16_t iHeight) {
const int16_t* pMf = g_kiQuantMF[qp];
const int16_t* pFfCompareI = g_kiQuantInterFFCompare[52 + qp];
const int16_t* pFfCompareP = g_kiQuantInterFFCompare[qp];
const int16_t* pFfI = g_kiQuantInterFF[6 + qp];
const int16_t* pFfP = g_kiQuantInterFF[qp];
//quant4x4 Intra MB
RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth, 0);
RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth, rand());
for (int16_t i = 0; i<16; i++) {
for (int16_t i = 0; i < 16; i++) {
pDct[i] = pSrc[i] - pPred[i];
pDctCompare[i] = pSrc[i] - pPred[i];
}
WelsQuant4x4_c(pDct,pFfI,pMf);
WelsQuant4x4_c(pDctCompare,pFfCompareI,pMf);
WelsQuant4x4_c (pDct, pFfI, pMf);
WelsQuant4x4_c (pDctCompare, pFfCompareI, pMf);
for (int16_t i = 0;i<16;i++) {
int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
for (int16_t i = 0; i < 16; i++) {
int16_t iDeta = WELS_ABS (pDct[i] - pDctCompare[i]);
iDeta = (iDeta < ThValue) ? 0 : iDeta;
EXPECT_EQ(iDeta,0);
EXPECT_EQ (iDeta, 0);
}
//quant4x4 DC
RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth, 0);
RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth, rand());
for (int16_t i = 0;i<16;i++) {
for (int16_t i = 0; i < 16; i++) {
pDct[i] = pSrc[i] - pPred[i];
pDctCompare[i] = pSrc[i] - pPred[i];
}
WelsQuant4x4Dc_c(pDct,pFfI[0]<<1,pMf[0]>>1);
WelsQuant4x4Dc_c(pDctCompare,pFfCompareI[0]<<1,pMf[0]>>1);
WelsQuant4x4Dc_c (pDct, pFfI[0] << 1, pMf[0]>>1);
WelsQuant4x4Dc_c (pDctCompare, pFfCompareI[0] << 1, pMf[0]>>1);
for (int16_t i = 0;i<16;i++) {
int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
for (int16_t i = 0; i < 16; i++) {
int16_t iDeta = WELS_ABS (pDct[i] - pDctCompare[i]);
iDeta = (iDeta < ThValue) ? 0 : iDeta;
EXPECT_EQ(iDeta,0);
EXPECT_EQ (iDeta, 0);
}
//quant4x4 Inter MB
RandomPixelDataGenerator(pSrc,iWidth,iHeight,iWidth,0);
RandomPixelDataGenerator(pPred,iWidth,iHeight,iWidth,rand());
RandomPixelDataGenerator (pSrc, iWidth, iHeight, iWidth, 0);
RandomPixelDataGenerator (pPred, iWidth, iHeight, iWidth, rand());
for (int16_t i = 0; i<64; i++) {
for (int16_t i = 0; i < 64; i++) {
pDct[i] = pSrc[i] - pPred[i];
pDctCompare[i] = pSrc[i] - pPred[i];
}
WelsQuantFour4x4_c(pDct,pFfP,pMf);
WelsQuantFour4x4_c(pDctCompare,pFfCompareP,pMf);
WelsQuantFour4x4_c (pDct, pFfP, pMf);
WelsQuantFour4x4_c (pDctCompare, pFfCompareP, pMf);
for (int16_t i = 0; i<64; i++) {
int16_t iDeta =WELS_ABS(pDct[i] - pDctCompare[i]);
iDeta = (iDeta <ThValue)?0:iDeta;
EXPECT_EQ(iDeta,0);
for (int16_t i = 0; i < 64; i++) {
int16_t iDeta = WELS_ABS (pDct[i] - pDctCompare[i]);
iDeta = (iDeta < ThValue) ? 0 : iDeta;
EXPECT_EQ (iDeta, 0);
}
}
TEST(EncoderMbTest, TestQuantTable) {
CMemoryAlign cMemoryAlign(0);
TEST (EncoderMbTest, TestQuantTable) {
CMemoryAlign cMemoryAlign (0);
int16_t iWidth = 16;
int16_t iHeight = 16;
uint8_t *pSrc = (uint8_t *)cMemoryAlign.WelsMalloc(iWidth*iHeight,"quant_src");
uint8_t *pPred = (uint8_t *)cMemoryAlign.WelsMalloc(iWidth*iHeight,"quant_pred");
int16_t *pDct = (int16_t *)cMemoryAlign.WelsMalloc(64*sizeof(int16_t),"Dct Buffer");
int16_t *pDctCompare = (int16_t *)cMemoryAlign.WelsMalloc(64*sizeof(int16_t),"DctCompare Buffer");
uint8_t* pSrc = (uint8_t*)cMemoryAlign.WelsMalloc (iWidth * iHeight, "quant_src");
uint8_t* pPred = (uint8_t*)cMemoryAlign.WelsMalloc (iWidth * iHeight, "quant_pred");
int16_t* pDct = (int16_t*)cMemoryAlign.WelsMalloc (64 * sizeof (int16_t), "Dct Buffer");
int16_t* pDctCompare = (int16_t*)cMemoryAlign.WelsMalloc (64 * sizeof (int16_t), "DctCompare Buffer");
for (int32_t iQP = 0; iQP<51; iQP++) {
TestQuant(iQP,pSrc,pPred,pDct,pDctCompare,iWidth,iHeight);
for (int32_t iQP = 0; iQP < 51; iQP++) {
TestQuant (iQP, pSrc, pPred, pDct, pDctCompare, iWidth, iHeight);
}
cMemoryAlign.WelsFree(pSrc,"quant_src");
cMemoryAlign.WelsFree(pPred,"quant_pred");
cMemoryAlign.WelsFree(pDct,"Dct Buffer");
cMemoryAlign.WelsFree(pDctCompare,"DctCompare Buffer");
cMemoryAlign.WelsFree (pSrc, "quant_src");
cMemoryAlign.WelsFree (pPred, "quant_pred");
cMemoryAlign.WelsFree (pDct, "Dct Buffer");
cMemoryAlign.WelsFree (pDctCompare, "DctCompare Buffer");
}

View File

@ -9,229 +9,230 @@ using namespace WelsSVCEnc;
#define ALLOC_MEMORY(type, name, num) type* name = (type*)cMemoryAlign.WelsMalloc(num*sizeof(type), #name);
#define FREE_MEMORY(name) cMemoryAlign.WelsFree(name, #name);
TEST(EncodeMbAuxTest, TestScan_4x4_ac_c) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iLevel, 16);
ALLOC_MEMORY(int16_t, iDctA, 16);
ALLOC_MEMORY(int16_t, iDctB, 16);
srand((unsigned int)time(NULL));
for(int i=0;i<16;i++) {
iDctA[i]=rand()%256+1;
iDctB[i]=iDctA[i];
TEST (EncodeMbAuxTest, TestScan_4x4_ac_c) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iLevel, 16);
ALLOC_MEMORY (int16_t, iDctA, 16);
ALLOC_MEMORY (int16_t, iDctB, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 16; i++) {
iDctA[i] = rand() % 256 + 1;
iDctB[i] = iDctA[i];
}
WelsScan4x4Ac_c( iLevel, iDctA );
EXPECT_EQ(iLevel[0],iDctB[1]);
EXPECT_EQ(iLevel[1],iDctB[4]);
EXPECT_EQ(iLevel[2],iDctB[8]);
EXPECT_EQ(iLevel[3],iDctB[5]);
EXPECT_EQ(iLevel[4],iDctB[2]);
EXPECT_EQ(iLevel[5],iDctB[3]);
EXPECT_EQ(iLevel[6],iDctB[6]);
EXPECT_EQ(iLevel[7],iDctB[9]);
EXPECT_EQ(iLevel[8],iDctB[12]);
EXPECT_EQ(iLevel[9],iDctB[13]);
EXPECT_EQ(iLevel[10],iDctB[10]);
EXPECT_EQ(iLevel[11],iDctB[7]);
EXPECT_EQ(iLevel[12],iDctB[11]);
EXPECT_EQ(iLevel[13],iDctB[14]);
EXPECT_EQ(iLevel[14],iDctB[15]);
EXPECT_EQ(iLevel[15],0);
FREE_MEMORY(iLevel);
FREE_MEMORY(iDctA);
FREE_MEMORY(iDctB);
WelsScan4x4Ac_c (iLevel, iDctA);
EXPECT_EQ (iLevel[0], iDctB[1]);
EXPECT_EQ (iLevel[1], iDctB[4]);
EXPECT_EQ (iLevel[2], iDctB[8]);
EXPECT_EQ (iLevel[3], iDctB[5]);
EXPECT_EQ (iLevel[4], iDctB[2]);
EXPECT_EQ (iLevel[5], iDctB[3]);
EXPECT_EQ (iLevel[6], iDctB[6]);
EXPECT_EQ (iLevel[7], iDctB[9]);
EXPECT_EQ (iLevel[8], iDctB[12]);
EXPECT_EQ (iLevel[9], iDctB[13]);
EXPECT_EQ (iLevel[10], iDctB[10]);
EXPECT_EQ (iLevel[11], iDctB[7]);
EXPECT_EQ (iLevel[12], iDctB[11]);
EXPECT_EQ (iLevel[13], iDctB[14]);
EXPECT_EQ (iLevel[14], iDctB[15]);
EXPECT_EQ (iLevel[15], 0);
FREE_MEMORY (iLevel);
FREE_MEMORY (iDctA);
FREE_MEMORY (iDctB);
}
#ifdef X86_ASM
TEST(EncodeMbAuxTest, TestScan_4x4_ac_sse2) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iLevelA, 16);
ALLOC_MEMORY(int16_t, iLevelB, 16);
ALLOC_MEMORY(int16_t, iDct, 16);
srand((unsigned int)time(NULL));
for(int i=0;i<16;i++) {
iDct[i]=rand()%256+1;
TEST (EncodeMbAuxTest, TestScan_4x4_ac_sse2) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iLevelA, 16);
ALLOC_MEMORY (int16_t, iLevelB, 16);
ALLOC_MEMORY (int16_t, iDct, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 16; i++) {
iDct[i] = rand() % 256 + 1;
}
WelsScan4x4Ac_c( iLevelA, iDct );
WelsScan4x4Ac_sse2( iLevelB, iDct );
for(int j=0; j<16;j++)
EXPECT_EQ(iLevelA[j], iLevelB[j]);
FREE_MEMORY(iLevelA);
FREE_MEMORY(iLevelB);
FREE_MEMORY(iDct);
WelsScan4x4Ac_c (iLevelA, iDct);
WelsScan4x4Ac_sse2 (iLevelB, iDct);
for (int j = 0; j < 16; j++)
EXPECT_EQ (iLevelA[j], iLevelB[j]);
FREE_MEMORY (iLevelA);
FREE_MEMORY (iLevelB);
FREE_MEMORY (iDct);
}
TEST(EncodeMbAuxTest, WelsScan4x4DcAc_sse2) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iLevelA, 32);
ALLOC_MEMORY(int16_t, iLevelB, 32);
ALLOC_MEMORY(int16_t, iDct, 32);
srand((unsigned int)time(NULL));
for(int i = 0; i < 32; i++)
TEST (EncodeMbAuxTest, WelsScan4x4DcAc_sse2) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iLevelA, 32);
ALLOC_MEMORY (int16_t, iLevelB, 32);
ALLOC_MEMORY (int16_t, iDct, 32);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 32; i++)
iDct[i] = (rand() & 32767) - 16384;
WelsScan4x4DcAc_sse2(iLevelA, iDct);
WelsScan4x4DcAc_c(iLevelB, iDct);
for(int i = 0; i < 16; i++)
EXPECT_EQ(iLevelA[i], iLevelB[i]);
FREE_MEMORY(iLevelA);
FREE_MEMORY(iLevelB);
FREE_MEMORY(iDct);
WelsScan4x4DcAc_sse2 (iLevelA, iDct);
WelsScan4x4DcAc_c (iLevelB, iDct);
for (int i = 0; i < 16; i++)
EXPECT_EQ (iLevelA[i], iLevelB[i]);
FREE_MEMORY (iLevelA);
FREE_MEMORY (iLevelB);
FREE_MEMORY (iDct);
}
#endif
TEST(EncodeMbAuxTest, TestScan_4x4_dcc) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iLevel, 16);
ALLOC_MEMORY(int16_t, iDctA, 16);
ALLOC_MEMORY(int16_t, iDctB, 16);
srand((unsigned int)time(NULL));
for(int i=0;i<16;i++)
iDctA[i] = iDctB[i] = rand()%256+1;
WelsScan4x4Dc( iLevel, iDctA );
EXPECT_EQ(iLevel[0],iDctB[0]);
EXPECT_EQ(iLevel[1],iDctB[1]);
EXPECT_EQ(iLevel[2],iDctB[4]);
EXPECT_EQ(iLevel[3],iDctB[8]);
EXPECT_EQ(iLevel[4],iDctB[5]);
EXPECT_EQ(iLevel[5],iDctB[2]);
EXPECT_EQ(iLevel[6],iDctB[3]);
EXPECT_EQ(iLevel[7],iDctB[6]);
EXPECT_EQ(iLevel[8],iDctB[9]);
EXPECT_EQ(iLevel[9],iDctB[12]);
EXPECT_EQ(iLevel[10],iDctB[13]);
EXPECT_EQ(iLevel[11],iDctB[10]);
EXPECT_EQ(iLevel[12],iDctB[7]);
EXPECT_EQ(iLevel[13],iDctB[11]);
EXPECT_EQ(iLevel[14],iDctB[14]);
EXPECT_EQ(iLevel[15],iDctB[15]);
FREE_MEMORY(iLevel);
FREE_MEMORY(iDctA);
FREE_MEMORY(iDctB);
TEST (EncodeMbAuxTest, TestScan_4x4_dcc) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iLevel, 16);
ALLOC_MEMORY (int16_t, iDctA, 16);
ALLOC_MEMORY (int16_t, iDctB, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 16; i++)
iDctA[i] = iDctB[i] = rand() % 256 + 1;
WelsScan4x4Dc (iLevel, iDctA);
EXPECT_EQ (iLevel[0], iDctB[0]);
EXPECT_EQ (iLevel[1], iDctB[1]);
EXPECT_EQ (iLevel[2], iDctB[4]);
EXPECT_EQ (iLevel[3], iDctB[8]);
EXPECT_EQ (iLevel[4], iDctB[5]);
EXPECT_EQ (iLevel[5], iDctB[2]);
EXPECT_EQ (iLevel[6], iDctB[3]);
EXPECT_EQ (iLevel[7], iDctB[6]);
EXPECT_EQ (iLevel[8], iDctB[9]);
EXPECT_EQ (iLevel[9], iDctB[12]);
EXPECT_EQ (iLevel[10], iDctB[13]);
EXPECT_EQ (iLevel[11], iDctB[10]);
EXPECT_EQ (iLevel[12], iDctB[7]);
EXPECT_EQ (iLevel[13], iDctB[11]);
EXPECT_EQ (iLevel[14], iDctB[14]);
EXPECT_EQ (iLevel[15], iDctB[15]);
FREE_MEMORY (iLevel);
FREE_MEMORY (iDctA);
FREE_MEMORY (iDctB);
}
static inline void PixelSubWH( int16_t *iDiff, int iSize, uint8_t *pPix1, int iStride1, uint8_t *pPix2, int iStride2 ) {
static inline void PixelSubWH (int16_t* iDiff, int iSize, uint8_t* pPix1, int iStride1, uint8_t* pPix2, int iStride2) {
int y, x;
for( y = 0; y < iSize; y++ ) {
for( x = 0; x < iSize; x++ )
iDiff[x + y*iSize] = pPix1[x] - pPix2[x];
pPix1 += iStride1;
pPix2 += iStride2;
}
for (y = 0; y < iSize; y++) {
for (x = 0; x < iSize; x++)
iDiff[x + y * iSize] = pPix1[x] - pPix2[x];
pPix1 += iStride1;
pPix2 += iStride2;
}
}
#define FENC_STRIDE 16
#define FDEC_STRIDE 32
static void Sub4x4DctAnchor( int16_t iDct[4][4], uint8_t *pPix1, uint8_t *pPix2 ) {
static void Sub4x4DctAnchor (int16_t iDct[4][4], uint8_t* pPix1, uint8_t* pPix2) {
int16_t iDiff[4][4];
int16_t tmp[4][4];
int i;
PixelSubWH( (int16_t*)iDiff, 4, pPix1, FENC_STRIDE, pPix2, FDEC_STRIDE );
for( i = 0; i < 4; i++ ) {
PixelSubWH ((int16_t*)iDiff, 4, pPix1, FENC_STRIDE, pPix2, FDEC_STRIDE);
for (i = 0; i < 4; i++) {
const int a03 = iDiff[i][0] + iDiff[i][3];
const int a12 = iDiff[i][1] + iDiff[i][2];
const int s03 = iDiff[i][0] - iDiff[i][3];
const int s12 = iDiff[i][1] - iDiff[i][2];
tmp[0][i] = a03 + a12;
tmp[1][i] = 2*s03 + s12;
tmp[1][i] = 2 * s03 + s12;
tmp[2][i] = a03 - a12;
tmp[3][i] = s03 - 2*s12;
tmp[3][i] = s03 - 2 * s12;
}
for( i = 0; i < 4; i++ ) {
for (i = 0; i < 4; i++) {
const int a03 = tmp[i][0] + tmp[i][3];
const int a12 = tmp[i][1] + tmp[i][2];
const int s03 = tmp[i][0] - tmp[i][3];
const int s12 = tmp[i][1] - tmp[i][2];
iDct[i][0] = a03 + a12;
iDct[i][1] = 2*s03 + s12;
iDct[i][1] = 2 * s03 + s12;
iDct[i][2] = a03 - a12;
iDct[i][3] = s03 - 2*s12;
iDct[i][3] = s03 - 2 * s12;
}
}
static void Sub8x8DctAnchor( int16_t iDct[4][4][4], uint8_t *pPix1, uint8_t *pPix2 ) {
Sub4x4DctAnchor( iDct[0], &pPix1[0], &pPix2[0] );
Sub4x4DctAnchor( iDct[1], &pPix1[4], &pPix2[4] );
Sub4x4DctAnchor( iDct[2], &pPix1[4*FENC_STRIDE+0], &pPix2[4*FDEC_STRIDE+0] );
Sub4x4DctAnchor( iDct[3], &pPix1[4*FENC_STRIDE+4], &pPix2[4*FDEC_STRIDE+4] );
static void Sub8x8DctAnchor (int16_t iDct[4][4][4], uint8_t* pPix1, uint8_t* pPix2) {
Sub4x4DctAnchor (iDct[0], &pPix1[0], &pPix2[0]);
Sub4x4DctAnchor (iDct[1], &pPix1[4], &pPix2[4]);
Sub4x4DctAnchor (iDct[2], &pPix1[4 * FENC_STRIDE + 0], &pPix2[4 * FDEC_STRIDE + 0]);
Sub4x4DctAnchor (iDct[3], &pPix1[4 * FENC_STRIDE + 4], &pPix2[4 * FDEC_STRIDE + 4]);
}
TEST(EncodeMbAuxTest, WelsDctT4_c) {
TEST (EncodeMbAuxTest, WelsDctT4_c) {
int16_t iDctRef[4][4];
uint8_t uiPix1[16*FENC_STRIDE], uiPix2[16*FDEC_STRIDE];
uint8_t uiPix1[16 * FENC_STRIDE], uiPix2[16 * FDEC_STRIDE];
int16_t iDct[16];
srand((unsigned int)time(NULL));
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255;
Sub4x4DctAnchor(iDctRef, uiPix1, uiPix2);
WelsDctT4_c(iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
EXPECT_EQ(iDctRef[j][i], iDct[i*4+j]);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255;
Sub4x4DctAnchor (iDctRef, uiPix1, uiPix2);
WelsDctT4_c (iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
EXPECT_EQ (iDctRef[j][i], iDct[i * 4 + j]);
}
TEST(EncodeMbAuxTest, WelsDctFourT4_c) {
int16_t iDctRef[4][4][4]; uint8_t uiPix1[16*FENC_STRIDE], uiPix2[16*FDEC_STRIDE];
int16_t iDct[16*4];
srand((unsigned int)time(NULL));
for(int i = 0; i < 8; i++)
for(int j = 0; j < 8; j++)
uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255;
Sub8x8DctAnchor(iDctRef, uiPix1, uiPix2);
WelsDctFourT4_c(iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for(int k = 0; k < 4; k++)
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
EXPECT_EQ(iDctRef[k][j][i], iDct[k*16+i*4+j]);
TEST (EncodeMbAuxTest, WelsDctFourT4_c) {
int16_t iDctRef[4][4][4];
uint8_t uiPix1[16 * FENC_STRIDE], uiPix2[16 * FDEC_STRIDE];
int16_t iDct[16 * 4];
srand ((unsigned int)time (NULL));
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255;
Sub8x8DctAnchor (iDctRef, uiPix1, uiPix2);
WelsDctFourT4_c (iDct, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for (int k = 0; k < 4; k++)
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
EXPECT_EQ (iDctRef[k][j][i], iDct[k * 16 + i * 4 + j]);
}
#ifdef X86_ASM
TEST(EncodeMbAuxTest, WelsDctT4_mmx) {
TEST (EncodeMbAuxTest, WelsDctT4_mmx) {
int16_t iDctC[16], iDctM[16];
uint8_t uiPix1[16*FENC_STRIDE], uiPix2[16*FDEC_STRIDE];
srand((unsigned int)time(NULL));
for(int i = 0; i < 4; i++)
for(int j = 0; j < 4; j++)
uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255;
WelsDctT4_c(iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
WelsDctT4_mmx(iDctM, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for(int i = 0; i < 16; i++)
EXPECT_EQ(iDctC[i], iDctM[i]);
uint8_t uiPix1[16 * FENC_STRIDE], uiPix2[16 * FDEC_STRIDE];
srand ((unsigned int)time (NULL));
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255;
WelsDctT4_c (iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
WelsDctT4_mmx (iDctM, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for (int i = 0; i < 16; i++)
EXPECT_EQ (iDctC[i], iDctM[i]);
}
TEST(EncodeMbAuxTest, WelsDctFourT4_sse2) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(uint8_t, uiPix1, 16*FENC_STRIDE);
ALLOC_MEMORY(uint8_t, uiPix2, 16*FDEC_STRIDE);
ALLOC_MEMORY(int16_t, iDctC, 16*4);
ALLOC_MEMORY(int16_t, iDctS, 16*4);
srand((unsigned int)time(NULL));
for(int i = 0; i < 8; i++)
for(int j = 0; j < 8; j++)
uiPix1[i*FENC_STRIDE+j] = uiPix2[i*FDEC_STRIDE+j] = rand() & 255;
WelsDctFourT4_c(iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
WelsDctFourT4_sse2(iDctS, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for(int i = 0; i < 64; i++)
EXPECT_EQ(iDctC[i], iDctS[i]);
FREE_MEMORY(uiPix1);
FREE_MEMORY(uiPix2);
FREE_MEMORY(iDctC);
FREE_MEMORY(iDctS);
TEST (EncodeMbAuxTest, WelsDctFourT4_sse2) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (uint8_t, uiPix1, 16 * FENC_STRIDE);
ALLOC_MEMORY (uint8_t, uiPix2, 16 * FDEC_STRIDE);
ALLOC_MEMORY (int16_t, iDctC, 16 * 4);
ALLOC_MEMORY (int16_t, iDctS, 16 * 4);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
uiPix1[i * FENC_STRIDE + j] = uiPix2[i * FDEC_STRIDE + j] = rand() & 255;
WelsDctFourT4_c (iDctC, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
WelsDctFourT4_sse2 (iDctS, uiPix1, FENC_STRIDE, uiPix2, FDEC_STRIDE);
for (int i = 0; i < 64; i++)
EXPECT_EQ (iDctC[i], iDctS[i]);
FREE_MEMORY (uiPix1);
FREE_MEMORY (uiPix2);
FREE_MEMORY (iDctC);
FREE_MEMORY (iDctS);
}
TEST(EncodeMbAuxTest, WelsCalculateSingleCtr4x4_sse2) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iDctC, 16);
ALLOC_MEMORY(int16_t, iDctS, 16);
srand((unsigned int)time(NULL));
for(int i = 0; i < 16; i++)
iDctC[i] = iDctS[i] = (rand() & 65535 ) - 32768;
WelsCalculateSingleCtr4x4_c(iDctC);
WelsCalculateSingleCtr4x4_sse2(iDctS);
for(int i = 0; i < 16; i++)
EXPECT_EQ(iDctC[i], iDctS[i]);
FREE_MEMORY(iDctC);
FREE_MEMORY(iDctS);
TEST (EncodeMbAuxTest, WelsCalculateSingleCtr4x4_sse2) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iDctC, 16);
ALLOC_MEMORY (int16_t, iDctS, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 16; i++)
iDctC[i] = iDctS[i] = (rand() & 65535) - 32768;
WelsCalculateSingleCtr4x4_c (iDctC);
WelsCalculateSingleCtr4x4_sse2 (iDctS);
for (int i = 0; i < 16; i++)
EXPECT_EQ (iDctC[i], iDctS[i]);
FREE_MEMORY (iDctC);
FREE_MEMORY (iDctS);
}
#endif
void copy(uint8_t *pDst, int32_t iDStride, uint8_t *pSrc, int32_t iSStride, int32_t iWidth, int32_t iHeight) {
for(int i = 0; i < iHeight; i++)
memcpy(pDst+i*iDStride, pSrc+i*iSStride, iWidth);
void copy (uint8_t* pDst, int32_t iDStride, uint8_t* pSrc, int32_t iSStride, int32_t iWidth, int32_t iHeight) {
for (int i = 0; i < iHeight; i++)
memcpy (pDst + i * iDStride, pSrc + i * iSStride, iWidth);
}
#define GENERATE_UT_FOR_COPY(width, height, function) \
@ -253,112 +254,112 @@ TEST(EncodeMbAuxTest, function) { \
EXPECT_EQ(ref_dst[i*iDStride+j], dst[i*iDStride+j]); \
}
GENERATE_UT_FOR_COPY(4,4, WelsCopy4x4);
GENERATE_UT_FOR_COPY(8,8, WelsCopy8x8_c);
GENERATE_UT_FOR_COPY(8, 16, WelsCopy8x16_c);
GENERATE_UT_FOR_COPY(16, 8, WelsCopy16x8_c);
GENERATE_UT_FOR_COPY(16, 16, WelsCopy16x16_c);
GENERATE_UT_FOR_COPY (4, 4, WelsCopy4x4);
GENERATE_UT_FOR_COPY (8, 8, WelsCopy8x8_c);
GENERATE_UT_FOR_COPY (8, 16, WelsCopy8x16_c);
GENERATE_UT_FOR_COPY (16, 8, WelsCopy16x8_c);
GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_c);
#ifdef X86_ASM
GENERATE_UT_FOR_COPY(16, 8, WelsCopy16x8NotAligned_sse2);
GENERATE_UT_FOR_COPY(16, 16, WelsCopy16x16NotAligned_sse2);
GENERATE_UT_FOR_COPY(16, 16, WelsCopy16x16_sse2);
GENERATE_UT_FOR_COPY (16, 8, WelsCopy16x8NotAligned_sse2);
GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16NotAligned_sse2);
GENERATE_UT_FOR_COPY (16, 16, WelsCopy16x16_sse2);
#endif
TEST(EncodeMbAuxTest, WelsGetNoneZeroCount_c) {
TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_c) {
int16_t _iLevel[32];
int16_t *pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4);
srand((unsigned int)time(NULL));
int16_t* pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4);
srand ((unsigned int)time (NULL));
int32_t result = 0;
for(int i = 0; i < 16; i++) {
for (int i = 0; i < 16; i++) {
pLevel[i] = (rand() & 0x07) - 4;
if(pLevel[i]) result ++;
if (pLevel[i]) result ++;
}
int32_t nnz = WelsGetNoneZeroCount_c(pLevel);
EXPECT_EQ(nnz, result);
int32_t nnz = WelsGetNoneZeroCount_c (pLevel);
EXPECT_EQ (nnz, result);
}
#ifdef X86_ASM
TEST(EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) {
TEST (EncodeMbAuxTest, WelsGetNoneZeroCount_sse2) {
int16_t _iLevel[32];
int16_t *pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4);
srand((unsigned int)time(NULL));
int16_t* pLevel = (int16_t*) (((((uintptr_t)_iLevel) + 15) >> 4) << 4);
srand ((unsigned int)time (NULL));
int32_t result = 0;
for(int i = 0; i < 16; i++) {
for (int i = 0; i < 16; i++) {
pLevel[i] = (rand() & 0x07) - 4;
if(pLevel[i]) result ++;
if (pLevel[i]) result ++;
}
int32_t nnz = WelsGetNoneZeroCount_sse2(pLevel);
EXPECT_EQ(nnz, result);
int32_t nnz = WelsGetNoneZeroCount_sse2 (pLevel);
EXPECT_EQ (nnz, result);
}
#endif
#define WELS_ABS_LC(a) ((sign ^ (int32_t)(a)) - sign)
#define NEW_QUANT(pDct, ff, mf) (((ff)+ WELS_ABS_LC(pDct))*(mf)) >>16
#define WELS_NEW_QUANT(pDct,ff,mf) WELS_ABS_LC(NEW_QUANT(pDct, ff, mf))
void WelsQuantFour4x4MaxAnchor(int16_t *pDct, int16_t* ff, int16_t *mf, int16_t *max) {
void WelsQuantFour4x4MaxAnchor (int16_t* pDct, int16_t* ff, int16_t* mf, int16_t* max) {
int32_t i, j, k, sign;
int16_t max_abs;
for( k = 0; k < 4; k++) {
for (k = 0; k < 4; k++) {
max_abs = 0;
for( i = 0; i < 16; i++ ) {
for (i = 0; i < 16; i++) {
j = i & 0x07;
sign = WELS_SIGN(pDct[i]);
pDct[i] = NEW_QUANT(pDct[i], ff[j], mf[j]);
if( max_abs < pDct[i]) max_abs = pDct[i];
pDct[i] = WELS_ABS_LC(pDct[i]);
sign = WELS_SIGN (pDct[i]);
pDct[i] = NEW_QUANT (pDct[i], ff[j], mf[j]);
if (max_abs < pDct[i]) max_abs = pDct[i];
pDct[i] = WELS_ABS_LC (pDct[i]);
}
pDct += 16;
max[k] = max_abs;
}
}
TEST(EncodeMbAuxTest, WelsQuantFour4x4Max_c) {
TEST (EncodeMbAuxTest, WelsQuantFour4x4Max_c) {
int16_t ff[8], mf[8];
int16_t iDctA[64], iMaxA[16];
int16_t iDctC[64], iMaxC[16];
srand((unsigned int)time(NULL));
for(int i = 0; i < 8; i++) {
srand ((unsigned int)time (NULL));
for (int i = 0; i < 8; i++) {
ff[i] = rand() & 32767;
mf[i] = rand() & 32767;
}
for(int i = 0; i < 64; i++)
for (int i = 0; i < 64; i++)
iDctA[i] = iDctC[i] = (rand() & 65535) - 32767;
WelsQuantFour4x4MaxAnchor(iDctA, ff, mf, iMaxA);
WelsQuantFour4x4Max_c(iDctC, ff, mf, iMaxC);
for(int i = 0; i < 64; i++)
EXPECT_EQ(iDctA[i],iDctC[i]);
for(int i = 0; i < 4; i++)
EXPECT_EQ(iMaxA[i], iMaxC[i]);
WelsQuantFour4x4MaxAnchor (iDctA, ff, mf, iMaxA);
WelsQuantFour4x4Max_c (iDctC, ff, mf, iMaxC);
for (int i = 0; i < 64; i++)
EXPECT_EQ (iDctA[i], iDctC[i]);
for (int i = 0; i < 4; i++)
EXPECT_EQ (iMaxA[i], iMaxC[i]);
}
#ifdef X86_ASM
TEST(EncodeMbAuxTest, WelsQuantFour4x4Max_sse2) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, ff, 8);
ALLOC_MEMORY(int16_t, mf, 8);
ALLOC_MEMORY(int16_t, iDctC, 64);
ALLOC_MEMORY(int16_t, iDctS, 64);
ALLOC_MEMORY(int16_t, iMaxC, 16);
ALLOC_MEMORY(int16_t, iMaxS, 16);
srand((unsigned int)time(NULL));
for(int i = 0; i < 8; i++) {
TEST (EncodeMbAuxTest, WelsQuantFour4x4Max_sse2) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, ff, 8);
ALLOC_MEMORY (int16_t, mf, 8);
ALLOC_MEMORY (int16_t, iDctC, 64);
ALLOC_MEMORY (int16_t, iDctS, 64);
ALLOC_MEMORY (int16_t, iMaxC, 16);
ALLOC_MEMORY (int16_t, iMaxS, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 8; i++) {
ff[i] = rand() & 32767;
mf[i] = rand() & 32767;
}
for(int i = 0; i < 64; i++)
for (int i = 0; i < 64; i++)
iDctC[i] = iDctS[i] = (rand() & 65535) - 32767;
WelsQuantFour4x4Max_c(iDctC, ff, mf, iMaxC);
WelsQuantFour4x4Max_sse2(iDctS, ff, mf, iMaxS);
for(int i = 0; i < 64; i++)
EXPECT_EQ(iDctC[i], iDctS[i]);
for(int i = 0; i < 4; i++)
EXPECT_EQ(iMaxC[i], iMaxS[i]);
FREE_MEMORY(ff);
FREE_MEMORY(mf);
FREE_MEMORY(iDctC);
FREE_MEMORY(iDctS);
FREE_MEMORY(iMaxC);
FREE_MEMORY(iMaxS);
WelsQuantFour4x4Max_c (iDctC, ff, mf, iMaxC);
WelsQuantFour4x4Max_sse2 (iDctS, ff, mf, iMaxS);
for (int i = 0; i < 64; i++)
EXPECT_EQ (iDctC[i], iDctS[i]);
for (int i = 0; i < 4; i++)
EXPECT_EQ (iMaxC[i], iMaxS[i]);
FREE_MEMORY (ff);
FREE_MEMORY (mf);
FREE_MEMORY (iDctC);
FREE_MEMORY (iDctS);
FREE_MEMORY (iMaxC);
FREE_MEMORY (iMaxS);
}
#endif
int32_t WelsHadamardQuant2x2SkipAnchor(int16_t *rs, int16_t ff, int16_t mf) {
int32_t WelsHadamardQuant2x2SkipAnchor (int16_t* rs, int16_t ff, int16_t mf) {
int16_t pDct[4], s[4];
int16_t threshold = ((1<<16)-1)/mf - ff;
int16_t threshold = ((1 << 16) - 1) / mf - ff;
s[0] = rs[0] + rs[32];
s[1] = rs[0] - rs[32];
s[2] = rs[16] + rs[48];
@ -367,21 +368,22 @@ int32_t WelsHadamardQuant2x2SkipAnchor(int16_t *rs, int16_t ff, int16_t mf) {
pDct[1] = s[0] - s[2];
pDct[2] = s[1] + s[3];
pDct[3] = s[1] - s[3];
return ((WELS_ABS(pDct[0]) > threshold) || (WELS_ABS(pDct[1]) > threshold) || (WELS_ABS(pDct[2]) > threshold) || (WELS_ABS(pDct[3]) > threshold));
return ((WELS_ABS (pDct[0]) > threshold) || (WELS_ABS (pDct[1]) > threshold) || (WELS_ABS (pDct[2]) > threshold)
|| (WELS_ABS (pDct[3]) > threshold));
}
TEST(EncodeMbAuxTest, WelsHadamardQuant2x2Skip_c) {
TEST (EncodeMbAuxTest, WelsHadamardQuant2x2Skip_c) {
int16_t iRS[64];
int16_t ff, mf;
srand((unsigned int)time(NULL));
for(int i = 0; i < 64; i++)
srand ((unsigned int)time (NULL));
for (int i = 0; i < 64; i++)
iRS[i] = (rand() & 32767) - 16384;
ff = rand() & 32767;
mf = rand() & 32767;
EXPECT_EQ(WelsHadamardQuant2x2Skip_c(iRS, ff, mf), WelsHadamardQuant2x2SkipAnchor(iRS, ff, mf));
EXPECT_EQ (WelsHadamardQuant2x2Skip_c (iRS, ff, mf), WelsHadamardQuant2x2SkipAnchor (iRS, ff, mf));
}
int32_t WelsHadamardQuant2x2Anchor(int16_t *rs, const int16_t ff, int16_t mf, int16_t * pDct, int16_t * block) {
int32_t WelsHadamardQuant2x2Anchor (int16_t* rs, const int16_t ff, int16_t mf, int16_t* pDct, int16_t* block) {
int16_t s[4];
int32_t sign, i, dc_nzc = 0;
@ -400,95 +402,95 @@ int32_t WelsHadamardQuant2x2Anchor(int16_t *rs, const int16_t ff, int16_t mf, in
pDct[2] = s[1] + s[3];
pDct[3] = s[1] - s[3];
sign = WELS_SIGN(pDct[0]);
pDct[0] = WELS_NEW_QUANT(pDct[0], ff, mf);
sign = WELS_SIGN(pDct[1]);
pDct[1] = WELS_NEW_QUANT(pDct[1], ff, mf);
sign = WELS_SIGN(pDct[2]);
pDct[2] = WELS_NEW_QUANT(pDct[2], ff, mf);
sign = WELS_SIGN(pDct[3]);
pDct[3] = WELS_NEW_QUANT(pDct[3], ff, mf);
ST64( block, LD64(pDct) );
for(i=0; i<4; i++)
sign = WELS_SIGN (pDct[0]);
pDct[0] = WELS_NEW_QUANT (pDct[0], ff, mf);
sign = WELS_SIGN (pDct[1]);
pDct[1] = WELS_NEW_QUANT (pDct[1], ff, mf);
sign = WELS_SIGN (pDct[2]);
pDct[2] = WELS_NEW_QUANT (pDct[2], ff, mf);
sign = WELS_SIGN (pDct[3]);
pDct[3] = WELS_NEW_QUANT (pDct[3], ff, mf);
ST64 (block, LD64 (pDct));
for (i = 0; i < 4; i++)
dc_nzc += (block[i] != 0);
return dc_nzc;
}
TEST(EncodeMbAuxTest, WelsHadamardQuant2x2_c) {
TEST (EncodeMbAuxTest, WelsHadamardQuant2x2_c) {
int16_t iRsC[64], iRsA[64];
int16_t ff, mf;
int16_t iBlockA[16], iBlockC[16], iDctA[4], iDctC[4];
srand((unsigned int)time(NULL));
for(int i = 0; i < 64; i++)
srand ((unsigned int)time (NULL));
for (int i = 0; i < 64; i++)
iRsA[i] = iRsC[i] = (rand() & 32767) - 16384;
for(int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
iDctA[i] = iDctC[i] = (rand() & 32767) - 16384;
ff = rand() & 32767;
mf = rand() & 32767;
int32_t iRetA = WelsHadamardQuant2x2Anchor(iRsA, ff, mf, iDctA, iBlockA);
int32_t iRetC = WelsHadamardQuant2x2_c(iRsC, ff, mf, iDctC, iBlockC);
EXPECT_EQ(iRetA, iRetC);
for(int i = 0; i < 4; i++)
EXPECT_EQ(iDctA[i], iDctC[i]);
int32_t iRetA = WelsHadamardQuant2x2Anchor (iRsA, ff, mf, iDctA, iBlockA);
int32_t iRetC = WelsHadamardQuant2x2_c (iRsC, ff, mf, iDctC, iBlockC);
EXPECT_EQ (iRetA, iRetC);
for (int i = 0; i < 4; i++)
EXPECT_EQ (iDctA[i], iDctC[i]);
}
void WelsHadamardT4DcAnchor( int16_t *pLumaDc, int16_t *pDct) {
void WelsHadamardT4DcAnchor (int16_t* pLumaDc, int16_t* pDct) {
int32_t p[16], s[4];
int32_t i, iIdx;
for(i = 0 ; i < 16 ; i +=4) {
iIdx = ((i&0x08) << 4) +((i&0x04) << 3);
s[0] = pDct[iIdx ] + pDct[iIdx+80];
s[3] = pDct[iIdx ] - pDct[iIdx+80];
s[1] = pDct[iIdx+16] + pDct[iIdx+64];
s[2] = pDct[iIdx+16] - pDct[iIdx+64];
for (i = 0 ; i < 16 ; i += 4) {
iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3);
s[0] = pDct[iIdx ] + pDct[iIdx + 80];
s[3] = pDct[iIdx ] - pDct[iIdx + 80];
s[1] = pDct[iIdx + 16] + pDct[iIdx + 64];
s[2] = pDct[iIdx + 16] - pDct[iIdx + 64];
p[i ] = s[0] + s[1];
p[i+2] = s[0] - s[1];
p[i+1] = s[3] + s[2];
p[i+3] = s[3] - s[2];
p[i + 2] = s[0] - s[1];
p[i + 1] = s[3] + s[2];
p[i + 3] = s[3] - s[2];
}
for(i = 0 ; i < 4 ; i ++) {
s[0] = p[i ] + p[i+12];
s[3] = p[i ] - p[i+12];
s[1] = p[i+4] + p[i+ 8];
s[2] = p[i+4] - p[i+ 8];
pLumaDc[i ] = WELS_CLIP3((s[0] + s[1] + 1) >> 1, -32768, 32767);
pLumaDc[i+8 ] = WELS_CLIP3((s[0] - s[1] + 1) >> 1, -32768, 32767);
pLumaDc[i+4 ] = WELS_CLIP3((s[3] + s[2] + 1) >> 1, -32768, 32767);
pLumaDc[i+12] = WELS_CLIP3((s[3] - s[2] + 1) >> 1, -32768, 32767);
for (i = 0 ; i < 4 ; i ++) {
s[0] = p[i ] + p[i + 12];
s[3] = p[i ] - p[i + 12];
s[1] = p[i + 4] + p[i + 8];
s[2] = p[i + 4] - p[i + 8];
pLumaDc[i ] = WELS_CLIP3 ((s[0] + s[1] + 1) >> 1, -32768, 32767);
pLumaDc[i + 8 ] = WELS_CLIP3 ((s[0] - s[1] + 1) >> 1, -32768, 32767);
pLumaDc[i + 4 ] = WELS_CLIP3 ((s[3] + s[2] + 1) >> 1, -32768, 32767);
pLumaDc[i + 12] = WELS_CLIP3 ((s[3] - s[2] + 1) >> 1, -32768, 32767);
}
}
TEST(EncodeMbAuxTest, WelsHadamardT4Dc_c) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iDct, 128*16);
ALLOC_MEMORY(int16_t, iLumaDcR, 16);
ALLOC_MEMORY(int16_t, iLumaDcC, 16);
srand((unsigned int)time(NULL));
for(int i = 0; i < 128*16; i++)
TEST (EncodeMbAuxTest, WelsHadamardT4Dc_c) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iDct, 128 * 16);
ALLOC_MEMORY (int16_t, iLumaDcR, 16);
ALLOC_MEMORY (int16_t, iLumaDcC, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 128 * 16; i++)
iDct[i] = (rand() & 32767) - 16384;
WelsHadamardT4DcAnchor(iLumaDcR, iDct);
WelsHadamardT4Dc_c(iLumaDcC, iDct);
for(int i = 0;i < 16; i++)
EXPECT_EQ(iLumaDcR[i], iLumaDcC[i]);
FREE_MEMORY(iDct);
FREE_MEMORY(iLumaDcR);
FREE_MEMORY(iLumaDcC);
WelsHadamardT4DcAnchor (iLumaDcR, iDct);
WelsHadamardT4Dc_c (iLumaDcC, iDct);
for (int i = 0; i < 16; i++)
EXPECT_EQ (iLumaDcR[i], iLumaDcC[i]);
FREE_MEMORY (iDct);
FREE_MEMORY (iLumaDcR);
FREE_MEMORY (iLumaDcC);
}
#ifdef X86_ASM
TEST(EncodeMbAuxTest, WelsHadamardT4Dc_sse2) {
CMemoryAlign cMemoryAlign(0);
ALLOC_MEMORY(int16_t, iDct, 128*16);
ALLOC_MEMORY(int16_t, iLumaDcC, 16);
ALLOC_MEMORY(int16_t, iLumaDcS, 16);
srand((unsigned int)time(NULL));
for(int i = 0; i < 128*16; i++)
TEST (EncodeMbAuxTest, WelsHadamardT4Dc_sse2) {
CMemoryAlign cMemoryAlign (0);
ALLOC_MEMORY (int16_t, iDct, 128 * 16);
ALLOC_MEMORY (int16_t, iLumaDcC, 16);
ALLOC_MEMORY (int16_t, iLumaDcS, 16);
srand ((unsigned int)time (NULL));
for (int i = 0; i < 128 * 16; i++)
iDct[i] = (rand() & 32767) - 16384;
WelsHadamardT4Dc_c(iLumaDcC, iDct);
WelsHadamardT4Dc_sse2(iLumaDcS, iDct);
for(int i = 0;i < 16; i++)
EXPECT_EQ(iLumaDcC[i], iLumaDcS[i]);
FREE_MEMORY(iDct);
FREE_MEMORY(iLumaDcC);
FREE_MEMORY(iLumaDcS);
WelsHadamardT4Dc_c (iLumaDcC, iDct);
WelsHadamardT4Dc_sse2 (iLumaDcS, iDct);
for (int i = 0; i < 16; i++)
EXPECT_EQ (iLumaDcC[i], iLumaDcS[i]);
FREE_MEMORY (iDct);
FREE_MEMORY (iLumaDcC);
FREE_MEMORY (iLumaDcS);
}
#endif

View File

@ -5,37 +5,37 @@
using namespace WelsSVCEnc;
const double g_kdLog2Factor = 1.0 / log(2.0);
const double g_kdLog2Factor = 1.0 / log (2.0);
TEST(UeExpGolombTest, TestBsSizeUeLt256) {
TEST (UeExpGolombTest, TestBsSizeUeLt256) {
uint32_t uiInVal = 0;
for (; uiInVal < 256; ++ uiInVal) {
const uint32_t uiActVal = BsSizeUE( uiInVal );
const int32_t m = static_cast<int32_t>(log( (uiInVal+1) * 1.0 ) * g_kdLog2Factor + 1e-6);
const uint32_t uiExpVal = (m<<1)+1;
EXPECT_EQ(uiActVal, uiExpVal);
const uint32_t uiActVal = BsSizeUE (uiInVal);
const int32_t m = static_cast<int32_t> (log ((uiInVal + 1) * 1.0) * g_kdLog2Factor + 1e-6);
const uint32_t uiExpVal = (m << 1) + 1;
EXPECT_EQ (uiActVal, uiExpVal);
}
}
TEST(UeExpGolombTest, TestBsSizeUeRangeFrom256To65534) {
TEST (UeExpGolombTest, TestBsSizeUeRangeFrom256To65534) {
uint32_t uiInVal = 0x100;
for (; uiInVal < 0xFFFF; ++ uiInVal) {
const uint32_t uiActVal = BsSizeUE( uiInVal );
const int32_t m = static_cast<int32_t>(log( (uiInVal+1) * 1.0 ) * g_kdLog2Factor + 1e-6);
const uint32_t uiExpVal = (m<<1)+1;
EXPECT_EQ(uiActVal, uiExpVal);
const uint32_t uiActVal = BsSizeUE (uiInVal);
const int32_t m = static_cast<int32_t> (log ((uiInVal + 1) * 1.0) * g_kdLog2Factor + 1e-6);
const uint32_t uiExpVal = (m << 1) + 1;
EXPECT_EQ (uiActVal, uiExpVal);
}
}
TEST(UeExpGolombTest, TestBsSizeUeRangeFrom65535ToPlus256) {
TEST (UeExpGolombTest, TestBsSizeUeRangeFrom65535ToPlus256) {
uint32_t uiInVal = 0xFFFF;
const uint32_t uiCountBase = 256;
const uint32_t uiInValEnd = uiInVal + uiCountBase;
for (; uiInVal < uiInValEnd; ++ uiInVal) {
const uint32_t uiActVal = BsSizeUE( uiInVal );
const uint32_t uiActVal = BsSizeUE (uiInVal);
// float precision issue in case use math::log
const int32_t m = WELS_LOG2(1+uiInVal);
const uint32_t uiExpVal = (m<<1)+1;
EXPECT_EQ(uiActVal, uiExpVal);
const int32_t m = WELS_LOG2 (1 + uiInVal);
const uint32_t uiExpVal = (m << 1) + 1;
EXPECT_EQ (uiActVal, uiExpVal);
}
}

View File

@ -7,40 +7,39 @@
using namespace WelsSVCEnc;
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredV) {
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[64];
for (int i=0; i<64; i++)
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredV) {
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256;
const int32_t kkiStride = 0;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredV_c(pPred, pRef, kkiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredV_c (pPred, pRef, kkiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&pRef[-kkiStride]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&pRef[-kkiStride]));
delete []pRef;
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredH)
{
const int32_t kiStride = rand()%256+16;
const uint32_t kiStride2 = (kiStride<<1)-1;
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredH) {
const int32_t kiStride = rand() % 256 + 16;
const uint32_t kiStride2 = (kiStride << 1) - 1;
const uint32_t kiStride3 = kiStride + kiStride2;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[kiStride3+2];
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[kiStride3 + 2];
for (int i=0; i<(static_cast<int32_t>(kiStride3+2)); i++)
for (int i = 0; i < (static_cast<int32_t> (kiStride3 + 2)); i++)
pRef[i] = rand() % 256;
pRef++;
const uint8_t kuiH1 = pRef[-1];
const uint8_t kuiH2 = pRef[kiStride-1];
const uint8_t kuiH2 = pRef[kiStride - 1];
const uint8_t kuiH3 = pRef[kiStride2];
const uint8_t kuiH4 = pRef[kiStride3];
const uint8_t kuiV1[4] = {kuiH1, kuiH1, kuiH1, kuiH1};
@ -50,17 +49,17 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredH)
const uint32_t kuiCpuFlag = 0;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16)// TobeCont'd about assign opt as follows
ST32(&uiV[0], LD32(kuiV1));
ST32(&uiV[4], LD32(kuiV2));
ST32(&uiV[8], LD32(kuiV3));
ST32(&uiV[12], LD32(kuiV4));
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
ST32 (&uiV[0], LD32 (kuiV1));
ST32 (&uiV[4], LD32 (kuiV2));
ST32 (&uiV[8], LD32 (kuiV3));
ST32 (&uiV[12], LD32 (kuiV4));
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredH_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredH_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]), LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
pRef--;
@ -68,105 +67,105 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredH)
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDL) {
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDL) {
const int32_t kiStride = 0;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[64];
for (int i=0; i<64; i++)
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256;
const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1-kiStride];
const uint8_t kuiT2 = pRef[2-kiStride];
const uint8_t kuiT3 = pRef[3-kiStride];
const uint8_t kuiT4 = pRef[4-kiStride];
const uint8_t kuiT5 = pRef[5-kiStride];
const uint8_t kuiT6 = pRef[6-kiStride];
const uint8_t kuiT7 = pRef[7-kiStride];
const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1<<1))>>2;
const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2<<1))>>2;
const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3<<1))>>2;
const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4<<1))>>2;
const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5<<1))>>2;
const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6<<1))>>2;
const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7<<1))>>2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiT4 = pRef[4 - kiStride];
const uint8_t kuiT5 = pRef[5 - kiStride];
const uint8_t kuiT6 = pRef[6 - kiStride];
const uint8_t kuiT7 = pRef[7 - kiStride];
const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2;
const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2;
const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2;
const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2;
const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2;
const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2;
const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = kuiDDL0;
uiV[1] = uiV[4] = kuiDDL1;
uiV[2] = uiV[5] = uiV[8] = kuiDDL2;
uiV[3] = uiV[6] = uiV[9] = uiV[12] = kuiDDL3;
uiV[7] = uiV[10]= uiV[13]= kuiDDL4;
uiV[11]= uiV[14]= kuiDDL5;
uiV[7] = uiV[10] = uiV[13] = kuiDDL4;
uiV[11] = uiV[14] = kuiDDL5;
uiV[15] = kuiDDL6;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredDDL_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredDDL_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
delete []pRef;
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDLTop) {
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDLTop) {
const int32_t kiStride = 0;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[64];
for (int i=0; i<64; i++)
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256;
const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1-kiStride];
const uint8_t kuiT2 = pRef[2-kiStride];
const uint8_t kuiT3 = pRef[3-kiStride];
const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1<<1))>>2;
const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2<<1))>>2;
const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3<<1))>>2;
const uint8_t kuiDLT3 = (2 + (kuiT3<<2))>>2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
memset(&uiV[6], kuiDLT3, 10*sizeof(uint8_t));
const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2;
const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2;
const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3 << 1)) >> 2;
const uint8_t kuiDLT3 = (2 + (kuiT3 << 2)) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
memset (&uiV[6], kuiDLT3, 10 * sizeof (uint8_t));
uiV[0] = kuiDLT0;
uiV[1] = uiV[4] = kuiDLT1;
uiV[2] = uiV[5] = uiV[8] = kuiDLT2;
uiV[3] = kuiDLT3;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredDDLTop_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredDDLTop_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
delete []pRef;
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
const int32_t kiStride = rand()%256+16;
const int32_t kiStride2 = kiStride<<1;
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
const int32_t kiStride = rand() % 256 + 16;
const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[kiStride3+kiStride+1];
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1];
for (int i=0; i<kiStride3+kiStride+1; i++)
for (int i = 0; i < kiStride3 + kiStride + 1; i++)
pRef[i] = rand() % 256;
pRef += kiStride + 1;
const uint8_t kuiLT = pRef[-kiStride-1];
const uint8_t kuiLT = pRef[-kiStride - 1];
const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride-1];
const uint8_t kuiL2 = pRef[kiStride2-1];
const uint8_t kuiL3 = pRef[kiStride3-1];
const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStride2 - 1];
const uint8_t kuiL3 = pRef[kiStride3 - 1];
const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1-kiStride];
const uint8_t kuiT2 = pRef[2-kiStride];
const uint8_t kuiT3 = pRef[3-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride];
const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
@ -182,21 +181,21 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2;
const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = uiV[5] = uiV[10] = uiV[15] = kuiDDR0;
uiV[1] = uiV[6] = uiV[11] = kuiDDR1;
uiV[2] = uiV[7] = kuiDDR2;
uiV[3] = kuiDDR3;
uiV[4] = uiV[9] = uiV[14] = kuiDDR4;
uiV[8] = uiV[13] = kuiDDR5;
uiV[12]= kuiDDR6;
uiV[12] = kuiDDR6;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredDDR_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredDDR_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
pRef -= kiStride + 1;
@ -204,94 +203,94 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVL) {
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVL) {
const int32_t kiStride = 0;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[64];
for (int i=0; i<64; i++)
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256;
const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1-kiStride];
const uint8_t kuiT2 = pRef[2-kiStride];
const uint8_t kuiT3 = pRef[3-kiStride];
const uint8_t kuiT4 = pRef[4-kiStride];
const uint8_t kuiT5 = pRef[5-kiStride];
const uint8_t kuiT6 = pRef[6-kiStride];
const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1)>>1;
const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2)>>1;
const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3)>>1;
const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4)>>1;
const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5)>>1;
const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1<<1) + kuiT2)>>2;
const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2<<1) + kuiT3)>>2;
const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3<<1) + kuiT4)>>2;
const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4<<1) + kuiT5)>>2;
const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5<<1) + kuiT6)>>2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiT4 = pRef[4 - kiStride];
const uint8_t kuiT5 = pRef[5 - kiStride];
const uint8_t kuiT6 = pRef[6 - kiStride];
const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1) >> 1;
const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2) >> 1;
const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3) >> 1;
const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4) >> 1;
const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5) >> 1;
const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3 << 1) + kuiT4) >> 2;
const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4 << 1) + kuiT5) >> 2;
const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5 << 1) + kuiT6) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = kuiVL0;
uiV[1] = uiV[8] = kuiVL1;
uiV[2] = uiV[9] = kuiVL2;
uiV[3] = uiV[10]= kuiVL3;
uiV[3] = uiV[10] = kuiVL3;
uiV[4] = kuiVL5;
uiV[5] = uiV[12] = kuiVL6;
uiV[6] = uiV[13] = kuiVL7;
uiV[7] = uiV[14] = kuiVL8;
uiV[11]= kuiVL4;
uiV[15]= kuiVL9;
uiV[11] = kuiVL4;
uiV[15] = kuiVL9;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredVL_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredVL_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
delete []pRef;
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVLTop) {
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVLTop) {
const int32_t kiStride = 0;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[64];
for (int i=0; i<64; i++)
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256;
pRef++;
uint8_t *pTopLeft = &pRef[-kiStride-1]; // top-left
uint8_t* pTopLeft = &pRef[-kiStride - 1]; // top-left
const uint8_t kuiT0 = *(pTopLeft+1);
const uint8_t kuiT1 = *(pTopLeft+2);
const uint8_t kuiT2 = *(pTopLeft+3);
const uint8_t kuiT3 = *(pTopLeft+4);
const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1)>>1;
const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2)>>1;
const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3)>>1;
const uint8_t kuiVLT3 = (1 + (kuiT3<<1))>>1;
const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1<<1) + kuiT2)>>2;
const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2<<1) + kuiT3)>>2;
const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3<<1) + kuiT3)>>2;
const uint8_t kuiVLT7 = (2 + (kuiT3<<2))>>2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
const uint8_t kuiT0 = * (pTopLeft + 1);
const uint8_t kuiT1 = * (pTopLeft + 2);
const uint8_t kuiT2 = * (pTopLeft + 3);
const uint8_t kuiT3 = * (pTopLeft + 4);
const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1) >> 1;
const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2) >> 1;
const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3) >> 1;
const uint8_t kuiVLT3 = (1 + (kuiT3 << 1)) >> 1;
const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3 << 1) + kuiT3) >> 2;
const uint8_t kuiVLT7 = (2 + (kuiT3 << 2)) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = kuiVLT0;
uiV[1] = uiV[8] = kuiVLT1;
uiV[2] = uiV[9] = kuiVLT2;
uiV[3] = uiV[10]= uiV[11] = kuiVLT3;
uiV[3] = uiV[10] = uiV[11] = kuiVLT3;
uiV[4] = kuiVLT4;
uiV[5] = uiV[12] = kuiVLT5;
uiV[6] = uiV[13] = kuiVLT6;
uiV[7] = uiV[14] = uiV[15] = kuiVLT7;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredVLTop_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredVLTop_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
pRef--;
@ -299,26 +298,26 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVLTop) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
const int32_t kiStride = rand()%256+16;
const int32_t kiStride2 = kiStride<<1;
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
const int32_t kiStride = rand() % 256 + 16;
const int32_t kiStride2 = kiStride << 1;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[kiStride2+kiStride+1];
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[kiStride2 + kiStride + 1];
for (int i=0; i<kiStride2+kiStride+1; i++)
for (int i = 0; i < kiStride2 + kiStride + 1; i++)
pRef[i] = rand() % 256;
pRef += kiStride + 1;
const uint8_t kuiLT = pRef[-kiStride-1]; // top-left
const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left
const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride-1];
const uint8_t kuiL2 = pRef[kiStride2-1];
const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStride2 - 1];
const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1-kiStride];
const uint8_t kuiT2 = pRef[2-kiStride];
const uint8_t kuiT3 = pRef[3-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1;
const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1;
const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1;
@ -329,7 +328,7 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2;
const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = uiV[9] = kuiVR0;
uiV[1] = uiV[10] = kuiVR1;
uiV[2] = uiV[11] = kuiVR2;
@ -339,14 +338,14 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
uiV[6] = uiV[15] = kuiVR6;
uiV[7] = kuiVR7;
uiV[8] = kuiVR8;
uiV[12]= kuiVR9;
uiV[12] = kuiVR9;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredVR_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredVR_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
pRef -= kiStride + 1;
@ -354,23 +353,23 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHU) {
const int32_t kiStride = rand()%256+16;
const int32_t kiStride2 = kiStride<<1;
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHU) {
const int32_t kiStride = rand() % 256 + 16;
const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[kiStride3+1];
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[kiStride3 + 1];
for (int i=0; i<kiStride3+1; i++)
for (int i = 0; i < kiStride3 + 1; i++)
pRef[i] = rand() % 256;
pRef++;
const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride-1];
const uint8_t kuiL2 = pRef[kiStride2-1];
const uint8_t kuiL3 = pRef[kiStride3-1];
const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStride2 - 1];
const uint8_t kuiL3 = pRef[kiStride3 - 1];
const uint16_t kuiL01 = (1 + kuiL0 + kuiL1);
const uint16_t kuiL12 = (1 + kuiL1 + kuiL2);
const uint16_t kuiL23 = (1 + kuiL2 + kuiL3);
@ -380,21 +379,21 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHU) {
const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2;
const uint8_t kuiHU4 = kuiL23 >> 1;
const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = kuiHU0;
uiV[1] = kuiHU1;
uiV[2] = uiV[4] = kuiHU2;
uiV[3] = uiV[5] = kuiHU3;
uiV[6] = uiV[8] = kuiHU4;
uiV[7] = uiV[9] = kuiHU5;
memset(&uiV[10], kuiL3, 6*sizeof(uint8_t));
memset (&uiV[10], kuiL3, 6 * sizeof (uint8_t));
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredHU_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredHU_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
pRef--;
@ -402,38 +401,38 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHU) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHD) {
const int32_t kiStride = rand()%256+16;
const int32_t kiStride2 = kiStride<<1;
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHD) {
const int32_t kiStride = rand() % 256 + 16;
const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2;
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[kiStride3+kiStride+1];
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1];
for (int i=0; i<kiStride3+kiStride+1; i++)
for (int i = 0; i < kiStride3 + kiStride + 1; i++)
pRef[i] = rand() % 256;
pRef += kiStride + 1;
const uint8_t kuiLT = pRef[-kiStride-1]; // top-left
const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left
const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride-1];
const uint8_t kuiL2 = pRef[kiStride2-1];
const uint8_t kuiL3 = pRef[kiStride3-1];
const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStride2 - 1];
const uint8_t kuiL3 = pRef[kiStride3 - 1];
const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1-kiStride];
const uint8_t kuiT2 = pRef[2-kiStride];
const uint8_t kuiHD0 = (1 + kuiLT + kuiL0)>>1;
const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT<<1) + kuiT0)>>2;
const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0<<1) + kuiT1)>>2;
const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1<<1) + kuiT2)>>2;
const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1)>>1;
const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0<<1) + kuiL1)>>2;
const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2)>>1;
const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1<<1) + kuiL2)>>2;
const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3)>>1;
const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2<<1) + kuiL3)>>2;
ENFORCE_STACK_ALIGN_1D(uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiHD0 = (1 + kuiLT + kuiL0) >> 1;
const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2;
const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2;
const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1) >> 1;
const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2;
const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2) >> 1;
const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2;
const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1;
const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
uiV[0] = uiV[6] = kuiHD0;
uiV[1] = uiV[7] = kuiHD1;
uiV[2] = kuiHD2;
@ -446,11 +445,11 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHD) {
uiV[13] = kuiHD9;
const uint32_t kuiCpuFlag = 0;
WelsInitFillingPredFuncs(kuiCpuFlag);
WelsI4x4LumaPredHD_c(pPred, pRef, kiStride);
WelsInitFillingPredFuncs (kuiCpuFlag);
WelsI4x4LumaPredHD_c (pPred, pRef, kiStride);
for (int i=0; i<4; i++)
EXPECT_EQ(LD32(&pPred[4*i]),LD32(&uiV[4*i]));
for (int i = 0; i < 4; i++)
EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
pRef -= kiStride + 1;
@ -458,52 +457,52 @@ TEST(GetIntraPredictorTest, TestGetI4x4LumaPredHD) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetIChormaPredV) {
uint8_t *pPred = new uint8_t[64];
uint8_t *pRef = new uint8_t[64];
for (int i=0; i<64; i++)
TEST (GetIntraPredictorTest, TestGetIChormaPredV) {
uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256 + 1;
const int32_t kiStride = 0;
WelsIChormaPredV_c(pPred, pRef, kiStride);
WelsIChormaPredV_c (pPred, pRef, kiStride);
for (int i=0; i<8; i++)
EXPECT_EQ(LD32(&pPred[8*i]),LD32(&pRef[-kiStride]));
for (int i = 0; i < 8; i++)
EXPECT_EQ (LD32 (&pPred[8 * i]), LD32 (&pRef[-kiStride]));
delete []pRef;
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI16x16LumaPredPlane) {
const int32_t kiStride = rand()%16+16;
TEST (GetIntraPredictorTest, TestGetI16x16LumaPredPlane) {
const int32_t kiStride = rand() % 16 + 16;
int32_t i, j;
uint8_t *pPred = new uint8_t[16*kiStride];
uint8_t *pRef = new uint8_t[16*kiStride+1];
for (i=0; i<16*kiStride+1; i++)
pRef[i]=rand()%256+1;
uint8_t* pPred = new uint8_t[16 * kiStride];
uint8_t* pRef = new uint8_t[16 * kiStride + 1];
for (i = 0; i < 16 * kiStride + 1; i++)
pRef[i] = rand() % 256 + 1;
pRef += kiStride + 1;
int32_t iA=0, iB=0, iC=0, iH=0, iV=0;
uint8_t *pTop = &pRef[-kiStride];
uint8_t *pLeft = &pRef[-1];
int32_t iA = 0, iB = 0, iC = 0, iH = 0, iV = 0;
uint8_t* pTop = &pRef[-kiStride];
uint8_t* pLeft = &pRef[-1];
int32_t iPredStride = 16;
for (i=0; i<8; i++) {
for (i = 0; i < 8; i++) {
iH += (i + 1) * (pTop[8 + i] - pTop[6 - i]);
iV += (i + 1) * (pLeft[(8 + i)*kiStride] - pLeft[(6 - i)*kiStride]);
iV += (i + 1) * (pLeft[ (8 + i) * kiStride] - pLeft[ (6 - i) * kiStride]);
}
iA = (pLeft[15*kiStride] + pTop[15]) << 4;
iA = (pLeft[15 * kiStride] + pTop[15]) << 4;
iB = (5 * iH + 32) >> 6;
iC = (5 * iV + 32) >> 6;
WelsI16x16LumaPredPlane_c(pPred, pRef, kiStride);
for (i=0; i<16; i++) {
for (j=0; j<16; j++) {
EXPECT_EQ(pPred[j],(uint8_t)WelsClip1((iA + iB * (j - 7) + iC * (i - 7) + 16) >> 5));
WelsI16x16LumaPredPlane_c (pPred, pRef, kiStride);
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
EXPECT_EQ (pPred[j], (uint8_t)WelsClip1 ((iA + iB * (j - 7) + iC * (i - 7) + 16) >> 5));
}
pPred += iPredStride;
}
@ -514,14 +513,14 @@ TEST(GetIntraPredictorTest, TestGetI16x16LumaPredPlane) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDc) {
const int32_t kiStride = rand()%16+16;
TEST (GetIntraPredictorTest, TestGetI16x16LumaPredDc) {
const int32_t kiStride = rand() % 16 + 16;
int i;
uint8_t *pPred = new uint8_t[256];
uint8_t *pRef = new uint8_t[16*kiStride];
for (i=0; i<16*kiStride; i++)
uint8_t* pPred = new uint8_t[256];
uint8_t* pRef = new uint8_t[16 * kiStride];
for (i = 0; i < 16 * kiStride; i++)
pRef[i] = rand() % 256 + 1;
pRef += kiStride;
@ -532,14 +531,14 @@ TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDc) {
uint8_t uiMean = 0;
do {
iSum += pRef[-1+iTmp] + pRef[-kiStride+i];
iSum += pRef[-1 + iTmp] + pRef[-kiStride + i];
iTmp -= kiStride;
} while(i-- > 0);
uiMean = ( 16 + iSum ) >> 5;
} while (i-- > 0);
uiMean = (16 + iSum) >> 5;
WelsI16x16LumaPredDc_c(pPred, pRef, kiStride);
for (i=0; i<256; i++)
EXPECT_EQ(pPred[i],uiMean);
WelsI16x16LumaPredDc_c (pPred, pRef, kiStride);
for (i = 0; i < 256; i++)
EXPECT_EQ (pPred[i], uiMean);
pRef -= kiStride;
@ -547,14 +546,14 @@ TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDc) {
delete []pPred;
}
TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDcTop) {
const int32_t kiStride = rand()%16+16;
TEST (GetIntraPredictorTest, TestGetI16x16LumaPredDcTop) {
const int32_t kiStride = rand() % 16 + 16;
int i;
uint8_t *pPred = new uint8_t[256];
uint8_t *pRef = new uint8_t[16*kiStride];
for (i=0; i<16*kiStride; i++)
uint8_t* pPred = new uint8_t[256];
uint8_t* pRef = new uint8_t[16 * kiStride];
for (i = 0; i < 16 * kiStride; i++)
pRef[i] = rand() % 256 + 1;
pRef += kiStride;
@ -563,13 +562,13 @@ TEST(GetIntraPredictorTest, TestGetI16x16LumaPredDcTop) {
i = 15;
uint8_t uiMean = 0;
do {
iSum += pRef[-kiStride+i];
} while(i-- > 0);
uiMean = ( 8 + iSum ) >> 4;
iSum += pRef[-kiStride + i];
} while (i-- > 0);
uiMean = (8 + iSum) >> 4;
WelsI16x16LumaPredDcTop_c(pPred, pRef, kiStride);
for (i=0; i<256; i++)
EXPECT_EQ(pPred[i],uiMean);
WelsI16x16LumaPredDcTop_c (pPred, pRef, kiStride);
for (i = 0; i < 256; i++)
EXPECT_EQ (pPred[i], uiMean);
pRef -= kiStride;

View File

@ -6,54 +6,54 @@
using namespace WelsSVCEnc;
//Tests of WelsGetCacheLineSize Begin
TEST(MemoryAlignTest, GetCacheLineSize_LoopWithin16K) {
TEST (MemoryAlignTest, GetCacheLineSize_LoopWithin16K) {
const unsigned int kuiTestBoundary16K = 16 * 1024;
unsigned int uiTargetAlign = 1;
while (uiTargetAlign < kuiTestBoundary16K) {
CMemoryAlign cTestMa(uiTargetAlign);
ASSERT_EQ( (uiTargetAlign & 0x0F)?16:uiTargetAlign, cTestMa.WelsGetCacheLineSize() );
++ uiTargetAlign;
}
unsigned int uiTargetAlign = 1;
while (uiTargetAlign < kuiTestBoundary16K) {
CMemoryAlign cTestMa (uiTargetAlign);
ASSERT_EQ ((uiTargetAlign & 0x0F) ? 16 : uiTargetAlign, cTestMa.WelsGetCacheLineSize());
++ uiTargetAlign;
}
}
TEST(MemoryAlignTest, GetCacheLineSize_Zero) {
CMemoryAlign cTestMa(0);
TEST (MemoryAlignTest, GetCacheLineSize_Zero) {
CMemoryAlign cTestMa (0);
const uint32_t kuiSixteen = 16;
ASSERT_EQ( kuiSixteen, cTestMa.WelsGetCacheLineSize() );
ASSERT_EQ (kuiSixteen, cTestMa.WelsGetCacheLineSize());
}
TEST(MemoryAlignTest, GetCacheLineSize_MaxUINT) {
CMemoryAlign cTestMa(0xFFFFFFFF);
const uint32_t kuiSixteen = 16;
ASSERT_EQ( kuiSixteen, cTestMa.WelsGetCacheLineSize() );
TEST (MemoryAlignTest, GetCacheLineSize_MaxUINT) {
CMemoryAlign cTestMa (0xFFFFFFFF);
const uint32_t kuiSixteen = 16;
ASSERT_EQ (kuiSixteen, cTestMa.WelsGetCacheLineSize());
}
//Tests of WelsGetCacheLineSize End
//Tests of WelsMallocAndFree Begin
TEST(MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) {
TEST (MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) {
const uint32_t kuiTargetAlignSize[4] = {32, 16, 64, 8};
srand((uint32_t)time(NULL));
srand ((uint32_t)time (NULL));
const uint32_t kuiZero = 0;
for (int i=0; i<4; i++) {
for (int i = 0; i < 4; i++) {
const uint32_t kuiTestAlignSize = kuiTargetAlignSize[i];
const uint32_t kuiTestDataSize = abs(rand());
const uint32_t kuiTestDataSize = abs (rand());
CMemoryAlign cTestMa(kuiTestAlignSize);
CMemoryAlign cTestMa (kuiTestAlignSize);
const uint32_t uiSize = kuiTestDataSize;
const char strUnitTestTag[100] = "pUnitTestData";
const uint32_t kuiUsedCacheLineSize = ((kuiTestAlignSize == 0) || (kuiTestAlignSize & 0x0F)) ? (16) : (kuiTestAlignSize);
const uint32_t kuiExtraAlignSize = kuiUsedCacheLineSize-1;
const uint32_t kuiExpectedSize = sizeof( void ** ) + sizeof( int32_t ) + kuiExtraAlignSize + uiSize;
uint8_t *pUnitTestData = static_cast<uint8_t *>(cTestMa.WelsMalloc(uiSize, strUnitTestTag));
if ( pUnitTestData != NULL ) {
ASSERT_TRUE( (((uintptr_t)(pUnitTestData)) & kuiExtraAlignSize) == 0 );
EXPECT_EQ( kuiExpectedSize, cTestMa.WelsGetMemoryUsage() );
cTestMa.WelsFree( pUnitTestData, strUnitTestTag );
EXPECT_EQ( kuiZero, cTestMa.WelsGetMemoryUsage() );
}
else {
EXPECT_EQ( NULL, pUnitTestData );
EXPECT_EQ( kuiZero, cTestMa.WelsGetMemoryUsage() );
cTestMa.WelsFree( pUnitTestData, strUnitTestTag );
EXPECT_EQ( kuiZero, cTestMa.WelsGetMemoryUsage() );
const uint32_t kuiUsedCacheLineSize = ((kuiTestAlignSize == 0)
|| (kuiTestAlignSize & 0x0F)) ? (16) : (kuiTestAlignSize);
const uint32_t kuiExtraAlignSize = kuiUsedCacheLineSize - 1;
const uint32_t kuiExpectedSize = sizeof (void**) + sizeof (int32_t) + kuiExtraAlignSize + uiSize;
uint8_t* pUnitTestData = static_cast<uint8_t*> (cTestMa.WelsMalloc (uiSize, strUnitTestTag));
if (pUnitTestData != NULL) {
ASSERT_TRUE ((((uintptr_t) (pUnitTestData)) & kuiExtraAlignSize) == 0);
EXPECT_EQ (kuiExpectedSize, cTestMa.WelsGetMemoryUsage());
cTestMa.WelsFree (pUnitTestData, strUnitTestTag);
EXPECT_EQ (kuiZero, cTestMa.WelsGetMemoryUsage());
} else {
EXPECT_EQ (NULL, pUnitTestData);
EXPECT_EQ (kuiZero, cTestMa.WelsGetMemoryUsage());
cTestMa.WelsFree (pUnitTestData, strUnitTestTag);
EXPECT_EQ (kuiZero, cTestMa.WelsGetMemoryUsage());
}
}
}

View File

@ -9,30 +9,30 @@
using namespace WelsSVCEnc;
void CopyTargetBlock( uint8_t* pSrcBlock, const int32_t kiBlockSize, SMVUnitXY sTargetMv, const int32_t kiRefPicStride,
uint8_t* pRefPic) {
uint8_t* pTargetPos = pRefPic+sTargetMv.iMvY*kiRefPicStride+sTargetMv.iMvX;
void CopyTargetBlock (uint8_t* pSrcBlock, const int32_t kiBlockSize, SMVUnitXY sTargetMv, const int32_t kiRefPicStride,
uint8_t* pRefPic) {
uint8_t* pTargetPos = pRefPic + sTargetMv.iMvY * kiRefPicStride + sTargetMv.iMvX;
uint8_t* pSourcePos = pSrcBlock;
for (int i = 0; i<kiBlockSize; i++) {
memcpy( pSourcePos, pTargetPos, kiBlockSize*sizeof(uint8_t) );
for (int i = 0; i < kiBlockSize; i++) {
memcpy (pSourcePos, pTargetPos, kiBlockSize * sizeof (uint8_t));
pTargetPos += kiRefPicStride;
pSourcePos += kiBlockSize;
}
}
void InitMe( const uint8_t kuiQp, const uint32_t kuiMvdTableMiddle, const uint32_t kuiMvdTableStride,
uint16_t* pMvdCostTable, SWelsME* pMe) {
MvdCostInit( pMvdCostTable, kuiMvdTableStride );
pMe->pMvdCost = &pMvdCostTable[kuiQp*kuiMvdTableStride + kuiMvdTableMiddle];
void InitMe (const uint8_t kuiQp, const uint32_t kuiMvdTableMiddle, const uint32_t kuiMvdTableStride,
uint16_t* pMvdCostTable, SWelsME* pMe) {
MvdCostInit (pMvdCostTable, kuiMvdTableStride);
pMe->pMvdCost = &pMvdCostTable[kuiQp * kuiMvdTableStride + kuiMvdTableMiddle];
pMe->sMvp.iMvX = pMe->sMvp.iMvY = 0;
pMe->sMvBase.iMvX = pMe->sMvBase.iMvY = 0;
pMe->sMv.iMvX = pMe->sMv.iMvY = 0;
}
class MotionEstimateTest : public ::testing::Test {
public:
public:
virtual void SetUp() {
m_pRefData = NULL;
m_pSrcBlock = NULL;
@ -41,72 +41,72 @@ public:
m_iWidth = 64;//size of search window
m_iHeight = 64;//size of search window
m_iMaxSearchBlock = 16;
m_uiMvdTableSize = (1 + (648 << 1));
m_uiMvdTableSize = (1 + (648 << 1));
pMa = new CMemoryAlign(0);
m_pRefData = static_cast<uint8_t *>
(pMa->WelsMalloc(m_iWidth*m_iHeight, "RefPic"));
ASSERT_TRUE( NULL != m_pRefData );
m_pSrcBlock = static_cast<uint8_t *>
(pMa->WelsMalloc(m_iMaxSearchBlock*m_iMaxSearchBlock, "SrcBlock"));
ASSERT_TRUE( NULL != m_pSrcBlock );
m_pMvdCostTable=new uint16_t[52*m_uiMvdTableSize];
ASSERT_TRUE( NULL != m_pMvdCostTable );
pMa = new CMemoryAlign (0);
m_pRefData = static_cast<uint8_t*>
(pMa->WelsMalloc (m_iWidth * m_iHeight, "RefPic"));
ASSERT_TRUE (NULL != m_pRefData);
m_pSrcBlock = static_cast<uint8_t*>
(pMa->WelsMalloc (m_iMaxSearchBlock * m_iMaxSearchBlock, "SrcBlock"));
ASSERT_TRUE (NULL != m_pSrcBlock);
m_pMvdCostTable = new uint16_t[52 * m_uiMvdTableSize];
ASSERT_TRUE (NULL != m_pMvdCostTable);
}
void DoLineTest(PLineFullSearchFunc func, bool horizontal);
void DoLineTest (PLineFullSearchFunc func, bool horizontal);
virtual void TearDown() {
delete [] m_pMvdCostTable;
pMa->WelsFree( m_pRefData, "RefPic");
pMa->WelsFree( m_pSrcBlock, "SrcBlock");
pMa->WelsFree (m_pRefData, "RefPic");
pMa->WelsFree (m_pSrcBlock, "SrcBlock");
delete pMa;
}
public:
uint8_t *m_pRefData;
uint8_t *m_pSrcBlock;
public:
uint8_t* m_pRefData;
uint8_t* m_pSrcBlock;
uint32_t m_uiMvdTableSize;
uint16_t *m_pMvdCostTable;
uint16_t* m_pMvdCostTable;
int32_t m_iWidth;
int32_t m_iHeight;
int32_t m_iMaxSearchBlock;
CMemoryAlign *pMa;
CMemoryAlign* pMa;
};
TEST_F(MotionEstimateTest, TestDiamondSearch) {
TEST_F (MotionEstimateTest, TestDiamondSearch) {
#define TEST_POS (5)
const int32_t kiPositionToCheck[TEST_POS][2] = {{0,0}, {0,1}, {1,0}, {0,-1}, {-1,0}};
const int32_t kiPositionToCheck[TEST_POS][2] = {{0, 0}, {0, 1}, {1, 0}, {0, -1}, { -1, 0}};
const int32_t kiMaxBlock16Sad = 72000;//a rough number
SWelsFuncPtrList sFuncList;
SWelsME sMe;
SSlice sSlice;
srand((uint32_t)time(NULL));
const uint8_t kuiQp = rand()%52;
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
srand ((uint32_t)time (NULL));
const uint8_t kuiQp = rand() % 52;
InitMe (kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
SMVUnitXY sTargetMv;
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
WelsInitSampleSadFunc (&sFuncList, 0); //test c functions
uint8_t *pRefPicCenter = m_pRefData+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
uint8_t* pRefPicCenter = m_pRefData + (m_iHeight / 2) * m_iWidth + (m_iWidth / 2);
bool bDataGeneratorSucceed = false;
bool bFoundMatch = false;
int32_t i, iTryTimes;
for (i=0;i<TEST_POS;i++) {
for (i = 0; i < TEST_POS; i++) {
sTargetMv.iMvX = kiPositionToCheck[i][0];
sTargetMv.iMvY = kiPositionToCheck[i][1];
iTryTimes = 100;
bDataGeneratorSucceed = false;
bFoundMatch = false;
while (!bFoundMatch && (iTryTimes--)>0) {
if (!YUVPixelDataGenerator( m_pRefData, m_iWidth, m_iHeight, m_iWidth ))
while (!bFoundMatch && (iTryTimes--) > 0) {
if (!YUVPixelDataGenerator (m_pRefData, m_iWidth, m_iHeight, m_iWidth))
continue;
bDataGeneratorSucceed = true;
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
CopyTargetBlock (m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
//clean the sMe status
sMe.uiBlockSize = rand()%5;
sMe.uiBlockSize = rand() % 5;
sMe.pEncMb = m_pSrcBlock;
sMe.pRefMb = pRefPicCenter;
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
@ -115,122 +115,121 @@ TEST_F(MotionEstimateTest, TestDiamondSearch) {
//the last selection may be affected by MVDcost, that is when (0,0) will be better
//when comparing (1,1) and (1,0), due to the difference between MVD cost, it is possible that (1,0) is selected while the best match is (1,1)
bFoundMatch = ((sMe.sMv.iMvX==(sTargetMv.iMvX))||(sMe.sMv.iMvX==0)) && ((sMe.sMv.iMvY==(sTargetMv.iMvY))||(sMe.sMv.iMvY==0));
bFoundMatch = ((sMe.sMv.iMvX == (sTargetMv.iMvX)) || (sMe.sMv.iMvX == 0)) && ((sMe.sMv.iMvY == (sTargetMv.iMvY))
|| (sMe.sMv.iMvY == 0));
}
if (bDataGeneratorSucceed) {
//if DataGenerator never succeed, there is no meaning to check iTryTimes
ASSERT_TRUE(iTryTimes > 0);
ASSERT_TRUE (iTryTimes > 0);
//it is possible that ref at differnt position is identical, but that should be under a low probability
}
}
}
void MotionEstimateTest::DoLineTest(PLineFullSearchFunc func, bool vertical) {
void MotionEstimateTest::DoLineTest (PLineFullSearchFunc func, bool vertical) {
const int32_t kiMaxBlock16Sad = 72000;//a rough number
SWelsFuncPtrList sFuncList;
SWelsME sMe;
srand((uint32_t)time(NULL));
const uint8_t kuiQp = rand()%52;
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
srand ((uint32_t)time (NULL));
const uint8_t kuiQp = rand() % 52;
InitMe (kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
SMVUnitXY sTargetMv;
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
WelsInitMeFunc(&sFuncList, WelsCPUFeatureDetect(NULL), 1);
WelsInitSampleSadFunc (&sFuncList, 0); //test c functions
WelsInitMeFunc (&sFuncList, WelsCPUFeatureDetect (NULL), 1);
uint8_t *pRefPicCenter = m_pRefData+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
sMe.iCurMeBlockPixX = (m_iWidth/2);
sMe.iCurMeBlockPixY = (m_iHeight/2);
uint8_t* pRefPicCenter = m_pRefData + (m_iHeight / 2) * m_iWidth + (m_iWidth / 2);
sMe.iCurMeBlockPixX = (m_iWidth / 2);
sMe.iCurMeBlockPixY = (m_iHeight / 2);
bool bDataGeneratorSucceed = false;
bool bFoundMatch = false;
int32_t iTryTimes=100;
int32_t iTryTimes = 100;
if (vertical) {
sTargetMv.iMvX = 0;
sTargetMv.iMvY = -sMe.iCurMeBlockPixY + INTPEL_NEEDED_MARGIN + rand()%(m_iHeight - 16 - 2*INTPEL_NEEDED_MARGIN);
sTargetMv.iMvY = -sMe.iCurMeBlockPixY + INTPEL_NEEDED_MARGIN + rand() % (m_iHeight - 16 - 2 * INTPEL_NEEDED_MARGIN);
} else {
sTargetMv.iMvX = -sMe.iCurMeBlockPixX + INTPEL_NEEDED_MARGIN + rand()%(m_iWidth - 16 - 2*INTPEL_NEEDED_MARGIN);
sTargetMv.iMvX = -sMe.iCurMeBlockPixX + INTPEL_NEEDED_MARGIN + rand() % (m_iWidth - 16 - 2 * INTPEL_NEEDED_MARGIN);
sTargetMv.iMvY = 0;
}
bDataGeneratorSucceed = false;
bFoundMatch = false;
while (!bFoundMatch && (iTryTimes--)>0) {
if (!YUVPixelDataGenerator( m_pRefData, m_iWidth, m_iHeight, m_iWidth ))
while (!bFoundMatch && (iTryTimes--) > 0) {
if (!YUVPixelDataGenerator (m_pRefData, m_iWidth, m_iHeight, m_iWidth))
continue;
bDataGeneratorSucceed = true;
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
CopyTargetBlock (m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
//clean the sMe status
sMe.uiBlockSize = rand()%5;
sMe.uiBlockSize = rand() % 5;
sMe.pEncMb = m_pSrcBlock;
sMe.pRefMb = pRefPicCenter;
sMe.pColoRefMb = pRefPicCenter;
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
const int32_t iCurMeBlockPixX = sMe.iCurMeBlockPixX;
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX) << 2);
const int32_t iCurMeBlockPixY = sMe.iCurMeBlockPixY;
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY)<<2);
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY) << 2);
uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here
uint16_t* pMvdCostY = sMe.pMvdCost - iCurMeBlockQpelPixY - sMe.sMvp.iMvY;
uint16_t* pMvdCost = vertical ? pMvdCostY : pMvdCostX;
int iSize = vertical ? m_iHeight : m_iWidth;
int iFixedMvd = vertical ? pMvdCostX[ iCurMeBlockQpelPixX ] : pMvdCostY[ iCurMeBlockQpelPixY ];
func ( &sFuncList, &sMe,
pMvdCost, iFixedMvd,
m_iMaxSearchBlock, m_iWidth,
INTPEL_NEEDED_MARGIN,
iSize-INTPEL_NEEDED_MARGIN-16, vertical );
func (&sFuncList, &sMe,
pMvdCost, iFixedMvd,
m_iMaxSearchBlock, m_iWidth,
INTPEL_NEEDED_MARGIN,
iSize - INTPEL_NEEDED_MARGIN - 16, vertical);
//the last selection may be affected by MVDcost, that is when smaller MvY will be better
if (vertical) {
bFoundMatch = (sMe.sMv.iMvX==0
&&(sMe.sMv.iMvY==sTargetMv.iMvY||abs(sMe.sMv.iMvY)<abs(sTargetMv.iMvY)));
bFoundMatch = (sMe.sMv.iMvX == 0
&& (sMe.sMv.iMvY == sTargetMv.iMvY || abs (sMe.sMv.iMvY) < abs (sTargetMv.iMvY)));
} else {
bFoundMatch = (sMe.sMv.iMvY==0
&&(sMe.sMv.iMvX==sTargetMv.iMvX||abs(sMe.sMv.iMvX)<abs(sTargetMv.iMvX)));
bFoundMatch = (sMe.sMv.iMvY == 0
&& (sMe.sMv.iMvX == sTargetMv.iMvX || abs (sMe.sMv.iMvX) < abs (sTargetMv.iMvX)));
}
//printf("DoLineTest Target: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY);
}
if (bDataGeneratorSucceed) {
//if DataGenerator never succeed, there is no meaning to check iTryTimes
ASSERT_TRUE(iTryTimes > 0);
ASSERT_TRUE (iTryTimes > 0);
//it is possible that ref at differnt position is identical, but that should be under a low probability
}
}
TEST_F(MotionEstimateTest, TestVerticalSearch) {
DoLineTest(LineFullSearch_c, true);
TEST_F (MotionEstimateTest, TestVerticalSearch) {
DoLineTest (LineFullSearch_c, true);
}
TEST_F(MotionEstimateTest, TestHorizontalSearch) {
DoLineTest(LineFullSearch_c, false);
TEST_F (MotionEstimateTest, TestHorizontalSearch) {
DoLineTest (LineFullSearch_c, false);
}
#ifdef X86_ASM
TEST_F(MotionEstimateTest, TestVerticalSearch_SSE41)
{
TEST_F (MotionEstimateTest, TestVerticalSearch_SSE41) {
int32_t iTmp = 1;
uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iTmp);
uint32_t uiCPUFlags = WelsCPUFeatureDetect (&iTmp);
if ((uiCPUFlags & WELS_CPU_SSE41) == 0) return ;
DoLineTest(VerticalFullSearchUsingSSE41, true);
DoLineTest (VerticalFullSearchUsingSSE41, true);
}
TEST_F(MotionEstimateTest, TestHorizontalSearch_SSE41)
{
TEST_F (MotionEstimateTest, TestHorizontalSearch_SSE41) {
int32_t iTmp = 1;
uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iTmp);
uint32_t uiCPUFlags = WelsCPUFeatureDetect (&iTmp);
if ((uiCPUFlags & WELS_CPU_SSE41) == 0) return ;
DoLineTest(HorizontalFullSearchUsingSSE41, false);
DoLineTest (HorizontalFullSearchUsingSSE41, false);
}
#endif
class FeatureMotionEstimateTest : public ::testing::Test {
public:
public:
virtual void SetUp() {
m_pRefData = NULL;
m_pSrcBlock = NULL;
@ -239,66 +238,68 @@ public:
m_iWidth = 64;//size of search window
m_iHeight = 64;//size of search window
m_iMaxSearchBlock = 8;
m_uiMvdTableSize = (1 + (648 << 1));
m_uiMvdTableSize = (1 + (648 << 1));
m_pMa = new CMemoryAlign(16);
ASSERT_TRUE( NULL != m_pMa );
m_pRefData = (uint8_t*)m_pMa->WelsMalloc (m_iWidth*m_iHeight*sizeof (uint8_t), "m_pRefData");
ASSERT_TRUE( NULL != m_pRefData );
m_pSrcBlock = (uint8_t*)m_pMa->WelsMalloc (m_iMaxSearchBlock*m_iMaxSearchBlock*sizeof (uint8_t), "m_pSrcBlock");
ASSERT_TRUE( NULL != m_pSrcBlock );
m_pMvdCostTable = (uint16_t*)m_pMa->WelsMalloc (52*m_uiMvdTableSize*sizeof (uint16_t), "m_pMvdCostTable");
ASSERT_TRUE( NULL != m_pMvdCostTable );
m_pFeatureSearchPreparation = (SFeatureSearchPreparation*)m_pMa->WelsMalloc (sizeof (SFeatureSearchPreparation), "m_pFeatureSearchPreparation");
ASSERT_TRUE( NULL != m_pFeatureSearchPreparation );
m_pScreenBlockFeatureStorage = (SScreenBlockFeatureStorage*)m_pMa->WelsMalloc (sizeof (SScreenBlockFeatureStorage), "m_pScreenBlockFeatureStorage");
ASSERT_TRUE( NULL != m_pScreenBlockFeatureStorage );
m_pMa = new CMemoryAlign (16);
ASSERT_TRUE (NULL != m_pMa);
m_pRefData = (uint8_t*)m_pMa->WelsMalloc (m_iWidth * m_iHeight * sizeof (uint8_t), "m_pRefData");
ASSERT_TRUE (NULL != m_pRefData);
m_pSrcBlock = (uint8_t*)m_pMa->WelsMalloc (m_iMaxSearchBlock * m_iMaxSearchBlock * sizeof (uint8_t), "m_pSrcBlock");
ASSERT_TRUE (NULL != m_pSrcBlock);
m_pMvdCostTable = (uint16_t*)m_pMa->WelsMalloc (52 * m_uiMvdTableSize * sizeof (uint16_t), "m_pMvdCostTable");
ASSERT_TRUE (NULL != m_pMvdCostTable);
m_pFeatureSearchPreparation = (SFeatureSearchPreparation*)m_pMa->WelsMalloc (sizeof (SFeatureSearchPreparation),
"m_pFeatureSearchPreparation");
ASSERT_TRUE (NULL != m_pFeatureSearchPreparation);
m_pScreenBlockFeatureStorage = (SScreenBlockFeatureStorage*)m_pMa->WelsMalloc (sizeof (SScreenBlockFeatureStorage),
"m_pScreenBlockFeatureStorage");
ASSERT_TRUE (NULL != m_pScreenBlockFeatureStorage);
}
virtual void TearDown() {
if (m_pMa) {
if (m_pRefData) {
m_pMa->WelsFree(m_pRefData, "m_pRefData");
m_pMa->WelsFree (m_pRefData, "m_pRefData");
m_pRefData = NULL;
}
if (m_pSrcBlock) {
m_pMa->WelsFree(m_pSrcBlock, "m_pSrcBlock");
m_pMa->WelsFree (m_pSrcBlock, "m_pSrcBlock");
m_pSrcBlock = NULL;
}
if (m_pMvdCostTable) {
m_pMa->WelsFree(m_pMvdCostTable, "m_pMvdCostTable");
m_pMa->WelsFree (m_pMvdCostTable, "m_pMvdCostTable");
m_pMvdCostTable = NULL;
}
if (m_pFeatureSearchPreparation) {
ReleaseFeatureSearchPreparation( m_pMa, m_pFeatureSearchPreparation->pFeatureOfBlock);
m_pMa->WelsFree(m_pFeatureSearchPreparation, "m_pFeatureSearchPreparation");
ReleaseFeatureSearchPreparation (m_pMa, m_pFeatureSearchPreparation->pFeatureOfBlock);
m_pMa->WelsFree (m_pFeatureSearchPreparation, "m_pFeatureSearchPreparation");
m_pFeatureSearchPreparation = NULL;
}
if (m_pScreenBlockFeatureStorage) {
ReleaseScreenBlockFeatureStorage( m_pMa, m_pScreenBlockFeatureStorage );
m_pMa->WelsFree(m_pScreenBlockFeatureStorage, "m_pScreenBlockFeatureStorage");
ReleaseScreenBlockFeatureStorage (m_pMa, m_pScreenBlockFeatureStorage);
m_pMa->WelsFree (m_pScreenBlockFeatureStorage, "m_pScreenBlockFeatureStorage");
m_pScreenBlockFeatureStorage = NULL;
}
delete m_pMa;
m_pMa = NULL;
}
}
void InitRefPicForMeTest(SPicture* pRefPic) {
void InitRefPicForMeTest (SPicture* pRefPic) {
pRefPic->pData[0] = m_pRefData;
pRefPic->iLineSize[0] = m_iWidth;
pRefPic->iFrameAverageQp = rand()%52;
pRefPic->iFrameAverageQp = rand() % 52;
pRefPic->iWidthInPixel = m_iWidth;
pRefPic->iHeightInPixel = m_iHeight;
}
public:
public:
CMemoryAlign* m_pMa;
SFeatureSearchPreparation* m_pFeatureSearchPreparation;
SScreenBlockFeatureStorage* m_pScreenBlockFeatureStorage;
uint8_t *m_pRefData;
uint8_t *m_pSrcBlock;
uint16_t *m_pMvdCostTable;
uint8_t* m_pRefData;
uint8_t* m_pSrcBlock;
uint16_t* m_pMvdCostTable;
uint32_t m_uiMvdTableSize;
int32_t m_iWidth;
@ -306,52 +307,52 @@ public:
int32_t m_iMaxSearchBlock;
};
TEST_F(FeatureMotionEstimateTest, TestFeatureSearch) {
TEST_F (FeatureMotionEstimateTest, TestFeatureSearch) {
const int32_t kiMaxBlock16Sad = 72000;//a rough number
SWelsFuncPtrList sFuncList;
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
WelsInitMeFunc( &sFuncList, 0, true );
WelsInitSampleSadFunc (&sFuncList, 0); //test c functions
WelsInitMeFunc (&sFuncList, 0, true);
SWelsME sMe;
srand((uint32_t)time(NULL));
const uint8_t kuiQp = rand()%52;
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
sMe.iCurMeBlockPixX = (m_iWidth/2);
sMe.iCurMeBlockPixY = (m_iHeight/2);
uint8_t *pRefPicCenter = m_pRefData+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
srand ((uint32_t)time (NULL));
const uint8_t kuiQp = rand() % 52;
InitMe (kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
sMe.iCurMeBlockPixX = (m_iWidth / 2);
sMe.iCurMeBlockPixY = (m_iHeight / 2);
uint8_t* pRefPicCenter = m_pRefData + (m_iHeight / 2) * m_iWidth + (m_iWidth / 2);
SPicture sRef;
InitRefPicForMeTest(&sRef);
InitRefPicForMeTest (&sRef);
SSlice sSlice;
const int32_t kiSupposedPaddingLength=16;
SetMvWithinIntegerMvRange( m_iWidth/16-kiSupposedPaddingLength, m_iHeight/16-kiSupposedPaddingLength,
m_iWidth/2/16, m_iHeight/2/16, 508,
&(sSlice.sMvStartMin), &(sSlice.sMvStartMax));
const int32_t kiSupposedPaddingLength = 16;
SetMvWithinIntegerMvRange (m_iWidth / 16 - kiSupposedPaddingLength, m_iHeight / 16 - kiSupposedPaddingLength,
m_iWidth / 2 / 16, m_iHeight / 2 / 16, 508,
& (sSlice.sMvStartMin), & (sSlice.sMvStartMax));
int32_t iReturn;
const int32_t kiNeedFeatureStorage = ME_DIA_CROSS_FME;
iReturn = RequestFeatureSearchPreparation( m_pMa, m_iWidth, m_iHeight, kiNeedFeatureStorage,
m_pFeatureSearchPreparation);
ASSERT_TRUE( ENC_RETURN_SUCCESS==iReturn );
iReturn = RequestScreenBlockFeatureStorage( m_pMa, m_iWidth, m_iHeight, kiNeedFeatureStorage,
m_pScreenBlockFeatureStorage);
ASSERT_TRUE( ENC_RETURN_SUCCESS==iReturn );
iReturn = RequestFeatureSearchPreparation (m_pMa, m_iWidth, m_iHeight, kiNeedFeatureStorage,
m_pFeatureSearchPreparation);
ASSERT_TRUE (ENC_RETURN_SUCCESS == iReturn);
iReturn = RequestScreenBlockFeatureStorage (m_pMa, m_iWidth, m_iHeight, kiNeedFeatureStorage,
m_pScreenBlockFeatureStorage);
ASSERT_TRUE (ENC_RETURN_SUCCESS == iReturn);
SMVUnitXY sTargetMv;
for (int i=sSlice.sMvStartMin.iMvX; i<=sSlice.sMvStartMax.iMvX;i++) {
for (int j=sSlice.sMvStartMin.iMvY; j<=sSlice.sMvStartMax.iMvY;j++) {
if ( i==0 || j==0) continue;//exclude x=0 or y=0 since that will be skipped by FME
for (int i = sSlice.sMvStartMin.iMvX; i <= sSlice.sMvStartMax.iMvX; i++) {
for (int j = sSlice.sMvStartMin.iMvY; j <= sSlice.sMvStartMax.iMvY; j++) {
if (i == 0 || j == 0) continue; //exclude x=0 or y=0 since that will be skipped by FME
bool bDataGeneratorSucceed = false;
bool bFoundMatch = false;
if (!YUVPixelDataGenerator( m_pRefData, m_iWidth, m_iHeight, m_iWidth ))
if (!YUVPixelDataGenerator (m_pRefData, m_iWidth, m_iHeight, m_iWidth))
continue;
bDataGeneratorSucceed = true;
sTargetMv.iMvX = i;
sTargetMv.iMvY = j;
CopyTargetBlock( m_pSrcBlock, m_iMaxSearchBlock, sTargetMv, m_iWidth, pRefPicCenter );
CopyTargetBlock (m_pSrcBlock, m_iMaxSearchBlock, sTargetMv, m_iWidth, pRefPicCenter);
//clean sMe status
sMe.uiBlockSize = BLOCK_8x8;
@ -362,22 +363,25 @@ TEST_F(FeatureMotionEstimateTest, TestFeatureSearch) {
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
//begin FME process
PerformFMEPreprocess(&sFuncList, &sRef, m_pFeatureSearchPreparation->pFeatureOfBlock,
m_pScreenBlockFeatureStorage);
PerformFMEPreprocess (&sFuncList, &sRef, m_pFeatureSearchPreparation->pFeatureOfBlock,
m_pScreenBlockFeatureStorage);
m_pScreenBlockFeatureStorage->uiSadCostThreshold[BLOCK_8x8] = UINT_MAX;//to avoid early skip
uint32_t uiMaxSearchPoint = INT_MAX;
SFeatureSearchIn sFeatureSearchIn = {0};
if (SetFeatureSearchIn(&sFuncList, sMe, &sSlice, m_pScreenBlockFeatureStorage,
m_iMaxSearchBlock, m_iWidth,
&sFeatureSearchIn)) {
MotionEstimateFeatureFullSearch( sFeatureSearchIn, uiMaxSearchPoint, &sMe);
if (SetFeatureSearchIn (&sFuncList, sMe, &sSlice, m_pScreenBlockFeatureStorage,
m_iMaxSearchBlock, m_iWidth,
&sFeatureSearchIn)) {
MotionEstimateFeatureFullSearch (sFeatureSearchIn, uiMaxSearchPoint, &sMe);
}
bool bMvMatch = sMe.sMv.iMvX==sTargetMv.iMvX && sMe.sMv.iMvY==sTargetMv.iMvY;
bool bMvMatch = sMe.sMv.iMvX == sTargetMv.iMvX && sMe.sMv.iMvY == sTargetMv.iMvY;
bool bFeatureMatch =
( *(m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer +(m_iHeight/2+sTargetMv.iMvY)*(m_iWidth-8)+(m_iWidth/2+sTargetMv.iMvX))
== *(m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer +(m_iHeight/2+sMe.sMv.iMvY)*(m_iWidth-8)+(m_iWidth/2+sMe.sMv.iMvX)) )
&& ((sMe.pMvdCost[sMe.sMv.iMvY<<2]+sMe.pMvdCost[sMe.sMv.iMvX<<2]) <= (sMe.pMvdCost[sTargetMv.iMvY<<2]+sMe.pMvdCost[sTargetMv.iMvX<<2]));
(* (m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer + (m_iHeight / 2 + sTargetMv.iMvY) * (m_iWidth - 8) +
(m_iWidth / 2 + sTargetMv.iMvX))
== * (m_pScreenBlockFeatureStorage->pFeatureOfBlockPointer + (m_iHeight / 2 + sMe.sMv.iMvY) * (m_iWidth - 8) +
(m_iWidth / 2 + sMe.sMv.iMvX)))
&& ((sMe.pMvdCost[sMe.sMv.iMvY << 2] + sMe.pMvdCost[sMe.sMv.iMvX << 2]) <= (sMe.pMvdCost[sTargetMv.iMvY << 2] +
sMe.pMvdCost[sTargetMv.iMvX << 2]));
//the last selection may be affected by MVDcost, that is when smaller Mv will be better
bFoundMatch = bMvMatch || bFeatureMatch;
@ -385,9 +389,9 @@ TEST_F(FeatureMotionEstimateTest, TestFeatureSearch) {
if (bDataGeneratorSucceed) {
//if DataGenerator never succeed, there is no meaning to check iTryTimes
if (!bFoundMatch) {
printf("TestFeatureSearch Target: %d,%d, Result: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY, sMe.sMv.iMvX, sMe.sMv.iMvY);
printf ("TestFeatureSearch Target: %d,%d, Result: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY, sMe.sMv.iMvX, sMe.sMv.iMvY);
}
EXPECT_TRUE(bFoundMatch);
EXPECT_TRUE (bFoundMatch);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -16,36 +16,36 @@ using namespace nsWelsVP;
ASSERT_TRUE(0); \
}
TEST(ScrollDetectionTest,TestScroll)
{
TEST (ScrollDetectionTest, TestScroll) {
unsigned char* pSrc, *pRef;
int iWidthSets[4] = {640,1024,1280,1980};
int iHeightSets[4] = {360,768,720,1080};
int iWidthSets[4] = {640, 1024, 1280, 1980};
int iHeightSets[4] = {360, 768, 720, 1080};
int iStride = 0;
int iIdx = 0;
for(int i=0; i<4; i++){
for (int i = 0; i < 4; i++) {
int iWidth = iWidthSets[i];
int iHeight = iHeightSets[i];
iStride = iWidth + 16;
pSrc = new unsigned char[iHeight*iStride];
ASSERT_TRUE(NULL != pSrc);
pRef = new unsigned char[iHeight*iStride];
ASSERT_MEMORY_FAIL2X(pSrc, pRef)
RandomPixelDataGenerator(pRef, iWidth, iHeight, iStride, iIdx );
pSrc = new unsigned char[iHeight * iStride];
ASSERT_TRUE (NULL != pSrc);
pRef = new unsigned char[iHeight * iStride];
ASSERT_MEMORY_FAIL2X (pSrc, pRef)
RandomPixelDataGenerator (pRef, iWidth, iHeight, iStride, iIdx);
int iMvRange = iHeight/3;
int iScrollMv = rand()%(iMvRange<<1) - iMvRange;
int iMvRange = iHeight / 3;
int iScrollMv = rand() % (iMvRange << 1) - iMvRange;
unsigned char* pSrcTmp = pSrc;
unsigned char* pRefTmp = pRef;
for (int j=0;j<iHeight;j++) {
if ((j+iScrollMv)>=0 && (j+iScrollMv)<iHeight)
for (int i=0;i<iWidth;i++) {
memcpy(pSrcTmp , &pRefTmp[(j+iScrollMv)*iStride], iWidth*sizeof(unsigned char));
} else {
for (int i=0;i<iWidth;i++)
pSrcTmp[i] = rand()%256;
for (int j = 0; j < iHeight; j++) {
if ((j + iScrollMv) >= 0 && (j + iScrollMv) < iHeight)
for (int i = 0; i < iWidth; i++) {
memcpy (pSrcTmp , &pRefTmp[ (j + iScrollMv)*iStride], iWidth * sizeof (unsigned char));
}
else {
for (int i = 0; i < iWidth; i++)
pSrcTmp[i] = rand() % 256;
}
pSrcTmp += iStride;
}
@ -65,16 +65,16 @@ TEST(ScrollDetectionTest,TestScroll)
int iCoreNum = 1;
unsigned int uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum);
CScrollDetection *pTest =new CScrollDetection(uiCPUFlag);
CScrollDetection* pTest = new CScrollDetection (uiCPUFlag);
int iMethodIdx = METHOD_SCROLL_DETECTION;
pTest->Set(iMethodIdx, (&sScrollDetectionResult));
int ret = pTest->Process(iMethodIdx,&sSrcMap, &sRefMap);
EXPECT_EQ(ret,0);
pTest->Get(iMethodIdx, (&sScrollDetectionResult));
pTest->Set (iMethodIdx, (&sScrollDetectionResult));
int ret = pTest->Process (iMethodIdx, &sSrcMap, &sRefMap);
EXPECT_EQ (ret, 0);
pTest->Get (iMethodIdx, (&sScrollDetectionResult));
EXPECT_EQ(sScrollDetectionResult.bScrollDetectFlag,true);
EXPECT_EQ(sScrollDetectionResult.iScrollMvY,iScrollMv);
EXPECT_EQ (sScrollDetectionResult.bScrollDetectFlag, true);
EXPECT_EQ (sScrollDetectionResult.iScrollMvY, iScrollMv);
delete pTest;
delete []pSrc;

View File

@ -54,27 +54,26 @@ extern "C" {
* This structure will hold context information for the hashing
* operation
*/
typedef struct SHA1Context
{
unsigned Message_Digest[5]; /* Message Digest (output) */
typedef struct SHA1Context {
unsigned Message_Digest[5]; /* Message Digest (output) */
unsigned Length_Low; /* Message length in bits */
unsigned Length_High; /* Message length in bits */
unsigned Length_Low; /* Message length in bits */
unsigned Length_High; /* Message length in bits */
unsigned char Message_Block[64]; /* 512-bit message blocks */
int Message_Block_Index; /* Index into message block array */
unsigned char Message_Block[64]; /* 512-bit message blocks */
int Message_Block_Index; /* Index into message block array */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corruped? */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corruped? */
} SHA1Context;
/*
* Function Prototypes
*/
void SHA1Reset(SHA1Context *);
int SHA1Result(SHA1Context *, unsigned char *);
void SHA1Input( SHA1Context *,
const unsigned char *,
void SHA1Reset (SHA1Context*);
int SHA1Result (SHA1Context*, unsigned char*);
void SHA1Input (SHA1Context*,
const unsigned char*,
unsigned);
#define SHA_DIGEST_LENGTH 20

View File

@ -8,34 +8,34 @@
class BufferedData {
public:
BufferedData() : data_(NULL), capacity_(0), length_(0) {}
BufferedData() : data_ (NULL), capacity_ (0), length_ (0) {}
~BufferedData() {
free(data_);
free (data_);
}
bool PushBack(uint8_t c) {
if (!EnsureCapacity(length_ + 1)) {
bool PushBack (uint8_t c) {
if (!EnsureCapacity (length_ + 1)) {
return false;
}
data_[length_++] = c;
return true;
}
bool PushBack(const uint8_t* data, size_t len) {
if (!EnsureCapacity(length_ + len)) {
bool PushBack (const uint8_t* data, size_t len) {
if (!EnsureCapacity (length_ + len)) {
return false;
}
memcpy(data_ + length_, data, len);
memcpy (data_ + length_, data, len);
length_ += len;
return true;
}
size_t PopFront(uint8_t* ptr, size_t len) {
len = std::min(length_, len);
memcpy(ptr, data_, len);
memmove(data_, data_ + len, length_ - len);
SetLength(length_ - len);
size_t PopFront (uint8_t* ptr, size_t len) {
len = std::min (length_, len);
memcpy (ptr, data_, len);
memmove (data_, data_ + len, length_ - len);
SetLength (length_ - len);
return len;
}
@ -43,8 +43,8 @@ class BufferedData {
length_ = 0;
}
void SetLength(size_t newLen) {
if (EnsureCapacity(newLen)) {
void SetLength (size_t newLen) {
if (EnsureCapacity (newLen)) {
length_ = newLen;
}
}
@ -58,11 +58,11 @@ class BufferedData {
}
private:
bool EnsureCapacity(size_t capacity) {
bool EnsureCapacity (size_t capacity) {
if (capacity > capacity_) {
size_t newsize = capacity * 2;
uint8_t* data = static_cast<uint8_t*>(realloc(data_, newsize));
uint8_t* data = static_cast<uint8_t*> (realloc (data_, newsize));
if (!data)
return false;

View File

@ -3,13 +3,13 @@
#include "typedefs.h"
bool YUVPixelDataGenerator( uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride );
bool YUVPixelDataGenerator (uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride);
void RandomPixelDataGenerator( uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride, int32_t iIdx );
void RandomPixelDataGenerator (uint8_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride, int32_t iIdx);
void RandomResidueDataGenerator( uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride );
void RandomResidueDataGenerator (uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride);
void RandomCoeffDataGenerator( uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride );
void RandomCoeffDataGenerator (uint16_t* pPointer, int32_t iWidth, int32_t iHeight, int32_t iStride);
#endif//DATA_GENERATOR_H__

View File

@ -6,15 +6,15 @@
class FileInputStream : public InputStream {
public:
bool Open(const char* fileName) {
file_.open(fileName, std::ios_base::in | std::ios_base::binary);
bool Open (const char* fileName) {
file_.open (fileName, std::ios_base::in | std::ios_base::binary);
return file_.is_open();
}
int read(void* ptr, size_t len) {
int read (void* ptr, size_t len) {
if (!file_.good()) {
return -1;
}
file_.read(static_cast<char*>(ptr), len);
file_.read (static_cast<char*> (ptr), len);
return file_.gcount();
}
private:

View File

@ -6,13 +6,13 @@
#include <gtest/gtest.h>
#include "../sha1.h"
static void CompareHash(const unsigned char* digest, const char* hashStr) {
static void CompareHash (const unsigned char* digest, const char* hashStr) {
char hashStrCmp[SHA_DIGEST_LENGTH * 2 + 1];
for (int i = 0; i < SHA_DIGEST_LENGTH; ++i) {
sprintf(&hashStrCmp[i*2], "%.2x", digest[i]);
sprintf (&hashStrCmp[i * 2], "%.2x", digest[i]);
}
hashStrCmp[SHA_DIGEST_LENGTH * 2] = '\0';
EXPECT_STREQ(hashStr, hashStrCmp);
EXPECT_STREQ (hashStr, hashStrCmp);
}
#endif //__HASHFUNCTIONS_H__

View File

@ -4,7 +4,7 @@
#include <cstddef>
struct InputStream {
virtual int read(void* ptr, size_t len) = 0;
virtual int read (void* ptr, size_t len) = 0;
};
#endif //__INPUTSTREAM_H__