Commit:8de2fd0d9659236701c39f309d4296809de45808 (browse)
Parent:f32a81d8d88ccb1fd7c2dd116944afea10bdbdff
Author:Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:Thu Dec 10 15:07:31 CET 2020
Message:
fix decoder, now it works correctly again

codec/common/inc/ls_defines.h => codec/common/inc/ls_defines.h
@@ -35,50 +35,25 @@
 
 #include "typedefs.h"
 
-#pragma pack on
-struct tagUnaligned_64 {
-  uint64_t l;
-};
-struct tagUnaligned_32 {
-  uint32_t l;
-};
-struct tagUnaligned_16 {
-  uint16_t l;
-};
-#pragma pack off
+#define LD16(a) (*((uint16_t*)(a)))
+#define LD32(a) (*((uint32_t*)(a)))
+#define LD64(a) (*((uint64_t*)(a)))
 
-#define LD16(a) (((struct tagUnaligned_16 *) (a))->l)
-#define LD32(a) (((struct tagUnaligned_32 *) (a))->l)
-#define LD64(a) (((struct tagUnaligned_64 *) (a))->l)
-
-#define STRUCTA(size, align) struct tagUnaligned_##size##_##align {\
-    uint##size##_t l; \
-}
-STRUCTA (16, 2);
-STRUCTA (32, 2);
-STRUCTA (32, 4);
-STRUCTA (64, 2);
-STRUCTA (64, 4);
-STRUCTA (64, 8);
-
-#define ST16(a, b) (((struct tagUnaligned_16 *) (a))->l) = (b)
-#define ST32(a, b) (((struct tagUnaligned_32 *) (a))->l) = (b)
-#define ST64(a, b) (((struct tagUnaligned_64 *) (a))->l) = (b)
-
-#define LDA(a, size, align) (((struct tagUnaligned_##size##_##align *) (a))->l)
-#define STA(a, b, size, align) (((struct tagUnaligned_##size##_##align *) (a))->l) = (b)
-#define LD16A2(a) LDA(a, 16, 2)
-#define LD32A2(a) LDA(a, 32, 2)
-#define LD32A4(a) LDA(a, 32, 4)
-#define LD64A2(a) LDA(a, 64, 2)
-#define LD64A4(a) LDA(a, 64, 4)
-#define LD64A8(a) LDA(a, 64, 8)
-#define ST16A2(a, b) STA(a, b, 16, 2)
-#define ST32A2(a, b) STA(a, b, 32, 2)
-#define ST32A4(a, b) STA(a, b, 32, 4)
-#define ST64A2(a, b) STA(a, b, 64, 2)
-#define ST64A4(a, b) STA(a, b, 64, 4)
-#define ST64A8(a, b) STA(a, b, 64, 8)
+#define ST16(a, b) *((uint16_t*)(a)) = (b)
+#define ST32(a, b) *((uint32_t*)(a)) = (b)
+#define ST64(a, b) *((uint64_t*)(a)) = (b)
+#define LD16A2 LD16
+#define LD32A2 LD32
+#define LD32A4 LD32
+#define LD64A2 LD64
+#define LD64A4 LD64
+#define LD64A8 LD64
+#define ST16A2 ST16
+#define ST32A2 ST32
+#define ST32A4 ST32
+#define ST64A2 ST64
+#define ST64A4 ST64
+#define ST64A8 ST64
 
 #ifndef INTD16
 #define INTD16 LD16

codec/decoder/core/inc/deblocking.h => codec/decoder/core/inc/deblocking.h
@@ -98,7 +98,6 @@
 
 uint32_t DeblockingBsMarginalMBAvcbase (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 DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc);
 

codec/decoder/core/inc/decoder.h => codec/decoder/core/inc/decoder.h
@@ -173,7 +173,7 @@
 void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa);
 //reset picture reodering buffer list
 void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo,
-                                    const bool *bFullReset);
+                                    const bool bFullReset);
 
 #ifdef __cplusplus
 }

codec/decoder/core/src/cabac_decoder.cpp => codec/decoder/core/src/cabac_decoder.cpp
@@ -252,19 +252,19 @@
   if (*uiSymVal == 0) {
     return ERR_NONE;
   } else {
-    uint32_t uiCode;
+    uint32_t uiCode = 0;
     pBinCtx += iCtxOffset;
     *uiSymVal = 0;
     do {
       WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, &uiCode));
