ref: 8246225eed279035fa79027c6cebb9e97d60fd14
parent: 3f19534dd6118b96ce73073ae1e047490c71b6e6
parent: 2211324e2b3aefbfbd9f27afb5017de6e11f6fe5
author: ruil2 <ruil2@cisco.com>
date: Fri Feb 6 07:17:40 EST 2015
Merge pull request #1791 from sijchen/fix_nal1 [Encoder] add a para check for max_nal_size
--- a/codec/encoder/core/inc/wels_const.h
+++ b/codec/encoder/core/inc/wels_const.h
@@ -106,8 +106,10 @@
#endif//PPS_BUFFER_SIZE
#if !defined(MAX_MACROBLOCK_SIZE_IN_BYTE)
-#define MAX_MACROBLOCK_SIZE_IN_BYTE 800 //3200*2/8
+#define MAX_MACROBLOCK_SIZE_IN_BYTE 400 //3200/8, 3200 is from Annex A.3.1.(n)
#endif
+
+#define MAX_MACROBLOCK_SIZE_IN_BYTE_x2 (MAX_MACROBLOCK_SIZE_IN_BYTE<<1)
#if defined(NUM_SPATIAL_LAYERS_CONSTRAINT)
#define MAX_DEPENDENCY_LAYER MAX_SPATIAL_LAYER_NUM // Maximal dependency layer
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -529,9 +529,9 @@
return ENC_RETURN_UNSUPPORTED_PARA;
}
- if (pCodingParam->uiMaxNalSize <= NAL_HEADER_ADD_0X30BYTES) {
- WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiMaxNalSize (%d) settings!",
- pCodingParam->uiMaxNalSize);
+ if (pCodingParam->uiMaxNalSize <= (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE)) {
+ WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiMaxNalSize (%d) settings! should be larger than (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE)(%d)",
+ pCodingParam->uiMaxNalSize, (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE));
return ENC_RETURN_UNSUPPORTED_PARA;
}
@@ -1740,7 +1740,7 @@
fCompressRatioThr = COMPRESS_RATIO_THR;
iLayerBsSize = WELS_ROUND (((3 * fDlp->iVideoWidth * fDlp->iVideoHeight) >> 1) * fCompressRatioThr) +
- MAX_MACROBLOCK_SIZE_IN_BYTE;
+ MAX_MACROBLOCK_SIZE_IN_BYTE_x2;
iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged
iVclLayersBsSizeCount += iLayerBsSize;
++ iIndex;
--- a/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp
+++ b/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp
@@ -212,7 +212,7 @@
const intX_t iLeftLength = pBs->pBufEnd - pBs->pBufPtr - 1;
assert (iLeftLength > 0);
- if (iLeftLength < MAX_MACROBLOCK_SIZE_IN_BYTE) {
+ if (iLeftLength < MAX_MACROBLOCK_SIZE_IN_BYTE_x2) {
return ENC_RETURN_MEMALLOCERR;
//TODO: call the realloc© instead
}