ref: fea27cab7b93fa0f806ede551a5838f470ca1ed0
parent: c1f66ea21ba869a4dcf901ad6edfbbaa8cca2618
parent: 518a317201d6bea5e5f61669d154e059f662a60c
author: huili2 <[email protected]>
date: Wed Nov 30 11:15:15 EST 2016
Merge pull request #2613 from ruil2/memory_issue fix memory lenght issue
--- a/codec/encoder/core/src/set_mb_syn_cavlc.cpp
+++ b/codec/encoder/core/src/set_mb_syn_cavlc.cpp
@@ -251,7 +251,8 @@
SCabacCtx* pCtx = &pSlice->sCabacCtx;
memcpy (&pDss->sStoredCabac, pCtx, sizeof (SCabacCtx));
if (pDss->pRestoreBuffer) {
- int32_t iLen = GetBsPosCabac (pSlice) - pDss->iStartPos;
+ int32_t iPosBitOffset = GetBsPosCabac (pSlice) - pDss->iStartPos;
+ int32_t iLen = ((iPosBitOffset >> 3) + ((iPosBitOffset & 0x07) ? 1 : 0));
memcpy (pDss->pRestoreBuffer, pCtx->m_pBufStart, iLen);
}
pDss->uiLastMbQp = pSlice->uiLastMbQp;
@@ -260,9 +261,9 @@
int32_t StashPopMBStatusCabac (SDynamicSlicingStack* pDss, SSlice* pSlice) {
SCabacCtx* pCtx = &pSlice->sCabacCtx;
memcpy (pCtx, &pDss->sStoredCabac, sizeof (SCabacCtx));
-
if (pDss->pRestoreBuffer) {
- int32_t iLen = GetBsPosCabac (pSlice) - pDss->iStartPos;
+ int32_t iPosBitOffset = GetBsPosCabac (pSlice) - pDss->iStartPos;
+ int32_t iLen = ((iPosBitOffset >> 3) + ((iPosBitOffset & 0x07) ? 1 : 0));
memcpy (pCtx->m_pBufStart, pDss->pRestoreBuffer, iLen);
}
pSlice->uiLastMbQp = pDss->uiLastMbQp;