| @@ -363,10 +363,13 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum · 362 unmodified lines |
| 363 | * \brief Dump reconstruction for dependency layer | 363 | * \brief Dump reconstruction for dependency layer |
| 364 | */ | 364 | */ |
| 365 | | 365 | |
| 366 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) { | 366 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) { |
| 367 | WelsFileHandle* pDumpRecFile = NULL; | 367 | WelsFileHandle* pDumpRecFile = NULL; |
| 368 | int32_t iWrittenSize = 0; | 368 | int32_t iWrittenSize = 0; |
| 369 | const char* openMode = bAppend ? "ab" : "wb"; | 369 | const char* openMode = bAppend ? "ab" : "wb"; |
| | 370 | SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP; |
| | 371 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; |
| | 372 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; |
| 370 | | 373 | |
| 371 | if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER) | 374 | if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER) |
| 372 | return; | 375 | return; |
| @@ -385,13 +388,14 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 12 unmodified lines |
| 385 | int32_t i = 0; | 388 | int32_t i = 0; |
| 386 | int32_t j = 0; | 389 | int32_t j = 0; |
| 387 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; | 390 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; |
| 388 | const int32_t kiLumaWidth = pCurPicture->iWidthInPixel; | 391 | const int32_t kiLumaWidth = bFrameCroppingFlag?(pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel; |
| 389 | const int32_t kiLumaHeight = pCurPicture->iHeightInPixel; | 392 | const int32_t kiLumaHeight = bFrameCroppingFlag?(pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel; |
| 390 | const int32_t kiChromaWidth = kiLumaWidth >> 1; | 393 | const int32_t kiChromaWidth = kiLumaWidth >> 1; |
| 391 | const int32_t kiChromaHeight = kiLumaHeight >> 1; | 394 | const int32_t kiChromaHeight = kiLumaHeight >> 1; |
| 392 | | 395 | uint8_t* pSrc = NULL; |
| | 396 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0]; |
| 393 | for (j = 0; j < kiLumaHeight; ++ j) { | 397 | for (j = 0; j < kiLumaHeight; ++ j) { |
| 394 | iWrittenSize = WelsFwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile); | 398 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); |
| 395 | assert (iWrittenSize == kiLumaWidth); | 399 | assert (iWrittenSize == kiLumaWidth); |
| 396 | if (iWrittenSize < kiLumaWidth) { | 400 | if (iWrittenSize < kiLumaWidth) { |
| 397 | assert (0); // make no sense for us if writing failed | 401 | assert (0); // make no sense for us if writing failed |
| @@ -401,8 +405,9 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 3 unmodified lines |
| 401 | } | 405 | } |
| 402 | for (i = 1; i < I420_PLANES; ++ i) { | 406 | for (i = 1; i < I420_PLANES; ++ i) { |
| 403 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; | 407 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; |
| | 408 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i]; |
| 404 | for (j = 0; j < kiChromaHeight; ++ j) { | 409 | for (j = 0; j < kiChromaHeight; ++ j) { |
| 405 | iWrittenSize = WelsFwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile); | 410 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); |
| 406 | assert (iWrittenSize == kiChromaWidth); | 411 | assert (iWrittenSize == kiChromaWidth); |
| 407 | if (iWrittenSize < kiChromaWidth) { | 412 | if (iWrittenSize < kiChromaWidth) { |
| 408 | assert (0); // make no sense for us if writing failed | 413 | assert (0); // make no sense for us if writing failed |
| @@ -420,8 +425,12 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 11 unmodified lines |
| 420 | * \brief Dump the reconstruction pictures | 425 | * \brief Dump the reconstruction pictures |
| 421 | */ | 426 | */ |
| 422 | | 427 | |
| 423 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) { | 428 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend, SDqLayer* pDqLayer) { |
| 424 | WelsFileHandle* pDumpRecFile = NULL; | 429 | WelsFileHandle* pDumpRecFile = NULL; |
| | 430 | SWelsSPS* pSpsTmp = (kiDid> BASE_DEPENDENCY_ID)? &(pDqLayer->sLayerInfo.pSubsetSpsP->pSps) : pDqLayer->sLayerInfo.pSpsP; |
| | 431 | bool bFrameCroppingFlag = pSpsTmp->bFrameCroppingFlag; |
| | 432 | SCropOffset* pFrameCrop = &pSpsTmp->sFrameCrop; |
| | 433 | |
| 425 | int32_t iWrittenSize = 0; | 434 | int32_t iWrittenSize = 0; |
| 426 | const char* openMode = bAppend ? "ab" : "wb"; | 435 | const char* openMode = bAppend ? "ab" : "wb"; |
| 427 | | 436 | |
| @@ -440,13 +449,14 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) · 12 unmodified lines |
| 440 | int32_t i = 0; | 449 | int32_t i = 0; |
| 441 | int32_t j = 0; | 450 | int32_t j = 0; |
| 442 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; | 451 | const int32_t kiStrideY = pCurPicture->iLineSize[0]; |
| 443 | const int32_t kiLumaWidth = pCurPicture->iWidthInPixel; | 452 | const int32_t kiLumaWidth = bFrameCroppingFlag ? (pCurPicture->iWidthInPixel-(( pFrameCrop->iCropLeft + pFrameCrop->iCropRight ) << 1 )) : pCurPicture->iWidthInPixel; |
| 444 | const int32_t kiLumaHeight = pCurPicture->iHeightInPixel; | 453 | const int32_t kiLumaHeight = bFrameCroppingFlag ? (pCurPicture->iHeightInPixel-(( pFrameCrop->iCropTop + pFrameCrop->iCropBottom ) << 1 )) : pCurPicture->iHeightInPixel; |
| 445 | const int32_t kiChromaWidth = kiLumaWidth >> 1; | 454 | const int32_t kiChromaWidth = kiLumaWidth >> 1; |
| 446 | const int32_t kiChromaHeight = kiLumaHeight >> 1; | 455 | const int32_t kiChromaHeight = kiLumaHeight >> 1; |
| 447 | | 456 | uint8_t* pSrc = NULL; |
| | 457 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[0] + kiStrideY * ( pFrameCrop->iCropTop << 1 ) + ( pFrameCrop->iCropLeft << 1 )) : pCurPicture->pData[0]; |
| 448 | for (j = 0; j < kiLumaHeight; ++ j) { | 458 | for (j = 0; j < kiLumaHeight; ++ j) { |
| 449 | iWrittenSize = WelsFwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile); | 459 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideY, 1, kiLumaWidth, pDumpRecFile); |
| 450 | assert (iWrittenSize == kiLumaWidth); | 460 | assert (iWrittenSize == kiLumaWidth); |
| 451 | if (iWrittenSize < kiLumaWidth) { | 461 | if (iWrittenSize < kiLumaWidth) { |
| 452 | assert (0); // make no sense for us if writing failed | 462 | assert (0); // make no sense for us if writing failed |
| @@ -456,8 +466,9 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) · 3 unmodified lines |
| 456 | } | 466 | } |
| 457 | for (i = 1; i < I420_PLANES; ++ i) { | 467 | for (i = 1; i < I420_PLANES; ++ i) { |
| 458 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; | 468 | const int32_t kiStrideUV = pCurPicture->iLineSize[i]; |
| | 469 | pSrc = bFrameCroppingFlag ? (pCurPicture->pData[i] + kiStrideUV * pFrameCrop->iCropTop + pFrameCrop->iCropLeft) : pCurPicture->pData[i]; |
| 459 | for (j = 0; j < kiChromaHeight; ++ j) { | 470 | for (j = 0; j < kiChromaHeight; ++ j) { |
| 460 | iWrittenSize = WelsFwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile); | 471 | iWrittenSize = WelsFwrite (pSrc + j * kiStrideUV, 1, kiChromaWidth, pDumpRecFile); |
| 461 | assert (iWrittenSize == kiChromaWidth); | 472 | assert (iWrittenSize == kiChromaWidth); |
| 462 | if (iWrittenSize < kiChromaWidth) { | 473 | if (iWrittenSize < kiChromaWidth) { |
| 463 | assert (0); // make no sense for us if writing failed | 474 | assert (0); // make no sense for us if writing failed |