| 836 | } |
| 837 | |
| 838 | bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { |
| 839 | for (int i = 0; i < MAX_LAYER_NUM; i++) { |
| 840 | if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == pSps) |
| 841 | return true; |
| 842 | } |
| 843 | // Pre-active, will be used soon |
| 844 | if (bUseSubsetFlag) { |
| 845 | if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSubspsAvailFlags[pSps->iSpsId]) { |
| 846 | if (pCtx->iTotalNumMbRec > 0) { |
| 847 | return true; |
| 848 | } |
| 849 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { |
| 850 | int i = 0, iNum = (int32_t) pCtx->pAccessUnitList->uiAvailUnitsNum; |
| 851 | while (i < iNum) { |
| 852 | PNalUnit pNalUnit = pCtx->pAccessUnitList->pNalUnitsList[i]; |
| 853 | if (pNalUnit->sNalData.sVclNal.bSliceHeaderExtFlag) { //ext data |
| 854 | PSps pNextUsedSps = pNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps; |
| 855 | if (pNextUsedSps->iSpsId == pSps->iSpsId) |
| 856 | return true; |
| 857 | } |
| 858 | ++i; |
| 859 | } |
| 860 | } |
| 861 | } |
| 862 | } else { |
| 863 | if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSpsAvailFlags[pSps->iSpsId]) { |
| 864 | if (pCtx->iTotalNumMbRec > 0) { |
| 865 | return true; |
| 866 | } |
| 867 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { |
| 868 | int i = 0, iNum = (int32_t) pCtx->pAccessUnitList->uiAvailUnitsNum; |
| 869 | while (i < iNum) { |
| 870 | PNalUnit pNalUnit = pCtx->pAccessUnitList->pNalUnitsList[i]; |
| 871 | if (!pNalUnit->sNalData.sVclNal.bSliceHeaderExtFlag) { //non-ext data |
| 872 | PSps pNextUsedSps = pNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps; |
| 873 | if (pNextUsedSps->iSpsId == pSps->iSpsId) |
| 874 | return true; |
| 875 | } |
| 876 | ++i; |
| 877 | } |
| 878 | } |
| 879 | } |
| 880 | } |
| 881 | return false; |
| 882 | } |
| 883 | |
| 884 | #define SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX 12 |
| 885 | #define SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX 12 |