Showing the changes to codec/encoder/core/src/encoder.cpp (1 of 7 files). Show all
Unified · Split
| @@ -365,11 +365,13 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum · 364 unmodified lines | |||
| 365 | * \brief Dump reconstruction for dependency layer | 365 | * \brief Dump reconstruction for dependency layer |
| 366 | */ | 366 | */ |
| 367 | 367 | ||
| 368 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) { | 368 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, |
| 369 | SDqLayer* pDqLayer) { | ||
| 369 | WelsFileHandle* pDumpRecFile = NULL; | 370 | WelsFileHandle* pDumpRecFile = NULL; |
| 370 | int32_t iWrittenSize = 0; | 371 | int32_t iWrittenSize = 0; |
| 371 | const char* openMode = bAppend ? "ab" : "wb"; | 372 | const char* openMode = bAppend ? "ab" : "wb"; |
| 372 | SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP; | 373 | SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : |
| 374 | pDqLayer->sLayerInfo.pSpsP; | ||
| 373 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; | 375 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; |
| 374 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; | 376 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; |
| 375 | 377 | ||
| @@ -390,12 +392,15 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 14 unmodified lines | |||
| 390 | int32_t i = 0; | 392 | int32_t i = 0; |
| 391 | int32_t j = 0; | 393 | int32_t j = 0; |
| 392 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; | 394 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; |
| 393 | const int32_t kiLumaWidth = bFrameCroppingFlag?(pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel; | 395 | const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + |
| 394 | const int32_t kiLumaHeight = bFrameCroppingFlag?(pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel; | 396 | pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; |
| 397 | const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + | ||
| 398 | pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; | ||
| 395 | const int32_t kiChromaWidth = kiLumaWidth >> 1; | 399 | const int32_t kiChromaWidth = kiLumaWidth >> 1; |
| 396 | const int32_t kiChromaHeight = kiLumaHeight >> 1; | 400 | const int32_t kiChromaHeight = kiLumaHeight >> 1; |
| 397 | uint8_t* pSrc = NULL; | 401 | uint8_t* pSrc = NULL; |
| 398 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0]; | 402 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + |
| 403 | (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; | ||
| 399 | for (j = 0; j < kiLumaHeight; ++ j) { | 404 | for (j = 0; j < kiLumaHeight; ++ j) { |
| 400 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); | 405 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); |
| 401 | assert (iWrittenSize == kiLumaWidth); | 406 | assert (iWrittenSize == kiLumaWidth); |
| @@ -407,7 +412,8 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 5 unmodified lines | |||
| 407 | } | 412 | } |
| 408 | for (i = 1; i < I420_PLANES; ++ i) { | 413 | for (i = 1; i < I420_PLANES; ++ i) { |
| 409 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; | 414 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; |
| 410 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i]; | 415 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : |
| 416 | pCurPicture->pData[i]; | ||
| 411 | for (j = 0; j < kiChromaHeight; ++ j) { | 417 | for (j = 0; j < kiChromaHeight; ++ j) { |
| 412 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); | 418 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); |
| 413 | assert (iWrittenSize == kiChromaWidth); | 419 | assert (iWrittenSize == kiChromaWidth); |
| @@ -427,9 +433,11 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 13 unmodified lines | |||
| 427 | * \brief Dump the reconstruction pictures | 433 | * \brief Dump the reconstruction pictures |
| 428 | */ | 434 | */ |
| 429 | 435 | ||
| 430 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) { | 436 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, |
| 437 | SDqLayer* pDqLayer) { | ||
| 431 | WelsFileHandle* pDumpRecFile = NULL; | 438 | WelsFileHandle* pDumpRecFile = NULL; |
| 432 | SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP; | 439 | SWelsSPS* pSpsTmp = (kiDid > BASE_DEPENDENCY_ID) ? & (pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : |
| 440 | pDqLayer->sLayerInfo.pSpsP; | ||
| 433 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; | 441 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; |
| 434 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; | 442 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; |
| 435 | 443 | ||
| @@ -451,12 +459,15 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k · 15 unmodified lines | |||
| 451 | int32_t i = 0; | 459 | int32_t i = 0; |
| 452 | int32_t j = 0; | 460 | int32_t j = 0; |
| 453 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; | 461 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; |
| 454 | const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel; | 462 | const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel - ((pFrameCrop->iCropLeft + |
| 455 | const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel; | 463 | pFrameCrop->iCropRight) << 1)) : pCurPicture->iWidthInPixel; |
| 464 | const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel - ((pFrameCrop->iCropTop + | ||
| 465 | pFrameCrop->iCropBottom) << 1)) : pCurPicture->iHeightInPixel; | ||
| 456 | const int32_t kiChromaWidth = kiLumaWidth >> 1; | 466 | const int32_t kiChromaWidth = kiLumaWidth >> 1; |
| 457 | const int32_t kiChromaHeight = kiLumaHeight >> 1; | 467 | const int32_t kiChromaHeight = kiLumaHeight >> 1; |
| 458 | uint8_t* pSrc = NULL; | 468 | uint8_t* pSrc = NULL; |
| 459 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0]; | 469 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * (pFrameCrop->iCropTop << 1) + |
| 470 | (pFrameCrop->iCropLeft << 1)) : pCurPicture->pData[0]; | ||
| 460 | for (j = 0; j < kiLumaHeight; ++ j) { | 471 | for (j = 0; j < kiLumaHeight; ++ j) { |
| 461 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); | 472 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); |
| 462 | assert (iWrittenSize == kiLumaWidth); | 473 | assert (iWrittenSize == kiLumaWidth); |
| @@ -468,7 +479,8 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t k · 5 unmodified lines | |||
| 468 | } | 479 | } |
| 469 | for (i = 1; i < I420_PLANES; ++ i) { | 480 | for (i = 1; i < I420_PLANES; ++ i) { |
| 470 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; | 481 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; |
| 471 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i]; | 482 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : |
| 483 | pCurPicture->pData[i]; | ||
| 472 | for (j = 0; j < kiChromaHeight; ++ j) { | 484 | for (j = 0; j < kiChromaHeight; ++ j) { |
| 473 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); | 485 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); |
| 474 | assert (iWrittenSize == kiChromaWidth); | 486 | assert (iWrittenSize == kiChromaWidth); |