Convert tabs to spaces in vertically aligned code

This commit is contained in:
Martin Storsjö
2015-05-15 11:45:20 +03:00
parent 723044837a
commit 51efa57a3d
64 changed files with 2729 additions and 2734 deletions

View File

@@ -67,11 +67,11 @@ namespace WelsCommon {
static inline int32_t InitBits (SBitStringAux* pBs, const uint8_t* kpBuf, const int32_t kiSize) { 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->pStartBuf = ptr; pBs->pStartBuf = ptr;
pBs->pCurBuf = ptr; pBs->pCurBuf = ptr;
pBs->pEndBuf = ptr + kiSize; pBs->pEndBuf = ptr + kiSize;
pBs->iLeftBits = 32; pBs->iLeftBits = 32;
pBs->uiCurBits = 0; pBs->uiCurBits = 0;
return kiSize; return kiSize;
} }

View File

@@ -36,19 +36,19 @@
// rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009 // rewrite it (split into luma & chroma) that is helpful for mmx/sse2 optimization perform, 9/27/2009
static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW,
const int32_t kiPicH) { const int32_t kiPicH) {
uint8_t* pTmp = pDst; uint8_t* pTmp = pDst;
uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride; uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride;
const int32_t kiPaddingLen = PADDING_LENGTH; const int32_t kiPaddingLen = PADDING_LENGTH;
const uint8_t kuiTL = pTmp[0]; const uint8_t kuiTL = pTmp[0];
const uint8_t kuiTR = pTmp[kiPicW - 1]; const uint8_t kuiTR = pTmp[kiPicW - 1];
const uint8_t kuiBL = pDstLastLine[0]; const uint8_t kuiBL = pDstLastLine[0];
const uint8_t kuiBR = pDstLastLine[kiPicW - 1]; const uint8_t kuiBR = pDstLastLine[kiPicW - 1];
int32_t i = 0; int32_t i = 0;
do { do {
const int32_t kiStrides = (1 + i) * kiStride; const int32_t kiStrides = (1 + i) * kiStride;
uint8_t* pTop = pTmp - kiStrides; uint8_t* pTop = pTmp - kiStrides;
uint8_t* pBottom = pDstLastLine + kiStrides; uint8_t* pBottom = pDstLastLine + kiStrides;
// pad pTop and pBottom // pad pTop and pBottom
memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage
@@ -76,19 +76,19 @@ static inline void ExpandPictureLuma_c (uint8_t* pDst, const int32_t kiStride, c
static inline void ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW, static inline void ExpandPictureChroma_c (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicW,
const int32_t kiPicH) { const int32_t kiPicH) {
uint8_t* pTmp = pDst; uint8_t* pTmp = pDst;
uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride; uint8_t* pDstLastLine = pTmp + (kiPicH - 1) * kiStride;
const int32_t kiPaddingLen = (PADDING_LENGTH >> 1); const int32_t kiPaddingLen = (PADDING_LENGTH >> 1);
const uint8_t kuiTL = pTmp[0]; const uint8_t kuiTL = pTmp[0];
const uint8_t kuiTR = pTmp[kiPicW - 1]; const uint8_t kuiTR = pTmp[kiPicW - 1];
const uint8_t kuiBL = pDstLastLine[0]; const uint8_t kuiBL = pDstLastLine[0];
const uint8_t kuiBR = pDstLastLine[kiPicW - 1]; const uint8_t kuiBR = pDstLastLine[kiPicW - 1];
int32_t i = 0; int32_t i = 0;
do { do {
const int32_t kiStrides = (1 + i) * kiStride; const int32_t kiStrides = (1 + i) * kiStride;
uint8_t* pTop = pTmp - kiStrides; uint8_t* pTop = pTmp - kiStrides;
uint8_t* pBottom = pDstLastLine + kiStrides; uint8_t* pBottom = pDstLastLine + kiStrides;
// pad pTop and pBottom // pad pTop and pBottom
memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage memcpy (pTop, pTmp, kiPicW); // confirmed_safe_unsafe_usage
@@ -147,13 +147,13 @@ void InitExpandPictureFunc (SExpandPicFunc* pExpandPicFunc, const uint32_t kuiCP
void ExpandReferencingPicture (uint8_t* pData[3], int32_t iWidth, int32_t iHeight, int32_t iStride[3], void ExpandReferencingPicture (uint8_t* pData[3], int32_t iWidth, int32_t iHeight, int32_t iStride[3],
PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]) { PExpandPictureFunc pExpLuma, PExpandPictureFunc pExpChrom[2]) {
/*local variable*/ /*local variable*/
uint8_t* pPicY = pData[0]; uint8_t* pPicY = pData[0];
uint8_t* pPicCb = pData[1]; uint8_t* pPicCb = pData[1];
uint8_t* pPicCr = pData[2]; uint8_t* pPicCr = pData[2];
const int32_t kiWidthY = iWidth; const int32_t kiWidthY = iWidth;
const int32_t kiHeightY = iHeight; const int32_t kiHeightY = iHeight;
const int32_t kiWidthUV = kiWidthY >> 1; const int32_t kiWidthUV = kiWidthY >> 1;
const int32_t kiHeightUV = kiHeightY >> 1; const int32_t kiHeightUV = kiHeightY >> 1;

View File

@@ -65,8 +65,8 @@ void WelsI16x16LumaPredH_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStrid
uint8_t i = 15; uint8_t i = 15;
do { do {
const uint8_t kuiSrc8 = pRef[iStridex15 - 1]; const uint8_t kuiSrc8 = pRef[iStridex15 - 1];
const uint64_t kuiV64 = (uint64_t) (0x0101010101010101ULL * kuiSrc8); const uint64_t kuiV64 = (uint64_t) (0x0101010101010101ULL * kuiSrc8);
ST64 (&pPred[iPredStridex15], kuiV64); ST64 (&pPred[iPredStridex15], kuiV64);
ST64 (&pPred[iPredStridex15 + 8], kuiV64); ST64 (&pPred[iPredStridex15 + 8], kuiV64);

View File

@@ -61,14 +61,14 @@ CMemoryAlign::~CMemoryAlign() {
} }
void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAlign) { void* WelsMalloc (const uint32_t kuiSize, const char* kpTag, const uint32_t kiAlign) {
const int32_t kiSizeOfVoidPointer = sizeof (void**); const int32_t kiSizeOfVoidPointer = sizeof (void**);
const int32_t kiSizeOfInt = sizeof (int32_t); const int32_t kiSizeOfInt = sizeof (int32_t);
const int32_t kiAlignedBytes = kiAlign - 1; const int32_t kiAlignedBytes = kiAlign - 1;
const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt; const int32_t kiTrialRequestedSize = kuiSize + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
const int32_t kiActualRequestedSize = kiTrialRequestedSize; const int32_t kiActualRequestedSize = kiTrialRequestedSize;
const uint32_t kiPayloadSize = kuiSize; const uint32_t kiPayloadSize = kuiSize;
uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize); uint8_t* pBuf = (uint8_t*) malloc (kiActualRequestedSize);
#ifdef MEMORY_CHECK #ifdef MEMORY_CHECK
if (fpMemChkPoint == NULL) { if (fpMemChkPoint == NULL) {
m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+"); m_fpMemChkPoint = fopen ("./enc_mem_check_point.txt", "at+");

View File

@@ -465,18 +465,18 @@ HRESULT InitWindow (HWND* hWnd) {
const TCHAR kszWindowClass[] = TEXT ("Wels Decoder Class"); const TCHAR kszWindowClass[] = TEXT ("Wels Decoder Class");
WNDCLASSEX sWndClassEx = {0}; WNDCLASSEX sWndClassEx = {0};
sWndClassEx.cbSize = sizeof (WNDCLASSEX); sWndClassEx.cbSize = sizeof (WNDCLASSEX);
sWndClassEx.style = CS_HREDRAW | CS_VREDRAW; sWndClassEx.style = CS_HREDRAW | CS_VREDRAW;
sWndClassEx.lpfnWndProc = (WNDPROC)WndProc; sWndClassEx.lpfnWndProc = (WNDPROC)WndProc;
sWndClassEx.cbClsExtra = 0; sWndClassEx.cbClsExtra = 0;
sWndClassEx.cbWndExtra = 0; sWndClassEx.cbWndExtra = 0;
sWndClassEx.hInstance = GetModuleHandle (NULL); sWndClassEx.hInstance = GetModuleHandle (NULL);
sWndClassEx.hIcon = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_TESTSHARESURFACE); sWndClassEx.hIcon = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_TESTSHARESURFACE);
sWndClassEx.hCursor = LoadCursor (NULL, IDC_ARROW); sWndClassEx.hCursor = LoadCursor (NULL, IDC_ARROW);
sWndClassEx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); sWndClassEx.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
sWndClassEx.lpszMenuName = (LPCSTR)IDC_TESTSHARESURFACE; sWndClassEx.lpszMenuName = (LPCSTR)IDC_TESTSHARESURFACE;
sWndClassEx.lpszClassName = kszWindowClass; sWndClassEx.lpszClassName = kszWindowClass;
sWndClassEx.hIconSm = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_SMALL); sWndClassEx.hIconSm = LoadIcon (sWndClassEx.hInstance, (LPCTSTR)IDI_SMALL);
if (!RegisterClassEx (&sWndClassEx)) if (!RegisterClassEx (&sWndClassEx))
return E_FAIL; return E_FAIL;

View File

@@ -73,8 +73,8 @@ int g_iDecodedFrameNum = 0;
void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName, void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, const char* kpOuputFileName,
int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName, const char* pLengthFileName) { int32_t& iWidth, int32_t& iHeight, const char* pOptionFileName, const char* pLengthFileName) {
FILE* pH264File = NULL; FILE* pH264File = NULL;
FILE* pYuvFile = NULL; FILE* pYuvFile = NULL;
FILE* pOptionFile = NULL; FILE* pOptionFile = NULL;
// Lenght input mode support // Lenght input mode support
FILE* fpTrack = NULL; FILE* fpTrack = NULL;
@@ -237,8 +237,8 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
pDst[1] = pData[1]; pDst[1] = pData[1];
pDst[2] = pData[2]; pDst[2] = pData[2];
} }
iEnd = WelsTime(); iEnd = WelsTime();
iTotal += iEnd - iStart; iTotal += iEnd - iStart;
if (sDstBufInfo.iBufferStatus == 1) { if (sDstBufInfo.iBufferStatus == 1) {
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile); cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;
@@ -269,8 +269,8 @@ void H264DecodeInstance (ISVCDecoder* pDecoder, const char* kpH264FileName, cons
pDst[1] = pData[1]; pDst[1] = pData[1];
pDst[2] = pData[2]; pDst[2] = pData[2];
} }
iEnd = WelsTime(); iEnd = WelsTime();
iTotal += iEnd - iStart; iTotal += iEnd - iStart;
if (sDstBufInfo.iBufferStatus == 1) { if (sDstBufInfo.iBufferStatus == 1) {
cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile); cOutputModule.Process ((void**)pDst, &sDstBufInfo, pYuvFile);
iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth; iWidth = sDstBufInfo.UsrData.sSystemBuffer.iWidth;

View File

@@ -197,8 +197,8 @@ int ParseLayerConfig (CReadConfig& cRdLayerCfg, const int iLayer, SEncParamExt&
} }
} }
} }
pDLayer->iDLayerQp = sLayerCtx.iDLayerQp; pDLayer->iDLayerQp = sLayerCtx.iDLayerQp;
pDLayer->sSliceCfg.uiSliceMode = sLayerCtx.sSliceCfg.uiSliceMode; pDLayer->sSliceCfg.uiSliceMode = sLayerCtx.sSliceCfg.uiSliceMode;
memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage memcpy (&pDLayer->sSliceCfg, &sLayerCtx.sSliceCfg, sizeof (SSliceConfig)); // confirmed_safe_unsafe_usage
memcpy (&pDLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[0], memcpy (&pDLayer->sSliceCfg.sSliceArgument.uiSliceMbNum[0], &sLayerCtx.sSliceCfg.sSliceArgument.uiSliceMbNum[0],
@@ -626,59 +626,59 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
int FillSpecificParameters (SEncParamExt& sParam) { int FillSpecificParameters (SEncParamExt& sParam) {
/* Test for temporal, spatial, SNR scalability */ /* Test for temporal, spatial, SNR scalability */
sParam.iUsageType = CAMERA_VIDEO_REAL_TIME; sParam.iUsageType = CAMERA_VIDEO_REAL_TIME;
sParam.fMaxFrameRate = 60.0f; // input frame rate sParam.fMaxFrameRate = 60.0f; // input frame rate
sParam.iPicWidth = 1280; // width of picture in samples sParam.iPicWidth = 1280; // width of picture in samples
sParam.iPicHeight = 720; // height of picture in samples sParam.iPicHeight = 720; // height of picture in samples
sParam.iTargetBitrate = 2500000; // target bitrate desired sParam.iTargetBitrate = 2500000; // target bitrate desired
sParam.iMaxBitrate = UNSPECIFIED_BIT_RATE; sParam.iMaxBitrate = UNSPECIFIED_BIT_RATE;
sParam.iRCMode = RC_QUALITY_MODE; // rc mode control sParam.iRCMode = RC_QUALITY_MODE; // rc mode control
sParam.iTemporalLayerNum = 3; // layer number at temporal level sParam.iTemporalLayerNum = 3; // layer number at temporal level
sParam.iSpatialLayerNum = 4; // layer number at spatial level sParam.iSpatialLayerNum = 4; // layer number at spatial level
sParam.bEnableDenoise = 0; // denoise control sParam.bEnableDenoise = 0; // denoise control
sParam.bEnableBackgroundDetection = 1; // background detection control sParam.bEnableBackgroundDetection = 1; // background detection control
sParam.bEnableAdaptiveQuant = 1; // adaptive quantization control sParam.bEnableAdaptiveQuant = 1; // adaptive quantization control
sParam.bEnableFrameSkip = 1; // frame skipping sParam.bEnableFrameSkip = 1; // frame skipping
sParam.bEnableLongTermReference = 0; // long term reference control sParam.bEnableLongTermReference = 0; // long term reference control
sParam.iLtrMarkPeriod = 30; sParam.iLtrMarkPeriod = 30;
sParam.uiIntraPeriod = 320; // period of Intra frame sParam.uiIntraPeriod = 320; // period of Intra frame
sParam.eSpsPpsIdStrategy = INCREASING_ID; sParam.eSpsPpsIdStrategy = INCREASING_ID;
sParam.bPrefixNalAddingCtrl = 0; sParam.bPrefixNalAddingCtrl = 0;
sParam.iComplexityMode = MEDIUM_COMPLEXITY; sParam.iComplexityMode = MEDIUM_COMPLEXITY;
int iIndexLayer = 0; int iIndexLayer = 0;
sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_BASELINE; sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_BASELINE;
sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 160; sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 160;
sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 90; sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 90;
sParam.sSpatialLayers[iIndexLayer].fFrameRate = 7.5f; sParam.sSpatialLayers[iIndexLayer].fFrameRate = 7.5f;
sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 64000; sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 64000;
sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
++ iIndexLayer; ++ iIndexLayer;
sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE;
sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 320; sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 320;
sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 180; sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 180;
sParam.sSpatialLayers[iIndexLayer].fFrameRate = 15.0f; sParam.sSpatialLayers[iIndexLayer].fFrameRate = 15.0f;
sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 160000; sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 160000;
sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
++ iIndexLayer; ++ iIndexLayer;
sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE;
sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 640; sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 640;
sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 360; sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 360;
sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f; sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f;
sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 512000; sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 512000;
sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1;
++ iIndexLayer; ++ iIndexLayer;
sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE; sParam.sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_SCALABLE_BASELINE;
sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 1280; sParam.sSpatialLayers[iIndexLayer].iVideoWidth = 1280;
sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 720; sParam.sSpatialLayers[iIndexLayer].iVideoHeight = 720;
sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f; sParam.sSpatialLayers[iIndexLayer].fFrameRate = 30.0f;
sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 1500000; sParam.sSpatialLayers[iIndexLayer].iSpatialBitrate = 1500000;
sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sParam.sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
sParam.sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1; sParam.sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceNum = 1;

View File

@@ -138,8 +138,8 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
return NULL; //uiForbiddenZeroBit should always equal to 0 return NULL; //uiForbiddenZeroBit should always equal to 0
} }
pNalUnitHeader->uiNalRefIdc = (uint8_t) (pNal[0] >> 5); // uiNalRefIdc pNalUnitHeader->uiNalRefIdc = (uint8_t) (pNal[0] >> 5); // uiNalRefIdc
pNalUnitHeader->eNalUnitType = (EWelsNalUnitType) (pNal[0] & 0x1f); // eNalUnitType pNalUnitHeader->eNalUnitType = (EWelsNalUnitType) (pNal[0] & 0x1f); // eNalUnitType
++pNal; ++pNal;
--iNalSize; --iNalSize;
@@ -241,8 +241,8 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
*pConsumedBytes += NAL_UNIT_HEADER_EXT_SIZE; *pConsumedBytes += NAL_UNIT_HEADER_EXT_SIZE;
pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit; pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit;
pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc; pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc;
pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType; pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType;
if (pNalUnitHeader->uiNalRefIdc != 0) { if (pNalUnitHeader->uiNalRefIdc != 0) {
pBs = &pCtx->sBs; pBs = &pCtx->sBs;
iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit iBitSize = (iNalSize << 3) - BsGetTrailingBits (pNal + iNalSize - 1); // convert into bit
@@ -272,9 +272,9 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
} }
pCurNal->uiTimeStamp = pCtx->uiTimeStamp; pCurNal->uiTimeStamp = pCtx->uiTimeStamp;
pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit; pCurNal->sNalHeaderExt.sNalUnitHeader.uiForbiddenZeroBit = pNalUnitHeader->uiForbiddenZeroBit;
pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc; pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc = pNalUnitHeader->uiNalRefIdc;
pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType; pCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType = pNalUnitHeader->eNalUnitType;
pCurAu = pCtx->pAccessUnitList; pCurAu = pCtx->pAccessUnitList;
uiAvailNalNum = pCurAu->uiAvailUnitsNum; uiAvailNalNum = pCurAu->uiAvailUnitsNum;
@@ -576,12 +576,12 @@ bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const
*/ */
int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen, uint8_t* pSrcNal, int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen, uint8_t* pSrcNal,
const int32_t kSrcNalLen) { const int32_t kSrcNalLen) {
PBitStringAux pBs = NULL; PBitStringAux pBs = NULL;
EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; // make initial value as unspecified EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; // make initial value as unspecified
int32_t iPicWidth = 0; int32_t iPicWidth = 0;
int32_t iPicHeight = 0; int32_t iPicHeight = 0;
int32_t iBitSize = 0; int32_t iBitSize = 0;
int32_t iErr = ERR_NONE; int32_t iErr = ERR_NONE;
if (kiSrcLen <= 0) if (kiSrcLen <= 0)
return iErr; return iErr;
@@ -674,8 +674,8 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi
if (kuiMmco == MMCO_SHORT2UNUSED) { if (kuiMmco == MMCO_SHORT2UNUSED) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_base_pic_nums_minus1 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_base_pic_nums_minus1
pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + uiCode; pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + uiCode;
pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0; pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0;
} else if (kuiMmco == MMCO_LONG2UNUSED) { } else if (kuiMmco == MMCO_LONG2UNUSED) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_base_pic_num WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_base_pic_num
pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode; pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode;
@@ -747,8 +747,8 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //chroma_phase_y_plus1 WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //chroma_phase_y_plus1
pExt->uiChromaPhaseYPlus1 = uiCode; pExt->uiChromaPhaseYPlus1 = uiCode;
pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag; pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag;
pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1; pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1;
memset (&pExt->sSeqScaledRefLayer, 0, sizeof (SPosOffset)); memset (&pExt->sSeqScaledRefLayer, 0, sizeof (SPosOffset));
if (pExt->uiExtendedSpatialScalability == 1) { if (pExt->uiExtendedSpatialScalability == 1) {
@@ -948,11 +948,11 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
} else pSps->pSLevelLimits = pSLevelLimits; } else pSps->pSLevelLimits = pSLevelLimits;
// syntax elements in default // syntax elements in default
pSps->uiChromaFormatIdc = 1; pSps->uiChromaFormatIdc = 1;
pSps->uiProfileIdc = uiProfileIdc; pSps->uiProfileIdc = uiProfileIdc;
pSps->uiLevelIdc = uiLevelIdc; pSps->uiLevelIdc = uiLevelIdc;
pSps->iSpsId = iSpsId; pSps->iSpsId = iSpsId;
if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc || if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc ||
PRO_HIGH == uiProfileIdc || PRO_HIGH10 == uiProfileIdc || PRO_HIGH == uiProfileIdc || PRO_HIGH10 == uiProfileIdc ||
@@ -1100,10 +1100,10 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA); return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CROPPING_DATA);
} }
} else { } else {
pSps->sFrameCrop.iLeftOffset = 0; // frame_crop_left_offset pSps->sFrameCrop.iLeftOffset = 0; // frame_crop_left_offset
pSps->sFrameCrop.iRightOffset = 0; // frame_crop_right_offset pSps->sFrameCrop.iRightOffset = 0; // frame_crop_right_offset
pSps->sFrameCrop.iTopOffset = 0; // frame_crop_top_offset pSps->sFrameCrop.iTopOffset = 0; // frame_crop_top_offset
pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset
} }
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag
pSps->bVuiParamPresentFlag = !!uiCode; pSps->bVuiParamPresentFlag = !!uiCode;
@@ -1208,8 +1208,8 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc) if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)
pCtx->bAvcBasedFlag = false; pCtx->bAvcBasedFlag = false;
*pPicWidth = pSps->iMbWidth << 4; *pPicWidth = pSps->iMbWidth << 4;
*pPicHeight = pSps->iMbHeight << 4; *pPicHeight = pSps->iMbHeight << 4;
PSps pTmpSps = NULL; PSps pTmpSps = NULL;
if (kbUseSubsetFlag) { if (kbUseSubsetFlag) {
pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps; pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps;

View File

@@ -74,9 +74,9 @@ int32_t DecInitBits (PBitStringAux pBitString, const uint8_t* kpBuf, const int32
if (NULL == pTmp) if (NULL == pTmp)
return ERR_INFO_INVALID_ACCESS; return ERR_INFO_INVALID_ACCESS;
pBitString->pStartBuf = pTmp; // buffer to start position pBitString->pStartBuf = pTmp; // buffer to start position
pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length pBitString->pEndBuf = pTmp + kiSizeBuf; // buffer + length
pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex; pBitString->iBits = kiSize; // count bits of overall bitstreaming inputindex;
pBitString->pCurBuf = pBitString->pStartBuf; pBitString->pCurBuf = pBitString->pStartBuf;
int32_t iErr = InitReadBits (pBitString, 0); int32_t iErr = InitReadBits (pBitString, 0);
if (iErr) { if (iErr) {

View File

@@ -815,7 +815,7 @@ void DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_
void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
uint8_t nBS[2][4][4] = {{{ 0 }}}; uint8_t nBS[2][4][4] = {{{ 0 }}};
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex]; int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex];
int32_t iMbNb; int32_t iMbNb;

View File

@@ -42,9 +42,9 @@ namespace WelsDec {
void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
int16_t iSrc[16]; int16_t iSrc[16];
uint8_t* pDst = pPred; uint8_t* pDst = pPred;
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
int32_t i; int32_t i;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
@@ -61,16 +61,16 @@ void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
int32_t kT1 = iSrc[i] + iSrc[i + 8]; int32_t kT1 = iSrc[i] + iSrc[i + 8];
int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1); int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1);
int32_t kT3 = (32 + kT1 + kT2) >> 6; int32_t kT3 = (32 + kT1 + kT2) >> 6;
int32_t kT4 = (32 + kT1 - kT2) >> 6; int32_t kT4 = (32 + kT1 - kT2) >> 6;
pDst[i] = WelsClip1 (kT3 + pPred[i]); pDst[i] = WelsClip1 (kT3 + pPred[i]);
pDst[i + kiStride3] = WelsClip1 (kT4 + pPred[i + kiStride3]); pDst[i + kiStride3] = WelsClip1 (kT4 + pPred[i + kiStride3]);
kT1 = iSrc[i] - iSrc[i + 8]; kT1 = iSrc[i] - iSrc[i + 8];
kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12]; kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12];
pDst[i + kiStride] = WelsClip1 (((32 + kT1 + kT2) >> 6) + pDst[i + kiStride]); pDst[i + kiStride] = WelsClip1 (((32 + kT1 + kT2) >> 6) + pDst[i + kiStride]);
pDst[i + kiStride2] = WelsClip1 (((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2]); pDst[i + kiStride2] = WelsClip1 (((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2]);
} }

View File

@@ -601,10 +601,10 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva
} }
int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag) { int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag) {
PDqLayer pCurLayer = pCtx->pCurDqLayer; PDqLayer pCurLayer = pCtx->pCurDqLayer;
PBitStringAux pBsAux = pCurLayer->pBitStringAux; PBitStringAux pBsAux = pCurLayer->pBitStringAux;
PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
SWelsNeighAvail sNeighAvail; SWelsNeighAvail sNeighAvail;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
@@ -812,10 +812,10 @@ int32_t WelsDecodeMbCabacISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin
} }
int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) { int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) {
PDqLayer pCurLayer = pCtx->pCurDqLayer; PDqLayer pCurLayer = pCtx->pCurDqLayer;
PBitStringAux pBsAux = pCurLayer->pBitStringAux; PBitStringAux pBsAux = pCurLayer->pBitStringAux;
PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
@@ -1048,9 +1048,9 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv
} }
int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
PDqLayer pCurLayer = pCtx->pCurDqLayer; PDqLayer pCurLayer = pCtx->pCurDqLayer;
PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0];
uint32_t uiCode; uint32_t uiCode;
int32_t iMbXy = pCurLayer->iMbXyIndex; int32_t iMbXy = pCurLayer->iMbXyIndex;
@@ -1260,10 +1260,10 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal
int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
SVlcTable* pVlcTable = &pCtx->sVlcTable; SVlcTable* pVlcTable = &pCtx->sVlcTable;
PDqLayer pCurLayer = pCtx->pCurDqLayer; PDqLayer pCurLayer = pCtx->pCurDqLayer;
PBitStringAux pBs = pCurLayer->pBitStringAux; PBitStringAux pBs = pCurLayer->pBitStringAux;
PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
SWelsNeighAvail sNeighAvail; SWelsNeighAvail sNeighAvail;
int32_t iMbResProperty; int32_t iMbResProperty;
@@ -1579,10 +1579,10 @@ int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin
int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
SVlcTable* pVlcTable = &pCtx->sVlcTable; SVlcTable* pVlcTable = &pCtx->sVlcTable;
PDqLayer pCurLayer = pCtx->pCurDqLayer; PDqLayer pCurLayer = pCtx->pCurDqLayer;
PBitStringAux pBs = pCurLayer->pBitStringAux; PBitStringAux pBs = pCurLayer->pBitStringAux;
PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart; int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd; int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
@@ -1909,10 +1909,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
} }
int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) { int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
PDqLayer pCurLayer = pCtx->pCurDqLayer; PDqLayer pCurLayer = pCtx->pCurDqLayer;
PBitStringAux pBs = pCurLayer->pBitStringAux; PBitStringAux pBs = pCurLayer->pBitStringAux;
PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0];
intX_t iUsedBits; intX_t iUsedBits;
const int32_t iMbXy = pCurLayer->iMbXyIndex; const int32_t iMbXy = pCurLayer->iMbXyIndex;

View File

@@ -93,9 +93,9 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons
} }
// initialize context in queue // initialize context in queue
pPicBuf->iCapacity = kiSize; pPicBuf->iCapacity = kiSize;
pPicBuf->iCurrentIdx = 0; pPicBuf->iCurrentIdx = 0;
* ppPicBuf = pPicBuf; * ppPicBuf = pPicBuf;
return 0; return 0;
} }
@@ -139,9 +139,9 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof (PPicture)); memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof (PPicture));
// initialize context in queue // initialize context in queue
pPicNewBuf->iCapacity = kiNewSize; pPicNewBuf->iCapacity = kiNewSize;
pPicNewBuf->iCurrentIdx = pPicOldBuf->iCurrentIdx; pPicNewBuf->iCurrentIdx = pPicOldBuf->iCurrentIdx;
* ppPicBuf = pPicNewBuf; * ppPicBuf = pPicNewBuf;
for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) {
pPicNewBuf->ppPic[i]->bUsedAsRef = false; pPicNewBuf->ppPic[i]->bUsedAsRef = false;
@@ -214,8 +214,8 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co
} }
// initialize context in queue // initialize context in queue
pPicNewBuf->iCapacity = kiNewSize; pPicNewBuf->iCapacity = kiNewSize;
*ppPicBuf = pPicNewBuf; *ppPicBuf = pPicNewBuf;
for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) { for (int32_t i = 0; i < pPicNewBuf->iCapacity; i++) {
pPicNewBuf->ppPic[i]->bUsedAsRef = false; pPicNewBuf->ppPic[i]->bUsedAsRef = false;
@@ -277,35 +277,35 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
pCtx->pArgDec = NULL; pCtx->pArgDec = NULL;
pCtx->eOutputColorFormat = videoFormatI420; // yuv in default pCtx->eOutputColorFormat = videoFormatI420; // yuv in default
pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related
pCtx->uiCpuFlag = 0; pCtx->uiCpuFlag = 0;
pCtx->bAuReadyFlag = 0; // au data is not ready pCtx->bAuReadyFlag = 0; // au data is not ready
pCtx->bCabacInited = false; pCtx->bCabacInited = false;
pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores);
pCtx->iImgWidthInPixel = 0; pCtx->iImgWidthInPixel = 0;
pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available
pCtx->iLastImgWidthInPixel = 0; pCtx->iLastImgWidthInPixel = 0;
pCtx->iLastImgHeightInPixel = 0; pCtx->iLastImgHeightInPixel = 0;
pCtx->bFreezeOutput = true; pCtx->bFreezeOutput = true;
pCtx->iFrameNum = -1; pCtx->iFrameNum = -1;
pCtx->iPrevFrameNum = -1; pCtx->iPrevFrameNum = -1;
pCtx->iErrorCode = ERR_NONE; pCtx->iErrorCode = ERR_NONE;
pCtx->pDec = NULL; pCtx->pDec = NULL;
WelsResetRefPic (pCtx); WelsResetRefPic (pCtx);
pCtx->iActiveFmoNum = 0; pCtx->iActiveFmoNum = 0;
pCtx->pPicBuff[LIST_0] = NULL; pCtx->pPicBuff[LIST_0] = NULL;
pCtx->pPicBuff[LIST_1] = NULL; pCtx->pPicBuff[LIST_1] = NULL;
pCtx->bAvcBasedFlag = true; pCtx->bAvcBasedFlag = true;
pCtx->eErrorConMethod = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE; pCtx->eErrorConMethod = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
pCtx->pPreviousDecodedPictureInDpb = NULL; pCtx->pPreviousDecodedPictureInDpb = NULL;
pCtx->sDecoderStatistics.iAvgLumaQp = -1; pCtx->sDecoderStatistics.iAvgLumaQp = -1;
@@ -353,13 +353,13 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) {
* request memory blocks for decoder avc part * request memory blocks for decoder avc part
*/ */
int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) {
const int32_t kiPicWidth = kiMbWidth << 4; const int32_t kiPicWidth = kiMbWidth << 4;
const int32_t kiPicHeight = kiMbHeight << 4; const int32_t kiPicHeight = kiMbHeight << 4;
int32_t iErr = ERR_NONE; int32_t iErr = ERR_NONE;
int32_t iListIdx = 0; //, mb_blocks = 0; int32_t iListIdx = 0; //, mb_blocks = 0;
int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
bool bNeedChangePicQueue = true; bool bNeedChangePicQueue = true;
WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0))
@@ -418,11 +418,11 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const
return iErr; return iErr;
pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding
pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding
pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested
pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed
if (pCtx->pCabacDecEngine == NULL) if (pCtx->pCabacDecEngine == NULL)
pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
@@ -450,12 +450,12 @@ void WelsFreeMem (PWelsDecoderContext pCtx) {
} }
// added for safe memory // added for safe memory
pCtx->iImgWidthInPixel = 0; pCtx->iImgWidthInPixel = 0;
pCtx->iImgHeightInPixel = 0; pCtx->iImgHeightInPixel = 0;
pCtx->iLastImgWidthInPixel = 0; pCtx->iLastImgWidthInPixel = 0;
pCtx->iLastImgHeightInPixel = 0; pCtx->iLastImgHeightInPixel = 0;
pCtx->bFreezeOutput = true; pCtx->bFreezeOutput = true;
pCtx->bHaveGotMemory = false; pCtx->bHaveGotMemory = false;
WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine"); WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
} }
@@ -660,8 +660,8 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in
((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) { ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) {
if (pSrcNal[2 + iSrcIdx] == 0x03) { if (pSrcNal[2 + iSrcIdx] == 0x03) {
ST16 (pDstNal + iDstIdx, 0); ST16 (pDstNal + iDstIdx, 0);
iDstIdx += 2; iDstIdx += 2;
iSrcIdx += 3; iSrcIdx += 3;
iSrcConsumed += 3; iSrcConsumed += 3;
} else { } else {
@@ -817,7 +817,7 @@ int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) {
*/ */
int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) {
int32_t iErr = ERR_NONE; int32_t iErr = ERR_NONE;
const int32_t kiPicWidth = kiMbWidth << 4; const int32_t kiPicWidth = kiMbWidth << 4;
const int32_t kiPicHeight = kiMbHeight << 4; const int32_t kiPicHeight = kiMbHeight << 4;
iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used

View File

@@ -427,27 +427,27 @@ bool FillDefaultSliceHeaderExt (PSliceHeaderExt pShExt, PNalUnitHeaderExt pNalEx
else else
pShExt->bBasePredWeightTableFlag = true; pShExt->bBasePredWeightTableFlag = true;
pShExt->uiRefLayerDqId = (uint8_t) - 1; pShExt->uiRefLayerDqId = (uint8_t) - 1;
pShExt->uiDisableInterLayerDeblockingFilterIdc = 0; pShExt->uiDisableInterLayerDeblockingFilterIdc = 0;
pShExt->iInterLayerSliceAlphaC0Offset = 0; pShExt->iInterLayerSliceAlphaC0Offset = 0;
pShExt->iInterLayerSliceBetaOffset = 0; pShExt->iInterLayerSliceBetaOffset = 0;
pShExt->bConstrainedIntraResamplingFlag = false; pShExt->bConstrainedIntraResamplingFlag = false;
pShExt->uiRefLayerChromaPhaseXPlus1Flag = 0; pShExt->uiRefLayerChromaPhaseXPlus1Flag = 0;
pShExt->uiRefLayerChromaPhaseYPlus1 = 1; pShExt->uiRefLayerChromaPhaseYPlus1 = 1;
//memset(&pShExt->sScaledRefLayer, 0, sizeof(SPosOffset)); //memset(&pShExt->sScaledRefLayer, 0, sizeof(SPosOffset));
pShExt->iScaledRefLayerPicWidthInSampleLuma = pShExt->sSliceHeader.iMbWidth << 4; pShExt->iScaledRefLayerPicWidthInSampleLuma = pShExt->sSliceHeader.iMbWidth << 4;
pShExt->iScaledRefLayerPicHeightInSampleLuma = pShExt->sSliceHeader.iMbHeight << 4; pShExt->iScaledRefLayerPicHeightInSampleLuma = pShExt->sSliceHeader.iMbHeight << 4;
pShExt->bSliceSkipFlag = false; pShExt->bSliceSkipFlag = false;
pShExt->bAdaptiveBaseModeFlag = false; pShExt->bAdaptiveBaseModeFlag = false;
pShExt->bDefaultBaseModeFlag = false; pShExt->bDefaultBaseModeFlag = false;
pShExt->bAdaptiveMotionPredFlag = false; pShExt->bAdaptiveMotionPredFlag = false;
pShExt->bDefaultMotionPredFlag = false; pShExt->bDefaultMotionPredFlag = false;
pShExt->bAdaptiveResidualPredFlag = false; pShExt->bAdaptiveResidualPredFlag = false;
pShExt->bDefaultResidualPredFlag = false; pShExt->bDefaultResidualPredFlag = false;
pShExt->bTCoeffLevelPredFlag = false; pShExt->bTCoeffLevelPredFlag = false;
pShExt->uiScanIdxStart = 0; pShExt->uiScanIdxStart = 0;
pShExt->uiScanIdxEnd = 15; pShExt->uiScanIdxEnd = 15;
return true; return true;
} }
@@ -551,8 +551,8 @@ int32_t WelsInitMemory (PWelsDecoderContext pCtx) {
if (InitBsBuffer (pCtx) != 0) if (InitBsBuffer (pCtx) != 0)
return ERR_INFO_OUT_OF_MEMORY; return ERR_INFO_OUT_OF_MEMORY;
pCtx->uiTargetDqId = (uint8_t) - 1; pCtx->uiTargetDqId = (uint8_t) - 1;
pCtx->bEndOfStreamFlag = false; pCtx->bEndOfStreamFlag = false;
return ERR_NONE; return ERR_NONE;
} }
@@ -579,15 +579,15 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) {
} }
pCtx->sRawData.pHead = NULL; pCtx->sRawData.pHead = NULL;
pCtx->sRawData.pEnd = NULL; pCtx->sRawData.pEnd = NULL;
pCtx->sRawData.pStartPos = NULL; pCtx->sRawData.pStartPos = NULL;
pCtx->sRawData.pCurPos = NULL; pCtx->sRawData.pCurPos = NULL;
if (pCtx->bParseOnly) { if (pCtx->bParseOnly) {
if (pCtx->sSavedData.pHead) { if (pCtx->sSavedData.pHead) {
WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead");
} }
pCtx->sSavedData.pHead = NULL; pCtx->sSavedData.pHead = NULL;
pCtx->sSavedData.pEnd = NULL; pCtx->sSavedData.pEnd = NULL;
pCtx->sSavedData.pStartPos = NULL; pCtx->sSavedData.pStartPos = NULL;
pCtx->sSavedData.pCurPos = NULL; pCtx->sSavedData.pCurPos = NULL;
if (pCtx->pParserBsInfo) { if (pCtx->pParserBsInfo) {
if (pCtx->pParserBsInfo->pDstBuff) { if (pCtx->pParserBsInfo->pDstBuff) {
@@ -610,20 +610,20 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) {
PNalUnitHeaderExt pHeaderExt = &pNal->sNalHeaderExt; PNalUnitHeaderExt pHeaderExt = &pNal->sNalHeaderExt;
uint8_t uiCurByte = *pSrc; uint8_t uiCurByte = *pSrc;
pHeaderExt->bIdrFlag = !! (uiCurByte & 0x40); pHeaderExt->bIdrFlag = !! (uiCurByte & 0x40);
pHeaderExt->uiPriorityId = uiCurByte & 0x3F; pHeaderExt->uiPriorityId = uiCurByte & 0x3F;
uiCurByte = * (++pSrc); uiCurByte = * (++pSrc);
pHeaderExt->iNoInterLayerPredFlag = uiCurByte >> 7; pHeaderExt->iNoInterLayerPredFlag = uiCurByte >> 7;
pHeaderExt->uiDependencyId = (uiCurByte & 0x70) >> 4; pHeaderExt->uiDependencyId = (uiCurByte & 0x70) >> 4;
pHeaderExt->uiQualityId = uiCurByte & 0x0F; pHeaderExt->uiQualityId = uiCurByte & 0x0F;
uiCurByte = * (++pSrc); uiCurByte = * (++pSrc);
pHeaderExt->uiTemporalId = uiCurByte >> 5; pHeaderExt->uiTemporalId = uiCurByte >> 5;
pHeaderExt->bUseRefBasePicFlag = !! (uiCurByte & 0x10); pHeaderExt->bUseRefBasePicFlag = !! (uiCurByte & 0x10);
pHeaderExt->bDiscardableFlag = !! (uiCurByte & 0x08); pHeaderExt->bDiscardableFlag = !! (uiCurByte & 0x08);
pHeaderExt->bOutputFlag = !! (uiCurByte & 0x04); pHeaderExt->bOutputFlag = !! (uiCurByte & 0x04);
pHeaderExt->uiReservedThree2Bits = uiCurByte & 0x03; pHeaderExt->uiReservedThree2Bits = uiCurByte & 0x03;
pHeaderExt->uiLayerDqId = (pHeaderExt->uiDependencyId << 4) | pHeaderExt->uiQualityId; pHeaderExt->uiLayerDqId = (pHeaderExt->uiDependencyId << 4) | pHeaderExt->uiQualityId;
} }
@@ -640,21 +640,21 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) {
* Parse slice header of bitstream in avc for storing data structure * Parse slice header of bitstream in avc for storing data structure
*/ */
int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) { int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) {
PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1]; PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
PNalUnitHeaderExt pNalHeaderExt = NULL; PNalUnitHeaderExt pNalHeaderExt = NULL;
PSliceHeader pSliceHead = NULL; PSliceHeader pSliceHead = NULL;
PSliceHeaderExt pSliceHeadExt = NULL; PSliceHeaderExt pSliceHeadExt = NULL;
PSubsetSps pSubsetSps = NULL; PSubsetSps pSubsetSps = NULL;
PSps pSps = NULL; PSps pSps = NULL;
PPps pPps = NULL; PPps pPps = NULL;
EWelsNalUnitType eNalType = static_cast<EWelsNalUnitType> (0); EWelsNalUnitType eNalType = static_cast<EWelsNalUnitType> (0);
int32_t iPpsId = 0; int32_t iPpsId = 0;
int32_t iRet = ERR_NONE; int32_t iRet = ERR_NONE;
uint8_t uiSliceType = 0; uint8_t uiSliceType = 0;
uint8_t uiQualityId = BASE_QUALITY_ID; uint8_t uiQualityId = BASE_QUALITY_ID;
bool bIdrFlag = false; bool bIdrFlag = false;
bool bSgChangeCycleInvolved = false; // involved slice group change cycle ? bool bSgChangeCycleInvolved = false; // involved slice group change cycle ?
uint32_t uiCode; uint32_t uiCode;
int32_t iCode; int32_t iCode;
SLogContext* pLogCtx = & (pCtx->sLogCtx); SLogContext* pLogCtx = & (pCtx->sLogCtx);
@@ -663,11 +663,11 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
return ERR_INFO_OUT_OF_MEMORY; return ERR_INFO_OUT_OF_MEMORY;
} }
pNalHeaderExt = &kpCurNal->sNalHeaderExt; pNalHeaderExt = &kpCurNal->sNalHeaderExt;
pSliceHead = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; pSliceHead = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
eNalType = pNalHeaderExt->sNalUnitHeader.eNalUnitType; eNalType = pNalHeaderExt->sNalUnitHeader.eNalUnitType;
pSliceHeadExt = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt; pSliceHeadExt = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt;
if (pSliceHeadExt) { if (pSliceHeadExt) {
SRefBasePicMarking sBaseMarking; SRefBasePicMarking sBaseMarking;
@@ -746,7 +746,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
if (kbExtensionFlag) { if (kbExtensionFlag) {
pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
pSps = &pSubsetSps->sSps; pSps = &pSubsetSps->sSps;
if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) { if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
pCtx->sDecoderStatistics.iSubSpsReportErrorNum++; pCtx->sDecoderStatistics.iSubSpsReportErrorNum++;
if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) { if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) {
@@ -798,15 +798,15 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
WELS_READ_VERIFY (BsGetBits (pBs, pSps->uiLog2MaxFrameNum, &uiCode)); //frame_num WELS_READ_VERIFY (BsGetBits (pBs, pSps->uiLog2MaxFrameNum, &uiCode)); //frame_num
pSliceHead->iFrameNum = uiCode; pSliceHead->iFrameNum = uiCode;
pSliceHead->bFieldPicFlag = false; pSliceHead->bFieldPicFlag = false;
pSliceHead->bBottomFiledFlag = false; pSliceHead->bBottomFiledFlag = false;
if (!pSps->bFrameMbsOnlyFlag) { if (!pSps->bFrameMbsOnlyFlag) {
WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseSliceHeaderSyntaxs(): frame_mbs_only_flag = %d not supported. ", WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseSliceHeaderSyntaxs(): frame_mbs_only_flag = %d not supported. ",
pSps->bFrameMbsOnlyFlag); pSps->bFrameMbsOnlyFlag);
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MBAFF); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MBAFF);
} }
pSliceHead->iMbWidth = pSps->iMbWidth; pSliceHead->iMbWidth = pSps->iMbWidth;
pSliceHead->iMbHeight = pSps->iMbHeight / (1 + pSliceHead->bFieldPicFlag); pSliceHead->iMbHeight = pSps->iMbHeight / (1 + pSliceHead->bFieldPicFlag);
if (bIdrFlag) { if (bIdrFlag) {
if (pSliceHead->iFrameNum != 0) { if (pSliceHead->iFrameNum != 0) {
@@ -825,9 +825,9 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
#endif #endif
} }
pSliceHead->iDeltaPicOrderCntBottom = 0; pSliceHead->iDeltaPicOrderCntBottom = 0;
pSliceHead->iDeltaPicOrderCnt[0] = pSliceHead->iDeltaPicOrderCnt[0] =
pSliceHead->iDeltaPicOrderCnt[1] = 0; pSliceHead->iDeltaPicOrderCnt[1] = 0;
if (pSps->uiPocType == 0) { if (pSps->uiPocType == 0) {
WELS_READ_VERIFY (BsGetBits (pBs, pSps->iLog2MaxPocLsb, &uiCode)); //pic_order_cnt_lsb WELS_READ_VERIFY (BsGetBits (pBs, pSps->iLog2MaxPocLsb, &uiCode)); //pic_order_cnt_lsb
pSliceHead->iPicOrderCntLsb = uiCode; pSliceHead->iPicOrderCntLsb = uiCode;
@@ -854,8 +854,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
} }
//set defaults, might be overriden a few line later //set defaults, might be overriden a few line later
pSliceHead->uiRefCount[0] = pPps->uiNumRefIdxL0Active; pSliceHead->uiRefCount[0] = pPps->uiNumRefIdxL0Active;
pSliceHead->uiRefCount[1] = pPps->uiNumRefIdxL1Active; pSliceHead->uiRefCount[1] = pPps->uiNumRefIdxL1Active;
bool bReadNumRefFlag = (P_SLICE == uiSliceType); bool bReadNumRefFlag = (P_SLICE == uiSliceType);
if (kbExtensionFlag) { if (kbExtensionFlag) {
@@ -928,8 +928,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
} }
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_qp_delta WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_qp_delta
pSliceHead->iSliceQpDelta = iCode; pSliceHead->iSliceQpDelta = iCode;
pSliceHead->iSliceQp = pPps->iPicInitQp + pSliceHead->iSliceQpDelta; pSliceHead->iSliceQp = pPps->iPicInitQp + pSliceHead->iSliceQpDelta;
if (pSliceHead->iSliceQp < 0 || pSliceHead->iSliceQp > 51) { if (pSliceHead->iSliceQp < 0 || pSliceHead->iSliceQp > 51) {
WelsLog (pLogCtx, WELS_LOG_WARNING, "QP %d out of range", pSliceHead->iSliceQp); WelsLog (pLogCtx, WELS_LOG_WARNING, "QP %d out of range", pSliceHead->iSliceQp);
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_QP); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_QP);
@@ -943,9 +943,9 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
} }
} }
pSliceHead->uiDisableDeblockingFilterIdc = 0; pSliceHead->uiDisableDeblockingFilterIdc = 0;
pSliceHead->iSliceAlphaC0Offset = 0; pSliceHead->iSliceAlphaC0Offset = 0;
pSliceHead->iSliceBetaOffset = 0; pSliceHead->iSliceBetaOffset = 0;
if (pPps->bDeblockingFilterControlPresentFlag) { if (pPps->bDeblockingFilterControlPresentFlag) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_deblocking_filter_idc WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_deblocking_filter_idc
pSliceHead->uiDisableDeblockingFilterIdc = uiCode; pSliceHead->uiDisableDeblockingFilterIdc = uiCode;
@@ -1017,21 +1017,21 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
} }
} }
pSliceHeadExt->uiRefLayerChromaPhaseXPlus1Flag = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseXPlus1Flag; pSliceHeadExt->uiRefLayerChromaPhaseXPlus1Flag = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseXPlus1Flag;
pSliceHeadExt->uiRefLayerChromaPhaseYPlus1 = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseYPlus1; pSliceHeadExt->uiRefLayerChromaPhaseYPlus1 = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseYPlus1;
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constrained_intra_resampling_flag WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constrained_intra_resampling_flag
pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode; pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode;
{ {
SPosOffset pos; SPosOffset pos;
pos.iLeftOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iLeftOffset; pos.iLeftOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iLeftOffset;
pos.iTopOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iTopOffset * (2 - pSps->bFrameMbsOnlyFlag); pos.iTopOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iTopOffset * (2 - pSps->bFrameMbsOnlyFlag);
pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset; pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset;
pos.iBottomOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iBottomOffset * (2 - pSps->bFrameMbsOnlyFlag); pos.iBottomOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iBottomOffset * (2 - pSps->bFrameMbsOnlyFlag);
//memcpy(&pSliceHeadExt->sScaledRefLayer, &pos, sizeof(SPosOffset));//confirmed_safe_unsafe_usage //memcpy(&pSliceHeadExt->sScaledRefLayer, &pos, sizeof(SPosOffset));//confirmed_safe_unsafe_usage
pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - (pos.iLeftOffset + pos.iRightOffset); pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - (pos.iLeftOffset + pos.iRightOffset);
pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) - pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) -
(pos.iTopOffset + pos.iBottomOffset) / (1 + pSliceHead->bFieldPicFlag); (pos.iTopOffset + pos.iBottomOffset) / (1 + pSliceHead->bFieldPicFlag);
} }
} else if (uiQualityId > BASE_QUALITY_ID) { } else if (uiQualityId > BASE_QUALITY_ID) {
@@ -1041,17 +1041,17 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
pSliceHeadExt->uiRefLayerDqId = (uint8_t) - 1; pSliceHeadExt->uiRefLayerDqId = (uint8_t) - 1;
} }
pSliceHeadExt->bSliceSkipFlag = false; pSliceHeadExt->bSliceSkipFlag = false;
pSliceHeadExt->bAdaptiveBaseModeFlag = false; pSliceHeadExt->bAdaptiveBaseModeFlag = false;
pSliceHeadExt->bDefaultBaseModeFlag = false; pSliceHeadExt->bDefaultBaseModeFlag = false;
pSliceHeadExt->bAdaptiveMotionPredFlag = false; pSliceHeadExt->bAdaptiveMotionPredFlag = false;
pSliceHeadExt->bDefaultMotionPredFlag = false; pSliceHeadExt->bDefaultMotionPredFlag = false;
pSliceHeadExt->bAdaptiveResidualPredFlag = false; pSliceHeadExt->bAdaptiveResidualPredFlag = false;
pSliceHeadExt->bDefaultResidualPredFlag = false; pSliceHeadExt->bDefaultResidualPredFlag = false;
if (pNalHeaderExt->iNoInterLayerPredFlag) if (pNalHeaderExt->iNoInterLayerPredFlag)
pSliceHeadExt->bTCoeffLevelPredFlag = false; pSliceHeadExt->bTCoeffLevelPredFlag = false;
else else
pSliceHeadExt->bTCoeffLevelPredFlag = pSubsetSps->sSpsSvcExt.bSeqTCoeffLevelPredFlag; pSliceHeadExt->bTCoeffLevelPredFlag = pSubsetSps->sSpsSvcExt.bSeqTCoeffLevelPredFlag;
if (!pNalHeaderExt->iNoInterLayerPredFlag) { if (!pNalHeaderExt->iNoInterLayerPredFlag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_skip_flag WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_skip_flag
@@ -1099,8 +1099,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MGS); return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_MGS);
} }
} else { } else {
pSliceHeadExt->uiScanIdxStart = 0; pSliceHeadExt->uiScanIdxStart = 0;
pSliceHeadExt->uiScanIdxEnd = 15; pSliceHeadExt->uiScanIdxEnd = 15;
} }
} }
@@ -1122,24 +1122,24 @@ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst
if (kppDst == NULL || kpSrc == NULL) if (kppDst == NULL || kpSrc == NULL)
return false; return false;
pNalHdrExtD = &kppDst->sNalHeaderExt; pNalHdrExtD = &kppDst->sNalHeaderExt;
pNalHdrExtS = &kpSrc->sNalHeaderExt; pNalHdrExtS = &kpSrc->sNalHeaderExt;
pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt; pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt;
pPrefixS = &kpSrc->sNalData.sPrefixNal; pPrefixS = &kpSrc->sNalData.sPrefixNal;
pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId]; pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId];
pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId; pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId;
pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId; pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId;
pNalHdrExtD->uiTemporalId = pNalHdrExtS->uiTemporalId; pNalHdrExtD->uiTemporalId = pNalHdrExtS->uiTemporalId;
pNalHdrExtD->uiPriorityId = pNalHdrExtS->uiPriorityId; pNalHdrExtD->uiPriorityId = pNalHdrExtS->uiPriorityId;
pNalHdrExtD->bIdrFlag = pNalHdrExtS->bIdrFlag; pNalHdrExtD->bIdrFlag = pNalHdrExtS->bIdrFlag;
pNalHdrExtD->iNoInterLayerPredFlag = pNalHdrExtS->iNoInterLayerPredFlag; pNalHdrExtD->iNoInterLayerPredFlag = pNalHdrExtS->iNoInterLayerPredFlag;
pNalHdrExtD->bDiscardableFlag = pNalHdrExtS->bDiscardableFlag; pNalHdrExtD->bDiscardableFlag = pNalHdrExtS->bDiscardableFlag;
pNalHdrExtD->bOutputFlag = pNalHdrExtS->bOutputFlag; pNalHdrExtD->bOutputFlag = pNalHdrExtS->bOutputFlag;
pNalHdrExtD->bUseRefBasePicFlag = pNalHdrExtS->bUseRefBasePicFlag; pNalHdrExtD->bUseRefBasePicFlag = pNalHdrExtS->bUseRefBasePicFlag;
pNalHdrExtD->uiLayerDqId = pNalHdrExtS->uiLayerDqId; pNalHdrExtD->uiLayerDqId = pNalHdrExtS->uiLayerDqId;
pShExtD->bStoreRefBasePicFlag = pPrefixS->bStoreRefBasePicFlag; pShExtD->bStoreRefBasePicFlag = pPrefixS->bStoreRefBasePicFlag;
memcpy (&pShExtD->sRefBasePicMarking, &pPrefixS->sRefPicBaseMarking, memcpy (&pShExtD->sRefBasePicMarking, &pPrefixS->sRefPicBaseMarking,
sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage sizeof (SRefBasePicMarking)); //confirmed_safe_unsafe_usage
if (pShExtD->sRefBasePicMarking.bAdaptiveRefBasePicMarkingModeFlag) { if (pShExtD->sRefBasePicMarking.bAdaptiveRefBasePicMarkingModeFlag) {
@@ -1161,7 +1161,7 @@ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst
int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) { int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) {
PAccessUnit pCurAu = pCtx->pAccessUnitList; PAccessUnit pCurAu = pCtx->pAccessUnitList;
int32_t iIdx = pCurAu->uiEndPos; int32_t iIdx = pCurAu->uiEndPos;
// Conversed iterator // Conversed iterator
@@ -1211,8 +1211,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
int32_t i = 0; int32_t i = 0;
WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiMaxWidth <= 0 || kiMaxHeight <= 0)) WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiMaxWidth <= 0 || kiMaxHeight <= 0))
pCtx->sMb.iMbWidth = (kiMaxWidth + 15) >> 4; pCtx->sMb.iMbWidth = (kiMaxWidth + 15) >> 4;
pCtx->sMb.iMbHeight = (kiMaxHeight + 15) >> 4; pCtx->sMb.iMbHeight = (kiMaxHeight + 15) >> 4;
if (pCtx->bInitialDqLayersMem && kiMaxWidth <= pCtx->iPicWidthReq if (pCtx->bInitialDqLayersMem && kiMaxWidth <= pCtx->iPicWidthReq
&& kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped
@@ -1313,9 +1313,9 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid
++ i; ++ i;
} while (i < LAYER_NUM_EXCHANGEABLE); } while (i < LAYER_NUM_EXCHANGEABLE);
pCtx->bInitialDqLayersMem = true; pCtx->bInitialDqLayersMem = true;
pCtx->iPicWidthReq = kiMaxWidth; pCtx->iPicWidthReq = kiMaxWidth;
pCtx->iPicHeightReq = kiMaxHeight; pCtx->iPicHeightReq = kiMaxHeight;
return ERR_NONE; return ERR_NONE;
} }
@@ -1478,22 +1478,22 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) {
++ i; ++ i;
} while (i < LAYER_NUM_EXCHANGEABLE); } while (i < LAYER_NUM_EXCHANGEABLE);
pCtx->iPicWidthReq = 0; pCtx->iPicWidthReq = 0;
pCtx->iPicHeightReq = 0; pCtx->iPicHeightReq = 0;
pCtx->bInitialDqLayersMem = false; pCtx->bInitialDqLayersMem = false;
} }
void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) { void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) {
PAccessUnit pCurAu = pCtx->pAccessUnitList; PAccessUnit pCurAu = pCtx->pAccessUnitList;
pCurAu->uiStartPos = 0; pCurAu->uiStartPos = 0;
pCurAu->uiEndPos = 0; pCurAu->uiEndPos = 0;
pCurAu->bCompletedAuFlag = false; pCurAu->bCompletedAuFlag = false;
if (pCurAu->uiActualUnitsNum > 0) { if (pCurAu->uiActualUnitsNum > 0) {
uint32_t iIdx = 0; uint32_t iIdx = 0;
const uint32_t kuiActualNum = pCurAu->uiActualUnitsNum; const uint32_t kuiActualNum = pCurAu->uiActualUnitsNum;
// a more simpler method to do nal units list management prefered here // a more simpler method to do nal units list management prefered here
const uint32_t kuiAvailNum = pCurAu->uiAvailUnitsNum; const uint32_t kuiAvailNum = pCurAu->uiAvailUnitsNum;
const uint32_t kuiLeftNum = kuiAvailNum - kuiActualNum; const uint32_t kuiLeftNum = kuiAvailNum - kuiActualNum;
// Swapping active nal unit nodes of succeeding AU with leading of list // Swapping active nal unit nodes of succeeding AU with leading of list
while (iIdx < kuiLeftNum) { while (iIdx < kuiLeftNum) {
@@ -1512,27 +1512,27 @@ void ResetCurrentAccessUnit (PWelsDecoderContext pCtx) {
* \history 11/16/2009 * \history 11/16/2009
*/ */
void ForceResetCurrentAccessUnit (PAccessUnit pAu) { void ForceResetCurrentAccessUnit (PAccessUnit pAu) {
uint32_t uiSucAuIdx = pAu->uiEndPos + 1; uint32_t uiSucAuIdx = pAu->uiEndPos + 1;
uint32_t uiCurAuIdx = 0; uint32_t uiCurAuIdx = 0;
// swap the succeeding AU's nal units to the front // swap the succeeding AU's nal units to the front
while (uiSucAuIdx < pAu->uiAvailUnitsNum) { while (uiSucAuIdx < pAu->uiAvailUnitsNum) {
PNalUnit t = pAu->pNalUnitsList[uiSucAuIdx]; PNalUnit t = pAu->pNalUnitsList[uiSucAuIdx];
pAu->pNalUnitsList[uiSucAuIdx] = pAu->pNalUnitsList[uiCurAuIdx]; pAu->pNalUnitsList[uiSucAuIdx] = pAu->pNalUnitsList[uiCurAuIdx];
pAu->pNalUnitsList[uiCurAuIdx] = t; pAu->pNalUnitsList[uiCurAuIdx] = t;
++ uiSucAuIdx; ++ uiSucAuIdx;
++ uiCurAuIdx; ++ uiCurAuIdx;
} }
// Update avail/actual units num accordingly for next AU parsing // Update avail/actual units num accordingly for next AU parsing
if (pAu->uiAvailUnitsNum > pAu->uiEndPos) if (pAu->uiAvailUnitsNum > pAu->uiEndPos)
pAu->uiAvailUnitsNum -= (pAu->uiEndPos + 1); pAu->uiAvailUnitsNum -= (pAu->uiEndPos + 1);
else else
pAu->uiAvailUnitsNum = 0; pAu->uiAvailUnitsNum = 0;
pAu->uiActualUnitsNum = 0; pAu->uiActualUnitsNum = 0;
pAu->uiStartPos = 0; pAu->uiStartPos = 0;
pAu->uiEndPos = 0; pAu->uiEndPos = 0;
pAu->bCompletedAuFlag = false; pAu->bCompletedAuFlag = false;
} }
//clear current corrupted NAL from pNalUnitsList //clear current corrupted NAL from pNalUnitsList
@@ -1547,11 +1547,11 @@ void ForceResetParaSetStatusAndAUList (PWelsDecoderContext pCtx) {
pCtx->bPpsExistAheadFlag = false; pCtx->bPpsExistAheadFlag = false;
// Force clear the AU list // Force clear the AU list
pCtx->pAccessUnitList->uiAvailUnitsNum = 0; pCtx->pAccessUnitList->uiAvailUnitsNum = 0;
pCtx->pAccessUnitList->uiActualUnitsNum = 0; pCtx->pAccessUnitList->uiActualUnitsNum = 0;
pCtx->pAccessUnitList->uiStartPos = 0; pCtx->pAccessUnitList->uiStartPos = 0;
pCtx->pAccessUnitList->uiEndPos = 0; pCtx->pAccessUnitList->uiEndPos = 0;
pCtx->pAccessUnitList->bCompletedAuFlag = false; pCtx->pAccessUnitList->bCompletedAuFlag = false;
} }
void CheckAvailNalUnitsListContinuity (PWelsDecoderContext pCtx, int32_t iStartIdx, int32_t iEndIdx) { void CheckAvailNalUnitsListContinuity (PWelsDecoderContext pCtx, int32_t iStartIdx, int32_t iEndIdx) {
@@ -1985,35 +1985,35 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PNalUnit pNalUnit, PPicture pPicDec) { static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PNalUnit pNalUnit, PPicture pPicDec) {
PNalUnitHeaderExt pNalHdrExt = &pNalUnit->sNalHeaderExt; PNalUnitHeaderExt pNalHdrExt = &pNalUnit->sNalHeaderExt;
PSliceHeaderExt pShExt = &pNalUnit->sNalData.sVclNal.sSliceHeaderExt; PSliceHeaderExt pShExt = &pNalUnit->sNalData.sVclNal.sSliceHeaderExt;
PSliceHeader pSh = &pShExt->sSliceHeader; PSliceHeader pSh = &pShExt->sSliceHeader;
const uint8_t kuiQualityId = pNalHdrExt->uiQualityId; const uint8_t kuiQualityId = pNalHdrExt->uiQualityId;
memcpy (&pDqLayer->sLayerInfo, pLayerInfo, sizeof (SLayerInfo)); //confirmed_safe_unsafe_usage memcpy (&pDqLayer->sLayerInfo, pLayerInfo, sizeof (SLayerInfo)); //confirmed_safe_unsafe_usage
pDqLayer->pDec = pPicDec; pDqLayer->pDec = pPicDec;
pDqLayer->iMbWidth = pSh->iMbWidth; // MB width of this picture pDqLayer->iMbWidth = pSh->iMbWidth; // MB width of this picture
pDqLayer->iMbHeight = pSh->iMbHeight;// MB height of this picture pDqLayer->iMbHeight = pSh->iMbHeight;// MB height of this picture
pDqLayer->iSliceIdcBackup = (pSh->iFirstMbInSlice << 7) | (pNalHdrExt->uiDependencyId << 4) | (pNalHdrExt->uiQualityId); pDqLayer->iSliceIdcBackup = (pSh->iFirstMbInSlice << 7) | (pNalHdrExt->uiDependencyId << 4) | (pNalHdrExt->uiQualityId);
/* Common syntax elements across all slices of a DQLayer */ /* Common syntax elements across all slices of a DQLayer */
pDqLayer->uiPpsId = pLayerInfo->pPps->iPpsId; pDqLayer->uiPpsId = pLayerInfo->pPps->iPpsId;
pDqLayer->uiDisableInterLayerDeblockingFilterIdc = pShExt->uiDisableInterLayerDeblockingFilterIdc; pDqLayer->uiDisableInterLayerDeblockingFilterIdc = pShExt->uiDisableInterLayerDeblockingFilterIdc;
pDqLayer->iInterLayerSliceAlphaC0Offset = pShExt->iInterLayerSliceAlphaC0Offset; pDqLayer->iInterLayerSliceAlphaC0Offset = pShExt->iInterLayerSliceAlphaC0Offset;
pDqLayer->iInterLayerSliceBetaOffset = pShExt->iInterLayerSliceBetaOffset; pDqLayer->iInterLayerSliceBetaOffset = pShExt->iInterLayerSliceBetaOffset;
pDqLayer->iSliceGroupChangeCycle = pSh->iSliceGroupChangeCycle; pDqLayer->iSliceGroupChangeCycle = pSh->iSliceGroupChangeCycle;
pDqLayer->bStoreRefBasePicFlag = pShExt->bStoreRefBasePicFlag; pDqLayer->bStoreRefBasePicFlag = pShExt->bStoreRefBasePicFlag;
pDqLayer->bTCoeffLevelPredFlag = pShExt->bTCoeffLevelPredFlag; pDqLayer->bTCoeffLevelPredFlag = pShExt->bTCoeffLevelPredFlag;
pDqLayer->bConstrainedIntraResamplingFlag = pShExt->bConstrainedIntraResamplingFlag; pDqLayer->bConstrainedIntraResamplingFlag = pShExt->bConstrainedIntraResamplingFlag;
pDqLayer->uiRefLayerDqId = pShExt->uiRefLayerDqId; pDqLayer->uiRefLayerDqId = pShExt->uiRefLayerDqId;
pDqLayer->uiRefLayerChromaPhaseXPlus1Flag = pShExt->uiRefLayerChromaPhaseXPlus1Flag; pDqLayer->uiRefLayerChromaPhaseXPlus1Flag = pShExt->uiRefLayerChromaPhaseXPlus1Flag;
pDqLayer->uiRefLayerChromaPhaseYPlus1 = pShExt->uiRefLayerChromaPhaseYPlus1; pDqLayer->uiRefLayerChromaPhaseYPlus1 = pShExt->uiRefLayerChromaPhaseYPlus1;
//memcpy(&pDqLayer->sScaledRefLayer, &pShExt->sScaledRefLayer, sizeof(SPosOffset));//confirmed_safe_unsafe_usage //memcpy(&pDqLayer->sScaledRefLayer, &pShExt->sScaledRefLayer, sizeof(SPosOffset));//confirmed_safe_unsafe_usage
if (kuiQualityId == BASE_QUALITY_ID) { if (kuiQualityId == BASE_QUALITY_ID) {
pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering; pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering;
pDqLayer->pRefPicMarking = &pSh->sRefMarking; pDqLayer->pRefPicMarking = &pSh->sRefMarking;
if (pSh->pPps->bWeightedPredFlag) { if (pSh->pPps->bWeightedPredFlag) {
pDqLayer->bUseWeightPredictionFlag = true; pDqLayer->bUseWeightPredictionFlag = true;
@@ -2022,20 +2022,20 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN
} else } else
pDqLayer->bUseWeightPredictionFlag = false; pDqLayer->bUseWeightPredictionFlag = false;
pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking; pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking;
} }
pDqLayer->uiLayerDqId = pNalHdrExt->uiLayerDqId; // dq_id of current layer pDqLayer->uiLayerDqId = pNalHdrExt->uiLayerDqId; // dq_id of current layer
pDqLayer->bUseRefBasePicFlag = pNalHdrExt->bUseRefBasePicFlag; pDqLayer->bUseRefBasePicFlag = pNalHdrExt->bUseRefBasePicFlag;
} }
void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pSps, PPps pPps) { void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pSps, PPps pPps) {
PSliceHeader pSh = &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; PSliceHeader pSh = &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
pCtx->eSliceType = pSh->eSliceType; pCtx->eSliceType = pSh->eSliceType;
pCtx->pSliceHeader = pSh; pCtx->pSliceHeader = pSh;
pCtx->iFrameNum = pSh->iFrameNum; pCtx->iFrameNum = pSh->iFrameNum;
} }
int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) { int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) {
@@ -2050,18 +2050,18 @@ int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t
void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) {
if (NULL != pCtx && NULL != pCurDq) { if (NULL != pCtx && NULL != pCurDq) {
pCurDq->pMbType = pCtx->sMb.pMbType[0]; pCurDq->pMbType = pCtx->sMb.pMbType[0];
pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0]; pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0];
pCurDq->pMv[0] = pCtx->sMb.pMv[0][0]; pCurDq->pMv[0] = pCtx->sMb.pMv[0][0];
pCurDq->pRefIndex[0] = pCtx->sMb.pRefIndex[0][0]; pCurDq->pRefIndex[0] = pCtx->sMb.pRefIndex[0][0];
pCurDq->pNoSubMbPartSizeLessThan8x8Flag = pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[0]; pCurDq->pNoSubMbPartSizeLessThan8x8Flag = pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[0];
pCurDq->pTransformSize8x8Flag = pCtx->sMb.pTransformSize8x8Flag[0]; pCurDq->pTransformSize8x8Flag = pCtx->sMb.pTransformSize8x8Flag[0];
pCurDq->pLumaQp = pCtx->sMb.pLumaQp[0]; pCurDq->pLumaQp = pCtx->sMb.pLumaQp[0];
pCurDq->pChromaQp = pCtx->sMb.pChromaQp[0]; pCurDq->pChromaQp = pCtx->sMb.pChromaQp[0];
pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0]; pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0];
pCurDq->pCbfDc = pCtx->sMb.pCbfDc[0]; pCurDq->pCbfDc = pCtx->sMb.pCbfDc[0];
pCurDq->pNzc = pCtx->sMb.pNzc[0]; pCurDq->pNzc = pCtx->sMb.pNzc[0];
pCurDq->pNzcRs = pCtx->sMb.pNzcRs[0]; pCurDq->pNzcRs = pCtx->sMb.pNzcRs[0];
pCurDq->pScaledTCoeff = pCtx->sMb.pScaledTCoeff[0]; pCurDq->pScaledTCoeff = pCtx->sMb.pScaledTCoeff[0];
pCurDq->pIntraPredMode = pCtx->sMb.pIntraPredMode[0]; pCurDq->pIntraPredMode = pCtx->sMb.pIntraPredMode[0];
pCurDq->pIntra4x4FinalMode = pCtx->sMb.pIntra4x4FinalMode[0]; pCurDq->pIntra4x4FinalMode = pCtx->sMb.pIntra4x4FinalMode[0];
@@ -2156,10 +2156,10 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
*/ */
while (iIdx <= iEndIdx) { while (iIdx <= iEndIdx) {
bool bReconstructSlice; bool bReconstructSlice;
iCurrIdQ = pNalCur->sNalHeaderExt.uiQualityId; iCurrIdQ = pNalCur->sNalHeaderExt.uiQualityId;
iCurrIdD = pNalCur->sNalHeaderExt.uiDependencyId; iCurrIdD = pNalCur->sNalHeaderExt.uiDependencyId;
pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader; pSh = &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
pShExt = &pNalCur->sNalData.sVclNal.sSliceHeaderExt; pShExt = &pNalCur->sNalData.sVclNal.sSliceHeaderExt;
pCtx->bRPLRError = false; pCtx->bRPLRError = false;
bReconstructSlice = CheckSliceNeedReconstruct (pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId); bReconstructSlice = CheckSliceNeedReconstruct (pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId);
@@ -2170,14 +2170,14 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf
pCtx->pDec->bIdrFlag = pNalCur->sNalHeaderExt.bIdrFlag; pCtx->pDec->bIdrFlag = pNalCur->sNalHeaderExt.bIdrFlag;
memcpy (&pLayerInfo.sSliceInLayer.sSliceHeaderExt, pShExt, sizeof (SSliceHeaderExt)); //confirmed_safe_unsafe_usage memcpy (&pLayerInfo.sSliceInLayer.sSliceHeaderExt, pShExt, sizeof (SSliceHeaderExt)); //confirmed_safe_unsafe_usage
pLayerInfo.sSliceInLayer.bSliceHeaderExtFlag = pNalCur->sNalData.sVclNal.bSliceHeaderExtFlag; pLayerInfo.sSliceInLayer.bSliceHeaderExtFlag = pNalCur->sNalData.sVclNal.bSliceHeaderExtFlag;
pLayerInfo.sSliceInLayer.eSliceType = pSh->eSliceType; pLayerInfo.sSliceInLayer.eSliceType = pSh->eSliceType;
pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp; pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp;
dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead; dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead;
uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc; uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc;
iPpsId = pSh->iPpsId; iPpsId = pSh->iPpsId;
pLayerInfo.pPps = pSh->pPps; pLayerInfo.pPps = pSh->pPps;
pLayerInfo.pSps = pSh->pSps; pLayerInfo.pSps = pSh->pSps;

View File

@@ -117,9 +117,9 @@ static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const in
*/ */
static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth, static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth,
const int32_t kiMbHeight) { const int32_t kiMbHeight) {
int32_t iNumMb = 0; int32_t iNumMb = 0;
int32_t iErr = 0; int32_t iErr = 0;
bool bResolutionChanged = false; bool bResolutionChanged = false;
// the cases we would not like // the cases we would not like
WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == kpPps)) WELS_VERIFY_RETURN_IF (1, (NULL == pFmo || NULL == kpPps))
@@ -168,9 +168,9 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const
} }
} }
if (0 == iErr) { // well now if (0 == iErr) { // well now
pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups; pFmo->iSliceGroupCount = kpPps->uiNumSliceGroups;
pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType; pFmo->iSliceGroupType = kpPps->uiSliceGroupMapType;
} }
return iErr; return iErr;
@@ -215,10 +215,10 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) {
pIter->pMbAllocMap = NULL; pIter->pMbAllocMap = NULL;
} }
pIter->iSliceGroupCount = 0; pIter->iSliceGroupCount = 0;
pIter->iSliceGroupType = -1; pIter->iSliceGroupType = -1;
pIter->iCountMbNum = 0; pIter->iCountMbNum = 0;
pIter->bActiveFlag = false; pIter->bActiveFlag = false;
++ iFreeNodes; ++ iFreeNodes;
if (iFreeNodes >= kiAvail) if (iFreeNodes >= kiAvail)
break; break;
@@ -289,8 +289,8 @@ bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) {
* \return slice group idc - successful; -1 - failed; * \return slice group idc - successful; -1 - failed;
*/ */
int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) { int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) {
const int32_t kiMbNum = pFmo->iCountMbNum; const int32_t kiMbNum = pFmo->iCountMbNum;
const uint8_t* kpMbMap = pFmo->pMbAllocMap; const uint8_t* kpMbMap = pFmo->pMbAllocMap;
if (kiMbXy < 0 || kiMbXy >= kiMbNum || kpMbMap == NULL) if (kiMbXy < 0 || kiMbXy >= kiMbNum || kpMbMap == NULL)
return -1; return -1;
@@ -307,10 +307,10 @@ int32_t FmoMbToSliceGroup (PFmo pFmo, const MB_XY_T kiMbXy) {
* \return iNextMb - successful; -1 - failed; * \return iNextMb - successful; -1 - failed;
*/ */
MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy) { MB_XY_T FmoNextMb (PFmo pFmo, const MB_XY_T kiMbXy) {
const int32_t kiTotalMb = pFmo->iCountMbNum; const int32_t kiTotalMb = pFmo->iCountMbNum;
const uint8_t* kpMbMap = pFmo->pMbAllocMap; const uint8_t* kpMbMap = pFmo->pMbAllocMap;
MB_XY_T iNextMb = kiMbXy; MB_XY_T iNextMb = kiMbXy;
const uint8_t kuiSliceGroupIdc = (uint8_t)FmoMbToSliceGroup (pFmo, kiMbXy); const uint8_t kuiSliceGroupIdc = (uint8_t)FmoMbToSliceGroup (pFmo, kiMbXy);
if (kuiSliceGroupIdc == (uint8_t) (-1)) if (kuiSliceGroupIdc == (uint8_t) (-1))
return -1; return -1;

View File

@@ -75,10 +75,10 @@ void WelsI4x4LumaPredH_c (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride2 + kiStride; const int32_t kiStride3 = kiStride2 + kiStride;
const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] +
pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 4) >> 3; pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 4) >> 3;
const uint32_t kuiMean32 = 0x01010101U * kuiMean; const uint32_t kuiMean32 = 0x01010101U * kuiMean;
ST32A4 (pPred , kuiMean32); ST32A4 (pPred , kuiMean32);
@@ -88,9 +88,9 @@ void WelsI4x4LumaPredDc_c (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride2 + kiStride; const int32_t kiStride3 = kiStride2 + kiStride;
const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + 2) >> 2; const uint8_t kuiMean = (pPred[-1] + pPred[-1 + kiStride] + pPred[-1 + kiStride2] + pPred[-1 + kiStride3] + 2) >> 2;
const uint32_t kuiMean32 = 0x01010101U * kuiMean; const uint32_t kuiMean32 = 0x01010101U * kuiMean;
ST32A4 (pPred , kuiMean32); ST32A4 (pPred , kuiMean32);
@@ -100,10 +100,9 @@ void WelsI4x4LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride2 + kiStride; const int32_t kiStride3 = kiStride2 + kiStride;
const uint8_t kuiMean = (pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 2) >> const uint8_t kuiMean = (pPred[-kiStride] + pPred[-kiStride + 1] + pPred[-kiStride + 2] + pPred[-kiStride + 3] + 2) >> 2;
2;
const uint32_t kuiMean32 = 0x01010101U * kuiMean; const uint32_t kuiMean32 = 0x01010101U * kuiMean;
ST32A4 (pPred , kuiMean32); ST32A4 (pPred , kuiMean32);
@@ -123,25 +122,25 @@ void WelsI4x4LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) {
/*down pLeft*/ /*down pLeft*/
void WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
/*get pTop*/ /*get pTop*/
uint8_t* ptop = &pPred[-kiStride]; uint8_t* ptop = &pPred[-kiStride];
const uint8_t kuiT0 = *ptop; const uint8_t kuiT0 = *ptop;
const uint8_t kuiT1 = * (ptop + 1); const uint8_t kuiT1 = * (ptop + 1);
const uint8_t kuiT2 = * (ptop + 2); const uint8_t kuiT2 = * (ptop + 2);
const uint8_t kuiT3 = * (ptop + 3); const uint8_t kuiT3 = * (ptop + 3);
const uint8_t kuiT4 = * (ptop + 4); const uint8_t kuiT4 = * (ptop + 4);
const uint8_t kuiT5 = * (ptop + 5); const uint8_t kuiT5 = * (ptop + 5);
const uint8_t kuiT6 = * (ptop + 6); const uint8_t kuiT6 = * (ptop + 6);
const uint8_t kuiT7 = * (ptop + 7); const uint8_t kuiT7 = * (ptop + 7);
const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0 const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0
const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1 const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1
const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2 const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2
const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3 const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3
const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4 const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4
const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5 const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5
const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6 const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6
const uint8_t kuiList[8] = { kuiDDL0, kuiDDL1, kuiDDL2, kuiDDL3, kuiDDL4, kuiDDL5, kuiDDL6, 0 }; const uint8_t kuiList[8] = { kuiDDL0, kuiDDL1, kuiDDL2, kuiDDL3, kuiDDL4, kuiDDL5, kuiDDL6, 0 };
ST32A4 (pPred , LD32 (kuiList)); ST32A4 (pPred , LD32 (kuiList));
@@ -152,22 +151,22 @@ void WelsI4x4LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride) {
/*down pLeft*/ /*down pLeft*/
void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
/*get pTop*/ /*get pTop*/
uint8_t* ptop = &pPred[-kiStride]; uint8_t* ptop = &pPred[-kiStride];
const uint8_t kuiT0 = *ptop; const uint8_t kuiT0 = *ptop;
const uint8_t kuiT1 = * (ptop + 1); const uint8_t kuiT1 = * (ptop + 1);
const uint8_t kuiT2 = * (ptop + 2); const uint8_t kuiT2 = * (ptop + 2);
const uint8_t kuiT3 = * (ptop + 3); const uint8_t kuiT3 = * (ptop + 3);
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiT33 = 1 + (kuiT3 << 1); const uint16_t kuiT33 = 1 + (kuiT3 << 1);
const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0 const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0
const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1 const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1
const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2 const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2
const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3 const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3
const uint8_t kuiList[8] = { kuiDLT0, kuiDLT1, kuiDLT2, kuiDLT3, kuiDLT3, kuiDLT3, kuiDLT3 , kuiDLT3 }; const uint8_t kuiList[8] = { kuiDLT0, kuiDLT1, kuiDLT2, kuiDLT3, kuiDLT3, kuiDLT3, kuiDLT3 , kuiDLT3 };
ST32A4 (pPred, LD32 (kuiList)); ST32A4 (pPred, LD32 (kuiList));
@@ -179,36 +178,36 @@ void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride) {
/*down right*/ /*down right*/
void WelsI4x4LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* ptopleft = &pPred[- (kiStride + 1)]; uint8_t* ptopleft = &pPred[- (kiStride + 1)];
uint8_t* pleft = &pPred[-1]; uint8_t* pleft = &pPred[-1];
const uint8_t kuiLT = *ptopleft; const uint8_t kuiLT = *ptopleft;
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = *pleft; const uint8_t kuiL0 = *pleft;
const uint8_t kuiL1 = * (pleft + kiStride); const uint8_t kuiL1 = * (pleft + kiStride);
const uint8_t kuiL2 = * (pleft + kiStride2); const uint8_t kuiL2 = * (pleft + kiStride2);
const uint8_t kuiL3 = * (pleft + kiStride3); const uint8_t kuiL3 = * (pleft + kiStride3);
const uint8_t kuiT0 = * (ptopleft + 1); const uint8_t kuiT0 = * (ptopleft + 1);
const uint8_t kuiT1 = * (ptopleft + 2); const uint8_t kuiT1 = * (ptopleft + 2);
const uint8_t kuiT2 = * (ptopleft + 3); const uint8_t kuiT2 = * (ptopleft + 3);
const uint8_t kuiT3 = * (ptopleft + 4); const uint8_t kuiT3 = * (ptopleft + 4);
const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0 const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0
const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1 const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1
const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2 const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2
const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3 const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3
const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4 const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4
const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5 const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5
const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6 const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6
const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 }; const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 };
ST32A4 (pPred , LD32 (kuiList + 3)); ST32A4 (pPred , LD32 (kuiList + 3));
ST32A4 (pPred + kiStride , LD32 (kuiList + 2)); ST32A4 (pPred + kiStride , LD32 (kuiList + 2));
@@ -219,34 +218,34 @@ void WelsI4x4LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride) {
/*vertical pLeft*/ /*vertical pLeft*/
void WelsI4x4LumaPredVL_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredVL_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* ptopleft = &pPred[- (kiStride + 1)]; uint8_t* ptopleft = &pPred[- (kiStride + 1)];
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = * (ptopleft + 1); const uint8_t kuiT0 = * (ptopleft + 1);
const uint8_t kuiT1 = * (ptopleft + 2); const uint8_t kuiT1 = * (ptopleft + 2);
const uint8_t kuiT2 = * (ptopleft + 3); const uint8_t kuiT2 = * (ptopleft + 3);
const uint8_t kuiT3 = * (ptopleft + 4); const uint8_t kuiT3 = * (ptopleft + 4);
const uint8_t kuiT4 = * (ptopleft + 5); const uint8_t kuiT4 = * (ptopleft + 5);
const uint8_t kuiT5 = * (ptopleft + 6); const uint8_t kuiT5 = * (ptopleft + 6);
const uint8_t kuiT6 = * (ptopleft + 7); const uint8_t kuiT6 = * (ptopleft + 7);
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiT34 = 1 + kuiT3 + kuiT4; const uint16_t kuiT34 = 1 + kuiT3 + kuiT4;
const uint16_t kuiT45 = 1 + kuiT4 + kuiT5; const uint16_t kuiT45 = 1 + kuiT4 + kuiT5;
const uint16_t kuiT56 = 1 + kuiT5 + kuiT6; const uint16_t kuiT56 = 1 + kuiT5 + kuiT6;
const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0 const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0
const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1 const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1
const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2 const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2
const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3 const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3
const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4 const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4
const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5 const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5
const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6 const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6
const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7 const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7
const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8 const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8
const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9 const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9
const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 }; const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 };
ST32A4 (pPred, LD32 (kuiList)); ST32A4 (pPred, LD32 (kuiList));
ST32A4 (pPred + kiStride, LD32 (kuiList + 5)); ST32A4 (pPred + kiStride, LD32 (kuiList + 5));
@@ -256,27 +255,27 @@ void WelsI4x4LumaPredVL_c (uint8_t* pPred, const int32_t kiStride) {
/*vertical pLeft*/ /*vertical pLeft*/
void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* ptopleft = &pPred[- (kiStride + 1)]; uint8_t* ptopleft = &pPred[- (kiStride + 1)];
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = * (ptopleft + 1); const uint8_t kuiT0 = * (ptopleft + 1);
const uint8_t kuiT1 = * (ptopleft + 2); const uint8_t kuiT1 = * (ptopleft + 2);
const uint8_t kuiT2 = * (ptopleft + 3); const uint8_t kuiT2 = * (ptopleft + 3);
const uint8_t kuiT3 = * (ptopleft + 4); const uint8_t kuiT3 = * (ptopleft + 4);
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiT33 = 1 + (kuiT3 << 1); const uint16_t kuiT33 = 1 + (kuiT3 << 1);
const uint8_t kuiVL0 = kuiT01 >> 1; const uint8_t kuiVL0 = kuiT01 >> 1;
const uint8_t kuiVL1 = kuiT12 >> 1; const uint8_t kuiVL1 = kuiT12 >> 1;
const uint8_t kuiVL2 = kuiT23 >> 1; const uint8_t kuiVL2 = kuiT23 >> 1;
const uint8_t kuiVL3 = kuiT33 >> 1; const uint8_t kuiVL3 = kuiT33 >> 1;
const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2; const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2;
const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2; const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2;
const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2; const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2;
const uint8_t kuiVL7 = kuiVL3; const uint8_t kuiVL7 = kuiVL3;
const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 }; const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 };
ST32A4 (pPred , LD32 (kuiList)); ST32A4 (pPred , LD32 (kuiList));
ST32A4 (pPred + kiStride , LD32 (kuiList + 5)); ST32A4 (pPred + kiStride , LD32 (kuiList + 5));
@@ -287,28 +286,28 @@ void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride) {
/*vertical right*/ /*vertical right*/
void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
const uint8_t kuiLT = pPred[-kiStride - 1]; const uint8_t kuiLT = pPred[-kiStride - 1];
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pPred[ -1]; const uint8_t kuiL0 = pPred[ - 1];
const uint8_t kuiL1 = pPred[kiStride - 1]; const uint8_t kuiL1 = pPred[kiStride - 1];
const uint8_t kuiL2 = pPred[kiStride2 - 1]; const uint8_t kuiL2 = pPred[kiStride2 - 1];
const uint8_t kuiT0 = pPred[ -kiStride]; const uint8_t kuiT0 = pPred[ -kiStride];
const uint8_t kuiT1 = pPred[1 - kiStride]; const uint8_t kuiT1 = pPred[1 - kiStride];
const uint8_t kuiT2 = pPred[2 - kiStride]; const uint8_t kuiT2 = pPred[2 - kiStride];
const uint8_t kuiT3 = pPred[3 - kiStride]; const uint8_t kuiT3 = pPred[3 - kiStride];
const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0 const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0
const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1 const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1
const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2 const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2
const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3 const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3
const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4 const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4
const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5 const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5
const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6 const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6
const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7 const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7
const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8 const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8
const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9 const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9
const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 }; const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 };
ST32A4 (pPred , LD32 (kuiList + 1)); ST32A4 (pPred , LD32 (kuiList + 1));
ST32A4 (pPred + kiStride , LD32 (kuiList + 6)); ST32A4 (pPred + kiStride , LD32 (kuiList + 6));
@@ -318,23 +317,23 @@ void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride) {
/*horizontal up*/ /*horizontal up*/
void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
/*get pLeft*/ /*get pLeft*/
const uint8_t kuiL0 = pPred[ -1]; const uint8_t kuiL0 = pPred[ - 1];
const uint8_t kuiL1 = pPred[kiStride - 1]; const uint8_t kuiL1 = pPred[kiStride - 1];
const uint8_t kuiL2 = pPred[kiStride2 - 1]; const uint8_t kuiL2 = pPred[kiStride2 - 1];
const uint8_t kuiL3 = pPred[kiStride3 - 1]; const uint8_t kuiL3 = pPred[kiStride3 - 1];
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiHU0 = kuiL01 >> 1; const uint8_t kuiHU0 = kuiL01 >> 1;
const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiHU2 = kuiL12 >> 1; const uint8_t kuiHU2 = kuiL12 >> 1;
const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2;
const uint8_t kuiHU4 = kuiL23 >> 1; const uint8_t kuiHU4 = kuiL23 >> 1;
const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2;
const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 }; const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 };
ST32A4 (pPred , LD32 (kuiList)); ST32A4 (pPred , LD32 (kuiList));
ST32A4 (pPred + kiStride , LD32 (kuiList + 2)); ST32A4 (pPred + kiStride , LD32 (kuiList + 2));
@@ -344,35 +343,35 @@ void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride) {
/*horizontal down*/ /*horizontal down*/
void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
const uint8_t kuiLT = pPred[- (kiStride + 1)]; const uint8_t kuiLT = pPred[- (kiStride + 1)];
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pPred[-1 ]; const uint8_t kuiL0 = pPred[-1 ];
const uint8_t kuiL1 = pPred[-1 + kiStride ]; const uint8_t kuiL1 = pPred[-1 + kiStride ];
const uint8_t kuiL2 = pPred[-1 + kiStride2]; const uint8_t kuiL2 = pPred[-1 + kiStride2];
const uint8_t kuiL3 = pPred[-1 + kiStride3]; const uint8_t kuiL3 = pPred[-1 + kiStride3];
const uint8_t kuiT0 = pPred[-kiStride ]; const uint8_t kuiT0 = pPred[-kiStride ];
const uint8_t kuiT1 = pPred[-kiStride + 1 ]; const uint8_t kuiT1 = pPred[-kiStride + 1 ];
const uint8_t kuiT2 = pPred[-kiStride + 2 ]; const uint8_t kuiT2 = pPred[-kiStride + 2 ];
const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiHD0 = kuiTL0 >> 1; const uint8_t kuiHD0 = kuiTL0 >> 1;
const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2; const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2;
const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2; const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2;
const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2; const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2;
const uint8_t kuiHD4 = kuiL01 >> 1; const uint8_t kuiHD4 = kuiL01 >> 1;
const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2; const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2;
const uint8_t kuiHD6 = kuiL12 >> 1; const uint8_t kuiHD6 = kuiL12 >> 1;
const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2; const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiHD8 = kuiL23 >> 1; const uint8_t kuiHD8 = kuiL23 >> 1;
const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2;
const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 }; const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 };
ST32A4 (pPred , LD32 (kuiList + 6)); ST32A4 (pPred , LD32 (kuiList + 6));
ST32A4 (pPred + kiStride , LD32 (kuiList + 4)); ST32A4 (pPred + kiStride , LD32 (kuiList + 4));
@@ -882,8 +881,8 @@ void WelsI8x8LumaPredHD_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail
void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) {
const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]); const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]);
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride4 = kiStride2 << 1; const int32_t kiStride4 = kiStride2 << 1;
ST64A8 (pPred , kuiVal64); ST64A8 (pPred , kuiVal64);
@@ -901,8 +900,8 @@ void WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride) {
uint8_t i = 7; uint8_t i = 7;
do { do {
const uint8_t kuiVal8 = pPred[iTmp - 1]; const uint8_t kuiVal8 = pPred[iTmp - 1];
const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8; const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8;
ST64A8 (pPred + iTmp, kuiVal64); ST64A8 (pPred + iTmp, kuiVal64);
@@ -938,25 +937,25 @@ void WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride) {
void WelsIChromaPredDc_c (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDc_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiL1 = kiStride - 1; const int32_t kiL1 = kiStride - 1;
const int32_t kiL2 = kiL1 + kiStride; const int32_t kiL2 = kiL1 + kiStride;
const int32_t kiL3 = kiL2 + kiStride; const int32_t kiL3 = kiL2 + kiStride;
const int32_t kiL4 = kiL3 + kiStride; const int32_t kiL4 = kiL3 + kiStride;
const int32_t kiL5 = kiL4 + kiStride; const int32_t kiL5 = kiL4 + kiStride;
const int32_t kiL6 = kiL5 + kiStride; const int32_t kiL6 = kiL5 + kiStride;
const int32_t kiL7 = kiL6 + kiStride; const int32_t kiL7 = kiL6 + kiStride;
/*caculate the kMean value*/ /*caculate the kMean value*/
const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] +
pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ; pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ;
const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride]; const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride];
const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7]; const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7];
const uint8_t kuiM2 = (kuiSum2 + 2) >> 2; const uint8_t kuiM2 = (kuiSum2 + 2) >> 2;
const uint8_t kuiM3 = (kuiSum3 + 2) >> 2; const uint8_t kuiM3 = (kuiSum3 + 2) >> 2;
const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3; const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3;
const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2};
const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4}; const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4};
const uint64_t kuiUP64 = LD64 (kuiMUP); const uint64_t kuiUP64 = LD64 (kuiMUP);
const uint64_t kuiDN64 = LD64 (kuiMDown); const uint64_t kuiDN64 = LD64 (kuiMDown);
ST64A8 (pPred , kuiUP64); ST64A8 (pPred , kuiUP64);
ST64A8 (pPred + kiL1 + 1, kuiUP64); ST64A8 (pPred + kiL1 + 1, kuiUP64);
@@ -969,13 +968,13 @@ void WelsIChromaPredDc_c (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsIChromaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiL1 = -1 + kiStride; const int32_t kiL1 = -1 + kiStride;
const int32_t kiL2 = kiL1 + kiStride; const int32_t kiL2 = kiL1 + kiStride;
const int32_t kiL3 = kiL2 + kiStride; const int32_t kiL3 = kiL2 + kiStride;
const int32_t kiL4 = kiL3 + kiStride; const int32_t kiL4 = kiL3 + kiStride;
const int32_t kiL5 = kiL4 + kiStride; const int32_t kiL5 = kiL4 + kiStride;
const int32_t kiL6 = kiL5 + kiStride; const int32_t kiL6 = kiL5 + kiStride;
const int32_t kiL7 = kiL6 + kiStride; const int32_t kiL7 = kiL6 + kiStride;
/*caculate the kMean value*/ /*caculate the kMean value*/
const uint8_t kuiMUP = (pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 2) >> 2 ; const uint8_t kuiMUP = (pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 2) >> 2 ;
const uint8_t kuiMDown = (pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7] + 2) >> 2; const uint8_t kuiMDown = (pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7] + 2) >> 2;
@@ -993,12 +992,11 @@ void WelsIChromaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsIChromaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDcTop_c (uint8_t* pPred, const int32_t kiStride) {
int32_t iTmp = (kiStride << 3) - kiStride; int32_t iTmp = (kiStride << 3) - kiStride;
/*caculate the kMean value*/ /*caculate the kMean value*/
const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2; const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + 2) >> 2;
const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> const uint8_t kuiM2 = (pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride] + 2) >> 2;
2; const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2};
const uint8_t kuiM[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2};
uint8_t i = 7; uint8_t i = 7;
@@ -1022,13 +1020,13 @@ void WelsIChromaPredDcNA_c (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsI16x16LumaPredV_c (uint8_t* pPred, const int32_t kiStride) { void WelsI16x16LumaPredV_c (uint8_t* pPred, const int32_t kiStride) {
int32_t iTmp = (kiStride << 4) - kiStride; int32_t iTmp = (kiStride << 4) - kiStride;
const uint64_t kuiTop1 = LD64A8 (pPred - kiStride); const uint64_t kuiTop1 = LD64A8 (pPred - kiStride);
const uint64_t kuiTop2 = LD64A8 (pPred - kiStride + 8); const uint64_t kuiTop2 = LD64A8 (pPred - kiStride + 8);
uint8_t i = 15; uint8_t i = 15;
do { do {
ST64A8 (pPred + iTmp , kuiTop1); ST64A8 (pPred + iTmp , kuiTop1);
ST64A8 (pPred + iTmp + 8, kuiTop2); ST64A8 (pPred + iTmp + 8, kuiTop2);
iTmp -= kiStride; iTmp -= kiStride;
@@ -1040,10 +1038,10 @@ void WelsI16x16LumaPredH_c (uint8_t* pPred, const int32_t kiStride) {
uint8_t i = 15; uint8_t i = 15;
do { do {
const uint8_t kuiVal8 = pPred[iTmp - 1]; const uint8_t kuiVal8 = pPred[iTmp - 1];
const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8; const uint64_t kuiVal64 = 0x0101010101010101ULL * kuiVal8;
ST64A8 (pPred + iTmp , kuiVal64); ST64A8 (pPred + iTmp , kuiVal64);
ST64A8 (pPred + iTmp + 8, kuiVal64); ST64A8 (pPred + iTmp + 8, kuiVal64);
iTmp -= kiStride; iTmp -= kiStride;
@@ -1128,8 +1126,8 @@ void WelsI16x16LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride) {
iSum += pPred[-1 + iTmp]; iSum += pPred[-1 + iTmp];
iTmp -= kiStride; iTmp -= kiStride;
} while (i-- > 0); } while (i-- > 0);
uiMean = (8 + iSum) >> 4; uiMean = (8 + iSum) >> 4;
uiMean64 = 0x0101010101010101ULL * uiMean; uiMean64 = 0x0101010101010101ULL * uiMean;
iTmp = (kiStride << 4) - kiStride; iTmp = (kiStride << 4) - kiStride;
i = 15; i = 15;

View File

@@ -72,12 +72,12 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) {
++ uiIdx; ++ uiIdx;
} while (uiIdx < kuiSize); } while (uiIdx < kuiSize);
(*ppAu)->uiCountUnitsNum = kuiSize; (*ppAu)->uiCountUnitsNum = kuiSize;
(*ppAu)->uiAvailUnitsNum = 0; (*ppAu)->uiAvailUnitsNum = 0;
(*ppAu)->uiActualUnitsNum = 0; (*ppAu)->uiActualUnitsNum = 0;
(*ppAu)->uiStartPos = 0; (*ppAu)->uiStartPos = 0;
(*ppAu)->uiEndPos = 0; (*ppAu)->uiEndPos = 0;
(*ppAu)->bCompletedAuFlag = false; (*ppAu)->bCompletedAuFlag = false;
return 0; return 0;
} }
@@ -109,11 +109,11 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int
++ iIdx; ++ iIdx;
} while (iIdx < kiOrgSize); } while (iIdx < kiOrgSize);
pTmp->uiCountUnitsNum = kiExpSize; pTmp->uiCountUnitsNum = kiExpSize;
pTmp->uiAvailUnitsNum = (*ppAu)->uiAvailUnitsNum; pTmp->uiAvailUnitsNum = (*ppAu)->uiAvailUnitsNum;
pTmp->uiActualUnitsNum = (*ppAu)->uiActualUnitsNum; pTmp->uiActualUnitsNum = (*ppAu)->uiActualUnitsNum;
pTmp->uiEndPos = (*ppAu)->uiEndPos; pTmp->uiEndPos = (*ppAu)->uiEndPos;
pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag; pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag;
MemFreeNalList (ppAu); // free old list MemFreeNalList (ppAu); // free old list
*ppAu = pTmp; *ppAu = pTmp;

View File

@@ -196,15 +196,15 @@ void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) {
//basic iMVs prediction unit for iMVs partition width (4, 2, 1) //basic iMVs prediction unit for iMVs partition width (4, 2, 1)
void PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30], void PredMv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[LIST_A][30],
int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]) { int32_t iPartIdx, int32_t iPartWidth, int8_t iRef, int16_t iMVP[2]) {
const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1; const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1;
const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6; const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6;
const uint8_t kuiRightTopIdx = kuiTopIdx + iPartWidth; const uint8_t kuiRightTopIdx = kuiTopIdx + iPartWidth;
const uint8_t kuiLeftTopIdx = kuiTopIdx - 1; const uint8_t kuiLeftTopIdx = kuiTopIdx - 1;
const int8_t kiLeftRef = iRefIndex[0][kuiLeftIdx]; const int8_t kiLeftRef = iRefIndex[0][kuiLeftIdx];
const int8_t kiTopRef = iRefIndex[0][ kuiTopIdx]; const int8_t kiTopRef = iRefIndex[0][ kuiTopIdx];
const int8_t kiRightTopRef = iRefIndex[0][kuiRightTopIdx]; const int8_t kiRightTopRef = iRefIndex[0][kuiRightTopIdx];
const int8_t kiLeftTopRef = iRefIndex[0][ kuiLeftTopIdx]; const int8_t kiLeftTopRef = iRefIndex[0][ kuiLeftTopIdx];
int8_t iDiagonalRef = kiRightTopRef; int8_t iDiagonalRef = kiRightTopRef;
int8_t iMatchRef = 0; int8_t iMatchRef = 0;
@@ -286,8 +286,8 @@ void PredInter16x8Mv (int16_t iMotionVector[LIST_A][30][MV_A], int8_t iRefIndex[
//update iMVs and iRefIndex cache for current MB, only for P_16*16 (SKIP inclusive) //update iMVs and iRefIndex cache for current MB, only for P_16*16 (SKIP inclusive)
/* can be further optimized */ /* can be further optimized */
void UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]) { void UpdateP16x16MotionInfo (PDqLayer pCurDqLayer, int8_t iRef, int16_t iMVs[2]) {
const int16_t kiRef2 = (iRef << 8) | iRef; const int16_t kiRef2 = (iRef << 8) | iRef;
const int32_t kiMV32 = LD32 (iMVs); const int32_t kiMV32 = LD32 (iMVs);
int32_t i; int32_t i;
int32_t iMbXy = pCurDqLayer->iMbXyIndex; int32_t iMbXy = pCurDqLayer->iMbXyIndex;

View File

@@ -374,8 +374,8 @@ int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeigh
int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A], int8_t pRefIndex[LIST_A][30]) { int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A], int8_t pRefIndex[LIST_A][30]) {
PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PDqLayer pCurDqLayer = pCtx->pCurDqLayer; PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0];
int32_t pRefCount[2]; int32_t pRefCount[2];

View File

@@ -990,8 +990,8 @@ int32_t WelsResidualBlockCavlc8x8 (SVlcTable* pVlcTable, uint8_t* pNonZeroCountC
int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
PBitStringAux pBs) { PBitStringAux pBs) {
PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0]; PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0];
int32_t iRefCount[2]; int32_t iRefCount[2];
PDqLayer pCurDqLayer = pCtx->pCurDqLayer; PDqLayer pCurDqLayer = pCtx->pCurDqLayer;

View File

@@ -64,10 +64,10 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
int32_t iPicWidth = 0; int32_t iPicWidth = 0;
int32_t iPicHeight = 0; int32_t iPicHeight = 0;
int32_t iPicChromaWidth = 0; int32_t iPicChromaWidth = 0;
int32_t iPicChromaHeight = 0; int32_t iPicChromaHeight = 0;
int32_t iLumaSize = 0; int32_t iLumaSize = 0;
int32_t iChromaSize = 0; int32_t iChromaSize = 0;
pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture"); pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture");
WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
@@ -76,11 +76,11 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
iPicWidth = WELS_ALIGN (kiPicWidth + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT); iPicWidth = WELS_ALIGN (kiPicWidth + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT);
iPicHeight = WELS_ALIGN (kiPicHeight + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT); iPicHeight = WELS_ALIGN (kiPicHeight + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT);
iPicChromaWidth = iPicWidth >> 1; iPicChromaWidth = iPicWidth >> 1;
iPicChromaHeight = iPicHeight >> 1; iPicChromaHeight = iPicHeight >> 1;
iLumaSize = iPicWidth * iPicHeight; iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight; iChromaSize = iPicChromaWidth * iPicChromaHeight;
if (pCtx->bParseOnly) { if (pCtx->bParseOnly) {
pPic->pBuffer[0] = pPic->pBuffer[1] = pPic->pBuffer[2] = NULL; pPic->pBuffer[0] = pPic->pBuffer[1] = pPic->pBuffer[2] = NULL;
@@ -95,16 +95,16 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const
memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1))); memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1)));
pPic->iLinesize[0] = iPicWidth; pPic->iLinesize[0] = iPicWidth;
pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize; pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize;
pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize; pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize;
pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH; pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH;
pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1); pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1);
pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1); pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1);
} }
pPic->iPlanes = 3; // yv12 in default pPic->iPlanes = 3; // yv12 in default
pPic->iWidthInPixel = kiPicWidth; pPic->iWidthInPixel = kiPicWidth;
pPic->iHeightInPixel = kiPicHeight; pPic->iHeightInPixel = kiPicHeight;
pPic->iFrameNum = -1; pPic->iFrameNum = -1;
pPic->bAvailableFlag = true; pPic->bAvailableFlag = true;
return pPic; return pPic;

View File

@@ -63,9 +63,9 @@ extern const uint8_t g_kuiTemporalIdListTable[MAX_TEMPORAL_LEVEL][MAX_GOP_SIZE
* \return 2 based scaling factor * \return 2 based scaling factor
*/ */
static inline uint32_t GetLogFactor (float base, float upper) { static inline uint32_t GetLogFactor (float base, float upper) {
const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0); const double dLog2factor = log10 (1.0 * upper / base) / log10 (2.0);
const double dEpsilon = 0.0001; const double dEpsilon = 0.0001;
const double dRound = floor (dLog2factor + 0.5); const double dRound = floor (dLog2factor + 0.5);
if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) { if (dLog2factor < dRound + dEpsilon && dRound < dLog2factor + dEpsilon) {
return (uint32_t) (dRound); return (uint32_t) (dRound);
@@ -125,46 +125,46 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
static void FillDefault (SEncParamExt& param) { static void FillDefault (SEncParamExt& param) {
memset (&param, 0, sizeof (param)); memset (&param, 0, sizeof (param));
param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired) param.uiIntraPeriod = 0; // intra period (multiple of GOP size as desired)
param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used param.iNumRefFrame = AUTO_REF_PIC_COUNT;// number of reference frame used
param.iPicWidth = 0; // actual input picture width param.iPicWidth = 0; // actual input picture width
param.iPicHeight = 0; // actual input picture height param.iPicHeight = 0; // actual input picture height
param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps] param.fMaxFrameRate = MAX_FRAME_RATE; // maximal frame rate [Hz / fps]
param.iComplexityMode = MEDIUM_COMPLEXITY; param.iComplexityMode = MEDIUM_COMPLEXITY;
param.iTargetBitrate = UNSPECIFIED_BIT_RATE; // overall target bitrate introduced in RC module param.iTargetBitrate = UNSPECIFIED_BIT_RATE; // overall target bitrate introduced in RC module
param.iMaxBitrate = UNSPECIFIED_BIT_RATE; param.iMaxBitrate = UNSPECIFIED_BIT_RATE;
param.iMultipleThreadIdc = 1; param.iMultipleThreadIdc = 1;
param.iLTRRefNum = 0; param.iLTRRefNum = 0;
param.iLtrMarkPeriod = 30; //the min distance of two int32_t references param.iLtrMarkPeriod = 30; //the min distance of two int32_t references
param.bEnableSSEI = false; param.bEnableSSEI = false;
param.bSimulcastAVC = false; param.bSimulcastAVC = false;
param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application param.bEnableFrameCroppingFlag = true; // enable frame cropping flag: true alwayse in application
// false: Streaming Video Sharing; true: Video Conferencing Meeting; // false: Streaming Video Sharing; true: Video Conferencing Meeting;
/* Deblocking loop filter */ /* Deblocking loop filter */
param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries param.iLoopFilterDisableIdc = 0; // 0: on, 1: off, 2: on except for slice boundaries
param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0 param.iLoopFilterAlphaC0Offset = 0; // AlphaOffset: valid range [-6, 6], default 0
param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0 param.iLoopFilterBetaOffset = 0; // BetaOffset: valid range [-6, 6], default 0
/* Rate Control */ /* Rate Control */
param.iRCMode = RC_QUALITY_MODE; param.iRCMode = RC_QUALITY_MODE;
param.iPaddingFlag = 0; param.iPaddingFlag = 0;
param.iEntropyCodingModeFlag = 0; param.iEntropyCodingModeFlag = 0;
param.bEnableDenoise = false; // denoise control param.bEnableDenoise = false; // denoise control
param.bEnableSceneChangeDetect = true; // scene change detection control param.bEnableSceneChangeDetect = true; // scene change detection control
param.bEnableBackgroundDetection = true; // background detection control param.bEnableBackgroundDetection = true; // background detection control
param.bEnableAdaptiveQuant = true; // adaptive quantization control param.bEnableAdaptiveQuant = true; // adaptive quantization control
param.bEnableFrameSkip = true; // frame skipping param.bEnableFrameSkip = true; // frame skipping
param.bEnableLongTermReference = false; // long term reference control param.bEnableLongTermReference = false; // long term reference control
param.eSpsPpsIdStrategy = INCREASING_ID; // pSps pPps id addition control param.eSpsPpsIdStrategy = INCREASING_ID;// pSps pPps id addition control
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
param.iTemporalLayerNum = 1; // number of temporal layer specified param.iTemporalLayerNum = 1; // number of temporal layer specified
param.iMaxQp = 51; param.iMaxQp = 51;
param.iMinQp = 0; param.iMinQp = 0;
@@ -188,28 +188,28 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
void FillDefault() { void FillDefault() {
FillDefault (*this); FillDefault (*this);
uiGopSize = 1; // GOP size (at maximal frame rate: 16) uiGopSize = 1; // GOP size (at maximal frame rate: 16)
iMaxNumRefFrame = AUTO_REF_PIC_COUNT; iMaxNumRefFrame = AUTO_REF_PIC_COUNT;
SUsedPicRect.iLeft = SUsedPicRect.iLeft =
SUsedPicRect.iTop = SUsedPicRect.iTop =
SUsedPicRect.iWidth = SUsedPicRect.iWidth =
SUsedPicRect.iHeight = 0; // the rect in input picture that encoder actually used 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/ pCurPath = NULL; // record current lib path such as:/pData/pData/com.wels.enc/lib/
bDeblockingParallelFlag = false; // deblocking filter parallelization control flag bDeblockingParallelFlag = false;// deblocking filter parallelization control flag
iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means; iCountThreadsNum = 1; // # derived from disable_multiple_slice_idc (=0 or >1) means;
iDecompStages = 0; // GOP size dependency, unknown here and be revised later iDecompStages = 0; // GOP size dependency, unknown here and be revised later
iBitsVaryPercentage = 0; iBitsVaryPercentage = 0;
} }
int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) { int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE); fMaxFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, MIN_FRAME_RATE, MAX_FRAME_RATE);
iTargetBitrate = pCodingParam.iTargetBitrate; iTargetBitrate = pCodingParam.iTargetBitrate;
iUsageType = pCodingParam.iUsageType; iUsageType = pCodingParam.iUsageType;
iPicWidth = pCodingParam.iPicWidth; iPicWidth = pCodingParam.iPicWidth;
iPicHeight = pCodingParam.iPicHeight; iPicHeight = pCodingParam.iPicHeight;
@@ -220,34 +220,34 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
iRCMode = pCodingParam.iRCMode; // rc mode iRCMode = pCodingParam.iRCMode; // rc mode
int8_t iIdxSpatial = 0; int8_t iIdxSpatial = 0;
EProfileIdc uiProfileIdc = PRO_BASELINE; EProfileIdc uiProfileIdc = PRO_BASELINE;
if (iEntropyCodingModeFlag) if (iEntropyCodingModeFlag)
uiProfileIdc = PRO_MAIN; uiProfileIdc = PRO_MAIN;
SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
while (iIdxSpatial < iSpatialLayerNum) { while (iIdxSpatial < iSpatialLayerNum) {
sSpatialLayers->uiProfileIdc = uiProfileIdc; sSpatialLayers->uiProfileIdc = uiProfileIdc;
sSpatialLayers->uiLevelIdc = LEVEL_UNKNOWN; sSpatialLayers->uiLevelIdc = LEVEL_UNKNOWN;
sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate, sSpatialLayers[iIdxSpatial].fFrameRate = WELS_CLIP3 (pCodingParam.fMaxFrameRate,
MIN_FRAME_RATE, MAX_FRAME_RATE); MIN_FRAME_RATE, MAX_FRAME_RATE);
pDlp->fInputFrameRate = pDlp->fInputFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE, pDlp->fOutputFrameRate = WELS_CLIP3 (sSpatialLayers[iIdxSpatial].fFrameRate, MIN_FRAME_RATE,
MAX_FRAME_RATE); MAX_FRAME_RATE);
#ifdef ENABLE_FRAME_DUMP #ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP #endif//ENABLE_FRAME_DUMP
pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth; pDlp->iActualWidth = sSpatialLayers[iIdxSpatial].iVideoWidth = iPicWidth;
pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight; pDlp->iActualHeight = sSpatialLayers[iIdxSpatial].iVideoHeight = iPicHeight;
sSpatialLayers->iSpatialBitrate = sSpatialLayers->iSpatialBitrate =
sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer sSpatialLayers[iIdxSpatial].iSpatialBitrate = pCodingParam.iTargetBitrate; // target bitrate for current spatial layer
sSpatialLayers->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE; sSpatialLayers->iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP; sSpatialLayers->iDLayerQp = SVC_QUALITY_BASE_QP;
uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE; uiProfileIdc = (!bSimulcastAVC) ? PRO_SCALABLE_BASELINE : PRO_BASELINE;
++ pDlp; ++ pDlp;
++ iIdxSpatial; ++ iIdxSpatial;
} }
@@ -280,18 +280,18 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc; iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc;
/* Deblocking loop filter */ /* Deblocking loop filter */
iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries, iLoopFilterDisableIdc = pCodingParam.iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries,
iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0 iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset; // AlphaOffset: valid range [-6, 6], default 0
iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0
iEntropyCodingModeFlag = pCodingParam.iEntropyCodingModeFlag; iEntropyCodingModeFlag = pCodingParam.iEntropyCodingModeFlag;
bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag; bEnableFrameCroppingFlag = pCodingParam.bEnableFrameCroppingFlag;
/* Rate Control */ /* Rate Control */
iRCMode = pCodingParam.iRCMode; // rc mode iRCMode = pCodingParam.iRCMode; // rc mode
bSimulcastAVC = pCodingParam.bSimulcastAVC; bSimulcastAVC = pCodingParam.bSimulcastAVC;
iPaddingFlag = pCodingParam.iPaddingFlag; iPaddingFlag = pCodingParam.iPaddingFlag;
iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate iTargetBitrate = pCodingParam.iTargetBitrate; // target bitrate
iMaxBitrate = pCodingParam.iMaxBitrate; iMaxBitrate = pCodingParam.iMaxBitrate;
if (iMaxBitrate < iTargetBitrate) { if (iMaxBitrate < iTargetBitrate) {
iMaxBitrate = iTargetBitrate; iMaxBitrate = iTargetBitrate;
@@ -302,19 +302,19 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now bEnableDenoise = pCodingParam.bEnableDenoise ? true : false; // Denoise Control // only support 0 or 1 now
/* Scene change detection control */ /* Scene change detection control */
bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect; bEnableSceneChangeDetect = pCodingParam.bEnableSceneChangeDetect;
/* Background detection Control */ /* Background detection Control */
bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false; bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false;
/* Adaptive quantization control */ /* Adaptive quantization control */
bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false; bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false;
/* Frame skipping */ /* Frame skipping */
bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false; bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false;
/* Enable int32_t term reference */ /* Enable int32_t term reference */
bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false; bEnableLongTermReference = pCodingParam.bEnableLongTermReference ? true : false;
iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod; iLtrMarkPeriod = pCodingParam.iLtrMarkPeriod;
bIsLosslessLink = pCodingParam.bIsLosslessLink; bIsLosslessLink = pCodingParam.bIsLosslessLink;
if (iUsageType == SCREEN_CONTENT_REAL_TIME && !bIsLosslessLink && bEnableLongTermReference) { if (iUsageType == SCREEN_CONTENT_REAL_TIME && !bIsLosslessLink && bEnableLongTermReference) {
@@ -322,8 +322,8 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
} }
/* For ssei information */ /* For ssei information */
bEnableSSEI = pCodingParam.bEnableSSEI; bEnableSSEI = pCodingParam.bEnableSSEI;
bSimulcastAVC = pCodingParam.bSimulcastAVC; bSimulcastAVC = pCodingParam.bSimulcastAVC;
/* Layer definition */ /* Layer definition */
iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1, iSpatialLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
@@ -331,9 +331,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1, iTemporalLayerNum = (int8_t)WELS_CLIP3 (pCodingParam.iTemporalLayerNum, 1,
MAX_TEMPORAL_LEVEL); // number of temporal layer specified MAX_TEMPORAL_LEVEL); // number of temporal layer specified
uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer uiGopSize = 1 << (iTemporalLayerNum - 1); // Override GOP size based temporal layer
iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency iDecompStages = iTemporalLayerNum - 1; // WELS_LOG2( uiGopSize );// GOP size dependency
uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired) uiIntraPeriod = pCodingParam.uiIntraPeriod;// intra period (multiple of GOP size as desired)
if (uiIntraPeriod == (uint32_t) (-1)) if (uiIntraPeriod == (uint32_t) (-1))
uiIntraPeriod = 0; uiIntraPeriod = 0;
else if (uiIntraPeriod & (uiGopSize - 1)) // none multiple of GOP size else if (uiIntraPeriod & (uiGopSize - 1)) // none multiple of GOP size
@@ -364,32 +364,32 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
// keep the default value // keep the default value
} }
SSpatialLayerInternal* pDlp = &sDependencyLayers[0]; SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0]; SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
EProfileIdc uiProfileIdc = PRO_BASELINE; EProfileIdc uiProfileIdc = PRO_BASELINE;
int8_t iIdxSpatial = 0; int8_t iIdxSpatial = 0;
while (iIdxSpatial < iSpatialLayerNum) { while (iIdxSpatial < iSpatialLayerNum) {
pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc : pSpatialLayer->uiProfileIdc = (pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc == PRO_UNKNOWN) ? uiProfileIdc :
pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc; pCodingParam.sSpatialLayers[iIdxSpatial].uiProfileIdc;
pSpatialLayer->uiLevelIdc = pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc; pSpatialLayer->uiLevelIdc = pCodingParam.sSpatialLayers[iIdxSpatial].uiLevelIdc;
float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate, float fLayerFrameRate = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].fFrameRate,
MIN_FRAME_RATE, fParamMaxFrameRate); MIN_FRAME_RATE, fParamMaxFrameRate);
pDlp->fInputFrameRate = fParamMaxFrameRate; pDlp->fInputFrameRate = fParamMaxFrameRate;
pSpatialLayer->fFrameRate = pSpatialLayer->fFrameRate =
pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, fParamMaxFrameRate); pDlp->fOutputFrameRate = WELS_CLIP3 (fLayerFrameRate, MIN_FRAME_RATE, fParamMaxFrameRate);
#ifdef ENABLE_FRAME_DUMP #ifdef ENABLE_FRAME_DUMP
pDlp->sRecFileName[0] = '\0'; // file to be constructed pDlp->sRecFileName[0] = '\0'; // file to be constructed
#endif//ENABLE_FRAME_DUMP #endif//ENABLE_FRAME_DUMP
pSpatialLayer->iVideoWidth = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth, 0, pSpatialLayer->iVideoWidth = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].iVideoWidth, 0,
iPicWidth); // frame width iPicWidth); // frame width
pSpatialLayer->iVideoHeight = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight, 0, pSpatialLayer->iVideoHeight = WELS_CLIP3 (pCodingParam.sSpatialLayers[iIdxSpatial].iVideoHeight, 0,
iPicHeight);// frame height iPicHeight);// frame height
pSpatialLayer->iSpatialBitrate = pSpatialLayer->iSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer pCodingParam.sSpatialLayers[iIdxSpatial].iSpatialBitrate; // target bitrate for current spatial layer
pSpatialLayer->iMaxSpatialBitrate = pSpatialLayer->iMaxSpatialBitrate =
pCodingParam.sSpatialLayers[iIdxSpatial].iMaxSpatialBitrate; pCodingParam.sSpatialLayers[iIdxSpatial].iMaxSpatialBitrate;
//multi slice //multi slice
@@ -437,17 +437,16 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
* \return NONE (should ensure valid parameter before this procedure) * \return NONE (should ensure valid parameter before this procedure)
*/ */
int32_t DetermineTemporalSettings() { int32_t DetermineTemporalSettings() {
const int32_t iDecStages = WELS_LOG2 ( const int32_t iDecStages = WELS_LOG2 (uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize)
uiGopSize); // (int8_t)GetLogFactor(1.0f, 1.0f * pcfg->uiGopSize); //log2(uiGopSize) const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0];
const uint8_t* pTemporalIdList = &g_kuiTemporalIdListTable[iDecStages][0]; SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0]; SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];
EProfileIdc uiProfileIdc = iEntropyCodingModeFlag ? PRO_MAIN : PRO_BASELINE; EProfileIdc uiProfileIdc = iEntropyCodingModeFlag ? PRO_MAIN : PRO_BASELINE;
int8_t i = 0; int8_t i = 0;
while (i < iSpatialLayerNum) { while (i < iSpatialLayerNum) {
const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate); const uint32_t kuiLogFactorInOutRate = GetLogFactor (pDlp->fOutputFrameRate, pDlp->fInputFrameRate);
const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate); const uint32_t kuiLogFactorMaxInRate = GetLogFactor (pDlp->fInputFrameRate, fMaxFrameRate);
if (UINT_MAX == kuiLogFactorInOutRate || UINT_MAX == kuiLogFactorMaxInRate) { if (UINT_MAX == kuiLogFactorInOutRate || UINT_MAX == kuiLogFactorMaxInRate) {
return ENC_RETURN_INVALIDINPUT; return ENC_RETURN_INVALIDINPUT;
} }
@@ -468,9 +467,9 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
} }
} }
pDlp->iHighestTemporalId = iMaxTemporalId; pDlp->iHighestTemporalId = iMaxTemporalId;
pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate; pDlp->iTemporalResolution = kuiLogFactorMaxInRate + kuiLogFactorInOutRate;
pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate; pDlp->iDecompositionStages = iDecStages - kuiLogFactorMaxInRate - kuiLogFactorInOutRate;
if (pDlp->iDecompositionStages < 0) { if (pDlp->iDecompositionStages < 0) {
return ENC_RETURN_INVALIDINPUT; return ENC_RETURN_INVALIDINPUT;
} }

View File

@@ -104,18 +104,18 @@ SScreenBlockFeatureStorage* pScreenBlockFeatureStorage;
* set picture as unreferenced * set picture as unreferenced
*/ */
void SetUnref () { void SetUnref () {
iFramePoc = -1; iFramePoc = -1;
iFrameNum = -1; iFrameNum = -1;
uiTemporalId = uiTemporalId =
uiSpatialId = uiSpatialId =
iLongTermPicNum = -1; iLongTermPicNum = -1;
bIsLongRef = false; bIsLongRef = false;
uiRecieveConfirmed = RECIEVE_FAILED; uiRecieveConfirmed = RECIEVE_FAILED;
iMarkFrameNum = -1; iMarkFrameNum = -1;
bUsedAsRef = false; bUsedAsRef = false;
if (NULL != pScreenBlockFeatureStorage) if (NULL != pScreenBlockFeatureStorage)
pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false; pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false;
} }
} SPicture; } SPicture;

View File

@@ -57,8 +57,8 @@ extern const ALIGNED_DECLARE (uint8_t, g_kuiEncNcMapTable[18], 16);
static inline int32_t WriteTotalCoeffTrailingones (SBitStringAux* pBs, uint8_t uiNc, uint8_t uiTotalCoeff, static inline int32_t WriteTotalCoeffTrailingones (SBitStringAux* pBs, uint8_t uiNc, uint8_t uiTotalCoeff,
uint8_t uiTrailingOnes) { uint8_t uiTrailingOnes) {
const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc]; const uint8_t kuiNcIdx = g_kuiEncNcMapTable[uiNc];
const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0]; const uint8_t* kpCoeffToken = &g_kuiVlcCoeffToken[kuiNcIdx][uiTotalCoeff][uiTrailingOnes][0];
return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]); return BsWriteBits (pBs, kpCoeffToken[1], kpCoeffToken[0]);
} }

View File

@@ -468,9 +468,9 @@ int32_t WelsInitSps (SWelsSPS* pSps, SSpatialLayerConfig* pLayerParam, SSpatialL
const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc, const uint32_t kuiSpsId, const bool kbEnableFrameCropping, bool bEnableRc,
const int32_t kiDlayerCount, bool bSVCBaselayer) { const int32_t kiDlayerCount, bool bSVCBaselayer) {
memset (pSps, 0, sizeof (SWelsSPS)); memset (pSps, 0, sizeof (SWelsSPS));
pSps->uiSpsId = kuiSpsId; pSps->uiSpsId = kuiSpsId;
pSps->iMbWidth = (pLayerParam->iVideoWidth + 15) >> 4; pSps->iMbWidth = (pLayerParam->iVideoWidth + 15) >> 4;
pSps->iMbHeight = (pLayerParam->iVideoHeight + 15) >> 4; pSps->iMbHeight = (pLayerParam->iVideoHeight + 15) >> 4;
//max value of both iFrameNum and POC are 2^16-1, in our encoder, iPOC=2*iFrameNum, so max of iFrameNum should be 2^15-1.-- //max value of both iFrameNum and POC are 2^16-1, in our encoder, iPOC=2*iFrameNum, so max of iFrameNum should be 2^15-1.--
pSps->uiLog2MaxFrameNum = 15;//16; pSps->uiLog2MaxFrameNum = 15;//16;
@@ -536,9 +536,9 @@ int32_t WelsInitSubsetSps (SSubsetSps* pSubsetSps, SSpatialLayerConfig* pLayerPa
pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc : pSps->uiProfileIdc = (pLayerParam->uiProfileIdc >= PRO_SCALABLE_BASELINE) ? pLayerParam->uiProfileIdc :
PRO_SCALABLE_BASELINE; PRO_SCALABLE_BASELINE;
pSubsetSps->sSpsSvcExt.iExtendedSpatialScalability = 0; /* ESS is 0 in default */ pSubsetSps->sSpsSvcExt.iExtendedSpatialScalability = 0; /* ESS is 0 in default */
pSubsetSps->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag = false; pSubsetSps->sSpsSvcExt.bAdaptiveTcoeffLevelPredFlag = false;
pSubsetSps->sSpsSvcExt.bSeqTcoeffLevelPredFlag = false; pSubsetSps->sSpsSvcExt.bSeqTcoeffLevelPredFlag = false;
pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag = true; pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag = true;
return 0; return 0;
@@ -594,11 +594,11 @@ int32_t WelsInitPps (SWelsPPS* pPps,
} }
#endif//!DISABLE_FMO_FEATURE #endif//!DISABLE_FMO_FEATURE
pPps->iPicInitQp = 26; pPps->iPicInitQp = 26;
pPps->iPicInitQs = 26; pPps->iPicInitQs = 26;
pPps->uiChromaQpIndexOffset = 0; pPps->uiChromaQpIndexOffset = 0;
pPps->bDeblockingFilterControlPresentFlag = kbDeblockingFilterPresentFlag; pPps->bDeblockingFilterControlPresentFlag = kbDeblockingFilterPresentFlag;
return 0; return 0;
} }

View File

@@ -655,9 +655,9 @@ void DeblockingMbAvcbase (SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilte
void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) { void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) {
int32_t i, j; int32_t i, j;
const int32_t kiMbWidth = pCurDq->iMbWidth; const int32_t kiMbWidth = pCurDq->iMbWidth;
const int32_t kiMbHeight = pCurDq->iMbHeight; const int32_t kiMbHeight = pCurDq->iMbHeight;
SMB* pCurrentMbBlock = pCurDq->sMbDataP; SMB* pCurrentMbBlock = pCurDq->sMbDataP;
SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[0].sSliceHeaderExt; SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[0].sSliceHeaderExt;
SDeblockingFilter pFilter; SDeblockingFilter pFilter;
@@ -691,14 +691,14 @@ void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) {
} }
void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx) { void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx) {
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
SMB* pMbList = pCurDq->sMbDataP; SMB* pMbList = pCurDq->sMbDataP;
SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt; SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt;
SMB* pCurrentMbBlock; SMB* pCurrentMbBlock;
const int32_t kiMbWidth = pCurDq->iMbWidth; const int32_t kiMbWidth = pCurDq->iMbWidth;
const int32_t kiMbHeight = pCurDq->iMbHeight; const int32_t kiMbHeight = pCurDq->iMbHeight;
const int32_t kiTotalNumMb = kiMbWidth * kiMbHeight; const int32_t kiTotalNumMb = kiMbWidth * kiMbHeight;
int32_t iCurMbIdx = 0, iNextMbIdx = 0, iNumMbFiltered = 0; int32_t iCurMbIdx = 0, iNextMbIdx = 0, iNumMbFiltered = 0;
/* Step1: parameters set */ /* Step1: parameters set */
@@ -712,13 +712,13 @@ void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, co
pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1]; pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1];
pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2]; pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2];
pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset;
pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset;
pFilter.iMbStride = kiMbWidth; pFilter.iMbStride = kiMbWidth;
iNextMbIdx = sSliceHeaderExt->sSliceHeader.iFirstMbInSlice; iNextMbIdx = sSliceHeaderExt->sSliceHeader.iFirstMbInSlice;
for (; ;) { for (; ;) {
iCurMbIdx = iNextMbIdx; iCurMbIdx = iNextMbIdx;
pCurrentMbBlock = &pMbList[ iCurMbIdx ]; pCurrentMbBlock = &pMbList[ iCurMbIdx ];
pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0]) pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0])
@@ -740,30 +740,30 @@ void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, co
} }
void PerformDeblockingFilter (sWelsEncCtx* pEnc) { void PerformDeblockingFilter (sWelsEncCtx* pEnc) {
const int32_t kiCurDid = pEnc->uiDependencyId; const int32_t kiCurDid = pEnc->uiDependencyId;
SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam; SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam;
SSpatialLayerConfig* pSpatialLayer = &pSvcParam->sSpatialLayers[kiCurDid]; SSpatialLayerConfig* pSpatialLayer = &pSvcParam->sSpatialLayers[kiCurDid];
SDqLayer* pCurLayer = pEnc->pCurDqLayer; SDqLayer* pCurLayer = pEnc->pCurDqLayer;
if (pCurLayer->iLoopFilterDisableIdc == 0) { if (pCurLayer->iLoopFilterDisableIdc == 0) {
DeblockingFilterFrameAvcbase (pCurLayer, pEnc->pFuncList); DeblockingFilterFrameAvcbase (pCurLayer, pEnc->pFuncList);
} else if (pCurLayer->iLoopFilterDisableIdc == 2) { } else if (pCurLayer->iLoopFilterDisableIdc == 2) {
int32_t iSliceCount = 0; int32_t iSliceCount = 0;
int32_t iSliceIdx = 0; int32_t iSliceIdx = 0;
if (SM_DYN_SLICE != pSpatialLayer->sSliceCfg.uiSliceMode) { if (SM_DYN_SLICE != pSpatialLayer->sSliceCfg.uiSliceMode) {
iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx); iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx);
do { do {
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx); DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx);
++ iSliceIdx; ++ iSliceIdx;
} while (iSliceIdx < iSliceCount); } while (iSliceIdx < iSliceCount);
} else { // for dynamic slicing mode } else { // for dynamic slicing mode
const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
int32_t iPartitionIdx = 0; int32_t iPartitionIdx = 0;
while (iPartitionIdx < kiNumPicPartition) { while (iPartitionIdx < kiNumPicPartition) {
iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx]; iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx];
iSliceIdx = iPartitionIdx; iSliceIdx = iPartitionIdx;
do { do {
DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx); DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx);
iSliceIdx += kiNumPicPartition; iSliceIdx += kiNumPicPartition;

View File

@@ -42,10 +42,10 @@ void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4
int32_t i = 4; int32_t i = 4;
while (--i >= 0) { while (--i >= 0) {
const int32_t kiIdx = i << 2; const int32_t kiIdx = i << 2;
const int32_t kiIdx1 = 1 + kiIdx; const int32_t kiIdx1 = 1 + kiIdx;
const int32_t kiIdx2 = 1 + kiIdx1; const int32_t kiIdx2 = 1 + kiIdx1;
const int32_t kiIdx3 = 1 + kiIdx2; const int32_t kiIdx3 = 1 + kiIdx2;
iTemp[0] = pRes[kiIdx ] + pRes[kiIdx2]; iTemp[0] = pRes[kiIdx ] + pRes[kiIdx2];
iTemp[1] = pRes[kiIdx ] - pRes[kiIdx2]; iTemp[1] = pRes[kiIdx ] - pRes[kiIdx2];
@@ -60,9 +60,9 @@ void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4
i = 4; i = 4;
while (--i >= 0) { while (--i >= 0) {
const int32_t kiI4 = 4 + i; const int32_t kiI4 = 4 + i;
const int32_t kiI8 = 4 + kiI4; const int32_t kiI8 = 4 + kiI4;
const int32_t kiI12 = 4 + kiI8; const int32_t kiI12 = 4 + kiI8;
iTemp[0] = pRes[i ] + pRes[kiI8 ]; iTemp[0] = pRes[i ] + pRes[kiI8 ];
iTemp[1] = pRes[i ] - pRes[kiI8 ]; iTemp[1] = pRes[i ] - pRes[kiI8 ];
@@ -78,14 +78,14 @@ void WelsIHadamard4x4Dc (int16_t* pRes) { //pBuffer size : 4x4
/* for qp < 12 */ /* for qp < 12 */
void WelsDequantLumaDc4x4 (int16_t* pRes, const int32_t kiQp) { void WelsDequantLumaDc4x4 (int16_t* pRes, const int32_t kiQp) {
int32_t i = 15; int32_t i = 15;
const uint16_t kuiDequantValue = g_kuiDequantCoeff[kiQp % 6][0]; const uint16_t kuiDequantValue = g_kuiDequantCoeff[kiQp % 6][0];
const int16_t kiQF0 = kiQp / 6; const int16_t kiQF0 = kiQp / 6;
const int16_t kiQF1 = 2 - kiQF0; const int16_t kiQF1 = 2 - kiQF0;
const int16_t kiQF0S = 1 << (1 - kiQF0); const int16_t kiQF0S = 1 << (1 - kiQF0);
while (i >= 0) { while (i >= 0) {
pRes[i ] = (pRes[i ] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i ] = (pRes[i ] * kuiDequantValue + kiQF0S) >> kiQF1;
pRes[i - 1] = (pRes[i - 1] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i - 1] = (pRes[i - 1] * kuiDequantValue + kiQF0S) >> kiQF1;
pRes[i - 2] = (pRes[i - 2] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i - 2] = (pRes[i - 2] * kuiDequantValue + kiQF0S) >> kiQF1;
pRes[i - 3] = (pRes[i - 3] * kuiDequantValue + kiQF0S) >> kiQF1; pRes[i - 3] = (pRes[i - 3] * kuiDequantValue + kiQF0S) >> kiQF1;
@@ -100,24 +100,24 @@ void WelsDequantIHadamard4x4_c (int16_t* pRes, const uint16_t kuiMF) {
int32_t i; int32_t i;
for (i = 0; i < 16; i += 4) { for (i = 0; i < 16; i += 4) {
iTemp[0] = pRes[i ] + pRes[i + 2]; iTemp[0] = pRes[i ] + pRes[i + 2];
iTemp[1] = pRes[i ] - pRes[i + 2]; iTemp[1] = pRes[i ] - pRes[i + 2];
iTemp[2] = pRes[i + 1] - pRes[i + 3]; iTemp[2] = pRes[i + 1] - pRes[i + 3];
iTemp[3] = pRes[i + 1] + pRes[i + 3]; iTemp[3] = pRes[i + 1] + pRes[i + 3];
pRes[i ] = iTemp[0] + iTemp[3]; pRes[i ] = iTemp[0] + iTemp[3];
pRes[i + 1] = iTemp[1] + iTemp[2]; pRes[i + 1] = iTemp[1] + iTemp[2];
pRes[i + 2] = iTemp[1] - iTemp[2]; pRes[i + 2] = iTemp[1] - iTemp[2];
pRes[i + 3] = iTemp[0] - iTemp[3]; pRes[i + 3] = iTemp[0] - iTemp[3];
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
iTemp[0] = pRes[i ] + pRes[i + 8 ]; iTemp[0] = pRes[i ] + pRes[i + 8 ];
iTemp[1] = pRes[i ] - pRes[i + 8 ]; iTemp[1] = pRes[i ] - pRes[i + 8 ];
iTemp[2] = pRes[i + 4 ] - pRes[i + 12]; iTemp[2] = pRes[i + 4 ] - pRes[i + 12];
iTemp[3] = pRes[i + 4 ] + pRes[i + 12]; iTemp[3] = pRes[i + 4 ] + pRes[i + 12];
pRes[i ] = (iTemp[0] + iTemp[3]) * kuiMF; pRes[i ] = (iTemp[0] + iTemp[3]) * kuiMF;
pRes[i + 4 ] = (iTemp[1] + iTemp[2]) * kuiMF; pRes[i + 4 ] = (iTemp[1] + iTemp[2]) * kuiMF;
pRes[i + 8 ] = (iTemp[1] - iTemp[2]) * kuiMF; pRes[i + 8 ] = (iTemp[1] - iTemp[2]) * kuiMF;
pRes[i + 12] = (iTemp[0] - iTemp[3]) * kuiMF; pRes[i + 12] = (iTemp[0] - iTemp[3]) * kuiMF;
@@ -126,9 +126,9 @@ void WelsDequantIHadamard4x4_c (int16_t* pRes, const uint16_t kuiMF) {
void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF) { void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF) {
const int16_t kiSumU = pDct[0] + pDct[2]; const int16_t kiSumU = pDct[0] + pDct[2];
const int16_t kiDelU = pDct[0] - pDct[2]; const int16_t kiDelU = pDct[0] - pDct[2];
const int16_t kiSumD = pDct[1] + pDct[3]; const int16_t kiSumD = pDct[1] + pDct[3];
const int16_t kiDelD = pDct[1] - pDct[3]; const int16_t kiDelD = pDct[1] - pDct[3];
pDct[0] = ((kiSumU + kiSumD) * kuiMF) >> 1; pDct[0] = ((kiSumU + kiSumD) * kuiMF) >> 1;
pDct[1] = ((kiSumU - kiSumD) * kuiMF) >> 1; pDct[1] = ((kiSumU - kiSumD) * kuiMF) >> 1;
@@ -139,22 +139,22 @@ void WelsDequantIHadamard2x2Dc (int16_t* pDct, const uint16_t kuiMF) {
void WelsDequant4x4_c (int16_t* pRes, const uint16_t* kpMF) { void WelsDequant4x4_c (int16_t* pRes, const uint16_t* kpMF) {
int32_t i; int32_t i;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
pRes[i] *= kpMF[i]; pRes[i] *= kpMF[i];
pRes[i + 8] *= kpMF[i]; pRes[i + 8] *= kpMF[i];
} }
} }
void WelsDequantFour4x4_c (int16_t* pRes, const uint16_t* kpMF) { void WelsDequantFour4x4_c (int16_t* pRes, const uint16_t* kpMF) {
int32_t i; int32_t i;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
pRes[i] *= kpMF[i]; pRes[i] *= kpMF[i];
pRes[i + 8] *= kpMF[i]; pRes[i + 8] *= kpMF[i];
pRes[i + 16] *= kpMF[i]; pRes[i + 16] *= kpMF[i];
pRes[i + 24] *= kpMF[i]; pRes[i + 24] *= kpMF[i];
pRes[i + 32] *= kpMF[i]; pRes[i + 32] *= kpMF[i];
pRes[i + 40] *= kpMF[i]; pRes[i + 40] *= kpMF[i];
pRes[i + 48] *= kpMF[i]; pRes[i + 48] *= kpMF[i];
pRes[i + 56] *= kpMF[i]; pRes[i + 56] *= kpMF[i];
} }
} }
@@ -238,13 +238,13 @@ void WelsGetEncBlockStrideOffset (int32_t* pBlock, const int32_t kiStrideY, cons
i = j << 2; i = j << 2;
k = (j & 0x01) << 1; k = (j & 0x01) << 1;
r = j & 0x02; r = j & 0x02;
pBlock[i] = (0 + k + (0 + r) * kiStrideY) << 2; pBlock[i] = (0 + k + (0 + r) * kiStrideY) << 2;
pBlock[i + 1] = (1 + k + (0 + r) * kiStrideY) << 2; pBlock[i + 1] = (1 + k + (0 + r) * kiStrideY) << 2;
pBlock[i + 2] = (0 + k + (1 + r) * kiStrideY) << 2; pBlock[i + 2] = (0 + k + (1 + r) * kiStrideY) << 2;
pBlock[i + 3] = (1 + k + (1 + r) * kiStrideY) << 2; pBlock[i + 3] = (1 + k + (1 + r) * kiStrideY) << 2;
pBlock[16 + j] = pBlock[16 + j] =
pBlock[20 + j] = ((j & 0x01) + r * kiStrideUV) << 2; pBlock[20 + j] = ((j & 0x01) + r * kiStrideUV) << 2;
} }
} }

View File

@@ -283,24 +283,24 @@ void WelsHadamardT4Dc_c (int16_t* pLumaDc, int16_t* pDct) {
for (i = 0 ; i < 16 ; i += 4) { for (i = 0 ; i < 16 ; i += 4) {
iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3); iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3);
s[0] = pDct[iIdx ] + pDct[iIdx + 80]; s[0] = pDct[iIdx ] + pDct[iIdx + 80];
s[3] = pDct[iIdx ] - pDct[iIdx + 80]; s[3] = pDct[iIdx ] - pDct[iIdx + 80];
s[1] = pDct[iIdx + 16] + pDct[iIdx + 64]; s[1] = pDct[iIdx + 16] + pDct[iIdx + 64];
s[2] = pDct[iIdx + 16] - pDct[iIdx + 64]; s[2] = pDct[iIdx + 16] - pDct[iIdx + 64];
p[i ] = s[0] + s[1]; p[i ] = s[0] + s[1];
p[i + 2] = s[0] - s[1]; p[i + 2] = s[0] - s[1];
p[i + 1] = s[3] + s[2]; p[i + 1] = s[3] + s[2];
p[i + 3] = s[3] - s[2]; p[i + 3] = s[3] - s[2];
} }
for (i = 0 ; i < 4 ; i ++) { for (i = 0 ; i < 4 ; i ++) {
s[0] = p[i ] + p[i + 12]; s[0] = p[i ] + p[i + 12];
s[3] = p[i ] - p[i + 12]; s[3] = p[i ] - p[i + 12];
s[1] = p[i + 4] + p[i + 8]; s[1] = p[i + 4] + p[i + 8];
s[2] = 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 ] = 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 + 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 + 4 ] = WELS_CLIP3 ((s[3] + s[2] + 1) >> 1, -32768, 32767);
pLumaDc[i + 12] = WELS_CLIP3 ((s[3] - s[2] + 1) >> 1, -32768, 32767); pLumaDc[i + 12] = WELS_CLIP3 ((s[3] - s[2] + 1) >> 1, -32768, 32767);
@@ -331,7 +331,7 @@ void WelsDctT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pP
s[1] = pData[kiI1] + pData[kiI2]; s[1] = pData[kiI1] + pData[kiI2];
s[2] = pData[kiI1] - pData[kiI2]; s[2] = pData[kiI1] - pData[kiI2];
pDct[i ] = s[0] + s[1]; pDct[i ] = s[0] + s[1];
pDct[kiI2] = s[0] - s[1]; pDct[kiI2] = s[0] - s[1];
pDct[kiI1] = (s[3] << 1) + s[2]; pDct[kiI1] = (s[3] << 1) + s[2];
pDct[kiI3] = s[3] - (s[2] << 1); pDct[kiI3] = s[3] - (s[2] << 1);
@@ -339,16 +339,16 @@ void WelsDctT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t* pP
/* vertical transform */ /* vertical transform */
for (i = 0 ; i < 4 ; i ++) { for (i = 0 ; i < 4 ; i ++) {
const int32_t kiI4 = 4 + i; const int32_t kiI4 = 4 + i;
const int32_t kiI8 = 8 + i; const int32_t kiI8 = 8 + i;
const int32_t kiI12 = 12 + i; const int32_t kiI12 = 12 + i;
s[0] = pDct[i ] + pDct[kiI12]; s[0] = pDct[i ] + pDct[kiI12];
s[3] = pDct[i ] - pDct[kiI12]; s[3] = pDct[i ] - pDct[kiI12];
s[1] = pDct[kiI4] + pDct[kiI8 ]; s[1] = pDct[kiI4] + pDct[kiI8 ];
s[2] = pDct[kiI4] - pDct[kiI8 ]; s[2] = pDct[kiI4] - pDct[kiI8 ];
pDct[i ] = s[0] + s[1]; pDct[i ] = s[0] + s[1];
pDct[kiI8 ] = s[0] - s[1]; pDct[kiI8 ] = s[0] - s[1];
pDct[kiI4 ] = (s[3] << 1) + s[2]; pDct[kiI4 ] = (s[3] << 1) + s[2];
pDct[kiI12] = s[3] - (s[2] << 1); pDct[kiI12] = s[3] - (s[2] << 1);
@@ -359,9 +359,9 @@ void WelsDctFourT4_c (int16_t* pDct, uint8_t* pPixel1, int32_t iStride1, uint8_t
int32_t stride_1 = iStride1 << 2; int32_t stride_1 = iStride1 << 2;
int32_t stride_2 = iStride2 << 2; int32_t stride_2 = iStride2 << 2;
WelsDctT4_c (pDct, &pPixel1[0], iStride1, &pPixel2[0], iStride2); WelsDctT4_c (pDct, &pPixel1[0], iStride1, &pPixel2[0], iStride2);
WelsDctT4_c (pDct + 16, &pPixel1[4], iStride1, &pPixel2[4], iStride2); WelsDctT4_c (pDct + 16, &pPixel1[4], iStride1, &pPixel2[4], iStride2);
WelsDctT4_c (pDct + 32, &pPixel1[stride_1 ], iStride1, &pPixel2[stride_2 ], iStride2); WelsDctT4_c (pDct + 32, &pPixel1[stride_1 ], iStride1, &pPixel2[stride_2 ], iStride2);
WelsDctT4_c (pDct + 48, &pPixel1[stride_1 + 4], iStride1, &pPixel2[stride_2 + 4], iStride2); WelsDctT4_c (pDct + 48, &pPixel1[stride_1 + 4], iStride1, &pPixel2[stride_2 + 4], iStride2);
} }

View File

@@ -74,9 +74,9 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki
if (NULL == pSrcPic || kiWidth == 0 || kiHeight == 0) if (NULL == pSrcPic || kiWidth == 0 || kiHeight == 0)
return 1; return 1;
pSrcPic->iColorFormat = kiColorspace; pSrcPic->iColorFormat = kiColorspace;
pSrcPic->iPicWidth = kiWidth; pSrcPic->iPicWidth = kiWidth;
pSrcPic->iPicHeight = kiHeight; pSrcPic->iPicHeight = kiHeight;
//currently encoder only supports videoFormatI420. //currently encoder only supports videoFormatI420.
if ((kiColorspace & (~videoFormatVFlip)) != videoFormatI420) if ((kiColorspace & (~videoFormatVFlip)) != videoFormatI420)
@@ -84,32 +84,32 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki
switch (kiColorspace & (~videoFormatVFlip)) { switch (kiColorspace & (~videoFormatVFlip)) {
case videoFormatI420: case videoFormatI420:
case videoFormatYV12: case videoFormatYV12:
pSrcPic->pData[0] = NULL; pSrcPic->pData[0] = NULL;
pSrcPic->pData[1] = NULL; pSrcPic->pData[1] = NULL;
pSrcPic->pData[2] = NULL; pSrcPic->pData[2] = NULL;
pSrcPic->pData[3] = NULL; pSrcPic->pData[3] = NULL;
pSrcPic->iStride[0] = kiWidth; pSrcPic->iStride[0] = kiWidth;
pSrcPic->iStride[2] = pSrcPic->iStride[1] = kiWidth >> 1; pSrcPic->iStride[2] = pSrcPic->iStride[1] = kiWidth >> 1;
pSrcPic->iStride[3] = 0; pSrcPic->iStride[3] = 0;
break; break;
case videoFormatYUY2: case videoFormatYUY2:
case videoFormatYVYU: case videoFormatYVYU:
case videoFormatUYVY: case videoFormatUYVY:
pSrcPic->pData[0] = NULL; pSrcPic->pData[0] = NULL;
pSrcPic->pData[1] = NULL; pSrcPic->pData[1] = NULL;
pSrcPic->pData[2] = NULL; pSrcPic->pData[2] = NULL;
pSrcPic->pData[3] = NULL; pSrcPic->pData[3] = NULL;
pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 16); pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 16);
pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0;
break; break;
case videoFormatRGB: case videoFormatRGB:
case videoFormatBGR: case videoFormatBGR:
pSrcPic->pData[0] = NULL; pSrcPic->pData[0] = NULL;
pSrcPic->pData[1] = NULL; pSrcPic->pData[1] = NULL;
pSrcPic->pData[2] = NULL; pSrcPic->pData[2] = NULL;
pSrcPic->pData[3] = NULL; pSrcPic->pData[3] = NULL;
pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 24); pSrcPic->iStride[0] = CALC_BI_STRIDE (kiWidth, 24);
pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0;
if (kiColorspace & videoFormatVFlip) if (kiColorspace & videoFormatVFlip)
pSrcPic->iColorFormat = kiColorspace & (~videoFormatVFlip); pSrcPic->iColorFormat = kiColorspace & (~videoFormatVFlip);
else else
@@ -119,12 +119,12 @@ int32_t InitPic (const void* kpSrc, const int32_t kiColorspace, const int32_t ki
case videoFormatRGBA: case videoFormatRGBA:
case videoFormatARGB: case videoFormatARGB:
case videoFormatABGR: case videoFormatABGR:
pSrcPic->pData[0] = NULL; pSrcPic->pData[0] = NULL;
pSrcPic->pData[1] = NULL; pSrcPic->pData[1] = NULL;
pSrcPic->pData[2] = NULL; pSrcPic->pData[2] = NULL;
pSrcPic->pData[3] = NULL; pSrcPic->pData[3] = NULL;
pSrcPic->iStride[0] = kiWidth << 2; pSrcPic->iStride[0] = kiWidth << 2;
pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0; pSrcPic->iStride[3] = pSrcPic->iStride[2] = pSrcPic->iStride[1] = 0;
if (kiColorspace & videoFormatVFlip) if (kiColorspace & videoFormatVFlip)
pSrcPic->iColorFormat = kiColorspace & (~videoFormatVFlip); pSrcPic->iColorFormat = kiColorspace & (~videoFormatVFlip);
else else
@@ -231,8 +231,8 @@ int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam,
*/ */
void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
// for bitstream writing // for bitstream writing
pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position pEncCtx->iPosBsBuffer = 0; // reset bs pBuffer position
pEncCtx->pOut->iNalIndex = 0; // reset NAL index pEncCtx->pOut->iNalIndex = 0; // reset NAL index
InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize); InitBits (&pEncCtx->pOut->sBsWrite, pEncCtx->pOut->pBsBuffer, pEncCtx->pOut->uiSize);
@@ -250,20 +250,20 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
else else
pEncCtx->iFrameNum = 0; // if iFrameNum overflow pEncCtx->iFrameNum = 0; // if iFrameNum overflow
} }
pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; pEncCtx->eNalType = NAL_UNIT_CODED_SLICE;
pEncCtx->eSliceType = P_SLICE; pEncCtx->eSliceType = P_SLICE;
pEncCtx->eNalPriority = NRI_PRI_HIGH; pEncCtx->eNalPriority = NRI_PRI_HIGH;
} else if (keFrameType == videoFrameTypeIDR) { } else if (keFrameType == videoFrameTypeIDR) {
pEncCtx->iFrameNum = 0; pEncCtx->iFrameNum = 0;
pEncCtx->iPOC = 0; pEncCtx->iPOC = 0;
pEncCtx->bEncCurFrmAsIdrFlag = false; pEncCtx->bEncCurFrmAsIdrFlag = false;
pEncCtx->iFrameIndex = 0; pEncCtx->iFrameIndex = 0;
pEncCtx->eNalType = NAL_UNIT_CODED_SLICE_IDR; pEncCtx->eNalType = NAL_UNIT_CODED_SLICE_IDR;
pEncCtx->eSliceType = I_SLICE; pEncCtx->eSliceType = I_SLICE;
pEncCtx->eNalPriority = NRI_PRI_HIGHEST; pEncCtx->eNalPriority = NRI_PRI_HIGHEST;
pEncCtx->iCodingIndex = 0; pEncCtx->iCodingIndex = 0;
// reset_ref_list // reset_ref_list
@@ -281,9 +281,9 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) {
pEncCtx->iFrameNum = 0; // if iFrameNum overflow pEncCtx->iFrameNum = 0; // if iFrameNum overflow
} }
pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; pEncCtx->eNalType = NAL_UNIT_CODED_SLICE;
pEncCtx->eSliceType = I_SLICE; pEncCtx->eSliceType = I_SLICE;
pEncCtx->eNalPriority = NRI_PRI_HIGHEST; pEncCtx->eNalPriority = NRI_PRI_HIGHEST;
// rc_init_gop // rc_init_gop
} else { // B pictures are not supported now, any else? } else { // B pictures are not supported now, any else?
@@ -393,13 +393,13 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName
if (NULL != pDumpRecFile) { if (NULL != pDumpRecFile) {
int32_t i = 0; int32_t i = 0;
int32_t j = 0; int32_t j = 0;
const int32_t kiStrideY = pCurPicture->iLineSize[0]; const int32_t kiStrideY = pCurPicture->iLineSize[0];
const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft +
pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel;
const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop +
pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel;
const int32_t kiChromaWidth = kiLumaWidth >> 1; const int32_t kiChromaWidth = kiLumaWidth >> 1;
const int32_t kiChromaHeight = kiLumaHeight >> 1; const int32_t kiChromaHeight = kiLumaHeight >> 1;
uint8_t* pSrc = NULL; uint8_t* pSrc = NULL;
pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) +
(pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0];
@@ -460,13 +460,13 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k
if (NULL != pDumpRecFile) { if (NULL != pDumpRecFile) {
int32_t i = 0; int32_t i = 0;
int32_t j = 0; int32_t j = 0;
const int32_t kiStrideY = pCurPicture->iLineSize[0]; const int32_t kiStrideY = pCurPicture->iLineSize[0];
const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft +
pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel;
const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop +
pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel;
const int32_t kiChromaWidth = kiLumaWidth >> 1; const int32_t kiChromaWidth = kiLumaWidth >> 1;
const int32_t kiChromaHeight = kiLumaHeight >> 1; const int32_t kiChromaHeight = kiLumaHeight >> 1;
uint8_t* pSrc = NULL; uint8_t* pSrc = NULL;
pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) +
(pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0];

File diff suppressed because it is too large Load Diff

View File

@@ -133,22 +133,22 @@ void WelsI4x4LumaPredDcNA_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri
/*down pLeft*/ /*down pLeft*/
void WelsI4x4LumaPredDDL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredDDL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = pRef[-kiStride]; const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride]; const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride]; const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride]; const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiT4 = pRef[4 - kiStride]; const uint8_t kuiT4 = pRef[4 - kiStride];
const uint8_t kuiT5 = pRef[5 - kiStride]; const uint8_t kuiT5 = pRef[5 - kiStride];
const uint8_t kuiT6 = pRef[6 - kiStride]; const uint8_t kuiT6 = pRef[6 - kiStride];
const uint8_t kuiT7 = pRef[7 - kiStride]; const uint8_t kuiT7 = pRef[7 - kiStride];
const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDDL0 const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDDL0
const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDDL1 const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDDL1
const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // uiDDL2 const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // uiDDL2
const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // uiDDL3 const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // uiDDL3
const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // uiDDL4 const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // uiDDL4
const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // uiDDL5 const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // uiDDL5
const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // uiDDL6 const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // uiDDL6
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = kuiDDL0; uiSrc[0] = kuiDDL0;
uiSrc[1] = uiSrc[4] = kuiDDL1; uiSrc[1] = uiSrc[4] = kuiDDL1;
uiSrc[2] = uiSrc[5] = uiSrc[8] = kuiDDL2; uiSrc[2] = uiSrc[5] = uiSrc[8] = kuiDDL2;
@@ -163,15 +163,15 @@ void WelsI4x4LumaPredDDL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStrid
/*down pLeft*/ /*down pLeft*/
void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = pRef[-kiStride]; const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride]; const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride]; const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride]; const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDLT0 const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // uiDLT0
const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDLT1 const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // uiDLT1
const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3 << 1)) >> 2; // uiDLT2 const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3 << 1)) >> 2; // uiDLT2
const uint8_t kuiDLT3 = (2 + (kuiT3 << 2)) >> 2; // uiDLT3 const uint8_t kuiDLT3 = (2 + (kuiT3 << 2)) >> 2; // uiDLT3
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
memset (&uiSrc[6], kuiDLT3, 10 * sizeof (uint8_t)); memset (&uiSrc[6], kuiDLT3, 10 * sizeof (uint8_t));
uiSrc[0] = kuiDLT0; uiSrc[0] = kuiDLT0;
uiSrc[1] = uiSrc[4] = kuiDLT1; uiSrc[1] = uiSrc[4] = kuiDLT1;
@@ -184,34 +184,34 @@ void WelsI4x4LumaPredDDLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiSt
/*down right*/ /*down right*/
void WelsI4x4LumaPredDDR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredDDR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const int32_t kiStridex2 = kiStride << 1; const int32_t kiStridex2 = kiStride << 1;
const int32_t kiStridex3 = kiStride + kiStridex2; const int32_t kiStridex3 = kiStride + kiStridex2;
const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pRef[-1]; const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride - 1]; const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStridex2 - 1]; const uint8_t kuiL2 = pRef[kiStridex2 - 1];
const uint8_t kuiL3 = pRef[kiStridex3 - 1]; const uint8_t kuiL3 = pRef[kiStridex3 - 1];
const uint8_t kuiT0 = pRef[-kiStride]; const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride]; const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride]; const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride]; const uint8_t kuiT3 = pRef[3 - kiStride];
const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2;
const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2;
const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2;
const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2;
const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2;
const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = uiSrc[5] = uiSrc[10] = uiSrc[15] = kuiDDR0; uiSrc[0] = uiSrc[5] = uiSrc[10] = uiSrc[15] = kuiDDR0;
uiSrc[1] = uiSrc[6] = uiSrc[11] = kuiDDR1; uiSrc[1] = uiSrc[6] = uiSrc[11] = kuiDDR1;
uiSrc[2] = uiSrc[7] = kuiDDR2; uiSrc[2] = uiSrc[7] = kuiDDR2;
@@ -227,24 +227,24 @@ void WelsI4x4LumaPredDDR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStrid
/*vertical pLeft*/ /*vertical pLeft*/
void WelsI4x4LumaPredVL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredVL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = pRef[-kiStride]; const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride]; const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride]; const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride]; const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiT4 = pRef[4 - kiStride]; const uint8_t kuiT4 = pRef[4 - kiStride];
const uint8_t kuiT5 = pRef[5 - kiStride]; const uint8_t kuiT5 = pRef[5 - kiStride];
const uint8_t kuiT6 = pRef[6 - kiStride]; const uint8_t kuiT6 = pRef[6 - kiStride];
const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1) >> 1; // uiVL0 const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1) >> 1; // uiVL0
const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2) >> 1; // uiVL1 const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2) >> 1; // uiVL1
const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3) >> 1; // uiVL2 const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3) >> 1; // uiVL2
const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4) >> 1; // uiVL3 const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4) >> 1; // uiVL3
const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5) >> 1; // uiVL4 const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5) >> 1; // uiVL4
const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVL5 const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVL5
const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVL6 const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVL6
const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3 << 1) + kuiT4) >> 2; // uiVL7 const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3 << 1) + kuiT4) >> 2; // uiVL7
const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4 << 1) + kuiT5) >> 2; // uiVL8 const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4 << 1) + kuiT5) >> 2; // uiVL8
const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5 << 1) + kuiT6) >> 2; // uiVL9 const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5 << 1) + kuiT6) >> 2; // uiVL9
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = kuiVL0; uiSrc[0] = kuiVL0;
uiSrc[1] = uiSrc[8] = kuiVL1; uiSrc[1] = uiSrc[8] = kuiVL1;
uiSrc[2] = uiSrc[9] = kuiVL2; uiSrc[2] = uiSrc[9] = kuiVL2;
@@ -263,21 +263,21 @@ void WelsI4x4LumaPredVL_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride
/*vertical pLeft*/ /*vertical pLeft*/
void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
uint8_t* pTopLeft = &pRef[-kiStride - 1]; // pTop-pLeft uint8_t* pTopLeft = &pRef[-kiStride - 1]; // pTop-pLeft
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = * (pTopLeft + 1); const uint8_t kuiT0 = * (pTopLeft + 1);
const uint8_t kuiT1 = * (pTopLeft + 2); const uint8_t kuiT1 = * (pTopLeft + 2);
const uint8_t kuiT2 = * (pTopLeft + 3); const uint8_t kuiT2 = * (pTopLeft + 3);
const uint8_t kuiT3 = * (pTopLeft + 4); const uint8_t kuiT3 = * (pTopLeft + 4);
const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1) >> 1; // uiVLT0 const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1) >> 1; // uiVLT0
const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2) >> 1; // uiVLT1 const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2) >> 1; // uiVLT1
const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3) >> 1; // uiVLT2 const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3) >> 1; // uiVLT2
const uint8_t kuiVLT3 = (1 + (kuiT3 << 1)) >> 1; // uiVLT3 const uint8_t kuiVLT3 = (1 + (kuiT3 << 1)) >> 1; // uiVLT3
const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVLT4 const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiVLT4
const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVLT5 const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // uiVLT5
const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3 << 1) + kuiT3) >> 2; // uiVLT6 const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3 << 1) + kuiT3) >> 2; // uiVLT6
const uint8_t kuiVLT7 = (2 + (kuiT3 << 2)) >> 2; // uiVLT7 const uint8_t kuiVLT7 = (2 + (kuiT3 << 2)) >> 2; // uiVLT7
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = kuiVLT0; uiSrc[0] = kuiVLT0;
uiSrc[1] = uiSrc[8] = kuiVLT1; uiSrc[1] = uiSrc[8] = kuiVLT1;
uiSrc[2] = uiSrc[9] = kuiVLT2; uiSrc[2] = uiSrc[9] = kuiVLT2;
@@ -292,27 +292,27 @@ void WelsI4x4LumaPredVLTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStr
/*vertical right*/ /*vertical right*/
void WelsI4x4LumaPredVR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredVR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const int32_t kiStridex2 = kiStride << 1; const int32_t kiStridex2 = kiStride << 1;
const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pRef[-1]; const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride - 1]; const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStridex2 - 1]; const uint8_t kuiL2 = pRef[kiStridex2 - 1];
const uint8_t kuiT0 = pRef[-kiStride]; const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride]; const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride]; const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiT3 = pRef[3 - kiStride]; const uint8_t kuiT3 = pRef[3 - kiStride];
const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1;
const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1;
const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1;
const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1;
const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2;
const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2;
const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2;
const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = uiSrc[9] = kuiVR0; uiSrc[0] = uiSrc[9] = kuiVR0;
uiSrc[1] = uiSrc[10] = kuiVR1; uiSrc[1] = uiSrc[10] = kuiVR1;
uiSrc[2] = uiSrc[11] = kuiVR2; uiSrc[2] = uiSrc[11] = kuiVR2;
@@ -330,23 +330,23 @@ void WelsI4x4LumaPredVR_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride
/*horizontal up*/ /*horizontal up*/
void WelsI4x4LumaPredHU_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredHU_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const int32_t kiStridex2 = kiStride << 1; const int32_t kiStridex2 = kiStride << 1;
const int32_t kiStridex3 = kiStride + kiStridex2; const int32_t kiStridex3 = kiStride + kiStridex2;
/*get pLeft*/ /*get pLeft*/
const uint8_t kuiL0 = pRef[-1]; const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride - 1]; const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStridex2 - 1]; const uint8_t kuiL2 = pRef[kiStridex2 - 1];
const uint8_t kuiL3 = pRef[kiStridex3 - 1]; const uint8_t kuiL3 = pRef[kiStridex3 - 1];
const uint16_t kuiL01 = (1 + kuiL0 + kuiL1); const uint16_t kuiL01 = (1 + kuiL0 + kuiL1);
const uint16_t kuiL12 = (1 + kuiL1 + kuiL2); const uint16_t kuiL12 = (1 + kuiL1 + kuiL2);
const uint16_t kuiL23 = (1 + kuiL2 + kuiL3); const uint16_t kuiL23 = (1 + kuiL2 + kuiL3);
const uint8_t kuiHU0 = kuiL01 >> 1; const uint8_t kuiHU0 = kuiL01 >> 1;
const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiHU2 = kuiL12 >> 1; const uint8_t kuiHU2 = kuiL12 >> 1;
const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2;
const uint8_t kuiHU4 = kuiL23 >> 1; const uint8_t kuiHU4 = kuiL23 >> 1;
const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = kuiHU0; uiSrc[0] = kuiHU0;
uiSrc[1] = kuiHU1; uiSrc[1] = kuiHU1;
uiSrc[2] = uiSrc[4] = kuiHU2; uiSrc[2] = uiSrc[4] = kuiHU2;
@@ -361,28 +361,28 @@ void WelsI4x4LumaPredHU_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride
/*horizontal down*/ /*horizontal down*/
void WelsI4x4LumaPredHD_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsI4x4LumaPredHD_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const int32_t kiStridex2 = kiStride << 1; const int32_t kiStridex2 = kiStride << 1;
const int32_t kiStridex3 = kiStride + kiStridex2; const int32_t kiStridex3 = kiStride + kiStridex2;
const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft const uint8_t kuiLT = pRef[-kiStride - 1]; // pTop-pLeft
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pRef[-1]; const uint8_t kuiL0 = pRef[-1];
const uint8_t kuiL1 = pRef[kiStride - 1]; const uint8_t kuiL1 = pRef[kiStride - 1];
const uint8_t kuiL2 = pRef[kiStridex2 - 1]; const uint8_t kuiL2 = pRef[kiStridex2 - 1];
const uint8_t kuiL3 = pRef[kiStridex3 - 1]; const uint8_t kuiL3 = pRef[kiStridex3 - 1];
const uint8_t kuiT0 = pRef[-kiStride]; const uint8_t kuiT0 = pRef[-kiStride];
const uint8_t kuiT1 = pRef[1 - kiStride]; const uint8_t kuiT1 = pRef[1 - kiStride];
const uint8_t kuiT2 = pRef[2 - kiStride]; const uint8_t kuiT2 = pRef[2 - kiStride];
const uint8_t kuiHD0 = (1 + kuiLT + kuiL0) >> 1; // uiHD0 const uint8_t kuiHD0 = (1 + kuiLT + kuiL0) >> 1; // uiHD0
const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // uiHD1 const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // uiHD1
const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // uiHD2 const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // uiHD2
const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiHD3 const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // uiHD3
const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1) >> 1; // uiHD4 const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1) >> 1; // uiHD4
const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // uiHD5 const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // uiHD5
const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2) >> 1; // uiHD6 const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2) >> 1; // uiHD6
const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // uiHD7 const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // uiHD7
const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1; // uiHD8 const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1; // uiHD8
const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2; // uiHD9 const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2; // uiHD9
ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows ENFORCE_STACK_ALIGN_1D (uint8_t, uiSrc, 16, 16) // TobeCont'd about assign opt as follows
uiSrc[0] = uiSrc[6] = kuiHD0; uiSrc[0] = uiSrc[6] = kuiHD0;
uiSrc[1] = uiSrc[7] = kuiHD1; uiSrc[1] = uiSrc[7] = kuiHD1;
uiSrc[2] = kuiHD2; uiSrc[2] = kuiHD2;
@@ -404,7 +404,7 @@ void WelsI4x4LumaPredHD_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride
void WelsIChromaPredV_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsIChromaPredV_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const uint64_t kuiSrc64 = LD64 (&pRef[-kiStride]); const uint64_t kuiSrc64 = LD64 (&pRef[-kiStride]);
ST64 (pPred , kuiSrc64); ST64 (pPred , kuiSrc64);
ST64 (pPred + 8 , kuiSrc64); ST64 (pPred + 8 , kuiSrc64);
ST64 (pPred + 16, kuiSrc64); ST64 (pPred + 16, kuiSrc64);
ST64 (pPred + 24, kuiSrc64); ST64 (pPred + 24, kuiSrc64);
@@ -476,7 +476,7 @@ void WelsIChromaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride)
const uint64_t kuiTopMean64 = LD64 (kuiTopMean); const uint64_t kuiTopMean64 = LD64 (kuiTopMean);
const uint64_t kuiBottomMean64 = LD64 (kuiBottomMean); const uint64_t kuiBottomMean64 = LD64 (kuiBottomMean);
ST64 (pPred , kuiTopMean64); ST64 (pPred , kuiTopMean64);
ST64 (pPred + 8 , kuiTopMean64); ST64 (pPred + 8 , kuiTopMean64);
ST64 (pPred + 16, kuiTopMean64); ST64 (pPred + 16, kuiTopMean64);
ST64 (pPred + 24, kuiTopMean64); ST64 (pPred + 24, kuiTopMean64);
@@ -487,19 +487,19 @@ void WelsIChromaPredDc_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride)
} }
void WelsIChromaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsIChromaPredDcLeft_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const int32_t kuiL1 = kiStride - 1; const int32_t kuiL1 = kiStride - 1;
const int32_t kuiL2 = kuiL1 + kiStride; const int32_t kuiL2 = kuiL1 + kiStride;
const int32_t kuiL3 = kuiL2 + kiStride; const int32_t kuiL3 = kuiL2 + kiStride;
const int32_t kuiL4 = kuiL3 + kiStride; const int32_t kuiL4 = kuiL3 + kiStride;
const int32_t kuiL5 = kuiL4 + kiStride; const int32_t kuiL5 = kuiL4 + kiStride;
const int32_t kuiL6 = kuiL5 + kiStride; const int32_t kuiL6 = kuiL5 + kiStride;
const int32_t kuiL7 = kuiL6 + kiStride; const int32_t kuiL7 = kuiL6 + kiStride;
/*caculate the iMean value*/ /*caculate the iMean value*/
const uint8_t kuiTopMean = (pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 2) >> 2 ; const uint8_t kuiTopMean = (pRef[-1] + pRef[kuiL1] + pRef[kuiL2] + pRef[kuiL3] + 2) >> 2 ;
const uint8_t kuiBottomMean = (pRef[kuiL4] + pRef[kuiL5] + pRef[kuiL6] + pRef[kuiL7] + 2) >> 2; const uint8_t kuiBottomMean = (pRef[kuiL4] + pRef[kuiL5] + pRef[kuiL6] + pRef[kuiL7] + 2) >> 2;
const uint64_t kuiTopMean64 = (uint64_t) (0x0101010101010101ULL * kuiTopMean); const uint64_t kuiTopMean64 = (uint64_t) (0x0101010101010101ULL * kuiTopMean);
const uint64_t kuiBottomMean64 = (uint64_t) (0x0101010101010101ULL * kuiBottomMean); const uint64_t kuiBottomMean64 = (uint64_t) (0x0101010101010101ULL * kuiBottomMean);
ST64 (pPred , kuiTopMean64); ST64 (pPred , kuiTopMean64);
ST64 (pPred + 8 , kuiTopMean64); ST64 (pPred + 8 , kuiTopMean64);
ST64 (pPred + 16, kuiTopMean64); ST64 (pPred + 16, kuiTopMean64);
ST64 (pPred + 24, kuiTopMean64); ST64 (pPred + 24, kuiTopMean64);
@@ -516,7 +516,7 @@ void WelsIChromaPredDcTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri
const uint8_t kuiMean[8] = {kuiMean1, kuiMean1, kuiMean1, kuiMean1, kuiMean2, kuiMean2, kuiMean2, kuiMean2}; const uint8_t kuiMean[8] = {kuiMean1, kuiMean1, kuiMean1, kuiMean1, kuiMean2, kuiMean2, kuiMean2, kuiMean2};
const uint64_t kuiMean64 = LD64 (kuiMean); const uint64_t kuiMean64 = LD64 (kuiMean);
ST64 (pPred , kuiMean64); ST64 (pPred , kuiMean64);
ST64 (pPred + 8 , kuiMean64); ST64 (pPred + 8 , kuiMean64);
ST64 (pPred + 16, kuiMean64); ST64 (pPred + 16, kuiMean64);
ST64 (pPred + 24, kuiMean64); ST64 (pPred + 24, kuiMean64);
@@ -528,7 +528,7 @@ void WelsIChromaPredDcTop_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStri
void WelsIChromaPredDcNA_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) { void WelsIChromaPredDcNA_c (uint8_t* pPred, uint8_t* pRef, const int32_t kiStride) {
const uint64_t kuiDcValue64 = (uint64_t)0x8080808080808080ULL; const uint64_t kuiDcValue64 = (uint64_t)0x8080808080808080ULL;
ST64 (pPred , kuiDcValue64); ST64 (pPred , kuiDcValue64);
ST64 (pPred + 8 , kuiDcValue64); ST64 (pPred + 8 , kuiDcValue64);
ST64 (pPred + 16, kuiDcValue64); ST64 (pPred + 16, kuiDcValue64);
ST64 (pPred + 24, kuiDcValue64); ST64 (pPred + 24, kuiDcValue64);

View File

@@ -435,10 +435,10 @@ uint8_t MdInterAnalysisVaaInfo_c (int32_t* pSad8x8) {
int32_t AnalysisVaaInfoIntra_c (uint8_t* pDataY, const int32_t kiLineSize) { int32_t AnalysisVaaInfoIntra_c (uint8_t* pDataY, const int32_t kiLineSize) {
ENFORCE_STACK_ALIGN_1D (uint16_t, uiAvgBlock, 16, 16) ENFORCE_STACK_ALIGN_1D (uint16_t, uiAvgBlock, 16, 16)
uint16_t* pBlock = &uiAvgBlock[0]; uint16_t* pBlock = &uiAvgBlock[0];
uint8_t* pEncData = pDataY; uint8_t* pEncData = pDataY;
const int32_t kiLineSize2 = kiLineSize << 1; const int32_t kiLineSize2 = kiLineSize << 1;
const int32_t kiLineSize3 = kiLineSize + kiLineSize2; const int32_t kiLineSize3 = kiLineSize + kiLineSize2;
const int32_t kiLineSize4 = kiLineSize << 2; const int32_t kiLineSize4 = kiLineSize << 2;
int32_t i = 0, j = 0, num = 0; int32_t i = 0, j = 0, num = 0;
int32_t iSumAvg = 0, iSumSqr = 0; int32_t iSumAvg = 0, iSumSqr = 0;
@@ -492,9 +492,9 @@ void InitIntraAnalysisVaaInfo (SWelsFuncPtrList* pFuncList, const uint32_t kuiCp
bool MdIntraAnalysisVaaInfo (sWelsEncCtx* pEncCtx, uint8_t* pEncMb) { bool MdIntraAnalysisVaaInfo (sWelsEncCtx* pEncCtx, uint8_t* pEncMb) {
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
const int32_t kiLineSize = pCurDqLayer->iEncStride[0]; const int32_t kiLineSize = pCurDqLayer->iEncStride[0];
const int32_t kiVariance = pEncCtx->pFuncList->pfGetVarianceFromIntraVaa (pEncMb, kiLineSize); const int32_t kiVariance = pEncCtx->pFuncList->pfGetVarianceFromIntraVaa (pEncMb, kiLineSize);
return (kiVariance >= INTRA_VARIANCE_SAD_THRESHOLD); return (kiVariance >= INTRA_VARIANCE_SAD_THRESHOLD);
} }
@@ -527,11 +527,11 @@ typedef struct TagQuarParams {
inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefinePointer* pMeRefine, inline void MeRefineQuarPixel (SWelsFuncPtrList* pFunc, SWelsME* pMe, SMeRefinePointer* pMeRefine,
const int32_t kiWidth, const int32_t kiHeight, SQuarRefineParams* pParams, int32_t iStrideEnc) { const int32_t kiWidth, const int32_t kiHeight, SQuarRefineParams* pParams, int32_t iStrideEnc) {
PWelsSampleAveragingFunc pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging; PWelsSampleAveragingFunc pSampleAvg = pFunc->sMcFuncs.pfSampleAveraging;
int32_t iCurCost; int32_t iCurCost;
uint8_t* pEncMb = pMe->pEncMb; uint8_t* pEncMb = pMe->pEncMb;
uint8_t* pTmp = NULL; uint8_t* pTmp = NULL;
const uint8_t kuiPixel = pMe->uiBlockSize; const uint8_t kuiPixel = pMe->uiBlockSize;
pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[0], ME_REFINE_BUF_STRIDE, pSampleAvg (pMeRefine->pQuarPixTmp, ME_REFINE_BUF_STRIDE, pParams->pSrcA[0], ME_REFINE_BUF_STRIDE,
pParams->pSrcB[0], pParams->iStrideA, kiWidth, kiHeight); pParams->pSrcB[0], pParams->iStrideA, kiWidth, kiHeight);
@@ -791,9 +791,9 @@ void InitBlkStrideWithRef (int32_t* pBlkStride, const int32_t kiStrideRef) {
* iMvdSz = (648*2+1) or (972*2+1); * iMvdSz = (648*2+1) or (972*2+1);
*/ */
void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) { void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) {
const int32_t kiSz = kiMvdSz >> 1; const int32_t kiSz = kiMvdSz >> 1;
uint16_t* pNegMvd = pMvdCostInter; uint16_t* pNegMvd = pMvdCostInter;
uint16_t* pPosMvd = pMvdCostInter + kiSz + 1; uint16_t* pPosMvd = pMvdCostInter + kiSz + 1;
const int32_t* kpQpLambda = &g_kiQpCostTable[0]; const int32_t* kpQpLambda = &g_kiQpCostTable[0];
int32_t i, j; int32_t i, j;
@@ -803,15 +803,15 @@ void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) {
int32_t iPosSe = 1; int32_t iPosSe = 1;
for (j = 0; j < kiSz; j += 4) { for (j = 0; j < kiSz; j += 4) {
*pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++);
*pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++);
*pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++);
*pNegMvd++ = kiLambda * BsSizeSE (iNegSe++); *pNegMvd++ = kiLambda * BsSizeSE (iNegSe++);
*pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++);
*pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++);
*pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++);
*pPosMvd++ = kiLambda * BsSizeSE (iPosSe++); *pPosMvd++ = kiLambda * BsSizeSE (iPosSe++);
} }
*pNegMvd = kiLambda; *pNegMvd = kiLambda;
pNegMvd += kiSz + 1; pNegMvd += kiSz + 1;
@@ -820,12 +820,12 @@ void MvdCostInit (uint16_t* pMvdCostInter, const int32_t kiMvdSz) {
} }
void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef, int32_t* pSadPred) { void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef, int32_t* pSadPred) {
const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4 const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4
int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2 int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2
const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1 const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1
const int32_t kiSadB = pSadCostCache[1]; const int32_t kiSadB = pSadCostCache[1];
int32_t iSadC = pSadCostCache[2]; int32_t iSadC = pSadCostCache[2];
const int32_t kiSadA = pSadCostCache[3]; const int32_t kiSadA = pSadCostCache[3];
int32_t iCount; int32_t iCount;
@@ -865,13 +865,13 @@ void PredictSad (int8_t* pRefIndexCache, int32_t* pSadCostCache, int32_t uiRef,
void PredictSadSkip (int8_t* pRefIndexCache, bool* pMbSkipCache, int32_t* pSadCostCache, int32_t uiRef, void PredictSadSkip (int8_t* pRefIndexCache, bool* pMbSkipCache, int32_t* pSadCostCache, int32_t uiRef,
int32_t* iSadPredSkip) { int32_t* iSadPredSkip) {
const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4 const int32_t kiRefB = pRefIndexCache[1];//top g_uiCache12_8x8RefIdx[0] - 4
int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2 int32_t iRefC = pRefIndexCache[5];//top-right g_uiCache12_8x8RefIdx[0] - 2
const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1 const int32_t kiRefA = pRefIndexCache[6];//left g_uiCache12_8x8RefIdx[0] - 1
const int32_t kiSadB = (pMbSkipCache[1] == 1 ? pSadCostCache[1] : 0); const int32_t kiSadB = (pMbSkipCache[1] == 1 ? pSadCostCache[1] : 0);
int32_t iSadC = (pMbSkipCache[2] == 1 ? pSadCostCache[2] : 0); int32_t iSadC = (pMbSkipCache[2] == 1 ? pSadCostCache[2] : 0);
const int32_t kiSadA = (pMbSkipCache[3] == 1 ? pSadCostCache[3] : 0); const int32_t kiSadA = (pMbSkipCache[3] == 1 ? pSadCostCache[3] : 0);
int32_t iRefSkip = pMbSkipCache[2]; int32_t iRefSkip = pMbSkipCache[2];
int32_t iCount = 0; int32_t iCount = 0;

View File

@@ -43,8 +43,8 @@
namespace WelsEnc { namespace WelsEnc {
//basic pMv prediction unit for pMv width (4, 2, 1) //basic pMv prediction unit for pMv width (4, 2, 1)
void PredMv (const SMVComponentUnit* kpMvComp, int8_t iPartIdx, int8_t iPartW, int32_t iRef, SMVUnitXY* sMvp) { void PredMv (const SMVComponentUnit* kpMvComp, int8_t iPartIdx, int8_t iPartW, int32_t iRef, SMVUnitXY* sMvp) {
const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1; const uint8_t kuiLeftIdx = g_kuiCache30ScanIdx[iPartIdx] - 1;
const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6; const uint8_t kuiTopIdx = g_kuiCache30ScanIdx[iPartIdx] - 6;
int32_t iMatchRef; int32_t iMatchRef;
int32_t iLeftRef = kpMvComp->iRefIndexCache[kuiLeftIdx]; int32_t iLeftRef = kpMvComp->iRefIndexCache[kuiLeftIdx];
@@ -69,8 +69,8 @@ void PredMv (const SMVComponentUnit* kpMvComp, int8_t iPartIdx, int8_t iPartW, i
} }
// b2[diag] b1[top] b0[left] is available! // b2[diag] b1[top] b0[left] is available!
iMatchRef = (iRef == iLeftRef) << MB_LEFT_BIT; iMatchRef = (iRef == iLeftRef) << MB_LEFT_BIT;
iMatchRef |= (iRef == iTopRef) << MB_TOP_BIT; iMatchRef |= (iRef == iTopRef) << MB_TOP_BIT;
iMatchRef |= (iRef == iDiagonalRef) << MB_TOPRIGHT_BIT; iMatchRef |= (iRef == iDiagonalRef) << MB_TOPRIGHT_BIT;
switch (iMatchRef) { switch (iMatchRef) {
case LEFT_MB_POS:// A case LEFT_MB_POS:// A
@@ -147,12 +147,12 @@ void PredSkipMv (SMbCache* pMbCache, SMVUnitXY* sMvp) {
//update pMv and uiRefIndex cache for current MB, only for P_16*16 (SKIP inclusive) //update pMv and uiRefIndex cache for current MB, only for P_16*16 (SKIP inclusive)
void UpdateP16x16MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef, SMVUnitXY* pMv) { void UpdateP16x16MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef, SMVUnitXY* pMv) {
// optimized 11/25/2011 // optimized 11/25/2011
SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; SMVComponentUnit* pMvComp = &pMbCache->sMvComponents;
const uint32_t kuiMv32 = LD32 (pMv); const uint32_t kuiMv32 = LD32 (pMv);
const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32);
uint64_t uiMvBuf[8] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64 }; uint64_t uiMvBuf[8] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64, kuiMv64 };
const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef);
const uint32_t kuiRef32 = BUTTERFLY2x4 (kuiRef16); const uint32_t kuiRef32 = BUTTERFLY2x4 (kuiRef16);
ST32 (pCurMb->pRefIndex, kuiRef32); ST32 (pCurMb->pRefIndex, kuiRef32);
// update pMv range from 0~15 // update pMv range from 0~15
@@ -161,23 +161,23 @@ void UpdateP16x16MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef
/* /*
* blocks 0: 7~10, 1: 13~16, 2: 19~22, 3: 25~28 * blocks 0: 7~10, 1: 13~16, 2: 19~22, 3: 25~28
*/ */
pMvComp->iRefIndexCache[7] = kiRef; pMvComp->iRefIndexCache[7] = kiRef;
ST16 (&pMvComp->iRefIndexCache[8], kuiRef16); ST16 (&pMvComp->iRefIndexCache[8], kuiRef16);
pMvComp->iRefIndexCache[10] = kiRef; pMvComp->iRefIndexCache[10] = kiRef;
pMvComp->iRefIndexCache[13] = kiRef; pMvComp->iRefIndexCache[13] = kiRef;
ST16 (&pMvComp->iRefIndexCache[14], kuiRef16); ST16 (&pMvComp->iRefIndexCache[14], kuiRef16);
pMvComp->iRefIndexCache[16] = kiRef; pMvComp->iRefIndexCache[16] = kiRef;
pMvComp->iRefIndexCache[19] = kiRef; pMvComp->iRefIndexCache[19] = kiRef;
ST16 (&pMvComp->iRefIndexCache[20], kuiRef16); ST16 (&pMvComp->iRefIndexCache[20], kuiRef16);
pMvComp->iRefIndexCache[22] = kiRef; pMvComp->iRefIndexCache[22] = kiRef;
pMvComp->iRefIndexCache[25] = kiRef; pMvComp->iRefIndexCache[25] = kiRef;
ST16 (&pMvComp->iRefIndexCache[26], kuiRef16); ST16 (&pMvComp->iRefIndexCache[26], kuiRef16);
pMvComp->iRefIndexCache[28] = kiRef; pMvComp->iRefIndexCache[28] = kiRef;
/* /*
* blocks 0: 7~10, 1: 13~16, 2: 19~22, 3: 25~28 * blocks 0: 7~10, 1: 13~16, 2: 19~22, 3: 25~28
*/ */
pMvComp->sMotionVectorCache[7] = *pMv; pMvComp->sMotionVectorCache[7] = *pMv;
ST64 (&pMvComp->sMotionVectorCache[8], kuiMv64); ST64 (&pMvComp->sMotionVectorCache[8], kuiMv64);
pMvComp->sMotionVectorCache[10] = *pMv; pMvComp->sMotionVectorCache[10] = *pMv;
pMvComp->sMotionVectorCache[13] = *pMv; pMvComp->sMotionVectorCache[13] = *pMv;
@@ -195,18 +195,18 @@ void UpdateP16x16MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int8_t kiRef
void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef,
SMVUnitXY* pMv) { SMVUnitXY* pMv) {
// optimized 11/25/2011 // optimized 11/25/2011
SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; SMVComponentUnit* pMvComp = &pMbCache->sMvComponents;
const uint32_t kuiMv32 = LD32 (pMv); const uint32_t kuiMv32 = LD32 (pMv);
const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32);
uint64_t uiMvBuf[4] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64 }; uint64_t uiMvBuf[4] = { kuiMv64, kuiMv64, kuiMv64, kuiMv64 };
const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx];
const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx];
const int16_t kiCacheIdx1 = 1 + kiCacheIdx; const int16_t kiCacheIdx1 = 1 + kiCacheIdx;
const int16_t kiCacheIdx3 = 3 + kiCacheIdx; const int16_t kiCacheIdx3 = 3 + kiCacheIdx;
const int16_t kiCacheIdx6 = 6 + kiCacheIdx; const int16_t kiCacheIdx6 = 6 + kiCacheIdx;
const int16_t kiCacheIdx7 = 7 + kiCacheIdx; const int16_t kiCacheIdx7 = 7 + kiCacheIdx;
const int16_t kiCacheIdx9 = 9 + kiCacheIdx; const int16_t kiCacheIdx9 = 9 + kiCacheIdx;
const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef);
ST16 (&pCurMb->pRefIndex[ (kiPartIdx >> 2)], kuiRef16); ST16 (&pCurMb->pRefIndex[ (kiPartIdx >> 2)], kuiRef16);
memcpy (&pCurMb->sMv[kiScan4Idx], uiMvBuf, sizeof (uiMvBuf)); // confirmed_safe_unsafe_usage memcpy (&pCurMb->sMv[kiScan4Idx], uiMvBuf, sizeof (uiMvBuf)); // confirmed_safe_unsafe_usage
@@ -214,17 +214,17 @@ void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPar
/* /*
* blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9
*/ */
pMvComp->iRefIndexCache[kiCacheIdx] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx] = kiRef;
ST16 (&pMvComp->iRefIndexCache[kiCacheIdx1], kuiRef16); ST16 (&pMvComp->iRefIndexCache[kiCacheIdx1], kuiRef16);
pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef;
pMvComp->iRefIndexCache[kiCacheIdx6] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx6] = kiRef;
ST16 (&pMvComp->iRefIndexCache[kiCacheIdx7], kuiRef16); ST16 (&pMvComp->iRefIndexCache[kiCacheIdx7], kuiRef16);
pMvComp->iRefIndexCache[kiCacheIdx9] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx9] = kiRef;
/* /*
* blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9
*/ */
pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv;
ST64 (&pMvComp->sMotionVectorCache[kiCacheIdx1], kuiMv64); ST64 (&pMvComp->sMotionVectorCache[kiCacheIdx1], kuiMv64);
pMvComp->sMotionVectorCache[kiCacheIdx3] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx3] = *pMv;
pMvComp->sMotionVectorCache[kiCacheIdx6] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx6] = *pMv;
@@ -235,20 +235,20 @@ void UpdateP16x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPar
void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef,
SMVUnitXY* pMv) { SMVUnitXY* pMv) {
// optimized 11/25/2011 // optimized 11/25/2011
SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; SMVComponentUnit* pMvComp = &pMbCache->sMvComponents;
const uint32_t kuiMv32 = LD32 (pMv); const uint32_t kuiMv32 = LD32 (pMv);
const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32);
const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx];
const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx];
const int16_t kiCacheIdx1 = 1 + kiCacheIdx; const int16_t kiCacheIdx1 = 1 + kiCacheIdx;
const int16_t kiCacheIdx3 = 3 + kiCacheIdx; const int16_t kiCacheIdx3 = 3 + kiCacheIdx;
const int16_t kiCacheIdx12 = 12 + kiCacheIdx; const int16_t kiCacheIdx12 = 12 + kiCacheIdx;
const int16_t kiCacheIdx13 = 13 + kiCacheIdx; const int16_t kiCacheIdx13 = 13 + kiCacheIdx;
const int16_t kiCacheIdx15 = 15 + kiCacheIdx; const int16_t kiCacheIdx15 = 15 + kiCacheIdx;
const int16_t kiBlkIdx = kiPartIdx >> 2; const int16_t kiBlkIdx = kiPartIdx >> 2;
const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef); const uint16_t kuiRef16 = BUTTERFLY1x2 (kiRef);
pCurMb->pRefIndex[kiBlkIdx] = kiRef; pCurMb->pRefIndex[kiBlkIdx] = kiRef;
pCurMb->pRefIndex[2 + kiBlkIdx] = kiRef; pCurMb->pRefIndex[2 + kiBlkIdx] = kiRef;
ST64 (&pCurMb->sMv[kiScan4Idx], kuiMv64); ST64 (&pCurMb->sMv[kiScan4Idx], kuiMv64);
ST64 (&pCurMb->sMv[4 + kiScan4Idx], kuiMv64); ST64 (&pCurMb->sMv[4 + kiScan4Idx], kuiMv64);
@@ -258,17 +258,17 @@ void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t ki
/* /*
* blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9
*/ */
pMvComp->iRefIndexCache[kiCacheIdx] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx] = kiRef;
ST16 (&pMvComp->iRefIndexCache[kiCacheIdx1], kuiRef16); ST16 (&pMvComp->iRefIndexCache[kiCacheIdx1], kuiRef16);
pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx3] = kiRef;
pMvComp->iRefIndexCache[kiCacheIdx12] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx12] = kiRef;
ST16 (&pMvComp->iRefIndexCache[kiCacheIdx13], kuiRef16); ST16 (&pMvComp->iRefIndexCache[kiCacheIdx13], kuiRef16);
pMvComp->iRefIndexCache[kiCacheIdx15] = kiRef; pMvComp->iRefIndexCache[kiCacheIdx15] = kiRef;
/* /*
* blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9 * blocks 0: g_kuiCache30ScanIdx[iPartIdx]~g_kuiCache30ScanIdx[iPartIdx]+3, 1: g_kuiCache30ScanIdx[iPartIdx]+6~g_kuiCache30ScanIdx[iPartIdx]+9
*/ */
pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx] = *pMv;
ST64 (&pMvComp->sMotionVectorCache[kiCacheIdx1], kuiMv64); ST64 (&pMvComp->sMotionVectorCache[kiCacheIdx1], kuiMv64);
pMvComp->sMotionVectorCache[kiCacheIdx3] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx3] = *pMv;
pMvComp->sMotionVectorCache[kiCacheIdx12] = *pMv; pMvComp->sMotionVectorCache[kiCacheIdx12] = *pMv;
@@ -279,13 +279,13 @@ void update_P8x16_motion_info (SMbCache* pMbCache, SMB* pCurMb, const int32_t ki
void UpdateP8x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef, void UpdateP8x8MotionInfo (SMbCache* pMbCache, SMB* pCurMb, const int32_t kiPartIdx, const int8_t kiRef,
SMVUnitXY* pMv) { SMVUnitXY* pMv) {
SMVComponentUnit* pMvComp = &pMbCache->sMvComponents; SMVComponentUnit* pMvComp = &pMbCache->sMvComponents;
const uint32_t kuiMv32 = LD32 (pMv); const uint32_t kuiMv32 = LD32 (pMv);
const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32); const uint64_t kuiMv64 = BUTTERFLY4x8 (kuiMv32);
const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx]; const int16_t kiScan4Idx = g_kuiMbCountScan4Idx[kiPartIdx];
const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx]; const int16_t kiCacheIdx = g_kuiCache30ScanIdx[kiPartIdx];
const int16_t kiCacheIdx1 = 1 + kiCacheIdx; const int16_t kiCacheIdx1 = 1 + kiCacheIdx;
const int16_t kiCacheIdx6 = 6 + kiCacheIdx; const int16_t kiCacheIdx6 = 6 + kiCacheIdx;
const int16_t kiCacheIdx7 = 7 + kiCacheIdx; const int16_t kiCacheIdx7 = 7 + kiCacheIdx;
//mb //mb
ST64 (&pCurMb->sMv[ kiScan4Idx], kuiMv64); ST64 (&pCurMb->sMv[ kiScan4Idx], kuiMv64);

View File

@@ -45,31 +45,31 @@ namespace WelsEnc {
*/ */
void WelsLoadNal (SWelsEncoderOutput* pEncoderOuput, const int32_t/*EWelsNalUnitType*/ kiType, void WelsLoadNal (SWelsEncoderOutput* pEncoderOuput, const int32_t/*EWelsNalUnitType*/ kiType,
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) { const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) {
SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput; SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput;
SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ pWelsEncoderOuput->iNalIndex ]; SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ pWelsEncoderOuput->iNalIndex ];
SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader; SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader;
const int32_t kiStartPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3); const int32_t kiStartPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3);
sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType; sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType;
sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc; sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc;
sNalUnitHeader->uiForbiddenZeroBit = 0; sNalUnitHeader->uiForbiddenZeroBit = 0;
pRawNal->pRawData = &pWelsEncoderOuput->pBsBuffer[kiStartPos]; pRawNal->pRawData = &pWelsEncoderOuput->pBsBuffer[kiStartPos];
pRawNal->iStartPos = kiStartPos; pRawNal->iStartPos = kiStartPos;
pRawNal->iPayloadSize = 0; pRawNal->iPayloadSize = 0;
} }
/*! /*!
* \brief unload pRawNal NAL * \brief unload pRawNal NAL
*/ */
void WelsUnloadNal (SWelsEncoderOutput* pEncoderOuput) { void WelsUnloadNal (SWelsEncoderOutput* pEncoderOuput) {
SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput; SWelsEncoderOutput* pWelsEncoderOuput = pEncoderOuput;
int32_t* pIdx = &pWelsEncoderOuput->iNalIndex; int32_t* pIdx = &pWelsEncoderOuput->iNalIndex;
SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ *pIdx ]; SWelsNalRaw* pRawNal = &pWelsEncoderOuput->sNalList[ *pIdx ];
const int32_t kiEndPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3); const int32_t kiEndPos = (BsGetBitsPos (&pWelsEncoderOuput->sBsWrite) >> 3);
/* count payload size of pRawNal NAL */ /* count payload size of pRawNal NAL */
pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos; pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos;
++ (*pIdx); ++ (*pIdx);
} }
@@ -79,33 +79,33 @@ void WelsUnloadNal (SWelsEncoderOutput* pEncoderOuput) {
*/ */
void WelsLoadNalForSlice (SWelsSliceBs* pSliceBsIn, const int32_t/*EWelsNalUnitType*/ kiType, void WelsLoadNalForSlice (SWelsSliceBs* pSliceBsIn, const int32_t/*EWelsNalUnitType*/ kiType,
const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) { const int32_t/*EWelsNalRefIdc*/ kiNalRefIdc) {
SWelsSliceBs* pSliceBs = pSliceBsIn; SWelsSliceBs* pSliceBs = pSliceBsIn;
SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ pSliceBs->iNalIndex ]; SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ pSliceBs->iNalIndex ];
SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader; SNalUnitHeader* sNalUnitHeader = &pRawNal->sNalExt.sNalUnitHeader;
SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite; SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite;
const int32_t kiStartPos = (BsGetBitsPos (pBitStringAux) >> 3); const int32_t kiStartPos = (BsGetBitsPos (pBitStringAux) >> 3);
sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType; sNalUnitHeader->eNalUnitType = (EWelsNalUnitType)kiType;
sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc; sNalUnitHeader->uiNalRefIdc = (EWelsNalRefIdc)kiNalRefIdc;
sNalUnitHeader->uiForbiddenZeroBit = 0; sNalUnitHeader->uiForbiddenZeroBit = 0;
pRawNal->pRawData = &pSliceBs->pBsBuffer[kiStartPos]; pRawNal->pRawData = &pSliceBs->pBsBuffer[kiStartPos];
pRawNal->iStartPos = kiStartPos; pRawNal->iStartPos = kiStartPos;
pRawNal->iPayloadSize = 0; pRawNal->iPayloadSize = 0;
} }
/*! /*!
* \brief unload pRawNal NAL * \brief unload pRawNal NAL
*/ */
void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBsIn) { void WelsUnloadNalForSlice (SWelsSliceBs* pSliceBsIn) {
SWelsSliceBs* pSliceBs = pSliceBsIn; SWelsSliceBs* pSliceBs = pSliceBsIn;
int32_t* pIdx = &pSliceBs->iNalIndex; int32_t* pIdx = &pSliceBs->iNalIndex;
SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ *pIdx ]; SWelsNalRaw* pRawNal = &pSliceBs->sNalList[ *pIdx ];
SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite; SBitStringAux* pBitStringAux = &pSliceBs->sBsWrite;
const int32_t kiEndPos = (BsGetBitsPos (pBitStringAux) >> 3); const int32_t kiEndPos = (BsGetBitsPos (pBitStringAux) >> 3);
/* count payload size of pRawNal NAL */ /* count payload size of pRawNal NAL */
pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos; pRawNal->iPayloadSize = kiEndPos - pRawNal->iStartPos;
++ (*pIdx); ++ (*pIdx);
} }
@@ -132,12 +132,12 @@ int32_t WelsEncodeNal (SWelsNalRaw* pRawNal, void* pNalHeaderExt, const int32_t
return ENC_RETURN_MEMALLOCERR; return ENC_RETURN_MEMALLOCERR;
//TODO: call the realloc&copy instead //TODO: call the realloc&copy instead
} }
uint8_t* pDstStart = (uint8_t*)pDst; uint8_t* pDstStart = (uint8_t*)pDst;
uint8_t* pDstPointer = pDstStart; uint8_t* pDstPointer = pDstStart;
uint8_t* pSrcPointer = pRawNal->pRawData; uint8_t* pSrcPointer = pRawNal->pRawData;
uint8_t* pSrcEnd = pRawNal->pRawData + pRawNal->iPayloadSize; uint8_t* pSrcEnd = pRawNal->pRawData + pRawNal->iPayloadSize;
int32_t iZeroCount = 0; int32_t iZeroCount = 0;
int32_t iNalLength = 0; int32_t iNalLength = 0;
*pDstLen = 0; *pDstLen = 0;
static const uint8_t kuiStartCodePrefix[NAL_HEADER_SIZE] = { 0, 0, 0, 1 }; static const uint8_t kuiStartCodePrefix[NAL_HEADER_SIZE] = { 0, 0, 0, 1 };

View File

@@ -54,43 +54,43 @@ SPicture* AllocPicture (CMemoryAlign* pMa, const int32_t kiWidth , const int32_t
int32_t iPicWidth = 0; int32_t iPicWidth = 0;
int32_t iPicHeight = 0; int32_t iPicHeight = 0;
int32_t iPicChromaWidth = 0; int32_t iPicChromaWidth = 0;
int32_t iPicChromaHeight = 0; int32_t iPicChromaHeight = 0;
int32_t iLumaSize = 0; int32_t iLumaSize = 0;
int32_t iChromaSize = 0; int32_t iChromaSize = 0;
pPic = static_cast<SPicture*> (pMa->WelsMallocz (sizeof (SPicture), "pPic")); pPic = static_cast<SPicture*> (pMa->WelsMallocz (sizeof (SPicture), "pPic"));
WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon
iPicHeight = WELS_ALIGN (kiHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical iPicHeight = WELS_ALIGN (kiHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical
iPicChromaWidth = iPicWidth >> 1; iPicChromaWidth = iPicWidth >> 1;
iPicChromaHeight = iPicHeight >> 1; iPicChromaHeight = iPicHeight >> 1;
iPicWidth = WELS_ALIGN (iPicWidth, iPicWidth = WELS_ALIGN (iPicWidth,
32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size 32); // 32(or 16 for chroma below) to match original imp. here instead of cache_line_size
iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16);
iLumaSize = iPicWidth * iPicHeight; iLumaSize = iPicWidth * iPicHeight;
iChromaSize = iPicChromaWidth * iPicChromaHeight; iChromaSize = iPicChromaWidth * iPicChromaHeight;
pPic->pBuffer = (uint8_t*)pMa->WelsMalloc (iLumaSize /* luma */ pPic->pBuffer = (uint8_t*)pMa->WelsMalloc (iLumaSize /* luma */
+ (iChromaSize << 1) /* Cb,Cr */ + (iChromaSize << 1) /* Cb,Cr */
, "pPic->pBuffer"); , "pPic->pBuffer");
WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer, FreePicture (pMa, &pPic)); WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer, FreePicture (pMa, &pPic));
pPic->iLineSize[0] = iPicWidth; pPic->iLineSize[0] = iPicWidth;
pPic->iLineSize[1] = pPic->iLineSize[2] = iPicChromaWidth; pPic->iLineSize[1] = pPic->iLineSize[2] = iPicChromaWidth;
pPic->pData[0] = pPic->pBuffer + (1 + pPic->iLineSize[0]) * PADDING_LENGTH; pPic->pData[0] = pPic->pBuffer + (1 + pPic->iLineSize[0]) * PADDING_LENGTH;
pPic->pData[1] = pPic->pBuffer + iLumaSize + (((1 + pPic->iLineSize[1]) * PADDING_LENGTH) >> 1); pPic->pData[1] = pPic->pBuffer + iLumaSize + (((1 + pPic->iLineSize[1]) * PADDING_LENGTH) >> 1);
pPic->pData[2] = pPic->pBuffer + iLumaSize + iChromaSize + (((1 + pPic->iLineSize[2]) * PADDING_LENGTH) >> 1); pPic->pData[2] = pPic->pBuffer + iLumaSize + iChromaSize + (((1 + pPic->iLineSize[2]) * PADDING_LENGTH) >> 1);
pPic->iWidthInPixel = kiWidth; pPic->iWidthInPixel = kiWidth;
pPic->iHeightInPixel = kiHeight; pPic->iHeightInPixel = kiHeight;
pPic->iFrameNum = -1; pPic->iFrameNum = -1;
pPic->bIsLongRef = false; pPic->bIsLongRef = false;
pPic->iLongTermPicNum = -1; pPic->iLongTermPicNum = -1;
pPic->uiRecieveConfirmed = 0; pPic->uiRecieveConfirmed = 0;
pPic->iMarkFrameNum = -1; pPic->iMarkFrameNum = -1;
if (bNeedMbInfo) { if (bNeedMbInfo) {
const uint32_t kuiCountMbNum = ((15 + kiWidth) >> 4) * ((15 + kiHeight) >> 4); const uint32_t kuiCountMbNum = ((15 + kiWidth) >> 4) * ((15 + kiHeight) >> 4);
@@ -134,22 +134,22 @@ void FreePicture (CMemoryAlign* pMa, SPicture** ppPic) {
pMa->WelsFree (pPic->pBuffer, "pPic->pBuffer"); pMa->WelsFree (pPic->pBuffer, "pPic->pBuffer");
pPic->pBuffer = NULL; pPic->pBuffer = NULL;
} }
pPic->pBuffer = NULL; pPic->pBuffer = NULL;
pPic->pData[0] = pPic->pData[0] =
pPic->pData[1] = pPic->pData[1] =
pPic->pData[2] = NULL; pPic->pData[2] = NULL;
pPic->iLineSize[0] = pPic->iLineSize[0] =
pPic->iLineSize[1] = pPic->iLineSize[1] =
pPic->iLineSize[2] = 0; pPic->iLineSize[2] = 0;
pPic->iWidthInPixel = 0; pPic->iWidthInPixel = 0;
pPic->iHeightInPixel = 0; pPic->iHeightInPixel = 0;
pPic->iFrameNum = -1; pPic->iFrameNum = -1;
pPic->bIsLongRef = false; pPic->bIsLongRef = false;
pPic->uiRecieveConfirmed = 0; pPic->uiRecieveConfirmed = 0;
pPic->iLongTermPicNum = -1; pPic->iLongTermPicNum = -1;
pPic->iMarkFrameNum = -1; pPic->iMarkFrameNum = -1;
if (pPic->uiRefMbType) { if (pPic->uiRefMbType) {
pMa->WelsFree (pPic->uiRefMbType, "pPic->uiRefMbType"); pMa->WelsFree (pPic->uiRefMbType, "pPic->uiRefMbType");

View File

@@ -59,27 +59,27 @@ const int32_t g_kiQpToQstepTable[52] = {
}; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0)) }; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) { void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) {
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiGomSize = pWelsSvcRc->iGomSize; const int32_t kiGomSize = pWelsSvcRc->iGomSize;
const int32_t kiGomSizeD = kiGomSize * sizeof (double); const int32_t kiGomSizeD = kiGomSize * sizeof (double);
const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t); const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t);
const int32_t kiLayerRcSize = kiGomSizeD + (kiGomSizeI * 3) + sizeof (SRCTemporal) * kiMaxTl; const int32_t kiLayerRcSize = kiGomSizeD + (kiGomSizeI * 3) + sizeof (SRCTemporal) * kiMaxTl;
uint8_t* pBaseMem = (uint8_t*)pMA->WelsMalloc (kiLayerRcSize, "pWelsSvcRc->pTemporalOverRc"); uint8_t* pBaseMem = (uint8_t*)pMA->WelsMalloc (kiLayerRcSize, "pWelsSvcRc->pTemporalOverRc");
if (NULL == pBaseMem) if (NULL == pBaseMem)
return; return;
pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem; pWelsSvcRc->pTemporalOverRc = (SRCTemporal*)pBaseMem;
pBaseMem += sizeof (SRCTemporal) * kiMaxTl; pBaseMem += sizeof (SRCTemporal) * kiMaxTl;
pWelsSvcRc->pGomComplexity = (double*)pBaseMem; pWelsSvcRc->pGomComplexity = (double*)pBaseMem;
pBaseMem += kiGomSizeD; pBaseMem += kiGomSizeD;
pWelsSvcRc->pGomForegroundBlockNum = (int32_t*)pBaseMem; pWelsSvcRc->pGomForegroundBlockNum = (int32_t*)pBaseMem;
pBaseMem += kiGomSizeI; pBaseMem += kiGomSizeI;
pWelsSvcRc->pCurrentFrameGomSad = (int32_t*)pBaseMem; pWelsSvcRc->pCurrentFrameGomSad = (int32_t*)pBaseMem;
pBaseMem += kiGomSizeI; pBaseMem += kiGomSizeI;
pWelsSvcRc->pGomCost = (int32_t*)pBaseMem; pWelsSvcRc->pGomCost = (int32_t*)pBaseMem;
pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC"); pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC");
} }
void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) { void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) {
@@ -90,10 +90,10 @@ void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) {
if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) { if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) {
pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc"); pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc");
pWelsSvcRc->pTemporalOverRc = NULL; pWelsSvcRc->pTemporalOverRc = NULL;
pWelsSvcRc->pGomComplexity = NULL; pWelsSvcRc->pGomComplexity = NULL;
pWelsSvcRc->pGomForegroundBlockNum = NULL; pWelsSvcRc->pGomForegroundBlockNum = NULL;
pWelsSvcRc->pCurrentFrameGomSad = NULL; pWelsSvcRc->pCurrentFrameGomSad = NULL;
pWelsSvcRc->pGomCost = NULL; pWelsSvcRc->pGomCost = NULL;
} }
} }
@@ -169,9 +169,9 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pEncCtx->pSvcParam->sDependencyLayers[j].iHighestTemporalId); RcInitLayerMemory (pWelsSvcRc, pEncCtx->pMemAlign, 1 + pEncCtx->pSvcParam->sDependencyLayers[j].iHighestTemporalId);
bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) || bMultiSliceMode = ((SM_RASTER_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
(SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) || (SM_ROWMB_SLICE == pDLayerParam->sSliceCfg.uiSliceMode) ||
(SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode)); (SM_DYN_SLICE == pDLayerParam->sSliceCfg.uiSliceMode));
if (bMultiSliceMode) if (bMultiSliceMode)
pWelsSvcRc->iNumberMbGom = pWelsSvcRc->iNumberMbFrame; pWelsSvcRc->iNumberMbGom = pWelsSvcRc->iNumberMbFrame;
} }
@@ -210,16 +210,16 @@ void RcInitTlWeight (sWelsEncCtx* pEncCtx) {
} }
void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId; const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate, const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate,
pDLayerParamInternal->fOutputFrameRate); pDLayerParamInternal->fOutputFrameRate);
const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize; const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize;
int32_t i; int32_t i;
pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate; pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
@@ -252,9 +252,9 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
void RcInitVGop (sWelsEncCtx* pEncCtx) { void RcInitVGop (sWelsEncCtx* pEncCtx) {
const int32_t kiDid = pEncCtx->uiDependencyId; const int32_t kiDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId; const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
pWelsSvcRc->iRemainingBits = VGOP_SIZE * pWelsSvcRc->iBitsPerFrame; pWelsSvcRc->iRemainingBits = VGOP_SIZE * pWelsSvcRc->iBitsPerFrame;
@@ -269,11 +269,11 @@ void RcInitVGop (sWelsEncCtx* pEncCtx) {
} }
void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) { void RcInitRefreshParameter (sWelsEncCtx* pEncCtx) {
const int32_t kiDid = pEncCtx->uiDependencyId; const int32_t kiDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid]; SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[kiDid];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid]; SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId; const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
int32_t i; int32_t i;
@@ -327,14 +327,14 @@ bool RcJudgeBitrateFpsUpdate (sWelsEncCtx* pEncCtx) {
#if GOM_TRACE_FLAG #if GOM_TRACE_FLAG
void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) { void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) {
const int32_t kiDid = pEncCtx->uiDependencyId; const int32_t kiDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
if (pWelsSvcRc->iFrameCodedInVGop) { if (pWelsSvcRc->iFrameCodedInVGop) {
const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId; const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
int32_t iVGopBitrate = 0; int32_t iVGopBitrate = 0;
int32_t iTotalBits = pWelsSvcRc->iPaddingBitrateStat; int32_t iTotalBits = pWelsSvcRc->iPaddingBitrateStat;
int32_t iTid = 0; int32_t iTid = 0;
while (iTid <= kiHighestTid) { while (iTid <= kiHighestTid) {
iTotalBits += pTOverRc[iTid].iGopBitsDq; iTotalBits += pTOverRc[iTid].iGopBitsDq;
@@ -356,10 +356,10 @@ void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) {
#endif #endif
void RcUpdateTemporalZero (sWelsEncCtx* pEncCtx) { void RcUpdateTemporalZero (sWelsEncCtx* pEncCtx) {
const int32_t kiDid = pEncCtx->uiDependencyId; const int32_t kiDid = pEncCtx->uiDependencyId;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[kiDid];
SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid]; SSpatialLayerInternal* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[kiDid];
const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages); const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages);
if (pWelsSvcRc->iPreviousGopSize != kiGopSize) { if (pWelsSvcRc->iPreviousGopSize != kiGopSize) {
#if GOM_TRACE_FLAG #if GOM_TRACE_FLAG
@@ -389,8 +389,8 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) {
int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}}; int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}};
int32_t iBppIndex = 0; int32_t iBppIndex = 0;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
if (pDLayerParamInternal->fOutputFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight) if (pDLayerParamInternal->fOutputFrameRate > EPSN && pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight)
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParamInternal->fOutputFrameRate * dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParamInternal->fOutputFrameRate *
@@ -438,9 +438,9 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) {
void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
int32_t iTl = pEncCtx->uiTemporalId; int32_t iTl = pEncCtx->uiTemporalId;
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
int32_t iLumaQp = 0; int32_t iLumaQp = 0;
if (0 == pTOverRc->iPFrameNum) { if (0 == pTOverRc->iPFrameNum) {
@@ -515,29 +515,29 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
} }
void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx; SSliceCtx* pCurSliceCtx = pEncCtx->pCurDqLayer->pSliceEncCtx;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iTargetBits) * INT_MULTIPLY, const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iTargetBits) * INT_MULTIPLY,
pWelsSvcRc->iNumberMbFrame); pWelsSvcRc->iNumberMbFrame);
for (int32_t i = 0; i < kiSliceNum; i++) { for (int32_t i = 0; i < kiSliceNum; i++) {
pSOverRc->iStartMbSlice = pSOverRc->iStartMbSlice =
pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i]; pSOverRc->iEndMbSlice = pCurSliceCtx->pFirstMbInSlice[i];
pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1);
pSOverRc->iTotalQpSlice = 0; pSOverRc->iTotalQpSlice = 0;
pSOverRc->iTotalMbSlice = 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->iFrameBitsSlice = 0;
pSOverRc->iGomBitsSlice = 0; pSOverRc->iGomBitsSlice = 0;
++ pSOverRc; ++ pSOverRc;
} }
} }
void RcDecideTargetBits (sWelsEncCtx* pEncCtx) { void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId]; SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId];
pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL; pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL;
//allocate bits //allocate bits
@@ -560,17 +560,17 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
void RcInitGomParameters (sWelsEncCtx* pEncCtx) { void RcInitGomParameters (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiGlobalQp = pEncCtx->iGlobalQp; const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
pWelsSvcRc->iAverageFrameQp = 0; pWelsSvcRc->iAverageFrameQp = 0;
pWelsSvcRc->iMinFrameQp = 51; pWelsSvcRc->iMinFrameQp = 51;
pWelsSvcRc->iMaxFrameQp = 0; pWelsSvcRc->iMaxFrameQp = 0;
for (int32_t i = 0; i < kiSliceNum; ++i) { for (int32_t i = 0; i < kiSliceNum; ++i) {
pSOverRc->iComplexityIndexSlice = 0; pSOverRc->iComplexityIndexSlice = 0;
pSOverRc->iCalculatedQpSlice = kiGlobalQp; pSOverRc->iCalculatedQpSlice = kiGlobalQp;
++ pSOverRc; ++ pSOverRc;
} }
memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double)); memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double));
@@ -579,16 +579,16 @@ void RcInitGomParameters (sWelsEncCtx* pEncCtx) {
void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId) { void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
int32_t iLumaQp = pSOverRc->iCalculatedQpSlice; int32_t iLumaQp = pSOverRc->iCalculatedQpSlice;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) { if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp + iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp +
pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51); pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51);
} }
pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)]; pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)];
pCurMb->uiLumaQp = iLumaQp; pCurMb->uiLumaQp = iLumaQp;
} }
SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) { SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) {
@@ -615,15 +615,15 @@ SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) {
} }
void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SWelsSvcRc* pWelsSvcRc_Base = NULL; SWelsSvcRc* pWelsSvcRc_Base = NULL;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
int32_t iAllocateBits = 0; int32_t iAllocateBits = 0;
int32_t iSumSad = 0; int32_t iSumSad = 0;
int32_t iLastGomIndex = 0; int32_t iLastGomIndex = 0;
int32_t iLeftBits = 0; int32_t iLeftBits = 0;
const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
int32_t i; int32_t i;
iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom; iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;
@@ -653,8 +653,8 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];
int64_t iBitsRatio = 1; int64_t iBitsRatio = 1;
int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice; int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
@@ -953,9 +953,9 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
} }
void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
const int32_t kiTl = pEncCtx->uiTemporalId; const int32_t kiTl = pEncCtx->uiTemporalId;
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl]; SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
if (0 == pTOverRc->iPFrameNum) { if (0 == pTOverRc->iPFrameNum) {
pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep; pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;
@@ -1046,11 +1046,11 @@ void WelsRcPictureInfoUpdateGom (sWelsEncCtx* pEncCtx, int32_t iLayerSize) {
} }
void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) { void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
const int32_t kiSliceId = pSlice->uiSliceIdx; const int32_t kiSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
SBitStringAux* bs = pSlice->pSliceBsa; SBitStringAux* bs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
pSOverRc->iBsPosSlice = BsGetBitsPos (bs); pSOverRc->iBsPosSlice = BsGetBitsPos (bs);
@@ -1073,11 +1073,11 @@ void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
} }
void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) { void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SBitStringAux* bs = pSlice->pSliceBsa; SBitStringAux* bs = pSlice->pSliceBsa;
int32_t iSliceId = pSlice->uiSliceIdx; int32_t iSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];
const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice; int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;
pSOverRc->iFrameBitsSlice += iCurMbBits; pSOverRc->iFrameBitsSlice += iCurMbBits;
@@ -1344,15 +1344,15 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
} }
} else { } else {
int32_t iTl = pEncCtx->uiTemporalId; int32_t iTl = pEncCtx->uiTemporalId;
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
int32_t iMaxTh = static_cast<int32_t> (pWelsSvcRc->iBufferSizeSkip - pWelsSvcRc->iBufferFullnessSkip); int32_t iMaxTh = static_cast<int32_t> (pWelsSvcRc->iBufferSizeSkip - pWelsSvcRc->iBufferFullnessSkip);
int32_t iMinTh = iMaxTh / (iTl + 2); int32_t iMinTh = iMaxTh / (iTl + 2);
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
int32_t iAverageFrameSize = (int32_t) ((double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate)); int32_t iAverageFrameSize = (int32_t) ((double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate));
const int32_t kiGopBits = iAverageFrameSize * kiGopSize; const int32_t kiGopBits = iAverageFrameSize * kiGopSize;
int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY, int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
pTOverRc->iFrameCmplxMean); pTOverRc->iFrameCmplxMean);
iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE); iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);

View File

@@ -191,8 +191,8 @@ static inline void DeleteInvalidLTR (sWelsEncCtx* pCtx) {
* handle LTR Mark feedback message * handle LTR Mark feedback message
*/ */
static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) { static inline void HandleLTRMarkFeedback (sWelsEncCtx* pCtx) {
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
SPicture** pLongRefList = pRefList->pLongRefList; SPicture** pLongRefList = pRefList->pLongRefList;
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
int32_t i, j; int32_t i, j;
@@ -323,8 +323,8 @@ static inline void LTRMarkProcessScreen (sWelsEncCtx* pCtx) {
} }
static void PrefetchNextBuffer (sWelsEncCtx* pCtx) { static void PrefetchNextBuffer (sWelsEncCtx* pCtx) {
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame;
int32_t i; int32_t i;
pRefList->pNextBuffer = NULL; pRefList->pNextBuffer = NULL;
@@ -347,14 +347,14 @@ static void PrefetchNextBuffer (sWelsEncCtx* pCtx) {
* update reference picture list * update reference picture list
*/ */
bool WelsUpdateRefList (sWelsEncCtx* pCtx) { bool WelsUpdateRefList (sWelsEncCtx* pCtx) {
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
int32_t iRefIdx = 0; int32_t iRefIdx = 0;
const uint8_t kuiTid = pCtx->uiTemporalId; const uint8_t kuiTid = pCtx->uiTemporalId;
const uint8_t kuiDid = pCtx->uiDependencyId; const uint8_t kuiDid = pCtx->uiDependencyId;
const EWelsSliceType keSliceType = pCtx->eSliceType; const EWelsSliceType keSliceType = pCtx->eSliceType;
uint32_t i = 0; uint32_t i = 0;
// Need update pRef list in case store base layer or target dependency layer construction // Need update pRef list in case store base layer or target dependency layer construction
if (NULL == pCtx->pCurDqLayer) if (NULL == pCtx->pCurDqLayer)
@@ -374,11 +374,11 @@ bool WelsUpdateRefList (sWelsEncCtx* pCtx) {
// move picture in list // move picture in list
pCtx->pDecPic->uiTemporalId = kuiTid; pCtx->pDecPic->uiTemporalId = kuiTid;
pCtx->pDecPic->uiSpatialId = kuiDid; pCtx->pDecPic->uiSpatialId = kuiDid;
pCtx->pDecPic->iFrameNum = pCtx->iFrameNum; pCtx->pDecPic->iFrameNum = pCtx->iFrameNum;
pCtx->pDecPic->iFramePoc = pCtx->iPOC; pCtx->pDecPic->iFramePoc = pCtx->iPOC;
pCtx->pDecPic->uiRecieveConfirmed = RECIEVE_UNKOWN; pCtx->pDecPic->uiRecieveConfirmed = RECIEVE_UNKOWN;
pCtx->pDecPic->bUsedAsRef = true; pCtx->pDecPic->bUsedAsRef = true;
for (iRefIdx = pRefList->uiShortRefCount - 1; iRefIdx >= 0; --iRefIdx) { for (iRefIdx = pRefList->uiShortRefCount - 1; iRefIdx >= 0; --iRefIdx) {
pRefList->pShortRefList[iRefIdx + 1] = pRefList->pShortRefList[iRefIdx]; pRefList->pShortRefList[iRefIdx + 1] = pRefList->pShortRefList[iRefIdx];
@@ -467,9 +467,9 @@ void WelsMarkPic (sWelsEncCtx* pCtx) {
} }
for (iSliceIdx = 0; iSliceIdx < kiCountSliceNum; iSliceIdx++) { for (iSliceIdx = 0; iSliceIdx < kiCountSliceNum; iSliceIdx++) {
SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt;
SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader;
SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking;
memset (pRefPicMark, 0, sizeof (SRefPicMarking)); memset (pRefPicMark, 0, sizeof (SRefPicMarking));
@@ -555,11 +555,11 @@ void FilterLTRMarkingFeedback (sWelsEncCtx* pCtx, SLTRMarkingFeedback* pLTRMarki
* build reference picture list * build reference picture list
*/ */
bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) { bool WelsBuildRefList (sWelsEncCtx* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) {
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame;
const uint8_t kuiTid = pCtx->uiTemporalId; const uint8_t kuiTid = pCtx->uiTemporalId;
uint32_t i = 0; uint32_t i = 0;
// to support any type of cur_dq->mgs_control // to support any type of cur_dq->mgs_control
// [ 0: using current layer to do ME/MC; // [ 0: using current layer to do ME/MC;
@@ -627,9 +627,9 @@ static void UpdateBlockStatic (sWelsEncCtx* pCtx) {
*/ */
void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) { void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) {
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
int32_t iIdx = 0; int32_t iIdx = 0;
const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); const int32_t kiCountSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
int32_t iAbsDiffPicNumMinus1 = -1; int32_t iAbsDiffPicNumMinus1 = -1;
assert (kiCountSliceNum > 0); assert (kiCountSliceNum > 0);
@@ -638,10 +638,10 @@ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t u
iAbsDiffPicNumMinus1 = pCtx->iFrameNum - (pCtx->pRefList0[0]->iFrameNum) - 1; iAbsDiffPicNumMinus1 = pCtx->iFrameNum - (pCtx->pRefList0[0]->iFrameNum) - 1;
for (iIdx = 0; iIdx < kiCountSliceNum; iIdx++) { for (iIdx = 0; iIdx < kiCountSliceNum; iIdx++) {
SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt; SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt;
SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader;
SRefPicListReorderSyntax* pRefReorder = &pSliceHdr->sRefReordering; SRefPicListReorderSyntax* pRefReorder = &pSliceHdr->sRefReordering;
SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking;
/*syntax for num_ref_idx_l0_active_minus1*/ /*syntax for num_ref_idx_l0_active_minus1*/
pSliceHdr->uiRefCount = pCtx->iNumRef0; pSliceHdr->uiRefCount = pCtx->iNumRef0;
@@ -713,10 +713,10 @@ static void UpdateSrcPicList (sWelsEncCtx* pCtx) {
} }
bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) { bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) {
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId]; SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId]; SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
const uint8_t kuiTid = pCtx->uiTemporalId; const uint8_t kuiTid = pCtx->uiTemporalId;
// Need update ref list in case store base layer or target dependency layer construction // Need update ref list in case store base layer or target dependency layer construction
if (NULL == pCtx->pCurDqLayer) if (NULL == pCtx->pCurDqLayer)
return false; return false;
@@ -734,13 +734,13 @@ bool WelsUpdateRefListScreen (sWelsEncCtx* pCtx) {
pCtx->pFuncList->sExpandPicFunc.pfExpandLumaPicture, pCtx->pFuncList->sExpandPicFunc.pfExpandChromaPicture); pCtx->pFuncList->sExpandPicFunc.pfExpandLumaPicture, pCtx->pFuncList->sExpandPicFunc.pfExpandChromaPicture);
// move picture in list // move picture in list
pCtx->pDecPic->uiTemporalId = pCtx->uiTemporalId; pCtx->pDecPic->uiTemporalId = pCtx->uiTemporalId;
pCtx->pDecPic->uiSpatialId = pCtx->uiDependencyId; pCtx->pDecPic->uiSpatialId = pCtx->uiDependencyId;
pCtx->pDecPic->iFrameNum = pCtx->iFrameNum; pCtx->pDecPic->iFrameNum = pCtx->iFrameNum;
pCtx->pDecPic->iFramePoc = pCtx->iPOC; pCtx->pDecPic->iFramePoc = pCtx->iPOC;
pCtx->pDecPic->bUsedAsRef = true; pCtx->pDecPic->bUsedAsRef = true;
pCtx->pDecPic->bIsLongRef = true; pCtx->pDecPic->bIsLongRef = true;
pCtx->pDecPic->bIsSceneLTR = pLtr->bLTRMarkingFlag || (pCtx->pSvcParam->bEnableLongTermReference pCtx->pDecPic->bIsSceneLTR = pLtr->bLTRMarkingFlag || (pCtx->pSvcParam->bEnableLongTermReference
&& pCtx->eSliceType == I_SLICE); && pCtx->eSliceType == I_SLICE);
pCtx->pDecPic->iLongTermPicNum = pLtr->iCurLtrIdx; pCtx->pDecPic->iLongTermPicNum = pLtr->iCurLtrIdx;
} }
@@ -919,9 +919,9 @@ void WelsMarkPicScreen (sWelsEncCtx* pCtx) {
const int32_t iMaxLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1; const int32_t iMaxLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1;
const int32_t iSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); const int32_t iSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
for (int32_t iSliceIdx = 0; iSliceIdx < iSliceNum; iSliceIdx++) { for (int32_t iSliceIdx = 0; iSliceIdx < iSliceNum; iSliceIdx++) {
SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt; SSliceHeaderExt* pSliceHdrExt = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt;
SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader; SSliceHeader* pSliceHdr = &pSliceHdrExt->sSliceHeader;
SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking; SRefPicMarking* pRefPicMark = &pSliceHdr->sRefMarking;
memset (pRefPicMark, 0, sizeof (SRefPicMarking)); memset (pRefPicMark, 0, sizeof (SRefPicMarking));
if (pCtx->pSvcParam->bEnableLongTermReference) { if (pCtx->pSvcParam->bEnableLongTermReference) {

View File

@@ -233,18 +233,18 @@ int32_t WriteBlockResidualCavlc (SWelsFuncPtrList* pFuncList, int16_t* pCoffLev
void StashMBStatusCavlc (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun) { void StashMBStatusCavlc (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun) {
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
pDss->pBsStackBufPtr = pBs->pCurBuf; pDss->pBsStackBufPtr = pBs->pCurBuf;
pDss->uiBsStackCurBits = pBs->uiCurBits; pDss->uiBsStackCurBits = pBs->uiCurBits;
pDss->iBsStackLeftBits = pBs->iLeftBits; pDss->iBsStackLeftBits = pBs->iLeftBits;
pDss->uiLastMbQp = pSlice->uiLastMbQp; pDss->uiLastMbQp = pSlice->uiLastMbQp;
pDss->iMbSkipRunStack = iMbSkipRun; pDss->iMbSkipRunStack = iMbSkipRun;
} }
int32_t StashPopMBStatusCavlc (SDynamicSlicingStack* pDss, SSlice* pSlice) { int32_t StashPopMBStatusCavlc (SDynamicSlicingStack* pDss, SSlice* pSlice) {
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
pBs->pCurBuf = pDss->pBsStackBufPtr; pBs->pCurBuf = pDss->pBsStackBufPtr;
pBs->uiCurBits = pDss->uiBsStackCurBits; pBs->uiCurBits = pDss->uiBsStackCurBits;
pBs->iLeftBits = pDss->iBsStackLeftBits; pBs->iLeftBits = pDss->iBsStackLeftBits;
pSlice->uiLastMbQp = pDss->uiLastMbQp; pSlice->uiLastMbQp = pDss->uiLastMbQp;
return pDss->iMbSkipRunStack; return pDss->iMbSkipRunStack;
} }
void StashMBStatusCabac (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun) { void StashMBStatusCabac (SDynamicSlicingStack* pDss, SSlice* pSlice, int32_t iMbSkipRun) {

View File

@@ -73,17 +73,17 @@ namespace WelsEnc {
void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,
SMB* pMbList, SMB* pMbList,
const int32_t uiSliceIdc) { const int32_t uiSliceIdc) {
const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap;
const int32_t kiMbWidth = pSliceCtx->iMbWidth; const int32_t kiMbWidth = pSliceCtx->iMbWidth;
int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc];
const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1;
do { do {
SMB* pMb = &pMbList[iIdx]; SMB* pMb = &pMbList[iIdx];
uint32_t uiNeighborAvailFlag = 0; uint32_t uiNeighborAvailFlag = 0;
const int32_t kiMbXY = pMb->iMbXY; const int32_t kiMbXY = pMb->iMbXY;
const int32_t kiMbX = pMb->iMbX; const int32_t kiMbX = pMb->iMbX;
const int32_t kiMbY = pMb->iMbY; const int32_t kiMbY = pMb->iMbY;
bool bLeft; bool bLeft;
bool bTop; bool bTop;
bool bLeftTop; bool bLeftTop;
@@ -112,21 +112,21 @@ void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,
if (bRightTop) { if (bRightTop) {
uiNeighborAvailFlag |= TOPRIGHT_MB_POS; uiNeighborAvailFlag |= TOPRIGHT_MB_POS;
} }
pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag; pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag;
pMb->uiSliceIdc = uiSliceIdc; pMb->uiSliceIdc = uiSliceIdc;
++ iIdx; ++ iIdx;
} while (iIdx <= kiEndMbInSlice); } while (iIdx <= kiEndMbInSlice);
} }
void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) { void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) {
int32_t* pRatioList = (int32_t*)pRatio; int32_t* pRatioList = (int32_t*)pRatio;
int32_t iAvI[MAX_SLICES_NUM]; int32_t iAvI[MAX_SLICES_NUM];
int32_t iSumAv = 0; int32_t iSumAv = 0;
uint32_t* pSliceTime = (uint32_t*)pSliceConsume; uint32_t* pSliceTime = (uint32_t*)pSliceConsume;
int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice; int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice;
const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame;
int32_t iSliceIdx = 0; int32_t iSliceIdx = 0;
WelsEmms(); WelsEmms();
@@ -145,10 +145,10 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice
} }
int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
uint32_t* pSliceConsume = (uint32_t*)pConsumeTime; uint32_t* pSliceConsume = (uint32_t*)pConsumeTime;
uint32_t uiTotalConsume = 0; uint32_t uiTotalConsume = 0;
int32_t iSliceIdx = 0; int32_t iSliceIdx = 0;
int32_t iNeedAdj = false; int32_t iNeedAdj = false;
WelsEmms(); WelsEmms();
@@ -164,9 +164,9 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
} }
iSliceIdx = 0; iSliceIdx = 0;
float fThr = EPSN; // threshold for various cores cases float fThr = EPSN; // threshold for various cores cases
float fRmse = .0f; // root mean square error of pSlice consume ratios float fRmse = .0f; // root mean square error of pSlice consume ratios
const float kfMeanRatio = 1.0f / iSliceNum; const float kfMeanRatio = 1.0f / iSliceNum;
do { do {
const float fRatio = 1.0f * pSliceConsume[iSliceIdx] / uiTotalConsume; const float fRatio = 1.0f * pSliceConsume[iSliceIdx] / uiTotalConsume;
const float fDiffRatio = fRatio - kfMeanRatio; const float fDiffRatio = fRatio - kfMeanRatio;
@@ -195,15 +195,15 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
SDqLayer* pCurDqLayer, SDqLayer* pCurDqLayer,
void* pComplexRatio, void* pComplexRatio,
int32_t iCurDid) { int32_t iCurDid) {
SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx;
const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;
const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;
int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
int32_t iMaximalMbNum = 0; // dynamically assign later int32_t iMaximalMbNum = 0; // dynamically assign later
int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio; int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio;
int32_t iMbNumLeft = kiCountNumMb; int32_t iMbNumLeft = kiCountNumMb;
int32_t iRunLen[MAX_THREADS_NUM] = {0}; int32_t iRunLen[MAX_THREADS_NUM] = {0};
int32_t iSliceIdx = 0; int32_t iSliceIdx = 0;
int32_t iNumMbInEachGom = 0; int32_t iNumMbInEachGom = 0;
SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[iCurDid]; SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[iCurDid];
@@ -271,8 +271,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) { if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) {
const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum;
int32_t iThreadIdx = 0; int32_t iThreadIdx = 0;
do { do {
WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]); WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]); WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
@@ -286,16 +286,16 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen, int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen,
const int32_t iTargetSpatialBsSize) { const int32_t iTargetSpatialBsSize) {
CMemoryAlign* pMa = NULL; CMemoryAlign* pMa = NULL;
SWelsSvcCodingParam* pPara = NULL; SWelsSvcCodingParam* pPara = NULL;
SSliceThreading* pSmt = NULL; SSliceThreading* pSmt = NULL;
SWelsSliceBs* pSliceB = NULL; SWelsSliceBs* pSliceB = NULL;
uint8_t* pBsBase = NULL; uint8_t* pBsBase = NULL;
int32_t iNumSpatialLayers = 0; int32_t iNumSpatialLayers = 0;
int32_t iThreadNum = 0; int32_t iThreadNum = 0;
int32_t iIdx = 0; int32_t iIdx = 0;
int32_t iSliceBsBufferSize = 0; int32_t iSliceBsBufferSize = 0;
int16_t iMaxSliceNum = 1; int16_t iMaxSliceNum = 1;
int32_t iReturn = ENC_RETURN_SUCCESS; int32_t iReturn = ENC_RETURN_SUCCESS;
if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0) if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)
@@ -333,8 +333,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx)) WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx))
} else { } else {
pSmt->pSliceConsumeTime[iIdx] = NULL; pSmt->pSliceConsumeTime[iIdx] = NULL;
pSmt->pSliceComplexRatio[iIdx] = NULL; pSmt->pSliceComplexRatio[iIdx] = NULL;
} }
++ iIdx; ++ iIdx;
} }
@@ -358,10 +358,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
iIdx = 0; iIdx = 0;
while (iIdx < iThreadNum) { while (iIdx < iThreadNum) {
pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx; pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx;
pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx; pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;
pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;
pSmt->pThreadHandles[iIdx] = 0; pSmt->pThreadHandles[iIdx] = 0;
WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name); err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name);
@@ -395,9 +395,9 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
(*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs"); (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx)) WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx))
pBsBase = (*ppCtx)->pFrameBs + iCountBsLen; pBsBase = (*ppCtx)->pFrameBs + iCountBsLen;
pSliceB = (*ppCtx)->pSliceBs; pSliceB = (*ppCtx)->pSliceBs;
iSliceBsBufferSize = iTargetSpatialBsSize; iSliceBsBufferSize = iTargetSpatialBsSize;
iIdx = 0; iIdx = 0;
while (iIdx < iMaxSliceNum) { while (iIdx < iMaxSliceNum) {
pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer"); pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer");
@@ -406,12 +406,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
pSliceB->uiSize = iSliceBsBufferSize; pSliceB->uiSize = iSliceBsBufferSize;
if (iIdx > 0) { if (iIdx > 0) {
pSliceB->pBs = pBsBase; pSliceB->pBs = pBsBase;
pSliceB->uiBsPos = 0; pSliceB->uiBsPos = 0;
pBsBase += iSliceBsBufferSize; pBsBase += iSliceBsBufferSize;
} else { } else {
pSliceB->pBs = NULL; pSliceB->pBs = NULL;
pSliceB->uiBsPos = 0; pSliceB->uiBsPos = 0;
} }
++ pSliceB; ++ pSliceB;
++ iIdx; ++ iIdx;
@@ -431,22 +431,22 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
} }
void ReleaseMtResource (sWelsEncCtx** ppCtx) { void ReleaseMtResource (sWelsEncCtx** ppCtx) {
SWelsSliceBs* pSliceB = NULL; SWelsSliceBs* pSliceB = NULL;
SWelsSvcCodingParam* pCodingParam = NULL; SWelsSvcCodingParam* pCodingParam = NULL;
SSliceThreading* pSmt = NULL; SSliceThreading* pSmt = NULL;
CMemoryAlign* pMa = NULL; CMemoryAlign* pMa = NULL;
int32_t iIdx = 0; int32_t iIdx = 0;
int32_t iThreadNum = 0; int32_t iThreadNum = 0;
int16_t uiSliceNum = 0; int16_t uiSliceNum = 0;
if (NULL == ppCtx || NULL == *ppCtx) if (NULL == ppCtx || NULL == *ppCtx)
return; return;
pMa = (*ppCtx)->pMemAlign; pMa = (*ppCtx)->pMemAlign;
pCodingParam = (*ppCtx)->pSvcParam; pCodingParam = (*ppCtx)->pSvcParam;
uiSliceNum = (*ppCtx)->iMaxSliceCount; uiSliceNum = (*ppCtx)->iMaxSliceCount;
iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum; iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum;
pSmt = (*ppCtx)->pSliceThreading; pSmt = (*ppCtx)->pSliceThreading;
if (NULL == pSmt) if (NULL == pSmt)
return; return;
@@ -520,19 +520,19 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) {
} }
int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) { int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) {
SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];
SWelsSliceBs* pSliceBs = NULL; SWelsSliceBs* pSliceBs = NULL;
const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE); const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE);
int32_t iLayerSize = 0; int32_t iLayerSize = 0;
int32_t iNalIdxBase = pLbi->iNalCount; int32_t iNalIdxBase = pLbi->iNalCount;
int32_t iSliceIdx = 0; int32_t iSliceIdx = 0;
if (!kbIsDynamicSlicingMode) { if (!kbIsDynamicSlicingMode) {
pSliceBs = &pCtx->pSliceBs[0]; pSliceBs = &pCtx->pSliceBs[0];
iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first
iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1 iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1
while (iSliceIdx < iSliceCount) { while (iSliceIdx < iSliceCount) {
++ pSliceBs; ++ pSliceBs;
if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
@@ -552,14 +552,14 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
++ iNalIdx; ++ iNalIdx;
} }
pLbi->iNalCount += iCountNal; pLbi->iNalCount += iCountNal;
iNalIdxBase += iCountNal; iNalIdxBase += iCountNal;
} }
++ iSliceIdx; ++ iSliceIdx;
} }
} else { // for SM_DYN_SLICE } else { // for SM_DYN_SLICE
const int32_t kiPartitionCnt = iSliceCount; const int32_t kiPartitionCnt = iSliceCount;
int32_t iPartitionIdx = 0; int32_t iPartitionIdx = 0;
// due partition_0 has been written to pFrameBsBuffer // due partition_0 has been written to pFrameBsBuffer
// so iLayerSize need add it // so iLayerSize need add it
@@ -584,8 +584,8 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx]; pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
++ iNalIdx; ++ iNalIdx;
} }
pLbi->iNalCount += iCountNal; pLbi->iNalCount += iCountNal;
iNalIdxBase += iCountNal; iNalIdxBase += iCountNal;
} else { } else {
iLayerSize += pSliceBs->uiBsPos; iLayerSize += pSliceBs->uiBsPos;
} }
@@ -603,17 +603,17 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32
int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx, int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx,
int32_t& iSliceSize) { int32_t& iSliceSize) {
SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
uint8_t* pDst = pFrameBsBuffer; uint8_t* pDst = pFrameBsBuffer;
const int32_t kiNalCnt = pSliceBs->iNalIndex; const int32_t kiNalCnt = pSliceBs->iNalIndex;
int32_t iNalIdx = 0; int32_t iNalIdx = 0;
int32_t iNalSize = 0; int32_t iNalSize = 0;
const int32_t iFirstSlice = (iSliceIdx == 0); const int32_t iFirstSlice = (iSliceIdx == 0);
int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount; int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount;
int32_t iReturn = ENC_RETURN_SUCCESS; int32_t iReturn = ENC_RETURN_SUCCESS;
const int32_t kiWrittenLength = pCtx->iPosBsBuffer; const int32_t kiWrittenLength = pCtx->iPosBsBuffer;
iSliceSize = 0; iSliceSize = 0;
while (iNalIdx < kiNalCnt) { while (iNalIdx < kiNalCnt) {
iNalSize = 0; iNalSize = 0;
@@ -630,26 +630,26 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr
pSliceBs->uiBsPos = iSliceSize; pSliceBs->uiBsPos = iSliceSize;
if (iFirstSlice) { if (iFirstSlice) {
// pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread() // pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread()
pLbi->uiLayerType = VIDEO_CODING_LAYER; pLbi->uiLayerType = VIDEO_CODING_LAYER;
pLbi->uiSpatialId = pNalHdrExt->uiDependencyId; pLbi->uiSpatialId = pNalHdrExt->uiDependencyId;
pLbi->uiTemporalId = pNalHdrExt->uiTemporalId; pLbi->uiTemporalId = pNalHdrExt->uiTemporalId;
pLbi->uiQualityId = 0; pLbi->uiQualityId = 0;
pLbi->iNalCount = kiNalCnt; pLbi->iNalCount = kiNalCnt;
} else { } else {
pLbi->iNalCount += kiNalCnt; pLbi->iNalCount += kiNalCnt;
} }
return ENC_RETURN_SUCCESS; return ENC_RETURN_SUCCESS;
} }
int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) { int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) {
SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx]; SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt; SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
uint8_t* pDst = pSliceBsBuf; uint8_t* pDst = pSliceBsBuf;
int32_t* pNalLen = &pSliceBs->iNalLen[0]; int32_t* pNalLen = &pSliceBs->iNalLen[0];
const int32_t kiNalCnt = pSliceBs->iNalIndex; const int32_t kiNalCnt = pSliceBs->iNalIndex;
int32_t iNalIdx = 0; int32_t iNalIdx = 0;
int32_t iNalSize = 0; int32_t iNalSize = 0;
int32_t iReturn = ENC_RETURN_SUCCESS; int32_t iReturn = ENC_RETURN_SUCCESS;
const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf); const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf);
@@ -675,34 +675,34 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl
// thread process for coding one pSlice // thread process for coding one pSlice
WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg; SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
sWelsEncCtx* pEncPEncCtx = NULL; sWelsEncCtx* pEncPEncCtx = NULL;
SDqLayer* pCurDq = NULL; SDqLayer* pCurDq = NULL;
SSlice* pSlice = NULL; SSlice* pSlice = NULL;
SWelsSliceBs* pSliceBs = NULL; SWelsSliceBs* pSliceBs = NULL;
WELS_EVENT pEventsList[3]; WELS_EVENT pEventsList[3];
int32_t iEventCount = 0; int32_t iEventCount = 0;
WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL; WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL;
uint32_t uiThrdRet = 0; uint32_t uiThrdRet = 0;
int32_t iSliceSize = 0; int32_t iSliceSize = 0;
int32_t iSliceIdx = -1; int32_t iSliceIdx = -1;
int32_t iThreadIdx = -1; int32_t iThreadIdx = -1;
int32_t iEventIdx = -1; int32_t iEventIdx = -1;
bool bNeedPrefix = false; bool bNeedPrefix = false;
EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0; EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0;
EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST; EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST;
int32_t iReturn = ENC_RETURN_SUCCESS; int32_t iReturn = ENC_RETURN_SUCCESS;
if (NULL == pPrivateData) if (NULL == pPrivateData)
WELS_THREAD_ROUTINE_RETURN (1); WELS_THREAD_ROUTINE_RETURN (1);
pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx; pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx;
iThreadIdx = pPrivateData->iThreadIndex; iThreadIdx = pPrivateData->iThreadIndex;
iEventIdx = iThreadIdx; iEventIdx = iThreadIdx;
pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx]; pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx];
pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx]; pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx];
pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx]; pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx];
WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc"); WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc");
@@ -716,32 +716,32 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
&pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled
if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
SLayerBSInfo* pLbi = pPrivateData->pLayerBs; SLayerBSInfo* pLbi = pPrivateData->pLayerBs;
const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; const int32_t kiCurTid = pEncPEncCtx->uiTemporalId;
SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam; SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid]; SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid];
pCurDq = pEncPEncCtx->pCurDqLayer; pCurDq = pEncPEncCtx->pCurDqLayer;
eNalType = pEncPEncCtx->eNalType; eNalType = pEncPEncCtx->eNalType;
eNalRefIdc = pEncPEncCtx->eNalPriority; eNalRefIdc = pEncPEncCtx->eNalPriority;
bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag;
if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) { if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) {
int64_t iSliceStart = 0; int64_t iSliceStart = 0;
bool bDsaFlag = false; bool bDsaFlag = false;
iSliceIdx = pPrivateData->iSliceIndex; iSliceIdx = pPrivateData->iSliceIndex;
pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE) bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
|| (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) && || (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) &&
pCodingParam->iMultipleThreadIdc > 1 && pCodingParam->iMultipleThreadIdc > 1 &&
pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum); pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
if (bDsaFlag) if (bDsaFlag)
iSliceStart = WelsTime(); iSliceStart = WelsTime();
pSliceBs->uiBsPos = 0; pSliceBs->uiBsPos = 0;
pSliceBs->iNalIndex = 0; pSliceBs->iNalIndex = 0;
assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa); assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa);
InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
@@ -825,21 +825,21 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
WelsEventSignal ( WelsEventSignal (
&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
} else { // for SM_DYN_SLICE parallelization } else { // for SM_DYN_SLICE parallelization
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
const int32_t kiPartitionId = iThreadIdx; const int32_t kiPartitionId = iThreadIdx;
const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum;
const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive
const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive
int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;
iSliceIdx = pPrivateData->iSliceIndex; iSliceIdx = pPrivateData->iSliceIndex;
pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition; pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition;
pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside
pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1;
pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0;
while (iAnyMbLeftInPartition > 0) { while (iAnyMbLeftInPartition > 0) {
if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) {
@@ -849,11 +849,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
break; break;
} }
pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
pSliceBs->uiBsPos = 0; pSliceBs->uiBsPos = 0;
pSliceBs->iNalIndex = 0; pSliceBs->iNalIndex = 0;
InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize); InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
if (bNeedPrefix) { if (bNeedPrefix) {
@@ -978,8 +978,8 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) {
int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList,
WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi, WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi,
const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) { const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) {
int32_t iEndMbIdx = 0; int32_t iEndMbIdx = 0;
int32_t iIdx = 0; int32_t iIdx = 0;
const int32_t kiEventCnt = uiNumThreads; const int32_t kiEventCnt = uiNumThreads;
if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) {
@@ -993,10 +993,10 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData,
if (bIsDynamicSlicingMode) { if (bIsDynamicSlicingMode) {
iEndMbIdx = pSliceCtx->iMbNumInFrame; iEndMbIdx = pSliceCtx->iMbNumInFrame;
for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) {
const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx]; const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx];
pPriData[iIdx].iStartMbIndex = iFirstMbIdx; pPriData[iIdx].iStartMbIndex = iFirstMbIdx;
pPriData[iIdx].iEndMbIndex = iEndMbIdx; pPriData[iIdx].iEndMbIndex = iEndMbIdx;
iEndMbIdx = iFirstMbIdx; iEndMbIdx = iFirstMbIdx;
} }
} }
@@ -1021,8 +1021,8 @@ int32_t DynamicDetectCpuCores() {
} }
int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) {
SDqLayer* pCurDq = pCtx->ppDqLayerList[0]; SDqLayer* pCurDq = pCtx->ppDqLayerList[0];
int32_t iNeedAdj = 1; int32_t iNeedAdj = 1;
#ifdef MT_DEBUG #ifdef MT_DEBUG
int64_t iT0 = WelsTime(); int64_t iT0 = WelsTime();
#endif//MT_DEBUG #endif//MT_DEBUG
@@ -1121,10 +1121,10 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t
pPara = pCtx->pSvcParam; pPara = pCtx->pSvcParam;
while (iSpatialIdx < iSpatialNum) { while (iSpatialIdx < iSpatialNum) {
const int32_t kiDid = pDidList[iSpatialIdx]; const int32_t kiDid = pDidList[iSpatialIdx];
SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid];
SSliceConfig* pMso = &pDlp->sSliceCfg; SSliceConfig* pMso = &pDlp->sSliceCfg;
SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
if (pCtx->pSliceThreading) { if (pCtx->pSliceThreading) {

View File

@@ -269,41 +269,41 @@ void WelsMdIntraInit (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, con
int32_t iStrideY, iStrideUV; int32_t iStrideY, iStrideUV;
int32_t iOffsetY, iOffsetUV; int32_t iOffsetY, iOffsetUV;
iStrideY = pCurLayer->iEncStride[0]; iStrideY = pCurLayer->iEncStride[0];
iStrideUV = pCurLayer->iEncStride[1]; iStrideUV = pCurLayer->iEncStride[1];
iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; iOffsetY = (kiMbX + kiMbY * iStrideY) << 4;
iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3;
pMbCache->SPicData.pEncMb[0] = pCurLayer->pEncData[0] + iOffsetY; pMbCache->SPicData.pEncMb[0] = pCurLayer->pEncData[0] + iOffsetY;
pMbCache->SPicData.pEncMb[1] = pCurLayer->pEncData[1] + iOffsetUV; pMbCache->SPicData.pEncMb[1] = pCurLayer->pEncData[1] + iOffsetUV;
pMbCache->SPicData.pEncMb[2] = pCurLayer->pEncData[2] + iOffsetUV; pMbCache->SPicData.pEncMb[2] = pCurLayer->pEncData[2] + iOffsetUV;
iStrideY = pCurLayer->iCsStride[0]; iStrideY = pCurLayer->iCsStride[0];
iStrideUV = pCurLayer->iCsStride[1]; iStrideUV = pCurLayer->iCsStride[1];
iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; iOffsetY = (kiMbX + kiMbY * iStrideY) << 4;
iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3;
pMbCache->SPicData.pCsMb[0] = pCurLayer->pCsData[0] + iOffsetY; pMbCache->SPicData.pCsMb[0] = pCurLayer->pCsData[0] + iOffsetY;
pMbCache->SPicData.pCsMb[1] = pCurLayer->pCsData[1] + iOffsetUV; pMbCache->SPicData.pCsMb[1] = pCurLayer->pCsData[1] + iOffsetUV;
pMbCache->SPicData.pCsMb[2] = pCurLayer->pCsData[2] + iOffsetUV; pMbCache->SPicData.pCsMb[2] = pCurLayer->pCsData[2] + iOffsetUV;
iStrideY = pCurLayer->pDecPic->iLineSize[0]; iStrideY = pCurLayer->pDecPic->iLineSize[0];
iStrideUV = pCurLayer->pDecPic->iLineSize[1]; iStrideUV = pCurLayer->pDecPic->iLineSize[1];
iOffsetY = (kiMbX + kiMbY * iStrideY) << 4; iOffsetY = (kiMbX + kiMbY * iStrideY) << 4;
iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3;
pMbCache->SPicData.pDecMb[0] = pCurLayer->pDecPic->pData[0] + iOffsetY; pMbCache->SPicData.pDecMb[0] = pCurLayer->pDecPic->pData[0] + iOffsetY;
pMbCache->SPicData.pDecMb[1] = pCurLayer->pDecPic->pData[1] + iOffsetUV; pMbCache->SPicData.pDecMb[1] = pCurLayer->pDecPic->pData[1] + iOffsetUV;
pMbCache->SPicData.pDecMb[2] = pCurLayer->pDecPic->pData[2] + iOffsetUV; pMbCache->SPicData.pDecMb[2] = pCurLayer->pDecPic->pData[2] + iOffsetUV;
} else { } else {
pMbCache->SPicData.pEncMb[0] += MB_WIDTH_LUMA; pMbCache->SPicData.pEncMb[0] += MB_WIDTH_LUMA;
pMbCache->SPicData.pEncMb[1] += MB_WIDTH_CHROMA; pMbCache->SPicData.pEncMb[1] += MB_WIDTH_CHROMA;
pMbCache->SPicData.pEncMb[2] += MB_WIDTH_CHROMA; pMbCache->SPicData.pEncMb[2] += MB_WIDTH_CHROMA;
pMbCache->SPicData.pDecMb[0] += MB_WIDTH_LUMA; pMbCache->SPicData.pDecMb[0] += MB_WIDTH_LUMA;
pMbCache->SPicData.pDecMb[1] += MB_WIDTH_CHROMA; pMbCache->SPicData.pDecMb[1] += MB_WIDTH_CHROMA;
pMbCache->SPicData.pDecMb[2] += MB_WIDTH_CHROMA; pMbCache->SPicData.pDecMb[2] += MB_WIDTH_CHROMA;
pMbCache->SPicData.pCsMb[0] += MB_WIDTH_LUMA; pMbCache->SPicData.pCsMb[0] += MB_WIDTH_LUMA;
pMbCache->SPicData.pCsMb[1] += MB_WIDTH_CHROMA; pMbCache->SPicData.pCsMb[1] += MB_WIDTH_CHROMA;
pMbCache->SPicData.pCsMb[2] += MB_WIDTH_CHROMA; pMbCache->SPicData.pCsMb[2] += MB_WIDTH_CHROMA;
} }
//step 2. initial pWelsMd //step 2. initial pWelsMd
@@ -320,10 +320,10 @@ void WelsMdIntraInit (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, con
void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const int32_t iSliceFirstMbXY) { void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const int32_t iSliceFirstMbXY) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
const int32_t kiMbX = pCurMb->iMbX; const int32_t kiMbX = pCurMb->iMbX;
const int32_t kiMbY = pCurMb->iMbY; const int32_t kiMbY = pCurMb->iMbY;
const int32_t kiMbXY = pCurMb->iMbXY; const int32_t kiMbXY = pCurMb->iMbXY;
const int32_t kiMbWidth = pCurLayer->iMbWidth; const int32_t kiMbWidth = pCurLayer->iMbWidth;
const int32_t kiMbHeight = pCurLayer->iMbHeight; const int32_t kiMbHeight = pCurLayer->iMbHeight;
@@ -338,17 +338,17 @@ void WelsMdInterInit (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb, const i
//step 4. locating current p_ref //step 4. locating current p_ref
// merge loops // merge loops
if (0 == kiMbX || iSliceFirstMbXY == kiMbXY) { if (0 == kiMbX || iSliceFirstMbXY == kiMbXY) {
const int32_t kiRefStrideY = pCurLayer->pRefPic->iLineSize[0]; const int32_t kiRefStrideY = pCurLayer->pRefPic->iLineSize[0];
const int32_t kiRefStrideUV = pCurLayer->pRefPic->iLineSize[1]; const int32_t kiRefStrideUV = pCurLayer->pRefPic->iLineSize[1];
const int32_t kiCurStrideY = (kiMbX + kiMbY * kiRefStrideY) << 4; const int32_t kiCurStrideY = (kiMbX + kiMbY * kiRefStrideY) << 4;
const int32_t kiCurStrideUV = (kiMbX + kiMbY * kiRefStrideUV) << 3; const int32_t kiCurStrideUV = (kiMbX + kiMbY * kiRefStrideUV) << 3;
pMbCache->SPicData.pRefMb[0] = pCurLayer->pRefPic->pData[0] + kiCurStrideY; pMbCache->SPicData.pRefMb[0] = pCurLayer->pRefPic->pData[0] + kiCurStrideY;
pMbCache->SPicData.pRefMb[1] = pCurLayer->pRefPic->pData[1] + kiCurStrideUV; pMbCache->SPicData.pRefMb[1] = pCurLayer->pRefPic->pData[1] + kiCurStrideUV;
pMbCache->SPicData.pRefMb[2] = pCurLayer->pRefPic->pData[2] + kiCurStrideUV; pMbCache->SPicData.pRefMb[2] = pCurLayer->pRefPic->pData[2] + kiCurStrideUV;
} else { } else {
pMbCache->SPicData.pRefMb[0] += MB_WIDTH_LUMA; pMbCache->SPicData.pRefMb[0] += MB_WIDTH_LUMA;
pMbCache->SPicData.pRefMb[1] += MB_WIDTH_CHROMA; pMbCache->SPicData.pRefMb[1] += MB_WIDTH_CHROMA;
pMbCache->SPicData.pRefMb[2] += MB_WIDTH_CHROMA; pMbCache->SPicData.pRefMb[2] += MB_WIDTH_CHROMA;
} }
pMbCache->uiRefMbType = pCurLayer->pRefPic->uiRefMbType[kiMbXY]; pMbCache->uiRefMbType = pCurLayer->pRefPic->uiRefMbType[kiMbXY];
@@ -367,7 +367,7 @@ int32_t WelsMdI16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache*
int32_t iAvailCount; int32_t iAvailCount;
int32_t iIdx = 0; int32_t iIdx = 0;
uint8_t* pPredI16x16[2] = {pMbCache->pMemPredMb, pMbCache->pMemPredMb + 256}; uint8_t* pPredI16x16[2] = {pMbCache->pMemPredMb, pMbCache->pMemPredMb + 256};
uint8_t* pDst = pPredI16x16[0]; uint8_t* pDst = pPredI16x16[0];
uint8_t* pDec = pMbCache->SPicData.pCsMb[0]; uint8_t* pDec = pMbCache->SPicData.pCsMb[0];
uint8_t* pEnc = pMbCache->SPicData.pEncMb[0]; uint8_t* pEnc = pMbCache->SPicData.pEncMb[0];
int32_t iLineSizeDec = pCurDqLayer->iCsStride[0]; int32_t iLineSizeDec = pCurDqLayer->iCsStride[0];
@@ -416,14 +416,14 @@ int32_t WelsMdI16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCache*
return iBestCost; return iBestCost;
} }
int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) {
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
int32_t iLambda = pWelsMd->iLambda; int32_t iLambda = pWelsMd->iLambda;
int32_t iBestCostLuma = pWelsMd->iCostLuma; int32_t iBestCostLuma = pWelsMd->iCostLuma;
uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0];
uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0]; uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0];
const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0]; const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0];
const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0]; const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0];
uint8_t* pCurEnc, *pCurDec, *pDst; uint8_t* pCurEnc, *pCurDec, *pDst;
@@ -432,16 +432,16 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach
int32_t iAvailCount; int32_t iAvailCount;
const uint8_t* kpAvailMode; const uint8_t* kpAvailMode;
int32_t i, j, iCoordinateX, iCoordinateY, iIdxStrideEnc, iIdxStrideDec; int32_t i, j, iCoordinateX, iCoordinateY, iIdxStrideEnc, iIdxStrideDec;
int32_t lambda[2] = {iLambda << 2, iLambda}; int32_t lambda[2] = {iLambda << 2, iLambda};
bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag; bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag;
int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag; int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag;
const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0]; const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0];
const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0]; const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0];
const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra]; const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra];
const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0]; const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0];
const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0]; const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0];
int32_t iBestPredBufferNum = 0; int32_t iBestPredBufferNum = 0;
int32_t iCosti4x4 = 0; int32_t iCosti4x4 = 0;
#if defined(X86_ASM) #if defined(X86_ASM)
WelsPrefetchZero_mmx (g_kiMapModeI4x4); WelsPrefetchZero_mmx (g_kiMapModeI4x4);
@@ -539,21 +539,21 @@ int32_t WelsMdI4x4 (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach
} }
ST32 (pCurMb->pIntra4x4PredMode, LD32 (&pMbCache->iIntraPredMode[33])); ST32 (pCurMb->pIntra4x4PredMode, LD32 (&pMbCache->iIntraPredMode[33]));
pCurMb->pIntra4x4PredMode[4] = pMbCache->iIntraPredMode[12]; pCurMb->pIntra4x4PredMode[4] = pMbCache->iIntraPredMode[12];
pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20]; pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20];
pCurMb->pIntra4x4PredMode[6] = pMbCache->iIntraPredMode[28]; pCurMb->pIntra4x4PredMode[6] = pMbCache->iIntraPredMode[28];
iCosti4x4 += (iLambda << 4) + (iLambda << 3); //4*6*lambda from JVT SATD0 iCosti4x4 += (iLambda << 4) + (iLambda << 3); //4*6*lambda from JVT SATD0
return iCosti4x4; return iCosti4x4;
} }
int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) {
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
int32_t iLambda = pWelsMd->iLambda; int32_t iLambda = pWelsMd->iLambda;
int32_t iBestCostLuma = pWelsMd->iCostLuma; int32_t iBestCostLuma = pWelsMd->iCostLuma;
uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0];
uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0]; uint8_t* pDecMb = pMbCache->SPicData.pCsMb[0];
const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0]; const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[0];
const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0]; const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[0];
uint8_t* pCurEnc, *pCurDec, *pDst; uint8_t* pCurEnc, *pCurDec, *pDst;
int8_t iPredMode, iCurMode, iBestMode, iFinalMode; int8_t iPredMode, iCurMode, iBestMode, iFinalMode;
@@ -562,16 +562,16 @@ int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMb
const uint8_t* kpAvailMode; const uint8_t* kpAvailMode;
int32_t i, j, iCoordinateX, iCoordinateY, iIdxStrideEnc, iIdxStrideDec; int32_t i, j, iCoordinateX, iCoordinateY, iIdxStrideEnc, iIdxStrideDec;
int32_t iCostH, iCostV, iCostVR, iCostHD, iCostVL, iCostHU, iBestModeFake; int32_t iCostH, iCostV, iCostVR, iCostHD, iCostVL, iCostHU, iBestModeFake;
int32_t lambda[2] = {iLambda << 2, iLambda}; int32_t lambda[2] = {iLambda << 2, iLambda};
bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag; bool* pPrevIntra4x4PredModeFlag = pMbCache->pPrevIntra4x4PredModeFlag;
int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag; int8_t* pRemIntra4x4PredModeFlag = pMbCache->pRemIntra4x4PredModeFlag;
const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0]; const uint8_t* kpIntra4x4AvailCount = &g_kiIntra4AvailCount[0];
const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0]; const uint8_t* kpCache48CountScan4 = &g_kuiCache48CountScan4Idx[0];
const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra]; const int8_t* kpNeighborIntraToI4x4 = g_kiNeighborIntraToI4x4[pMbCache->uiNeighborIntra];
const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0]; const int8_t* kpCoordinateIdxX = &g_kiCoordinateIdx4x4X[0];
const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0]; const int8_t* kpCoordinateIdxY = &g_kiCoordinateIdx4x4Y[0];
int32_t iBestPredBufferNum = 0; int32_t iBestPredBufferNum = 0;
int32_t iCosti4x4 = 0; int32_t iCosti4x4 = 0;
#if defined(X86_ASM) #if defined(X86_ASM)
WelsPrefetchZero_mmx (g_kiMapModeI4x4); WelsPrefetchZero_mmx (g_kiMapModeI4x4);
WelsPrefetchZero_mmx ((int8_t*)&pFunc->pfGetLumaI4x4Pred); WelsPrefetchZero_mmx ((int8_t*)&pFunc->pfGetLumaI4x4Pred);
@@ -858,7 +858,7 @@ int32_t WelsMdI4x4Fast (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMb
} }
ST32 (pCurMb->pIntra4x4PredMode, LD32 (&pMbCache->iIntraPredMode[33])); ST32 (pCurMb->pIntra4x4PredMode, LD32 (&pMbCache->iIntraPredMode[33]));
pCurMb->pIntra4x4PredMode[4] = pMbCache->iIntraPredMode[12]; pCurMb->pIntra4x4PredMode[4] = pMbCache->iIntraPredMode[12];
pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20]; pCurMb->pIntra4x4PredMode[5] = pMbCache->iIntraPredMode[20];
pCurMb->pIntra4x4PredMode[6] = pMbCache->iIntraPredMode[28]; pCurMb->pIntra4x4PredMode[6] = pMbCache->iIntraPredMode[28];
iCosti4x4 += (iLambda << 4) + (iLambda << 3); //4*6*lambda from JVT SATD0 iCosti4x4 += (iLambda << 4) + (iLambda << 3); //4*6*lambda from JVT SATD0
return iCosti4x4; return iCosti4x4;
@@ -868,14 +868,14 @@ int32_t WelsMdIntraChroma (SWelsFuncPtrList* pFunc, SDqLayer* pCurDqLayer, SMbCa
const int8_t* kpAvailMode; const int8_t* kpAvailMode;
int32_t iAvailCount = 0; int32_t iAvailCount = 0;
int32_t iChmaIdx = 0; int32_t iChmaIdx = 0;
uint8_t* pPredIntraChma[2] = {pMbCache->pMemPredChroma, pMbCache->pMemPredChroma + 128}; uint8_t* pPredIntraChma[2] = {pMbCache->pMemPredChroma, pMbCache->pMemPredChroma + 128};
uint8_t* pDstChma = pPredIntraChma[0]; uint8_t* pDstChma = pPredIntraChma[0];
uint8_t* pEncCb = pMbCache->SPicData.pEncMb[1]; uint8_t* pEncCb = pMbCache->SPicData.pEncMb[1];
uint8_t* pEncCr = pMbCache->SPicData.pEncMb[2]; uint8_t* pEncCr = pMbCache->SPicData.pEncMb[2];
uint8_t* pDecCb = pMbCache->SPicData.pCsMb[1];//pMbCache->SPicData.pDecMb[1]; uint8_t* pDecCb = pMbCache->SPicData.pCsMb[1];//pMbCache->SPicData.pDecMb[1];
uint8_t* pDecCr = pMbCache->SPicData.pCsMb[2];//pMbCache->SPicData.pDecMb[2]; uint8_t* pDecCr = pMbCache->SPicData.pCsMb[2];//pMbCache->SPicData.pDecMb[2];
const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[1]; const int32_t kiLineSizeEnc = pCurDqLayer->iEncStride[1];
const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[1];//pMbCache->SPicData.i_stride_dec[1]; const int32_t kiLineSizeDec = pCurDqLayer->iCsStride[1];//pMbCache->SPicData.i_stride_dec[1];
int32_t i, iCurMode, iCurCost, iBestMode, iBestCost = INT_MAX; int32_t i, iCurMode, iCurCost, iBestMode, iBestCost = INT_MAX;
@@ -979,8 +979,8 @@ int32_t WelsMdP16x16 (SWelsFuncPtrList* pFunc, SDqLayer* pCurLayer, SWelsMD* pWe
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SWelsME* pMe16x16 = &pWelsMd->sMe.sMe16x16; SWelsME* pMe16x16 = &pWelsMd->sMe.sMe16x16;
uint32_t uiNeighborAvail = pCurMb->uiNeighborAvail; uint32_t uiNeighborAvail = pCurMb->uiNeighborAvail;
const int32_t kiMbWidth = pCurLayer->iMbWidth; // for assign once const int32_t kiMbWidth = pCurLayer->iMbWidth; // for assign once
const int32_t kiMbHeight = pCurLayer->iMbHeight; const int32_t kiMbHeight = pCurLayer->iMbHeight;
InitMe (*pWelsMd, BLOCK_16x16, pMbCache->SPicData.pEncMb[0], pMbCache->SPicData.pRefMb[0], InitMe (*pWelsMd, BLOCK_16x16, pMbCache->SPicData.pEncMb[0], pMbCache->SPicData.pRefMb[0],
pCurLayer->pRefPic->pScreenBlockFeatureStorage, pCurLayer->pRefPic->pScreenBlockFeatureStorage,
*pMe16x16); *pMe16x16);
@@ -1218,10 +1218,10 @@ void WelsMdInterFinePartitionVaa (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice
inline void VaaBackgroundMbDataUpdate (SWelsFuncPtrList* pFunc, SVAAFrameInfo* pVaaInfo, SMB* pCurMb) { inline void VaaBackgroundMbDataUpdate (SWelsFuncPtrList* pFunc, SVAAFrameInfo* pVaaInfo, SMB* pCurMb) {
const int32_t kiPicStride = pVaaInfo->iPicStride; const int32_t kiPicStride = pVaaInfo->iPicStride;
const int32_t kiPicStrideUV = pVaaInfo->iPicStrideUV; const int32_t kiPicStrideUV = pVaaInfo->iPicStrideUV;
const int32_t kiOffsetY = (pCurMb->iMbY * kiPicStride + pCurMb->iMbX) << 4; const int32_t kiOffsetY = (pCurMb->iMbY * kiPicStride + pCurMb->iMbX) << 4;
const int32_t kiOffsetUV = (pCurMb->iMbY * kiPicStrideUV + pCurMb->iMbX) << 3; const int32_t kiOffsetUV = (pCurMb->iMbY * kiPicStrideUV + pCurMb->iMbX) << 3;
pFunc->pfCopy16x16Aligned (pVaaInfo->pCurY + kiOffsetY, kiPicStride, pVaaInfo->pRefY + kiOffsetY, kiPicStride); pFunc->pfCopy16x16Aligned (pVaaInfo->pCurY + kiOffsetY, kiPicStride, pVaaInfo->pRefY + kiOffsetY, kiPicStride);
pFunc->pfCopy8x8Aligned (pVaaInfo->pCurU + kiOffsetUV, kiPicStrideUV, pVaaInfo->pRefU + kiOffsetUV, kiPicStrideUV); pFunc->pfCopy8x8Aligned (pVaaInfo->pCurU + kiOffsetUV, kiPicStrideUV, pVaaInfo->pRefU + kiOffsetUV, kiPicStrideUV);
@@ -1230,22 +1230,22 @@ inline void VaaBackgroundMbDataUpdate (SWelsFuncPtrList* pFunc, SVAAFrameInfo* p
void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache, SSlice* pSlice, void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache, SSlice* pSlice,
bool bSkipMbFlag) { bool bSkipMbFlag) {
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SMVUnitXY sMvp = { 0 }; SMVUnitXY sMvp = { 0 };
uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0];
uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1];
uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2]; uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2];
int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0]; int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0];
int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1]; int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1];
uint8_t* pDstLuma = pMbCache->pSkipMb; uint8_t* pDstLuma = pMbCache->pSkipMb;
uint8_t* pDstCb = pMbCache->pSkipMb + 256; uint8_t* pDstCb = pMbCache->pSkipMb + 256;
uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64; uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64;
if (!bSkipMbFlag) { if (!bSkipMbFlag) {
pDstLuma = pMbCache->pMemPredLuma; pDstLuma = pMbCache->pMemPredLuma;
pDstCb = pMbCache->pMemPredChroma; pDstCb = pMbCache->pMemPredChroma;
pDstCr = pMbCache->pMemPredChroma + 64; pDstCr = pMbCache->pMemPredChroma + 64;
} }
//MC //MC
pFunc->sMcFuncs.pMcLumaFunc (pRefLuma, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16); pFunc->sMcFuncs.pMcLumaFunc (pRefLuma, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16);
@@ -1300,8 +1300,8 @@ void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb,
} }
bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) { bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0];
uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1];
@@ -1316,8 +1316,8 @@ bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCac
SMVUnitXY sMvp = { 0 }; SMVUnitXY sMvp = { 0 };
int32_t n; int32_t n;
int32_t iEncStride = pCurLayer->iEncStride[0]; int32_t iEncStride = pCurLayer->iEncStride[0];
uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0]; uint8_t* pEncMb = pMbCache->SPicData.pEncMb[0];
int32_t* pStrideEncBlockOffset = pEncCtx->pStrideTab->pStrideEncBlockOffset[pEncCtx->uiDependencyId]; int32_t* pStrideEncBlockOffset = pEncCtx->pStrideTab->pStrideEncBlockOffset[pEncCtx->uiDependencyId];
int32_t* pEncBlockOffset; int32_t* pEncBlockOffset;
@@ -1612,14 +1612,14 @@ bool WelsMdFirstIntraMode (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb,
} }
void WelsMdInterMb (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pUnused) { void WelsMdInterMb (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pUnused) {
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail; const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail;
const int32_t kiMbWidth = pCurDqLayer->iMbWidth; const int32_t kiMbWidth = pCurDqLayer->iMbWidth;
const SMB* top_mb = pCurMb - kiMbWidth; const SMB* top_mb = pCurMb - kiMbWidth;
const bool bMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false); const bool bMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false);
const bool bMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (top_mb->uiMbType) : false); const bool bMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (top_mb->uiMbType) : false);
const bool bMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((top_mb - 1)->uiMbType) : false); const bool bMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((top_mb - 1)->uiMbType) : false);
const bool bMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP ((top_mb + 1)->uiMbType) : false); const bool bMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP ((top_mb + 1)->uiMbType) : false);
bool bTrySkip = bMbLeftAvailPskip || bMbTopAvailPskip || bMbTopLeftAvailPskip || bMbTopRightAvailPskip; bool bTrySkip = bMbLeftAvailPskip || bMbTopAvailPskip || bMbTopLeftAvailPskip || bMbTopRightAvailPskip;
bool bKeepSkip = bMbLeftAvailPskip && bMbTopAvailPskip && bMbTopRightAvailPskip; bool bKeepSkip = bMbLeftAvailPskip && bMbTopAvailPskip && bMbTopRightAvailPskip;

View File

@@ -76,8 +76,8 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
while (uiSliceIdx < iSliceNum) { while (uiSliceIdx < iSliceNum) {
const int32_t kiFirstMb = uiSliceIdx * kiMbWidth; const int32_t kiFirstMb = uiSliceIdx * kiMbWidth;
pSliceSeg->pCountMbNumInSlice[uiSliceIdx] = kiMbWidth; pSliceSeg->pCountMbNumInSlice[uiSliceIdx] = kiMbWidth;
pSliceSeg->pFirstMbInSlice[uiSliceIdx] = kiFirstMb; pSliceSeg->pFirstMbInSlice[uiSliceIdx] = kiFirstMb;
WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, uiSliceIdx, WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, uiSliceIdx,
kiMbWidth, sizeof(uint16_t)); kiMbWidth, sizeof(uint16_t));
++ uiSliceIdx; ++ uiSliceIdx;
@@ -87,18 +87,18 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
} else if (SM_RASTER_SLICE == pSliceSeg->uiSliceMode || } else if (SM_RASTER_SLICE == pSliceSeg->uiSliceMode ||
SM_FIXEDSLCNUM_SLICE == pSliceSeg->uiSliceMode || SM_FIXEDSLCNUM_SLICE == pSliceSeg->uiSliceMode ||
SM_AUTO_SLICE == pSliceSeg->uiSliceMode) { SM_AUTO_SLICE == pSliceSeg->uiSliceMode) {
const int32_t* kpSlicesAssignList = (int32_t*) & (kpMso->sSliceArgument.uiSliceMbNum[0]); const int32_t* kpSlicesAssignList = (int32_t*) & (kpMso->sSliceArgument.uiSliceMbNum[0]);
const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame; const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame;
const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame; const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame;
uint16_t iSliceIdx = 0; uint16_t iSliceIdx = 0;
int32_t iMbIdx = 0; int32_t iMbIdx = 0;
do { do {
const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx]; const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx];
int32_t iRunIdx = 0; int32_t iRunIdx = 0;
pSliceSeg->pFirstMbInSlice[iSliceIdx] = iMbIdx; pSliceSeg->pFirstMbInSlice[iSliceIdx] = iMbIdx;
pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength; pSliceSeg->pCountMbNumInSlice[iSliceIdx] = kiCurRunLength;
// due here need check validate mb_assign_map for input pData, can not use memset // due here need check validate mb_assign_map for input pData, can not use memset
do { do {
@@ -132,11 +132,11 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
//slice parameter check for SM_FIXEDSLCNUM_SLICE //slice parameter check for SM_FIXEDSLCNUM_SLICE
bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) { bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) {
int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]);
const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; const uint32_t kuiSliceNum = pSliceArg->uiSliceNum;
uint32_t uiSliceIdx = 0; uint32_t uiSliceIdx = 0;
const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum; const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum;
int32_t iNumMbLeft = kiMbNumInFrame; int32_t iNumMbLeft = kiMbNumInFrame;
if (NULL == pSlicesAssignList) if (NULL == pSlicesAssignList)
return false; return false;
@@ -153,8 +153,8 @@ bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceAr
//slice parameter check for SM_ROWMB_SLICE //slice parameter check for SM_ROWMB_SLICE
bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSliceArg) { bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSliceArg) {
int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]);
const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; const uint32_t kuiSliceNum = pSliceArg->uiSliceNum;
uint32_t uiSliceIdx = 0; uint32_t uiSliceIdx = 0;
if (NULL == pSlicesAssignList) if (NULL == pSlicesAssignList)
return false; return false;
@@ -168,19 +168,19 @@ bool CheckRowMbMultiSliceSetting (const int32_t kiMbWidth, SSliceArgument* pSlic
//slice parameter check for SM_RASTER_SLICE //slice parameter check for SM_RASTER_SLICE
bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) { bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) {
int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]); int32_t* pSlicesAssignList = (int32_t*) & (pSliceArg->uiSliceMbNum[0]);
int32_t iActualSliceCount = 0; int32_t iActualSliceCount = 0;
//check mb_num setting //check mb_num setting
uint32_t uiSliceIdx = 0; uint32_t uiSliceIdx = 0;
int32_t iCountMb = 0; int32_t iCountMb = 0;
if (NULL == pSlicesAssignList) if (NULL == pSlicesAssignList)
return false; return false;
while ((uiSliceIdx < MAX_SLICES_NUM) && (0 < pSlicesAssignList[uiSliceIdx])) { while ((uiSliceIdx < MAX_SLICES_NUM) && (0 < pSlicesAssignList[uiSliceIdx])) {
iCountMb += pSlicesAssignList[uiSliceIdx]; iCountMb += pSlicesAssignList[uiSliceIdx];
iActualSliceCount = uiSliceIdx + 1; iActualSliceCount = uiSliceIdx + 1;
if (iCountMb >= kiMbNumInFrame) { if (iCountMb >= kiMbNumInFrame) {
break; break;
@@ -198,8 +198,8 @@ bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument*
//need correction: //need correction:
//setting is more than iMbNumInFrame, //setting is more than iMbNumInFrame,
//cut the last uiSliceMbNum; adjust iCountMb //cut the last uiSliceMbNum; adjust iCountMb
pSlicesAssignList[iActualSliceCount - 1] -= (iCountMb - kiMbNumInFrame); pSlicesAssignList[iActualSliceCount - 1] -= (iCountMb - kiMbNumInFrame);
iCountMb = kiMbNumInFrame; iCountMb = kiMbNumInFrame;
} else if (iActualSliceCount < MAX_SLICES_NUM) { } else if (iActualSliceCount < MAX_SLICES_NUM) {
//where ( iCountMb < iMbNumInFrame ) //where ( iCountMb < iMbNumInFrame )
//can do correction: //can do correction:
@@ -220,8 +220,8 @@ bool CheckRasterMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument*
// GOM based RC related for uiSliceNum decision, only used at SM_FIXEDSLCNUM_SLICE // GOM based RC related for uiSliceNum decision, only used at SM_FIXEDSLCNUM_SLICE
bool GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, uint32_t* pSliceNum) { bool GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, uint32_t* pSliceNum) {
const int32_t kiCountNumMb = kiMbWidth * kiMbHeight; const int32_t kiCountNumMb = kiMbWidth * kiMbHeight;
uint32_t iSliceNum = *pSliceNum; uint32_t iSliceNum = *pSliceNum;
int32_t iGomSize; int32_t iGomSize;
//The default RC is Bit-rate mode[Yi], but need consider as below: //The default RC is Bit-rate mode[Yi], but need consider as below:
@@ -257,14 +257,14 @@ bool GomValidCheckSliceNum (const int32_t kiMbWidth, const int32_t kiMbHeight, u
// GOM based RC related for uiSliceMbNum decision, only used at SM_FIXEDSLCNUM_SLICE // GOM based RC related for uiSliceMbNum decision, only used at SM_FIXEDSLCNUM_SLICE
bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceArgument* pSliceArg) { bool GomValidCheckSliceMbNum (const int32_t kiMbWidth, const int32_t kiMbHeight, SSliceArgument* pSliceArg) {
uint32_t* pSlicesAssignList = & (pSliceArg->uiSliceMbNum[0]); uint32_t* pSlicesAssignList = & (pSliceArg->uiSliceMbNum[0]);
const uint32_t kuiSliceNum = pSliceArg->uiSliceNum; const uint32_t kuiSliceNum = pSliceArg->uiSliceNum;
const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight;
const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum; const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum;
int32_t iNumMbLeft = kiMbNumInFrame; int32_t iNumMbLeft = kiMbNumInFrame;
int32_t iMinimalMbNum = kiMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required int32_t iMinimalMbNum = kiMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
int32_t iMaximalMbNum = 0; // dynamically assign later int32_t iMaximalMbNum = 0; // dynamically assign later
int32_t iGomSize; int32_t iGomSize;
uint32_t uiSliceIdx = 0; // for test uint32_t uiSliceIdx = 0; // for test
@@ -385,11 +385,11 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
pSliceSeg->pCountMbNumInSlice = NULL; pSliceSeg->pCountMbNumInSlice = NULL;
} }
// just for safe // just for safe
pSliceSeg->iSliceNumInFrame = 0; pSliceSeg->iSliceNumInFrame = 0;
pSliceSeg->iMbNumInFrame = 0; pSliceSeg->iMbNumInFrame = 0;
pSliceSeg->iMbWidth = 0; pSliceSeg->iMbWidth = 0;
pSliceSeg->iMbHeight = 0; pSliceSeg->iMbHeight = 0;
pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // sigle in default pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // sigle in default
} }
if (SM_SINGLE_SLICE == uiSliceMode) { if (SM_SINGLE_SLICE == uiSliceMode) {
@@ -407,12 +407,12 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
"pSliceSeg->pCountMbNumInSlice"); "pSliceSeg->pCountMbNumInSlice");
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice) WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice)
pSliceSeg->uiSliceMode = uiSliceMode; pSliceSeg->uiSliceMode = uiSliceMode;
pSliceSeg->iMbWidth = kiMbWidth; pSliceSeg->iMbWidth = kiMbWidth;
pSliceSeg->iMbHeight = kiMbHeight; pSliceSeg->iMbHeight = kiMbHeight;
pSliceSeg->iMbNumInFrame = kiCountMbNum; pSliceSeg->iMbNumInFrame = kiCountMbNum;
pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum; pSliceSeg->pCountMbNumInSlice[0] = kiCountMbNum;
pSliceSeg->pFirstMbInSlice[0] = 0; pSliceSeg->pFirstMbInSlice[0] = 0;
return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0])); return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0]));
} else { //if ( SM_MULTIPLE_SLICE == uiSliceMode ) } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode )
@@ -441,10 +441,10 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
"pSliceSeg->pFirstMbInSlice"); "pSliceSeg->pFirstMbInSlice");
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice) WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice)
pSliceSeg->uiSliceMode = pMso->uiSliceMode; pSliceSeg->uiSliceMode = pMso->uiSliceMode;
pSliceSeg->iMbWidth = kiMbWidth; pSliceSeg->iMbWidth = kiMbWidth;
pSliceSeg->iMbHeight = kiMbHeight; pSliceSeg->iMbHeight = kiMbHeight;
pSliceSeg->iMbNumInFrame = kiCountMbNum; pSliceSeg->iMbNumInFrame = kiCountMbNum;
if (SM_DYN_SLICE == pMso->uiSliceMode) { if (SM_DYN_SLICE == pMso->uiSliceMode) {
if (0 < pMso->sSliceArgument.uiSliceSizeConstraint) { if (0 < pMso->sSliceArgument.uiSliceSizeConstraint) {
pSliceSeg->uiSliceSizeConstraint = pMso->sSliceArgument.uiSliceSizeConstraint; pSliceSeg->uiSliceSizeConstraint = pMso->sSliceArgument.uiSliceSizeConstraint;
@@ -491,11 +491,11 @@ void UninitSliceSegment (SSliceCtx* pSliceSeg, CMemoryAlign* pMa) {
pSliceSeg->pCountMbNumInSlice = NULL; pSliceSeg->pCountMbNumInSlice = NULL;
} }
pSliceSeg->iMbNumInFrame = 0; pSliceSeg->iMbNumInFrame = 0;
pSliceSeg->iMbWidth = 0; pSliceSeg->iMbWidth = 0;
pSliceSeg->iMbHeight = 0; pSliceSeg->iMbHeight = 0;
pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // single in default pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // single in default
pSliceSeg->iSliceNumInFrame = 0; pSliceSeg->iSliceNumInFrame = 0;
} }
} }
@@ -664,11 +664,11 @@ int32_t GetCurrentSliceNum (const SSliceCtx* kpSliceCtx) {
} }
int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx, int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx,
int32_t* pRunLength) { int32_t* pRunLength) {
const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame; const int32_t iCountNumMbInFrame = pSliceCtx->iMbNumInFrame;
const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame; const int32_t iCountSliceNumInFrame = pSliceCtx->iSliceNumInFrame;
int32_t iSameRunLenFlag = 1; int32_t iSameRunLenFlag = 1;
int32_t iFirstMbIdx = 0; int32_t iFirstMbIdx = 0;
int32_t iSliceIdx = 0; int32_t iSliceIdx = 0;
assert (iCountSliceNumInFrame <= MAX_THREADS_NUM); assert (iCountSliceNumInFrame <= MAX_THREADS_NUM);
@@ -687,8 +687,8 @@ int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx,
do { do {
const int32_t kiSliceRun = pRunLength[iSliceIdx]; const int32_t kiSliceRun = pRunLength[iSliceIdx];
pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx; pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx;
pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun;
WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx,
kiSliceRun, sizeof(uint16_t)); kiSliceRun, sizeof(uint16_t));

View File

@@ -53,17 +53,17 @@ void WelsDctMb (int16_t* pRes, uint8_t* pEncMb, int32_t iEncStride, uint8_t* pBe
void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) {
ENFORCE_STACK_ALIGN_1D (int16_t, aDctT4Dc, 16, 16) ENFORCE_STACK_ALIGN_1D (int16_t, aDctT4Dc, 16, 16)
SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList; SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList;
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
const int32_t kiEncStride = pCurDqLayer->iEncStride[0]; const int32_t kiEncStride = pCurDqLayer->iEncStride[0];
int16_t* pRes = pMbCache->pCoeffLevel; int16_t* pRes = pMbCache->pCoeffLevel;
uint8_t* pPred = pMbCache->SPicData.pCsMb[0]; uint8_t* pPred = pMbCache->SPicData.pCsMb[0];
const int32_t kiRecStride = pCurDqLayer->iCsStride[0]; const int32_t kiRecStride = pCurDqLayer->iCsStride[0];
int16_t* pBlock = pMbCache->pDct->iLumaBlock[0]; int16_t* pBlock = pMbCache->pDct->iLumaBlock[0];
uint8_t* pBestPred = pMbCache->pMemPredLuma; uint8_t* pBestPred = pMbCache->pMemPredLuma;
const uint8_t* kpNoneZeroCountIdx = &g_kuiMbCountScan4Idx[0]; const uint8_t* kpNoneZeroCountIdx = &g_kuiMbCountScan4Idx[0];
uint8_t i, uiQp = pCurMb->uiLumaQp; uint8_t i, uiQp = pCurMb->uiLumaQp;
uint32_t uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiCountI16x16Dc; uint32_t uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiCountI16x16Dc;
const int16_t* pMF = g_kiQuantMF[uiQp]; const int16_t* pMF = g_kiQuantMF[uiQp];
const int16_t* pFF = g_iQuantIntraFF[uiQp]; const int16_t* pFF = g_iQuantIntraFF[uiQp];
@@ -137,10 +137,10 @@ void WelsEncRecI16x16Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) {
} }
} }
void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uint8_t uiI4x4Idx) { void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uint8_t uiI4x4Idx) {
SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList; SWelsFuncPtrList* pFuncList = pEncCtx->pFuncList;
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
int32_t iEncStride = pCurDqLayer->iEncStride[0]; int32_t iEncStride = pCurDqLayer->iEncStride[0];
uint8_t uiQp = pCurMb->uiLumaQp; uint8_t uiQp = pCurMb->uiLumaQp;
int16_t* pResI4x4 = pMbCache->pCoeffLevel; int16_t* pResI4x4 = pMbCache->pCoeffLevel;
uint8_t* pPredI4x4; uint8_t* pPredI4x4;
@@ -178,17 +178,17 @@ void WelsEncRecI4x4Y (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, uin
} }
void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache) { void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache) {
PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max; PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max;
PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8; PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8;
PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64; PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64;
PScanFunc pfScan4x4 = pFuncList->pfScan4x4; PScanFunc pfScan4x4 = pFuncList->pfScan4x4;
PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4; PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4;
PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount; PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount;
PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4; PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4;
int16_t* pRes = pMbCache->pCoeffLevel; int16_t* pRes = pMbCache->pCoeffLevel;
int32_t iSingleCtrMb = 0, iSingleCtr8x8[4]; int32_t iSingleCtrMb = 0, iSingleCtr8x8[4];
int16_t* pBlock = pMbCache->pDct->iLumaBlock[0]; int16_t* pBlock = pMbCache->pDct->iLumaBlock[0];
uint8_t uiQp = pCurMb->uiLumaQp; uint8_t uiQp = pCurMb->uiLumaQp;
const int16_t* pMF = g_kiQuantMF[uiQp]; const int16_t* pMF = g_kiQuantMF[uiQp];
const int16_t* pFF = g_kiQuantInterFF[uiQp]; const int16_t* pFF = g_kiQuantInterFF[uiQp];
int16_t aMax[16]; int16_t aMax[16];
@@ -244,20 +244,20 @@ void WelsEncInterY (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache
} }
void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache, int16_t* pRes, int32_t iUV) { void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache, int16_t* pRes, int32_t iUV) {
PQuantizationHadamardFunc pfQuantizationHadamard2x2 = pFuncList->pfQuantizationHadamard2x2; PQuantizationHadamardFunc pfQuantizationHadamard2x2 = pFuncList->pfQuantizationHadamard2x2;
PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max; PQuantizationMaxFunc pfQuantizationFour4x4Max = pFuncList->pfQuantizationFour4x4Max;
PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8; PSetMemoryZero pfSetMemZeroSize8 = pFuncList->pfSetMemZeroSize8;
PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64; PSetMemoryZero pfSetMemZeroSize64 = pFuncList->pfSetMemZeroSize64;
PScanFunc pfScan4x4Ac = pFuncList->pfScan4x4Ac; PScanFunc pfScan4x4Ac = pFuncList->pfScan4x4Ac;
PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4; PCalculateSingleCtrFunc pfCalculateSingleCtr4x4 = pFuncList->pfCalculateSingleCtr4x4;
PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount; PGetNoneZeroCountFunc pfGetNoneZeroCount = pFuncList->pfGetNoneZeroCount;
PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4; PDeQuantizationFunc pfDequantizationFour4x4 = pFuncList->pfDequantizationFour4x4;
const int32_t kiInterFlag = !IS_INTRA (pCurMb->uiMbType); const int32_t kiInterFlag = !IS_INTRA (pCurMb->uiMbType);
const uint8_t kiQp = pCurMb->uiChromaQp; const uint8_t kiQp = pCurMb->uiChromaQp;
uint8_t i, uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiNoneZeroCountMbDc = 0; uint8_t i, uiNoneZeroCount, uiNoneZeroCountMbAc = 0, uiNoneZeroCountMbDc = 0;
uint8_t uiNoneZeroCountOffset = (iUV - 1) << 1; //UV==1 or 2 uint8_t uiNoneZeroCountOffset = (iUV - 1) << 1; //UV==1 or 2
uint8_t uiSubMbIdx = 16 + ((iUV - 1) << 2); //uiSubMbIdx == 16 or 20 uint8_t uiSubMbIdx = 16 + ((iUV - 1) << 2); //uiSubMbIdx == 16 or 20
int16_t* iChromaDc = pMbCache->pDct->iChromaDc[iUV - 1], *pBlock = pMbCache->pDct->iChromaBlock[ (iUV - 1) << 2]; int16_t* iChromaDc = pMbCache->pDct->iChromaDc[iUV - 1], *pBlock = pMbCache->pDct->iChromaBlock[ (iUV - 1) << 2];
int16_t aDct2x2[4], j, aMax[4]; int16_t aDct2x2[4], j, aMax[4];
int32_t iSingleCtr8x8 = 0; int32_t iSingleCtr8x8 = 0;
const int16_t* pMF = g_kiQuantMF[kiQp]; const int16_t* pMF = g_kiQuantMF[kiQp];
@@ -307,17 +307,17 @@ void WelsEncRecUV (SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCac
WelsDequantIHadamard2x2Dc (aDct2x2, g_kuiDequantCoeff[kiQp][0]); WelsDequantIHadamard2x2Dc (aDct2x2, g_kuiDequantCoeff[kiQp][0]);
if (2 != (pCurMb->uiCbp >> 4)) if (2 != (pCurMb->uiCbp >> 4))
pCurMb->uiCbp |= (0x01 << 4) ; pCurMb->uiCbp |= (0x01 << 4) ;
pRes[0] = aDct2x2[0]; pRes[0] = aDct2x2[0];
pRes[16] = aDct2x2[1]; pRes[16] = aDct2x2[1];
pRes[32] = aDct2x2[2]; pRes[32] = aDct2x2[2];
pRes[48] = aDct2x2[3]; pRes[48] = aDct2x2[3];
} }
} }
void WelsRecPskip (SDqLayer* pCurLayer, SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache) { void WelsRecPskip (SDqLayer* pCurLayer, SWelsFuncPtrList* pFuncList, SMB* pCurMb, SMbCache* pMbCache) {
int32_t* iRecStride = pCurLayer->iCsStride; int32_t* iRecStride = pCurLayer->iCsStride;
uint8_t** pCsMb = &pMbCache->SPicData.pCsMb[0]; uint8_t** pCsMb = &pMbCache->SPicData.pCsMb[0];
pFuncList->pfCopy16x16Aligned (pCsMb[0], *iRecStride++, pMbCache->pSkipMb, 16); pFuncList->pfCopy16x16Aligned (pCsMb[0], *iRecStride++, pMbCache->pSkipMb, 16);
pFuncList->pfCopy8x8Aligned (pCsMb[1], *iRecStride++, pMbCache->pSkipMb + 256, 8); pFuncList->pfCopy8x8Aligned (pCsMb[1], *iRecStride++, pMbCache->pSkipMb + 256, 8);

View File

@@ -178,8 +178,8 @@ void WelsCountMbType (int32_t (*iMbCount)[18], const EWelsSliceType keSt, const
* \brief write reference picture list on reordering syntax in Slice header * \brief write reference picture list on reordering syntax in Slice header
*/ */
void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) { void WriteReferenceReorder (SBitStringAux* pBs, SSliceHeader* sSliceHeader) {
SRefPicListReorderSyntax* pRefOrdering = &sSliceHeader->sRefReordering; SRefPicListReorderSyntax* pRefOrdering = &sSliceHeader->sRefReordering;
uint8_t eSliceType = sSliceHeader->eSliceType % 5; uint8_t eSliceType = sSliceHeader->eSliceType % 5;
int16_t n = 0; int16_t n = 0;
if (I_SLICE != eSliceType && SI_SLICE != eSliceType) { // !I && !SI if (I_SLICE != eSliceType && SI_SLICE != eSliceType) { // !I && !SI
@@ -417,14 +417,14 @@ void WelsInterMbEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) {
//only BaseLayer inter MB and SpatialLayer (uiQualityId = 0) inter MB calling this pFunc. //only BaseLayer inter MB and SpatialLayer (uiQualityId = 0) inter MB calling this pFunc.
//only for I SSlice //only for I SSlice
void WelsIMbChromaEncode (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) { void WelsIMbChromaEncode (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache) {
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const int32_t kiEncStride = pCurLayer->iEncStride[1]; const int32_t kiEncStride = pCurLayer->iEncStride[1];
const int32_t kiCsStride = pCurLayer->iCsStride[1]; const int32_t kiCsStride = pCurLayer->iCsStride[1];
int16_t* pCurRS = pMbCache->pCoeffLevel; int16_t* pCurRS = pMbCache->pCoeffLevel;
uint8_t* pBestPred = pMbCache->pBestPredIntraChroma; uint8_t* pBestPred = pMbCache->pBestPredIntraChroma;
uint8_t* pCsCb = pMbCache->SPicData.pCsMb[1]; uint8_t* pCsCb = pMbCache->SPicData.pCsMb[1];
uint8_t* pCsCr = pMbCache->SPicData.pCsMb[2]; uint8_t* pCsCr = pMbCache->SPicData.pCsMb[2];
//cb //cb
pFunc->pfDctFourT4 (pCurRS, pMbCache->SPicData.pEncMb[1], kiEncStride, pBestPred, 8); pFunc->pfDctFourT4 (pCurRS, pMbCache->SPicData.pEncMb[1], kiEncStride, pBestPred, 8);
@@ -441,12 +441,12 @@ void WelsIMbChromaEncode (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache)
//only BaseLayer inter MB and SpatialLayer (uiQualityId = 0) inter MB calling this pFunc. //only BaseLayer inter MB and SpatialLayer (uiQualityId = 0) inter MB calling this pFunc.
//for P SSlice (intra part + inter part) //for P SSlice (intra part + inter part)
void WelsPMbChromaEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { void WelsPMbChromaEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) {
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const int32_t kiEncStride = pCurLayer->iEncStride[1]; const int32_t kiEncStride = pCurLayer->iEncStride[1];
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
int16_t* pCurRS = pMbCache->pCoeffLevel + 256; int16_t* pCurRS = pMbCache->pCoeffLevel + 256;
uint8_t* pBestPred = pMbCache->pMemPredChroma; uint8_t* pBestPred = pMbCache->pMemPredChroma;
pFunc->pfDctFourT4 (pCurRS, pMbCache->SPicData.pEncMb[1], kiEncStride, pBestPred, 8); pFunc->pfDctFourT4 (pCurRS, pMbCache->SPicData.pEncMb[1], kiEncStride, pBestPred, 8);
pFunc->pfDctFourT4 (pCurRS + 64, pMbCache->SPicData.pEncMb[2], kiEncStride, pBestPred + 64, 8); pFunc->pfDctFourT4 (pCurRS + 64, pMbCache->SPicData.pEncMb[2], kiEncStride, pBestPred + 64, 8);
@@ -457,15 +457,15 @@ void WelsPMbChromaEncode (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) {
void OutputPMbWithoutConstructCsRsNoCopy (sWelsEncCtx* pCtx, SDqLayer* pDq, SSlice* pSlice, SMB* pMb) { void OutputPMbWithoutConstructCsRsNoCopy (sWelsEncCtx* pCtx, SDqLayer* pDq, SSlice* pSlice, SMB* pMb) {
if ((IS_INTER (pMb->uiMbType) && !IS_SKIP (pMb->uiMbType)) if ((IS_INTER (pMb->uiMbType) && !IS_SKIP (pMb->uiMbType))
|| IS_I_BL (pMb->uiMbType)) { //intra have been reconstructed, NO COPY from CS to pDecPic-- || IS_I_BL (pMb->uiMbType)) { //intra have been reconstructed, NO COPY from CS to pDecPic--
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
uint8_t* pDecY = pMbCache->SPicData.pDecMb[0]; uint8_t* pDecY = pMbCache->SPicData.pDecMb[0];
uint8_t* pDecU = pMbCache->SPicData.pDecMb[1]; uint8_t* pDecU = pMbCache->SPicData.pDecMb[1];
uint8_t* pDecV = pMbCache->SPicData.pDecMb[2]; uint8_t* pDecV = pMbCache->SPicData.pDecMb[2];
int16_t* pScaledTcoeff = pMbCache->pCoeffLevel; int16_t* pScaledTcoeff = pMbCache->pCoeffLevel;
const int32_t kiDecStrideLuma = pDq->pDecPic->iLineSize[0]; const int32_t kiDecStrideLuma = pDq->pDecPic->iLineSize[0];
const int32_t kiDecStrideChroma = pDq->pDecPic->iLineSize[1]; const int32_t kiDecStrideChroma = pDq->pDecPic->iLineSize[1];
PIDctFunc pfIdctFour4x4 = pCtx->pFuncList->pfIDctFourT4; PIDctFunc pfIdctFour4x4 = pCtx->pFuncList->pfIDctFourT4;
WelsIDctT4RecOnMb (pDecY, kiDecStrideLuma, pDecY, kiDecStrideLuma, pScaledTcoeff, pfIdctFour4x4); WelsIDctT4RecOnMb (pDecY, kiDecStrideLuma, pDecY, kiDecStrideLuma, pScaledTcoeff, pfIdctFour4x4);
pfIdctFour4x4 (pDecU, kiDecStrideChroma, pDecU, kiDecStrideChroma, pScaledTcoeff + 256); pfIdctFour4x4 (pDecU, kiDecStrideChroma, pDecU, kiDecStrideChroma, pScaledTcoeff + 256);
@@ -482,17 +482,17 @@ void UpdateQpForOverflow (SMB* pCurMb, uint8_t kuiChromaQpIndexOffset) {
//first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction) //first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction)
//second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer) //second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer)
int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt; SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt;
SMB* pMbList = pCurLayer->sMbDataP; SMB* pMbList = pCurLayer->sMbDataP;
SMB* pCurMb = NULL; SMB* pCurMb = NULL;
const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice; const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice;
int32_t iNextMbIdx = kiSliceFirstMbXY; int32_t iNextMbIdx = kiSliceFirstMbXY;
const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
int32_t iCurMbIdx = 0, iNumMbCoded = 0; int32_t iCurMbIdx = 0, iNumMbCoded = 0;
const int32_t kiSliceIdx = pSlice->uiSliceIdx; const int32_t kiSliceIdx = pSlice->uiSliceIdx;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
SWelsMD sMd; SWelsMD sMd;
@@ -544,19 +544,19 @@ TRY_REENCODING:
// Only for intra dynamic slicing // Only for intra dynamic slicing
int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt; SSliceHeaderExt* pSliceHdExt = &pSlice->sSliceHeaderExt;
SMB* pMbList = pCurLayer->sMbDataP; SMB* pMbList = pCurLayer->sMbDataP;
SMB* pCurMb = NULL; SMB* pCurMb = NULL;
const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice; const int32_t kiSliceFirstMbXY = pSliceHdExt->sSliceHeader.iFirstMbInSlice;
int32_t iNextMbIdx = kiSliceFirstMbXY; int32_t iNextMbIdx = kiSliceFirstMbXY;
const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
int32_t iCurMbIdx = 0, iNumMbCoded = 0; int32_t iCurMbIdx = 0, iNumMbCoded = 0;
const int32_t kiSliceIdx = pSlice->uiSliceIdx; const int32_t kiSliceIdx = pSlice->uiSliceIdx;
const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
int32_t iEncReturn = ENC_RETURN_SUCCESS; int32_t iEncReturn = ENC_RETURN_SUCCESS;
@@ -631,13 +631,13 @@ TRY_REENCODING:
// first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction) // first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction)
// second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer) // second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer)
int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { //pMd + encoding int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { //pMd + encoding
const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt; const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt;
const SSliceHeader* kpSh = &kpShExt->sSliceHeader; const SSliceHeader* kpSh = &kpShExt->sSliceHeader;
const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice; const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice;
SWelsMD sMd; SWelsMD sMd;
sMd.uiRef = kpSh->uiRefIndex; sMd.uiRef = kpSh->uiRefIndex;
sMd.bMdUsingSad = kbIsHighestDlayerFlag; sMd.bMdUsingSad = kbIsHighestDlayerFlag;
if (!pEncCtx->pCurDqLayer->bBaseLayerAvailableFlag || !kbIsHighestDlayerFlag) if (!pEncCtx->pCurDqLayer->bBaseLayerAvailableFlag || !kbIsHighestDlayerFlag)
memset (&sMd.sMe, 0, sizeof (sMd.sMe)); memset (&sMd.sMe, 0, sizeof (sMd.sMe));
@@ -646,13 +646,13 @@ int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsH
} }
int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) {
const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt; const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt;
const SSliceHeader* kpSh = &kpShExt->sSliceHeader; const SSliceHeader* kpSh = &kpShExt->sSliceHeader;
const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice; const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice;
SWelsMD sMd; SWelsMD sMd;
sMd.uiRef = kpSh->uiRefIndex; sMd.uiRef = kpSh->uiRefIndex;
sMd.bMdUsingSad = kbIsHighestDlayerFlag; sMd.bMdUsingSad = kbIsHighestDlayerFlag;
if (!pEncCtx->pCurDqLayer->bBaseLayerAvailableFlag || !kbIsHighestDlayerFlag) if (!pEncCtx->pCurDqLayer->bBaseLayerAvailableFlag || !kbIsHighestDlayerFlag)
memset (&sMd.sMe, 0, sizeof (sMd.sMe)); memset (&sMd.sMe, 0, sizeof (sMd.sMe));
@@ -711,11 +711,11 @@ static const PWelsSliceHeaderWriteFunc g_pWelsWriteSliceHeader[2] = { // 0: for
int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) { int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx]; SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx];
SBitStringAux* pBs = pCurSlice->pSliceBsa; SBitStringAux* pBs = pCurSlice->pSliceBsa;
const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceCfg.uiSliceMode
== ==
SM_DYN_SLICE); SM_DYN_SLICE);
@@ -763,19 +763,19 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx,
SMB* pMbList, SMB* pMbList,
const int32_t kiFirstMbIdxOfNextSlice, const int32_t kiFirstMbIdxOfNextSlice,
const int32_t kiLastMbIdxInPartition) { const int32_t kiLastMbIdxInPartition) {
const int32_t kiMbWidth = pSliceCtx->iMbWidth; const int32_t kiMbWidth = pSliceCtx->iMbWidth;
int32_t iIdx = kiFirstMbIdxOfNextSlice; int32_t iIdx = kiFirstMbIdxOfNextSlice;
int32_t iNextSliceFirstMbIdxRowStart = ((kiFirstMbIdxOfNextSlice % kiMbWidth) ? 1 : 0); int32_t iNextSliceFirstMbIdxRowStart = ((kiFirstMbIdxOfNextSlice % kiMbWidth) ? 1 : 0);
int32_t iCountMbUpdate = kiMbWidth + int32_t iCountMbUpdate = kiMbWidth +
iNextSliceFirstMbIdxRowStart; //need to update MB(iMbXY+1) to MB(iMbXY+1+row) in common case iNextSliceFirstMbIdxRowStart; //need to update MB(iMbXY+1) to MB(iMbXY+1+row) in common case
const int32_t kiEndMbNeedUpdate = kiFirstMbIdxOfNextSlice + iCountMbUpdate; const int32_t kiEndMbNeedUpdate = kiFirstMbIdxOfNextSlice + iCountMbUpdate;
SMB* pMb = &pMbList[iIdx]; SMB* pMb = &pMbList[iIdx];
do { do {
uint32_t uiNeighborAvailFlag = 0; uint32_t uiNeighborAvailFlag = 0;
const int32_t kiMbXY = pMb->iMbXY; const int32_t kiMbXY = pMb->iMbXY;
const int32_t kiMbX = pMb->iMbX; const int32_t kiMbX = pMb->iMbX;
const int32_t kiMbY = pMb->iMbY; const int32_t kiMbY = pMb->iMbY;
bool bLeft; bool bLeft;
bool bTop; bool bTop;
bool bLeftTop; bool bLeftTop;
@@ -817,12 +817,12 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx,
void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb, void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSliceCtx, SMB* pCurMb,
int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
int32_t iCurMbIdx = pCurMb->iMbXY; int32_t iCurMbIdx = pCurMb->iMbXY;
uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ];
const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum;
uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep;
SSlice* pNextSlice = NULL; SSlice* pNextSlice = NULL;
SMB* pMbList = pCurLayer->sMbDataP; SMB* pMbList = pCurLayer->sMbDataP;
@@ -855,9 +855,9 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli
SDynamicSlicingStack* pDss) { SDynamicSlicingStack* pDss) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx; sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SSlice* pCurSlice = (SSlice*)pSlice; SSlice* pCurSlice = (SSlice*)pSlice;
int32_t iCurMbIdx = pCurMb->iMbXY; int32_t iCurMbIdx = pCurMb->iMbXY;
uint32_t uiLen = 0; uint32_t uiLen = 0;
int32_t iPosBitOffset = 0; int32_t iPosBitOffset = 0;
const int32_t kiActiveThreadsNum = pEncCtx->iActiveThreadsNum; const int32_t kiActiveThreadsNum = pEncCtx->iActiveThreadsNum;
const int32_t kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum; const int32_t kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum;
const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId]; const int32_t kiLastMbIdxInPartition = pEncCtx->pCurDqLayer->pLastMbIdxOfPartition[kiPartitaionId];
@@ -933,26 +933,26 @@ inline void WelsInitInterMDStruc (const SMB* pCurMb, uint16_t* pMvdCostTable, co
SWelsMD* pMd) { SWelsMD* pMd) {
pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp]; pMd->iLambda = g_kiQpCostTable[pCurMb->uiLumaQp];
pMd->pMvdCost = &pMvdCostTable[pCurMb->uiLumaQp * kiMvdInterTableStride]; pMd->pMvdCost = &pMvdCostTable[pCurMb->uiLumaQp * kiMvdInterTableStride];
pMd-> iMbPixX = (pCurMb->iMbX << 4); pMd-> iMbPixX = (pCurMb->iMbX << 4);
pMd-> iMbPixY = (pCurMb->iMbY << 4); pMd-> iMbPixY = (pCurMb->iMbY << 4);
memset (&pMd->iBlock8x8StaticIdc[0], 0, sizeof (pMd->iBlock8x8StaticIdc)); memset (&pMd->iBlock8x8StaticIdc[0], 0, sizeof (pMd->iBlock8x8StaticIdc));
} }
// for inter non-dynamic pSlice // for inter non-dynamic pSlice
int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) { int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) {
SWelsMD* pMd = (SWelsMD*)pWelsMd; SWelsMD* pMd = (SWelsMD*)pWelsMd;
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SMB* pMbList = pCurLayer->sMbDataP; SMB* pMbList = pCurLayer->sMbDataP;
SMB* pCurMb = NULL; SMB* pCurMb = NULL;
int32_t iNumMbCoded = 0; int32_t iNumMbCoded = 0;
int32_t iNextMbIdx = kiSliceFirstMbXY; int32_t iNextMbIdx = kiSliceFirstMbXY;
int32_t iCurMbIdx = -1; int32_t iCurMbIdx = -1;
const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride; const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride;
uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize]; uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize];
const int32_t kiSliceIdx = pSlice->uiSliceIdx; const int32_t kiSliceIdx = pSlice->uiSliceIdx;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
int32_t iEncReturn = ENC_RETURN_SUCCESS; int32_t iEncReturn = ENC_RETURN_SUCCESS;
SDynamicSlicingStack sDss; SDynamicSlicingStack sDss;
@@ -1030,21 +1030,21 @@ TRY_REENCODING:
// Only for inter dynamic slicing // Only for inter dynamic slicing
int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
const int32_t kiSliceFirstMbXY) { const int32_t kiSliceFirstMbXY) {
SWelsMD* pMd = (SWelsMD*)pWelsMd; SWelsMD* pMd = (SWelsMD*)pWelsMd;
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SMB* pMbList = pCurLayer->sMbDataP; SMB* pMbList = pCurLayer->sMbDataP;
SMB* pCurMb = NULL; SMB* pCurMb = NULL;
int32_t iNumMbCoded = 0; int32_t iNumMbCoded = 0;
const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight; const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
int32_t iNextMbIdx = kiSliceFirstMbXY; int32_t iNextMbIdx = kiSliceFirstMbXY;
int32_t iCurMbIdx = -1; int32_t iCurMbIdx = -1;
const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride; const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride;
uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize]; uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize];
const int32_t kiSliceIdx = pSlice->uiSliceIdx; const int32_t kiSliceIdx = pSlice->uiSliceIdx;
const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum); const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
int32_t iEncReturn = ENC_RETURN_SUCCESS; int32_t iEncReturn = ENC_RETURN_SUCCESS;

View File

@@ -58,11 +58,10 @@ void WelsMdSpatialelInterMbIlfmdNoilp (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, S
const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail; const uint32_t kuiNeighborAvail = pCurMb->uiNeighborAvail;
const int32_t kiMbWidth = pCurDqLayer->iMbWidth; const int32_t kiMbWidth = pCurDqLayer->iMbWidth;
const SMB* kpTopMb = pCurMb - kiMbWidth; const SMB* kpTopMb = pCurMb - kiMbWidth;
const bool kbMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false); const bool kbMbLeftAvailPskip = ((kuiNeighborAvail & LEFT_MB_POS) ? IS_SKIP ((pCurMb - 1)->uiMbType) : false);
const bool kbMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (kpTopMb->uiMbType) : false); const bool kbMbTopAvailPskip = ((kuiNeighborAvail & TOP_MB_POS) ? IS_SKIP (kpTopMb->uiMbType) : false);
const bool kbMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((kpTopMb - 1)->uiMbType) : false); const bool kbMbTopLeftAvailPskip = ((kuiNeighborAvail & TOPLEFT_MB_POS) ? IS_SKIP ((kpTopMb - 1)->uiMbType) : false);
const bool kbMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP (( const bool kbMbTopRightAvailPskip = ((kuiNeighborAvail & TOPRIGHT_MB_POS) ? IS_SKIP ((kpTopMb + 1)->uiMbType) : false);
kpTopMb + 1)->uiMbType) : false);
bool bTrySkip = kbMbLeftAvailPskip | kbMbTopAvailPskip | kbMbTopLeftAvailPskip | kbMbTopRightAvailPskip; bool bTrySkip = kbMbLeftAvailPskip | kbMbTopAvailPskip | kbMbTopLeftAvailPskip | kbMbTopRightAvailPskip;
bool bKeepSkip = kbMbLeftAvailPskip & kbMbTopAvailPskip & kbMbTopRightAvailPskip; bool bKeepSkip = kbMbLeftAvailPskip & kbMbTopAvailPskip & kbMbTopRightAvailPskip;
@@ -107,10 +106,10 @@ void WelsMdSpatialelInterMbIlfmdNoilp (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, S
void WelsMdInterMbEnhancelayer (sWelsEncCtx* pEncCtx, SWelsMD* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache) { void WelsMdInterMbEnhancelayer (sWelsEncCtx* pEncCtx, SWelsMD* pMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SWelsMD* pWelsMd = (SWelsMD*)pMd; SWelsMD* pWelsMd = (SWelsMD*)pMd;
const SMB* kpInterLayerRefMb = GetRefMb (pCurLayer, pCurMb); const SMB* kpInterLayerRefMb = GetRefMb (pCurLayer, pCurMb);
const Mb_Type kuiInterLayerRefMbType = kpInterLayerRefMb->uiMbType; const Mb_Type kuiInterLayerRefMbType = kpInterLayerRefMb->uiMbType;
SetMvBaseEnhancelayer (pWelsMd, pCurMb, SetMvBaseEnhancelayer (pWelsMd, pCurMb,
kpInterLayerRefMb); // initial sMvBase here only when pRef mb type is inter, if not sMvBase will be not used! kpInterLayerRefMb); // initial sMvBase here only when pRef mb type is inter, if not sMvBase will be not used!
@@ -180,12 +179,12 @@ bool CheckChromaCost (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMbCache* pMbCache
uint8_t* pCbEnc = pMbCache->SPicData.pEncMb[1]; uint8_t* pCbEnc = pMbCache->SPicData.pEncMb[1];
uint8_t* pCrEnc = pMbCache->SPicData.pEncMb[2]; uint8_t* pCrEnc = pMbCache->SPicData.pEncMb[2];
uint8_t* pCbRef = pMbCache->SPicData.pRefMb[1]; uint8_t* pCbRef = pMbCache->SPicData.pRefMb[1];
uint8_t* pCrRef = pMbCache->SPicData.pRefMb[2]; uint8_t* pCrRef = pMbCache->SPicData.pRefMb[2];
const int32_t iCbEncStride = pCurDqLayer->iEncStride[1]; const int32_t iCbEncStride = pCurDqLayer->iEncStride[1];
const int32_t iCrEncStride = pCurDqLayer->iEncStride[2]; const int32_t iCrEncStride = pCurDqLayer->iEncStride[2];
const int32_t iChromaRefStride = pCurDqLayer->pRefPic->iLineSize[1]; const int32_t iChromaRefStride = pCurDqLayer->pRefPic->iLineSize[1];
const int32_t iCbSad = GetChromaCost (pSad, pCbEnc, iCbEncStride, pCbRef, iChromaRefStride); const int32_t iCbSad = GetChromaCost (pSad, pCbEnc, iCbEncStride, pCbRef, iChromaRefStride);
const int32_t iCrSad = GetChromaCost (pSad, pCrEnc, iCrEncStride, pCrRef, iChromaRefStride); const int32_t iCrSad = GetChromaCost (pSad, pCrEnc, iCrEncStride, pCrRef, iChromaRefStride);
@@ -220,7 +219,7 @@ bool WelsMdInterJudgeBGDPskip (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* p
const int32_t kiRefMbQp = pCurDqLayer->pRefPic->pRefMbQp[pCurMb->iMbXY]; const int32_t kiRefMbQp = pCurDqLayer->pRefPic->pRefMbQp[pCurMb->iMbXY];
const int32_t kiCurMbQp = pCurMb->uiLumaQp;// unsigned -> signed const int32_t kiCurMbQp = pCurMb->uiLumaQp;// unsigned -> signed
int8_t* pVaaBgMbFlag = pEncCtx->pVaa->pVaaBackgroundMbFlag + pCurMb->iMbXY; int8_t* pVaaBgMbFlag = pEncCtx->pVaa->pVaaBackgroundMbFlag + pCurMb->iMbXY;
const int32_t kiMbWidth = pCurDqLayer->iMbWidth; const int32_t kiMbWidth = pCurDqLayer->iMbWidth;
@@ -332,8 +331,8 @@ bool JudgeStaticSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SPicture* pRefOri = pCurDqLayer->pRefOri[0]; SPicture* pRefOri = pCurDqLayer->pRefOri[0];
if (pRefOri != NULL) { if (pRefOri != NULL) {
iStrideUV = pCurDqLayer->iEncStride[1]; iStrideUV = pCurDqLayer->iEncStride[1];
iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3; iOffsetUV = (kiMbX + kiMbY * iStrideUV) << 3;
int32_t iSadCostCb = CalUVSadCost (pFunc, pMbCache->SPicData.pEncMb[1], iStrideUV, pRefOri->pData[1] + iOffsetUV, int32_t iSadCostCb = CalUVSadCost (pFunc, pMbCache->SPicData.pEncMb[1], iStrideUV, pRefOri->pData[1] + iOffsetUV,
pRefOri->iLineSize[1]); pRefOri->iLineSize[1]);
@@ -372,8 +371,8 @@ bool JudgeScrollSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe
if (CheckBorder (kiMbX, kiMbY, iScrollMvX, iScrollMvY, kiMbWidth, kiMbHeight)) { if (CheckBorder (kiMbX, kiMbY, iScrollMvX, iScrollMvY, kiMbWidth, kiMbHeight)) {
bTryScrollSkip = false; bTryScrollSkip = false;
} else { } else {
iStrideUV = pCurDqLayer->iEncStride[1]; iStrideUV = pCurDqLayer->iEncStride[1];
iOffsetUV = (kiMbX << 3) + (iScrollMvX >> 1) + ((kiMbY << 3) + (iScrollMvY >> 1)) * iStrideUV; iOffsetUV = (kiMbX << 3) + (iScrollMvX >> 1) + ((kiMbY << 3) + (iScrollMvY >> 1)) * iStrideUV;
int32_t iSadCostCb = CalUVSadCost (pFunc, pMbCache->SPicData.pEncMb[1], iStrideUV, pRefOri->pData[1] + iOffsetUV, int32_t iSadCostCb = CalUVSadCost (pFunc, pMbCache->SPicData.pEncMb[1], iStrideUV, pRefOri->pData[1] + iOffsetUV,
pRefOri->iLineSize[1]); pRefOri->iLineSize[1]);
@@ -391,27 +390,27 @@ bool JudgeScrollSkip (sWelsEncCtx* pEncCtx, SMB* pCurMb, SMbCache* pMbCache, SWe
void SvcMdSCDMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache, SSlice* pSlice, void SvcMdSCDMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCache* pMbCache, SSlice* pSlice,
bool bQpSimilarFlag, bool bQpSimilarFlag,
bool bMbSkipFlag, SMVUnitXY sCurMbMv[], ESkipModes eSkipMode) { bool bMbSkipFlag, SMVUnitXY sCurMbMv[], ESkipModes eSkipMode) {
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
SWelsFuncPtrList* pFunc = pEncCtx->pFuncList; SWelsFuncPtrList* pFunc = pEncCtx->pFuncList;
SMVUnitXY sMvp = { 0}; SMVUnitXY sMvp = { 0};
ST16 (&sMvp.iMvX, sCurMbMv[eSkipMode].iMvX); ST16 (&sMvp.iMvX, sCurMbMv[eSkipMode].iMvX);
ST16 (&sMvp.iMvY, sCurMbMv[eSkipMode].iMvY); ST16 (&sMvp.iMvY, sCurMbMv[eSkipMode].iMvY);
uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0]; uint8_t* pRefLuma = pMbCache->SPicData.pRefMb[0];
uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1]; uint8_t* pRefCb = pMbCache->SPicData.pRefMb[1];
uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2]; uint8_t* pRefCr = pMbCache->SPicData.pRefMb[2];
int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0]; int32_t iLineSizeY = pCurDqLayer->pRefPic->iLineSize[0];
int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1]; int32_t iLineSizeUV = pCurDqLayer->pRefPic->iLineSize[1];
uint8_t* pDstLuma = pMbCache->pSkipMb; uint8_t* pDstLuma = pMbCache->pSkipMb;
uint8_t* pDstCb = pMbCache->pSkipMb + 256; uint8_t* pDstCb = pMbCache->pSkipMb + 256;
uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64; uint8_t* pDstCr = pMbCache->pSkipMb + 256 + 64;
const int32_t iOffsetY = (sCurMbMv[eSkipMode].iMvX >> 2) + (sCurMbMv[eSkipMode].iMvY >> 2) * iLineSizeY; const int32_t iOffsetY = (sCurMbMv[eSkipMode].iMvX >> 2) + (sCurMbMv[eSkipMode].iMvY >> 2) * iLineSizeY;
const int32_t iOffsetUV = (sCurMbMv[eSkipMode].iMvX >> 3) + (sCurMbMv[eSkipMode].iMvY >> 3) * iLineSizeUV; const int32_t iOffsetUV = (sCurMbMv[eSkipMode].iMvX >> 3) + (sCurMbMv[eSkipMode].iMvY >> 3) * iLineSizeUV;
if (!bQpSimilarFlag || !bMbSkipFlag) { if (!bQpSimilarFlag || !bMbSkipFlag) {
pDstLuma = pMbCache->pMemPredLuma; pDstLuma = pMbCache->pMemPredLuma;
pDstCb = pMbCache->pMemPredChroma; pDstCb = pMbCache->pMemPredChroma;
pDstCr = pMbCache->pMemPredChroma + 64; pDstCr = pMbCache->pMemPredChroma + 64;
} }
//MC //MC
pFunc->sMcFuncs.pMcLumaFunc (pRefLuma + iOffsetY, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16); pFunc->sMcFuncs.pMcLumaFunc (pRefLuma + iOffsetY, iLineSizeY, pDstLuma, 16, 0, 0, 16, 16);
@@ -466,8 +465,8 @@ void SvcMdSCDMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach
bool MdInterSCDPskipProcess (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache, bool MdInterSCDPskipProcess (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SSlice* pSlice, SMB* pCurMb, SMbCache* pMbCache,
ESkipModes eSkipMode) { ESkipModes eSkipMode) {
SVAAFrameInfoExt_t* pVaaExt = static_cast<SVAAFrameInfoExt_t*> (pEncCtx->pVaa); SVAAFrameInfoExt_t* pVaaExt = static_cast<SVAAFrameInfoExt_t*> (pEncCtx->pVaa);
SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurDqLayer = pEncCtx->pCurDqLayer;
const int32_t kiRefMbQp = pCurDqLayer->pRefPic->pRefMbQp[pCurMb->iMbXY]; const int32_t kiRefMbQp = pCurDqLayer->pRefPic->pRefMbQp[pCurMb->iMbXY];
const int32_t kiCurMbQp = pCurMb->uiLumaQp;// unsigned -> signed const int32_t kiCurMbQp = pCurMb->uiLumaQp;// unsigned -> signed

View File

@@ -57,8 +57,8 @@ const uint32_t g_kuiInterCbpMap[48] = {
//============================Enhance Layer CAVLC Writing=========================== //============================Enhance Layer CAVLC Writing===========================
void WelsSpatialWriteMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { void WelsSpatialWriteMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) {
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt;
int32_t iNumRefIdxl0ActiveMinus1 = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1; int32_t iNumRefIdxl0ActiveMinus1 = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1;
@@ -169,8 +169,8 @@ void WelsSpatialWriteMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb)
} }
void WelsSpatialWriteSubMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) { void WelsSpatialWriteSubMbPred (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb) {
SMbCache* pMbCache = &pSlice->sMbCacheInfo; SMbCache* pMbCache = &pSlice->sMbCacheInfo;
SBitStringAux* pBs = pSlice->pSliceBsa; SBitStringAux* pBs = pSlice->pSliceBsa;
SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt; SSliceHeaderExt* pSliceHeadExt = &pSlice->sSliceHeaderExt;
int32_t iNumRefIdxl0ActiveMinus1 = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1; int32_t iNumRefIdxl0ActiveMinus1 = pSliceHeadExt->sSliceHeader.uiNumRefIdxL0Active - 1;
@@ -271,10 +271,10 @@ int32_t WelsSpatialWriteMbSyn (sWelsEncCtx* pEncCtx, SSlice* pSlice, SMB* pCurMb
int32_t WelsWriteMbResidual (SWelsFuncPtrList* pFuncList, SMbCache* sMbCacheInfo, SMB* pCurMb, SBitStringAux* pBs) { int32_t WelsWriteMbResidual (SWelsFuncPtrList* pFuncList, SMbCache* sMbCacheInfo, SMB* pCurMb, SBitStringAux* pBs) {
int32_t i; int32_t i;
Mb_Type uiMbType = pCurMb->uiMbType; Mb_Type uiMbType = pCurMb->uiMbType;
const int32_t kiCbpChroma = pCurMb->uiCbp >> 4; const int32_t kiCbpChroma = pCurMb->uiCbp >> 4;
const int32_t kiCbpLuma = pCurMb->uiCbp & 0x0F; const int32_t kiCbpLuma = pCurMb->uiCbp & 0x0F;
int8_t* pNonZeroCoeffCount = sMbCacheInfo->iNonZeroCoeffCount; int8_t* pNonZeroCoeffCount = sMbCacheInfo->iNonZeroCoeffCount;
int16_t* pBlock; int16_t* pBlock;
int8_t iA, iB, iC; int8_t iA, iB, iC;

View File

@@ -122,9 +122,9 @@ int32_t CWelsPreProcess::WelsPreprocessReset (sWelsEncCtx* pCtx) {
} }
int32_t CWelsPreProcess::AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam) { int32_t CWelsPreProcess::AllocSpatialPictures (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pParam) {
CMemoryAlign* pMa = pCtx->pMemAlign; CMemoryAlign* pMa = pCtx->pMemAlign;
const int32_t kiDlayerCount = pParam->iSpatialLayerNum; const int32_t kiDlayerCount = pParam->iSpatialLayerNum;
int32_t iDlayerIndex = 0; int32_t iDlayerIndex = 0;
// spatial pictures // spatial pictures
iDlayerIndex = 0; iDlayerIndex = 0;
@@ -294,21 +294,21 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
int8_t iDependencyId = pSvcParam->iSpatialLayerNum - 1; int8_t iDependencyId = pSvcParam->iSpatialLayerNum - 1;
int32_t iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1; int32_t iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1;
SPicture* pSrcPic = NULL; // large SPicture* pSrcPic = NULL; // large
SPicture* pDstPic = NULL; // small SPicture* pDstPic = NULL; // small
SSpatialLayerConfig* pDlayerParam = NULL; SSpatialLayerConfig* pDlayerParam = NULL;
SSpatialLayerInternal* pDlayerParamInternal = NULL; SSpatialLayerInternal* pDlayerParamInternal = NULL;
int32_t iSpatialNum = 0; int32_t iSpatialNum = 0;
int32_t iSrcWidth = 0; int32_t iSrcWidth = 0;
int32_t iSrcHeight = 0; int32_t iSrcHeight = 0;
int32_t iTargetWidth = 0; int32_t iTargetWidth = 0;
int32_t iTargetHeight = 0; int32_t iTargetHeight = 0;
int32_t iTemporalId = 0; int32_t iTemporalId = 0;
int32_t iActualSpatialLayerNum = 0; int32_t iActualSpatialLayerNum = 0;
pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId]; pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId];
pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId]; pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId];
iTargetWidth = pDlayerParam->iVideoWidth; iTargetWidth = pDlayerParam->iVideoWidth;
iTargetHeight = pDlayerParam->iVideoHeight; iTargetHeight = pDlayerParam->iVideoHeight;
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)]; iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)];
iSrcWidth = pSvcParam->SUsedPicRect.iWidth; iSrcWidth = pSvcParam->SUsedPicRect.iWidth;
@@ -374,10 +374,10 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
while (iDependencyId >= 0) { while (iDependencyId >= 0) {
pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId]; pDlayerParamInternal = &pSvcParam->sDependencyLayers[iDependencyId];
pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId]; pDlayerParam = &pSvcParam->sSpatialLayers[iDependencyId];
iTargetWidth = pDlayerParam->iVideoWidth; iTargetWidth = pDlayerParam->iVideoWidth;
iTargetHeight = pDlayerParam->iVideoHeight; iTargetHeight = pDlayerParam->iVideoHeight;
iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)]; iTemporalId = pDlayerParamInternal->uiCodingIdx2TemporalId[pCtx->iCodingIndex & (pSvcParam->uiGopSize - 1)];
iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1; iPicturePos = m_uiSpatialLayersInTemporal[iDependencyId] - 1;
// NOT work for CGS, FIXME // NOT work for CGS, FIXME
// spatial layer is able to encode indeed // spatial layer is able to encode indeed
@@ -408,10 +408,10 @@ int32_t CWelsPreProcess::SingleLayerPreprocess (sWelsEncCtx* pCtx, const SSource
* \brief Whether input picture need be scaled? * \brief Whether input picture need be scaled?
*/ */
bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPicture) { bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPicture) {
const int32_t kiInputPicWidth = pParam->SUsedPicRect.iWidth; const int32_t kiInputPicWidth = pParam->SUsedPicRect.iWidth;
const int32_t kiInputPicHeight = pParam->SUsedPicRect.iHeight; const int32_t kiInputPicHeight = pParam->SUsedPicRect.iHeight;
const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualWidth; const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualWidth;
const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualHeight; const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualHeight;
bool bNeedDownsampling = true; bool bNeedDownsampling = true;
int32_t iSpatialIdx = pParam->iSpatialLayerNum - 1; int32_t iSpatialIdx = pParam->iSpatialLayerNum - 1;
@@ -423,10 +423,10 @@ bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPic
for (; iSpatialIdx >= 0; iSpatialIdx --) { for (; iSpatialIdx >= 0; iSpatialIdx --) {
SSpatialLayerInternal* pCurLayer = &pParam->sDependencyLayers[iSpatialIdx]; SSpatialLayerInternal* pCurLayer = &pParam->sDependencyLayers[iSpatialIdx];
int32_t iCurDstWidth = pCurLayer->iActualWidth; int32_t iCurDstWidth = pCurLayer->iActualWidth;
int32_t iCurDstHeight = pCurLayer->iActualHeight; int32_t iCurDstHeight = pCurLayer->iActualHeight;
int32_t iInputWidthXDstHeight = kiInputPicWidth * iCurDstHeight; int32_t iInputWidthXDstHeight = kiInputPicWidth * iCurDstHeight;
int32_t iInputHeightXDstWidth = kiInputPicHeight * iCurDstWidth; int32_t iInputHeightXDstWidth = kiInputPicHeight * iCurDstWidth;
if (iInputWidthXDstHeight > iInputHeightXDstWidth) { if (iInputWidthXDstHeight > iInputHeightXDstWidth) {
pScaledPicture->iScaledWidth[iSpatialIdx] = WELS_MAX (iCurDstWidth, 4); pScaledPicture->iScaledWidth[iSpatialIdx] = WELS_MAX (iCurDstWidth, 4);
@@ -459,9 +459,9 @@ void FreeScaledPic (Scaled_Picture* pScaledPicture, CMemoryAlign* pMemoryAlign
} }
int32_t CWelsPreProcess::InitLastSpatialPictures (sWelsEncCtx* pCtx) { int32_t CWelsPreProcess::InitLastSpatialPictures (sWelsEncCtx* pCtx) {
SWelsSvcCodingParam* pParam = pCtx->pSvcParam; SWelsSvcCodingParam* pParam = pCtx->pSvcParam;
const int32_t kiDlayerCount = pParam->iSpatialLayerNum; const int32_t kiDlayerCount = pParam->iSpatialLayerNum;
int32_t iDlayerIndex = 0; int32_t iDlayerIndex = 0;
if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) { for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) {
m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL; m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL;
@@ -469,11 +469,11 @@ int32_t CWelsPreProcess::InitLastSpatialPictures (sWelsEncCtx* pCtx) {
} else { } else {
for (; iDlayerIndex < kiDlayerCount; iDlayerIndex++) { for (; iDlayerIndex < kiDlayerCount; iDlayerIndex++) {
const int32_t kiLayerInTemporal = m_uiSpatialLayersInTemporal[iDlayerIndex]; const int32_t kiLayerInTemporal = m_uiSpatialLayersInTemporal[iDlayerIndex];
m_pLastSpatialPicture[iDlayerIndex][0] = m_pSpatialPic[iDlayerIndex][kiLayerInTemporal - 2]; m_pLastSpatialPicture[iDlayerIndex][0] = m_pSpatialPic[iDlayerIndex][kiLayerInTemporal - 2];
m_pLastSpatialPicture[iDlayerIndex][1] = NULL; m_pLastSpatialPicture[iDlayerIndex][1] = NULL;
} }
for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) { for (; iDlayerIndex < MAX_DEPENDENCY_LAYER; iDlayerIndex++) {
m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL; m_pLastSpatialPicture[iDlayerIndex][0] = m_pLastSpatialPicture[iDlayerIndex][1] = NULL;
} }
} }
return 0; return 0;
@@ -614,9 +614,9 @@ void CWelsPreProcess::VaaCalculation (SVAAFrameInfo* pVaaInfo, SPicture* pCurPic
sRefPixMap.iStride[0] = pRefPicture->iLineSize[0]; sRefPixMap.iStride[0] = pRefPicture->iLineSize[0];
sRefPixMap.eFormat = VIDEO_FORMAT_I420; sRefPixMap.eFormat = VIDEO_FORMAT_I420;
calc_param.iCalcVar = bCalculateVar; calc_param.iCalcVar = bCalculateVar;
calc_param.iCalcBgd = bCalculateBGD; calc_param.iCalcBgd = bCalculateBGD;
calc_param.iCalcSsd = bCalculateSQDiff; calc_param.iCalcSsd = bCalculateSQDiff;
calc_param.pCalcResult = &pVaaInfo->sVaaCalcInfo; calc_param.pCalcResult = &pVaaInfo->sVaaCalcInfo;
m_pInterfaceVp->Set (iMethodIdx, &calc_param); m_pInterfaceVp->Set (iMethodIdx, &calc_param);
@@ -630,14 +630,14 @@ void CWelsPreProcess::BackgroundDetection (SVAAFrameInfo* pVaaInfo, SPicture* pC
pVaaInfo->iPicWidth = pCurPicture->iWidthInPixel; pVaaInfo->iPicWidth = pCurPicture->iWidthInPixel;
pVaaInfo->iPicHeight = pCurPicture->iHeightInPixel; pVaaInfo->iPicHeight = pCurPicture->iHeightInPixel;
pVaaInfo->iPicStride = pCurPicture->iLineSize[0]; pVaaInfo->iPicStride = pCurPicture->iLineSize[0];
pVaaInfo->iPicStrideUV = pCurPicture->iLineSize[1]; pVaaInfo->iPicStrideUV = pCurPicture->iLineSize[1];
pVaaInfo->pCurY = pCurPicture->pData[0]; pVaaInfo->pCurY = pCurPicture->pData[0];
pVaaInfo->pRefY = pRefPicture->pData[0]; pVaaInfo->pRefY = pRefPicture->pData[0];
pVaaInfo->pCurU = pCurPicture->pData[1]; pVaaInfo->pCurU = pCurPicture->pData[1];
pVaaInfo->pRefU = pRefPicture->pData[1]; pVaaInfo->pRefU = pRefPicture->pData[1];
pVaaInfo->pCurV = pCurPicture->pData[2]; pVaaInfo->pCurV = pCurPicture->pData[2];
pVaaInfo->pRefV = pRefPicture->pData[2]; pVaaInfo->pRefV = pRefPicture->pData[2];
int32_t iMethodIdx = METHOD_BACKGROUND_DETECTION; int32_t iMethodIdx = METHOD_BACKGROUND_DETECTION;
SPixMap sSrcPixMap; SPixMap sSrcPixMap;
@@ -673,8 +673,8 @@ void CWelsPreProcess::BackgroundDetection (SVAAFrameInfo* pVaaInfo, SPicture* pC
m_pInterfaceVp->Set (iMethodIdx, (void*)&BGDParam); m_pInterfaceVp->Set (iMethodIdx, (void*)&BGDParam);
m_pInterfaceVp->Process (iMethodIdx, &sSrcPixMap, &sRefPixMap); m_pInterfaceVp->Process (iMethodIdx, &sSrcPixMap, &sRefPixMap);
} else { } else {
int32_t iPicWidthInMb = (pCurPicture->iWidthInPixel + 15) >> 4; int32_t iPicWidthInMb = (pCurPicture->iWidthInPixel + 15) >> 4;
int32_t iPicHeightInMb = (pCurPicture->iHeightInPixel + 15) >> 4; int32_t iPicHeightInMb = (pCurPicture->iHeightInPixel + 15) >> 4;
memset (pVaaInfo->pVaaBackgroundMbFlag, 0, iPicWidthInMb * iPicHeightInMb); memset (pVaaInfo->pVaaBackgroundMbFlag, 0, iPicWidthInMb * iPicHeightInMb);
} }
} }
@@ -713,11 +713,11 @@ void CWelsPreProcess::AdaptiveQuantCalculation (SVAAFrameInfo* pVaaInfo, SPictur
} }
void CWelsPreProcess::SetRefMbType (sWelsEncCtx* pCtx, uint32_t** pRefMbTypeArray, int32_t iRefPicType) { void CWelsPreProcess::SetRefMbType (sWelsEncCtx* pCtx, uint32_t** pRefMbTypeArray, int32_t iRefPicType) {
const uint8_t uiTid = pCtx->uiTemporalId; const uint8_t uiTid = pCtx->uiTemporalId;
const uint8_t uiDid = pCtx->uiDependencyId; const uint8_t uiDid = pCtx->uiDependencyId;
SRefList* pRefPicLlist = pCtx->ppRefPicListExt[uiDid]; SRefList* pRefPicLlist = pCtx->ppRefPicListExt[uiDid];
SLTRState* pLtr = &pCtx->pLtr[uiDid]; SLTRState* pLtr = &pCtx->pLtr[uiDid];
uint8_t i = 0; uint8_t i = 0;
if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bReceivedT0LostFlag && uiTid == 0) { if (pCtx->pSvcParam->bEnableLongTermReference && pLtr->bReceivedT0LostFlag && uiTid == 0) {
for (i = 0; i < pRefPicLlist->uiLongRefCount; i++) { for (i = 0; i < pRefPicLlist->uiLongRefCount; i++) {
@@ -1292,12 +1292,12 @@ void CWelsPreProcess::WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SP
int32_t iSrcWidth = kpSrc->iPicWidth; int32_t iSrcWidth = kpSrc->iPicWidth;
int32_t iSrcHeight = kpSrc->iPicHeight; int32_t iSrcHeight = kpSrc->iPicHeight;
if (iSrcHeight > kiTargetHeight) iSrcHeight = kiTargetHeight; if (iSrcHeight > kiTargetHeight) iSrcHeight = kiTargetHeight;
if (iSrcWidth > kiTargetWidth) iSrcWidth = kiTargetWidth; if (iSrcWidth > kiTargetWidth) iSrcWidth = kiTargetWidth;
// copy from fr26 to fix the odd uiSize failed issue // copy from fr26 to fix the odd uiSize failed issue
if (iSrcWidth & 0x1) -- iSrcWidth; if (iSrcWidth & 0x1) -- iSrcWidth;
if (iSrcHeight & 0x1) -- iSrcHeight; if (iSrcHeight & 0x1) -- iSrcHeight;
const int32_t kiSrcTopOffsetY = pSvcParam->SUsedPicRect.iTop; const int32_t kiSrcTopOffsetY = pSvcParam->SUsedPicRect.iTop;
const int32_t kiSrcTopOffsetUV = (kiSrcTopOffsetY >> 1); const int32_t kiSrcTopOffsetUV = (kiSrcTopOffsetY >> 1);

View File

@@ -124,8 +124,8 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder()
m_pFileBs = WelsFopen (strStreamFileName, "wb"); m_pFileBs = WelsFopen (strStreamFileName, "wb");
m_pFileBsSize = WelsFopen (strLenFileName, "wb"); m_pFileBsSize = WelsFopen (strLenFileName, "wb");
m_bSwitch = false; m_bSwitch = false;
m_iSwitchTimes = 0; m_iSwitchTimes = 0;
#endif//OUTPUT_BIT_STREAM #endif//OUTPUT_BIT_STREAM
InitEncoder(); InitEncoder();
@@ -149,8 +149,8 @@ CWelsH264SVCEncoder::~CWelsH264SVCEncoder() {
WelsFclose (m_pFileBsSize); WelsFclose (m_pFileBsSize);
m_pFileBsSize = NULL; m_pFileBsSize = NULL;
} }
m_bSwitch = false; m_bSwitch = false;
m_iSwitchTimes = 0; m_iSwitchTimes = 0;
#endif//OUTPUT_BIT_STREAM #endif//OUTPUT_BIT_STREAM
Uninitialize(); Uninitialize();
@@ -323,13 +323,13 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) {
} }
const int32_t kiDecStages = WELS_LOG2 (pCfg->uiGopSize); const int32_t kiDecStages = WELS_LOG2 (pCfg->uiGopSize);
pCfg->iTemporalLayerNum = (int8_t) (1 + kiDecStages); pCfg->iTemporalLayerNum = (int8_t) (1 + kiDecStages);
pCfg->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pCfg->iLoopFilterAlphaC0Offset, -6, 6); pCfg->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pCfg->iLoopFilterAlphaC0Offset, -6, 6);
pCfg->iLoopFilterBetaOffset = WELS_CLIP3 (pCfg->iLoopFilterBetaOffset, -6, 6); pCfg->iLoopFilterBetaOffset = WELS_CLIP3 (pCfg->iLoopFilterBetaOffset, -6, 6);
// decide property list size between INIT_TYPE_PARAMETER_BASED/INIT_TYPE_CONFIG_BASED // decide property list size between INIT_TYPE_PARAMETER_BASED/INIT_TYPE_CONFIG_BASED
m_iMaxPicWidth = pCfg->iPicWidth; m_iMaxPicWidth = pCfg->iPicWidth;
m_iMaxPicHeight = pCfg->iPicHeight; m_iMaxPicHeight = pCfg->iPicHeight;
TraceParamInfo (pCfg); TraceParamInfo (pCfg);
if (WelsInitEncoderExt (&m_pEncContext, pCfg, &m_pWelsTrace->m_sLogCtx, NULL)) { if (WelsInitEncoderExt (&m_pEncContext, pCfg, &m_pWelsTrace->m_sLogCtx, NULL)) {
@@ -683,9 +683,9 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue; m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue;
} }
break; break;
case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter
SEncParamBase sEncodingParam; SEncParamBase sEncodingParam;
SWelsSvcCodingParam sConfig; SWelsSvcCodingParam sConfig;
int32_t iTargetWidth = 0; int32_t iTargetWidth = 0;
int32_t iTargetHeight = 0; int32_t iTargetHeight = 0;
@@ -694,12 +694,12 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
return cmInitParaError; return cmInitParaError;
} }
/* New configuration available here */ /* New configuration available here */
iTargetWidth = sConfig.iPicWidth; iTargetWidth = sConfig.iPicWidth;
iTargetHeight = sConfig.iPicHeight; iTargetHeight = sConfig.iPicHeight;
if (m_iMaxPicWidth != iTargetWidth if (m_iMaxPicWidth != iTargetWidth
|| m_iMaxPicHeight != iTargetHeight) { || m_iMaxPicHeight != iTargetHeight) {
m_iMaxPicWidth = iTargetWidth; m_iMaxPicWidth = iTargetWidth;
m_iMaxPicHeight = iTargetHeight; m_iMaxPicHeight = iTargetHeight;
} }
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE iUsageType = %d,iPicWidth= %d;iPicHeight= %d;iTargetBitrate= %d;fMaxFrameRate= %.6ff;iRCMode= %d", "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_BASE iUsageType = %d,iPicWidth= %d;iPicHeight= %d;iTargetBitrate= %d;fMaxFrameRate= %.6ff;iRCMode= %d",
@@ -715,9 +715,9 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
} }
break; break;
case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter case ENCODER_OPTION_SVC_ENCODE_PARAM_EXT: { // SVC Encoding Parameter
SEncParamExt sEncodingParam; SEncParamExt sEncodingParam;
SWelsSvcCodingParam sConfig; SWelsSvcCodingParam sConfig;
int32_t iTargetWidth = 0; int32_t iTargetWidth = 0;
int32_t iTargetHeight = 0; int32_t iTargetHeight = 0;
@@ -756,12 +756,12 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
} }
/* New configuration available here */ /* New configuration available here */
iTargetWidth = sConfig.iPicWidth; iTargetWidth = sConfig.iPicWidth;
iTargetHeight = sConfig.iPicHeight; iTargetHeight = sConfig.iPicHeight;
if (m_iMaxPicWidth != iTargetWidth if (m_iMaxPicWidth != iTargetWidth
|| m_iMaxPicHeight != iTargetHeight) { || m_iMaxPicHeight != iTargetHeight) {
m_iMaxPicWidth = iTargetWidth; m_iMaxPicWidth = iTargetWidth;
m_iMaxPicHeight = iTargetHeight; m_iMaxPicHeight = iTargetHeight;
} }
/* Check every field whether there is new request for memory block changed or else, Oct. 24, 2008 */ /* Check every field whether there is new request for memory block changed or else, Oct. 24, 2008 */
if (WelsEncoderParamAdjust (&m_pEncContext, &sConfig)) { if (WelsEncoderParamAdjust (&m_pEncContext, &sConfig)) {

View File

@@ -66,8 +66,8 @@ EResult CAdaptiveQuantization::Process (int32_t iType, SPixMap* pSrcPixMap, SPix
SMotionTextureUnit* pMotionTexture = NULL; SMotionTextureUnit* pMotionTexture = NULL;
SVAACalcResult* pVaaCalcResults = NULL; SVAACalcResult* pVaaCalcResults = NULL;
int32_t iMotionTextureIndexToDeltaQp = 0; int32_t iMotionTextureIndexToDeltaQp = 0;
int32_t iAverMotionTextureIndexToDeltaQp = 0; // double to uint32 int32_t iAverMotionTextureIndexToDeltaQp = 0; // double to uint32
int64_t iAverageMotionIndex = 0; // double to float int64_t iAverageMotionIndex = 0; // double to float
int64_t iAverageTextureIndex = 0; int64_t iAverageTextureIndex = 0;
int64_t iQStep = 0; int64_t iQStep = 0;

View File

@@ -107,16 +107,16 @@ EResult CBackgroundDetection::Set (int32_t iType, void* pParam) {
} }
inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight) { inline SBackgroundOU* CBackgroundDetection::AllocateOUArrayMemory (int32_t iWidth, int32_t iHeight) {
int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE; int32_t iMaxOUWidth = (BGD_OU_SIZE - 1 + iWidth) >> LOG2_BGD_OU_SIZE;
int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE; int32_t iMaxOUHeight = (BGD_OU_SIZE - 1 + iHeight) >> LOG2_BGD_OU_SIZE;
return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU)); return (SBackgroundOU*)WelsMalloc (iMaxOUWidth * iMaxOUHeight * sizeof (SBackgroundOU));
} }
void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth, void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_t iMbIndex, int32_t iMbWidth,
SBackgroundOU* pBgdOU) { SBackgroundOU* pBgdOU) {
int32_t iSubSD[4]; int32_t iSubSD[4];
uint8_t iSubMAD[4]; uint8_t iSubMAD[4];
int32_t iSubSAD[4]; int32_t iSubSAD[4];
uint8_t (*pMad8x8)[4]; uint8_t (*pMad8x8)[4];
int32_t (*pSad8x8)[4]; int32_t (*pSad8x8)[4];
@@ -141,9 +141,9 @@ void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_
iSubMAD[2] = pMad8x8[iMbIndex][2]; iSubMAD[2] = pMad8x8[iMbIndex][2];
iSubMAD[3] = pMad8x8[iMbIndex][3]; iSubMAD[3] = pMad8x8[iMbIndex][3];
pBgdOU->iSD = iSubSD[0] + iSubSD[1] + iSubSD[2] + iSubSD[3]; pBgdOU->iSD = iSubSD[0] + iSubSD[1] + iSubSD[2] + iSubSD[3];
pBgdOU->iSAD = iSubSAD[0] + iSubSAD[1] + iSubSAD[2] + iSubSAD[3]; pBgdOU->iSAD = iSubSAD[0] + iSubSAD[1] + iSubSAD[2] + iSubSAD[3];
pBgdOU->iSD = WELS_ABS (pBgdOU->iSD); pBgdOU->iSD = WELS_ABS (pBgdOU->iSD);
// get the max absolute difference (MAD) of OU and min value of the MAD of sub-blocks of OU // get the max absolute difference (MAD) of OU and min value of the MAD of sub-blocks of OU
pBgdOU->iMAD = WELS_MAX (WELS_MAX (iSubMAD[0], iSubMAD[1]), WELS_MAX (iSubMAD[2], iSubMAD[3])); pBgdOU->iMAD = WELS_MAX (WELS_MAX (iSubMAD[0], iSubMAD[1]), WELS_MAX (iSubMAD[2], iSubMAD[3]));
@@ -155,9 +155,9 @@ void CBackgroundDetection::GetOUParameters (SVAACalcResult* sVaaCalcInfo, int32_
} }
void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) { void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) {
int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE;
int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE;
int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4;
SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array; SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array;
@@ -187,8 +187,8 @@ void CBackgroundDetection::ForegroundBackgroundDivision (vBGDParam* pBgdParam) {
} }
} }
inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, uint8_t* pOriCur, int32_t iStride) { inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, uint8_t* pOriCur, int32_t iStride) {
int32_t ASD = 0; int32_t ASD = 0;
int32_t idx; int32_t idx;
for (idx = 0; idx < BGD_OU_SIZE_UV; idx++) { for (idx = 0; idx < BGD_OU_SIZE_UV; idx++) {
ASD += *pOriCur - *pOriRef; ASD += *pOriCur - *pOriRef;
pOriRef += iStride; pOriRef += iStride;
@@ -199,16 +199,16 @@ inline int32_t CBackgroundDetection::CalculateAsdChromaEdge (uint8_t* pOriRef, u
inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU, inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBackgroundOU,
SBackgroundOU* pOUNeighbours[]) { SBackgroundOU* pOUNeighbours[]) {
SBackgroundOU* pOU_L = pOUNeighbours[0]; SBackgroundOU* pOU_L = pOUNeighbours[0];
SBackgroundOU* pOU_R = pOUNeighbours[1]; SBackgroundOU* pOU_R = pOUNeighbours[1];
SBackgroundOU* pOU_U = pOUNeighbours[2]; SBackgroundOU* pOU_U = pOUNeighbours[2];
SBackgroundOU* pOU_D = pOUNeighbours[3]; SBackgroundOU* pOU_D = pOUNeighbours[3];
if (pBackgroundOU->iMAD > pBackgroundOU->iMinSubMad << 1) { if (pBackgroundOU->iMAD > pBackgroundOU->iMinSubMad << 1) {
int32_t iMaxNbrForegroundMad; int32_t iMaxNbrForegroundMad;
int32_t iMaxNbrBackgroundMad; int32_t iMaxNbrBackgroundMad;
int32_t aBackgroundMad[4]; int32_t aBackgroundMad[4];
int32_t aForegroundMad[4]; int32_t aForegroundMad[4];
aForegroundMad[0] = (pOU_L->iBackgroundFlag - 1) & pOU_L->iMAD; aForegroundMad[0] = (pOU_L->iBackgroundFlag - 1) & pOU_L->iMAD;
aForegroundMad[1] = (pOU_R->iBackgroundFlag - 1) & pOU_R->iMAD; aForegroundMad[1] = (pOU_R->iBackgroundFlag - 1) & pOU_R->iMAD;
@@ -232,9 +232,9 @@ inline bool CBackgroundDetection::ForegroundDilation23Luma (SBackgroundOU* pBack
inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourForegroundFlags, inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourForegroundFlags,
int32_t iStartSamplePos, int32_t iPicStrideUV, vBGDParam* pBgdParam) { int32_t iStartSamplePos, int32_t iPicStrideUV, vBGDParam* pBgdParam) {
static const int8_t kaOUPos[4] = {OU_LEFT, OU_RIGHT, OU_TOP, OU_BOTTOM}; static const int8_t kaOUPos[4] = {OU_LEFT, OU_RIGHT, OU_TOP, OU_BOTTOM};
int32_t aEdgeOffset[4] = {0, BGD_OU_SIZE_UV - 1, 0, iPicStrideUV* (BGD_OU_SIZE_UV - 1)}; int32_t aEdgeOffset[4] = {0, BGD_OU_SIZE_UV - 1, 0, iPicStrideUV* (BGD_OU_SIZE_UV - 1)};
int32_t iStride[4] = {iPicStrideUV, iPicStrideUV, 1, 1}; int32_t iStride[4] = {iPicStrideUV, iPicStrideUV, 1, 1};
// V component first, high probability because V stands for red color and human skin colors have more weight on this component // V component first, high probability because V stands for red color and human skin colors have more weight on this component
for (int32_t i = 0; i < 4; i++) { for (int32_t i = 0; i < 4; i++) {
@@ -262,8 +262,8 @@ inline bool CBackgroundDetection::ForegroundDilation23Chroma (int8_t iNeighbourF
inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[], inline void CBackgroundDetection::ForegroundDilation (SBackgroundOU* pBackgroundOU, SBackgroundOU* pOUNeighbours[],
vBGDParam* pBgdParam, int32_t iChromaSampleStartPos) { vBGDParam* pBgdParam, int32_t iChromaSampleStartPos) {
int32_t iPicStrideUV = pBgdParam->iStride[1]; int32_t iPicStrideUV = pBgdParam->iStride[1];
int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag + int32_t iSumNeighBackgroundFlags = pOUNeighbours[0]->iBackgroundFlag + pOUNeighbours[1]->iBackgroundFlag +
pOUNeighbours[2]->iBackgroundFlag + pOUNeighbours[3]->iBackgroundFlag; pOUNeighbours[2]->iBackgroundFlag + pOUNeighbours[3]->iBackgroundFlag;
if (pBackgroundOU->iSAD > BGD_OU_SIZE * Q_FACTOR) { if (pBackgroundOU->iSAD > BGD_OU_SIZE * Q_FACTOR) {
@@ -318,10 +318,10 @@ inline void CBackgroundDetection::SetBackgroundMbFlag (int8_t* pBackgroundMbFlag
inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU, int8_t* pBackgroundMbFlag, inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU, int8_t* pBackgroundMbFlag,
int32_t iPicWidthInOU, int32_t iPicWidthInMb) { int32_t iPicWidthInOU, int32_t iPicWidthInMb) {
if (pCurOU->iSAD > BGD_OU_SIZE * Q_FACTOR) { if (pCurOU->iSAD > BGD_OU_SIZE * Q_FACTOR) {
SBackgroundOU* pOU_L = pCurOU - 1; SBackgroundOU* pOU_L = pCurOU - 1;
SBackgroundOU* pOU_R = pCurOU + 1; SBackgroundOU* pOU_R = pCurOU + 1;
SBackgroundOU* pOU_U = pCurOU - iPicWidthInOU; SBackgroundOU* pOU_U = pCurOU - iPicWidthInOU;
SBackgroundOU* pOU_D = pCurOU + iPicWidthInOU; SBackgroundOU* pOU_D = pCurOU + iPicWidthInOU;
if (pOU_L->iBackgroundFlag + pOU_R->iBackgroundFlag + pOU_U->iBackgroundFlag + pOU_D->iBackgroundFlag <= 1) { if (pOU_L->iBackgroundFlag + pOU_R->iBackgroundFlag + pOU_U->iBackgroundFlag + pOU_D->iBackgroundFlag <= 1) {
SetBackgroundMbFlag (pBackgroundMbFlag, iPicWidthInMb, 0); SetBackgroundMbFlag (pBackgroundMbFlag, iPicWidthInMb, 0);
pCurOU->iBackgroundFlag = 0; pCurOU->iBackgroundFlag = 0;
@@ -330,21 +330,21 @@ inline void CBackgroundDetection::UpperOUForegroundCheck (SBackgroundOU* pCurOU,
} }
void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pBgdParam) { void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pBgdParam) {
int32_t iPicStrideUV = pBgdParam->iStride[1]; int32_t iPicStrideUV = pBgdParam->iStride[1];
int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE; int32_t iPicWidthInOU = pBgdParam->iBgdWidth >> LOG2_BGD_OU_SIZE;
int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE; int32_t iPicHeightInOU = pBgdParam->iBgdHeight >> LOG2_BGD_OU_SIZE;
int32_t iOUStrideUV = iPicStrideUV << (LOG2_BGD_OU_SIZE - 1); int32_t iOUStrideUV = iPicStrideUV << (LOG2_BGD_OU_SIZE - 1);
int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4; int32_t iPicWidthInMb = (15 + pBgdParam->iBgdWidth) >> 4;
SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array; SBackgroundOU* pBackgroundOU = pBgdParam->pOU_array;
int8_t* pVaaBackgroundMbFlag = (int8_t*)pBgdParam->pBackgroundMbFlag; int8_t* pVaaBackgroundMbFlag = (int8_t*)pBgdParam->pBackgroundMbFlag;
SBackgroundOU* pOUNeighbours[4];//0: left; 1: right; 2: top; 3: bottom SBackgroundOU* pOUNeighbours[4];//0: left; 1: right; 2: top; 3: bottom
pOUNeighbours[2] = pBackgroundOU;//top OU pOUNeighbours[2] = pBackgroundOU;//top OU
for (int32_t j = 0; j < iPicHeightInOU; j ++) { for (int32_t j = 0; j < iPicHeightInOU; j ++) {
int8_t* pRowSkipFlag = pVaaBackgroundMbFlag; int8_t* pRowSkipFlag = pVaaBackgroundMbFlag;
pOUNeighbours[0] = pBackgroundOU;//left OU pOUNeighbours[0] = pBackgroundOU;//left OU
pOUNeighbours[3] = pBackgroundOU + (iPicWidthInOU & ((j == iPicHeightInOU - 1) - 1)); //bottom OU pOUNeighbours[3] = pBackgroundOU + (iPicWidthInOU & ((j == iPicHeightInOU - 1) - 1)); //bottom OU
for (int32_t i = 0; i < iPicWidthInOU; i++) { for (int32_t i = 0; i < iPicWidthInOU; i++) {
pOUNeighbours[1] = pBackgroundOU + (i < iPicWidthInOU - 1); //right OU pOUNeighbours[1] = pBackgroundOU + (i < iPicWidthInOU - 1); //right OU
@@ -367,7 +367,7 @@ void CBackgroundDetection::ForegroundDilationAndBackgroundErosion (vBGDParam* pB
pOUNeighbours[3]++; pOUNeighbours[3]++;
pBackgroundOU++; pBackgroundOU++;
} }
pOUNeighbours[2] = pBackgroundOU - iPicWidthInOU; pOUNeighbours[2] = pBackgroundOU - iPicWidthInOU;
pVaaBackgroundMbFlag += OU_SIZE_IN_MB * iPicWidthInMb; pVaaBackgroundMbFlag += OU_SIZE_IN_MB * iPicWidthInMb;
} }
} }

View File

@@ -36,11 +36,11 @@ WELSVP_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
void* WelsMalloc (const uint32_t kuiSize, char* pTag) { void* WelsMalloc (const uint32_t kuiSize, char* pTag) {
const int32_t kiSizeVoidPointer = sizeof (void**); const int32_t kiSizeVoidPointer = sizeof (void**);
const int32_t kiSizeInt32 = sizeof (int32_t); const int32_t kiSizeInt32 = sizeof (int32_t);
const int32_t kiAlignedBytes = ALIGNBYTES - 1; const int32_t kiAlignedBytes = ALIGNBYTES - 1;
uint8_t* pBuf = (uint8_t*) ::malloc (kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32); uint8_t* pBuf = (uint8_t*) ::malloc (kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32);
uint8_t* pAlignedBuf = NULL; uint8_t* pAlignedBuf = NULL;
if (NULL == pBuf) if (NULL == pBuf)

View File

@@ -350,8 +350,8 @@ EResult CComplexityAnalysisScreen::Get (int32_t nType, void* pParam) {
void CComplexityAnalysisScreen::GomComplexityAnalysisIntra (SPixMap* pSrc) { void CComplexityAnalysisScreen::GomComplexityAnalysisIntra (SPixMap* pSrc) {
int32_t iWidth = pSrc->sRect.iRectWidth; int32_t iWidth = pSrc->sRect.iRectWidth;
int32_t iHeight = pSrc->sRect.iRectHeight; int32_t iHeight = pSrc->sRect.iRectHeight;
int32_t iBlockWidth = iWidth >> 4; int32_t iBlockWidth = iWidth >> 4;
int32_t iBlockHeight = iHeight >> 4; int32_t iBlockHeight = iHeight >> 4;
int32_t iBlockSadH, iBlockSadV, iGomSad = 0; int32_t iBlockSadH, iBlockSadV, iGomSad = 0;
int32_t iIdx = 0; int32_t iIdx = 0;
@@ -406,8 +406,8 @@ void CComplexityAnalysisScreen::GomComplexityAnalysisIntra (SPixMap* pSrc) {
void CComplexityAnalysisScreen::GomComplexityAnalysisInter (SPixMap* pSrc, SPixMap* pRef, bool bScrollFlag) { void CComplexityAnalysisScreen::GomComplexityAnalysisInter (SPixMap* pSrc, SPixMap* pRef, bool bScrollFlag) {
int32_t iWidth = pSrc->sRect.iRectWidth; int32_t iWidth = pSrc->sRect.iRectWidth;
int32_t iHeight = pSrc->sRect.iRectHeight; int32_t iHeight = pSrc->sRect.iRectHeight;
int32_t iBlockWidth = iWidth >> 4; int32_t iBlockWidth = iWidth >> 4;
int32_t iBlockHeight = iHeight >> 4; int32_t iBlockHeight = iHeight >> 4;
int32_t iInterSad, iScrollSad, iBlockSadH, iBlockSadV, iGomSad = 0; int32_t iInterSad, iScrollSad, iBlockSadH, iBlockSadV, iGomSad = 0;
int32_t iIdx = 0; int32_t iIdx = 0;

View File

@@ -46,7 +46,7 @@ CDenoiser::CDenoiser (int32_t iCpuFlag) {
m_uiSpaceRadius = DENOISE_GRAY_RADIUS; m_uiSpaceRadius = DENOISE_GRAY_RADIUS;
m_fSigmaGrey = DENOISE_GRAY_SIGMA; m_fSigmaGrey = DENOISE_GRAY_SIGMA;
m_uiType = DENOISE_ALL_COMPONENT; m_uiType = DENOISE_ALL_COMPONENT;
InitDenoiseFunc (m_pfDenoise, m_CPUFlag); InitDenoiseFunc (m_pfDenoise, m_CPUFlag);
} }

View File

@@ -49,11 +49,11 @@ void DyadicBilinearDownsampler_c (uint8_t* pDst, const int32_t kiDstStride,
const int32_t kiSrcWidth, const int32_t kiSrcHeight) const int32_t kiSrcWidth, const int32_t kiSrcHeight)
{ {
uint8_t* pDstLine = pDst; uint8_t* pDstLine = pDst;
uint8_t* pSrcLine = pSrc; uint8_t* pSrcLine = pSrc;
const int32_t kiSrcStridex2 = kiSrcStride << 1; const int32_t kiSrcStridex2 = kiSrcStride << 1;
const int32_t kiDstWidth = kiSrcWidth >> 1; const int32_t kiDstWidth = kiSrcWidth >> 1;
const int32_t kiDstHeight = kiSrcHeight >> 1; const int32_t kiDstHeight = kiSrcHeight >> 1;
for (int32_t j = 0; j < kiDstHeight; j ++) { for (int32_t j = 0; j < kiDstHeight; j ++) {
for (int32_t i = 0; i < kiDstWidth; i ++) { for (int32_t i = 0; i < kiDstWidth; i ++) {
@@ -63,8 +63,8 @@ void DyadicBilinearDownsampler_c (uint8_t* pDst, const int32_t kiDstStride,
pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1); pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1);
} }
pDstLine += kiDstStride; pDstLine += kiDstStride;
pSrcLine += kiSrcStridex2; pSrcLine += kiSrcStridex2;
} }
} }

View File

@@ -69,9 +69,9 @@ int32_t CheckLine (uint8_t* pData, int32_t iWidth) {
int32_t SelectTestLine (uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight, int32_t SelectTestLine (uint8_t* pY, int32_t iWidth, int32_t iHeight, int32_t iPicHeight,
int32_t iStride, int32_t iOffsetX, int32_t iOffsetY) { int32_t iStride, int32_t iOffsetX, int32_t iOffsetY) {
const int32_t kiHalfHeight = iHeight >> 1; const int32_t kiHalfHeight = iHeight >> 1;
const int32_t kiMidPos = iOffsetY + kiHalfHeight; const int32_t kiMidPos = iOffsetY + kiHalfHeight;
int32_t TestPos = kiMidPos; int32_t TestPos = kiMidPos;
int32_t iOffsetAbs; int32_t iOffsetAbs;
uint8_t* pTmp; uint8_t* pTmp;

View File

@@ -87,11 +87,11 @@ void CVAACalculation::InitVaaFuncs (SVaaFuncs& sVaaFuncs, int32_t iCpuFlag) {
} }
EResult CVAACalculation::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) { EResult CVAACalculation::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pRefPixMap) {
uint8_t* pCurData = (uint8_t*)pSrcPixMap->pPixel[0]; uint8_t* pCurData = (uint8_t*)pSrcPixMap->pPixel[0];
uint8_t* pRefData = (uint8_t*)pRefPixMap->pPixel[0]; uint8_t* pRefData = (uint8_t*)pRefPixMap->pPixel[0];
int32_t iPicWidth = pSrcPixMap->sRect.iRectWidth; int32_t iPicWidth = pSrcPixMap->sRect.iRectWidth;
int32_t iPicHeight = pSrcPixMap->sRect.iRectHeight; int32_t iPicHeight = pSrcPixMap->sRect.iRectHeight;
int32_t iPicStride = pSrcPixMap->iStride[0]; int32_t iPicStride = pSrcPixMap->iStride[0];
SVAACalcResult* pResult = m_sCalcParam.pCalcResult; SVAACalcResult* pResult = m_sCalcParam.pCalcResult;

View File

@@ -543,15 +543,15 @@ void EncodeDecodeTestAPIBase::SliceParamValidationForMode2 (int iSpatialIdx) {
unsigned int uiSliceIdx = 0; unsigned int uiSliceIdx = 0;
unsigned int uiActualSliceCount = 0; unsigned int uiActualSliceCount = 0;
uiMbWidth = (param_.iPicWidth + 15) >> 4; uiMbWidth = (param_.iPicWidth + 15) >> 4;
uiMbHeight = (param_.iPicHeight + 15) >> 4; uiMbHeight = (param_.iPicHeight + 15) >> 4;
uiMbNumInFrame = uiMbWidth * uiMbHeight; uiMbNumInFrame = uiMbWidth * uiMbHeight;
uiSliceIdx = 0; uiSliceIdx = 0;
while (uiSliceIdx < MAX_SLICES_NUM) { while (uiSliceIdx < MAX_SLICES_NUM) {
param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx] = rand() % uiMbNumInFrame; param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx] = rand() % uiMbNumInFrame;
uiCountMb += param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx]; uiCountMb += param_.sSpatialLayers[iSpatialIdx].sSliceCfg.sSliceArgument.uiSliceMbNum[uiSliceIdx];
uiActualSliceCount = uiSliceIdx + 1; uiActualSliceCount = uiSliceIdx + 1;
if (uiCountMb >= uiMbNumInFrame) { if (uiCountMb >= uiMbNumInFrame) {
break; break;

View File

@@ -218,23 +218,23 @@ TEST (ExpandPicture, ExpandPicForMotion) {
if (uiCpuFlag & WELS_CPU_SSE2) { if (uiCpuFlag & WELS_CPU_SSE2) {
iPicWidth = WELS_ALIGN (iPicWidth, 32); iPicWidth = WELS_ALIGN (iPicWidth, 32);
} }
iStride[0] = WELS_ALIGN (iPicWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon iStride[0] = WELS_ALIGN (iPicWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with width of horizon
int32_t iPicHeightExt = WELS_ALIGN (iPicHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical int32_t iPicHeightExt = WELS_ALIGN (iPicHeight, MB_HEIGHT_LUMA) + (PADDING_LENGTH << 1); // with height of vertical
iStride[1] = iStride[0] >> 1; iStride[1] = iStride[0] >> 1;
int32_t iPicChromaHeightExt = iPicHeightExt >> 1; int32_t iPicChromaHeightExt = iPicHeightExt >> 1;
iStride[2] = iStride[1]; iStride[2] = iStride[1];
int32_t iLumaSize = iStride[0] * iPicHeightExt; int32_t iLumaSize = iStride[0] * iPicHeightExt;
int32_t iChromaSize = iStride[1] * iPicChromaHeightExt; int32_t iChromaSize = iStride[1] * iPicChromaHeightExt;
pPicAnchorBuffer = static_cast<uint8_t*> (WelsMallocz (iLumaSize + (iChromaSize << 1), "pPicAnchor")); pPicAnchorBuffer = static_cast<uint8_t*> (WelsMallocz (iLumaSize + (iChromaSize << 1), "pPicAnchor"));
pPicAnchor[0] = pPicAnchorBuffer + (1 + iStride[0]) * PADDING_LENGTH; pPicAnchor[0] = pPicAnchorBuffer + (1 + iStride[0]) * PADDING_LENGTH;
pPicAnchor[1] = pPicAnchorBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1); pPicAnchor[1] = pPicAnchorBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1);
pPicAnchor[2] = pPicAnchorBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1); pPicAnchor[2] = pPicAnchorBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1);
pPicTestBuffer = static_cast<uint8_t*> (WelsMallocz (iLumaSize + (iChromaSize << 1), "pPicTest")); pPicTestBuffer = static_cast<uint8_t*> (WelsMallocz (iLumaSize + (iChromaSize << 1), "pPicTest"));
pPicTest[0] = pPicTestBuffer + (1 + iStride[0]) * PADDING_LENGTH; pPicTest[0] = pPicTestBuffer + (1 + iStride[0]) * PADDING_LENGTH;
pPicTest[1] = pPicTestBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1); pPicTest[1] = pPicTestBuffer + iLumaSize + (((1 + iStride[1]) * PADDING_LENGTH) >> 1);
pPicTest[2] = pPicTestBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1); pPicTest[2] = pPicTestBuffer + iLumaSize + iChromaSize + (((1 + iStride[2]) * PADDING_LENGTH) >> 1);
// Generate Src // Generate Src

View File

@@ -7,9 +7,9 @@ using namespace WelsDec;
void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
int16_t iSrc[16]; int16_t iSrc[16];
uint8_t* pDst = pPred; uint8_t* pDst = pPred;
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
int32_t i; int32_t i;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
@@ -26,16 +26,16 @@ void IdctResAddPred_ref (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
} }
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
int32_t kT1 = iSrc[i] + iSrc[i + 8]; int32_t kT1 = iSrc[i] + iSrc[i + 8];
int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1); int32_t kT2 = iSrc[i + 4] + (iSrc[i + 12] >> 1);
int32_t kT3 = (32 + kT1 + kT2) >> 6; int32_t kT3 = (32 + kT1 + kT2) >> 6;
int32_t kT4 = (32 + kT1 - kT2) >> 6; int32_t kT4 = (32 + kT1 - kT2) >> 6;
pDst[i] = WelsClip1 (kT3 + pPred[i]); pDst[i] = WelsClip1 (kT3 + pPred[i]);
pDst[i + kiStride3] = WelsClip1 (kT4 + pPred[i + kiStride3]); pDst[i + kiStride3] = WelsClip1 (kT4 + pPred[i + kiStride3]);
kT1 = iSrc[i] - iSrc[i + 8]; kT1 = iSrc[i] - iSrc[i + 8];
kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12]; kT2 = (iSrc[i + 4] >> 1) - iSrc[i + 12];
pDst[i + kiStride] = WelsClip1 (((32 + kT1 + kT2) >> 6) + pDst[i + kiStride]); pDst[i + kiStride] = WelsClip1 (((32 + kT1 + kT2) >> 6) + pDst[i + kiStride]);
pDst[i + kiStride2] = WelsClip1 (((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2]); pDst[i + kiStride2] = WelsClip1 (((32 + kT1 - kT2) >> 6) + pDst[i + kiStride2]);
} }

View File

@@ -93,25 +93,25 @@ void LumaI##size##x##size##PredDCNone(uint8_t *pPred, const int32_t kiStride) {\
/*down pLeft*/ /*down pLeft*/
void WelsI4x4LumaPredDDL_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDDL_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
/*get pTop*/ /*get pTop*/
uint8_t* ptop = &pPred[-kiStride]; uint8_t* ptop = &pPred[-kiStride];
const uint8_t kuiT0 = *ptop; const uint8_t kuiT0 = *ptop;
const uint8_t kuiT1 = * (ptop + 1); const uint8_t kuiT1 = * (ptop + 1);
const uint8_t kuiT2 = * (ptop + 2); const uint8_t kuiT2 = * (ptop + 2);
const uint8_t kuiT3 = * (ptop + 3); const uint8_t kuiT3 = * (ptop + 3);
const uint8_t kuiT4 = * (ptop + 4); const uint8_t kuiT4 = * (ptop + 4);
const uint8_t kuiT5 = * (ptop + 5); const uint8_t kuiT5 = * (ptop + 5);
const uint8_t kuiT6 = * (ptop + 6); const uint8_t kuiT6 = * (ptop + 6);
const uint8_t kuiT7 = * (ptop + 7); const uint8_t kuiT7 = * (ptop + 7);
const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0 const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2; // kDDL0
const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1 const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2; // kDDL1
const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2 const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2; // kDDL2
const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3 const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2; // kDDL3
const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4 const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2; // kDDL4
const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5 const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2; // kDDL5
const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6 const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2; // kDDL6
const uint8_t kuiList[8] = { kuiDDL0, kuiDDL1, kuiDDL2, kuiDDL3, kuiDDL4, kuiDDL5, kuiDDL6, 0 }; const uint8_t kuiList[8] = { kuiDDL0, kuiDDL1, kuiDDL2, kuiDDL3, kuiDDL4, kuiDDL5, kuiDDL6, 0 };
ST32 (pPred , LD32 (kuiList)); ST32 (pPred , LD32 (kuiList));
@@ -122,22 +122,22 @@ void WelsI4x4LumaPredDDL_ref (uint8_t* pPred, const int32_t kiStride) {
/*down pLeft*/ /*down pLeft*/
void WelsI4x4LumaPredDDLTop_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDDLTop_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
/*get pTop*/ /*get pTop*/
uint8_t* ptop = &pPred[-kiStride]; uint8_t* ptop = &pPred[-kiStride];
const uint8_t kuiT0 = *ptop; const uint8_t kuiT0 = *ptop;
const uint8_t kuiT1 = * (ptop + 1); const uint8_t kuiT1 = * (ptop + 1);
const uint8_t kuiT2 = * (ptop + 2); const uint8_t kuiT2 = * (ptop + 2);
const uint8_t kuiT3 = * (ptop + 3); const uint8_t kuiT3 = * (ptop + 3);
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiT33 = 1 + (kuiT3 << 1); const uint16_t kuiT33 = 1 + (kuiT3 << 1);
const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0 const uint8_t kuiDLT0 = (kuiT01 + kuiT12) >> 2; // kDLT0
const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1 const uint8_t kuiDLT1 = (kuiT12 + kuiT23) >> 2; // kDLT1
const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2 const uint8_t kuiDLT2 = (kuiT23 + kuiT33) >> 2; // kDLT2
const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3 const uint8_t kuiDLT3 = kuiT33 >> 1; // kDLT3
const uint8_t kuiList[8] = { kuiDLT0, kuiDLT1, kuiDLT2, kuiDLT3, kuiDLT3, kuiDLT3, kuiDLT3 , kuiDLT3 }; const uint8_t kuiList[8] = { kuiDLT0, kuiDLT1, kuiDLT2, kuiDLT3, kuiDLT3, kuiDLT3, kuiDLT3 , kuiDLT3 };
ST32 (pPred, LD32 (kuiList)); ST32 (pPred, LD32 (kuiList));
@@ -149,36 +149,36 @@ void WelsI4x4LumaPredDDLTop_ref (uint8_t* pPred, const int32_t kiStride) {
/*down right*/ /*down right*/
void WelsI4x4LumaPredDDR_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredDDR_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* ptopleft = &pPred[- (kiStride + 1)]; uint8_t* ptopleft = &pPred[- (kiStride + 1)];
uint8_t* pleft = &pPred[-1]; uint8_t* pleft = &pPred[-1];
const uint8_t kuiLT = *ptopleft; const uint8_t kuiLT = *ptopleft;
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = *pleft; const uint8_t kuiL0 = *pleft;
const uint8_t kuiL1 = * (pleft + kiStride); const uint8_t kuiL1 = * (pleft + kiStride);
const uint8_t kuiL2 = * (pleft + kiStride2); const uint8_t kuiL2 = * (pleft + kiStride2);
const uint8_t kuiL3 = * (pleft + kiStride3); const uint8_t kuiL3 = * (pleft + kiStride3);
const uint8_t kuiT0 = * (ptopleft + 1); const uint8_t kuiT0 = * (ptopleft + 1);
const uint8_t kuiT1 = * (ptopleft + 2); const uint8_t kuiT1 = * (ptopleft + 2);
const uint8_t kuiT2 = * (ptopleft + 3); const uint8_t kuiT2 = * (ptopleft + 3);
const uint8_t kuiT3 = * (ptopleft + 4); const uint8_t kuiT3 = * (ptopleft + 4);
const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0 const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2; // kuiDDR0
const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1 const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2; // kuiDDR1
const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2 const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2; // kuiDDR2
const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3 const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2; // kuiDDR3
const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4 const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2; // kuiDDR4
const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5 const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2; // kuiDDR5
const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6 const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2; // kuiDDR6
const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 }; const uint8_t kuiList[8] = { kuiDDR6, kuiDDR5, kuiDDR4, kuiDDR0, kuiDDR1, kuiDDR2, kuiDDR3, 0 };
ST32 (pPred , LD32 (kuiList + 3)); ST32 (pPred , LD32 (kuiList + 3));
ST32 (pPred + kiStride , LD32 (kuiList + 2)); ST32 (pPred + kiStride , LD32 (kuiList + 2));
@@ -189,34 +189,34 @@ void WelsI4x4LumaPredDDR_ref (uint8_t* pPred, const int32_t kiStride) {
/*vertical pLeft*/ /*vertical pLeft*/
void WelsI4x4LumaPredVL_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredVL_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* ptopleft = &pPred[- (kiStride + 1)]; uint8_t* ptopleft = &pPred[- (kiStride + 1)];
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = * (ptopleft + 1); const uint8_t kuiT0 = * (ptopleft + 1);
const uint8_t kuiT1 = * (ptopleft + 2); const uint8_t kuiT1 = * (ptopleft + 2);
const uint8_t kuiT2 = * (ptopleft + 3); const uint8_t kuiT2 = * (ptopleft + 3);
const uint8_t kuiT3 = * (ptopleft + 4); const uint8_t kuiT3 = * (ptopleft + 4);
const uint8_t kuiT4 = * (ptopleft + 5); const uint8_t kuiT4 = * (ptopleft + 5);
const uint8_t kuiT5 = * (ptopleft + 6); const uint8_t kuiT5 = * (ptopleft + 6);
const uint8_t kuiT6 = * (ptopleft + 7); const uint8_t kuiT6 = * (ptopleft + 7);
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiT34 = 1 + kuiT3 + kuiT4; const uint16_t kuiT34 = 1 + kuiT3 + kuiT4;
const uint16_t kuiT45 = 1 + kuiT4 + kuiT5; const uint16_t kuiT45 = 1 + kuiT4 + kuiT5;
const uint16_t kuiT56 = 1 + kuiT5 + kuiT6; const uint16_t kuiT56 = 1 + kuiT5 + kuiT6;
const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0 const uint8_t kuiVL0 = kuiT01 >> 1; // kuiVL0
const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1 const uint8_t kuiVL1 = kuiT12 >> 1; // kuiVL1
const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2 const uint8_t kuiVL2 = kuiT23 >> 1; // kuiVL2
const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3 const uint8_t kuiVL3 = kuiT34 >> 1; // kuiVL3
const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4 const uint8_t kuiVL4 = kuiT45 >> 1; // kuiVL4
const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5 const uint8_t kuiVL5 = (kuiT01 + kuiT12) >> 2; // kuiVL5
const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6 const uint8_t kuiVL6 = (kuiT12 + kuiT23) >> 2; // kuiVL6
const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7 const uint8_t kuiVL7 = (kuiT23 + kuiT34) >> 2; // kuiVL7
const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8 const uint8_t kuiVL8 = (kuiT34 + kuiT45) >> 2; // kuiVL8
const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9 const uint8_t kuiVL9 = (kuiT45 + kuiT56) >> 2; // kuiVL9
const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 }; const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL8, kuiVL9 };
ST32 (pPred, LD32 (kuiList)); ST32 (pPred, LD32 (kuiList));
ST32 (pPred + kiStride, LD32 (kuiList + 5)); ST32 (pPred + kiStride, LD32 (kuiList + 5));
@@ -226,27 +226,27 @@ void WelsI4x4LumaPredVL_ref (uint8_t* pPred, const int32_t kiStride) {
/*vertical pLeft*/ /*vertical pLeft*/
void WelsI4x4LumaPredVLTop_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredVLTop_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* ptopleft = &pPred[- (kiStride + 1)]; uint8_t* ptopleft = &pPred[- (kiStride + 1)];
/*get pTop*/ /*get pTop*/
const uint8_t kuiT0 = * (ptopleft + 1); const uint8_t kuiT0 = * (ptopleft + 1);
const uint8_t kuiT1 = * (ptopleft + 2); const uint8_t kuiT1 = * (ptopleft + 2);
const uint8_t kuiT2 = * (ptopleft + 3); const uint8_t kuiT2 = * (ptopleft + 3);
const uint8_t kuiT3 = * (ptopleft + 4); const uint8_t kuiT3 = * (ptopleft + 4);
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiT23 = 1 + kuiT2 + kuiT3; const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
const uint16_t kuiT33 = 1 + (kuiT3 << 1); const uint16_t kuiT33 = 1 + (kuiT3 << 1);
const uint8_t kuiVL0 = kuiT01 >> 1; const uint8_t kuiVL0 = kuiT01 >> 1;
const uint8_t kuiVL1 = kuiT12 >> 1; const uint8_t kuiVL1 = kuiT12 >> 1;
const uint8_t kuiVL2 = kuiT23 >> 1; const uint8_t kuiVL2 = kuiT23 >> 1;
const uint8_t kuiVL3 = kuiT33 >> 1; const uint8_t kuiVL3 = kuiT33 >> 1;
const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2; const uint8_t kuiVL4 = (kuiT01 + kuiT12) >> 2;
const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2; const uint8_t kuiVL5 = (kuiT12 + kuiT23) >> 2;
const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2; const uint8_t kuiVL6 = (kuiT23 + kuiT33) >> 2;
const uint8_t kuiVL7 = kuiVL3; const uint8_t kuiVL7 = kuiVL3;
const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 }; const uint8_t kuiList[10] = { kuiVL0, kuiVL1, kuiVL2, kuiVL3, kuiVL3, kuiVL4, kuiVL5, kuiVL6, kuiVL7, kuiVL7 };
ST32 (pPred , LD32 (kuiList)); ST32 (pPred , LD32 (kuiList));
ST32 (pPred + kiStride , LD32 (kuiList + 5)); ST32 (pPred + kiStride , LD32 (kuiList + 5));
@@ -257,28 +257,28 @@ void WelsI4x4LumaPredVLTop_ref (uint8_t* pPred, const int32_t kiStride) {
/*vertical right*/ /*vertical right*/
void WelsI4x4LumaPredVR_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredVR_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
const uint8_t kuiLT = pPred[-kiStride - 1]; const uint8_t kuiLT = pPred[-kiStride - 1];
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pPred[ -1]; const uint8_t kuiL0 = pPred[ - 1];
const uint8_t kuiL1 = pPred[kiStride - 1]; const uint8_t kuiL1 = pPred[kiStride - 1];
const uint8_t kuiL2 = pPred[kiStride2 - 1]; const uint8_t kuiL2 = pPred[kiStride2 - 1];
const uint8_t kuiT0 = pPred[ -kiStride]; const uint8_t kuiT0 = pPred[ -kiStride];
const uint8_t kuiT1 = pPred[1 - kiStride]; const uint8_t kuiT1 = pPred[1 - kiStride];
const uint8_t kuiT2 = pPred[2 - kiStride]; const uint8_t kuiT2 = pPred[2 - kiStride];
const uint8_t kuiT3 = pPred[3 - kiStride]; const uint8_t kuiT3 = pPred[3 - kiStride];
const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0 const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1; // kuiVR0
const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1 const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1; // kuiVR1
const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2 const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1; // kuiVR2
const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3 const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1; // kuiVR3
const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4 const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2; // kuiVR4
const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5 const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2; // kuiVR5
const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6 const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2; // kuiVR6
const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7 const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2; // kuiVR7
const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8 const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2; // kuiVR8
const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9 const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2; // kuiVR9
const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 }; const uint8_t kuiList[10] = { kuiVR8, kuiVR0, kuiVR1, kuiVR2, kuiVR3, kuiVR9, kuiVR4, kuiVR5, kuiVR6, kuiVR7 };
ST32 (pPred , LD32 (kuiList + 1)); ST32 (pPred , LD32 (kuiList + 1));
ST32 (pPred + kiStride , LD32 (kuiList + 6)); ST32 (pPred + kiStride , LD32 (kuiList + 6));
@@ -288,23 +288,23 @@ void WelsI4x4LumaPredVR_ref (uint8_t* pPred, const int32_t kiStride) {
/*horizontal up*/ /*horizontal up*/
void WelsI4x4LumaPredHU_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredHU_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
/*get pLeft*/ /*get pLeft*/
const uint8_t kuiL0 = pPred[ -1]; const uint8_t kuiL0 = pPred[ - 1];
const uint8_t kuiL1 = pPred[kiStride - 1]; const uint8_t kuiL1 = pPred[kiStride - 1];
const uint8_t kuiL2 = pPred[kiStride2 - 1]; const uint8_t kuiL2 = pPred[kiStride2 - 1];
const uint8_t kuiL3 = pPred[kiStride3 - 1]; const uint8_t kuiL3 = pPred[kiStride3 - 1];
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiHU0 = kuiL01 >> 1; const uint8_t kuiHU0 = kuiL01 >> 1;
const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2; const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiHU2 = kuiL12 >> 1; const uint8_t kuiHU2 = kuiL12 >> 1;
const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2;
const uint8_t kuiHU4 = kuiL23 >> 1; const uint8_t kuiHU4 = kuiL23 >> 1;
const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2; const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2;
const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 }; const uint8_t kuiList[10] = { kuiHU0, kuiHU1, kuiHU2, kuiHU3, kuiHU4, kuiHU5, kuiL3, kuiL3, kuiL3, kuiL3 };
ST32 (pPred , LD32 (kuiList)); ST32 (pPred , LD32 (kuiList));
ST32 (pPred + kiStride , LD32 (kuiList + 2)); ST32 (pPred + kiStride , LD32 (kuiList + 2));
@@ -314,35 +314,35 @@ void WelsI4x4LumaPredHU_ref (uint8_t* pPred, const int32_t kiStride) {
/*horizontal down*/ /*horizontal down*/
void WelsI4x4LumaPredHD_ref (uint8_t* pPred, const int32_t kiStride) { void WelsI4x4LumaPredHD_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
const uint8_t kuiLT = pPred[- (kiStride + 1)]; const uint8_t kuiLT = pPred[- (kiStride + 1)];
/*get pLeft and pTop*/ /*get pLeft and pTop*/
const uint8_t kuiL0 = pPred[-1 ]; const uint8_t kuiL0 = pPred[-1 ];
const uint8_t kuiL1 = pPred[-1 + kiStride ]; const uint8_t kuiL1 = pPred[-1 + kiStride ];
const uint8_t kuiL2 = pPred[-1 + kiStride2]; const uint8_t kuiL2 = pPred[-1 + kiStride2];
const uint8_t kuiL3 = pPred[-1 + kiStride3]; const uint8_t kuiL3 = pPred[-1 + kiStride3];
const uint8_t kuiT0 = pPred[-kiStride ]; const uint8_t kuiT0 = pPred[-kiStride ];
const uint8_t kuiT1 = pPred[-kiStride + 1 ]; const uint8_t kuiT1 = pPred[-kiStride + 1 ];
const uint8_t kuiT2 = pPred[-kiStride + 2 ]; const uint8_t kuiT2 = pPred[-kiStride + 2 ];
const uint16_t kuiTL0 = 1 + kuiLT + kuiL0; const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
const uint16_t kuiLT0 = 1 + kuiLT + kuiT0; const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
const uint16_t kuiT01 = 1 + kuiT0 + kuiT1; const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
const uint16_t kuiT12 = 1 + kuiT1 + kuiT2; const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
const uint16_t kuiL01 = 1 + kuiL0 + kuiL1; const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
const uint16_t kuiL12 = 1 + kuiL1 + kuiL2; const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
const uint16_t kuiL23 = 1 + kuiL2 + kuiL3; const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
const uint8_t kuiHD0 = kuiTL0 >> 1; const uint8_t kuiHD0 = kuiTL0 >> 1;
const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2; const uint8_t kuiHD1 = (kuiTL0 + kuiLT0) >> 2;
const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2; const uint8_t kuiHD2 = (kuiLT0 + kuiT01) >> 2;
const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2; const uint8_t kuiHD3 = (kuiT01 + kuiT12) >> 2;
const uint8_t kuiHD4 = kuiL01 >> 1; const uint8_t kuiHD4 = kuiL01 >> 1;
const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2; const uint8_t kuiHD5 = (kuiTL0 + kuiL01) >> 2;
const uint8_t kuiHD6 = kuiL12 >> 1; const uint8_t kuiHD6 = kuiL12 >> 1;
const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2; const uint8_t kuiHD7 = (kuiL01 + kuiL12) >> 2;
const uint8_t kuiHD8 = kuiL23 >> 1; const uint8_t kuiHD8 = kuiL23 >> 1;
const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2; const uint8_t kuiHD9 = (kuiL12 + kuiL23) >> 2;
const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 }; const uint8_t kuiList[10] = { kuiHD8, kuiHD9, kuiHD6, kuiHD7, kuiHD4, kuiHD5, kuiHD0, kuiHD1, kuiHD2, kuiHD3 };
ST32 (pPred , LD32 (kuiList + 6)); ST32 (pPred , LD32 (kuiList + 6));
ST32 (pPred + kiStride , LD32 (kuiList + 4)); ST32 (pPred + kiStride , LD32 (kuiList + 4));
@@ -433,27 +433,27 @@ void WelsIChromaPredPlane_ref (uint8_t* pPred, const int32_t kiStride) {
void WelsIChromaPredDc_ref (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDc_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiL1 = kiStride - 1; const int32_t kiL1 = kiStride - 1;
const int32_t kiL2 = kiL1 + kiStride; const int32_t kiL2 = kiL1 + kiStride;
const int32_t kiL3 = kiL2 + kiStride; const int32_t kiL3 = kiL2 + kiStride;
const int32_t kiL4 = kiL3 + kiStride; const int32_t kiL4 = kiL3 + kiStride;
const int32_t kiL5 = kiL4 + kiStride; const int32_t kiL5 = kiL4 + kiStride;
const int32_t kiL6 = kiL5 + kiStride; const int32_t kiL6 = kiL5 + kiStride;
const int32_t kiL7 = kiL6 + kiStride; const int32_t kiL7 = kiL6 + kiStride;
/*caculate the kMean value*/ /*caculate the kMean value*/
const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] + const uint8_t kuiM1 = (pPred[-kiStride] + pPred[1 - kiStride] + pPred[2 - kiStride] + pPred[3 - kiStride] +
pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ; pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 4) >> 3 ;
const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride]; const uint32_t kuiSum2 = pPred[4 - kiStride] + pPred[5 - kiStride] + pPred[6 - kiStride] + pPred[7 - kiStride];
const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7]; const uint32_t kuiSum3 = pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7];
const uint8_t kuiM2 = (kuiSum2 + 2) >> 2; const uint8_t kuiM2 = (kuiSum2 + 2) >> 2;
const uint8_t kuiM3 = (kuiSum3 + 2) >> 2; const uint8_t kuiM3 = (kuiSum3 + 2) >> 2;
const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3; const uint8_t kuiM4 = (kuiSum2 + kuiSum3 + 4) >> 3;
const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2}; const uint8_t kuiMUP[8] = {kuiM1, kuiM1, kuiM1, kuiM1, kuiM2, kuiM2, kuiM2, kuiM2};
const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4}; const uint8_t kuiMDown[8] = {kuiM3, kuiM3, kuiM3, kuiM3, kuiM4, kuiM4, kuiM4, kuiM4};
const uint64_t kuiUP64 = LD64 (kuiMUP); const uint64_t kuiUP64 = LD64 (kuiMUP);
const uint64_t kuiDN64 = LD64 (kuiMDown); const uint64_t kuiDN64 = LD64 (kuiMDown);
ST64 (pPred , kuiUP64); ST64 (pPred , kuiUP64);
ST64 (pPred + kiL1 + 1, kuiUP64); ST64 (pPred + kiL1 + 1, kuiUP64);
ST64 (pPred + kiL2 + 1, kuiUP64); ST64 (pPred + kiL2 + 1, kuiUP64);
ST64 (pPred + kiL3 + 1, kuiUP64); ST64 (pPred + kiL3 + 1, kuiUP64);
@@ -464,20 +464,20 @@ void WelsIChromaPredDc_ref (uint8_t* pPred, const int32_t kiStride) {
} }
void WelsIChromaPredDcLeft_ref (uint8_t* pPred, const int32_t kiStride) { void WelsIChromaPredDcLeft_ref (uint8_t* pPred, const int32_t kiStride) {
const int32_t kiL1 = -1 + kiStride; const int32_t kiL1 = -1 + kiStride;
const int32_t kiL2 = kiL1 + kiStride; const int32_t kiL2 = kiL1 + kiStride;
const int32_t kiL3 = kiL2 + kiStride; const int32_t kiL3 = kiL2 + kiStride;
const int32_t kiL4 = kiL3 + kiStride; const int32_t kiL4 = kiL3 + kiStride;
const int32_t kiL5 = kiL4 + kiStride; const int32_t kiL5 = kiL4 + kiStride;
const int32_t kiL6 = kiL5 + kiStride; const int32_t kiL6 = kiL5 + kiStride;
const int32_t kiL7 = kiL6 + kiStride; const int32_t kiL7 = kiL6 + kiStride;
/*caculate the kMean value*/ /*caculate the kMean value*/
const uint8_t kuiMUP = (pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 2) >> 2 ; const uint8_t kuiMUP = (pPred[-1] + pPred[kiL1] + pPred[kiL2] + pPred[kiL3] + 2) >> 2 ;
const uint8_t kuiMDown = (pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7] + 2) >> 2; const uint8_t kuiMDown = (pPred[kiL4] + pPred[kiL5] + pPred[kiL6] + pPred[kiL7] + 2) >> 2;
const uint64_t kuiUP64 = 0x0101010101010101ULL * kuiMUP; const uint64_t kuiUP64 = 0x0101010101010101ULL * kuiMUP;
const uint64_t kuiDN64 = 0x0101010101010101ULL * kuiMDown; const uint64_t kuiDN64 = 0x0101010101010101ULL * kuiMDown;
ST64 (pPred , kuiUP64); ST64 (pPred , kuiUP64);
ST64 (pPred + kiL1 + 1, kuiUP64); ST64 (pPred + kiL1 + 1, kuiUP64);
ST64 (pPred + kiL2 + 1, kuiUP64); ST64 (pPred + kiL2 + 1, kuiUP64);
ST64 (pPred + kiL3 + 1, kuiUP64); ST64 (pPred + kiL3 + 1, kuiUP64);

View File

@@ -421,8 +421,8 @@ void WelsHadamardT4DcAnchor (int16_t* pLumaDc, int16_t* pDct) {
int32_t i, iIdx; int32_t i, iIdx;
for (i = 0 ; i < 16 ; i += 4) { for (i = 0 ; i < 16 ; i += 4) {
iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3); iIdx = ((i & 0x08) << 4) + ((i & 0x04) << 3);
s[0] = pDct[iIdx ] + pDct[iIdx + 80]; s[0] = pDct[iIdx ] + pDct[iIdx + 80];
s[3] = pDct[iIdx ] - pDct[iIdx + 80]; s[3] = pDct[iIdx ] - pDct[iIdx + 80];
s[1] = pDct[iIdx + 16] + pDct[iIdx + 64]; s[1] = pDct[iIdx + 16] + pDct[iIdx + 64];
s[2] = pDct[iIdx + 16] - pDct[iIdx + 64]; s[2] = pDct[iIdx + 16] - pDct[iIdx + 64];
p[i ] = s[0] + s[1]; p[i ] = s[0] + s[1];

View File

@@ -9,7 +9,7 @@ using namespace WelsEnc;
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredV) { TEST (GetIntraPredictorTest, TestGetI4x4LumaPredV) {
uint8_t* pPred = new uint8_t[64]; uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[64]; uint8_t* pRef = new uint8_t[64];
for (int i = 0; i < 64; i++) for (int i = 0; i < 64; i++)
pRef[i] = rand() % 256; pRef[i] = rand() % 256;
@@ -137,8 +137,8 @@ TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDLTop) {
TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDR) { TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
const int32_t kiStride = rand() % 256 + 16; const int32_t kiStride = rand() % 256 + 16;
const int32_t kiStride2 = kiStride << 1; const int32_t kiStride2 = kiStride << 1;
const int32_t kiStride3 = kiStride + kiStride2; const int32_t kiStride3 = kiStride + kiStride2;
uint8_t* pPred = new uint8_t[64]; uint8_t* pPred = new uint8_t[64];
uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1]; uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1];

View File

@@ -30,16 +30,16 @@ TEST (MemoryAlignTest, WelsMallocAndFreeOnceFunctionVerify) {
const uint32_t kuiTargetAlignSize[4] = {32, 16, 64, 8}; const uint32_t kuiTargetAlignSize[4] = {32, 16, 64, 8};
const uint32_t kuiZero = 0; 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 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 uint32_t uiSize = kuiTestDataSize;
const char strUnitTestTag[100] = "pUnitTestData"; const char strUnitTestTag[100] = "pUnitTestData";
const uint32_t kuiUsedCacheLineSize = ((kuiTestAlignSize == 0) const uint32_t kuiUsedCacheLineSize = ((kuiTestAlignSize == 0)
|| (kuiTestAlignSize & 0x0F)) ? (16) : (kuiTestAlignSize); || (kuiTestAlignSize & 0x0F)) ? (16) : (kuiTestAlignSize);
const uint32_t kuiExtraAlignSize = kuiUsedCacheLineSize - 1; const uint32_t kuiExtraAlignSize = kuiUsedCacheLineSize - 1;
const uint32_t kuiExpectedSize = sizeof (void**) + sizeof (int32_t) + kuiExtraAlignSize + uiSize; const uint32_t kuiExpectedSize = sizeof (void**) + sizeof (int32_t) + kuiExtraAlignSize + uiSize;
uint8_t* pUnitTestData = static_cast<uint8_t*> (cTestMa.WelsMalloc (uiSize, strUnitTestTag)); uint8_t* pUnitTestData = static_cast<uint8_t*> (cTestMa.WelsMalloc (uiSize, strUnitTestTag));
if (pUnitTestData != NULL) { if (pUnitTestData != NULL) {
ASSERT_TRUE ((((uintptr_t) (pUnitTestData)) & kuiExtraAlignSize) == 0); ASSERT_TRUE ((((uintptr_t) (pUnitTestData)) & kuiExtraAlignSize) == 0);

View File

@@ -142,9 +142,9 @@ class MotionEstimateRangeTest : public ::testing::Test {
m_iMvRange = m_iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE; m_iMvRange = m_iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE;
m_iMvdRange = (m_iUsageType ? EXPANDED_MVD_RANGE : ((m_iNumDependencyLayers == 1) ? CAMERA_MVD_RANGE : m_iMvdRange = (m_iUsageType ? EXPANDED_MVD_RANGE : ((m_iNumDependencyLayers == 1) ? CAMERA_MVD_RANGE :
CAMERA_HIGHLAYER_MVD_RANGE)); CAMERA_HIGHLAYER_MVD_RANGE));
m_uiMvdInterTableSize = (m_iMvdRange << 2); //intepel*4=qpel m_uiMvdInterTableSize = (m_iMvdRange << 2); //intepel*4=qpel
m_uiMvdInterTableStride = 1 + (m_uiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-); m_uiMvdInterTableStride = 1 + (m_uiMvdInterTableSize << 1);//qpel_mv_range*2=(+/-);
m_uiMvdCacheAlignedSize = m_uiMvdInterTableStride * sizeof (uint16_t); m_uiMvdCacheAlignedSize = m_uiMvdInterTableStride * sizeof (uint16_t);
m_pMa = new CMemoryAlign (16); m_pMa = new CMemoryAlign (16);
ASSERT_TRUE (NULL != m_pMa); ASSERT_TRUE (NULL != m_pMa);

View File

@@ -11,11 +11,11 @@ using namespace WelsVP;
void DyadicBilinearDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride, void DyadicBilinearDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride,
uint8_t* pSrc, const int32_t kiSrcStride, uint8_t* pSrc, const int32_t kiSrcStride,
const int32_t kiSrcWidth, const int32_t kiSrcHeight) { const int32_t kiSrcWidth, const int32_t kiSrcHeight) {
uint8_t* pDstLine = pDst; uint8_t* pDstLine = pDst;
uint8_t* pSrcLine = pSrc; uint8_t* pSrcLine = pSrc;
const int32_t kiSrcStridex2 = kiSrcStride << 1; const int32_t kiSrcStridex2 = kiSrcStride << 1;
const int32_t kiDstWidth = kiSrcWidth >> 1; const int32_t kiDstWidth = kiSrcWidth >> 1;
const int32_t kiDstHeight = kiSrcHeight >> 1; const int32_t kiDstHeight = kiSrcHeight >> 1;
for (int32_t j = 0; j < kiDstHeight; j ++) { for (int32_t j = 0; j < kiDstHeight; j ++) {
for (int32_t i = 0; i < kiDstWidth; i ++) { for (int32_t i = 0; i < kiDstWidth; i ++) {
@@ -25,8 +25,8 @@ void DyadicBilinearDownsampler_ref (uint8_t* pDst, const int32_t kiDstStride,
pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1); pDstLine[i] = (uint8_t) ((kiTempRow1 + kiTempRow2 + 1) >> 1);
} }
pDstLine += kiDstStride; pDstLine += kiDstStride;
pSrcLine += kiSrcStridex2; pSrcLine += kiSrcStridex2;
} }
} }