| 482 | */ |
| 483 | |
| 484 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, |
| 485 | SDqLayer* pDqLayer) { |
| 486 | WelsFileHandle* pDumpRecFile = NULL; |
| 487 | SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : |
| 488 | pDqLayer->sLayerInfo.pSpsP; |
| 489 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; |
| 490 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; |
| 491 | |
| 492 | int32_t iWrittenSize = 0; |
| 493 | const char* openMode = bAppend ? "ab" : "wb"; |
| 494 | |
| 495 | if (NULL == pCurPicture || NULL == kpFileName) |
| 496 | return; |
| 497 | |
| 498 | if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage |
| 499 | pDumpRecFile = WelsFopen (kpFileName, openMode); |
| 500 | } else { |
| 501 | pDumpRecFile = WelsFopen ("rec.yuv", openMode); |
| 502 | } |
| 503 | if (NULL != pDumpRecFile && bAppend) |
| 504 | WelsFseek (pDumpRecFile, 0, SEEK_END); |
| 505 | |
| 506 | if (NULL != pDumpRecFile) { |
| 507 | int32_t i = 0; |
| 508 | int32_t j = 0; |
| 509 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; |
| 510 | const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + |
| 511 | pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; |
| 512 | const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + |
| 513 | pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; |
| 514 | const int32_t kiChromaWidth = kiLumaWidth >> 1; |
| 515 | const int32_t kiChromaHeight = kiLumaHeight >> 1; |
| 516 | uint8_t* pSrc = NULL; |
| 517 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + |
| 518 | (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; |
| 519 | for (j = 0; j < kiLumaHeight; ++ j) { |
| 520 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); |
| 521 | assert (iWrittenSize == kiLumaWidth); |
| 522 | if (iWrittenSize < kiLumaWidth) { |
| 523 | assert (0); // make no sense for us if writing failed |
| 524 | WelsFclose (pDumpRecFile); |
| 525 | return; |
| 526 | } |
| 527 | } |
| 528 | for (i = 1; i < I420_PLANES; ++ i) { |
| 529 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; |
| 530 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : |
| 531 | pCurPicture->pData[i]; |
| 532 | for (j = 0; j < kiChromaHeight; ++ j) { |
| 533 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); |
| 534 | assert (iWrittenSize == kiChromaWidth); |
| 535 | if (iWrittenSize < kiChromaWidth) { |
| 536 | assert (0); // make no sense for us if writing failed |
| 537 | WelsFclose (pDumpRecFile); |
| 538 | return; |
| 539 | } |
| 540 | } |
| 541 | } |
nothing calls this directly
no test coverage detected