ref: 2f5ecec958a91df3eaa14e7be590a8eb800cb28f
parent: 9ed97c73627482b975992b20a53d9fca426f8cbb
author: xiaotiansf <xiaotianshimail@gmail.com>
date: Tue Oct 15 18:23:34 EDT 2019
re-structure SWelsDecoderContext and others and prepare for the support of multi-threading support.
--- a/codec/build/win32/dec/WelsDecCore.vcproj
+++ b/codec/build/win32/dec/WelsDecCore.vcproj
@@ -860,6 +860,10 @@
RelativePath="..\..\..\common\inc\wels_const_common.h"
>
</File>
+ <File
+ RelativePath="..\..\..\decoder\core\inc\wels_decoder_thread.h"
+ >
+ </File>
</Filter>
<Filter
Name="Source Files"
@@ -975,6 +979,10 @@
</File>
<File
RelativePath="..\..\..\common\src\utils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\decoder\core\src\wels_decoder_thread.cpp"
>
</File>
</Filter>
--- a/codec/decoder/core/inc/decode_slice.h
+++ b/codec/decoder/core/inc/decode_slice.h
@@ -61,12 +61,12 @@
int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx);
-int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, bool bOutput);
-int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer,
+int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer, bool bOutput);
+int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer,
uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC);
-int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
+int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer);
void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pCtx);
-int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
+int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer);
void WelsChromaDcIdct (int16_t* pBlock);
bool ComputeColocatedTemporalScaling (PWelsDecoderContext pCtx);
--- a/codec/decoder/core/inc/decoder.h
+++ b/codec/decoder/core/inc/decoder.h
@@ -59,6 +59,17 @@
*/
void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx);
+/*
+* fill last decoded picture info
+*/
+void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo);
+
+/*!
+* \brief fill data fields in SPS and PPS default for decoder context
+*/
+void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx);
+
+
/*!
*************************************************************************************
* \brief Initialize Wels decoder parameters and memory
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -56,6 +56,7 @@
#include "expand_pic.h"
#include "mc.h"
#include "memory_align.h"
+#include "wels_decoder_thread.h"
namespace WelsDec {
#define MAX_PRED_MODE_ID_I16x16 3
@@ -172,7 +173,7 @@
int8_t iChromaQP[2];
int8_t iLumaQP;
struct TagDeblockingFunc* pLoopf;
- PPicture *pRefPics[LIST_A];
+ PPicture* pRefPics[LIST_A];
} SDeblockingFilter, *PDeblockingFilter;
typedef void (*PDeblockingFilterMbFunc) (PDqLayer pCurDqLayer, PDeblockingFilter filter, int32_t boundry_flag);
@@ -215,7 +216,7 @@
} SBlockFunc;
typedef void (*PWelsFillNeighborMbInfoIntra4x4Func) (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
- int8_t* pIntraPredMode, PDqLayer pCurLayer);
+ int8_t* pIntraPredMode, PDqLayer pCurDqLayer);
typedef void (*PWelsMapNeighToSample) (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail);
typedef void (*PWelsMap16NeighToSample) (PWelsNeighAvail pNeighAvail, uint8_t* pSampleAvail);
typedef int32_t (*PWelsParseIntra4x4ModeFunc) (PWelsNeighAvail pNeighAvail, int8_t* pIntraPredMode, PBitStringAux pBs,
@@ -229,6 +230,54 @@
OVERWRITE_SUBSETSPS = 1 << 2
};
+
+//Decoder SPS and PPS global CTX
+typedef struct tagWelsWelsDecoderSpsPpsCTX {
+ SPosOffset sFrameCrop;
+
+ SSps sSpsBuffer[MAX_SPS_COUNT + 1];
+ SPps sPpsBuffer[MAX_PPS_COUNT + 1];
+
+ SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1];
+ SNalUnit sPrefixNal;
+
+ PSps pActiveLayerSps[MAX_LAYER_NUM];
+ bool bAvcBasedFlag; // For decoding bitstream:
+
+ // for EC parameter sets
+ bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
+ bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
+ bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
+
+ int32_t iSpsErrorIgnored;
+ int32_t iSubSpsErrorIgnored;
+ int32_t iPpsErrorIgnored;
+
+ bool bSpsAvailFlags[MAX_SPS_COUNT];
+ bool bSubspsAvailFlags[MAX_SPS_COUNT];
+ bool bPpsAvailFlags[MAX_PPS_COUNT];
+ int32_t iPPSLastInvalidId;
+ int32_t iPPSInvalidNum;
+ int32_t iSPSLastInvalidId;
+ int32_t iSPSInvalidNum;
+ int32_t iSubSPSLastInvalidId;
+ int32_t iSubSPSInvalidNum;
+ int32_t iSeqId; //sequence id
+ int iOverwriteFlags;
+} SWelsDecoderSpsPpsCTX, *PWelsDecoderSpsPpsCTX;
+
+//Last Decoded Picture Info
+typedef struct tagSWelsLastDecPicInfo {
+ // Save the last nal header info
+ SNalUnitHeaderExt sLastNalHdrExt;
+ SSliceHeader sLastSliceHeader;
+ int32_t iPrevPicOrderCntMsb;
+ int32_t iPrevPicOrderCntLsb;
+ PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
+ int32_t iPrevFrameNum;// frame number of previous frame well decoded for non-truncated mode yet
+ bool bLastHasMmco5;
+} SWelsLastDecPicInfo, *PWelsLastDecPicInfo;
+
/*
* SWelsDecoderContext: to maintail all modules data over decoder@framework
*/
@@ -263,9 +312,6 @@
EWelsSliceType eSliceType; // Slice type
bool bUsedAsRef; //flag as ref
int32_t iFrameNum;
- int32_t
- iPrevFrameNum; // frame number of previous frame well decoded for non-truncated mode yet
- bool bLastHasMmco5; //
int32_t iErrorCode; // error code return while decoding in case packets lost
SFmo sFmoList[MAX_PPS_COUNT]; // list for FMO storage
PFmo pFmo; // current fmo context after parsed slice_header
@@ -305,6 +351,7 @@
uint32_t iMbHeight;
} sMb;
+
// reconstruction picture
PPicture pDec; //pointer to current picture being reconstructed
@@ -313,28 +360,25 @@
// reference pictures
SRefPic sRefPic;
+ SRefPic sTmpRefPic; //used to temporarily save RefPic for next active thread
+ SVlcTable* pVlcTable; // vlc table
- SVlcTable sVlcTable; // vlc table
-
SBitStringAux sBs;
int32_t iMaxBsBufferSizeInByte; //actual memory size for BS buffer
/* Global memory external */
+ SWelsDecoderSpsPpsCTX sSpsPpsCtx;
+ bool bHasNewSps;
SPosOffset sFrameCrop;
- SSps sSpsBuffer[MAX_SPS_COUNT + 1];
- SPps sPpsBuffer[MAX_PPS_COUNT + 1];
PSliceHeader pSliceHeader;
PPicBuff pPicBuff; // Initially allocated memory for pictures which are used in decoding.
int32_t iPicQueueNumber;
- SSubsetSps sSubsetSpsBuffer[MAX_SPS_COUNT + 1];
- SNalUnit sPrefixNal;
-
PAccessUnit pAccessUnitList; // current access unit list to be performed
- PSps pActiveLayerSps[MAX_LAYER_NUM];
+ //PSps pActiveLayerSps[MAX_LAYER_NUM];
PSps pSps; // used by current AU
PPps pPps; // used by current AU
// Memory for pAccessUnitList is dynamically held till decoder destruction.
@@ -341,12 +385,13 @@
PDqLayer
pCurDqLayer; // current DQ layer representation, also carry reference base layer if applicable
PDqLayer pDqLayersList[LAYER_NUM_EXCHANGEABLE]; // DQ layers list with memory allocated
-
+ PNalUnit pNalCur; // point to current NAL Nnit
+ uint8_t uiNalRefIdc; // NalRefIdc for easy access;
int32_t iPicWidthReq; // picture width have requested the memory
int32_t iPicHeightReq; // picture height have requested the memory
uint8_t uiTargetDqId; // maximal DQ ID in current access unit, meaning target layer ID
- bool bAvcBasedFlag; // For decoding bitstream:
+ //bool bAvcBasedFlag; // For decoding bitstream:
bool bEndOfStreamFlag; // Flag on end of stream requested by external application layer
bool bInstantDecFlag; // Flag for no-delay decoding
bool bInitialDqLayersMem; // dq layers related memory is available?
@@ -353,25 +398,6 @@
bool bOnlyOneLayerInCurAuFlag; //only one layer in current AU: 1
-// for EC parameter sets
- bool bSpsExistAheadFlag; // whether does SPS NAL exist ahead of sequence?
- bool bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
- bool bPpsExistAheadFlag; // whether does PPS NAL exist ahead of sequence?
-
- int32_t iSpsErrorIgnored;
- int32_t iSubSpsErrorIgnored;
- int32_t iPpsErrorIgnored;
-
- bool bSpsAvailFlags[MAX_SPS_COUNT];
- bool bSubspsAvailFlags[MAX_SPS_COUNT];
- bool bPpsAvailFlags[MAX_PPS_COUNT];
- int32_t iPPSLastInvalidId;
- int32_t iPPSInvalidNum;
- int32_t iSPSLastInvalidId;
- int32_t iSPSInvalidNum;
- int32_t iSubSPSLastInvalidId;
- int32_t iSubSPSInvalidNum;
-
bool bReferenceLostAtT0Flag;
int32_t iTotalNumMbRec; //record current number of decoded MB
#ifdef LONG_TERM_REF
@@ -385,7 +411,6 @@
#endif
bool bNewSeqBegin;
bool bNextNewSeqBegin;
- int iOverwriteFlags;
//for Parse only
bool bFramePending;
@@ -397,7 +422,7 @@
SPpsBsInfo sPpsBsInfo [MAX_PPS_COUNT];
SParserBsInfo* pParserBsInfo;
- PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
+ //PPicture pPreviousDecodedPictureInDpb; //pointer to previously decoded picture in DPB for error concealment
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
@@ -437,11 +462,7 @@
//trace handle
void* pTraceHandle;
-//Save the last nal header info
- SNalUnitHeaderExt sLastNalHdrExt;
- SSliceHeader sLastSliceHeader;
- int32_t iPrevPicOrderCntMsb;
- int32_t iPrevPicOrderCntLsb;
+ PWelsLastDecPicInfo pLastDecPicInfo;
SWelsCabacCtx sWelsCabacContexts[4][WELS_QP_MAX + 1][WELS_CONTEXT_COUNT];
bool bCabacInited;
@@ -448,7 +469,7 @@
SWelsCabacCtx pCabacCtx[WELS_CONTEXT_COUNT];
PWelsCabacDecEngine pCabacDecEngine;
double dDecTime;
- SDecoderStatistics sDecoderStatistics;// For real time debugging
+ SDecoderStatistics* pDecoderStatistics; // For real time debugging
int32_t iMbEcedNum;
int32_t iMbEcedPropNum;
int32_t iMbNum;
@@ -457,6 +478,7 @@
int32_t iECMVs[16][2];
PPicture pECRefPic[16];
unsigned long long uiTimeStamp;
+ uint32_t uiDecodingTimeStamp; //represent relative decoding time stamps
// To support scaling list HP
uint16_t pDequant_coeff_buffer4x4[6][52][16];
uint16_t pDequant_coeff_buffer8x8[6][52][64];
@@ -466,12 +488,41 @@
bool bDequantCoeff4x4Init;
bool bUseScalingList;
CMemoryAlign* pMemAlign;
+ void* pThreadCtx;
+ void* pLastThreadCtx;
+ WELS_MUTEX* pCsDecoder;
+ int16_t lastReadyHeightOffset[LIST_A][MAX_REF_PIC_COUNT]; //last ready reference MB offset
} SWelsDecoderContext, *PWelsDecoderContext;
+typedef struct tagSWelsDecThread {
+ SWelsDecSemphore* sIsBusy;
+ SWelsDecSemphore sIsActivated;
+ SWelsDecSemphore sIsIdle;
+ SWelsDecThread sThrHandle;
+ uint32_t uiCommand;
+ uint32_t uiThrNum;
+ uint32_t uiThrMaxNum;
+ uint32_t uiThrStackSize;
+ DECLARE_PROCTHREAD_PTR (pThrProcMain);
+} SWelsDecThreadInfo, *PWelsDecThreadInfo;
+
+typedef struct tagSWelsDecThreadCtx {
+ SWelsDecThreadInfo sThreadInfo;
+ PWelsDecoderContext pCtx;
+ void* threadCtxOwner;
+ uint8_t* kpSrc;
+ int32_t kiSrcLen;
+ uint8_t** ppDst;
+ SBufferInfo sDstInfo;
+ PPicture pDec;
+ SWelsDecEvent sImageReady;
+ SWelsDecEvent sSliceDecodeStart;
+} SWelsDecoderThreadCTX, *PWelsDecoderThreadCTX;
+
static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) {
if (pCtx->iTotalNumMbRec == 0) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
- pCtx->pActiveLayerSps[i] = NULL;
+ pCtx->sSpsPpsCtx.pActiveLayerSps[i] = NULL;
}
}
}
--- a/codec/decoder/core/inc/mv_pred.h
+++ b/codec/decoder/core/inc/mv_pred.h
@@ -91,7 +91,7 @@
* \param
* \param output iMvp[]
*/
-void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]);
+void PredPSkipMvFromNeighbor (PDqLayer pCurDqLayer, int16_t iMvp[2]);
/*!
* \brief get the motion predictor and reference for B-slice direct mode version 2
@@ -149,7 +149,7 @@
* \param
* \param output motion vector cache and motion vector deviation cache
*/
-void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
+void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
const SubMbType& subMbType, const bool& bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A],
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]);
@@ -158,7 +158,8 @@
* \param
* \param output motion vector cache and motion vector deviation cache
*/
-void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
+void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount,
+ const int8_t& iPartW,
const SubMbType& subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2],
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]);
@@ -176,6 +177,14 @@
* \param
*/
void Update8x8RefIdx (PDqLayer& pCurDqLayer, const int16_t& iPartIdx, const int32_t& listIdx, const int8_t& iRef);
+
+inline uint32_t* GetMbType (PDqLayer& pCurDqLayer) {
+ if (pCurDqLayer->pDec != NULL) {
+ return pCurDqLayer->pDec->pMbType;
+ } else {
+ return pCurDqLayer->pMbType;
+ }
+}
} // namespace WelsDec
--- a/codec/decoder/core/inc/parse_mb_syn_cavlc.h
+++ b/codec/decoder/core/inc/parse_mb_syn_cavlc.h
@@ -51,18 +51,18 @@
-void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer);
-void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer);
+void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurDqLayer);
+void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurDqLayer);
void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
- PDqLayer pCurLayer);
+ PDqLayer pCurDqLayer);
void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
- PDqLayer pCurLayer);
+ PDqLayer pCurDqLayer);
void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
int16_t iMvArray[LIST_A][30][MV_A], int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
- PDqLayer pCurLayer);
-void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurLayer);
+ PDqLayer pCurDqLayer);
+void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurDqLayer);
void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
- int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
+ int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer);
/*!
* \brief check iPredMode for intra16x16 eligible or not
--- a/codec/decoder/core/inc/picture.h
+++ b/codec/decoder/core/inc/picture.h
@@ -85,6 +85,8 @@
int32_t iSpsId; //against mosaic caused by cross-IDR interval reference.
int32_t iPpsId;
unsigned long long uiTimeStamp;
+ uint32_t uiDecodingTimeStamp; //represent relative decoding time stamps
+ int32_t iPicBuffIdx;
bool bNewSeqBegin;
int32_t iMbEcedNum;
int32_t iMbEcedPropNum;
--- a/codec/decoder/core/inc/rec_mb.h
+++ b/codec/decoder/core/inc/rec_mb.h
@@ -77,7 +77,7 @@
void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]);
-void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurLayer);
+void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurDqLayer);
int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
--- /dev/null
+++ b/codec/decoder/core/inc/wels_decoder_thread.h
@@ -1,0 +1,170 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2019, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file wels_decoder_thread.h
+ *
+ * \brief Interfaces introduced in thread programming
+ *
+ * \date 08/06/2018 Created
+ *
+ *************************************************************************************
+ */
+
+#ifndef _WELS_DECODER_THREAD_H_
+#define _WELS_DECODER_THREAD_H_
+
+#include "WelsThreadLib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WELS_DEC_MAX_NUM_CPU 16
+#define WELS_DEC_MAX_THREAD_STACK_SIZE 4096
+#define WELS_DEC_THREAD_COMMAND_RUN 0
+#define WELS_DEC_THREAD_COMMAND_ABORT 1
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+typedef struct tagWelsDecSemphore {
+ WELS_THREAD_HANDLE h;
+} SWelsDecSemphore;
+
+typedef struct tagWelsDecEvent {
+ WELS_THREAD_HANDLE h;
+ int isSignaled;
+} SWelsDecEvent;
+
+typedef struct tagWelsDecThread {
+ WELS_THREAD_HANDLE h;
+} SWelsDecThread;
+
+#define WelsDecThreadFunc(fn,a) DWORD WINAPI fn(LPVOID a)
+#define WelsDecThreadFuncArg(a) LPWELS_THREAD_ROUTINE a
+#define WELS_DEC_THREAD_WAIT_TIMEDOUT WAIT_TIMEOUT
+#define WELS_DEC_THREAD_WAIT_SIGNALED WAIT_OBJECT_0
+#define WELS_DEC_THREAD_WAIT_INFINITE INFINITE
+
+#else // NON-WINDOWS
+
+typedef pthread_mutexattr_t WELS_MUTEX_ATTR;
+
+typedef struct tagWelsDecSemphore {
+ long max;
+ long v;
+ WELS_EVENT e;
+ WELS_MUTEX m;
+} SWelsDecSemphore;
+
+typedef struct tagWelsDecEvent {
+ int manualReset;
+ int isSignaled;
+ pthread_cond_t c;
+ WELS_MUTEX m;
+} SWelsDecEvent;
+
+typedef struct tagWelsDecThread {
+ WELS_THREAD_HANDLE h;
+} SWelsDecThread;
+
+#define WelsDecThreadFunc(fn,a) void* fn(void* a)
+#define WelsDecThreadFuncArg(a) void* (*a)(void*)
+
+#define WELS_DEC_THREAD_WAIT_TIMEDOUT ETIMEDOUT
+#define WELS_DEC_THREAD_WAIT_SIGNALED EINTR
+#define WELS_DEC_THREAD_WAIT_INFINITE -1
+
+#endif//_WIN32
+
+#define WelsDecThreadReturn WELS_THREAD_ROUTINE_RETURN(0);
+
+int32_t GetCPUCount();
+
+// Event
+int EventCreate (SWelsDecEvent* e, int manualReset, int initialState);
+void EventPost (SWelsDecEvent* e);
+int EventWait (SWelsDecEvent* e, int32_t timeout);
+void EventReset (SWelsDecEvent* e);
+void EventDestroy (SWelsDecEvent* e);
+
+// Semaphore
+int SemCreate (SWelsDecSemphore* s, long value, long max);
+int SemWait (SWelsDecSemphore* s, int32_t timeout);
+void SemRelease (SWelsDecSemphore* s, long* prev_count);
+void SemDestroy (SWelsDecSemphore* s);
+
+// Thread
+int ThreadCreate (SWelsDecThread* t, LPWELS_THREAD_ROUTINE tf, void* ta);
+int ThreadWait (SWelsDecThread* t);
+
+#define DECLARE_PROCTHREAD(name, argument) \
+ WelsDecThreadFunc(name,argument)
+
+#define DECLARE_PROCTHREAD_PTR(name) \
+ LPWELS_THREAD_ROUTINE name
+
+#define CREATE_THREAD(ph, threadproc,argument) \
+ ThreadCreate(ph, threadproc, (void*)argument)
+
+#define CREATE_EVENT(ph, manualreset,initial_state,name) \
+ EventCreate(ph,(int)(manualreset),(int)(initial_state))
+
+#define CREATE_SEMAPHORE(ph, initial_count,max_count, name) \
+ SemCreate(ph, (long)initial_count,(long)(max_count))
+
+#define CLOSE_EVENT(ph) \
+ EventDestroy(ph)
+
+#define CLOSE_SEMAPHORE(ph) \
+ SemDestroy(ph)
+
+#define SET_EVENT(ph) \
+ EventPost(ph)
+
+#define RESET_EVENT(ph) \
+ EventReset(ph)
+
+#define RELEASE_SEMAPHORE(ph) \
+ SemRelease(ph,NULL)
+
+#define WAIT_EVENT(ph,timeout) \
+ EventWait(ph, (int32_t)timeout)
+
+#define WAIT_THREAD(ph) \
+ ThreadWait(ph)
+
+#define WAIT_SEMAPHORE(ph,timeout) \
+ SemWait(ph,(int32_t)timeout)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -148,48 +148,50 @@
++ (*pConsumedBytes);
if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType)
- || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->bSpsExistAheadFlag)) {
- if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSpsErrorIgnored == 0) {
+ || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->sSpsPpsCtx.bSpsExistAheadFlag)) {
+ if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iSpsErrorIgnored == 0) {
WelsLog (pLogCtx, WELS_LOG_WARNING,
"parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
pNalUnitHeader->eNalUnitType);
} else {
- pCtx->iSpsErrorIgnored++;
+ pCtx->sSpsPpsCtx.iSpsErrorIgnored++;
}
- pCtx->sDecoderStatistics.iSpsNoExistNalNum++;
+ pCtx->pDecoderStatistics->iSpsNoExistNalNum++;
pCtx->iErrorCode = dsNoParamSets;
return NULL;
}
- pCtx->iSpsErrorIgnored = 0;
+ pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0;
if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType)
- || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->bPpsExistAheadFlag)) {
- if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iPpsErrorIgnored == 0) {
+ || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->sSpsPpsCtx.bPpsExistAheadFlag)) {
+ if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iPpsErrorIgnored == 0) {
WelsLog (pLogCtx, WELS_LOG_WARNING,
"parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
pNalUnitHeader->eNalUnitType);
} else {
- pCtx->iPpsErrorIgnored++;
+ pCtx->sSpsPpsCtx.iPpsErrorIgnored++;
}
- pCtx->sDecoderStatistics.iPpsNoExistNalNum++;
+ pCtx->pDecoderStatistics->iPpsNoExistNalNum++;
pCtx->iErrorCode = dsNoParamSets;
return NULL;
}
- pCtx->iPpsErrorIgnored = 0;
- if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bPpsExistAheadFlag)) ||
- (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag
- || pCtx->bPpsExistAheadFlag))) {
- if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSubSpsErrorIgnored == 0) {
+ pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0;
+ if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->sSpsPpsCtx.bSpsExistAheadFlag
+ || pCtx->sSpsPpsCtx.bPpsExistAheadFlag)) ||
+ (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->sSpsPpsCtx.bSpsExistAheadFlag
+ || pCtx->sSpsPpsCtx.bSubspsExistAheadFlag
+ || pCtx->sSpsPpsCtx.bPpsExistAheadFlag))) {
+ if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iSubSpsErrorIgnored == 0) {
WelsLog (pLogCtx, WELS_LOG_WARNING,
"ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).",
pNalUnitHeader->eNalUnitType);
} else {
- pCtx->iSubSpsErrorIgnored++;
+ pCtx->sSpsPpsCtx.iSubSpsErrorIgnored++;
}
- pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++;
+ pCtx->pDecoderStatistics->iSubSpsNoExistNalNum++;
pCtx->iErrorCode |= dsNoParamSets;
return NULL;
}
- pCtx->iSubSpsErrorIgnored = 0;
+ pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0;
switch (pNalUnitHeader->eNalUnitType) {
case NAL_UNIT_AU_DELIMITER:
@@ -201,7 +203,7 @@
break;
case NAL_UNIT_PREFIX:
- pCurNal = &pCtx->sPrefixNal;
+ pCurNal = &pCtx->sSpsPpsCtx.sPrefixNal;
pCurNal->uiTimeStamp = pCtx->uiTimeStamp;
if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
@@ -365,9 +367,9 @@
memcpy (pSavedData->pCurPos + iStartDeltaByte, pSrcNal, iActualLen);
pSavedData->pCurPos += iStartDeltaByte + iActualLen;
}
- if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
- if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) {
- PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sPrefixNal);
+ if (NAL_UNIT_PREFIX == pCtx->sSpsPpsCtx.sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
+ if (pCtx->sSpsPpsCtx.sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) {
+ PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sSpsPpsCtx.sPrefixNal);
}
}
@@ -496,8 +498,8 @@
const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
const SSliceHeader* kpLastSliceHeader = &kpLastNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
const SSliceHeader* kpCurSliceHeader = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
- if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
- && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
+ && pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
return true; // the active sps changed, new sequence begins, so the current au is ready
}
@@ -548,8 +550,8 @@
bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PSps kpSps) {
const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
- if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
- && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps)
+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
+ && pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps)
return true;
if (kpCurNalHeaderExt->bIdrFlag)
return true;
@@ -620,7 +622,7 @@
return iErr;
}
}
- iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen);
+ iErr = ParsePps (pCtx, &pCtx->sSpsPpsCtx.sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen);
if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009
if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE)
pCtx->iErrorCode |= dsNoParamSets;
@@ -629,7 +631,7 @@
return iErr;
}
- pCtx->bPpsExistAheadFlag = true;
+ pCtx->sSpsPpsCtx.bPpsExistAheadFlag = true;
break;
@@ -683,7 +685,7 @@
}
int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
- PNalUnit pCurNal = &pCtx->sPrefixNal;
+ PNalUnit pCurNal = &pCtx->sSpsPpsCtx.sPrefixNal;
uint32_t uiCode;
if (pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
@@ -834,12 +836,12 @@
bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
- if (pCtx->pActiveLayerSps[i] == pSps)
+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == pSps)
return true;
}
// Pre-active, will be used soon
if (bUseSubsetFlag) {
- if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSubspsAvailFlags[pSps->iSpsId]) {
+ if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSubspsAvailFlags[pSps->iSpsId]) {
if (pCtx->iTotalNumMbRec > 0) {
return true;
}
@@ -857,7 +859,7 @@
}
}
} else {
- if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSpsAvailFlags[pSps->iSpsId]) {
+ if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSpsAvailFlags[pSps->iSpsId]) {
if (pCtx->iTotalNumMbRec > 0) {
return true;
}
@@ -1251,44 +1253,44 @@
if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)
- pCtx->bAvcBasedFlag = false;
+ pCtx->sSpsPpsCtx.bAvcBasedFlag = false;
*pPicWidth = pSps->iMbWidth << 4;
*pPicHeight = pSps->iMbHeight << 4;
PSps pTmpSps = NULL;
if (kbUseSubsetFlag) {
- pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps;
+ pTmpSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId].sSps;
} else {
- pTmpSps = &pCtx->sSpsBuffer[iSpsId];
+ pTmpSps = &pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId];
}
if (CheckSpsActive (pCtx, pTmpSps, kbUseSubsetFlag)) {
// we are overwriting the active sps, copy a temp buffer
if (kbUseSubsetFlag) {
- if (memcmp (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) {
+ if (memcmp (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) {
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
- memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
pCtx->bAuReadyFlag = true;
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
- pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS;
+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SUBSETSPS;
} else if ((pCtx->pSps != NULL) && (pCtx->pSps->iSpsId == pSubsetSps->sSps.iSpsId)) {
- memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
- pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS;
+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SUBSETSPS;
} else {
- memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
}
}
} else {
- if (memcmp (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) {
+ if (memcmp (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) {
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
- memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
- pCtx->iOverwriteFlags |= OVERWRITE_SPS;
+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SPS;
pCtx->bAuReadyFlag = true;
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
} else if ((pCtx->pSps != NULL) && (pCtx->pSps->iSpsId == pSps->iSpsId)) {
- memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
- pCtx->iOverwriteFlags |= OVERWRITE_SPS;
+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SPS;
} else {
- memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps));
}
}
}
@@ -1295,13 +1297,13 @@
}
// Not overwrite active sps, just copy to final place
else if (kbUseSubsetFlag) {
- memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
- pCtx->bSubspsAvailFlags[iSpsId] = true;
- pCtx->bSubspsExistAheadFlag = true;
+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
+ pCtx->sSpsPpsCtx.bSubspsAvailFlags[iSpsId] = true;
+ pCtx->sSpsPpsCtx.bSubspsExistAheadFlag = true;
} else {
- memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
- pCtx->bSpsAvailFlags[iSpsId] = true;
- pCtx->bSpsExistAheadFlag = true;
+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps));
+ pCtx->sSpsPpsCtx.bSpsAvailFlags[iSpsId] = true;
+ pCtx->sSpsPpsCtx.bSpsExistAheadFlag = true;
}
return ERR_NONE;
}
@@ -1421,8 +1423,8 @@
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //pic_scaling_matrix_present_flag
pPps->bPicScalingMatrixPresentFlag = !!uiCode;
if (pPps->bPicScalingMatrixPresentFlag) {
- if (pCtx->bSpsAvailFlags[pPps->iSpsId]) {
- WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag,
+ if (pCtx->sSpsPpsCtx.bSpsAvailFlags[pPps->iSpsId]) {
+ WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsPpsCtx.sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag,
pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, pPps->iScalingList8x8));
} else {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
@@ -1440,8 +1442,8 @@
if (pCtx->pPps != NULL && pCtx->pPps->iPpsId == pPps->iPpsId) {
if (memcmp (pCtx->pPps, pPps, sizeof (*pPps)) != 0) {
- memcpy (&pCtx->sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps));
- pCtx->iOverwriteFlags |= OVERWRITE_PPS;
+ memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps));
+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_PPS;
if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
pCtx->bAuReadyFlag = true;
pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
@@ -1448,8 +1450,8 @@
}
}
} else {
- memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
- pCtx->bPpsAvailFlags[uiPpsId] = true;
+ memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
+ pCtx->sSpsPpsCtx.bPpsAvailFlags[uiPpsId] = true;
}
if (pCtx->pParam->bParseOnly) {
if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //pps bs exceeds
--- a/codec/decoder/core/src/deblocking.cpp
+++ b/codec/decoder/core/src/deblocking.cpp
@@ -201,11 +201,12 @@
nBS[1][2][2] = nBS[1][2][3] = (i8x8NnzTab[1] | i8x8NnzTab[3]) << iLShiftFactor;
}
-void static inline DeblockingBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab,
+void static inline DeblockingBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, uint8_t nBS[2][4][4],
+ int8_t* pNnzTab,
int32_t iMbXy) {
uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
- int8_t* iRefIdx = pCurDqLayer->pRefIndex[LIST_0][iMbXy];
- void *iRefs[MB_BLOCK4x4_NUM];
+ int8_t* iRefIdx = pCurDqLayer->pDec->pRefIndex[LIST_0][iMbXy];
+ void* iRefs[MB_BLOCK4x4_NUM];
int i;
ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4);
@@ -226,15 +227,15 @@
pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]);
}
//vertical
- nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy],
+ nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy],
g_kuiMbCountScan4Idx[1 << 2], g_kuiMbCountScan4Idx[0]);
- nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy],
+ nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy],
g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[2 << 2]);
//horizontal
- nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy],
+ nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy],
g_kuiMbCountScan4Idx[2 << 2], g_kuiMbCountScan4Idx[0]);
- nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pMv[LIST_0][iMbXy],
+ nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy],
g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[1 << 2]);
} else {
uiNnz32b0 = * (uint32_t*) (pNnzTab + 0);
@@ -244,53 +245,54 @@
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
- nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0);
- nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1);
- nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2);
+ nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 1, 0);
+ nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 2, 1);
+ nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 3, 2);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
- nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4);
- nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5);
- nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6);
+ nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 5, 4);
+ nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 6, 5);
+ nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 7, 6);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
- nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8);
- nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9);
- nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10);
+ nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 9, 8);
+ nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 10, 9);
+ nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 11, 10);
for (int i = 0; i < 3; i++)
uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
- nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12);
- nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13);
- nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14);
+ nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 13, 12);
+ nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 14, 13);
+ nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 15, 14);
// horizontal
* (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1);
- nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0);
- nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1);
- nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2);
- nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3);
+ nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 4, 0);
+ nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 5, 1);
+ nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 6, 2);
+ nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 7, 3);
* (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2);
- nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4);
- nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5);
- nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6);
- nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7);
+ nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 8, 4);
+ nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 9, 5);
+ nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 10, 6);
+ nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 11, 7);
* (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3);
- nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8);
- nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9);
- nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10);
- nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11);
+ nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 12, 8);
+ nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 13, 9);
+ nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 14, 10);
+ nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs, pCurDqLayer->pDec->pMv[LIST_0][iMbXy], 15, 11);
}
}
-void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab,
+void static inline DeblockingBSliceBSInsideMBNormal (PDeblockingFilter pFilter, PDqLayer pCurDqLayer,
+ uint8_t nBS[2][4][4], int8_t* pNnzTab,
int32_t iMbXy) {
uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
- void *iRefs[LIST_A][MB_BLOCK4x4_NUM];
+ void* iRefs[LIST_A][MB_BLOCK4x4_NUM];
ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4);
int8_t i8x8NnzTab[4];
@@ -297,7 +299,7 @@
int l;
for (l = 0; l < LIST_A; l++) {
- int8_t* iRefIdx = pCurDqLayer->pRefIndex[l][iMbXy];
+ int8_t* iRefIdx = pCurDqLayer->pDec->pRefIndex[l][iMbXy];
int i;
/* Look up each reference picture based on indices */
for (i = 0; i < MB_BLOCK4x4_NUM; i++) {
@@ -321,7 +323,7 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) {
nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefs[listIdx],
- pCurDqLayer->pMv[listIdx][iMbXy],
+ pCurDqLayer->pDec->pMv[listIdx][iMbXy],
iIndex, iNeigborIndex);
break;
}
@@ -332,7 +334,7 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) {
nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefs[listIdx],
- pCurDqLayer->pMv[listIdx][iMbXy],
+ pCurDqLayer->pDec->pMv[listIdx][iMbXy],
iIndex, iNeigborIndex);
break;
}
@@ -345,7 +347,7 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) {
nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefs[listIdx],
- pCurDqLayer->pMv[listIdx][iMbXy],
+ pCurDqLayer->pDec->pMv[listIdx][iMbXy],
iIndex, iNeigborIndex);
break;
}
@@ -357,7 +359,7 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][iIndex] && iRefs[listIdx][iNeigborIndex]) {
nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefs[listIdx],
- pCurDqLayer->pMv[listIdx][iMbXy],
+ pCurDqLayer->pDec->pMv[listIdx][iMbXy],
iIndex, iNeigborIndex);
break;
}
@@ -373,7 +375,7 @@
nBS[0][1][0] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][1] && iRefs[listIdx][0]) {
- nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 1, 0);
+ nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 1, 0);
break;
}
}
@@ -380,7 +382,7 @@
nBS[0][2][0] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][2] && iRefs[listIdx][1]) {
- nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 2, 1);
+ nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 2, 1);
break;
}
}
@@ -387,7 +389,7 @@
nBS[0][3][0] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][3] && iRefs[listIdx][2]) {
- nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 3, 2);
+ nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 3, 2);
break;
}
}
@@ -397,7 +399,7 @@
nBS[0][1][1] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][5] && iRefs[listIdx][4]) {
- nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 5, 4);
+ nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 5, 4);
break;
}
}
@@ -404,7 +406,7 @@
nBS[0][2][1] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][6] && iRefs[listIdx][5]) {
- nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 6, 5);
+ nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 6, 5);
break;
}
}
@@ -411,7 +413,7 @@
nBS[0][3][1] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][7] && iRefs[listIdx][6]) {
- nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 7, 6);
+ nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 7, 6);
break;
}
}
@@ -421,7 +423,7 @@
nBS[0][1][2] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][9] && iRefs[listIdx][8]) {
- nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 9, 8);
+ nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 9, 8);
break;
}
}
@@ -428,7 +430,7 @@
nBS[0][2][2] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][10] && iRefs[listIdx][9]) {
- nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 10, 9);
+ nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 10, 9);
break;
}
}
@@ -435,7 +437,7 @@
nBS[0][3][2] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][11] && iRefs[listIdx][10]) {
- nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 11, 10);
+ nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 11, 10);
break;
}
}
@@ -445,7 +447,7 @@
nBS[0][1][3] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][13] && iRefs[listIdx][12]) {
- nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 13, 12);
+ nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 13, 12);
break;
}
}
@@ -452,7 +454,7 @@
nBS[0][2][3] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][14] && iRefs[listIdx][13]) {
- nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 14, 13);
+ nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 14, 13);
break;
}
}
@@ -459,7 +461,7 @@
nBS[0][3][3] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][15] && iRefs[listIdx][14]) {
- nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 15, 14);
+ nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 15, 14);
break;
}
}
@@ -469,7 +471,7 @@
nBS[1][1][0] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][4] && iRefs[listIdx][0]) {
- nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 4, 0);
+ nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 4, 0);
break;
}
}
@@ -476,7 +478,7 @@
nBS[1][1][1] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][5] && iRefs[listIdx][1]) {
- nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 5, 1);
+ nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 5, 1);
break;
}
}
@@ -483,7 +485,7 @@
nBS[1][1][2] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][6] && iRefs[listIdx][2]) {
- nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 6, 2);
+ nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 6, 2);
break;
}
}
@@ -490,7 +492,7 @@
nBS[1][1][3] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][7] && iRefs[listIdx][3]) {
- nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 7, 3);
+ nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 7, 3);
break;
}
}
@@ -499,7 +501,7 @@
nBS[1][2][0] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][8] && iRefs[listIdx][4]) {
- nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 8, 4);
+ nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 8, 4);
break;
}
}
@@ -506,7 +508,7 @@
nBS[1][2][1] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][9] && iRefs[listIdx][5]) {
- nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 9, 5);
+ nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 9, 5);
break;
}
}
@@ -513,7 +515,7 @@
nBS[1][2][2] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][10] && iRefs[listIdx][6]) {
- nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 10, 6);
+ nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 10, 6);
break;
}
}
@@ -520,7 +522,7 @@
nBS[1][2][3] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][11] && iRefs[listIdx][7]) {
- nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 11, 7);
+ nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 11, 7);
break;
}
}
@@ -529,7 +531,7 @@
nBS[1][3][0] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][12] && iRefs[listIdx][8]) {
- nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 12, 8);
+ nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 12, 8);
break;
}
}
@@ -536,7 +538,7 @@
nBS[1][3][1] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][13] && iRefs[listIdx][9]) {
- nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 13, 9);
+ nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 13, 9);
break;
}
}
@@ -543,7 +545,7 @@
nBS[1][3][2] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][14] && iRefs[listIdx][10]) {
- nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 14, 10);
+ nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 14, 10);
break;
}
}
@@ -550,7 +552,7 @@
nBS[1][3][3] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (iRefs[listIdx][15] && iRefs[listIdx][11]) {
- nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 15, 11);
+ nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefs[listIdx], pCurDqLayer->pDec->pMv[listIdx][iMbXy], 15, 11);
break;
}
}
@@ -558,7 +560,8 @@
}
-uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) {
+uint32_t DeblockingBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge,
+ int32_t iNeighMb, int32_t iMbXy) {
int32_t i, j;
uint32_t uiBSx4;
uint8_t* pBS = (uint8_t*) (&uiBSx4);
@@ -566,7 +569,8 @@
const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4];
const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0];
const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8];
- int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[LIST_0];
+ int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pRefIndex[LIST_0] :
+ pCurDqLayer->pRefIndex[LIST_0];
if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) {
for (i = 0; i < 2; i++) {
@@ -579,8 +583,9 @@
} else {
PPicture ref0, ref1;
ref0 = (iRefIdx[iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pB8x8Idx]] : NULL;
- ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] : NULL;
- pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb,
+ ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] :
+ NULL;
+ pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[LIST_0], iMbXy, iNeighMb,
*pB8x8Idx, *pBn8x8Idx);
}
pB8x8Idx += 4;
@@ -599,7 +604,8 @@
PPicture ref0, ref1;
ref0 = (iRefIdx[iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pB8x8Idx]] : NULL;
ref1 = (iRefIdx[iNeighMb][*pBnIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBnIdx]] : NULL;
- pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pB8x8Idx,
+ pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1,
+ (pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMv[LIST_0] : pCurDqLayer->pMv[LIST_0]), iMbXy, iNeighMb, *pB8x8Idx,
*pBnIdx);
}
pBnIdx++;
@@ -618,8 +624,10 @@
} else {
PPicture ref0, ref1;
ref0 = (iRefIdx[iMbXy][*pBIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pBIdx]] : NULL;
- ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] : NULL;
- pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx,
+ ref1 = (iRefIdx[iNeighMb][*pBn8x8Idx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBn8x8Idx]] :
+ NULL;
+ pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1,
+ (pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMv[LIST_0] : pCurDqLayer->pMv[LIST_0]), iMbXy, iNeighMb, *pBIdx,
*pBn8x8Idx);
}
pBIdx++;
@@ -635,7 +643,8 @@
PPicture ref0, ref1;
ref0 = (iRefIdx[iMbXy][*pBIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iMbXy][*pBIdx]] : NULL;
ref1 = (iRefIdx[iNeighMb][*pBnIdx] > REF_NOT_IN_LIST) ? pFilter->pRefPics[LIST_0][iRefIdx[iNeighMb][*pBnIdx]] : NULL;
- pBS[i] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, *pBnIdx);
+ pBS[i] = MB_BS_MV (ref0, ref1, (pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMv[LIST_0] : pCurDqLayer->pMv[LIST_0]),
+ iMbXy, iNeighMb, *pBIdx, *pBnIdx);
}
pBIdx++;
pBnIdx++;
@@ -644,7 +653,8 @@
return uiBSx4;
}
-uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) {
+uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDeblockingFilter pFilter, PDqLayer pCurDqLayer, int32_t iEdge,
+ int32_t iNeighMb, int32_t iMbXy) {
int32_t i, j;
uint32_t uiBSx4;
uint8_t* pBS = (uint8_t*) (&uiBSx4);
@@ -665,12 +675,12 @@
} else {
pBS[i << 1] = pBS[1 + (i << 1)] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
- if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST
- && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) {
- int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx];
+ if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST
+ && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) {
+ int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx];
ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pB8x8Idx]];
ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBn8x8Idx]];
- pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb,
+ pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb,
*pB8x8Idx, *pBn8x8Idx);
break;
}
@@ -691,12 +701,12 @@
} else {
pBS[j + (i << 1)] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
- if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST
- && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) {
- int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx];
+ if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST
+ && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) {
+ int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx];
ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pB8x8Idx]];
ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBnIdx]];
- pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pB8x8Idx,
+ pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pB8x8Idx,
*pBnIdx);
break;
}
@@ -718,12 +728,12 @@
} else {
pBS[j + (i << 1)] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
- if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST
- && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) {
- int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx];
+ if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST
+ && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) {
+ int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx];
ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pBIdx]];
ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBn8x8Idx]];
- pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBn8x8Idx);
+ pBS[j + (i << 1)] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBn8x8Idx);
break;
}
}
@@ -740,12 +750,12 @@
} else {
pBS[i] = 1;
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
- if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST
- && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) {
- int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pRefIndex[listIdx];
+ if (pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST
+ && pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) {
+ int8_t (*iRefIdx)[MB_BLOCK4x4_NUM] = pCurDqLayer->pDec->pRefIndex[listIdx];
ref0 = pFilter->pRefPics[listIdx][iRefIdx[iMbXy][*pBIdx]];
ref1 = pFilter->pRefPics[listIdx][iRefIdx[iNeighMb][*pBnIdx]];
- pBS[i] = MB_BS_MV (ref0, ref1, pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBnIdx);
+ pBS[i] = MB_BS_MV (ref0, ref1, pCurDqLayer->pDec->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBnIdx);
break;
}
}
@@ -972,7 +982,7 @@
static void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4],
- int32_t iBoundryFlag) {
+ int32_t iBoundryFlag) {
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
int32_t iMbX = pCurDqLayer->iMbX;
int32_t iMbY = pCurDqLayer->iMbY;
@@ -1224,7 +1234,8 @@
uint8_t nBS[2][4][4] = {{{ 0 }}};
int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
- uint32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex];
+ uint32_t iCurMbType = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMbType[iMbXyIndex] :
+ pCurDqLayer->pMbType[iMbXyIndex];
int32_t iMbNb;
PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -1242,11 +1253,13 @@
if (iBoundryFlag & LEFT_FLAG_MASK) {
iMbNb = iMbXyIndex - 1;
+ uint32_t uiMbType = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMbType[iMbNb] : pCurDqLayer->pMbType[iMbNb];
if (bBSlice) {
- * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBSliceBsMarginalMBAvcbase (
+ * (uint32_t*)nBS[0][0] = IS_INTRA (uiMbType) ? 0x04040404 :
+ DeblockingBSliceBsMarginalMBAvcbase (
pFilter, pCurDqLayer, 0, iMbNb, iMbXyIndex);
} else {
- * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
+ * (uint32_t*)nBS[0][0] = IS_INTRA (uiMbType) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
pFilter, pCurDqLayer, 0, iMbNb, iMbXyIndex);
}
} else {
@@ -1254,11 +1267,13 @@
}
if (iBoundryFlag & TOP_FLAG_MASK) {
iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth;
+ uint32_t uiMbType = pCurDqLayer->pDec != NULL ? pCurDqLayer->pDec->pMbType[iMbNb] : pCurDqLayer->pMbType[iMbNb];
if (bBSlice) {
- * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBSliceBsMarginalMBAvcbase (
+ * (uint32_t*)nBS[1][0] = IS_INTRA (uiMbType) ? 0x04040404 :
+ DeblockingBSliceBsMarginalMBAvcbase (
pFilter, pCurDqLayer, 1, iMbNb, iMbXyIndex);
} else {
- * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
+ * (uint32_t*)nBS[1][0] = IS_INTRA (uiMbType) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
pFilter, pCurDqLayer, 1, iMbNb, iMbXyIndex);
}
} else {
@@ -1360,6 +1375,7 @@
} while (1);
}
}
+
/*!
* \brief deblocking module initialize
*
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -79,14 +79,14 @@
}
int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PSlice pCurSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader;
int32_t iTotalMbTargetLayer = pSliceHeader->pSps->uiTotalMbCount;
- int32_t iCurLayerWidth = pCurLayer->iMbWidth << 4;
- int32_t iCurLayerHeight = pCurLayer->iMbHeight << 4;
+ int32_t iCurLayerWidth = pCurDqLayer->iMbWidth << 4;
+ int32_t iCurLayerHeight = pCurDqLayer->iMbHeight << 4;
int32_t iNextMbXyIndex = 0;
PFmo pFmo = pCtx->pFmo;
@@ -95,20 +95,20 @@
int32_t iCountNumMb = 0;
PDeblockingFilterMbFunc pDeblockMb;
- if (!pCtx->bAvcBasedFlag && iCurLayerWidth != pCtx->iCurSeqIntervalMaxPicWidth) {
+ if (!pCtx->sSpsPpsCtx.bAvcBasedFlag && iCurLayerWidth != pCtx->iCurSeqIntervalMaxPicWidth) {
return ERR_INFO_WIDTH_MISMATCH;
}
iNextMbXyIndex = pSliceHeader->iFirstMbInSlice;
- pCurLayer->iMbX = iNextMbXyIndex % pCurLayer->iMbWidth;
- pCurLayer->iMbY = iNextMbXyIndex / pCurLayer->iMbWidth;
- pCurLayer->iMbXyIndex = iNextMbXyIndex;
+ pCurDqLayer->iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth;
+ pCurDqLayer->iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth;
+ pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
if (0 == iNextMbXyIndex) {
- pCurLayer->pDec->iSpsId = pCtx->pSps->iSpsId;
- pCurLayer->pDec->iPpsId = pCtx->pPps->iPpsId;
+ pCurDqLayer->pDec->iSpsId = pCtx->pSps->iSpsId;
+ pCurDqLayer->pDec->iPpsId = pCtx->pPps->iPpsId;
- pCurLayer->pDec->uiQualityId = pCurLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
+ pCurDqLayer->pDec->uiQualityId = pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
}
do {
@@ -120,7 +120,7 @@
if (WelsTargetMbConstruction (pCtx)) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
"WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d",
- pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
+ pCurDqLayer->iMbX, pCurDqLayer->iMbY, pCurSlice->eSliceType);
return ERR_INFO_MB_RECON_FAIL;
}
@@ -127,9 +127,9 @@
}
++iCountNumMb;
- if (!pCurLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex]) { //already con-ed, overwrite
- pCurLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex] = true;
- pCtx->pDec->iMbEcedPropNum += (pCurLayer->pMbRefConcealedFlag[iNextMbXyIndex] ? 1 : 0);
+ if (!pCurDqLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex]) { //already con-ed, overwrite
+ pCurDqLayer->pMbCorrectlyDecodedFlag[iNextMbXyIndex] = true;
+ pCtx->pDec->iMbEcedPropNum += (pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] ? 1 : 0);
++pCtx->iTotalNumMbRec;
}
@@ -149,9 +149,9 @@
if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbTargetLayer) { // slice group boundary or end of a frame
break;
}
- pCurLayer->iMbX = iNextMbXyIndex % pCurLayer->iMbWidth;
- pCurLayer->iMbY = iNextMbXyIndex / pCurLayer->iMbWidth;
- pCurLayer->iMbXyIndex = iNextMbXyIndex;
+ pCurDqLayer->iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth;
+ pCurDqLayer->iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth;
+ pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
} while (1);
pCtx->pDec->iWidthInPixel = iCurLayerWidth;
@@ -176,24 +176,24 @@
return ERR_NONE;
}
-int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer,
+int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer,
uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC) {
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t i, iIndex, iOffset;
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
for (i = 0; i < 4; i++) {
iIndex = g_kuiMbCountScan4Idx[i << 2];
- if (pCurLayer->pNzc[iMbXy][iIndex] || pCurLayer->pNzc[iMbXy][iIndex + 1] || pCurLayer->pNzc[iMbXy][iIndex + 4]
- || pCurLayer->pNzc[iMbXy][iIndex + 5]) {
+ if (pCurDqLayer->pNzc[iMbXy][iIndex] || pCurDqLayer->pNzc[iMbXy][iIndex + 1] || pCurDqLayer->pNzc[iMbXy][iIndex + 4]
+ || pCurDqLayer->pNzc[iMbXy][iIndex + 5]) {
iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2);
- pCtx->pIdctResAddPredFunc8x8 (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 6));
+ pCtx->pIdctResAddPredFunc8x8 (pDstY + iOffset, iStrideL, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 6));
}
}
} else {
// luma.
- const int8_t* pNzc = pCurLayer->pNzc[iMbXy];
- int16_t* pScaledTCoeff = pCurLayer->pScaledTCoeff[iMbXy];
+ const int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
+ int16_t* pScaledTCoeff = pCurDqLayer->pScaledTCoeff[iMbXy];
pCtx->pIdctFourResAddPredFunc (pDstY + 0 * iStrideL + 0, iStrideL, pScaledTCoeff + 0 * 64, pNzc + 0);
pCtx->pIdctFourResAddPredFunc (pDstY + 0 * iStrideL + 8, iStrideL, pScaledTCoeff + 1 * 64, pNzc + 2);
pCtx->pIdctFourResAddPredFunc (pDstY + 8 * iStrideL + 0, iStrideL, pScaledTCoeff + 2 * 64, pNzc + 8);
@@ -200,8 +200,8 @@
pCtx->pIdctFourResAddPredFunc (pDstY + 8 * iStrideL + 8, iStrideL, pScaledTCoeff + 3 * 64, pNzc + 10);
}
- const int8_t* pNzc = pCurLayer->pNzc[iMbXy];
- int16_t* pScaledTCoeff = pCurLayer->pScaledTCoeff[iMbXy];
+ const int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
+ int16_t* pScaledTCoeff = pCurDqLayer->pScaledTCoeff[iMbXy];
// Cb.
pCtx->pIdctFourResAddPredFunc (pDstU, iStrideC, pScaledTCoeff + 4 * 64, pNzc + 16);
// Cr.
@@ -209,17 +209,17 @@
return ERR_NONE;
}
-int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) {
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
+int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer) {
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
uint8_t* pDstY, *pDstCb, *pDstCr;
int32_t iLumaStride = pCtx->pDec->iLinesize[0];
int32_t iChromaStride = pCtx->pDec->iLinesize[1];
- pDstY = pCurLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
- pDstCb = pCurLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
- pDstCr = pCurLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
+ pDstY = pCurDqLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
+ pDstCb = pCurDqLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
+ pDstCr = pCurDqLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
if (pCtx->eSliceType == P_SLICE) {
WELS_B_MB_REC_VERIFY (GetInterPred (pDstY, pDstCb, pDstCr, pCtx));
@@ -236,10 +236,10 @@
pDstYCbCr[2] = pDstCr;
WELS_B_MB_REC_VERIFY (GetInterBPred (pDstYCbCr, pTempDstYCbCr, pCtx));
}
- WelsMbInterSampleConstruction (pCtx, pCurLayer, pDstY, pDstCb, pDstCr, iLumaStride, iChromaStride);
+ WelsMbInterSampleConstruction (pCtx, pCurDqLayer, pDstY, pDstCb, pDstCr, iLumaStride, iChromaStride);
pCtx->sBlockFunc.pWelsSetNonZeroCountFunc (
- pCurLayer->pNzc[pCurLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti!
+ pCurDqLayer->pNzc[pCurDqLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti!
return ERR_NONE;
}
@@ -285,33 +285,33 @@
#undef STRIDE
}
-int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer, bool bOutput) {
+int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer, bool bOutput) {
//seems IPCM should not enter this path
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
- WelsFillRecNeededMbInfo (pCtx, bOutput, pCurLayer);
+ WelsFillRecNeededMbInfo (pCtx, bOutput, pCurDqLayer);
- if (IS_INTRA16x16 (pCurLayer->pMbType[iMbXy])) {
- RecI16x16Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
- } else if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) {
- RecI8x8Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
- } else if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) {
- RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
+ if (IS_INTRA16x16 (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ RecI16x16Mb (iMbXy, pCtx, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer);
+ } else if (IS_INTRA8x8 (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ RecI8x8Mb (iMbXy, pCtx, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer);
+ } else if (IS_INTRA4x4 (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ RecI4x4Mb (iMbXy, pCtx, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer);
}
return ERR_NONE;
}
-int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) {
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
+int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurDqLayer) {
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
uint8_t* pDstY, *pDstCb, *pDstCr;
int32_t iLumaStride = pCtx->pDec->iLinesize[0];
int32_t iChromaStride = pCtx->pDec->iLinesize[1];
- pDstY = pCurLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
- pDstCb = pCurLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
- pDstCr = pCurLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
+ pDstY = pCurDqLayer->pDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
+ pDstCb = pCurDqLayer->pDec->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
+ pDstCr = pCurDqLayer->pDec->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
if (pCtx->eSliceType == P_SLICE) {
WELS_B_MB_REC_VERIFY (GetInterPred (pDstY, pDstCb, pDstCr, pCtx));
@@ -332,24 +332,24 @@
}
int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- if (MB_TYPE_INTRA_PCM == pCurLayer->pMbType[pCurLayer->iMbXyIndex]) {
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ if (MB_TYPE_INTRA_PCM == pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex]) {
//already decoded and reconstructed when parsing
return ERR_NONE;
- } else if (IS_INTRA (pCurLayer->pMbType[pCurLayer->iMbXyIndex])) {
- WelsMbIntraPredictionConstruction (pCtx, pCurLayer, 1);
- } else if (IS_INTER (pCurLayer->pMbType[pCurLayer->iMbXyIndex])) { //InterMB
- if (0 == pCurLayer->pCbp[pCurLayer->iMbXyIndex]) { //uiCbp==0 include SKIP
+ } else if (IS_INTRA (pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex])) {
+ WelsMbIntraPredictionConstruction (pCtx, pCurDqLayer, 1);
+ } else if (IS_INTER (pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex])) { //InterMB
+ if (0 == pCurDqLayer->pCbp[pCurDqLayer->iMbXyIndex]) { //uiCbp==0 include SKIP
if (!CheckRefPics (pCtx)) {
return ERR_INFO_MB_RECON_FAIL;
}
- return WelsMbInterPrediction (pCtx, pCurLayer);
+ return WelsMbInterPrediction (pCtx, pCurDqLayer);
} else {
- WelsMbInterConstruction (pCtx, pCurLayer);
+ WelsMbInterConstruction (pCtx, pCurDqLayer);
}
} else {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetMbConstruction():::::Unknown MB type: %d",
- pCurLayer->pMbType[pCurLayer->iMbXyIndex]);
+ pCurDqLayer->pDec->pMbType[pCurDqLayer->iMbXyIndex]);
return ERR_INFO_MB_RECON_FAIL;
}
@@ -644,25 +644,25 @@
}
int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBsAux = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBsAux = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
SWelsNeighAvail sNeighAvail;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t i;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0;
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
- GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
+ GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer);
WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, uiMbType));
if (uiMbType > 25) {
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
@@ -680,104 +680,104 @@
return ERR_NONE;
} else if (0 == uiMbType) { //I4x4
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
// Transform 8x8 cabac will be added soon
WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, &sNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
}
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
- uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
+ uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
} else {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
}
//get uiCbp for I4x4
WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
- pCurLayer->pCbp[iMbXy] = uiCbp;
+ pCurDqLayer->pCbp[iMbXy] = uiCbp;
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? uiCbp >> 4 : 0;
uiCbpLuma = uiCbp & 15;
} else { //I16x16;
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
- pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
- uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
- uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
- WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
- WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBsAux, pCurLayer));
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
+ pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0 ;
+ uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15;
+ WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBsAux, pCurDqLayer));
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
- pCurLayer->pCbfDc[iMbXy] = 0;
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
+ pCurDqLayer->pCbfDc[iMbXy] = 0;
- if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ if (pCurDqLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)];
}
}
- if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
- memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
+ if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
+ memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0]));
int32_t iQpDelta, iId8x8, iId4x4;
WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta));
if (iQpDelta > 25 || iQpDelta < -26) {//out of iQpDelta range
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
- pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
- pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
+ pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
+ pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy];
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pSlice->iLastMbQp +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pSlice->iLastMbQp +
pSliceHeader->pPps->iChromaQpIndexOffset[i]), 0, 51)];
}
- if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
//step1: Luma DC
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan,
- I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx));
+ I16_LUMA_DC, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx));
//step2: Luma AC
if (uiCbpLuma) {
for (i = 0; i < 16; i++) {
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, i,
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC,
- pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), pCurLayer->pLumaQp[iMbXy], pCtx));
+ pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4), pCurDqLayer->pLumaQp[iMbXy], pCtx));
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else { //pNonZeroCount = 0
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
}
} else { //non-MB_TYPE_INTRA16x16
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
// Transform 8x8 support for CABAC
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
if (uiCbpLuma & (1 << iId8x8)) {
WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (&sNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, LUMA_DC_AC_INTRA_8,
- pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
+ pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurDqLayer->pLumaQp[iMbXy], pCtx));
} else {
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else {
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
if (uiCbpLuma & (1 << iId8x8)) {
@@ -785,8 +785,8 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
//Luma (DC and AC decoding together)
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx));
+ g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx));
iIdx++;
}
} else {
@@ -794,10 +794,10 @@
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
}
}
int32_t iMbResProperty;
@@ -808,7 +808,7 @@
for (i = 0; i < 2; i++) {
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
- iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx));
+ iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx));
}
}
@@ -820,27 +820,27 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx,
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty,
- pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx));
+ pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurDqLayer->pChromaQp[iMbXy][i], pCtx));
iIdx++;
}
}
- ST16 (&pCurLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1]));
- ST16 (&pCurLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2]));
- ST16 (&pCurLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4]));
- ST16 (&pCurLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5]));
} else {
- ST16 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST16 (&pCurLayer->pNzc[iMbXy][20], 0);
- ST16 (&pCurLayer->pNzc[iMbXy][18], 0);
- ST16 (&pCurLayer->pNzc[iMbXy][22], 0);
+ ST16 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST16 (&pCurDqLayer->pNzc[iMbXy][20], 0);
+ ST16 (&pCurDqLayer->pNzc[iMbXy][18], 0);
+ ST16 (&pCurDqLayer->pNzc[iMbXy][22], 0);
}
} else {
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
}
WELS_READ_VERIFY (ParseEndOfSliceCabac (pCtx, uiEosFlag));
@@ -856,14 +856,14 @@
}
int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBsAux = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBsAux = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t iMbResProperty;
int32_t i;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0;
@@ -870,7 +870,7 @@
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
WELS_READ_VERIFY (ParseMBTypePSliceCabac (pCtx, pNeighAvail, uiMbType));
// uiMbType = 4 is not allowded.
@@ -878,10 +878,10 @@
int16_t pMotionVector[LIST_A][30][MV_A];
int16_t pMvdCache[LIST_A][30][MV_A];
int8_t pRefIndex[LIST_A][30];
- pCurLayer->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType;
- WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurLayer);
+ pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType;
+ WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurDqLayer);
WELS_READ_VERIFY (ParseInterPMotionInfoCabac (pCtx, pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex));
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
} else { //Intra mode
uiMbType -= 5;
if (uiMbType > 25)
@@ -901,58 +901,58 @@
} else { //normal Intra mode
if (0 == uiMbType) { //Intra4x4
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
}
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
- uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
- pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
+ uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
} else {
- pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
+ pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
}
} else { //Intra16x16
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
- pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
- uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
- uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
- WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
- WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurLayer));
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
+ pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0;
+ uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15;
+ WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurDqLayer));
}
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
- if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp));
- pCurLayer->pCbp[iMbXy] = uiCbp;
+ pCurDqLayer->pCbp[iMbXy] = uiCbp;
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
- uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
- uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0 ;
+ uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15;
}
- if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
- if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
// Need modification when B picutre add in
bool bNeedParseTransformSize8x8Flag =
- (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16)
- || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
- && ((pCurLayer->pCbp[iMbXy] & 0x0F) > 0)
+ (((pCurDqLayer->pDec->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurDqLayer->pDec->pMbType[iMbXy] <= MB_TYPE_8x16)
+ || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
+ && ((pCurDqLayer->pCbp[iMbXy] & 0x0F) > 0)
&& (pCtx->pPps->bTransform8x8ModeFlag));
if (bNeedParseTransformSize8x8Flag) {
@@ -961,7 +961,7 @@
}
}
- memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
+ memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0]));
int32_t iQpDelta, iId8x8, iId4x4;
@@ -969,33 +969,33 @@
if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
- pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
- pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
+ pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
+ pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy];
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
- if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
//step1: Luma DC
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan,
- I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx));
+ I16_LUMA_DC, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx));
//step2: Luma AC
if (uiCbpLuma) {
for (i = 0; i < 16; i++) {
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, i, iScanIdxEnd - WELS_MAX (iScanIdxStart,
- 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx));
+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx));
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else {
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
}
} else { //non-MB_TYPE_INTRA16x16
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
@@ -1004,19 +1004,19 @@
if (uiCbpLuma & (1 << iId8x8)) {
WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart,
- IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8,
- pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
+ IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8,
+ pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurDqLayer->pLumaQp[iMbXy], pCtx));
} else {
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
if (uiCbpLuma & (1 << iId8x8)) {
int32_t iIdx = (iId8x8 << 2);
@@ -1023,8 +1023,8 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
//Luma (DC and AC decoding together)
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
- pCurLayer->pLumaQp[iMbXy],
+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
+ pCurDqLayer->pLumaQp[iMbXy],
pCtx));
iIdx++;
}
@@ -1033,10 +1033,10 @@
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
}
}
@@ -1044,19 +1044,19 @@
//step1: DC
if (1 == uiCbpChroma || 2 == uiCbpChroma) {
for (i = 0; i < 2; i++) {
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
else
iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
- iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx));
+ iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx));
}
}
//step2: AC
if (2 == uiCbpChroma) {
for (i = 0; i < 2; i++) {
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
else
iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
@@ -1064,22 +1064,22 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, index,
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
- iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx));
+ iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurDqLayer->pChromaQp[iMbXy][i], pCtx));
index++;
}
}
- ST16 (&pCurLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1]));
- ST16 (&pCurLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2]));
- ST16 (&pCurLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4]));
- ST16 (&pCurLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5]));
} else {
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
}
} else {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
@@ -1093,14 +1093,14 @@
}
int32_t WelsDecodeMbCabacBSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBsAux = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBsAux = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t iMbResProperty;
int32_t i;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0;
@@ -1107,7 +1107,7 @@
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
WELS_READ_VERIFY (ParseMBTypeBSliceCabac (pCtx, pNeighAvail, uiMbType));
@@ -1116,12 +1116,12 @@
int16_t pMvdCache[LIST_A][30][MV_A];
int8_t pRefIndex[LIST_A][30];
int8_t pDirect[30];
- pCurLayer->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType;
- WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurLayer);
- WelsFillDirectCacheCabac (pNeighAvail, pDirect, pCurLayer);
+ pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType;
+ WelsFillCacheInterCabac (pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex, pCurDqLayer);
+ WelsFillDirectCacheCabac (pNeighAvail, pDirect, pCurDqLayer);
WELS_READ_VERIFY (ParseInterBMotionInfoCabac (pCtx, pNeighAvail, pNonZeroCount, pMotionVector, pMvdCache, pRefIndex,
pDirect));
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
} else { //Intra mode
uiMbType -= 23;
if (uiMbType > 25)
@@ -1141,59 +1141,59 @@
} else { //normal Intra mode
if (0 == uiMbType) { //Intra4x4
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
}
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
- uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
- pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
+ uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
} else {
- pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
+ pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurDqLayer));
}
} else { //Intra16x16
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
- pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
- uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
- uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
- WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
- WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurLayer));
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
+ pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0;
+ uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15;
+ WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, pNeighAvail, pBsAux, pCurDqLayer));
}
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
- if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, pNeighAvail, uiCbp));
- pCurLayer->pCbp[iMbXy] = uiCbp;
+ pCurDqLayer->pCbp[iMbXy] = uiCbp;
pSlice->iLastDeltaQp = uiCbp == 0 ? 0 : pSlice->iLastDeltaQp;
- uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
- uiCbpLuma = pCurLayer->pCbp[iMbXy] & 15;
+ uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0;
+ uiCbpLuma = pCurDqLayer->pCbp[iMbXy] & 15;
}
- if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
- if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
// Need modification when B picutre add in
bool bNeedParseTransformSize8x8Flag =
- (((IS_INTER_16x16 (pCurLayer->pMbType[iMbXy]) || IS_DIRECT (pCurLayer->pMbType[iMbXy])
- || IS_INTER_16x8 (pCurLayer->pMbType[iMbXy]) || IS_INTER_8x16 (pCurLayer->pMbType[iMbXy]))
- || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
- && ((pCurLayer->pCbp[iMbXy] & 0x0F) > 0)
+ (((IS_INTER_16x16 (pCurDqLayer->pDec->pMbType[iMbXy]) || IS_DIRECT (pCurDqLayer->pDec->pMbType[iMbXy])
+ || IS_INTER_16x8 (pCurDqLayer->pDec->pMbType[iMbXy]) || IS_INTER_8x16 (pCurDqLayer->pDec->pMbType[iMbXy]))
+ || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
+ && ((pCurDqLayer->pCbp[iMbXy] & 0x0F) > 0)
&& (pCtx->pPps->bTransform8x8ModeFlag));
if (bNeedParseTransformSize8x8Flag) {
@@ -1202,7 +1202,7 @@
}
}
- memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
+ memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0]));
int32_t iQpDelta, iId8x8, iId4x4;
@@ -1210,33 +1210,33 @@
if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
- pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
- pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
+ pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
+ pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy];
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
- if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
//step1: Luma DC
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 0, 16, g_kuiLumaDcZigzagScan,
- I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx));
+ I16_LUMA_DC, pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx));
//step2: Luma AC
if (uiCbpLuma) {
for (i = 0; i < 16; i++) {
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, i, iScanIdxEnd - WELS_MAX (iScanIdxStart,
- 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx));
+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx));
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else {
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
}
} else { //non-MB_TYPE_INTRA16x16
if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
@@ -1245,19 +1245,19 @@
if (uiCbpLuma & (1 << iId8x8)) {
WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart,
- IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8,
- pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
+ IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8,
+ pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurDqLayer->pLumaQp[iMbXy], pCtx));
} else {
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
if (uiCbpLuma & (1 << iId8x8)) {
int32_t iIdx = (iId8x8 << 2);
@@ -1264,8 +1264,8 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
//Luma (DC and AC decoding together)
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
- pCurLayer->pLumaQp[iMbXy],
+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
+ pCurDqLayer->pLumaQp[iMbXy],
pCtx));
iIdx++;
}
@@ -1274,10 +1274,10 @@
ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
}
}
- ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
- ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
- ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
- ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
}
}
@@ -1285,19 +1285,19 @@
//step1: DC
if (1 == uiCbpChroma || 2 == uiCbpChroma) {
for (i = 0; i < 2; i++) {
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
else
iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
- iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx));
+ iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx));
}
}
//step2: AC
if (2 == uiCbpChroma) {
for (i = 0; i < 2; i++) {
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
else
iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
@@ -1305,22 +1305,22 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, index,
iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
- iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx));
+ iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurDqLayer->pChromaQp[iMbXy][i], pCtx));
index++;
}
}
- ST16 (&pCurLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1]));
- ST16 (&pCurLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2]));
- ST16 (&pCurLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4]));
- ST16 (&pCurLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][16], LD16 (&pNonZeroCount[6 + 8 * 1]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][20], LD16 (&pNonZeroCount[6 + 8 * 2]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][18], LD16 (&pNonZeroCount[6 + 8 * 4]));
+ ST16 (&pCurDqLayer->pNzc[iMbXy][22], LD16 (&pNonZeroCount[6 + 8 * 5]));
} else {
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
}
} else {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
@@ -1335,52 +1335,52 @@
int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0];
uint32_t uiCode;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t i;
SWelsNeighAvail uiNeighAvail;
- pCurLayer->pCbp[iMbXy] = 0;
- pCurLayer->pCbfDc[iMbXy] = 0;
- pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
+ pCurDqLayer->pCbp[iMbXy] = 0;
+ pCurDqLayer->pCbfDc[iMbXy] = 0;
+ pCurDqLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
- GetNeighborAvailMbType (&uiNeighAvail, pCurLayer);
+ GetNeighborAvailMbType (&uiNeighAvail, pCurDqLayer);
WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
if (uiCode) {
int16_t pMv[2] = {0};
- pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP;
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP;
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- memset (pCurLayer->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16);
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ memset (pCurDqLayer->pDec->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16);
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[0] && ppRefPic[0]->bIsComplete);
//predict mv
- PredPSkipMvFromNeighbor (pCurLayer, pMv);
+ PredPSkipMvFromNeighbor (pCurDqLayer, pMv);
for (i = 0; i < 16; i++) {
- ST32 (pCurLayer->pMv[0][iMbXy][i], * (uint32_t*)pMv);
- ST32 (pCurLayer->pMvd[0][iMbXy][i], 0);
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][i], * (uint32_t*)pMv);
+ ST32 (pCurDqLayer->pMvd[0][iMbXy][i], 0);
}
//if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag) {
- // memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t));
+ // memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t));
//}
//reset rS
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
@@ -1398,41 +1398,41 @@
int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPicL0 = pCtx->sRefPic.pRefList[LIST_0];
PPicture* ppRefPicL1 = pCtx->sRefPic.pRefList[LIST_1];
uint32_t uiCode;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t i;
SWelsNeighAvail uiNeighAvail;
- pCurLayer->pCbp[iMbXy] = 0;
- pCurLayer->pCbfDc[iMbXy] = 0;
- pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
+ pCurDqLayer->pCbp[iMbXy] = 0;
+ pCurDqLayer->pCbfDc[iMbXy] = 0;
+ pCurDqLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
- GetNeighborAvailMbType (&uiNeighAvail, pCurLayer);
+ GetNeighborAvailMbType (&uiNeighAvail, pCurDqLayer);
WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
- memset (pCurLayer->pDirect[iMbXy], 0, sizeof (int8_t) * 16);
+ memset (pCurDqLayer->pDirect[iMbXy], 0, sizeof (int8_t) * 16);
if (uiCode) {
int16_t pMv[LIST_A][2] = { {0, 0}, { 0, 0 } };
int8_t ref[LIST_A] = { 0 };
- pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT;
- ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
- ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT;
+ ST32 (&pCurDqLayer->pNzc[iMbXy][0], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][4], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][8], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][12], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][16], 0);
+ ST32 (&pCurDqLayer->pNzc[iMbXy][20], 0);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- memset (pCurLayer->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16);
- memset (pCurLayer->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16);
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ memset (pCurDqLayer->pDec->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16);
+ memset (pCurDqLayer->pDec->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16);
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
|| ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
@@ -1460,9 +1460,9 @@
//reset rS
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; //??????????????? dqaunt of previous mb
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
@@ -1509,12 +1509,12 @@
}
int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNalUnit pNalCur) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
PFmo pFmo = pCtx->pFmo;
int32_t iRet;
int32_t iNextMbXyIndex, iSliceIdc;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeaderExt pSliceHeaderExt = &pSlice->sSliceHeaderExt;
PSliceHeader pSliceHeader = &pSliceHeaderExt->sSliceHeader;
int32_t iMbX, iMbY;
@@ -1560,7 +1560,7 @@
}
pCtx->eSliceType = pSliceHeader->eSliceType;
- if (pCurLayer->sLayerInfo.pPps->bEntropyCodingModeFlag == 1) {
+ if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag == 1) {
int32_t iQp = pSlice->sSliceHeaderExt.sSliceHeader.iSliceQp;
int32_t iCabacInitIdc = pSlice->sSliceHeaderExt.sSliceHeader.iCabacInitIdc;
WelsCabacContextInit (pCtx, pSlice->eSliceType, iCabacInitIdc, iQp);
@@ -1572,14 +1572,14 @@
WelsCalcDeqCoeffScalingList (pCtx);
iNextMbXyIndex = pSliceHeader->iFirstMbInSlice;
- iMbX = iNextMbXyIndex % pCurLayer->iMbWidth;
- iMbY = iNextMbXyIndex / pCurLayer->iMbWidth; // error is introduced by multiple slices case, 11/23/2009
+ iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth;
+ iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth; // error is introduced by multiple slices case, 11/23/2009
pSlice->iMbSkipRun = -1;
- iSliceIdc = (pSliceHeader->iFirstMbInSlice << 7) + pCurLayer->uiLayerDqId;
+ iSliceIdc = (pSliceHeader->iFirstMbInSlice << 7) + pCurDqLayer->uiLayerDqId;
- pCurLayer->iMbX = iMbX;
- pCurLayer->iMbY = iMbY;
- pCurLayer->iMbXyIndex = iNextMbXyIndex;
+ pCurDqLayer->iMbX = iMbX;
+ pCurDqLayer->iMbY = iMbY;
+ pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
do {
if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame
@@ -1586,10 +1586,10 @@
break;
}
- pCurLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc;
+ pCurDqLayer->pSliceIdc[iNextMbXyIndex] = iSliceIdc;
pCtx->bMbRefConcealed = false;
iRet = pDecMbFunc (pCtx, pNalCur, uiEosFlag);
- pCurLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed;
+ pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed;
if (iRet != ERR_NONE) {
return iRet;
}
@@ -1603,11 +1603,11 @@
} else {
++iNextMbXyIndex;
}
- iMbX = iNextMbXyIndex % pCurLayer->iMbWidth;
- iMbY = iNextMbXyIndex / pCurLayer->iMbWidth;
- pCurLayer->iMbX = iMbX;
- pCurLayer->iMbY = iMbY;
- pCurLayer->iMbXyIndex = iNextMbXyIndex;
+ iMbX = iNextMbXyIndex % pCurDqLayer->iMbWidth;
+ iMbY = iNextMbXyIndex / pCurDqLayer->iMbWidth;
+ pCurDqLayer->iMbX = iMbX;
+ pCurDqLayer->iMbY = iMbY;
+ pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
} while (1);
return ERR_NONE;
@@ -1614,10 +1614,10 @@
}
int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) {
- SVlcTable* pVlcTable = &pCtx->sVlcTable;
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBs = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ SVlcTable* pVlcTable = pCtx->pVlcTable;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBs = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
SWelsNeighAvail sNeighAvail;
@@ -1626,10 +1626,10 @@
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
- const int32_t iMbXy = pCurLayer->iMbXyIndex;
- int8_t* pNzc = pCurLayer->pNzc[iMbXy];
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
+ const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t i;
int32_t iRet = ERR_NONE;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
@@ -1637,12 +1637,12 @@
int32_t iCode;
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
- GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
+ GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer);
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
uiMbType = uiCode;
@@ -1653,15 +1653,15 @@
if (25 == uiMbType) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "I_PCM mode exists in I slice!");
- int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
- int32_t iDecStrideC = pCurLayer->pDec->iLinesize[1];
+ int32_t iDecStrideL = pCurDqLayer->pDec->iLinesize[0];
+ int32_t iDecStrideC = pCurDqLayer->pDec->iLinesize[1];
int32_t iOffsetL = (iMbX + iMbY * iDecStrideL) << 4;
int32_t iOffsetC = (iMbX + iMbY * iDecStrideC) << 3;
- uint8_t* pDecY = pCurLayer->pDec->pData[0] + iOffsetL;
- uint8_t* pDecU = pCurLayer->pDec->pData[1] + iOffsetC;
- uint8_t* pDecV = pCurLayer->pDec->pData[2] + iOffsetC;
+ uint8_t* pDecY = pCurDqLayer->pDec->pData[0] + iOffsetL;
+ uint8_t* pDecU = pCurDqLayer->pDec->pData[1] + iOffsetC;
+ uint8_t* pDecV = pCurDqLayer->pDec->pData[2] + iOffsetC;
uint8_t* pTmpBsBuf;
@@ -1672,7 +1672,7 @@
int32_t iIndex = ((-pBs->iLeftBits) >> 3) + 2;
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
//step 1: locating bit-stream pointer [must align into integer byte]
pBs->pCurBuf -= iIndex;
@@ -1700,27 +1700,27 @@
pBs->pCurBuf += 384;
//step 3: update QP and pNonZeroCount
- pCurLayer->pLumaQp[iMbXy] = 0;
- memset (pCurLayer->pChromaQp[iMbXy], 0, sizeof (pCurLayer->pChromaQp[iMbXy]));
- memset (pNzc, 16, sizeof (pCurLayer->pNzc[iMbXy])); //Rec. 9.2.1 for PCM, nzc=16
+ pCurDqLayer->pLumaQp[iMbXy] = 0;
+ memset (pCurDqLayer->pChromaQp[iMbXy], 0, sizeof (pCurDqLayer->pChromaQp[iMbXy]));
+ memset (pNzc, 16, sizeof (pCurDqLayer->pNzc[iMbXy])); //Rec. 9.2.1 for PCM, nzc=16
WELS_READ_VERIFY (InitReadBits (pBs, 0));
return ERR_NONE;
} else if (0 == uiMbType) { //reference to JM
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
- pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
- uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
+ uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
}
}
- if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer));
} else {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer));
}
//uiCbp
@@ -1736,19 +1736,19 @@
uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
else
uiCbp = g_kuiIntra4x4CbpTable400[uiCbp];
- pCurLayer->pCbp[iMbXy] = uiCbp;
+ pCurDqLayer->pCbp[iMbXy] = uiCbp;
uiCbpC = uiCbp >> 4;
uiCbpL = uiCbp & 15;
} else { //I_PCM exclude, we can ignore it
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
- pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
- uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
- uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
- WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
- WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer));
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
+ pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
+ uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0;
+ uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15;
+ WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurDqLayer));
}
ST32A4 (&pNzc[0], 0);
@@ -1758,17 +1758,17 @@
ST32A4 (&pNzc[16], 0);
ST32A4 (&pNzc[20], 0);
- if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ if (pCurDqLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
- if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
- memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
+ if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
+ memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurDqLayer->pScaledTCoeff[iMbXy][0]));
int32_t iQpDelta, iId8x8, iId4x4;
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta
@@ -1778,10 +1778,10 @@
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
- pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
- pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
+ pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
+ pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy];
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0,
51)];
}
@@ -1789,10 +1789,10 @@
BsStartCavlc (pBs);
- if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
//step1: Luma DC
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC,
- pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
//step2: Luma AC
@@ -1799,8 +1799,8 @@
if (uiCbpL) {
for (i = 0; i < 16; i++) {
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1,
- g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
}
@@ -1810,15 +1810,15 @@
ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
}
} else { //non-MB_TYPE_INTRA16x16
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8;
if (uiCbpL & (1 << iId8x8)) {
int32_t iIndex = (iId8x8 << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;
}
iIndex++;
@@ -1839,8 +1839,8 @@
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
//Luma (DC and AC decoding together)
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
iIndex++;
@@ -1863,7 +1863,7 @@
for (i = 0; i < 2; i++) { //Cb Cr
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty,
- pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
+ pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
}
@@ -1876,8 +1876,8 @@
int32_t iIndex = 16 + (i << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart,
- 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
- pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
+ pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
iIndex++;
@@ -1895,9 +1895,9 @@
}
int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBs = pCurLayer->pBitStringAux;
- PSliceHeaderExt pSliceHeaderExt = &pCurLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBs = pCurDqLayer->pBitStringAux;
+ PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;
int32_t iBaseModeFlag;
int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
@@ -1922,7 +1922,7 @@
// check whether there is left bits to read next time in case multiple slices
iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits);
// sub 1, for stop bit
- if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
+ if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
uiEosFlag = 1;
}
if (iUsedBits > (pBs->iBits -
@@ -1936,10 +1936,10 @@
}
int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
- SVlcTable* pVlcTable = &pCtx->sVlcTable;
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBs = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ SVlcTable* pVlcTable = pCtx->pVlcTable;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBs = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
@@ -1946,10 +1946,10 @@
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
SWelsNeighAvail sNeighAvail;
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
- const int32_t iMbXy = pCurLayer->iMbXyIndex;
- int8_t* pNzc = pCurLayer->pNzc[iMbXy];
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
+ const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t i;
int32_t iRet = ERR_NONE;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
@@ -1957,16 +1957,16 @@
int32_t iCode;
int32_t iMbResProperty;
- GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
+ GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer);
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
uiMbType = uiCode;
if (uiMbType < 5) { //inter MB type
int16_t iMotionVector[LIST_A][30][MV_A];
int8_t iRefIndex[LIST_A][30];
- pCurLayer->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType;
- WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);
+ pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterPMbTypeInfo[uiMbType].iType;
+ WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurDqLayer);
if ((iRet = ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) != ERR_NONE) {
return iRet;//abnormal
@@ -1974,13 +1974,13 @@
if (pSlice->sSliceHeaderExt.bAdaptiveResidualPredFlag == 1) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //residual_prediction_flag
- pCurLayer->pResidualPredFlag[iMbXy] = uiCode;
+ pCurDqLayer->pResidualPredFlag[iMbXy] = uiCode;
} else {
- pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
+ pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
}
- if (pCurLayer->pResidualPredFlag[iMbXy] == 0) {
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ if (pCurDqLayer->pResidualPredFlag[iMbXy] == 0) {
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
} else {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "residual_pred_flag = 1 not supported.");
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -1994,15 +1994,15 @@
if (25 == uiMbType) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "I_PCM mode exists in P slice!");
- int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
- int32_t iDecStrideC = pCurLayer->pDec->iLinesize[1];
+ int32_t iDecStrideL = pCurDqLayer->pDec->iLinesize[0];
+ int32_t iDecStrideC = pCurDqLayer->pDec->iLinesize[1];
int32_t iOffsetL = (iMbX + iMbY * iDecStrideL) << 4;
int32_t iOffsetC = (iMbX + iMbY * iDecStrideC) << 3;
- uint8_t* pDecY = pCurLayer->pDec->pData[0] + iOffsetL;
- uint8_t* pDecU = pCurLayer->pDec->pData[1] + iOffsetC;
- uint8_t* pDecV = pCurLayer->pDec->pData[2] + iOffsetC;
+ uint8_t* pDecY = pCurDqLayer->pDec->pData[0] + iOffsetL;
+ uint8_t* pDecU = pCurDqLayer->pDec->pData[1] + iOffsetC;
+ uint8_t* pDecV = pCurDqLayer->pDec->pData[2] + iOffsetC;
uint8_t* pTmpBsBuf;
@@ -2012,7 +2012,7 @@
int32_t iIndex = ((-pBs->iLeftBits) >> 3) + 2;
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
//step 1: locating bit-stream pointer [must align into integer byte]
pBs->pCurBuf -= iIndex;
@@ -2041,8 +2041,8 @@
pBs->pCurBuf += 384;
//step 3: update QP and pNonZeroCount
- pCurLayer->pLumaQp[iMbXy] = 0;
- pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0;
+ pCurDqLayer->pLumaQp[iMbXy] = 0;
+ pCurDqLayer->pChromaQp[iMbXy][0] = pCurDqLayer->pChromaQp[iMbXy][1] = 0;
//Rec. 9.2.1 for PCM, nzc=16
ST32A4 (&pNzc[0], 0x10101010);
ST32A4 (&pNzc[4], 0x10101010);
@@ -2055,31 +2055,31 @@
} else {
if (0 == uiMbType) {
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
- pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
- uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
+ uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
}
}
- if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer));
} else {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer));
}
} else { //I_PCM exclude, we can ignore it
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
- pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
- uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
- uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
- WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
- if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) != ERR_NONE) {
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
+ pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
+ uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0;
+ uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15;
+ WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer);
+ if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurDqLayer)) != ERR_NONE) {
return iRet;
}
}
@@ -2086,7 +2086,7 @@
}
}
- if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
uiCbp = uiCode;
{
@@ -2094,7 +2094,7 @@
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
- if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA4x4 == pCurDqLayer->pDec->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurDqLayer->pDec->pMbType[iMbXy]) {
uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
} else //inter
@@ -2101,22 +2101,22 @@
uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiInterCbpTable[uiCbp] : g_kuiInterCbpTable400[uiCbp];
}
- pCurLayer->pCbp[iMbXy] = uiCbp;
- uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
- uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
+ pCurDqLayer->pCbp[iMbXy] = uiCbp;
+ uiCbpC = pCurDqLayer->pCbp[iMbXy] >> 4;
+ uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15;
// Need modification when B picutre add in
bool bNeedParseTransformSize8x8Flag =
- (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16)
- || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
+ (((pCurDqLayer->pDec->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurDqLayer->pDec->pMbType[iMbXy] <= MB_TYPE_8x16)
+ || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
&& (uiCbpL > 0)
&& (pCtx->pPps->bTransform8x8ModeFlag));
if (bNeedParseTransformSize8x8Flag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
- pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
}
}
@@ -2126,17 +2126,17 @@
ST32A4 (&pNzc[12], 0);
ST32A4 (&pNzc[16], 0);
ST32A4 (&pNzc[20], 0);
- if (pCurLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurLayer->pMbType[iMbXy]) && !IS_I_BL (pCurLayer->pMbType[iMbXy])) {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ if (pCurDqLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurDqLayer->pDec->pMbType[iMbXy]) && !IS_I_BL (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
- if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
int32_t iQpDelta, iId8x8, iId4x4;
- memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
+ memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta
iQpDelta = iCode;
@@ -2144,10 +2144,10 @@
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
- pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
- pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
+ pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
+ pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy];
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0,
51)];
}
@@ -2154,10 +2154,10 @@
BsStartCavlc (pBs);
- if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
//step1: Luma DC
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC,
- pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
//step2: Luma AC
@@ -2164,8 +2164,8 @@
if (uiCbpL) {
for (i = 0; i < 16; i++) {
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1,
- g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
}
@@ -2175,15 +2175,15 @@
ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
}
} else { //non-MB_TYPE_INTRA16x16
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8;
if (uiCbpL & (1 << iId8x8)) {
int32_t iIndex = (iId8x8 << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;
}
iIndex++;
@@ -2199,14 +2199,14 @@
ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else { // Normal T4x4
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
if (uiCbpL & (1 << iId8x8)) {
int32_t iIndex = (iId8x8 << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
//Luma (DC and AC decoding together)
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
iIndex++;
@@ -2228,13 +2228,13 @@
//step1: DC
if (1 == uiCbpC || 2 == uiCbpC) {
for (i = 0; i < 2; i++) { //Cb Cr
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
else
iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty,
- pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
+ pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
}
@@ -2243,7 +2243,7 @@
//step2: AC
if (2 == uiCbpC) {
for (i = 0; i < 2; i++) { //Cb Cr
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
else
iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
@@ -2251,8 +2251,8 @@
int32_t iIndex = 16 + (i << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart,
- 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
- pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
+ pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
iIndex++;
@@ -2270,20 +2270,20 @@
}
int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBs = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBs = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPic = pCtx->sRefPic.pRefList[LIST_0];
intX_t iUsedBits;
- const int32_t iMbXy = pCurLayer->iMbXyIndex;
- int8_t* pNzc = pCurLayer->pNzc[iMbXy];
+ const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t iBaseModeFlag, i;
int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
if (-1 == pSlice->iMbSkipRun) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run
@@ -2295,7 +2295,7 @@
if (pSlice->iMbSkipRun--) {
int16_t iMv[2];
- pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP;
ST32A4 (&pNzc[0], 0);
ST32A4 (&pNzc[4], 0);
ST32A4 (&pNzc[8], 0);
@@ -2303,30 +2303,30 @@
ST32A4 (&pNzc[16], 0);
ST32A4 (&pNzc[20], 0);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- memset (pCurLayer->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16);
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ memset (pCurDqLayer->pDec->pRefIndex[0][iMbXy], 0, sizeof (int8_t) * 16);
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[0] && ppRefPic[0]->bIsComplete);
//predict iMv
- PredPSkipMvFromNeighbor (pCurLayer, iMv);
+ PredPSkipMvFromNeighbor (pCurDqLayer, iMv);
for (i = 0; i < 16; i++) {
- ST32A2 (pCurLayer->pMv[0][iMbXy][i], * (uint32_t*)iMv);
+ ST32A2 (pCurDqLayer->pDec->pMv[0][iMbXy][i], * (uint32_t*)iMv);
}
//if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag) {
- // memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t));
+ // memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t));
//}
//reset rS
if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag ||
(pNalCur->sNalHeaderExt.uiQualityId == 0 && pNalCur->sNalHeaderExt.uiDependencyId == 0)) {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
- pCurLayer->pCbp[iMbXy] = 0;
+ pCurDqLayer->pCbp[iMbXy] = 0;
} else {
if (pSlice->sSliceHeaderExt.bAdaptiveBaseModeFlag == 1) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //base_mode_flag
@@ -2348,7 +2348,7 @@
// check whether there is left bits to read next time in case multiple slices
iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits);
// sub 1, for stop bit
- if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
+ if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
uiEosFlag = 1;
}
if (iUsedBits > (pBs->iBits -
@@ -2362,21 +2362,21 @@
}
int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBs = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBs = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
PPicture* ppRefPicL0 = pCtx->sRefPic.pRefList[LIST_0];
PPicture* ppRefPicL1 = pCtx->sRefPic.pRefList[LIST_1];
intX_t iUsedBits;
- const int32_t iMbXy = pCurLayer->iMbXyIndex;
- int8_t* pNzc = pCurLayer->pNzc[iMbXy];
+ const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t iBaseModeFlag, i;
int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
uint32_t uiCode;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
if (-1 == pSlice->iMbSkipRun) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run
@@ -2389,7 +2389,7 @@
int16_t iMv[LIST_A][2] = { { 0, 0 }, { 0, 0 } };
int8_t ref[LIST_A] = { 0 };
- pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_SKIP | MB_TYPE_DIRECT;
ST32A4 (&pNzc[0], 0);
ST32A4 (&pNzc[4], 0);
ST32A4 (&pNzc[8], 0);
@@ -2397,9 +2397,9 @@
ST32A4 (&pNzc[16], 0);
ST32A4 (&pNzc[20], 0);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
- memset (pCurLayer->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16);
- memset (pCurLayer->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16);
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ memset (pCurDqLayer->pDec->pRefIndex[LIST_0][iMbXy], 0, sizeof (int8_t) * 16);
+ memset (pCurDqLayer->pDec->pRefIndex[LIST_1][iMbXy], 0, sizeof (int8_t) * 16);
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
|| ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
@@ -2426,20 +2426,20 @@
}
//if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag) {
- // memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t));
+ // memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (int16_t));
//}
//reset rS
if (!pSlice->sSliceHeaderExt.bDefaultResidualPredFlag ||
(pNalCur->sNalHeaderExt.uiQualityId == 0 && pNalCur->sNalHeaderExt.uiDependencyId == 0)) {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
- pCurLayer->pCbp[iMbXy] = 0;
+ pCurDqLayer->pCbp[iMbXy] = 0;
} else {
if (pSlice->sSliceHeaderExt.bAdaptiveBaseModeFlag == 1) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //base_mode_flag
@@ -2461,7 +2461,7 @@
// check whether there is left bits to read next time in case multiple slices
iUsedBits = ((pBs->pCurBuf - pBs->pStartBuf) << 3) - (16 - pBs->iLeftBits);
// sub 1, for stop bit
- if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
+ if ((iUsedBits == (pBs->iBits - 1)) && (0 >= pCurDqLayer->sLayerInfo.sSliceInLayer.iMbSkipRun)) { // slice boundary
uiEosFlag = 1;
}
if (iUsedBits > (pBs->iBits -
@@ -2475,10 +2475,10 @@
}
int32_t WelsActualDecodeMbCavlcBSlice (PWelsDecoderContext pCtx) {
- SVlcTable* pVlcTable = &pCtx->sVlcTable;
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PBitStringAux pBs = pCurLayer->pBitStringAux;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ SVlcTable* pVlcTable = pCtx->pVlcTable;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PBitStringAux pBs = pCurDqLayer->pBitStringAux;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
@@ -2485,10 +2485,10 @@
int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
SWelsNeighAvail sNeighAvail;
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
- const int32_t iMbXy = pCurLayer->iMbXyIndex;
- int8_t* pNzc = pCurLayer->pNzc[iMbXy];
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
+ const int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ int8_t* pNzc = pCurDqLayer->pNzc[iMbXy];
int32_t i;
int32_t iRet = ERR_NONE;
uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
@@ -2496,16 +2496,16 @@
int32_t iCode;
int32_t iMbResProperty;
- GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
+ GetNeighborAvailMbType (&sNeighAvail, pCurDqLayer);
ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
uiMbType = uiCode;
if (uiMbType < 23) { //inter MB type
int16_t iMotionVector[LIST_A][30][MV_A];
int8_t iRefIndex[LIST_A][30];
- pCurLayer->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType;
- WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);
+ pCurDqLayer->pDec->pMbType[iMbXy] = g_ksInterBMbTypeInfo[uiMbType].iType;
+ WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurDqLayer);
if ((iRet = ParseInterBInfo (pCtx, iMotionVector, iRefIndex, pBs)) != ERR_NONE) {
return iRet;//abnormal
@@ -2513,13 +2513,13 @@
if (pSlice->sSliceHeaderExt.bAdaptiveResidualPredFlag == 1) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //residual_prediction_flag
- pCurLayer->pResidualPredFlag[iMbXy] = uiCode;
+ pCurDqLayer->pResidualPredFlag[iMbXy] = uiCode;
} else {
- pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
+ pCurDqLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
}
- if (pCurLayer->pResidualPredFlag[iMbXy] == 0) {
- pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
+ if (pCurDqLayer->pResidualPredFlag[iMbXy] == 0) {
+ pCurDqLayer->pInterPredictionDoneFlag[iMbXy] = 0;
} else {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "residual_pred_flag = 1 not supported.");
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -2533,15 +2533,15 @@
if (25 == uiMbType) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "I_PCM mode exists in B slice!");
- int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
- int32_t iDecStrideC = pCurLayer->pDec->iLinesize[1];
+ int32_t iDecStrideL = pCurDqLayer->pDec->iLinesize[0];
+ int32_t iDecStrideC = pCurDqLayer->pDec->iLinesize[1];
int32_t iOffsetL = (iMbX + iMbY * iDecStrideL) << 4;
int32_t iOffsetC = (iMbX + iMbY * iDecStrideC) << 3;
- uint8_t* pDecY = pCurLayer->pDec->pData[0] + iOffsetL;
- uint8_t* pDecU = pCurLayer->pDec->pData[1] + iOffsetC;
- uint8_t* pDecV = pCurLayer->pDec->pData[2] + iOffsetC;
+ uint8_t* pDecY = pCurDqLayer->pDec->pData[0] + iOffsetL;
+ uint8_t* pDecU = pCurDqLayer->pDec->pData[1] + iOffsetC;
+ uint8_t* pDecV = pCurDqLayer->pDec->pData[2] + iOffsetC;
uint8_t* pTmpBsBuf;
@@ -2551,7 +2551,7 @@
int32_t iIndex = ((-pBs->iLeftBits) >> 3) + 2;
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
//step 1: locating bit-stream pointer [must align into integer byte]
pBs->pCurBuf -= iIndex;
@@ -2580,8 +2580,8 @@
pBs->pCurBuf += 384;
//step 3: update QP and pNonZeroCount
- pCurLayer->pLumaQp[iMbXy] = 0;
- pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0;
+ pCurDqLayer->pLumaQp[iMbXy] = 0;
+ pCurDqLayer->pChromaQp[iMbXy][0] = pCurDqLayer->pChromaQp[iMbXy][1] = 0;
//Rec. 9.2.1 for PCM, nzc=16
ST32A4 (&pNzc[0], 0x10101010);
ST32A4 (&pNzc[4], 0x10101010);
@@ -2594,31 +2594,31 @@
} else {
if (0 == uiMbType) {
ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
if (pCtx->pPps->bTransform8x8ModeFlag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
- pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
- uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
+ uiMbType = pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
}
}
- if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer));
} else {
- pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
- WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurDqLayer);
+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurDqLayer));
}
} else { //I_PCM exclude, we can ignore it
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
- pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
- pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
- pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
- pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
- uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
- uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
- WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
- if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) != ERR_NONE) {
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = false;
+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
+ pCurDqLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
+ pCurDqLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
+ uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurDqLayer->pCbp[iMbXy] >> 4 : 0;
+ uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15;
+ WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurDqLayer);
+ if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurDqLayer)) != ERR_NONE) {
return iRet;
}
}
@@ -2625,7 +2625,7 @@
}
}
- if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 != pCurDqLayer->pDec->pMbType[iMbXy]) {
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
uiCbp = uiCode;
{
@@ -2633,7 +2633,7 @@
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
- if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA4x4 == pCurDqLayer->pDec->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurDqLayer->pDec->pMbType[iMbXy]) {
uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
} else //inter
@@ -2640,22 +2640,22 @@
uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiInterCbpTable[uiCbp] : g_kuiInterCbpTable400[uiCbp];
}
- pCurLayer->pCbp[iMbXy] = uiCbp;
- uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
- uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
+ pCurDqLayer->pCbp[iMbXy] = uiCbp;
+ uiCbpC = pCurDqLayer->pCbp[iMbXy] >> 4;
+ uiCbpL = pCurDqLayer->pCbp[iMbXy] & 15;
// Need modification when B picutre add in
bool bNeedParseTransformSize8x8Flag =
- (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16)
- || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
- && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
+ (((pCurDqLayer->pDec->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurDqLayer->pDec->pMbType[iMbXy] <= MB_TYPE_8x16)
+ || pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
+ && (pCurDqLayer->pDec->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
&& (uiCbpL > 0)
&& (pCtx->pPps->bTransform8x8ModeFlag));
if (bNeedParseTransformSize8x8Flag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
- pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
+ pCurDqLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
}
}
@@ -2665,17 +2665,17 @@
ST32A4 (&pNzc[12], 0);
ST32A4 (&pNzc[16], 0);
ST32A4 (&pNzc[20], 0);
- if (pCurLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurLayer->pMbType[iMbXy]) && !IS_I_BL (pCurLayer->pMbType[iMbXy])) {
- pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
+ if (pCurDqLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurDqLayer->pDec->pMbType[iMbXy]) && !IS_I_BL (pCurDqLayer->pDec->pMbType[iMbXy])) {
+ pCurDqLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurLayer->pLumaQp[iMbXy] +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pCurDqLayer->pLumaQp[iMbXy] +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0, 51)];
}
}
- if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (pCurDqLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
int32_t iQpDelta, iId8x8, iId4x4;
- memset (pCurLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
+ memset (pCurDqLayer->pScaledTCoeff[iMbXy], 0, MB_COEFF_LIST_SIZE * sizeof (int16_t));
WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //mb_qp_delta
iQpDelta = iCode;
@@ -2683,10 +2683,10 @@
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
}
- pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
- pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
+ pCurDqLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
+ pSlice->iLastMbQp = pCurDqLayer->pLumaQp[iMbXy];
for (i = 0; i < 2; i++) {
- pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
+ pCurDqLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 (pSlice->iLastMbQp +
pSliceHeader->pPps->iChromaQpIndexOffset[i], 0,
51)];
}
@@ -2693,10 +2693,10 @@
BsStartCavlc (pBs);
- if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_INTRA16x16 == pCurDqLayer->pDec->pMbType[iMbXy]) {
//step1: Luma DC
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC,
- pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ pCurDqLayer->pScaledTCoeff[iMbXy], pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
//step2: Luma AC
@@ -2703,8 +2703,8 @@
if (uiCbpL) {
for (i = 0; i < 16; i++) {
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1,
- g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurDqLayer->pScaledTCoeff[iMbXy] + (i << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
}
@@ -2714,15 +2714,15 @@
ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
}
} else { //non-MB_TYPE_INTRA16x16
- if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8;
if (uiCbpL & (1 << iId8x8)) {
int32_t iIndex = (iId8x8 << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;
}
iIndex++;
@@ -2738,14 +2738,14 @@
ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
} else { // Normal T4x4
for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
- iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
+ iMbResProperty = (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
if (uiCbpL & (1 << iId8x8)) {
int32_t iIndex = (iId8x8 << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
//Luma (DC and AC decoding together)
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
- g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
- pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
+ pCurDqLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
iIndex++;
@@ -2767,13 +2767,13 @@
//step1: DC
if (1 == uiCbpC || 2 == uiCbpC) {
for (i = 0; i < 2; i++) { //Cb Cr
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
else
iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty,
- pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
+ pCurDqLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
}
@@ -2782,7 +2782,7 @@
//step2: AC
if (2 == uiCbpC) {
for (i = 0; i < 2; i++) { //Cb Cr
- if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
+ if (IS_INTRA (pCurDqLayer->pDec->pMbType[iMbXy]))
iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
else
iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
@@ -2790,8 +2790,8 @@
int32_t iIndex = 16 + (i << 2);
for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart,
- 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
- pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurDqLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
+ pCurDqLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
return iRet;//abnormal
}
iIndex++;
@@ -2860,8 +2860,8 @@
// to all direct MBs in this slice, as per clause 8.4.1.2.3
// of T-REC H.264 201704
bool ComputeColocatedTemporalScaling (PWelsDecoderContext pCtx) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ PSlice pCurSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader;
if (!pSliceHeader->iDirectSpatialMvPredFlag) {
uint32_t uiRefCount = pSliceHeader->uiRefCount[LIST_0];
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -192,7 +192,7 @@
int32_t iPrevPicIdx = -1;
for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {
- if (pCtx->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
+ if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
break;
}
}
@@ -308,7 +308,7 @@
pCtx->bFreezeOutput = true;
pCtx->iFrameNum = -1;
- pCtx->iPrevFrameNum = -1;
+ pCtx->pLastDecPicInfo->iPrevFrameNum = -1;
pCtx->iErrorCode = ERR_NONE;
pCtx->pDec = NULL;
@@ -321,31 +321,62 @@
pCtx->pPicBuff = NULL;
- pCtx->bAvcBasedFlag = true;
- pCtx->pPreviousDecodedPictureInDpb = NULL;
- pCtx->sDecoderStatistics.iAvgLumaQp = -1;
- pCtx->sDecoderStatistics.iStatisticsLogInterval = 1000;
+ pCtx->sSpsPpsCtx.bAvcBasedFlag = true;
+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
+ pCtx->pDecoderStatistics->iAvgLumaQp = -1;
+ pCtx->pDecoderStatistics->iStatisticsLogInterval = 1000;
pCtx->bUseScalingList = false;
- pCtx->iSpsErrorIgnored = 0;
- pCtx->iSubSpsErrorIgnored = 0;
- pCtx->iPpsErrorIgnored = 0;
- pCtx->iPPSInvalidNum = 0;
- pCtx->iPPSLastInvalidId = -1;
- pCtx->iSPSInvalidNum = 0;
- pCtx->iSPSLastInvalidId = -1;
- pCtx->iSubSPSInvalidNum = 0;
- pCtx->iSubSPSLastInvalidId = -1;
+ pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0;
+ pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0;
+ pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0;
+ pCtx->sSpsPpsCtx.iPPSInvalidNum = 0;
+ pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1;
+ pCtx->sSpsPpsCtx.iSPSInvalidNum = 0;
+ pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1;
+ pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0;
+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1;
pCtx->iFeedbackNalRefIdc = -1; //initialize
- pCtx->iPrevPicOrderCntMsb = 0;
- pCtx->iPrevPicOrderCntLsb = 0;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
}
/*
+* fill data fields in SPS and PPS default for decoder context
+*/
+void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx) {
+ sSpsPpsCtx.bSpsExistAheadFlag = false;
+ sSpsPpsCtx.bSubspsExistAheadFlag = false;
+ sSpsPpsCtx.bPpsExistAheadFlag = false;
+ sSpsPpsCtx.bAvcBasedFlag = true;
+ sSpsPpsCtx.iSpsErrorIgnored = 0;
+ sSpsPpsCtx.iSubSpsErrorIgnored = 0;
+ sSpsPpsCtx.iPpsErrorIgnored = 0;
+ sSpsPpsCtx.iPPSInvalidNum = 0;
+ sSpsPpsCtx.iPPSLastInvalidId = -1;
+ sSpsPpsCtx.iSPSInvalidNum = 0;
+ sSpsPpsCtx.iSPSLastInvalidId = -1;
+ sSpsPpsCtx.iSubSPSInvalidNum = 0;
+ sSpsPpsCtx.iSubSPSLastInvalidId = -1;
+ sSpsPpsCtx.iSeqId = -1;
+}
+
+/*
+* fill last decoded picture info
+*/
+void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) {
+ sLastDecPicInfo.iPrevPicOrderCntMsb = 0;
+ sLastDecPicInfo.iPrevPicOrderCntLsb = 0;
+ sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;
+ sLastDecPicInfo.iPrevFrameNum = -1;
+ sLastDecPicInfo.bLastHasMmco5 = false;
+}
+
+
+/*
* destory_mb_blocks
*/
-
/*
* get size of reference picture list in target layer incoming, = (iNumRefFrames
*/
@@ -429,7 +460,7 @@
}
- pCtx->pPreviousDecodedPictureInDpb = NULL;
+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
// currently only active for LIST_0 due to have no B frames
iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff, iPicQueueSize, kiPicWidth, kiPicHeight);
@@ -500,7 +531,7 @@
InitDecFuncs (pCtx, pCtx->uiCpuFlag);
// vlc tables
- InitVlcTable (&pCtx->sVlcTable);
+ InitVlcTable (pCtx->pVlcTable);
// static memory
iRet = WelsInitStaticMemory (pCtx);
@@ -1088,7 +1119,7 @@
void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
PDqLayer pCurDq = pCtx->pCurDqLayer;
PPicture pPic = pCtx->pDec;
- SDecoderStatistics* pDecStat = &pCtx->sDecoderStatistics;
+ SDecoderStatistics* pDecStat = pCtx->pDecoderStatistics;
if (pDecStat->iAvgLumaQp == -1) //first correct frame received
pDecStat->iAvgLumaQp = 0;
@@ -1130,7 +1161,7 @@
//update decoder statistics information
void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) {
if (pCtx->bFreezeOutput)
- UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, &pCtx->sDecoderStatistics);
+ UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, pCtx->pDecoderStatistics);
else if (kbOutput)
UpdateDecStatNoFreezingInfo (pCtx);
}
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -77,11 +77,11 @@
if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) {
- if ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth)
- || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight)) {
- pCtx->sDecoderStatistics.uiResolutionChangeTimes++;
- pCtx->sDecoderStatistics.uiWidth = kiActualWidth;
- pCtx->sDecoderStatistics.uiHeight = kiActualHeight;
+ if ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth)
+ || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight)) {
+ pCtx->pDecoderStatistics->uiResolutionChangeTimes++;
+ pCtx->pDecoderStatistics->uiWidth = kiActualWidth;
+ pCtx->pDecoderStatistics->uiHeight = kiActualHeight;
}
UpdateDecStatNoFreezingInfo (pCtx);
}
@@ -250,11 +250,11 @@
pCtx->iMbNum = pPic->iMbNum;
pCtx->iMbEcedPropNum = pPic->iMbEcedPropNum;
if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
- if (pDstInfo->iBufferStatus && ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth)
- || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight))) {
- pCtx->sDecoderStatistics.uiResolutionChangeTimes++;
- pCtx->sDecoderStatistics.uiWidth = kiActualWidth;
- pCtx->sDecoderStatistics.uiHeight = kiActualHeight;
+ if (pDstInfo->iBufferStatus && ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth)
+ || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight))) {
+ pCtx->pDecoderStatistics->uiResolutionChangeTimes++;
+ pCtx->pDecoderStatistics->uiWidth = kiActualWidth;
+ pCtx->pDecoderStatistics->uiHeight = kiActualHeight;
}
UpdateDecStat (pCtx, pDstInfo->iBufferStatus != 0);
}
@@ -527,8 +527,8 @@
WELS_VERIFY_RETURN_IF (-1, (!bAllowMmco5 || bMmco5Exist));
bMmco5Exist = true;
- pCtx->iPrevPicOrderCntLsb = 0;
- pCtx->iPrevPicOrderCntMsb = 0;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
pSh->iPicOrderCntLsb = 0;
if (pCtx->pSliceHeader)
pCtx->pSliceHeader->iPicOrderCntLsb = 0;
@@ -924,22 +924,22 @@
iPpsId = uiCode;
//add check PPS available here
- if (pCtx->bPpsAvailFlags[iPpsId] == false) {
- pCtx->sDecoderStatistics.iPpsReportErrorNum++;
- if (pCtx->iPPSLastInvalidId != iPpsId) {
+ if (pCtx->sSpsPpsCtx.bPpsAvailFlags[iPpsId] == false) {
+ pCtx->pDecoderStatistics->iPpsReportErrorNum++;
+ if (pCtx->sSpsPpsCtx.iPPSLastInvalidId != iPpsId) {
WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id (%d) is invalid, previous id (%d) error ignored (%d)!", iPpsId,
- pCtx->iPPSLastInvalidId, pCtx->iPPSInvalidNum);
- pCtx->iPPSLastInvalidId = iPpsId;
- pCtx->iPPSInvalidNum = 0;
+ pCtx->sSpsPpsCtx.iPPSLastInvalidId, pCtx->sSpsPpsCtx.iPPSInvalidNum);
+ pCtx->sSpsPpsCtx.iPPSLastInvalidId = iPpsId;
+ pCtx->sSpsPpsCtx.iPPSInvalidNum = 0;
} else {
- pCtx->iPPSInvalidNum++;
+ pCtx->sSpsPpsCtx.iPPSInvalidNum++;
}
pCtx->iErrorCode |= dsNoParamSets;
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
}
- pCtx->iPPSLastInvalidId = -1;
+ pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1;
- pPps = &pCtx->sPpsBuffer[iPpsId];
+ pPps = &pCtx->sSpsPpsCtx.sPpsBuffer[iPpsId];
if (pPps->uiNumSliceGroups == 0) {
WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
@@ -948,38 +948,38 @@
}
if (kbExtensionFlag) {
- pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
+ pSubsetSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[pPps->iSpsId];
pSps = &pSubsetSps->sSps;
- if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
- pCtx->sDecoderStatistics.iSubSpsReportErrorNum++;
- if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) {
+ if (pCtx->sSpsPpsCtx.bSubspsAvailFlags[pPps->iSpsId] == false) {
+ pCtx->pDecoderStatistics->iSubSpsReportErrorNum++;
+ if (pCtx->sSpsPpsCtx.iSubSPSLastInvalidId != pPps->iSpsId) {
WelsLog (pLogCtx, WELS_LOG_ERROR, "Sub SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId,
- pCtx->iSubSPSLastInvalidId, pCtx->iSubSPSInvalidNum);
- pCtx->iSubSPSLastInvalidId = pPps->iSpsId;
- pCtx->iSubSPSInvalidNum = 0;
+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId, pCtx->sSpsPpsCtx.iSubSPSInvalidNum);
+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = pPps->iSpsId;
+ pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0;
} else {
- pCtx->iSubSPSInvalidNum++;
+ pCtx->sSpsPpsCtx.iSubSPSInvalidNum++;
}
pCtx->iErrorCode |= dsNoParamSets;
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
}
- pCtx->iSubSPSLastInvalidId = -1;
+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1;
} else {
- if (pCtx->bSpsAvailFlags[pPps->iSpsId] == false) {
- pCtx->sDecoderStatistics.iSpsReportErrorNum++;
- if (pCtx->iSPSLastInvalidId != pPps->iSpsId) {
+ if (pCtx->sSpsPpsCtx.bSpsAvailFlags[pPps->iSpsId] == false) {
+ pCtx->pDecoderStatistics->iSpsReportErrorNum++;
+ if (pCtx->sSpsPpsCtx.iSPSLastInvalidId != pPps->iSpsId) {
WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId,
- pCtx->iSPSLastInvalidId, pCtx->iSPSInvalidNum);
- pCtx->iSPSLastInvalidId = pPps->iSpsId;
- pCtx->iSPSInvalidNum = 0;
+ pCtx->sSpsPpsCtx.iSPSLastInvalidId, pCtx->sSpsPpsCtx.iSPSInvalidNum);
+ pCtx->sSpsPpsCtx.iSPSLastInvalidId = pPps->iSpsId;
+ pCtx->sSpsPpsCtx.iSPSInvalidNum = 0;
} else {
- pCtx->iSPSInvalidNum++;
+ pCtx->sSpsPpsCtx.iSPSInvalidNum++;
}
pCtx->iErrorCode |= dsNoParamSets;
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
}
- pCtx->iSPSLastInvalidId = -1;
- pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
+ pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1;
+ pSps = &pCtx->sSpsPpsCtx.sSpsBuffer[pPps->iSpsId];
}
pSliceHead->iPpsId = iPpsId;
pSliceHead->iSpsId = pPps->iSpsId;
@@ -1049,16 +1049,18 @@
//Calculate poc if necessary
int32_t pocLsb = pSliceHead->iPicOrderCntLsb;
if (pSliceHead->bIdrFlag || kpCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR) {
- pCtx->iPrevPicOrderCntMsb = 0;
- pCtx->iPrevPicOrderCntLsb = 0;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
}
int32_t pocMsb;
- if (pocLsb < pCtx->iPrevPicOrderCntLsb && pCtx->iPrevPicOrderCntLsb - pocLsb >= iMaxPocLsb / 2)
- pocMsb = pCtx->iPrevPicOrderCntMsb + iMaxPocLsb;
- else if (pocLsb > pCtx->iPrevPicOrderCntLsb && pocLsb - pCtx->iPrevPicOrderCntLsb > iMaxPocLsb / 2)
- pocMsb = pCtx->iPrevPicOrderCntMsb - iMaxPocLsb;
+ if (pocLsb < pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb
+ && pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb - pocLsb >= iMaxPocLsb / 2)
+ pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb + iMaxPocLsb;
+ else if (pocLsb > pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb
+ && pocLsb - pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb > iMaxPocLsb / 2)
+ pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb - iMaxPocLsb;
else
- pocMsb = pCtx->iPrevPicOrderCntMsb;
+ pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb;
pSliceHead->iPicOrderCntLsb = pocMsb + pocLsb;
if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) {
@@ -1066,8 +1068,8 @@
}
if (kpCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
- pCtx->iPrevPicOrderCntLsb = pocLsb;
- pCtx->iPrevPicOrderCntMsb = pocMsb;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = pocLsb;
+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = pocMsb;
}
//End of Calculating poc
} else if (pSps->uiPocType == 1 && !pSps->bDeltaPicOrderAlwaysZeroFlag) {
@@ -1376,7 +1378,7 @@
pNalHdrExtS = &kpSrc->sNalHeaderExt;
pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt;
pPrefixS = &kpSrc->sNalData.sPrefixNal;
- pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId];
+ pSps = &pCtx->sSpsPpsCtx.sSpsBuffer[pCtx->sSpsPpsCtx.sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId];
pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId;
pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId;
@@ -1438,7 +1440,7 @@
if (uiActualIdx ==
pCurAu->uiActualUnitsNum) { // no found IDR nal within incoming AU, need exit to avoid mosaic issue, 11/19/2009
- pCtx->sDecoderStatistics.uiIDRLostNum++;
+ pCtx->pDecoderStatistics->uiIDRLostNum++;
if (!pCtx->bParamSetsLostFlag)
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
"UpdateAccessUnit():::::Key frame lost.....CAN NOT find IDR from current AU.");
@@ -1825,9 +1827,9 @@
}
void ForceResetParaSetStatusAndAUList (PWelsDecoderContext pCtx) {
- pCtx->bSpsExistAheadFlag = false;
- pCtx->bSubspsExistAheadFlag = false;
- pCtx->bPpsExistAheadFlag = false;
+ pCtx->sSpsPpsCtx.bSpsExistAheadFlag = false;
+ pCtx->sSpsPpsCtx.bSubspsExistAheadFlag = false;
+ pCtx->sSpsPpsCtx.bPpsExistAheadFlag = false;
// Force clear the AU list
pCtx->pAccessUnitList->uiAvailUnitsNum = 0;
@@ -2101,7 +2103,7 @@
return iRet;
pCtx->pAccessUnitList->uiStartPos = 0;
- if (!pCtx->bAvcBasedFlag && !CheckIntegrityNalUnitsList (pCtx)) {
+ if (!pCtx->sSpsPpsCtx.bAvcBasedFlag && !CheckIntegrityNalUnitsList (pCtx)) {
pCtx->iErrorCode |= dsBitstreamError;
return dsBitstreamError;
}
@@ -2108,7 +2110,7 @@
//check current AU has only one layer or not
//If YES, can use deblocking based on AVC
- if (!pCtx->bAvcBasedFlag) {
+ if (!pCtx->sSpsPpsCtx.bAvcBasedFlag) {
CheckOnlyOneLayerInAu (pCtx);
}
@@ -2119,8 +2121,8 @@
//save previous header info
PAccessUnit pCurAu = pCtx->pAccessUnitList;
PNalUnit pCurNal = pCurAu->pNalUnitsList[pCurAu->uiEndPos];
- memcpy (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
- memcpy (&pCtx->sLastSliceHeader,
+ memcpy (&pCtx->pLastDecPicInfo->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
+ memcpy (&pCtx->pLastDecPicInfo->sLastSliceHeader,
&pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader, sizeof (SSliceHeader));
// uninitialize context of current access unit and rbsp buffer clean
ResetCurrentAccessUnit (pCtx);
@@ -2147,7 +2149,7 @@
}
int iMaxActiveLayer = 0, iMaxCurrentLayer = 0;
for (int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
- if (pCtx->pActiveLayerSps[i] != NULL) {
+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] != NULL) {
iMaxActiveLayer = i;
break;
}
@@ -2159,37 +2161,39 @@
}
}
if ((iMaxCurrentLayer != iMaxActiveLayer)
- || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->pActiveLayerSps[iMaxActiveLayer])) {
+ || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->sSpsPpsCtx.pActiveLayerSps[iMaxActiveLayer])) {
bNewSeq = true;
}
// fill active sps if the current sps is not null while active layer is null
if (!bNewSeq) {
for (int i = 0; i < MAX_LAYER_NUM; i++) {
- if (pCtx->pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) {
- pCtx->pActiveLayerSps[i] = pTmpLayerSps[i];
+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) {
+ pCtx->sSpsPpsCtx.pActiveLayerSps[i] = pTmpLayerSps[i];
}
}
} else {
// UpdateActiveLayerSps if new sequence start
- memcpy (&pCtx->pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps));
+ memcpy (&pCtx->sSpsPpsCtx.pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps));
}
return bNewSeq;
}
static void WriteBackActiveParameters (PWelsDecoderContext pCtx) {
- if (pCtx->iOverwriteFlags & OVERWRITE_PPS) {
- memcpy (&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps));
+ if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_PPS) {
+ memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT].iPpsId],
+ &pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps));
}
- if (pCtx->iOverwriteFlags & OVERWRITE_SPS) {
- memcpy (&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps));
+ if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SPS) {
+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT].iSpsId],
+ &pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps));
pCtx->bNewSeqBegin = true;
}
- if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) {
- memcpy (&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId],
- &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps));
+ if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SUBSETSPS) {
+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId],
+ &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps));
pCtx->bNewSeqBegin = true;
}
- pCtx->iOverwriteFlags = OVERWRITE_NONE;
+ pCtx->sSpsPpsCtx.iOverwriteFlags = OVERWRITE_NONE;
}
/*
@@ -2223,7 +2227,7 @@
int32_t iErr;
PAccessUnit pCurAu = pCtx->pAccessUnitList;
pCtx->bAuReadyFlag = false;
- pCtx->bLastHasMmco5 = false;
+ pCtx->pLastDecPicInfo->bLastHasMmco5 = false;
bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx);
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || bTmpNewSeqBegin;
iErr = WelsDecodeAccessUnitStart (pCtx);
@@ -2320,8 +2324,7 @@
pCtx->bUsedAsRef = false;
pCtx->iFrameNum = pSh->iFrameNum;
- UpdateDecoderStatisticsForActiveParaset (& (pCtx->sDecoderStatistics),
- pSps, pPps);
+ UpdateDecoderStatisticsForActiveParaset (pCtx->pDecoderStatistics, pSps, pPps);
}
int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) {
@@ -2396,7 +2399,7 @@
const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4;
int16_t iLastIdD = -1, iLastIdQ = -1;
int16_t iCurrIdD = 0, iCurrIdQ = 0;
- uint8_t uiNalRefIdc = 0;
+ pCtx->uiNalRefIdc = 0;
bool bFreshSliceAvailable =
true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008
@@ -2432,6 +2435,7 @@
pCtx->pDec->bNewSeqBegin = pCtx->bNewSeqBegin; //set flag for start decoding
}
pCtx->pDec->uiTimeStamp = pNalCur->uiTimeStamp;
+ pCtx->pDec->uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp;
if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
@@ -2475,7 +2479,7 @@
pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp;
dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead;
- uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc;
+ pCtx->uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc;
iPpsId = pSh->iPpsId;
@@ -2515,10 +2519,12 @@
|| (dq_cur->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR);
// Subclause 8.2.5.2 Decoding process for gaps in frame_num
if (!kbIdrFlag &&
- pSh->iFrameNum != pCtx->iPrevFrameNum &&
- pSh->iFrameNum != ((pCtx->iPrevFrameNum + 1) & ((1 << dq_cur->sLayerInfo.pSps->uiLog2MaxFrameNum) - 1))) {
+ pSh->iFrameNum != pCtx->pLastDecPicInfo->iPrevFrameNum &&
+ pSh->iFrameNum != ((pCtx->pLastDecPicInfo->iPrevFrameNum + 1) & ((1 << dq_cur->sLayerInfo.pSps->uiLog2MaxFrameNum) -
+ 1))) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
- "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", pCtx->iPrevFrameNum,
+ "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d",
+ pCtx->pLastDecPicInfo->iPrevFrameNum,
pSh->iFrameNum);
bAllRefComplete = false;
@@ -2535,7 +2541,7 @@
}
if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID) {
- iRet = InitRefPicList (pCtx, uiNalRefIdc, pSh->iPicOrderCntLsb);
+ iRet = InitRefPicList (pCtx, pCtx->uiNalRefIdc, pSh->iPicOrderCntLsb);
if (iRet) {
pCtx->bRPLRError = true;
bAllRefComplete = false; // RPLR error, set ref pictures complete flag false
@@ -2636,20 +2642,10 @@
if (iRet)
return iRet;
- pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
pCtx->bUsedAsRef = false;
- if (uiNalRefIdc > 0) {
+ if (pCtx->uiNalRefIdc > 0) {
pCtx->bUsedAsRef = true;
- //save MBType, MV and RefIndex for use in B-Slice direct mode
- memcpy (pCtx->pDec->pMbType, pCtx->pCurDqLayer->pMbType, pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint32_t));
- memcpy (pCtx->pDec->pMv[LIST_0], pCtx->pCurDqLayer->pMv[LIST_0],
- pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t) * MV_A * MB_BLOCK4x4_NUM);
- memcpy (pCtx->pDec->pMv[LIST_1], pCtx->pCurDqLayer->pMv[LIST_1],
- pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t) * MV_A * MB_BLOCK4x4_NUM);
- memcpy (pCtx->pDec->pRefIndex[LIST_0], pCtx->pCurDqLayer->pRefIndex[LIST_0],
- pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM);
- memcpy (pCtx->pDec->pRefIndex[LIST_1], pCtx->pCurDqLayer->pRefIndex[LIST_1],
- pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM);
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
uint32_t i = 0;
while (i < MAX_DPB_COUNT && pCtx->sRefPic.pRefList[listIdx][i]) {
@@ -2676,9 +2672,9 @@
// need update frame_num due current frame is well decoded
if (pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0)
- pCtx->iPrevFrameNum = pSh->iFrameNum;
- if (pCtx->bLastHasMmco5)
- pCtx->iPrevFrameNum = 0;
+ pCtx->pLastDecPicInfo->iPrevFrameNum = pSh->iFrameNum;
+ if (pCtx->pLastDecPicInfo->bLastHasMmco5)
+ pCtx->pLastDecPicInfo->iPrevFrameNum = 0;
}
return ERR_NONE;
@@ -2690,7 +2686,8 @@
if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { //VCL data, AU list should have data
PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
bAuBoundaryFlag = (pCtx->iTotalNumMbRec != 0)
- && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
+ && (CheckAccessUnitBoundaryExt (&pCtx->pLastDecPicInfo->sLastNalHdrExt, &pCurNal->sNalHeaderExt,
+ &pCtx->pLastDecPicInfo->sLastSliceHeader,
&pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader));
} else { //non VCL
if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_AU_DELIMITER) {
@@ -2698,11 +2695,11 @@
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SEI) {
bAuBoundaryFlag = true;
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SPS) {
- bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SPS);
+ bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SPS);
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SUBSET_SPS) {
- bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS);
+ bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SUBSETSPS);
} else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_PPS) {
- bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_PPS);
+ bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_PPS);
}
if (bAuBoundaryFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { //Construct remaining data first
ConstructAccessUnit (pCtx, ppDst, pDstInfo);
@@ -2718,8 +2715,8 @@
pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
- pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
- if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
+ if (pCtx->pLastDecPicInfo->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
if (MarkECFrameAsRef (pCtx) == ERR_INFO_INVALID_PTR) {
pCtx->iErrorCode |= dsRefListNullPtrs;
return false;
@@ -2730,7 +2727,8 @@
pCtx->bFrameFinish = true; //clear frame pending status here!
} else {
if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
- if ((pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) && (pCtx->sLastNalHdrExt.uiTemporalId == 0))
+ if ((pCtx->pLastDecPicInfo->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0)
+ && (pCtx->pLastDecPicInfo->sLastNalHdrExt.uiTemporalId == 0))
pCtx->iErrorCode |= dsNoParamSets;
else
pCtx->iErrorCode |= dsBitstreamError;
@@ -2740,9 +2738,9 @@
}
pCtx->pDec = NULL;
if (pAu->pNalUnitsList[pAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0)
- pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
- if (pCtx->bLastHasMmco5)
- pCtx->iPrevFrameNum = 0;
+ pCtx->pLastDecPicInfo->iPrevFrameNum = pCtx->pLastDecPicInfo->sLastSliceHeader.iFrameNum; //save frame_num
+ if (pCtx->pLastDecPicInfo->bLastHasMmco5)
+ pCtx->pLastDecPicInfo->iPrevFrameNum = 0;
}
return ERR_NONE;
}
@@ -2753,28 +2751,37 @@
int32_t iRealMbIdx = pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
for (int32_t iMbIdx = 0; bAllRefComplete
&& iMbIdx < pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice; iMbIdx++) {
- switch (pCtx->pCurDqLayer->pMbType[iRealMbIdx]) {
+ switch (pCtx->pCurDqLayer->pDec->pMbType[iRealMbIdx]) {
case MB_TYPE_SKIP:
case MB_TYPE_16x16:
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
break;
case MB_TYPE_16x8:
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
break;
case MB_TYPE_8x16:
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
break;
case MB_TYPE_8x8:
case MB_TYPE_8x8_REF0:
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
- bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
+ bAllRefComplete &=
+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete;
break;
default:
--- a/codec/decoder/core/src/error_concealment.cpp
+++ b/codec/decoder/core/src/error_concealment.cpp
@@ -83,7 +83,7 @@
//Do error concealment using frame copy method
void DoErrorConFrameCopy (PWelsDecoderContext pCtx) {
PPicture pDstPic = pCtx->pDec;
- PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb;
+ PPicture pSrcPic = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb;
uint32_t uiHeightInPixelY = (pCtx->pSps->iMbHeight) << 4;
int32_t iStrideY = pDstPic->iLinesize[0];
int32_t iStrideUV = pDstPic->iLinesize[1];
@@ -109,7 +109,7 @@
int32_t iMbWidth = (int32_t) pCtx->pSps->iMbWidth;
int32_t iMbHeight = (int32_t) pCtx->pSps->iMbHeight;
PPicture pDstPic = pCtx->pDec;
- PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb;
+ PPicture pSrcPic = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb;
if ((pCtx->pParam->eEcActiveIdc == ERROR_CON_SLICE_COPY) && (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag))
pSrcPic = NULL; //no cross IDR method, should fill in data instead of copy
@@ -266,40 +266,40 @@
for (int32_t iMbY = 0; iMbY < iMbHeight; ++iMbY) {
for (int32_t iMbX = 0; iMbX < iMbWidth; ++iMbX) {
iMbXyIndex = iMbY * iMbWidth + iMbX;
- if (pMbCorrectlyDecodedFlag[iMbXyIndex] && IS_INTER (pCurDqLayer->pMbType[iMbXyIndex])) {
- uint32_t iMBType = pCurDqLayer->pMbType[iMbXyIndex];
+ if (pMbCorrectlyDecodedFlag[iMbXyIndex] && IS_INTER (pCurDqLayer->pDec->pMbType[iMbXyIndex])) {
+ uint32_t iMBType = pCurDqLayer->pDec->pMbType[iMbXyIndex];
switch (iMBType) {
case MB_TYPE_SKIP:
case MB_TYPE_16x16:
- iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][0];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][0][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][0][1];
+ iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][0];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][1];
pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
iInterMbCorrectNum[iRefIdx]++;
break;
case MB_TYPE_16x8:
- iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][0];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][0][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][0][1];
+ iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][0];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][1];
pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
iInterMbCorrectNum[iRefIdx]++;
- iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][8];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][8][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][8][1];
+ iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][8];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][8][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][8][1];
pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
iInterMbCorrectNum[iRefIdx]++;
break;
case MB_TYPE_8x16:
- iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][0];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][0][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][0][1];
+ iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][0];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][0][1];
pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
iInterMbCorrectNum[iRefIdx]++;
- iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][2];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][2][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][2][1];
+ iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][2];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][2][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][2][1];
pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
iInterMbCorrectNum[iRefIdx]++;
break;
@@ -311,39 +311,39 @@
for (i = 0; i < 4; i++) {
iSubMBType = pCurDqLayer->pSubMbType[iMbXyIndex][i];
iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
- iRefIdx = pCurDqLayer->pRefIndex[0][iMbXyIndex][iIIdx];
+ iRefIdx = pCurDqLayer->pDec->pRefIndex[0][iMbXyIndex][iIIdx];
pCtx->pECRefPic[iRefIdx] = pCtx->sRefPic.pRefList[LIST_0][iRefIdx];
switch (iSubMBType) {
case SUB_MB_TYPE_8x8:
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][1];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][1];
iInterMbCorrectNum[iRefIdx]++;
break;
case SUB_MB_TYPE_8x4:
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][1];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][1];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 4][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 4][1];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 4][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 4][1];
iInterMbCorrectNum[iRefIdx] += 2;
break;
case SUB_MB_TYPE_4x8:
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx][1];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx][1];
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 1][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + 1][1];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 1][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + 1][1];
iInterMbCorrectNum[iRefIdx] += 2;
break;
case SUB_MB_TYPE_4x4: {
for (j = 0; j < 4; j++) {
iJIdx = ((j >> 1) << 2) + (j & 1);
- pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + iJIdx][0];
- pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pMv[0][iMbXyIndex][iIIdx + iJIdx][1];
+ pCtx->iECMVs[iRefIdx][0] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + iJIdx][0];
+ pCtx->iECMVs[iRefIdx][1] += pCurDqLayer->pDec->pMv[0][iMbXyIndex][iIIdx + iJIdx][1];
}
iInterMbCorrectNum[iRefIdx] += 4;
}
@@ -372,7 +372,7 @@
int32_t iMbWidth = (int32_t) pCtx->pSps->iMbWidth;
int32_t iMbHeight = (int32_t) pCtx->pSps->iMbHeight;
PPicture pDstPic = pCtx->pDec;
- PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb;
+ PPicture pSrcPic = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb;
bool* pMbCorrectlyDecodedFlag = pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag;
int32_t iMbXyIndex;
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -140,20 +140,24 @@
|| (ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->pParam->eEcActiveIdc)
|| (ERROR_CON_SLICE_MV_COPY_CROSS_IDR == pCtx->pParam->eEcActiveIdc)
|| (ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->pParam->eEcActiveIdc))
- && (NULL != pCtx->pPreviousDecodedPictureInDpb);
- bCopyPrevious = bCopyPrevious && (pRef->iWidthInPixel == pCtx->pPreviousDecodedPictureInDpb->iWidthInPixel)
- && (pRef->iHeightInPixel == pCtx->pPreviousDecodedPictureInDpb->iHeightInPixel);
+ && (NULL != pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb);
+ bCopyPrevious = bCopyPrevious
+ && (pRef->iWidthInPixel == pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iWidthInPixel)
+ && (pRef->iHeightInPixel == pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iHeightInPixel);
if (!bCopyPrevious) {
memset (pRef->pData[0], 128, pRef->iLinesize[0] * pRef->iHeightInPixel);
memset (pRef->pData[1], 128, pRef->iLinesize[1] * pRef->iHeightInPixel / 2);
memset (pRef->pData[2], 128, pRef->iLinesize[2] * pRef->iHeightInPixel / 2);
- } else if (pRef == pCtx->pPreviousDecodedPictureInDpb) {
+ } else if (pRef == pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsInitRefList()::EC memcpy overlap.");
} else {
- memcpy (pRef->pData[0], pCtx->pPreviousDecodedPictureInDpb->pData[0], pRef->iLinesize[0] * pRef->iHeightInPixel);
- memcpy (pRef->pData[1], pCtx->pPreviousDecodedPictureInDpb->pData[1], pRef->iLinesize[1] * pRef->iHeightInPixel / 2);
- memcpy (pRef->pData[2], pCtx->pPreviousDecodedPictureInDpb->pData[2], pRef->iLinesize[2] * pRef->iHeightInPixel / 2);
+ memcpy (pRef->pData[0], pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->pData[0],
+ pRef->iLinesize[0] * pRef->iHeightInPixel);
+ memcpy (pRef->pData[1], pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->pData[1],
+ pRef->iLinesize[1] * pRef->iHeightInPixel / 2);
+ memcpy (pRef->pData[2], pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->pData[2],
+ pRef->iLinesize[2] * pRef->iHeightInPixel / 2);
}
pRef->iFrameNum = 0;
pRef->iFramePoc = 0;
@@ -577,7 +581,7 @@
}
}
- if (pCtx->bLastHasMmco5) {
+ if (pCtx->pLastDecPicInfo->bLastHasMmco5) {
pCtx->pDec->iFrameNum = 0;
pCtx->pDec->iFramePoc = 0;
}
@@ -684,7 +688,7 @@
break;
case MMCO_RESET:
WelsResetRefPic (pCtx);
- pCtx->bLastHasMmco5 = true;
+ pCtx->pLastDecPicInfo->bLastHasMmco5 = true;
break;
case MMCO_LONG:
if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
--- a/codec/decoder/core/src/mv_pred.cpp
+++ b/codec/decoder/core/src/mv_pred.cpp
@@ -155,7 +155,7 @@
memcpy (&dst[stride_dst * 3], &src[stride_src * 3], 16);
}
}
-void PredPSkipMvFromNeighbor (PDqLayer pCurLayer, int16_t iMvp[2]) {
+void PredPSkipMvFromNeighbor (PDqLayer pCurDqLayer, int16_t iMvp[2]) {
bool bTopAvail, bLeftTopAvail, bRightTopAvail, bLeftAvail;
int32_t iCurSliceIdc, iTopSliceIdc, iLeftTopSliceIdc, iRightTopSliceIdc, iLeftSliceIdc;
@@ -170,14 +170,14 @@
int8_t iMatchRef;
int16_t iMvA[2], iMvB[2], iMvC[2], iMvD[2];
- iCurXy = pCurLayer->iMbXyIndex;
- iCurX = pCurLayer->iMbX;
- iCurY = pCurLayer->iMbY;
- iCurSliceIdc = pCurLayer->pSliceIdc[iCurXy];
+ iCurXy = pCurDqLayer->iMbXyIndex;
+ iCurX = pCurDqLayer->iMbX;
+ iCurY = pCurDqLayer->iMbY;
+ iCurSliceIdc = pCurDqLayer->pSliceIdc[iCurXy];
if (iCurX != 0) {
iLeftXy = iCurXy - 1;
- iLeftSliceIdc = pCurLayer->pSliceIdc[iLeftXy];
+ iLeftSliceIdc = pCurDqLayer->pSliceIdc[iLeftXy];
bLeftAvail = (iLeftSliceIdc == iCurSliceIdc);
} else {
bLeftAvail = 0;
@@ -185,19 +185,19 @@
}
if (iCurY != 0) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
- iTopSliceIdc = pCurLayer->pSliceIdc[iTopXy];
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
+ iTopSliceIdc = pCurDqLayer->pSliceIdc[iTopXy];
bTopAvail = (iTopSliceIdc == iCurSliceIdc);
if (iCurX != 0) {
iLeftTopXy = iTopXy - 1;
- iLeftTopSliceIdc = pCurLayer->pSliceIdc[iLeftTopXy];
+ iLeftTopSliceIdc = pCurDqLayer->pSliceIdc[iLeftTopXy];
bLeftTopAvail = (iLeftTopSliceIdc == iCurSliceIdc);
} else {
bLeftTopAvail = 0;
}
- if (iCurX != (pCurLayer->iMbWidth - 1)) {
+ if (iCurX != (pCurDqLayer->iMbWidth - 1)) {
iRightTopXy = iTopXy + 1;
- iRightTopSliceIdc = pCurLayer->pSliceIdc[iRightTopXy];
+ iRightTopSliceIdc = pCurDqLayer->pSliceIdc[iRightTopXy];
bRightTopAvail = (iRightTopSliceIdc == iCurSliceIdc);
} else {
bRightTopAvail = 0;
@@ -208,18 +208,18 @@
bRightTopAvail = 0;
}
- iLeftType = ((iCurX != 0 && bLeftAvail) ? pCurLayer->pMbType[iLeftXy] : 0);
- iTopType = ((iCurY != 0 && bTopAvail) ? pCurLayer->pMbType[iTopXy] : 0);
+ iLeftType = ((iCurX != 0 && bLeftAvail) ? GetMbType (pCurDqLayer)[iLeftXy] : 0);
+ iTopType = ((iCurY != 0 && bTopAvail) ? GetMbType (pCurDqLayer)[iTopXy] : 0);
iLeftTopType = ((iCurX != 0 && iCurY != 0 && bLeftTopAvail)
- ? pCurLayer->pMbType[iLeftTopXy] : 0);
- iRightTopType = ((iCurX != pCurLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail)
- ? pCurLayer->pMbType[iRightTopXy] : 0);
+ ? GetMbType (pCurDqLayer)[iLeftTopXy] : 0);
+ iRightTopType = ((iCurX != pCurDqLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail)
+ ? GetMbType (pCurDqLayer)[iRightTopXy] : 0);
/*get neb mv&iRefIdxArray*/
/*left*/
if (bLeftAvail && IS_INTER (iLeftType)) {
- ST32 (iMvA, LD32 (pCurLayer->pMv[0][iLeftXy][3]));
- iLeftRef = pCurLayer->pRefIndex[0][iLeftXy][3];
+ ST32 (iMvA, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iLeftXy][3] : pCurDqLayer->pMv[0][iLeftXy][3]));
+ iLeftRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iLeftXy][3] : pCurDqLayer->pRefIndex[0][iLeftXy][3];
} else {
ST32 (iMvA, 0);
if (0 == bLeftAvail) { //not available
@@ -236,8 +236,8 @@
/*top*/
if (bTopAvail && IS_INTER (iTopType)) {
- ST32 (iMvB, LD32 (pCurLayer->pMv[0][iTopXy][12]));
- iTopRef = pCurLayer->pRefIndex[0][iTopXy][12];
+ ST32 (iMvB, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iTopXy][12] : pCurDqLayer->pMv[0][iTopXy][12]));
+ iTopRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iTopXy][12] : pCurDqLayer->pRefIndex[0][iTopXy][12];
} else {
ST32 (iMvB, 0);
if (0 == bTopAvail) { //not available
@@ -254,8 +254,10 @@
/*right_top*/
if (bRightTopAvail && IS_INTER (iRightTopType)) {
- ST32 (iMvC, LD32 (pCurLayer->pMv[0][iRightTopXy][12]));
- iRightTopRef = pCurLayer->pRefIndex[0][iRightTopXy][12];
+ ST32 (iMvC, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iRightTopXy][12] :
+ pCurDqLayer->pMv[0][iRightTopXy][12]));
+ iRightTopRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iRightTopXy][12] :
+ pCurDqLayer->pRefIndex[0][iRightTopXy][12];
} else {
ST32 (iMvC, 0);
if (0 == bRightTopAvail) { //not available
@@ -267,8 +269,9 @@
/*left_top*/
if (bLeftTopAvail && IS_INTER (iLeftTopType)) {
- ST32 (iMvD, LD32 (pCurLayer->pMv[0][iLeftTopXy][15]));
- iLeftTopRef = pCurLayer->pRefIndex[0][iLeftTopXy][15];
+ ST32 (iMvD, LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[0][iLeftTopXy][15] : pCurDqLayer->pMv[0][iLeftTopXy][15]));
+ iLeftTopRef = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[0][iLeftTopXy][15] :
+ pCurDqLayer->pRefIndex[0][iLeftTopXy][15];
} else {
ST32 (iMvD, 0);
if (0 == bLeftTopAvail) { //not available
@@ -305,11 +308,11 @@
}
int32_t GetColocatedMb (PWelsDecoderContext pCtx, MbType& mbType, SubMbType& subMbType) {
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
- uint32_t is8x8 = IS_Inter_8x8 (pCurLayer->pMbType[iMbXy]);
- mbType = pCurLayer->pMbType[iMbXy];
+ uint32_t is8x8 = IS_Inter_8x8 (GetMbType (pCurDqLayer)[iMbXy]);
+ mbType = GetMbType (pCurDqLayer)[iMbXy];
PPicture colocPic = pCtx->sRefPic.pRefList[LIST_1][0];
@@ -336,43 +339,43 @@
}
if (IS_INTRA (coloc_mbType)) {
- SetRectBlock (pCurLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 1, sizeof (int8_t));
+ SetRectBlock (pCurDqLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 1, sizeof (int8_t));
return ERR_NONE;
}
- SetRectBlock (pCurLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 0, sizeof (int8_t));
+ SetRectBlock (pCurDqLayer->iColocIntra, 4, 4, 4 * sizeof (int8_t), 0, sizeof (int8_t));
if (IS_INTER_16x16 (mbType)) {
int16_t iMVZero[2] = { 0 };
int16_t* pMv = IS_TYPE_L1 (coloc_mbType) ? colocPic->pMv[LIST_1][iMbXy][0] : iMVZero;
- ST32 (pCurLayer->iColocMv[LIST_0][0], LD32 (colocPic->pMv[LIST_0][iMbXy][0]));
- ST32 (pCurLayer->iColocMv[LIST_1][0], LD32 (pMv));
- pCurLayer->iColocRefIndex[LIST_0][0] = colocPic->pRefIndex[LIST_0][iMbXy][0];
- pCurLayer->iColocRefIndex[LIST_1][0] = IS_TYPE_L1 (coloc_mbType) ? colocPic->pRefIndex[LIST_1][iMbXy][0] :
- REF_NOT_IN_LIST;
+ ST32 (pCurDqLayer->iColocMv[LIST_0][0], LD32 (colocPic->pMv[LIST_0][iMbXy][0]));
+ ST32 (pCurDqLayer->iColocMv[LIST_1][0], LD32 (pMv));
+ pCurDqLayer->iColocRefIndex[LIST_0][0] = colocPic->pRefIndex[LIST_0][iMbXy][0];
+ pCurDqLayer->iColocRefIndex[LIST_1][0] = IS_TYPE_L1 (coloc_mbType) ? colocPic->pRefIndex[LIST_1][iMbXy][0] :
+ REF_NOT_IN_LIST;
} else {
if (!pCtx->pSps->bDirect8x8InferenceFlag) {
- CopyRectBlock4Cols (pCurLayer->iColocMv[LIST_0], colocPic->pMv[LIST_0][iMbXy], 16, 16, 4, 4);
- CopyRectBlock4Cols (pCurLayer->iColocRefIndex[LIST_0], colocPic->pRefIndex[LIST_0][iMbXy], 4, 4, 4, 1);
+ CopyRectBlock4Cols (pCurDqLayer->iColocMv[LIST_0], colocPic->pMv[LIST_0][iMbXy], 16, 16, 4, 4);
+ CopyRectBlock4Cols (pCurDqLayer->iColocRefIndex[LIST_0], colocPic->pRefIndex[LIST_0][iMbXy], 4, 4, 4, 1);
if (IS_TYPE_L1 (coloc_mbType)) {
- CopyRectBlock4Cols (pCurLayer->iColocMv[LIST_1], colocPic->pMv[LIST_1][iMbXy], 16, 16, 4, 4);
- CopyRectBlock4Cols (pCurLayer->iColocRefIndex[LIST_1], colocPic->pRefIndex[LIST_1][iMbXy], 4, 4, 4, 1);
+ CopyRectBlock4Cols (pCurDqLayer->iColocMv[LIST_1], colocPic->pMv[LIST_1][iMbXy], 16, 16, 4, 4);
+ CopyRectBlock4Cols (pCurDqLayer->iColocRefIndex[LIST_1], colocPic->pRefIndex[LIST_1][iMbXy], 4, 4, 4, 1);
} else { // only forward prediction
- SetRectBlock (pCurLayer->iColocRefIndex[LIST_1], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1);
+ SetRectBlock (pCurDqLayer->iColocRefIndex[LIST_1], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1);
}
} else {
for (int32_t listIdx = 0; listIdx < 1 + !! (coloc_mbType & MB_TYPE_L1); listIdx++) {
- SetRectBlock (pCurLayer->iColocMv[listIdx][0], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][0]), 4);
- SetRectBlock (pCurLayer->iColocMv[listIdx][2], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][3]), 4);
- SetRectBlock (pCurLayer->iColocMv[listIdx][8], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][12]), 4);
- SetRectBlock (pCurLayer->iColocMv[listIdx][10], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][15]), 4);
+ SetRectBlock (pCurDqLayer->iColocMv[listIdx][0], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][0]), 4);
+ SetRectBlock (pCurDqLayer->iColocMv[listIdx][2], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][3]), 4);
+ SetRectBlock (pCurDqLayer->iColocMv[listIdx][8], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][12]), 4);
+ SetRectBlock (pCurDqLayer->iColocMv[listIdx][10], 2, 2, 16, LD32 (colocPic->pMv[listIdx][iMbXy][15]), 4);
- SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][0], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][0], 1);
- SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][2], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][3], 1);
- SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][8], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][12], 1);
- SetRectBlock (&pCurLayer->iColocRefIndex[listIdx][10], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][15], 1);
+ SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][0], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][0], 1);
+ SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][2], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][3], 1);
+ SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][8], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][12], 1);
+ SetRectBlock (&pCurDqLayer->iColocRefIndex[listIdx][10], 2, 2, 4, colocPic->pRefIndex[listIdx][iMbXy][15], 1);
}
if (! (coloc_mbType & MB_TYPE_L1)) // only forward prediction
- SetRectBlock (&pCurLayer->iColocRefIndex[1][0], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1);
+ SetRectBlock (&pCurDqLayer->iColocRefIndex[1][0], 4, 4, 4, (uint8_t)REF_NOT_IN_LIST, 1);
}
}
return ERR_NONE;
@@ -382,9 +385,9 @@
SubMbType& subMbType) {
int32_t ret = ERR_NONE;
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
- bool bSkipOrDirect = (IS_SKIP (pCurLayer->pMbType[iMbXy]) | IS_DIRECT (pCurLayer->pMbType[iMbXy])) > 0;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ bool bSkipOrDirect = (IS_SKIP (GetMbType (pCurDqLayer)[iMbXy]) | IS_DIRECT (GetMbType (pCurDqLayer)[iMbXy])) > 0;
MbType mbType;
ret = GetColocatedMb (pCtx, mbType, subMbType);
@@ -404,15 +407,15 @@
int8_t iDiagonalRef[LIST_A];
int16_t iMvA[LIST_A][2], iMvB[LIST_A][2], iMvC[LIST_A][2], iMvD[LIST_A][2];
- iCurXy = pCurLayer->iMbXyIndex;
+ iCurXy = pCurDqLayer->iMbXyIndex;
- iCurX = pCurLayer->iMbX;
- iCurY = pCurLayer->iMbY;
- iCurSliceIdc = pCurLayer->pSliceIdc[iCurXy];
+ iCurX = pCurDqLayer->iMbX;
+ iCurY = pCurDqLayer->iMbY;
+ iCurSliceIdc = pCurDqLayer->pSliceIdc[iCurXy];
if (iCurX != 0) {
iLeftXy = iCurXy - 1;
- iLeftSliceIdc = pCurLayer->pSliceIdc[iLeftXy];
+ iLeftSliceIdc = pCurDqLayer->pSliceIdc[iLeftXy];
bLeftAvail = (iLeftSliceIdc == iCurSliceIdc);
} else {
bLeftAvail = 0;
@@ -420,19 +423,19 @@
}
if (iCurY != 0) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
- iTopSliceIdc = pCurLayer->pSliceIdc[iTopXy];
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
+ iTopSliceIdc = pCurDqLayer->pSliceIdc[iTopXy];
bTopAvail = (iTopSliceIdc == iCurSliceIdc);
if (iCurX != 0) {
iLeftTopXy = iTopXy - 1;
- iLeftTopSliceIdc = pCurLayer->pSliceIdc[iLeftTopXy];
+ iLeftTopSliceIdc = pCurDqLayer->pSliceIdc[iLeftTopXy];
bLeftTopAvail = (iLeftTopSliceIdc == iCurSliceIdc);
} else {
bLeftTopAvail = 0;
}
- if (iCurX != (pCurLayer->iMbWidth - 1)) {
+ if (iCurX != (pCurDqLayer->iMbWidth - 1)) {
iRightTopXy = iTopXy + 1;
- iRightTopSliceIdc = pCurLayer->pSliceIdc[iRightTopXy];
+ iRightTopSliceIdc = pCurDqLayer->pSliceIdc[iRightTopXy];
bRightTopAvail = (iRightTopSliceIdc == iCurSliceIdc);
} else {
bRightTopAvail = 0;
@@ -443,12 +446,12 @@
bRightTopAvail = 0;
}
- iLeftType = ((iCurX != 0 && bLeftAvail) ? pCurLayer->pMbType[iLeftXy] : 0);
- iTopType = ((iCurY != 0 && bTopAvail) ? pCurLayer->pMbType[iTopXy] : 0);
+ iLeftType = ((iCurX != 0 && bLeftAvail) ? GetMbType (pCurDqLayer)[iLeftXy] : 0);
+ iTopType = ((iCurY != 0 && bTopAvail) ? GetMbType (pCurDqLayer)[iTopXy] : 0);
iLeftTopType = ((iCurX != 0 && iCurY != 0 && bLeftTopAvail)
- ? pCurLayer->pMbType[iLeftTopXy] : 0);
- iRightTopType = ((iCurX != pCurLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail)
- ? pCurLayer->pMbType[iRightTopXy] : 0);
+ ? GetMbType (pCurDqLayer)[iLeftTopXy] : 0);
+ iRightTopType = ((iCurX != pCurDqLayer->iMbWidth - 1 && iCurY != 0 && bRightTopAvail)
+ ? GetMbType (pCurDqLayer)[iRightTopXy] : 0);
/*get neb mv&iRefIdxArray*/
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
@@ -455,8 +458,10 @@
/*left*/
if (bLeftAvail && IS_INTER (iLeftType)) {
- ST32 (iMvA[listIdx], LD32 (pCurLayer->pMv[listIdx][iLeftXy][3]));
- iLeftRef[listIdx] = pCurLayer->pRefIndex[listIdx][iLeftXy][3];
+ ST32 (iMvA[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iLeftXy][3] :
+ pCurDqLayer->pMv[listIdx][iLeftXy][3]));
+ iLeftRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][3] :
+ pCurDqLayer->pRefIndex[listIdx][iLeftXy][3];
} else {
ST32 (iMvA[listIdx], 0);
if (0 == bLeftAvail) { //not available
@@ -468,8 +473,10 @@
/*top*/
if (bTopAvail && IS_INTER (iTopType)) {
- ST32 (iMvB[listIdx], LD32 (pCurLayer->pMv[listIdx][iTopXy][12]));
- iTopRef[listIdx] = pCurLayer->pRefIndex[listIdx][iTopXy][12];
+ ST32 (iMvB[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iTopXy][12] :
+ pCurDqLayer->pMv[listIdx][iTopXy][12]));
+ iTopRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iTopXy][12] :
+ pCurDqLayer->pRefIndex[listIdx][iTopXy][12];
} else {
ST32 (iMvB[listIdx], 0);
if (0 == bTopAvail) { //not available
@@ -481,8 +488,10 @@
/*right_top*/
if (bRightTopAvail && IS_INTER (iRightTopType)) {
- ST32 (iMvC[listIdx], LD32 (pCurLayer->pMv[listIdx][iRightTopXy][12]));
- iRightTopRef[listIdx] = pCurLayer->pRefIndex[listIdx][iRightTopXy][12];
+ ST32 (iMvC[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iRightTopXy][12] :
+ pCurDqLayer->pMv[listIdx][iRightTopXy][12]));
+ iRightTopRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iRightTopXy][12] :
+ pCurDqLayer->pRefIndex[listIdx][iRightTopXy][12];
} else {
ST32 (iMvC[listIdx], 0);
if (0 == bRightTopAvail) { //not available
@@ -493,8 +502,10 @@
}
/*left_top*/
if (bLeftTopAvail && IS_INTER (iLeftTopType)) {
- ST32 (iMvD[listIdx], LD32 (pCurLayer->pMv[listIdx][iLeftTopXy][15]));
- iLeftTopRef[listIdx] = pCurLayer->pRefIndex[listIdx][iLeftTopXy][15];
+ ST32 (iMvD[listIdx], LD32 (pCurDqLayer->pDec ? pCurDqLayer->pDec->pMv[listIdx][iLeftTopXy][15] :
+ pCurDqLayer->pMv[listIdx][iLeftTopXy][15]));
+ iLeftTopRef[listIdx] = pCurDqLayer->pDec ? pCurDqLayer->pDec->pRefIndex[listIdx][iLeftTopXy][15] :
+ pCurDqLayer->pRefIndex[listIdx][iLeftTopXy][15];
} else {
ST32 (iMvD[listIdx], 0);
if (0 == bLeftTopAvail) { //not available
@@ -543,7 +554,7 @@
mbType &= ~MB_TYPE_L0;
subMbType &= ~MB_TYPE_L0;
}
- pCurLayer->pMbType[iMbXy] = mbType;
+ GetMbType (pCurDqLayer)[iMbXy] = mbType;
int16_t pMvd[4] = { 0 };
@@ -551,20 +562,20 @@
if (IS_INTER_16x16 (mbType)) {
if ((* (int32_t*)iMvp[LIST_0] | * (int32_t*)iMvp[LIST_1])) {
- if (0 == pCurLayer->iColocIntra[0] && !bIsLongRef
- && ((pCurLayer->iColocRefIndex[LIST_0][0] == 0 && (unsigned) (pCurLayer->iColocMv[LIST_0][0][0] + 1) <= 2
- && (unsigned) (pCurLayer->iColocMv[LIST_0][0][1] + 1) <= 2)
- || (pCurLayer->iColocRefIndex[LIST_0][0] < 0 && pCurLayer->iColocRefIndex[LIST_1][0] == 0
- && (unsigned) (pCurLayer->iColocMv[LIST_1][0][0] + 1) <= 2
- && (unsigned) (pCurLayer->iColocMv[LIST_1][0][1] + 1) <= 2))) {
+ if (0 == pCurDqLayer->iColocIntra[0] && !bIsLongRef
+ && ((pCurDqLayer->iColocRefIndex[LIST_0][0] == 0 && (unsigned) (pCurDqLayer->iColocMv[LIST_0][0][0] + 1) <= 2
+ && (unsigned) (pCurDqLayer->iColocMv[LIST_0][0][1] + 1) <= 2)
+ || (pCurDqLayer->iColocRefIndex[LIST_0][0] < 0 && pCurDqLayer->iColocRefIndex[LIST_1][0] == 0
+ && (unsigned) (pCurDqLayer->iColocMv[LIST_1][0][0] + 1) <= 2
+ && (unsigned) (pCurDqLayer->iColocMv[LIST_1][0][1] + 1) <= 2))) {
if (0 >= ref[0]) * (uint32_t*)iMvp[LIST_0] = 0;
if (0 >= ref[1]) * (uint32_t*)iMvp[LIST_1] = 0;
}
}
- UpdateP16x16DirectCabac (pCurLayer);
+ UpdateP16x16DirectCabac (pCurDqLayer);
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
- UpdateP16x16MotionInfo (pCurLayer, listIdx, ref[listIdx], iMvp[listIdx]);
- UpdateP16x16MvdCabac (pCurLayer, pMvd, listIdx);
+ UpdateP16x16MotionInfo (pCurDqLayer, listIdx, ref[listIdx], iMvp[listIdx]);
+ UpdateP16x16MvdCabac (pCurDqLayer, pMvd, listIdx);
}
} else {
if (bSkipOrDirect) {
@@ -571,11 +582,11 @@
int8_t pSubPartCount[4], pPartW[4];
for (int32_t i = 0; i < 4; i++) { //Direct 8x8 Ref and mv
int16_t iIdx8 = i << 2;
- pCurLayer->pSubMbType[iMbXy][i] = subMbType;
+ pCurDqLayer->pSubMbType[iMbXy][i] = subMbType;
int8_t pRefIndex[LIST_A][30];
- UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
- UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1);
- UpdateP8x8DirectCabac (pCurLayer, iIdx8);
+ UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
+ UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1);
+ UpdateP8x8DirectCabac (pCurDqLayer, iIdx8);
pSubPartCount[i] = g_ksInterBSubMbTypeInfo[0].iPartCount;
pPartW[i] = g_ksInterBSubMbTypeInfo[0].iPartWidth;
@@ -584,7 +595,7 @@
pSubPartCount[i] = 4;
pPartW[i] = 1;
}
- FillSpatialDirect8x8Mv (pCurLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, bIsLongRef, iMvp, ref, NULL, NULL);
+ FillSpatialDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, bIsLongRef, iMvp, ref, NULL, NULL);
}
}
}
@@ -594,9 +605,9 @@
int32_t PredBDirectTemporal (PWelsDecoderContext pCtx, int16_t iMvp[LIST_A][2], int8_t ref[LIST_A],
SubMbType& subMbType) {
int32_t ret = ERR_NONE;
- PDqLayer pCurLayer = pCtx->pCurDqLayer;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
- bool bSkipOrDirect = (IS_SKIP (pCurLayer->pMbType[iMbXy]) | IS_DIRECT (pCurLayer->pMbType[iMbXy])) > 0;
+ PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
+ bool bSkipOrDirect = (IS_SKIP (GetMbType (pCurDqLayer)[iMbXy]) | IS_DIRECT (GetMbType (pCurDqLayer)[iMbXy])) > 0;
MbType mbType;
ret = GetColocatedMb (pCtx, mbType, subMbType);
@@ -604,9 +615,9 @@
return ret;
}
- pCurLayer->pMbType[iMbXy] = mbType;
+ GetMbType (pCurDqLayer)[iMbXy] = mbType;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int16_t pMvd[4] = { 0 };
const int32_t ref0Count = WELS_MIN (pSliceHeader->uiRefCount[LIST_0], pCtx->sRefPic.uiRefCount[LIST_0]);
@@ -613,33 +624,33 @@
if (IS_INTER_16x16 (mbType)) {
ref[LIST_0] = 0;
ref[LIST_1] = 0;
- UpdateP16x16DirectCabac (pCurLayer);
- UpdateP16x16RefIdx (pCurLayer, LIST_1, ref[LIST_1]);
+ UpdateP16x16DirectCabac (pCurDqLayer);
+ UpdateP16x16RefIdx (pCurDqLayer, LIST_1, ref[LIST_1]);
ST64 (iMvp, 0);
- if (pCurLayer->iColocIntra[0]) {
- UpdateP16x16MotionOnly (pCurLayer, LIST_0, iMvp[LIST_0]);
- UpdateP16x16MotionOnly (pCurLayer, LIST_1, iMvp[LIST_1]);
- UpdateP16x16RefIdx (pCurLayer, LIST_0, ref[LIST_0]);
+ if (pCurDqLayer->iColocIntra[0]) {
+ UpdateP16x16MotionOnly (pCurDqLayer, LIST_0, iMvp[LIST_0]);
+ UpdateP16x16MotionOnly (pCurDqLayer, LIST_1, iMvp[LIST_1]);
+ UpdateP16x16RefIdx (pCurDqLayer, LIST_0, ref[LIST_0]);
} else {
ref[LIST_0] = 0;
- int16_t* mv = pCurLayer->iColocMv[LIST_0][0];
- int8_t colocRefIndexL0 = pCurLayer->iColocRefIndex[LIST_0][0];
+ int16_t* mv = pCurDqLayer->iColocMv[LIST_0][0];
+ int8_t colocRefIndexL0 = pCurDqLayer->iColocRefIndex[LIST_0][0];
if (colocRefIndexL0 >= 0) {
ref[LIST_0] = MapColToList0 (pCtx, colocRefIndexL0, ref0Count);
} else {
- mv = pCurLayer->iColocMv[LIST_1][0];
+ mv = pCurDqLayer->iColocMv[LIST_1][0];
}
- UpdateP16x16RefIdx (pCurLayer, LIST_0, ref[LIST_0]);
+ UpdateP16x16RefIdx (pCurDqLayer, LIST_0, ref[LIST_0]);
iMvp[LIST_0][0] = (pSlice->iMvScale[LIST_0][ref[LIST_0]] * mv[0] + 128) >> 8;
iMvp[LIST_0][1] = (pSlice->iMvScale[LIST_0][ref[LIST_0]] * mv[1] + 128) >> 8;
- UpdateP16x16MotionOnly (pCurLayer, LIST_0, iMvp[LIST_0]);
+ UpdateP16x16MotionOnly (pCurDqLayer, LIST_0, iMvp[LIST_0]);
iMvp[LIST_1][0] = iMvp[LIST_0][0] - mv[0];
iMvp[LIST_1][1] = iMvp[LIST_0][1] - mv[1];
- UpdateP16x16MotionOnly (pCurLayer, LIST_1, iMvp[LIST_1]);
+ UpdateP16x16MotionOnly (pCurDqLayer, LIST_1, iMvp[LIST_1]);
}
- UpdateP16x16MvdCabac (pCurLayer, pMvd, LIST_0);
- UpdateP16x16MvdCabac (pCurLayer, pMvd, LIST_1);
+ UpdateP16x16MvdCabac (pCurDqLayer, pMvd, LIST_0);
+ UpdateP16x16MvdCabac (pCurDqLayer, pMvd, LIST_1);
} else {
if (bSkipOrDirect) {
int8_t pSubPartCount[4], pPartW[4];
@@ -647,27 +658,27 @@
for (int32_t i = 0; i < 4; i++) {
int16_t iIdx8 = i << 2;
const uint8_t iScan4Idx = g_kuiScan4[iIdx8];
- pCurLayer->pSubMbType[iMbXy][i] = subMbType;
+ pCurDqLayer->pSubMbType[iMbXy][i] = subMbType;
- int16_t (*mvColoc)[2] = pCurLayer->iColocMv[LIST_0];
+ int16_t (*mvColoc)[2] = pCurDqLayer->iColocMv[LIST_0];
ref[LIST_1] = 0;
- UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1);
- if (pCurLayer->iColocIntra[iScan4Idx]) {
+ UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_1], LIST_1);
+ if (pCurDqLayer->iColocIntra[iScan4Idx]) {
ref[LIST_0] = 0;
- UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
+ UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
ST64 (iMvp, 0);
} else {
ref[LIST_0] = 0;
- int8_t colocRefIndexL0 = pCurLayer->iColocRefIndex[LIST_0][iScan4Idx];
+ int8_t colocRefIndexL0 = pCurDqLayer->iColocRefIndex[LIST_0][iScan4Idx];
if (colocRefIndexL0 >= 0) {
ref[LIST_0] = MapColToList0 (pCtx, colocRefIndexL0, ref0Count);
} else {
- mvColoc = pCurLayer->iColocMv[LIST_1];
+ mvColoc = pCurDqLayer->iColocMv[LIST_1];
}
- UpdateP8x8RefIdxCabac (pCurLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
+ UpdateP8x8RefIdxCabac (pCurDqLayer, pRefIndex, iIdx8, ref[LIST_0], LIST_0);
}
- UpdateP8x8DirectCabac (pCurLayer, iIdx8);
+ UpdateP8x8DirectCabac (pCurDqLayer, iIdx8);
pSubPartCount[i] = g_ksInterBSubMbTypeInfo[0].iPartCount;
pPartW[i] = g_ksInterBSubMbTypeInfo[0].iPartWidth;
@@ -676,7 +687,7 @@
pSubPartCount[i] = 4;
pPartW[i] = 1;
}
- FillTemporalDirect8x8Mv (pCurLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, ref, mvColoc, NULL, NULL);
+ FillTemporalDirect8x8Mv (pCurDqLayer, iIdx8, pSubPartCount[i], pPartW[i], subMbType, ref, mvColoc, NULL, NULL);
}
}
}
@@ -785,14 +796,23 @@
//mb
const uint8_t kuiScan4Idx = g_kuiScan4[i];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
+ if (pCurDqLayer->pDec != NULL) {
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx ], kiRef2);
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ } else {
+ ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4Idx ], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx ], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4IdxPlus4], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ }
}
}
@@ -808,8 +828,8 @@
const uint8_t kuiScan4Idx = g_kuiScan4[i];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
}
}
@@ -824,11 +844,17 @@
//mb
const uint8_t kuiScan4Idx = g_kuiScan4[i];
const uint8_t kuiScan4IdxPlus4 = 4 + kuiScan4Idx;
-
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ if (pCurDqLayer->pDec != NULL) {
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ } else {
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ }
}
}
@@ -848,12 +874,21 @@
const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx;
//mb
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx ], kiRef2);
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4Idx ], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx ], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4IdxPlus4], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ if (pCurDqLayer->pDec != NULL) {
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ } else {
+ ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ }
//cache
ST16 (&iRefIndex[listIdx][kuiCacheIdx ], kiRef2);
ST16 (&iRefIndex[listIdx][kuiCacheIdxPlus6], kiRef2);
@@ -879,12 +914,21 @@
const uint8_t kuiCacheIdxPlus6 = 6 + kuiCacheIdx;
//mb
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx ], kiRef2);
- ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4Idx ], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx ], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][ kuiScan4IdxPlus4], kiMV32);
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ if (pCurDqLayer->pDec != NULL) {
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ } else {
+ ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4Idx], kiRef2);
+ ST16 (&pCurDqLayer->pRefIndex[listIdx][iMbXy][kuiScan4IdxPlus4], kiRef2);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4Idx], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][kuiScan4IdxPlus4], kiMV32);
+ ST32 (pCurDqLayer->pMv[listIdx][iMbXy][1 + kuiScan4IdxPlus4], kiMV32);
+ }
//cache
ST16 (&iRefIndex[listIdx][kuiCacheIdx ], kiRef2);
ST16 (&iRefIndex[listIdx][kuiCacheIdxPlus6], kiRef2);
@@ -895,10 +939,10 @@
}
}
-void FillSpatialDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
+void FillSpatialDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
const SubMbType& subMbType, const bool& bIsLongRef, int16_t pMvDirect[LIST_A][2], int8_t iRef[LIST_A],
int16_t pMotionVector[LIST_A][30][MV_A], int16_t pMvdCache[LIST_A][30][MV_A]) {
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
for (int32_t j = 0; j < iPartCount; j++) {
int8_t iPartIdx = iIdx8 + j * iPartW;
uint8_t iScan4Idx = g_kuiScan4[iPartIdx];
@@ -909,10 +953,10 @@
if (IS_SUB_8x8 (subMbType)) {
* (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_0];
ST32 ((pMV + 2), LD32 (pMV));
- ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV));
- ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV));
- ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV));
+ ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV));
+ ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0);
if (pMotionVector != NULL) {
ST64 (pMotionVector[LIST_0][iCacheIdx], LD64 (pMV));
ST64 (pMotionVector[LIST_0][iCacheIdx + 6], LD64 (pMV));
@@ -923,10 +967,10 @@
}
* (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_1];
ST32 ((pMV + 2), LD32 (pMV));
- ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV));
- ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV));
- ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV));
+ ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV));
+ ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0);
if (pMotionVector != NULL) {
ST64 (pMotionVector[LIST_1][iCacheIdx], LD64 (pMV));
ST64 (pMotionVector[LIST_1][iCacheIdx + 6], LD64 (pMV));
@@ -937,8 +981,8 @@
}
} else { //SUB_4x4
* (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_0];
- ST32 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMV));
- ST32 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMV));
+ ST32 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
if (pMotionVector != NULL) {
ST32 (pMotionVector[LIST_0][iCacheIdx], LD32 (pMV));
}
@@ -946,8 +990,8 @@
ST32 (pMvdCache[LIST_0][iCacheIdx], 0);
}
* (uint32_t*)pMV = * (uint32_t*)pMvDirect[LIST_1];
- ST32 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMV));
- ST32 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMV));
+ ST32 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
if (pMotionVector != NULL) {
ST32 (pMotionVector[LIST_1][iCacheIdx], LD32 (pMV));
}
@@ -956,19 +1000,19 @@
}
}
if ((* (int32_t*)pMvDirect[LIST_0] | * (int32_t*)pMvDirect[LIST_1])) {
- uint32_t uiColZeroFlag = (0 == pCurLayer->iColocIntra[iColocIdx]) && !bIsLongRef &&
- (pCurLayer->iColocRefIndex[LIST_0][iColocIdx] == 0 || (pCurLayer->iColocRefIndex[LIST_0][iColocIdx] < 0
- && pCurLayer->iColocRefIndex[LIST_1][iColocIdx] == 0));
- const int16_t (*mvColoc)[2] = 0 == pCurLayer->iColocRefIndex[LIST_0][iColocIdx] ? pCurLayer->iColocMv[LIST_0] :
- pCurLayer->iColocMv[LIST_1];
+ uint32_t uiColZeroFlag = (0 == pCurDqLayer->iColocIntra[iColocIdx]) && !bIsLongRef &&
+ (pCurDqLayer->iColocRefIndex[LIST_0][iColocIdx] == 0 || (pCurDqLayer->iColocRefIndex[LIST_0][iColocIdx] < 0
+ && pCurDqLayer->iColocRefIndex[LIST_1][iColocIdx] == 0));
+ const int16_t (*mvColoc)[2] = 0 == pCurDqLayer->iColocRefIndex[LIST_0][iColocIdx] ? pCurDqLayer->iColocMv[LIST_0] :
+ pCurDqLayer->iColocMv[LIST_1];
const int16_t* mv = mvColoc[iColocIdx];
if (IS_SUB_8x8 (subMbType)) {
if (uiColZeroFlag && ((unsigned) (mv[0] + 1) <= 2 && (unsigned) (mv[1] + 1) <= 2)) {
if (iRef[LIST_0] == 0) {
- ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx + 4], 0);
- ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0);
if (pMotionVector != NULL) {
ST64 (pMotionVector[LIST_0][iCacheIdx], 0);
ST64 (pMotionVector[LIST_0][iCacheIdx + 6], 0);
@@ -980,10 +1024,10 @@
}
if (iRef[LIST_1] == 0) {
- ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx + 4], 0);
- ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0);
if (pMotionVector != NULL) {
ST64 (pMotionVector[LIST_1][iCacheIdx], 0);
ST64 (pMotionVector[LIST_1][iCacheIdx + 6], 0);
@@ -997,8 +1041,8 @@
} else {
if (uiColZeroFlag && ((unsigned) (mv[0] + 1) <= 2 && (unsigned) (mv[1] + 1) <= 2)) {
if (iRef[LIST_0] == 0) {
- ST32 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], 0);
- ST32 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
if (pMotionVector != NULL) {
ST32 (pMotionVector[LIST_0][iCacheIdx], 0);
}
@@ -1007,8 +1051,8 @@
}
}
if (iRef[LIST_1] == 0) {
- ST32 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], 0);
- ST32 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
if (pMotionVector != NULL) {
ST32 (pMotionVector[LIST_1][iCacheIdx], 0);
}
@@ -1022,11 +1066,12 @@
}
}
-void FillTemporalDirect8x8Mv (PDqLayer pCurLayer, const int16_t& iIdx8, const int8_t& iPartCount, const int8_t& iPartW,
+void FillTemporalDirect8x8Mv (PDqLayer pCurDqLayer, const int16_t& iIdx8, const int8_t& iPartCount,
+ const int8_t& iPartW,
const SubMbType& subMbType, int8_t iRef[LIST_A], int16_t (*mvColoc)[2], int16_t pMotionVector[LIST_A][30][MV_A],
int16_t pMvdCache[LIST_A][30][MV_A]) {
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int16_t pMvDirect[LIST_A][2] = { { 0, 0 }, { 0, 0 } };
for (int32_t j = 0; j < iPartCount; j++) {
int8_t iPartIdx = iIdx8 + j * iPartW;
@@ -1038,16 +1083,16 @@
int16_t pMV[4] = { 0 };
if (IS_SUB_8x8 (subMbType)) {
- if (!pCurLayer->iColocIntra[iColocIdx]) {
+ if (!pCurDqLayer->iColocIntra[iColocIdx]) {
pMvDirect[LIST_0][0] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[0] + 128) >> 8;
pMvDirect[LIST_0][1] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[1] + 128) >> 8;
}
ST32 (pMV, LD32 (pMvDirect[LIST_0]));
ST32 ((pMV + 2), LD32 (pMvDirect[LIST_0]));
- ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV));
- ST64 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV));
- ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD64 (pMV));
+ ST64 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx + 4], LD64 (pMV));
+ ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx + 4], 0);
if (pMotionVector != NULL) {
ST64 (pMotionVector[LIST_0][iCacheIdx], LD64 (pMV));
ST64 (pMotionVector[LIST_0][iCacheIdx + 6], LD64 (pMV));
@@ -1056,16 +1101,16 @@
ST64 (pMvdCache[LIST_0][iCacheIdx], 0);
ST64 (pMvdCache[LIST_0][iCacheIdx + 6], 0);
}
- if (!pCurLayer->iColocIntra[g_kuiScan4[iIdx8]]) {
+ if (!pCurDqLayer->iColocIntra[g_kuiScan4[iIdx8]]) {
pMvDirect[LIST_1][0] = pMvDirect[LIST_0][0] - mv[0];
pMvDirect[LIST_1][1] = pMvDirect[LIST_0][1] - mv[1];
}
ST32 (pMV, LD32 (pMvDirect[LIST_1]));
ST32 ((pMV + 2), LD32 (pMvDirect[LIST_1]));
- ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV));
- ST64 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV));
- ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
- ST64 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0);
+ ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD64 (pMV));
+ ST64 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx + 4], LD64 (pMV));
+ ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
+ ST64 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx + 4], 0);
if (pMotionVector != NULL) {
ST64 (pMotionVector[LIST_1][iCacheIdx], LD64 (pMV));
ST64 (pMotionVector[LIST_1][iCacheIdx + 6], LD64 (pMV));
@@ -1075,12 +1120,12 @@
ST64 (pMvdCache[LIST_1][iCacheIdx + 6], 0);
}
} else { //SUB_4x4
- if (!pCurLayer->iColocIntra[iColocIdx]) {
+ if (!pCurDqLayer->iColocIntra[iColocIdx]) {
pMvDirect[LIST_0][0] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[0] + 128) >> 8;
pMvDirect[LIST_0][1] = (pSlice->iMvScale[LIST_0][iRef[LIST_0]] * mv[1] + 128) >> 8;
}
- ST32 (pCurLayer->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_0]));
- ST32 (pCurLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pDec->pMv[LIST_0][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_0]));
+ ST32 (pCurDqLayer->pMvd[LIST_0][iMbXy][iScan4Idx], 0);
if (pMotionVector != NULL) {
ST32 (pMotionVector[LIST_0][iCacheIdx], LD32 (pMvDirect[LIST_0]));
}
@@ -1087,12 +1132,12 @@
if (pMvdCache != NULL) {
ST32 (pMvdCache[LIST_0][iCacheIdx], 0);
}
- if (!pCurLayer->iColocIntra[iColocIdx]) {
+ if (!pCurDqLayer->iColocIntra[iColocIdx]) {
pMvDirect[LIST_1][0] = pMvDirect[LIST_0][0] - mv[0];
pMvDirect[LIST_1][1] = pMvDirect[LIST_0][1] - mv[1];
}
- ST32 (pCurLayer->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_1]));
- ST32 (pCurLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
+ ST32 (pCurDqLayer->pDec->pMv[LIST_1][iMbXy][iScan4Idx], LD32 (pMvDirect[LIST_1]));
+ ST32 (pCurDqLayer->pMvd[LIST_1][iMbXy][iScan4Idx], 0);
if (pMotionVector != NULL) {
ST32 (pMotionVector[LIST_1][iCacheIdx], LD32 (pMvDirect[LIST_1]));
}
@@ -1122,8 +1167,9 @@
void Update8x8RefIdx (PDqLayer& pCurDqLayer, const int16_t& iPartIdx, const int32_t& listIdx, const int8_t& iRef) {
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
const uint8_t iScan4Idx = g_kuiScan4[iPartIdx];
- pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx] = pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx + 1] =
- pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pRefIndex[listIdx][iMbXy][iScan4Idx + 5] = iRef;
+ pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx] = pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx + 1] =
+ pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pDec->pRefIndex[listIdx][iMbXy][iScan4Idx +
+ 5] = iRef;
}
} // namespace WelsDec
--- a/codec/decoder/core/src/parse_mb_syn_cabac.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cabac.cpp
@@ -110,8 +110,8 @@
const uint8_t iCacheIdx = g_kuiCache30ScanIdx[iPartIdx];
const uint8_t iCacheIdx6 = 6 + iCacheIdx;
//mb
- ST32 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef4Bytes);
- ST32 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef4Bytes);
+ ST32 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef4Bytes);
+ ST32 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef4Bytes);
//cache
ST32 (&pRefIndex[iListIdx][iCacheIdx ], iRef4Bytes);
ST32 (&pRefIndex[iListIdx][iCacheIdx6], iRef4Bytes);
@@ -129,8 +129,8 @@
const uint8_t iScan4Idx4 = 4 + iScan4Idx;
const uint8_t iCacheIdx6 = 6 + iCacheIdx;
//mb
- ST16 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef2Bytes);
- ST16 (&pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef2Bytes);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx ], iRef2Bytes);
+ ST16 (&pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx4], iRef2Bytes);
//cache
ST16 (&pRefIndex[iListIdx][iCacheIdx ], iRef2Bytes);
ST16 (&pRefIndex[iListIdx][iCacheIdx6], iRef2Bytes);
@@ -141,8 +141,10 @@
const int8_t iListIdx) {
int32_t iMbXy = pCurDqLayer->iMbXyIndex;
const uint8_t iScan4Idx = g_kuiScan4[iPartIdx];
- pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx] = pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx + 1] =
- pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pRefIndex[iListIdx][iMbXy][iScan4Idx + 5] = iRef;
+ pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx] = pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx + 1]
+ =
+ pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx + 4] = pCurDqLayer->pDec->pRefIndex[iListIdx][iMbXy][iScan4Idx +
+ 5] = iRef;
}
void UpdateP8x8DirectCabac (PDqLayer pCurDqLayer, int32_t iPartIdx) {
@@ -476,7 +478,7 @@
uint32_t uiCode;
int32_t iIdxA, iIdxB, iCtxInc;
int8_t* pChromaPredMode = pCtx->pCurDqLayer->pChromaPredMode;
- uint32_t* pMbType = pCtx->pCurDqLayer->pMbType;
+ uint32_t* pMbType = pCtx->pCurDqLayer->pDec->pMbType;
int32_t iLeftAvail = uiNeighAvail & 0x04;
int32_t iTopAvail = uiNeighAvail & 0x01;
@@ -532,7 +534,7 @@
pRefCount[0] = pSliceHeader->uiRefCount[0];
pRefCount[1] = pSliceHeader->uiRefCount[1];
- switch (pCurDqLayer->pMbType[iMbXy]) {
+ switch (pCurDqLayer->pDec->pMbType[iMbXy]) {
case MB_TYPE_16x16: {
iPartIdx = 0;
WELS_READ_VERIFY (ParseRefIdxCabac (pCtx, pNeighAvail, pNonZeroCount, pRefIndex, 0, LIST_0, iPartIdx, pRefCount[0], 0,
@@ -677,8 +679,8 @@
if (SUB_MB_TYPE_8x8 == uiSubMbType) {
ST32 ((pMv + 2), LD32 (pMv));
ST32 ((pMvd + 2), LD32 (pMvd));
- ST64 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx], LD64 (pMv));
- ST64 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx + 4], LD64 (pMv));
+ ST64 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx], LD64 (pMv));
+ ST64 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx + 4], LD64 (pMv));
ST64 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx], LD64 (pMvd));
ST64 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx + 4], LD64 (pMvd));
ST64 (pMotionVector[0][iCacheIdx ], LD64 (pMv));
@@ -688,13 +690,13 @@
} else if (SUB_MB_TYPE_8x4 == uiSubMbType) {
ST32 ((pMv + 2), LD32 (pMv));
ST32 ((pMvd + 2), LD32 (pMvd));
- ST64 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx ], LD64 (pMv));
+ ST64 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx ], LD64 (pMv));
ST64 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx ], LD64 (pMvd));
ST64 (pMotionVector[0][iCacheIdx ], LD64 (pMv));
ST64 (pMvdCache[0][iCacheIdx ], LD64 (pMvd));
} else if (SUB_MB_TYPE_4x8 == uiSubMbType) {
- ST32 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv));
- ST32 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx + 4], LD32 (pMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx + 4], LD32 (pMv));
ST32 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx ], LD32 (pMvd));
ST32 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx + 4], LD32 (pMvd));
ST32 (pMotionVector[0][iCacheIdx ], LD32 (pMv));
@@ -702,7 +704,7 @@
ST32 (pMvdCache[0][iCacheIdx ], LD32 (pMvd));
ST32 (pMvdCache[0][iCacheIdx + 6], LD32 (pMvd));
} else { //SUB_MB_TYPE_4x4
- ST32 (pCurDqLayer->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][iScan4Idx ], LD32 (pMv));
ST32 (pCurDqLayer->pMvd[0][iMbXy][iScan4Idx ], LD32 (pMvd));
ST32 (pMotionVector[0][iCacheIdx ], LD32 (pMv));
ST32 (pMvdCache[0][iCacheIdx ], LD32 (pMvd));
@@ -734,7 +736,7 @@
pRefCount[0] = pSliceHeader->uiRefCount[0];
pRefCount[1] = pSliceHeader->uiRefCount[1];
- MbType mbType = pCurDqLayer->pMbType[iMbXy];
+ MbType mbType = pCurDqLayer->pDec->pMbType[iMbXy];
if (IS_DIRECT (mbType)) {
@@ -1030,8 +1032,8 @@
if (IS_SUB_8x8 (subMbType)) { //MB_TYPE_8x8
ST32 ((pMv + 2), LD32 (pMv));
ST32 ((pMvd + 2), LD32 (pMvd));
- ST64 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv));
- ST64 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx + 4], LD64 (pMv));
+ ST64 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv));
+ ST64 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx + 4], LD64 (pMv));
ST64 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD64 (pMvd));
ST64 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx + 4], LD64 (pMvd));
ST64 (pMotionVector[listIdx][iCacheIdx], LD64 (pMv));
@@ -1039,13 +1041,13 @@
ST64 (pMvdCache[listIdx][iCacheIdx], LD64 (pMvd));
ST64 (pMvdCache[listIdx][iCacheIdx + 6], LD64 (pMvd));
} else if (IS_SUB_4x4 (subMbType)) { //MB_TYPE_4x4
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv));
ST32 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD32 (pMvd));
ST32 (pMotionVector[listIdx][iCacheIdx], LD32 (pMv));
ST32 (pMvdCache[listIdx][iCacheIdx], LD32 (pMvd));
} else if (IS_SUB_4x8 (subMbType)) { //MB_TYPE_4x8 5, 7, 9
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv));
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx + 4], LD32 (pMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD32 (pMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx + 4], LD32 (pMv));
ST32 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD32 (pMvd));
ST32 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx + 4], LD32 (pMvd));
ST32 (pMotionVector[listIdx][iCacheIdx], LD32 (pMv));
@@ -1055,7 +1057,7 @@
} else { //MB_TYPE_8x4 4, 6, 8
ST32 ((pMv + 2), LD32 (pMv));
ST32 ((pMvd + 2), LD32 (pMvd));
- ST64 (pCurDqLayer->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv));
+ ST64 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][iScan4Idx], LD64 (pMv));
ST64 (pCurDqLayer->pMvd[listIdx][iMbXy][iScan4Idx], LD64 (pMvd));
ST64 (pMotionVector[listIdx][iCacheIdx], LD64 (pMv));
ST64 (pMvdCache[listIdx][iCacheIdx], LD64 (pMvd));
@@ -1077,7 +1079,7 @@
uint32_t uiCode;
int32_t iIdxA = 0, iIdxB = 0;
int32_t iCtxInc = 0;
- int8_t* pRefIdxInMB = pCtx->pCurDqLayer->pRefIndex[iListIdx][pCtx->pCurDqLayer->iMbXyIndex];
+ int8_t* pRefIdxInMB = pCtx->pCurDqLayer->pDec->pRefIndex[iListIdx][pCtx->pCurDqLayer->iMbXyIndex];
int8_t* pDirect = pCtx->pCurDqLayer->pDirect[pCtx->pCurDqLayer->iMbXyIndex];
if (iZOrderIdx == 0) {
iIdxB = (pNeighAvail->iTopAvail && pNeighAvail->iTopType != MB_TYPE_INTRA_PCM
@@ -1270,7 +1272,7 @@
int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring
int32_t iLeftBlkXy = iCurrBlkXy - 1; //default value: MB neighboring
uint16_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc;
- uint32_t* pMbType = pCtx->pCurDqLayer->pMbType;
+ uint32_t* pMbType = pCtx->pCurDqLayer->pDec->pMbType;
int32_t iCtxInc;
uiCbfBit = 0;
nA = nB = (int8_t)!!IS_INTRA (pMbType[iCurrBlkXy]);
@@ -1493,12 +1495,12 @@
int32_t i;
PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
SBitStringAux* pBsAux = pCtx->pCurDqLayer->pBitStringAux;
- SDqLayer* pCurLayer = pCtx->pCurDqLayer;
- int32_t iDstStrideLuma = pCurLayer->pDec->iLinesize[0];
- int32_t iDstStrideChroma = pCurLayer->pDec->iLinesize[1];
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
- int32_t iMbXy = pCurLayer->iMbXyIndex;
+ SDqLayer* pCurDqLayer = pCtx->pCurDqLayer;
+ int32_t iDstStrideLuma = pCurDqLayer->pDec->iLinesize[0];
+ int32_t iDstStrideChroma = pCurDqLayer->pDec->iLinesize[1];
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
int32_t iMbOffsetLuma = (iMbX + iMbY * iDstStrideLuma) << 4;
int32_t iMbOffsetChroma = (iMbX + iMbY * iDstStrideChroma) << 3;
@@ -1509,7 +1511,7 @@
uint8_t* pPtrSrc;
- pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
+ pCurDqLayer->pDec->pMbType[iMbXy] = MB_TYPE_INTRA_PCM;
RestoreCabacDecEngineToBS (pCabacDecEngine, pBsAux);
intX_t iBytesLeft = pBsAux->pEndBuf - pBsAux->pCurBuf;
if (iBytesLeft < 384) {
@@ -1536,9 +1538,9 @@
pBsAux->pCurBuf += 384;
- pCurLayer->pLumaQp[iMbXy] = 0;
- pCurLayer->pChromaQp[iMbXy][0] = pCurLayer->pChromaQp[iMbXy][1] = 0;
- memset (pCurLayer->pNzc[iMbXy], 16, sizeof (pCurLayer->pNzc[iMbXy]));
+ pCurDqLayer->pLumaQp[iMbXy] = 0;
+ pCurDqLayer->pChromaQp[iMbXy][0] = pCurDqLayer->pChromaQp[iMbXy][1] = 0;
+ memset (pCurDqLayer->pNzc[iMbXy], 16, sizeof (pCurDqLayer->pNzc[iMbXy]));
//step 4: cabac engine init
WELS_READ_VERIFY (InitReadBits (pBsAux, 1));
--- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
@@ -53,20 +53,20 @@
uint8_t* pBuf;
} SReadBitsCache;
-void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer) {
+void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurDqLayer) {
int32_t iCurSliceIdc, iTopSliceIdc, iLeftTopSliceIdc, iRightTopSliceIdc, iLeftSliceIdc;
int32_t iCurXy, iTopXy = 0, iLeftXy = 0, iLeftTopXy = 0, iRightTopXy = 0;
int32_t iCurX, iCurY;
- iCurXy = pCurLayer->iMbXyIndex;
- iCurX = pCurLayer->iMbX;
- iCurY = pCurLayer->iMbY;
- iCurSliceIdc = pCurLayer->pSliceIdc[iCurXy];
+ iCurXy = pCurDqLayer->iMbXyIndex;
+ iCurX = pCurDqLayer->iMbX;
+ iCurY = pCurDqLayer->iMbY;
+ iCurSliceIdc = pCurDqLayer->pSliceIdc[iCurXy];
if (iCurX != 0) {
iLeftXy = iCurXy - 1;
- iLeftSliceIdc = pCurLayer->pSliceIdc[iLeftXy];
+ iLeftSliceIdc = pCurDqLayer->pSliceIdc[iLeftXy];
pNeighAvail->iLeftAvail = (iLeftSliceIdc == iCurSliceIdc);
- pNeighAvail->iLeftCbp = pNeighAvail->iLeftAvail ? pCurLayer->pCbp[iLeftXy] : 0;
+ pNeighAvail->iLeftCbp = pNeighAvail->iLeftAvail ? pCurDqLayer->pCbp[iLeftXy] : 0;
} else {
pNeighAvail->iLeftAvail = 0;
pNeighAvail->iLeftTopAvail = 0;
@@ -74,20 +74,20 @@
}
if (iCurY != 0) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
- iTopSliceIdc = pCurLayer->pSliceIdc[iTopXy];
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
+ iTopSliceIdc = pCurDqLayer->pSliceIdc[iTopXy];
pNeighAvail->iTopAvail = (iTopSliceIdc == iCurSliceIdc);
- pNeighAvail->iTopCbp = pNeighAvail->iTopAvail ? pCurLayer->pCbp[iTopXy] : 0;
+ pNeighAvail->iTopCbp = pNeighAvail->iTopAvail ? pCurDqLayer->pCbp[iTopXy] : 0;
if (iCurX != 0) {
iLeftTopXy = iTopXy - 1;
- iLeftTopSliceIdc = pCurLayer->pSliceIdc[iLeftTopXy];
+ iLeftTopSliceIdc = pCurDqLayer->pSliceIdc[iLeftTopXy];
pNeighAvail->iLeftTopAvail = (iLeftTopSliceIdc == iCurSliceIdc);
} else {
pNeighAvail->iLeftTopAvail = 0;
}
- if (iCurX != (pCurLayer->iMbWidth - 1)) {
+ if (iCurX != (pCurDqLayer->iMbWidth - 1)) {
iRightTopXy = iTopXy + 1;
- iRightTopSliceIdc = pCurLayer->pSliceIdc[iRightTopXy];
+ iRightTopSliceIdc = pCurDqLayer->pSliceIdc[iRightTopXy];
pNeighAvail->iRightTopAvail = (iRightTopSliceIdc == iCurSliceIdc);
} else {
pNeighAvail->iRightTopAvail = 0;
@@ -99,18 +99,18 @@
pNeighAvail->iTopCbp = 0;
}
- pNeighAvail->iLeftType = (pNeighAvail->iLeftAvail ? pCurLayer->pMbType[iLeftXy] : 0);
- pNeighAvail->iTopType = (pNeighAvail->iTopAvail ? pCurLayer->pMbType[iTopXy] : 0);
- pNeighAvail->iLeftTopType = (pNeighAvail->iLeftTopAvail ? pCurLayer->pMbType[iLeftTopXy] : 0);
- pNeighAvail->iRightTopType = (pNeighAvail->iRightTopAvail ? pCurLayer->pMbType[iRightTopXy] : 0);
+ pNeighAvail->iLeftType = (pNeighAvail->iLeftAvail ? pCurDqLayer->pDec->pMbType[iLeftXy] : 0);
+ pNeighAvail->iTopType = (pNeighAvail->iTopAvail ? pCurDqLayer->pDec->pMbType[iTopXy] : 0);
+ pNeighAvail->iLeftTopType = (pNeighAvail->iLeftTopAvail ? pCurDqLayer->pDec->pMbType[iLeftTopXy] : 0);
+ pNeighAvail->iRightTopType = (pNeighAvail->iRightTopAvail ? pCurDqLayer->pDec->pMbType[iRightTopXy] : 0);
}
void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
- PDqLayer pCurLayer) { //no matter slice type, intra_pred_constrained_flag
- int32_t iCurXy = pCurLayer->iMbXyIndex;
+ PDqLayer pCurDqLayer) { //no matter slice type, intra_pred_constrained_flag
+ int32_t iCurXy = pCurDqLayer->iMbXyIndex;
int32_t iTopXy = 0;
int32_t iLeftXy = 0;
if (pNeighAvail->iTopAvail) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iLeftAvail) {
iLeftXy = iCurXy - 1;
@@ -118,10 +118,10 @@
//stuff non_zero_coeff_count from pNeighAvail(left and top)
if (pNeighAvail->iTopAvail) {
- ST32 (&pNonZeroCount[1], LD32 (&pCurLayer->pNzc[iTopXy][12]));
+ ST32 (&pNonZeroCount[1], LD32 (&pCurDqLayer->pNzc[iTopXy][12]));
pNonZeroCount[0] = pNonZeroCount[5] = pNonZeroCount[29] = 0;
- ST16 (&pNonZeroCount[6], LD16 (&pCurLayer->pNzc[iTopXy][20]));
- ST16 (&pNonZeroCount[30], LD16 (&pCurLayer->pNzc[iTopXy][22]));
+ ST16 (&pNonZeroCount[6], LD16 (&pCurDqLayer->pNzc[iTopXy][20]));
+ ST16 (&pNonZeroCount[30], LD16 (&pCurDqLayer->pNzc[iTopXy][22]));
} else {
ST32 (&pNonZeroCount[1], 0xFFFFFFFFU);
pNonZeroCount[0] = pNonZeroCount[5] = pNonZeroCount[29] = 0xFF;
@@ -130,15 +130,15 @@
}
if (pNeighAvail->iLeftAvail) {
- pNonZeroCount[8 * 1] = pCurLayer->pNzc[iLeftXy][3];
- pNonZeroCount[8 * 2] = pCurLayer->pNzc[iLeftXy][7];
- pNonZeroCount[8 * 3] = pCurLayer->pNzc[iLeftXy][11];
- pNonZeroCount[8 * 4] = pCurLayer->pNzc[iLeftXy][15];
+ pNonZeroCount[8 * 1] = pCurDqLayer->pNzc[iLeftXy][3];
+ pNonZeroCount[8 * 2] = pCurDqLayer->pNzc[iLeftXy][7];
+ pNonZeroCount[8 * 3] = pCurDqLayer->pNzc[iLeftXy][11];
+ pNonZeroCount[8 * 4] = pCurDqLayer->pNzc[iLeftXy][15];
- pNonZeroCount[5 + 8 * 1] = pCurLayer->pNzc[iLeftXy][17];
- pNonZeroCount[5 + 8 * 2] = pCurLayer->pNzc[iLeftXy][21];
- pNonZeroCount[5 + 8 * 4] = pCurLayer->pNzc[iLeftXy][19];
- pNonZeroCount[5 + 8 * 5] = pCurLayer->pNzc[iLeftXy][23];
+ pNonZeroCount[5 + 8 * 1] = pCurDqLayer->pNzc[iLeftXy][17];
+ pNonZeroCount[5 + 8 * 2] = pCurDqLayer->pNzc[iLeftXy][21];
+ pNonZeroCount[5 + 8 * 4] = pCurDqLayer->pNzc[iLeftXy][19];
+ pNonZeroCount[5 + 8 * 5] = pCurDqLayer->pNzc[iLeftXy][23];
} else {
pNonZeroCount[8 * 1] =
pNonZeroCount[8 * 2] =
@@ -153,16 +153,16 @@
}
}
void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
- PDqLayer pCurLayer) { //no matter slice type
- int32_t iCurXy = pCurLayer->iMbXyIndex;
+ PDqLayer pCurDqLayer) { //no matter slice type
+ int32_t iCurXy = pCurDqLayer->iMbXyIndex;
int32_t iTopXy = 0;
int32_t iLeftXy = 0;
//stuff non_zero_coeff_count from pNeighAvail(left and top)
- WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
+ WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer);
if (pNeighAvail->iTopAvail) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iLeftAvail) {
iLeftXy = iCurXy - 1;
@@ -170,7 +170,7 @@
//intraNxN_pred_mode
if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top
- ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0]));
+ ST32 (pIntraPredMode + 1, LD32 (&pCurDqLayer->pIntraPredMode[iTopXy][0]));
} else {
int32_t iPred;
if (IS_INTRA16x16 (pNeighAvail->iTopType) || (MB_TYPE_INTRA_PCM == pNeighAvail->iTopType))
@@ -181,10 +181,10 @@
}
if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left
- pIntraPredMode[ 0 + 8 ] = pCurLayer->pIntraPredMode[iLeftXy][4];
- pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5];
- pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6];
- pIntraPredMode[ 0 + 8 * 4] = pCurLayer->pIntraPredMode[iLeftXy][3];
+ pIntraPredMode[ 0 + 8 ] = pCurDqLayer->pIntraPredMode[iLeftXy][4];
+ pIntraPredMode[ 0 + 8 * 2] = pCurDqLayer->pIntraPredMode[iLeftXy][5];
+ pIntraPredMode[ 0 + 8 * 3] = pCurDqLayer->pIntraPredMode[iLeftXy][6];
+ pIntraPredMode[ 0 + 8 * 4] = pCurDqLayer->pIntraPredMode[iLeftXy][3];
} else {
int8_t iPred;
if (IS_INTRA16x16 (pNeighAvail->iLeftType) || (MB_TYPE_INTRA_PCM == pNeighAvail->iLeftType))
@@ -199,16 +199,16 @@
}
void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
- PDqLayer pCurLayer) { //no matter slice type
- int32_t iCurXy = pCurLayer->iMbXyIndex;
+ PDqLayer pCurDqLayer) { //no matter slice type
+ int32_t iCurXy = pCurDqLayer->iMbXyIndex;
int32_t iTopXy = 0;
int32_t iLeftXy = 0;
//stuff non_zero_coeff_count from pNeighAvail(left and top)
- WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
+ WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer);
if (pNeighAvail->iTopAvail) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iLeftAvail) {
iLeftXy = iCurXy - 1;
@@ -216,7 +216,7 @@
//intra4x4_pred_mode
if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top
- ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0]));
+ ST32 (pIntraPredMode + 1, LD32 (&pCurDqLayer->pIntraPredMode[iTopXy][0]));
} else {
int32_t iPred;
if (pNeighAvail->iTopAvail)
@@ -227,10 +227,10 @@
}
if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left
- pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4];
- pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5];
- pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6];
- pIntraPredMode[ 0 + 8 * 4] = pCurLayer->pIntraPredMode[iLeftXy][3];
+ pIntraPredMode[ 0 + 8 * 1] = pCurDqLayer->pIntraPredMode[iLeftXy][4];
+ pIntraPredMode[ 0 + 8 * 2] = pCurDqLayer->pIntraPredMode[iLeftXy][5];
+ pIntraPredMode[ 0 + 8 * 3] = pCurDqLayer->pIntraPredMode[iLeftXy][6];
+ pIntraPredMode[ 0 + 8 * 4] = pCurDqLayer->pIntraPredMode[iLeftXy][3];
} else {
int8_t iPred;
if (pNeighAvail->iLeftAvail)
@@ -245,14 +245,14 @@
}
void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t iMvArray[LIST_A][30][MV_A],
- int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) {
- int32_t iCurXy = pCurLayer->iMbXyIndex;
+ int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer) {
+ int32_t iCurXy = pCurDqLayer->iMbXyIndex;
int32_t iTopXy = 0;
int32_t iLeftXy = 0;
int32_t iLeftTopXy = 0;
int32_t iRightTopXy = 0;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t listCount = 1;
if (pSliceHeader->eSliceType == B_SLICE) {
@@ -259,38 +259,38 @@
listCount = 2;
}
//stuff non_zero_coeff_count from pNeighAvail(left and top)
- WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
+ WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer);
if (pNeighAvail->iTopAvail) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iLeftAvail) {
iLeftXy = iCurXy - 1;
}
if (pNeighAvail->iLeftTopAvail) {
- iLeftTopXy = iCurXy - 1 - pCurLayer->iMbWidth;
+ iLeftTopXy = iCurXy - 1 - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iRightTopAvail) {
- iRightTopXy = iCurXy + 1 - pCurLayer->iMbWidth;
+ iRightTopXy = iCurXy + 1 - pCurDqLayer->iMbWidth;
}
for (int32_t listIdx = 0; listIdx < listCount; ++listIdx) {
//stuff mv_cache and iRefIdxArray from left and top (inter)
if (pNeighAvail->iLeftAvail && IS_INTER (pNeighAvail->iLeftType)) {
- ST32 (iMvArray[listIdx][6], LD32 (pCurLayer->pMv[listIdx][iLeftXy][3]));
- ST32 (iMvArray[listIdx][12], LD32 (pCurLayer->pMv[listIdx][iLeftXy][7]));
- ST32 (iMvArray[listIdx][18], LD32 (pCurLayer->pMv[listIdx][iLeftXy][11]));
- ST32 (iMvArray[listIdx][24], LD32 (pCurLayer->pMv[listIdx][iLeftXy][15]));
+ ST32 (iMvArray[listIdx][6], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][3]));
+ ST32 (iMvArray[listIdx][12], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][7]));
+ ST32 (iMvArray[listIdx][18], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][11]));
+ ST32 (iMvArray[listIdx][24], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][15]));
- ST32 (iMvdCache[listIdx][6], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][3]));
- ST32 (iMvdCache[listIdx][12], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][7]));
- ST32 (iMvdCache[listIdx][18], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][11]));
- ST32 (iMvdCache[listIdx][24], LD32 (pCurLayer->pMvd[listIdx][iLeftXy][15]));
+ ST32 (iMvdCache[listIdx][6], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][3]));
+ ST32 (iMvdCache[listIdx][12], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][7]));
+ ST32 (iMvdCache[listIdx][18], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][11]));
+ ST32 (iMvdCache[listIdx][24], LD32 (pCurDqLayer->pMvd[listIdx][iLeftXy][15]));
- iRefIdxArray[listIdx][6] = pCurLayer->pRefIndex[listIdx][iLeftXy][3];
- iRefIdxArray[listIdx][12] = pCurLayer->pRefIndex[listIdx][iLeftXy][7];
- iRefIdxArray[listIdx][18] = pCurLayer->pRefIndex[listIdx][iLeftXy][11];
- iRefIdxArray[listIdx][24] = pCurLayer->pRefIndex[listIdx][iLeftXy][15];
+ iRefIdxArray[listIdx][6] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][3];
+ iRefIdxArray[listIdx][12] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][7];
+ iRefIdxArray[listIdx][18] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][11];
+ iRefIdxArray[listIdx][24] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][15];
} else {
ST32 (iMvArray[listIdx][6], 0);
ST32 (iMvArray[listIdx][12], 0);
@@ -316,9 +316,9 @@
}
}
if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) {
- ST32 (iMvArray[listIdx][0], LD32 (pCurLayer->pMv[listIdx][iLeftTopXy][15]));
- ST32 (iMvdCache[listIdx][0], LD32 (pCurLayer->pMvd[listIdx][iLeftTopXy][15]));
- iRefIdxArray[listIdx][0] = pCurLayer->pRefIndex[listIdx][iLeftTopXy][15];
+ ST32 (iMvArray[listIdx][0], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftTopXy][15]));
+ ST32 (iMvdCache[listIdx][0], LD32 (pCurDqLayer->pMvd[listIdx][iLeftTopXy][15]));
+ iRefIdxArray[listIdx][0] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftTopXy][15];
} else {
ST32 (iMvArray[listIdx][0], 0);
ST32 (iMvdCache[listIdx][0], 0);
@@ -330,11 +330,11 @@
}
if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) {
- ST64 (iMvArray[listIdx][1], LD64 (pCurLayer->pMv[listIdx][iTopXy][12]));
- ST64 (iMvArray[listIdx][3], LD64 (pCurLayer->pMv[listIdx][iTopXy][14]));
- ST64 (iMvdCache[listIdx][1], LD64 (pCurLayer->pMvd[listIdx][iTopXy][12]));
- ST64 (iMvdCache[listIdx][3], LD64 (pCurLayer->pMvd[listIdx][iTopXy][14]));
- ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurLayer->pRefIndex[listIdx][iTopXy][12]));
+ ST64 (iMvArray[listIdx][1], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][12]));
+ ST64 (iMvArray[listIdx][3], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][14]));
+ ST64 (iMvdCache[listIdx][1], LD64 (pCurDqLayer->pMvd[listIdx][iTopXy][12]));
+ ST64 (iMvdCache[listIdx][3], LD64 (pCurDqLayer->pMvd[listIdx][iTopXy][14]));
+ ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurDqLayer->pDec->pRefIndex[listIdx][iTopXy][12]));
} else {
ST64 (iMvArray[listIdx][1], 0);
ST64 (iMvArray[listIdx][3], 0);
@@ -354,9 +354,9 @@
}
if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) {
- ST32 (iMvArray[listIdx][5], LD32 (pCurLayer->pMv[listIdx][iRightTopXy][12]));
- ST32 (iMvdCache[listIdx][5], LD32 (pCurLayer->pMvd[listIdx][iRightTopXy][12]));
- iRefIdxArray[listIdx][5] = pCurLayer->pRefIndex[listIdx][iRightTopXy][12];
+ ST32 (iMvArray[listIdx][5], LD32 (pCurDqLayer->pDec->pMv[listIdx][iRightTopXy][12]));
+ ST32 (iMvdCache[listIdx][5], LD32 (pCurDqLayer->pMvd[listIdx][iRightTopXy][12]));
+ iRefIdxArray[listIdx][5] = pCurDqLayer->pDec->pRefIndex[listIdx][iRightTopXy][12];
} else {
ST32 (iMvArray[listIdx][5], 0);
if (0 == pNeighAvail->iRightTopAvail) { //not available
@@ -385,9 +385,9 @@
}
}
-void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurLayer) {
+void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurDqLayer) {
- int32_t iCurXy = pCurLayer->iMbXyIndex;
+ int32_t iCurXy = pCurDqLayer->iMbXyIndex;
int32_t iTopXy = 0;
int32_t iLeftXy = 0;
int32_t iLeftTopXy = 0;
@@ -394,47 +394,47 @@
int32_t iRightTopXy = 0;
if (pNeighAvail->iTopAvail) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iLeftAvail) {
iLeftXy = iCurXy - 1;
}
if (pNeighAvail->iLeftTopAvail) {
- iLeftTopXy = iCurXy - 1 - pCurLayer->iMbWidth;
+ iLeftTopXy = iCurXy - 1 - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iRightTopAvail) {
- iRightTopXy = iCurXy + 1 - pCurLayer->iMbWidth;
+ iRightTopXy = iCurXy + 1 - pCurDqLayer->iMbWidth;
}
memset (iDirect, 0, 30);
if (pNeighAvail->iLeftAvail && IS_INTER (pNeighAvail->iLeftType)) {
- iDirect[6] = pCurLayer->pDirect[iLeftXy][3];
- iDirect[12] = pCurLayer->pDirect[iLeftXy][7];
- iDirect[18] = pCurLayer->pDirect[iLeftXy][11];
- iDirect[24] = pCurLayer->pDirect[iLeftXy][15];
+ iDirect[6] = pCurDqLayer->pDirect[iLeftXy][3];
+ iDirect[12] = pCurDqLayer->pDirect[iLeftXy][7];
+ iDirect[18] = pCurDqLayer->pDirect[iLeftXy][11];
+ iDirect[24] = pCurDqLayer->pDirect[iLeftXy][15];
}
if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) {
- iDirect[0] = pCurLayer->pDirect[iLeftTopXy][15];
+ iDirect[0] = pCurDqLayer->pDirect[iLeftTopXy][15];
}
if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) {
- ST32 (&iDirect[1], LD32 (&pCurLayer->pDirect[iTopXy][12]));
+ ST32 (&iDirect[1], LD32 (&pCurDqLayer->pDirect[iTopXy][12]));
}
if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) {
- iDirect[5] = pCurLayer->pDirect[iRightTopXy][12];
+ iDirect[5] = pCurDqLayer->pDirect[iRightTopXy][12];
}
//right-top 4*4 block unavailable
}
void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
- int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) {
- int32_t iCurXy = pCurLayer->iMbXyIndex;
+ int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer) {
+ int32_t iCurXy = pCurDqLayer->iMbXyIndex;
int32_t iTopXy = 0;
int32_t iLeftXy = 0;
int32_t iLeftTopXy = 0;
int32_t iRightTopXy = 0;
- PSlice pSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
+ PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer;
PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
int32_t listCount = 1;
if (pSliceHeader->eSliceType == B_SLICE) {
@@ -442,32 +442,32 @@
}
//stuff non_zero_coeff_count from pNeighAvail(left and top)
- WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurLayer);
+ WelsFillCacheNonZeroCount (pNeighAvail, pNonZeroCount, pCurDqLayer);
if (pNeighAvail->iTopAvail) {
- iTopXy = iCurXy - pCurLayer->iMbWidth;
+ iTopXy = iCurXy - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iLeftAvail) {
iLeftXy = iCurXy - 1;
}
if (pNeighAvail->iLeftTopAvail) {
- iLeftTopXy = iCurXy - 1 - pCurLayer->iMbWidth;
+ iLeftTopXy = iCurXy - 1 - pCurDqLayer->iMbWidth;
}
if (pNeighAvail->iRightTopAvail) {
- iRightTopXy = iCurXy + 1 - pCurLayer->iMbWidth;
+ iRightTopXy = iCurXy + 1 - pCurDqLayer->iMbWidth;
}
for (int32_t listIdx = 0; listIdx < listCount; ++listIdx) {
//stuff mv_cache and iRefIdxArray from left and top (inter)
if (pNeighAvail->iLeftAvail && IS_INTER (pNeighAvail->iLeftType)) {
- ST32 (iMvArray[listIdx][6], LD32 (pCurLayer->pMv[listIdx][iLeftXy][3]));
- ST32 (iMvArray[listIdx][12], LD32 (pCurLayer->pMv[listIdx][iLeftXy][7]));
- ST32 (iMvArray[listIdx][18], LD32 (pCurLayer->pMv[listIdx][iLeftXy][11]));
- ST32 (iMvArray[listIdx][24], LD32 (pCurLayer->pMv[listIdx][iLeftXy][15]));
- iRefIdxArray[listIdx][6] = pCurLayer->pRefIndex[listIdx][iLeftXy][3];
- iRefIdxArray[listIdx][12] = pCurLayer->pRefIndex[listIdx][iLeftXy][7];
- iRefIdxArray[listIdx][18] = pCurLayer->pRefIndex[listIdx][iLeftXy][11];
- iRefIdxArray[listIdx][24] = pCurLayer->pRefIndex[listIdx][iLeftXy][15];
+ ST32 (iMvArray[listIdx][6], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][3]));
+ ST32 (iMvArray[listIdx][12], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][7]));
+ ST32 (iMvArray[listIdx][18], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][11]));
+ ST32 (iMvArray[listIdx][24], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftXy][15]));
+ iRefIdxArray[listIdx][6] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][3];
+ iRefIdxArray[listIdx][12] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][7];
+ iRefIdxArray[listIdx][18] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][11];
+ iRefIdxArray[listIdx][24] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftXy][15];
} else {
ST32 (iMvArray[listIdx][6], 0);
ST32 (iMvArray[listIdx][12], 0);
@@ -487,8 +487,8 @@
}
}
if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) {
- ST32 (iMvArray[listIdx][0], LD32 (pCurLayer->pMv[listIdx][iLeftTopXy][15]));
- iRefIdxArray[listIdx][0] = pCurLayer->pRefIndex[listIdx][iLeftTopXy][15];
+ ST32 (iMvArray[listIdx][0], LD32 (pCurDqLayer->pDec->pMv[listIdx][iLeftTopXy][15]));
+ iRefIdxArray[listIdx][0] = pCurDqLayer->pDec->pRefIndex[listIdx][iLeftTopXy][15];
} else {
ST32 (iMvArray[listIdx][0], 0);
if (0 == pNeighAvail->iLeftTopAvail) { //not available
@@ -498,9 +498,9 @@
}
}
if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) {
- ST64 (iMvArray[listIdx][1], LD64 (pCurLayer->pMv[listIdx][iTopXy][12]));
- ST64 (iMvArray[listIdx][3], LD64 (pCurLayer->pMv[listIdx][iTopXy][14]));
- ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurLayer->pRefIndex[listIdx][iTopXy][12]));
+ ST64 (iMvArray[listIdx][1], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][12]));
+ ST64 (iMvArray[listIdx][3], LD64 (pCurDqLayer->pDec->pMv[listIdx][iTopXy][14]));
+ ST32 (&iRefIdxArray[listIdx][1], LD32 (&pCurDqLayer->pDec->pRefIndex[listIdx][iTopXy][12]));
} else {
ST64 (iMvArray[listIdx][1], 0);
ST64 (iMvArray[listIdx][3], 0);
@@ -517,8 +517,8 @@
}
}
if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) {
- ST32 (iMvArray[listIdx][5], LD32 (pCurLayer->pMv[listIdx][iRightTopXy][12]));
- iRefIdxArray[listIdx][5] = pCurLayer->pRefIndex[listIdx][iRightTopXy][12];
+ ST32 (iMvArray[listIdx][5], LD32 (pCurDqLayer->pDec->pMv[listIdx][iRightTopXy][12]));
+ iRefIdxArray[listIdx][5] = pCurDqLayer->pDec->pRefIndex[listIdx][iRightTopXy][12];
} else {
ST32 (iMvArray[listIdx][5], 0);
if (0 == pNeighAvail->iRightTopAvail) { //not available
@@ -1083,7 +1083,7 @@
iRefCount[0] = pSliceHeader->uiRefCount[0];
iRefCount[1] = pSliceHeader->uiRefCount[1];
- switch (pCurDqLayer->pMbType[iMbXy]) {
+ switch (pCurDqLayer->pDec->pMbType[iMbXy]) {
case MB_TYPE_16x16: {
int32_t iRefIdx = 0;
if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) {
@@ -1207,7 +1207,7 @@
int32_t iRefIdx[4] = {0}, iSubPartCount[4], iPartWidth[4];
uint32_t uiSubMbType;
- if (MB_TYPE_8x8_REF0 == pCurDqLayer->pMbType[iMbXy]) {
+ if (MB_TYPE_8x8_REF0 == pCurDqLayer->pDec->pMbType[iMbXy]) {
iRefCount[0] =
iRefCount[1] = 1;
}
@@ -1235,8 +1235,8 @@
}
//iRefIdxArray
- if (MB_TYPE_8x8_REF0 == pCurDqLayer->pMbType[iMbXy]) {
- memset (pCurDqLayer->pRefIndex[0][iMbXy], 0, 16);
+ if (MB_TYPE_8x8_REF0 == pCurDqLayer->pDec->pMbType[iMbXy]) {
+ memset (pCurDqLayer->pDec->pRefIndex[0][iMbXy], 0, 16);
} else {
for (i = 0; i < 4; i++) {
int16_t iIndex8 = i << 2;
@@ -1257,8 +1257,8 @@
pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
&& ppRefPic[iRefIdx[i]]->bIsComplete);
- pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] =
- pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i];
+ pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx + 1] =
+ pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pDec->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i];
} else {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. ");
return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -1290,26 +1290,26 @@
iMv[1] += iCode;
WELS_CHECK_SE_BOTH_WARNING (iMv[1], iMinVmv, iMaxVmv, "vertical mv");
if (SUB_MB_TYPE_8x8 == uiSubMbType) {
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 5], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 5], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx + 1], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx + 6], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx + 7], LD32 (iMv));
} else if (SUB_MB_TYPE_8x4 == uiSubMbType) {
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 1], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx + 1], LD32 (iMv));
} else if (SUB_MB_TYPE_4x8 == uiSubMbType) {
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx + 4], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx + 6], LD32 (iMv));
} else { //SUB_MB_TYPE_4x4 == uiSubMbType
- ST32 (pCurDqLayer->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[0][iMbXy][uiScan4Idx ], LD32 (iMv));
ST32 (iMvArray[0][uiCacheIdx ], LD32 (iMv));
}
}
@@ -1345,7 +1345,7 @@
iRefCount[0] = pSliceHeader->uiRefCount[0];
iRefCount[1] = pSliceHeader->uiRefCount[1];
- MbType mbType = pCurDqLayer->pMbType[iMbXy];
+ MbType mbType = pCurDqLayer->pDec->pMbType[iMbXy];
if (IS_DIRECT (mbType)) {
int16_t pMvDirect[LIST_A][2] = { { 0, 0 }, { 0, 0 } };
@@ -1689,26 +1689,26 @@
* (uint32_t*)iMv = 0;
}
if (IS_SUB_8x8 (subMbType)) { //MB_TYPE_8x8
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 5], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 5], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx + 1], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx + 6], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx + 7], LD32 (iMv));
} else if (IS_SUB_8x4 (subMbType)) {
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 1], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx + 1], LD32 (iMv));
} else if (IS_SUB_4x8 (subMbType)) {
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx + 4], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx + 6], LD32 (iMv));
} else { //SUB_MB_TYPE_4x4 == uiSubMbType
- ST32 (pCurDqLayer->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
+ ST32 (pCurDqLayer->pDec->pMv[listIdx][iMbXy][uiScan4Idx], LD32 (iMv));
ST32 (iMvArray[listIdx][uiCacheIdx], LD32 (iMv));
}
}
--- a/codec/decoder/core/src/pic_queue.cpp
+++ b/codec/decoder/core/src/pic_queue.cpp
@@ -168,6 +168,7 @@
}
if (pPic != NULL) {
pPicBuf->iCurrentIdx = iPicIdx;
+ pPic->iPicBuffIdx = iPicIdx;
return pPic;
}
for (iPicIdx = 0 ; iPicIdx <= pPicBuf->iCurrentIdx ; ++iPicIdx) {
@@ -179,6 +180,9 @@
}
pPicBuf->iCurrentIdx = iPicIdx;
+ if (pPic != NULL) {
+ pPic->iPicBuffIdx = iPicIdx;
+ }
return pPic;
}
--- a/codec/decoder/core/src/rec_mb.cpp
+++ b/codec/decoder/core/src/rec_mb.cpp
@@ -44,20 +44,20 @@
namespace WelsDec {
-void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurLayer) {
+void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurDqLayer) {
PPicture pCurPic = pCtx->pDec;
int32_t iLumaStride = pCurPic->iLinesize[0];
int32_t iChromaStride = pCurPic->iLinesize[1];
- int32_t iMbX = pCurLayer->iMbX;
- int32_t iMbY = pCurLayer->iMbY;
+ int32_t iMbX = pCurDqLayer->iMbX;
+ int32_t iMbY = pCurDqLayer->iMbY;
- pCurLayer->iLumaStride = iLumaStride;
- pCurLayer->iChromaStride = iChromaStride;
+ pCurDqLayer->iLumaStride = iLumaStride;
+ pCurDqLayer->iChromaStride = iChromaStride;
if (bOutput) {
- pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
- pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
- pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
+ pCurDqLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
+ pCurDqLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
+ pCurDqLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
}
}
@@ -446,7 +446,7 @@
int16_t iMVs[2] = {0};
- uint32_t iMBType = pCurDqLayer->pMbType[iMBXY];
+ uint32_t iMBType = pCurDqLayer->pDec->pMbType[iMBXY];
int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;
int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;
@@ -471,30 +471,30 @@
switch (iMBType) {
case MB_TYPE_SKIP:
case MB_TYPE_16x16:
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0));
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][0][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][0][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[0][iMBXY], 0, LIST_0));
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
- iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
+ iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0];
WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 16);
}
break;
case MB_TYPE_16x8:
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0));
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][0][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][0][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[0][iMBXY], 0, LIST_0));
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
- iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
+ iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0];
WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8);
}
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8, LIST_0));
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][8][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][8][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[0][iMBXY], 8, LIST_0));
pMCRefMem.pDstY = pPredY + (iDstLineLuma << 3);
pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);
pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);
@@ -501,23 +501,23 @@
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
- iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][8];
+ iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][8];
WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8);
}
break;
case MB_TYPE_8x16:
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0));
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][0][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][0][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[0][iMBXY], 0, LIST_0));
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
- iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
+ iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][0];
WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16);
}
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 2, LIST_0));
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][2][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][2][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[0][iMBXY], 2, LIST_0));
pMCRefMem.pDstY = pPredY + 8;
pMCRefMem.pDstU = pPredCb + 4;
pMCRefMem.pDstV = pPredCr + 4;
@@ -524,7 +524,7 @@
BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
- iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][2];
+ iRefIndex = pCurDqLayer->pDec->pRefIndex[0][iMBXY][2];
WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16);
}
break;
@@ -541,8 +541,8 @@
iYOffset = iMBOffsetY + iBlk8Y;
iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx, LIST_0));
- iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0;
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[0][iMBXY], iIIdx, LIST_0));
+ iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pDec->pRefIndex[0][iMBXY][iIIdx] : 0;
pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;
pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
@@ -552,8 +552,8 @@
pMCRefMem.pDstV = pDstV;
switch (iSubMBType) {
case SUB_MB_TYPE_8x8:
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
@@ -562,8 +562,8 @@
break;
case SUB_MB_TYPE_8x4:
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
@@ -571,8 +571,8 @@
}
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 4][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 4][1];
pMCRefMem.pDstY += (iDstLineLuma << 2);
pMCRefMem.pDstU += (iDstLineChroma << 1);
pMCRefMem.pDstV += (iDstLineChroma << 1);
@@ -584,8 +584,8 @@
break;
case SUB_MB_TYPE_4x8:
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
@@ -593,8 +593,8 @@
}
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 1][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + 1][1];
pMCRefMem.pDstY += 4;
pMCRefMem.pDstU += 2;
pMCRefMem.pDstV += 2;
@@ -618,8 +618,8 @@
pMCRefMem.pDstU = pDstU + iUVLineStride;
pMCRefMem.pDstV = pDstV + iUVLineStride;
- iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];
- iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + iJIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[0][iMBXY][iIIdx + iJIdx][1];
BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
if (pCurDqLayer->bUseWeightPredictionFlag) {
@@ -652,7 +652,7 @@
int16_t iMVs[2] = { 0 };
- uint32_t iMBType = pCurDqLayer->pMbType[iMBXY];
+ uint32_t iMBType = pCurDqLayer->pDec->pMbType[iMBXY];
int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;
int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;
@@ -684,17 +684,17 @@
if (IS_INTER_16x16 (iMBType)) {
if (IS_TYPE_L0 (iMBType) && IS_TYPE_L1 (iMBType)) {
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][0][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][0][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], 0, LIST_0));
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][0][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][0][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY], 0, LIST_0));
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][0][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][0][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], 0, LIST_1));
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][0][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][0][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY], 0, LIST_1));
BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
- iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][0];
- iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][0];
+ iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][0];
+ iRefIndex2 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][0];
if (pCurDqLayer->bUseWeightedBiPredIdc) {
BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 16);
} else {
@@ -702,12 +702,12 @@
}
} else {
int32_t listIdx = (iMBType & MB_TYPE_P0L0) ? LIST_0 : LIST_1;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][0][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][0][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], 0, listIdx));
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][0][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][0][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY], 0, listIdx));
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
if (bWeightedBipredIdcIs1) {
- int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][0];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][0];
WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 16, 16);
}
}
@@ -719,9 +719,9 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (IS_DIR (iMBType, i, listIdx)) {
lastListIdx = listIdx;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iPartIdx, listIdx));
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iPartIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iPartIdx][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY], iPartIdx, listIdx));
if (i) {
pMCRefMem.pDstY += (iDstLineLuma << 3);
pMCRefMem.pDstU += (iDstLineChroma << 2);
@@ -729,9 +729,9 @@
}
BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs);
if (++listCount == 2) {
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iPartIdx, LIST_1));
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iPartIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iPartIdx][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY], iPartIdx, LIST_1));
if (i) {
pTempMCRefMem.pDstY += (iDstLineLuma << 3);
pTempMCRefMem.pDstU += (iDstLineChroma << 2);
@@ -739,8 +739,8 @@
}
BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
- iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iPartIdx];
- iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iPartIdx];
+ iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][iPartIdx];
+ iRefIndex2 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][iPartIdx];
BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 8);
} else {
BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 8);
@@ -750,7 +750,7 @@
}
if (listCount == 1) {
if (bWeightedBipredIdcIs1) {
- int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][iPartIdx];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[lastListIdx][iMBXY][iPartIdx];
WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 16, 8);
}
}
@@ -762,9 +762,9 @@
for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
if (IS_DIR (iMBType, i, listIdx)) {
lastListIdx = listIdx;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], i << 1, listIdx));
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][i << 1][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][i << 1][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY], i << 1, listIdx));
if (i) {
pMCRefMem.pDstY += 8;
pMCRefMem.pDstU += 4;
@@ -772,9 +772,9 @@
}
BaseMC (&pMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs);
if (++listCount == 2) {
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][1];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], i << 1, LIST_1));
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][i << 1][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][i << 1][1];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY], i << 1, LIST_1));
if (i) {
pTempMCRefMem.pDstY += 8;
pTempMCRefMem.pDstU += 4;
@@ -782,8 +782,8 @@
}
BaseMC (&pTempMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
- iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][i << 1];
- iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][i << 1];
+ iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][i << 1];
+ iRefIndex2 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][i << 1];
BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 16);
} else {
BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 16);
@@ -793,7 +793,7 @@
}
if (listCount == 1) {
if (bWeightedBipredIdcIs1) {
- int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][i << 1];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[lastListIdx][iMBXY][i << 1];
WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 8, 16);
}
}
@@ -830,25 +830,25 @@
pTempMCRefMem.pDstV = pDstV2;
if ((IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType))) {
- iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iIIdx];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], iIIdx, LIST_0));
+ iRefIndex1 = pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY][iIIdx];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[LIST_0][iMBXY], iIIdx, LIST_0));
- iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iIIdx];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iIIdx, LIST_1));
+ iRefIndex2 = pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY][iIIdx];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[LIST_1][iMBXY], iIIdx, LIST_1));
} else {
int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
- iRefIndex1 = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
- WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iIIdx, listIdx));
+ iRefIndex1 = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx];
+ WELS_B_MB_REC_VERIFY (GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY], iIIdx, listIdx));
}
if (IS_SUB_8x8 (iSubMBType)) {
if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) {
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][1];
BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
@@ -858,21 +858,21 @@
}
} else {
int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
if (bWeightedBipredIdcIs1) {
- int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx];
WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 8);
}
}
} else if (IS_SUB_8x4 (iSubMBType)) {
if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_8x4
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][1];
BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
@@ -884,15 +884,15 @@
pMCRefMem.pDstY += (iDstLineLuma << 2);
pMCRefMem.pDstU += (iDstLineChroma << 1);
pMCRefMem.pDstV += (iDstLineChroma << 1);
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 4][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 4][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
pTempMCRefMem.pDstY += (iDstLineLuma << 2);
pTempMCRefMem.pDstU += (iDstLineChroma << 1);
pTempMCRefMem.pDstV += (iDstLineChroma << 1);
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 4][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 4][1];
BaseMC (&pTempMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
@@ -902,27 +902,27 @@
}
} else { //B_L0_8x4 B_L1_8x4
int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
pMCRefMem.pDstY += (iDstLineLuma << 2);
pMCRefMem.pDstU += (iDstLineChroma << 1);
pMCRefMem.pDstV += (iDstLineChroma << 1);
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 4][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 4][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
if (bWeightedBipredIdcIs1) {
- int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx];
WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 4);
}
}
} else if (IS_SUB_4x8 (iSubMBType)) {
if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_4x8
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx][1];
BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
@@ -934,15 +934,15 @@
pMCRefMem.pDstY += 4;
pMCRefMem.pDstU += 2;
pMCRefMem.pDstV += 2;
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 1][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + 1][1];
BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
pTempMCRefMem.pDstY += 4;
pTempMCRefMem.pDstU += 2;
pTempMCRefMem.pDstV += 2;
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 1][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + 1][1];
BaseMC (&pTempMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
@@ -952,17 +952,17 @@
}
} else { //B_L0_4x8 B_L1_4x8
int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx][1];
BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
pMCRefMem.pDstY += 4;
pMCRefMem.pDstU += 2;
pMCRefMem.pDstV += 2;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 1][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + 1][1];
BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
if (bWeightedBipredIdcIs1) {
- int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx];
WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 8);
}
}
@@ -980,8 +980,8 @@
pMCRefMem.pDstU = pDstU + iUVLineStride;
pMCRefMem.pDstV = pDstV + iUVLineStride;
- iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + iJIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_0][iMBXY][iIIdx + iJIdx][1];
BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
pTempMCRefMem.pDstY = pDstY2 + iBlk8X + iBlk8Y * iDstLineLuma;
@@ -988,8 +988,8 @@
pTempMCRefMem.pDstU = pDstU2 + iUVLineStride;
pTempMCRefMem.pDstV = pDstV2 + iUVLineStride;;
- iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][0];
- iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + iJIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[LIST_1][iMBXY][iIIdx + iJIdx][1];
BaseMC (&pTempMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
if (pCurDqLayer->bUseWeightedBiPredIdc) {
@@ -1000,7 +1000,7 @@
}
} else {
int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
- int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
+ int32_t iRefIndex = pCurDqLayer->pDec->pRefIndex[listIdx][iMBXY][iIIdx];
for (int32_t j = 0; j < 4; j++) {
int32_t iUVLineStride;
iJIdx = ((j >> 1) << 2) + (j & 1);
@@ -1013,8 +1013,8 @@
pMCRefMem.pDstU = pDstU + iUVLineStride;
pMCRefMem.pDstV = pDstV + iUVLineStride;
- iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][0];
- iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][1];
+ iMVs[0] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + iJIdx][0];
+ iMVs[1] = pCurDqLayer->pDec->pMv[listIdx][iMBXY][iIIdx + iJIdx][1];
BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
if (bWeightedBipredIdcIs1) {
WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 4);
--- /dev/null
+++ b/codec/decoder/core/src/wels_decoder_thread.cpp
@@ -1,0 +1,317 @@
+/*!
+ * \copy
+ * Copyright (c) 2009-2019, Cisco Systems
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ * \file wels_decoder_thread.cpp
+ *
+ * \brief Interfaces introduced in thread programming
+ *
+ * \date 08/06/2018 Created
+ *
+ *************************************************************************************
+ */
+
+
+#ifdef __linux__
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <sched.h>
+#elif !defined(_WIN32) && !defined(__CYGWIN__)
+#include <sys/types.h>
+#include <sys/param.h>
+#include <unistd.h>
+#ifndef __Fuchsia__
+#include <sys/sysctl.h>
+#endif
+#ifdef __APPLE__
+#define HW_NCPU_NAME "hw.logicalcpu"
+#else
+#define HW_NCPU_NAME "hw.ncpu"
+#endif
+#endif
+#ifdef ANDROID_NDK
+#include <cpu-features.h>
+#endif
+#ifdef __ANDROID__
+#include <android/api-level.h>
+#endif
+
+#include "wels_decoder_thread.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+int32_t GetCPUCount() {
+ WelsLogicalProcessInfo pInfo;
+ pInfo.ProcessorCount = 1;
+ WelsQueryLogicalProcessInfo (&pInfo);
+ return pInfo.ProcessorCount;
+}
+
+int ThreadCreate (SWelsDecThread* t, LPWELS_THREAD_ROUTINE tf, void* ta) {
+ WELS_THREAD_ATTR attr = 0;
+ return WelsThreadCreate (& (t->h), tf, ta, attr);
+}
+
+int ThreadWait (SWelsDecThread* t) {
+ return WelsThreadJoin (t->h);
+}
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+
+int EventCreate (SWelsDecEvent* e, int manualReset, int initialState) {
+ e->h = CreateEvent (NULL, manualReset, initialState, NULL);
+ e->isSignaled = initialState;
+ return (e->h != NULL) ? 0 : 1;
+}
+
+void EventReset (SWelsDecEvent* e) {
+ ResetEvent (e->h);
+ e->isSignaled = 0;
+}
+
+void EventPost (SWelsDecEvent* e) {
+ SetEvent (e->h);
+ e->isSignaled = 1;
+}
+
+int EventWait (SWelsDecEvent* e, int32_t timeout) {
+ DWORD result;
+ if ((uint32_t)timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0)
+ result = WaitForSingleObject (e->h, INFINITE);
+ else
+ result = WaitForSingleObject (e->h, timeout);
+
+ if (result == WAIT_OBJECT_0)
+ return WELS_DEC_THREAD_WAIT_SIGNALED;
+ else
+ return WAIT_TIMEOUT;
+}
+
+void EventDestroy (SWelsDecEvent* e) {
+ CloseHandle (e->h);
+ e->h = NULL;
+}
+
+int SemCreate (SWelsDecSemphore* s, long value, long max) {
+ s->h = CreateSemaphore (NULL, value, max, NULL);
+ return (s->h != NULL) ? 0 : 1;
+}
+
+int SemWait (SWelsDecSemphore* s, int32_t timeout) {
+ DWORD result;
+ if ((uint32_t)timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0)
+ result = WaitForSingleObject (s->h, INFINITE);
+ else
+ result = WaitForSingleObject (s->h, timeout);
+
+ if (result == WAIT_OBJECT_0) {
+ return WELS_DEC_THREAD_WAIT_SIGNALED;
+ } else {
+ return WELS_DEC_THREAD_WAIT_TIMEDOUT;
+ }
+}
+
+void SemRelease (SWelsDecSemphore* s, long* prevcount) {
+ ReleaseSemaphore (s->h, 1, prevcount);
+}
+
+void SemDestroy (SWelsDecSemphore* s) {
+ CloseHandle (s->h);
+ s->h = NULL;
+}
+
+#else /* _WIN32 */
+
+static void getTimespecFromTimeout (struct timespec* ts, int32_t timeout) {
+ struct timeval tv;
+ gettimeofday (&tv, 0);
+ ts->tv_nsec = tv.tv_usec * 1000 + timeout * 1000000;
+ ts->tv_sec = tv.tv_sec + ts->tv_nsec / 1000000000;
+ ts->tv_nsec %= 1000000000;
+}
+int EventCreate (SWelsDecEvent* e, int manualReset, int initialState) {
+ if (pthread_mutex_init (& (e->m), NULL))
+ return 1;
+ if (pthread_cond_init (& (e->c), NULL))
+ return 2;
+
+ e->isSignaled = initialState;
+ e->manualReset = manualReset;
+
+ return 0;
+}
+
+void EventReset (SWelsDecEvent* e) {
+ pthread_mutex_lock (& (e->m));
+ e->isSignaled = 0;
+ pthread_mutex_unlock (& (e->m));
+}
+
+void EventPost (SWelsDecEvent* e) {
+ pthread_mutex_lock (& (e->m));
+ pthread_cond_broadcast (& (e->c));
+ e->isSignaled = 1;
+ pthread_mutex_unlock (& (e->m));
+}
+
+int EventWait (SWelsDecEvent* e, int32_t timeout) {
+ pthread_mutex_lock (& (e->m));
+ int signaled = e->isSignaled;
+ if (timeout == 0) {
+ pthread_mutex_unlock (& (e->m));
+ if (signaled)
+ return WELS_DEC_THREAD_WAIT_SIGNALED;
+ else
+ return WELS_DEC_THREAD_WAIT_TIMEDOUT;
+ }
+ if (signaled) {
+ if (!e->manualReset) {
+ e->isSignaled = 0;
+ }
+ pthread_mutex_unlock (& (e->m));
+ return WELS_DEC_THREAD_WAIT_SIGNALED;
+ }
+ int rc = 0;
+ if (timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0) {
+ rc = pthread_cond_wait (& (e->c), & (e->m));
+ } else {
+ struct timespec ts;
+ getTimespecFromTimeout (&ts, timeout);
+ rc = pthread_cond_timedwait (& (e->c), & (e->m), &ts);
+ }
+ if (!e->manualReset) {
+ e->isSignaled = 0;
+ }
+ pthread_mutex_unlock (& (e->m));
+ if (rc == 0)
+ return WELS_DEC_THREAD_WAIT_SIGNALED;
+ else
+ return WELS_DEC_THREAD_WAIT_TIMEDOUT;
+}
+
+void EventDestroy (SWelsDecEvent* e) {
+ pthread_mutex_destroy (& (e->m));
+ pthread_cond_destroy (& (e->c));
+}
+
+int SemCreate (SWelsDecSemphore* s, long value, long max) {
+ s->v = value;
+ s->max = max;
+ if (pthread_mutex_init (& (s->m), NULL))
+ return 1;
+ const char* event_name = "";
+ if (WelsEventOpen (& (s->e), event_name)) {
+ return 2;
+ }
+ return 0;
+}
+
+int SemWait (SWelsDecSemphore* s, int32_t timeout) {
+#if defined(__APPLE__)
+ pthread_mutex_lock (& (s->m));
+#endif
+ int rc = 0;
+ if (timeout != 0) {
+ while ((s->v) == 0) {
+ if (timeout == WELS_DEC_THREAD_WAIT_INFINITE || timeout < 0) {
+ // infinite wait until released
+#if defined(__APPLE__)
+ rc = pthread_cond_wait (& (s->e), & (s->m));
+#else
+ rc = sem_wait (s->e);
+ if (rc != 0) rc = errno;
+#endif
+ } else {
+ struct timespec ts;
+ getTimespecFromTimeout (&ts, timeout);
+#if defined(__APPLE__)
+ rc = pthread_cond_timedwait (& (s->e), & (s->m), &ts);
+#else
+ rc = sem_timedwait (s->e, &ts);
+ if (rc != 0) rc = errno;
+#endif
+ if (rc != EINTR) {
+ // if timed out we return to the caller
+ break;
+ }
+ }
+ }
+ // only decrement counter if semaphore was signaled
+ if (rc == 0)
+ s->v -= 1;
+
+ } else {
+ // Special handling for timeout of 0
+ if (s->v > 0) {
+ s->v -= 1;
+ rc = 0;
+ } else {
+ rc = 1;
+ }
+ }
+#if defined(__APPLE__)
+ pthread_mutex_unlock (& (s->m));
+#endif
+ // set return value
+ if (rc == 0)
+ return WELS_DEC_THREAD_WAIT_SIGNALED;
+ else
+ return WELS_DEC_THREAD_WAIT_TIMEDOUT;
+}
+
+void SemRelease (SWelsDecSemphore* s, long* o_pPrevCount) {
+ long prevcount;
+#ifdef __APPLE__
+ pthread_mutex_lock (& (s->m));
+ prevcount = s->v;
+ if (s->v < s->max)
+ s->v += 1;
+ pthread_cond_signal (& (s->e));
+ pthread_mutex_unlock (& (s->m));
+#else
+ prevcount = s->v;
+ if (s->v < s->max)
+ s->v += 1;
+ sem_post (s->e);
+#endif
+ if (o_pPrevCount != NULL) {
+ *o_pPrevCount = prevcount;
+ }
+}
+
+void SemDestroy (SWelsDecSemphore* s) {
+ pthread_mutex_destroy (& (s->m));
+ const char* event_name = "";
+ WelsEventClose (& (s->e), event_name);
+}
+
+#endif /* !_WIN32 */
+
--- a/codec/decoder/meson.build
+++ b/codec/decoder/meson.build
@@ -19,6 +19,7 @@
'core/src/pic_queue.cpp',
'core/src/rec_mb.cpp',
'plus/src/welsDecoderExt.cpp',
+ 'core/src/wels_decoder_thread.cpp',
]
asm_sources = [
--- a/codec/decoder/plus/inc/welsDecoderExt.h
+++ b/codec/decoder/plus/inc/welsDecoderExt.h
@@ -113,6 +113,7 @@
SBufferInfo sBufferInfo;
int32_t iPOC;
int32_t iPicBuffIdx;
+ uint32_t uiDecodingTimeStamp;
bool bLastGOP;
unsigned char* pData[3];
} SPictInfo, *PPictInfo;
@@ -127,6 +128,9 @@
int32_t m_iLastGOPRemainPicts;
int32_t m_LastWrittenPOC;
int32_t m_iLargestBufferedPicIndex;
+ SVlcTable m_sVlcTable;
+ SWelsLastDecPicInfo m_sLastDecPicInfo;
+ SDecoderStatistics m_sDecoderStatistics;// For real time debugging
int32_t InitDecoder (const SDecodingParam* pParam);
void UninitDecoder (void);
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -257,6 +257,10 @@
VERSION_NUMBER, (int32_t)pParam->bParseOnly);
//reset decoder context
+ memset (&m_sDecoderStatistics, 0, sizeof (SDecoderStatistics));
+ memset (&m_sLastDecPicInfo, 0, sizeof (SWelsLastDecPicInfo));
+ memset (&m_sVlcTable, 0, sizeof (SVlcTable));
+ WelsDecoderLastDecPicInfoDefaults (m_sLastDecPicInfo);
if (m_pDecContext) //free
UninitDecoder();
m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
@@ -267,7 +271,11 @@
WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pMemAlign), UninitDecoder())
//fill in default value into context
+ m_pDecContext->pLastDecPicInfo = &m_sLastDecPicInfo;
+ m_pDecContext->pDecoderStatistics = &m_sDecoderStatistics;
+ m_pDecContext->pVlcTable = &m_sVlcTable;
WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx);
+ WelsDecoderSpsPpsDefaults (m_pDecContext->sSpsPpsCtx);
//check param and update decoder context
m_pDecContext->pParam = (SDecodingParam*)m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam),
@@ -364,7 +372,7 @@
return cmInitParaError;
} else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
if (pOption) {
- m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
+ m_pDecContext->pDecoderStatistics->iStatisticsLogInterval = (* ((unsigned int*)pOption));
return cmResultSuccess;
}
} else if (eOptID == DECODER_OPTION_GET_SAR_INFO) {
@@ -432,19 +440,19 @@
} else if (DECODER_OPTION_GET_STATISTICS == eOptID) { // get decoder statistics info for real time debugging
SDecoderStatistics* pDecoderStatistics = (static_cast<SDecoderStatistics*> (pOption));
- memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics));
+ memcpy (pDecoderStatistics, m_pDecContext->pDecoderStatistics, sizeof (SDecoderStatistics));
- if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status
+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount != 0) { //not original status
pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
- (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount);
+ (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount);
pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
- (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum +
- m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
+ (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount + m_pDecContext->pDecoderStatistics->uiFreezingIDRNum +
+ m_pDecContext->pDecoderStatistics->uiFreezingNonIDRNum);
}
return cmResultSuccess;
} else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
if (pOption) {
- iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
+ iVal = m_pDecContext->pDecoderStatistics->iStatisticsLogInterval;
* ((unsigned int*)pOption) = iVal;
return cmResultSuccess;
}
@@ -626,30 +634,30 @@
//TODO after dec status updated
m_pDecContext->iErrorCode |= dsDataErrorConcealed;
- m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
- if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
- ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
- m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t
+ ResetDecStatNums (m_pDecContext->pDecoderStatistics);
+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
}
int32_t iMbConcealedNum = m_pDecContext->iMbEcedNum + m_pDecContext->iMbEcedPropNum;
- m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbNum == 0 ?
- (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((
- m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((
+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio = m_pDecContext->iMbNum == 0 ?
+ (m_pDecContext->pDecoderStatistics->uiAvgEcRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) : ((
+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) + ((
iMbConcealedNum * 100) / m_pDecContext->iMbNum));
- m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ?
- (m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((
- m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((
+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ?
+ (m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) : ((
+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) + ((
m_pDecContext->iMbEcedPropNum * 100) / m_pDecContext->iMbNum));
- m_pDecContext->sDecoderStatistics.uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1);
- m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :
- m_pDecContext->sDecoderStatistics.uiAvgEcRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;
- m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :
- m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;
+ m_pDecContext->pDecoderStatistics->uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1);
+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio = m_pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 :
+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio / m_pDecContext->pDecoderStatistics->uiEcFrameNum;
+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio = m_pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 :
+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio / m_pDecContext->pDecoderStatistics->uiEcFrameNum;
}
iEnd = WelsTime();
m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
- OutputStatisticsLog (m_pDecContext->sDecoderStatistics);
+ OutputStatisticsLog (*m_pDecContext->pDecoderStatistics);
#ifdef _PICTURE_REORDERING_
ReorderPicturesInDisplay (ppDst, pDstInfo);
@@ -661,13 +669,13 @@
if (pDstInfo->iBufferStatus == 1) {
- m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
- if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
- ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
- m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t
+ ResetDecStatNums (m_pDecContext->pDecoderStatistics);
+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
}
- OutputStatisticsLog (m_pDecContext->sDecoderStatistics);
+ OutputStatisticsLog (*m_pDecContext->pDecoderStatistics);
}
iEnd = WelsTime();
m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
@@ -761,19 +769,22 @@
DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) {
DECODING_STATE iRet = dsErrorFree;
- if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66
- && m_pDecContext->pSps->uiProfileIdc != 83) {
+ if (pDstInfo->iBufferStatus == 0) {
+ return iRet;
+ }
+ ++m_pDecContext->uiDecodingTimeStamp;
+ if (m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pSps->uiProfileIdc != 83) {
/*if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
m_LastWrittenPOC = 0;
return dsErrorFree;
}
- if (m_iNumOfPicts == 0 && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin
+ if (m_iNumOfPicts == 0 && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin
&& m_pDecContext->eSliceType != I_SLICE) {
m_LastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
return dsErrorFree;
}*/
- if (m_iNumOfPicts && m_pDecContext->pPreviousDecodedPictureInDpb
- && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin) {
+ if (m_iNumOfPicts && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb
+ && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) {
m_iLastGOPRemainPicts = m_iNumOfPicts;
for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
if (m_sPictInfoList[i].iPOC > sIMinInt32) {
@@ -807,7 +818,8 @@
m_sPictInfoList[i].pData[1] = ppDst[1];
m_sPictInfoList[i].pData[2] = ppDst[2];
m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
- m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pPicBuff->iCurrentIdx;
+ m_sPictInfoList[i].uiDecodingTimeStamp = m_pDecContext->uiDecodingTimeStamp;
+ m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx;
m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false;
m_sPictInfoList[i].bLastGOP = false;
pDstInfo->iBufferStatus = 0;
@@ -955,10 +967,10 @@
memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo));
if (m_pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count
- m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
- if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
- ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
- m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t
+ ResetDecStatNums (m_pDecContext->pDecoderStatistics);
+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
}
}
}
--- a/codec/decoder/targets.mk
+++ b/codec/decoder/targets.mk
@@ -22,6 +22,7 @@
$(DECODER_SRCDIR)/core/src/parse_mb_syn_cavlc.cpp\
$(DECODER_SRCDIR)/core/src/pic_queue.cpp\
$(DECODER_SRCDIR)/core/src/rec_mb.cpp\
+ $(DECODER_SRCDIR)/core/src/wels_decoder_thread.cpp\
$(DECODER_SRCDIR)/plus/src/welsDecoderExt.cpp\
DECODER_OBJS += $(DECODER_CPP_SRCS:.cpp=.$(OBJ))
--- a/test/decoder/DecUT_DeblockCommon.cpp
+++ b/test/decoder/DecUT_DeblockCommon.cpp
@@ -804,11 +804,11 @@
// Dummy picture list pointers to 1..MAX_DPB_COUNT
// the pointer values don't need to be valid, just different
for (i = 0; i < MAX_DPB_COUNT; i++)
- iFilterPics[0][i] = iFilterPics[1][i] = (PPicture)(iFilterPics + (i<<3));
+ iFilterPics[0][i] = iFilterPics[1][i] = (PPicture) (iFilterPics + (i << 3));
sFilter.pRefPics[0] = iFilterPics[0];
sFilter.pRefPics[1] = iFilterPics[1];
-
+ sDqLayer.pDec = NULL;
#define UT_DB_CLEAN_STATUS \
memset(iNoZeroCount, 0, sizeof(int8_t)*24*2); \
memset(iLayerRefIndex, 0, sizeof(int8_t)*2*16*2); \
@@ -829,7 +829,7 @@
// (1) iEdge == 0, current block NoZeroCount != 0
UT_DB_CLEAN_STATUS
iNoZeroCount[0 * 24 + iCurrBlock] = 1; // Current MB_block position
- SET_REF_VALUE(2, iPos);
+ SET_REF_VALUE (2, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " NoZeroCount!=0";
@@ -836,7 +836,7 @@
// (2) iEdge == 0, neighbor block NoZeroCount != 0
UT_DB_CLEAN_STATUS
iNoZeroCount[1 * 24 + iNeighborBlock ] = 1; // Neighbor MB_block position
- SET_REF_VALUE(2, iPos);
+ SET_REF_VALUE (2, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " NoZeroCount!=0";
@@ -844,7 +844,7 @@
UT_DB_CLEAN_STATUS
iLayerRefIndex[0][0 * 16 + iCurrBlock] = 0;
iLayerRefIndex[0][1 * 16 + iNeighborBlock] = 1;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " Ref idx diff";
@@ -851,42 +851,46 @@
// (4) iEdge == 0, abs(mv diff) < 4
UT_DB_CLEAN_STATUS
iLayerMv[0][0 * 16 + iCurrBlock][0] = rand() % 4;
- EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
+ EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
+ 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
UT_DB_CLEAN_STATUS
iLayerMv[0][0 * 16 + iCurrBlock][1] = rand() % 4;
- EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
+ EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
+ 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
UT_DB_CLEAN_STATUS
iLayerMv[0][1 * 16 + iNeighborBlock][0] = rand() % 4;
- EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
+ EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
+ 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
UT_DB_CLEAN_STATUS
iLayerMv[0][1 * 16 + iNeighborBlock][1] = rand() % 4;
- EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1, 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
+ EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
+ 0) == 0) << iEdge << " " << iPos << " diff_mv < 4";
// (5) iEdge == 0, abs(mv diff) > 4
UT_DB_CLEAN_STATUS
iLayerMv[0][0 * 16 + iCurrBlock][0] = 4;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
UT_DB_CLEAN_STATUS
iLayerMv[0][0 * 16 + iCurrBlock][1] = 4;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
UT_DB_CLEAN_STATUS
iLayerMv[0][1 * 16 + iNeighborBlock][0] = 4;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
UT_DB_CLEAN_STATUS
iLayerMv[0][1 * 16 + iNeighborBlock][1] = 4;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == 4";
@@ -893,7 +897,7 @@
UT_DB_CLEAN_STATUS
iLayerMv[0][0 * 16 + iCurrBlock][0] = -2048;
iLayerMv[0][1 * 16 + iNeighborBlock][0] = 2047;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == maximum";
@@ -900,7 +904,7 @@
UT_DB_CLEAN_STATUS
iLayerMv[0][0 * 16 + iCurrBlock][1] = -2048;
iLayerMv[0][1 * 16 + iNeighborBlock][1] = 2047;
- SET_REF_VALUE(1, iPos);
+ SET_REF_VALUE (1, iPos);
EXPECT_TRUE (DeblockingBsMarginalMBAvcbase (&sFilter, &sDqLayer, iEdge, 1,
0) == uiBSx4) << iEdge << " " << iPos << " diff_mv == maximum";
}
@@ -912,7 +916,7 @@
/* Deblock one MB, calculate the Bs inside the function, only consider the intra / intra block */
SDqLayer sDqLayer;
sDqLayer.sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.eSliceType = P_SLICE;
-
+ sDqLayer.pDec = NULL;
SDeblockingFilter sFilter;
SDeblockingFunc sDBFunc;
sFilter.pLoopf = &sDBFunc;
--- a/test/decoder/DecUT_ErrorConcealment.cpp
+++ b/test/decoder/DecUT_ErrorConcealment.cpp
@@ -21,6 +21,7 @@
SPicture sAncPic; //Anc picture for comparison
SPicture sSrcPic; //Src picture as common input picture data
SPicture sWelsPic; //Wels picture to be compared
+ SWelsLastDecPicInfo sLastDecPicInfo;
} SECInputCtx, *PECInputCtx;
void FreeInputData (PECInputCtx pECCtx) {
@@ -90,7 +91,7 @@
pECCtx->pCtx->pDec = &pECCtx->sWelsPic;
pECCtx->pCtx->pCurDqLayer = &pECCtx->sDqLayer;
pECCtx->pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag = pECCtx->pMbCorrectlyDecodedFlag;
-
+ pECCtx->pCtx->pLastDecPicInfo = &pECCtx->sLastDecPicInfo;
pECCtx->pCtx->pSps = (PSps) WelsMallocz (sizeof (SSps), "pECCtx->pCtx->pSps");
if (pECCtx->pCtx->pSps == NULL)
return 1;
@@ -124,7 +125,7 @@
int32_t iMbWidth = (int32_t) pECCtx->iMbWidth;
int32_t iMbHeight = (int32_t) pECCtx->iMbHeight;
PPicture pDstPic = &pECCtx->sAncPic;
- PPicture pSrcPic = pECCtx->pCtx->pPreviousDecodedPictureInDpb;
+ PPicture pSrcPic = pECCtx->pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb;
if ((pECCtx->pCtx->pParam->eEcActiveIdc == ERROR_CON_SLICE_COPY)
&& (pECCtx->pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag))
pSrcPic = NULL;
@@ -244,7 +245,7 @@
int32_t iLumaSize = pECCtx->iMbWidth * pECCtx->iMbHeight * 256;
for (int iRef = 0; iRef < 2; ++ iRef) { //no ref, with ref
- pECCtx->pCtx->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL;
+ pECCtx->pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL;
for (int iIDR = 0; iIDR < 2; ++ iIDR) { //non IDR, IDR
pECCtx->pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag = (iIDR > 0);
//Do reference code method
@@ -279,7 +280,7 @@
pECCtx->pCtx->pParam->eEcActiveIdc = iEC > 0 ? ERROR_CON_SLICE_COPY_CROSS_IDR : ERROR_CON_SLICE_COPY;
InitECCopyData (pECCtx);
for (int iRef = 0; iRef < 2; ++ iRef) { //no ref, with ref
- pECCtx->pCtx->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL;
+ pECCtx->pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = iRef ? &pECCtx->sSrcPic : NULL;
for (int iIDR = 0; iIDR < 2; ++ iIDR) { //non IDR, IDR
pECCtx->pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag = (iIDR > 0);
//Do reference code method
--- a/test/decoder/DecUT_ParseSyntax.cpp
+++ b/test/decoder/DecUT_ParseSyntax.cpp
@@ -155,6 +155,11 @@
SDecodingParam m_sDecParam;
SBufferInfo m_sBufferInfo;
SParserBsInfo m_sParserBsInfo;
+ SWelsDecoderSpsPpsCTX m_sDecoderSpsPpsCTX;
+ SWelsLastDecPicInfo m_sLastDecPicInfo;
+ SDecoderStatistics m_sDecoderStatistics;
+ SVlcTable m_sVlcTable;
+
uint8_t* m_pData[3];
unsigned char m_szBuffer[BUF_SIZE]; //for mocking packet
int m_iBufLength; //record the valid data in m_szBuffer
@@ -168,6 +173,11 @@
memset (&m_sBufferInfo, 0, sizeof (SBufferInfo));
memset (&m_sDecParam, 0, sizeof (SDecodingParam));
memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
+ memset (&m_sDecoderSpsPpsCTX, 0, sizeof (SWelsDecoderSpsPpsCTX));
+ memset (&m_sLastDecPicInfo, 0, sizeof (SWelsLastDecPicInfo));
+ memset (&m_sDecoderStatistics, 0, sizeof (SDecoderStatistics));
+ memset (&m_sVlcTable, 0, sizeof (SVlcTable));
+
m_sDecParam.pFileNameRestructed = NULL;
m_sDecParam.uiCpuLoad = rand() % 100;
m_sDecParam.uiTargetDqLayer = rand() % 100;
@@ -193,6 +203,10 @@
m_pCtx = NULL;
return ERR_MALLOC_FAILED;
}
+ m_pCtx->pLastDecPicInfo = &m_sLastDecPicInfo;
+ m_pCtx->pDecoderStatistics = &m_sDecoderStatistics;
+ m_pCtx->pVlcTable = &m_sVlcTable;
+ WelsDecoderSpsPpsDefaults (m_pCtx->sSpsPpsCtx);
CM_RETURN eRet = (CM_RETURN)Initialize (&m_sDecParam, m_pCtx, &m_pWelsTrace->m_sLogCtx);
return (int32_t)eRet;
}
@@ -377,23 +391,23 @@
iRet = Init();
ASSERT_EQ (iRet, ERR_NONE);
ASSERT_TRUE (DecodeBs ("res/BA_MW_D.264", CorrectDec));
- ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
- EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
- ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
- EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
+ ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sSpsBuffer[0].bSeqScalingMatrixPresentFlag == false);
+ EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsPpsCtx.sSpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
+ ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sPpsBuffer[0].bPicScalingMatrixPresentFlag == false);
+ EXPECT_EQ (0, memcmp (iScalingListZero, m_pCtx->sSpsPpsCtx.sPpsBuffer[0].iScalingList4x4, 6 * 16 * sizeof (uint8_t)));
Uninit();
//Scalinglist value just written into sps and pps
iRet = Init();
ASSERT_EQ (iRet, ERR_NONE);
ASSERT_TRUE (DecodeBs ("res/test_scalinglist_jm.264", CorrectDec));
- ASSERT_TRUE (m_pCtx->sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
+ ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sSpsBuffer[0].bSeqScalingMatrixPresentFlag);
for (int i = 0; i < 6; i++) {
- EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t)));
+ EXPECT_EQ (0, memcmp (iScalingList[i], m_pCtx->sSpsPpsCtx.sSpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t)));
}
- ASSERT_TRUE (m_pCtx->sPpsBuffer[0].bPicScalingMatrixPresentFlag == true);
+ ASSERT_TRUE (m_pCtx->sSpsPpsCtx.sPpsBuffer[0].bPicScalingMatrixPresentFlag == true);
for (int i = 0; i < 6; i++) {
- EXPECT_EQ (0, memcmp (iScalingListPPS[i], m_pCtx->sPpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t)));
+ EXPECT_EQ (0, memcmp (iScalingListPPS[i], m_pCtx->sSpsPpsCtx.sPpsBuffer[0].iScalingList4x4[i], 16 * sizeof (uint8_t)));
}
Uninit();
}