History

Decoder WP suppor

missed some part fix clip value update according to wayne's suggestion

zhuiling committed 11 years ago

Commit 9ef0c741 parent 2da0ce66 files · +235 −8Browse files

Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 6 files). Show all

Unified · Split

codec/decoder/core/src/decoder_core.cpp+94−3
@@ -179,6 +179,78 @@ inline int32_t WelsDecodeConstructSlice (PWelsDecoderContext pCtx, PNalUnit pCu · 178 unmodified lines
179 return iRet;179 return iRet;
180}180}
181 181
182int32_t ParsePredWeightedTable (PBitStringAux pBs, PSliceHeader pSh) {
183 uint32_t uiCode;
184 int32_t iList = 0;
185 int32_t iCode;
186
187 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
188 WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "luma_log2_weight_denom",
189 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM));
190 pSh->sPredWeightTable.uiLumaLog2WeightDenom = uiCode;
191 if (pSh->pSps->uiChromaArrayType != 0) {
192 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode));
193 WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "chroma_log2_weight_denom",
194 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM));
195 pSh->sPredWeightTable.uiChromaLog2WeightDenom = uiCode;
196 }
197
198
199 do {
200
201 for (int i = 0; i < pSh->uiRefCount[iList]; i++) {
202 //luma
203 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
204 if (!!uiCode) {
205
206 WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
207 WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_weight",
208 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_WEIGHT));
209 pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = iCode;
210
211 WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
212 WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_offset",
213 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_OFFSET));
214 pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = iCode;
215 } else {
216 pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = 1 << (pSh->sPredWeightTable.uiLumaLog2WeightDenom);
217 pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = 0;
218
219 }
220 //chroma
221 if (pSh->pSps->uiChromaArrayType == 0)
222 continue;
223
224 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
225 if (!!uiCode) {
226 for (int j = 0; j < 2; j++) {
227
228
229 WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
230 WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_weight",
231 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_WEIGHT));
232 pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = iCode;
233
234 WELS_READ_VERIFY (BsGetSe (pBs, &iCode));
235 WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_offset",
236 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_OFFSET));
237 pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = iCode;
238 }
239 } else {
240 for (int j = 0; j < 2; j++) {
241
242
243 pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = 1 << (pSh->sPredWeightTable.uiChromaLog2WeightDenom);
244 pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = 0;
245 }
246 }
247
248 }
249 ++iList;
250 } while (iList < LIST_1);//TODO: SUPPORT LIST_A
251 return ERR_NONE;
252}
253
182/*254/*
183 * Predeclared function routines ..255 * Predeclared function routines ..
184 */256 */
@@ -701,6 +773,14 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 516 unmodified lines
701 return iRet;773 return iRet;
702 }774 }
703 775
776 if (pPps->bWeightedPredFlag && (uiSliceType == P_SLICE)) {
777 iRet = ParsePredWeightedTable (pBs, pSliceHead);
778 if (iRet != ERR_NONE) {
779 WelsLog (pLogCtx, WELS_LOG_WARNING, "invalid weighted prediction syntaxs!");
780 return iRet;
781 }
782 }
783
704 if (kbExtensionFlag) {784 if (kbExtensionFlag) {
705 if (pNalHeaderExt->iNoInterLayerPredFlag || pNalHeaderExt->uiQualityId > 0)785 if (pNalHeaderExt->iNoInterLayerPredFlag || pNalHeaderExt->uiQualityId > 0)
706 pSliceHeadExt->bBasePredWeightTableFlag = false;786 pSliceHeadExt->bBasePredWeightTableFlag = false;
@@ -1042,7 +1122,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 335 unmodified lines
1042 "pCtx->sMb.pMbType[]");1122 "pCtx->sMb.pMbType[]");
1043 pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (1123 pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1044 int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]");1124 int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]");
1045 pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (1125 pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1126 sizeof (
1046 int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]");1127 int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]");
1047 pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),1128 pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1048 "pCtx->sMb.pLumaQp[]");1129 "pCtx->sMb.pLumaQp[]");
@@ -1058,7 +1139,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 9 unmodified lines
1058 "pCtx->sMb.pNzcRs[]");1139 "pCtx->sMb.pNzcRs[]");
1059 pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *1140 pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1060 sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]");1141 sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]");
1061 pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8,1142 pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1143 int8_t) * 8,
1062 "pCtx->sMb.pIntraPredMode[]");1144 "pCtx->sMb.pIntraPredMode[]");
1063 pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *1145 pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1064 sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]");1146 sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]");
@@ -1066,7 +1148,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 1 unmodified line
1066 "pCtx->sMb.pChromaPredMode[]");1148 "pCtx->sMb.pChromaPredMode[]");
1067 pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),1149 pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1068 "pCtx->sMb.pCbp[]");1150 "pCtx->sMb.pCbp[]");
1069 pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (1151 pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1152 sizeof (
1070 int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]");1153 int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]");
1071 pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),1154 pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),
1072 "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/20101155 "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010
@@ -1846,6 +1929,14 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN · 773 unmodified lines
1846 if (kuiQualityId == BASE_QUALITY_ID) {1929 if (kuiQualityId == BASE_QUALITY_ID) {
1847 pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering;1930 pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering;
1848 pDqLayer->pRefPicMarking = &pSh->sRefMarking;1931 pDqLayer->pRefPicMarking = &pSh->sRefMarking;
1932
1933 if (pSh->pPps->bWeightedPredFlag) {
1934 pDqLayer->bUseWeightPredictionFlag = true;
1935 pDqLayer->pPredWeightTable = &pSh->sPredWeightTable;
1936
1937 } else
1938 pDqLayer->bUseWeightPredictionFlag = false;
1939
1849 pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking;1940 pDqLayer->pRefPicBaseMarking = &pShExt->sRefBasePicMarking;
1850 }1941 }
1851 1942

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t