Merge pull request #2351 from huili2/fix_width_height_enc_constraint
fix frame size constraints for width and height
This commit is contained in:
commit
f5fd7420a9
@ -43,8 +43,7 @@
|
||||
#include "typedefs.h"
|
||||
|
||||
#define MAX_LOG_SIZE 1024
|
||||
#define MAX_WIDTH (4096)
|
||||
#define MAX_HEIGHT (2304)//MAX_FS_LEVEL51 (36864); MAX_FS_LEVEL51*256/4096 = 2304
|
||||
#define MAX_MBS_PER_FRAME 36864 //in accordance with max level support in Rec
|
||||
/*
|
||||
* Function pointer declaration for various tool sets
|
||||
*/
|
||||
|
@ -485,10 +485,10 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa
|
||||
int32_t iMbNumInFrame = 0;
|
||||
uint32_t iMaxSliceNum = MAX_SLICES_NUM;
|
||||
int32_t iReturn = 0;
|
||||
if ((kiPicWidth <= 0) || (kiPicHeight <= 0) || (kiPicWidth > MAX_WIDTH) || (kiPicHeight > MAX_HEIGHT)) {
|
||||
if ((kiPicWidth <= 0) || (kiPicHeight <= 0) || (kiPicWidth * kiPicHeight > (MAX_MBS_PER_FRAME << 8))) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR,
|
||||
"ParamValidationExt(),width(1-%d),height(1-%d)invalid %d x %d in dependency layer settings!", MAX_WIDTH, MAX_HEIGHT,
|
||||
kiPicWidth, kiPicHeight);
|
||||
"ParamValidationExt(), width > 0, height > 0, width * height <= %d, invalid %d x %d in dependency layer settings!",
|
||||
(MAX_MBS_PER_FRAME << 8), kiPicWidth, kiPicHeight);
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
}
|
||||
if ((kiPicWidth & 0x0F) != 0 || (kiPicHeight & 0x0F) != 0) {
|
||||
|
@ -1346,13 +1346,13 @@ void CWelsPreProcess::WelsMoveMemoryWrapper (SWelsSvcCodingParam* pSvcParam, SP
|
||||
const int32_t kiDstStrideUV = pDstPic->iLineSize[1];
|
||||
|
||||
if (pSrcY) {
|
||||
if (iSrcWidth <= 0 || iSrcWidth > MAX_WIDTH || iSrcHeight <= 0 || iSrcHeight > MAX_HEIGHT)
|
||||
if (iSrcWidth <= 0 || iSrcHeight <= 0 || (iSrcWidth * iSrcHeight > (MAX_MBS_PER_FRAME << 8)))
|
||||
return;
|
||||
if (kiSrcTopOffsetY >= iSrcHeight || kiSrcLeftOffsetY >= iSrcWidth || iSrcWidth > kiSrcStrideY)
|
||||
return;
|
||||
}
|
||||
if (pDstY) {
|
||||
if (kiTargetWidth <= 0 || kiTargetWidth > MAX_WIDTH || kiTargetHeight <= 0 || kiTargetHeight > MAX_HEIGHT)
|
||||
if (kiTargetWidth <= 0 || kiTargetHeight <= 0 || (kiTargetWidth * kiTargetHeight > (MAX_MBS_PER_FRAME << 8)))
|
||||
return;
|
||||
if (kiTargetWidth > kiDstStrideY)
|
||||
return;
|
||||
|
@ -233,16 +233,16 @@ bool CVpFrameWork::CheckValid (EMethods eMethod, SPixMap& pSrcPixMap, SPixMap&
|
||||
}
|
||||
|
||||
if (pSrcPixMap.pPixel[0]) {
|
||||
if (pSrcPixMap.sRect.iRectWidth <= 0 || pSrcPixMap.sRect.iRectWidth > MAX_WIDTH || pSrcPixMap.sRect.iRectHeight <= 0
|
||||
|| pSrcPixMap.sRect.iRectHeight > MAX_HEIGHT)
|
||||
if (pSrcPixMap.sRect.iRectWidth <= 0 || pSrcPixMap.sRect.iRectHeight <= 0
|
||||
|| pSrcPixMap.sRect.iRectWidth * pSrcPixMap.sRect.iRectHeight > (MAX_MBS_PER_FRAME << 8))
|
||||
goto exit;
|
||||
if (pSrcPixMap.sRect.iRectTop >= pSrcPixMap.sRect.iRectHeight
|
||||
|| pSrcPixMap.sRect.iRectLeft >= pSrcPixMap.sRect.iRectWidth || pSrcPixMap.sRect.iRectWidth > pSrcPixMap.iStride[0])
|
||||
goto exit;
|
||||
}
|
||||
if (pDstPixMap.pPixel[0]) {
|
||||
if (pDstPixMap.sRect.iRectWidth <= 0 || pDstPixMap.sRect.iRectWidth > MAX_WIDTH || pDstPixMap.sRect.iRectHeight <= 0
|
||||
|| pDstPixMap.sRect.iRectHeight > MAX_HEIGHT)
|
||||
if (pDstPixMap.sRect.iRectWidth <= 0 || pDstPixMap.sRect.iRectHeight <= 0
|
||||
|| pDstPixMap.sRect.iRectWidth * pDstPixMap.sRect.iRectHeight > (MAX_MBS_PER_FRAME << 8))
|
||||
goto exit;
|
||||
if (pDstPixMap.sRect.iRectTop >= pDstPixMap.sRect.iRectHeight
|
||||
|| pDstPixMap.sRect.iRectLeft >= pDstPixMap.sRect.iRectWidth || pDstPixMap.sRect.iRectWidth > pDstPixMap.iStride[0])
|
||||
|
@ -54,8 +54,7 @@
|
||||
|
||||
WELSVP_NAMESPACE_BEGIN
|
||||
|
||||
#define MAX_WIDTH (4096)
|
||||
#define MAX_HEIGHT (2304)//MAX_FS_LEVEL51 (36864); MAX_FS_LEVEL51*256/4096 = 2304
|
||||
#define MAX_MBS_PER_FRAME 36864 //in accordance with max level support in Rec
|
||||
|
||||
#define MB_WIDTH_LUMA (16)
|
||||
#define PESN (1e-6) // desired float precision
|
||||
|
@ -573,11 +573,28 @@ TEST_F (EncoderInterfaceTest, BasicInitializeTestFalse) {
|
||||
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
||||
|
||||
//TODO: add checking max in interface and then enable this checking
|
||||
//GetValidEncParamBase(&sEncParamBase);
|
||||
//sEncParamBase.iPicWidth = rand()+(MAX_HEIGHT+1);
|
||||
//iResult = pPtrEnc->Initialize (&sEncParamBase);
|
||||
//EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
||||
//iPicWidth * iPicHeight <= 36864 * 16 * 16, from Level 5.2 constraint
|
||||
//Initialize test: FALSE
|
||||
GetValidEncParamBase (&sEncParamBase);
|
||||
sEncParamBase.iPicWidth = 5000;
|
||||
sEncParamBase.iPicHeight = 5000;
|
||||
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
||||
//Initialize test: TRUE, with SetOption test following
|
||||
GetValidEncParamBase (&sEncParamBase);
|
||||
sEncParamBase.iPicWidth = 36864;
|
||||
sEncParamBase.iPicHeight = 256;
|
||||
iResult = pPtrEnc->Initialize (&sEncParamBase);
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
sEncParamBase.iPicWidth = 256;
|
||||
sEncParamBase.iPicHeight = 36864;
|
||||
iResult = pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, &sEncParamBase);
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
|
||||
sEncParamBase.iPicWidth = 5000;
|
||||
sEncParamBase.iPicHeight = 5000;
|
||||
iResult = pPtrEnc->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_BASE, &sEncParamBase);
|
||||
EXPECT_EQ (iResult, static_cast<int> (cmInitParaError));
|
||||
pPtrEnc->Uninitialize();
|
||||
|
||||
//iTargetBitrate
|
||||
GetValidEncParamBase (&sEncParamBase);
|
||||
|
Loading…
x
Reference in New Issue
Block a user