📄 swdec_shortvideo.c
字号:
* eight LSBs */
tmp = SwDec_GetBits(pDecContainer,8);
CHECK_END_OF_STREAM(tmp);
pDecContainer->SvDesc.temporalReference = tmp;
tmp = SwDec_GetOneBit(pDecContainer); /* marker */
CHECK_END_OF_STREAM(tmp);
if (tmp == 0) return(HANTRO_NOK);
tmp = SwDec_GetOneBit(pDecContainer); /* zero */
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
pDecContainer->SvDesc.splitScreenIndicator =
SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(pDecContainer->SvDesc.splitScreenIndicator);
pDecContainer->SvDesc.documentCameraIndicator =
SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(pDecContainer->SvDesc.documentCameraIndicator);
pDecContainer->SvDesc.fullPictureFreezeRelease =
SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(pDecContainer->SvDesc.fullPictureFreezeRelease);
pDecContainer->SvDesc.sourceFormat = SwDec_GetBits(pDecContainer,3);
CHECK_END_OF_STREAM(pDecContainer->SvDesc.sourceFormat);
if ((pDecContainer->SvDesc.sourceFormat == 0) || /* forbidden */
(pDecContainer->SvDesc.sourceFormat == 6) ) /* reserved */
return (HANTRO_NOK);
else if (pDecContainer->SvDesc.sourceFormat != 7)
{
pDecContainer->VopDesc.vopCodingType = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(pDecContainer->VopDesc.vopCodingType);
tmp = SwDec_GetBits(pDecContainer,4); /* 4 zero */
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* QP */
pDecContainer->VopDesc.QP = SwDec_GetBits(pDecContainer,5);
CHECK_END_OF_STREAM(pDecContainer->VopDesc.QP);
if (pDecContainer->VopDesc.QP == 0) return(HANTRO_NOK);
pDecContainer->StrmStorage.QP = pDecContainer->VopDesc.QP;
pDecContainer->StrmStorage.prevQP = pDecContainer->VopDesc.QP;
pDecContainer->StrmStorage.vpQP = pDecContainer->VopDesc.QP;
tmp = SwDec_GetOneBit(pDecContainer); /* zero */
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
}
else /* extented PTYPE */
{
ufep = SwDec_GetBits(pDecContainer,3); /* upfep */
CHECK_END_OF_STREAM(ufep);
if (ufep == 1) /* read OPPTYPE 18bits */
{
pDecContainer->SvDesc.sourceFormat =
SwDec_GetBits(pDecContainer,3);
CHECK_END_OF_STREAM(pDecContainer->SvDesc.sourceFormat);
if ((pDecContainer->SvDesc.sourceFormat == 0) || /* forbidden */
(pDecContainer->SvDesc.sourceFormat == 7) ) /* reserved */
return (HANTRO_NOK);
/* custom PCF off(0)/on(1) */
/* CPCFC is not supported but implementation exists */
pDecContainer->SvDesc.customPictureClockFrequency =
SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(
pDecContainer->SvDesc.customPictureClockFrequency);
if (pDecContainer->SvDesc.customPictureClockFrequency)
return(HANTRO_NOK);
/* unrestricted motion vector off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* syntax-based arithmetic coding off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* advanced prediction off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* advanced intra coding off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* deblocking filter off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* slice structured off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* reference picture selection off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* independent segment decoding off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* alternative inter vlc mode off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* optional modified quantization mode off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* marker */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp == 0) return(HANTRO_NOK);
/* reserved, 3 zeros */
tmp = SwDec_GetBits(pDecContainer,3);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
}
else if(ufep > 1)
{
return(HANTRO_NOK);
}
/* mpptype is decoded anyway regardless of value of ufep */
/* picture coding type */
tmp = SwDec_GetBits(pDecContainer,3);
CHECK_END_OF_STREAM(tmp);
if(tmp>1 || (!tmp && !ufep)) return(HANTRO_NOK);
pDecContainer->VopDesc.vopCodingType = tmp;
/* reference picture resampling off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* reduced-resolution update off(0)/on(1) */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp) return(HANTRO_NOK);
/* rounding type */
pDecContainer->VopDesc.vopRoundingType =
SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(pDecContainer->VopDesc.vopRoundingType);
/* reserved (zero) bits */
tmp = SwDec_GetBits(pDecContainer, 2);
CHECK_END_OF_STREAM(tmp);
if(tmp) return(HANTRO_NOK);
/* marker */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if (tmp == 0) return(HANTRO_NOK);
/* Plus header decoding continues after plustype */
/* Picture header location of CPM */
tmp = SwDec_GetBits(pDecContainer, 1);
CHECK_END_OF_STREAM(tmp);
if(tmp) return(HANTRO_NOK);
if(ufep == 1)
{
/* Custom Picture Format */
/* Pixel aspect ratio */
tmp = SwDec_GetBits(pDecContainer, 4);
CHECK_END_OF_STREAM(tmp);
if(tmp>2) return(HANTRO_NOK);
/* Picture width indication */
tmp = SwDec_GetBits(pDecContainer, 9);
CHECK_END_OF_STREAM(tmp);
if(tmp>511) return(HANTRO_NOK); /* [0,...,511] */
pDecContainer->SvDesc.customWidth = ((tmp+1)*4);
/* marker */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if(tmp == 0) return(HANTRO_NOK);
/* Picture height indication */
tmp = SwDec_GetBits(pDecContainer, 9);
CHECK_END_OF_STREAM(tmp);
if( (tmp==0) || (tmp>288) ) return(HANTRO_NOK); /* [1,...,288] */
pDecContainer->SvDesc.customHeight = (tmp*4);
/* CFCFC is currently not supported
* (although implementation exists) */
if (pDecContainer->SvDesc.customPictureClockFrequency)
{
/* clock conversion code */
tmp = SwDec_GetOneBit(pDecContainer);
CHECK_END_OF_STREAM(tmp);
if(tmp == 0)
pDecContainer->SvDesc.clockConversionCode = 1000;
else
pDecContainer->SvDesc.clockConversionCode = 1001;
/* clock divisor */
tmp = SwDec_GetBits(pDecContainer, 7);
CHECK_END_OF_STREAM(tmp);
if (tmp == 0)
return (HANTRO_NOK);
else
pDecContainer->SvDesc.clockDivisor = tmp;
/* custom picture clock frequency */
pDecContainer->Hdrs.vopTimeIncrementResolution =
(1800000/(pDecContainer->SvDesc.clockDivisor *
pDecContainer->SvDesc.clockConversionCode));
}
}
/* CPCFC is currently not supported because we could not test it */
if (pDecContainer->SvDesc.customPictureClockFrequency)
{
/* Extended temporal reference */
tmp = SwDec_GetBits(pDecContainer,2);
CHECK_END_OF_STREAM(tmp);
pDecContainer->SvDesc.temporalReference |= (tmp<<8);
}
/* QP */
pDecContainer->VopDesc.QP = SwDec_GetBits(pDecContainer,5);
CHECK_END_OF_STREAM(pDecContainer->VopDesc.QP);
if (pDecContainer->VopDesc.QP == 0) return(HANTRO_NOK);
pDecContainer->StrmStorage.QP = pDecContainer->VopDesc.QP;
pDecContainer->StrmStorage.prevQP = pDecContainer->VopDesc.QP;
pDecContainer->StrmStorage.vpQP = pDecContainer->VopDesc.QP;
}
do {
tmp = SwDec_GetOneBit(pDecContainer); /* pei */
if (tmp == 1)
{
(void)SwDec_FlushBits(pDecContainer,8); /* psupp */
}
} while (tmp == 1);
CHECK_END_OF_STREAM(tmp);
/* update tics */
if (pDecContainer->SvDesc.customPictureClockFrequency)
{
pDecContainer->VopDesc.ticsFromPrev =
(pDecContainer->SvDesc.temporalReference + 1024 -
(pDecContainer->SvDesc.tics&0x3FF)) & 0x33FF;
pDecContainer->SvDesc.tics += pDecContainer->VopDesc.ticsFromPrev;
}
else
{
pDecContainer->VopDesc.ticsFromPrev =
(pDecContainer->SvDesc.temporalReference + 256 -
(pDecContainer->SvDesc.tics&0xFF)) & 0xFF;
pDecContainer->SvDesc.tics += pDecContainer->VopDesc.ticsFromPrev;
}
/* no resync marker in the beginning of first gob */
pDecContainer->StrmStorage.gobResyncFlag = 0;
pDecContainer->StrmStorage.vpMbNumber = 0;
pDecContainer->StrmStorage.vpFirstCodedMb = 0;
/* successful decoding -> set valid vop header */
pDecContainer->StrmStorage.validVopHeader = 1;
return (HANTRO_OK);
}
/*------------------------------------------------------------------------------
5.4 Function name: SwDec_CheckNextGobNumber
Purpose:
Input:
Pointer to decContainer_t structure
Output:
GOB number
0 if non-valid gob number found in stream
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -