| 1894 | } |
| 1895 | |
| 1896 | ELevelIdc CheckLevelLimitation (SEncParamExt* pParam) { |
| 1897 | int32_t iOrder = 0; |
| 1898 | ELevelIdc iLevel = LEVEL_5_2; |
| 1899 | const SLevelLimits* kpLevelLimit = g_ksLevelLimits; |
| 1900 | uint32_t uiPicWidthInMBs = (pParam->sSpatialLayers[0].iVideoWidth + 15) >> 4; |
| 1901 | uint32_t uiPicHeightInMBs = (pParam->sSpatialLayers[0].iVideoHeight + 15) >> 4; |
| 1902 | uint32_t uiPicInMBs = uiPicWidthInMBs * uiPicHeightInMBs; |
| 1903 | uint32_t uiNumRefFrames = pParam->iNumRefFrame; |
| 1904 | for (iOrder = 0; iOrder < LEVEL_NUMBER; iOrder++, kpLevelLimit++) { |
| 1905 | |
| 1906 | |
| 1907 | if (kpLevelLimit->uiMaxMBPS < (uint32_t) (uiPicInMBs * pParam->fMaxFrameRate)) |
| 1908 | continue; |
| 1909 | |
| 1910 | if (kpLevelLimit->uiMaxFS < uiPicInMBs) |
| 1911 | continue; |
| 1912 | |
| 1913 | if ((kpLevelLimit->uiMaxFS << 3) < (uiPicWidthInMBs * uiPicWidthInMBs)) |
| 1914 | continue; |
| 1915 | if ((kpLevelLimit->uiMaxFS << 3) < (uiPicHeightInMBs * uiPicHeightInMBs)) |
| 1916 | continue; |
| 1917 | if (kpLevelLimit->uiMaxDPBMbs < uiNumRefFrames * uiPicInMBs) |
| 1918 | continue; |
| 1919 | |
| 1920 | if ((pParam->sSpatialLayers[0].iSpatialBitrate != UNSPECIFIED_BIT_RATE) |
| 1921 | && ((int32_t) kpLevelLimit->uiMaxBR * 1200) < |
| 1922 | pParam->sSpatialLayers[0].iSpatialBitrate) //RC enabled, considering bitrate constraint |
| 1923 | continue; |
| 1924 | |
| 1925 | break; |
| 1926 | } |
| 1927 | iLevel = kpLevelLimit->uiLevelIdc; |
| 1928 | |
| 1929 | return iLevel; |
| 1930 | } |
| 1931 | TEST_F (EncodeDecodeTestAPI, ProfileLevelSetting) { |
| 1932 | int iWidth = GetRandWidth(); |
| 1933 | int iHeight = GetRandHeight(); |