-      ++(*uiSymVal);
+      *uiSymVal += 1;
     } while (uiCode != 0);
     return ERR_NONE;
   }
 }
 
 int32_t DecodeExpBypassCabac (PWelsCabacDecEngine pDecEngine, int32_t iCount, uint32_t *uiSymVal) {
-  uint32_t uiCode;
+  uint32_t uiCode = 0;
   int32_t iSymTmp = 0;
   int32_t iSymTmp2 = 0;
   *uiSymVal = 0;
@@ -295,11 +295,11 @@
   if (*uiCode == 0)
     return ERR_NONE;
   else {
-    uint32_t uiTmp, uiCount = 1;
+    uint32_t uiTmp = 0, uiCount = 1;
     *uiCode = 0;
     do {
       WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx, &uiTmp));
-      ++(*uiCode);
+      *uiCode += 1;
       ++uiCount;
     } while (uiTmp != 0 && uiCount != 13);
 
@@ -321,7 +321,7 @@
     *uiCode = 0;
     do {
       WELS_READ_VERIFY (DecodeBinCabac (pDecEngine, pBinCtx + g_kMvdBinPos2Ctx[uiCount++], &uiTmp));
-      (*uiCode)++;
+      *uiCode += 1;
     } while (uiTmp != 0 && uiCount != 8);
 
     if (uiTmp != 0) {

codec/decoder/core/src/decode_slice.cpp => codec/decoder/core/src/decode_slice.cpp
@@ -1536,7 +1536,6 @@
       WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
                "WelsDecodeSlice()::::ILP flag exist, not supported with CABAC enabled!");
       pCtx->iErrorCode |= dsBitstreamError;
-      fprint(2, "dsBitstreamError\n");
       return dsBitstreamError;
     }
     if (P_SLICE == pSliceHeader->eSliceType)
@@ -1588,7 +1587,6 @@
   pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
 
   do {
-    //fprint(2, "(-1 == %d) || (%d >= %d) → %d\n", iNextMbXyIndex, iNextMbXyIndex, kiCountNumMb, (-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb));
     if ((-1 == iNextMbXyIndex) || (iNextMbXyIndex >= kiCountNumMb)) { // slice group boundary or end of a frame
       break;
     }
@@ -1598,7 +1596,6 @@
     iRet = pDecMbFunc (pCtx,  pNalCur, &uiEosFlag);
     pCurDqLayer->pMbRefConcealedFlag[iNextMbXyIndex] = pCtx->bMbRefConcealed;
     if (iRet != ERR_NONE) {
-      fprint(2, "pDecMbFunc %p %p %d\n", pDecMbFunc, WelsDecodeMbCabacPSlice, iRet);
       return iRet;
     }
 
@@ -1733,6 +1730,7 @@
     if (pCtx->uiNalRefIdc > 0) {
       if (pCurDqLayer->iMbX == 0 || pCurDqLayer->iMbX == pCurDqLayer->iMbWidth - 1 || pCurDqLayer->iMbY == 0
           || pCurDqLayer->iMbY == pCurDqLayer->iMbHeight - 1) {
+
         PadMBLuma_c (pCurDqLayer->pDec->pData[0], pCurDqLayer->pDec->iLinesize[0], pCurDqLayer->pDec->iWidthInPixel,
                      pCurDqLayer->pDec->iHeightInPixel, pCurDqLayer->iMbX, pCurDqLayer->iMbY, pCurDqLayer->iMbWidth, pCurDqLayer->iMbHeight);
         PadMBChroma_c (pCurDqLayer->pDec->pData[1], pCurDqLayer->pDec->iLinesize[1], pCurDqLayer->pDec->iWidthInPixel / 2,

codec/decoder/core/src/decoder.cpp => codec/decoder/core/src/decoder.cpp
@@ -284,9 +284,9 @@
 
 //reset picture reodering buffer list
 void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo,
-                                    const bool *fullReset) {
+                                    const bool fullReset) {
   if (pPictReoderingStatus != NULL && pPictInfo != NULL) {
-    int32_t pictInfoListCount = *fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1);
+    int32_t pictInfoListCount = fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1);
     pPictReoderingStatus->iPictInfoIndex = 0;
     pPictReoderingStatus->iMinPOC = IMinInt32;
     pPictReoderingStatus->iNumOfPicts = 0;
@@ -1038,7 +1038,7 @@
   pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c;
 
   pCtx->pIdctResAddPredFunc     = IdctResAddPred_c;
-  pCtx->pIdctFourResAddPredFunc = (void*)IdctResAddPred_c;
+  pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_;
 
   pCtx->pIdctResAddPredFunc8x8  = IdctResAddPred8x8_c;
 

codec/decoder/core/src/decoder_core.cpp => codec/decoder/core/src/decoder_core.cpp
@@ -2721,7 +2721,6 @@
             SET_EVENT (&pThreadCtx->sSliceDecodeStart);
           }
           iRet = WelsDecodeAndConstructSlice (pCtx);
-fprint(2, "WelsDecodeAndConstructSlice %d\n", iRet);
         } else {
           iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur);
         }