commit
681b1da698
@ -42,6 +42,21 @@
|
|||||||
namespace WelsCommon {
|
namespace WelsCommon {
|
||||||
/*common use table*/
|
/*common use table*/
|
||||||
|
|
||||||
|
#define LEVEL_NUMBER 17
|
||||||
|
typedef struct TagLevelLimits {
|
||||||
|
uint8_t uiLevelIdc; // level idc
|
||||||
|
uint32_t uiMaxMBPS; // Max macroblock processing rate(MB/s)
|
||||||
|
uint32_t uiMaxFS; // Max frame sizea(MBs)
|
||||||
|
uint32_t uiMaxDPBMbs;// Max decoded picture buffer size(MBs)
|
||||||
|
uint32_t uiMaxBR; // Max video bit rate
|
||||||
|
uint32_t uiMaxCPB; // Max CPB size
|
||||||
|
int16_t iMinVmv; // Vertical MV component range upper bound
|
||||||
|
int16_t iMaxVmv; // Vertical MV component range lower bound
|
||||||
|
uint16_t uiMinCR; // Min compression ration
|
||||||
|
int16_t iMaxMvsPer2Mb; // Max number of motion vectors per two consecutive MBs
|
||||||
|
} SLevelLimits;
|
||||||
|
|
||||||
|
extern const SLevelLimits g_ksLevelLimits[LEVEL_NUMBER];
|
||||||
extern const uint8_t g_kuiMbCountScan4Idx[24];
|
extern const uint8_t g_kuiMbCountScan4Idx[24];
|
||||||
extern const uint8_t g_kuiCache30ScanIdx[16];
|
extern const uint8_t g_kuiCache30ScanIdx[16];
|
||||||
extern const uint8_t g_kuiCache48CountScan4Idx[24];
|
extern const uint8_t g_kuiCache48CountScan4Idx[24];
|
||||||
@ -53,38 +68,38 @@ extern const uint8_t g_kuiChromaQpTable[52];
|
|||||||
* NAL Unit Type (5 Bits)
|
* NAL Unit Type (5 Bits)
|
||||||
*/
|
*/
|
||||||
enum EWelsNalUnitType {
|
enum EWelsNalUnitType {
|
||||||
NAL_UNIT_UNSPEC_0 = 0,
|
NAL_UNIT_UNSPEC_0 = 0,
|
||||||
NAL_UNIT_CODED_SLICE = 1,
|
NAL_UNIT_CODED_SLICE = 1,
|
||||||
NAL_UNIT_CODED_SLICE_DPA = 2,
|
NAL_UNIT_CODED_SLICE_DPA = 2,
|
||||||
NAL_UNIT_CODED_SLICE_DPB = 3,
|
NAL_UNIT_CODED_SLICE_DPB = 3,
|
||||||
NAL_UNIT_CODED_SLICE_DPC = 4,
|
NAL_UNIT_CODED_SLICE_DPC = 4,
|
||||||
NAL_UNIT_CODED_SLICE_IDR = 5,
|
NAL_UNIT_CODED_SLICE_IDR = 5,
|
||||||
NAL_UNIT_SEI = 6,
|
NAL_UNIT_SEI = 6,
|
||||||
NAL_UNIT_SPS = 7,
|
NAL_UNIT_SPS = 7,
|
||||||
NAL_UNIT_PPS = 8,
|
NAL_UNIT_PPS = 8,
|
||||||
NAL_UNIT_AU_DELIMITER = 9,
|
NAL_UNIT_AU_DELIMITER = 9,
|
||||||
NAL_UNIT_END_OF_SEQ = 10,
|
NAL_UNIT_END_OF_SEQ = 10,
|
||||||
NAL_UNIT_END_OF_STR = 11,
|
NAL_UNIT_END_OF_STR = 11,
|
||||||
NAL_UNIT_FILLER_DATA = 12,
|
NAL_UNIT_FILLER_DATA = 12,
|
||||||
NAL_UNIT_SPS_EXT = 13,
|
NAL_UNIT_SPS_EXT = 13,
|
||||||
NAL_UNIT_PREFIX = 14,
|
NAL_UNIT_PREFIX = 14,
|
||||||
NAL_UNIT_SUBSET_SPS = 15,
|
NAL_UNIT_SUBSET_SPS = 15,
|
||||||
NAL_UNIT_RESV_16 = 16,
|
NAL_UNIT_RESV_16 = 16,
|
||||||
NAL_UNIT_RESV_17 = 17,
|
NAL_UNIT_RESV_17 = 17,
|
||||||
NAL_UNIT_RESV_18 = 18,
|
NAL_UNIT_RESV_18 = 18,
|
||||||
NAL_UNIT_AUX_CODED_SLICE = 19,
|
NAL_UNIT_AUX_CODED_SLICE = 19,
|
||||||
NAL_UNIT_CODED_SLICE_EXT = 20,
|
NAL_UNIT_CODED_SLICE_EXT = 20,
|
||||||
NAL_UNIT_RESV_21 = 21,
|
NAL_UNIT_RESV_21 = 21,
|
||||||
NAL_UNIT_RESV_22 = 22,
|
NAL_UNIT_RESV_22 = 22,
|
||||||
NAL_UNIT_RESV_23 = 23,
|
NAL_UNIT_RESV_23 = 23,
|
||||||
NAL_UNIT_UNSPEC_24 = 24,
|
NAL_UNIT_UNSPEC_24 = 24,
|
||||||
NAL_UNIT_UNSPEC_25 = 25,
|
NAL_UNIT_UNSPEC_25 = 25,
|
||||||
NAL_UNIT_UNSPEC_26 = 26,
|
NAL_UNIT_UNSPEC_26 = 26,
|
||||||
NAL_UNIT_UNSPEC_27 = 27,
|
NAL_UNIT_UNSPEC_27 = 27,
|
||||||
NAL_UNIT_UNSPEC_28 = 28,
|
NAL_UNIT_UNSPEC_28 = 28,
|
||||||
NAL_UNIT_UNSPEC_29 = 29,
|
NAL_UNIT_UNSPEC_29 = 29,
|
||||||
NAL_UNIT_UNSPEC_30 = 30,
|
NAL_UNIT_UNSPEC_30 = 30,
|
||||||
NAL_UNIT_UNSPEC_31 = 31
|
NAL_UNIT_UNSPEC_31 = 31
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,10 +107,10 @@ NAL_UNIT_UNSPEC_31 = 31
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
enum EWelsNalRefIdc {
|
enum EWelsNalRefIdc {
|
||||||
NRI_PRI_LOWEST = 0,
|
NRI_PRI_LOWEST = 0,
|
||||||
NRI_PRI_LOW = 1,
|
NRI_PRI_LOW = 1,
|
||||||
NRI_PRI_HIGH = 2,
|
NRI_PRI_HIGH = 2,
|
||||||
NRI_PRI_HIGHEST = 3
|
NRI_PRI_HIGHEST = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -103,9 +118,9 @@ NRI_PRI_HIGHEST = 3
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
enum EVclType {
|
enum EVclType {
|
||||||
NON_VCL = 0,
|
NON_VCL = 0,
|
||||||
VCL = 1,
|
VCL = 1,
|
||||||
NOT_APP = 2
|
NOT_APP = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -132,43 +147,43 @@ extern const EVclType g_keTypeMap[32][2];
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
enum EWelsSliceType {
|
enum EWelsSliceType {
|
||||||
P_SLICE = 0,
|
P_SLICE = 0,
|
||||||
B_SLICE = 1,
|
B_SLICE = 1,
|
||||||
I_SLICE = 2,
|
I_SLICE = 2,
|
||||||
SP_SLICE = 3,
|
SP_SLICE = 3,
|
||||||
SI_SLICE = 4,
|
SI_SLICE = 4,
|
||||||
UNKNOWN_SLICE = 5
|
UNKNOWN_SLICE = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
/* SSlice Types in scalable extension */ ;
|
/* SSlice Types in scalable extension */ ;
|
||||||
enum ESliceTypeExt {
|
enum ESliceTypeExt {
|
||||||
EP_SLICE = 0, // EP_SLICE: 0, 5
|
EP_SLICE = 0, // EP_SLICE: 0, 5
|
||||||
EB_SLICE = 1, // EB_SLICE: 1, 6
|
EB_SLICE = 1, // EB_SLICE: 1, 6
|
||||||
EI_SLICE = 2 // EI_SLICE: 2, 7
|
EI_SLICE = 2 // EI_SLICE: 2, 7
|
||||||
};
|
};
|
||||||
|
|
||||||
/* List Index */
|
/* List Index */
|
||||||
enum EListIndex {
|
enum EListIndex {
|
||||||
LIST_0 = 0,
|
LIST_0 = 0,
|
||||||
LIST_1 = 1,
|
LIST_1 = 1,
|
||||||
LIST_A = 2
|
LIST_A = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Motion Vector components */
|
/* Motion Vector components */
|
||||||
enum EMvComp {
|
enum EMvComp {
|
||||||
MV_X = 0,
|
MV_X = 0,
|
||||||
MV_Y = 1,
|
MV_Y = 1,
|
||||||
MV_A = 2
|
MV_A = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Chroma Components */
|
/* Chroma Components */
|
||||||
|
|
||||||
enum EChromaComp {
|
enum EChromaComp {
|
||||||
CHROMA_CB = 0,
|
CHROMA_CB = 0,
|
||||||
CHROMA_CR = 1,
|
CHROMA_CR = 1,
|
||||||
CHROMA_A = 2
|
CHROMA_A = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -177,13 +192,13 @@ CHROMA_A = 2
|
|||||||
* Memory Management Control Operation (MMCO) code
|
* Memory Management Control Operation (MMCO) code
|
||||||
*/
|
*/
|
||||||
enum EMmcoCode {
|
enum EMmcoCode {
|
||||||
MMCO_END = 0,
|
MMCO_END = 0,
|
||||||
MMCO_SHORT2UNUSED = 1,
|
MMCO_SHORT2UNUSED = 1,
|
||||||
MMCO_LONG2UNUSED = 2,
|
MMCO_LONG2UNUSED = 2,
|
||||||
MMCO_SHORT2LONG = 3,
|
MMCO_SHORT2LONG = 3,
|
||||||
MMCO_SET_MAX_LONG = 4,
|
MMCO_SET_MAX_LONG = 4,
|
||||||
MMCO_RESET = 5,
|
MMCO_RESET = 5,
|
||||||
MMCO_LONG = 6
|
MMCO_LONG = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////intra16x16 Luma
|
/////////intra16x16 Luma
|
||||||
|
@ -149,5 +149,29 @@ ALIGNED_DECLARE (const uint16_t, g_kuiDequantCoeff[52][8], 16) = {
|
|||||||
/*50*/{ 3328, 4096, 3328, 4096, 4096, 5120, 4096, 5120 }, /*51*/{ 3584, 4608, 3584, 4608, 4608, 5888, 4608, 5888 },
|
/*50*/{ 3328, 4096, 3328, 4096, 4096, 5120, 4096, 5120 }, /*51*/{ 3584, 4608, 3584, 4608, 4608, 5888, 4608, 5888 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// table A-1 - Level limits
|
||||||
|
const SLevelLimits g_ksLevelLimits[LEVEL_NUMBER] = {
|
||||||
|
{10, 1485, 99, 396, 64, 175, -256, 255, 2, 0x7fff}, /* level 1 */
|
||||||
|
{9, 1485, 99, 396, 128, 350, -256, 255, 2, 0x7fff}, /* level 1.b */
|
||||||
|
{11, 3000, 396, 900, 192, 500, -512, 511, 2, 0x7fff}, /* level 1.1 */
|
||||||
|
{12, 6000, 396, 2376, 384, 1000, -512, 511, 2, 0x7fff}, /* level 1.2 */
|
||||||
|
{13, 11880, 396, 2376, 768, 2000, -512, 511, 2, 0x7fff}, /* level 1.3 */
|
||||||
|
|
||||||
|
{20, 11880, 396, 2376, 2000, 2000, -512, 511, 2, 0x7fff}, /* level 2 */
|
||||||
|
{21, 19800, 792, 4752, 4000, 4000, -1024, 1023, 2, 0x7fff}, /* level 2.1 */
|
||||||
|
{22, 20250, 1620, 8100, 4000, 4000, -1024, 1023, 2, 0x7fff}, /* level 2.2 */
|
||||||
|
|
||||||
|
{30, 40500, 1620, 8100, 10000, 10000, -1024, 1023, 2, 32 }, /* level 3 */
|
||||||
|
{31, 108000, 3600, 18000, 14000, 14000, -2048, 2047, 4, 16}, /* level 3.1 */
|
||||||
|
{32, 216000, 5120, 20480, 20000, 20000, -2048, 2047, 4, 16}, /* level 3.2 */
|
||||||
|
|
||||||
|
{40, 245760, 8192, 32768, 20000, 25000, -2048, 2047, 4, 16}, /* level 4 */
|
||||||
|
{41, 245760, 8192, 32768, 50000, 62500, -2048, 2047, 2, 16}, /* level 4.1 */
|
||||||
|
{42, 522240, 8704, 34816, 50000, 62500, -2048, 2047, 2, 16}, /* level 4.2 */
|
||||||
|
|
||||||
|
{50, 589824, 22080, 110400, 135000, 135000, -2048, 2047, 2, 16}, /* level 5 */
|
||||||
|
{51, 983040, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16}, /* level 5.1 */
|
||||||
|
{52, 2073600, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16} /* level 5.2 */
|
||||||
|
};
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
}
|
||||||
|
@ -39,67 +39,56 @@
|
|||||||
|
|
||||||
namespace WelsDec {
|
namespace WelsDec {
|
||||||
|
|
||||||
typedef struct TagLevelLimits {
|
|
||||||
int32_t iMaxMBPS; // Max macroblock processing rate(MB/s)
|
|
||||||
int32_t iMaxFS; // Max frame sizea(MBs)
|
|
||||||
int32_t iMaxDPBMbs;// Max decoded picture buffer size(MBs)
|
|
||||||
int32_t iMaxBR; // Max video bit rate
|
|
||||||
int32_t iMaxCPB; // Max CPB size
|
|
||||||
int16_t iMinVmv; // Vertical MV component range upper bound
|
|
||||||
int16_t iMaxVmv; // Vertical MV component range lower bound
|
|
||||||
int16_t iMinCR; // Min compression ration
|
|
||||||
int16_t iMaxMvsPer2Mb; // Max number of motion vectors per two consecutive MBs
|
|
||||||
} SLevelLimits;
|
|
||||||
|
|
||||||
/* Sequence Parameter Set, refer to Page 57 in JVT X201wcm */
|
/* Sequence Parameter Set, refer to Page 57 in JVT X201wcm */
|
||||||
typedef struct TagSps {
|
typedef struct TagSps {
|
||||||
int32_t iSpsId;
|
int32_t iSpsId;
|
||||||
uint32_t iMbWidth;
|
uint32_t iMbWidth;
|
||||||
uint32_t iMbHeight;
|
uint32_t iMbHeight;
|
||||||
uint32_t uiTotalMbCount; //used in decode_slice_data()
|
uint32_t uiTotalMbCount; //used in decode_slice_data()
|
||||||
|
|
||||||
uint32_t uiLog2MaxFrameNum;
|
uint32_t uiLog2MaxFrameNum;
|
||||||
uint32_t uiPocType;
|
uint32_t uiPocType;
|
||||||
/* POC type 0 */
|
/* POC type 0 */
|
||||||
int32_t iLog2MaxPocLsb;
|
int32_t iLog2MaxPocLsb;
|
||||||
/* POC type 1 */
|
/* POC type 1 */
|
||||||
int32_t iOffsetForNonRefPic;
|
int32_t iOffsetForNonRefPic;
|
||||||
|
|
||||||
int32_t iOffsetForTopToBottomField;
|
int32_t iOffsetForTopToBottomField;
|
||||||
int32_t iNumRefFramesInPocCycle;
|
int32_t iNumRefFramesInPocCycle;
|
||||||
int8_t iOffsetForRefFrame[256];
|
int8_t iOffsetForRefFrame[256];
|
||||||
int32_t iNumRefFrames;
|
int32_t iNumRefFrames;
|
||||||
|
|
||||||
SPosOffset sFrameCrop;
|
SPosOffset sFrameCrop;
|
||||||
|
|
||||||
ProfileIdc uiProfileIdc;
|
ProfileIdc uiProfileIdc;
|
||||||
uint8_t uiLevelIdc;
|
uint8_t uiLevelIdc;
|
||||||
uint8_t uiChromaFormatIdc;
|
uint8_t uiChromaFormatIdc;
|
||||||
uint8_t uiChromaArrayType;
|
uint8_t uiChromaArrayType;
|
||||||
|
|
||||||
uint8_t uiBitDepthLuma;
|
uint8_t uiBitDepthLuma;
|
||||||
uint8_t uiBitDepthChroma;
|
uint8_t uiBitDepthChroma;
|
||||||
/* TO BE CONTINUE: POC type 1 */
|
/* TO BE CONTINUE: POC type 1 */
|
||||||
bool bDeltaPicOrderAlwaysZeroFlag;
|
bool bDeltaPicOrderAlwaysZeroFlag;
|
||||||
bool bGapsInFrameNumValueAllowedFlag;
|
bool bGapsInFrameNumValueAllowedFlag;
|
||||||
|
|
||||||
bool bFrameMbsOnlyFlag;
|
bool bFrameMbsOnlyFlag;
|
||||||
bool bMbaffFlag; // MB Adapative Frame Field
|
bool bMbaffFlag; // MB Adapative Frame Field
|
||||||
bool bDirect8x8InferenceFlag;
|
bool bDirect8x8InferenceFlag;
|
||||||
bool bFrameCroppingFlag;
|
bool bFrameCroppingFlag;
|
||||||
|
|
||||||
bool bVuiParamPresentFlag;
|
bool bVuiParamPresentFlag;
|
||||||
// bool bTimingInfoPresentFlag;
|
// bool bTimingInfoPresentFlag;
|
||||||
// bool bFixedFrameRateFlag;
|
// bool bFixedFrameRateFlag;
|
||||||
bool bConstraintSet0Flag;
|
bool bConstraintSet0Flag;
|
||||||
bool bConstraintSet1Flag;
|
bool bConstraintSet1Flag;
|
||||||
bool bConstraintSet2Flag;
|
bool bConstraintSet2Flag;
|
||||||
bool bConstraintSet3Flag;
|
bool bConstraintSet3Flag;
|
||||||
bool bSeparateColorPlaneFlag;
|
bool bSeparateColorPlaneFlag;
|
||||||
bool bQpPrimeYZeroTransfBypassFlag;
|
bool bQpPrimeYZeroTransfBypassFlag;
|
||||||
bool bSeqScalingMatrixPresentFlag;
|
bool bSeqScalingMatrixPresentFlag;
|
||||||
bool bSeqScalingListPresentFlag[12];
|
bool bSeqScalingListPresentFlag[12];
|
||||||
const SLevelLimits* pSLevelLimits;
|
const SLevelLimits* pSLevelLimits;
|
||||||
} SSps, *PSps;
|
} SSps, *PSps;
|
||||||
|
|
||||||
|
|
||||||
@ -117,63 +106,63 @@ const SLevelLimits* pSLevelLimits;
|
|||||||
|
|
||||||
/* Sequence Parameter Set extension syntax, refer to Page 391 in JVT X201wcm */
|
/* Sequence Parameter Set extension syntax, refer to Page 391 in JVT X201wcm */
|
||||||
typedef struct TagSpsSvcExt {
|
typedef struct TagSpsSvcExt {
|
||||||
SPosOffset sSeqScaledRefLayer;
|
SPosOffset sSeqScaledRefLayer;
|
||||||
|
|
||||||
uint8_t uiExtendedSpatialScalability; // ESS
|
uint8_t uiExtendedSpatialScalability; // ESS
|
||||||
uint8_t uiChromaPhaseXPlus1Flag;
|
uint8_t uiChromaPhaseXPlus1Flag;
|
||||||
uint8_t uiChromaPhaseYPlus1;
|
uint8_t uiChromaPhaseYPlus1;
|
||||||
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
|
uint8_t uiSeqRefLayerChromaPhaseXPlus1Flag;
|
||||||
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
|
uint8_t uiSeqRefLayerChromaPhaseYPlus1;
|
||||||
bool bInterLayerDeblockingFilterCtrlPresentFlag;
|
bool bInterLayerDeblockingFilterCtrlPresentFlag;
|
||||||
bool bSeqTCoeffLevelPredFlag;
|
bool bSeqTCoeffLevelPredFlag;
|
||||||
bool bAdaptiveTCoeffLevelPredFlag;
|
bool bAdaptiveTCoeffLevelPredFlag;
|
||||||
bool bSliceHeaderRestrictionFlag;
|
bool bSliceHeaderRestrictionFlag;
|
||||||
} SSpsSvcExt, *PSpsSvcExt;
|
} SSpsSvcExt, *PSpsSvcExt;
|
||||||
|
|
||||||
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
|
/* Subset sequence parameter set syntax, refer to Page 391 in JVT X201wcm */
|
||||||
typedef struct TagSubsetSps {
|
typedef struct TagSubsetSps {
|
||||||
SSps sSps;
|
SSps sSps;
|
||||||
SSpsSvcExt sSpsSvcExt;
|
SSpsSvcExt sSpsSvcExt;
|
||||||
bool bSvcVuiParamPresentFlag;
|
bool bSvcVuiParamPresentFlag;
|
||||||
bool bAdditionalExtension2Flag;
|
bool bAdditionalExtension2Flag;
|
||||||
bool bAdditionalExtension2DataFlag;
|
bool bAdditionalExtension2DataFlag;
|
||||||
} SSubsetSps, *PSubsetSps;
|
} SSubsetSps, *PSubsetSps;
|
||||||
|
|
||||||
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
|
/* Picture parameter set syntax, refer to Page 59 in JVT X201wcm */
|
||||||
typedef struct TagPps {
|
typedef struct TagPps {
|
||||||
int32_t iSpsId;
|
int32_t iSpsId;
|
||||||
int32_t iPpsId;
|
int32_t iPpsId;
|
||||||
|
|
||||||
uint32_t uiNumSliceGroups;
|
uint32_t uiNumSliceGroups;
|
||||||
uint32_t uiSliceGroupMapType;
|
uint32_t uiSliceGroupMapType;
|
||||||
/* slice_group_map_type = 0 */
|
/* slice_group_map_type = 0 */
|
||||||
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
|
uint32_t uiRunLength[MAX_SLICEGROUP_IDS];
|
||||||
/* slice_group_map_type = 2 */
|
/* slice_group_map_type = 2 */
|
||||||
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
|
uint32_t uiTopLeft[MAX_SLICEGROUP_IDS];
|
||||||
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
|
uint32_t uiBottomRight[MAX_SLICEGROUP_IDS];
|
||||||
/* slice_group_map_type = 3, 4 or 5 */
|
/* slice_group_map_type = 3, 4 or 5 */
|
||||||
uint32_t uiSliceGroupChangeRate;
|
uint32_t uiSliceGroupChangeRate;
|
||||||
/* slice_group_map_type = 6 */
|
/* slice_group_map_type = 6 */
|
||||||
uint32_t uiPicSizeInMapUnits;
|
uint32_t uiPicSizeInMapUnits;
|
||||||
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
|
uint32_t uiSliceGroupId[MAX_SLICEGROUP_IDS];
|
||||||
|
|
||||||
uint32_t uiNumRefIdxL0Active;
|
uint32_t uiNumRefIdxL0Active;
|
||||||
uint32_t uiNumRefIdxL1Active;
|
uint32_t uiNumRefIdxL1Active;
|
||||||
|
|
||||||
int32_t iPicInitQp;
|
int32_t iPicInitQp;
|
||||||
int32_t iPicInitQs;
|
int32_t iPicInitQs;
|
||||||
int32_t iChromaQpIndexOffset;
|
int32_t iChromaQpIndexOffset;
|
||||||
|
|
||||||
bool bEntropyCodingModeFlag;
|
bool bEntropyCodingModeFlag;
|
||||||
bool bPicOrderPresentFlag;
|
bool bPicOrderPresentFlag;
|
||||||
/* slice_group_map_type = 3, 4 or 5 */
|
/* slice_group_map_type = 3, 4 or 5 */
|
||||||
bool bSliceGroupChangeDirectionFlag;
|
bool bSliceGroupChangeDirectionFlag;
|
||||||
bool bDeblockingFilterControlPresentFlag;
|
bool bDeblockingFilterControlPresentFlag;
|
||||||
|
|
||||||
bool bConstainedIntraPredFlag;
|
bool bConstainedIntraPredFlag;
|
||||||
bool bRedundantPicCntPresentFlag;
|
bool bRedundantPicCntPresentFlag;
|
||||||
bool bWeightedPredFlag;
|
bool bWeightedPredFlag;
|
||||||
uint8_t uiWeightedBipredIdc;
|
uint8_t uiWeightedBipredIdc;
|
||||||
|
|
||||||
} SPps, *PPps;
|
} SPps, *PPps;
|
||||||
|
|
||||||
|
@ -688,64 +688,43 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// table A-1 - Level limits
|
|
||||||
static const SLevelLimits g_kSLevelLimits[17] = {
|
|
||||||
{1485, 99, 396, 64, 175, -256, 255, 2, 0x7fff}, /* level 1 */
|
|
||||||
{1485, 99, 396, 128, 350, -256, 255, 2, 0x7fff}, /* level 1.b */
|
|
||||||
{3000, 396, 900, 192, 500, -512, 511, 2, 0x7fff}, /* level 1.1 */
|
|
||||||
{6000, 396, 2376, 384, 1000, -512, 511, 2, 0x7fff}, /* level 1.2 */
|
|
||||||
{11880, 396, 2376, 768, 2000, -512, 511, 2, 0x7fff}, /* level 1.3 */
|
|
||||||
{11880, 396, 2376, 2000, 2000, -512, 511, 2, 0x7fff}, /* level 2 */
|
|
||||||
{19800, 792, 4752, 4000, 4000, -1024, 1023, 2, 0x7fff}, /* level 2.1 */
|
|
||||||
{20250, 1620, 8100, 4000, 4000, -1024, 1023, 2, 0x7fff}, /* level 2.2 */
|
|
||||||
{40500, 1620, 8100, 10000, 10000, -1024, 1023, 2, 32 }, /* level 3 */
|
|
||||||
{108000, 3600, 18000, 14000, 14000, -2048, 2047, 4, 16}, /* level 3.1 */
|
|
||||||
{216000, 5120, 20480, 20000, 20000, -2048, 2047, 4, 16}, /* level 3.2 */
|
|
||||||
{245760, 8192, 32768, 20000, 25000, -2048, 2047, 4, 16}, /* level 4 */
|
|
||||||
{245760, 8192, 32768, 50000, 62500, -2048, 2047, 2, 16}, /* level 4.1 */
|
|
||||||
{522240, 8704, 34816, 50000, 62500, -2048, 2047, 2, 16}, /* level 4.2 */
|
|
||||||
{589824, 22080, 110400, 135000, 135000, -2048, 2047, 2, 16}, /* level 5 */
|
|
||||||
{983040, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16}, /* level 5.1 */
|
|
||||||
{2073600, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16} /* level 5.2 */
|
|
||||||
};
|
|
||||||
|
|
||||||
const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) {
|
const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) {
|
||||||
switch (iLevelIdx) {
|
switch (iLevelIdx) {
|
||||||
case 10:
|
case 10:
|
||||||
return &g_kSLevelLimits[0];
|
return &g_ksLevelLimits[0];
|
||||||
case 11:
|
case 11:
|
||||||
if (bConstraint3)
|
if (bConstraint3)
|
||||||
return &g_kSLevelLimits[1];
|
return &g_ksLevelLimits[1];
|
||||||
else
|
else
|
||||||
return &g_kSLevelLimits[2];
|
return &g_ksLevelLimits[2];
|
||||||
case 12:
|
case 12:
|
||||||
return &g_kSLevelLimits[3];
|
return &g_ksLevelLimits[3];
|
||||||
case 13:
|
case 13:
|
||||||
return &g_kSLevelLimits[4];
|
return &g_ksLevelLimits[4];
|
||||||
case 20:
|
case 20:
|
||||||
return &g_kSLevelLimits[5];
|
return &g_ksLevelLimits[5];
|
||||||
case 21:
|
case 21:
|
||||||
return &g_kSLevelLimits[6];
|
return &g_ksLevelLimits[6];
|
||||||
case 22:
|
case 22:
|
||||||
return &g_kSLevelLimits[7];
|
return &g_ksLevelLimits[7];
|
||||||
case 30:
|
case 30:
|
||||||
return &g_kSLevelLimits[8];
|
return &g_ksLevelLimits[8];
|
||||||
case 31:
|
case 31:
|
||||||
return &g_kSLevelLimits[9];
|
return &g_ksLevelLimits[9];
|
||||||
case 32:
|
case 32:
|
||||||
return &g_kSLevelLimits[10];
|
return &g_ksLevelLimits[10];
|
||||||
case 40:
|
case 40:
|
||||||
return &g_kSLevelLimits[11];
|
return &g_ksLevelLimits[11];
|
||||||
case 41:
|
case 41:
|
||||||
return &g_kSLevelLimits[12];
|
return &g_ksLevelLimits[12];
|
||||||
case 42:
|
case 42:
|
||||||
return &g_kSLevelLimits[13];
|
return &g_ksLevelLimits[13];
|
||||||
case 50:
|
case 50:
|
||||||
return &g_kSLevelLimits[14];
|
return &g_ksLevelLimits[14];
|
||||||
case 51:
|
case 51:
|
||||||
return &g_kSLevelLimits[15];
|
return &g_ksLevelLimits[15];
|
||||||
case 52:
|
case 52:
|
||||||
return &g_kSLevelLimits[16];
|
return &g_ksLevelLimits[16];
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -923,7 +902,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
|||||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_width_in_mbs(%d) exceeds the maximum allowed!\n", pSps->iMbWidth);
|
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_width_in_mbs(%d) exceeds the maximum allowed!\n", pSps->iMbWidth);
|
||||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
|
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
|
||||||
}
|
}
|
||||||
if (((uint64_t)pSps->iMbWidth * (uint64_t)pSps->iMbWidth) > (uint64_t) (8 * pSLevelLimits->iMaxFS)) {
|
if (((uint64_t)pSps->iMbWidth * (uint64_t)pSps->iMbWidth) > (uint64_t) (8 * pSLevelLimits->uiMaxFS)) {
|
||||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!\n");
|
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!\n");
|
||||||
}
|
}
|
||||||
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_height_in_map_units_minus1
|
WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_height_in_map_units_minus1
|
||||||
@ -932,18 +911,18 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
|
|||||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_height_in_mbs(%d) exceeds the maximum allowed!\n", pSps->iMbHeight);
|
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "pic_height_in_mbs(%d) exceeds the maximum allowed!\n", pSps->iMbHeight);
|
||||||
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
|
return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
|
||||||
}
|
}
|
||||||
if (((uint64_t)pSps->iMbHeight * (uint64_t)pSps->iMbHeight) > (uint64_t) (8 * pSLevelLimits->iMaxFS)) {
|
if (((uint64_t)pSps->iMbHeight * (uint64_t)pSps->iMbHeight) > (uint64_t) (8 * pSLevelLimits->uiMaxFS)) {
|
||||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the pic_height_in_mbs exceeds the level limits!\n");
|
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the pic_height_in_mbs exceeds the level limits!\n");
|
||||||
}
|
}
|
||||||
uint32_t uiTmp32 = pSps->iMbWidth * pSps->iMbHeight;
|
uint32_t uiTmp32 = pSps->iMbWidth * pSps->iMbHeight;
|
||||||
if (uiTmp32 > (uint32_t)pSLevelLimits->iMaxFS) {
|
if (uiTmp32 > (uint32_t)pSLevelLimits->uiMaxFS) {
|
||||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the total count of mb exceeds the level limits!\n");
|
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, " the total count of mb exceeds the level limits!\n");
|
||||||
}
|
}
|
||||||
pSps->uiTotalMbCount = uiTmp32;
|
pSps->uiTotalMbCount = uiTmp32;
|
||||||
WELS_CHECK_SE_UPPER_ERROR (pSps->iNumRefFrames, SPS_MAX_NUM_REF_FRAMES_MAX, "max_num_ref_frames",
|
WELS_CHECK_SE_UPPER_ERROR (pSps->iNumRefFrames, SPS_MAX_NUM_REF_FRAMES_MAX, "max_num_ref_frames",
|
||||||
GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_NUM_REF_FRAMES));
|
GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_NUM_REF_FRAMES));
|
||||||
// here we check max_num_ref_frames
|
// here we check max_num_ref_frames
|
||||||
uint32_t uiMaxDpbMbs = pSLevelLimits->iMaxDPBMbs;
|
uint32_t uiMaxDpbMbs = pSLevelLimits->uiMaxDPBMbs;
|
||||||
uint32_t uiMaxDpbFrames = uiMaxDpbMbs / pSps->uiTotalMbCount;
|
uint32_t uiMaxDpbFrames = uiMaxDpbMbs / pSps->uiTotalMbCount;
|
||||||
if (uiMaxDpbFrames > SPS_MAX_NUM_REF_FRAMES_MAX)
|
if (uiMaxDpbFrames > SPS_MAX_NUM_REF_FRAMES_MAX)
|
||||||
uiMaxDpbFrames = SPS_MAX_NUM_REF_FRAMES_MAX;
|
uiMaxDpbFrames = SPS_MAX_NUM_REF_FRAMES_MAX;
|
||||||
|
@ -41,50 +41,21 @@
|
|||||||
#include "au_set.h"
|
#include "au_set.h"
|
||||||
#include "svc_enc_golomb.h"
|
#include "svc_enc_golomb.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
|
#include "wels_common_defs.h"
|
||||||
|
|
||||||
|
using namespace WelsCommon;
|
||||||
|
|
||||||
namespace WelsEnc {
|
namespace WelsEnc {
|
||||||
|
|
||||||
|
static inline int32_t WelsCheckLevelLimitation (const SWelsSPS* kpSps, const SLevelLimits* kpLevelLimit,
|
||||||
#define LEVEL_NUMBER 16
|
|
||||||
|
|
||||||
typedef struct TagLevelLimit {
|
|
||||||
uint8_t iLevelIdc;
|
|
||||||
uint32_t uiMaxMbPS; // Max MBs processing speed
|
|
||||||
uint32_t uiMaxFS; // Max Frame size
|
|
||||||
uint32_t uiMaxDPBMB; //Max DPB MB Size
|
|
||||||
uint32_t uiMaxBR; //Max Bitrate
|
|
||||||
} SLevelLimit;
|
|
||||||
|
|
||||||
const SLevelLimit g_ksLevelLimit[LEVEL_NUMBER] = {
|
|
||||||
{ 10, 1485, 99, 396, 64 }, //10
|
|
||||||
{ 9, 1485, 99, 396, 128 }, //9 (1b)
|
|
||||||
{ 11, 3000, 396, 900, 192 }, //11
|
|
||||||
{ 12, 6000, 396, 2376, 384 }, //12
|
|
||||||
{ 13, 11880, 396, 2376, 768 }, //13
|
|
||||||
|
|
||||||
{ 20, 11880, 396, 2376, 2000 }, //20
|
|
||||||
{ 21, 19800, 792, 4752, 4000 }, //21
|
|
||||||
{ 22, 20250, 1620, 8100, 4000 }, //22
|
|
||||||
|
|
||||||
{ 30, 40500, 1620, 8100, 10000 }, //30
|
|
||||||
{ 31, 108000, 3600, 18000, 14000 }, //31
|
|
||||||
{ 32, 216000, 5120, 20480, 20000 }, //32
|
|
||||||
|
|
||||||
{ 40, 245760, 8192, 32768, 20000 }, //40
|
|
||||||
{ 41, 245760, 8192, 32768, 50000 }, //41
|
|
||||||
{ 42, 491520, 8192, 34816, 50000 }, //42
|
|
||||||
|
|
||||||
{ 50, 589824, 22080, 110400, 135000 }, //50
|
|
||||||
{ 51, 983040, 36864, 184320, 240000 } //51
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline int32_t WelsCheckLevelLimitation (const SWelsSPS* kpSps, const SLevelLimit* kpLevelLimit,
|
|
||||||
float fFrameRate, int32_t iTargetBitRate) {
|
float fFrameRate, int32_t iTargetBitRate) {
|
||||||
uint32_t uiPicWidthInMBs = kpSps->iMbWidth;
|
uint32_t uiPicWidthInMBs = kpSps->iMbWidth;
|
||||||
uint32_t uiPicHeightInMBs = kpSps->iMbHeight;
|
uint32_t uiPicHeightInMBs = kpSps->iMbHeight;
|
||||||
uint32_t uiPicInMBs = uiPicWidthInMBs * uiPicHeightInMBs;
|
uint32_t uiPicInMBs = uiPicWidthInMBs * uiPicHeightInMBs;
|
||||||
uint32_t uiNumRefFrames = kpSps->iNumRefFrames;
|
uint32_t uiNumRefFrames = kpSps->iNumRefFrames;
|
||||||
|
|
||||||
if (kpLevelLimit->uiMaxMbPS < (uint32_t) (uiPicInMBs * fFrameRate))
|
if (kpLevelLimit->uiMaxMBPS < (uint32_t) (uiPicInMBs * fFrameRate))
|
||||||
return 0;
|
return 0;
|
||||||
if (kpLevelLimit->uiMaxFS < uiPicInMBs)
|
if (kpLevelLimit->uiMaxFS < uiPicInMBs)
|
||||||
return 0;
|
return 0;
|
||||||
@ -92,7 +63,7 @@ static inline int32_t WelsCheckLevelLimitation (const SWelsSPS* kpSps, const SLe
|
|||||||
return 0;
|
return 0;
|
||||||
if ((kpLevelLimit->uiMaxFS << 3) < (uiPicHeightInMBs * uiPicHeightInMBs))
|
if ((kpLevelLimit->uiMaxFS << 3) < (uiPicHeightInMBs * uiPicHeightInMBs))
|
||||||
return 0;
|
return 0;
|
||||||
if (kpLevelLimit->uiMaxDPBMB < uiNumRefFrames * uiPicInMBs)
|
if (kpLevelLimit->uiMaxDPBMbs < uiNumRefFrames * uiPicInMBs)
|
||||||
return 0;
|
return 0;
|
||||||
if (iTargetBitRate
|
if (iTargetBitRate
|
||||||
&& ((int32_t) kpLevelLimit->uiMaxBR * 1200) < iTargetBitRate) //RC enabled, considering bitrate constraint
|
&& ((int32_t) kpLevelLimit->uiMaxBR * 1200) < iTargetBitRate) //RC enabled, considering bitrate constraint
|
||||||
@ -114,7 +85,7 @@ int32_t WelsCheckRefFrameLimitation (SLogContext* pLogCtx, SWelsSvcCodingParam*
|
|||||||
pSpatialLayer->uiLevelIdc = LEVEL_5_0;
|
pSpatialLayer->uiLevelIdc = LEVEL_5_0;
|
||||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "change level to level5.0\n");
|
WelsLog (pLogCtx, WELS_LOG_WARNING, "change level to level5.0\n");
|
||||||
}
|
}
|
||||||
iRefFrame = g_ksLevelLimit[pSpatialLayer->uiLevelIdc - 1].uiMaxDPBMB / uiPicInMBs;
|
iRefFrame = g_ksLevelLimits[pSpatialLayer->uiLevelIdc - 1].uiMaxDPBMbs / uiPicInMBs;
|
||||||
if (iRefFrame < pParam->iMaxNumRefFrame)
|
if (iRefFrame < pParam->iMaxNumRefFrame)
|
||||||
pParam->iMaxNumRefFrame = iRefFrame;
|
pParam->iMaxNumRefFrame = iRefFrame;
|
||||||
if (pParam->iMaxNumRefFrame < 1) {
|
if (pParam->iMaxNumRefFrame < 1) {
|
||||||
@ -129,8 +100,8 @@ int32_t WelsCheckRefFrameLimitation (SLogContext* pLogCtx, SWelsSvcCodingParam*
|
|||||||
static inline int32_t WelsGetLevelIdc (const SWelsSPS* kpSps, float fFrameRate, int32_t iTargetBitRate) {
|
static inline int32_t WelsGetLevelIdc (const SWelsSPS* kpSps, float fFrameRate, int32_t iTargetBitRate) {
|
||||||
int32_t iOrder;
|
int32_t iOrder;
|
||||||
for (iOrder = 0; iOrder < LEVEL_NUMBER; iOrder++) {
|
for (iOrder = 0; iOrder < LEVEL_NUMBER; iOrder++) {
|
||||||
if (WelsCheckLevelLimitation (kpSps, & (g_ksLevelLimit[iOrder]), fFrameRate, iTargetBitRate)) {
|
if (WelsCheckLevelLimitation (kpSps, & (g_ksLevelLimits[iOrder]), fFrameRate, iTargetBitRate)) {
|
||||||
return (int32_t) (g_ksLevelLimit[iOrder].iLevelIdc);
|
return (int32_t) (g_ksLevelLimits[iOrder].uiLevelIdc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 51; //final decision: select the biggest level
|
return 51; //final decision: select the biggest level
|
||||||
|
Loading…
x
Reference in New Issue
Block a user