Showing the changes to codec/decoder/core/src/au_parser.cpp (1 of 2 files). Show all
Unified · Split
| @@ -306,25 +306,49 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 305 unmodified lines | |||
| 306 | 306 | ||
| 307 | if (pCtx->bParseOnly) { | 307 | if (pCtx->bParseOnly) { |
| 308 | pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; | 308 | pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; |
| 309 | pCurNal->sNalData.sVclNal.iNalLength = iSrcNalLen - NAL_UNIT_HEADER_EXT_SIZE; | 309 | int32_t iTrailingZeroByte = 0; |
| 310 | while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes | ||
| 311 | iTrailingZeroByte++; | ||
| 312 | int32_t iActualLen = iSrcNalLen - iTrailingZeroByte; | ||
| 313 | pCurNal->sNalData.sVclNal.iNalLength = iActualLen - NAL_UNIT_HEADER_EXT_SIZE; | ||
| 314 | //unify start code as 0x0001 | ||
| 315 | int32_t iCurrStartByte = 4; //4 for 0x0001, 3 for 0x001 | ||
| 316 | if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001 | ||
| 317 | iCurrStartByte = 3; | ||
| 318 | pCurNal->sNalData.sVclNal.iNalLength++; | ||
| 319 | } | ||
| 310 | if (pCurNal->sNalHeaderExt.bIdrFlag) { | 320 | if (pCurNal->sNalHeaderExt.bIdrFlag) { |
| 311 | * (pSrcNal + 3) &= 0xE0; | 321 | * (pSrcNal + iCurrStartByte) &= 0xE0; |
| 312 | * (pSrcNal + 3) |= 0x05; | 322 | * (pSrcNal + iCurrStartByte) |= 0x05; |
| 313 | } else { | 323 | } else { |
| 314 | * (pSrcNal + 3) &= 0xE0; | 324 | * (pSrcNal + iCurrStartByte) &= 0xE0; |
| 315 | * (pSrcNal + 3) |= 0x01; | 325 | * (pSrcNal + iCurrStartByte) |= 0x01; |
| 316 | } | 326 | } |
| 317 | memcpy (pSavedData->pCurPos, pSrcNal, 4); | 327 | pSavedData->pCurPos[0] = pSavedData->pCurPos[1] = pSavedData->pCurPos[2] = 0x0; |
| 318 | pSavedData->pCurPos += 4; | 328 | pSavedData->pCurPos[3] = 0x1; |
| 319 | memcpy (pSavedData->pCurPos, pSrcNal + 7, iSrcNalLen - 7); | 329 | pSavedData->pCurPos[4] = * (pSrcNal + iCurrStartByte); |
| 320 | pSavedData->pCurPos += iSrcNalLen - 7; | 330 | pSavedData->pCurPos += 5; |
| 331 | int32_t iOffset = iCurrStartByte + 1 + NAL_UNIT_HEADER_EXT_SIZE; | ||
| 332 | memcpy (pSavedData->pCurPos, pSrcNal + iOffset, iActualLen - iOffset); | ||
| 333 | pSavedData->pCurPos += iActualLen - iOffset; | ||
| 321 | } | 334 | } |
| 322 | } else { | 335 | } else { |
| 323 | if (pCtx->bParseOnly) { | 336 | if (pCtx->bParseOnly) { |
| 324 | pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; | 337 | pCurNal->sNalData.sVclNal.pNalPos = pSavedData->pCurPos; |
| 325 | pCurNal->sNalData.sVclNal.iNalLength = iSrcNalLen; | 338 | int32_t iTrailingZeroByte = 0; |
| 326 | memcpy (pSavedData->pCurPos, pSrcNal, iSrcNalLen); | 339 | while (pSrcNal[iSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes |
| 327 | pSavedData->pCurPos += iSrcNalLen; | 340 | iTrailingZeroByte++; |
| 341 | int32_t iActualLen = iSrcNalLen - iTrailingZeroByte; | ||
| 342 | pCurNal->sNalData.sVclNal.iNalLength = iActualLen; | ||
| 343 | //unify start code as 0x0001 | ||
| 344 | int32_t iStartDeltaByte = 0; //0 for 0x0001, 1 for 0x001 | ||
| 345 | if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001 | ||
| 346 | pSavedData->pCurPos[0] = 0x0; | ||
| 347 | iStartDeltaByte = 1; | ||
| 348 | pCurNal->sNalData.sVclNal.iNalLength++; | ||
| 349 | } | ||
| 350 | memcpy (pSavedData->pCurPos + iStartDeltaByte, pSrcNal, iActualLen); | ||
| 351 | pSavedData->pCurPos += iStartDeltaByte + iActualLen; | ||
| 328 | } | 352 | } |
| 329 | if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) { | 353 | if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) { |
| 330 | if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) { | 354 | if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) { |
| @@ -449,9 +473,9 @@ bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeade · 118 unmodified lines | |||
| 449 | if (pLastSliceHeader->iDeltaPicOrderCnt[1] != pCurSliceHeader->iDeltaPicOrderCnt[1]) | 473 | if (pLastSliceHeader->iDeltaPicOrderCnt[1] != pCurSliceHeader->iDeltaPicOrderCnt[1]) |
| 450 | return true; | 474 | return true; |
| 451 | } | 475 | } |
| 452 | if(memcmp(pLastSliceHeader->pPps, pCurSliceHeader->pPps, sizeof(SPps)) != 0 | 476 | if (memcmp (pLastSliceHeader->pPps, pCurSliceHeader->pPps, sizeof (SPps)) != 0 |
| 453 | || memcmp(pLastSliceHeader->pSps, pCurSliceHeader->pSps, sizeof(SSps)) != 0) { | 477 | || memcmp (pLastSliceHeader->pSps, pCurSliceHeader->pSps, sizeof (SSps)) != 0) { |
| 454 | return true; | 478 | return true; |
| 455 | } | 479 | } |
| 456 | return false; | 480 | return false; |
| 457 | } | 481 | } |
| @@ -1065,8 +1089,19 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 607 unmodified lines | |||
| 1065 | if (!kbUseSubsetFlag) { //SPS | 1089 | if (!kbUseSubsetFlag) { //SPS |
| 1066 | SSpsBsInfo* pSpsBs = &pCtx->sSpsBsInfo [iSpsId]; | 1090 | SSpsBsInfo* pSpsBs = &pCtx->sSpsBsInfo [iSpsId]; |
| 1067 | pSpsBs->iSpsId = iSpsId; | 1091 | pSpsBs->iSpsId = iSpsId; |
| 1068 | memcpy (pSpsBs->pSpsBsBuf, pSrcNal, kSrcNalLen); | 1092 | int32_t iTrailingZeroByte = 0; |
| 1069 | pSpsBs->uiSpsBsLen = (uint32_t) kSrcNalLen; | 1093 | while (pSrcNal[kSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes |
| 1094 | iTrailingZeroByte++; | ||
| 1095 | int32_t iActualLen = kSrcNalLen - iTrailingZeroByte; | ||
| 1096 | pSpsBs->uiSpsBsLen = (uint16_t) iActualLen; | ||
| 1097 | //unify start code as 0x0001 | ||
| 1098 | int32_t iStartDeltaByte = 0; //0 for 0x0001, 1 for 0x001 | ||
| 1099 | if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001 | ||
| 1100 | pSpsBs->pSpsBsBuf[0] = 0x0; //add 0 to form 0x0001 | ||
| 1101 | iStartDeltaByte++; | ||
| 1102 | pSpsBs->uiSpsBsLen++; | ||
| 1103 | } | ||
| 1104 | memcpy (pSpsBs->pSpsBsBuf + iStartDeltaByte, pSrcNal, iActualLen); | ||
| 1070 | } else { //subset SPS | 1105 | } else { //subset SPS |
| 1071 | SSpsBsInfo* pSpsBs = &pCtx->sSubsetSpsBsInfo [iSpsId]; | 1106 | SSpsBsInfo* pSpsBs = &pCtx->sSubsetSpsBsInfo [iSpsId]; |
| 1072 | pSpsBs->iSpsId = iSpsId; | 1107 | pSpsBs->iSpsId = iSpsId; |
| @@ -1353,8 +1388,19 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 280 unmodified lines | |||
| 1353 | } | 1388 | } |
| 1354 | SPpsBsInfo* pPpsBs = &pCtx->sPpsBsInfo [uiPpsId]; | 1389 | SPpsBsInfo* pPpsBs = &pCtx->sPpsBsInfo [uiPpsId]; |
| 1355 | pPpsBs->iPpsId = (int32_t) uiPpsId; | 1390 | pPpsBs->iPpsId = (int32_t) uiPpsId; |
| 1356 | memcpy (pPpsBs->pPpsBsBuf, pSrcNal, kSrcNalLen); | 1391 | int32_t iTrailingZeroByte = 0; |
| 1357 | pPpsBs->uiPpsBsLen = kSrcNalLen; | 1392 | while (pSrcNal[kSrcNalLen - iTrailingZeroByte - 1] == 0x0) //remove final trailing 0 bytes |
| 1393 | iTrailingZeroByte++; | ||
| 1394 | int32_t iActualLen = kSrcNalLen - iTrailingZeroByte; | ||
| 1395 | pPpsBs->uiPpsBsLen = (uint16_t) iActualLen; | ||
| 1396 | //unify start code as 0x0001 | ||
| 1397 | int32_t iStartDeltaByte = 0; //0 for 0x0001, 1 for 0x001 | ||
| 1398 | if (pSrcNal[0] == 0x0 && pSrcNal[1] == 0x0 && pSrcNal[2] == 0x1) { //if 0x001 | ||
| 1399 | pPpsBs->pPpsBsBuf[0] = 0x0; //add 0 to form 0x0001 | ||
| 1400 | iStartDeltaByte++; | ||
| 1401 | pPpsBs->uiPpsBsLen++; | ||
| 1402 | } | ||
| 1403 | memcpy (pPpsBs->pPpsBsBuf + iStartDeltaByte, pSrcNal, iActualLen); | ||
| 1358 | } | 1404 | } |
| 1359 | return ERR_NONE; | 1405 | return ERR_NONE; |
| 1360 | } | 1406 | } |