History

Merge pull request #1657 from mstorsjo/clip-bitrate

Make sure the random test bitrate is high enough

sijchen committed 11 years ago

Commit 9a602ca2 parents 397c7ca 887b4f416 files · +705 −79Browse files

Showing the changes to codec/decoder (11 of 16 files). Show all

Unified · Split

11 files
  1. codec/decoder/core/inc/au_parser.h +16 −1
  2. codec/decoder/core/inc/decode_slice.h +1 −1
  3. codec/decoder/core/inc/decoder_context.h +9 −0
  4. codec/decoder/core/inc/error_code.h +2 −0
  5. codec/decoder/core/inc/parameter_sets.h +11 −2
  6. codec/decoder/core/inc/wels_common_basis.h +59 −0
  7. codec/decoder/core/src/au_parser.cpp +135 −6
  8. codec/decoder/core/src/decode_slice.cpp +108 −23
  9. codec/decoder/core/src/decoder.cpp +2 −0
  10. codec/decoder/core/src/parse_mb_syn_cabac.cpp +9 −3
  11. codec/decoder/core/src/parse_mb_syn_cavlc.cpp +48 −43
codec/decoder/core/inc/au_parser.h+16−1
@@ -131,11 +131,26 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 130 unmodified lines
131131 */
132132 int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, uint8_t* pSrcNal, const int32_t kSrcNalLen);
133133
134+/*!
135+ *************************************************************************************
136+ * \brief to parse scaling list message payload
137+ *
138+ * \param PPS SPS scaling list matrix message to be parsed output
139+ * \param pBsAux bitstream reader auxiliary
140+ *
141+ * \return 0 - successed
142+ * 1 - failed
143+ *
144+ * \note Call it in case scaling matrix present at sps or pps
145+ *************************************************************************************
146+*/
147+int32_t SetScalingListValue (uint8_t *pScalingList,int iScalingListNum,bool* bUseDefaultScalingMatrixFlag,PBitStringAux pBsAux);
148+int32_t ParseScalingList(PSps pSps,PBitStringAux pBs,bool bPPS,bool *bScalingListPresentFlag,uint8_t(*iScalingList4x4)[16],uint8_t(*iScalingList8x8)[64]);
134149 /*!
135150 *************************************************************************************
136151 * \brief to parse SEI message payload
137152 *
138− * \param pSei sei message to be parsed output
153+ * \param pSei sei message to be parsed output
139154 * \param pBsAux bitstream reader auxiliary
140155 *
141156 * \return 0 - successed
codec/decoder/core/inc/decode_slice.h+1−1
@@ -59,7 +59,7 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 58 unmodified lines
5959 int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer,
6060 uint8_t* pDstY, uint8_t* pDstU, uint8_t* pDstV, int32_t iStrideL, int32_t iStrideC);
6161 int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
62−void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp);
62+void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp,PWelsDecoderContext pCtx);
6363 int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer);
6464 void WelsChromaDcIdct (int16_t* pBlock);
6565
codec/decoder/core/inc/decoder_context.h+9−0
@@ -409,6 +409,15 @@ bool bRPLRError; · 408 unmodified lines
409409 int32_t iECMVs[16][2];
410410 PPicture pECRefPic[16];
411411 unsigned long long uiTimeStamp;
412+// To support scaling list HP
413+uint16_t pDequant_coeff_buffer4x4[6][52][16];
414+uint16_t pDequant_coeff_buffer8x8[6][52][64];
415+uint16_t (*pDequant_coeff4x4[6])[16];// 4x4 sclaing list value pointer
416+uint16_t (*pDequant_coeff8x8[6])[64];//64 residual coeff ,with 6 kinds of residual type, 52 qp level
417+int iDequantCoeffPpsid;//When a new pps actived, reinitialised the scaling list value
418+bool bDequantCoeff4x4Init;
419+bool bSpsLatePps;
420+bool bUseScalingList;
412421 } SWelsDecoderContext, *PWelsDecoderContext;
413422
414423 static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) {
codec/decoder/core/inc/error_code.h+2−0
@@ -185,6 +185,8 @@ ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH, · 184 unmodified lines
185185 ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX,
186186 //for CABAC
187187 ERR_CABAC_NO_BS_TO_READ,
188+//for scaling list
189+ERR_SCALING_LIST_DELTA_SCALE,
188190 };
189191 //-----------------------------------------------------------------------------------------------------------
190192
codec/decoder/core/inc/parameter_sets.h+11−2
@@ -88,7 +88,11 @@ typedef struct TagSps { · 87 unmodified lines
8888 bool bQpPrimeYZeroTransfBypassFlag;
8989 bool bSeqScalingMatrixPresentFlag;
9090 bool bSeqScalingListPresentFlag[12];
91− const SLevelLimits* pSLevelLimits;
91+ //Add scaling list supporting
92+ uint8_t iScalingList4x4[6][16];
93+ uint8_t iScalingList8x8[6][64];
94+
95+const SLevelLimits* pSLevelLimits;
9296 } SSps, *PSps;
9397
9498
@@ -163,7 +167,12 @@ typedef struct TagPps { · 68 unmodified lines
163167 bool bRedundantPicCntPresentFlag;
164168 bool bWeightedPredFlag;
165169 uint8_t uiWeightedBipredIdc;
166−
170+ bool bTransform_8x8_mode_flag;
171+ //Add for scalinglist support
172+ bool bPicScalingMatrixPresentFlag;
173+ bool bPicScalingListPresentFlag[12];
174+ uint8_t iScalingList4x4[6][16];
175+ uint8_t iScalingList8x8[6][64];
167176 } SPps, *PPps;
168177
169178 } // namespace WelsDec
codec/decoder/core/inc/wels_common_basis.h+59−0
@@ -132,6 +132,12 @@ typedef int32_t SubMbType; · 131 unmodified lines
132132 #define CHROMA_DC_V 7
133133 #define CHROMA_AC_U 8
134134 #define CHROMA_AC_V 9
135+#define LUMA_DC_AC_INTRA 10
136+#define LUMA_DC_AC_INTER 11
137+#define CHROMA_DC_U_INTER 12
138+#define CHROMA_DC_V_INTER 13
139+#define CHROMA_AC_U_INTER 14
140+#define CHROMA_AC_V_INTER 15
135141
136142 typedef struct TagReadBitsCache {
137143 uint32_t uiCache32Bit;
@@ -150,6 +156,59 @@ static const uint8_t g_kuiZigzagScan[16] = { //4*4block residual zig-zag scan or · 12 unmodified lines
150156 };
151157
152158
159+static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProperty,bool bCavlc)
160+{
161+ switch(*pResidualProperty)
162+ {
163+ case CHROMA_AC_U:
164+ *pMBproperty = 1;
165+ *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U;
166+ break;
167+ case CHROMA_AC_V:
168+ *pMBproperty = 2;
169+ *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V;
170+ break;
171+ case LUMA_DC_AC_INTRA:
172+ *pMBproperty = 0;
173+ *pResidualProperty = LUMA_DC_AC;
174+ break;
175+ case CHROMA_DC_U:
176+ *pMBproperty = 1;
177+ *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U;
178+ break;
179+ case CHROMA_DC_V:
180+ *pMBproperty = 2;
181+ *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V;
182+ break;
183+ case I16_LUMA_AC:
184+ *pMBproperty = 0;
185+ break;
186+ case I16_LUMA_DC:
187+ *pMBproperty = 0;
188+ break;
189+ case LUMA_DC_AC_INTER:
190+ *pMBproperty = 3;
191+ *pResidualProperty = LUMA_DC_AC;
192+ break;
193+ case CHROMA_DC_U_INTER:
194+ *pMBproperty = 4;
195+ *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_U;
196+ break;
197+ case CHROMA_DC_V_INTER:
198+ *pMBproperty = 5;
199+ *pResidualProperty = bCavlc ? CHROMA_DC : CHROMA_DC_V;
200+ break;
201+ case CHROMA_AC_U_INTER:
202+ *pMBproperty = 4;
203+ *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_U;
204+ break;
205+ case CHROMA_AC_V_INTER:
206+ *pMBproperty = 5;
207+ *pResidualProperty = bCavlc ?CHROMA_AC:CHROMA_AC_V;
208+ break;
209+ }
210+ }
211+
153212 typedef struct TagI16PredInfo {
154213 int8_t iPredMode;
155214 int8_t iLeftAvail;
codec/decoder/core/src/au_parser.cpp+135−6
@@ -833,6 +833,8 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { · 832 unmodified lines
833833 #define PPS_PIC_INIT_QP_QS_MAX 51
834834 #define PPS_CHROMA_QP_INDEX_OFFSET_MIN -12
835835 #define PPS_CHROMA_QP_INDEX_OFFSET_MAX 12
836+#define SCALING_LIST_DELTA_SCALE_MAX 127
837+#define SCALING_LIST_DELTA_SCALE_MIN -128
836838
837839 /*!
838840 *************************************************************************************
@@ -935,12 +937,16 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 96 unmodified lines
935937 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag
936938 pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
937939
938− if (pSps->bSeqScalingMatrixPresentFlag) { // For high profile, it is not used in current application. FIXME
939− WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
940− "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",
941− pSps->bSeqScalingMatrixPresentFlag);
942− return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
943− }
940+ if (pSps->bSeqScalingMatrixPresentFlag)// For high profile, it is not used in current application. FIXME
941+
942+ WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4,
943+ pSps->iScalingList8x8));
944+ //if exist, to parse scalinglist matrix value
945+
946+ // WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
947+ // "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",
948+ // pSps->bSeqScalingMatrixPresentFlag);
949+ //return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
944950 }
945951 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4
946952 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",
@@ -1307,6 +1313,22 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 360 unmodified lines
13071313 pPps->bConstainedIntraPredFlag = !!uiCode;
13081314 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
13091315 pPps->bRedundantPicCntPresentFlag = !!uiCode;
1316+//going on to parse high profile syntax, need fix me
1317+ WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
1318+ pPps->bTransform_8x8_mode_flag = !!uiCode;
1319+ WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
1320+ pPps->bPicScalingMatrixPresentFlag = !!uiCode;
1321+ if (pPps->bPicScalingMatrixPresentFlag) {
1322+ if (pCtx->bSpsAvailFlags[pPps->iSpsId])
1323+ WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag,
1324+ pPps->iScalingList4x4, pPps->iScalingList8x8));
1325+ else {
1326+ pCtx->bSpsLatePps = true;
1327+ WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4,
1328+ pPps->iScalingList8x8));
1329+ }
1330+ }
1331+
13101332 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
13111333 PNalUnit pLastNalUnit = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
13121334 PPps pLastPps = pLastNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;
@@ -1355,6 +1377,113 @@ int32_t ParseSei (void* pSei, PBitStringAux pBsAux) { // reserved Sei_Msg type · 42 unmodified lines
13551377
13561378 return ERR_NONE;
13571379 }
1380+/*
1381+ *************************************************************************************
1382+ * \brief to parse scalinglist message payload
1383+ *
1384+ * \param pps sps scaling list matrix message to be parsed output
1385+ * \param pBsAux bitstream reader auxiliary
1386+ *
1387+ * \return 0 - successed
1388+ * 1 - failed
1389+ *
1390+ * \note Call it in case scaling list matrix present at sps or pps level
1391+ *************************************************************************************
1392+ */
1393+int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* bUseDefaultScalingMatrixFlag,
1394+ PBitStringAux pBsAux) { // reserved Sei_Msg type
1395+ int iLastScale = 8;
1396+ int iNextScale = 8;
1397+ int iDeltaScale;
1398+ int32_t iCode;
1399+ for (int j = 0; j < iScalingListNum; j++) {
1400+ if (iNextScale != 0) {
1401+ WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode));
1402+ WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, SCALING_LIST_DELTA_SCALE_MIN, SCALING_LIST_DELTA_SCALE_MAX, "DeltaScale",
1403+ ERR_SCALING_LIST_DELTA_SCALE);
1404+ iDeltaScale = iCode;
1405+ iNextScale = (iLastScale + iDeltaScale + 256) % 256;
1406+ *bUseDefaultScalingMatrixFlag = (j == 0 && iNextScale == 0);
1407+ if (*bUseDefaultScalingMatrixFlag)
1408+ break;
1409+ }
1410+ pScalingList[g_kuiZigzagScan[j]] = (iNextScale == 0) ? iLastScale : iNextScale;
1411+ iLastScale = pScalingList[g_kuiZigzagScan[j]];
1412+ }
1413+
1414+
1415+ return ERR_NONE;
1416+}
1417+
1418+int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, bool* pScalingListPresentFlag,
1419+ uint8_t (*iScalingList4x4)[16], uint8_t (*iScalingList8x8)[64]) {
1420+ uint32_t uiScalingListNum;
1421+ uint32_t uiCode;
1422+ int32_t iRetTmp;
1423+ bool bUseDefaultScalingMatrixFlag4x4 = false;
1424+ bool bUseDefaultScalingMatrixFlag8x8 = false;
1425+ bool bInit = false;
1426+ const uint8_t* defaultScaling[4];
1427+
1428+ if (pSps != NULL) {
1429+ uiScalingListNum = (pSps->uiChromaFormatIdc != 3) ? 8 : 12;
1430+ bInit = bPPS && pSps->bSeqScalingMatrixPresentFlag;
1431+ } else
1432+ uiScalingListNum = 12;
1433+
1434+//Init default_scaling_list value for sps or pps
1435+ defaultScaling[0] = bInit ? pSps->iScalingList4x4[0] : g_kuiDequantScaling4x4Default[0];
1436+ defaultScaling[1] = bInit ? pSps->iScalingList4x4[3] : g_kuiDequantScaling4x4Default[1];
1437+ defaultScaling[2] = bInit ? pSps->iScalingList8x8[0] : g_kuiDequantScaling8x8Default[0];
1438+ defaultScaling[3] = bInit ? pSps->iScalingList8x8[1] : g_kuiDequantScaling8x8Default[1];
1439+
1440+ for (int i = 0; i < uiScalingListNum; i++) {
1441+ WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
1442+ pScalingListPresentFlag[i] = !!uiCode;
1443+ if (!!uiCode) {
1444+ if (i < 6) {
1445+ iRetTmp = SetScalingListValue (iScalingList4x4[i], 16, &bUseDefaultScalingMatrixFlag4x4, pBs);
1446+ if (iRetTmp == ERR_NONE) {
1447+ if (bUseDefaultScalingMatrixFlag4x4) {
1448+ bUseDefaultScalingMatrixFlag4x4 = false;
1449+ memcpy (iScalingList4x4[i], g_kuiDequantScaling4x4Default[i / 3], sizeof (uint8_t) * 16);
1450+ }
1451+ } else
1452+ return iRetTmp;
1453+
1454+ } else {
1455+ SetScalingListValue (iScalingList8x8[i - 6], 64, &bUseDefaultScalingMatrixFlag8x8, pBs);
1456+ //if(iRetTmp == ERR_NONE)
1457+ //{
1458+ if (bUseDefaultScalingMatrixFlag8x8) {
1459+ bUseDefaultScalingMatrixFlag8x8 = false;
1460+ memcpy (iScalingList8x8[i - 6], g_kuiDequantScaling8x8Default[ (i - 6) & 1], sizeof (uint8_t) * 64);
1461+ }
1462+ // }
1463+
1464+ //else
1465+ // return iRetTmp;
1466+ }
1467+
1468+ } else {
1469+ if (i < 6) {
1470+ if ((i != 0) && (i != 3))
1471+ memcpy (iScalingList4x4[i], iScalingList4x4[i - 1], sizeof (uint8_t) * 16);
1472+ else
1473+ memcpy (iScalingList4x4[i], defaultScaling[i / 3], sizeof (uint8_t) * 16);
1474+
1475+ } else {
1476+ if ((i == 6) || (i == 7))
1477+ memcpy (iScalingList8x8[i - 6], defaultScaling[ (i & 1) + 2], sizeof (uint8_t) * 64);
1478+ else
1479+ memcpy (iScalingList8x8[i - 6], iScalingList8x8[ (i - 6) / 3], sizeof (uint8_t) * 64);
1480+
1481+ }
1482+ }
1483+ }
1484+ return ERR_NONE;
1485+
1486+}
13581487
13591488 /*!
13601489 *************************************************************************************
codec/decoder/core/src/decode_slice.cpp+108−23
@@ -197,8 +197,8 @@ int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { · 196 unmodified lines
197197 return 0;
198198 }
199199
200−void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp) {
201− const int32_t kiQMul = g_kuiDequantCoeff[iQp][0];
200+void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pCtx) {
201+ const int32_t kiQMul = pCtx->bUseScalingList ? pCtx->pDequant_coeff4x4[0][iQp][0] >> 4 : g_kuiDequantCoeff[iQp][0];
202202 #define STRIDE 16
203203 int32_t i;
204204 int32_t iTemp[16]; //FIXME check if this is a good idea
@@ -246,7 +246,7 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 41 unmodified lines
246246 WelsFillRecNeededMbInfo (pCtx, bOutput, pCurLayer);
247247
248248 if (IS_INTRA16x16 (pCurLayer->pMbType[iMbXy])) {
249− WelsLumaDcDequantIdct (pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy]);
249+ WelsLumaDcDequantIdct (pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx);
250250 RecI16x16Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
251251
252252 return 0;
@@ -596,7 +596,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 343 unmodified lines
596596 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
597597 //Luma (DC and AC decoding together)
598598 WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
599− g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pLumaQp[iMbXy],
599+ g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
600+ pCurLayer->pLumaQp[iMbXy],
600601 pCtx));
601602 iIdx++;
602603 }
@@ -610,25 +611,26 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 7 unmodified lines
610611 ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
611612 ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
612613 }
613−
614+ int32_t iMbResProperty;
614615 //chroma
615616 //step1: DC
616617 if (1 == uiCbpChroma || 2 == uiCbpChroma) {
617618 //Cb Cr
618− WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (0 << 2), 4, g_kuiChromaDcScan,
619− CHROMA_DC_V, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (0 << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
620− WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (1 << 2), 4, g_kuiChromaDcScan,
621− CHROMA_DC_U, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (1 << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
619+ for (i = 0; i < 2; i++) {
620+ iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
621+ WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
622+ iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
623+ }
622624 }
623625
624626 //step2: AC
625627 if (2 == uiCbpChroma) {
626628 for (i = 0; i < 2; i++) { //Cb Cr
627− int32_t iResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
629+ iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
628630 int32_t iIdx = 16 + (i << 2);
629631 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
630632 WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx,
631− iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iResProperty,
633+ iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty,
632634 pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pChromaQp[iMbXy], pCtx));
633635 iIdx++;
634636 }
@@ -673,7 +675,7 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 38 unmodified lines
673675 int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
674676 int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
675677 int32_t iMbXy = pCurLayer->iMbXyIndex;
676−
678+ int32_t iMbResProperty;
677679 int32_t i;
678680 uint32_t uiMbType = 0, uiCbp = 0, uiCbpLuma = 0, uiCbpChroma = 0;
679681
@@ -723,6 +725,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 43 unmodified lines
723725 }
724726 }
725727
728+
729+
730+
731+
732+
733+
734+
735+
736+
737+
738+
739+
740+
741+
742+
726743 ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
727744 ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
728745 ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
@@ -774,13 +791,15 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 45 unmodified lines
774791 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
775792 }
776793 } else { //non-MB_TYPE_INTRA16x16
794+ iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
777795 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
778796 if (uiCbpLuma & (1 << iId8x8)) {
779797 int32_t iIdx = (iId8x8 << 2);
780798 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
781799 //Luma (DC and AC decoding together)
782800 WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
783− g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), pCurLayer->pLumaQp[iMbXy],
801+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
802+ pCurLayer->pLumaQp[iMbXy],
784803 pCtx));
785804 iIdx++;
786805 }
@@ -799,20 +818,27 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 12 unmodified lines
799818 //step1: DC
800819 if (1 == uiCbpChroma || 2 == uiCbpChroma) {
801820 for (i = 0; i < 2; i++) {
802− int32_t iResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
821+ if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
822+ iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
823+ else
824+ iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
825+
803826 WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, 16 + (i << 2), 4, g_kuiChromaDcScan,
804− iResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
827+ iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy], pCtx));
805828 }
806829 }
807830 //step2: AC
808831 if (2 == uiCbpChroma) {
809832 for (i = 0; i < 2; i++) {
810− int32_t iResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
833+ if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
834+ iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
835+ else
836+ iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
811837 int32_t index = 16 + (i << 2);
812838 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
813839 WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, index,
814840 iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
815− iResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy], pCtx));
841+ iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (index << 4), pCurLayer->pChromaQp[iMbXy], pCtx));
816842 index++;
817843 }
818844 }
@@ -893,6 +919,46 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 74 unmodified lines
893919 WELS_READ_VERIFY (WelsDecodeMbCabacPSliceBaseMode0 (pCtx, &uiNeighAvail, uiEosFlag));
894920 return ERR_NONE;
895921 }
922+// Calculate deqaunt coeff scaling list value
923+int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) {
924+ int32_t iScalingListNum = 0;
925+ if (pCtx->pSps->bSeqScalingMatrixPresentFlag || pCtx->pPps->bPicScalingMatrixPresentFlag) {
926+ pCtx->bUseScalingList = true;
927+ iScalingListNum = (pCtx->pSps->uiChromaFormatIdc != 3) ? 8 : 12;
928+
929+ if (!pCtx->bDequantCoeff4x4Init || (pCtx->iDequantCoeffPpsid != pCtx->pPps->iPpsId)) {
930+ int i, q, x;
931+ // Rewrite pps scaling list for scalingList present flag=0
932+ if (pCtx->bSpsLatePps) {
933+ for (i = 0; i < 6; i++) {
934+ if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) {
935+ if (i == 0 || i == 3)
936+ memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t));
937+ else
938+ memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t));
939+
940+ }
941+ }
942+ //TO DO, SUPPORT 8x8 SCALINGlist
943+
944+ }
945+ //Init dequant coeff value for different QP
946+ for (i = 0; i < 6; i++) {
947+ pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i];
948+ for (q = 0; q < 51; q++) {
949+ for (x = 0; x < 16; x++) {
950+ pCtx->pDequant_coeff4x4[i][q][x] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList4x4[i][x] *
951+ g_kuiDequantCoeff[q][x & 0x07] : pCtx->pSps->iScalingList4x4[i][x] * g_kuiDequantCoeff[q][x & 0x07];
952+ }
953+ }
954+ }
955+
956+ pCtx->bDequantCoeff4x4Init = true;
957+ }
958+ } else
959+ pCtx->bUseScalingList = false;
960+ return ERR_NONE;
961+}
896962
897963 int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNalUnit pNalCur) {
898964 PDqLayer pCurLayer = pCtx->pCurDqLayer;
@@ -950,6 +1016,8 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal · 51 unmodified lines
9501016 pSlice->iLastDeltaQp = 0;
9511017 WELS_READ_VERIFY (InitCabacDecEngineFromBS (pCtx->pCabacDecEngine, pCtx->pCurDqLayer->pBitStringAux));
9521018 }
1019+ //try to calculate the dequant_coeff
1020+ WelsCalcDeqCoeffScalingList (pCtx);
9531021
9541022 iNextMbXyIndex = pSliceHeader->iFirstMbInSlice;
9551023 iMbX = iNextMbXyIndex % pCurLayer->iMbWidth;
@@ -1001,6 +1069,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 45 unmodified lines
10011069 PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
10021070
10031071 SWelsNeighAvail sNeighAvail;
1072+ int32_t iMbResProperty;
10041073
10051074 int32_t iScanIdxStart = pSlice->sSliceHeaderExt.uiScanIdxStart;
10061075 int32_t iScanIdxEnd = pSlice->sSliceHeaderExt.uiScanIdxEnd;
@@ -1038,6 +1107,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 31 unmodified lines
10381107
10391108 uint8_t* pTmpBsBuf;
10401109
1110+
10411111 int32_t i;
10421112 int32_t iCopySizeY = (sizeof (uint8_t) << 4);
10431113 int32_t iCopySizeUV = (sizeof (uint8_t) << 3);
@@ -1165,7 +1235,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 121 unmodified lines
11651235 //Luma (DC and AC decoding together)
11661236 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
11671237 iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart,
1168− LUMA_DC_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1238+ LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
11691239 return -1;//abnormal
11701240 }
11711241 iIndex++;
@@ -1185,8 +1255,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 13 unmodified lines
11851255 //step1: DC
11861256 if (1 == uiCbpC || 2 == uiCbpC) {
11871257 for (i = 0; i < 2; i++) { //Cb Cr
1258+ iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
11881259 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs,
1189− 16 + (i << 2), 4, g_kuiChromaDcScan, CHROMA_DC, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
1260+ 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
11901261 pCurLayer->pChromaQp[iMbXy], pCtx)) {
11911262 return -1;//abnormal
11921263 }
@@ -1196,11 +1267,12 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 3 unmodified lines
11961267 //step2: AC
11971268 if (2 == uiCbpC) {
11981269 for (i = 0; i < 2; i++) { //Cb Cr
1270+ iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
11991271 int32_t iIndex = 16 + (i << 2);
12001272 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
12011273 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
12021274 iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
1203− CHROMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy], pCtx)) {
1275+ iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy], pCtx)) {
12041276 return -1;//abnormal
12051277 }
12061278 iIndex++;
@@ -1277,6 +1349,8 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 70 unmodified lines
12771349 uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
12781350 uint32_t uiCode;
12791351 int32_t iCode;
1352+ int32_t iMbResProperty;
1353+
12801354 GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
12811355 ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
12821356 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;//2009.10.23
@@ -1461,12 +1535,13 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 178 unmodified lines
14611535 }
14621536 } else { //non-MB_TYPE_INTRA16x16
14631537 for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1538+ iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
14641539 if (uiCbpL & (1 << iId8x8)) {
14651540 int32_t iIndex = (iId8x8 << 2);
14661541 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
14671542 //Luma (DC and AC decoding together)
14681543 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1469− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC,
1544+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty,
14701545 pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
14711546 return -1;//abnormal
14721547 }
@@ -1488,8 +1563,13 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 15 unmodified lines
14881563 //step1: DC
14891564 if (1 == uiCbpC || 2 == uiCbpC) {
14901565 for (i = 0; i < 2; i++) { //Cb Cr
1566+ if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
1567+ iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
1568+ else
1569+ iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
1570+
14911571 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs,
1492− 16 + (i << 2), 4, g_kuiChromaDcScan, CHROMA_DC, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
1572+ 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
14931573 pCurLayer->pChromaQp[iMbXy], pCtx)) {
14941574 return -1;//abnormal
14951575 }
@@ -1499,11 +1579,16 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 3 unmodified lines
14991579 //step2: AC
15001580 if (2 == uiCbpC) {
15011581 for (i = 0; i < 2; i++) { //Cb Cr
1582+ if (IS_INTRA (pCurLayer->pMbType[iMbXy]))
1583+ iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
1584+ else
1585+ iMbResProperty = i ? CHROMA_AC_V_INTER : CHROMA_AC_U_INTER;
1586+
15021587 int32_t iIndex = 16 + (i << 2);
15031588 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
15041589 if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
15051590 iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
1506− CHROMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy], pCtx)) {
1591+ iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy], pCtx)) {
15071592 return -1;//abnormal
15081593 }
15091594 iIndex++;
codec/decoder/core/src/decoder.cpp+2−0
@@ -309,6 +309,8 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 308 unmodified lines
309309 pCtx->eErrorConMethod = ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
310310 pCtx->pPreviousDecodedPictureInDpb = NULL;
311311 pCtx->sDecoderStatistics.iAvgLumaQp = -1;
312+ pCtx->bSpsLatePps = false;
313+ pCtx->bUseScalingList = false;
312314
313315 }
314316
codec/decoder/core/src/parse_mb_syn_cabac.cpp+9−3
@@ -821,11 +821,15 @@ int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroC · 820 unmodified lines
821821 const uint8_t* pScanTable, int32_t iResProperty, short* sTCoeff, /*int mb_mode*/ uint8_t uiQp,
822822 PWelsDecoderContext pCtx) {
823823 int32_t iCurNzCacheIdx;
824− const uint16_t* pDeQuantMul = g_kuiDequantCoeff[uiQp];
825824 uint32_t uiTotalCoeffNum = 0;
826825 uint32_t uiCbpBit;
827826 int32_t pSignificantMap[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
828827
828+ int32_t iMbResProperty;
829+ GetMbResProperty (&iMbResProperty, &iResProperty, false);
830+ const uint16_t* pDeQuantMul = (pCtx->bUseScalingList) ? pCtx->pDequant_coeff4x4[iMbResProperty][uiQp] :
831+ g_kuiDequantCoeff[uiQp];
832+
829833 WELS_READ_VERIFY (ParseCbfInfoCabac (pNeighAvail, pNonZeroCountCache, iIndex, iResProperty, pCtx, uiCbpBit));
830834 if (uiCbpBit) { //has coeff
831835 WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, uiTotalCoeffNum));
@@ -847,13 +851,15 @@ int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroC · 15 unmodified lines
847851 } else if (iResProperty == CHROMA_DC_U || iResProperty == CHROMA_DC_V) {
848852 do {
849853 if (pSignificantMap[j] != 0)
850− sTCoeff[pScanTable[j]] = pSignificantMap[j] * pDeQuantMul[0];
854+ sTCoeff[pScanTable[j]] = pCtx->bUseScalingList ? (pSignificantMap[j] * pDeQuantMul[0]) >> 4 :
855+ (pSignificantMap[j] * pDeQuantMul[0]);
851856 ++j;
852857 } while (j < 16);
853858 } else { //luma ac, chroma ac
854859 do {
855860 if (pSignificantMap[j] != 0)
856− sTCoeff[pScanTable[j]] = pSignificantMap[j] * pDeQuantMul[pScanTable[j] & 0x07];
861+ sTCoeff[pScanTable[j]] = pCtx->bUseScalingList ? (pSignificantMap[j] * pDeQuantMul[pScanTable[j]] >> 4) :
862+ pSignificantMap[j] * pDeQuantMul[pScanTable[j] & 0x07];
857863 ++j;
858864 } while (j < 16);
859865 }
codec/decoder/core/src/parse_mb_syn_cavlc.cpp+48−43
@@ -236,8 +236,8 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 235 unmodified lines
236236 }
237237 }
238238
239−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)
240−{
239+void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int16_t iMvArray[LIST_A][30][MV_A],
240+ int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) {
241241 int32_t iCurXy = pCurLayer->iMbXyIndex;
242242 int32_t iTopXy = 0;
243243 int32_t iLeftXy = 0;
@@ -267,10 +267,10 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount · 23 unmodified lines
267267 ST32 (iMvArray[0][18], LD32 (pCurLayer->pMv[0][iLeftXy][11]));
268268 ST32 (iMvArray[0][24], LD32 (pCurLayer->pMv[0][iLeftXy][15]));
269269
270− ST32(iMvdCache[0][ 6], LD32(pCurLayer->pMvd[0][iLeftXy][ 3]));
271− ST32(iMvdCache[0][12], LD32(pCurLayer->pMvd[0][iLeftXy][ 7]));
272− ST32(iMvdCache[0][18], LD32(pCurLayer->pMvd[0][iLeftXy][11]));
273− ST32(iMvdCache[0][24], LD32(pCurLayer->pMvd[0][iLeftXy][15]));
270+ ST32 (iMvdCache[0][ 6], LD32 (pCurLayer->pMvd[0][iLeftXy][ 3]));
271+ ST32 (iMvdCache[0][12], LD32 (pCurLayer->pMvd[0][iLeftXy][ 7]));
272+ ST32 (iMvdCache[0][18], LD32 (pCurLayer->pMvd[0][iLeftXy][11]));
273+ ST32 (iMvdCache[0][24], LD32 (pCurLayer->pMvd[0][iLeftXy][15]));
274274
275275 iRefIdxArray[0][ 6] = pCurLayer->pRefIndex[0][iLeftXy][ 3];
276276 iRefIdxArray[0][12] = pCurLayer->pRefIndex[0][iLeftXy][ 7];
@@ -282,31 +282,31 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount · 5 unmodified lines
282282 ST32 (iMvArray[0][18], 0);
283283 ST32 (iMvArray[0][24], 0);
284284
285− ST32(iMvdCache[0][ 6], 0);
286− ST32(iMvdCache[0][12], 0);
287− ST32(iMvdCache[0][18], 0);
288− ST32(iMvdCache[0][24], 0);
285+ ST32 (iMvdCache[0][ 6], 0);
286+ ST32 (iMvdCache[0][12], 0);
287+ ST32 (iMvdCache[0][18], 0);
288+ ST32 (iMvdCache[0][24], 0);
289289
290290
291291 if (0 == pNeighAvail->iLeftAvail) { //not available
292292 iRefIdxArray[0][ 6] =
293− iRefIdxArray[0][12] =
294− iRefIdxArray[0][18] =
295− iRefIdxArray[0][24] = REF_NOT_AVAIL;
293+ iRefIdxArray[0][12] =
294+ iRefIdxArray[0][18] =
295+ iRefIdxArray[0][24] = REF_NOT_AVAIL;
296296 } else { //available but is intra mb type
297297 iRefIdxArray[0][ 6] =
298− iRefIdxArray[0][12] =
299− iRefIdxArray[0][18] =
300− iRefIdxArray[0][24] = REF_NOT_IN_LIST;
298+ iRefIdxArray[0][12] =
299+ iRefIdxArray[0][18] =
300+ iRefIdxArray[0][24] = REF_NOT_IN_LIST;
301301 }
302302 }
303303 if (pNeighAvail->iLeftTopAvail && IS_INTER (pNeighAvail->iLeftTopType)) {
304304 ST32 (iMvArray[0][0], LD32 (pCurLayer->pMv[0][iLeftTopXy][15]));
305− ST32(iMvdCache[0][0], LD32(pCurLayer->pMvd[0][iLeftTopXy][15]));
305+ ST32 (iMvdCache[0][0], LD32 (pCurLayer->pMvd[0][iLeftTopXy][15]));
306306 iRefIdxArray[0][0] = pCurLayer->pRefIndex[0][iLeftTopXy][15];
307307 } else {
308308 ST32 (iMvArray[0][0], 0);
309− ST32(iMvdCache[0][0], 0);
309+ ST32 (iMvdCache[0][0], 0);
310310 if (0 == pNeighAvail->iLeftTopAvail) { //not available
311311 iRefIdxArray[0][0] = REF_NOT_AVAIL;
312312 } else { //available but is intra mb type
@@ -317,30 +317,30 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount · 4 unmodified lines
317317 if (pNeighAvail->iTopAvail && IS_INTER (pNeighAvail->iTopType)) {
318318 ST64 (iMvArray[0][1], LD64 (pCurLayer->pMv[0][iTopXy][12]));
319319 ST64 (iMvArray[0][3], LD64 (pCurLayer->pMv[0][iTopXy][14]));
320− ST64(iMvdCache[0][1], LD64(pCurLayer->pMvd[0][iTopXy][12]));
321− ST64(iMvdCache[0][3], LD64(pCurLayer->pMvd[0][iTopXy][14]));
320+ ST64 (iMvdCache[0][1], LD64 (pCurLayer->pMvd[0][iTopXy][12]));
321+ ST64 (iMvdCache[0][3], LD64 (pCurLayer->pMvd[0][iTopXy][14]));
322322 ST32 (&iRefIdxArray[0][1], LD32 (&pCurLayer->pRefIndex[0][iTopXy][12]));
323323 } else {
324324 ST64 (iMvArray[0][1], 0);
325325 ST64 (iMvArray[0][3], 0);
326− ST64(iMvdCache[0][1], 0);
327− ST64(iMvdCache[0][3], 0);
326+ ST64 (iMvdCache[0][1], 0);
327+ ST64 (iMvdCache[0][3], 0);
328328 if (0 == pNeighAvail->iTopAvail) { //not available
329329 iRefIdxArray[0][1] =
330− iRefIdxArray[0][2] =
331− iRefIdxArray[0][3] =
332− iRefIdxArray[0][4] = REF_NOT_AVAIL;
330+ iRefIdxArray[0][2] =
331+ iRefIdxArray[0][3] =
332+ iRefIdxArray[0][4] = REF_NOT_AVAIL;
333333 } else { //available but is intra mb type
334334 iRefIdxArray[0][1] =
335− iRefIdxArray[0][2] =
336− iRefIdxArray[0][3] =
337− iRefIdxArray[0][4] = REF_NOT_IN_LIST;
335+ iRefIdxArray[0][2] =
336+ iRefIdxArray[0][3] =
337+ iRefIdxArray[0][4] = REF_NOT_IN_LIST;
338338 }
339339 }
340340
341341 if (pNeighAvail->iRightTopAvail && IS_INTER (pNeighAvail->iRightTopType)) {
342342 ST32 (iMvArray[0][5], LD32 (pCurLayer->pMv[0][iRightTopXy][12]));
343− ST32(iMvdCache[0][5], LD32(pCurLayer->pMvd[0][iRightTopXy][12]));
343+ ST32 (iMvdCache[0][5], LD32 (pCurLayer->pMvd[0][iRightTopXy][12]));
344344 iRefIdxArray[0][5] = pCurLayer->pRefIndex[0][iRightTopXy][12];
345345 } else {
346346 ST32 (iMvArray[0][5], 0);
@@ -357,21 +357,20 @@ void WelsFillCacheInterCabac(PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount · 10 unmodified lines
357357 ST32 (iMvArray[0][11], 0);
358358 ST32 (iMvArray[0][17], 0);
359359 ST32 (iMvArray[0][23], 0);
360− ST32(iMvdCache[0][ 9], 0);
361− ST32(iMvdCache[0][21], 0);
362− ST32(iMvdCache[0][11], 0);
363− ST32(iMvdCache[0][17], 0);
364− ST32(iMvdCache[0][23], 0);
360+ ST32 (iMvdCache[0][ 9], 0);
361+ ST32 (iMvdCache[0][21], 0);
362+ ST32 (iMvdCache[0][11], 0);
363+ ST32 (iMvdCache[0][17], 0);
364+ ST32 (iMvdCache[0][23], 0);
365365 iRefIdxArray[0][ 9] =
366− iRefIdxArray[0][21] =
367− iRefIdxArray[0][11] =
368− iRefIdxArray[0][17] =
369− iRefIdxArray[0][23] = REF_NOT_AVAIL;
366+ iRefIdxArray[0][21] =
367+ iRefIdxArray[0][11] =
368+ iRefIdxArray[0][17] =
369+ iRefIdxArray[0][23] = REF_NOT_AVAIL;
370370 }
371371
372372 void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
373− int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer)
374−{
373+ int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer) {
375374 int32_t iCurXy = pCurLayer->iMbXyIndex;
376375 int32_t iTopXy = 0;
377376 int32_t iLeftXy = 0;
@@ -798,7 +797,13 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 420 unmodified lines
798797 int32_t iLevel[16], iZerosLeft, iCoeffNum;
799798 int32_t iRun[16];
800799 int32_t iCurNonZeroCacheIdx, i;
801− const uint16_t* kpDequantCoeff = g_kuiDequantCoeff[uiQp];
800+
801+
802+ int32_t iMbResProperty = 0;
803+ GetMbResProperty (&iMbResProperty, &iResidualProperty, 1);
804+ const uint16_t* kpDequantCoeff = pCtx->bUseScalingList ? pCtx->pDequant_coeff4x4[iMbResProperty][uiQp] :
805+ g_kuiDequantCoeff[uiQp];
806+
802807 int8_t nA, nB, nC;
803808 uint8_t uiTotalCoeff, uiTrailingOnes;
804809 int32_t iUsedBits = 0;
@@ -867,7 +872,7 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 62 unmodified lines
867872 int32_t j;
868873 iCoeffNum += iRun[i] + 1; //FIXME add 1 earlier ?
869874 j = kpZigzagTable[ iCoeffNum ];
870− pTCoeff[j] = iLevel[i] * kpDequantCoeff[0];
875+ pTCoeff[j] = pCtx->bUseScalingList ? (iLevel[i] * kpDequantCoeff[0]) >> 4 : (iLevel[i] * kpDequantCoeff[0]);
871876 }
872877 } else if (iResidualProperty == I16_LUMA_DC) { //DC coefficent, only call in Intra_16x16, base_mode_flag = 0
873878 for (i = uiTotalCoeff - 1; i >= 0; --i) { //FIXME merge into rundecode?
@@ -881,7 +886,7 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 7 unmodified lines
881886 int32_t j;
882887 iCoeffNum += iRun[i] + 1; //FIXME add 1 earlier ?
883888 j = kpZigzagTable[ iCoeffNum ];
884− pTCoeff[j] = iLevel[i] * kpDequantCoeff[j & 0x07];
889+ pTCoeff[j] = pCtx->bUseScalingList ? (iLevel[i] * kpDequantCoeff[j]) >> 4 : (iLevel[i] * kpDequantCoeff[j & 0x07]);
885890 }
886891 }
887892

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t