📄 swdec_vop.c
字号:
Output:
HANTRO_OK/HANTRO_NOK/END_OF_STREAM
------------------------------------------------------------------------------*/
u32 SwDec_DecodeVop(decContainer_t *pDecContainer)
{
u32 tmp;
u32 isEndOfVop;
u32 stuffingLength;
u32 isResyncMarker = 0;
u32 status = HANTRO_OK;
ASSERT(pDecContainer);
ASSERT(!pDecContainer->StrmStorage.shortVideo);
status = SwDec_DecodeVopHeader(pDecContainer);
if (status != HANTRO_OK) return(status);
if (pDecContainer->VopDesc.vopCoded)
{
status = SwDec_DecodeMotionTexture(pDecContainer);
if (status != HANTRO_OK) return(status);
}
else
{
pDecContainer->StrmStorage.vpNumMbs =
pDecContainer->VopDesc.totalMbInVop;
/* copy previous picture if external memory allocation used */
if (pDecContainer->StrmStorage.extPicBufAlloc)
{
MP4SwDecMemcpy(pDecContainer->pOut, pDecContainer->pRef,
(384 * pDecContainer->VopDesc.totalMbInVop));
}
else
{
tmp = (u32)pDecContainer->pRef;
pDecContainer->pRef = pDecContainer->pOut;
pDecContainer->pOut = (u8*)tmp;
}
}
isEndOfVop = (pDecContainer->StrmStorage.vpMbNumber +
pDecContainer->StrmStorage.vpNumMbs) ==
pDecContainer->VopDesc.totalMbInVop;
status = SwDec_GetStuffing(pDecContainer);
if (status != HANTRO_OK)
{
/* NOT coded vop and problem in stuffing or next startcode
* --> prevent concealing current vop */
if (!pDecContainer->VopDesc.vopCoded)
{
pDecContainer->StrmStorage.vpMbNumber +=
pDecContainer->StrmStorage.vpNumMbs;
pDecContainer->StrmStorage.vpQP = pDecContainer->StrmStorage.QP;
pDecContainer->StrmStorage.vpNumMbs = 0;
return (HANTRO_OK);
}
else if (isEndOfVop)
{
/* read stuffing until stream ends or resync marker or
* startcode found */
while( !IS_END_OF_STREAM(pDecContainer) )
{
tmp = SwDec_ShowBits(pDecContainer,32);
isResyncMarker =
(tmp>>(32-pDecContainer->StrmStorage.resyncMarkerLength));
/* break if there is resync marker or startcode */
if ( (isResyncMarker == 0x1) || ((tmp>>8) == 0x1) )
break;
/* read stuffing byte */
stuffingLength = 8-pDecContainer->StrmDesc.bitPosInWord;
tmp = SwDec_GetBits(pDecContainer,stuffingLength);
/* check that stuffing is valid H.263 or MPEG-4 stuffing */
if ( (tmp != 0) && (tmp != stuffingTable[stuffingLength - 1]))
return (HANTRO_NOK);
}
}
else
return(status);
}
/* there might be extra stuffing byte if next start code is video
* object sequence start or end code */
tmp = SwDec_ShowBitsAligned(pDecContainer,32,1);
if ((tmp == SC_VOS_START) || (tmp == SC_VOS_END))
{
tmp = SwDec_GetStuffing(pDecContainer);
if (tmp != HANTRO_OK)
{
/* NOT coded vop and problem in stuffing or next startcode
* --> prevent concealing current vop */
if (!pDecContainer->VopDesc.vopCoded)
{
pDecContainer->StrmStorage.vpMbNumber +=
pDecContainer->StrmStorage.vpNumMbs;
pDecContainer->StrmStorage.vpQP = pDecContainer->StrmStorage.QP;
pDecContainer->StrmStorage.vpNumMbs = 0;
return (HANTRO_OK);
}
else
return(tmp);
}
}
/* skip all extra zero bits, not according to standard
* but some encoders put zero bytes to stream */
tmp = SwDec_ShowBits(pDecContainer, 24);
if (tmp == 0)
{
/* while startcode prefix found or end of stream */
while ( (tmp != 0x1) && !IS_END_OF_STREAM(pDecContainer))
{
SwDec_FlushBits(pDecContainer, 8);
tmp = SwDec_ShowBits(pDecContainer, 24);
}
}
/* stuffing ok -> check that there is proper start code or marker or
* stream ends */
tmp = SwDec_ShowBits(pDecContainer,32);
if (/* END_OF_STREAM */
(IS_END_OF_STREAM(pDecContainer)) ||
/* RESYNC_MARKER (if enabled) */
(((tmp>>(32-pDecContainer->StrmStorage.resyncMarkerLength)) == 0x01) &&
!isEndOfVop) ||
/* end of VOP and START_CODE or SC_ERROR (i.e. at least 23 zeros) */
(isEndOfVop && !(tmp>>9)))
{
/* whole video packet decoded and stuffing ok -> set vpMbNumber in
* StrmStorage so that this video packet won't be touched/concealed
* anymore. Also set VpQP to QP so that concealment will use qp of last
* decoded macro block */
pDecContainer->StrmStorage.vpMbNumber +=
pDecContainer->StrmStorage.vpNumMbs;
pDecContainer->StrmStorage.vpQP = pDecContainer->StrmStorage.QP;
pDecContainer->StrmStorage.vpNumMbs = 0;
return(HANTRO_OK);
}
else
{
/* NOT coded vop and problem in stuffing or next startcode
* --> prevent concealing current vop */
if (!pDecContainer->VopDesc.vopCoded)
{
pDecContainer->StrmStorage.vpMbNumber +=
pDecContainer->StrmStorage.vpNumMbs;
pDecContainer->StrmStorage.vpQP = pDecContainer->StrmStorage.QP;
pDecContainer->StrmStorage.vpNumMbs = 0;
return (HANTRO_OK);
}
else
return(HANTRO_NOK);
}
}
/*------------------------------------------------------------------------------
5.3 Function name: SwDec_ReadVopComplexity
Purpose: read vop complexity estimation header
Input:
Pointer to decContainer_t structure
Output:
HANTRO_OK/END_OF_STREAM
------------------------------------------------------------------------------*/
u32 SwDec_ReadVopComplexity(decContainer_t *pDecContainer)
{
u32 tmp;
ASSERT(pDecContainer);
ASSERT((pDecContainer->VopDesc.vopCodingType == IVOP) ||
(pDecContainer->VopDesc.vopCodingType == PVOP));
tmp = 0;
if (pDecContainer->Hdrs.estimationMethod == 0)
{
/* common stuff for I- and P-VOPs */
if (pDecContainer->Hdrs.opaque)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.transparent)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.intraCae)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.interCae)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.noUpdate)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.upsampling)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.intraBlocks)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.notCodedBlocks)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.dctCoefs)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.dctLines)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.vlcSymbols)
tmp = SwDec_GetBits(pDecContainer,8);
/* NOTE that this is just 4 bits long */
if (pDecContainer->Hdrs.vlcBits)
tmp = SwDec_GetBits(pDecContainer,4);
if (pDecContainer->VopDesc.vopCodingType == IVOP)
{
if (pDecContainer->Hdrs.sadct)
tmp = SwDec_GetBits(pDecContainer,8);
}
else /* PVOP */
{
if (pDecContainer->Hdrs.interBlocks)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.inter4vBlocks)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.apm)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.npm)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.forwBackMcQ)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.halfpel2)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.halfpel4)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.sadct)
tmp = SwDec_GetBits(pDecContainer,8);
if (pDecContainer->Hdrs.quarterpel)
tmp = SwDec_GetBits(pDecContainer,8);
}
}
CHECK_END_OF_STREAM(tmp);
return(HANTRO_OK);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -