| 318 | } |
| 319 | |
| 320 | int32_t ParsePredWeightedTable (PBitStringAux pBs, PSliceHeader pSh) { |
| 321 | uint32_t uiCode; |
| 322 | int32_t iList = 0; |
| 323 | int32_t iCode; |
| 324 | |
| 325 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); |
| 326 | WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "luma_log2_weight_denom", |
| 327 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_LOG2_WEIGHT_DENOM)); |
| 328 | pSh->sPredWeightTable.uiLumaLog2WeightDenom = uiCode; |
| 329 | if (pSh->pSps->uiChromaArrayType != 0) { |
| 330 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); |
| 331 | WELS_CHECK_SE_BOTH_ERROR_NOLOG (uiCode, 0, 7, "chroma_log2_weight_denom", |
| 332 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_LOG2_WEIGHT_DENOM)); |
| 333 | pSh->sPredWeightTable.uiChromaLog2WeightDenom = uiCode; |
| 334 | } |
| 335 | |
| 336 | if ((pSh->sPredWeightTable.uiLumaLog2WeightDenom | pSh->sPredWeightTable.uiChromaLog2WeightDenom) > 7) |
| 337 | return ERR_NONE; |
| 338 | |
| 339 | do { |
| 340 | |
| 341 | for (int i = 0; i < pSh->uiRefCount[iList]; i++) { |
| 342 | //luma |
| 343 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); |
| 344 | if (!!uiCode) { |
| 345 | |
| 346 | WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); |
| 347 | WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_weight", |
| 348 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_WEIGHT)); |
| 349 | pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = iCode; |
| 350 | |
| 351 | WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); |
| 352 | WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "luma_offset", |
| 353 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_LUMA_OFFSET)); |
| 354 | pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = iCode; |
| 355 | } else { |
| 356 | pSh->sPredWeightTable.sPredList[iList].iLumaWeight[i] = 1 << (pSh->sPredWeightTable.uiLumaLog2WeightDenom); |
| 357 | pSh->sPredWeightTable.sPredList[iList].iLumaOffset[i] = 0; |
| 358 | |
| 359 | } |
| 360 | //chroma |
| 361 | if (pSh->pSps->uiChromaArrayType == 0) |
| 362 | continue; |
| 363 | |
| 364 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); |
| 365 | if (!!uiCode) { |
| 366 | for (int j = 0; j < 2; j++) { |
| 367 | |
| 368 | |
| 369 | WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); |
| 370 | WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_weight", |
| 371 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_WEIGHT)); |
| 372 | pSh->sPredWeightTable.sPredList[iList].iChromaWeight[i][j] = iCode; |
| 373 | |
| 374 | WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); |
| 375 | WELS_CHECK_SE_BOTH_ERROR_NOLOG (iCode, -128, 127, "chroma_offset", |
| 376 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_CHROMA_OFFSET)); |
| 377 | pSh->sPredWeightTable.sPredList[iList].iChromaOffset[i][j] = iCode; |
no test coverage detected